/* * Copyright (c) 2016, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/
// kPsnrThreshold represents the psnr threshold used to validate the quality of // the first frame. The indices correspond to one/two-pass, allintra and // realtime encoding modes. constdouble kPsnrThreshold[3] = { 29.0, 41.5, 41.5 };
// kPsnrFluctuation represents the maximum allowed psnr fluctuation w.r.t first // frame. The indices correspond to one/two-pass, allintra and realtime // encoding modes. constdouble kPsnrFluctuation[3] = { 2.5, 0.3, 17.0 };
class MonochromeTest
: public ::libaom_test::CodecTestWith3Params<libaom_test::TestMode, int, int>, public ::libaom_test::EncoderTest { protected:
MonochromeTest()
: EncoderTest(GET_PARAM(0)), lossless_(GET_PARAM(2)),
frame0_psnr_y_(0.0) {}
// Chroma planes should be constant
EXPECT_TRUE(is_chroma_constant);
// Monochrome flag on image should be set
EXPECT_EQ(img.monochrome, 1);
chroma_value_list_.push_back(chroma_value);
}
// Returns true if all pixels on the plane are equal to value, and returns // false otherwise. bool ComparePlaneToValue(const aom_image_t &img, constint plane, constint value) { constint w = aom_img_plane_width(&img, plane); constint h = aom_img_plane_height(&img, plane); const uint8_t *const buf = img.planes[plane]; constint stride = img.stride[plane];
for (int r = 0; r < h; ++r) { for (int c = 0; c < w; ++c) { if (buf[r * stride + c] != value) returnfalse;
}
} returntrue;
}
void PSNRPktHook(const aom_codec_cx_pkt_t *pkt) override { // Check average PSNR value is >= 100 db in case of lossless encoding. if (lossless_) {
EXPECT_GE(pkt->data.psnr.psnr[0], kMaxPsnr); return;
} constint psnr_index = (mode_ == ::libaom_test::kRealTime) ? 2
: (mode_ == ::libaom_test::kAllIntra) ? 1
: 0; // Check that the initial Y PSNR value is 'high enough', and check that // subsequent Y PSNR values are 'close' to this initial value. if (frame0_psnr_y_ == 0.0) {
frame0_psnr_y_ = pkt->data.psnr.psnr[1];
EXPECT_GT(frame0_psnr_y_, kPsnrThreshold[psnr_index]);
}
EXPECT_NEAR(pkt->data.psnr.psnr[1], frame0_psnr_y_,
kPsnrFluctuation[psnr_index]);
}
int lossless_;
std::vector<int> chroma_value_list_; double frame0_psnr_y_;
};
// Check that the chroma planes are equal across all frames
std::vector<int>::const_iterator iter = chroma_value_list_.begin(); int initial_chroma_value = *iter; for (; iter != chroma_value_list_.end(); ++iter) { // Check that all decoded frames have the same constant chroma planes.
EXPECT_EQ(*iter, initial_chroma_value);
}
}
class MonochromeAllIntraTest : public MonochromeTest {};
// Check that the chroma planes are equal across all frames
std::vector<int>::const_iterator iter = chroma_value_list_.begin(); int initial_chroma_value = *iter; for (; iter != chroma_value_list_.end(); ++iter) { // Check that all decoded frames have the same constant chroma planes.
EXPECT_EQ(*iter, initial_chroma_value);
}
}
#endif// !CONFIG_REALTIME_ONLY
class MonochromeRealtimeTest : public MonochromeTest {};
TEST_P(MonochromeRealtimeTest, TestMonochromeEncoding) {
::libaom_test::I420VideoSource video("hantro_collage_w352h288.yuv", 352, 288,
30, 1, 0, 30);
init_flags_ = AOM_CODEC_USE_PSNR; // Set monochrome encoding flag
cfg_.monochrome = 1; // Run at low bitrate.
cfg_.rc_target_bitrate = 40;
cfg_.rc_buf_sz = 6000;
cfg_.rc_buf_initial_sz = 4000;
cfg_.rc_buf_optimal_sz = 5000;
ASSERT_NO_FATAL_FAILURE(RunLoop(&video));
#if CONFIG_AV1_DECODER // Check that the chroma planes are equal across all frames
std::vector<int>::const_iterator iter = chroma_value_list_.begin(); int initial_chroma_value = *iter; for (; iter != chroma_value_list_.end(); ++iter) { // Check that all decoded frames have the same constant chroma planes.
EXPECT_EQ(*iter, initial_chroma_value);
} #endif
}
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.