Revision 59743d16 libavcodec/h263.c

View differences:

libavcodec/h263.c
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 504
 * modify qscale so that encoding is acually possible in h263 (limit difference to -2..2)
491 505
 */
492 506
void ff_clean_h263_qscales(MpegEncContext *s){
493 507
    int i;
494 508
    int8_t * const qscale_table= s->current_picture.qscale_table;
495 509

  
510
    ff_init_qscale_tab(s);
511

  
496 512
    for(i=1; i<s->mb_num; i++){
497 513
        if(qscale_table[ s->mb_index2xy[i] ] - qscale_table[ s->mb_index2xy[i-1] ] >2)
498 514
            qscale_table[ s->mb_index2xy[i] ]= qscale_table[ s->mb_index2xy[i-1] ]+2;
......
507 523
            int mb_xy= s->mb_index2xy[i];
508 524

  
509 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 526
                s->mb_type[mb_xy]|= CANDIDATE_MB_TYPE_INTER;
512 527
            }
513 528
        }

Also available in: Unified diff