Merge "vp9/MACROBLOCKD: reorder struct members"
diff --git a/build/make/iosbuild.sh b/build/make/iosbuild.sh
index 5d2051e..2d6eb5b 100755
--- a/build/make/iosbuild.sh
+++ b/build/make/iosbuild.sh
@@ -172,8 +172,13 @@
# Trap function. Cleans up the subtree used to build all targets contained in
# $TARGETS.
cleanup() {
+ local readonly res=$?
cd "${ORIG_PWD}"
+ if [ $res -ne 0 ]; then
+ elog "build exited with error ($res)"
+ fi
+
if [ "${PRESERVE_BUILD_OUTPUT}" != "yes" ]; then
rm -rf "${BUILD_ROOT}"
fi
@@ -194,6 +199,10 @@
EOF
}
+elog() {
+ echo "${0##*/} failed because: $@" 1>&2
+}
+
vlog() {
if [ "${VERBOSE}" = "yes" ]; then
echo "$@"
@@ -255,3 +264,5 @@
fi
build_framework "${TARGETS}"
+echo "Successfully built '${FRAMEWORK_DIR}' for:"
+echo " ${TARGETS}"
diff --git a/test/byte_alignment_test.cc b/test/byte_alignment_test.cc
deleted file mode 100644
index aa4b78b..0000000
--- a/test/byte_alignment_test.cc
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 2014 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 "./vpx_config.h"
-#include "test/codec_factory.h"
-#include "test/decode_test_driver.h"
-#include "test/md5_helper.h"
-#include "test/util.h"
-#if CONFIG_WEBM_IO
-#include "test/webm_video_source.h"
-#endif
-
-namespace {
-
-const int kLegacyByteAlignment = 0;
-const int kLegacyYPlaneByteAlignment = 32;
-const int kNumPlanesToCheck = 3;
-const char kVP9TestFile[] = "vp90-2-02-size-lf-1920x1080.webm";
-const char kVP9Md5File[] = "vp90-2-02-size-lf-1920x1080.webm.md5";
-
-#if CONFIG_WEBM_IO
-
-struct ByteAlignmentTestParam {
- int byte_alignment;
- vpx_codec_err_t expected_value;
- bool decode_remaining;
-};
-
-const ByteAlignmentTestParam kBaTestParams[] = {
- {kLegacyByteAlignment, VPX_CODEC_OK, true},
- {32, VPX_CODEC_OK, true},
- {64, VPX_CODEC_OK, true},
- {128, VPX_CODEC_OK, true},
- {256, VPX_CODEC_OK, true},
- {512, VPX_CODEC_OK, true},
- {1024, VPX_CODEC_OK, true},
- {1, VPX_CODEC_INVALID_PARAM, false},
- {-2, VPX_CODEC_INVALID_PARAM, false},
- {4, VPX_CODEC_INVALID_PARAM, false},
- {16, VPX_CODEC_INVALID_PARAM, false},
- {255, VPX_CODEC_INVALID_PARAM, false},
- {2048, VPX_CODEC_INVALID_PARAM, false},
-};
-
-// Class for testing byte alignment of reference buffers.
-class ByteAlignmentTest
- : public ::testing::TestWithParam<ByteAlignmentTestParam> {
- protected:
- ByteAlignmentTest()
- : video_(NULL),
- decoder_(NULL),
- md5_file_(NULL) {}
-
- virtual void SetUp() {
- video_ = new libvpx_test::WebMVideoSource(kVP9TestFile);
- ASSERT_TRUE(video_ != NULL);
- video_->Init();
- video_->Begin();
-
- const vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
- decoder_ = new libvpx_test::VP9Decoder(cfg, 0);
- ASSERT_TRUE(decoder_ != NULL);
-
- OpenMd5File(kVP9Md5File);
- }
-
- virtual void TearDown() {
- if (md5_file_ != NULL)
- fclose(md5_file_);
-
- delete decoder_;
- delete video_;
- }
-
- void SetByteAlignment(int byte_alignment, vpx_codec_err_t expected_value) {
- decoder_->Control(VP9_SET_BYTE_ALIGNMENT, byte_alignment, expected_value);
- }
-
- vpx_codec_err_t DecodeOneFrame(int byte_alignment_to_check) {
- const vpx_codec_err_t res =
- decoder_->DecodeFrame(video_->cxdata(), video_->frame_size());
- CheckDecodedFrames(byte_alignment_to_check);
- if (res == VPX_CODEC_OK)
- video_->Next();
- return res;
- }
-
- vpx_codec_err_t DecodeRemainingFrames(int byte_alignment_to_check) {
- for (; video_->cxdata() != NULL; video_->Next()) {
- const vpx_codec_err_t res =
- decoder_->DecodeFrame(video_->cxdata(), video_->frame_size());
- if (res != VPX_CODEC_OK)
- return res;
- CheckDecodedFrames(byte_alignment_to_check);
- }
- return VPX_CODEC_OK;
- }
-
- private:
- // Check if |data| is aligned to |byte_alignment_to_check|.
- // |byte_alignment_to_check| must be a power of 2.
- void CheckByteAlignment(const uint8_t *data, int byte_alignment_to_check) {
- ASSERT_EQ(0u, reinterpret_cast<size_t>(data) % byte_alignment_to_check);
- }
-
- // Iterate through the planes of the decoded frames and check for
- // alignment based off |byte_alignment_to_check|.
- void CheckDecodedFrames(int byte_alignment_to_check) {
- libvpx_test::DxDataIterator dec_iter = decoder_->GetDxData();
- const vpx_image_t *img;
-
- // Get decompressed data
- while ((img = dec_iter.Next()) != NULL) {
- if (byte_alignment_to_check == kLegacyByteAlignment) {
- CheckByteAlignment(img->planes[0], kLegacyYPlaneByteAlignment);
- } else {
- for (int i = 0; i < kNumPlanesToCheck; ++i) {
- CheckByteAlignment(img->planes[i], byte_alignment_to_check);
- }
- }
- CheckMd5(*img);
- }
- }
-
- // TODO(fgalligan): Move the MD5 testing code into another class.
- 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_;
- }
-
- void CheckMd5(const vpx_image_t &img) {
- 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";
- }
-
- libvpx_test::WebMVideoSource *video_;
- libvpx_test::VP9Decoder *decoder_;
- FILE *md5_file_;
-};
-
-TEST_F(ByteAlignmentTest, SwitchByteAlignment) {
- const int num_elements = 14;
- const int byte_alignments[] = { 0, 32, 64, 128, 256, 512, 1024,
- 0, 1024, 32, 512, 64, 256, 128 };
-
- for (int i = 0; i < num_elements; ++i) {
- SetByteAlignment(byte_alignments[i], VPX_CODEC_OK);
- ASSERT_EQ(VPX_CODEC_OK, DecodeOneFrame(byte_alignments[i]));
- }
- SetByteAlignment(byte_alignments[0], VPX_CODEC_OK);
- ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames(byte_alignments[0]));
-}
-
-TEST_P(ByteAlignmentTest, TestAlignment) {
- const ByteAlignmentTestParam t = GetParam();
- SetByteAlignment(t.byte_alignment, t.expected_value);
- if (t.decode_remaining)
- ASSERT_EQ(VPX_CODEC_OK, DecodeRemainingFrames(t.byte_alignment));
-}
-
-INSTANTIATE_TEST_CASE_P(Alignments, ByteAlignmentTest,
- ::testing::ValuesIn(kBaTestParams));
-
-#endif // CONFIG_WEBM_IO
-
-} // namespace
diff --git a/test/codec_factory.h b/test/codec_factory.h
index 7f9398c..3a0e3db 100644
--- a/test/codec_factory.h
+++ b/test/codec_factory.h
@@ -35,6 +35,11 @@
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
unsigned long deadline) const = 0;
+ virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
+ const vpx_codec_flags_t flags,
+ unsigned long deadline) // NOLINT(runtime/int)
+ const = 0;
+
virtual Encoder* CreateEncoder(vpx_codec_enc_cfg_t cfg,
unsigned long deadline,
const unsigned long init_flags,
@@ -72,6 +77,10 @@
VP8Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
: Decoder(cfg, deadline) {}
+ VP8Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
+ unsigned long deadline) // NOLINT
+ : Decoder(cfg, flag, deadline) {}
+
protected:
virtual vpx_codec_iface_t* CodecInterface() const {
#if CONFIG_VP8_DECODER
@@ -104,8 +113,14 @@
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
unsigned long deadline) const {
+ return CreateDecoder(cfg, 0, deadline);
+ }
+
+ virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
+ const vpx_codec_flags_t flags,
+ unsigned long deadline) const { // NOLINT
#if CONFIG_VP8_DECODER
- return new VP8Decoder(cfg, deadline);
+ return new VP8Decoder(cfg, flags, deadline);
#else
return NULL;
#endif
@@ -154,6 +169,10 @@
VP9Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
: Decoder(cfg, deadline) {}
+ VP9Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
+ unsigned long deadline) // NOLINT
+ : Decoder(cfg, flag, deadline) {}
+
protected:
virtual vpx_codec_iface_t* CodecInterface() const {
#if CONFIG_VP9_DECODER
@@ -186,8 +205,14 @@
virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
unsigned long deadline) const {
+ return CreateDecoder(cfg, 0, deadline);
+ }
+
+ virtual Decoder* CreateDecoder(vpx_codec_dec_cfg_t cfg,
+ const vpx_codec_flags_t flags,
+ unsigned long deadline) const { // NOLINT
#if CONFIG_VP9_DECODER
- return new VP9Decoder(cfg, deadline);
+ return new VP9Decoder(cfg, flags, deadline);
#else
return NULL;
#endif
diff --git a/test/decode_test_driver.cc b/test/decode_test_driver.cc
index 0ef4f7b..852d90e 100644
--- a/test/decode_test_driver.cc
+++ b/test/decode_test_driver.cc
@@ -110,4 +110,12 @@
RunLoop(video, dec_cfg);
}
+void DecoderTest::set_cfg(const vpx_codec_dec_cfg_t &dec_cfg) {
+ memcpy(&cfg_, &dec_cfg, sizeof(cfg_));
+}
+
+void DecoderTest::set_flags(const vpx_codec_flags_t flags) {
+ flags_ = flags;
+}
+
} // namespace libvpx_test
diff --git a/test/decode_test_driver.h b/test/decode_test_driver.h
index 72a279f..232428e 100644
--- a/test/decode_test_driver.h
+++ b/test/decode_test_driver.h
@@ -41,7 +41,13 @@
class Decoder {
public:
Decoder(vpx_codec_dec_cfg_t cfg, unsigned long deadline)
- : cfg_(cfg), deadline_(deadline), init_done_(false) {
+ : cfg_(cfg), flags_(0), deadline_(deadline), init_done_(false) {
+ memset(&decoder_, 0, sizeof(decoder_));
+ }
+
+ Decoder(vpx_codec_dec_cfg_t cfg, const vpx_codec_flags_t flag,
+ unsigned long deadline) // NOLINT
+ : cfg_(cfg), flags_(flag), deadline_(deadline), init_done_(false) {
memset(&decoder_, 0, sizeof(decoder_));
}
@@ -66,7 +72,9 @@
}
void Control(int ctrl_id, int arg) {
- Control(ctrl_id, arg, VPX_CODEC_OK);
+ InitOnce();
+ const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
+ ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
}
void Control(int ctrl_id, const void *arg) {
@@ -75,12 +83,6 @@
ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
}
- void Control(int ctrl_id, int arg, vpx_codec_err_t expected_value) {
- InitOnce();
- const vpx_codec_err_t res = vpx_codec_control_(&decoder_, ctrl_id, arg);
- ASSERT_EQ(expected_value, res) << DecodeError();
- }
-
const char* DecodeError() {
const char *detail = vpx_codec_error_detail(&decoder_);
return detail ? detail : vpx_codec_error(&decoder_);
@@ -112,7 +114,7 @@
if (!init_done_) {
const vpx_codec_err_t res = vpx_codec_dec_init(&decoder_,
CodecInterface(),
- &cfg_, 0);
+ &cfg_, flags_);
ASSERT_EQ(VPX_CODEC_OK, res) << DecodeError();
init_done_ = true;
}
@@ -120,6 +122,7 @@
vpx_codec_ctx_t decoder_;
vpx_codec_dec_cfg_t cfg_;
+ vpx_codec_flags_t flags_;
unsigned int deadline_;
bool init_done_;
};
@@ -132,6 +135,9 @@
virtual void RunLoop(CompressedVideoSource *video,
const vpx_codec_dec_cfg_t &dec_cfg);
+ virtual void set_cfg(const vpx_codec_dec_cfg_t &dec_cfg);
+ virtual void set_flags(const vpx_codec_flags_t flags);
+
// Hook to be called before decompressing every frame.
virtual void PreDecodeFrameHook(const CompressedVideoSource& /*video*/,
Decoder* /*decoder*/) {}
@@ -154,11 +160,16 @@
const vpx_codec_err_t res_peek);
protected:
- explicit DecoderTest(const CodecFactory *codec) : codec_(codec) {}
+ explicit DecoderTest(const CodecFactory *codec)
+ : codec_(codec),
+ cfg_(),
+ flags_(0) {}
virtual ~DecoderTest() {}
const CodecFactory *codec_;
+ vpx_codec_dec_cfg_t cfg_;
+ vpx_codec_flags_t flags_;
};
} // namespace libvpx_test
diff --git a/test/encode_test_driver.cc b/test/encode_test_driver.cc
index 5b6757c..b49e8cb 100644
--- a/test/encode_test_driver.cc
+++ b/test/encode_test_driver.cc
@@ -140,6 +140,8 @@
}
void EncoderTest::RunLoop(VideoSource *video) {
+ vpx_codec_dec_cfg_t dec_cfg = vpx_codec_dec_cfg_t();
+
stats_.Reset();
ASSERT_TRUE(passes_ == 1 || passes_ == 2);
@@ -157,7 +159,13 @@
Encoder* const encoder = codec_->CreateEncoder(cfg_, deadline_, init_flags_,
&stats_);
ASSERT_TRUE(encoder != NULL);
- Decoder* const decoder = codec_->CreateDecoder(dec_cfg_, 0);
+
+ unsigned long dec_init_flags = 0; // NOLINT
+ // Use fragment decoder if encoder outputs partitions.
+ // NOTE: fragment decoder and partition encoder are only supported by VP8.
+ if (init_flags_ & VPX_CODEC_USE_OUTPUT_PARTITION)
+ dec_init_flags |= VPX_CODEC_USE_INPUT_FRAGMENTS;
+ Decoder* const decoder = codec_->CreateDecoder(dec_cfg, dec_init_flags, 0);
bool again;
for (again = true, video->Begin(); again; video->Next()) {
again = (video->img() != NULL);
@@ -199,6 +207,13 @@
}
}
+ // Flush the decoder when there are no more fragments.
+ if ((init_flags_ & VPX_CODEC_USE_OUTPUT_PARTITION) && has_dxdata) {
+ const vpx_codec_err_t res_dec = decoder->DecodeFrame(NULL, 0);
+ if (!HandleDecodeResult(res_dec, *video, decoder))
+ break;
+ }
+
if (has_dxdata && has_cxdata) {
const vpx_image_t *img_enc = encoder->GetPreviewFrame();
DxDataIterator dec_iter = decoder->GetDxData();
diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h
index 3bc7847..770ac7e 100644
--- a/test/encode_test_driver.h
+++ b/test/encode_test_driver.h
@@ -185,6 +185,11 @@
// Map the TestMode enum to the deadline_ and passes_ variables.
void SetMode(TestMode mode);
+ // Set encoder flag.
+ void set_init_flags(unsigned long flag) { // NOLINT(runtime/int)
+ init_flags_ = flag;
+ }
+
// Main loop
virtual void RunLoop(VideoSource *video);
diff --git a/test/test.mk b/test/test.mk
index f5c9c37..6e935de 100644
--- a/test/test.mk
+++ b/test/test.mk
@@ -31,7 +31,6 @@
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += cq_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP8_ENCODER) += keyframe_test.cc
-LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += byte_alignment_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += external_frame_buffer_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += invalid_file_test.cc
LIBVPX_TEST_SRCS-$(CONFIG_VP9_DECODER) += user_priv_test.cc
@@ -95,6 +94,7 @@
# These tests require both the encoder and decoder to be built.
ifeq ($(CONFIG_VP8_ENCODER)$(CONFIG_VP8_DECODER),yesyes)
LIBVPX_TEST_SRCS-yes += vp8_boolcoder_test.cc
+LIBVPX_TEST_SRCS-yes += vp8_fragments_test.cc
endif
LIBVPX_TEST_SRCS-$(CONFIG_POSTPROC) += pp_filter_test.cc
diff --git a/test/vp8_fragments_test.cc b/test/vp8_fragments_test.cc
new file mode 100644
index 0000000..cb0d1a1
--- /dev/null
+++ b/test/vp8_fragments_test.cc
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014 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 "third_party/googletest/src/include/gtest/gtest.h"
+#include "test/codec_factory.h"
+#include "test/video_source.h"
+
+namespace {
+
+class VP8FramgmentsTest
+ : public ::libvpx_test::EncoderTest,
+ public ::testing::Test {
+ protected:
+ VP8FramgmentsTest() : EncoderTest(&::libvpx_test::kVP8) {}
+ virtual ~VP8FramgmentsTest() {}
+
+ virtual void SetUp() {
+ const unsigned long init_flags = // NOLINT(runtime/int)
+ VPX_CODEC_USE_OUTPUT_PARTITION;
+ InitializeConfig();
+ SetMode(::libvpx_test::kRealTime);
+ set_init_flags(init_flags);
+ }
+};
+
+TEST_F(VP8FramgmentsTest, TestFragmentsEncodeDecode) {
+ ::libvpx_test::RandomVideoSource video;
+ ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
+}
+
+} // namespace
diff --git a/vp8/vp8_dx_iface.c b/vp8/vp8_dx_iface.c
index 5aa274d..352ed7b 100644
--- a/vp8/vp8_dx_iface.c
+++ b/vp8/vp8_dx_iface.c
@@ -60,7 +60,6 @@
vpx_decrypt_cb decrypt_cb;
void *decrypt_state;
vpx_image_t img;
- int flushed;
int img_setup;
struct frame_buffers yv12_frame_buffers;
void *user_priv;
@@ -89,7 +88,6 @@
priv->si.sz = sizeof(priv->si);
priv->decrypt_cb = NULL;
priv->decrypt_state = NULL;
- priv->flushed = 0;
if (ctx->config.dec)
{
@@ -307,6 +305,11 @@
return 0;
}
+ if (!ctx->fragments.enabled && (data == NULL && data_sz == 0))
+ {
+ return 0;
+ }
+
if (!ctx->fragments.enabled)
{
ctx->fragments.ptrs[0] = data;
@@ -327,14 +330,11 @@
unsigned int resolution_change = 0;
unsigned int w, h;
- if (data == NULL && data_sz == 0) {
- ctx->flushed = 1;
- return VPX_CODEC_OK;
+ if (!ctx->fragments.enabled && (data == NULL && data_sz == 0))
+ {
+ return 0;
}
- /* Reset flushed when receiving a valid frame */
- ctx->flushed = 0;
-
/* Update the input fragment data */
if(update_fragments(ctx, data, data_sz, &res) <= 0)
return res;
diff --git a/vp9/common/vp9_alloccommon.c b/vp9/common/vp9_alloccommon.c
index a9c44f9..cad5750 100644
--- a/vp9/common/vp9_alloccommon.c
+++ b/vp9/common/vp9_alloccommon.c
@@ -112,8 +112,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS,
- cm->byte_alignment) < 0)
+ VP9_ENC_BORDER_IN_PIXELS) < 0)
goto fail;
if (cm->frame_bufs[i].mvs == NULL) {
cm->frame_bufs[i].mvs =
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index bba24e0..c166590 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -208,7 +208,6 @@
int frame_parallel_decoding_mode;
int log2_tile_cols, log2_tile_rows;
- int byte_alignment;
// Private data associated with the frame buffer callbacks.
void *cb_priv;
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index 6eb9026..58df87d 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -719,7 +719,6 @@
cm->use_highbitdepth,
#endif
VP9_DEC_BORDER_IN_PIXELS,
- cm->byte_alignment,
&cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb,
cm->cb_priv)) {
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
@@ -794,7 +793,6 @@
cm->use_highbitdepth,
#endif
VP9_DEC_BORDER_IN_PIXELS,
- cm->byte_alignment,
&cm->frame_bufs[cm->new_fb_idx].raw_frame_buffer, cm->get_fb_cb,
cm->cb_priv)) {
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
diff --git a/vp9/encoder/vp9_denoiser.c b/vp9/encoder/vp9_denoiser.c
index 56ec6b3..4deeed2 100644
--- a/vp9/encoder/vp9_denoiser.c
+++ b/vp9/encoder/vp9_denoiser.c
@@ -425,7 +425,6 @@
#endif
int border) {
int i, fail;
- const int legacy_byte_alignment = 0;
assert(denoiser != NULL);
for (i = 0; i < MAX_REF_FRAMES; ++i) {
@@ -434,7 +433,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
use_highbitdepth,
#endif
- border, legacy_byte_alignment);
+ border);
if (fail) {
vp9_denoiser_free(denoiser);
return 1;
@@ -449,7 +448,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
use_highbitdepth,
#endif
- border, legacy_byte_alignment);
+ border);
if (fail) {
vp9_denoiser_free(denoiser);
return 1;
diff --git a/vp9/encoder/vp9_encoder.c b/vp9/encoder/vp9_encoder.c
index a7f34a2..aaa6b23 100644
--- a/vp9/encoder/vp9_encoder.c
+++ b/vp9/encoder/vp9_encoder.c
@@ -491,8 +491,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate altref buffer");
}
@@ -512,8 +511,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate last frame buffer");
@@ -523,8 +521,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate scaled source buffer");
@@ -534,8 +531,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to allocate scaled last source buffer");
}
@@ -571,8 +567,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to reallocate alt_ref_buffer");
}
@@ -2478,8 +2473,7 @@
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
cm->use_highbitdepth,
- VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL);
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL);
scale_and_extend_frame(ref, &cm->frame_bufs[new_fb].buf,
(int)cm->bit_depth);
#else
@@ -2488,8 +2482,7 @@
vp9_realloc_frame_buffer(&cm->frame_bufs[new_fb].buf,
cm->width, cm->height,
cm->subsampling_x, cm->subsampling_y,
- VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL);
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL);
scale_and_extend_frame(ref, &cm->frame_bufs[new_fb].buf);
#endif // CONFIG_VP9_HIGHBITDEPTH
cpi->scaled_ref_idx[ref_frame - 1] = new_fb;
@@ -2728,8 +2721,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS, cm->byte_alignment,
- NULL, NULL, NULL);
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL);
alloc_util_frame_buffers(cpi);
init_motion_estimation(cpi);
diff --git a/vp9/encoder/vp9_lookahead.c b/vp9/encoder/vp9_lookahead.c
index 708072e..823e7a1 100644
--- a/vp9/encoder/vp9_lookahead.c
+++ b/vp9/encoder/vp9_lookahead.c
@@ -65,7 +65,6 @@
// Allocate the lookahead structures
ctx = calloc(1, sizeof(*ctx));
if (ctx) {
- const int legacy_byte_alignment = 0;
unsigned int i;
ctx->max_sz = depth;
ctx->buf = calloc(depth, sizeof(*ctx->buf));
@@ -77,8 +76,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS,
- legacy_byte_alignment))
+ VP9_ENC_BORDER_IN_PIXELS))
goto bail;
}
return ctx;
diff --git a/vp9/encoder/vp9_svc_layercontext.c b/vp9/encoder/vp9_svc_layercontext.c
index 31e93be..184322f 100644
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -39,9 +39,7 @@
#if CONFIG_VP9_HIGHBITDEPTH
cpi->common.use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS,
- cpi->common.byte_alignment,
- NULL, NULL, NULL))
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL, NULL))
vpx_internal_error(&cpi->common.error, VPX_CODEC_MEM_ERROR,
"Failed to allocate empty frame for multiple frame "
"contexts");
diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c
index 424cc08..a4051f0 100644
--- a/vp9/encoder/vp9_temporal_filter.c
+++ b/vp9/encoder/vp9_temporal_filter.c
@@ -710,9 +710,8 @@
#if CONFIG_VP9_HIGHBITDEPTH
cm->use_highbitdepth,
#endif
- VP9_ENC_BORDER_IN_PIXELS,
- cm->byte_alignment,
- NULL, NULL, NULL)) {
+ VP9_ENC_BORDER_IN_PIXELS, NULL, NULL,
+ NULL)) {
vpx_internal_error(&cm->error, VPX_CODEC_MEM_ERROR,
"Failed to reallocate alt_ref_buffer");
}
diff --git a/vp9/vp9_dx_iface.c b/vp9/vp9_dx_iface.c
index 43bf35f..8095140 100644
--- a/vp9/vp9_dx_iface.c
+++ b/vp9/vp9_dx_iface.c
@@ -44,7 +44,6 @@
int flushed;
int invert_tile_order;
int frame_parallel_decode; // frame-based threading.
- int byte_alignment;
// External frame buffer info to save for VP9 common.
void *ext_priv; // Private data associated with the external frame buffers.
@@ -220,7 +219,6 @@
VP9_COMMON *const cm = &ctx->pbi->common;
cm->new_fb_idx = -1;
- cm->byte_alignment = ctx->byte_alignment;
if (ctx->get_ext_fb_cb != NULL && ctx->release_ext_fb_cb != NULL) {
cm->get_fb_cb = ctx->get_ext_fb_cb;
@@ -619,27 +617,6 @@
return VPX_CODEC_OK;
}
-static vpx_codec_err_t ctrl_set_byte_alignment(vpx_codec_alg_priv_t *ctx,
- va_list args) {
- const int legacy_byte_alignment = 0;
- const int min_byte_alignment = 32;
- const int max_byte_alignment = 1024;
- const int byte_alignment = va_arg(args, int);
-
- if (byte_alignment != legacy_byte_alignment &&
- (byte_alignment < min_byte_alignment ||
- byte_alignment > max_byte_alignment ||
- (byte_alignment & (byte_alignment - 1)) != 0))
- return VPX_CODEC_INVALID_PARAM;
-
- ctx->byte_alignment = byte_alignment;
- if (ctx->pbi != NULL) {
- VP9_COMMON *const cm = &ctx->pbi->common;
- cm->byte_alignment = byte_alignment;
- }
- return VPX_CODEC_OK;
-}
-
static vpx_codec_ctrl_fn_map_t decoder_ctrl_maps[] = {
{VP8_COPY_REFERENCE, ctrl_copy_reference},
@@ -652,7 +629,6 @@
{VP8_SET_DBG_DISPLAY_MV, ctrl_set_dbg_options},
{VP9_INVERT_TILE_DECODE_ORDER, ctrl_set_invert_tile_order},
{VPXD_SET_DECRYPTOR, ctrl_set_decryptor},
- {VP9_SET_BYTE_ALIGNMENT, ctrl_set_byte_alignment},
// Getters
{VP8D_GET_LAST_REF_UPDATES, ctrl_get_last_ref_updates},
diff --git a/vpx/vp8dx.h b/vpx/vp8dx.h
index 5cc25cd..379b306 100644
--- a/vpx/vp8dx.h
+++ b/vpx/vp8dx.h
@@ -78,13 +78,6 @@
/** control function to get the bit depth of the stream. */
VP9D_GET_BIT_DEPTH,
- /** control function to set the byte alignment of the planes in the reference
- * buffers. Valid values are power of 2, from 32 to 1024. A value of 0 sets
- * legacy alignment. I.e. Y plane is aligned to 32 bytes, U plane directly
- * follows Y plane, and V plane directly follows U plane. Default value is 0.
- */
- VP9_SET_BYTE_ALIGNMENT,
-
/** For testing. */
VP9_INVERT_TILE_DECODE_ORDER,
diff --git a/vpx_scale/generic/yv12config.c b/vpx_scale/generic/yv12config.c
index ff49ffb..00a8c16 100644
--- a/vpx_scale/generic/yv12config.c
+++ b/vpx_scale/generic/yv12config.c
@@ -143,25 +143,22 @@
int use_highbitdepth,
#endif
int border,
- int byte_alignment,
vpx_codec_frame_buffer_t *fb,
vpx_get_frame_buffer_cb_fn_t cb,
void *cb_priv) {
if (ybf) {
- const int vp9_byte_align = (byte_alignment == 0) ? 1 : byte_alignment;
const int aligned_width = (width + 7) & ~7;
const int aligned_height = (height + 7) & ~7;
const int y_stride = ((aligned_width + 2 * border) + 31) & ~31;
const uint64_t yplane_size = (aligned_height + 2 * border) *
- (uint64_t)y_stride + byte_alignment;
+ (uint64_t)y_stride;
const int uv_width = aligned_width >> ss_x;
const int uv_height = aligned_height >> ss_y;
const int uv_stride = y_stride >> ss_x;
const int uv_border_w = border >> ss_x;
const int uv_border_h = border >> ss_y;
const uint64_t uvplane_size = (uv_height + 2 * uv_border_h) *
- (uint64_t)uv_stride + byte_alignment;
-
+ (uint64_t)uv_stride;
#if CONFIG_ALPHA
const int alpha_width = aligned_width;
const int alpha_height = aligned_height;
@@ -169,7 +166,7 @@
const int alpha_border_w = border;
const int alpha_border_h = border;
const uint64_t alpha_plane_size = (alpha_height + 2 * alpha_border_h) *
- (uint64_t)alpha_stride + byte_alignment;
+ (uint64_t)alpha_stride;
#if CONFIG_VP9_HIGHBITDEPTH
const uint64_t frame_size = (1 + use_highbitdepth) *
(yplane_size + 2 * uvplane_size + alpha_plane_size);
@@ -185,9 +182,6 @@
const uint64_t frame_size = yplane_size + 2 * uvplane_size;
#endif // CONFIG_VP9_HIGHBITDEPTH
#endif // CONFIG_ALPHA
-
- uint8_t *buf = NULL;
-
if (cb != NULL) {
const int align_addr_extra_size = 31;
const uint64_t external_frame_size = frame_size + align_addr_extra_size;
@@ -250,33 +244,38 @@
ybf->subsampling_x = ss_x;
ybf->subsampling_y = ss_y;
- buf = ybf->buffer_alloc;
#if CONFIG_VP9_HIGHBITDEPTH
if (use_highbitdepth) {
// Store uint16 addresses when using 16bit framebuffers
- buf = CONVERT_TO_BYTEPTR(ybf->buffer_alloc);
+ uint8_t *p = CONVERT_TO_BYTEPTR(ybf->buffer_alloc);
+ ybf->y_buffer = p + (border * y_stride) + border;
+ ybf->u_buffer = p + yplane_size +
+ (uv_border_h * uv_stride) + uv_border_w;
+ ybf->v_buffer = p + yplane_size + uvplane_size +
+ (uv_border_h * uv_stride) + uv_border_w;
ybf->flags = YV12_FLAG_HIGHBITDEPTH;
} else {
+ ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border;
+ ybf->u_buffer = ybf->buffer_alloc + yplane_size +
+ (uv_border_h * uv_stride) + uv_border_w;
+ ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size +
+ (uv_border_h * uv_stride) + uv_border_w;
ybf->flags = 0;
}
+#else
+ ybf->y_buffer = ybf->buffer_alloc + (border * y_stride) + border;
+ ybf->u_buffer = ybf->buffer_alloc + yplane_size +
+ (uv_border_h * uv_stride) + uv_border_w;
+ ybf->v_buffer = ybf->buffer_alloc + yplane_size + uvplane_size +
+ (uv_border_h * uv_stride) + uv_border_w;
#endif // CONFIG_VP9_HIGHBITDEPTH
- ybf->y_buffer = (uint8_t *)yv12_align_addr(
- buf + (border * y_stride) + border, vp9_byte_align);
- ybf->u_buffer = (uint8_t *)yv12_align_addr(
- buf + yplane_size + (uv_border_h * uv_stride) + uv_border_w,
- vp9_byte_align);
- ybf->v_buffer = (uint8_t *)yv12_align_addr(
- buf + yplane_size + uvplane_size + (uv_border_h * uv_stride) +
- uv_border_w, vp9_byte_align);
-
#if CONFIG_ALPHA
ybf->alpha_width = alpha_width;
ybf->alpha_height = alpha_height;
ybf->alpha_stride = alpha_stride;
- ybf->alpha_buffer = (uint8_t *)yv12_align_addr(
- buf + yplane_size + 2 * uvplane_size +
- (alpha_border_h * alpha_stride) + alpha_border_w, vp9_byte_align);
+ ybf->alpha_buffer = ybf->buffer_alloc + yplane_size + 2 * uvplane_size +
+ (alpha_border_h * alpha_stride) + alpha_border_w;
#endif
ybf->corrupted = 0; /* assume not corrupted by errors */
return 0;
@@ -290,15 +289,14 @@
#if CONFIG_VP9_HIGHBITDEPTH
int use_highbitdepth,
#endif
- int border,
- int byte_alignment) {
+ int border) {
if (ybf) {
vp9_free_frame_buffer(ybf);
return vp9_realloc_frame_buffer(ybf, width, height, ss_x, ss_y,
#if CONFIG_VP9_HIGHBITDEPTH
use_highbitdepth,
#endif
- border, byte_alignment, NULL, NULL, NULL);
+ border, NULL, NULL, NULL);
}
return -2;
}
diff --git a/vpx_scale/yv12config.h b/vpx_scale/yv12config.h
index f04dee1..b9f13fd 100644
--- a/vpx_scale/yv12config.h
+++ b/vpx_scale/yv12config.h
@@ -73,10 +73,9 @@
#if CONFIG_VP9_HIGHBITDEPTH
int use_highbitdepth,
#endif
- int border, int byte_alignment);
+ int border);
-// Updates the yv12 buffer config with the frame buffer. |byte_alignment| must
-// be a power of 2, from 32 to 1024. 0 sets legacy alignment. If cb is not
+// Updates the yv12 buffer config with the frame buffer. If cb is not
// NULL, then libvpx is using the frame buffer callbacks to handle memory.
// If cb is not NULL, libvpx will call cb with minimum size in bytes needed
// to decode the current frame. If cb is NULL, libvpx will allocate memory
@@ -88,7 +87,6 @@
int use_highbitdepth,
#endif
int border,
- int byte_alignment,
vpx_codec_frame_buffer_t *fb,
vpx_get_frame_buffer_cb_fn_t cb,
void *cb_priv);