From 918a2fd72658ac764f5627b7eb2b56f91479cf09 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Wed, 27 Apr 2016 15:59:18 -0700 Subject: [PATCH] Use signed variables in the lookahead. Wrap around behavior is enforced manually and we use the values in arithmetic involving negative integers. Change-Id: I199706b6f3af91f4fb6fe2ef302fbbc6d0cf5785 --- vp10/encoder/lookahead.c | 10 +++++----- vp10/encoder/lookahead.h | 8 ++++---- vp9/encoder/vp9_lookahead.c | 10 +++++----- vp9/encoder/vp9_lookahead.h | 8 ++++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/vp10/encoder/lookahead.c b/vp10/encoder/lookahead.c index dce013903..3185cb691 100644 --- a/vp10/encoder/lookahead.c +++ b/vp10/encoder/lookahead.c @@ -20,8 +20,8 @@ /* Return the buffer at the given absolute index and increment the index */ static struct lookahead_entry *pop(struct lookahead_ctx *ctx, - unsigned int *idx) { - unsigned int index = *idx; + int *idx) { + int index = *idx; struct lookahead_entry *buf = ctx->buf + index; assert(index < ctx->max_sz); @@ -35,7 +35,7 @@ static struct lookahead_entry *pop(struct lookahead_ctx *ctx, void vp10_lookahead_destroy(struct lookahead_ctx *ctx) { if (ctx) { if (ctx->buf) { - unsigned int i; + int i; for (i = 0; i < ctx->max_sz; i++) vpx_free_frame_buffer(&ctx->buf[i].img); @@ -221,9 +221,9 @@ struct lookahead_entry *vp10_lookahead_peek(struct lookahead_ctx *ctx, if (index >= 0) { // Forward peek - if (index < (int)ctx->sz) { + if (index < ctx->sz) { index += ctx->read_idx; - if (index >= (int)ctx->max_sz) + if (index >= ctx->max_sz) index -= ctx->max_sz; buf = ctx->buf + index; } diff --git a/vp10/encoder/lookahead.h b/vp10/encoder/lookahead.h index 22429aeeb..f650f8028 100644 --- a/vp10/encoder/lookahead.h +++ b/vp10/encoder/lookahead.h @@ -31,10 +31,10 @@ struct lookahead_entry { #define MAX_PRE_FRAMES 1 struct lookahead_ctx { - unsigned int max_sz; /* Absolute size of the queue */ - unsigned int sz; /* Number of buffers currently in the queue */ - unsigned int read_idx; /* Read index */ - unsigned int write_idx; /* Write index */ + int max_sz; /* Absolute size of the queue */ + int sz; /* Number of buffers currently in the queue */ + int read_idx; /* Read index */ + int write_idx; /* Write index */ struct lookahead_entry *buf; /* Buffer list */ }; diff --git a/vp9/encoder/vp9_lookahead.c b/vp9/encoder/vp9_lookahead.c index def9b8c1d..441280cb1 100644 --- a/vp9/encoder/vp9_lookahead.c +++ b/vp9/encoder/vp9_lookahead.c @@ -20,8 +20,8 @@ /* Return the buffer at the given absolute index and increment the index */ static struct lookahead_entry *pop(struct lookahead_ctx *ctx, - unsigned int *idx) { - unsigned int index = *idx; + int *idx) { + int index = *idx; struct lookahead_entry *buf = ctx->buf + index; assert(index < ctx->max_sz); @@ -35,7 +35,7 @@ static struct lookahead_entry *pop(struct lookahead_ctx *ctx, void vp9_lookahead_destroy(struct lookahead_ctx *ctx) { if (ctx) { if (ctx->buf) { - unsigned int i; + int i; for (i = 0; i < ctx->max_sz; i++) vpx_free_frame_buffer(&ctx->buf[i].img); @@ -221,9 +221,9 @@ struct lookahead_entry *vp9_lookahead_peek(struct lookahead_ctx *ctx, if (index >= 0) { // Forward peek - if (index < (int)ctx->sz) { + if (index < ctx->sz) { index += ctx->read_idx; - if (index >= (int)ctx->max_sz) + if (index >= ctx->max_sz) index -= ctx->max_sz; buf = ctx->buf + index; } diff --git a/vp9/encoder/vp9_lookahead.h b/vp9/encoder/vp9_lookahead.h index 13820380f..db0fd1cde 100644 --- a/vp9/encoder/vp9_lookahead.h +++ b/vp9/encoder/vp9_lookahead.h @@ -36,10 +36,10 @@ struct lookahead_entry { #define MAX_PRE_FRAMES 1 struct lookahead_ctx { - unsigned int max_sz; /* Absolute size of the queue */ - unsigned int sz; /* Number of buffers currently in the queue */ - unsigned int read_idx; /* Read index */ - unsigned int write_idx; /* Write index */ + int max_sz; /* Absolute size of the queue */ + int sz; /* Number of buffers currently in the queue */ + int read_idx; /* Read index */ + int write_idx; /* Write index */ struct lookahead_entry *buf; /* Buffer list */ };