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 {
pub low_latency: bool,
pub quantizer: usize,
pub tune: Tune,
pub pixel_range: PixelRange,
pub color_description: Option<ColorDescription>,
pub speed_settings: SpeedSettings,
pub show_psnr: bool,
......@@ -90,6 +91,7 @@ impl EncoderConfig {
low_latency: true,
quantizer: 100,
tune: Tune::Psnr,
pixel_range: PixelRange::Unspecified,
color_description: None,
speed_settings: SpeedSettings::from_preset(speed),
show_psnr: false,
......@@ -185,6 +187,22 @@ pub enum PredictionModesSetting {
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!{
#[derive(Debug, Clone, Copy, PartialEq)]
#[repr(C)]
......@@ -460,6 +478,7 @@ impl Context {
fn get_frame_properties(&mut self, idx: u64) -> (FrameInvariants, bool) {
if idx == 0 {
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;
// The first frame will always be a key frame
......
......@@ -99,6 +99,13 @@ pub fn parse_cli() -> CliOptions {
.possible_values(&Tune::variants())
.default_value("psnr")
.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::with_name("COLOR_PRIMARIES")
.help("Color primaries used to describe color parameters.")
......@@ -186,6 +193,8 @@ fn parse_config(matches: &ArgMatches) -> EncoderConfig {
cfg.max_key_frame_interval = max_interval;
cfg.low_latency = matches.value_of("LOW_LATENCY").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 &&
transfer_characteristics == TransferCharacteristics::Unspecified &&
matrix_coefficients == MatrixCoefficients::Unspecified {
......
......@@ -236,6 +236,7 @@ pub struct Sequence {
pub bit_depth: usize,
pub chroma_sampling: ChromaSampling,
pub chroma_sample_position: ChromaSamplePosition,
pub pixel_range: PixelRange,
pub color_description: Option<ColorDescription>,
pub max_frame_width: u32,
pub max_frame_height: u32,
......@@ -319,6 +320,7 @@ impl Sequence {
bit_depth: info.bit_depth,
chroma_sampling: info.chroma_sampling,
chroma_sample_position: info.chroma_sample_position,
pixel_range: PixelRange::Unspecified,
color_description: None,
max_frame_width: info.width as u32,
max_frame_height: info.height as u32,
......@@ -1082,7 +1084,7 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
}
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_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