Go to the documentation of this file.
136 #define ASF_MAX_STREAMS 127
137 #define FRAME_HEADER_SIZE 6
143 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
146 #define PRINT_IF_GUID(g, cmp) \
147 if (!ff_guidcmp(g, &cmp)) \
148 av_log(NULL, AV_LOG_TRACE, "(GUID: %s) ", # cmp)
176 else PRINT_IF_GUID(
g, stream_bitrate_guid);
180 for (
i = 0;
i < 16;
i++)
186 #define print_guid(g) while(0)
226 int ret,
type, picsize, desc_len;
229 if (
len < 1 + 4 + 2 + 2) {
249 if (!strncmp(mime->
str, mimetype,
sizeof(mimetype))) {
261 if (picsize >=
len) {
268 desc_len = (
len - picsize) * 2 + 1;
310 if (id3v2_extra_meta) {
342 if (!strcmp(
key,
"WM/Picture")) {
344 }
else if (!strcmp(
key,
"ID3")) {
363 "Unsupported value type %d in tag %s.\n",
type,
key);
406 int type_specific_size, sizeX;
409 int test_for_ext_stream_audio, is_dvr_ms_audio = 0;
433 test_for_ext_stream_audio = 0;
444 test_for_ext_stream_audio = 1;
460 if (test_for_ext_stream_audio) {
479 if (is_dvr_ms_audio) {
491 if (
size >= (pos2 + 8 - pos1 + 24)) {
544 if (tag1 ==
MKTAG(
'D',
'V',
'R',
' ')) {
570 int ext_len, payload_ext_ct, stream_ct,
i;
571 uint32_t leak_rate, stream_num;
572 unsigned int stream_languageid_index;
587 if (stream_num < 128)
594 if (stream_num < 128) {
599 for (
i = 0;
i < stream_ct;
i++) {
605 for (
i = 0;
i < payload_ext_ct;
i++) {
626 int len1, len2, len3, len4, len5;
635 get_tag(
s,
"copyright", 0, len3, 32);
646 int desc_count,
i,
ret;
649 for (
i = 0;
i < desc_count;
i++) {
650 int name_len, value_type, value_len;
660 if (!value_type && value_len % 2)
665 if (!strcmp(
name,
"AspectRatioX"))
667 else if (!strcmp(
name,
"AspectRatioY"))
682 for (j = 0; j < stream_count; j++) {
684 unsigned int lang_len =
avio_r8(pb);
686 sizeof(lang))) < lang_len)
700 int n, stream_num, name_len_utf16, name_len_utf8, value_len;
704 for (
i = 0;
i < n;
i++) {
714 if (value_len < 0 || value_len > UINT16_MAX)
717 name_len_utf8 = 2*name_len_utf16 + 1;
725 i, stream_num, name_len_utf16, value_type, value_len,
name);
727 if (!strcmp(
name,
"AspectRatioX")){
728 int aspect_x =
get_value(
s->pb, value_type, 16);
730 asf->
dar[stream_num].
num = aspect_x;
731 }
else if(!strcmp(
name,
"AspectRatioY")){
732 int aspect_y =
get_value(
s->pb, value_type, 16);
734 asf->
dar[stream_num].
den = aspect_y;
748 int i, count, name_len,
ret;
758 for (
i = 0;
i < count;
i++) {
773 sizeof(
name))) < name_len)
799 for (
i = 0;
i<128;
i++)
812 if (!(asf->
hdr.
flags & 0x01) && gsize >= 100)
854 "DRM protected stream detected, decoding will likely fail!\n");
864 if (
len > UINT16_MAX)
869 if (
len > UINT16_MAX)
874 if (
len > UINT16_MAX)
879 "Ext DRM protected stream detected, decoding will likely fail!\n");
880 av_dict_set(&
s->metadata,
"encryption",
"ASF Extended Content Encryption", 0);
891 "gpos mismatch our pos=%"PRIu64
", end=%"PRId64
"\n",
904 for (
i = 0;
i < 128;
i++) {
906 if (stream_num >= 0) {
914 }
else if ((asf->
dar[0].
num > 0) && (asf->
dar[0].
den > 0) &&
928 if (rfc1766 && strlen(rfc1766) > 1) {
929 const char primary_tag[3] = { rfc1766[0], rfc1766[1],
'\0' };
944 #define DO_2BITS(bits, var, defval) \
945 switch (bits & 3) { \
947 var = avio_rl32(pb); \
951 var = avio_rl16(pb); \
972 uint32_t packet_length, padsize;
989 if (
c == 0x82 && !d && !e)
1002 "ff asf bad header %x at:%"PRId64
"\n",
c,
avio_tell(pb));
1004 if ((
c & 0x8f) == 0x82) {
1047 if (!packet_length || packet_length >= (1
U << 29)) {
1049 "invalid packet_length %"PRIu32
" at:%"PRId64
"\n",
1053 if (padsize >= packet_length) {
1055 "invalid padsize %"PRIu32
" at:%"PRId64
"\n", padsize,
avio_tell(pb));
1071 if (rsize > packet_length - padsize) {
1074 "invalid packet header length %d for pktlen %"PRIu32
"-%"PRIu32
" at %"PRId64
"\n",
1075 rsize, packet_length, padsize,
avio_tell(pb));
1079 if (packet_length < asf->hdr.min_pktsize)
1103 asfst = &asf->
streams[num & 0x7f];
1108 av_log(asf,
AV_LOG_TRACE,
"key:%d stream:%d seq:%d offset:%d replic_size:%d num:%X packet_property %X\n",
1145 s->streams[asf->
stream_index]->sample_aspect_ratio = aspect;
1272 "stream:%d, expected:%d but got %d from pkt)\n",
1303 "freeing incomplete packet size %d, new %d\n",
1331 av_log(asf,
AV_LOG_TRACE,
"new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
1353 "packet fragment position invalid %u,%u not in %u\n",
1367 if (ret < 0 || asf->packet_frag_offset +
ret == 0)
1382 if (
s->key &&
s->keylen == 20)
1406 "pkt.size != ds_packet_size * ds_span (%d %d %d)\n",
1416 memset(newdata + asf_st->
pkt.
size, 0,
1418 while (offset < asf_st->
pkt.
size) {
1420 int row = off / asf_st->
ds_span;
1421 int col = off % asf_st->
ds_span;
1492 for (
i = 0;
i < 128;
i++) {
1507 for (
i = 0;
i < 128;
i++) {
1525 int64_t *ppos, int64_t pos_limit)
1531 int64_t
pos = *ppos;
1535 for (
i = 0;
i <
s->nb_streams;
i++)
1538 if (
s->packet_size > 0)
1539 pos = (
pos +
s->packet_size - 1 -
s->internal->data_offset) /
1540 s->packet_size *
s->packet_size +
1541 s->internal->data_offset;
1559 asf_st = &asf->
streams[
s->streams[
i]->id];
1608 int64_t itime, last_pos = -1;
1618 "itime:0x%"PRIx64
", pct:%d, ict:%d\n", itime, pct, ict);
1620 for (
i = 0;
i < ict;
i++) {
1623 int64_t
pos =
s->internal->data_offset +
s->packet_size * (int64_t)pktnum;
1631 if (
pos != last_pos) {
1633 pktnum, pktct, index_pts);
1653 AVStream *st =
s->streams[stream_index];
1656 if (
s->packet_size <= 0)
1671 avio_seek(
s->pb,
s->internal->data_offset, SEEK_SET);
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
const ff_asf_guid ff_asf_ext_stream_embed_stream_header
static const AVClass asf_class
const ff_asf_guid ff_asf_jfif_media
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_LOG_WARNING
Something somehow does not look correct.
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
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 name
AVBufferRef * av_buffer_alloc(int size)
Allocate an AVBuffer of the given size using av_malloc().
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
int ff_get_guid(AVIOContext *s, ff_asf_guid *g)
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
enum AVMediaType codec_type
General type of the encoded data.
uint64_t send_time
time to send file, in 100-nanosecond units invalid if broadcasting (could be ignored)
#define AVERROR_EOF
End of file.
uint8_t * data
The data buffer.
#define MKTAG(a, b, c, d)
static int asf_read_content_desc(AVFormatContext *s, int64_t size)
static void skip_to_key(AVFormatContext *s)
static int asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
Parse data from individual ASF packets (which were previously loaded with asf_get_packet()).
static av_cold int end(AVCodecContext *avctx)
uint32_t preroll
timestamp of the first packet, in milliseconds if nonzero - subtract from time
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
static int asf_build_simple_index(AVFormatContext *s, int stream_index)
int error
contains the error code or 0 if no error happened
void ff_id3v2_read(AVFormatContext *s, const char *magic, ID3v2ExtraMeta **extra_meta, unsigned int max_search_size)
Read an ID3v2 tag, including supported extra metadata.
const ff_asf_guid ff_asf_video_stream
const ff_asf_guid ff_asf_simple_index_header
#define AV_LOG_VERBOSE
Detailed information.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
const ff_asf_guid ff_asf_stream_header
const ff_asf_guid ff_asf_codec_comment_header
uint64_t data_offset
beginning of the first data packet
int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create chapters for all CHAP tags found in the ID3v2 header.
int64_t avio_size(AVIOContext *s)
Get the filesize.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
Load a single ASF packet into the demuxer.
static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
unsigned int packet_frag_size
uint32_t flags
0x01 - broadcast 0x02 - seekable rest is reserved should be 0
uint32_t stream_bitrates[128]
max number of streams, bitrate for each (for streaming)
ASFStream streams[128]
it's max number and it's not that big
int64_t avio_seek_time(AVIOContext *h, int stream_index, int64_t timestamp, int flags)
Seek to a given timestamp relative to some component stream.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, int size, int distance, int flags)
Add an index entry into a sorted list.
uint64_t data_object_size
size of the data object
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
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 type
static int asf_read_ext_content_desc(AVFormatContext *s, int64_t size)
int64_t duration
Decoding: duration of the stream, in stream time base.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
unsigned int avio_rl16(AVIOContext *s)
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
uint64_t create_time
time of creation, in 100-nanosecond units since 1.1.1601 invalid if broadcasting
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
#define AV_LOG_TRACE
Extremely verbose debugging, useful for libav* development.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int get_value(AVIOContext *pb, int type, int type2_size)
static int asf_read_close(AVFormatContext *s)
ASFStream * asf_st
currently decoded stream
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.
int64_t packet_frag_timestamp
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
const ff_asf_guid ff_asf_data_header
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
static void get_id3_tag(AVFormatContext *s, int len)
#define DO_2BITS(bits, var, defval)
static int asf_read_marker(AVFormatContext *s, int64_t size)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static int asf_probe(const AVProbeData *pd)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVStreamParseType need_parsing
unsigned int packet_frag_offset
static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
static int64_t fsize(FILE *f)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
@ AVDISCARD_ALL
discard all
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define LIBAVUTIL_VERSION_INT
static int read_header(FFV1Context *f)
Describe the class of an AVClass context structure.
ff_asf_guid guid
generated by client computer
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
const ff_asf_guid ff_asf_header
const AVMetadataConv ff_asf_metadata_conv[]
Rational number (pair of numerator and denominator).
const char * av_default_item_name(void *ptr)
Return the context name.
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header.
uint32_t ignore
preroll is 64 bits - but let's just ignore it
This structure contains the data a format has to probe a file.
char stream_languages[128][6]
max number of streams, language for each (RFC1766, e.g. en-US)
uint64_t play_time
play time, in 100-nanosecond units invalid if broadcasting
const char *const ff_id3v2_picture_types[21]
const ff_asf_guid ff_asf_head1_guid
const ff_asf_guid ff_asf_digital_signature
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
const CodecMime ff_id3v2_mime_tags[]
AVCodecID
Identify the syntax and semantics of the bitstream.
int extradata_size
Size of the extradata content in bytes.
static const AVOption options[]
unsigned int avio_rl32(AVIOContext *s)
@ AVDISCARD_NONKEY
discard all frames except keyframes
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
static int64_t start_time
static int asf_read_metadata(AVFormatContext *s, int64_t size)
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
#define AV_NOPTS_VALUE
Undefined timestamp value.
uint32_t min_pktsize
size of a data packet invalid if broadcasting
uint32_t max_pktsize
shall be the same as for min_pktsize invalid if broadcasting
#define FRAME_HEADER_SIZE
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int avio_r8(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
int flags
A combination of AV_PKT_FLAG values.
uint64_t data_object_offset
data object offset (excl. GUID & size)
#define AV_LOG_INFO
Standard information.
static int asf_read_picture(AVFormatContext *s, int len)
const ff_asf_guid ff_asf_command_stream
int ffio_limit(AVIOContext *s, int size)
const ff_asf_guid ff_asf_content_encryption
#define i(width, name, range_min, range_max)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
uint16_t stream_language_index
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
const ff_asf_guid ff_asf_ext_stream_header
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 value
#define AV_OPT_FLAG_DECODING_PARAM
a generic parameter which can be set by the user for demuxing or decoding
static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb)
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
const ff_asf_guid ff_asf_extended_content_header
int disposition
AV_DISPOSITION_* bit field.
int id
Format-specific stream ID.
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
Send a nice hexadecimal dump of a buffer to the log.
const ff_asf_guid ff_asf_audio_stream
const ff_asf_guid ff_asf_metadata_library_header
uint64_t file_size
in bytes invalid if broadcasting
static int asf_read_file_properties(AVFormatContext *s, int64_t size)
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
#define AV_INPUT_BUFFER_PADDING_SIZE
#define FF_ARRAY_ELEMS(a)
int asfid2avid[128]
conversion table from asf ID 2 AVStream ID
int index
stream index in AVFormatContext
const AVCodecTag ff_codec_bmp_tags[]
const ff_asf_guid ff_asf_comment_header
static int asf_read_language_list(AVFormatContext *s, int64_t size)
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
const ff_asf_guid ff_asf_language_guid
const ff_asf_guid ff_asf_ext_content_encryption
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
static void asf_reset_header(AVFormatContext *s)
int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
const ff_asf_guid ff_asf_file_header
const ff_asf_guid ff_asf_metadata_header
int bits_per_coded_sample
The number of bits per sample in the codedwords.
const ff_asf_guid ff_asf_head2_guid
A reference to a data buffer.
uint32_t max_bitrate
bandwidth of stream in bps should be the sum of bitrates of the individual media streams
#define avpriv_request_sample(...)
static void get_tag(AVFormatContext *s, const char *key, int type, int len, int type2_size)
static av_always_inline int diff(const uint32_t a, const uint32_t b)
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
This structure stores compressed data.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
int64_t pos
byte position in stream, -1 if unknown
uint64_t avio_rl64(AVIOContext *s)
const ff_asf_guid ff_asf_my_guid
#define flags(name, subs,...)
const ff_asf_guid ff_asf_marker_header
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size)
const ff_asf_guid ff_asf_video_conceal_none
const ff_asf_guid ff_asf_audio_conceal_none
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
const ff_asf_guid ff_asf_codec_comment1_header
static int asf_read_header(AVFormatContext *s)
const ff_asf_guid ff_asf_ext_stream_audio_stream
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
AVInputFormat ff_asf_demuxer
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.