# HG changeset patch # User michael # Date 1166711063 0 # Node ID fabb67829f3fd3f0d30e978406dbd9525cd9b35f # Parent 671a64d357e0774c2025f94a450449cbb856c6e6 dont randomly disallow intr4v in adaptive quant 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 diff -r 671a64d357e0 -r fabb67829f3f h263.c --- a/h263.c Thu Dec 21 13:23:49 2006 +0000 +++ b/h263.c Thu Dec 21 14:24:23 2006 +0000 @@ -487,12 +487,28 @@ } /** + * 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; imb_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) */ void ff_clean_h263_qscales(MpegEncContext *s){ int i; int8_t * const qscale_table= s->current_picture.qscale_table; + ff_init_qscale_tab(s); + for(i=1; imb_num; i++){ 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; @@ -507,7 +523,6 @@ 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)){ - s->mb_type[mb_xy]&= ~CANDIDATE_MB_TYPE_INTER4V; s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER; } }