# HG changeset patch # User benoit # Date 1177948571 0 # Node ID ebc45cc020b70758a4e82e75af79acb8a5e11579 # Parent 0682a125d2864334db2571394c9be23fec1aafc7 use asf stream information to set bitrate patch by Zuxy Meng zuxy dot meng chez gmail tod com reference thread: [Ffmpeg-devel] Third Try: Set bit_rate for asf format diff -r 0682a125d286 -r ebc45cc020b7 asf.c --- a/asf.c Mon Apr 30 09:46:11 2007 +0000 +++ b/asf.c Mon Apr 30 15:56:11 2007 +0000 @@ -145,8 +145,10 @@ int size, i; int64_t gsize; AVRational dar[128]; + uint32_t bitrate[128]; memset(dar, 0, sizeof(dar)); + memset(bitrate, 0, sizeof(bitrate)); get_guid(pb, &g); if (memcmp(&g, &asf_header, sizeof(GUID))) @@ -421,13 +423,13 @@ } } else if (!memcmp(&g, &ext_stream_header, sizeof(GUID))) { int ext_len, payload_ext_ct, stream_ct; - uint32_t ext_d; + uint32_t ext_d, leak_rate, stream_num; int64_t pos_ex_st; pos_ex_st = url_ftell(pb); get_le64(pb); // starttime get_le64(pb); // endtime - get_le32(pb); // leak-datarate + leak_rate = get_le32(pb); // leak-datarate get_le32(pb); // bucket-datasize get_le32(pb); // init-bucket-fullness get_le32(pb); // alt-leak-datarate @@ -435,12 +437,15 @@ get_le32(pb); // alt-init-bucket-fullness get_le32(pb); // max-object-size get_le32(pb); // flags (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved) - get_le16(pb); // stream-num + stream_num = get_le16(pb); // stream-num get_le16(pb); // stream-language-id-index get_le64(pb); // avg frametime in 100ns units stream_ct = get_le16(pb); //stream-name-count payload_ext_ct = get_le16(pb); //payload-extension-system-count + if (stream_num < 128) + bitrate[stream_num] = leak_rate; + for (i=0; iasfid2avid[i]; - if(stream_num>=0 && dar[i].num>0 && dar[i].den>0){ + if(stream_num>=0){ AVCodecContext *codec= s->streams[stream_num]->codec; + if (!codec->bit_rate) + codec->bit_rate = bitrate[i]; + if (dar[i].num > 0 && dar[i].den > 0) av_reduce(&codec->sample_aspect_ratio.num, &codec->sample_aspect_ratio.den, dar[i].num, dar[i].den, INT_MAX);