Adding vp9_update_frame_size function.

Moving common code from encoder and decoder to vp9_update_frame_size.

Change-Id: I6ca758b7d05ffd52821bd3f7ad68089da11e4165
This commit is contained in:
Dmitry Kovalev 2013-04-30 11:14:27 -07:00
parent 70d12c3a75
commit 15b5e465f2
4 changed files with 29 additions and 40 deletions

View File

@ -223,3 +223,28 @@ void vp9_initialize_common() {
vp9_entropy_mode_init();
vp9_entropy_mv_init();
}
void vp9_update_frame_size(VP9_COMMON *cm) {
const int aligned_width = multiple16(cm->width);
const int aligned_height = multiple16(cm->height);
cm->mb_rows = aligned_height >> 4;
cm->mb_cols = aligned_width >> 4;
cm->mi_rows = aligned_height >> LOG2_MI_SIZE;
cm->mi_cols = aligned_width >> LOG2_MI_SIZE;
cm->MBs = cm->mb_rows * cm->mb_cols;
cm->mode_info_stride = cm->mi_cols + 1;
cm->mi = cm->mip + cm->mode_info_stride + 1;
cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
memset(cm->mip, 0,
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vp9_update_mode_info_border(cm, cm->mip);
vp9_update_mode_info_in_image(cm, cm->mi);
vp9_update_mode_info_border(cm, cm->prev_mip);
vp9_update_mode_info_in_image(cm, cm->prev_mi);
}

View File

@ -25,4 +25,6 @@ void vp9_free_frame_buffers(VP9_COMMON *oci);
void vp9_setup_version(VP9_COMMON *oci);
void vp9_update_frame_size(VP9_COMMON *cm);
#endif // VP9_COMMON_VP9_ALLOCCOMMON_H_

View File

@ -896,29 +896,6 @@ static void read_coef_probs(VP9D_COMP *pbi, vp9_reader *r) {
read_coef_probs_common(fc->coef_probs_32x32, TX_32X32, r);
}
static void update_frame_size(VP9D_COMP *pbi) {
VP9_COMMON *cm = &pbi->common;
const int width = multiple16(cm->width);
const int height = multiple16(cm->height);
cm->mb_rows = height / 16;
cm->mi_rows = height >> LOG2_MI_SIZE;
cm->mb_cols = width / 16;
cm->mi_cols = width >> LOG2_MI_SIZE;
cm->MBs = cm->mb_rows * cm->mb_cols;
cm->mode_info_stride = cm->mi_cols + 1;
memset(cm->mip, 0,
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vp9_update_mode_info_border(cm, cm->mip);
vp9_update_mode_info_border(cm, cm->prev_mip);
cm->mi = cm->mip + cm->mode_info_stride + 1;
cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
vp9_update_mode_info_in_image(cm, cm->mi);
vp9_update_mode_info_in_image(cm, cm->prev_mi);
}
static void setup_segmentation(VP9_COMMON *pc, MACROBLOCKD *xd, vp9_reader *r) {
int i, j;
@ -1110,7 +1087,7 @@ static const uint8_t *setup_frame_size(VP9D_COMP *pbi, int scaling_active,
pc->display_width = scaling_active ? display_width : width;
pc->display_height = scaling_active ? display_height : height;
update_frame_size(pbi);
vp9_update_frame_size(pc);
}
return data;

View File

@ -982,22 +982,7 @@ void vp9_alloc_compressor_data(VP9_COMP *cpi) {
static void update_frame_size(VP9_COMP *cpi) {
VP9_COMMON *cm = &cpi->common;
const int aligned_width = multiple16(cm->width);
const int aligned_height = multiple16(cm->height);
cm->mb_rows = aligned_height >> 4;
cm->mi_rows = aligned_height >> LOG2_MI_SIZE;
cm->mb_cols = aligned_width >> 4;
cm->mi_cols = aligned_width >> LOG2_MI_SIZE;
cm->MBs = cm->mb_rows * cm->mb_cols;
cm->mode_info_stride = cm->mi_cols + 1;
memset(cm->mip, 0,
cm->mode_info_stride * (cm->mi_rows + 1) * sizeof(MODE_INFO));
vp9_update_mode_info_border(cm, cm->mip);
cm->mi = cm->mip + cm->mode_info_stride + 1;
cm->prev_mi = cm->prev_mip + cm->mode_info_stride + 1;
vp9_update_mode_info_in_image(cm, cm->mi);
vp9_update_frame_size(cm);
// Update size of buffers local to this frame
if (vp8_yv12_realloc_frame_buffer(&cpi->last_frame_uf,