diff --git a/libs.mk b/libs.mk index 77840a45619eb66fadba4bae6f10db69f21ba01e..470066a67ae6e379a89b3496505d02966499007a 100644 --- a/libs.mk +++ b/libs.mk @@ -183,7 +183,6 @@ CODEC_EXPORTS-$(CONFIG_DECODERS) += vpx/exports_dec INSTALL-LIBS-yes += include/vpx/vpx_codec.h INSTALL-LIBS-yes += include/vpx/vpx_image.h -INSTALL-LIBS-yes += include/vpx/vpx_external_frame_buffer.h INSTALL-LIBS-yes += include/vpx/vpx_integer.h INSTALL-LIBS-$(CONFIG_DECODERS) += include/vpx/vpx_decoder.h INSTALL-LIBS-$(CONFIG_ENCODERS) += include/vpx/vpx_encoder.h diff --git a/test/codec_factory.h b/test/codec_factory.h index c060e86dc9908e531cf2e4f5f228bbbb2d043a36..38c4d29a0bdbc6c22dffe752f264773b693c4eeb 100644 --- a/test/codec_factory.h +++ b/test/codec_factory.h @@ -24,8 +24,6 @@ #include "test/encode_test_driver.h" namespace libvpx_test { -const int kCodecFactoryParam = 0; - class CodecFactory { public: CodecFactory() {} diff --git a/test/decode_test_driver.h b/test/decode_test_driver.h index 79db6e1bc56459275bac9c62849bdceb8c306a06..ddaed9fa0d1836a92da37ba093c93c59a7d5116a 100644 --- a/test/decode_test_driver.h +++ b/test/decode_test_driver.h @@ -76,16 +76,6 @@ class Decoder { return detail ? detail : vpx_codec_error(&decoder_); } - // Passes the external frame buffer information to libvpx. - vpx_codec_err_t SetExternalFrameBuffers( - vpx_codec_frame_buffer_t *fb_list, int fb_count, - vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv) { - InitOnce(); - return vpx_codec_set_frame_buffers(&decoder_, - fb_list, fb_count, - cb, user_priv); - } - protected: virtual const vpx_codec_iface_t* CodecInterface() const = 0; diff --git a/test/external_frame_buffer_test.cc b/test/external_frame_buffer_test.cc deleted file mode 100644 index 48eb8530e5cfa8f4f9a9d1d4850b42f08add9f52..0000000000000000000000000000000000000000 --- a/test/external_frame_buffer_test.cc +++ /dev/null @@ -1,322 +0,0 @@ -/* - * Copyright (c) 2013 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <string> - -#include "test/codec_factory.h" -#include "test/decode_test_driver.h" -#include "test/ivf_video_source.h" -#include "test/md5_helper.h" -#include "test/test_vectors.h" -#include "test/util.h" -#include "test/webm_video_source.h" - -namespace { - -const int kVideoNameParam = 1; -const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm"; - -// Callback used by libvpx to request the application to allocate a frame -// buffer of at least |new_size| in bytes. -int realloc_vp9_frame_buffer(void *user_priv, size_t new_size, - vpx_codec_frame_buffer_t *fb) { - (void)user_priv; - if (fb == NULL) - return -1; - - delete [] fb->data; - fb->data = new uint8_t[new_size]; - fb->size = new_size; - return 0; -} - -// Callback will not allocate data for frame buffer. -int zero_realloc_vp9_frame_buffer(void *user_priv, size_t new_size, - vpx_codec_frame_buffer_t *fb) { - (void)user_priv; - if (fb == NULL) - return -1; - - delete [] fb->data; - fb->data = NULL; - fb->size = new_size; - return 0; -} - -// Callback will allocate one less byte. -int one_less_byte_realloc_vp9_frame_buffer(void *user_priv, size_t new_size, - vpx_codec_frame_buffer_t *fb) { - (void)user_priv; - if (fb == NULL) - return -1; - - delete [] fb->data; - - const size_t error_size = new_size - 1; - fb->data = new uint8_t[error_size]; - fb->size = error_size; - return 0; -} - -// Class for testing passing in external frame buffers to libvpx. -class ExternalFrameBufferMD5Test - : public ::libvpx_test::DecoderTest, - public ::libvpx_test::CodecTestWithParam<const char*> { - protected: - ExternalFrameBufferMD5Test() - : DecoderTest(GET_PARAM(::libvpx_test::kCodecFactoryParam)), - md5_file_(NULL), - num_buffers_(0), - frame_buffers_(NULL) {} - - virtual ~ExternalFrameBufferMD5Test() { - for (int i = 0; i < num_buffers_; ++i) { - delete [] frame_buffers_[i].data; - } - delete [] frame_buffers_; - - if (md5_file_ != NULL) - fclose(md5_file_); - } - - virtual void PreDecodeFrameHook( - const libvpx_test::CompressedVideoSource &video, - libvpx_test::Decoder *decoder) { - if (num_buffers_ > 0 && video.frame_number() == 0) { - // Have libvpx use frame buffers we create. - frame_buffers_ = new vpx_codec_frame_buffer_t[num_buffers_]; - memset(frame_buffers_, 0, sizeof(frame_buffers_[0]) * num_buffers_); - - ASSERT_EQ(VPX_CODEC_OK, - decoder->SetExternalFrameBuffers( - frame_buffers_, num_buffers_, - realloc_vp9_frame_buffer, NULL)); - } - } - - void OpenMD5File(const std::string &md5_file_name_) { - md5_file_ = libvpx_test::OpenTestDataFile(md5_file_name_); - ASSERT_TRUE(md5_file_ != NULL) << "Md5 file open failed. Filename: " - << md5_file_name_; - } - - virtual void DecompressedFrameHook(const vpx_image_t &img, - const unsigned int frame_number) { - ASSERT_TRUE(md5_file_ != NULL); - char expected_md5[33]; - char junk[128]; - - // Read correct md5 checksums. - const int res = fscanf(md5_file_, "%s %s", expected_md5, junk); - ASSERT_NE(EOF, res) << "Read md5 data failed"; - expected_md5[32] = '\0'; - - ::libvpx_test::MD5 md5_res; - md5_res.Add(&img); - const char *const actual_md5 = md5_res.Get(); - - // Check md5 match. - ASSERT_STREQ(expected_md5, actual_md5) - << "Md5 checksums don't match: frame number = " << frame_number; - } - - void set_num_buffers(int num_buffers) { num_buffers_ = num_buffers; } - int num_buffers() const { return num_buffers_; } - - private: - FILE *md5_file_; - int num_buffers_; - vpx_codec_frame_buffer_t *frame_buffers_; -}; - -class ExternalFrameBufferTest : public ::testing::Test { - protected: - ExternalFrameBufferTest() - : video_(NULL), - decoder_(NULL), - num_buffers_(0), - frame_buffers_(NULL) {} - - virtual void SetUp() { - video_ = new libvpx_test::WebMVideoSource(kVP9TestFile); - video_->Init(); - video_->Begin(); - - vpx_codec_dec_cfg_t cfg = {0}; - decoder_ = new libvpx_test::VP9Decoder(cfg, 0); - } - - virtual void TearDown() { - for (int i = 0; i < num_buffers_; ++i) { - delete [] frame_buffers_[i].data; - } - delete [] frame_buffers_; - delete decoder_; - delete video_; - } - - // Passes the external frame buffer information to libvpx. - vpx_codec_err_t SetExternalFrameBuffers( - int num_buffers, - vpx_realloc_frame_buffer_cb_fn_t cb) { - if (num_buffers > 0) { - num_buffers_ = num_buffers; - - // Have libvpx use frame buffers we create. - frame_buffers_ = new vpx_codec_frame_buffer_t[num_buffers_]; - memset(frame_buffers_, 0, sizeof(frame_buffers_[0]) * num_buffers_); - } - - return decoder_->SetExternalFrameBuffers(frame_buffers_, num_buffers_, - cb, NULL); - } - - // Pass Null frame buffer list to libvpx. - vpx_codec_err_t SetNullFrameBuffers( - int num_buffers, - vpx_realloc_frame_buffer_cb_fn_t cb) { - return decoder_->SetExternalFrameBuffers(NULL, num_buffers, - cb, NULL); - } - - vpx_codec_err_t DecodeOneFrame() { - const vpx_codec_err_t res = - decoder_->DecodeFrame(video_->cxdata(), video_->frame_size()); - if (res == VPX_CODEC_OK) - video_->Next(); - return res; - } - - vpx_codec_err_t DecodeRemainingFrames() { - for (; video_->cxdata(); video_->Next()) { - const vpx_codec_err_t res = - decoder_->DecodeFrame(video_->cxdata(), video_->frame_size()); - if (res != VPX_CODEC_OK) - return res; - - libvpx_test::DxDataIterator dec_iter = decoder_->GetDxData(); - const vpx_image_t *img = NULL; - - // Get decompressed data - while ((img = dec_iter.Next())) { - } - } - return VPX_CODEC_OK; - } - - libvpx_test::WebMVideoSource *video_; - libvpx_test::VP9Decoder *decoder_; - int num_buffers_; - vpx_codec_frame_buffer_t *frame_buffers_; -}; - - -// This test runs through the set of test vectors, and decodes them. -// Libvpx will call into the application to allocate a frame buffer when -// needed. The md5 checksums are computed for each frame in the video file. -// If md5 checksums match the correct md5 data, then the test is passed. -// Otherwise, the test failed. -TEST_P(ExternalFrameBufferMD5Test, ExtFBMD5Match) { - const std::string filename = GET_PARAM(kVideoNameParam); - libvpx_test::CompressedVideoSource *video = NULL; - - // Number of buffers equals number of possible reference buffers(8), plus - // one working buffer, plus four jitter buffers. - const int num_buffers = 13; - set_num_buffers(num_buffers); - -#if CONFIG_VP8_DECODER - // Tell compiler we are not using kVP8TestVectors. - (void)libvpx_test::kVP8TestVectors; -#endif - - // Open compressed video file. - if (filename.substr(filename.length() - 3, 3) == "ivf") { - video = new libvpx_test::IVFVideoSource(filename); - } else if (filename.substr(filename.length() - 4, 4) == "webm") { - video = new libvpx_test::WebMVideoSource(filename); - } - video->Init(); - - // Construct md5 file name. - const std::string md5_filename = filename + ".md5"; - OpenMD5File(md5_filename); - - // Decode frame, and check the md5 matching. - ASSERT_NO_FATAL_FAILURE(RunLoop(video)); - delete video; -} - -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 #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 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 #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 #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)); - ASSERT_EQ(VPX_CODEC_MEM_ERROR, DecodeOneFrame()); -} - -TEST_F(ExternalFrameBufferTest, ReallocOneLessByte) { - // 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)); - ASSERT_EQ(VPX_CODEC_MEM_ERROR, DecodeOneFrame()); -} - -VP9_INSTANTIATE_TEST_CASE(ExternalFrameBufferMD5Test, - ::testing::ValuesIn(libvpx_test::kVP9TestVectors)); -} // namespace diff --git a/test/lru_frame_buffer_test.cc b/test/lru_frame_buffer_test.cc deleted file mode 100644 index cd6b432d89929062d7c6a7c611dd825c063b0d33..0000000000000000000000000000000000000000 --- a/test/lru_frame_buffer_test.cc +++ /dev/null @@ -1,207 +0,0 @@ -/* - * Copyright (c) 2013 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include <queue> -#include <string> - -#include "test/codec_factory.h" -#include "test/decode_test_driver.h" -#include "test/ivf_video_source.h" -#include "test/md5_helper.h" -#include "test/util.h" -#include "test/webm_video_source.h" - -namespace { - -const int kVideoNameParam = 1; - -const char *kLRUTestVectors[] = { - "vp90-2-02-size-lf-1920x1080.webm", - "vp90-2-05-resize.ivf", -}; - -// Callback used by libvpx to request the application to allocate a frame -// buffer of at least |new_size| in bytes. -int realloc_vp9_frame_buffer(void *user_priv, size_t new_size, - vpx_codec_frame_buffer_t *fb) { - (void)user_priv; - if (fb == NULL) - return -1; - - delete [] fb->data; - fb->data = new uint8_t[new_size]; - fb->size = new_size; - - return 0; -} - -// Class for testing libvpx is using the least recently -// used frame buffer when a new buffer is requested. -class LRUFrameBufferTest - : public ::libvpx_test::DecoderTest, - public ::libvpx_test::CodecTestWithParam<const char*> { - protected: - struct FrameBufferMD5Sum { - int frame_buffer_index; - vpx_image_t img; - std::string md5; - }; - - LRUFrameBufferTest() - : DecoderTest(GET_PARAM(::libvpx_test::kCodecFactoryParam)), - num_buffers_(0), - num_jitter_buffers_(0), - frame_buffers_(NULL) {} - - virtual ~LRUFrameBufferTest() { - for (int i = 0; i < num_buffers_; ++i) { - delete [] frame_buffers_[i].data; - } - delete [] frame_buffers_; - } - - virtual void PreDecodeFrameHook( - const libvpx_test::CompressedVideoSource &video, - libvpx_test::Decoder *decoder) { - // Use external buffers for testing jitter buffers. - if (num_jitter_buffers_ > 0 && video.frame_number() == 0) { - const int max_reference_buffers = 8; - - // Add 1 for a work buffer. - num_buffers_ = max_reference_buffers + 1 + num_jitter_buffers_; - - // Have libvpx use frame buffers we create. - frame_buffers_ = new vpx_codec_frame_buffer_t[num_buffers_]; - memset(frame_buffers_, 0, sizeof(frame_buffers_[0]) * num_buffers_); - - decoder->SetExternalFrameBuffers(frame_buffers_, num_buffers_, - realloc_vp9_frame_buffer, NULL); - } - - // Turn on frame buffer LRU cache. - decoder->Control(VP9D_SET_FRAME_BUFFER_LRU_CACHE, 1); - } - - virtual void DecompressedFrameHook(const vpx_image_t &img, - const unsigned int frame_number) { - const uint32_t ximg_y_plane = 0; - const uint8_t *const y_buffer = img.planes[ximg_y_plane]; - - // Find which external buffer contains the y_buffer. - int i = 0; - for (i = 0; i < num_buffers_; ++i) { - if (y_buffer >= frame_buffers_[i].data && - y_buffer < (frame_buffers_[i].data + frame_buffers_[i].size)) { - break; - } - } - - FrameBufferMD5Sum fb_md5; - fb_md5.frame_buffer_index = i; - fb_md5.img = img; - - libvpx_test::MD5 md5; - md5.Add(&img); - fb_md5.md5 = md5.Get(); - jitter_buffer_md5_sums_.push(fb_md5); - - // Check to see if any of the reconstructed image changed. - if (jitter_buffer_md5_sums_.size() > - static_cast<size_t>(num_jitter_buffers_)) { - fb_md5 = jitter_buffer_md5_sums_.front(); - - libvpx_test::MD5 md5; - md5.Add(&fb_md5.img); - const std::string check_str = md5.Get(); - - ASSERT_EQ(fb_md5.md5, check_str); - jitter_buffer_md5_sums_.pop(); - } - } - - libvpx_test::CompressedVideoSource *OpenCompressedFile( - const std::string &filename) { - if (filename.substr(filename.length() - 3, 3) == "ivf") { - return new libvpx_test::IVFVideoSource(filename); - } else if (filename.substr(filename.length() - 4, 4) == "webm") { - return new libvpx_test::WebMVideoSource(filename); - } - return NULL; - } - - void set_num_jitter_buffers(int num_buffers) { - num_jitter_buffers_ = num_buffers; - } - - private: - // Total number of external frame buffers. - int num_buffers_; - int num_jitter_buffers_; - - // External frame buffers used by libvpx. - vpx_codec_frame_buffer_t *frame_buffers_; - - // Save the md5 checksums for later comparison. - std::queue<FrameBufferMD5Sum> jitter_buffer_md5_sums_; -}; - -// This test runs through a set of test vectors, and decodes them. -// Libvpx will call into the application to allocate a frame buffer when -// needed. The md5 checksums are computed for each frame after it is -// decoded and stored to be checked later. After a jitter frame buffer -// has expired, the md5 checksum is computed again for the expired jitter -// buffer frame and checked against the md5 checksum after the frame was -// decoded. If md5 checksums match, then the test is passed. Otherwise, -// the test failed. -TEST_P(LRUFrameBufferTest, CheckLRUOneJitterBuffer) { - const std::string filename = GET_PARAM(kVideoNameParam); - - set_num_jitter_buffers(1); - - libvpx_test::CompressedVideoSource *const video = - OpenCompressedFile(filename); - video->Init(); - - // Decode frame, and check the md5 matching. - ASSERT_NO_FATAL_FAILURE(RunLoop(video)); - delete video; -} - -TEST_P(LRUFrameBufferTest, CheckLRUFourJitterBuffers) { - const std::string filename = GET_PARAM(kVideoNameParam); - - set_num_jitter_buffers(4); - - libvpx_test::CompressedVideoSource *const video = - OpenCompressedFile(filename); - video->Init(); - - // Decode frame, and check the md5 matching. - ASSERT_NO_FATAL_FAILURE(RunLoop(video)); - delete video; -} - -TEST_P(LRUFrameBufferTest, CheckLRUEightJitterBuffers) { - const std::string filename = GET_PARAM(kVideoNameParam); - - set_num_jitter_buffers(8); - - libvpx_test::CompressedVideoSource *const video = - OpenCompressedFile(filename); - video->Init(); - - // Decode frame, and check the md5 matching. - ASSERT_NO_FATAL_FAILURE(RunLoop(video)); - delete video; -} - -VP9_INSTANTIATE_TEST_CASE(LRUFrameBufferTest, - ::testing::ValuesIn(kLRUTestVectors)); -} // namespace diff --git a/test/test.mk b/test/test.mk index 178b1621014610d77e4fb6ea2e3fa395fede312d..cb62615685df7c87daa84c63f98b39bd204d1b48 100644 --- a/test/test.mk +++ b/test/test.mk @@ -36,8 +36,6 @@ LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ../md5_utils.h ../md5_utils.c LIBVPX_TEST_SRCS-yes += decode_test_driver.cc LIBVPX_TEST_SRCS-yes += decode_test_driver.h LIBVPX_TEST_SRCS-$(CONFIG_DECODERS) += ivf_video_source.h -LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += external_frame_buffer_test.cc -LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += lru_frame_buffer_test.cc ## WebM Parsing NESTEGG_SRCS += ../nestegg/halloc/halloc.h diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c index 0b4c4cbbfb93fc6544951c1155630c5a8e0bbe44..871b8d3857913182469616ef16711e59ea86c973 100644 --- a/vp8/vp8_dx_iface.c +++ b/vp8/vp8_dx_iface.c @@ -929,7 +929,6 @@ CODEC_INTERFACE(vpx_codec_vp8_dx) = vp8_get_si, /* vpx_codec_get_si_fn_t get_si; */ vp8_decode, /* vpx_codec_decode_fn_t decode; */ vp8_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */ - NOT_IMPLEMENTED, }, { /* encoder functions */ NOT_IMPLEMENTED, diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c index ca42090c129aab6640a93e3c8b4cd43d71c5d5d1..ada7c6c033612e318222f8609909636421452c15 100644 --- a/vp9/common/vp9_alloccommon.c +++ b/vp9/common/vp9_alloccommon.c @@ -33,7 +33,7 @@ void vp9_update_mode_info_border(VP9_COMMON *cm, MODE_INFO *mi) { void vp9_free_frame_buffers(VP9_COMMON *cm) { int i; - for (i = 0; i < cm->fb_count; i++) + for (i = 0; i < FRAME_BUFFERS; i++) vp9_free_frame_buffer(&cm->yv12_fb[i]); vp9_free_frame_buffer(&cm->post_proc_buffer); @@ -85,7 +85,7 @@ int vp9_resize_frame_buffers(VP9_COMMON *cm, int width, int height) { int mi_size; if (vp9_realloc_frame_buffer(&cm->post_proc_buffer, width, height, ss_x, ss_y, - VP9_DEC_BORDER_IN_PIXELS, NULL, NULL, NULL) < 0) + VP9_DEC_BORDER_IN_PIXELS) < 0) goto fail; set_mb_mi(cm, aligned_width, aligned_height); @@ -137,28 +137,16 @@ int vp9_alloc_frame_buffers(VP9_COMMON *cm, int width, int height) { const int ss_y = cm->subsampling_y; int mi_size; - if (cm->fb_count == 0) { - cm->fb_count = FRAME_BUFFERS; - CHECK_MEM_ERROR(cm, cm->yv12_fb, - vpx_calloc(cm->fb_count, sizeof(*cm->yv12_fb))); - CHECK_MEM_ERROR(cm, cm->fb_idx_ref_cnt, - vpx_calloc(cm->fb_count, sizeof(*cm->fb_idx_ref_cnt))); - if (cm->fb_lru) { - CHECK_MEM_ERROR(cm, cm->fb_idx_ref_lru, - vpx_calloc(cm->fb_count, sizeof(*cm->fb_idx_ref_lru))); - } - } - vp9_free_frame_buffers(cm); - for (i = 0; i < cm->fb_count; i++) { + for (i = 0; i < FRAME_BUFFERS; i++) { cm->fb_idx_ref_cnt[i] = 0; if (vp9_alloc_frame_buffer(&cm->yv12_fb[i], width, height, ss_x, ss_y, VP9_ENC_BORDER_IN_PIXELS) < 0) goto fail; } - cm->new_fb_idx = cm->fb_count - 1; + cm->new_fb_idx = FRAME_BUFFERS - 1; cm->fb_idx_ref_cnt[cm->new_fb_idx] = 1; for (i = 0; i < REF_FRAMES; i++) { @@ -211,14 +199,6 @@ void vp9_create_common(VP9_COMMON *cm) { void vp9_remove_common(VP9_COMMON *cm) { vp9_free_frame_buffers(cm); - - vpx_free(cm->yv12_fb); - vpx_free(cm->fb_idx_ref_cnt); - vpx_free(cm->fb_idx_ref_lru); - - cm->yv12_fb = NULL; - cm->fb_idx_ref_cnt = NULL; - cm->fb_idx_ref_lru = NULL; } void vp9_initialize_common() { diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 364c2a93dae91b56cebfce843e6eb91b3182c1fd..39fa7b1bbecc7b77229cf785c2a9bfb8c2b04ea9 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -117,8 +117,8 @@ typedef struct VP9Common { YV12_BUFFER_CONFIG *frame_to_show; - YV12_BUFFER_CONFIG *yv12_fb; - int *fb_idx_ref_cnt; /* reference counts */ + YV12_BUFFER_CONFIG yv12_fb[FRAME_BUFFERS]; + int fb_idx_ref_cnt[FRAME_BUFFERS]; /* reference counts */ int ref_frame_map[REF_FRAMES]; /* maps fb_idx to reference slot */ // TODO(jkoleszar): could expand active_ref_idx to 4, with 0 as intra, and @@ -217,15 +217,6 @@ typedef struct VP9Common { int frame_parallel_decoding_mode; int log2_tile_cols, log2_tile_rows; - - vpx_codec_frame_buffer_t *fb_list; // External frame buffers - int fb_count; // Total number of frame buffers - vpx_realloc_frame_buffer_cb_fn_t realloc_fb_cb; - void *user_priv; // Private data associated with the external frame buffers. - - int fb_lru; // Flag telling if lru is on/off - uint32_t *fb_idx_ref_lru; // Frame buffer lru cache - uint32_t fb_idx_ref_lru_count; } VP9_COMMON; static YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) { @@ -234,27 +225,13 @@ static YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) { static int get_free_fb(VP9_COMMON *cm) { int i; - uint32_t lru_count = cm->fb_idx_ref_lru_count + 1; - int free_buffer_idx = cm->fb_count; - for (i = 0; i < cm->fb_count; i++) { - if (!cm->fb_lru) { - if (cm->fb_idx_ref_cnt[i] == 0) { - free_buffer_idx = i; - break; - } - } else { - if (cm->fb_idx_ref_cnt[i] == 0 && cm->fb_idx_ref_lru[i] < lru_count) { - free_buffer_idx = i; - lru_count = cm->fb_idx_ref_lru[i]; - } - } - } + for (i = 0; i < FRAME_BUFFERS; i++) + if (cm->fb_idx_ref_cnt[i] == 0) + break; - assert(free_buffer_idx < cm->fb_count); - cm->fb_idx_ref_cnt[free_buffer_idx] = 1; - if (cm->fb_lru) - cm->fb_idx_ref_lru[free_buffer_idx] = ++cm->fb_idx_ref_lru_count; - return free_buffer_idx; + assert(i < FRAME_BUFFERS); + cm->fb_idx_ref_cnt[i] = 1; + return i; } static void ref_cnt_fb(int *buf, int *idx, int new_idx) { diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c index fa680d9832759f9d2b8f9072ff95728f5283a7de..e6f1dfddf0b7d816e858fc8d908871f130c2f9f3 100644 --- a/vp9/decoder/vp9_decodeframe.c +++ b/vp9/decoder/vp9_decodeframe.c @@ -699,21 +699,9 @@ static void apply_frame_size(VP9D_COMP *pbi, int width, int height) { vp9_update_frame_size(cm); } - if (cm->fb_list != NULL) { - vpx_codec_frame_buffer_t *const ext_fb = &cm->fb_list[cm->new_fb_idx]; - if (vp9_realloc_frame_buffer(get_frame_new_buffer(cm), - cm->width, cm->height, - cm->subsampling_x, cm->subsampling_y, - VP9_DEC_BORDER_IN_PIXELS, ext_fb, - cm->realloc_fb_cb, cm->user_priv)) { - vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, - "Failed to allocate external frame buffer"); - } - } else { - vp9_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height, - cm->subsampling_x, cm->subsampling_y, - VP9_DEC_BORDER_IN_PIXELS, NULL, NULL, NULL); - } + vp9_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height, + cm->subsampling_x, cm->subsampling_y, + VP9_DEC_BORDER_IN_PIXELS); } static void setup_frame_size(VP9D_COMP *pbi, diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 27531d23218804fcfce8f60ecad8946d68ce6ae7..85baefea1027fd9a32976b165be8caf008434cc1 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -969,7 +969,7 @@ static void alloc_raw_frame_buffers(VP9_COMP *cpi) { if (vp9_realloc_frame_buffer(&cpi->alt_ref_buffer, cpi->oxcf.width, cpi->oxcf.height, cm->subsampling_x, cm->subsampling_y, - VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL)) + VP9_ENC_BORDER_IN_PIXELS)) vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to allocate altref buffer"); } @@ -1037,14 +1037,14 @@ static void update_frame_size(VP9_COMP *cpi) { if (vp9_realloc_frame_buffer(&cpi->last_frame_uf, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, - VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL)) + VP9_ENC_BORDER_IN_PIXELS)) vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to reallocate last frame buffer"); if (vp9_realloc_frame_buffer(&cpi->scaled_source, cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, - VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL)) + VP9_ENC_BORDER_IN_PIXELS)) vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR, "Failed to reallocate scaled source buffer"); @@ -2589,7 +2589,7 @@ static void scale_references(VP9_COMP *cpi) { vp9_realloc_frame_buffer(&cm->yv12_fb[new_fb], cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, - VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL); + VP9_ENC_BORDER_IN_PIXELS); scale_and_extend_frame(ref, &cm->yv12_fb[new_fb]); cpi->scaled_ref_idx[ref_frame - 1] = new_fb; } else { @@ -3580,8 +3580,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, vp9_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, - VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL); - + VP9_ENC_BORDER_IN_PIXELS); for (ref_frame = LAST_FRAME; ref_frame <= ALTREF_FRAME; ++ref_frame) { const int idx = cm->ref_frame_map[get_ref_frame_idx(cpi, ref_frame)]; diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c index a03f7befcd2de3d2dbcde5f112dcb4807aaf2517..92c6cd20cc4ffce40f0a098fba65eb6c6fb1eff5 100644 --- a/vp9/vp9_dx_iface.c +++ b/vp9/vp9_dx_iface.c @@ -59,13 +59,6 @@ struct vpx_codec_alg_priv { int img_setup; int img_avail; int invert_tile_order; - int fb_lru; - - /* External buffer info to save for VP9 common. */ - vpx_codec_frame_buffer_t *fb_list; // External frame buffers - int fb_count; // Total number of frame buffers - vpx_realloc_frame_buffer_cb_fn_t realloc_fb_cb; - void *user_priv; // Private data associated with the external frame buffers. }; static unsigned long priv_sz(const vpx_codec_dec_cfg_t *si, @@ -298,32 +291,10 @@ static vpx_codec_err_t decode_one(vpx_codec_alg_priv_t *ctx, ctx->postproc_cfg.noise_level = 0; } - if (!optr) { + if (!optr) res = VPX_CODEC_ERROR; - } else { - VP9D_COMP *const pbi = (VP9D_COMP*)optr; - VP9_COMMON *const cm = &pbi->common; - if (ctx->fb_list != NULL && ctx->realloc_fb_cb != NULL && - ctx->fb_count > 0) { - cm->fb_list = ctx->fb_list; - cm->fb_count = ctx->fb_count; - cm->realloc_fb_cb = ctx->realloc_fb_cb; - cm->user_priv = ctx->user_priv; - } else { - cm->fb_count = FRAME_BUFFERS; - } - cm->fb_lru = ctx->fb_lru; - CHECK_MEM_ERROR(cm, cm->yv12_fb, - vpx_calloc(cm->fb_count, sizeof(*cm->yv12_fb))); - CHECK_MEM_ERROR(cm, cm->fb_idx_ref_cnt, - vpx_calloc(cm->fb_count, sizeof(*cm->fb_idx_ref_cnt))); - if (cm->fb_lru) { - CHECK_MEM_ERROR(cm, cm->fb_idx_ref_lru, - vpx_calloc(cm->fb_count, - sizeof(*cm->fb_idx_ref_lru))); - } + else ctx->pbi = optr; - } } ctx->decoder_init = 1; @@ -481,28 +452,6 @@ static vpx_image_t *vp9_get_frame(vpx_codec_alg_priv_t *ctx, return img; } -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 < (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 - * frame buffers. - */ - ctx->fb_list = fb_list; - ctx->fb_count = fb_count; - ctx->realloc_fb_cb = cb; - ctx->user_priv = user_priv; - return VPX_CODEC_OK; - } - - return VPX_CODEC_ERROR; -} - static vpx_codec_err_t vp9_xma_get_mmap(const vpx_codec_ctx_t *ctx, vpx_codec_mmap_t *mmap, vpx_codec_iter_t *iter) { @@ -713,21 +662,6 @@ static vpx_codec_err_t set_invert_tile_order(vpx_codec_alg_priv_t *ctx, return VPX_CODEC_OK; } -static vpx_codec_err_t set_frame_buffer_lru_cache(vpx_codec_alg_priv_t *ctx, - int ctr_id, - va_list args) { - VP9D_COMP *const pbi = (VP9D_COMP*)ctx->pbi; - - // Save for later to pass into vp9 common. - ctx->fb_lru = va_arg(args, int); - - if (pbi) { - VP9_COMMON *const cm = &pbi->common; - cm->fb_lru = ctx->fb_lru; - } - return VPX_CODEC_OK; -} - static vpx_codec_ctrl_fn_map_t ctf_maps[] = { {VP8_SET_REFERENCE, set_reference}, {VP8_COPY_REFERENCE, copy_reference}, @@ -741,7 +675,6 @@ static vpx_codec_ctrl_fn_map_t ctf_maps[] = { {VP9_GET_REFERENCE, get_reference}, {VP9D_GET_DISPLAY_SIZE, get_display_size}, {VP9_INVERT_TILE_DECODE_ORDER, set_invert_tile_order}, - {VP9D_SET_FRAME_BUFFER_LRU_CACHE, set_frame_buffer_lru_cache}, { -1, NULL}, }; @@ -752,8 +685,7 @@ static vpx_codec_ctrl_fn_map_t ctf_maps[] = { CODEC_INTERFACE(vpx_codec_vp9_dx) = { "WebM Project VP9 Decoder" VERSION_STRING, VPX_CODEC_INTERNAL_ABI_VERSION, - VPX_CODEC_CAP_DECODER | VP9_CAP_POSTPROC | - VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER, + VPX_CODEC_CAP_DECODER | VP9_CAP_POSTPROC, /* vpx_codec_caps_t caps; */ vp9_init, /* vpx_codec_init_fn_t init; */ vp9_destroy, /* vpx_codec_destroy_fn_t destroy; */ @@ -765,7 +697,6 @@ CODEC_INTERFACE(vpx_codec_vp9_dx) = { vp9_get_si, /* vpx_codec_get_si_fn_t get_si; */ vp9_decode, /* vpx_codec_decode_fn_t decode; */ vp9_get_frame, /* vpx_codec_frame_get_fn_t frame_get; */ - vp9_set_frame_buffers, /* vpx_codec_set_frame_buffers_fn_t set_fb; */ }, { // NOLINT /* encoder functions */ diff --git a/vpx/exports_dec b/vpx/exports_dec index d058c9bdb0d6648c6bab1e1c101b4428f939ac50..ed121f7ec58afedad4407c95b7825c48fc12618e 100644 --- a/vpx/exports_dec +++ b/vpx/exports_dec @@ -7,4 +7,3 @@ text vpx_codec_peek_stream_info text vpx_codec_register_put_frame_cb text vpx_codec_register_put_slice_cb text vpx_codec_set_mem_map -text vpx_codec_set_frame_buffers diff --git a/vpx/internal/vpx_codec_internal.h b/vpx/internal/vpx_codec_internal.h index 9f9da5c2891cf7c853279da763c790b865c7ed86..0f42a1d20ca2262b4a009ebce518f0c144011b55 100644 --- a/vpx/internal/vpx_codec_internal.h +++ b/vpx/internal/vpx_codec_internal.h @@ -59,7 +59,7 @@ extern "C" { * types, removing or reassigning enums, adding/removing/rearranging * fields to structures */ -#define VPX_CODEC_INTERNAL_ABI_VERSION (5) /**<\hideinitializer*/ +#define VPX_CODEC_INTERNAL_ABI_VERSION (4) /**<\hideinitializer*/ typedef struct vpx_codec_alg_priv vpx_codec_alg_priv_t; typedef struct vpx_codec_priv_enc_mr_cfg vpx_codec_priv_enc_mr_cfg_t; @@ -218,37 +218,6 @@ typedef vpx_codec_err_t (*vpx_codec_decode_fn_t)(vpx_codec_alg_priv_t *ctx, typedef vpx_image_t *(*vpx_codec_get_frame_fn_t)(vpx_codec_alg_priv_t *ctx, vpx_codec_iter_t *iter); -/*!\brief Pass in external frame buffers for the decoder to use. - * - * Registers a given function to be called when the current frame to - * decode will be bigger than the external frame buffer size. This - * function must be called before the first call to decode or libvpx - * will assume the default behavior of allocating frame buffers internally. - * Frame buffers with a size of 0 are valid. - * - * \param[in] ctx Pointer to this instance's context - * \param[in] fb_list Pointer to array of frame buffers - * \param[in] fb_count Number of elements in frame buffer array - * \param[in] cb Pointer to the callback function - * \param[in] user_priv User's private data - * - * \retval #VPX_CODEC_OK - * External frame buffers will be used by libvpx. - * \retval #VPX_CODEC_INVALID_PARAM - * fb_count was less than the value needed by the codec. - * \retval #VPX_CODEC_ERROR - * Decoder context not initialized, or algorithm not capable of - * using external frame buffers. - * - * \note - * When decoding VP9, the application must pass in at least - * #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, - vpx_codec_frame_buffer_t *fb_list, int fb_count, - vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv); /*\brief eXternal Memory Allocation memory map get iterator * @@ -339,7 +308,6 @@ struct vpx_codec_iface { vpx_codec_get_si_fn_t get_si; /**< \copydoc ::vpx_codec_get_si_fn_t */ vpx_codec_decode_fn_t decode; /**< \copydoc ::vpx_codec_decode_fn_t */ vpx_codec_get_frame_fn_t get_frame; /**< \copydoc ::vpx_codec_get_frame_fn_t */ - vpx_codec_set_frame_buffers_fn_t set_fb; /**< \copydoc ::vpx_codec_set_frame_buffers_fn_t */ } dec; struct vpx_codec_enc_iface { vpx_codec_enc_cfg_map_t *cfg_maps; /**< \copydoc ::vpx_codec_enc_cfg_map_t */ diff --git a/vpx/src/vpx_decoder.c b/vpx/src/vpx_decoder.c index 39fd217eaa9a9f230f37ca55ee9479ccd4f70cfe..a99e48f88e7b2c980e28b15bce6dc1e82f757c01 100644 --- a/vpx/src/vpx_decoder.c +++ b/vpx/src/vpx_decoder.c @@ -226,22 +226,3 @@ vpx_codec_err_t vpx_codec_set_mem_map(vpx_codec_ctx_t *ctx, return SAVE_STATUS(ctx, res); } - -vpx_codec_err_t vpx_codec_set_frame_buffers( - vpx_codec_ctx_t *ctx, - vpx_codec_frame_buffer_t *fb_list, int fb_count, - vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv) { - vpx_codec_err_t res; - - if (!ctx || !fb_list || fb_count <= 0 || !cb) { - res = VPX_CODEC_INVALID_PARAM; - } else if (!ctx->iface || !ctx->priv || - !(ctx->iface->caps & VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER)) { - res = VPX_CODEC_ERROR; - } else { - res = ctx->iface->dec.set_fb(ctx->priv->alg_priv, fb_list, fb_count, - cb, user_priv); - } - - return SAVE_STATUS(ctx, res); -} diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h index e89c0bcb14bd3b22798ed016ac2e93f48c8f70b6..bde77c24d87b506cd74bd5b6e663d3a256db392b 100644 --- a/vpx/vp8dx.h +++ b/vpx/vp8dx.h @@ -77,13 +77,6 @@ enum vp8_dec_control_id { /** For testing. */ VP9_INVERT_TILE_DECODE_ORDER, - /** control function to set the vp9 decoder into using the least recently - * used frame buffer when a new buffer is requested. Takes an int and if - * the value is zero will turn off using lru cache. The value of zero is - * the default. If the value is anything besides zero, then that will turn - * on lru cache.*/ - VP9D_SET_FRAME_BUFFER_LRU_CACHE, - VP8_DECODER_CTRL_ID_MAX }; @@ -115,7 +108,6 @@ VPX_CTRL_USE_TYPE(VP8D_GET_LAST_REF_USED, int *) VPX_CTRL_USE_TYPE(VP8D_SET_DECRYPTOR, vp8_decrypt_init *) VPX_CTRL_USE_TYPE(VP9D_GET_DISPLAY_SIZE, int *) VPX_CTRL_USE_TYPE(VP9_INVERT_TILE_DECODE_ORDER, int) -VPX_CTRL_USE_TYPE(VP9D_SET_FRAME_BUFFER_LRU_CACHE, int) /*! @} - end defgroup vp8_decoder */ diff --git a/vpx/vpx_codec.mk b/vpx/vpx_codec.mk index df3ff6ef1443e395c721f72954025d5c829a0519..549c249084be1358ae4dbc432836a46b44ea67bf 100644 --- a/vpx/vpx_codec.mk +++ b/vpx/vpx_codec.mk @@ -27,7 +27,6 @@ API_DOC_SRCS-yes += vpx_codec.h API_DOC_SRCS-yes += vpx_decoder.h API_DOC_SRCS-yes += vpx_encoder.h API_DOC_SRCS-yes += vpx_image.h -API_DOC_SRCS-yes += vpx_external_frame_buffer.h API_SRCS-yes += src/vpx_decoder.c API_SRCS-yes += vpx_decoder.h @@ -39,5 +38,4 @@ API_SRCS-yes += src/vpx_image.c API_SRCS-yes += vpx_codec.h API_SRCS-yes += vpx_codec.mk API_SRCS-yes += vpx_image.h -API_SRCS-yes += vpx_external_frame_buffer.h API_SRCS-$(BUILD_LIBVPX) += vpx_integer.h diff --git a/vpx/vpx_decoder.h b/vpx/vpx_decoder.h index 24be82d76e55dbe3f078299cd6d376153e1af97e..7356baea38f6ab524cdb170bb3b4f5737804c696 100644 --- a/vpx/vpx_decoder.h +++ b/vpx/vpx_decoder.h @@ -30,7 +30,6 @@ extern "C" { #endif #include "./vpx_codec.h" -#include "./vpx_external_frame_buffer.h" /*!\brief Current ABI version number * @@ -40,7 +39,7 @@ extern "C" { * types, removing or reassigning enums, adding/removing/rearranging * fields to structures */ -#define VPX_DECODER_ABI_VERSION (3 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/ +#define VPX_DECODER_ABI_VERSION (2 + VPX_CODEC_ABI_VERSION) /**<\hideinitializer*/ /*! \brief Decoder capabilities bitfield * @@ -67,8 +66,6 @@ extern "C" { */ #define VPX_CODEC_CAP_FRAME_THREADING 0x200000 /**< Can support frame-based multi-threading */ -#define VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER 0x400000 /**< Can support external - frame buffers */ #define VPX_CODEC_USE_POSTPROC 0x10000 /**< Postprocess decoded frame */ #define VPX_CODEC_USE_ERROR_CONCEALMENT 0x20000 /**< Conceal errors in decoded @@ -329,50 +326,6 @@ extern "C" { /*!@} - end defgroup cap_put_slice*/ - /*!\defgroup cap_external_frame_buffer External Frame Buffer Functions - * - * The following section is required to be implemented for all decoders - * that advertise the VPX_CODEC_CAP_EXTERNAL_FRAME_BUFFER capability. - * Calling this function for codecs that don't advertise this capability - * will result in an error code being returned, usually VPX_CODEC_ERROR. - * - * \note - * Currently this only works with VP9. - * @{ - */ - - /*!\brief Pass in external frame buffers for the decoder to use. - * - * Registers a given function to be called when the current frame to - * decode will be bigger than the external frame buffer size. This - * function must be called before the first call to decode or libvpx - * will assume the default behavior of allocating frame buffers internally. - * Frame buffers with a size of 0 are valid. - * - * \param[in] ctx Pointer to this instance's context - * \param[in] fb_list Pointer to array of frame buffers - * \param[in] fb_count Number of elements in frame buffer array - * \param[in] cb Pointer to the callback function - * \param[in] user_priv User's private data - * - * \retval #VPX_CODEC_OK - * External frame buffers passed into the decoder. - * \retval #VPX_CODEC_ERROR - * Decoder context not initialized, or algorithm not capable of - * using external frame buffers. - * - * \note - * When decoding VP9, the application must pass in at least - * #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, - vpx_codec_frame_buffer_t *fb_list, int fb_count, - vpx_realloc_frame_buffer_cb_fn_t cb, void *user_priv); - - /*!@} - end defgroup cap_external_frame_buffer */ - /*!@} - end defgroup decoder*/ #ifdef __cplusplus } diff --git a/vpx/vpx_external_frame_buffer.h b/vpx/vpx_external_frame_buffer.h deleted file mode 100644 index 98ce5fdfe395537119d1c6fbfa3c7d8d4f2e959c..0000000000000000000000000000000000000000 --- a/vpx/vpx_external_frame_buffer.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2013 The WebM project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef VPX_VPX_EXTERNAL_FRAME_BUFFER_H_ -#define VPX_VPX_EXTERNAL_FRAME_BUFFER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "./vpx_integer.h" - -/*!\brief The maximum number of work buffers used by libvpx. - */ -#define VPX_MAXIMUM_WORK_BUFFERS 1 - -/*!\brief The maximum number of reference buffers that a VP9 encoder may use. - */ -#define VP9_MAXIMUM_REF_BUFFERS 8 - -/*!\brief External frame buffer - * - * This structure is used to hold external frame buffers passed into the - * decoder by the application. - */ -typedef struct vpx_codec_frame_buffer { - uint8_t *data; /**< Pointer to the data buffer */ - size_t size; /**< Size of data in bytes */ - void *frame_priv; /**< Frame's private data */ -} vpx_codec_frame_buffer_t; - -/*!\brief realloc frame buffer callback prototype - * - * This callback is invoked by the decoder to notify the application one - * of the external frame buffers must increase in size, in order for the - * decode call to complete. The callback must allocate at least new_size in - * bytes and assign it to fb->data. Then the callback must set fb->size to - * the allocated size. The application does not need to align the allocated - * data. The callback is usually triggered by a frame size change. On success - * the callback must return 0. Any failure the callback must return a value - * less than 0. - * - * \param[in] user_priv User's private data - * \param[in] new_size Size in bytes needed by the buffer. - * \param[in/out] fb Pointer to frame buffer to increase size. - */ -typedef int (*vpx_realloc_frame_buffer_cb_fn_t)( - void *user_priv, size_t new_size, vpx_codec_frame_buffer_t *fb); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif // VPX_VPX_EXTERNAL_FRAME_BUFFER_H_ diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c index 994e8430c23d553570060994066714ef8e5c2269..693125a0f3a2af81b981465811384e6da7a34390 100644 --- a/vpx_scale/generic/yv12config.c +++ b/vpx_scale/generic/yv12config.c @@ -19,18 +19,10 @@ /**************************************************************************** * ****************************************************************************/ - -#define yv12_align_addr(addr, align) \ - (void*)(((size_t)(addr) + ((align) - 1)) & (size_t)-(align)) - int vp8_yv12_de_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf) { if (ybf) { - // If libvpx is using external frame buffers then buffer_alloc_sz must - // not be set. - if (ybf->buffer_alloc_sz > 0) { - vpx_free(ybf->buffer_alloc); - } + vpx_free(ybf->buffer_alloc); /* buffer_alloc isn't accessed by most functions. Rather y_buffer, u_buffer and v_buffer point to buffer_alloc and are used. Clear out @@ -116,9 +108,7 @@ int vp8_yv12_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int vp9_free_frame_buffer(YV12_BUFFER_CONFIG *ybf) { if (ybf) { - if (ybf->buffer_alloc_sz > 0) { - vpx_free(ybf->buffer_alloc); - } + vpx_free(ybf->buffer_alloc); /* buffer_alloc isn't accessed by most functions. Rather y_buffer, u_buffer and v_buffer point to buffer_alloc and are used. Clear out @@ -133,10 +123,7 @@ int vp9_free_frame_buffer(YV12_BUFFER_CONFIG *ybf) { int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, - int ss_x, int ss_y, int border, - vpx_codec_frame_buffer_t *ext_fb, - vpx_realloc_frame_buffer_cb_fn_t cb, - void *user_priv) { + int ss_x, int ss_y, int border) { if (ybf) { const int aligned_width = (width + 7) & ~7; const int aligned_height = (height + 7) & ~7; @@ -161,48 +148,25 @@ int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, #else const int frame_size = yplane_size + 2 * uvplane_size; #endif + if (frame_size > ybf->buffer_alloc_sz) { + // Allocation to hold larger frame, or first allocation. + if (ybf->buffer_alloc) + vpx_free(ybf->buffer_alloc); + ybf->buffer_alloc = vpx_memalign(32, frame_size); + if (!ybf->buffer_alloc) + return -1; - if (ext_fb != NULL) { - const int align_addr_extra_size = 31; - const size_t external_frame_size = frame_size + align_addr_extra_size; - if (external_frame_size > ext_fb->size) { - // Allocation to hold larger frame, or first allocation. - if (cb(user_priv, external_frame_size, ext_fb) < 0) { - return -1; - } - - if (ext_fb->data == NULL || ext_fb->size < external_frame_size) { - return -1; - } - - // This memset is needed for fixing valgrind error from C loop filter - // due to access uninitialized memory in frame border. It could be - // removed if border is totally removed. - vpx_memset(ext_fb->data, 0, ext_fb->size); - - ybf->buffer_alloc = yv12_align_addr(ext_fb->data, 32); - } - } else { - if (frame_size > ybf->buffer_alloc_sz) { - // Allocation to hold larger frame, or first allocation. - if (ybf->buffer_alloc) - vpx_free(ybf->buffer_alloc); - ybf->buffer_alloc = vpx_memalign(32, frame_size); - if (!ybf->buffer_alloc) - return -1; - - ybf->buffer_alloc_sz = frame_size; - - // This memset is needed for fixing valgrind error from C loop filter - // due to access uninitialized memory in frame boarder. It could be - // removed if border is totally removed. - vpx_memset(ybf->buffer_alloc, 0, ybf->buffer_alloc_sz); - } + ybf->buffer_alloc_sz = frame_size; - if (ybf->buffer_alloc_sz < frame_size) - return -1; + // This memset is needed for fixing valgrind error from C loop filter + // due to access uninitialized memory in frame boarder. It could be + // removed if border is totally removed. + vpx_memset(ybf->buffer_alloc, 0, ybf->buffer_alloc_sz); } + if (ybf->buffer_alloc_sz < frame_size) + return -1; + /* Only support allocating buffers that have a border that's a multiple * of 32. The border restriction is required to get 16-byte alignment of * the start of the chroma rows without introducing an arbitrary gap @@ -250,8 +214,7 @@ int vp9_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int ss_x, int ss_y, int border) { if (ybf) { vp9_free_frame_buffer(ybf); - return vp9_realloc_frame_buffer(ybf, width, height, ss_x, ss_y, border, - NULL, NULL, NULL); + return vp9_realloc_frame_buffer(ybf, width, height, ss_x, ss_y, border); } return -2; } diff --git a/vpx_scale/yv12config.h b/vpx_scale/yv12config.h index 610e7d280264c13627e5080e583a5fac43c18f30..8f39eb7699067c9ab3aeac540ca79c0cb33bae7e 100644 --- a/vpx_scale/yv12config.h +++ b/vpx_scale/yv12config.h @@ -15,7 +15,6 @@ extern "C" { #endif -#include "vpx/vpx_external_frame_buffer.h" #include "vpx/vpx_integer.h" #define VP8BORDERINPIXELS 32 @@ -66,20 +65,9 @@ extern "C" { int vp9_alloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int ss_x, int ss_y, int border); - - // Updates the yv12 buffer config with the frame buffer. If ext_fb is not - // NULL then libvpx is using external frame buffers. The function will - // check if the frame buffer is big enough to fit the decoded frame and - // try to reallocate the frame buffer. If ext_fb is not NULL and the frame - // buffer is not big enough libvpx will call cb with minimum size in bytes. - // - // Returns 0 on success. Returns < 0 on failure. int vp9_realloc_frame_buffer(YV12_BUFFER_CONFIG *ybf, int width, int height, int ss_x, int ss_y, - int border, - vpx_codec_frame_buffer_t *ext_fb, - vpx_realloc_frame_buffer_cb_fn_t cb, - void *user_priv); + int border); int vp9_free_frame_buffer(YV12_BUFFER_CONFIG *ybf); #ifdef __cplusplus diff --git a/vpxdec.c b/vpxdec.c index cd50b05218962bce3a2905e784c8edf5d348960e..2a79665f634d94b4748f02682379aedf2bd3663f 100644 --- a/vpxdec.c +++ b/vpxdec.c @@ -87,10 +87,6 @@ static const arg_def_t error_concealment = ARG_DEF(NULL, "error-concealment", 0, "Enable decoder error-concealment"); static const arg_def_t scalearg = ARG_DEF("S", "scale", 0, "Scale output frames uniformly"); -static const arg_def_t fb_arg = - ARG_DEF(NULL, "frame-buffers", 1, "Number of frame buffers to use"); -static const arg_def_t fb_lru_arg = - ARG_DEF(NULL, "frame-buffers-lru", 1, "Turn on/off frame buffer lru"); static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0, @@ -99,7 +95,7 @@ static const arg_def_t md5arg = ARG_DEF(NULL, "md5", 0, static const arg_def_t *all_args[] = { &codecarg, &use_yv12, &use_i420, &flipuvarg, &noblitarg, &progressarg, &limitarg, &skiparg, &postprocarg, &summaryarg, &outputfile, - &threadsarg, &verbosearg, &scalearg, &fb_arg, &fb_lru_arg, + &threadsarg, &verbosearg, &scalearg, &md5arg, &error_concealment, NULL @@ -329,31 +325,6 @@ void show_progress(int frame_in, int frame_out, unsigned long dx_time) { (float)frame_out * 1000000.0 / (float)dx_time); } -// Called by libvpx if the frame buffer size needs to increase. -// -// Parameters: -// user_priv Data passed into libvpx. -// new_size Minimum size needed by libvpx to decompress the next frame. -// fb Pointer to the frame buffer to update. -// -// Returns 0 on success. Returns < 0 on failure. -int realloc_vp9_frame_buffer(void *user_priv, size_t new_size, - vpx_codec_frame_buffer_t *fb) { - (void)user_priv; - if (!fb) - return -1; - - free(fb->data); - fb->data = (uint8_t*)malloc(new_size); - if (!fb->data) { - fb->size = 0; - return -1; - } - - fb->size = new_size; - return 0; -} - void generate_filename(const char *pattern, char *out, size_t q_len, unsigned int d_w, unsigned int d_h, unsigned int frame_in) { @@ -499,9 +470,6 @@ int main_loop(int argc, const char **argv_) { int do_scale = 0; vpx_image_t *scaled_img = NULL; int frame_avail, got_data; - int num_external_frame_buffers = 0; - int fb_lru_cache = 0; - vpx_codec_frame_buffer_t *frame_buffers = NULL; const char *outfile_pattern = NULL; char outfile_name[PATH_MAX] = {0}; @@ -568,10 +536,6 @@ int main_loop(int argc, const char **argv_) { quiet = 0; else if (arg_match(&arg, &scalearg, argi)) do_scale = 1; - else if (arg_match(&arg, &fb_arg, argi)) - num_external_frame_buffers = arg_parse_uint(&arg); - else if (arg_match(&arg, &fb_lru_arg, argi)) - fb_lru_cache = arg_parse_uint(&arg); #if CONFIG_VP8_DECODER else if (arg_match(&arg, &addnoise_level, argi)) { @@ -762,30 +726,6 @@ int main_loop(int argc, const char **argv_) { arg_skip--; } - if (num_external_frame_buffers > 0) { - // Allocate the frame buffer list, setting all of the values to 0. - // Including the size of frame buffers. Libvpx will request the - // application to realloc the frame buffer data if the size is too small. - frame_buffers = (vpx_codec_frame_buffer_t*)calloc( - num_external_frame_buffers, sizeof(*frame_buffers)); - if (vpx_codec_set_frame_buffers(&decoder, frame_buffers, - num_external_frame_buffers, - realloc_vp9_frame_buffer, - NULL)) { - fprintf(stderr, "Failed to configure external frame buffers: %s\n", - vpx_codec_error(&decoder)); - return EXIT_FAILURE; - } - } - - if (fb_lru_cache > 0 && - vpx_codec_control(&decoder, VP9D_SET_FRAME_BUFFER_LRU_CACHE, - fb_lru_cache)) { - fprintf(stderr, "Failed to set frame buffer lru cache: %s\n", - vpx_codec_error(&decoder)); - return EXIT_FAILURE; - } - frame_avail = 1; got_data = 0; @@ -940,10 +880,6 @@ fail: free(buf); if (scaled_img) vpx_img_free(scaled_img); - for (i = 0; i < num_external_frame_buffers; ++i) { - free(frame_buffers[i].data); - } - free(frame_buffers); fclose(infile); free(argv);