Revision 622348f9 libavcodec/mpegvideo.c

View differences:

libavcodec/mpegvideo.c
973 973
    s->progressive_frame= 
974 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 978
    ff_init_me(s);
977 979

  
978 980
#ifdef CONFIG_ENCODERS
......
3168 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 3173
#endif //CONFIG_ENCODERS
3237 3174

  
3238 3175
/**
......
3352 3289
        if(s->flags&CODEC_FLAG_INTERLACED_DCT){
3353 3290
            int progressive_score, interlaced_score;
3354 3291

  
3355
            progressive_score= pix_vcmp16x8(ptr, wrap_y  ) + pix_vcmp16x8(ptr + wrap_y*8, wrap_y );
3356
            interlaced_score = pix_vcmp16x8(ptr, wrap_y*2) + pix_vcmp16x8(ptr + wrap_y  , wrap_y*2);
3357
            
3358
            if(progressive_score > interlaced_score + 100){
3359
                s->interlaced_dct=1;
3292
            s->interlaced_dct=0;
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;
3360 3301
            
3361
                dct_offset= wrap_y;
3362
                wrap_y<<=1;
3363
            }else
3364
                s->interlaced_dct=0;
3302
                    dct_offset= wrap_y;
3303
                    wrap_y<<=1;
3304
                }
3305
            }
3365 3306
        }
3366 3307
        
3367 3308
	s->dsp.get_pixels(s->block[0], ptr                 , wrap_y);
......
3430 3371
        
3431 3372
        if(s->flags&CODEC_FLAG_INTERLACED_DCT){
3432 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  ) 
3435
                             + pix_diff_vcmp16x8(ptr_y + wrap_y*8, dest_y + wrap_y*8, wrap_y  );
3436
            interlaced_score = pix_diff_vcmp16x8(ptr_y           , dest_y           , wrap_y*2)
3437
                             + pix_diff_vcmp16x8(ptr_y + wrap_y  , dest_y + wrap_y  , wrap_y*2);
3379
            if(s->avctx->ildct_cmp == FF_CMP_VSSE) progressive_score -= 400;
3380

  
3381
            if(progressive_score>0){
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){
3440
                s->interlaced_dct=1;
3385
                if(progressive_score > interlaced_score){
3386
                    s->interlaced_dct=1;
3441 3387
            
3442
                dct_offset= wrap_y;
3443
                wrap_y<<=1;
3444
            }else
3445
                s->interlaced_dct=0;
3388
                    dct_offset= wrap_y;
3389
                    wrap_y<<=1;
3390
                }
3391
            }
3446 3392
        }
3447 3393
        
3448 3394
	s->dsp.diff_pixels(s->block[0], ptr_y                 , dest_y                 , wrap_y);

Also available in: Unified diff