ref: 40070a7d002a6ab9e9e432c01873dfc5e08e1a49
parent: feaae409c8c4d76ccbeb06f1eeda331fd1117887
parent: e4c5f7e2b6b51417cce2e5acb3fc286a6fc32d24
author: hkuang <hkuang@google.com>
date: Fri Jun 13 11:28:24 EDT 2014
Merge "Delay decreasing reference count in frame-parallel decoding."
--- a/vp9/decoder/vp9_decoder.c
+++ b/vp9/decoder/vp9_decoder.c
@@ -211,8 +211,11 @@
}
cm->frame_to_show = get_frame_new_buffer(cm);
- cm->frame_bufs[cm->new_fb_idx].ref_count--;
+ if (!pbi->frame_parallel_decode || !cm->show_frame) {
+ --cm->frame_bufs[cm->new_fb_idx].ref_count;
+ }
+
// Invalidate these references until the next frame starts.
for (ref_index = 0; ref_index < 3; ref_index++)
cm->frame_refs[ref_index].idx = INT_MAX;
@@ -240,7 +243,9 @@
}
// Check if the previous frame was a frame without any references to it.
- if (cm->new_fb_idx >= 0 && cm->frame_bufs[cm->new_fb_idx].ref_count == 0)
+ // Release frame buffer if not decoding in frame parallel mode.
+ if (!pbi->frame_parallel_decode && cm->new_fb_idx >= 0 &&
+ cm->frame_bufs[cm->new_fb_idx].ref_count == 0)
cm->release_fb_cb(cm->cb_priv,
&cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer);
cm->new_fb_idx = get_free_fb(cm);
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -40,6 +40,7 @@
vpx_image_t img;
int invert_tile_order;
int frame_parallel_decode; // frame-based threading.
+ int last_show_frame; // Index of last output frame.
// External frame buffer info to save for VP9 common.
void *ext_priv; // Private data associated with the external frame buffers.
@@ -238,6 +239,7 @@
ctx->pbi->max_threads = ctx->cfg.threads;
ctx->pbi->inv_tile_order = ctx->invert_tile_order;
ctx->pbi->frame_parallel_decode = ctx->frame_parallel_decode;
+ ctx->last_show_frame = -1;
// If postprocessing was enabled by the application and a
// configuration has not been provided, default it.
@@ -430,6 +432,15 @@
ctx->img.fb_priv = cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer.priv;
img = &ctx->img;
*iter = img;
+ // Decrease reference count of last output frame in frame parallel mode.
+ if (ctx->frame_parallel_decode && ctx->last_show_frame >= 0) {
+ --cm->frame_bufs[ctx->last_show_frame].ref_count;
+ if (cm->frame_bufs[ctx->last_show_frame].ref_count == 0) {
+ cm->release_fb_cb(cm->cb_priv,
+ &cm->frame_bufs[ctx->last_show_frame].raw_frame_buffer);
+ }
+ }
+ ctx->last_show_frame = ctx->pbi->common.new_fb_idx;
}
}
--
⑨