/* * 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.
*/
// Class for testing byte alignment of reference buffers. class ByteAlignmentTest
: public ::testing::TestWithParam<ByteAlignmentTestParam> { protected:
ByteAlignmentTest()
: video_(nullptr), decoder_(nullptr), md5_file_(nullptr) {}
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() != nullptr; 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()) != nullptr) { 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_NE(md5_file_, nullptr)
<< "MD5 file open failed. Filename: " << md5_file_name_;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.