From: Ronald S. Bultje Date: Sat, 8 Jun 2013 00:20:50 +0000 (-0700) Subject: Align frame size to 8 instead of 16. X-Git-Tag: v1.3.0~1104^2~31^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=71701f3d40fb64a21420d0e0c15d4c204f5963cb;p=platform%2Fupstream%2Flibvpx.git Align frame size to 8 instead of 16. Change-Id: Ic606ef1b31e49963a779455a1e010a9ebb0f3f1f --- diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c index 4960963..ce55267 100644 --- a/vp9/common/vp9_alloccommon.c +++ b/vp9/common/vp9_alloccommon.c @@ -68,8 +68,8 @@ void vp9_free_frame_buffers(VP9_COMMON *oci) { } static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) { - cm->mb_cols = aligned_width >> 4; - cm->mb_rows = aligned_height >> 4; + cm->mb_cols = (aligned_width + 8) >> 4; + cm->mb_rows = (aligned_height + 8) >> 4; cm->MBs = cm->mb_rows * cm->mb_cols; cm->mi_cols = aligned_width >> LOG2_MI_SIZE; @@ -95,8 +95,8 @@ int vp9_alloc_frame_buffers(VP9_COMMON *oci, int width, int height) { int i, mi_cols; // Our internal buffers are always multiples of 16 - const int aligned_width = multiple16(width); - const int aligned_height = multiple16(height); + const int aligned_width = multiple8(width); + const int aligned_height = multiple8(height); const int ss_x = oci->subsampling_x; const int ss_y = oci->subsampling_y; @@ -223,8 +223,8 @@ void vp9_initialize_common() { } void vp9_update_frame_size(VP9_COMMON *cm) { - const int aligned_width = multiple16(cm->width); - const int aligned_height = multiple16(cm->height); + const int aligned_width = multiple8(cm->width); + const int aligned_height = multiple8(cm->height); set_mb_mi(cm, aligned_width, aligned_height); setup_mi(cm); diff --git a/vp9/common/vp9_common.h b/vp9/common/vp9_common.h index 5c97f98..0d7babf 100644 --- a/vp9/common/vp9_common.h +++ b/vp9/common/vp9_common.h @@ -56,8 +56,8 @@ static INLINE double fclamp(double value, double low, double high) { return value < low ? low : (value > high ? high : value); } -static INLINE int multiple16(int value) { - return (value + 15) & ~15; +static INLINE int multiple8(int value) { + return (value + 7) & ~7; } #define SYNC_CODE_0 0x49 diff --git a/vp9/common/vp9_loopfilter.c b/vp9/common/vp9_loopfilter.c index 0347630..30fc278 100644 --- a/vp9/common/vp9_loopfilter.c +++ b/vp9/common/vp9_loopfilter.c @@ -180,6 +180,7 @@ static int sb_mb_lf_skip(const MODE_INFO *const mip0, static void lpf_mb(VP9_COMMON *cm, const MODE_INFO *mi, int do_left_mb_v, int do_above_mb_h, int do_left_mbuv_v, int do_above_mbuv_h, + int mb_row, int mb_col, uint8_t *y_ptr, uint8_t *u_ptr, uint8_t *v_ptr, int y_stride, int uv_stride) { loop_filter_info_n *lfi_n = &cm->lf_info; @@ -209,7 +210,7 @@ static void lpf_mb(VP9_COMMON *cm, const MODE_INFO *mi, vp9_loop_filter_mbh(y_ptr, u_ptr, v_ptr, y_stride, uv_stride, &lfi); } - if (!skip_lf) { + if (!skip_lf && mb_row * 2 + 1 < cm->mi_rows) { if (tx_size >= TX_8X8) { if (tx_size == TX_8X8 && mi->mbmi.sb_type < BLOCK_SIZE_MB16X16) @@ -234,7 +235,7 @@ static void lpf_mb(VP9_COMMON *cm, const MODE_INFO *mi, vp9_loop_filter_mbv(y_ptr, u_ptr, v_ptr, y_stride, uv_stride, &lfi); } - if (!skip_lf) { + if (!skip_lf && mb_col * 2 + 1 < cm->mi_cols) { if (tx_size >= TX_8X8) { if (tx_size == TX_8X8 && mi->mbmi.sb_type < BLOCK_SIZE_MB16X16) @@ -274,6 +275,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context, tx_size >= TX_32X32 && (mb_row & 2)); lpf_mb(cm, mi, do_left_v, do_above_h, do_left_v_mbuv, do_above_h_mbuv, + mb_row, mb_col, y_ptr, y_only? 0 : u_ptr, y_only? 0 : v_ptr, @@ -289,6 +291,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context, tx_size >= TX_32X32 && (mb_row & 2)); lpf_mb(cm, mi, do_left_v, do_above_h, do_left_v_mbuv, do_above_h_mbuv, + mb_row, mb_col + 1, y_ptr + 16, y_only ? 0 : (u_ptr + 8), y_only ? 0 : (v_ptr + 8), @@ -305,6 +308,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context, sb_mb_lf_skip(mode_info_context, mi))); lpf_mb(cm, mi, do_left_v, do_above_h, do_left_v_mbuv, do_above_h_mbuv, + mb_row + 1, mb_col, y_ptr + 16 * y_stride, y_only ? 0 : (u_ptr + 8 * uv_stride), y_only ? 0 : (v_ptr + 8 * uv_stride), @@ -322,6 +326,7 @@ static void lpf_sb32(VP9_COMMON *cm, const MODE_INFO *mode_info_context, sb_mb_lf_skip(mode_info_context + 2, mi))); lpf_mb(cm, mi, do_left_v, do_above_h, do_left_v_mbuv, do_above_h_mbuv, + mb_row + 1, mb_col + 1, y_ptr + 16 * y_stride + 16, y_only ? 0 : (u_ptr + 8 * uv_stride + 8), y_only ? 0 : (v_ptr + 8 * uv_stride + 8), @@ -444,6 +449,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, do_above_h_mbuv = 1; lpf_mb(cm, mi, do_left_v, do_above_h, do_left_v_mbuv, do_above_h_mbuv, + mb_row + k, mb_col, y_ptr + (k * 16) * y_stride, y_only ? 0 : (u_ptr + (k * 8) * uv_stride), y_only ? 0 : (v_ptr + (k * 8) * uv_stride), @@ -456,13 +462,13 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, mode_info_context += 2; // step to next MB } // move pointers to the begining of next sb64 row - y_ptr += y_stride * 64 - post->y_width; + y_ptr += y_stride * 64 - cm->mb_cols * 16; if (!y_only) { - u_ptr += uv_stride * 32 - post->uv_width; - v_ptr += uv_stride * 32 - post->uv_width; + u_ptr += uv_stride * 32 - cm->mb_cols * 8; + v_ptr += uv_stride * 32 - cm->mb_cols * 8; } /* skip to next SB64 row */ - mode_info_context += mis * 8 - cm->mi_cols; + mode_info_context += mis * 8 - cm->mb_cols * 2; } if (extra_sb32_row) { const int sb32_cols = sb64_cols * 2 + extra_sb32_col; @@ -484,6 +490,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, do_above_h_mbuv = 1; lpf_mb(cm, mi, do_left_v, do_above_h, do_left_v_mbuv, do_above_h_mbuv, + mb_row, mb_col, y_ptr, y_only? NULL : u_ptr, y_only? NULL : v_ptr, @@ -496,6 +503,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, do_above_h_mbuv = 1; lpf_mb(cm, mi, do_left_v, do_above_h, do_left_v_mbuv, do_above_h_mbuv, + mb_row + 1, mb_col, y_ptr + 16 * y_stride, y_only ? NULL : (u_ptr + 8 * uv_stride), y_only ? NULL : (v_ptr + 8 * uv_stride), @@ -506,11 +514,11 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, mode_info_context += 2; /* step to next MB */ } // move pointers to the beginning of next sb64 row - y_ptr += y_stride * 32 - post->y_width; - u_ptr += y_only? 0 : uv_stride * 16 - post->uv_width; - v_ptr += y_only? 0 : uv_stride * 16 - post->uv_width; + y_ptr += y_stride * 32 - cm->mb_cols * 16; + u_ptr += y_only? 0 : uv_stride * 16 - cm->mb_cols * 8; + v_ptr += y_only? 0 : uv_stride * 16 - cm->mb_cols * 8; // skip to next MB row if exist - mode_info_context += mis * 4 - cm->mi_cols; + mode_info_context += mis * 4 - cm->mb_cols * 2; mb_row += 2; } if (extra_mb_row) { @@ -522,6 +530,7 @@ void vp9_loop_filter_frame(VP9_COMMON *cm, do_above_h_mbuv = 1; lpf_mb(cm, mi, do_left_v, do_above_h, do_left_v_mbuv, do_above_h_mbuv, + mb_row, mb_col, y_ptr, y_only? 0 : u_ptr, y_only? 0 : v_ptr, diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 65efb54..1287763 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -2409,8 +2409,8 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, int64_t mcomp_filter_cost[4]; /* Scale the source buffer, if required */ - if (cm->mb_cols * 16 != cpi->un_scaled_source->y_width || - cm->mb_rows * 16 != cpi->un_scaled_source->y_height) { + if (cm->mi_cols * 8 != cpi->un_scaled_source->y_width || + cm->mi_rows * 8 != cpi->un_scaled_source->y_height) { scale_and_extend_frame(cpi->un_scaled_source, &cpi->scaled_source); cpi->Source = &cpi->scaled_source; } else { diff --git a/vp9/vp9_iface_common.h b/vp9/vp9_iface_common.h index 1c3cc62..dc41d77 100644 --- a/vp9/vp9_iface_common.h +++ b/vp9/vp9_iface_common.h @@ -29,7 +29,7 @@ static void yuvconfig2image(vpx_image_t *img, const YV12_BUFFER_CONFIG *yv12, img->fmt = VPX_IMG_FMT_I420; } img->w = yv12->y_stride; - img->h = multiple16(yv12->y_height + 2 * VP9BORDERINPIXELS); + img->h = multiple8(yv12->y_height + 2 * VP9BORDERINPIXELS); img->d_w = yv12->y_crop_width; img->d_h = yv12->y_crop_height; img->x_chroma_shift = yv12->uv_width < yv12->y_width; diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c index 632ff71..754a615 100644 --- a/vpx_scale/generic/yv12config.c +++ b/vpx_scale/generic/yv12config.c @@ -125,8 +125,8 @@ int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int ss_x, int ss_y, int border) { if (ybf) { - const int aligned_width = (width + 15) & ~15; - const int aligned_height = (height + 15) & ~15; + const int aligned_width = (width + 7) & ~7; + const int aligned_height = (height + 7) & ~7; const int y_stride = ((aligned_width + 2 * border) + 31) & ~31; const int yplane_size = (aligned_height + 2 * border) * y_stride; const int uv_width = aligned_width >> ss_x;