bool MatchAndExplain(const VideoFrame& actual_frame,
MatchResultListener* listener) const { if (actual_frame.width() != width_ || actual_frame.height() != height_) {
*listener << "which has dimensions " << actual_frame.width() << "x"
<< actual_frame.height() << ", but expected dimensions are "
<< width_ << "x" << height_; returnfalse;
}
const scoped_refptr<I420BufferInterface> actual_frame_buffer =
actual_frame.video_frame_buffer()->ToI420(); if (actual_frame_buffer->ChromaWidth() !=
expected_frame_buffer_->ChromaWidth() ||
actual_frame_buffer->ChromaHeight() !=
expected_frame_buffer_->ChromaHeight()) {
*listener << "which has chroma dimensions "
<< actual_frame_buffer->ChromaWidth() << "x"
<< actual_frame_buffer->ChromaHeight()
<< ", but expected chroma dimensions are "
<< expected_frame_buffer_->ChromaWidth() << "x"
<< expected_frame_buffer_->ChromaHeight(); returnfalse;
}
// The reason for going through all the channels is to make sure that all // channels are as expected. Even if one of the channels is not as expected, // the test would not terminate until all the channels are checked. This is // done in order to give a more detailed error message. bool is_same = true;
is_same &= DataMatricesAreEqual(
std::span(
expected_frame_buffer_->DataY(),
expected_frame_buffer_->width() * expected_frame_buffer_->height()),
std::span(actual_frame_buffer->DataY(),
actual_frame_buffer->width() * actual_frame_buffer->height()),
width_, height_, SampleType::kY, *listener);
void DescribeTo(std::ostream* os) const {
*os << "is the actual frame to have the following Y channel:\n";
PrintOneChannelToOs(std::span(expected_frame_buffer_->DataY(),
expected_frame_buffer_->width() *
expected_frame_buffer_->height()),
width_, height_, *os);
*os << "is the actual frame to have the following U channel:\n";
PrintOneChannelToOs(std::span(expected_frame_buffer_->DataU(),
expected_frame_buffer_->ChromaWidth() *
expected_frame_buffer_->ChromaHeight()),
width_ / 2, height_ / 2, *os);
*os << "or the actual frame to have the following V channel:\n";
PrintOneChannelToOs(std::span(expected_frame_buffer_->DataV(),
expected_frame_buffer_->ChromaWidth() *
expected_frame_buffer_->ChromaHeight()),
width_ / 2, height_ / 2, *os);
}
void DescribeNegationTo(std::ostream* os) const {
*os << "is the actual frame to not have the following Y channel:\n";
PrintOneChannelToOs(std::span(expected_frame_buffer_->DataY(),
expected_frame_buffer_->width() *
expected_frame_buffer_->height()),
width_, height_, *os);
*os << "is the actual frame to not have the following U channel:\n";
PrintOneChannelToOs(std::span(expected_frame_buffer_->DataU(),
expected_frame_buffer_->ChromaWidth() *
expected_frame_buffer_->ChromaHeight()),
width_ / 2, height_ / 2, *os);
*os << "and the actual frame to not have the following V channel:\n";
PrintOneChannelToOs(std::span(expected_frame_buffer_->DataV(),
expected_frame_buffer_->ChromaWidth() *
expected_frame_buffer_->ChromaHeight()),
width_ / 2, height_ / 2, *os);
}
for (int i = 0; i < height * width; ++i) { if (expected_data[i] != actual_data[i]) {
listener << "\n"
<< SampleTypeToString(sample_type)
<< " content is not the same. The actual data is:\n";
PrintOneChannelToListener(actual_data, width, height, listener);
listener << "First index to differ is at position (" << (i / width)
<< ", " << (i % width)
<< "). Here the expected value was: " << int{expected_data[i]}
<< ", and the actual value was: " << int{actual_data[i]}
<< ".\n"; returnfalse;
}
} return true;
}
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.