public static void v_block_filter(MpegEncContext s,int[] dst_base,int dst_offset,int w,int h,int stride,int is_luma){
  int b_x, b_y, mvx_stride, mvy_stride;
  int[] cm_base=H264DSPContext.ff_cropTbl;
  int cm_offset=H264DSPContext.MAX_NEG_CROP;
  int[] param=new int[2];
  set_mv_strides(s,param);
  mvx_stride=param[0];
  mvy_stride=param[1];
  mvx_stride>>=is_luma;
  mvy_stride*=mvx_stride;
  for (b_y=0; b_y < h - 1; b_y++) {
    for (b_x=0; b_x < w; b_x++) {
      int x;
      int top_status=s.error_status_table[(b_x >> is_luma) + (b_y >> is_luma) * s.mb_stride];
      int bottom_status=s.error_status_table[(b_x >> is_luma) + ((b_y + 1) >> is_luma) * s.mb_stride];
      int top_intra=7 & (int)(s.current_picture.mb_type_base[s.current_picture.mb_type_offset + (b_x >> is_luma) + (b_y >> is_luma) * s.mb_stride]);
      int bottom_intra=7 & (int)(s.current_picture.mb_type_base[s.current_picture.mb_type_offset + (b_x >> is_luma) + ((b_y + 1) >> is_luma) * s.mb_stride]);
      int top_damage=top_status & (MpegEncContext.DC_ERROR | MpegEncContext.AC_ERROR | MpegEncContext.MV_ERROR);
      int bottom_damage=bottom_status & (MpegEncContext.DC_ERROR | MpegEncContext.AC_ERROR | MpegEncContext.MV_ERROR);
      int offset=b_x * 8 + b_y * stride * 8;
      int[] top_mv=s.current_picture.motion_val_base[0][s.current_picture.motion_val_offset[0] + mvy_stride * b_y + mvx_stride * b_x];
      int[] bottom_mv=s.current_picture.motion_val_base[0][s.current_picture.motion_val_offset[0] + mvy_stride * (b_y + 1) + mvx_stride * b_x];
      if (!(top_damage != 0 || bottom_damage != 0))       continue;
      if ((0 == top_intra) && (0 == bottom_intra) && Math.abs(top_mv[0] - bottom_mv[0]) + Math.abs(top_mv[1] + bottom_mv[1]) < 2)       continue;
      for (x=0; x < 8; x++) {
        int a, b, c, d;
        a=dst_base[dst_offset + offset + x+ 7 * stride] - dst_base[dst_offset + offset + x+ 6 * stride];
        b=dst_base[dst_offset + offset + x+ 8 * stride] - dst_base[dst_offset + offset + x+ 7 * stride];
        c=dst_base[dst_offset + offset + x+ 9 * stride] - dst_base[dst_offset + offset + x+ 8 * stride];
        d=Math.abs(b) - ((Math.abs(a) + Math.abs(c) + 1) >> 1);
        d=Math.max(d,0);
        if (b < 0)         d=-d;
        if (d == 0)         continue;
        if (!(0 != top_damage && 0 != bottom_damage))         d=d * 16 / 9;
        if (0 != top_damage) {
          dst_base[dst_offset + offset + x+ 7 * stride]=cm_base[cm_offset + dst_base[dst_offset + offset + x+ 7 * stride] + ((d * 7) >> 4)];
          dst_base[dst_offset + offset + x+ 6 * stride]=cm_base[cm_offset + dst_base[dst_offset + offset + x+ 6 * stride] + ((d * 5) >> 4)];
          dst_base[dst_offset + offset + x+ 5 * stride]=cm_base[cm_offset + dst_base[dst_offset + offset + x+ 5 * stride] + ((d * 3) >> 4)];
          dst_base[dst_offset + offset + x+ 4 * stride]=cm_base[cm_offset + dst_base[dst_offset + offset + x+ 4 * stride] + ((d * 1) >> 4)];
        }
        if (0 != bottom_damage) {
          dst_base[dst_offset + offset + x+ 8 * stride]=cm_base[cm_offset + dst_base[dst_offset + offset + x+ 8 * stride] - ((d * 7) >> 4)];
          dst_base[dst_offset + offset + x+ 9 * stride]=cm_base[cm_offset + dst_base[dst_offset + offset + x+ 9 * stride] - ((d * 5) >> 4)];
          dst_base[dst_offset + offset + x+ 10 * stride]=cm_base[cm_offset + dst_base[dst_offset + offset + x+ 10 * stride] - ((d * 3) >> 4)];
          dst_base[dst_offset + offset + x+ 11 * stride]=cm_base[cm_offset + dst_base[dst_offset + offset + x+ 11 * stride] - ((d * 1) >> 4)];
        }
      }
    }
  }
}

public static void v_block_filter ( MpegEncContext s , int [ ] dst_base , int dst_offset , int w , int h , int stride , int is_luma ) { int b_x , b_y , mvx_stride , mvy_stride ; int [ ] cm_base = H264DSPContext . ff_cropTbl ; int cm_offset = H264DSPContext . MAX_NEG_CROP ; int [ ] param = new int [ 2 ] ; set_mv_strides ( s , param ) ; mvx_stride = param [ 0 ] ; mvy_stride = param [ 1 ] ; mvx_stride >>= is_luma ; mvy_stride *= mvx_stride ; for ( b_y = 0 ; b_y < h - 1 ; b_y ++ ) { for ( b_x = 0 ; b_x < w ; b_x ++ ) { int x ; int top_status = s . error_status_table [ ( b_x > > is_luma ) + ( b_y > > is_luma ) * s . mb_stride ] ; int bottom_status = s . error_status_table [ ( b_x > > is_luma ) + ( ( b_y + 1 ) > > is_luma ) * s . mb_stride ] ; int top_intra = 7 & ( int ) ( s . current_picture . mb_type_base [ s . current_picture . mb_type_offset + ( b_x > > is_luma ) + ( b_y > > is_luma ) * s . mb_stride ] ) ; int bottom_intra = 7 & ( int ) ( s . current_picture . mb_type_base [ s . current_picture . mb_type_offset + ( b_x > > is_luma ) + ( ( b_y + 1 ) > > is_luma ) * s . mb_stride ] ) ; int top_damage = top_status & ( MpegEncContext . DC_ERROR | MpegEncContext . AC_ERROR | MpegEncContext . MV_ERROR ) ; int bottom_damage = bottom_status & ( MpegEncContext . DC_ERROR | MpegEncContext . AC_ERROR | MpegEncContext . MV_ERROR ) ; int offset = b_x * 8 + b_y * stride * 8 ; int [ ] top_mv = s . current_picture . motion_val_base [ 0 ] [ s . current_picture . motion_val_offset [ 0 ] + mvy_stride * b_y + mvx_stride * b_x ] ; int [ ] bottom_mv = s . current_picture . motion_val_base [ 0 ] [ s . current_picture . motion_val_offset [ 0 ] + mvy_stride * ( b_y + 1 ) + mvx_stride * b_x ] ; if ( ! ( top_damage != 0 || bottom_damage != 0 ) ) continue ; if ( ( 0 == top_intra ) && ( 0 == bottom_intra ) && Math . abs ( top_mv [ 0 ] - bottom_mv [ 0 ] ) + Math . abs ( top_mv [ 1 ] + bottom_mv [ 1 ] ) < 2 ) continue ; for ( x = 0 ; x < 8 ; x ++ ) { int a , b , c , d ; a = dst_base [ dst_offset + offset + x + 7 * stride ] - dst_base [ dst_offset + offset + x + 6 * stride ] ; b = dst_base [ dst_offset + offset + x + 8 * stride ] - dst_base [ dst_offset + offset + x + 7 * stride ] ; c = dst_base [ dst_offset + offset + x + 9 * stride ] - dst_base [ dst_offset + offset + x + 8 * stride ] ; d = Math . abs ( b ) - ( ( Math . abs ( a ) + Math . abs ( c ) + 1 ) > > 1 ) ; d = Math . max ( d , 0 ) ; if ( b < 0 ) d = - d ; if ( d == 0 ) continue ; if ( ! ( 0 != top_damage && 0 != bottom_damage ) ) d = d * 16 / 9 ; if ( 0 != top_damage ) { dst_base [ dst_offset + offset + x + 7 * stride ] = cm_base [ cm_offset + dst_base [ dst_offset + offset + x + 7 * stride ] + ( ( d * 7 ) > > 4 ) ] ; dst_base [ dst_offset + offset + x + 6 * stride ] = cm_base [ cm_offset + dst_base [ dst_offset + offset + x + 6 * stride ] + ( ( d * 5 ) > > 4 ) ] ; dst_base [ dst_offset + offset + x + 5 * stride ] = cm_base [ cm_offset + dst_base [ dst_offset + offset + x + 5 * stride ] + ( ( d * 3 ) > > 4 ) ] ; dst_base [ dst_offset + offset + x + 4 * stride ] = cm_base [ cm_offset + dst_base [ dst_offset + offset + x + 4 * stride ] + ( ( d * 1 ) > > 4 ) ] ; } if ( 0 != bottom_damage ) { dst_base [ dst_offset + offset + x + 8 * stride ] = cm_base [ cm_offset + dst_base [ dst_offset + offset + x + 8 * stride ] - ( ( d * 7 ) > > 4 ) ] ; dst_base [ dst_offset + offset + x + 9 * stride ] = cm_base [ cm_offset + dst_base [ dst_offset + offset + x + 9 * stride ] - ( ( d * 5 ) > > 4 ) ] ; dst_base [ dst_offset + offset + x + 10 * stride ] = cm_base [ cm_offset + dst_base [ dst_offset + offset + x + 10 * stride ] - ( ( d * 3 ) > > 4 ) ] ; dst_base [ dst_offset + offset + x + 11 * stride ] = cm_base [ cm_offset + dst_base [ dst_offset + offset + x + 11 * stride ] - ( ( d * 1 ) > > 4 ) ] ; } } } } }
simple vertical deblocking filter used for error resilience
