67 #define OFFSET(x) offsetof(WAVDemuxContext, x)
68 #define DEC AV_OPT_FLAG_DECODING_PARAM
70 #define W64_DEMUXER_OPTIONS_OFFSET (1 * CONFIG_WAV_DEMUXER)
71 #if CONFIG_WAV_DEMUXER
95 s->streams[0]->codecpar->codec_id = codec;
109 #if CONFIG_WAV_DEMUXER
111 static int64_t next_tag(
AVIOContext *pb, uint32_t *
tag,
int big_endian)
141 wav_seek_tag(wav, pb,
size, SEEK_CUR);
151 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
152 if (!memcmp(p->
buf,
"RIFF", 4) || !memcmp(p->
buf,
"RIFX", 4))
157 else if ((!memcmp(p->
buf,
"RF64", 4) ||
158 !memcmp(p->
buf,
"BW64", 4)) &&
159 !memcmp(p->
buf + 12,
"ds64", 4))
165 static void handle_stream_probing(
AVStream *st)
187 handle_stream_probing(*st);
216 if (
size != (32 + ((
version==3)?0:8) + 4*num_streams))
219 (*st)->codecpar->sample_rate =
avio_rb32(pb);
226 for (
i = 0;
i < num_streams;
i++) {
230 (*st)->codecpar->channels =
channels;
232 if ((*st)->codecpar->channels <= 0 || (*st)->codecpar->sample_rate <= 0)
264 char temp[131], *coding_history;
266 uint64_t time_reference;
267 int64_t umid_parts[8], umid_mask = 0;
269 if ((ret = wav_parse_bext_string(
s,
"description", 256)) < 0 ||
270 (ret = wav_parse_bext_string(
s,
"originator", 32)) < 0 ||
271 (ret = wav_parse_bext_string(
s,
"originator_reference", 32)) < 0 ||
272 (ret = wav_parse_bext_string(
s,
"origination_date", 10)) < 0 ||
273 (ret = wav_parse_bext_string(
s,
"origination_time", 8)) < 0)
283 for (x = 0; x < 8; x++)
284 umid_mask |= umid_parts[x] =
avio_rb64(
s->pb);
288 if (umid_parts[4] == 0 && umid_parts[5] == 0 &&
289 umid_parts[6] == 0 && umid_parts[7] == 0) {
292 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
293 umid_parts[0], umid_parts[1],
294 umid_parts[2], umid_parts[3]);
298 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
299 "%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
300 umid_parts[0], umid_parts[1],
301 umid_parts[2], umid_parts[3],
302 umid_parts[4], umid_parts[5],
303 umid_parts[6], umid_parts[7]);
326 coding_history[
size] = 0;
327 if ((ret =
av_dict_set(&
s->metadata,
"coding_history", coding_history,
336 {
"description",
"comment" },
337 {
"originator",
"encoded_by" },
338 {
"origination_date",
"date" },
339 {
"origination_time",
"creation_time" },
347 int64_t sample_count = 0;
348 int rf64 = 0, bw64 = 0;
353 int ret, got_fmt = 0, got_xma2 = 0;
354 int64_t next_tag_ofs, data_ofs = -1;
363 case MKTAG(
'R',
'I',
'F',
'F'):
365 case MKTAG(
'R',
'I',
'F',
'X'):
368 case MKTAG(
'R',
'F',
'6',
'4'):
371 case MKTAG(
'B',
'W',
'6',
'4'):
400 if (data_size < 0 || sample_count < 0) {
402 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
403 data_size, sample_count);
419 case MKTAG(
'f',
'm',
't',
' '):
421 if (!got_xma2 && !got_fmt && (ret = wav_parse_fmt_tag(
s,
size, &st)) < 0) {
428 case MKTAG(
'X',
'M',
'A',
'2'):
430 if (!got_fmt && !got_xma2 && (ret = wav_parse_xma2_tag(
s,
size, &st)) < 0) {
437 case MKTAG(
'd',
'a',
't',
'a'):
440 "found no 'fmt ' tag before the 'data' tag\n");
446 }
else if (
size != 0xFFFFFFFF) {
448 next_tag_ofs = wav->
data_end =
size ? next_tag_ofs : INT64_MAX;
451 "file may be invalid\n");
453 next_tag_ofs = wav->
data_end = INT64_MAX;
464 case MKTAG(
'f',
'a',
'c',
't'):
468 case MKTAG(
'b',
'e',
'x',
't'):
469 if ((ret = wav_parse_bext_tag(
s,
size)) < 0)
472 case MKTAG(
'S',
'M',
'V',
'0'):
514 case MKTAG(
'L',
'I',
'S',
'T'):
515 case
MKTAG(
'l',
'i',
's',
't'):
521 case MKTAG(
'I',
'N',
'F',
'O'):
524 case MKTAG(
'a',
'd',
't',
'l'):
525 if (
s->nb_chapters > 0) {
529 unsigned id, sub_size;
538 avio_get_str(pb, sub_size - 4, cue_label,
sizeof(cue_label));
541 for (
int i = 0;
i <
s->nb_chapters;
i++) {
542 if (
s->chapters[
i]->id ==
id) {
543 av_dict_set(&
s->chapters[
i]->metadata,
"title", cue_label, 0);
552 case MKTAG(
'I',
'D',
'3',
' '):
553 case
MKTAG(
'i',
'd',
'3',
' '): {
556 if (id3v2_extra_meta) {
564 case MKTAG(
'c',
'u',
'e',
' '):
569 if (
size >= nb_cues * 24LL + 4LL) {
570 for (
int i = 0;
i < nb_cues;
i++) {
589 wav_seek_tag(wav, pb, next_tag_ofs, SEEK_SET) < 0) {
595 if (!got_fmt && !got_xma2) {
607 if (data_size > (INT64_MAX>>3)) {
639 sample_count = (data_size << 3)
685 if (size <= 24 || size > INT64_MAX - 8)
687 if (!memcmp(guid, guid1, 16))
757 left = find_tag(wav,
s->pb,
MKTAG(
'd',
'a',
't',
'a'));
769 if (size < st->codecpar->block_align)
783 int stream_index, int64_t timestamp,
int flags)
790 int64_t smv_timestamp = timestamp;
791 if (stream_index == 0)
792 smv_timestamp =
av_rescale_q(timestamp,
s->streams[0]->time_base,
s->streams[1]->time_base);
794 timestamp =
av_rescale_q(smv_timestamp,
s->streams[1]->time_base,
s->streams[0]->time_base);
815 static const AVClass wav_demuxer_class = {
831 .priv_class = &wav_demuxer_class,
835 #if CONFIG_W64_DEMUXER
849 int64_t
size, data_ofs = 0;
861 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
907 int64_t start, end, cur;
908 uint32_t count, chunk_size,
i;
915 for (
i = 0;
i < count;
i++) {
916 char chunk_key[5], *
value;
924 if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize))
954 handle_stream_probing(st);
964 static const AVClass w64_demuxer_class = {
981 .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.
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.
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