ref: 073c7d5eec5454e1e082e33e1847bc1ed9176eb4
parent: b64be439989c4298298b93972ed49c32c5a527af
author: Ronald S. Bultje <[email protected]>
date: Sat Jun 8 08:04:12 EDT 2013
Fix firstpass if framesize is not a multiple of 16. Change-Id: Iec41736c2b6140715f90f40de5ae6cf52497a9b8
--- a/vp9/common/vp9_rtcd_defs.sh
+++ b/vp9/common/vp9_rtcd_defs.sh
@@ -545,6 +545,15 @@
specialize vp9_mse16x16 mmx sse2
vp9_mse16x16_sse2=vp9_mse16x16_wmt
+prototype unsigned int vp9_mse8x16 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"
+specialize vp9_mse8x16
+
+prototype unsigned int vp9_mse16x8 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"
+specialize vp9_mse16x8
+
+prototype unsigned int vp9_mse8x8 "const uint8_t *src_ptr, int source_stride, const uint8_t *ref_ptr, int recon_stride, unsigned int *sse"
+specialize vp9_mse8x8
+
prototype unsigned int vp9_sub_pixel_mse64x64 "const uint8_t *src_ptr, int source_stride, int xoffset, int yoffset, const uint8_t *ref_ptr, int ref_stride, unsigned int *sse"
specialize vp9_sub_pixel_mse64x64
--- a/vp9/encoder/vp9_encodeintra.c
+++ b/vp9/encoder/vp9_encodeintra.c
@@ -22,11 +22,11 @@
mbmi->mode = DC_PRED;
mbmi->ref_frame[0] = INTRA_FRAME;
if (use_16x16_pred) {
- mbmi->txfm_size = TX_16X16;
- vp9_encode_intra_block_y(&cpi->common, x, BLOCK_SIZE_MB16X16);
+ mbmi->txfm_size = mbmi->sb_type >= BLOCK_SIZE_MB16X16 ? TX_16X16 : TX_8X8;
+ vp9_encode_intra_block_y(&cpi->common, x, mbmi->sb_type);
} else {
mbmi->txfm_size = TX_4X4;
- vp9_encode_intra_block_y(&cpi->common, x, BLOCK_SIZE_MB16X16);
+ vp9_encode_intra_block_y(&cpi->common, x, mbmi->sb_type);
}
return vp9_get_mb_ss(x->plane[0].src_diff);
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -346,11 +346,43 @@
// Set up pointers for this macro block recon buffer
xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset;
- vp9_mse16x16(x->plane[0].src.buf, x->plane[0].src.stride,
- xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
- (unsigned int *)(best_motion_err));
+ switch (xd->mode_info_context->mbmi.sb_type) {
+ case BLOCK_SIZE_SB8X8:
+ vp9_mse8x8(x->plane[0].src.buf, x->plane[0].src.stride,
+ xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
+ (unsigned int *)(best_motion_err));
+ break;
+ case BLOCK_SIZE_SB16X8:
+ vp9_mse16x8(x->plane[0].src.buf, x->plane[0].src.stride,
+ xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
+ (unsigned int *)(best_motion_err));
+ break;
+ case BLOCK_SIZE_SB8X16:
+ vp9_mse8x16(x->plane[0].src.buf, x->plane[0].src.stride,
+ xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
+ (unsigned int *)(best_motion_err));
+ break;
+ default:
+ vp9_mse16x16(x->plane[0].src.buf, x->plane[0].src.stride,
+ xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride,
+ (unsigned int *)(best_motion_err));
+ break;
+ }
}
+static enum BlockSize get_bs(BLOCK_SIZE_TYPE b) {
+ switch (b) {
+ case BLOCK_SIZE_SB8X8:
+ return BLOCK_8X8;
+ case BLOCK_SIZE_SB16X8:
+ return BLOCK_16X8;
+ case BLOCK_SIZE_SB8X16:
+ return BLOCK_8X16;
+ default:
+ return BLOCK_16X16;
+ }
+}
+
static void first_pass_motion_search(VP9_COMP *cpi, MACROBLOCK *x,
int_mv *ref_mv, MV *best_mv,
YV12_BUFFER_CONFIG *recon_buffer,
@@ -365,7 +397,8 @@
int step_param = 3;
int further_steps = (MAX_MVSEARCH_STEPS - 1) - step_param;
int n;
- vp9_variance_fn_ptr_t v_fn_ptr = cpi->fn_ptr[BLOCK_16X16];
+ vp9_variance_fn_ptr_t v_fn_ptr =
+ cpi->fn_ptr[get_bs(xd->mode_info_context->mbmi.sb_type)];
int new_mv_mode_penalty = 256;
int sr = 0;
@@ -382,7 +415,20 @@
further_steps -= sr;
// override the default variance function to use MSE
- v_fn_ptr.vf = vp9_mse16x16;
+ switch (xd->mode_info_context->mbmi.sb_type) {
+ case BLOCK_SIZE_SB8X8:
+ v_fn_ptr.vf = vp9_mse8x8;
+ break;
+ case BLOCK_SIZE_SB16X8:
+ v_fn_ptr.vf = vp9_mse16x8;
+ break;
+ case BLOCK_SIZE_SB8X16:
+ v_fn_ptr.vf = vp9_mse8x16;
+ break;
+ default:
+ v_fn_ptr.vf = vp9_mse16x16;
+ break;
+ }
// Set up pointers for this macro block recon buffer
xd->plane[0].pre[0].buf = recon_buffer->y_buffer + recon_yoffset;
@@ -511,19 +557,30 @@
int gf_motion_error = INT_MAX;
int use_dc_pred = (mb_col || mb_row) && (!mb_col || !mb_row);
- set_mi_row_col(cm, xd,
- mb_row << 1,
- 1 << mi_height_log2(BLOCK_SIZE_MB16X16),
- mb_col << 1,
- 1 << mi_height_log2(BLOCK_SIZE_MB16X16));
-
xd->plane[0].dst.buf = new_yv12->y_buffer + recon_yoffset;
xd->plane[1].dst.buf = new_yv12->u_buffer + recon_uvoffset;
xd->plane[2].dst.buf = new_yv12->v_buffer + recon_uvoffset;
xd->left_available = (mb_col != 0);
- xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_MB16X16;
+ if (mb_col * 2 + 1 < cm->mi_cols) {
+ if (mb_row * 2 + 1 < cm->mi_rows) {
+ xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_MB16X16;
+ } else {
+ xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB16X8;
+ }
+ } else {
+ if (mb_row * 2 + 1 < cm->mi_rows) {
+ xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB8X16;
+ } else {
+ xd->mode_info_context->mbmi.sb_type = BLOCK_SIZE_SB8X8;
+ }
+ }
xd->mode_info_context->mbmi.ref_frame[0] = INTRA_FRAME;
+ set_mi_row_col(cm, xd,
+ mb_row << 1,
+ 1 << mi_height_log2(xd->mode_info_context->mbmi.sb_type),
+ mb_col << 1,
+ 1 << mi_height_log2(xd->mode_info_context->mbmi.sb_type));
// do intra 16x16 prediction
this_error = vp9_encode_intra(cpi, x, use_dc_pred);
@@ -624,8 +681,8 @@
xd->mode_info_context->mbmi.ref_frame[1] = NONE;
vp9_build_inter_predictors_sby(xd, mb_row << 1,
mb_col << 1,
- BLOCK_SIZE_MB16X16);
- vp9_encode_sby(cm, x, BLOCK_SIZE_MB16X16);
+ xd->mode_info_context->mbmi.sb_type);
+ vp9_encode_sby(cm, x, xd->mode_info_context->mbmi.sb_type);
sum_mvr += mv.as_mv.row;
sum_mvr_abs += abs(mv.as_mv.row);
sum_mvc += mv.as_mv.col;
--- a/vp9/encoder/vp9_variance_c.c
+++ b/vp9/encoder/vp9_variance_c.c
@@ -390,6 +390,45 @@
return var;
}
+unsigned int vp9_mse16x8_c(const uint8_t *src_ptr,
+ int source_stride,
+ const uint8_t *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 16, 8, &var, &avg);
+ *sse = var;
+ return var;
+}
+
+unsigned int vp9_mse8x16_c(const uint8_t *src_ptr,
+ int source_stride,
+ const uint8_t *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 16, &var, &avg);
+ *sse = var;
+ return var;
+}
+
+unsigned int vp9_mse8x8_c(const uint8_t *src_ptr,
+ int source_stride,
+ const uint8_t *ref_ptr,
+ int recon_stride,
+ unsigned int *sse) {
+ unsigned int var;
+ int avg;
+
+ variance(src_ptr, source_stride, ref_ptr, recon_stride, 8, 8, &var, &avg);
+ *sse = var;
+ return var;
+}
+
unsigned int vp9_sub_pixel_variance4x4_c(const uint8_t *src_ptr,
int src_pixels_per_line,