summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorFrank Galligan <fgalligan@google.com>2014-01-24 11:31:23 -0800
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-01-24 11:31:23 -0800
commitc6d537155c0eef7de973a09fdc5755e734f02042 (patch)
tree0e958076c33a11321123d4ab453d06507eaaf5b9 /vp9
parent9c0fbd573fcb051bfa2bdcc81b00b7d475cfe131 (diff)
parentb1c72b633ef633a1ee6e83c3556393b6fe9068c4 (diff)
downloadlibvpx-c6d537155c0eef7de973a09fdc5755e734f02042.tar
libvpx-c6d537155c0eef7de973a09fdc5755e734f02042.tar.gz
libvpx-c6d537155c0eef7de973a09fdc5755e734f02042.tar.bz2
libvpx-c6d537155c0eef7de973a09fdc5755e734f02042.zip
Merge "Revert external frame buffer code."
Diffstat (limited to 'vp9')
-rw-r--r--vp9/common/vp9_alloccommon.c28
-rw-r--r--vp9/common/vp9_onyxc_int.h39
-rw-r--r--vp9/decoder/vp9_decodeframe.c18
-rw-r--r--vp9/encoder/vp9_onyx_if.c11
-rw-r--r--vp9/vp9_dx_iface.c75
5 files changed, 23 insertions, 148 deletions
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
index ca42090c1..ada7c6c03 100644
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -33,7 +33,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 < cm->fb_count; i++)
+ for (i = 0; i < FRAME_BUFFERS; i++)
vp9_free_frame_buffer(&cm->yv12_fb[i]);
vp9_free_frame_buffer(&cm->post_proc_buffer);
@@ -85,7 +85,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,
- VP9_DEC_BORDER_IN_PIXELS, NULL, NULL, NULL) < 0)
+ VP9_DEC_BORDER_IN_PIXELS) < 0)
goto fail;
set_mb_mi(cm, aligned_width, aligned_height);
@@ -137,28 +137,16 @@ 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)));
- if (cm->fb_lru) {
- CHECK_MEM_ERROR(cm, cm->fb_idx_ref_lru,
- vpx_calloc(cm->fb_count, sizeof(*cm->fb_idx_ref_lru)));
- }
- }
-
vp9_free_frame_buffers(cm);
- for (i = 0; i < cm->fb_count; i++) {
+ for (i = 0; i < FRAME_BUFFERS; i++) {
cm->fb_idx_ref_cnt[i] = 0;
if (vp9_alloc_frame_buffer(&cm->yv12_fb[i], width, height, ss_x, ss_y,
VP9_ENC_BORDER_IN_PIXELS) < 0)
goto fail;
}
- cm->new_fb_idx = cm->fb_count - 1;
+ cm->new_fb_idx = FRAME_BUFFERS - 1;
cm->fb_idx_ref_cnt[cm->new_fb_idx] = 1;
for (i = 0; i < REF_FRAMES; i++) {
@@ -211,14 +199,6 @@ 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);
- vpx_free(cm->fb_idx_ref_lru);
-
- cm->yv12_fb = NULL;
- cm->fb_idx_ref_cnt = NULL;
- cm->fb_idx_ref_lru = NULL;
}
void vp9_initialize_common() {
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index 364c2a93d..39fa7b1bb 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -117,8 +117,8 @@ typedef struct VP9Common {
YV12_BUFFER_CONFIG *frame_to_show;
- YV12_BUFFER_CONFIG *yv12_fb;
- int *fb_idx_ref_cnt; /* reference counts */
+ YV12_BUFFER_CONFIG yv12_fb[FRAME_BUFFERS];
+ int fb_idx_ref_cnt[FRAME_BUFFERS]; /* 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
@@ -217,15 +217,6 @@ 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.
-
- int fb_lru; // Flag telling if lru is on/off
- uint32_t *fb_idx_ref_lru; // Frame buffer lru cache
- uint32_t fb_idx_ref_lru_count;
} VP9_COMMON;
static YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) {
@@ -234,27 +225,13 @@ static YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) {
static int get_free_fb(VP9_COMMON *cm) {
int i;
- uint32_t lru_count = cm->fb_idx_ref_lru_count + 1;
- int free_buffer_idx = cm->fb_count;
- for (i = 0; i < cm->fb_count; i++) {
- if (!cm->fb_lru) {
- if (cm->fb_idx_ref_cnt[i] == 0) {
- free_buffer_idx = i;
- break;
- }
- } else {
- if (cm->fb_idx_ref_cnt[i] == 0 && cm->fb_idx_ref_lru[i] < lru_count) {
- free_buffer_idx = i;
- lru_count = cm->fb_idx_ref_lru[i];
- }
- }
- }
+ for (i = 0; i < FRAME_BUFFERS; i++)
+ if (cm->fb_idx_ref_cnt[i] == 0)
+ break;
- assert(free_buffer_idx < cm->fb_count);
- cm->fb_idx_ref_cnt[free_buffer_idx] = 1;
- if (cm->fb_lru)
- cm->fb_idx_ref_lru[free_buffer_idx] = ++cm->fb_idx_ref_lru_count;
- return free_buffer_idx;
+ assert(i < FRAME_BUFFERS);
+ cm->fb_idx_ref_cnt[i] = 1;
+ return i;
}
static void ref_cnt_fb(int *buf, int *idx, int new_idx) {
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index fa680d983..e6f1dfddf 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -699,21 +699,9 @@ static void apply_frame_size(VP9D_COMP *pbi, int width, int height) {
vp9_update_frame_size(cm);
}
- if (cm->fb_list != NULL) {
- vpx_codec_frame_buffer_t *const ext_fb = &cm->fb_list[cm->new_fb_idx];
- if (vp9_realloc_frame_buffer(get_frame_new_buffer(cm),
- cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
- VP9_DEC_BORDER_IN_PIXELS, ext_fb,
- cm->realloc_fb_cb, cm->user_priv)) {
- vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
- "Failed to allocate external frame buffer");
- }
- } else {
- vp9_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height,
- cm->subsampling_x, cm->subsampling_y,
- VP9_DEC_BORDER_IN_PIXELS, NULL, NULL, NULL);
- }
+ vp9_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height,
+ cm->subsampling_x, cm->subsampling_y,
+ VP9_DEC_BORDER_IN_PIXELS);
}
static void setup_frame_size(VP9D_COMP *pbi,
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index 27531d232..85baefea1 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -969,7 +969,7 @@ static void alloc_raw_frame_buffers(VP9_COMP *cpi) {
if (vp9_realloc_frame_buffer(&cpi->alt_ref_buffer,
cpi->oxcf.width, cpi->oxcf.height,
cm->subsampling_x, cm->subsampling_y,
- VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate altref buffer");
}
@@ -1037,14 +1037,14 @@ static void update_frame_size(VP9_COMP *cpi) {
if (vp9_realloc_frame_buffer(&cpi->last_frame_uf,
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
- VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to reallocate last frame buffer");
if (vp9_realloc_frame_buffer(&cpi->scaled_source,
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
- VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to reallocate scaled source buffer");
@@ -2589,7 +2589,7 @@ static void scale_references(VP9_COMP *cpi) {
vp9_realloc_frame_buffer(&cm->yv12_fb[new_fb],
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
- VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL);
+ VP9_ENC_BORDER_IN_PIXELS);
scale_and_extend_frame(ref, &cm->yv12_fb[new_fb]);
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
} else {
@@ -3580,8 +3580,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
vp9_realloc_frame_buffer(get_frame_new_buffer(cm),
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
- VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL);
-
+ VP9_ENC_BORDER_IN_PIXELS);
for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) {
const int idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)];
diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c
index a03f7befc..92c6cd20c 100644
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -59,13 +59,6 @@ struct vpx_codec_alg_priv {
int img_setup;
int img_avail;
int invert_tile_order;
- int fb_lru;
-
- /* External buffer info to save for VP9 common. */
- 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.
};
static unsigned long priv_sz(const vpx_codec_dec_cfg_t *si,
@@ -298,32 +291,10 @@ static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx,
ctx->postproc_cfg.noise_level = 0;
}
- if (!optr) {
+ if (!optr)
res = VPX_CODEC_ERROR;
- } else {
- VP9D_COMP *const pbi = (VP9D_COMP*)optr;
- VP9_COMMON *const cm = &pbi->common;
- if (ctx->fb_list != NULL && ctx->realloc_fb_cb != NULL &&
- ctx->fb_count > 0) {
- cm->fb_list = ctx->fb_list;
- cm->fb_count = ctx->fb_count;
- cm->realloc_fb_cb = ctx->realloc_fb_cb;
- cm->user_priv = ctx->user_priv;
- } else {
- cm->fb_count = FRAME_BUFFERS;
- }
- cm->fb_lru = ctx->fb_lru;
- 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)));
- if (cm->fb_lru) {
- CHECK_MEM_ERROR(cm, cm->fb_idx_ref_lru,
- vpx_calloc(cm->fb_count,
- sizeof(*cm->fb_idx_ref_lru)));
- }
+ else
ctx->pbi = optr;
- }
}
ctx->decoder_init = 1;
@@ -481,28 +452,6 @@ static vpx_image_t *vp9_get_frame(vpx_codec_alg_priv_t *ctx,
return img;
}
-static vpx_codec_err_t vp9_set_frame_buffers(
- vpx_codec_alg_priv_t *ctx,
- vpx_codec_frame_buffer_t *fb_list, int fb_count,
- vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv) {
- if (fb_count < (VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS)) {
- /* The application must pass in at least VP9_MAXIMUM_REF_BUFFERS +
- * VPX_MAXIMUM_WORK_BUFFERS frame buffers. */
- return VPX_CODEC_INVALID_PARAM;
- } else if (!ctx->pbi) {
- /* If the decoder has already been initialized, do not accept external
- * frame buffers.
- */
- ctx->fb_list = fb_list;
- ctx->fb_count = fb_count;
- ctx->realloc_fb_cb = cb;
- ctx->user_priv = user_priv;
- return VPX_CODEC_OK;
- }
-
- return VPX_CODEC_ERROR;
-}
-
static vpx_codec_err_t vp9_xma_get_mmap(const vpx_codec_ctx_t *ctx,
vpx_codec_mmap_t *mmap,
vpx_codec_iter_t *iter) {
@@ -713,21 +662,6 @@ static vpx_codec_err_t set_invert_tile_order(vpx_codec_alg_priv_t *ctx,
return VPX_CODEC_OK;
}
-static vpx_codec_err_t set_frame_buffer_lru_cache(vpx_codec_alg_priv_t *ctx,
- int ctr_id,
- va_list args) {
- VP9D_COMP *const pbi = (VP9D_COMP*)ctx->pbi;
-
- // Save for later to pass into vp9 common.
- ctx->fb_lru = va_arg(args, int);
-
- if (pbi) {
- VP9_COMMON *const cm = &pbi->common;
- cm->fb_lru = ctx->fb_lru;
- }
- return VPX_CODEC_OK;
-}
-
static vpx_codec_ctrl_fn_map_t ctf_maps[] = {
{VP8_SET_REFERENCE, set_reference},
{VP8_COPY_REFERENCE, copy_reference},
@@ -741,7 +675,6 @@ static vpx_codec_ctrl_fn_map_t ctf_maps[] = {
{VP9_GET_REFERENCE, get_reference},
{VP9D_GET_DISPLAY_SIZE, get_display_size},
{VP9_INVERT_TILE_DECODE_ORDER, set_invert_tile_order},
- {VP9D_SET_FRAME_BUFFER_LRU_CACHE, set_frame_buffer_lru_cache},
{ -1, NULL},
};
@@ -752,8 +685,7 @@ static vpx_codec_ctrl_fn_map_t ctf_maps[] = {
CODEC_INTERFACE(vpx_codec_vp9_dx) = {
"WebM Project VP9 Decoder" VERSION_STRING,
VPX_CODEC_INTERNAL_ABI_VERSION,
- VPX_CODEC_CAP_DECODER | VP9_CAP_POSTPROC |
- VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER,
+ VPX_CODEC_CAP_DECODER | VP9_CAP_POSTPROC,
/* vpx_codec_caps_t caps; */
vp9_init, /* vpx_codec_init_fn_t init; */
vp9_destroy, /* vpx_codec_destroy_fn_t destroy; */
@@ -765,7 +697,6 @@ CODEC_INTERFACE(vpx_codec_vp9_dx) = {
vp9_get_si, /* vpx_codec_get_si_fn_t get_si; */
vp9_decode, /* vpx_codec_decode_fn_t decode; */
vp9_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */
- vp9_set_frame_buffers, /* vpx_codec_set_frame_buffers_fn_t set_fb; */
},
{ // NOLINT
/* encoder functions */