95 #if CONFIG_WAV_DEMUXER 97 static int64_t next_tag(
AVIOContext *pb, uint32_t *
tag,
int big_endian)
124 size = next_tag(pb, &tag, wav->
rifx);
127 wav_seek_tag(wav, pb, size, SEEK_CUR);
137 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
138 if (!memcmp(p->
buf,
"RIFF", 4) || !memcmp(p->
buf,
"RIFX", 4))
143 else if (!memcmp(p->
buf,
"RF64", 4) &&
144 !memcmp(p->
buf + 12,
"ds64", 4))
150 static void handle_stream_probing(
AVStream *st)
172 handle_stream_probing(*st);
198 if (version != 3 && version != 4)
201 if (
size != (32 + ((version==3)?0:8) + 4*num_streams))
204 (*st)->codecpar->sample_rate =
avio_rb32(pb);
211 for (i = 0; i < num_streams; i++) {
215 (*st)->codecpar->channels =
channels;
217 if ((*st)->codecpar->channels <= 0 || (*st)->codecpar->sample_rate <= 0)
236 if ((ret =
avio_read(s->
pb, temp, length)) != length)
249 char temp[131], *coding_history;
251 uint64_t time_reference;
252 int64_t umid_parts[8], umid_mask = 0;
254 if ((ret = wav_parse_bext_string(s,
"description", 256)) < 0 ||
255 (ret = wav_parse_bext_string(s,
"originator", 32)) < 0 ||
256 (ret = wav_parse_bext_string(s,
"originator_reference", 32)) < 0 ||
257 (ret = wav_parse_bext_string(s,
"origination_date", 10)) < 0 ||
258 (ret = wav_parse_bext_string(s,
"origination_time", 8)) < 0)
262 snprintf(temp,
sizeof(temp),
"%"PRIu64, time_reference);
268 for (x = 0; x < 8; x++)
273 if (umid_parts[4] == 0 && umid_parts[5] == 0 &&
274 umid_parts[6] == 0 && umid_parts[7] == 0) {
277 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
278 umid_parts[0], umid_parts[1],
279 umid_parts[2], umid_parts[3]);
283 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
284 "%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
285 umid_parts[0], umid_parts[1],
286 umid_parts[2], umid_parts[3],
287 umid_parts[4], umid_parts[5],
288 umid_parts[6], umid_parts[7]);
303 if (!(coding_history =
av_malloc(size + 1)))
306 if ((ret =
avio_read(s->
pb, coding_history, size)) != size) {
311 coding_history[
size] = 0;
321 {
"description",
"comment" },
322 {
"originator",
"encoded_by" },
323 {
"origination_date",
"date" },
324 {
"origination_time",
"creation_time" },
332 int64_t sample_count = 0;
338 int ret, got_fmt = 0, got_xma2 = 0;
339 int64_t next_tag_ofs, data_ofs = -1;
348 case MKTAG(
'R',
'I',
'F',
'F'):
350 case MKTAG(
'R',
'I',
'F',
'X'):
353 case MKTAG(
'R',
'F',
'6',
'4'):
382 if (data_size < 0 || sample_count < 0) {
384 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
385 data_size, sample_count);
394 size = next_tag(pb, &tag, wav->
rifx);
401 case MKTAG(
'f',
'm',
't',
' '):
403 if (!got_xma2 && !got_fmt && (ret = wav_parse_fmt_tag(s, size, &st)) < 0) {
410 case MKTAG(
'X',
'M',
'A',
'2'):
412 if (!got_fmt && !got_xma2 && (ret = wav_parse_xma2_tag(s, size, &st)) < 0) {
419 case MKTAG(
'd',
'a',
't',
'a'):
422 "found no 'fmt ' tag before the 'data' tag\n");
428 }
else if (size != 0xFFFFFFFF) {
430 next_tag_ofs = wav->
data_end = size ? next_tag_ofs : INT64_MAX;
433 "file may be invalid\n");
435 next_tag_ofs = wav->
data_end = INT64_MAX;
446 case MKTAG(
'f',
'a',
'c',
't'):
450 case MKTAG(
'b',
'e',
'x',
't'):
451 if ((ret = wav_parse_bext_tag(s, size)) < 0)
454 case MKTAG(
'S',
'M',
'V',
'0'):
460 if (size !=
MKTAG(
'0',
'2',
'0',
'0')) {
497 case MKTAG(
'L',
'I',
'S',
'T'):
503 case MKTAG(
'I',
'N',
'F',
'O'):
507 case MKTAG(
'I',
'D',
'3',
' '):
508 case MKTAG(
'i',
'd',
'3',
' '): {
511 if (id3v2_extra_meta) {
523 wav_seek_tag(wav, pb, next_tag_ofs, SEEK_SET) < 0) {
529 if (!got_fmt && !got_xma2) {
541 if (data_size > (INT64_MAX>>3)) {
573 sample_count = (data_size << 3)
619 if (size <= 24 || size > INT64_MAX - 8)
621 if (!memcmp(guid, guid1, 16))
628 #define MAX_SIZE 4096 700 left = find_tag(wav, s->
pb,
MKTAG(
'd',
'a',
't',
'a'));
714 if (size < st->codecpar->block_align)
718 size =
FFMIN(size, left);
728 int stream_index, int64_t timestamp,
int flags)
735 int64_t smv_timestamp = timestamp;
736 if (stream_index == 0)
761 #define OFFSET(x) offsetof(WAVDemuxContext, x) 762 #define DEC AV_OPT_FLAG_DECODING_PARAM 763 static const AVOption demux_options[] = {
768 static const AVClass wav_demuxer_class = {
771 .option = demux_options,
784 .priv_class = &wav_demuxer_class,
788 #if CONFIG_W64_DEMUXER 802 int64_t
size, data_ofs = 0;
814 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
833 if (size <= 24 || INT64_MAX - size <
avio_tell(pb))
860 int64_t start,
end, cur;
861 uint32_t count, chunk_size,
i;
865 end = start +
FFALIGN(size, INT64_C(8)) - 24;
868 for (i = 0; i < count; i++) {
869 char chunk_key[5], *
value;
877 if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize))
907 handle_stream_probing(st);
int ff_read_riff_info(AVFormatContext *s, int64_t size)
int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Add metadata for all PRIV tags in the ID3v2 header.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
int64_t avio_size(AVIOContext *s)
Get the filesize.
const uint8_t ff_w64_guid_wave[16]
int ff_spdif_probe(const uint8_t *p_buf, int buf_size, enum AVCodecID *codec)
const uint8_t ff_w64_guid_fact[16]
#define AV_LOG_WARNING
Something somehow does not look correct.
#define LIBAVUTIL_VERSION_INT
int64_t pos
byte position in stream, -1 if unknown
int probe_packets
Number of packets to buffer for codec probing.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * av_default_item_name(void *ptr)
Return the context name.
AVFormatInternal * internal
An opaque field for libavformat internal usage.
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a UTF-16 string from pb and convert it to UTF-8.
static const GUIDParseTable * find_guid(ff_asf_guid guid)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
unsigned int avio_rb32(AVIOContext *s)
static av_cold int end(AVCodecContext *avctx)
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.
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create chapters for all CHAP tags found in the ID3v2 header.
#define AVERROR_EOF
End of file.
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.
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
#define i(width, name, range_min, range_max)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVDictionary * metadata
Metadata that applies to the whole file.
unsigned int avio_rl32(AVIOContext *s)
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
preferred ID for decoding MPEG audio layer 1, 2 or 3
#define av_fourcc2str(fourcc)
enum AVMediaType codec_type
General type of the encoded data.
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
static const uint8_t offset[127][2]
const AVCodecTag ff_codec_wav_tags[]
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
int extradata_size
Size of the extradata content in bytes.
int avio_r8(AVIOContext *s)
#define CONFIG_W64_DEMUXER
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 block_align
Audio only.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
const uint8_t ff_w64_guid_data[16]
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
const uint8_t ff_w64_guid_riff[16]
static int read_header(FFV1Context *f)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
AVIOContext * pb
I/O context.
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header. ...
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Describe the class of an AVClass context structure.
This structure contains the data a format has to probe a file.
const AVMetadataConv ff_riff_info_conv[]
#define flags(name, subs,...)
const uint8_t ff_w64_guid_fmt[16]
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int64_t duration
Decoding: duration of the stream, in stream time base.
int sample_rate
Audio only.
unsigned int avio_rl16(AVIOContext *s)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata, const char *magic, ID3v2ExtraMeta **extra_meta)
Read an ID3v2 tag into specified dictionary and retrieve supported extra metadata.
void * priv_data
Format private data.
const uint8_t ff_w64_guid_summarylist[16]
int bits_per_coded_sample
The number of bits per sample in the codedwords.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
#define CONFIG_SPDIF_DEMUXER
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
unsigned int avio_rl24(AVIOContext *s)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
#define MKTAG(a, b, c, d)
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
This structure stores compressed data.
uint64_t avio_rl64(AVIOContext *s)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
#define AV_NOPTS_VALUE
Undefined timestamp value.