Revision fa12b546 libavcodec/ratecontrol.c

View differences:

libavcodec/ratecontrol.c
358 358
static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type){
359 359
    int qmin= s->avctx->qmin;                                                       
360 360
    int qmax= s->avctx->qmax;
361
    
362
    assert(qmin <= qmax);
361 363

  
362 364
    if(pict_type==B_TYPE){
363 365
        qmin= (int)(qmin*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5);
......
367 369
        qmax= (int)(qmax*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5);
368 370
    }
369 371

  
370
    if(qmin<1) qmin=1;
372
    qmin= clip(qmin, 1, 31);
373
    qmax= clip(qmax, 1, 31);
374

  
371 375
    if(qmin==1 && s->avctx->qmin>1) qmin=2; //avoid qmin=1 unless the user wants qmin=1
372 376

  
373 377
    if(qmin<3 && s->max_qcoeff<=128 && pict_type==I_TYPE) qmin=3; //reduce cliping problems
374 378

  
375
    if(qmax>31) qmax=31;
376
    if(qmax<=qmin) qmax= qmin= (qmax+qmin+1)>>1;
379
    if(qmax<qmin) qmax= qmin;
377 380
    
378 381
    *qmin_ret= qmin;
379 382
    *qmax_ret= qmax;

Also available in: Unified diff