45 #if CONFIG_WAV_DEMUXER
54 static int64_t wav_seek_tag(
AVIOContext *s, int64_t offset,
int whence)
56 return avio_seek(s, offset + (offset & 1), whence);
60 static int64_t find_tag(
AVIOContext *pb, uint32_t tag1)
68 size = next_tag(pb, &tag);
71 wav_seek_tag(pb, size, SEEK_CUR);
81 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
82 if (!memcmp(p->
buf,
"RIFF", 4))
89 else if (!memcmp(p->
buf,
"RF64", 4) &&
90 !memcmp(p->
buf + 12,
"ds64", 4))
116 static inline int wav_parse_bext_string(
AVFormatContext *s,
const char *key,
136 char temp[131], *coding_history;
138 uint64_t time_reference;
139 int64_t umid_parts[8], umid_mask = 0;
141 if ((ret = wav_parse_bext_string(s,
"description", 256)) < 0 ||
142 (ret = wav_parse_bext_string(s,
"originator", 32)) < 0 ||
143 (ret = wav_parse_bext_string(s,
"originator_reference", 32)) < 0 ||
144 (ret = wav_parse_bext_string(s,
"origination_date", 10)) < 0 ||
145 (ret = wav_parse_bext_string(s,
"origination_time", 8)) < 0)
149 snprintf(temp,
sizeof(temp),
"%"PRIu64, time_reference);
155 for (x = 0; x < 8; x++)
160 if (umid_parts[4] == 0 && umid_parts[5] == 0 && umid_parts[6] == 0 && umid_parts[7] == 0) {
162 snprintf(temp,
sizeof(temp),
"0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
163 umid_parts[0], umid_parts[1], umid_parts[2], umid_parts[3]);
166 snprintf(temp,
sizeof(temp),
"0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
167 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
168 umid_parts[0], umid_parts[1], umid_parts[2], umid_parts[3],
169 umid_parts[4], umid_parts[5], umid_parts[6], umid_parts[7]);
184 if (!(coding_history =
av_malloc(size+1)))
187 if ((ret =
avio_read(s->
pb, coding_history, size)) < 0)
190 coding_history[
size] = 0;
200 {
"description",
"comment" },
201 {
"originator",
"encoded_by" },
202 {
"origination_date",
"date" },
203 {
"origination_time",
"creation_time"},
211 int64_t sample_count=0;
217 int ret, got_fmt = 0;
218 int64_t next_tag_ofs, data_ofs = -1;
223 rf64 = tag ==
MKTAG(
'R',
'F',
'6',
'4');
224 if (!rf64 && tag !=
MKTAG(
'R',
'I',
'F',
'F'))
228 if (tag !=
MKTAG(
'W',
'A',
'V',
'E'))
240 if (data_size < 0 || sample_count < 0) {
242 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
243 data_size, sample_count);
250 size = next_tag(pb, &tag);
257 case MKTAG(
'f',
'm',
't',
' '):
259 if (!got_fmt && (ret = wav_parse_fmt_tag(s, size, &st) < 0)) {
266 case MKTAG(
'd',
'a',
't',
'a'):
276 next_tag_ofs = wav->
data_end = size ? next_tag_ofs : INT64_MAX;
284 if (!pb->
seekable || (!rf64 && !size))
287 case MKTAG(
'f',
'a',
'c',
't'):
291 case MKTAG(
'b',
'e',
'x',
't'):
292 if ((ret = wav_parse_bext_tag(s, size)) < 0)
295 case MKTAG(
'L',
'I',
'S',
'T'):
301 case MKTAG(
'I',
'N',
'F',
'O'):
310 wav_seek_tag(pb, next_tag_ofs, SEEK_SET) < 0) {
346 if (!memcmp(guid, guid1, 16))
353 static const uint8_t guid_data[16] = {
'd',
'a',
't',
'a',
354 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
356 #define MAX_SIZE 4096
371 left = find_guid(s->
pb, guid_data) - 24;
373 left = find_tag(s->
pb,
MKTAG(
'd',
'a',
't',
'a'));
381 if (size < st->codec->block_align)
385 size =
FFMIN(size, left);
395 int stream_index, int64_t timestamp,
int flags)
427 #if CONFIG_W64_DEMUXER
428 static const uint8_t guid_riff[16] = {
'r',
'i',
'f',
'f',
429 0x2E, 0x91, 0xCF, 0x11, 0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00 };
431 static const uint8_t guid_wave[16] = {
'w',
'a',
'v',
'e',
432 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
434 static const uint8_t guid_fmt [16] = {
'f',
'm',
't',
' ',
435 0xF3, 0xAC, 0xD3, 0x11, 0x8C, 0xD1, 0x00, 0xC0, 0x4F, 0x8E, 0xDB, 0x8A };
441 if (!memcmp(p->
buf, guid_riff, 16) &&
442 !memcmp(p->
buf + 24, guid_wave, 16))
458 if (memcmp(guid, guid_riff, 16))
461 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
465 if (memcmp(guid, guid_wave, 16)) {
470 size = find_guid(pb, guid_fmt);
490 size = find_guid(pb, guid_data);
int ff_read_riff_info(AVFormatContext *s, int64_t size)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
int64_t avio_size(AVIOContext *s)
Get the filesize.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
struct WAVDemuxContext WAVDemuxContext
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
enum AVStreamParseType need_parsing
#define MKTAG(a, b, c, d)
uint64_t avio_rb64(AVIOContext *s)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
#define AV_DICT_DONT_STRDUP_VAL
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
unsigned int avio_rl32(AVIOContext *s)
int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
#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
simple assert() macros that are a bit more flexible than ISO C assert().
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
const AVCodecTag ff_codec_wav_tags[]
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.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
static int read_header(FFV1Context *f)
int sample_rate
samples per second
AVIOContext * pb
I/O context.
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
This structure contains the data a format has to probe a file.
const AVMetadataConv ff_riff_info_conv[]
int64_t duration
Decoding: duration of the stream, in stream time base.
unsigned int avio_rl16(AVIOContext *s)
#define AVERROR_INVALIDDATA
#define AVPROBE_SCORE_MAX
int eof_reached
true if eof reached
int channels
number of audio channels
void * priv_data
Format private data.
This structure stores compressed data.
uint64_t avio_rl64(AVIOContext *s)
#define AVFMT_GENERIC_INDEX
if(!(ptr_align%ac->ptr_align)&&samples_align >=aligned_len)