Add color space information to webrtc::VideoFrame and extract from VP9
This CL is the first step for introducing color space information in webrtc.
- Add ColorSpace class listing color profiles.
- Add ColorSpace as a member of webrtc::VideoFrame.
- Make use of this class by extracting info from VP9 decoder.
Bug: webrtc:9522
Change-Id: I5e2514efee2a193bddb4459261387f2d40e936ad
Reviewed-on: https://webrtc-review.googlesource.com/88540
Reviewed-by: Niklas Enbom <niklas.enbom@webrtc.org>
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Commit-Queue: Emircan Uysaler <emircan@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23988}
diff --git a/api/video/video_frame.cc b/api/video/video_frame.cc
index e8fb29d..5521ad8 100644
--- a/api/video/video_frame.cc
+++ b/api/video/video_frame.cc
@@ -15,6 +15,55 @@
namespace webrtc {
+VideoFrame::Builder::Builder() = default;
+
+VideoFrame::Builder::~Builder() = default;
+
+VideoFrame VideoFrame::Builder::build() {
+ return VideoFrame(video_frame_buffer_, timestamp_us_, timestamp_rtp_,
+ ntp_time_ms_, rotation_, color_space_);
+}
+
+VideoFrame::Builder& VideoFrame::Builder::set_video_frame_buffer(
+ const rtc::scoped_refptr<VideoFrameBuffer>& buffer) {
+ video_frame_buffer_ = buffer;
+ return *this;
+}
+
+VideoFrame::Builder& VideoFrame::Builder::set_timestamp_ms(
+ int64_t timestamp_ms) {
+ timestamp_us_ = timestamp_ms * rtc::kNumMicrosecsPerMillisec;
+ return *this;
+}
+
+VideoFrame::Builder& VideoFrame::Builder::set_timestamp_us(
+ int64_t timestamp_us) {
+ timestamp_us_ = timestamp_us;
+ return *this;
+}
+
+VideoFrame::Builder& VideoFrame::Builder::set_timestamp_rtp(
+ uint32_t timestamp_rtp) {
+ timestamp_rtp_ = timestamp_rtp;
+ return *this;
+}
+
+VideoFrame::Builder& VideoFrame::Builder::set_ntp_time_ms(int64_t ntp_time_ms) {
+ ntp_time_ms_ = ntp_time_ms;
+ return *this;
+}
+
+VideoFrame::Builder& VideoFrame::Builder::set_rotation(VideoRotation rotation) {
+ rotation_ = rotation;
+ return *this;
+}
+
+VideoFrame::Builder& VideoFrame::Builder::set_color_space(
+ const ColorSpace& color_space) {
+ color_space_ = color_space;
+ return *this;
+}
+
VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
webrtc::VideoRotation rotation,
int64_t timestamp_us)
@@ -36,6 +85,19 @@
RTC_DCHECK(buffer);
}
+VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
+ int64_t timestamp_us,
+ uint32_t timestamp_rtp,
+ int64_t ntp_time_ms,
+ VideoRotation rotation,
+ const absl::optional<ColorSpace>& color_space)
+ : video_frame_buffer_(buffer),
+ timestamp_rtp_(timestamp_rtp),
+ ntp_time_ms_(ntp_time_ms),
+ timestamp_us_(timestamp_us),
+ rotation_(rotation),
+ color_space_(color_space) {}
+
VideoFrame::~VideoFrame() = default;
VideoFrame::VideoFrame(const VideoFrame&) = default;