Index: libmpdemux/demux_asf.c =================================================================== --- libmpdemux/demux_asf.c (版本 22434) +++ libmpdemux/demux_asf.c (工作副本) @@ -571,7 +571,6 @@ } else { sh_video=demuxer->video->sh;sh_video->ds=demuxer->video; //sh_video->fps=1000.0f; sh_video->frametime=0.001f; // 1ms - now set when reading asf header - //sh_video->i_bps=10*asf->packetsize; // FIXME! if (asf->asf_is_dvr_ms) { sh_video->bih->biWidth = 0; Index: libmpdemux/asfheader.c =================================================================== --- libmpdemux/asfheader.c (版本 23259) +++ libmpdemux/asfheader.c (工作副本) @@ -70,6 +70,8 @@ 0xdb, 0x06, 0xfa, 0x4c, 0x80, 0x1c, 0x72, 0x12, 0xd3, 0x87, 0x45, 0xe4}; const char asf_dvr_ms_vid_frame_rep_data[16] = {0xcc, 0x32, 0x64, 0xdd, 0x29, 0xe2, 0xdb, 0x40, 0x80, 0xf6, 0xd2, 0x63, 0x28, 0xd2, 0x76, 0x1f}; +const char asf_stream_bitrate[16] = {0xce, 0x75, 0xf8, 0x7b, + 0x8d, 0x46, 0xd1, 0x11, 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}; typedef struct { // must be 0 for metadata record, might be non-zero for metadata lib record @@ -198,6 +200,7 @@ int pos=0; uint8_t *buffer = &buf[0]; uint64_t avg_ft; + unsigned bitrate; while ((pos = find_asf_guid(buf, asf_ext_stream_header, pos, buf_len)) >= 0) { int this_stream_num, stnamect, payct, i, objlen; @@ -213,7 +216,9 @@ // max-object-size(4), // flags(4) (reliable,seekable,no_cleanpoints?,resend-live-cleanpoints, rest of bits reserved) - buffer +=8+8+4+4+4+4+4+4+4+4; + buffer += 8+8; + bitrate = AV_RL32(buffer); + buffer += 8*4; this_stream_num=AV_RL16(buffer);buffer+=2; if (this_stream_num == stream_num) { @@ -222,6 +227,7 @@ buffer+=2; //skip stream-language-id-index avg_ft = AV_RL32(buffer) | (uint64_t)AV_RL32(buffer + 4) << 32; // provided in 100ns units buffer+=8; + asf->bps = bitrate / 8; // after this are values for stream-name-count and // payload-extension-system-count @@ -393,6 +399,30 @@ return 1; } +static unsigned get_bitrate(char *buf, int buf_len, int this_stream_num) +{ + int pos = find_asf_guid(buf, asf_stream_bitrate, 0, buf_len); + unsigned count, i; + + if (pos < 0) + return 0; + + buf += pos; + count = AV_RL16(buf); + buf += 2; + + for (i = 0; i < count; i++) { + unsigned bitrate, flags = AV_RL16(buf); + buf += 2; + bitrate = AV_RL32(buf); + buf += 4; + if (flags == this_stream_num) { + return bitrate / 8; + } + } + return 0; +} + static int asf_init_audio_stream(demuxer_t *demuxer,struct asf_priv* asf, sh_audio_t* sh_audio, ASF_stream_header_t *streamh, int *ppos, uint8_t** buf, char *hdr, unsigned int hdr_len) { uint8_t *buffer = *buf; @@ -556,6 +586,9 @@ sh_video->aspect = asp_ratio * sh_video->bih->biWidth / sh_video->bih->biHeight; } + if (asf->bps == 0) + asf->bps = get_bitrate(hdr, hdr_len, streamh->stream_no); + sh_video->i_bps = asf->bps; if( mp_msg_test(MSGT_DEMUX,MSGL_V) ) print_video_header(sh_video->bih, MSGL_V); //asf_video_id=streamh.stream_no & 0x7F; Index: libmpdemux/asf.h =================================================================== --- libmpdemux/asf.h (版本 23259) +++ libmpdemux/asf.h (工作副本) @@ -241,6 +241,7 @@ int aud_ext_timing_index; int vid_ext_frame_index; int know_frame_time; + unsigned bps; }; #endif