Mercurial > libavcodec.hg
comparison mpegvideo.c @ 2292:8556f080fcc2 libavcodec
lowres 4mv
author | michael |
---|---|
date | Sat, 09 Oct 2004 12:02:19 +0000 |
parents | c4e882a7c07c |
children | 41b5a7bd9a96 |
comparison
equal
deleted
inserted
replaced
2291:c4e882a7c07c | 2292:8556f080fcc2 |
---|---|
2496 src += s->linesize; | 2496 src += s->linesize; |
2497 pix_op[dxy](dest, src, stride, h); | 2497 pix_op[dxy](dest, src, stride, h); |
2498 return emu; | 2498 return emu; |
2499 } | 2499 } |
2500 | 2500 |
2501 static inline int hpel_motion_lowres(MpegEncContext *s, | |
2502 uint8_t *dest, uint8_t *src, | |
2503 int field_based, int field_select, | |
2504 int src_x, int src_y, | |
2505 int width, int height, int stride, | |
2506 int h_edge_pos, int v_edge_pos, | |
2507 int w, int h, h264_chroma_mc_func *pix_op, | |
2508 int motion_x, int motion_y) | |
2509 { | |
2510 const int lowres= s->avctx->lowres; | |
2511 const int s_mask= (2<<lowres)-1; | |
2512 int emu=0; | |
2513 int sx, sy; | |
2514 | |
2515 if(s->quarter_sample){ | |
2516 motion_x/=2; | |
2517 motion_y/=2; | |
2518 } | |
2519 | |
2520 sx= motion_x & s_mask; | |
2521 sy= motion_y & s_mask; | |
2522 src_x += motion_x >> (lowres+1); | |
2523 src_y += motion_y >> (lowres+1); | |
2524 | |
2525 src += src_y * stride + src_x; | |
2526 | |
2527 if( (unsigned)src_x > h_edge_pos - (!!sx) - w | |
2528 || (unsigned)src_y >(v_edge_pos >> field_based) - (!!sy) - h){ | |
2529 ff_emulated_edge_mc(s->edge_emu_buffer, src, s->linesize, w+1, (h+1)<<field_based, | |
2530 src_x, src_y<<field_based, h_edge_pos, v_edge_pos); | |
2531 src= s->edge_emu_buffer; | |
2532 emu=1; | |
2533 } | |
2534 | |
2535 sx <<= 2 - lowres; | |
2536 sy <<= 2 - lowres; | |
2537 if(field_select) | |
2538 src += s->linesize; | |
2539 pix_op[lowres](dest, src, stride, h, sx, sy); | |
2540 return emu; | |
2541 } | |
2542 | |
2501 /* apply one mpeg motion vector to the three components */ | 2543 /* apply one mpeg motion vector to the three components */ |
2502 static always_inline void mpeg_motion(MpegEncContext *s, | 2544 static always_inline void mpeg_motion(MpegEncContext *s, |
2503 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, | 2545 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, |
2504 int field_based, int bottom_field, int field_select, | 2546 int field_based, int bottom_field, int field_select, |
2505 uint8_t **ref_picture, op_pixels_func (*pix_op)[4], | 2547 uint8_t **ref_picture, op_pixels_func (*pix_op)[4], |
2935 ptr= s->edge_emu_buffer; | 2977 ptr= s->edge_emu_buffer; |
2936 } | 2978 } |
2937 pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8); | 2979 pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8); |
2938 } | 2980 } |
2939 | 2981 |
2982 static inline void chroma_4mv_motion_lowres(MpegEncContext *s, | |
2983 uint8_t *dest_cb, uint8_t *dest_cr, | |
2984 uint8_t **ref_picture, | |
2985 h264_chroma_mc_func *pix_op, | |
2986 int mx, int my){ | |
2987 const int lowres= s->avctx->lowres; | |
2988 const int block_s= 8>>lowres; | |
2989 const int s_mask= (2<<lowres)-1; | |
2990 const int h_edge_pos = s->h_edge_pos >> (lowres+1); | |
2991 const int v_edge_pos = s->v_edge_pos >> (lowres+1); | |
2992 int emu=0, src_x, src_y, offset, sx, sy; | |
2993 uint8_t *ptr; | |
2994 | |
2995 if(s->quarter_sample){ | |
2996 mx/=2; | |
2997 my/=2; | |
2998 } | |
2999 | |
3000 /* In case of 8X8, we construct a single chroma motion vector | |
3001 with a special rounding */ | |
3002 mx= ff_h263_round_chroma(mx); | |
3003 my= ff_h263_round_chroma(my); | |
3004 | |
3005 sx= mx & s_mask; | |
3006 sy= my & s_mask; | |
3007 src_x = s->mb_x*block_s + (mx >> (lowres+1)); | |
3008 src_y = s->mb_y*block_s + (my >> (lowres+1)); | |
3009 | |
3010 offset = src_y * s->uvlinesize + src_x; | |
3011 ptr = ref_picture[1] + offset; | |
3012 if(s->flags&CODEC_FLAG_EMU_EDGE){ | |
3013 if( (unsigned)src_x > h_edge_pos - (!!sx) - block_s | |
3014 || (unsigned)src_y > v_edge_pos - (!!sy) - block_s){ | |
3015 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos); | |
3016 ptr= s->edge_emu_buffer; | |
3017 emu=1; | |
3018 } | |
3019 } | |
3020 sx <<= 2 - lowres; | |
3021 sy <<= 2 - lowres; | |
3022 pix_op[lowres](dest_cb, ptr, s->uvlinesize, block_s, sx, sy); | |
3023 | |
3024 ptr = ref_picture[2] + offset; | |
3025 if(emu){ | |
3026 ff_emulated_edge_mc(s->edge_emu_buffer, ptr, s->uvlinesize, 9, 9, src_x, src_y, h_edge_pos, v_edge_pos); | |
3027 ptr= s->edge_emu_buffer; | |
3028 } | |
3029 pix_op[lowres](dest_cr, ptr, s->uvlinesize, block_s, sx, sy); | |
3030 } | |
3031 | |
2940 /** | 3032 /** |
2941 * motion compesation of a single macroblock | 3033 * motion compesation of a single macroblock |
2942 * @param s context | 3034 * @param s context |
2943 * @param dest_y luma destination pointer | 3035 * @param dest_y luma destination pointer |
2944 * @param dest_cb chroma cb/u destination pointer | 3036 * @param dest_cb chroma cb/u destination pointer |
3202 static inline void MPV_motion_lowres(MpegEncContext *s, | 3294 static inline void MPV_motion_lowres(MpegEncContext *s, |
3203 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, | 3295 uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr, |
3204 int dir, uint8_t **ref_picture, | 3296 int dir, uint8_t **ref_picture, |
3205 h264_chroma_mc_func *pix_op) | 3297 h264_chroma_mc_func *pix_op) |
3206 { | 3298 { |
3207 int dxy, mx, my, src_x, src_y, motion_x, motion_y; | 3299 int mx, my; |
3208 int mb_x, mb_y, i; | 3300 int mb_x, mb_y, i; |
3209 uint8_t *ptr, *dest; | |
3210 const int lowres= s->avctx->lowres; | 3301 const int lowres= s->avctx->lowres; |
3211 const int block_s= 8>>lowres; | 3302 const int block_s= 8>>lowres; |
3212 | 3303 |
3213 mb_x = s->mb_x; | 3304 mb_x = s->mb_x; |
3214 mb_y = s->mb_y; | 3305 mb_y = s->mb_y; |
3218 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | 3309 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, |
3219 0, 0, 0, | 3310 0, 0, 0, |
3220 ref_picture, pix_op, | 3311 ref_picture, pix_op, |
3221 s->mv[dir][0][0], s->mv[dir][0][1], 2*block_s); | 3312 s->mv[dir][0][0], s->mv[dir][0][1], 2*block_s); |
3222 break; | 3313 break; |
3223 /* case MV_TYPE_8X8: | 3314 case MV_TYPE_8X8: |
3224 mx = 0; | 3315 mx = 0; |
3225 my = 0; | 3316 my = 0; |
3226 for(i=0;i<4;i++) { | 3317 for(i=0;i<4;i++) { |
3227 hpel_motion(s, dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize, | 3318 hpel_motion_lowres(s, dest_y + ((i & 1) + (i >> 1) * s->linesize)*block_s, |
3228 ref_picture[0], 0, 0, | 3319 ref_picture[0], 0, 0, |
3229 mb_x * 16 + (i & 1) * 8, mb_y * 16 + (i >>1) * 8, | 3320 (2*mb_x + (i & 1))*block_s, (2*mb_y + (i >>1))*block_s, |
3230 s->width, s->height, s->linesize, | 3321 s->width, s->height, s->linesize, |
3231 s->h_edge_pos, s->v_edge_pos, | 3322 s->h_edge_pos >> lowres, s->v_edge_pos >> lowres, |
3232 8, 8, pix_op[1], | 3323 block_s, block_s, pix_op, |
3233 s->mv[dir][i][0], s->mv[dir][i][1]); | 3324 s->mv[dir][i][0], s->mv[dir][i][1]); |
3234 | 3325 |
3235 mx += s->mv[dir][i][0]; | 3326 mx += s->mv[dir][i][0]; |
3236 my += s->mv[dir][i][1]; | 3327 my += s->mv[dir][i][1]; |
3237 } | 3328 } |
3238 | 3329 |
3239 if(!(s->flags&CODEC_FLAG_GRAY)) | 3330 if(!(s->flags&CODEC_FLAG_GRAY)) |
3240 chroma_4mv_motion(s, dest_cb, dest_cr, ref_picture, pix_op[1], mx, my); | 3331 chroma_4mv_motion_lowres(s, dest_cb, dest_cr, ref_picture, pix_op, mx, my); |
3241 break;*/ | 3332 break; |
3242 case MV_TYPE_FIELD: | 3333 case MV_TYPE_FIELD: |
3243 if (s->picture_structure == PICT_FRAME) { | 3334 if (s->picture_structure == PICT_FRAME) { |
3244 /* top field */ | 3335 /* top field */ |
3245 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, | 3336 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, |
3246 1, 0, s->field_select[dir][0], | 3337 1, 0, s->field_select[dir][0], |