# HG changeset patch # User michaelni # Date 1058356139 0 # Node ID d58fa7cc6008d040212c3a558685426511d6d8d3 # Parent 463090933f609802b0fba4f9d5641e6ef71e388f fix qmin==qmax==1 && msmpeg4 && intra bug diff -r 463090933f60 -r d58fa7cc6008 ratecontrol.c --- a/ratecontrol.c Tue Jul 15 20:22:22 2003 +0000 +++ b/ratecontrol.c Wed Jul 16 11:48:59 2003 +0000 @@ -358,6 +358,8 @@ static void get_qminmax(int *qmin_ret, int *qmax_ret, MpegEncContext *s, int pict_type){ int qmin= s->avctx->qmin; int qmax= s->avctx->qmax; + + assert(qmin <= qmax); if(pict_type==B_TYPE){ qmin= (int)(qmin*ABS(s->avctx->b_quant_factor)+s->avctx->b_quant_offset + 0.5); @@ -367,13 +369,14 @@ qmax= (int)(qmax*ABS(s->avctx->i_quant_factor)+s->avctx->i_quant_offset + 0.5); } - if(qmin<1) qmin=1; + qmin= clip(qmin, 1, 31); + qmax= clip(qmax, 1, 31); + if(qmin==1 && s->avctx->qmin>1) qmin=2; //avoid qmin=1 unless the user wants qmin=1 if(qmin<3 && s->max_qcoeff<=128 && pict_type==I_TYPE) qmin=3; //reduce cliping problems - if(qmax>31) qmax=31; - if(qmax<=qmin) qmax= qmin= (qmax+qmin+1)>>1; + if(qmax