Remove the libaom av1 decoder.

Bug: webrtc:14267
Change-Id: I95a416b25fa20d4dea6896e05beb59789621f1fa
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268305
Reviewed-by: Sergey Silkin <ssilkin@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38253}
This commit is contained in:
philipel 2022-09-29 18:13:07 +02:00 committed by WebRTC LUCI CQ
parent 94fd3351f1
commit 0c4563c0c4
14 changed files with 31 additions and 396 deletions

View file

@ -220,7 +220,6 @@ rtc_library("rtc_internal_video_codecs") {
"../modules/video_coding:webrtc_multiplex",
"../modules/video_coding:webrtc_vp8",
"../modules/video_coding:webrtc_vp9",
"../modules/video_coding/codecs/av1:libaom_av1_decoder",
"../rtc_base:checks",
"../rtc_base:logging",
"../rtc_base/system:rtc_export",
@ -626,7 +625,6 @@ if (rtc_include_tests) {
"../modules/video_coding:video_codec_interface",
"../modules/video_coding:webrtc_h264",
"../modules/video_coding:webrtc_vp8",
"../modules/video_coding/codecs/av1:libaom_av1_decoder",
"../p2p:p2p_test_utils",
"../rtc_base",
"../rtc_base:byte_order",

View file

@ -16,7 +16,6 @@
#include "api/video_codecs/video_codec.h"
#include "media/base/codec.h"
#include "media/base/media_constants.h"
#include "modules/video_coding/codecs/av1/libaom_av1_decoder.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,12 +50,8 @@ std::vector<SdpVideoFormat> InternalDecoderFactory::GetSupportedFormats()
for (const SdpVideoFormat& h264_format : SupportedH264DecoderCodecs())
formats.push_back(h264_format);
bool isDav1dEnabled =
kDav1dIsIncluded && !field_trial::IsDisabled(kDav1dFieldTrial);
if (kIsLibaomAv1DecoderSupported || isDav1dEnabled) {
if (kDav1dIsIncluded && !field_trial::IsDisabled(kDav1dFieldTrial)) {
formats.push_back(SdpVideoFormat(cricket::kAv1CodecName));
}
if (isDav1dEnabled) {
formats.push_back(SdpVideoFormat(
cricket::kAv1CodecName,
{{kAV1FmtpProfile, AV1ProfileToString(AV1Profile::kProfile1).data()}}));
@ -103,11 +98,6 @@ std::unique_ptr<VideoDecoder> InternalDecoderFactory::CreateVideoDecoder(
return CreateDav1dDecoder();
}
if (absl::EqualsIgnoreCase(format.name, cricket::kAv1CodecName) &&
kIsLibaomAv1DecoderSupported) {
return CreateLibaomAv1Decoder();
}
RTC_DCHECK_NOTREACHED();
return nullptr;
}

View file

@ -15,7 +15,6 @@
#include "api/video_codecs/video_decoder.h"
#include "api/video_codecs/vp9_profile.h"
#include "media/base/media_constants.h"
#include "modules/video_coding/codecs/av1/libaom_av1_decoder.h"
#include "system_wrappers/include/field_trial.h"
#include "test/gmock.h"
#include "test/gtest.h"
@ -92,7 +91,7 @@ TEST(InternalDecoderFactoryTest, H264) {
TEST(InternalDecoderFactoryTest, Av1Profile0) {
InternalDecoderFactory factory;
InitFieldTrialsFromString(kDav1dDecoderFieldTrialEnabled);
if (kIsLibaomAv1DecoderSupported || kDav1dIsIncluded) {
if (kDav1dIsIncluded) {
EXPECT_THAT(factory.GetSupportedFormats(),
Contains(Field(&SdpVideoFormat::name, cricket::kAv1CodecName)));
EXPECT_TRUE(
@ -104,6 +103,14 @@ TEST(InternalDecoderFactoryTest, Av1Profile0) {
}
}
#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
TEST(InternalDecoderFactoryTest, Av1) {
InternalDecoderFactory factory;
EXPECT_THAT(factory.GetSupportedFormats(),
Contains(Field(&SdpVideoFormat::name, cricket::kAv1CodecName)));
}
#endif
TEST(InternalDecoderFactoryTest, Av1Profile1_Dav1dDecoderTrialEnabled) {
InitFieldTrialsFromString(kDav1dDecoderFieldTrialEnabled);
InternalDecoderFactory factory;
@ -138,10 +145,12 @@ TEST(InternalDecoderFactoryTest, QueryCodecSupportNoReferenceScaling) {
VP9ProfileToString(VP9Profile::kProfile1)}}),
/*reference_scaling=*/false),
Support(kVp9Enabled ? kSupported : kUnsupported));
EXPECT_THAT(
factory.QueryCodecSupport(SdpVideoFormat(cricket::kAv1CodecName),
/*reference_scaling=*/false),
Support(kIsLibaomAv1DecoderSupported ? kSupported : kUnsupported));
#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kAv1CodecName),
/*reference_scaling=*/false),
Support(kSupported));
#endif
}
TEST(InternalDecoderFactoryTest, QueryCodecSupportReferenceScaling) {
@ -150,10 +159,11 @@ TEST(InternalDecoderFactoryTest, QueryCodecSupportReferenceScaling) {
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kVp9CodecName),
/*reference_scaling=*/true),
Support(kVp9Enabled ? kSupported : kUnsupported));
EXPECT_THAT(
factory.QueryCodecSupport(SdpVideoFormat(cricket::kAv1CodecName),
/*reference_scaling=*/true),
Support(kIsLibaomAv1DecoderSupported ? kSupported : kUnsupported));
#if defined(RTC_DAV1D_IN_INTERNAL_DECODER_FACTORY)
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kAv1CodecName),
/*reference_scaling=*/true),
Support(kSupported));
#endif
// Invalid config even though VP8 and H264 are supported.
EXPECT_THAT(factory.QueryCodecSupport(SdpVideoFormat(cricket::kH264CodecName),

View file

@ -1080,7 +1080,6 @@ if (rtc_include_tests) {
"../../test:video_test_common",
"../rtp_rtcp:rtp_rtcp_format",
"codecs/av1:dav1d_decoder",
"codecs/av1:libaom_av1_decoder",
"//third_party/libyuv",
]
absl_deps = [

View file

@ -47,31 +47,6 @@ rtc_library("dav1d_decoder") {
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]
}
rtc_library("libaom_av1_decoder") {
visibility = [ "*" ]
poisonous = [ "software_video_codecs" ]
public = [ "libaom_av1_decoder.h" ]
deps = [ "../../../../api/video_codecs:video_codecs_api" ]
absl_deps = [ "//third_party/abseil-cpp/absl/base:core_headers" ]
if (enable_libaom) {
sources = [ "libaom_av1_decoder.cc" ]
deps += [
"../..:video_codec_interface",
"../../../../api:scoped_refptr",
"../../../../api/video:encoded_image",
"../../../../api/video:video_frame",
"../../../../common_video",
"../../../../rtc_base:logging",
"//third_party/libaom",
"//third_party/libyuv",
]
absl_deps += [ "//third_party/abseil-cpp/absl/types:optional" ]
} else {
sources = [ "libaom_av1_decoder_absent.cc" ]
}
}
rtc_library("libaom_av1_encoder") {
visibility = [ "*" ]
poisonous = [ "software_video_codecs" ]
@ -115,7 +90,7 @@ if (rtc_include_tests) {
"libaom_av1_unittest.cc",
]
deps += [
":libaom_av1_decoder",
":dav1d_decoder",
":libaom_av1_encoder",
"../..:encoded_video_frame_producer",
"../..:video_codec_interface",

View file

@ -1,200 +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_decoder.h"
#include <stdint.h>
#include <memory>
#include "absl/types/optional.h"
#include "api/scoped_refptr.h"
#include "api/video/encoded_image.h"
#include "api/video/i420_buffer.h"
#include "api/video_codecs/video_decoder.h"
#include "common_video/include/video_frame_buffer_pool.h"
#include "modules/video_coding/include/video_error_codes.h"
#include "rtc_base/logging.h"
#include "third_party/libaom/source/libaom/aom/aom_decoder.h"
#include "third_party/libaom/source/libaom/aom/aomdx.h"
#include "third_party/libyuv/include/libyuv/convert.h"
namespace webrtc {
namespace {
constexpr int kConfigLowBitDepth = 1; // 8-bits per luma/chroma sample.
constexpr int kDecFlags = 0; // 0 signals no post processing.
class LibaomAv1Decoder final : public VideoDecoder {
public:
LibaomAv1Decoder();
LibaomAv1Decoder(const LibaomAv1Decoder&) = delete;
LibaomAv1Decoder& operator=(const LibaomAv1Decoder&) = delete;
~LibaomAv1Decoder();
// Implements VideoDecoder.
bool Configure(const Settings& settings) override;
// Decode an encoded video frame.
int32_t Decode(const EncodedImage& encoded_image,
bool missing_frames,
int64_t render_time_ms) override;
int32_t RegisterDecodeCompleteCallback(
DecodedImageCallback* callback) override;
int32_t Release() override;
DecoderInfo GetDecoderInfo() const override;
const char* ImplementationName() const override;
private:
aom_codec_ctx_t context_;
bool inited_;
// Pool of memory buffers to store decoded image data for application access.
VideoFrameBufferPool buffer_pool_;
DecodedImageCallback* decode_complete_callback_;
};
LibaomAv1Decoder::LibaomAv1Decoder()
: context_(), // Force value initialization instead of default one.
inited_(false),
buffer_pool_(false, /*max_number_of_buffers=*/150),
decode_complete_callback_(nullptr) {}
LibaomAv1Decoder::~LibaomAv1Decoder() {
Release();
}
bool LibaomAv1Decoder::Configure(const Settings& settings) {
aom_codec_dec_cfg_t config = {};
config.threads = static_cast<unsigned int>(settings.number_of_cores());
config.allow_lowbitdepth = kConfigLowBitDepth;
aom_codec_err_t ret =
aom_codec_dec_init(&context_, aom_codec_av1_dx(), &config, kDecFlags);
if (ret != AOM_CODEC_OK) {
RTC_LOG(LS_WARNING) << "LibaomAv1Decoder::Configure returned " << ret
<< " on aom_codec_dec_init.";
return false;
}
inited_ = true;
return true;
}
int32_t LibaomAv1Decoder::Decode(const EncodedImage& encoded_image,
bool missing_frames,
int64_t /*render_time_ms*/) {
if (!inited_) {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}
if (decode_complete_callback_ == nullptr) {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
}
// Decode one video frame.
aom_codec_err_t ret =
aom_codec_decode(&context_, encoded_image.data(), encoded_image.size(),
/*user_priv=*/nullptr);
if (ret != AOM_CODEC_OK) {
RTC_LOG(LS_WARNING) << "LibaomAv1Decoder::Decode returned " << ret
<< " on aom_codec_decode.";
return WEBRTC_VIDEO_CODEC_ERROR;
}
// Get decoded frame data.
int corrupted_frame = 0;
aom_codec_iter_t iter = nullptr;
while (aom_image_t* decoded_image = aom_codec_get_frame(&context_, &iter)) {
if (aom_codec_control(&context_, AOMD_GET_FRAME_CORRUPTED,
&corrupted_frame)) {
RTC_LOG(LS_WARNING) << "LibaomAv1Decoder::Decode "
"AOM_GET_FRAME_CORRUPTED.";
}
// Check that decoded image format is I420 and has 8-bit depth.
if (decoded_image->fmt != AOM_IMG_FMT_I420) {
RTC_LOG(LS_WARNING) << "LibaomAv1Decoder::Decode invalid image format";
return WEBRTC_VIDEO_CODEC_ERROR;
}
// Return decoded frame data.
int qp;
ret = aom_codec_control(&context_, AOMD_GET_LAST_QUANTIZER, &qp);
if (ret != AOM_CODEC_OK) {
RTC_LOG(LS_WARNING) << "LibaomAv1Decoder::Decode returned " << ret
<< " on control AOME_GET_LAST_QUANTIZER.";
return WEBRTC_VIDEO_CODEC_ERROR;
}
// Allocate memory for decoded frame.
rtc::scoped_refptr<I420Buffer> buffer =
buffer_pool_.CreateI420Buffer(decoded_image->d_w, decoded_image->d_h);
if (!buffer.get()) {
// Pool has too many pending frames.
RTC_LOG(LS_WARNING) << "LibaomAv1Decoder::Decode returned due to lack of"
" space in decoded frame buffer pool.";
return WEBRTC_VIDEO_CODEC_ERROR;
}
// Copy decoded_image to decoded_frame.
libyuv::I420Copy(
decoded_image->planes[AOM_PLANE_Y], decoded_image->stride[AOM_PLANE_Y],
decoded_image->planes[AOM_PLANE_U], decoded_image->stride[AOM_PLANE_U],
decoded_image->planes[AOM_PLANE_V], decoded_image->stride[AOM_PLANE_V],
buffer->MutableDataY(), buffer->StrideY(), buffer->MutableDataU(),
buffer->StrideU(), buffer->MutableDataV(), buffer->StrideV(),
decoded_image->d_w, decoded_image->d_h);
VideoFrame decoded_frame = VideoFrame::Builder()
.set_video_frame_buffer(buffer)
.set_timestamp_rtp(encoded_image.Timestamp())
.set_ntp_time_ms(encoded_image.ntp_time_ms_)
.set_color_space(encoded_image.ColorSpace())
.build();
decode_complete_callback_->Decoded(decoded_frame, absl::nullopt,
absl::nullopt);
}
return WEBRTC_VIDEO_CODEC_OK;
}
int32_t LibaomAv1Decoder::RegisterDecodeCompleteCallback(
DecodedImageCallback* decode_complete_callback) {
decode_complete_callback_ = decode_complete_callback;
return WEBRTC_VIDEO_CODEC_OK;
}
int32_t LibaomAv1Decoder::Release() {
if (aom_codec_destroy(&context_) != AOM_CODEC_OK) {
return WEBRTC_VIDEO_CODEC_MEMORY;
}
buffer_pool_.Release();
inited_ = false;
return WEBRTC_VIDEO_CODEC_OK;
}
VideoDecoder::DecoderInfo LibaomAv1Decoder::GetDecoderInfo() const {
DecoderInfo info;
info.implementation_name = "libaom";
info.is_hardware_accelerated = false;
return info;
}
const char* LibaomAv1Decoder::ImplementationName() const {
return "libaom";
}
} // namespace
ABSL_CONST_INIT const bool kIsLibaomAv1DecoderSupported = true;
std::unique_ptr<VideoDecoder> CreateLibaomAv1Decoder() {
return std::make_unique<LibaomAv1Decoder>();
}
} // namespace webrtc

View file

@ -1,26 +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.
*/
#ifndef MODULES_VIDEO_CODING_CODECS_AV1_LIBAOM_AV1_DECODER_H_
#define MODULES_VIDEO_CODING_CODECS_AV1_LIBAOM_AV1_DECODER_H_
#include <memory>
#include "absl/base/attributes.h"
#include "api/video_codecs/video_decoder.h"
namespace webrtc {
ABSL_CONST_INIT extern const bool kIsLibaomAv1DecoderSupported;
std::unique_ptr<VideoDecoder> CreateLibaomAv1Decoder();
} // namespace webrtc
#endif // MODULES_VIDEO_CODING_CODECS_AV1_LIBAOM_AV1_DECODER_H_

View file

@ -1,24 +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_decoder.h"
#include <memory>
#include "api/video_codecs/video_decoder.h"
namespace webrtc {
ABSL_CONST_INIT const bool kIsLibaomAv1DecoderSupported = false;
std::unique_ptr<VideoDecoder> CreateLibaomAv1Decoder() {
return nullptr;
}
} // namespace webrtc

View file

@ -22,7 +22,7 @@
#include "api/units/time_delta.h"
#include "api/video_codecs/video_codec.h"
#include "api/video_codecs/video_encoder.h"
#include "modules/video_coding/codecs/av1/libaom_av1_decoder.h"
#include "modules/video_coding/codecs/av1/dav1d_decoder.h"
#include "modules/video_coding/codecs/av1/libaom_av1_encoder.h"
#include "modules/video_coding/codecs/test/encoded_video_frame_producer.h"
#include "modules/video_coding/include/video_codec_interface.h"
@ -73,7 +73,7 @@ VideoEncoder::Settings DefaultEncoderSettings() {
class TestAv1Decoder {
public:
explicit TestAv1Decoder(int decoder_id)
: decoder_id_(decoder_id), decoder_(CreateLibaomAv1Decoder()) {
: decoder_id_(decoder_id), decoder_(CreateDav1dDecoder()) {
if (decoder_ == nullptr) {
ADD_FAILURE() << "Failed to create a decoder#" << decoder_id_;
return;

View file

@ -18,7 +18,6 @@
#include "media/engine/internal_decoder_factory.h"
#include "media/engine/internal_encoder_factory.h"
#include "media/engine/simulcast_encoder_adapter.h"
#include "modules/video_coding/codecs/av1/libaom_av1_decoder.h"
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"

View file

@ -43,7 +43,7 @@ if (is_android) {
":filevideo_java",
":hwcodecs_java",
":java_audio_device_module_java",
":libaom_av1_java",
":libaom_av1_encoder_java",
":libjingle_peerconnection_java",
":libjingle_peerconnection_metrics_default_java",
":libvpx_vp8_java",
@ -511,20 +511,6 @@ if (is_android) {
]
}
rtc_android_library("libaom_av1_java") {
visibility = [ "*" ]
sources = [
"api/org/webrtc/LibaomAv1Decoder.java",
"api/org/webrtc/LibaomAv1Encoder.java",
]
deps = [
":base_java",
":video_api_java",
":video_java",
"//rtc_base:base_java",
]
}
rtc_android_library("dav1d_java") {
visibility = [ "*" ]
sources = [ "api/org/webrtc/Dav1dDecoder.java" ]
@ -540,7 +526,8 @@ if (is_android) {
deps = [
":base_java",
":libaom_av1_java",
":dav1d_java",
":libaom_av1_encoder_java",
":libvpx_vp8_java",
":libvpx_vp9_java",
":video_api_java",
@ -884,18 +871,6 @@ if (current_os == "linux" || is_android) {
]
}
rtc_library("libaom_av1_decoder_if_supported_jni") {
visibility = [ "*" ]
allow_poison = [ "software_video_codecs" ]
sources = [ "src/jni/libaom_av1_codec.cc" ]
deps = [
":base_jni",
":generated_libaom_av1_decoder_if_supported_jni",
":video_jni",
"../../modules/video_coding/codecs/av1:libaom_av1_decoder",
]
}
rtc_library("dav1d_av1_jni") {
visibility = [ "*" ]
allow_poison = [ "software_video_codecs" ]
@ -912,7 +887,6 @@ if (current_os == "linux" || is_android) {
visibility = [ "*" ]
allow_poison = [ "software_video_codecs" ]
deps = [
":libaom_av1_decoder_if_supported_jni",
":libvpx_vp8_jni",
":libvpx_vp9_jni",
]
@ -1373,13 +1347,6 @@ if (current_os == "linux" || is_android) {
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
generate_jni("generated_libaom_av1_decoder_if_supported_jni") {
sources = [ "api/org/webrtc/LibaomAv1Decoder.java" ]
namespace = "webrtc::jni"
jni_generator_include = "//sdk/android/src/jni/jni_generator_helper.h"
}
generate_jni("generated_dav1d_jni") {
sources = [ "api/org/webrtc/Dav1dDecoder.java" ]

View file

@ -1,22 +0,0 @@
/*
* 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.
*/
package org.webrtc;
public class LibaomAv1Decoder extends WrappedNativeVideoDecoder {
@Override
public long createNativeVideoDecoder() {
return nativeCreateDecoder();
}
static native long nativeCreateDecoder();
static native boolean nativeIsSupported();
}

View file

@ -28,9 +28,8 @@ public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
&& LibvpxVp9Decoder.nativeIsSupported()) {
return new LibvpxVp9Decoder();
}
if (codecName.equalsIgnoreCase(VideoCodecMimeType.AV1.name())
&& LibaomAv1Decoder.nativeIsSupported()) {
return new LibaomAv1Decoder();
if (codecName.equalsIgnoreCase(VideoCodecMimeType.AV1.name())) {
return new Dav1dDecoder();
}
return null;
@ -48,9 +47,8 @@ public class SoftwareVideoDecoderFactory implements VideoDecoderFactory {
if (LibvpxVp9Decoder.nativeIsSupported()) {
codecs.add(new VideoCodecInfo(VideoCodecMimeType.VP9.name(), new HashMap<>()));
}
if (LibaomAv1Decoder.nativeIsSupported()) {
codecs.add(new VideoCodecInfo(VideoCodecMimeType.AV1.name(), new HashMap<>()));
}
codecs.add(new VideoCodecInfo(VideoCodecMimeType.AV1.name(), new HashMap<>()));
return codecs.toArray(new VideoCodecInfo[codecs.size()]);
}

View file

@ -1,29 +0,0 @@
/*
* Copyright 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 <jni.h>
#include "modules/video_coding/codecs/av1/libaom_av1_decoder.h"
#include "sdk/android/generated_libaom_av1_decoder_if_supported_jni/LibaomAv1Decoder_jni.h"
#include "sdk/android/src/jni/jni_helpers.h"
namespace webrtc {
namespace jni {
static jlong JNI_LibaomAv1Decoder_CreateDecoder(JNIEnv* jni) {
return jlongFromPointer(webrtc::CreateLibaomAv1Decoder().release());
}
static jboolean JNI_LibaomAv1Decoder_IsSupported(JNIEnv* jni) {
return webrtc::kIsLibaomAv1DecoderSupported;
}
} // namespace jni
} // namespace webrtc