Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Commit 06bbeb3

Browse files
DanilChapovalovCommit Bot
authored andcommitted
in Av1 encoder wrapper communicate end_of_picture flag similar to VP9
In particular move end_of_picture flag out of vp9 specific information since VP9 is not the only codec that can use spatial scalability and thus need to distinguish layer frame and picture (aka temporal unit). Bug: webrtc:12167 Change-Id: I0d046d8785fbea55281209ad099738c03ea7db96 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192542 Reviewed-by: Sami Kalliomäki <[email protected]> Reviewed-by: Erik Språng <[email protected]> Commit-Queue: Danil Chapovalov <[email protected]> Cr-Commit-Position: refs/heads/master@{#32588}
1 parent f2a2fe8 commit 06bbeb3

12 files changed

+45
-26
lines changed

call/rtp_payload_params.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ void PopulateRtpWithCodecSpecifics(const CodecSpecificInfo& info,
8585
for (int i = 0; i < info.codecSpecific.VP9.num_ref_pics; ++i) {
8686
vp9_header.pid_diff[i] = info.codecSpecific.VP9.p_diff[i];
8787
}
88-
vp9_header.end_of_picture = info.codecSpecific.VP9.end_of_picture;
88+
vp9_header.end_of_picture = info.end_of_picture;
8989
return;
9090
}
9191
case kVideoCodecH264: {

call/rtp_payload_params_unittest.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_Vp9) {
103103
codec_info.codecSpecific.VP9.num_spatial_layers = 3;
104104
codec_info.codecSpecific.VP9.first_frame_in_picture = true;
105105
codec_info.codecSpecific.VP9.temporal_idx = 2;
106-
codec_info.codecSpecific.VP9.end_of_picture = false;
106+
codec_info.end_of_picture = false;
107107

108108
RTPVideoHeader header =
109109
params.GetRtpVideoHeader(encoded_image, &codec_info, kDontCare);
@@ -120,12 +120,11 @@ TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_Vp9) {
120120
EXPECT_EQ(vp9_header.spatial_idx, encoded_image.SpatialIndex());
121121
EXPECT_EQ(vp9_header.num_spatial_layers,
122122
codec_info.codecSpecific.VP9.num_spatial_layers);
123-
EXPECT_EQ(vp9_header.end_of_picture,
124-
codec_info.codecSpecific.VP9.end_of_picture);
123+
EXPECT_EQ(vp9_header.end_of_picture, codec_info.end_of_picture);
125124

126125
// Next spatial layer.
127126
codec_info.codecSpecific.VP9.first_frame_in_picture = false;
128-
codec_info.codecSpecific.VP9.end_of_picture = true;
127+
codec_info.end_of_picture = true;
129128

130129
encoded_image.SetSpatialIndex(1);
131130
ColorSpace color_space(
@@ -144,8 +143,7 @@ TEST(RtpPayloadParamsTest, InfoMappedToRtpVideoHeader_Vp9) {
144143
EXPECT_EQ(vp9_header.spatial_idx, encoded_image.SpatialIndex());
145144
EXPECT_EQ(vp9_header.num_spatial_layers,
146145
codec_info.codecSpecific.VP9.num_spatial_layers);
147-
EXPECT_EQ(vp9_header.end_of_picture,
148-
codec_info.codecSpecific.VP9.end_of_picture);
146+
EXPECT_EQ(vp9_header.end_of_picture, codec_info.end_of_picture);
149147
}
150148

151149
TEST(RtpPayloadParamsTest, PictureIdIsSetForVp8) {

modules/video_coding/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ rtc_library("video_codec_interface") {
228228
"../../api/video_codecs:video_codecs_api",
229229
"../../common_video",
230230
"../../common_video/generic_frame_descriptor",
231+
"../../rtc_base:deprecation",
231232
"../../rtc_base/system:rtc_export",
232233
]
233234
absl_deps = [ "//third_party/abseil-cpp/absl/types:optional" ]

modules/video_coding/codecs/av1/libaom_av1_encoder.cc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,10 @@ int32_t LibaomAv1Encoder::Encode(
462462
const uint32_t duration =
463463
kRtpTicksPerSecond / static_cast<float>(encoder_settings_.maxFramerate);
464464

465-
for (ScalableVideoController::LayerFrameConfig& layer_frame : layer_frames) {
465+
for (size_t i = 0; i < layer_frames.size(); ++i) {
466+
ScalableVideoController::LayerFrameConfig& layer_frame = layer_frames[i];
467+
const bool end_of_picture = i == layer_frames.size() - 1;
468+
466469
aom_enc_frame_flags_t flags =
467470
layer_frame.IsKeyframe() ? AOM_EFLAG_FORCE_KF : 0;
468471

@@ -528,6 +531,7 @@ int32_t LibaomAv1Encoder::Encode(
528531
if (encoded_image.size() > 0) {
529532
CodecSpecificInfo codec_specific_info;
530533
codec_specific_info.codecType = kVideoCodecAV1;
534+
codec_specific_info.end_of_picture = end_of_picture;
531535
bool is_keyframe = layer_frame.IsKeyframe();
532536
codec_specific_info.generic_frame_info =
533537
svc_controller_->OnEncodeDone(std::move(layer_frame));

modules/video_coding/codecs/av1/libaom_av1_encoder_unittest.cc

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,24 @@ TEST(LibaomAv1EncoderTest, NoBitrateOnTopLayerRefecltedInActiveDecodeTargets) {
8383
0b01);
8484
}
8585

86+
TEST(LibaomAv1EncoderTest, SetsEndOfPictureForLastFrameInTemporalUnit) {
87+
std::unique_ptr<VideoEncoder> encoder = CreateLibaomAv1Encoder();
88+
VideoCodec codec_settings = DefaultCodecSettings();
89+
// Configure encoder with 3 spatial layers.
90+
codec_settings.SetScalabilityMode("L3T1");
91+
ASSERT_EQ(encoder->InitEncode(&codec_settings, DefaultEncoderSettings()),
92+
WEBRTC_VIDEO_CODEC_OK);
93+
94+
std::vector<EncodedVideoFrameProducer::EncodedFrame> encoded_frames =
95+
EncodedVideoFrameProducer(*encoder).SetNumInputFrames(2).Encode();
96+
ASSERT_THAT(encoded_frames, SizeIs(6));
97+
EXPECT_FALSE(encoded_frames[0].codec_specific_info.end_of_picture);
98+
EXPECT_FALSE(encoded_frames[1].codec_specific_info.end_of_picture);
99+
EXPECT_TRUE(encoded_frames[2].codec_specific_info.end_of_picture);
100+
EXPECT_FALSE(encoded_frames[3].codec_specific_info.end_of_picture);
101+
EXPECT_FALSE(encoded_frames[4].codec_specific_info.end_of_picture);
102+
EXPECT_TRUE(encoded_frames[5].codec_specific_info.end_of_picture);
103+
}
104+
86105
} // namespace
87106
} // namespace webrtc

modules/video_coding/codecs/test/videoprocessor.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,13 +373,11 @@ void VideoProcessor::FrameEncoded(
373373
frame_stat->max_nalu_size_bytes = GetMaxNaluSizeBytes(encoded_image, config_);
374374
frame_stat->qp = encoded_image.qp_;
375375

376-
bool end_of_picture = false;
377376
if (codec_type == kVideoCodecVP9) {
378377
const CodecSpecificInfoVP9& vp9_info = codec_specific.codecSpecific.VP9;
379378
frame_stat->inter_layer_predicted = vp9_info.inter_layer_predicted;
380379
frame_stat->non_ref_for_inter_layer_pred =
381380
vp9_info.non_ref_for_inter_layer_pred;
382-
end_of_picture = vp9_info.end_of_picture;
383381
} else {
384382
frame_stat->inter_layer_predicted = false;
385383
frame_stat->non_ref_for_inter_layer_pred = true;
@@ -397,7 +395,7 @@ void VideoProcessor::FrameEncoded(
397395
if (config_.decode) {
398396
DecodeFrame(*encoded_image_for_decode, spatial_idx);
399397

400-
if (end_of_picture && num_spatial_layers > 1) {
398+
if (codec_specific.end_of_picture && num_spatial_layers > 1) {
401399
// If inter-layer prediction is enabled and upper layer was dropped then
402400
// base layer should be passed to upper layer decoder. Otherwise decoder
403401
// won't be able to decode next superframe.

modules/video_coding/codecs/vp9/test/vp9_impl_unittest.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,8 @@ TEST_F(TestVp9Impl, EndOfPicture) {
919919
std::vector<EncodedImage> frames;
920920
std::vector<CodecSpecificInfo> codec_specific;
921921
ASSERT_TRUE(WaitForEncodedFrames(&frames, &codec_specific));
922-
EXPECT_FALSE(codec_specific[0].codecSpecific.VP9.end_of_picture);
923-
EXPECT_TRUE(codec_specific[1].codecSpecific.VP9.end_of_picture);
922+
EXPECT_FALSE(codec_specific[0].end_of_picture);
923+
EXPECT_TRUE(codec_specific[1].end_of_picture);
924924

925925
// Encode only base layer. Check that end-of-superframe flag is
926926
// set on base layer frame.
@@ -935,7 +935,7 @@ TEST_F(TestVp9Impl, EndOfPicture) {
935935

936936
ASSERT_TRUE(WaitForEncodedFrames(&frames, &codec_specific));
937937
EXPECT_FALSE(frames[0].SpatialIndex());
938-
EXPECT_TRUE(codec_specific[0].codecSpecific.VP9.end_of_picture);
938+
EXPECT_TRUE(codec_specific[0].end_of_picture);
939939
}
940940

941941
TEST_F(TestVp9Impl, InterLayerPred) {

modules/video_coding/codecs/vp9/vp9_impl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1683,7 +1683,7 @@ void VP9EncoderImpl::DeliverBufferedFrame(bool end_of_picture) {
16831683
}
16841684
}
16851685

1686-
codec_specific_.codecSpecific.VP9.end_of_picture = end_of_picture;
1686+
codec_specific_.end_of_picture = end_of_picture;
16871687

16881688
encoded_complete_callback_->OnEncodedImage(encoded_image_,
16891689
&codec_specific_);

modules/video_coding/include/video_codec_interface.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "modules/video_coding/codecs/h264/include/h264_globals.h"
2323
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
2424
#include "modules/video_coding/include/video_error_codes.h"
25+
#include "rtc_base/deprecation.h"
2526
#include "rtc_base/system/rtc_export.h"
2627

2728
namespace webrtc {
@@ -79,7 +80,7 @@ struct CodecSpecificInfoVP9 {
7980
uint8_t num_ref_pics;
8081
uint8_t p_diff[kMaxVp9RefPics];
8182

82-
bool end_of_picture;
83+
RTC_DEPRECATED bool end_of_picture;
8384
};
8485
static_assert(std::is_pod<CodecSpecificInfoVP9>::value, "");
8586

@@ -109,6 +110,7 @@ struct RTC_EXPORT CodecSpecificInfo {
109110

110111
VideoCodecType codecType;
111112
CodecSpecificInfoUnion codecSpecific;
113+
bool end_of_picture = true;
112114
absl::optional<GenericFrameInfo> generic_frame_info;
113115
absl::optional<FrameDependencyStructure> template_structure;
114116
};

sdk/android/src/jni/video_encoder_wrapper.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ CodecSpecificInfo VideoEncoderWrapper::ParseCodecSpecificInfo(
347347
static_cast<uint8_t>(gof_idx_++ % gof_.num_frames_in_gof);
348348
info.codecSpecific.VP9.num_spatial_layers = 1;
349349
info.codecSpecific.VP9.first_frame_in_picture = true;
350-
info.codecSpecific.VP9.end_of_picture = true;
351350
info.codecSpecific.VP9.spatial_layer_resolution_present = false;
352351
if (info.codecSpecific.VP9.ss_data_available) {
353352
info.codecSpecific.VP9.spatial_layer_resolution_present = true;

0 commit comments

Comments
 (0)