Commit 9e41d569 authored by Frank Galligan's avatar Frank Galligan

Increase required number of external frame buffers

Make applications pass in VPX_MAXIMUM_WORK_BUFFERS as well as
VP9_MAXIMUM_REF_BUFFERS.

Change-Id: I9c07ce83fa19c90ed43227b801b2013690e81edd
parent bbf53047
......@@ -252,42 +252,51 @@ TEST_P(ExternalFrameBufferMD5Test, ExtFBMD5Match) {
delete video;
}
TEST_F(ExternalFrameBufferTest, EightFrameBuffers) {
// Minimum number of reference buffers for VP9 is 8.
const int num_buffers = 8;
TEST_F(ExternalFrameBufferTest, NineFrameBuffers) {
// Minimum number of external frame buffers for VP9 is
// #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS.
const int num_buffers = VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS;
ASSERT_EQ(VPX_CODEC_OK,
SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer));
ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames());
}
TEST_F(ExternalFrameBufferTest, EightJitterBuffers) {
// Number of buffers equals number of possible reference buffers(8), plus
// one working buffer, plus eight jitter buffers.
const int num_buffers = 17;
// Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
// #VPX_MAXIMUM_WORK_BUFFERS + eight jitter buffers.
const int jitter_buffers = 8;
const int num_buffers =
VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS + jitter_buffers;
ASSERT_EQ(VPX_CODEC_OK,
SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer));
ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames());
}
TEST_F(ExternalFrameBufferTest, NotEnoughBuffers) {
// Minimum number of reference buffers for VP9 is 8.
const int num_buffers = 7;
// Minimum number of external frame buffers for VP9 is
// #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS. Set one less.
const int num_buffers =
VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS - 1;
ASSERT_EQ(VPX_CODEC_INVALID_PARAM,
SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer));
}
TEST_F(ExternalFrameBufferTest, NullFrameBufferList) {
// Number of buffers equals number of possible reference buffers(8), plus
// one working buffer, plus four jitter buffers.
const int num_buffers = 13;
// Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
// #VPX_MAXIMUM_WORK_BUFFERS + four jitter buffers.
const int jitter_buffers = 4;
const int num_buffers =
VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS + jitter_buffers;
ASSERT_EQ(VPX_CODEC_INVALID_PARAM,
SetNullFrameBuffers(num_buffers, realloc_vp9_frame_buffer));
}
TEST_F(ExternalFrameBufferTest, NullRealloc) {
// Number of buffers equals number of possible reference buffers(8), plus
// one working buffer, plus four jitter buffers.
const int num_buffers = 13;
// Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
// #VPX_MAXIMUM_WORK_BUFFERS + four jitter buffers.
const int jitter_buffers = 4;
const int num_buffers =
VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS + jitter_buffers;
ASSERT_EQ(VPX_CODEC_OK,
SetExternalFrameBuffers(num_buffers,
zero_realloc_vp9_frame_buffer));
......@@ -295,9 +304,11 @@ TEST_F(ExternalFrameBufferTest, NullRealloc) {
}
TEST_F(ExternalFrameBufferTest, ReallocOneLessByte) {
// Number of buffers equals number of possible reference buffers(8), plus
// one working buffer, plus four jitter buffers.
const int num_buffers = 13;
// Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
// #VPX_MAXIMUM_WORK_BUFFERS + four jitter buffers.
const int jitter_buffers = 4;
const int num_buffers =
VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS + jitter_buffers;
ASSERT_EQ(VPX_CODEC_OK,
SetExternalFrameBuffers(num_buffers,
one_less_byte_realloc_vp9_frame_buffer));
......
......@@ -508,8 +508,9 @@ 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 < REF_FRAMES) {
/* The application must pass in at least REF_FRAMES frame buffers. */
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
......
......@@ -239,8 +239,8 @@ typedef vpx_image_t *(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx,
*
* \note
* When decoding VP9, the application must pass in at least
* #VP9_MAXIMUM_REF_BUFFERS external frame buffers, as VP9 can have up to
* that many reference frames.
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
* buffers.
*/
typedef vpx_codec_err_t (*vpx_codec_set_frame_buffers_fn_t)(
vpx_codec_alg_priv_t *ctx,
......
......@@ -363,8 +363,8 @@ extern "C" {
*
* \note
* When decoding VP9, the application must pass in at least
* #VP9_MAXIMUM_REF_BUFFERS external frame buffers, as VP9 can have up to
* that many reference frames.
* #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
* buffers.
*/
vpx_codec_err_t vpx_codec_set_frame_buffers(
vpx_codec_ctx_t *ctx,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment