97 #if CONFIG_WAV_DEMUXER 99 static int64_t next_tag(
AVIOContext *pb, uint32_t *
tag,
int big_endian)
126 size = next_tag(pb, &tag, wav->
rifx);
129 wav_seek_tag(wav, pb, size, SEEK_CUR);
139 if (!memcmp(p->
buf + 8,
"WAVE", 4)) {
140 if (!memcmp(p->
buf,
"RIFF", 4) || !memcmp(p->
buf,
"RIFX", 4))
145 else if ((!memcmp(p->
buf,
"RF64", 4) ||
146 !memcmp(p->
buf,
"BW64", 4)) &&
147 !memcmp(p->
buf + 12,
"ds64", 4))
153 static void handle_stream_probing(
AVStream *st)
175 handle_stream_probing(*st);
201 if (version != 3 && version != 4)
204 if (
size != (32 + ((version==3)?0:8) + 4*num_streams))
207 (*st)->codecpar->sample_rate =
avio_rb32(pb);
214 for (i = 0; i < num_streams; i++) {
218 (*st)->codecpar->channels =
channels;
220 if ((*st)->codecpar->channels <= 0 || (*st)->codecpar->sample_rate <= 0)
239 if ((ret =
avio_read(s->
pb, temp, length)) != length)
252 char temp[131], *coding_history;
254 uint64_t time_reference;
255 int64_t umid_parts[8], umid_mask = 0;
257 if ((ret = wav_parse_bext_string(s,
"description", 256)) < 0 ||
258 (ret = wav_parse_bext_string(s,
"originator", 32)) < 0 ||
259 (ret = wav_parse_bext_string(s,
"originator_reference", 32)) < 0 ||
260 (ret = wav_parse_bext_string(s,
"origination_date", 10)) < 0 ||
261 (ret = wav_parse_bext_string(s,
"origination_time", 8)) < 0)
265 snprintf(temp,
sizeof(temp),
"%"PRIu64, time_reference);
271 for (x = 0; x < 8; x++)
276 if (umid_parts[4] == 0 && umid_parts[5] == 0 &&
277 umid_parts[6] == 0 && umid_parts[7] == 0) {
280 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
281 umid_parts[0], umid_parts[1],
282 umid_parts[2], umid_parts[3]);
286 "0x%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64
287 "%016"PRIX64
"%016"PRIX64
"%016"PRIX64
"%016"PRIX64,
288 umid_parts[0], umid_parts[1],
289 umid_parts[2], umid_parts[3],
290 umid_parts[4], umid_parts[5],
291 umid_parts[6], umid_parts[7]);
306 if (!(coding_history =
av_malloc(size + 1)))
309 if ((ret =
avio_read(s->
pb, coding_history, size)) != size) {
314 coding_history[
size] = 0;
324 {
"description",
"comment" },
325 {
"originator",
"encoded_by" },
326 {
"origination_date",
"date" },
327 {
"origination_time",
"creation_time" },
335 int64_t sample_count = 0;
336 int rf64 = 0, bw64 = 0;
341 int ret, got_fmt = 0, got_xma2 = 0;
342 int64_t next_tag_ofs, data_ofs = -1;
351 case MKTAG(
'R',
'I',
'F',
'F'):
353 case MKTAG(
'R',
'I',
'F',
'X'):
356 case MKTAG(
'R',
'F',
'6',
'4'):
359 case MKTAG(
'B',
'W',
'6',
'4'):
388 if (data_size < 0 || sample_count < 0) {
390 "ds64: data_size = %"PRId64
", sample_count = %"PRId64
"\n",
391 data_size, sample_count);
400 size = next_tag(pb, &tag, wav->
rifx);
407 case MKTAG(
'f',
'm',
't',
' '):
409 if (!got_xma2 && !got_fmt && (ret = wav_parse_fmt_tag(s, size, &st)) < 0) {
416 case MKTAG(
'X',
'M',
'A',
'2'):
418 if (!got_fmt && !got_xma2 && (ret = wav_parse_xma2_tag(s, size, &st)) < 0) {
425 case MKTAG(
'd',
'a',
't',
'a'):
428 "found no 'fmt ' tag before the 'data' tag\n");
434 }
else if (size != 0xFFFFFFFF) {
436 next_tag_ofs = wav->
data_end = size ? next_tag_ofs : INT64_MAX;
439 "file may be invalid\n");
441 next_tag_ofs = wav->
data_end = INT64_MAX;
452 case MKTAG(
'f',
'a',
'c',
't'):
456 case MKTAG(
'b',
'e',
'x',
't'):
457 if ((ret = wav_parse_bext_tag(s, size)) < 0)
460 case MKTAG(
'S',
'M',
'V',
'0'):
466 if (size !=
MKTAG(
'0',
'2',
'0',
'0')) {
500 case MKTAG(
'L',
'I',
'S',
'T'):
501 case MKTAG(
'l',
'i',
's',
't'):
507 case MKTAG(
'I',
'N',
'F',
'O'):
510 case MKTAG(
'a',
'd',
't',
'l'):
515 unsigned id, sub_size;
524 avio_get_str(pb, sub_size - 4, cue_label,
sizeof(cue_label));
538 case MKTAG(
'I',
'D',
'3',
' '):
539 case MKTAG(
'i',
'd',
'3',
' '): {
542 if (id3v2_extra_meta) {
550 case MKTAG(
'c',
'u',
'e',
' '):
555 if (size >= nb_cues * 24LL + 4LL) {
556 for (
int i = 0;
i < nb_cues;
i++) {
575 wav_seek_tag(wav, pb, next_tag_ofs, SEEK_SET) < 0) {
581 if (!got_fmt && !got_xma2) {
593 if (data_size > (INT64_MAX>>3)) {
625 sample_count = (data_size << 3)
672 if (!memcmp(guid, guid1, 16))
686 if (CONFIG_SPDIF_DEMUXER && wav->
spdif == 1)
739 if (CONFIG_W64_DEMUXER && wav->
w64)
742 left = find_tag(wav, s->
pb,
MKTAG(
'd',
'a',
't',
'a'));
758 size =
FFMIN(size, left);
768 int stream_index, int64_t timestamp,
int flags)
775 int64_t smv_timestamp = timestamp;
776 if (stream_index == 0)
800 #define OFFSET(x) offsetof(WAVDemuxContext, x) 801 #define DEC AV_OPT_FLAG_DECODING_PARAM 802 static const AVOption demux_options[] = {
808 static const AVClass wav_demuxer_class = {
811 .option = demux_options,
824 .priv_class = &wav_demuxer_class,
828 #if CONFIG_W64_DEMUXER 842 int64_t
size, data_ofs = 0;
854 if (
avio_rl64(pb) < 16 + 8 + 16 + 8 + 16 + 8)
873 if (size <= 24 || INT64_MAX - size <
avio_tell(pb))
900 int64_t start,
end, cur;
901 uint32_t
count, chunk_size,
i;
905 end = start +
FFALIGN(size, INT64_C(8)) - 24;
908 for (i = 0; i <
count; i++) {
909 char chunk_key[5], *
value;
917 if (chunk_size == UINT32_MAX || (filesize >= 0 && chunk_size > filesize))
943 handle_stream_probing(st);
953 #define OFFSET(x) offsetof(WAVDemuxContext, x) 954 #define DEC AV_OPT_FLAG_DECODING_PARAM 955 static const AVOption w64_demux_options[] = {
960 static const AVClass w64_demuxer_class = {
963 .option = w64_demux_options,
977 .priv_class = &w64_demuxer_class,
unsigned int nb_chapters
Number of chapters in AVChapter array.
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)
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
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)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
static av_cold int end(AVCodecContext *avctx)
int id
unique ID to identify the chapter
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
enum AVStreamParseType need_parsing
int id
Format-specific stream ID.
GLsizei GLboolean const GLfloat * value
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)
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.
static __device__ float fabs(float a)
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)
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option keep it simple and lowercase description are in without and describe what they for example set the foo of the bar offset is the offset of the field in your local see the OFFSET() macro
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.
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
simple assert() macros that are a bit more flexible than ISO C assert().
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)
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.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
AVIOContext * pb
I/O context.
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2]...the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so...,+,-,+,-,+,+,-,+,-,+,...hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32-hcoeff[1]-hcoeff[2]-...a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2}an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||.........intra?||||:Block01:yes no||||:Block02:.................||||:Block03::y DC::ref index:||||:Block04::cb DC::motion x:||||.........:cr DC::motion y:||||.................|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------------------------------|||Y subbands||Cb subbands||Cr subbands||||------||------||------|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||------||------||------||||------||------||------|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||------||------||------||||------||------||------|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||------||------||------||||------||------||------|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------------------------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction------------|\Dequantization-------------------\||Reference frames|\IDWT|--------------|Motion\|||Frame 0||Frame 1||Compensation.OBMC v-------|--------------|--------------.\------> Frame n output Frame Frame<----------------------------------/|...|-------------------Range Coder:============Binary Range Coder:-------------------The implemented range coder is an adapted version based upon"Range encoding: an algorithm for removing redundancy from a digitised message."by G.N.N.Martin.The symbols encoded by the Snow range coder are bits(0|1).The associated probabilities are not fix but change depending on the symbol mix seen so far.bit seen|new state---------+-----------------------------------------------0|256-state_transition_table[256-old_state];1|state_transition_table[old_state];state_transition_table={0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:-------------------------FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1.the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
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.
Rational number (pair of numerator and denominator).
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)
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.
Filter the word “frame” indicates either a video frame or a group of audio samples
AVCodecParameters * codecpar
Codec parameters associated with this stream.
int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen)
Read a string from pb into buf.
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...
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
#define MKTAG(a, b, c, d)
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.