summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Zern <jzern@google.com>2014-08-12 22:48:27 -0700
committerGerrit Code Review <gerrit@gerrit.golo.chromium.org>2014-08-12 22:48:27 -0700
commit4b79563805b1d44978ff5fb607c133af5a7939fc (patch)
tree8438fcf3d4135ab1975772b90079cf62e41e2a03
parent80b6c9c56fe963c87cd24cdfc476bc4242d4674f (diff)
parent3caed4f8fdecaf2a9f4faf591f7c3f7cd739ce8f (diff)
downloadlibvpx-4b79563805b1d44978ff5fb607c133af5a7939fc.tar
libvpx-4b79563805b1d44978ff5fb607c133af5a7939fc.tar.gz
libvpx-4b79563805b1d44978ff5fb607c133af5a7939fc.tar.bz2
libvpx-4b79563805b1d44978ff5fb607c133af5a7939fc.zip
Merge "get_ref_frame: check ref_frame_map value"
-rw-r--r--test/decode_api_test.cc18
-rw-r--r--vp9/common/vp9_onyxc_int.h3
2 files changed, 21 insertions, 0 deletions
diff --git a/test/decode_api_test.cc b/test/decode_api_test.cc
index 06790645f..72fdfc7bc 100644
--- a/test/decode_api_test.cc
+++ b/test/decode_api_test.cc
@@ -81,6 +81,24 @@ void TestVp9Controls(vpx_codec_ctx_t *dec) {
EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
vpx_codec_control_(dec, kControls[i], NULL));
}
+
+ vp9_ref_frame_t ref;
+ ref.idx = 0;
+ EXPECT_EQ(VPX_CODEC_ERROR, vpx_codec_control(dec, VP9_GET_REFERENCE, &ref));
+ EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
+ vpx_codec_control(dec, VP9_GET_REFERENCE, NULL));
+
+ vpx_ref_frame_t ref_copy;
+ const int width = 352;
+ const int height = 288;
+ ASSERT_TRUE(
+ vpx_img_alloc(&ref_copy.img, VPX_IMG_FMT_I420, width, height, 1) != NULL);
+ ref_copy.frame_type = VP8_LAST_FRAME;
+ EXPECT_EQ(VPX_CODEC_ERROR,
+ vpx_codec_control(dec, VP8_COPY_REFERENCE, &ref_copy));
+ EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
+ vpx_codec_control(dec, VP8_COPY_REFERENCE, NULL));
+ vpx_img_free(&ref_copy.img);
}
TEST(DecodeAPI, Vp9InvalidDecode) {
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index ae32aff7d..dff077c11 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -205,6 +205,9 @@ typedef struct VP9Common {
static INLINE YV12_BUFFER_CONFIG *get_ref_frame(VP9_COMMON *cm, int index) {
if (index < 0 || index >= REF_FRAMES)
return NULL;
+ if (cm->ref_frame_map[index] < 0)
+ return NULL;
+ assert(cm->ref_frame_map[index] < REF_FRAMES);
return &cm->frame_bufs[cm->ref_frame_map[index]].buf;
}