Add HdrMetadata to VideoFrame

Bug: webrtc:8651
Change-Id: I28aacbc63e346328633fb862662343f47e966bf1
Reviewed-on: https://webrtc-review.googlesource.com/c/108320
Commit-Queue: Johannes Kron <kron@webrtc.org>
Reviewed-by: Emircan Uysaler <emircan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25513}
This commit is contained in:
Johannes Kron
2018-11-05 16:13:02 +01:00
committed by Commit Bot
parent 4f0f3d5a22
commit fbf168386b
4 changed files with 36 additions and 5 deletions

View File

@ -15,12 +15,21 @@ namespace webrtc {
HdrMasteringMetadata::Chromaticity::Chromaticity() = default;
HdrMasteringMetadata::Chromaticity::Chromaticity(const Chromaticity& rhs) =
default;
HdrMasteringMetadata::Chromaticity::Chromaticity(Chromaticity&& rhs) = default;
HdrMasteringMetadata::Chromaticity& HdrMasteringMetadata::Chromaticity::
operator=(const Chromaticity& rhs) = default;
HdrMasteringMetadata::HdrMasteringMetadata() = default;
HdrMasteringMetadata::HdrMasteringMetadata(const HdrMasteringMetadata& rhs) =
default;
HdrMasteringMetadata::HdrMasteringMetadata(HdrMasteringMetadata&& rhs) =
default;
HdrMasteringMetadata& HdrMasteringMetadata::operator=(
const HdrMasteringMetadata& rhs) = default;
HdrMetadata::HdrMetadata() = default;
HdrMetadata::HdrMetadata(const HdrMetadata& rhs) = default;
HdrMetadata::HdrMetadata(HdrMetadata&& rhs) = default;
HdrMetadata& HdrMetadata::operator=(const HdrMetadata& rhs) = default;
} // namespace webrtc

View File

@ -31,6 +31,8 @@ struct HdrMasteringMetadata {
Chromaticity();
Chromaticity(const Chromaticity& rhs);
Chromaticity(Chromaticity&& rhs);
Chromaticity& operator=(const Chromaticity& rhs);
};
// The nominal primaries of the mastering display.
@ -53,6 +55,8 @@ struct HdrMasteringMetadata {
HdrMasteringMetadata();
HdrMasteringMetadata(const HdrMasteringMetadata& rhs);
HdrMasteringMetadata(HdrMasteringMetadata&& rhs);
HdrMasteringMetadata& operator=(const HdrMasteringMetadata& rhs);
bool operator==(const HdrMasteringMetadata& rhs) const {
return ((primary_r == rhs.primary_r) && (primary_g == rhs.primary_g) &&
@ -76,6 +80,8 @@ struct HdrMetadata {
HdrMetadata();
HdrMetadata(const HdrMetadata& rhs);
HdrMetadata(HdrMetadata&& rhs);
HdrMetadata& operator=(const HdrMetadata& rhs);
bool operator==(const HdrMetadata& rhs) const {
return (

View File

@ -21,7 +21,7 @@ VideoFrame::Builder::~Builder() = default;
VideoFrame VideoFrame::Builder::build() {
return VideoFrame(video_frame_buffer_, timestamp_us_, timestamp_rtp_,
ntp_time_ms_, rotation_, color_space_);
ntp_time_ms_, rotation_, color_space_, hdr_metadata_);
}
VideoFrame::Builder& VideoFrame::Builder::set_video_frame_buffer(
@ -64,6 +64,12 @@ VideoFrame::Builder& VideoFrame::Builder::set_color_space(
return *this;
}
VideoFrame::Builder& VideoFrame::Builder::set_hdr_metadata(
const HdrMetadata& hdr_metadata) {
hdr_metadata_ = hdr_metadata;
return *this;
}
VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
webrtc::VideoRotation rotation,
int64_t timestamp_us)
@ -90,13 +96,15 @@ VideoFrame::VideoFrame(const rtc::scoped_refptr<VideoFrameBuffer>& buffer,
uint32_t timestamp_rtp,
int64_t ntp_time_ms,
VideoRotation rotation,
const absl::optional<ColorSpace>& color_space)
const absl::optional<ColorSpace>& color_space,
const absl::optional<HdrMetadata>& hdr_metadata)
: video_frame_buffer_(buffer),
timestamp_rtp_(timestamp_rtp),
ntp_time_ms_(ntp_time_ms),
timestamp_us_(timestamp_us),
rotation_(rotation),
color_space_(color_space) {}
color_space_(color_space),
hdr_metadata_(hdr_metadata) {}
VideoFrame::~VideoFrame() = default;

View File

@ -15,6 +15,7 @@
#include "absl/types/optional.h"
#include "api/video/color_space.h"
#include "api/video/hdr_metadata.h"
#include "api/video/video_frame_buffer.h"
#include "api/video/video_rotation.h"
#include "rtc_base/scoped_ref_ptr.h"
@ -39,6 +40,7 @@ class RTC_EXPORT VideoFrame {
Builder& set_ntp_time_ms(int64_t ntp_time_ms);
Builder& set_rotation(VideoRotation rotation);
Builder& set_color_space(const ColorSpace& color_space);
Builder& set_hdr_metadata(const HdrMetadata& hdr_metadata);
private:
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
@ -47,6 +49,7 @@ class RTC_EXPORT VideoFrame {
int64_t ntp_time_ms_ = 0;
VideoRotation rotation_ = kVideoRotation_0;
absl::optional<ColorSpace> color_space_;
absl::optional<HdrMetadata> hdr_metadata_;
};
// To be deprecated. Migrate all use to Builder.
@ -112,9 +115,12 @@ class RTC_EXPORT VideoFrame {
VideoRotation rotation() const { return rotation_; }
void set_rotation(VideoRotation rotation) { rotation_ = rotation; }
// Set Color space when available.
// Get color space when available.
absl::optional<ColorSpace> color_space() const { return color_space_; }
// Get HDR metadata when available.
absl::optional<HdrMetadata> hdr_metadata() const { return hdr_metadata_; }
// Get render time in milliseconds.
// TODO(nisse): Deprecated. Migrate all users to timestamp_us().
int64_t render_time_ms() const;
@ -135,7 +141,8 @@ class RTC_EXPORT VideoFrame {
uint32_t timestamp_rtp,
int64_t ntp_time_ms,
VideoRotation rotation,
const absl::optional<ColorSpace>& color_space);
const absl::optional<ColorSpace>& color_space,
const absl::optional<HdrMetadata>& hdr_metadata);
// An opaque reference counted handle that stores the pixel data.
rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer_;
@ -144,6 +151,7 @@ class RTC_EXPORT VideoFrame {
int64_t timestamp_us_;
VideoRotation rotation_;
absl::optional<ColorSpace> color_space_;
absl::optional<HdrMetadata> hdr_metadata_;
};
} // namespace webrtc