From 2455c9ed361671cc2ea41deb81cbcfbda073a6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Tue, 24 Jul 2018 17:18:18 +0200 Subject: [PATCH] Add spatial index to EncodedImage, not yet used. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a preparation for landing cl https://webrtc-review.googlesource.com/c/src/+/83161, which needs to be done in multiple steps: 1. Add the new spatial_index_ member and accessor methods to EncodedImage (this cl). 2. Update downstream encoders to assign spatial index and simulcast index in EncodedImage, in addition to the old members of CodecSpecificInfo. 3. Land main cl, converting webrtc code to use the spatial index from EncodedImage. Ignore the old fields in CodecSpecificInfo, but leave them in place in respective structs. 4. Delete downstream code accessing old fields. 5. Delete old fields in webrtc. Bug: webrtc:9378 Change-Id: Ic132daf71f1cbbd57fb3b44f74ae94b921733f7a Reviewed-on: https://webrtc-review.googlesource.com/90248 Reviewed-by: Erik Språng Reviewed-by: Marco Paniconi Reviewed-by: Marco Paniconi Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#24093} --- common_video/include/video_frame.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/common_video/include/video_frame.h b/common_video/include/video_frame.h index 41c391941e..2053ea488e 100644 --- a/common_video/include/video_frame.h +++ b/common_video/include/video_frame.h @@ -16,6 +16,7 @@ // to refactor and clean up related interfaces, at which point it // should be moved to somewhere under api/. +#include "absl/types/optional.h" #include "api/video/video_content_type.h" #include "api/video/video_rotation.h" #include "api/video/video_timing.h" @@ -39,6 +40,17 @@ class EncodedImage { void SetEncodeTime(int64_t encode_start_ms, int64_t encode_finish_ms); + absl::optional SpatialIndex() const { + if (spatial_index_ < 0) + return absl::nullopt; + return spatial_index_; + } + void SetSpatialIndex(absl::optional spatial_index) { + RTC_DCHECK_GE(spatial_index.value_or(0), 0); + RTC_DCHECK_LT(spatial_index.value_or(0), kMaxSpatialLayers); + spatial_index_ = spatial_index.value_or(-1); + } + uint32_t _encodedWidth = 0; uint32_t _encodedHeight = 0; uint32_t _timeStamp = 0; @@ -70,6 +82,11 @@ class EncodedImage { int64_t receive_start_ms = 0; int64_t receive_finish_ms = 0; } timing_; + + private: + // -1 means not set. Use a plain int rather than optional, to keep this class + // copyable with memcpy. + int spatial_index_ = -1; }; } // namespace webrtc