When reconfiguring VP9 restore previous input pixel format

Otherwise if the pixel format is not I420, the image buffer will
need to be reallocated on each reconfiguration.

Bug: webrtc:11974
Change-Id: Ib13f1865d7dbba4635f57dc09c7bff846e127585
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/186340
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Evan Shrubsole <eshr@google.com>
Cr-Commit-Position: refs/heads/master@{#32281}
This commit is contained in:
Evan Shrubsole
2020-10-01 17:16:22 +02:00
committed by Commit Bot
parent b3d539ef25
commit c082eba758

View File

@ -490,6 +490,9 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
return WEBRTC_VIDEO_CODEC_ERR_PARAMETER; return WEBRTC_VIDEO_CODEC_ERR_PARAMETER;
} }
absl::optional<vpx_img_fmt_t> previous_img_fmt =
raw_ ? absl::make_optional<vpx_img_fmt_t>(raw_->fmt) : absl::nullopt;
int ret_val = Release(); int ret_val = Release();
if (ret_val < 0) { if (ret_val < 0) {
return ret_val; return ret_val;
@ -530,7 +533,7 @@ int VP9EncoderImpl::InitEncode(const VideoCodec* inst,
unsigned int bits_for_storage = 8; unsigned int bits_for_storage = 8;
switch (profile_) { switch (profile_) {
case VP9Profile::kProfile0: case VP9Profile::kProfile0:
img_fmt = VPX_IMG_FMT_I420; img_fmt = previous_img_fmt.value_or(VPX_IMG_FMT_I420);
bits_for_storage = 8; bits_for_storage = 8;
config_->g_bit_depth = VPX_BITS_8; config_->g_bit_depth = VPX_BITS_8;
config_->g_profile = 0; config_->g_profile = 0;