Mercurial > libavcodec.hg
comparison mpegvideo.c @ 1729:a4a5e7521339 libavcodec
interlaced dct decision cleanup
function moved to dspcontext
mmx&mmx2 optimized
change SSE -> SAD as default (better quality)
vbv buffer size command line option in kbyte
author | michael |
---|---|
date | Mon, 05 Jan 2004 22:57:07 +0000 |
parents | 033d889d7c2c |
children | 07a484280a82 |
comparison
equal
deleted
inserted
replaced
1728:73a3699b8375 | 1729:a4a5e7521339 |
---|---|
971 if(s->modified_quant) | 971 if(s->modified_quant) |
972 s->chroma_qscale_table= ff_h263_chroma_qscale_table; | 972 s->chroma_qscale_table= ff_h263_chroma_qscale_table; |
973 s->progressive_frame= | 973 s->progressive_frame= |
974 s->progressive_sequence= !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)); | 974 s->progressive_sequence= !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME)); |
975 | 975 |
976 ff_set_cmp(&s->dsp, s->dsp.ildct_cmp, s->avctx->ildct_cmp); | |
977 | |
976 ff_init_me(s); | 978 ff_init_me(s); |
977 | 979 |
978 #ifdef CONFIG_ENCODERS | 980 #ifdef CONFIG_ENCODERS |
979 #ifdef CONFIG_RISKY | 981 #ifdef CONFIG_RISKY |
980 if (s->out_format == FMT_H263) | 982 if (s->out_format == FMT_H263) |
3166 | 3168 |
3167 if(overflow && s->avctx->mb_decision == FF_MB_DECISION_SIMPLE) | 3169 if(overflow && s->avctx->mb_decision == FF_MB_DECISION_SIMPLE) |
3168 av_log(s->avctx, AV_LOG_INFO, "warning, cliping %d dct coefficents to %d..%d\n", overflow, minlevel, maxlevel); | 3170 av_log(s->avctx, AV_LOG_INFO, "warning, cliping %d dct coefficents to %d..%d\n", overflow, minlevel, maxlevel); |
3169 } | 3171 } |
3170 | 3172 |
3171 #if 0 | |
3172 static int pix_vcmp16x8(uint8_t *s, int stride){ //FIXME move to dsputil & optimize | |
3173 int score=0; | |
3174 int x,y; | |
3175 | |
3176 for(y=0; y<7; y++){ | |
3177 for(x=0; x<16; x+=4){ | |
3178 score+= ABS(s[x ] - s[x +stride]) + ABS(s[x+1] - s[x+1+stride]) | |
3179 +ABS(s[x+2] - s[x+2+stride]) + ABS(s[x+3] - s[x+3+stride]); | |
3180 } | |
3181 s+= stride; | |
3182 } | |
3183 | |
3184 return score; | |
3185 } | |
3186 | |
3187 static int pix_diff_vcmp16x8(uint8_t *s1, uint8_t*s2, int stride){ //FIXME move to dsputil & optimize | |
3188 int score=0; | |
3189 int x,y; | |
3190 | |
3191 for(y=0; y<7; y++){ | |
3192 for(x=0; x<16; x++){ | |
3193 score+= ABS(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]); | |
3194 } | |
3195 s1+= stride; | |
3196 s2+= stride; | |
3197 } | |
3198 | |
3199 return score; | |
3200 } | |
3201 #else | |
3202 #define SQ(a) ((a)*(a)) | |
3203 | |
3204 static int pix_vcmp16x8(uint8_t *s, int stride){ //FIXME move to dsputil & optimize | |
3205 int score=0; | |
3206 int x,y; | |
3207 | |
3208 for(y=0; y<7; y++){ | |
3209 for(x=0; x<16; x+=4){ | |
3210 score+= SQ(s[x ] - s[x +stride]) + SQ(s[x+1] - s[x+1+stride]) | |
3211 +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]); | |
3212 } | |
3213 s+= stride; | |
3214 } | |
3215 | |
3216 return score; | |
3217 } | |
3218 | |
3219 static int pix_diff_vcmp16x8(uint8_t *s1, uint8_t*s2, int stride){ //FIXME move to dsputil & optimize | |
3220 int score=0; | |
3221 int x,y; | |
3222 | |
3223 for(y=0; y<7; y++){ | |
3224 for(x=0; x<16; x++){ | |
3225 score+= SQ(s1[x ] - s2[x ] - s1[x +stride] + s2[x +stride]); | |
3226 } | |
3227 s1+= stride; | |
3228 s2+= stride; | |
3229 } | |
3230 | |
3231 return score; | |
3232 } | |
3233 | |
3234 #endif | |
3235 | |
3236 #endif //CONFIG_ENCODERS | 3173 #endif //CONFIG_ENCODERS |
3237 | 3174 |
3238 /** | 3175 /** |
3239 * | 3176 * |
3240 * @param h is the normal height, this will be reduced automatically if needed for the last row | 3177 * @param h is the normal height, this will be reduced automatically if needed for the last row |
3350 } | 3287 } |
3351 | 3288 |
3352 if(s->flags&CODEC_FLAG_INTERLACED_DCT){ | 3289 if(s->flags&CODEC_FLAG_INTERLACED_DCT){ |
3353 int progressive_score, interlaced_score; | 3290 int progressive_score, interlaced_score; |
3354 | 3291 |
3355 progressive_score= pix_vcmp16x8(ptr, wrap_y ) + pix_vcmp16x8(ptr + wrap_y*8, wrap_y ); | 3292 s->interlaced_dct=0; |
3356 interlaced_score = pix_vcmp16x8(ptr, wrap_y*2) + pix_vcmp16x8(ptr + wrap_y , wrap_y*2); | 3293 progressive_score= s->dsp.ildct_cmp[4](s, ptr , NULL, wrap_y, 8) |
3294 +s->dsp.ildct_cmp[4](s, ptr + wrap_y*8, NULL, wrap_y, 8) - 400; | |
3295 | |
3296 if(progressive_score > 0){ | |
3297 interlaced_score = s->dsp.ildct_cmp[4](s, ptr , NULL, wrap_y*2, 8) | |
3298 +s->dsp.ildct_cmp[4](s, ptr + wrap_y , NULL, wrap_y*2, 8); | |
3299 if(progressive_score > interlaced_score){ | |
3300 s->interlaced_dct=1; | |
3357 | 3301 |
3358 if(progressive_score > interlaced_score + 100){ | 3302 dct_offset= wrap_y; |
3359 s->interlaced_dct=1; | 3303 wrap_y<<=1; |
3360 | 3304 } |
3361 dct_offset= wrap_y; | 3305 } |
3362 wrap_y<<=1; | |
3363 }else | |
3364 s->interlaced_dct=0; | |
3365 } | 3306 } |
3366 | 3307 |
3367 s->dsp.get_pixels(s->block[0], ptr , wrap_y); | 3308 s->dsp.get_pixels(s->block[0], ptr , wrap_y); |
3368 s->dsp.get_pixels(s->block[1], ptr + 8, wrap_y); | 3309 s->dsp.get_pixels(s->block[1], ptr + 8, wrap_y); |
3369 s->dsp.get_pixels(s->block[2], ptr + dct_offset , wrap_y); | 3310 s->dsp.get_pixels(s->block[2], ptr + dct_offset , wrap_y); |
3428 emu=1; | 3369 emu=1; |
3429 } | 3370 } |
3430 | 3371 |
3431 if(s->flags&CODEC_FLAG_INTERLACED_DCT){ | 3372 if(s->flags&CODEC_FLAG_INTERLACED_DCT){ |
3432 int progressive_score, interlaced_score; | 3373 int progressive_score, interlaced_score; |
3374 | |
3375 s->interlaced_dct=0; | |
3376 progressive_score= s->dsp.ildct_cmp[0](s, dest_y , ptr_y , wrap_y, 8) | |
3377 +s->dsp.ildct_cmp[0](s, dest_y + wrap_y*8, ptr_y + wrap_y*8, wrap_y, 8) - 400; | |
3433 | 3378 |
3434 progressive_score= pix_diff_vcmp16x8(ptr_y , dest_y , wrap_y ) | 3379 if(s->avctx->ildct_cmp == FF_CMP_VSSE) progressive_score -= 400; |
3435 + pix_diff_vcmp16x8(ptr_y + wrap_y*8, dest_y + wrap_y*8, wrap_y ); | 3380 |
3436 interlaced_score = pix_diff_vcmp16x8(ptr_y , dest_y , wrap_y*2) | 3381 if(progressive_score>0){ |
3437 + pix_diff_vcmp16x8(ptr_y + wrap_y , dest_y + wrap_y , wrap_y*2); | 3382 interlaced_score = s->dsp.ildct_cmp[0](s, dest_y , ptr_y , wrap_y*2, 8) |
3383 +s->dsp.ildct_cmp[0](s, dest_y + wrap_y , ptr_y + wrap_y , wrap_y*2, 8); | |
3438 | 3384 |
3439 if(progressive_score > interlaced_score + 600){ | 3385 if(progressive_score > interlaced_score){ |
3440 s->interlaced_dct=1; | 3386 s->interlaced_dct=1; |
3441 | 3387 |
3442 dct_offset= wrap_y; | 3388 dct_offset= wrap_y; |
3443 wrap_y<<=1; | 3389 wrap_y<<=1; |
3444 }else | 3390 } |
3445 s->interlaced_dct=0; | 3391 } |
3446 } | 3392 } |
3447 | 3393 |
3448 s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , wrap_y); | 3394 s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , wrap_y); |
3449 s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y); | 3395 s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y); |
3450 s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset , dest_y + dct_offset , wrap_y); | 3396 s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset , dest_y + dct_offset , wrap_y); |