Mercurial > libavcodec.hg
comparison h263.c @ 4316:fabb67829f3f libavcodec
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
author | michael |
---|---|
date | Thu, 21 Dec 2006 14:24:23 +0000 |
parents | 671a64d357e0 |
children | 855350bd0daf |
comparison
equal
deleted
inserted
replaced
4315:671a64d357e0 | 4316:fabb67829f3f |
---|---|
485 } | 485 } |
486 } | 486 } |
487 } | 487 } |
488 | 488 |
489 /** | 489 /** |
490 * init s->current_picture.qscale_table from s->lambda_table | |
491 */ | |
492 static void ff_init_qscale_tab(MpegEncContext *s){ | |
493 int8_t * const qscale_table= s->current_picture.qscale_table; | |
494 int i; | |
495 | |
496 for(i=0; i<s->mb_num; i++){ | |
497 unsigned int lam= s->lambda_table[ s->mb_index2xy[i] ]; | |
498 int qp= (lam*139 + FF_LAMBDA_SCALE*64) >> (FF_LAMBDA_SHIFT + 7); | |
499 qscale_table[ s->mb_index2xy[i] ]= clip(qp, s->avctx->qmin, s->avctx->qmax); | |
500 } | |
501 } | |
502 | |
503 /** | |
490 * modify qscale so that encoding is acually possible in h263 (limit difference to -2..2) | 504 * modify qscale so that encoding is acually possible in h263 (limit difference to -2..2) |
491 */ | 505 */ |
492 void ff_clean_h263_qscales(MpegEncContext *s){ | 506 void ff_clean_h263_qscales(MpegEncContext *s){ |
493 int i; | 507 int i; |
494 int8_t * const qscale_table= s->current_picture.qscale_table; | 508 int8_t * const qscale_table= s->current_picture.qscale_table; |
495 | 509 |
510 ff_init_qscale_tab(s); | |
511 | |
496 for(i=1; i<s->mb_num; i++){ | 512 for(i=1; i<s->mb_num; i++){ |
497 if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2) | 513 if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2) |
498 qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2; | 514 qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2; |
499 } | 515 } |
500 for(i=s->mb_num-2; i>=0; i--){ | 516 for(i=s->mb_num-2; i>=0; i--){ |
505 if(s->codec_id != CODEC_ID_H263P){ | 521 if(s->codec_id != CODEC_ID_H263P){ |
506 for(i=1; i<s->mb_num; i++){ | 522 for(i=1; i<s->mb_num; i++){ |
507 int mb_xy= s->mb_index2xy[i]; | 523 int mb_xy= s->mb_index2xy[i]; |
508 | 524 |
509 if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTER4V)){ | 525 if(qscale_table[mb_xy] != qscale_table[s->mb_index2xy[i-1]] && (s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTER4V)){ |
510 s->mb_type[mb_xy]&= ~CANDIDATE_MB_TYPE_INTER4V; | |
511 s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER; | 526 s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER; |
512 } | 527 } |
513 } | 528 } |
514 } | 529 } |
515 } | 530 } |