Mercurial > libavcodec.hg
comparison ratecontrol.c @ 1365:d58fa7cc6008 libavcodec
fix qmin==qmax==1 && msmpeg4 && intra bug
| author | michaelni |
|---|---|
| date | Wed, 16 Jul 2003 11:48:59 +0000 |
| parents | 2fa34e615c76 |
| children | c4539ef4d8cb |
comparison
equal
deleted
inserted
replaced
| 1364:463090933f60 | 1365:d58fa7cc6008 |
|---|---|
| 356 * gets the qmin & qmax for pict_type | 356 * gets the qmin & qmax for pict_type |
| 357 */ | 357 */ |
| 358 static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type){ | 358 static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type){ |
| 359 int qmin= s->avctx->qmin; | 359 int qmin= s->avctx->qmin; |
| 360 int qmax= s->avctx->qmax; | 360 int qmax= s->avctx->qmax; |
| 361 | |
| 362 assert(qmin <= qmax); | |
| 361 | 363 |
| 362 if(pict_type==B_TYPE){ | 364 if(pict_type==B_TYPE){ |
| 363 qmin= (int)(qmin*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5); | 365 qmin= (int)(qmin*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5); |
| 364 qmax= (int)(qmax*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5); | 366 qmax= (int)(qmax*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5); |
| 365 }else if(pict_type==I_TYPE){ | 367 }else if(pict_type==I_TYPE){ |
| 366 qmin= (int)(qmin*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5); | 368 qmin= (int)(qmin*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5); |
| 367 qmax= (int)(qmax*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5); | 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 if(qmin==1 && s->avctx->qmin>1) qmin=2; //avoid qmin=1 unless the user wants qmin=1 | 375 if(qmin==1 && s->avctx->qmin>1) qmin=2; //avoid qmin=1 unless the user wants qmin=1 |
| 372 | 376 |
| 373 if(qmin<3 && s->max_qcoeff<=128 && pict_type==I_TYPE) qmin=3; //reduce cliping problems | 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; | 379 if(qmax<qmin) qmax= qmin; |
| 376 if(qmax<=qmin) qmax= qmin= (qmax+qmin+1)>>1; | |
| 377 | 380 |
| 378 *qmin_ret= qmin; | 381 *qmin_ret= qmin; |
| 379 *qmax_ret= qmax; | 382 *qmax_ret= qmax; |
| 380 } | 383 } |
| 381 | 384 |
