34 #define NSV_MAX_RESYNC (500*1024)
35 #define NSV_MAX_RESYNC_TRIES 300
90 uint32_t info_strings_size;
91 uint32_t table_entries;
92 uint32_t table_entries_used;
105 struct nsv_avchunk_header {
107 uint16_t vchunk_size_msb;
108 uint16_t achunk_size;
111 struct nsv_pcm_header {
126 #define T_NSVF MKTAG('N', 'S', 'V', 'f')
127 #define T_NSVS MKTAG('N', 'S', 'V', 's')
128 #define T_TOC2 MKTAG('T', 'O', 'C', '2')
129 #define T_NONE MKTAG('N', 'O', 'N', 'E')
130 #define T_SUBT MKTAG('S', 'U', 'B', 'T')
131 #define T_ASYN MKTAG('A', 'S', 'Y', 'N')
132 #define T_KEYF MKTAG('K', 'E', 'Y', 'F')
134 #define TB_NSVF MKBETAG('N', 'S', 'V', 'f')
135 #define TB_NSVS MKBETAG('N', 'S', 'V', 's')
138 #define NSV_ST_VIDEO 0
139 #define NSV_ST_AUDIO 1
140 #define NSV_ST_SUBT 2
215 #define print_tag(str, tag, size) \
216 av_log(NULL, AV_LOG_TRACE, "%s: tag=%c%c%c%c\n", \
219 (tag >> 16) & 0xff, \
246 if ((v & 0x0000ffff) == 0xefbe) {
257 if (v ==
MKBETAG(
'N',
'S',
'V',
's')) {
277 int table_entries_used;
300 av_log(s,
AV_LOG_TRACE,
"NSV NSVf info-strings size: %d, table entries: %d, bis %d\n",
301 strings_size, table_entries, table_entries_used);
307 if (strings_size > 0) {
313 p = strings =
av_mallocz((
size_t)strings_size + 1);
316 endp = strings + strings_size;
325 if (!p || p >= endp-2)
330 p = strchr(p, quote);
344 if (table_entries_used > 0) {
347 if((
unsigned)table_entries_used >= UINT_MAX /
sizeof(uint32_t))
353 for(i=0;i<table_entries_used;i++)
356 if(table_entries > table_entries_used &&
361 for(i=0;i<table_entries_used;i++) {
382 uint16_t vwidth, vheight;
402 framerate.
num *= 1000;
403 framerate.
den *= 1001;
406 if((i&3)==3) framerate.
num *= 24;
407 else if((i&3)==2) framerate.
num *= 25;
408 else framerate.
num *= 30;
567 vsize = (vsize << 4) | (auxcount >> 4);
569 av_log(s,
AV_LOG_TRACE,
"NSV CHUNK %d aux, %u bytes video, %d bytes audio\n", auxcount, vsize, asize);
571 for (i = 0; i < auxcount; i++) {
577 ((auxtag >> 8) & 0x0ff),
578 ((auxtag >> 16) & 0x0ff),
579 ((auxtag >> 24) & 0x0ff),
582 vsize -= auxsize +
sizeof(uint16_t) +
sizeof(uint32_t);
587 if (!vsize && !asize) {
589 goto null_chunk_retry;
606 for (i = 0; i <
FFMIN(8, vsize); i++)
610 ((
NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset++;
617 if (asize && st[NSV_ST_AUDIO]->codec->codec_tag ==
MKTAG(
'P',
'C',
'M',
' ')) {
624 if (!channels || !samplerate)
627 av_log(s,
AV_LOG_TRACE,
"NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
640 av_log(s,
AV_LOG_TRACE,
"NSV RAWAUDIO: bps %d, nchan %d, srate %d\n", bps, channels, samplerate);
649 pkt->
dts = (((
NSVStream*)st[NSV_ST_VIDEO]->priv_data)->frame_offset-1);
676 for (i = 0; i < 2; i++) {
728 if (p->
buf[0] ==
'N' && p->
buf[1] ==
'S' &&
729 p->
buf[2] ==
'V' && (p->
buf[3] ==
'f' || p->
buf[3] ==
's'))
735 for (i = 1; i < p->
buf_size - 3; i++) {
740 int offset = i + 23 + asize + vsize + 1;
741 if (offset <= p->buf_size - 2 &&
AV_RL16(p->
buf + offset) == 0xBEEF)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
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.
static const AVCodecTag nsv_codec_video_tags[]
static int nsv_parse_NSVf_header(AVFormatContext *s)
uint32_t * nsvs_file_offset
uint32_t * nsvs_timestamps
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int index
stream index in AVFormatContext
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
static const AVCodecTag nsv_codec_audio_tags[]
Macro definitions for various function/variable attributes.
#define NSV_MAX_RESYNC_TRIES
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
static av_cold int read_close(AVFormatContext *ctx)
static int nsv_resync(AVFormatContext *s)
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.
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
static int nsv_read_close(AVFormatContext *s)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int nsv_read_packet(AVFormatContext *s, AVPacket *pkt)
AVDictionary * metadata
Metadata that applies to the whole file.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
unsigned int avio_rl32(AVIOContext *s)
int64_t timestamp
Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are...
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
preferred ID for decoding MPEG audio layer 1, 2 or 3
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_RL24
static const uint8_t offset[127][2]
static int nsv_read_chunk(AVFormatContext *s, int fill_header)
int flags
A combination of AV_PKT_FLAG values.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
Codec context associated with this stream.
int buf_size
Size of buf except extra allocated bytes.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVInputFormat ff_nsv_demuxer
static int nsv_parse_NSVs_header(AVFormatContext *s)
char filename[1024]
input or output filename
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
static int nsv_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
int width
picture width / height.
GLsizei GLboolean const GLfloat * value
static int nsv_probe(AVProbeData *p)
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
enum AVMediaType codec_type
int sample_rate
samples per second
AVIOContext * pb
I/O context.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
rational number numerator/denominator
This structure contains the data a format has to probe a file.
static int nsv_read_header(AVFormatContext *s)
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rl16(AVIOContext *s)
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
#define MKBETAG(a, b, c, d)
int channels
number of audio channels
void * priv_data
Format private data.
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
#define av_malloc_array(a, b)
int avio_feof(AVIOContext *s)
feof() equivalent for AVIOContext.
#define MKTAG(a, b, c, d)
#define print_tag(str, tag, size)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...