Revision 2f5feea4

View differences:

libavcodec/ratecontrol.c
479 479
    const int qmin= s->avctx->mb_qmin;
480 480
    const int qmax= s->avctx->mb_qmax;
481 481
    Picture * const pic= &s->current_picture;
482
    int last_qscale=0;
482 483
    
483 484
    for(i=0; i<s->mb_num; i++){
484
        float temp_cplx= sqrt(pic->mc_mb_var[i]);
485
        float spat_cplx= sqrt(pic->mb_var[i]);
486
        const int lumi= pic->mb_mean[i];
485
        const int mb_xy= s->mb_index2xy[i];
486
        float temp_cplx= sqrt(pic->mc_mb_var[mb_xy]);
487
        float spat_cplx= sqrt(pic->mb_var[mb_xy]);
488
        const int lumi= pic->mb_mean[mb_xy];
487 489
        float bits, cplx, factor;
488 490
        
489 491
        if(spat_cplx < q/3) spat_cplx= q/3; //FIXME finetune
490 492
        if(temp_cplx < q/3) temp_cplx= q/3; //FIXME finetune
491 493
        
492
        if((s->mb_type[i]&MB_TYPE_INTRA)){//FIXME hq mode 
494
        if((s->mb_type[mb_xy]&MB_TYPE_INTRA)){//FIXME hq mode 
493 495
            cplx= spat_cplx;
494 496
            factor= 1.0 + p_masking;
495 497
        }else{
......
530 532
    }
531 533
   
532 534
    for(i=0; i<s->mb_num; i++){
535
        const int mb_xy= s->mb_index2xy[i];
533 536
        float newq= q*cplx_tab[i]/bits_tab[i];
534 537
        int intq;
535 538

  
......
537 540
            newq*= bits_sum/cplx_sum;
538 541
        }
539 542

  
540
        if(i && ABS(pic->qscale_table[i-1] - newq)<0.75)
541
            intq= pic->qscale_table[i-1];
543
        if(i && ABS(last_qscale - newq)<0.75)
544
            intq= last_qscale;
542 545
        else
543 546
            intq= (int)(newq + 0.5);
544 547

  
......
546 549
        else if(intq < qmin) intq= qmin;
547 550
//if(i%s->mb_width==0) printf("\n");
548 551
//printf("%2d%3d ", intq, ff_sqrt(s->mc_mb_var[i]));
549
        pic->qscale_table[i]= intq;
552
        last_qscale=
553
        pic->qscale_table[mb_xy]= intq;
550 554
    }
551 555
}
552 556

  

Also available in: Unified diff