bit_rate in mpeg1/2 should be 0x3FFFF for vbr or at least >= max_bitrate

Originally committed as revision 2180 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2003-08-29 19:42:23 +00:00
parent 904736b519
commit 12dccd4e60
3 changed files with 20 additions and 13 deletions

View File

@ -227,18 +227,25 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
put_bits(&s->pb, 4, s->aspect_ratio_info);
put_bits(&s->pb, 4, s->frame_rate_index);
v = (s->bit_rate + 399) / 400;
if (v > 0x3ffff && s->codec_id == CODEC_ID_MPEG1VIDEO)
v = 0x3ffff;
put_bits(&s->pb, 18, v & 0x3FFFF);
put_bits(&s->pb, 1, 1); /* marker */
if(s->avctx->rc_max_rate){
v = (s->avctx->rc_max_rate + 399) / 400;
if (v > 0x3ffff && s->codec_id == CODEC_ID_MPEG1VIDEO)
v = 0x3ffff;
}else{
v= 0x3FFFF;
}
if(s->avctx->rc_buffer_size)
vbv_buffer_size = s->avctx->rc_buffer_size;
else
/* VBV calculation: Scaled so that a VCD has the proper VBV size of 40 kilobytes */
vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
put_bits(&s->pb, 10, ((vbv_buffer_size + 16383) / 16384) & 0x3FF);
vbv_buffer_size = (( 20 * s->bit_rate) / (1151929 / 2)) * 8 * 1024;
vbv_buffer_size= (vbv_buffer_size + 16383) / 16384;
put_bits(&s->pb, 18, v & 0x3FFFF);
put_bits(&s->pb, 1, 1); /* marker */
put_bits(&s->pb, 10, vbv_buffer_size & 0x3FF);
put_bits(&s->pb, 1, 1); /* constrained parameter flag */
ff_write_quant_matrix(&s->pb, s->avctx->intra_matrix);

View File

@ -1,8 +1,8 @@
ffmpeg regression test
dda0ba041aef50a5101884291c06d4d9 *./data/a-mpeg1.mpg
6787ecce1da78d5e0cdeb35931f3212c *./data/a-mpeg1.mpg
6713259d72260740bbddaea30631ea18 *./data/out.yuv
stddev: 7.58 bytes:7299072
17c66261cb5dc193793b5af9564c8592 *./data/a-mpeg2.vob
40b1ce56144067f5c8d4df422705ae6a *./data/a-mpeg2.vob
9f5d85c6473b802a9d86cfc01a3ed046 *./data/out.yuv
stddev: 7.66 bytes:7450624
d0dc46dd831398237a690ebbeff18b64 *./data/a-msmpeg4v2.avi
@ -35,7 +35,7 @@ stddev: 10.53 bytes:7145472
2cbab98ebef5fbd229c66fb6435bf9a2 *./data/a-mpeg4-adv.avi
b54262af56f6681186fa2c44e4ef6ec7 *./data/out.yuv
stddev: 7.32 bytes:7602176
a38cb11e3035a280f3dad3ccdff5997b *./data/a-mpeg1b.mpg
5515306aa3c69112ee627023856bd696 *./data/a-mpeg1b.mpg
bd047a4567c366566da96874d176199d *./data/out.yuv
stddev: 6.35 bytes:6993920
07042f42b3119c39eb26537a84a451df *./data/a-mjpeg.avi

View File

@ -1,8 +1,8 @@
ffmpeg regression test
1738d12380be0d8aa20d08e178349299 *./data/a-mpeg1.mpg
6dce999b1f02a94dfd6d6222caf06ff1 *./data/a-mpeg1.mpg
0cf790edd0f4c5cf993c2d59211b9de2 *./data/out.yuv
stddev: 4.91 bytes:7299072
55cedcf0fb67e18718d6ed88da7784a4 *./data/a-mpeg2.vob
bbb41fb21c836cff975442e583702216 *./data/a-mpeg2.vob
f5436b327c38b66eb95f3428aff790f1 *./data/out.yuv
stddev: 4.94 bytes:7450624
14db391f167b52b21a983157b410affc *./data/a-msmpeg4v2.avi
@ -35,7 +35,7 @@ stddev: 4.32 bytes:7145472
aeb300900461bdf9e0321934aa6dcc93 *./data/a-mpeg4-adv.avi
e465df12f2c8a6492a6ec0b1bddc1d0d *./data/out.yuv
stddev: 4.97 bytes:7602176
a7ab3fba8d7cd004b4809b5fe04e37d0 *./data/a-mpeg1b.mpg
fc873784878d9588e748c1494df606be *./data/a-mpeg1b.mpg
c9b8f923d91d6a574b0673e05fd2d6bd *./data/out.yuv
stddev: 4.61 bytes:6993920
e9218a1db885fe0262e88f9df630307d *./data/a-mjpeg.avi