From 10f891696bc4c972c13cc9fde2c53470501a03e2 Mon Sep 17 00:00:00 2001 From: Frank Galligan Date: Wed, 11 Dec 2013 09:06:35 -0800 Subject: Add support to pass in external frame buffers. VP9 decoder can now use frame buffers passed in by the application. Change-Id: I599527ec85c577f3f5552831d79a693884fafb73 --- vp9/common/vp9_alloccommon.c | 22 ++++++++++++++++++---- vp9/common/vp9_onyxc_int.h | 13 +++++++++---- vp9/common/vp9_reconinter.c | 2 +- 3 files changed, 28 insertions(+), 9 deletions(-) (limited to 'vp9/common') 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 975a1d52a..db1ca3db3 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 e8247679c..24f7b597f 100644 --- a/vp9/common/vp9_reconinter.c +++ b/vp9/common/vp9_reconinter.c @@ -288,7 +288,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 { -- cgit v1.2.3