/*****************************************************************************
- * deblock.c: h264 encoder library
+ * deblock.c: deblocking
*****************************************************************************
- * Copyright (C) 2003-2008 x264 project
+ * Copyright (C) 2003-2010 x264 project
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Loren Merritt <lorenm@u.washington.edu>
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@x264.com.
*****************************************************************************/
#include "common.h"
int mb_xy = h->mb.i_mb_xy;
int transform_8x8 = h->mb.mb_transform_size[h->mb.i_mb_xy];
int intra_cur = IS_INTRA( h->mb.type[mb_xy] );
- uint8_t (*bs)[4][4] = h->deblock_strength[mb_y&b_interlaced][mb_x];
+ uint8_t (*bs)[4][4] = h->deblock_strength[mb_y&1][mb_x];
pixel *pixy = h->fdec->plane[0] + 16*mb_y*stridey + 16*mb_x;
pixel *pixuv = h->fdec->plane[1] + 8*mb_y*strideuv + 16*mb_x;
FILTER( , 1, 2, qp, qpc );
if( !transform_8x8 ) FILTER( , 1, 3, qp, qpc );
}
+
+ #undef FILTER
}
}
+/* For deblock-aware RD.
+ * TODO:
+ * deblock macroblock edges
+ * support analysis partitions smaller than 16x16
+ * deblock chroma
+ * handle duplicate refs correctly
+ * handle cavlc+8x8dct correctly
+ */
+void x264_macroblock_deblock( x264_t *h )
+{
+ int qp_thresh = 15 - X264_MIN( h->sh.i_alpha_c0_offset, h->sh.i_beta_offset ) - X264_MAX( 0, h->param.analyse.i_chroma_qp_offset );
+ int qp = h->mb.i_qp;
+ if( qp <= qp_thresh || h->mb.i_type == P_SKIP )
+ return;
+
+ uint8_t (*bs)[4][4] = h->deblock_strength[h->mb.i_mb_y&1][h->mb.i_mb_x];
+ if( IS_INTRA( h->mb.i_type ) )
+ memset( bs, 3, 2*4*4*sizeof(uint8_t) );
+ else
+ h->loopf.deblock_strength( h->mb.cache.non_zero_count, h->mb.cache.ref, h->mb.cache.mv,
+ bs, 4 >> h->sh.b_mbaff, h->sh.i_type == SLICE_TYPE_B );
+
+ int transform_8x8 = h->mb.b_transform_8x8;
+ pixel *fdec = h->mb.pic.p_fdec[0];
+
+ #define FILTER( dir, edge )\
+ do\
+ {\
+ deblock_edge( h, fdec + 4*edge*(dir?FDEC_STRIDE:1),\
+ FDEC_STRIDE, bs[dir][edge], qp, 0,\
+ h->loopf.deblock_luma[dir] );\
+ } while(0)
+
+ if( !transform_8x8 ) FILTER( 0, 1 );
+ FILTER( 0, 2 );
+ if( !transform_8x8 ) FILTER( 0, 3 );
+
+ if( !transform_8x8 ) FILTER( 1, 1 );
+ FILTER( 1, 2 );
+ if( !transform_8x8 ) FILTER( 1, 3 );
+
+ #undef FILTER
+}
+
#if HAVE_MMX
void x264_deblock_v_luma_sse2( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );
void x264_deblock_h_luma_sse2( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 );