summaryrefslogtreecommitdiffstats
path: root/libvpx/vp9/encoder/vp9_lookahead.c
diff options
context:
space:
mode:
authorhkuang <hkuang@google.com>2014-04-09 14:20:00 -0700
committerLajos Molnar <lajos@google.com>2014-04-10 17:18:16 +0000
commit4fb68e5dd4e93c7599dc905d861de11ac39c5585 (patch)
treea9a16f0806a169ec4291bcd60bbfefccebb338d4 /libvpx/vp9/encoder/vp9_lookahead.c
parent2ec72e65689c948e92b826ae1e867bf369e72f13 (diff)
downloadandroid_external_libvpx-4fb68e5dd4e93c7599dc905d861de11ac39c5585.tar.gz
android_external_libvpx-4fb68e5dd4e93c7599dc905d861de11ac39c5585.tar.bz2
android_external_libvpx-4fb68e5dd4e93c7599dc905d861de11ac39c5585.zip
Roll latest libvpx to fix hang when doing adaptive playback.
VP9 decoder will hang when switching from frames with 2 tiles to 4 tiles on a 4 core device. libvpx hash:4fffefe189a9123d4b04482c26a1be5eb632b397 (cherry picked from commit 6ac915abcdb404a00d927fe6308a47fcf09d9519) Bug: 13931133 Change-Id: I24a51fd572ca7e872bc440491e2c645a20e9a736
Diffstat (limited to 'libvpx/vp9/encoder/vp9_lookahead.c')
-rw-r--r--libvpx/vp9/encoder/vp9_lookahead.c51
1 files changed, 33 insertions, 18 deletions
diff --git a/libvpx/vp9/encoder/vp9_lookahead.c b/libvpx/vp9/encoder/vp9_lookahead.c
index a88d5ec..cf03e01 100644
--- a/libvpx/vp9/encoder/vp9_lookahead.c
+++ b/libvpx/vp9/encoder/vp9_lookahead.c
@@ -28,8 +28,8 @@ struct lookahead_ctx {
/* Return the buffer at the given absolute index and increment the index */
-static struct lookahead_entry * pop(struct lookahead_ctx *ctx,
- unsigned int *idx) {
+static struct lookahead_entry *pop(struct lookahead_ctx *ctx,
+ unsigned int *idx) {
unsigned int index = *idx;
struct lookahead_entry *buf = ctx->buf + index;
@@ -55,16 +55,19 @@ void vp9_lookahead_destroy(struct lookahead_ctx *ctx) {
}
-struct lookahead_ctx * vp9_lookahead_init(unsigned int width,
- unsigned int height,
- unsigned int subsampling_x,
- unsigned int subsampling_y,
- unsigned int depth) {
+struct lookahead_ctx *vp9_lookahead_init(unsigned int width,
+ unsigned int height,
+ unsigned int subsampling_x,
+ unsigned int subsampling_y,
+ unsigned int depth) {
struct lookahead_ctx *ctx = NULL;
// Clamp the lookahead queue depth
depth = clamp(depth, 1, MAX_LAG_BUFFERS);
+ // Allocate memory to keep previous source frames available.
+ depth += MAX_PRE_FRAMES;
+
// Allocate the lookahead structures
ctx = calloc(1, sizeof(*ctx));
if (ctx) {
@@ -96,7 +99,7 @@ int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src,
int mb_cols = (src->y_width + 15) >> 4;
#endif
- if (ctx->sz + 1 > ctx->max_sz)
+ if (ctx->sz + 1 + MAX_PRE_FRAMES > ctx->max_sz)
return 1;
ctx->sz++;
buf = pop(ctx, &ctx->write_idx);
@@ -159,11 +162,11 @@ int vp9_lookahead_push(struct lookahead_ctx *ctx, YV12_BUFFER_CONFIG *src,
}
-struct lookahead_entry * vp9_lookahead_pop(struct lookahead_ctx *ctx,
- int drain) {
+struct lookahead_entry *vp9_lookahead_pop(struct lookahead_ctx *ctx,
+ int drain) {
struct lookahead_entry *buf = NULL;
- if (ctx->sz && (drain || ctx->sz == ctx->max_sz)) {
+ if (ctx->sz && (drain || ctx->sz == ctx->max_sz - MAX_PRE_FRAMES)) {
buf = pop(ctx, &ctx->read_idx);
ctx->sz--;
}
@@ -171,16 +174,28 @@ struct lookahead_entry * vp9_lookahead_pop(struct lookahead_ctx *ctx,
}
-struct lookahead_entry * vp9_lookahead_peek(struct lookahead_ctx *ctx,
- int index) {
+struct lookahead_entry *vp9_lookahead_peek(struct lookahead_ctx *ctx,
+ int index) {
struct lookahead_entry *buf = NULL;
- if (index < (int)ctx->sz) {
- index += ctx->read_idx;
- if (index >= (int)ctx->max_sz)
- index -= ctx->max_sz;
- buf = ctx->buf + index;
+ if (index >= 0) {
+ // Forward peek
+ if (index < (int)ctx->sz) {
+ index += ctx->read_idx;
+ if (index >= (int)ctx->max_sz)
+ index -= ctx->max_sz;
+ buf = ctx->buf + index;
+ }
+ } else if (index < 0) {
+ // Backward peek
+ if (-index <= MAX_PRE_FRAMES) {
+ index += ctx->read_idx;
+ if (index < 0)
+ index += ctx->max_sz;
+ buf = ctx->buf + index;
+ }
}
+
return buf;
}