36#define NSV_MAX_RESYNC (500*1024)
37#define NSV_MAX_RESYNC_TRIES 300
92 uint32_t info_strings_size;
93 uint32_t table_entries;
94 uint32_t table_entries_used;
107struct nsv_avchunk_header {
108 uint8_t vchunk_size_lsb;
109 uint16_t vchunk_size_msb;
110 uint16_t achunk_size;
113struct nsv_pcm_header {
114 uint8_t bits_per_sample;
115 uint8_t channel_count;
116 uint16_t sample_rate;
128#define T_NSVF MKTAG('N', 'S', 'V', 'f')
129#define T_NSVS MKTAG('N', 'S', 'V', 's')
130#define T_TOC2 MKTAG('T', 'O', 'C', '2')
131#define T_NONE MKTAG('N', 'O', 'N', 'E')
132#define T_SUBT MKTAG('S', 'U', 'B', 'T')
133#define T_ASYN MKTAG('A', 'S', 'Y', 'N')
134#define T_KEYF MKTAG('K', 'E', 'Y', 'F')
136#define TB_NSVF MKBETAG('N', 'S', 'V', 'f')
137#define TB_NSVS MKBETAG('N', 'S', 'V', 's')
140#define NSV_ST_VIDEO 0
141#define NSV_ST_AUDIO 1
239 if ((v & 0x0000ffff) == 0xefbe) {
250 if (v ==
MKBETAG(
'N',
'S',
'V',
's')) {
270 int table_entries_used;
297 strings_size, table_entries, table_entries_used);
303 if (strings_size > 0) {
309 p = strings =
av_mallocz((
size_t)strings_size + 1);
312 endp = strings + strings_size;
321 if (!p || p >= endp-2)
326 p = strchr(p, quote);
340 if (table_entries_used > 0) {
343 if((
unsigned)table_entries_used >= UINT_MAX /
sizeof(uint32_t))
349 for(
i=0;
i<table_entries_used;
i++) {
355 if(table_entries > table_entries_used &&
360 for(
i=0;
i<table_entries_used;
i++) {
381 uint16_t vwidth, vheight;
417 if (
s->nb_streams == 0) {
468 if (atag ==
MKTAG(
'A',
'A',
'V',
' ')) {
469 static const uint8_t aav_pce[] = {
470 0x12, 0x00, 0x05, 0x08, 0x48, 0x00,
471 0x20, 0x00, 0xC6, 0x40, 0x04, 0x4C,
472 0x61, 0x76, 0x63, 0x56, 0xE5, 0x00,
531 if (
s->nb_streams < 1)
576 vsize = (vsize << 4) | (auxcount >> 4);
578 av_log(
s,
AV_LOG_TRACE,
"NSV CHUNK %d aux, %"PRIu32
" bytes video, %d bytes audio\n", auxcount, vsize, asize);
580 for (
i = 0;
i < auxcount;
i++) {
585 vsize -= auxsize +
sizeof(uint16_t) +
sizeof(uint32_t);
590 if (!vsize && !asize) {
592 goto null_chunk_retry;
596 if (
s->nb_streams > 0)
597 st[
s->streams[0]->id] =
s->streams[0];
598 if (
s->nb_streams > 1)
599 st[
s->streams[1]->id] =
s->streams[1];
609 for (
i = 0;
i <
FFMIN(8, vsize);
i++)
620 if (asize >= 4 && st[
NSV_ST_AUDIO]->codecpar->codec_tag ==
MKTAG(
'P',
'C',
'M',
' ')) {
677 for (
i = 0;
i < 2;
i++) {
727 if (p->buf[0] ==
'N' && p->buf[1] ==
'S' &&
728 p->buf[2] ==
'V' && (p->buf[3] ==
'f' || p->buf[3] ==
's'))
734 for (
i = 1;
i < p->buf_size - 3;
i++) {
737 int vsize =
AV_RL24(p->buf+
i+19) >> 4;
739 int offset =
i + 23 + asize + vsize + 1;
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
unsigned int avio_rl16(AVIOContext *s)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
unsigned int avio_rl32(AVIOContext *s)
int avio_r8(AVIOContext *s)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
#define FF_INFMT_FLAG_INIT_CLEANUP
For an FFInputFormat with this flag set read_close() needs to be called by the caller upon read_heade...
static int read_header(FFV1Context *f, RangeCoder *c)
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
#define AV_CHANNEL_LAYOUT_MONO
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
Macro definitions for various function/variable attributes.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
#define MKTAG(a, b, c, d)
#define MKBETAG(a, b, c, d)
Memory handling functions.
static int nsv_read_close(AVFormatContext *s)
static int nsv_read_packet(AVFormatContext *s, AVPacket *pkt)
#define NSV_MAX_RESYNC_TRIES
static const AVCodecTag nsv_codec_video_tags[]
static int nsv_resync(AVFormatContext *s)
static int nsv_read_header(AVFormatContext *s)
static int nsv_parse_NSVs_header(AVFormatContext *s)
static int nsv_probe(const AVProbeData *p)
static int nsv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
static int nsv_read_chunk(AVFormatContext *s, int fill_header)
static const AVCodecTag nsv_codec_audio_tags[]
static int nsv_parse_NSVf_header(AVFormatContext *s)
An AVChannelLayout holds information about the channel layout of audio data.
int height
The height of the video frame in pixels.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
AVChannelLayout ch_layout
The channel layout and number of channels.
int width
The width of the video frame in pixels.
enum AVMediaType codec_type
General type of the encoded data.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int sample_rate
The number of audio samples per second.
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
This structure stores compressed data.
This structure contains the data a format has to probe a file.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int64_t duration
Decoding: duration of the stream, in stream time base.
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
enum AVStreamParseType need_parsing
uint32_t * nsvs_timestamps
uint32_t * nsvs_file_offset
#define av_malloc_array(a, b)