41 uint32_t stream_bitrates[128];
43 char stream_languages[128][6];
81 #define ASF_MAX_STREAMS 127
82 #define FRAME_HEADER_SIZE 17
86 0x90, 0x08, 0x00, 0x33, 0xb1, 0xe5, 0xcf, 0x11, 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb
91 0xce, 0x75, 0xf8, 0x7b, 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
94 #define PRINT_IF_GUID(g,cmp) \
95 if (!ff_guidcmp(g, &cmp)) \
96 av_dlog(NULL, "(GUID: %s) ", #cmp)
123 else PRINT_IF_GUID(g, stream_bitrate_guid);
133 #define print_guid(g)
138 assert(
sizeof(*g) == 16);
157 default:
return INT_MIN;
166 if ((
unsigned)len >= (UINT_MAX - 1)/2)
175 }
else if (type > 1 && type <= 5) {
177 snprintf(value, len,
"%"PRIu64, num);
221 int type_specific_size, sizeX;
224 int test_for_ext_stream_audio, is_dvr_ms_audio=0;
248 (10000000 / 1000) - start_time;
252 test_for_ext_stream_audio = 0;
263 test_for_ext_stream_audio = 1;
278 if (test_for_ext_stream_audio) {
297 if (is_dvr_ms_audio) {
310 if (size >= (pos2 + 8 - pos1 + 24)) {
346 size - (
avio_tell(pb) - pos1 + 24) >= 51) {
383 if(tag1 ==
MKTAG(
'D',
'V',
'R',
' ')){
395 avio_skip(pb, size - (pos2 - pos1 + 24));
405 int ext_len, payload_ext_ct, stream_ct, i;
406 uint32_t leak_rate, stream_num;
407 unsigned int stream_languageid_index;
422 if (stream_num < 128)
429 if (stream_num < 128)
432 for (i=0; i<stream_ct; i++){
438 for (i=0; i<payload_ext_ct; i++){
451 int len1, len2, len3, len4, len5;
459 get_tag(s,
"author" , 0, len2);
460 get_tag(s,
"copyright", 0, len3);
461 get_tag(s,
"comment" , 0, len4);
471 int desc_count, i, ret;
474 for(i=0;i<desc_count;i++) {
475 int name_len,value_type,value_len;
485 if (!value_type && value_len%2)
491 if (!strcmp(name,
"AspectRatioX")){
493 }
else if(!strcmp(name,
"AspectRatioY")){
496 get_tag(s, name, value_type, value_len);
508 for(j = 0; j < stream_count; j++) {
510 unsigned int lang_len =
avio_r8(pb);
524 int n, stream_num, name_len, value_len, value_num;
544 if (!strcmp(name,
"AspectRatioX")) asf->
dar[stream_num].
num= value_num;
545 else if(!strcmp(name,
"AspectRatioY")) asf->
dar[stream_num].
den= value_num;
555 int i, count, name_len, ret;
563 for(i=0;i<name_len;i++){
567 for(i=0;i<count;i++){
577 if ((ret =
avio_get_str16le(pb, name_len * 2, name,
sizeof(name))) < name_len)
605 av_dlog(s,
"%08"PRIx64
": ", gpos);
607 av_dlog(s,
" size=0x%"PRIx64
"\n", gsize);
611 if (!(asf->
hdr.
flags & 0x01) && gsize >= 100) {
675 for(i=0; i<128; i++){
695 if (rfc1766 && strlen(rfc1766) > 1) {
696 const char primary_tag[3] = { rfc1766[0], rfc1766[1],
'\0' };
710 #define DO_2BITS(bits, var, defval) \
713 case 3: var = avio_rl32(pb); rsize += 4; break; \
714 case 2: var = avio_rl16(pb); rsize += 2; break; \
715 case 1: var = avio_r8(pb); rsize++; break; \
716 default: var = defval; break; \
728 uint32_t packet_length, padsize;
741 if(c == 0x82 && !d && !e)
757 if ((c & 0x8f) == 0x82) {
778 if(!packet_length || packet_length >= (1
U<<29)){
782 if(padsize >= packet_length){
798 if (rsize > packet_length - padsize) {
801 "invalid packet header length %d for pktlen %d-%d at %"PRId64
"\n",
802 rsize, packet_length, padsize,
avio_tell(pb));
806 if (packet_length < asf->hdr.min_pktsize)
1031 if (ret < 0 || asf->packet_frag_offset + ret == 0)
1073 while (offset < asf_st->pkt.
size) {
1075 int row = off / asf_st->
ds_span;
1076 int col = off % asf_st->
ds_span;
1082 memcpy(newdata + offset,
1230 if (gsize < 24 || s->pb->eof_reached) {
1239 int64_t itime, last_pos=-1;
1248 for (i=0;i<ict;i++){
1254 if(pos != last_pos){
1255 av_log(s,
AV_LOG_DEBUG,
"pktnum:%d, pktct:%d pts: %"PRId64
"\n", pktnum, pktct, index_pts);
#define FRAME_HEADER_SIZE
const ff_asf_guid ff_asf_header
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int asf_read_marker(AVFormatContext *s, int64_t size)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
const ff_asf_guid ff_asf_ext_stream_audio_stream
const ff_asf_guid ff_asf_ext_content_encryption
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.
const ff_asf_guid ff_asf_codec_comment_header
const ff_asf_guid ff_asf_metadata_header
AVInputFormat ff_asf_demuxer
int64_t pos
byte position in stream, -1 if unknown
static int asf_read_ext_stream_properties(AVFormatContext *s, int64_t size)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
uint64_t data_offset
beginning of the first data packet
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
static int asf_read_metadata(AVFormatContext *s, int64_t size)
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
AVIndexEntry * index_entries
Only used if the format does not support seeking natively.
int64_t packet_frag_timestamp
const ff_asf_guid ff_asf_command_stream
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
const ff_asf_guid ff_asf_ext_stream_header
int64_t data_offset
offset of the first packet
uint32_t min_pktsize
size of a data packet invalid if broadcasting
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 int asf_read_file_properties(AVFormatContext *s, int64_t size)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
const ff_asf_guid ff_asf_data_header
uint32_t flags
0x01 - broadcast 0x02 - seekable rest is reserved should be 0
Opaque data information usually continuous.
const ff_asf_guid ff_asf_audio_stream
enum AVStreamParseType need_parsing
int id
format-specific stream ID
ASFStream streams[128]
it's max number and it's not that big
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
static int read_header(FFV1Context *f)
#define DO_2BITS(bits, var, defval)
ASFStream * asf_st
currently decoded stream
uint64_t send_time
time to send file, in 100-nanosecond units invalid if broadcasting (could be ignored) ...
void av_free_packet(AVPacket *pkt)
Free a packet.
#define AVERROR_EOF
End of file.
static av_cold int read_close(AVFormatContext *ctx)
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int bits_per_coded_sample
bits per sample/pixel from the demuxer (needed for huffyuv).
enum CodecID ff_codec_get_id(const AVCodecTag *tags, unsigned int tag)
int asfid2avid[128]
conversion table from asf ID 2 AVStream ID
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
uint64_t file_size
in bytes invalid if broadcasting
ff_asf_guid guid
generated by client computer
preferred ID for MPEG-1/2 video decoding
const ff_asf_guid ff_asf_audio_conceal_none
static int64_t start_time
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
const ff_asf_guid ff_asf_head1_guid
static int get_value(AVIOContext *pb, int type)
int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags)
Get the index for a specific timestamp.
void ff_get_guid(AVIOContext *s, ff_asf_guid *g)
const ff_asf_guid ff_asf_head2_guid
unsigned int avio_rl32(AVIOContext *s)
int ff_get_wav_header(AVIOContext *pb, AVCodecContext *codec, int size)
const char * av_convert_lang_to(const char *lang, enum AVLangCodespace target_codespace)
Convert a language code to a target codespace.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
void ff_asfcrypt_dec(const uint8_t key[20], uint8_t *data, int len)
const ff_asf_guid ff_asf_video_conceal_none
void av_log(void *avcl, int level, const char *fmt,...)
AVStream * avformat_new_stream(AVFormatContext *s, AVCodec *c)
Add a new stream to a media file.
uint64_t data_object_size
size of the data object
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.
int flags
A combination of AV_PKT_FLAG values.
int avio_r8(AVIOContext *s)
AVCodecContext * codec
codec context
uint32_t max_pktsize
shall be the same as for min_pktsize invalid if broadcasting
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
unsigned int nb_streams
A list of all streams in the file.
int bit_rate
the average bitrate
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_digital_signature
const AVCodecTag ff_codec_bmp_tags[]
char stream_languages[128][6]
max number of streams, language for each (RFC1766, e.g. en-US)
int width
picture width / height.
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
const ff_asf_guid ff_asf_extended_content_header
static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
Skip given number of bytes forward.
unsigned int packet_frag_size
internal header for RIFF based (de)muxers do NOT include this in end user applications ...
static int read_probe(AVProbeData *p)
const ff_asf_guid ff_asf_ext_stream_embed_stream_header
const ff_asf_guid ff_asf_my_guid
Usually treated as AVMEDIA_TYPE_DATA.
static int asf_probe(AVProbeData *pd)
#define av_dlog(pctx,...)
av_dlog macros Useful to print debug messages that shouldn't get compiled in normally.
static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it ...
int frame_size
Samples per packet, initialized when calling 'init'.
static int ff_asf_parse_packet(AVFormatContext *s, AVIOContext *pb, AVPacket *pkt)
Parse data from individual ASF packets (which were previously loaded with asf_get_packet()).
uint32_t ignore
preroll is 64bit - but let's just ignore it
uint32_t stream_bitrates[128]
max number of streams, bitrate for each (for streaming)
uint64_t create_time
time of creation, in 100-nanosecond units since 1.1.1601 invalid if broadcasting
enum AVMediaType codec_type
const ff_asf_guid ff_asf_file_header
uint64_t play_time
play time, in 100-nanosecond units invalid if broadcasting
static void get_tag(AVFormatContext *s, const char *key, int type, int len)
static int64_t asf_read_pts(AVFormatContext *s, int stream_index, int64_t *ppos, int64_t pos_limit)
const ff_asf_guid ff_asf_video_stream
static int asf_read_seek(AVFormatContext *s, int stream_index, int64_t pts, int flags)
static int ff_asf_get_packet(AVFormatContext *s, AVIOContext *pb)
Load a single ASF packet into the demuxer.
uint16_t stream_language_index
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
unsigned int codec_tag
fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A').
static int read_packet(AVFormatContext *ctx, AVPacket *pkt)
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 * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
rational number numerator/denominator
const ff_asf_guid ff_asf_stream_header
unsigned int packet_frag_offset
static void asf_build_simple_index(AVFormatContext *s, int stream_index)
static int asf_read_close(AVFormatContext *s)
const AVMetadataConv ff_asf_metadata_conv[]
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
uint64_t data_object_offset
data object offset (excl. GUID & size)
int error
contains the error code or 0 if no error happened
This structure contains the data a format has to probe a file.
static int asf_read_ext_content_desc(AVFormatContext *s, int64_t size)
static int asf_read_frame_header(AVFormatContext *s, AVIOContext *pb)
static int asf_read_content_desc(AVFormatContext *s, int64_t size)
const ff_asf_guid ff_asf_comment_header
struct AVPacket::@10 * side_data
Additional packet data that can be provided by the container.
int64_t duration
Decoding: duration of the stream, in stream time base.
uint32_t preroll
timestamp of the first packet, in milliseconds if nonzero - subtract from time
const ff_asf_guid ff_asf_language_guid
unsigned int avio_rl16(AVIOContext *s)
const ff_asf_guid ff_asf_jfif_media
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
common internal and external API header
static const ff_asf_guid index_guid
int64_t start_time
Decoding: pts of the first frame of the stream, in stream time base.
mpeg audio declarations for both encoder and decoder.
const ff_asf_guid ff_asf_codec_comment1_header
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.
const ff_asf_guid ff_asf_content_encryption
int eof_reached
true if eof reached
void * priv_data
Format private data.
static int asf_read_language_list(AVFormatContext *s, int64_t size)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
static int asf_read_header(AVFormatContext *s, AVFormatParameters *ap)
const ff_asf_guid ff_asf_marker_header
discard all frames except keyframes
#define MKTAG(a, b, c, d)
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
static void asf_reset_header(AVFormatContext *s)
uint64_t avio_rl64(AVIOContext *s)
uint32_t max_bitrate
bandwidth of stream in bps should be the sum of bitrates of the individual media streams ...
static av_always_inline int ff_guidcmp(const void *g1, const void *g2)
static int asf_read_packet(AVFormatContext *s, AVPacket *pkt)
#define AV_NOPTS_VALUE
Undefined timestamp value.
preferred ID for decoding MPEG audio layer 1, 2 or 3