Skip to content

Commit a6240d6

Browse files
barrbraintdaede
authored andcommitted
Fix fall-through of x86 dispatch_predict_intra for CpuFeatureLevel::RUST
1 parent 54b667c commit a6240d6

File tree

7 files changed

+59
-18
lines changed

7 files changed

+59
-18
lines changed

src/api/config/encoder.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ pub struct EncoderConfig {
3131
pub height: usize,
3232
/// Sample aspect ratio (for anamorphic video).
3333
pub sample_aspect_ratio: Rational,
34+
/// Maximum width of the frames in pixels (for seq header)
35+
/// 0 means to use the width setting instead.
36+
/// Used for multiple renditions when switch frames are in use.
37+
/// Set all renditions to have identical max_width / max_height.
38+
pub max_width: usize,
39+
/// Maximum height of the frames in pixels (for seq header)
40+
pub max_height: usize,
3441
/// Video time base.
3542
pub time_base: Rational,
3643

@@ -133,7 +140,8 @@ impl EncoderConfig {
133140
height: 480,
134141
sample_aspect_ratio: Rational { num: 1, den: 1 },
135142
time_base: Rational { num: 1, den: 30 },
136-
143+
max_width: 0,
144+
max_height: 0,
137145
bit_depth: 8,
138146
chroma_sampling: ChromaSampling::Cs420,
139147
chroma_sample_position: ChromaSamplePosition::Unknown,
@@ -213,7 +221,7 @@ impl EncoderConfig {
213221
// has the property that the scaled distortion of a 2Nx2N block is always
214222
// equal to the sum of the scaled distortions of the NxN sub-blocks it's
215223
// made of, this is a necessary property to be able to do RDO between
216-
// multiple partition sizes properly. Unfortunately, when tx domain
224+
// multiple partition sizes properly. Unfortunately, when tx domains
217225
// distortion is used, distortion is only known at the tx block level which
218226
// might be bigger than 8x8. So temporal RDO is always disabled in that case.
219227
!self.speed_settings.tx_domain_distortion

src/api/config/mod.rs

+6
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ impl Config {
313313
if render_height == 0 || render_height > u16::max_value() as usize {
314314
return Err(InvalidRenderHeight(render_height));
315315
}
316+
if config.max_width != 0 && config.width > config.max_width {
317+
return Err(InvalidWidth(config.width));
318+
}
319+
if config.max_height != 0 && config.height > config.max_height {
320+
return Err(InvalidHeight(config.height));
321+
}
316322

317323
if config.rdo_lookahead_frames > MAX_RDO_LOOKAHEAD_FRAMES
318324
|| config.rdo_lookahead_frames < 1

src/api/test.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,8 @@ fn log_q_exp_overflow() {
19021902
width: 16,
19031903
height: 16,
19041904
sample_aspect_ratio: Rational::new(1, 1),
1905+
max_width: 0,
1906+
max_height: 0,
19051907
bit_depth: 8,
19061908
chroma_sampling: ChromaSampling::Cs420,
19071909
chroma_sample_position: ChromaSamplePosition::Unknown,
@@ -1967,6 +1969,8 @@ fn guess_frame_subtypes_assert() {
19671969
width: 16,
19681970
height: 16,
19691971
sample_aspect_ratio: Rational::new(1, 1),
1972+
max_width: 0,
1973+
max_height: 0,
19701974
bit_depth: 8,
19711975
chroma_sampling: ChromaSampling::Cs420,
19721976
chroma_sample_position: ChromaSamplePosition::Unknown,

src/bin/common.rs

+17
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,20 @@ pub fn parse_cli() -> Result<CliOptions, CliError> {
258258
.takes_value(true)
259259
.default_value("0")
260260
)
261+
.arg(
262+
Arg::with_name("MAX_WIDTH")
263+
.help("Maximum width coded in the sequence header. 0 uses the input video width.")
264+
.long("max-width")
265+
.takes_value(true)
266+
.default_value("0")
267+
)
268+
.arg(
269+
Arg::with_name("MAX_HEIGHT")
270+
.help("Maximum height coded in the sequence header. 0 uses the input video width.")
271+
.long("max-height")
272+
.takes_value(true)
273+
.default_value("0")
274+
)
261275
.arg(
262276
Arg::with_name("TILES")
263277
.help("Number of tiles. Tile-cols and tile-rows are overridden\n\
@@ -740,6 +754,9 @@ fn parse_config(matches: &ArgMatches<'_>) -> Result<EncoderConfig, CliError> {
740754
cfg.tile_cols = matches.value_of("TILE_COLS").unwrap().parse().unwrap();
741755
cfg.tile_rows = matches.value_of("TILE_ROWS").unwrap().parse().unwrap();
742756

757+
cfg.max_width = matches.value_of("MAX_WIDTH").unwrap().parse().unwrap();
758+
cfg.max_height = matches.value_of("MAX_HEIGHT").unwrap().parse().unwrap();
759+
743760
cfg.tiles = matches.value_of("TILES").unwrap().parse().unwrap();
744761

745762
if cfg.tile_cols > 64 || cfg.tile_rows > 64 {

src/capi.rs

+6
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,12 @@ unsafe fn option_match(
609609
match key {
610610
"width" => enc.width = value.parse().map_err(|_| ())?,
611611
"height" => enc.height = value.parse().map_err(|_| ())?,
612+
"max_width" => {
613+
enc.max_width = value.parse().map_err(|_| ())?
614+
}
615+
"max_height" => {
616+
enc.max_height = value.parse().map_err(|_| ())?
617+
}
612618
"speed" => {
613619
enc.speed_settings =
614620
rav1e::SpeedSettings::from_preset(value.parse().map_err(|_| ())?)

src/encoder.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,12 @@ pub struct Sequence {
187187

188188
impl Sequence {
189189
pub fn new(config: &EncoderConfig) -> Sequence {
190-
let width_bits = 32 - (config.width as u32).leading_zeros();
191-
let height_bits = 32 - (config.height as u32).leading_zeros();
190+
let max_width =
191+
if config.max_width > 0 { config.max_width } else { config.width };
192+
let max_height =
193+
if config.max_height > 0 { config.max_height } else { config.height };
194+
let width_bits = 32 - ((max_width as u32) - 1).leading_zeros();
195+
let height_bits = 32 - ((max_height as u32) - 1).leading_zeros();
192196
assert!(width_bits <= 16);
193197
assert!(height_bits <= 16);
194198

@@ -277,8 +281,8 @@ impl Sequence {
277281
color_description: config.color_description,
278282
mastering_display: config.mastering_display,
279283
content_light: config.content_light,
280-
max_frame_width: config.width as u32,
281-
max_frame_height: config.height as u32,
284+
max_frame_width: max_width as u32,
285+
max_frame_height: max_height as u32,
282286
frame_id_numbers_present_flag: false,
283287
frame_id_length: FRAME_ID_LENGTH,
284288
delta_frame_id_length: DELTA_FRAME_ID_LENGTH,

src/header.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -837,12 +837,10 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
837837
fn write_max_frame_size<T: Pixel>(
838838
&mut self, fi: &FrameInvariants<T>,
839839
) -> io::Result<()> {
840-
// width_bits and height_bits will have to be moved to the sequence header OBU
841-
// when we add support for it.
842-
let width = fi.width - 1;
843-
let height = fi.height - 1;
844-
let width_bits = log_in_base_2(width as u32) as u32 + 1;
845-
let height_bits = log_in_base_2(height as u32) as u32 + 1;
840+
let width = fi.sequence.max_frame_width - 1;
841+
let height = fi.sequence.max_frame_height - 1;
842+
let width_bits = fi.sequence.num_bits_width;
843+
let height_bits = fi.sequence.num_bits_height;
846844
assert!(width_bits <= 16);
847845
assert!(height_bits <= 16);
848846
self.write(4, width_bits - 1)?;
@@ -858,14 +856,12 @@ impl<W: io::Write> UncompressedHeader for BitWriter<W, BigEndian> {
858856
// width_bits and height_bits will have to be moved to the sequence header OBU
859857
// when we add support for it.
860858
if fi.frame_size_override_flag {
861-
let width = fi.width - 1;
862-
let height = fi.height - 1;
863-
let width_bits = log_in_base_2(width as u32) as u32 + 1;
864-
let height_bits = log_in_base_2(height as u32) as u32 + 1;
859+
let width_bits = fi.sequence.num_bits_width;
860+
let height_bits = fi.sequence.num_bits_height;
865861
assert!(width_bits <= 16);
866862
assert!(height_bits <= 16);
867-
self.write(width_bits, width as u16)?;
868-
self.write(height_bits, height as u16)?;
863+
self.write(width_bits, (fi.width - 1) as u16)?;
864+
self.write(height_bits, (fi.height - 1) as u16)?;
869865
}
870866
if fi.sequence.enable_superres {
871867
unimplemented!();

0 commit comments

Comments
 (0)