Mercurial > libavcodec.hg
comparison mpegvideo.c @ 1099:988b180afd31 libavcodec
cleanup
author | michaelni |
---|---|
date | Wed, 05 Mar 2003 20:13:11 +0000 |
parents | b7f267d168b7 |
children | 1e39f273ecd6 |
comparison
equal
deleted
inserted
replaced
1098:b7f267d168b7 | 1099:988b180afd31 |
---|---|
2215 const int j= s->intra_scantable.permutated[i]; | 2215 const int j= s->intra_scantable.permutated[i]; |
2216 int level = block[j]; | 2216 int level = block[j]; |
2217 | 2217 |
2218 if (level>maxlevel) level=maxlevel; | 2218 if (level>maxlevel) level=maxlevel; |
2219 else if(level<minlevel) level=minlevel; | 2219 else if(level<minlevel) level=minlevel; |
2220 | |
2220 block[j]= level; | 2221 block[j]= level; |
2221 } | 2222 } |
2222 } | 2223 } |
2223 | 2224 |
2224 static inline void requantize_coeffs(MpegEncContext *s, DCTELEM block[64], int oldq, int newq, int n) | |
2225 { | |
2226 int i; | |
2227 | |
2228 if(s->mb_intra){ | |
2229 i=1; //skip clipping of intra dc | |
2230 //FIXME requantize, note (mpeg1/h263/h263p-aic dont need it,...) | |
2231 }else | |
2232 i=0; | |
2233 | |
2234 for(;i<=s->block_last_index[n]; i++){ | |
2235 const int j = s->intra_scantable.permutated[i]; | |
2236 int level = block[j]; | |
2237 | |
2238 block[j]= ROUNDED_DIV(level*oldq, newq); | |
2239 } | |
2240 | |
2241 for(i=s->block_last_index[n]; i>=0; i--){ | |
2242 const int j = s->intra_scantable.permutated[i]; | |
2243 if(block[j]) break; | |
2244 } | |
2245 s->block_last_index[n]= i; | |
2246 } | |
2247 | |
2248 static inline void auto_requantize_coeffs(MpegEncContext *s, DCTELEM block[6][64]) | |
2249 { | |
2250 int i,n, newq; | |
2251 const int maxlevel= s->max_qcoeff; | |
2252 const int minlevel= s->min_qcoeff; | |
2253 int largest=0, smallest=0; | |
2254 | |
2255 assert(s->adaptive_quant); | |
2256 | |
2257 for(n=0; n<6; n++){ | |
2258 if(s->mb_intra){ | |
2259 i=1; //skip clipping of intra dc | |
2260 //FIXME requantize, note (mpeg1/h263/h263p-aic dont need it,...) | |
2261 }else | |
2262 i=0; | |
2263 | |
2264 for(;i<=s->block_last_index[n]; i++){ | |
2265 const int j = s->intra_scantable.permutated[i]; | |
2266 int level = block[n][j]; | |
2267 if(largest < level) largest = level; | |
2268 if(smallest > level) smallest= level; | |
2269 } | |
2270 } | |
2271 | |
2272 for(newq=s->qscale+1; newq<32; newq++){ | |
2273 if( ROUNDED_DIV(smallest*s->qscale, newq) >= minlevel | |
2274 && ROUNDED_DIV(largest *s->qscale, newq) <= maxlevel) | |
2275 break; | |
2276 } | |
2277 | |
2278 if(s->out_format==FMT_H263){ | |
2279 /* h263 like formats cannot change qscale by more than 2 easiely */ | |
2280 if(s->avctx->qmin + 2 < newq) | |
2281 newq= s->avctx->qmin + 2; | |
2282 } | |
2283 | |
2284 for(n=0; n<6; n++){ | |
2285 requantize_coeffs(s, block[n], s->qscale, newq, n); | |
2286 clip_coeffs(s, block[n], s->block_last_index[n]); | |
2287 } | |
2288 | |
2289 s->dquant+= newq - s->qscale; | |
2290 s->qscale= newq; | |
2291 } | |
2292 #if 0 | 2225 #if 0 |
2293 static int pix_vcmp16x8(uint8_t *s, int stride){ //FIXME move to dsputil & optimize | 2226 static int pix_vcmp16x8(uint8_t *s, int stride){ //FIXME move to dsputil & optimize |
2294 int score=0; | 2227 int score=0; |
2295 int x,y; | 2228 int x,y; |
2296 | 2229 |