Commit cdffeaaa authored by hkuang's avatar hkuang
Browse files

Add mode info arrays and mode info index.

In non frame-parallel decoding, this works the same way as
current decoding scheme. Every time after decoder finish
decoding a frame, it will swap the current mode info pointer
and  previous mode info pointer if the decoded frame needs
to be shown. Both mode info pointer and previous mode info
pointer are from mode info arrays.

In frame-parallel decoding, this will become more complicated
as current frame's mode info pointer will be shared with next
frame as previous mode info pointer. But when one decoder
thread finishes decoding one frame and starts to work on next
available frame, it needs to retain the decoded frame's mode
info pointers until next frame finishes decoding. The mode info
index will serve this purpose. The decoder will use different
buffer in the mode info arrays and use the other buffer to save
previous decoded frame’s mode info.

Change-Id: If11d57d8eb0ee38c8876158e5482177fcb229428
parent 70eb862f
......@@ -53,32 +53,41 @@ static void setup_mi(VP9_COMMON *cm) {
}
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;
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->prev_mip = (MODE_INFO *)vpx_calloc(mi_size, sizeof(*cm->prev_mip));
if (cm->prev_mip == 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->mi_grid_base =
(MODE_INFO **)vpx_calloc(mi_size, sizeof(*cm->mi_grid_base));
if (cm->mi_grid_base == NULL)
return 1;
// Init the index.
cm->mi_idx = 0;
cm->prev_mi_idx = 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;
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;
......@@ -237,13 +246,16 @@ void vp9_update_frame_size(VP9_COMMON *cm) {
}
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;
......
......@@ -142,6 +142,11 @@ typedef struct VP9Common {
/* 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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment