128 .class_name =
"asf demuxer",
137#define ASF_MAX_STREAMS 127
138#define FRAME_HEADER_SIZE 6
144 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
150 0x00, 0x57, 0xfb, 0x20, 0x55, 0x5B, 0xCF, 0x11, 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
153#define PRINT_IF_GUID(g, cmp) \
154 if (!ff_guidcmp(g, &(cmp))) \
155 av_log(NULL, AV_LOG_TRACE, "(GUID: %s) ", # cmp)
164 else PRINT_IF_GUID(
g, asf_audio_conceal_none);
183 else PRINT_IF_GUID(
g, stream_bitrate_guid);
187 for (
i = 0;
i < 16;
i++)
193#define print_guid(g) while(0)
264 "Unsupported value type %d in tag %s.\n",
type,
key);
309 int type_specific_size, sizeX;
312 int test_for_ext_stream_audio, is_dvr_ms_audio = 0;
337 test_for_ext_stream_audio = 0;
348 test_for_ext_stream_audio = 1;
364 if (test_for_ext_stream_audio) {
383 if (is_dvr_ms_audio) {
395 if (
size >= (pos2 + 8 - pos1 + 24)) {
452 if (tag1 ==
MKTAG(
'D',
'V',
'R',
' ')) {
480 int ext_len, payload_ext_ct, stream_ct,
i;
481 uint32_t leak_rate, stream_num;
482 unsigned int stream_languageid_index;
497 if (stream_num < 128)
504 if (stream_num < 128) {
509 for (
i = 0;
i < stream_ct;
i++) {
515 for (
i = 0;
i < payload_ext_ct;
i++) {
538 int len1, len2, len3, len4, len5;
558 int desc_count,
i, ret;
561 for (
i = 0;
i < desc_count;
i++) {
562 int name_len, value_type, value_len;
572 if (!value_type && value_len % 2)
581 if (!strcmp(
name,
"AspectRatioX"))
583 else if (!strcmp(
name,
"AspectRatioY"))
598 for (j = 0; j < stream_count; j++) {
600 unsigned int lang_len =
avio_r8(pb);
602 sizeof(lang))) < lang_len)
616 int n, stream_num, name_len_utf16, name_len_utf8;
617 unsigned int value_len;
621 for (
i = 0;
i < n;
i++) {
631 if (value_len >= (INT_MAX -
LEN) / 2)
634 name_len_utf8 = 2*name_len_utf16 + 1;
642 i, stream_num, name_len_utf16, value_type, value_len,
name);
644 if (!strcmp(
name,
"AspectRatioX")){
647 asf->
dar[stream_num].
num = aspect_x;
648 }
else if(!strcmp(
name,
"AspectRatioY")){
651 asf->
dar[stream_num].
den = aspect_y;
665 int i, count, name_len, ret;
675 for (
i = 0;
i < count;
i++) {
688 if ((
unsigned)name_len > INT_MAX / 2)
691 sizeof(
name))) < name_len)
717 for (
i = 0;
i<128;
i++)
730 if (!(asf->
hdr.
flags & 0x01) && gsize >= 100)
772 "DRM protected stream detected, decoding will likely fail!\n");
782 if (
len > UINT16_MAX)
787 if (
len > UINT16_MAX)
792 if (
len > UINT16_MAX)
797 "Ext DRM protected stream detected, decoding will likely fail!\n");
798 av_dict_set(&
s->metadata,
"encryption",
"ASF Extended Content Encryption", 0);
809 "gpos mismatch our pos=%"PRIu64
", end=%"PRId64
"\n",
822 for (
i = 0;
i < 128;
i++) {
824 if (stream_num >= 0) {
832 }
else if ((asf->
dar[0].
num > 0) && (asf->
dar[0].
den > 0) &&
846 if (rfc1766 && strlen(rfc1766) > 1) {
847 const char primary_tag[3] = { rfc1766[0], rfc1766[1],
'\0' };
862#define DO_2BITS(bits, var, defval) \
863 switch (bits & 3) { \
865 var = avio_rl32(pb); \
869 var = avio_rl16(pb); \
890 uint32_t packet_length, padsize;
907 if (
c == 0x82 && !d && !e)
920 "ff asf bad header %x at:%"PRId64
"\n",
c,
avio_tell(pb));
922 if ((
c & 0x8f) == 0x82) {
965 if (!packet_length || packet_length >= (1U << 29)) {
967 "invalid packet_length %"PRIu32
" at:%"PRId64
"\n",
971 if (padsize >= packet_length) {
973 "invalid padsize %"PRIu32
" at:%"PRId64
"\n", padsize,
avio_tell(pb));
989 if (rsize > packet_length - padsize) {
992 "invalid packet header length %d for pktlen %"PRIu32
"-%"PRIu32
" at %"PRId64
"\n",
993 rsize, packet_length, padsize,
avio_tell(pb));
997 if (packet_length < asf->hdr.min_pktsize)
1021 asfst = &asf->
streams[num & 0x7f];
1026 av_log(asf,
AV_LOG_TRACE,
"key:%d stream:%d seq:%d offset:%d replic_size:%d num:%X packet_property %X\n",
1063 s->streams[asf->
stream_index]->sample_aspect_ratio = aspect;
1190 "stream:%d, expected:%d but got %d from pkt)\n",
1221 "freeing incomplete packet size %d, new %d\n",
1251 av_log(asf,
AV_LOG_TRACE,
"new packet: stream:%d key:%d packet_key:%d audio:%d size:%d\n",
1273 "packet fragment position invalid %u,%u not in %u\n",
1302 if (
s->key &&
s->keylen == 20)
1326 "pkt.size != ds_packet_size * ds_span (%d %d %d)\n",
1334 uint8_t *newdata = buf->
data;
1336 memset(newdata + asf_st->
pkt.
size, 0,
1340 int row = off / asf_st->
ds_span;
1341 int col = off % asf_st->
ds_span;
1412 for (
i = 0;
i < 128;
i++) {
1427 for (
i = 0;
i < 128;
i++) {
1456 for (
i = 0;
i <
s->nb_streams;
i++)
1459 if (
s->packet_size > 0)
1461 s->packet_size *
s->packet_size +
1478 i =
pkt->stream_index;
1480 asf_st = &asf->
streams[
s->streams[
i]->id];
1490 if (
pkt->stream_index == stream_index) {
1539 "itime:0x%"PRIx64
", pct:%d, ict:%d\n", itime, pct, ict);
1541 for (
i = 0;
i < ict;
i++) {
1552 if (
pos != last_pos) {
1554 pktnum, pktct, index_pts);
1574 AVStream *st =
s->streams[stream_index];
1578 if (
s->packet_size <= 0)
const AVMetadataConv ff_asf_metadata_conv[]
int ff_asf_handle_byte_array(AVFormatContext *s, const char *name, int val_len)
Handles both attached pictures as well as id3 tags.
const ff_asf_guid ff_asf_video_conceal_none
const ff_asf_guid ff_asf_codec_comment1_header
const ff_asf_guid ff_asf_video_stream
const ff_asf_guid ff_asf_ext_stream_header
const ff_asf_guid ff_asf_stream_header
const ff_asf_guid ff_asf_command_stream
const ff_asf_guid ff_asf_ext_stream_audio_stream
const ff_asf_guid ff_asf_language_guid
const ff_asf_guid ff_asf_header
const ff_asf_guid ff_asf_audio_stream
const ff_asf_guid ff_asf_simple_index_header
const ff_asf_guid ff_asf_ext_stream_embed_stream_header
const ff_asf_guid ff_asf_content_encryption
const ff_asf_guid ff_asf_extended_content_header
const ff_asf_guid ff_asf_head1_guid
const ff_asf_guid ff_asf_head2_guid
const ff_asf_guid ff_asf_marker_header
const ff_asf_guid ff_asf_metadata_library_header
static int64_t ff_asf_filetime_to_avtime(int64_t filetime)
const ff_asf_guid ff_asf_data_header
const ff_asf_guid ff_asf_jfif_media
const ff_asf_guid ff_asf_digital_signature
const ff_asf_guid ff_asf_ext_content_encryption
const ff_asf_guid ff_asf_codec_comment_header
const ff_asf_guid ff_asf_my_guid
const ff_asf_guid ff_asf_file_header
const ff_asf_guid ff_asf_comment_header
const ff_asf_guid ff_asf_metadata_header
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb)
static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
static int asf_read_marker(AVFormatContext *s)
static void asf_reset_header(AVFormatContext *s)
static int asf_read_header(AVFormatContext *s)
static int asf_read_file_properties(AVFormatContext *s)
static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
static const AVClass asf_class
#define DO_2BITS(bits, var, defval)
static int asf_build_simple_index(AVFormatContext *s, int stream_index)
static int asf_read_content_desc(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 void skip_to_key(AVFormatContext *s)
static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
Load a single ASF packet into the demuxer.
static int asf_probe(const AVProbeData *pd)
static void get_tag(AVFormatContext *s, const char *key, int type, int len)
static uint64_t get_value(AVIOContext *pb, int type)
static int asf_read_ext_stream_properties(AVFormatContext *s)
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
static int asf_read_language_list(AVFormatContext *s)
static int asf_read_close(AVFormatContext *s)
static int asf_read_ext_content_desc(AVFormatContext *s)
static int asf_read_metadata(AVFormatContext *s)
static int64_t fsize(FILE *f)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#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.
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)
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.
int avio_r8(AVIOContext *s)
uint64_t avio_rl64(AVIOContext *s)
int ffio_read_size(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
int ffio_limit(AVIOContext *s, int size)
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
const char * ff_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
static uint32_t BS_FUNC read(BSCTX *bc, unsigned int n)
Return n bits from the buffer, n has to be in the 0-32 range.
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static int read_probe(const AVProbeData *p)
common internal and external API header
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define FRAME_HEADER_SIZE
AVChapter * avpriv_new_chapter(AVFormatContext *s, int64_t id, AVRational time_base, int64_t start, int64_t end, const char *title)
Add a new chapter.
int ff_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags)
Perform a binary search using av_index_search_timestamp() and FFInputFormat.read_timestamp().
void ff_read_frame_flush(AVFormatContext *s)
Flush the frame reader.
static int64_t start_time
static int read_header(FFV1Context *f, RangeCoder *c)
#define AV_OPT_FLAG_DECODING_PARAM
A generic parameter which can be set by the user for demuxing or decoding.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AVDISCARD_ALL
discard all
@ AVDISCARD_NONKEY
discard all frames except keyframes
@ AV_PKT_DATA_PALETTE
An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE bytes worth of palette.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, size_t size)
Allocate new information of a packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
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.
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.
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
AVBufferRef * av_buffer_alloc(size_t size)
Allocate an AVBuffer of the given size using av_malloc().
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_TRACE
Extremely verbose debugging, useful for libav* development.
#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_VERBOSE
Detailed information.
#define AV_LOG_INFO
Standard information.
#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_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
@ AVMEDIA_TYPE_DATA
Opaque data information usually continuous.
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
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.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define LIBAVUTIL_VERSION_INT
Macro definitions for various function/variable attributes.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
#define MKTAG(a, b, c, d)
Memory handling functions.
const AVCodecTag ff_codec_bmp_tags_unofficial[]
const AVCodecTag ff_codec_bmp_tags[]
internal header for RIFF based (de)muxers do NOT include this in end user applications
static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
int ff_get_guid(AVIOContext *s, ff_asf_guid *g)
int ff_get_wav_header(AVFormatContext *s, AVIOContext *pb, AVCodecParameters *par, int size, int big_endian)
static int64_t read_timestamp(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit, int64_t(*read_timestamp)(struct AVFormatContext *, int, int64_t *, int64_t))
#define FF_ARRAY_ELEMS(a)
char stream_languages[128][6]
max number of streams, language for each (RFC1766, e.g. en-US)
unsigned int packet_frag_size
ASFStream * asf_st
currently decoded stream
ASFStream streams[128]
it's max number and it's not that big
int64_t packet_frag_timestamp
uint64_t data_offset
beginning of the first data packet
uint64_t data_object_offset
data object offset (excl. GUID & size)
int asfid2avid[128]
conversion table from asf ID 2 AVStream ID
int64_t packet_time_start
uint32_t stream_bitrates[128]
max number of streams, bitrate for each (for streaming)
unsigned int packet_frag_offset
uint64_t data_object_size
size of the data object
uint64_t create_time
time of creation, in 100-nanosecond units since 1.1.1601 invalid if broadcasting
uint32_t min_pktsize
size of a data packet invalid if broadcasting
uint32_t ignore
preroll is 64 bits - but let's just ignore it
ff_asf_guid guid
generated by client computer
uint32_t max_pktsize
shall be the same as for min_pktsize invalid if broadcasting
uint64_t send_time
time to send file, in 100-nanosecond units invalid if broadcasting (could be ignored)
uint32_t max_bitrate
bandwidth of stream in bps should be the sum of bitrates of the individual media streams
uint32_t flags
0x01 - broadcast 0x02 - seekable rest is reserved should be 0
uint64_t file_size
in bytes invalid if broadcasting
uint64_t play_time
play time, in 100-nanosecond units invalid if broadcasting
uint32_t preroll
timestamp of the first packet, in milliseconds if nonzero - subtract from time
uint16_t stream_language_index
A reference to a data buffer.
uint8_t * data
The data buffer.
Describe the class of an AVClass context structure.
int extradata_size
Size of the extradata content in bytes.
int height
The height of the video frame in pixels.
int bits_per_coded_sample
The number of bits per sample in the codedwords.
int width
The width of the video frame in pixels.
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.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
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 error
contains the error code or 0 if no error happened
This structure stores compressed data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int flags
A combination of AV_PKT_FLAG values.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
int64_t pos
byte position in stream, -1 if unknown
AVPacketSideData * side_data
Additional packet data that can be provided by the container.
This structure contains the data a format has to probe a file.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Rational number (pair of numerator and denominator).
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int64_t duration
Decoding: duration of the stream, in stream time base.
int id
Format-specific stream ID.
int64_t data_offset
offset of the first packet
AVPacket * parse_pkt
The generic code uses this as a temporary packet to parse packets or for muxing, especially flushing.
int request_probe
stream probing state -1 -> probing finished 0 -> no probing requested rest -> perform probing with re...
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
enum AVStreamParseType need_parsing
#define avpriv_request_sample(...)
static av_always_inline int diff(const struct color_info *a, const struct color_info *b, const int trans_thresh)