Allow to set av1 scalability mode after encoder is constructed
Bug: webrtc:11404 Change-Id: I70b4115c8afdc4f32fd876d31d54b7d95d0a7e1b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/188582 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32437}
This commit is contained in:

committed by
Commit Bot

parent
0835ce5d6d
commit
9f4859e5e3
@ -40,6 +40,7 @@ rtc_library("libaom_av1_encoder") {
|
||||
public = [ "libaom_av1_encoder.h" ]
|
||||
deps = [
|
||||
"../../../../api/video_codecs:video_codecs_api",
|
||||
"../../svc:scalability_structures",
|
||||
"../../svc:scalable_video_controller",
|
||||
]
|
||||
absl_deps = [
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "modules/video_coding/include/video_codec_interface.h"
|
||||
#include "modules/video_coding/include/video_error_codes.h"
|
||||
#include "modules/video_coding/svc/create_scalability_structure.h"
|
||||
#include "modules/video_coding/svc/scalable_video_controller.h"
|
||||
#include "modules/video_coding/svc/scalable_video_controller_no_layering.h"
|
||||
#include "rtc_base/checks.h"
|
||||
@ -93,7 +94,7 @@ class LibaomAv1Encoder final : public VideoEncoder {
|
||||
void SetSvcRefFrameConfig(
|
||||
const ScalableVideoController::LayerFrameConfig& layer_frame);
|
||||
|
||||
const std::unique_ptr<ScalableVideoController> svc_controller_;
|
||||
std::unique_ptr<ScalableVideoController> svc_controller_;
|
||||
bool inited_;
|
||||
absl::optional<aom_svc_params_t> svc_params_;
|
||||
VideoCodec encoder_settings_;
|
||||
@ -164,6 +165,21 @@ int LibaomAv1Encoder::InitEncode(const VideoCodec* codec_settings,
|
||||
"LibaomAv1Encoder.";
|
||||
return result;
|
||||
}
|
||||
if (encoder_settings_.numberOfSimulcastStreams > 1) {
|
||||
RTC_LOG(LS_WARNING) << "Simulcast is not implemented by LibaomAv1Encoder.";
|
||||
return result;
|
||||
}
|
||||
absl::string_view scalability_mode = encoder_settings_.ScalabilityMode();
|
||||
// When scalability_mode is not set, keep using svc_controller_ created
|
||||
// at construction of the encoder.
|
||||
if (!scalability_mode.empty()) {
|
||||
svc_controller_ = CreateScalabilityStructure(scalability_mode);
|
||||
}
|
||||
if (svc_controller_ == nullptr) {
|
||||
RTC_LOG(LS_WARNING) << "Failed to set scalability mode "
|
||||
<< scalability_mode;
|
||||
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
|
||||
}
|
||||
|
||||
if (!SetSvcParams(svc_controller_->StreamConfig())) {
|
||||
return WEBRTC_VIDEO_CODEC_ERROR;
|
||||
|
@ -179,14 +179,13 @@ struct SvcTestParam {
|
||||
class LibaomAv1SvcTest : public ::testing::TestWithParam<SvcTestParam> {};
|
||||
|
||||
TEST_P(LibaomAv1SvcTest, EncodeAndDecodeAllDecodeTargets) {
|
||||
std::unique_ptr<ScalableVideoController> svc_controller =
|
||||
CreateScalabilityStructure(GetParam().name);
|
||||
size_t num_decode_targets =
|
||||
svc_controller->DependencyStructure().num_decode_targets;
|
||||
size_t num_decode_targets = CreateScalabilityStructure(GetParam().name)
|
||||
->DependencyStructure()
|
||||
.num_decode_targets;
|
||||
|
||||
std::unique_ptr<VideoEncoder> encoder =
|
||||
CreateLibaomAv1Encoder(std::move(svc_controller));
|
||||
std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder();
|
||||
VideoCodec codec_settings = DefaultCodecSettings();
|
||||
codec_settings.SetScalabilityMode(GetParam().name);
|
||||
ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()),
|
||||
WEBRTC_VIDEO_CODEC_OK);
|
||||
std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames =
|
||||
|
Reference in New Issue
Block a user