Restore setting encoder speed for AV1 encoder wrapper

Also add simple unittests for the wrapper.

Bug: webrtc:11404
Change-Id: I41d185da9bce392297d1982194c059bddb7881ac
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/171481
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30867}
This commit is contained in:
Danil Chapovalov
2020-03-24 09:35:04 +01:00
committed by Commit Bot
parent 01611ed3ac
commit a4c4425748
4 changed files with 69 additions and 3 deletions

View File

@ -63,3 +63,17 @@ rtc_library("libaom_av1_encoder") {
sources = [ "libaom_av1_encoder_absent.cc" ]
}
}
rtc_library("video_coding_codecs_av1_tests") {
testonly = true
if (enable_libaom) {
sources = [ "libaom_av1_encoder_unittest.cc" ]
deps = [
":libaom_av1_encoder",
"../..:video_codec_interface",
"../../../../api/video_codecs:video_codecs_api",
"../../../../test:test_support",
]
}
}

View File

@ -36,9 +36,10 @@ namespace {
// Encoder configuration parameters
constexpr int kQpMax = 56;
constexpr int kQpMin = 10;
constexpr int kUsageProfile = 1; // 0 = good quality; 1 = real-time.
constexpr int kMinQindex = 58; // Min qindex threshold for QP scaling.
constexpr int kMaxQindex = 180; // Max qindex threshold for QP scaling.
constexpr int kDefaultEncSpeed = 7; // Use values 6, 7, or 8 for RTC.
constexpr int kUsageProfile = 1; // 0 = good quality; 1 = real-time.
constexpr int kMinQindex = 58; // Min qindex threshold for QP scaling.
constexpr int kMaxQindex = 180; // Max qindex threshold for QP scaling.
constexpr int kBitDepth = 8;
constexpr int kLagInFrames = 0; // No look ahead.
constexpr int kRtpTicksPerSecond = 90000;
@ -179,6 +180,12 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings,
inited_ = true;
// Set control parameters
ret = aom_codec_control(&ctx_, AOME_SET_CPUUSED, kDefaultEncSpeed);
if (ret != AOM_CODEC_OK) {
RTC_LOG(LS_WARNING) << "LibaomAv1Encoder::EncodeInit returned " << ret
<< " on control AV1E_SET_CPUUSED.";
return WEBRTC_VIDEO_CODEC_ERROR;
}
ret = aom_codec_control(&ctx_, AV1E_SET_ENABLE_TPL_MODEL, 0);
if (ret != AOM_CODEC_OK) {
RTC_LOG(LS_WARNING) << "LibaomAv1Encoder::EncodeInit returned " << ret

View File

@ -0,0 +1,44 @@
/*
* Copyright (c) 2020 The WebRTC 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 "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
#include <memory>
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder.h"
#include "modules/video_coding/include/video_error_codes.h"
#include "test/gtest.h"
namespace webrtc {
namespace {
TEST(LibaomAv1EncoderTest, CanCreate) {
std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder();
EXPECT_TRUE(encoder);
}
TEST(LibaomAv1EncoderTest, InitAndRelease) {
std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder();
ASSERT_TRUE(encoder);
VideoCodec codec_settings;
codec_settings.width = 1280;
codec_settings.height = 720;
codec_settings.maxFramerate = 30;
VideoEncoder::Capabilities capabilities(/*loss_notification=*/false);
VideoEncoder::Settings encoder_settings(capabilities, /*number_of_cores=*/1,
/*max_payload_size=*/1200);
EXPECT_EQ(encoder->InitEncode(&codec_settings, encoder_settings),
WEBRTC_VIDEO_CODEC_OK);
EXPECT_EQ(encoder->Release(), WEBRTC_VIDEO_CODEC_OK);
}
} // namespace
} // namespace webrtc