Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sdroege/gst-plugin-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2022-02-06 22:34:13 +0300
committerSebastian Dröge <slomo@coaxion.net>2022-02-07 10:30:57 +0300
commit76545672011a5439cca0de0878c6de165037302d (patch)
treeb798cf3ddc651859c21ec5fdbf55c5b80b6486bf /video/rav1e
parent1451e267cc8be95ade812e2d4ea80c3b2e826f72 (diff)
rav1enc: Set mastering display info, content light level and HDR related colorimetry
Configurable behind the "hdr" cargo feature that is enabled by default but requires GStreamer 1.18.
Diffstat (limited to 'video/rav1e')
-rw-r--r--video/rav1e/Cargo.toml2
-rw-r--r--video/rav1e/src/rav1enc/imp.rs83
2 files changed, 84 insertions, 1 deletions
diff --git a/video/rav1e/Cargo.toml b/video/rav1e/Cargo.toml
index 4afcc6e4..b1a49c3d 100644
--- a/video/rav1e/Cargo.toml
+++ b/video/rav1e/Cargo.toml
@@ -26,10 +26,12 @@ path = "src/lib.rs"
gst-plugin-version-helper = { path="../../version-helper" }
[features]
+default = ["hdr"]
# GStreamer 1.14 is required for static linking
static = ["gst/v1_14"]
capi = []
asm = ["rav1e/asm"]
+hdr = ["gst-video/v1_18"]
[package.metadata.capi]
min_version = "0.8.0"
diff --git a/video/rav1e/src/rav1enc/imp.rs b/video/rav1e/src/rav1enc/imp.rs
index cef2fe5e..5cc29e9f 100644
--- a/video/rav1e/src/rav1enc/imp.rs
+++ b/video/rav1e/src/rav1enc/imp.rs
@@ -637,7 +637,6 @@ impl VideoEncoderImpl for Rav1Enc {
let settings = self.settings.lock().unwrap();
- // TODO: More properties, HDR information
let cfg = config::Config::new()
.with_encoder_config(config::EncoderConfig {
width: video_info.width() as usize,
@@ -699,6 +698,22 @@ impl VideoEncoderImpl for Rav1Enc {
gst_video::VideoTransferFunction::Bt202012 => {
color::TransferCharacteristics::BT2020_12Bit
}
+ #[cfg(feature = "hdr")]
+ gst_video::VideoTransferFunction::Bt202010 => {
+ color::TransferCharacteristics::BT2020_10Bit
+ }
+ #[cfg(feature = "hdr")]
+ gst_video::VideoTransferFunction::Smpte2084 => {
+ color::TransferCharacteristics::SMPTE2084
+ }
+ #[cfg(feature = "hdr")]
+ gst_video::VideoTransferFunction::AribStdB67 => {
+ color::TransferCharacteristics::HLG
+ }
+ #[cfg(feature = "hdr")]
+ gst_video::VideoTransferFunction::Bt601 => {
+ color::TransferCharacteristics::BT601
+ }
gst_video::VideoTransferFunction::Gamma18
| gst_video::VideoTransferFunction::Gamma20
| gst_video::VideoTransferFunction::Gamma22
@@ -716,6 +731,18 @@ impl VideoEncoderImpl for Rav1Enc {
}
gst_video::VideoColorPrimaries::Film => color::ColorPrimaries::GenericFilm,
gst_video::VideoColorPrimaries::Bt2020 => color::ColorPrimaries::BT2020,
+ #[cfg(feature = "hdr")]
+ gst_video::VideoColorPrimaries::Smptest428 => color::ColorPrimaries::XYZ,
+ #[cfg(feature = "hdr")]
+ gst_video::VideoColorPrimaries::Smpterp431 => {
+ color::ColorPrimaries::SMPTE431
+ }
+ #[cfg(feature = "hdr")]
+ gst_video::VideoColorPrimaries::Smpteeg432 => {
+ color::ColorPrimaries::SMPTE432
+ }
+ #[cfg(feature = "hdr")]
+ gst_video::VideoColorPrimaries::Ebu3213 => color::ColorPrimaries::EBU3213,
gst_video::VideoColorPrimaries::Adobergb | _ => {
color::ColorPrimaries::Unspecified
}
@@ -727,6 +754,60 @@ impl VideoEncoderImpl for Rav1Enc {
matrix_coefficients: matrix,
})
},
+ mastering_display: {
+ #[cfg(feature = "hdr")]
+ {
+ state
+ .caps()
+ .and_then(|caps| {
+ gst_video::VideoMasteringDisplayInfo::from_caps(caps).ok()
+ })
+ .map(|info| rav1e::prelude::color::MasteringDisplay {
+ primaries: [
+ rav1e::prelude::color::ChromaticityPoint {
+ x: info.display_primaries()[0].x,
+ y: info.display_primaries()[0].y,
+ },
+ rav1e::prelude::color::ChromaticityPoint {
+ x: info.display_primaries()[1].x,
+ y: info.display_primaries()[1].y,
+ },
+ rav1e::prelude::color::ChromaticityPoint {
+ x: info.display_primaries()[2].x,
+ y: info.display_primaries()[2].y,
+ },
+ ],
+ white_point: rav1e::prelude::color::ChromaticityPoint {
+ x: info.white_point().x,
+ y: info.white_point().y,
+ },
+ max_luminance: info.max_display_mastering_luminance(),
+ min_luminance: info.min_display_mastering_luminance(),
+ })
+ }
+ #[cfg(not(feature = "hdr"))]
+ {
+ None
+ }
+ },
+ content_light: {
+ #[cfg(feature = "hdr")]
+ {
+ state
+ .caps()
+ .and_then(|caps| {
+ gst_video::VideoContentLightLevel::from_caps(caps).ok()
+ })
+ .map(|info| rav1e::prelude::color::ContentLight {
+ max_content_light_level: info.max_content_light_level(),
+ max_frame_average_light_level: info.max_frame_average_light_level(),
+ })
+ }
+ #[cfg(not(feature = "hdr"))]
+ {
+ None
+ }
+ },
speed_settings: config::SpeedSettings::from_preset(settings.speed_preset as usize),
time_base: if video_info.fps() != gst::Fraction::new(0, 1) {
data::Rational {