Mercurial > libavcodec.hg
comparison vc1.c @ 3510:f8d3be212bce libavcodec
Replace code for clipping MV vectors (which is wrong to use here) with clipping source coords.
author | kostya |
---|---|
date | Sat, 22 Jul 2006 03:57:53 +0000 |
parents | da6095607f26 |
children | f88787aeed6b |
comparison
equal
deleted
inserted
replaced
3509:da6095607f26 | 3510:f8d3be212bce |
---|---|
892 | 892 |
893 dsp->put_pixels_clamped(block[4], v->s.dest[1], us); | 893 dsp->put_pixels_clamped(block[4], v->s.dest[1], us); |
894 dsp->put_pixels_clamped(block[5], v->s.dest[2], vs); | 894 dsp->put_pixels_clamped(block[5], v->s.dest[2], vs); |
895 } | 895 } |
896 | 896 |
897 /* clip motion vector as specified in 8.3.6.5 */ | |
898 #define CLIP_RANGE(mv, src, lim, bs) \ | |
899 if(mv < -bs) mv = -bs - src * bs; \ | |
900 if(mv > lim) mv = lim - src * bs; | |
901 | |
902 /** Do motion compensation over 1 macroblock | 897 /** Do motion compensation over 1 macroblock |
903 * Mostly adapted hpel_motion and qpel_motion from mpegvideo.c | 898 * Mostly adapted hpel_motion and qpel_motion from mpegvideo.c |
904 */ | 899 */ |
905 static void vc1_mc_1mv(VC1Context *v) | 900 static void vc1_mc_1mv(VC1Context *v) |
906 { | 901 { |
922 src_x = s->mb_x * 16 + (mx >> 2); | 917 src_x = s->mb_x * 16 + (mx >> 2); |
923 src_y = s->mb_y * 16 + (my >> 2); | 918 src_y = s->mb_y * 16 + (my >> 2); |
924 uvsrc_x = s->mb_x * 8 + (uvmx >> 2); | 919 uvsrc_x = s->mb_x * 8 + (uvmx >> 2); |
925 uvsrc_y = s->mb_y * 8 + (uvmy >> 2); | 920 uvsrc_y = s->mb_y * 8 + (uvmy >> 2); |
926 | 921 |
927 CLIP_RANGE( src_x, s->mb_x, s->mb_width * 16, 16); | 922 src_x = clip( src_x, -16, s->mb_width * 16); |
928 CLIP_RANGE( src_y, s->mb_y, s->mb_height * 16, 16); | 923 src_y = clip( src_y, -16, s->mb_height * 16); |
929 CLIP_RANGE(uvsrc_x, s->mb_x, s->mb_width * 8, 8); | 924 uvsrc_x = clip(uvsrc_x, -8, s->mb_width * 8); |
930 CLIP_RANGE(uvsrc_y, s->mb_y, s->mb_height * 8, 8); | 925 uvsrc_y = clip(uvsrc_y, -8, s->mb_height * 8); |
931 | 926 |
932 srcY += src_y * s->linesize + src_x; | 927 srcY += src_y * s->linesize + src_x; |
933 srcU += uvsrc_y * s->uvlinesize + uvsrc_x; | 928 srcU += uvsrc_y * s->uvlinesize + uvsrc_x; |
934 srcV += uvsrc_y * s->uvlinesize + uvsrc_x; | 929 srcV += uvsrc_y * s->uvlinesize + uvsrc_x; |
935 | 930 |
1020 off = s->linesize * 4 * (n&2) + (n&1) * 8; | 1015 off = s->linesize * 4 * (n&2) + (n&1) * 8; |
1021 | 1016 |
1022 src_x = s->mb_x * 16 + (n&1) * 8 + (mx >> 2); | 1017 src_x = s->mb_x * 16 + (n&1) * 8 + (mx >> 2); |
1023 src_y = s->mb_y * 16 + (n&2) * 4 + (my >> 2); | 1018 src_y = s->mb_y * 16 + (n&2) * 4 + (my >> 2); |
1024 | 1019 |
1025 CLIP_RANGE(src_x, s->mb_x, s->mb_width * 16, 16); | 1020 src_x = clip( src_x, -16, s->mb_width * 16); |
1026 CLIP_RANGE(src_y, s->mb_y, s->mb_height * 16, 16); | 1021 src_y = clip( src_y, -16, s->mb_height * 16); |
1027 | 1022 |
1028 srcY += src_y * s->linesize + src_x; | 1023 srcY += src_y * s->linesize + src_x; |
1029 | 1024 |
1030 if((unsigned)src_x > s->h_edge_pos - (mx&3) - 16 | 1025 if((unsigned)src_x > s->h_edge_pos - (mx&3) - 16 |
1031 || (unsigned)src_y > s->v_edge_pos - (my&3) - 16){ | 1026 || (unsigned)src_y > s->v_edge_pos - (my&3) - 16){ |
1122 uvmy = (ty + ((ty&3) == 3)) >> 1; | 1117 uvmy = (ty + ((ty&3) == 3)) >> 1; |
1123 | 1118 |
1124 uvsrc_x = s->mb_x * 8 + (uvmx >> 2); | 1119 uvsrc_x = s->mb_x * 8 + (uvmx >> 2); |
1125 uvsrc_y = s->mb_y * 8 + (uvmy >> 2); | 1120 uvsrc_y = s->mb_y * 8 + (uvmy >> 2); |
1126 | 1121 |
1127 CLIP_RANGE(uvsrc_x, s->mb_x, s->mb_width * 8, 8); | 1122 uvsrc_x = clip(uvsrc_x, -8, s->mb_width * 8); |
1128 CLIP_RANGE(uvsrc_y, s->mb_y, s->mb_height * 8, 8); | 1123 uvsrc_y = clip(uvsrc_y, -8, s->mb_height * 8); |
1129 srcU = s->last_picture.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; | 1124 srcU = s->last_picture.data[1] + uvsrc_y * s->uvlinesize + uvsrc_x; |
1130 srcV = s->last_picture.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; | 1125 srcV = s->last_picture.data[2] + uvsrc_y * s->uvlinesize + uvsrc_x; |
1131 if((unsigned)uvsrc_x > (s->h_edge_pos >> 1) - ((uvmx >> 1)&1) - 8 | 1126 if((unsigned)uvsrc_x > (s->h_edge_pos >> 1) - ((uvmx >> 1)&1) - 8 |
1132 || (unsigned)uvsrc_y > (s->v_edge_pos >> 1) - ((uvmy >> 1)&1) - 8){ | 1127 || (unsigned)uvsrc_y > (s->v_edge_pos >> 1) - ((uvmy >> 1)&1) - 8){ |
1133 ff_emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, 8+1, 8+1, | 1128 ff_emulated_edge_mc(s->edge_emu_buffer , srcU, s->uvlinesize, 8+1, 8+1, |