~ubuntu-branches/ubuntu/edgy/gstreamer0.10-ffmpeg/edgy

« back to all changes in this revision

Viewing changes to gst-libs/ext/ffmpeg/libavcodec/ratecontrol.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastian Dröge
  • Date: 2006-04-01 16:13:43 UTC
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20060401161343-n621cgjlujio0otg
Tags: upstream-0.10.1
Import upstream version 0.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 * You should have received a copy of the GNU Lesser General Public
17
17
 * License along with this library; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
19
 */
20
20
 
21
21
/**
22
22
 * @file ratecontrol.c
23
23
 * Rate control for video encoders.
24
 
 */ 
 
24
 */
25
25
 
26
26
#include "avcodec.h"
27
27
#include "dsputil.h"
38
38
static double get_qscale(MpegEncContext *s, RateControlEntry *rce, double rate_factor, int frame_num);
39
39
 
40
40
void ff_write_pass1_stats(MpegEncContext *s){
41
 
    snprintf(s->avctx->stats_out, 256, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d;\n",
42
 
            s->current_picture_ptr->display_picture_number, s->current_picture_ptr->coded_picture_number, s->pict_type, 
43
 
            s->current_picture.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits, 
44
 
            s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count);
 
41
    snprintf(s->avctx->stats_out, 256, "in:%d out:%d type:%d q:%d itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d;\n",
 
42
            s->current_picture_ptr->display_picture_number, s->current_picture_ptr->coded_picture_number, s->pict_type,
 
43
            s->current_picture.quality, s->i_tex_bits, s->p_tex_bits, s->mv_bits, s->misc_bits,
 
44
            s->f_code, s->b_code, s->current_picture.mc_mb_var_sum, s->current_picture.mb_var_sum, s->i_count, s->skip_count, s->header_bits);
45
45
}
46
46
 
47
47
int ff_rate_control_init(MpegEncContext *s)
53
53
    for(i=0; i<5; i++){
54
54
        rcc->pred[i].coeff= FF_QP2LAMBDA * 7.0;
55
55
        rcc->pred[i].count= 1.0;
56
 
    
 
56
 
57
57
        rcc->pred[i].decay= 0.4;
58
58
        rcc->i_cplx_sum [i]=
59
59
        rcc->p_cplx_sum [i]=
78
78
            return -1;
79
79
        rcc->entry = (RateControlEntry*)av_mallocz(i*sizeof(RateControlEntry));
80
80
        rcc->num_entries= i;
81
 
        
 
81
 
82
82
        /* init all to skipped p frames (with b frames we might have a not encoded frame at the end FIXME) */
83
83
        for(i=0; i<rcc->num_entries; i++){
84
84
            RateControlEntry *rce= &rcc->entry[i];
86
86
            rce->qscale= rce->new_qscale=FF_QP2LAMBDA * 2;
87
87
            rce->misc_bits= s->mb_num + 10;
88
88
            rce->mb_var_sum= s->mb_num*100;
89
 
        }        
90
 
        
 
89
        }
 
90
 
91
91
        /* read stats */
92
92
        p= s->avctx->stats_in;
93
93
        for(i=0; i<rcc->num_entries - s->max_b_frames; i++){
107
107
            assert(picture_number < rcc->num_entries);
108
108
            rce= &rcc->entry[picture_number];
109
109
 
110
 
            e+=sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d",
111
 
                   &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits, 
112
 
                   &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count);
113
 
            if(e!=12){
 
110
            e+=sscanf(p, " in:%*d out:%*d type:%d q:%f itex:%d ptex:%d mv:%d misc:%d fcode:%d bcode:%d mc-var:%d var:%d icount:%d skipcount:%d hbits:%d",
 
111
                   &rce->pict_type, &rce->qscale, &rce->i_tex_bits, &rce->p_tex_bits, &rce->mv_bits, &rce->misc_bits,
 
112
                   &rce->f_code, &rce->b_code, &rce->mc_mb_var_sum, &rce->mb_var_sum, &rce->i_count, &rce->skip_count, &rce->header_bits);
 
113
            if(e!=14){
114
114
                av_log(s->avctx, AV_LOG_ERROR, "statistics are damaged at line %d, parser out=%d\n", i, e);
115
115
                return -1;
116
116
            }
 
117
 
117
118
            p= next;
118
119
        }
119
 
        
 
120
#ifdef CONFIG_XVID
 
121
        //FIXME maybe move to end
 
122
        if((s->flags&CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID)
 
123
            return ff_xvid_rate_control_init(s);
 
124
#endif
 
125
 
120
126
        if(init_pass2(s) < 0) return -1;
121
127
    }
122
 
     
 
128
 
123
129
    if(!(s->flags&CODEC_FLAG_PASS2)){
124
130
 
125
131
        rcc->short_term_qsum=0.001;
126
132
        rcc->short_term_qcount=0.001;
127
 
    
 
133
 
128
134
        rcc->pass1_rc_eq_output_sum= 0.001;
129
135
        rcc->pass1_wanted_bits=0.001;
130
 
        
 
136
 
131
137
        /* init stuff with the user specified complexity */
132
138
        if(s->avctx->rc_initial_cplx){
133
139
            for(i=0; i<60*30; i++){
134
140
                double bits= s->avctx->rc_initial_cplx * (i/10000.0 + 1.0)*s->mb_num;
135
141
                RateControlEntry rce;
136
142
                double q;
137
 
                
 
143
 
138
144
                if     (i%((s->gop_size+3)/4)==0) rce.pict_type= I_TYPE;
139
145
                else if(i%(s->max_b_frames+1))    rce.pict_type= B_TYPE;
140
146
                else                              rce.pict_type= P_TYPE;
171
177
        }
172
178
 
173
179
    }
174
 
    
 
180
 
175
181
    return 0;
176
182
}
177
183
 
181
187
    emms_c();
182
188
 
183
189
    av_freep(&rcc->entry);
 
190
 
 
191
#ifdef CONFIG_XVID
 
192
    if((s->flags&CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID)
 
193
        ff_xvid_rate_control_uninit(s);
 
194
#endif
184
195
}
185
196
 
186
197
static inline double qp2bits(RateControlEntry *rce, double qp){
196
207
    }
197
208
    return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits+1)/ bits;
198
209
}
199
 
    
 
210
 
200
211
int ff_vbv_update(MpegEncContext *s, int frame_size){
201
212
    RateControlContext *rcc= &s->rc_context;
202
213
    const double fps= 1/av_q2d(s->avctx->time_base);
203
214
    const int buffer_size= s->avctx->rc_buffer_size;
204
215
    const double min_rate= s->avctx->rc_min_rate/fps;
205
216
    const double max_rate= s->avctx->rc_max_rate/fps;
206
 
    
 
217
 
207
218
//printf("%d %f %d %f %f\n", buffer_size, rcc->buffer_index, frame_size, min_rate, max_rate);
208
219
    if(buffer_size){
209
220
        int left;
219
230
 
220
231
        if(rcc->buffer_index > buffer_size){
221
232
            int stuffing= ceil((rcc->buffer_index - buffer_size)/8);
222
 
            
 
233
 
223
234
            if(stuffing < 4 && s->codec_id == CODEC_ID_MPEG4)
224
235
                stuffing=4;
225
236
            rcc->buffer_index -= 8*stuffing;
226
 
            
 
237
 
227
238
            if(s->avctx->debug & FF_DEBUG_RC)
228
239
                av_log(s->avctx, AV_LOG_DEBUG, "stuffing %d bytes\n", stuffing);
229
240
 
241
252
    AVCodecContext *a= s->avctx;
242
253
    double q, bits;
243
254
    const int pict_type= rce->new_pict_type;
244
 
    const double mb_num= s->mb_num;  
 
255
    const double mb_num= s->mb_num;
245
256
    int i;
246
257
 
247
258
    double const_values[]={
310
321
    };
311
322
 
312
323
    bits= ff_eval(s->avctx->rc_eq, const_values, const_names, func1, func1_names, NULL, NULL, rce);
313
 
    
 
324
 
314
325
    rcc->pass1_rc_eq_output_sum+= bits;
315
326
    bits*=rate_factor;
316
327
    if(bits<0.0) bits=0.0;
317
328
    bits+= 1.0; //avoid 1/0 issues
318
 
    
 
329
 
319
330
    /* user override */
320
331
    for(i=0; i<s->avctx->rc_override_count; i++){
321
332
        RcOverride *rco= s->avctx->rc_override;
322
333
        if(rco[i].start_frame > frame_num) continue;
323
334
        if(rco[i].end_frame   < frame_num) continue;
324
 
    
325
 
        if(rco[i].qscale) 
 
335
 
 
336
        if(rco[i].qscale)
326
337
            bits= qp2bits(rce, rco[i].qscale); //FIXME move at end to really force it?
327
338
        else
328
339
            bits*= rco[i].quality_factor;
329
340
    }
330
341
 
331
342
    q= bits2qp(rce, bits);
332
 
    
 
343
 
333
344
    /* I/B difference */
334
345
    if     (pict_type==I_TYPE && s->avctx->i_quant_factor<0.0)
335
346
        q= -q*s->avctx->i_quant_factor + s->avctx->i_quant_offset;
336
347
    else if(pict_type==B_TYPE && s->avctx->b_quant_factor<0.0)
337
348
        q= -q*s->avctx->b_quant_factor + s->avctx->b_quant_offset;
338
 
        
 
349
 
339
350
    return q;
340
351
}
341
352
 
345
356
    const int pict_type= rce->new_pict_type;
346
357
    const double last_p_q    = rcc->last_qscale_for[P_TYPE];
347
358
    const double last_non_b_q= rcc->last_qscale_for[rcc->last_non_b_pict_type];
348
 
    
 
359
 
349
360
    if     (pict_type==I_TYPE && (a->i_quant_factor>0.0 || rcc->last_non_b_pict_type==P_TYPE))
350
361
        q= last_p_q    *ABS(a->i_quant_factor) + a->i_quant_offset;
351
362
    else if(pict_type==B_TYPE && a->b_quant_factor>0.0)
361
372
    }
362
373
 
363
374
    rcc->last_qscale_for[pict_type]= q; //Note we cant do that after blurring
364
 
    
 
375
 
365
376
    if(pict_type!=B_TYPE)
366
377
        rcc->last_non_b_pict_type= pict_type;
367
378
 
372
383
 * gets the qmin & qmax for pict_type
373
384
 */
374
385
static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type){
375
 
    int qmin= s->avctx->lmin;                                                       
 
386
    int qmin= s->avctx->lmin;
376
387
    int qmax= s->avctx->lmax;
377
 
    
 
388
 
378
389
    assert(qmin <= qmax);
379
390
 
380
391
    if(pict_type==B_TYPE){
389
400
    qmax= clip(qmax, 1, FF_LAMBDA_MAX);
390
401
 
391
402
    if(qmax<qmin) qmax= qmin;
392
 
    
 
403
 
393
404
    *qmin_ret= qmin;
394
405
    *qmax_ret= qmax;
395
406
}
403
414
    const double fps= 1/av_q2d(s->avctx->time_base);
404
415
    const double min_rate= s->avctx->rc_min_rate / fps;
405
416
    const double max_rate= s->avctx->rc_max_rate / fps;
406
 
    
 
417
 
407
418
    get_qminmax(&qmin, &qmax, s, pict_type);
408
419
 
409
420
    /* modulation */
454
465
    }else{
455
466
        double min2= log(qmin);
456
467
        double max2= log(qmax);
457
 
        
 
468
 
458
469
        q= log(q);
459
470
        q= (q - min2)/(max2-min2) - 0.5;
460
471
        q*= -4.0;
461
472
        q= 1.0/(1.0 + exp(q));
462
473
        q= q*(max2-min2) + min2;
463
 
        
 
474
 
464
475
        q= exp(q);
465
476
    }
466
 
    
 
477
 
467
478
    return q;
468
479
}
469
480
 
511
522
    Picture * const pic= &s->current_picture;
512
523
    const int mb_width = s->mb_width;
513
524
    const int mb_height = s->mb_height;
514
 
    
 
525
 
515
526
    for(i=0; i<s->mb_num; i++){
516
527
        const int mb_xy= s->mb_index2xy[i];
517
528
        float temp_cplx= sqrt(pic->mc_mb_var[mb_xy]); //FIXME merge in pow()
522
533
        int mb_y = mb_xy / s->mb_stride;
523
534
        int mb_distance;
524
535
        float mb_factor = 0.0;
525
 
#if 0        
 
536
#if 0
526
537
        if(spat_cplx < q/3) spat_cplx= q/3; //FIXME finetune
527
538
        if(temp_cplx < q/3) temp_cplx= q/3; //FIXME finetune
528
 
#endif   
 
539
#endif
529
540
        if(spat_cplx < 4) spat_cplx= 4; //FIXME finetune
530
541
        if(temp_cplx < 4) temp_cplx= 4; //FIXME finetune
531
542
 
532
 
        if((s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTRA)){//FIXME hq mode 
 
543
        if((s->mb_type[mb_xy]&CANDIDATE_MB_TYPE_INTRA)){//FIXME hq mode
533
544
            cplx= spat_cplx;
534
545
            factor= 1.0 + p_masking;
535
546
        }else{
559
570
        }
560
571
 
561
572
        factor*= 1.0 - border_masking*mb_factor;
562
 
        
 
573
 
563
574
        if(factor<0.00001) factor= 0.00001;
564
 
        
 
575
 
565
576
        bits= cplx*factor;
566
577
        cplx_sum+= cplx;
567
578
        bits_sum+= bits;
588
599
        if(bits_sum < 0.001) bits_sum= 0.001;
589
600
        if(cplx_sum < 0.001) cplx_sum= 0.001;
590
601
    }
591
 
   
 
602
 
592
603
    for(i=0; i<s->mb_num; i++){
593
604
        const int mb_xy= s->mb_index2xy[i];
594
605
        float newq= q*cplx_tab[i]/bits_tab[i];
607
618
        s->lambda_table[mb_xy]= intq;
608
619
    }
609
620
}
 
621
 
 
622
void ff_get_2pass_fcode(MpegEncContext *s){
 
623
    RateControlContext *rcc= &s->rc_context;
 
624
    int picture_number= s->picture_number;
 
625
    RateControlEntry *rce;
 
626
 
 
627
    rce= &rcc->entry[picture_number];
 
628
    s->f_code= rce->f_code;
 
629
    s->b_code= rce->b_code;
 
630
}
 
631
 
610
632
//FIXME rd or at least approx for dquant
611
633
 
612
 
float ff_rate_estimate_qscale(MpegEncContext *s)
 
634
float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run)
613
635
{
614
636
    float q;
615
637
    int qmin, qmax;
629
651
    Picture * const pic= &s->current_picture;
630
652
    emms_c();
631
653
 
 
654
#ifdef CONFIG_XVID
 
655
    if((s->flags&CODEC_FLAG_PASS2) && s->avctx->rc_strategy == FF_RC_STRATEGY_XVID)
 
656
        return ff_xvid_rate_estimate_qscale(s, dry_run);
 
657
#endif
 
658
 
632
659
    get_qminmax(&qmin, &qmax, s, pict_type);
633
660
 
634
661
    fps= 1/av_q2d(s->avctx->time_base);
635
662
//printf("input_pic_num:%d pic_num:%d frame_rate:%d\n", s->input_picture_number, s->picture_number, s->frame_rate);
636
663
        /* update predictors */
637
 
    if(picture_number>2){
 
664
    if(picture_number>2 && !dry_run){
638
665
        const int last_var= s->last_pict_type == I_TYPE ? rcc->last_mb_var_sum : rcc->last_mc_mb_var_sum;
639
666
        update_predictor(&rcc->pred[s->last_pict_type], rcc->last_qscale, sqrt(last_var), s->frame_bits);
640
667
    }
654
681
    if(br_compensation<=0.0) br_compensation=0.001;
655
682
 
656
683
    var= pict_type == I_TYPE ? pic->mb_var_sum : pic->mc_mb_var_sum;
657
 
    
 
684
 
658
685
    short_term_q = 0; /* avoid warning */
659
686
    if(s->flags&CODEC_FLAG_PASS2){
660
687
        if(pict_type!=I_TYPE)
663
690
        q= rce->new_qscale / br_compensation;
664
691
//printf("%f %f %f last:%d var:%d type:%d//\n", q, rce->new_qscale, br_compensation, s->frame_bits, var, pict_type);
665
692
    }else{
666
 
        rce->pict_type= 
 
693
        rce->pict_type=
667
694
        rce->new_pict_type= pict_type;
668
695
        rce->mc_mb_var_sum= pic->mc_mb_var_sum;
669
696
        rce->mb_var_sum   = pic->   mb_var_sum;
682
709
            rce->i_count   = 0; //FIXME we do know this approx
683
710
            rce->i_tex_bits= 0;
684
711
            rce->p_tex_bits= bits*0.9;
685
 
            
 
712
 
686
713
            rce->mv_bits= bits*0.1;
687
714
        }
688
715
        rcc->i_cplx_sum [pict_type] += rce->i_tex_bits*rce->qscale;
692
719
 
693
720
        bits= rce->i_tex_bits + rce->p_tex_bits;
694
721
        rate_factor= rcc->pass1_wanted_bits/rcc->pass1_rc_eq_output_sum * br_compensation;
695
 
    
 
722
 
696
723
        q= get_qscale(s, rce, rate_factor, picture_number);
697
724
 
698
725
        assert(q>0.0);
712
739
//printf("%f ", q);
713
740
        }
714
741
        assert(q>0.0);
715
 
        
 
742
 
716
743
        q= modify_qscale(s, rce, q, picture_number);
717
744
 
718
745
        rcc->pass1_wanted_bits+= s->bit_rate/fps;
727
754
        );
728
755
    }
729
756
 
730
 
    if     (q<qmin) q=qmin; 
 
757
    if     (q<qmin) q=qmin;
731
758
    else if(q>qmax) q=qmax;
732
759
 
733
760
    if(s->adaptive_quant)
734
761
        adaptive_quantization(s, q);
735
762
    else
736
763
        q= (int)(q + 0.5);
737
 
    
738
 
    rcc->last_qscale= q;
739
 
    rcc->last_mc_mb_var_sum= pic->mc_mb_var_sum;
740
 
    rcc->last_mb_var_sum= pic->mb_var_sum;
 
764
 
 
765
    if(!dry_run){
 
766
        rcc->last_qscale= q;
 
767
        rcc->last_mc_mb_var_sum= pic->mc_mb_var_sum;
 
768
        rcc->last_mb_var_sum= pic->mb_var_sum;
 
769
    }
741
770
#if 0
742
771
{
743
772
    static int mvsum=0, texsum=0;
767
796
    double rate_factor=0;
768
797
    double step;
769
798
    //int last_i_frame=-10000000;
770
 
    const int filter_size= (int)(a->qblur*4) | 1;  
 
799
    const int filter_size= (int)(a->qblur*4) | 1;
771
800
    double expected_bits;
772
801
    double *qscale, *blured_qscale;
773
802
 
774
803
    /* find complexity & const_bits & decide the pict_types */
775
804
    for(i=0; i<rcc->num_entries; i++){
776
805
        RateControlEntry *rce= &rcc->entry[i];
777
 
        
 
806
 
778
807
        rce->new_pict_type= rce->pict_type;
779
808
        rcc->i_cplx_sum [rce->pict_type] += rce->i_tex_bits*rce->qscale;
780
809
        rcc->p_cplx_sum [rce->pict_type] += rce->p_tex_bits*rce->qscale;
785
814
        const_bits[rce->new_pict_type]+= rce->mv_bits + rce->misc_bits;
786
815
    }
787
816
    all_const_bits= const_bits[I_TYPE] + const_bits[P_TYPE] + const_bits[B_TYPE];
788
 
    
 
817
 
789
818
    if(all_available_bits < all_const_bits){
790
819
        av_log(s->avctx, AV_LOG_ERROR, "requested bitrate is to low\n");
791
820
        return -1;
792
821
    }
793
 
    
 
822
 
794
823
    /* find average quantizers */
795
824
    avg_quantizer[P_TYPE]=0;
796
825
    for(step=256*256; step>0.0000001; step*=0.5){
797
826
        double expected_bits=0;
798
827
        avg_quantizer[P_TYPE]+= step;
799
 
        
 
828
 
800
829
        avg_quantizer[I_TYPE]= avg_quantizer[P_TYPE]*ABS(s->avctx->i_quant_factor) + s->avctx->i_quant_offset;
801
830
        avg_quantizer[B_TYPE]= avg_quantizer[P_TYPE]*ABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset;
802
 
        
803
 
        expected_bits= 
804
 
            + all_const_bits 
 
831
 
 
832
        expected_bits=
 
833
            + all_const_bits
805
834
            + complexity[I_TYPE]/avg_quantizer[I_TYPE]
806
835
            + complexity[P_TYPE]/avg_quantizer[P_TYPE]
807
836
            + complexity[B_TYPE]/avg_quantizer[B_TYPE];
808
 
            
 
837
 
809
838
        if(expected_bits < all_available_bits) avg_quantizer[P_TYPE]-= step;
810
839
//printf("%f %lld %f\n", expected_bits, all_available_bits, avg_quantizer[P_TYPE]);
811
840
    }
815
844
        available_bits[i]= const_bits[i] + complexity[i]/avg_quantizer[i];
816
845
    }
817
846
//printf("%lld %lld %lld %lld\n", available_bits[I_TYPE], available_bits[P_TYPE], available_bits[B_TYPE], all_available_bits);
818
 
        
 
847
 
819
848
    qscale= av_malloc(sizeof(double)*rcc->num_entries);
820
849
    blured_qscale= av_malloc(sizeof(double)*rcc->num_entries);
821
850
 
822
851
    for(step=256*256; step>0.0000001; step*=0.5){
823
852
        expected_bits=0;
824
853
        rate_factor+= step;
825
 
        
 
854
 
826
855
        rcc->buffer_index= s->avctx->rc_buffer_size/2;
827
856
 
828
857
        /* find qscale */
834
863
        /* fixed I/B QP relative to P mode */
835
864
        for(i=rcc->num_entries-1; i>=0; i--){
836
865
            RateControlEntry *rce= &rcc->entry[i];
837
 
            
 
866
 
838
867
            qscale[i]= get_diff_limited_q(s, rce, qscale[i]);
839
868
        }
840
869
 
844
873
            const int pict_type= rce->new_pict_type;
845
874
            int j;
846
875
            double q=0.0, sum=0.0;
847
 
        
 
876
 
848
877
            for(j=0; j<filter_size; j++){
849
878
                int index= i+j-filter_size/2;
850
879
                double d= index-i;
851
880
                double coeff= a->qblur==0 ? 1.0 : exp(-d*d/(a->qblur * a->qblur));
852
 
            
 
881
 
853
882
                if(index < 0 || index >= rcc->num_entries) continue;
854
883
                if(pict_type != rcc->entry[index].new_pict_type) continue;
855
884
                q+= qscale[index] * coeff;
857
886
            }
858
887
            blured_qscale[i]= q/sum;
859
888
        }
860
 
    
 
889
 
861
890
        /* find expected bits */
862
891
        for(i=0; i<rcc->num_entries; i++){
863
892
            RateControlEntry *rce= &rcc->entry[i];