Commit 7de7e030 authored by Vittorio Giovara's avatar Vittorio Giovara Committed by Thomas Daede

rav1e: Support setting full range color property

parent e59140b2
...@@ -70,6 +70,7 @@ pub struct EncoderConfig { ...@@ -70,6 +70,7 @@ pub struct EncoderConfig {
pub low_latency: bool, pub low_latency: bool,
pub quantizer: usize, pub quantizer: usize,
pub tune: Tune, pub tune: Tune,
pub pixel_range: PixelRange,
pub color_description: Option<ColorDescription>, pub color_description: Option<ColorDescription>,
pub speed_settings: SpeedSettings, pub speed_settings: SpeedSettings,
pub show_psnr: bool, pub show_psnr: bool,
...@@ -90,6 +91,7 @@ impl EncoderConfig { ...@@ -90,6 +91,7 @@ impl EncoderConfig {
low_latency: true, low_latency: true,
quantizer: 100, quantizer: 100,
tune: Tune::Psnr, tune: Tune::Psnr,
pixel_range: PixelRange::Unspecified,
color_description: None, color_description: None,
speed_settings: SpeedSettings::from_preset(speed), speed_settings: SpeedSettings::from_preset(speed),
show_psnr: false, show_psnr: false,
...@@ -185,6 +187,22 @@ pub enum PredictionModesSetting { ...@@ -185,6 +187,22 @@ pub enum PredictionModesSetting {
ComplexAll, ComplexAll,
} }
arg_enum!{
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C)]
pub enum PixelRange {
Unspecified = 0,
Limited,
Full,
}
}
impl Default for PixelRange {
fn default() -> Self {
PixelRange::Unspecified
}
}
arg_enum!{ arg_enum!{
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C)] #[repr(C)]
...@@ -460,6 +478,7 @@ impl Context { ...@@ -460,6 +478,7 @@ impl Context {
fn get_frame_properties(&mut self, idx: u64) -> (FrameInvariants, bool) { fn get_frame_properties(&mut self, idx: u64) -> (FrameInvariants, bool) {
if idx == 0 { if idx == 0 {
let mut seq = Sequence::new(&self.config.video_info); let mut seq = Sequence::new(&self.config.video_info);
seq.pixel_range = self.config.enc.pixel_range;
seq.color_description = self.config.enc.color_description; seq.color_description = self.config.enc.color_description;
// The first frame will always be a key frame // The first frame will always be a key frame
......
...@@ -99,6 +99,13 @@ pub fn parse_cli() -> CliOptions { ...@@ -99,6 +99,13 @@ pub fn parse_cli() -> CliOptions {
.possible_values(&Tune::variants()) .possible_values(&Tune::variants())
.default_value("psnr") .default_value("psnr")
.case_insensitive(true) .case_insensitive(true)
).arg(
Arg::with_name("PIXEL_RANGE")
.help("Pixel range")
.long("range")
.possible_values(&PixelRange::variants())
.default_value("unspecified")
.case_insensitive(true)
).arg( ).arg(
Arg::with_name("COLOR_PRIMARIES") Arg::with_name("COLOR_PRIMARIES")
.help("Color primaries used to describe color parameters.") .help("Color primaries used to describe color parameters.")
...@@ -186,6 +193,8 @@ fn parse_config(matches: &ArgMatches) -> EncoderConfig { ...@@ -186,6 +193,8 @@ fn parse_config(matches: &ArgMatches) -> EncoderConfig {
cfg.max_key_frame_interval = max_interval; cfg.max_key_frame_interval = max_interval;
cfg.low_latency = matches.value_of("LOW_LATENCY").unwrap().parse().unwrap(); cfg.low_latency = matches.value_of("LOW_LATENCY").unwrap().parse().unwrap();
cfg.tune = matches.value_of("TUNE").unwrap().parse().unwrap(); cfg.tune = matches.value_of("TUNE").unwrap().parse().unwrap();
cfg.pixel_range = matches.value_of("PIXEL_RANGE").unwrap().parse().unwrap_or_default();
cfg.color_description = if color_primaries == ColorPrimaries::Unspecified && cfg.color_description = if color_primaries == ColorPrimaries::Unspecified &&
transfer_characteristics == TransferCharacteristics::Unspecified && transfer_characteristics == TransferCharacteristics::Unspecified &&
matrix_coefficients == MatrixCoefficients::Unspecified { matrix_coefficients == MatrixCoefficients::Unspecified {
......
...@@ -236,6 +236,7 @@ pub struct Sequence { ...@@ -236,6 +236,7 @@ pub struct Sequence {
pub bit_depth: usize, pub bit_depth: usize,
pub chroma_sampling: ChromaSampling, pub chroma_sampling: ChromaSampling,
pub chroma_sample_position: ChromaSamplePosition, pub chroma_sample_position: ChromaSamplePosition,
pub pixel_range: PixelRange,
pub color_description: Option<ColorDescription>, pub color_description: Option<ColorDescription>,
pub max_frame_width: u32, pub max_frame_width: u32,
pub max_frame_height: u32, pub max_frame_height: u32,
...@@ -319,6 +320,7 @@ impl Sequence { ...@@ -319,6 +320,7 @@ impl Sequence {
bit_depth: info.bit_depth, bit_depth: info.bit_depth,
chroma_sampling: info.chroma_sampling, chroma_sampling: info.chroma_sampling,
chroma_sample_position: info.chroma_sample_position, chroma_sample_position: info.chroma_sample_position,
pixel_range: PixelRange::Unspecified,
color_description: None, color_description: None,
max_frame_width: info.width as u32, max_frame_width: info.width as u32,
max_frame_height: info.height as u32, max_frame_height: info.height as u32,
...@@ -1082,7 +1084,7 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> { ...@@ -1082,7 +1084,7 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
} }
if write_color_range { if write_color_range {
self.write_bit(false)?; // full color range self.write_bit(seq.pixel_range == PixelRange::Full)?; // full color range
let subsampling_x = seq.chroma_sampling != ChromaSampling::Cs444; let subsampling_x = seq.chroma_sampling != ChromaSampling::Cs444;
let subsampling_y = seq.chroma_sampling == ChromaSampling::Cs420; let subsampling_y = seq.chroma_sampling == ChromaSampling::Cs420;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment