diff --git a/test/external_frame_buffer_test.cc b/test/external_frame_buffer_test.cc index 874d1997c..e50340159 100644 --- a/test/external_frame_buffer_test.cc +++ b/test/external_frame_buffer_test.cc @@ -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)); diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c index c123c4653..445198bb4 100644 --- a/vp9/vp9_dx_iface.c +++ b/vp9/vp9_dx_iface.c @@ -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 diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h index 6404b9872..6c644f045 100644 --- a/vpx/internal/vpx_codec_internal.h +++ b/vpx/internal/vpx_codec_internal.h @@ -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, diff --git a/vpx/vpx_decoder.h b/vpx/vpx_decoder.h index f28a07fb3..24be82d76 100644 --- a/vpx/vpx_decoder.h +++ b/vpx/vpx_decoder.h @@ -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,