Adding get_frame_ref_buffer() function + cleanup.
Change-Id: Ib9ead216fc54b2df6f6f1fe82d2ea137197beebd
This commit is contained in:
@@ -217,6 +217,13 @@ typedef struct VP9Common {
|
||||
int cur_tile_mi_row_start, cur_tile_mi_row_end;
|
||||
} VP9_COMMON;
|
||||
|
||||
// ref == 0 => LAST_FRAME
|
||||
// ref == 1 => GOLDEN_FRAME
|
||||
// ref == 2 => ALTREF_FRAME
|
||||
static YV12_BUFFER_CONFIG *get_frame_ref_buffer(VP9_COMMON *cm, int ref) {
|
||||
return &cm->yv12_fb[cm->active_ref_idx[ref]];
|
||||
}
|
||||
|
||||
static int get_free_fb(VP9_COMMON *cm) {
|
||||
int i;
|
||||
for (i = 0; i < NUM_YV12_BUFFERS; i++)
|
||||
|
@@ -324,7 +324,7 @@ static void set_ref(VP9_COMMON *const cm, MACROBLOCKD *const xd,
|
||||
int idx, int mi_row, int mi_col) {
|
||||
MB_MODE_INFO *const mbmi = &xd->mi_8x8[0]->mbmi;
|
||||
const int ref = mbmi->ref_frame[idx] - LAST_FRAME;
|
||||
const YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[ref]];
|
||||
const YV12_BUFFER_CONFIG *cfg = get_frame_ref_buffer(cm, ref);
|
||||
const struct scale_factors_common *sfc = &cm->active_ref_scale_comm[ref];
|
||||
if (!vp9_is_valid_scale(sfc))
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_UNSUP_BITSTREAM,
|
||||
@@ -671,7 +671,7 @@ static void setup_frame_size_with_refs(VP9D_COMP *pbi,
|
||||
int found = 0, i;
|
||||
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
|
||||
if (vp9_rb_read_bit(rb)) {
|
||||
YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->active_ref_idx[i]];
|
||||
YV12_BUFFER_CONFIG *const cfg = get_frame_ref_buffer(cm, i);
|
||||
width = cfg->y_crop_width;
|
||||
height = cfg->y_crop_height;
|
||||
found = 1;
|
||||
|
@@ -176,7 +176,6 @@ vpx_codec_err_t vp9_copy_reference_dec(VP9D_PTR ptr,
|
||||
YV12_BUFFER_CONFIG *sd) {
|
||||
VP9D_COMP *pbi = (VP9D_COMP *) ptr;
|
||||
VP9_COMMON *cm = &pbi->common;
|
||||
int ref_fb_idx;
|
||||
|
||||
/* TODO(jkoleszar): The decoder doesn't have any real knowledge of what the
|
||||
* encoder is using the frame buffers for. This is just a stub to keep the
|
||||
@@ -184,18 +183,15 @@ vpx_codec_err_t vp9_copy_reference_dec(VP9D_PTR ptr,
|
||||
* later commit that adds VP9-specific controls for this functionality.
|
||||
*/
|
||||
if (ref_frame_flag == VP9_LAST_FLAG) {
|
||||
ref_fb_idx = cm->ref_frame_map[0];
|
||||
YV12_BUFFER_CONFIG *cfg = &cm->yv12_fb[cm->ref_frame_map[0]];
|
||||
if (!equal_dimensions(cfg, sd))
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
||||
"Incorrect buffer dimensions");
|
||||
else
|
||||
vp8_yv12_copy_frame(cfg, sd);
|
||||
} else {
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
||||
"Invalid reference frame");
|
||||
return cm->error.error_code;
|
||||
}
|
||||
|
||||
if (!equal_dimensions(&cm->yv12_fb[ref_fb_idx], sd)) {
|
||||
vpx_internal_error(&cm->error, VPX_CODEC_ERROR,
|
||||
"Incorrect buffer dimensions");
|
||||
} else {
|
||||
vp8_yv12_copy_frame(&cm->yv12_fb[ref_fb_idx], sd);
|
||||
}
|
||||
|
||||
return cm->error.error_code;
|
||||
@@ -305,7 +301,7 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
|
||||
* thing to do here.
|
||||
*/
|
||||
if (cm->active_ref_idx[0] != INT_MAX)
|
||||
cm->yv12_fb[cm->active_ref_idx[0]].corrupted = 1;
|
||||
get_frame_ref_buffer(cm, 0)->corrupted = 1;
|
||||
}
|
||||
|
||||
cm->new_fb_idx = get_free_fb(cm);
|
||||
@@ -322,7 +318,7 @@ int vp9_receive_compressed_data(VP9D_PTR ptr,
|
||||
* thing to do here.
|
||||
*/
|
||||
if (cm->active_ref_idx[0] != INT_MAX)
|
||||
cm->yv12_fb[cm->active_ref_idx[0]].corrupted = 1;
|
||||
get_frame_ref_buffer(cm, 0)->corrupted = 1;
|
||||
|
||||
if (cm->fb_idx_ref_cnt[cm->new_fb_idx] > 0)
|
||||
cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
|
||||
|
Reference in New Issue
Block a user