ref: 5556d1184169168e59656863456c88c3f958ca45
parent: 22368479c0d99c1679a0560600f90aff7ee1814c
parent: cdffeaaae05f9261ab9be5aebe0fbb2454b295fb
author: hkuang <[email protected]>
date: Tue Jun 10 10:27:31 EDT 2014
Merge "Add mode info arrays and mode info index."
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -53,33 +53,42 @@
}
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;
+ int i;
- cm->prev_mip = (MODE_INFO *)vpx_calloc(mi_size, sizeof(*cm->prev_mip));
- if (cm->prev_mip == NULL)
- return 1;
+ for (i = 0; i < 2; ++i) {
+ cm->mip_array[i] =
+ (MODE_INFO *)vpx_calloc(mi_size, sizeof(*cm->mip));
+ if (cm->mip_array[i] == 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->mi_grid_base_array[i] =
+ (MODE_INFO **)vpx_calloc(mi_size, sizeof(*cm->mi_grid_base));
+ if (cm->mi_grid_base_array[i] == 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;
+ // Init the index.
+ cm->mi_idx = 0;
+ cm->prev_mi_idx = 1;
+ cm->mip = cm->mip_array[cm->mi_idx];
+ cm->prev_mip = cm->mip_array[cm->prev_mi_idx];
+ cm->mi_grid_base = cm->mi_grid_base_array[cm->mi_idx];
+ cm->prev_mi_grid_base = cm->mi_grid_base_array[cm->prev_mi_idx];
+
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);
+ int i;
+ for (i = 0; i < 2; ++i) {
+ vpx_free(cm->mip_array[i]);
+ cm->mip_array[i] = NULL;
+ vpx_free(cm->mi_grid_base_array[i]);
+ cm->mi_grid_base_array[i] = NULL;
+ }
+
cm->mip = NULL;
cm->prev_mip = NULL;
cm->mi_grid_base = NULL;
@@ -237,13 +246,16 @@
}
void vp9_swap_mi_and_prev_mi(VP9_COMMON *cm) {
+ // Swap indices.
+ const int tmp = cm->mi_idx;
+ cm->mi_idx = cm->prev_mi_idx;
+ cm->prev_mi_idx = tmp;
+
// Current mip will be the prev_mip for the next frame.
- MODE_INFO *temp = cm->prev_mip;
- MODE_INFO **temp2 = cm->prev_mi_grid_base;
- cm->prev_mip = cm->mip;
- cm->mip = temp;
- cm->prev_mi_grid_base = cm->mi_grid_base;
- cm->mi_grid_base = temp2;
+ cm->mip = cm->mip_array[cm->mi_idx];
+ cm->prev_mip = cm->mip_array[cm->prev_mi_idx];
+ cm->mi_grid_base = cm->mi_grid_base_array[cm->mi_idx];
+ cm->prev_mi_grid_base = cm->mi_grid_base_array[cm->prev_mi_idx];
// Update the upper left visible macroblock ptrs.
cm->mi = cm->mip + cm->mi_stride + 1;
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -142,6 +142,11 @@
/* We allocate a MODE_INFO struct for each macroblock, together with
an extra row on top and column on the left to simplify prediction. */
+ int mi_idx;
+ int prev_mi_idx;
+ MODE_INFO *mip_array[2];
+ MODE_INFO **mi_grid_base_array[2];
+
MODE_INFO *mip; /* Base of allocated array */
MODE_INFO *mi; /* Corresponds to upper left visible macroblock */
MODE_INFO *prev_mip; /* MODE_INFO array 'mip' from last decoded frame */