some PSNR/bitrate gain if adaptive quant is used initalize qscale_table correctly (it was pretty much random since the qp->lambda change) this probably has not much effect as the table isnt used currently IIRC Originally committed as revision 7342 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
| @@ -486,6 +486,20 @@ static inline void restore_ac_coeffs(MpegEncContext * s, DCTELEM block[6][64], i | |||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * init s->current_picture.qscale_table from s->lambda_table | |||||
| */ | |||||
| static void ff_init_qscale_tab(MpegEncContext *s){ | |||||
| int8_t * const qscale_table= s->current_picture.qscale_table; | |||||
| int i; | |||||
| for(i=0; i<s->mb_num; i++){ | |||||
| unsigned int lam= s->lambda_table[ s->mb_index2xy[i] ]; | |||||
| int qp= (lam*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7); | |||||
| qscale_table[ s->mb_index2xy[i] ]= clip(qp, s->avctx->qmin, s->avctx->qmax); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * modify qscale so that encoding is acually possible in h263 (limit difference to -2..2) | * modify qscale so that encoding is acually possible in h263 (limit difference to -2..2) | ||||
| */ | */ | ||||
| @@ -493,6 +507,8 @@ void ff_clean_h263_qscales(MpegEncContext *s){ | |||||
| int i; | int i; | ||||
| int8_t * const qscale_table= s->current_picture.qscale_table; | int8_t * const qscale_table= s->current_picture.qscale_table; | ||||
| ff_init_qscale_tab(s); | |||||
| for(i=1; i<s->mb_num; i++){ | for(i=1; i<s->mb_num; i++){ | ||||
| if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2) | if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2) | ||||
| qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2; | qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2; | ||||
| @@ -507,7 +523,6 @@ void ff_clean_h263_qscales(MpegEncContext *s){ | |||||
| int mb_xy= s->mb_index2xy[i]; | int mb_xy= s->mb_index2xy[i]; | ||||
| if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTER4V)){ | if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTER4V)){ | ||||
| s->mb_type[mb_xy]&= ~CANDIDATE_MB_TYPE_INTER4V; | |||||
| s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER; | s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER; | ||||
| } | } | ||||
| } | } | ||||
| @@ -79,10 +79,10 @@ stddev: 10.25 PSNR:27.91 bytes:7602176 | |||||
| 657582 ./data/a-mpeg4-qprd.avi | 657582 ./data/a-mpeg4-qprd.avi | ||||
| 5b620f592a795b1caad323ab3fab0859 *./data/out.yuv | 5b620f592a795b1caad323ab3fab0859 *./data/out.yuv | ||||
| stddev: 12.12 PSNR:26.45 bytes:7602176 | stddev: 12.12 PSNR:26.45 bytes:7602176 | ||||
| b41b9915af65da1c03f17f59a1806d0e *./data/a-mpeg4-adap.avi | |||||
| 400192 ./data/a-mpeg4-adap.avi | |||||
| 9dffb8079a1666c054514ab02d9d4871 *./data/out.yuv | |||||
| stddev: 14.68 PSNR:24.78 bytes:7602176 | |||||
| 94c5a5e14f51e04b173d72eb0648b206 *./data/a-mpeg4-adap.avi | |||||
| 400190 ./data/a-mpeg4-adap.avi | |||||
| 8e5842fc2b92afa362bfcf17f339d47f *./data/out.yuv | |||||
| stddev: 14.67 PSNR:24.79 bytes:7602176 | |||||
| 5fff534f0b958547dfdb811d4f289931 *./data/a-mpeg4-thread.avi | 5fff534f0b958547dfdb811d4f289931 *./data/a-mpeg4-thread.avi | ||||
| 761170 ./data/a-mpeg4-thread.avi | 761170 ./data/a-mpeg4-thread.avi | ||||
| fe1d119938f8a26174b38eeaa18dff85 *./data/out.yuv | fe1d119938f8a26174b38eeaa18dff85 *./data/out.yuv | ||||
| @@ -79,10 +79,10 @@ stddev: 4.84 PSNR:34.41 bytes:7602176 | |||||
| 235016 ./data/a-mpeg4-qprd.avi | 235016 ./data/a-mpeg4-qprd.avi | ||||
| 224969c07440a23b376521c484936e75 *./data/out.yuv | 224969c07440a23b376521c484936e75 *./data/out.yuv | ||||
| stddev: 4.24 PSNR:35.56 bytes:7602176 | stddev: 4.24 PSNR:35.56 bytes:7602176 | ||||
| 62c7e87076d4741eb99d76e3ec424db0 *./data/a-mpeg4-adap.avi | |||||
| 205456 ./data/a-mpeg4-adap.avi | |||||
| fe20d6bd1aa019196fb6426fdd0f4779 *./data/out.yuv | |||||
| stddev: 4.08 PSNR:35.91 bytes:7602176 | |||||
| 7ecfbb848740d316e2fcf573b32cb848 *./data/a-mpeg4-adap.avi | |||||
| 205454 ./data/a-mpeg4-adap.avi | |||||
| c9225addf2e620e0094d26e805693af1 *./data/out.yuv | |||||
| stddev: 4.05 PSNR:35.96 bytes:7602176 | |||||
| 8cd8940d7451925784536fe9b2f2a5e3 *./data/a-mpeg4-thread.avi | 8cd8940d7451925784536fe9b2f2a5e3 *./data/a-mpeg4-thread.avi | ||||
| 254260 ./data/a-mpeg4-thread.avi | 254260 ./data/a-mpeg4-thread.avi | ||||
| d160a4224ea1af66c85178912f8d3a7c *./data/out.yuv | d160a4224ea1af66c85178912f8d3a7c *./data/out.yuv | ||||