diff options
Diffstat (limited to 'vp9/common')
-rw-r--r-- | vp9/common/vp9_alloccommon.c | 150 | ||||
-rw-r--r-- | vp9/common/vp9_blockd.h | 1 | ||||
-rw-r--r-- | vp9/common/vp9_debugmodes.c | 4 | ||||
-rw-r--r-- | vp9/common/vp9_entropymv.c | 8 | ||||
-rw-r--r-- | vp9/common/vp9_enums.h | 6 | ||||
-rw-r--r-- | vp9/common/vp9_onyxc_int.h | 6 | ||||
-rw-r--r-- | vp9/common/vp9_reconinter.c | 47 |
7 files changed, 120 insertions, 102 deletions
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c index 920aefa79..ad11d1c94 100644 --- a/vp9/common/vp9_alloccommon.c +++ b/vp9/common/vp9_alloccommon.c @@ -8,7 +8,6 @@ * be found in the AUTHORS file in the root of the source tree. */ - #include "./vpx_config.h" #include "vpx_mem/vpx_mem.h" @@ -30,34 +29,6 @@ void vp9_update_mode_info_border(VP9_COMMON *cm, MODE_INFO *mi) { vpx_memset(&mi[i * stride], 0, sizeof(MODE_INFO)); } -void vp9_free_frame_buffers(VP9_COMMON *cm) { - int i; - - for (i = 0; i < FRAME_BUFFERS; i++) { - vp9_free_frame_buffer(&cm->frame_bufs[i].buf); - - if (cm->frame_bufs[i].ref_count > 0 && - cm->frame_bufs[i].raw_frame_buffer.data != NULL) { - cm->release_fb_cb(cm->cb_priv, &cm->frame_bufs[i].raw_frame_buffer); - cm->frame_bufs[i].ref_count = 0; - } - } - - vp9_free_frame_buffer(&cm->post_proc_buffer); - - vpx_free(cm->mip); - vpx_free(cm->prev_mip); - vpx_free(cm->last_frame_seg_map); - vpx_free(cm->mi_grid_base); - vpx_free(cm->prev_mi_grid_base); - - cm->mip = NULL; - cm->prev_mip = NULL; - cm->last_frame_seg_map = NULL; - cm->mi_grid_base = NULL; - cm->prev_mi_grid_base = NULL; -} - static void set_mb_mi(VP9_COMMON *cm, int aligned_width, int aligned_height) { cm->mi_cols = aligned_width >> MI_SIZE_LOG2; cm->mi_rows = aligned_height >> MI_SIZE_LOG2; @@ -75,7 +46,7 @@ static void setup_mi(VP9_COMMON *cm) { cm->prev_mi_grid_visible = cm->prev_mi_grid_base + cm->mode_info_stride + 1; vpx_memset(cm->mip, 0, - cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO)); + cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(*cm->mip)); vpx_memset(cm->mi_grid_base, 0, cm->mode_info_stride * (cm->mi_rows + 1) * @@ -84,12 +55,69 @@ static void setup_mi(VP9_COMMON *cm) { vp9_update_mode_info_border(cm, cm->prev_mip); } +static int alloc_mi(VP9_COMMON *cm, int mi_size) { + cm->mip = (MODE_INFO *)vpx_calloc(mi_size, sizeof(*cm->mip)); + if (cm->mip == NULL) + return 1; + + cm->prev_mip = (MODE_INFO *)vpx_calloc(mi_size, sizeof(*cm->prev_mip)); + if (cm->prev_mip == NULL) + return 1; + + cm->mi_grid_base = + (MODE_INFO **)vpx_calloc(mi_size, sizeof(*cm->mi_grid_base)); + if (cm->mi_grid_base == NULL) + return 1; + + cm->prev_mi_grid_base = + (MODE_INFO **)vpx_calloc(mi_size, sizeof(*cm->prev_mi_grid_base)); + if (cm->prev_mi_grid_base == NULL) + return 1; + + return 0; +} + +static void free_mi(VP9_COMMON *cm) { + vpx_free(cm->mip); + vpx_free(cm->prev_mip); + vpx_free(cm->mi_grid_base); + vpx_free(cm->prev_mi_grid_base); + + cm->mip = NULL; + cm->prev_mip = NULL; + cm->mi_grid_base = NULL; + cm->prev_mi_grid_base = NULL; +} + +void vp9_free_frame_buffers(VP9_COMMON *cm) { + int i; + + for (i = 0; i < FRAME_BUFFERS; ++i) { + vp9_free_frame_buffer(&cm->frame_bufs[i].buf); + + if (cm->frame_bufs[i].ref_count > 0 && + cm->frame_bufs[i].raw_frame_buffer.data != NULL) { + cm->release_fb_cb(cm->cb_priv, &cm->frame_bufs[i].raw_frame_buffer); + cm->frame_bufs[i].ref_count = 0; + } + } + + vp9_free_frame_buffer(&cm->post_proc_buffer); + + free_mi(cm); + + vpx_free(cm->last_frame_seg_map); + cm->last_frame_seg_map = NULL; + + vpx_free(cm->above_seg_context); + cm->above_seg_context = NULL; +} + int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { const int aligned_width = ALIGN_POWER_OF_TWO(width, MI_SIZE_LOG2); const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); const int ss_x = cm->subsampling_x; const int ss_y = cm->subsampling_y; - int mi_size; if (vp9_realloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y, VP9_DEC_BORDER_IN_PIXELS, NULL, NULL, NULL) < 0) @@ -97,29 +125,8 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { set_mb_mi(cm, aligned_width, aligned_height); - // Allocation - mi_size = cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE); - - vpx_free(cm->mip); - cm->mip = (MODE_INFO *)vpx_calloc(mi_size, sizeof(MODE_INFO)); - if (!cm->mip) - goto fail; - - vpx_free(cm->prev_mip); - cm->prev_mip = (MODE_INFO *)vpx_calloc(mi_size, sizeof(MODE_INFO)); - if (!cm->prev_mip) - goto fail; - - vpx_free(cm->mi_grid_base); - cm->mi_grid_base = - (MODE_INFO **)vpx_calloc(mi_size, sizeof(*cm->mi_grid_base)); - if (!cm->mi_grid_base) - goto fail; - - vpx_free(cm->prev_mi_grid_base); - cm->prev_mi_grid_base = - (MODE_INFO **)vpx_calloc(mi_size, sizeof(*cm->prev_mi_grid_base)); - if (!cm->prev_mi_grid_base) + free_mi(cm); + if (alloc_mi(cm, cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE))) goto fail; setup_mi(cm); @@ -130,6 +137,13 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { if (!cm->last_frame_seg_map) goto fail; + vpx_free(cm->above_seg_context); + cm->above_seg_context = + (PARTITION_CONTEXT *)vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols), + sizeof(*cm->above_seg_context)); + if (!cm->above_seg_context) + goto fail; + return 0; fail: @@ -144,7 +158,6 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { const int aligned_height = ALIGN_POWER_OF_TWO(height, MI_SIZE_LOG2); const int ss_x = cm->subsampling_x; const int ss_y = cm->subsampling_y; - int mi_size; vp9_free_frame_buffers(cm); @@ -169,25 +182,7 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { set_mb_mi(cm, aligned_width, aligned_height); - // Allocation - mi_size = cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE); - - cm->mip = (MODE_INFO *)vpx_calloc(mi_size, sizeof(MODE_INFO)); - if (!cm->mip) - goto fail; - - cm->prev_mip = (MODE_INFO *)vpx_calloc(mi_size, sizeof(MODE_INFO)); - if (!cm->prev_mip) - goto fail; - - cm->mi_grid_base = - (MODE_INFO **)vpx_calloc(mi_size, sizeof(*cm->mi_grid_base)); - if (!cm->mi_grid_base) - goto fail; - - cm->prev_mi_grid_base = - (MODE_INFO **)vpx_calloc(mi_size, sizeof(*cm->prev_mi_grid_base)); - if (!cm->prev_mi_grid_base) + if (alloc_mi(cm, cm->mode_info_stride * (cm->mi_rows + MI_BLOCK_SIZE))) goto fail; setup_mi(cm); @@ -197,6 +192,13 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { if (!cm->last_frame_seg_map) goto fail; + + cm->above_seg_context = + (PARTITION_CONTEXT *)vpx_calloc(mi_cols_aligned_to_sb(cm->mi_cols), + sizeof(*cm->above_seg_context)); + if (!cm->above_seg_context) + goto fail; + return 0; fail: diff --git a/vp9/common/vp9_blockd.h b/vp9/common/vp9_blockd.h index b9e30fe9a..ca5a0c2b7 100644 --- a/vp9/common/vp9_blockd.h +++ b/vp9/common/vp9_blockd.h @@ -209,7 +209,6 @@ typedef struct macroblockd { // A NULL indicates that the 8x8 is not part of the image MODE_INFO **mi_8x8; MODE_INFO **prev_mi_8x8; - MODE_INFO *mi_stream; int up_available; int left_available; diff --git a/vp9/common/vp9_debugmodes.c b/vp9/common/vp9_debugmodes.c index 24c785f2a..8f150a406 100644 --- a/vp9/common/vp9_debugmodes.c +++ b/vp9/common/vp9_debugmodes.c @@ -22,7 +22,7 @@ static void log_frame_info(VP9_COMMON *cm, const char *str, FILE *f) { * and uses the passed in member offset to print out the value of an integer * for each mbmi member value in the mi structure. */ -static void print_mi_data(VP9_COMMON *cm, FILE *file, char *descriptor, +static void print_mi_data(VP9_COMMON *cm, FILE *file, const char *descriptor, size_t member_offset) { int mi_row; int mi_col; @@ -47,7 +47,7 @@ static void print_mi_data(VP9_COMMON *cm, FILE *file, char *descriptor, } fprintf(file, "\n"); } -void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, char *file) { +void vp9_print_modes_and_motion_vectors(VP9_COMMON *cm, const char *file) { int mi_row; int mi_col; int mi_index = 0; diff --git a/vp9/common/vp9_entropymv.c b/vp9/common/vp9_entropymv.c index e1f5ef7b4..197b7c05e 100644 --- a/vp9/common/vp9_entropymv.c +++ b/vp9/common/vp9_entropymv.c @@ -122,12 +122,8 @@ static const uint8_t log_in_base_2[] = { }; MV_CLASS_TYPE vp9_get_mv_class(int z, int *offset) { - MV_CLASS_TYPE c = MV_CLASS_0; - if (z >= CLASS0_SIZE * 4096) - c = MV_CLASS_10; - else - c = log_in_base_2[z >> 3]; - + const MV_CLASS_TYPE c = (z >= CLASS0_SIZE * 4096) ? MV_CLASS_10 : + (MV_CLASS_TYPE)log_in_base_2[z >> 3]; if (offset) *offset = z - mv_class_base(c); return c; diff --git a/vp9/common/vp9_enums.h b/vp9/common/vp9_enums.h index e96e76947..779dce017 100644 --- a/vp9/common/vp9_enums.h +++ b/vp9/common/vp9_enums.h @@ -94,6 +94,12 @@ typedef enum { SRGB = 7 // RGB } COLOR_SPACE; +typedef enum { + VP9_LAST_FLAG = 1 << 0, + VP9_GOLD_FLAG = 1 << 1, + VP9_ALT_FLAG = 1 << 2, +} VP9_REFFRAME; + #ifdef __cplusplus } // extern "C" #endif diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 024b197a1..a049db109 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -153,10 +153,6 @@ typedef struct VP9Common { MODE_INFO **prev_mi_grid_base; MODE_INFO **prev_mi_grid_visible; - // Each tile column has its own MODE_INFO stream. This array indexes them by - // tile column index. - MODE_INFO **mi_streams; - // Persistent mb segment id map used in prediction. unsigned char *last_frame_seg_map; @@ -206,6 +202,8 @@ typedef struct VP9Common { // Handles memory for the codec. InternalFrameBufferList int_frame_buffers; + + PARTITION_CONTEXT *above_seg_context; } VP9_COMMON; static INLINE YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) { diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c index 86548750e..005f370a0 100644 --- a/vp9/common/vp9_reconinter.c +++ b/vp9/common/vp9_reconinter.c @@ -293,24 +293,40 @@ static void dec_build_inter_predictors(MACROBLOCKD *xd, int plane, int block, ref_frame = plane == 1 ? ref_buf->u_buffer : ref_buf->v_buffer; } - // Get block position in current frame. - x0 = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x)) + x; - y0 = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y)) + y; + if (vp9_is_scaled(sf)) { + // Co-ordinate of containing block to pixel precision. + int x_start = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x)); + int y_start = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y)); - // Precision of x0_16 and y0_16 is 1/16th pixel. - x0_16 = x0 << SUBPEL_BITS; - y0_16 = y0 << SUBPEL_BITS; + // Co-ordinate of the block to 1/16th pixel precision. + x0_16 = (x_start + x) << SUBPEL_BITS; + y0_16 = (y_start + y) << SUBPEL_BITS; - if (vp9_is_scaled(sf)) { + // Co-ordinate of current block in reference frame + // to 1/16th pixel precision. + x0_16 = sf->scale_value_x(x0_16, sf); + y0_16 = sf->scale_value_y(y0_16, sf); + + // Map the top left corner of the block into the reference frame. + // NOTE: This must be done in this way instead of + // sf->scale_value_x(x_start + x, sf). + x0 = sf->scale_value_x(x_start, sf) + sf->scale_value_x(x, sf); + y0 = sf->scale_value_y(y_start, sf) + sf->scale_value_y(y, sf); + + // Scale the MV and incorporate the sub-pixel offset of the block + // in the reference frame. scaled_mv = vp9_scale_mv(&mv_q4, mi_x + x, mi_y + y, sf); xs = sf->x_step_q4; ys = sf->y_step_q4; - // Map the top left corner of the block into the reference frame. - x0 = sf->scale_value_x(x0, sf); - y0 = sf->scale_value_y(y0, sf); - x0_16 = sf->scale_value_x(x0_16, sf); - y0_16 = sf->scale_value_y(y0_16, sf); } else { + // Co-ordinate of containing block to pixel precision. + x0 = (-xd->mb_to_left_edge >> (3 + pd->subsampling_x)) + x; + y0 = (-xd->mb_to_top_edge >> (3 + pd->subsampling_y)) + y; + + // Co-ordinate of the block to 1/16th pixel precision. + x0_16 = x0 << SUBPEL_BITS; + y0_16 = y0 << SUBPEL_BITS; + scaled_mv.row = mv_q4.row; scaled_mv.col = mv_q4.col; xs = ys = 16; @@ -354,9 +370,10 @@ static void dec_build_inter_predictors(MACROBLOCKD *xd, int plane, int block, y0 < 0 || y0 > frame_height - 1 || y1 < 0 || y1 > frame_height - 1) { uint8_t *buf_ptr1 = ref_frame + y0 * pre_buf->stride + x0; // Extend the border. - build_mc_border(buf_ptr1, pre_buf->stride, xd->mc_buf, x1 - x0, - x0, y0, x1 - x0, y1 - y0, frame_width, frame_height); - buf_stride = x1 - x0; + build_mc_border(buf_ptr1, pre_buf->stride, xd->mc_buf, x1 - x0 + 1, + x0, y0, x1 - x0 + 1, y1 - y0 + 1, frame_width, + frame_height); + buf_stride = x1 - x0 + 1; buf_ptr = xd->mc_buf + y_pad * 3 * buf_stride + x_pad * 3; } } |