summaryrefslogtreecommitdiff
path: root/vp9/common
diff options
context:
space:
mode:
authorFrank Galligan <fgalligan@google.com>2013-12-15 19:18:25 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2013-12-15 19:18:25 -0800
commitd0ee1fd797598fd692cbfe410bc37308a9e8924e (patch)
treebf56546460f11ca40605ac6dfe209ecb79d9b337 /vp9/common
parentc5aaf923d80e9f71e0c93d7d99dc1e2f83d7acbf (diff)
parent10f891696bc4c972c13cc9fde2c53470501a03e2 (diff)
downloadlibvpx-d0ee1fd797598fd692cbfe410bc37308a9e8924e.tar
libvpx-d0ee1fd797598fd692cbfe410bc37308a9e8924e.tar.gz
libvpx-d0ee1fd797598fd692cbfe410bc37308a9e8924e.tar.bz2
libvpx-d0ee1fd797598fd692cbfe410bc37308a9e8924e.zip
Merge "Add support to pass in external frame buffers."
Diffstat (limited to 'vp9/common')
-rw-r--r--vp9/common/vp9_alloccommon.c22
-rw-r--r--vp9/common/vp9_onyxc_int.h13
-rw-r--r--vp9/common/vp9_reconinter.c2
3 files changed, 28 insertions, 9 deletions
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
index f56784071..6c333c5ef 100644
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -34,7 +34,7 @@ void vp9_update_mode_info_border(VP9_COMMON *cm, MODE_INFO *mi) {
void vp9_free_frame_buffers(VP9_COMMON *cm) {
int i;
- for (i = 0; i < FRAME_BUFFERS; i++)
+ for (i = 0; i < cm->fb_count; i++)
vp9_free_frame_buffer(&cm->yv12_fb[i]);
vp9_free_frame_buffer(&cm->post_proc_buffer);
@@ -86,7 +86,7 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) {
int mi_size;
if (vp9_realloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y,
- VP9BORDERINPIXELS) < 0)
+ VP9BORDERINPIXELS, NULL, NULL, NULL) < 0)
goto fail;
set_mb_mi(cm, aligned_width, aligned_height);
@@ -138,16 +138,24 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) {
const int ss_y = cm->subsampling_y;
int mi_size;
+ if (cm->fb_count == 0) {
+ cm->fb_count = FRAME_BUFFERS;
+ CHECK_MEM_ERROR(cm, cm->yv12_fb,
+ vpx_calloc(cm->fb_count, sizeof(*cm->yv12_fb)));
+ CHECK_MEM_ERROR(cm, cm->fb_idx_ref_cnt,
+ vpx_calloc(cm->fb_count, sizeof(*cm->fb_idx_ref_cnt)));
+ }
+
vp9_free_frame_buffers(cm);
- for (i = 0; i < FRAME_BUFFERS; i++) {
+ for (i = 0; i < cm->fb_count; i++) {
cm->fb_idx_ref_cnt[i] = 0;
if (vp9_alloc_frame_buffer(&cm->yv12_fb[i], width, height, ss_x, ss_y,
VP9BORDERINPIXELS) < 0)
goto fail;
}
- cm->new_fb_idx = FRAME_BUFFERS - 1;
+ cm->new_fb_idx = cm->fb_count - 1;
cm->fb_idx_ref_cnt[cm->new_fb_idx] = 1;
for (i = 0; i < REFS_PER_FRAME; i++)
@@ -203,6 +211,12 @@ void vp9_create_common(VP9_COMMON *cm) {
void vp9_remove_common(VP9_COMMON *cm) {
vp9_free_frame_buffers(cm);
+
+ vpx_free(cm->yv12_fb);
+ vpx_free(cm->fb_idx_ref_cnt);
+
+ cm->yv12_fb = NULL;
+ cm->fb_idx_ref_cnt = NULL;
}
void vp9_initialize_common() {
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index a6e5b27e3..aa7086882 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -113,8 +113,8 @@ typedef struct VP9Common {
YV12_BUFFER_CONFIG *frame_to_show;
- YV12_BUFFER_CONFIG yv12_fb[FRAME_BUFFERS];
- int fb_idx_ref_cnt[FRAME_BUFFERS]; /* reference counts */
+ YV12_BUFFER_CONFIG *yv12_fb;
+ int *fb_idx_ref_cnt; /* reference counts */
int ref_frame_map[REF_FRAMES]; /* maps fb_idx to reference slot */
// TODO(jkoleszar): could expand active_ref_idx to 4, with 0 as intra, and
@@ -213,6 +213,11 @@ typedef struct VP9Common {
int frame_parallel_decoding_mode;
int log2_tile_cols, log2_tile_rows;
+
+ vpx_codec_frame_buffer_t *fb_list; // External frame buffers
+ int fb_count; // Total number of frame buffers
+ vpx_realloc_frame_buffer_cb_fn_t realloc_fb_cb;
+ void *user_priv; // Private data associated with the external frame buffers.
} VP9_COMMON;
// ref == 0 => LAST_FRAME
@@ -228,11 +233,11 @@ static YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) {
static int get_free_fb(VP9_COMMON *cm) {
int i;
- for (i = 0; i < FRAME_BUFFERS; i++)
+ for (i = 0; i < cm->fb_count; i++)
if (cm->fb_idx_ref_cnt[i] == 0)
break;
- assert(i < FRAME_BUFFERS);
+ assert(i < cm->fb_count);
cm->fb_idx_ref_cnt[i] = 1;
return i;
}
diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c
index a6e51d792..b17725243 100644
--- a/vp9/common/vp9_reconinter.c
+++ b/vp9/common/vp9_reconinter.c
@@ -397,7 +397,7 @@ void vp9_setup_scale_factors(VP9_COMMON *cm, int i) {
const int ref = cm->active_ref_idx[i];
struct scale_factors *const sf = &cm->active_ref_scale[i];
struct scale_factors_common *const sfc = &cm->active_ref_scale_comm[i];
- if (ref >= FRAME_BUFFERS) {
+ if (ref >= cm->fb_count) {
vp9_zero(*sf);
vp9_zero(*sfc);
} else {