Make libaom_av1_encoder always build the libaom encoder.
Currently `CreateLibaomAv1Encoder` will either return an actual libaom AV1 encoder or a nullptr depening on whether the build flag `enable_libaom` was configured to true or not. This CL updates the `libaom_av1_encoder` build target to no longer depend on `enable_libaom` so that `CreateLibaomAv1Encoder` will always return an encoder instance. Added `CreateLibaomAv1EncoderIfSupported` as a replacement to the old `CreateLibaomAv1Encoder`. Bug: webrtc:13573 Change-Id: Ibdcd52c609acd79feefa2b86f19d1b4ca3e91d0a Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/242360 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Peter Hanspers <peterhanspers@webrtc.org> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Commit-Queue: Philip Eliasson <philipel@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35763}
This commit is contained in:
parent
01ef37c08e
commit
95701503f2
@ -211,7 +211,7 @@ rtc_library("rtc_internal_video_codecs") {
|
||||
"../modules/video_coding:webrtc_vp8",
|
||||
"../modules/video_coding:webrtc_vp9",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_decoder",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_encoder",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_encoder_if_supported",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:rtc_base_approved",
|
||||
"../rtc_base/system:rtc_export",
|
||||
@ -622,7 +622,7 @@ if (rtc_include_tests) {
|
||||
"../modules/video_coding:webrtc_h264",
|
||||
"../modules/video_coding:webrtc_vp8",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_decoder",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_encoder",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_encoder_if_supported",
|
||||
"../p2p:p2p_test_utils",
|
||||
"../rtc_base",
|
||||
"../rtc_base:checks",
|
||||
|
||||
@ -16,7 +16,7 @@
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "media/base/codec.h"
|
||||
#include "media/base/media_constants.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder_supported.h"
|
||||
#include "modules/video_coding/codecs/h264/include/h264.h"
|
||||
#include "modules/video_coding/codecs/vp8/include/vp8.h"
|
||||
#include "modules/video_coding/codecs/vp9/include/vp9.h"
|
||||
@ -51,7 +51,7 @@ std::unique_ptr<VideoEncoder> InternalEncoderFactory::CreateVideoEncoder(
|
||||
return H264Encoder::Create(cricket::VideoCodec(format));
|
||||
if (kIsLibaomAv1EncoderSupported &&
|
||||
absl::EqualsIgnoreCase(format.name, cricket::kAv1CodecName))
|
||||
return CreateLibaomAv1Encoder();
|
||||
return CreateLibaomAv1EncoderIfSupported();
|
||||
RTC_LOG(LS_ERROR) << "Trying to created encoder of unsupported format "
|
||||
<< format.name;
|
||||
return nullptr;
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "api/video_codecs/vp9_profile.h"
|
||||
#include "media/base/media_constants.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder_supported.h"
|
||||
#include "test/gmock.h"
|
||||
#include "test/gtest.h"
|
||||
|
||||
|
||||
@ -71,32 +71,46 @@ rtc_library("libaom_av1_encoder") {
|
||||
visibility = [ "*" ]
|
||||
poisonous = [ "software_video_codecs" ]
|
||||
public = [ "libaom_av1_encoder.h" ]
|
||||
sources = [ "libaom_av1_encoder.cc" ]
|
||||
deps = [
|
||||
"../..:video_codec_interface",
|
||||
"../../../../api:scoped_refptr",
|
||||
"../../../../api/video:encoded_image",
|
||||
"../../../../api/video:video_frame",
|
||||
"../../../../api/video_codecs:video_codecs_api",
|
||||
"../../../../common_video",
|
||||
"../../../../rtc_base:checks",
|
||||
"../../../../rtc_base:logging",
|
||||
"../../svc:scalability_structures",
|
||||
"../../svc:scalable_video_controller",
|
||||
"//third_party/libaom",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/strings:strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_library("libaom_av1_encoder_if_supported") {
|
||||
visibility = [ "*" ]
|
||||
poisonous = [ "software_video_codecs" ]
|
||||
public = [ "libaom_av1_encoder_supported.h" ]
|
||||
sources = [ "libaom_av1_encoder_supported.cc" ]
|
||||
deps = [
|
||||
"../../../../api/video_codecs:video_codecs_api",
|
||||
"../../svc:scalability_structures",
|
||||
"../../svc:scalable_video_controller",
|
||||
]
|
||||
absl_deps = [
|
||||
"//third_party/abseil-cpp/absl/algorithm:container",
|
||||
"//third_party/abseil-cpp/absl/base:core_headers",
|
||||
"//third_party/abseil-cpp/absl/strings:strings",
|
||||
"//third_party/abseil-cpp/absl/types:optional",
|
||||
]
|
||||
|
||||
defines = []
|
||||
if (enable_libaom) {
|
||||
sources = [ "libaom_av1_encoder.cc" ]
|
||||
deps += [
|
||||
"../..:video_codec_interface",
|
||||
"../../../../api:scoped_refptr",
|
||||
"../../../../api/video:encoded_image",
|
||||
"../../../../api/video:video_frame",
|
||||
"../../../../common_video",
|
||||
"../../../../rtc_base:checks",
|
||||
"../../../../rtc_base:logging",
|
||||
"//third_party/libaom",
|
||||
]
|
||||
} else {
|
||||
sources = [ "libaom_av1_encoder_absent.cc" ]
|
||||
defines += [ "RTC_USE_LIBAOM_AV1_ENCODER" ]
|
||||
deps += [ ":libaom_av1_encoder" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -820,17 +820,8 @@ VideoEncoder::EncoderInfo LibaomAv1Encoder::GetEncoderInfo() const {
|
||||
|
||||
} // namespace
|
||||
|
||||
const bool kIsLibaomAv1EncoderSupported = true;
|
||||
|
||||
std::unique_ptr<VideoEncoder> CreateLibaomAv1Encoder() {
|
||||
return std::make_unique<LibaomAv1Encoder>();
|
||||
}
|
||||
|
||||
bool LibaomAv1EncoderSupportsScalabilityMode(
|
||||
absl::string_view scalability_mode) {
|
||||
// For AV1, the scalability mode is supported if we can create the scalability
|
||||
// structure.
|
||||
return ScalabilityStructureConfig(scalability_mode) != absl::nullopt;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -12,18 +12,11 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ABSL_CONST_INIT extern const bool kIsLibaomAv1EncoderSupported;
|
||||
|
||||
std::unique_ptr<VideoEncoder> CreateLibaomAv1Encoder();
|
||||
bool LibaomAv1EncoderSupportsScalabilityMode(
|
||||
absl::string_view scalability_mode);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_VIDEO_CODING_CODECS_AV1_LIBAOM_AV1_ENCODER_H_
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* 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_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
const bool kIsLibaomAv1EncoderSupported = false;
|
||||
|
||||
std::unique_ptr<VideoEncoder> CreateLibaomAv1Encoder() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool LibaomAv1EncoderSupportsScalabilityMode(
|
||||
absl::string_view scalability_mode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (c) 2021 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_supported.h"
|
||||
|
||||
#include "modules/video_coding/svc/create_scalability_structure.h"
|
||||
|
||||
#if defined(RTC_USE_LIBAOM_AV1_ENCODER)
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h" // nogncheck
|
||||
#endif
|
||||
|
||||
namespace webrtc {
|
||||
#if defined(RTC_USE_LIBAOM_AV1_ENCODER)
|
||||
const bool kIsLibaomAv1EncoderSupported = true;
|
||||
std::unique_ptr<VideoEncoder> CreateLibaomAv1EncoderIfSupported() {
|
||||
return CreateLibaomAv1Encoder();
|
||||
}
|
||||
bool LibaomAv1EncoderSupportsScalabilityMode(
|
||||
absl::string_view scalability_mode) {
|
||||
// For libaom AV1, the scalability mode is supported if we can create the
|
||||
// scalability structure.
|
||||
return ScalabilityStructureConfig(scalability_mode) != absl::nullopt;
|
||||
}
|
||||
#else
|
||||
const bool kIsLibaomAv1EncoderSupported = false;
|
||||
std::unique_ptr<VideoEncoder> CreateLibaomAv1EncoderIfSupported() {
|
||||
return nullptr;
|
||||
}
|
||||
bool LibaomAv1EncoderSupportsScalabilityMode(
|
||||
absl::string_view scalability_mode) {
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace webrtc
|
||||
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2022 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.
|
||||
*/
|
||||
#ifndef MODULES_VIDEO_CODING_CODECS_AV1_LIBAOM_AV1_ENCODER_SUPPORTED_H_
|
||||
#define MODULES_VIDEO_CODING_CODECS_AV1_LIBAOM_AV1_ENCODER_SUPPORTED_H_
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "absl/base/attributes.h"
|
||||
#include "absl/strings/string_view.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
ABSL_CONST_INIT extern const bool kIsLibaomAv1EncoderSupported;
|
||||
|
||||
std::unique_ptr<VideoEncoder> CreateLibaomAv1EncoderIfSupported();
|
||||
bool LibaomAv1EncoderSupportsScalabilityMode(
|
||||
absl::string_view scalability_mode);
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // MODULES_VIDEO_CODING_CODECS_AV1_LIBAOM_AV1_ENCODER_SUPPORTED_H_
|
||||
@ -730,7 +730,7 @@ if (is_ios || is_mac) {
|
||||
":wrapped_native_codec_objc",
|
||||
"../media:rtc_media_base",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_decoder",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_encoder",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_encoder_if_supported",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -876,7 +876,7 @@ if (current_os == "linux" || is_android) {
|
||||
":generated_libaom_av1_jni",
|
||||
":video_jni",
|
||||
"../../modules/video_coding/codecs/av1:libaom_av1_decoder",
|
||||
"../../modules/video_coding/codecs/av1:libaom_av1_encoder",
|
||||
"../../modules/video_coding/codecs/av1:libaom_av1_encoder_if_supported",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@ -11,7 +11,7 @@
|
||||
#include <jni.h>
|
||||
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_decoder.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder_supported.h"
|
||||
#include "sdk/android/generated_libaom_av1_jni/LibaomAv1Decoder_jni.h"
|
||||
#include "sdk/android/generated_libaom_av1_jni/LibaomAv1Encoder_jni.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
@ -20,7 +20,8 @@ namespace webrtc {
|
||||
namespace jni {
|
||||
|
||||
static jlong JNI_LibaomAv1Encoder_CreateEncoder(JNIEnv* jni) {
|
||||
return jlongFromPointer(webrtc::CreateLibaomAv1Encoder().release());
|
||||
return jlongFromPointer(
|
||||
webrtc::CreateLibaomAv1EncoderIfSupported().release());
|
||||
}
|
||||
|
||||
static jboolean JNI_LibaomAv1Encoder_IsSupported(JNIEnv* jni) {
|
||||
|
||||
@ -15,12 +15,12 @@
|
||||
#import "RTCVideoEncoderAV1.h"
|
||||
#import "RTCWrappedNativeVideoEncoder.h"
|
||||
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder_supported.h"
|
||||
|
||||
@implementation RTC_OBJC_TYPE (RTCVideoEncoderAV1)
|
||||
|
||||
+ (id<RTC_OBJC_TYPE(RTCVideoEncoder)>)av1Encoder {
|
||||
std::unique_ptr<webrtc::VideoEncoder> nativeEncoder(webrtc::CreateLibaomAv1Encoder());
|
||||
std::unique_ptr<webrtc::VideoEncoder> nativeEncoder(webrtc::CreateLibaomAv1EncoderIfSupported());
|
||||
if (nativeEncoder == nullptr) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
@ -736,7 +736,7 @@ if (rtc_include_tests) {
|
||||
"../modules/video_coding:webrtc_vp8",
|
||||
"../modules/video_coding:webrtc_vp9",
|
||||
"../modules/video_coding:webrtc_vp9_helpers",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_encoder",
|
||||
"../modules/video_coding/codecs/av1:libaom_av1_encoder_if_supported",
|
||||
"../rtc_base",
|
||||
"../rtc_base:checks",
|
||||
"../rtc_base:gunit_helpers",
|
||||
|
||||
@ -40,7 +40,7 @@
|
||||
#include "common_video/include/video_frame_buffer.h"
|
||||
#include "media/base/video_adapter.h"
|
||||
#include "media/engine/webrtc_video_engine.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
|
||||
#include "modules/video_coding/codecs/av1/libaom_av1_encoder_supported.h"
|
||||
#include "modules/video_coding/codecs/h264/include/h264.h"
|
||||
#include "modules/video_coding/codecs/multiplex/include/multiplex_encoder_adapter.h"
|
||||
#include "modules/video_coding/codecs/vp8/include/vp8.h"
|
||||
@ -8439,7 +8439,7 @@ class VideoStreamEncoderWithRealEncoderTest
|
||||
encoder = VP9Encoder::Create();
|
||||
break;
|
||||
case kVideoCodecAV1:
|
||||
encoder = CreateLibaomAv1Encoder();
|
||||
encoder = CreateLibaomAv1EncoderIfSupported();
|
||||
break;
|
||||
case kVideoCodecH264:
|
||||
encoder =
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user