From: Henrik Gramner Date: Wed, 10 Aug 2011 18:25:07 +0000 (+0200) Subject: Expand borders before chroma weightp analysis X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=ada894da37b88f9f92b8747d91245fe88944a8fb;p=x264.git Expand borders before chroma weightp analysis Prevents mc from using uninitialized source pixels. --- diff --git a/common/frame.c b/common/frame.c index ffda67fb..1a799c68 100644 --- a/common/frame.c +++ b/common/frame.c @@ -542,6 +542,13 @@ void x264_frame_expand_border_lowres( x264_frame_t *frame ) plane_expand_border( frame->lowres[i], frame->i_stride_lowres, frame->i_width_lowres, frame->i_lines_lowres, PADH, PADV, 1, 1, 0 ); } +void x264_frame_expand_border_chroma( x264_t *h, x264_frame_t *frame, int plane ) +{ + int shift = !CHROMA444; + plane_expand_border( frame->plane[plane], frame->i_stride[plane], 16*h->mb.i_mb_width, 16*h->mb.i_mb_height>>shift, + PADH, PADV>>shift, 1, 1, shift ); +} + void x264_frame_expand_border_mod16( x264_t *h, x264_frame_t *frame ) { for( int i = 0; i < frame->i_plane; i++ ) diff --git a/common/frame.h b/common/frame.h index 1214672e..c87343cb 100644 --- a/common/frame.h +++ b/common/frame.h @@ -198,6 +198,7 @@ int x264_frame_copy_picture( x264_t *h, x264_frame_t *dst, x264_pictur void x264_frame_expand_border( x264_t *h, x264_frame_t *frame, int mb_y, int b_end ); void x264_frame_expand_border_filtered( x264_t *h, x264_frame_t *frame, int mb_y, int b_end ); void x264_frame_expand_border_lowres( x264_frame_t *frame ); +void x264_frame_expand_border_chroma( x264_t *h, x264_frame_t *frame, int plane ); void x264_frame_expand_border_mod16( x264_t *h, x264_frame_t *frame ); void x264_expand_border_mbpair( x264_t *h, int mb_x, int mb_y ); diff --git a/encoder/slicetype.c b/encoder/slicetype.c index 417e8012..f005b5f5 100644 --- a/encoder/slicetype.c +++ b/encoder/slicetype.c @@ -115,6 +115,7 @@ static NOINLINE void x264_weight_cost_init_chroma( x264_t *h, x264_frame_t *fenc if( fenc->lowres_mvs[0][ref0_distance][0][0] != 0x7FFF ) { + x264_frame_expand_border_chroma( h, ref, 1 ); for( int y = 0, mb_xy = 0, pel_offset_y = 0; y < i_lines; y += 8, pel_offset_y = y*i_stride ) for( int x = 0, pel_offset_x = 0; x < i_width; x += 8, mb_xy++, pel_offset_x += 8 ) { @@ -141,6 +142,7 @@ static NOINLINE pixel *x264_weight_cost_init_chroma444( x264_t *h, x264_frame_t if( fenc->lowres_mvs[0][ref0_distance][0][0] != 0x7FFF ) { + x264_frame_expand_border_chroma( h, ref, p ); for( int y = 0, mb_xy = 0, pel_offset_y = 0; y < i_lines; y += 16, pel_offset_y = y*i_stride ) for( int x = 0, pel_offset_x = 0; x < i_width; x += 16, mb_xy++, pel_offset_x += 16 ) {