Mercurial > libavcodec.hg
comparison error_resilience.c @ 11483:b16c5c5705df libavcodec
Ensure that the deblock filter accesses the correct MVs for h264.
| author | michael |
|---|---|
| date | Sun, 14 Mar 2010 00:42:26 +0000 |
| parents | c9f240e43ef9 |
| children | 5330f17dc769 |
comparison
equal
deleted
inserted
replaced
| 11482:7211254a444c | 11483:b16c5c5705df |
|---|---|
| 218 * simple horizontal deblocking filter used for error resilience | 218 * simple horizontal deblocking filter used for error resilience |
| 219 * @param w width in 8 pixel blocks | 219 * @param w width in 8 pixel blocks |
| 220 * @param h height in 8 pixel blocks | 220 * @param h height in 8 pixel blocks |
| 221 */ | 221 */ |
| 222 static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){ | 222 static void h_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){ |
| 223 int b_x, b_y; | 223 int b_x, b_y, mvx_stride, mvy_stride; |
| 224 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | 224 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; |
| 225 set_mv_strides(s, &mvx_stride, &mvy_stride); | |
| 226 mvx_stride >>= is_luma; | |
| 227 mvy_stride *= mvx_stride; | |
| 225 | 228 |
| 226 for(b_y=0; b_y<h; b_y++){ | 229 for(b_y=0; b_y<h; b_y++){ |
| 227 for(b_x=0; b_x<w-1; b_x++){ | 230 for(b_x=0; b_x<w-1; b_x++){ |
| 228 int y; | 231 int y; |
| 229 int left_status = s->error_status_table[( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]; | 232 int left_status = s->error_status_table[( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]; |
| 231 int left_intra= IS_INTRA(s->current_picture.mb_type [( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]); | 234 int left_intra= IS_INTRA(s->current_picture.mb_type [( b_x >>is_luma) + (b_y>>is_luma)*s->mb_stride]); |
| 232 int right_intra= IS_INTRA(s->current_picture.mb_type [((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]); | 235 int right_intra= IS_INTRA(s->current_picture.mb_type [((b_x+1)>>is_luma) + (b_y>>is_luma)*s->mb_stride]); |
| 233 int left_damage = left_status&(DC_ERROR|AC_ERROR|MV_ERROR); | 236 int left_damage = left_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
| 234 int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR); | 237 int right_damage= right_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
| 235 int offset= b_x*8 + b_y*stride*8; | 238 int offset= b_x*8 + b_y*stride*8; |
| 236 int16_t *left_mv= s->current_picture.motion_val[0][s->b8_stride*(b_y<<(1-is_luma)) + ( b_x <<(1-is_luma))]; | 239 int16_t *left_mv= s->current_picture.motion_val[0][mvy_stride*b_y + mvx_stride* b_x ]; |
| 237 int16_t *right_mv= s->current_picture.motion_val[0][s->b8_stride*(b_y<<(1-is_luma)) + ((b_x+1)<<(1-is_luma))]; | 240 int16_t *right_mv= s->current_picture.motion_val[0][mvy_stride*b_y + mvx_stride*(b_x+1)]; |
| 238 | 241 |
| 239 if(!(left_damage||right_damage)) continue; // both undamaged | 242 if(!(left_damage||right_damage)) continue; // both undamaged |
| 240 | 243 |
| 241 if( (!left_intra) && (!right_intra) | 244 if( (!left_intra) && (!right_intra) |
| 242 && FFABS(left_mv[0]-right_mv[0]) + FFABS(left_mv[1]+right_mv[1]) < 2) continue; | 245 && FFABS(left_mv[0]-right_mv[0]) + FFABS(left_mv[1]+right_mv[1]) < 2) continue; |
| 278 * simple vertical deblocking filter used for error resilience | 281 * simple vertical deblocking filter used for error resilience |
| 279 * @param w width in 8 pixel blocks | 282 * @param w width in 8 pixel blocks |
| 280 * @param h height in 8 pixel blocks | 283 * @param h height in 8 pixel blocks |
| 281 */ | 284 */ |
| 282 static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){ | 285 static void v_block_filter(MpegEncContext *s, uint8_t *dst, int w, int h, int stride, int is_luma){ |
| 283 int b_x, b_y; | 286 int b_x, b_y, mvx_stride, mvy_stride; |
| 284 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; | 287 uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; |
| 288 set_mv_strides(s, &mvx_stride, &mvy_stride); | |
| 289 mvx_stride >>= is_luma; | |
| 290 mvy_stride *= mvx_stride; | |
| 285 | 291 |
| 286 for(b_y=0; b_y<h-1; b_y++){ | 292 for(b_y=0; b_y<h-1; b_y++){ |
| 287 for(b_x=0; b_x<w; b_x++){ | 293 for(b_x=0; b_x<w; b_x++){ |
| 288 int x; | 294 int x; |
| 289 int top_status = s->error_status_table[(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]; | 295 int top_status = s->error_status_table[(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]; |
| 291 int top_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]); | 297 int top_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ( b_y >>is_luma)*s->mb_stride]); |
| 292 int bottom_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]); | 298 int bottom_intra= IS_INTRA(s->current_picture.mb_type [(b_x>>is_luma) + ((b_y+1)>>is_luma)*s->mb_stride]); |
| 293 int top_damage = top_status&(DC_ERROR|AC_ERROR|MV_ERROR); | 299 int top_damage = top_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
| 294 int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR); | 300 int bottom_damage= bottom_status&(DC_ERROR|AC_ERROR|MV_ERROR); |
| 295 int offset= b_x*8 + b_y*stride*8; | 301 int offset= b_x*8 + b_y*stride*8; |
| 296 int16_t *top_mv= s->current_picture.motion_val[0][s->b8_stride*( b_y <<(1-is_luma)) + (b_x<<(1-is_luma))]; | 302 int16_t *top_mv= s->current_picture.motion_val[0][mvy_stride* b_y + mvx_stride*b_x]; |
| 297 int16_t *bottom_mv= s->current_picture.motion_val[0][s->b8_stride*((b_y+1)<<(1-is_luma)) + (b_x<<(1-is_luma))]; | 303 int16_t *bottom_mv= s->current_picture.motion_val[0][mvy_stride*(b_y+1) + mvx_stride*b_x]; |
| 298 | 304 |
| 299 if(!(top_damage||bottom_damage)) continue; // both undamaged | 305 if(!(top_damage||bottom_damage)) continue; // both undamaged |
| 300 | 306 |
| 301 if( (!top_intra) && (!bottom_intra) | 307 if( (!top_intra) && (!bottom_intra) |
| 302 && FFABS(top_mv[0]-bottom_mv[0]) + FFABS(top_mv[1]+bottom_mv[1]) < 2) continue; | 308 && FFABS(top_mv[0]-bottom_mv[0]) + FFABS(top_mv[1]+bottom_mv[1]) < 2) continue; |
