
Cherry-Picked the following commits: 0defd8f Changed "WebM" to "AOMedia" & "webm" to "aomedia" 54e6676 Replace "VPx" by "AVx" 5082a36 Change "Vpx" to "Avx" 7df44f1 Replace "Vp9" w/ "Av1" 967f722 Remove kVp9CodecId 828f30c Change "Vp8" to "AOM" 030b5ff AUTHORS regenerated 2524cae Add ref-mv experimental flag 016762b Change copyright notice to AOMedia form 81e5526 Replace vp9 w/ av1 9b94565 Add missing files fa8ca9f Change "vp9" to "av1" ec838b7 Convert "vp8" to "aom" 80edfa0 Change "VP9" to "AV1" d1a11fb Change "vp8" to "aom" 7b58251 Point to WebM test data dd1a5c8 Replace "VP8" with "AOM" ff00fc0 Change "VPX" to "AOM" 01dee0b Change "vp10" to "av1" in source code cebe6f0 Convert "vpx" to "aom" 17b0567 rename vp10*.mk to av1_*.mk fe5f8a8 rename files vp10_* to av1_* Change-Id: I6fc3d18eb11fc171e46140c836ad5339cf6c9419
150 lines
5.3 KiB
C++
150 lines
5.3 KiB
C++
/*
|
|
* 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/encode_test_driver.h"
|
|
#include "test/util.h"
|
|
#include "test/y4m_video_source.h"
|
|
#include "av1/av1_dx_iface.c"
|
|
|
|
namespace {
|
|
|
|
const int kCpuUsed = 2;
|
|
|
|
struct EncodePerfTestVideo {
|
|
const char *name;
|
|
uint32_t width;
|
|
uint32_t height;
|
|
uint32_t bitrate;
|
|
int frames;
|
|
};
|
|
|
|
const EncodePerfTestVideo kAV1EncodePerfTestVectors[] = {
|
|
{ "niklas_1280_720_30.y4m", 1280, 720, 600, 10 },
|
|
};
|
|
|
|
struct EncodeParameters {
|
|
int32_t tile_rows;
|
|
int32_t tile_cols;
|
|
int32_t lossless;
|
|
int32_t error_resilient;
|
|
int32_t frame_parallel;
|
|
aom_color_range_t color_range;
|
|
aom_color_space_t cs;
|
|
int render_size[2];
|
|
// TODO(JBB): quantizers / bitrate
|
|
};
|
|
|
|
const EncodeParameters kAV1EncodeParameterSet[] = {
|
|
{ 0, 0, 0, 1, 0, AOM_CR_STUDIO_RANGE, AOM_CS_BT_601, { 0, 0 } },
|
|
{ 0, 0, 0, 0, 0, AOM_CR_FULL_RANGE, AOM_CS_BT_709, { 0, 0 } },
|
|
{ 0, 0, 1, 0, 0, AOM_CR_FULL_RANGE, AOM_CS_BT_2020, { 0, 0 } },
|
|
{ 0, 2, 0, 0, 1, AOM_CR_STUDIO_RANGE, AOM_CS_UNKNOWN, { 640, 480 } },
|
|
// TODO(JBB): Test profiles (requires more work).
|
|
};
|
|
|
|
class AvxEncoderParmsGetToDecoder
|
|
: public ::libaom_test::EncoderTest,
|
|
public ::libaom_test::CodecTestWith2Params<EncodeParameters,
|
|
EncodePerfTestVideo> {
|
|
protected:
|
|
AvxEncoderParmsGetToDecoder()
|
|
: EncoderTest(GET_PARAM(0)), encode_parms(GET_PARAM(1)) {}
|
|
|
|
virtual ~AvxEncoderParmsGetToDecoder() {}
|
|
|
|
virtual void SetUp() {
|
|
InitializeConfig();
|
|
SetMode(::libaom_test::kTwoPassGood);
|
|
cfg_.g_lag_in_frames = 25;
|
|
cfg_.g_error_resilient = encode_parms.error_resilient;
|
|
dec_cfg_.threads = 4;
|
|
test_video_ = GET_PARAM(2);
|
|
cfg_.rc_target_bitrate = test_video_.bitrate;
|
|
}
|
|
|
|
virtual void PreEncodeFrameHook(::libaom_test::VideoSource *video,
|
|
::libaom_test::Encoder *encoder) {
|
|
if (video->frame() == 1) {
|
|
encoder->Control(AV1E_SET_COLOR_SPACE, encode_parms.cs);
|
|
encoder->Control(AV1E_SET_COLOR_RANGE, encode_parms.color_range);
|
|
encoder->Control(AV1E_SET_LOSSLESS, encode_parms.lossless);
|
|
encoder->Control(AV1E_SET_FRAME_PARALLEL_DECODING,
|
|
encode_parms.frame_parallel);
|
|
encoder->Control(AV1E_SET_TILE_ROWS, encode_parms.tile_rows);
|
|
encoder->Control(AV1E_SET_TILE_COLUMNS, encode_parms.tile_cols);
|
|
encoder->Control(AOME_SET_CPUUSED, kCpuUsed);
|
|
encoder->Control(AOME_SET_ENABLEAUTOALTREF, 1);
|
|
encoder->Control(AOME_SET_ARNR_MAXFRAMES, 7);
|
|
encoder->Control(AOME_SET_ARNR_STRENGTH, 5);
|
|
encoder->Control(AOME_SET_ARNR_TYPE, 3);
|
|
if (encode_parms.render_size[0] > 0 && encode_parms.render_size[1] > 0)
|
|
encoder->Control(AV1E_SET_RENDER_SIZE, encode_parms.render_size);
|
|
}
|
|
}
|
|
|
|
virtual bool HandleDecodeResult(const aom_codec_err_t res_dec,
|
|
const libaom_test::VideoSource & /*video*/,
|
|
libaom_test::Decoder *decoder) {
|
|
aom_codec_ctx_t *const av1_decoder = decoder->GetDecoder();
|
|
aom_codec_alg_priv_t *const priv =
|
|
reinterpret_cast<aom_codec_alg_priv_t *>(av1_decoder->priv);
|
|
FrameWorkerData *const worker_data =
|
|
reinterpret_cast<FrameWorkerData *>(priv->frame_workers[0].data1);
|
|
AV1_COMMON *const common = &worker_data->pbi->common;
|
|
|
|
if (encode_parms.lossless) {
|
|
EXPECT_EQ(0, common->base_qindex);
|
|
EXPECT_EQ(0, common->y_dc_delta_q);
|
|
EXPECT_EQ(0, common->uv_dc_delta_q);
|
|
EXPECT_EQ(0, common->uv_ac_delta_q);
|
|
EXPECT_EQ(ONLY_4X4, common->tx_mode);
|
|
}
|
|
EXPECT_EQ(encode_parms.error_resilient, common->error_resilient_mode);
|
|
if (encode_parms.error_resilient) {
|
|
EXPECT_EQ(0, common->use_prev_frame_mvs);
|
|
}
|
|
EXPECT_EQ(encode_parms.color_range, common->color_range);
|
|
EXPECT_EQ(encode_parms.cs, common->color_space);
|
|
if (encode_parms.render_size[0] > 0 && encode_parms.render_size[1] > 0) {
|
|
EXPECT_EQ(encode_parms.render_size[0], common->render_width);
|
|
EXPECT_EQ(encode_parms.render_size[1], common->render_height);
|
|
}
|
|
EXPECT_EQ(encode_parms.tile_cols, common->log2_tile_cols);
|
|
EXPECT_EQ(encode_parms.tile_rows, common->log2_tile_rows);
|
|
|
|
EXPECT_EQ(AOM_CODEC_OK, res_dec) << decoder->DecodeError();
|
|
return AOM_CODEC_OK == res_dec;
|
|
}
|
|
|
|
EncodePerfTestVideo test_video_;
|
|
|
|
private:
|
|
EncodeParameters encode_parms;
|
|
};
|
|
|
|
TEST_P(AvxEncoderParmsGetToDecoder, BitstreamParms) {
|
|
init_flags_ = AOM_CODEC_USE_PSNR;
|
|
|
|
libaom_test::VideoSource *const video =
|
|
new libaom_test::Y4mVideoSource(test_video_.name, 0, test_video_.frames);
|
|
ASSERT_TRUE(video != NULL);
|
|
|
|
ASSERT_NO_FATAL_FAILURE(RunLoop(video));
|
|
delete video;
|
|
}
|
|
|
|
AV1_INSTANTIATE_TEST_CASE(AvxEncoderParmsGetToDecoder,
|
|
::testing::ValuesIn(kAV1EncodeParameterSet),
|
|
::testing::ValuesIn(kAV1EncodePerfTestVectors));
|
|
} // namespace
|