Migrate software decoders to new VideoDecoder::Configure

Bug: webrtc:13045
Change-Id: I1fa28a7c2dd59f0889d98c8ec5f58161c0ec9f95
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228380
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34716}
This commit is contained in:
Danil Chapovalov
2021-08-10 14:33:31 +02:00
committed by WebRTC LUCI CQ
parent bf75041b8d
commit 53d4be223b
14 changed files with 98 additions and 110 deletions

View File

@ -138,10 +138,9 @@ LibvpxVp8Decoder::~LibvpxVp8Decoder() {
Release();
}
int LibvpxVp8Decoder::InitDecode(const VideoCodec* inst, int number_of_cores) {
int ret_val = Release();
if (ret_val < 0) {
return ret_val;
bool LibvpxVp8Decoder::Configure(const Settings& settings) {
if (Release() < 0) {
return false;
}
if (decoder_ == NULL) {
decoder_ = new vpx_codec_ctx_t;
@ -157,7 +156,7 @@ int LibvpxVp8Decoder::InitDecode(const VideoCodec* inst, int number_of_cores) {
if (vpx_codec_dec_init(decoder_, vpx_codec_vp8_dx(), &cfg, flags)) {
delete decoder_;
decoder_ = nullptr;
return WEBRTC_VIDEO_CODEC_MEMORY;
return false;
}
propagation_cnt_ = -1;
@ -165,12 +164,12 @@ int LibvpxVp8Decoder::InitDecode(const VideoCodec* inst, int number_of_cores) {
// Always start with a complete key frame.
key_frame_required_ = true;
if (inst && inst->buffer_pool_size) {
if (!buffer_pool_.Resize(*inst->buffer_pool_size)) {
return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
if (absl::optional<int> buffer_pool_size = settings.buffer_pool_size()) {
if (!buffer_pool_.Resize(*buffer_pool_size)) {
return false;
}
}
return WEBRTC_VIDEO_CODEC_OK;
return true;
}
int LibvpxVp8Decoder::Decode(const EncodedImage& input_image,

View File

@ -29,8 +29,7 @@ class LibvpxVp8Decoder : public VideoDecoder {
LibvpxVp8Decoder();
~LibvpxVp8Decoder() override;
int InitDecode(const VideoCodec* inst, int number_of_cores) override;
bool Configure(const Settings& settings) override;
int Decode(const EncodedImage& input_image,
bool missing_frames,
int64_t /*render_time_ms*/) override;

View File

@ -244,10 +244,9 @@ TEST_F(TestVp8Impl, EncodeI420FrameAfterNv12Frame) {
encoder_->Encode(NextInputFrame(), nullptr));
}
TEST_F(TestVp8Impl, InitDecode) {
TEST_F(TestVp8Impl, Configure) {
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK, decoder_->Release());
EXPECT_EQ(WEBRTC_VIDEO_CODEC_OK,
decoder_->InitDecode(&codec_settings_, kNumCores));
EXPECT_TRUE(decoder_->Configure({}));
}
TEST_F(TestVp8Impl, OnEncodedImageReportsInfo) {