Revision da9c9637 libavcodec/mpegvideo.c

View differences:

libavcodec/mpegvideo.c
2625 2625
    linesize   = s->current_picture.linesize[0] << field_based;
2626 2626
    uvlinesize = s->current_picture.linesize[1] << field_based;
2627 2627

  
2628
    if(s->quarter_sample){ //FIXME obviously not perfect but qpel wont work in lowres anyway
2629
        motion_x/=2;
2630
        motion_y/=2;
2631
    }
2632
    
2633
    if(field_based){
2634
        motion_y += (bottom_field - field_select)*((1<<lowres)-1);
2635
    }
2636

  
2628 2637
    sx= motion_x & s_mask;
2629 2638
    sy= motion_y & s_mask;
2630 2639
    src_x = s->mb_x*2*block_s               + (motion_x >> (lowres+1));
2631
    src_y = s->mb_y*2*block_s               + (motion_y >> (lowres+1));
2640
    src_y =(s->mb_y*2*block_s>>field_based) + (motion_y >> (lowres+1));
2632 2641
    
2633 2642
    if (s->out_format == FMT_H263) {
2634 2643
        uvsx = sx | ((motion_x & 2)>>1);
......
2648 2657
        uvsx = mx & s_mask;
2649 2658
        uvsy = my & s_mask;
2650 2659
        uvsrc_x = s->mb_x*block_s               + (mx >> (lowres+1));
2651
        uvsrc_y = s->mb_y*block_s               + (my >> (lowres+1));
2660
        uvsrc_y =(s->mb_y*block_s>>field_based) + (my >> (lowres+1));
2652 2661
    }
2653 2662

  
2654 2663
    ptr_y  = ref_picture[0] + src_y * linesize + src_x;
......
2671 2680
            }
2672 2681
    }
2673 2682

  
2683
    if(bottom_field){ //FIXME use this for field pix too instead of the obnoxious hack which changes picture.data
2684
        dest_y += s->linesize;
2685
        dest_cb+= s->uvlinesize;
2686
        dest_cr+= s->uvlinesize;
2687
    }
2688

  
2689
    if(field_select){
2690
        ptr_y += s->linesize;
2691
        ptr_cb+= s->uvlinesize;
2692
        ptr_cr+= s->uvlinesize;
2693
    }
2694

  
2674 2695
    sx <<= 2 - lowres;
2675 2696
    sy <<= 2 - lowres;
2676 2697
    pix_op[lowres-1](dest_y, ptr_y, linesize, h, sx, sy);
......
3177 3198
                              int dir, uint8_t **ref_picture, 
3178 3199
                              h264_chroma_mc_func *pix_op)
3179 3200
{
3180
    assert(s->mv_type == MV_TYPE_16X16);
3181
    mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 
3182
                0, 0, 0,
3183
                ref_picture, pix_op,
3184
                s->mv[dir][0][0], s->mv[dir][0][1], 16>>s->avctx->lowres);
3201
    int dxy, mx, my, src_x, src_y, motion_x, motion_y;
3202
    int mb_x, mb_y, i;
3203
    uint8_t *ptr, *dest;
3204
    const int lowres= s->avctx->lowres;
3205
    const int block_s= 8>>lowres;    
3206

  
3207
    mb_x = s->mb_x;
3208
    mb_y = s->mb_y;
3209

  
3210
    switch(s->mv_type) {
3211
    case MV_TYPE_16X16:
3212
        mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 
3213
                    0, 0, 0,
3214
                    ref_picture, pix_op,
3215
                    s->mv[dir][0][0], s->mv[dir][0][1], 2*block_s);
3216
        break;
3217
/*    case MV_TYPE_8X8:
3218
        mx = 0;
3219
        my = 0;
3220
            for(i=0;i<4;i++) {
3221
                hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize,
3222
                            ref_picture[0], 0, 0,
3223
                            mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8,
3224
                            s->width, s->height, s->linesize,
3225
                            s->h_edge_pos, s->v_edge_pos,
3226
                            8, 8, pix_op[1],
3227
                            s->mv[dir][i][0], s->mv[dir][i][1]);
3228

  
3229
                mx += s->mv[dir][i][0];
3230
                my += s->mv[dir][i][1];
3231
            }
3232

  
3233
        if(!(s->flags&CODEC_FLAG_GRAY))
3234
            chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my);
3235
        break;*/
3236
    case MV_TYPE_FIELD:
3237
        if (s->picture_structure == PICT_FRAME) {
3238
            /* top field */       
3239
            mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
3240
                        1, 0, s->field_select[dir][0],
3241
                        ref_picture, pix_op,
3242
                        s->mv[dir][0][0], s->mv[dir][0][1], block_s);
3243
            /* bottom field */
3244
            mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
3245
                        1, 1, s->field_select[dir][1],
3246
                        ref_picture, pix_op,
3247
                        s->mv[dir][1][0], s->mv[dir][1][1], block_s);
3248
        } else {
3249
            if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != B_TYPE && !s->first_field){
3250
                ref_picture= s->current_picture_ptr->data;
3251
            } 
3252

  
3253
            mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
3254
                        0, 0, s->field_select[dir][0],
3255
                        ref_picture, pix_op,
3256
                        s->mv[dir][0][0], s->mv[dir][0][1], 2*block_s);
3257
        }
3258
        break;
3259
    case MV_TYPE_16X8:
3260
        for(i=0; i<2; i++){
3261
            uint8_t ** ref2picture;
3262

  
3263
            if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == B_TYPE || s->first_field){
3264
                ref2picture= ref_picture;
3265
            }else{
3266
                ref2picture= s->current_picture_ptr->data;
3267
            } 
3268

  
3269
            mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 
3270
                        0, 0, s->field_select[dir][i],
3271
                        ref2picture, pix_op,
3272
                        s->mv[dir][i][0], s->mv[dir][i][1] + 2*block_s*i, block_s);
3273
                
3274
            dest_y += 2*block_s*s->linesize;
3275
            dest_cb+= (2*block_s>>s->chroma_y_shift)*s->uvlinesize;
3276
            dest_cr+= (2*block_s>>s->chroma_y_shift)*s->uvlinesize;
3277
        }        
3278
        break;
3279
    case MV_TYPE_DMV:
3280
        if(s->picture_structure == PICT_FRAME){
3281
            for(i=0; i<2; i++){
3282
                int j;
3283
                for(j=0; j<2; j++){
3284
                    mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
3285
                                1, j, j^i,
3286
                                ref_picture, pix_op,
3287
                                s->mv[dir][2*i + j][0], s->mv[dir][2*i + j][1], block_s);
3288
                }
3289
                pix_op = s->dsp.avg_h264_chroma_pixels_tab;
3290
            }
3291
        }else{
3292
            for(i=0; i<2; i++){
3293
                mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 
3294
                            0, 0, s->picture_structure != i+1,
3295
                            ref_picture, pix_op,
3296
                            s->mv[dir][2*i][0],s->mv[dir][2*i][1],2*block_s);
3297

  
3298
                // after put we make avg of the same block
3299
                pix_op = s->dsp.avg_h264_chroma_pixels_tab;
3300

  
3301
                //opposite parity is always in the same frame if this is second field
3302
                if(!s->first_field){
3303
                    ref_picture = s->current_picture_ptr->data;    
3304
                }
3305
            }
3306
        }
3307
    break;
3308
    default: assert(0);
3309
    }
3185 3310
}
3186 3311

  
3187 3312
/* put block[] to dest[] */

Also available in: Unified diff