in Vp8 encoder fill resolution into codec agnostic structure

so that it will be filled in the dependency descriptor rtp header extension

Bug: webrtc:10342
Change-Id: Ifaf4963ca84f6d495287959746686ae3dcd176d8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/168767
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32692}
This commit is contained in:
Danil Chapovalov
2020-11-25 12:29:13 +01:00
committed by Commit Bot
parent b6b678d0f8
commit 9a5e21da68
2 changed files with 31 additions and 3 deletions

View File

@ -1062,9 +1062,25 @@ void LibvpxVp8Encoder::PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
int qp = 0;
vpx_codec_control(&encoders_[encoder_idx], VP8E_GET_LAST_QUANTIZER_64, &qp);
frame_buffer_controller_->OnEncodeDone(
stream_idx, timestamp, encoded_images_[encoder_idx].size(),
(pkt.data.frame.flags & VPX_FRAME_IS_KEY) != 0, qp, codec_specific);
bool is_keyframe = (pkt.data.frame.flags & VPX_FRAME_IS_KEY) != 0;
frame_buffer_controller_->OnEncodeDone(stream_idx, timestamp,
encoded_images_[encoder_idx].size(),
is_keyframe, qp, codec_specific);
if (is_keyframe && codec_specific->template_structure != absl::nullopt) {
// Number of resolutions must match number of spatial layers, VP8 structures
// expected to use single spatial layer. Templates must be ordered by
// spatial_id, so assumption there is exactly one spatial layer is same as
// assumption last template uses spatial_id = 0.
// This check catches potential scenario where template_structure is shared
// across multiple vp8 streams and they are distinguished using spatial_id.
// Assigning single resolution doesn't support such scenario, i.e. assumes
// vp8 simulcast is sent using multiple ssrcs.
RTC_DCHECK(!codec_specific->template_structure->templates.empty());
RTC_DCHECK_EQ(
codec_specific->template_structure->templates.back().spatial_id, 0);
codec_specific->template_structure->resolutions = {
RenderResolution(pkt.data.frame.width[0], pkt.data.frame.height[0])};
}
}
int LibvpxVp8Encoder::GetEncodedPartitions(const VideoFrame& input_image,

View File

@ -33,6 +33,7 @@ namespace webrtc {
using ::testing::_;
using ::testing::AllOf;
using ::testing::ElementsAre;
using ::testing::ElementsAreArray;
using ::testing::Field;
using ::testing::Invoke;
@ -262,6 +263,17 @@ TEST_F(TestVp8Impl, OnEncodedImageReportsInfo) {
EXPECT_EQ(kHeight, static_cast<int>(encoded_frame._encodedHeight));
}
TEST_F(TestVp8Impl,
EncoderFillsResolutionInCodecAgnosticSectionOfCodecSpecificInfo) {
EncodedImage encoded_frame;
CodecSpecificInfo codec_specific_info;
EncodeAndWaitForFrame(NextInputFrame(), &encoded_frame, &codec_specific_info);
ASSERT_TRUE(codec_specific_info.template_structure);
EXPECT_THAT(codec_specific_info.template_structure->resolutions,
ElementsAre(RenderResolution(kWidth, kHeight)));
}
TEST_F(TestVp8Impl, DecodedQpEqualsEncodedQp) {
VideoFrame input_frame = NextInputFrame();
EncodedImage encoded_frame;