68 #define OFFSET(x) offsetof(WAVDemuxContext, x)
69 #define DEC AV_OPT_FLAG_DECODING_PARAM
71 #define W64_DEMUXER_OPTIONS_OFFSET (1 * CONFIG_WAV_DEMUXER)
72 #if CONFIG_WAV_DEMUXER
96 s->streams[0]->codecpar->codec_id = codec;
110 #if CONFIG_WAV_DEMUXER
155 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
156 if (!memcmp(p->
buf,
"RIFF", 4) || !memcmp(p->
buf,
"RIFX", 4))
161 else if ((!memcmp(p->
buf,
"RF64", 4) ||
162 !memcmp(p->
buf,
"BW64", 4)) &&
163 !memcmp(p->
buf + 12,
"ds64", 4))
169 static void handle_stream_probing(
AVStream *st)
187 handle_stream_probing(st);
212 if (
size != (32 + ((
version==3)?0:8) + 4*num_streams))
222 for (
i = 0;
i < num_streams;
i++) {
260 char temp[131], *coding_history;
262 uint64_t time_reference;
263 int64_t umid_parts[8], umid_mask = 0;
265 if ((ret = wav_parse_bext_string(
s,
"description", 256)) < 0 ||
266 (ret = wav_parse_bext_string(
s,
"originator", 32)) < 0 ||
267 (ret = wav_parse_bext_string(
s,
"originator_reference", 32)) < 0 ||
268 (ret = wav_parse_bext_string(
s,
"origination_date", 10)) < 0 ||
269 (ret = wav_parse_bext_string(
s,
"origination_time", 8)) < 0)
279 for (x = 0; x < 8; x++)
280 umid_mask |= umid_parts[x] =
avio_rb64(
s->pb);
284 if (umid_parts[4] == 0 && umid_parts[5] == 0 &&
285 umid_parts[6] == 0 && umid_parts[7] == 0) {
288 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
289 umid_parts[0], umid_parts[1],
290 umid_parts[2], umid_parts[3]);
294 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
295 "%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
296 umid_parts[0], umid_parts[1],
297 umid_parts[2], umid_parts[3],
298 umid_parts[4], umid_parts[5],
299 umid_parts[6], umid_parts[7]);
322 coding_history[
size] = 0;
323 if ((ret =
av_dict_set(&
s->metadata,
"coding_history", coding_history,
332 {
"description",
"comment" },
333 {
"originator",
"encoded_by" },
334 {
"origination_date",
"date" },
335 {
"origination_time",
"creation_time" },
344 int rf64 = 0, bw64 = 0;
349 int ret, got_fmt = 0, got_xma2 = 0;
350 int64_t next_tag_ofs, data_ofs = -1;
359 case MKTAG(
'R',
'I',
'F',
'F'):
361 case MKTAG(
'R',
'I',
'F',
'X'):
364 case MKTAG(
'R',
'F',
'6',
'4'):
367 case MKTAG(
'B',
'W',
'6',
'4'):
396 if (data_size < 0 || sample_count < 0) {
398 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
399 data_size, sample_count);
420 case MKTAG(
'f',
'm',
't',
' '):
422 if (!got_xma2 && !got_fmt && (ret = wav_parse_fmt_tag(
s,
size, st)) < 0) {
429 case MKTAG(
'X',
'M',
'A',
'2'):
431 if (!got_fmt && !got_xma2 && (ret = wav_parse_xma2_tag(
s,
size, st)) < 0) {
438 case MKTAG(
'd',
'a',
't',
'a'):
441 "found no 'fmt ' tag before the 'data' tag\n");
448 }
else if (
size > 0 &&
size != 0xFFFFFFFF) {
454 "file may be invalid\n");
456 next_tag_ofs = wav->
data_end = INT64_MAX;
467 case MKTAG(
'f',
'a',
'c',
't'):
471 case MKTAG(
'b',
'e',
'x',
't'):
472 if ((ret = wav_parse_bext_tag(
s,
size)) < 0)
475 case MKTAG(
'S',
'M',
'V',
'0'):
518 case MKTAG(
'L',
'I',
'S',
'T'):
519 case
MKTAG(
'l',
'i',
's',
't'):
525 case MKTAG(
'I',
'N',
'F',
'O'):
528 case MKTAG(
'a',
'd',
't',
'l'):
529 if (
s->nb_chapters > 0) {
533 unsigned id, sub_size;
542 avio_get_str(pb, sub_size - 4, cue_label,
sizeof(cue_label));
545 for (
int i = 0;
i <
s->nb_chapters;
i++) {
546 if (
s->chapters[
i]->id ==
id) {
547 av_dict_set(&
s->chapters[
i]->metadata,
"title", cue_label, 0);
556 case MKTAG(
'I',
'D',
'3',
' '):
557 case
MKTAG(
'i',
'd',
'3',
' '): {
560 if (id3v2_extra_meta) {
568 case MKTAG(
'c',
'u',
'e',
' '):
573 if (
size >= nb_cues * 24LL + 4LL) {
574 for (
int i = 0;
i < nb_cues;
i++) {
593 wav_seek_tag(wav, pb, next_tag_ofs) < 0) {
599 if (!got_fmt && !got_xma2) {
611 if (data_size > (INT64_MAX>>3)) {
643 sample_count = (data_size << 3)
690 if (size <= 24 || size > INT64_MAX - 8)
692 if (!memcmp(guid, guid1, 16))
765 left = find_tag(wav,
s->pb,
MKTAG(
'd',
'a',
't',
'a'));
779 if (size < st->codecpar->block_align)
800 if (stream_index != 0 && (!vst || stream_index != vst->
index))
803 int64_t smv_timestamp = timestamp;
804 if (stream_index == 0)
827 static const AVClass wav_demuxer_class = {
843 .priv_class = &wav_demuxer_class,
847 #if CONFIG_W64_DEMUXER
872 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
921 uint32_t count, chunk_size,
i;
928 for (
i = 0;
i < count;
i++) {
929 char chunk_key[5], *
value;
937 if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize))
967 handle_stream_probing(st);
977 static const AVClass w64_demuxer_class = {
994 .priv_class = &w64_demuxer_class,
static const GUIDParseTable * find_guid(ff_asf_guid guid)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_SEEKABLE_NORMAL
Seeking works like for a local file.
uint64_t avio_rb64(AVIOContext *s)
int64_t avio_size(AVIOContext *s)
Get the filesize.
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.
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_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
unsigned int avio_rl24(AVIOContext *s)
unsigned int avio_rb32(AVIOContext *s)
int avio_r8(AVIOContext *s)
uint64_t avio_rl64(AVIOContext *s)
int ffio_ensure_seekback(AVIOContext *s, int64_t buf_size)
Ensures that the requested seekback buffer size will be available.
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
#define flags(name, subs,...)
#define MKTAG(a, b, c, d)
#define CONFIG_W64_DEMUXER
#define CONFIG_SPDIF_DEMUXER
static __device__ float fabs(float a)
static int read_header(FFV1Context *f)
AVCodecID
Identify the syntax and semantics of the bitstream.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
int av_get_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
int av_get_exact_bits_per_sample(enum AVCodecID codec_id)
Return codec bits per sample.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
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 AVERROR_EOF
End of file.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
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.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
#define av_fourcc2str(fourcc)
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define LIBAVUTIL_VERSION_INT
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header.
int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Add metadata for all PRIV tags in the ID3v2 header.
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create chapters for all CHAP tags found in the ID3v2 header.
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.
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
const AVMetadataConv ff_riff_info_conv[]
internal header for RIFF based (de)muxers do NOT include this in end user applications
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
int ff_read_riff_info(AVFormatContext *s, int64_t size)
const AVCodecTag *const ff_wav_codec_tags_list[]
int ff_spdif_probe(const uint8_t *p_buf, int buf_size, enum AVCodecID *codec)
int ff_spdif_read_packet(AVFormatContext *s, AVPacket *pkt)
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int extradata_size
Size of the extradata content in bytes.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
int block_align
Audio only.
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
Audio only.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
This structure stores compressed data.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t pos
byte position in stream, -1 if unknown
This structure contains the data a format has to probe a file.
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.
Rational number (pair of numerator and denominator).
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int probe_packets
Number of packets to buffer for codec probing.
int64_t duration
Decoding: duration of the stream, in stream time base.
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
enum AVStreamParseType need_parsing
AVStreamInternal * internal
An opaque field for libavformat internal usage.
static const uint8_t offset[127][2]
const uint8_t ff_w64_guid_wave[16]
const uint8_t ff_w64_guid_summarylist[16]
const uint8_t ff_w64_guid_riff[16]
const uint8_t ff_w64_guid_data[16]
const uint8_t ff_w64_guid_fact[16]
const uint8_t ff_w64_guid_fmt[16]
static void set_spdif(AVFormatContext *s, WAVDemuxContext *wav)
static const AVOption demux_options[]
#define W64_DEMUXER_OPTIONS_OFFSET