VP9 encoder: mark only base spatial layer as keyframe
Bug: webrtc:13576 Change-Id: Ia4173d3aa2c8e546a818eccc5d6c09d1150dcaf4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/247188 Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Commit-Queue: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35736}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
376bd6da72
commit
4b5caee6b1
@ -1634,18 +1634,6 @@ void LibvpxVp9Encoder::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {
|
|||||||
encoded_image_.SetEncodedData(EncodedImageBuffer::Create(
|
encoded_image_.SetEncodedData(EncodedImageBuffer::Create(
|
||||||
static_cast<const uint8_t*>(pkt->data.frame.buf), pkt->data.frame.sz));
|
static_cast<const uint8_t*>(pkt->data.frame.buf), pkt->data.frame.sz));
|
||||||
|
|
||||||
const bool is_key_frame =
|
|
||||||
(pkt->data.frame.flags & VPX_FRAME_IS_KEY) ? true : false;
|
|
||||||
// Ensure encoder issued key frame on request.
|
|
||||||
RTC_DCHECK(is_key_frame || !force_key_frame_);
|
|
||||||
|
|
||||||
// Check if encoded frame is a key frame.
|
|
||||||
encoded_image_._frameType = VideoFrameType::kVideoFrameDelta;
|
|
||||||
if (is_key_frame) {
|
|
||||||
encoded_image_._frameType = VideoFrameType::kVideoFrameKey;
|
|
||||||
force_key_frame_ = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
codec_specific_ = {};
|
codec_specific_ = {};
|
||||||
absl::optional<int> spatial_index;
|
absl::optional<int> spatial_index;
|
||||||
if (!PopulateCodecSpecific(&codec_specific_, &spatial_index, *pkt,
|
if (!PopulateCodecSpecific(&codec_specific_, &spatial_index, *pkt,
|
||||||
@ -1656,6 +1644,20 @@ void LibvpxVp9Encoder::GetEncodedLayerFrame(const vpx_codec_cx_pkt* pkt) {
|
|||||||
}
|
}
|
||||||
encoded_image_.SetSpatialIndex(spatial_index);
|
encoded_image_.SetSpatialIndex(spatial_index);
|
||||||
|
|
||||||
|
const bool is_key_frame =
|
||||||
|
((pkt->data.frame.flags & VPX_FRAME_IS_KEY) ? true : false) &&
|
||||||
|
!codec_specific_.codecSpecific.VP9.inter_layer_predicted;
|
||||||
|
|
||||||
|
// Ensure encoder issued key frame on request.
|
||||||
|
RTC_DCHECK(is_key_frame || !force_key_frame_);
|
||||||
|
|
||||||
|
// Check if encoded frame is a key frame.
|
||||||
|
encoded_image_._frameType = VideoFrameType::kVideoFrameDelta;
|
||||||
|
if (is_key_frame) {
|
||||||
|
encoded_image_._frameType = VideoFrameType::kVideoFrameKey;
|
||||||
|
force_key_frame_ = false;
|
||||||
|
}
|
||||||
|
|
||||||
UpdateReferenceBuffers(*pkt, pics_since_key_);
|
UpdateReferenceBuffers(*pkt, pics_since_key_);
|
||||||
|
|
||||||
TRACE_COUNTER1("webrtc", "EncodedFrameSize", encoded_image_.size());
|
TRACE_COUNTER1("webrtc", "EncodedFrameSize", encoded_image_.size());
|
||||||
|
Reference in New Issue
Block a user