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
This commit is contained in:
Frank Galligan 2013-12-17 17:34:36 -08:00
parent bbf53047b0
commit 9e41d569d7
4 changed files with 35 additions and 23 deletions

View File

@ -252,42 +252,51 @@ TEST_P(ExternalFrameBufferMD5Test, ExtFBMD5Match) {
delete video; delete video;
} }
TEST_F(ExternalFrameBufferTest, EightFrameBuffers) { TEST_F(ExternalFrameBufferTest, NineFrameBuffers) {
// Minimum number of reference buffers for VP9 is 8. // Minimum number of external frame buffers for VP9 is
const int num_buffers = 8; // #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, ASSERT_EQ(VPX_CODEC_OK,
SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer)); SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer));
ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames()); ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames());
} }
TEST_F(ExternalFrameBufferTest, EightJitterBuffers) { TEST_F(ExternalFrameBufferTest, EightJitterBuffers) {
// Number of buffers equals number of possible reference buffers(8), plus // Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
// one working buffer, plus eight jitter buffers. // #VPX_MAXIMUM_WORK_BUFFERS + eight jitter buffers.
const int num_buffers = 17; const int jitter_buffers = 8;
const int num_buffers =
VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS + jitter_buffers;
ASSERT_EQ(VPX_CODEC_OK, ASSERT_EQ(VPX_CODEC_OK,
SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer)); SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer));
ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames()); ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames());
} }
TEST_F(ExternalFrameBufferTest, NotEnoughBuffers) { TEST_F(ExternalFrameBufferTest, NotEnoughBuffers) {
// Minimum number of reference buffers for VP9 is 8. // Minimum number of external frame buffers for VP9 is
const int num_buffers = 7; // #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, ASSERT_EQ(VPX_CODEC_INVALID_PARAM,
SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer)); SetExternalFrameBuffers(num_buffers, realloc_vp9_frame_buffer));
} }
TEST_F(ExternalFrameBufferTest, NullFrameBufferList) { TEST_F(ExternalFrameBufferTest, NullFrameBufferList) {
// Number of buffers equals number of possible reference buffers(8), plus // Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
// one working buffer, plus four jitter buffers. // #VPX_MAXIMUM_WORK_BUFFERS + four jitter buffers.
const int num_buffers = 13; 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, ASSERT_EQ(VPX_CODEC_INVALID_PARAM,
SetNullFrameBuffers(num_buffers, realloc_vp9_frame_buffer)); SetNullFrameBuffers(num_buffers, realloc_vp9_frame_buffer));
} }
TEST_F(ExternalFrameBufferTest, NullRealloc) { TEST_F(ExternalFrameBufferTest, NullRealloc) {
// Number of buffers equals number of possible reference buffers(8), plus // Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
// one working buffer, plus four jitter buffers. // #VPX_MAXIMUM_WORK_BUFFERS + four jitter buffers.
const int num_buffers = 13; const int jitter_buffers = 4;
const int num_buffers =
VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS + jitter_buffers;
ASSERT_EQ(VPX_CODEC_OK, ASSERT_EQ(VPX_CODEC_OK,
SetExternalFrameBuffers(num_buffers, SetExternalFrameBuffers(num_buffers,
zero_realloc_vp9_frame_buffer)); zero_realloc_vp9_frame_buffer));
@ -295,9 +304,11 @@ TEST_F(ExternalFrameBufferTest, NullRealloc) {
} }
TEST_F(ExternalFrameBufferTest, ReallocOneLessByte) { TEST_F(ExternalFrameBufferTest, ReallocOneLessByte) {
// Number of buffers equals number of possible reference buffers(8), plus // Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
// one working buffer, plus four jitter buffers. // #VPX_MAXIMUM_WORK_BUFFERS + four jitter buffers.
const int num_buffers = 13; const int jitter_buffers = 4;
const int num_buffers =
VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS + jitter_buffers;
ASSERT_EQ(VPX_CODEC_OK, ASSERT_EQ(VPX_CODEC_OK,
SetExternalFrameBuffers(num_buffers, SetExternalFrameBuffers(num_buffers,
one_less_byte_realloc_vp9_frame_buffer)); one_less_byte_realloc_vp9_frame_buffer));

View File

@ -508,8 +508,9 @@ static vpx_codec_err_t vp9_set_frame_buffers(
vpx_codec_alg_priv_t *ctx, vpx_codec_alg_priv_t *ctx,
vpx_codec_frame_buffer_t *fb_list, int fb_count, vpx_codec_frame_buffer_t *fb_list, int fb_count,
vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv) { vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv) {
if (fb_count < REF_FRAMES) { if (fb_count < (VP9_MAXIMUM_REF_BUFFERS + VPX_MAXIMUM_WORK_BUFFERS)) {
/* The application must pass in at least REF_FRAMES frame buffers. */ /* The application must pass in at least VP9_MAXIMUM_REF_BUFFERS +
* VPX_MAXIMUM_WORK_BUFFERS frame buffers. */
return VPX_CODEC_INVALID_PARAM; return VPX_CODEC_INVALID_PARAM;
} else if (!ctx->pbi) { } else if (!ctx->pbi) {
/* If the decoder has already been initialized, do not accept external /* If the decoder has already been initialized, do not accept external

View File

@ -239,8 +239,8 @@ typedef vpx_image_t *(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx,
* *
* \note * \note
* When decoding VP9, the application must pass in at least * When decoding VP9, the application must pass in at least
* #VP9_MAXIMUM_REF_BUFFERS external frame buffers, as VP9 can have up to * #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
* that many reference frames. * buffers.
*/ */
typedef vpx_codec_err_t (*vpx_codec_set_frame_buffers_fn_t)( typedef vpx_codec_err_t (*vpx_codec_set_frame_buffers_fn_t)(
vpx_codec_alg_priv_t *ctx, vpx_codec_alg_priv_t *ctx,

View File

@ -363,8 +363,8 @@ extern "C" {
* *
* \note * \note
* When decoding VP9, the application must pass in at least * When decoding VP9, the application must pass in at least
* #VP9_MAXIMUM_REF_BUFFERS external frame buffers, as VP9 can have up to * #VP9_MAXIMUM_REF_BUFFERS + #VPX_MAXIMUM_WORK_BUFFERS external frame
* that many reference frames. * buffers.
*/ */
vpx_codec_err_t vpx_codec_set_frame_buffers( vpx_codec_err_t vpx_codec_set_frame_buffers(
vpx_codec_ctx_t *ctx, vpx_codec_ctx_t *ctx,