Add spatial index to EncodedImage.
Replaces the VP8 simulcast index and VP9 spatial index formely part of CodecSpecificInfo. Bug: webrtc:9378 Change-Id: I80eafd63fbdee0a25864338196a690628b4bd3d2 Reviewed-on: https://webrtc-review.googlesource.com/83161 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Sebastian Jansson <srte@webrtc.org> Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Philip Eliasson <philipel@webrtc.org> Reviewed-by: Rasmus Brandt <brandtr@webrtc.org> Cr-Commit-Position: refs/heads/master@{#24485}
This commit is contained in:
@ -506,6 +506,7 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
|
||||
: VideoContentType::UNSPECIFIED;
|
||||
encoded_images_[i].timing_.flags = VideoSendTiming::kInvalid;
|
||||
encoded_images_[i]._frameType = ConvertToVideoFrameType(info.eFrameType);
|
||||
encoded_images_[i].SetSpatialIndex(configurations_[i].simulcast_idx);
|
||||
|
||||
// Split encoded image up into fragments. This also updates
|
||||
// |encoded_image_|.
|
||||
@ -526,8 +527,6 @@ int32_t H264EncoderImpl::Encode(const VideoFrame& input_frame,
|
||||
codec_specific.codecType = kVideoCodecH264;
|
||||
codec_specific.codecSpecific.H264.packetization_mode =
|
||||
packetization_mode_;
|
||||
codec_specific.codecSpecific.H264.simulcast_idx =
|
||||
configurations_[i].simulcast_idx;
|
||||
encoded_image_callback_->OnEncodedImage(encoded_images_[i],
|
||||
&codec_specific, &frag_header);
|
||||
}
|
||||
|
||||
@ -285,7 +285,6 @@ EncodedImageCallback::Result MultiplexEncoderAdapter::OnEncodedImage(
|
||||
|
||||
CodecSpecificInfo codec_info = *codecSpecificInfo;
|
||||
codec_info.codecType = kVideoCodecMultiplex;
|
||||
codec_info.codecSpecific.generic.simulcast_idx = 0;
|
||||
encoded_complete_callback_->OnEncodedImage(combined_image_, &codec_info,
|
||||
fragmentation);
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ TEST_P(TestMultiplexAdapter, CheckSingleFrameEncodedBitstream) {
|
||||
CodecSpecificInfo codec_specific_info;
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
EXPECT_EQ(kVideoCodecMultiplex, codec_specific_info.codecType);
|
||||
EXPECT_EQ(0, codec_specific_info.codecSpecific.generic.simulcast_idx);
|
||||
EXPECT_FALSE(encoded_frame.SpatialIndex());
|
||||
|
||||
const MultiplexImage& unpacked_frame =
|
||||
MultiplexEncodedImagePacker::Unpack(encoded_frame);
|
||||
@ -252,7 +252,7 @@ TEST_P(TestMultiplexAdapter, CheckDoubleFramesEncodedBitstream) {
|
||||
CodecSpecificInfo codec_specific_info;
|
||||
ASSERT_TRUE(WaitForEncodedFrame(&encoded_frame, &codec_specific_info));
|
||||
EXPECT_EQ(kVideoCodecMultiplex, codec_specific_info.codecType);
|
||||
EXPECT_EQ(0, codec_specific_info.codecSpecific.generic.simulcast_idx);
|
||||
EXPECT_FALSE(encoded_frame.SpatialIndex());
|
||||
|
||||
const MultiplexImage& unpacked_frame =
|
||||
MultiplexEncodedImagePacker::Unpack(encoded_frame);
|
||||
|
||||
@ -56,22 +56,17 @@ size_t GetMaxNaluSizeBytes(const EncodedImage& encoded_frame,
|
||||
return max_size;
|
||||
}
|
||||
|
||||
void GetLayerIndices(const CodecSpecificInfo& codec_specific,
|
||||
size_t* spatial_idx,
|
||||
size_t* temporal_idx) {
|
||||
size_t GetTemporalLayerIndex(const CodecSpecificInfo& codec_specific) {
|
||||
size_t temporal_idx = 0;
|
||||
if (codec_specific.codecType == kVideoCodecVP8) {
|
||||
*spatial_idx = codec_specific.codecSpecific.VP8.simulcastIdx;
|
||||
*temporal_idx = codec_specific.codecSpecific.VP8.temporalIdx;
|
||||
temporal_idx = codec_specific.codecSpecific.VP8.temporalIdx;
|
||||
} else if (codec_specific.codecType == kVideoCodecVP9) {
|
||||
*spatial_idx = codec_specific.codecSpecific.VP9.spatial_idx;
|
||||
*temporal_idx = codec_specific.codecSpecific.VP9.temporal_idx;
|
||||
temporal_idx = codec_specific.codecSpecific.VP9.temporal_idx;
|
||||
}
|
||||
if (*spatial_idx == kNoSpatialIdx) {
|
||||
*spatial_idx = 0;
|
||||
}
|
||||
if (*temporal_idx == kNoTemporalIdx) {
|
||||
*temporal_idx = 0;
|
||||
if (temporal_idx == kNoTemporalIdx) {
|
||||
temporal_idx = 0;
|
||||
}
|
||||
return temporal_idx;
|
||||
}
|
||||
|
||||
int GetElapsedTimeMicroseconds(int64_t start_ns, int64_t stop_ns) {
|
||||
@ -347,9 +342,8 @@ void VideoProcessor::FrameEncoded(
|
||||
}
|
||||
|
||||
// Layer metadata.
|
||||
size_t spatial_idx = 0;
|
||||
size_t temporal_idx = 0;
|
||||
GetLayerIndices(codec_specific, &spatial_idx, &temporal_idx);
|
||||
size_t spatial_idx = encoded_image.SpatialIndex().value_or(0);
|
||||
size_t temporal_idx = GetTemporalLayerIndex(codec_specific);
|
||||
|
||||
FrameStatistics* frame_stat =
|
||||
stats_->GetFrameWithTimestamp(encoded_image.Timestamp(), spatial_idx);
|
||||
|
||||
@ -817,7 +817,6 @@ void LibvpxVp8Encoder::PopulateCodecSpecific(
|
||||
codec_specific->codecType = kVideoCodecVP8;
|
||||
codec_specific->codec_name = ImplementationName();
|
||||
CodecSpecificInfoVP8* vp8Info = &(codec_specific->codecSpecific.VP8);
|
||||
vp8Info->simulcastIdx = stream_idx;
|
||||
vp8Info->keyIdx = kNoKeyIdx; // TODO(hlundin) populate this
|
||||
vp8Info->nonReference = (pkt.data.frame.flags & VPX_FRAME_IS_DROPPABLE) != 0;
|
||||
temporal_layers_[stream_idx]->PopulateCodecSpecific(
|
||||
@ -876,6 +875,7 @@ int LibvpxVp8Encoder::GetEncodedPartitions(
|
||||
encoded_images_[encoder_idx]._frameType = kVideoFrameKey;
|
||||
is_keyframe = true;
|
||||
}
|
||||
encoded_images_[encoder_idx].SetSpatialIndex(stream_idx);
|
||||
PopulateCodecSpecific(&codec_specific, tl_configs[stream_idx], *pkt,
|
||||
stream_idx, input_image.timestamp());
|
||||
break;
|
||||
|
||||
@ -70,7 +70,7 @@ class TestVp8Impl : public VideoCodecUnitTest {
|
||||
VerifyQpParser(*encoded_frame);
|
||||
EXPECT_STREQ("libvpx", codec_specific_info->codec_name);
|
||||
EXPECT_EQ(kVideoCodecVP8, codec_specific_info->codecType);
|
||||
EXPECT_EQ(0u, codec_specific_info->codecSpecific.VP8.simulcastIdx);
|
||||
EXPECT_EQ(0, encoded_frame->SpatialIndex());
|
||||
}
|
||||
|
||||
void EncodeAndExpectFrameWith(const VideoFrame& input_frame,
|
||||
|
||||
@ -356,7 +356,7 @@ TEST_F(TestVp9Impl, EndOfPicture) {
|
||||
encoder_->Encode(*NextInputFrame(), nullptr, nullptr));
|
||||
|
||||
ASSERT_TRUE(WaitForEncodedFrames(&frames, &codec_specific));
|
||||
EXPECT_EQ(codec_specific[0].codecSpecific.VP9.spatial_idx, kNoSpatialIdx);
|
||||
EXPECT_FALSE(frames[0].SpatialIndex());
|
||||
EXPECT_TRUE(codec_specific[0].codecSpecific.VP9.end_of_picture);
|
||||
}
|
||||
|
||||
@ -395,7 +395,7 @@ TEST_F(TestVp9Impl, InterLayerPred) {
|
||||
|
||||
// Key frame.
|
||||
EXPECT_FALSE(codec_specific[0].codecSpecific.VP9.inter_pic_predicted);
|
||||
EXPECT_EQ(codec_specific[0].codecSpecific.VP9.spatial_idx, 0);
|
||||
EXPECT_EQ(frames[0].SpatialIndex(), 0);
|
||||
EXPECT_EQ(codec_specific[0].codecSpecific.VP9.non_ref_for_inter_layer_pred,
|
||||
inter_layer_pred == InterLayerPredMode::kOff);
|
||||
EXPECT_TRUE(
|
||||
@ -408,7 +408,7 @@ TEST_F(TestVp9Impl, InterLayerPred) {
|
||||
|
||||
// Delta frame.
|
||||
EXPECT_TRUE(codec_specific[0].codecSpecific.VP9.inter_pic_predicted);
|
||||
EXPECT_EQ(codec_specific[0].codecSpecific.VP9.spatial_idx, 0);
|
||||
EXPECT_EQ(frames[0].SpatialIndex(), 0);
|
||||
EXPECT_EQ(codec_specific[0].codecSpecific.VP9.non_ref_for_inter_layer_pred,
|
||||
inter_layer_pred == InterLayerPredMode::kOff ||
|
||||
inter_layer_pred == InterLayerPredMode::kOnKeyPic);
|
||||
|
||||
@ -754,6 +754,7 @@ int VP9EncoderImpl::Encode(const VideoFrame& input_image,
|
||||
}
|
||||
|
||||
void VP9EncoderImpl::PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
|
||||
absl::optional<int>* spatial_idx,
|
||||
const vpx_codec_cx_pkt& pkt,
|
||||
uint32_t timestamp,
|
||||
bool first_frame_in_picture) {
|
||||
@ -780,9 +781,9 @@ void VP9EncoderImpl::PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
|
||||
}
|
||||
if (num_active_spatial_layers_ == 1) {
|
||||
RTC_CHECK_EQ(layer_id.spatial_layer_id, 0);
|
||||
vp9_info->spatial_idx = kNoSpatialIdx;
|
||||
*spatial_idx = absl::nullopt;
|
||||
} else {
|
||||
vp9_info->spatial_idx = layer_id.spatial_layer_id;
|
||||
*spatial_idx = layer_id.spatial_layer_id;
|
||||
}
|
||||
if (layer_id.spatial_layer_id != 0) {
|
||||
vp9_info->ss_data_available = false;
|
||||
@ -1021,8 +1022,10 @@ int VP9EncoderImpl::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {
|
||||
RTC_DCHECK_LE(encoded_image_._length, encoded_image_._size);
|
||||
|
||||
memset(&codec_specific_, 0, sizeof(codec_specific_));
|
||||
PopulateCodecSpecific(&codec_specific_, *pkt, input_image_->timestamp(),
|
||||
first_frame_in_picture);
|
||||
absl::optional<int> spatial_index;
|
||||
PopulateCodecSpecific(&codec_specific_, &spatial_index, *pkt,
|
||||
input_image_->timestamp(), first_frame_in_picture);
|
||||
encoded_image_.SetSpatialIndex(spatial_index);
|
||||
|
||||
if (is_flexible_mode_) {
|
||||
UpdateReferenceBuffers(*pkt, pics_since_key_);
|
||||
|
||||
@ -61,6 +61,7 @@ class VP9EncoderImpl : public VP9Encoder {
|
||||
int InitAndSetControlSettings(const VideoCodec* inst);
|
||||
|
||||
void PopulateCodecSpecific(CodecSpecificInfo* codec_specific,
|
||||
absl::optional<int>* spatial_idx,
|
||||
const vpx_codec_cx_pkt& pkt,
|
||||
uint32_t timestamp,
|
||||
bool first_frame_in_picture);
|
||||
|
||||
Reference in New Issue
Block a user