Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix and add test case for 4:2:2 fuzzing failure #2537

Merged
merged 1 commit into from
Sep 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 44 additions & 1 deletion src/tiling/tiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ impl TilingInfo {
tile_width_sb_pre
};

let cols = (frame_width_sb + tile_width_sb - 1) / tile_width_sb;

// Adjust tile_cols_log2 in case of rounding tile_width_sb to even.
let tile_cols_log2 = Self::tile_log2(1, cols).unwrap();
assert!(tile_cols_log2 >= min_tile_cols_log2);

let min_tile_rows_log2 = if min_tiles_log2 > tile_cols_log2 {
min_tiles_log2 - tile_cols_log2
} else {
Expand All @@ -127,7 +133,6 @@ impl TilingInfo {
.min(max_tile_rows_log2);
let tile_height_sb = sb_rows.align_power_of_two_and_shift(tile_rows_log2);

let cols = (frame_width_sb + tile_width_sb - 1) / tile_width_sb;
let rows = (frame_height_sb + tile_height_sb - 1) / tile_height_sb;

Self {
Expand Down Expand Up @@ -818,4 +823,42 @@ pub mod test {
fn tile_log2_overflow() {
assert_eq!(TilingInfo::tile_log2(1, usize::max_value()), None);
}

#[test]
fn from_target_tiles_422() {
let sb_size_log2 = 6;
let is_422_p = true;
let frame_rate = 60.;
let sb_size = 1 << sb_size_log2;

for frame_height in (sb_size..4352).step_by(sb_size) {
for tile_rows_log2 in
0..=TilingInfo::tile_log2(1, frame_height >> sb_size_log2).unwrap()
{
for frame_width in (sb_size..7680).step_by(sb_size) {
for tile_cols_log2 in
0..=TilingInfo::tile_log2(1, frame_width >> sb_size_log2).unwrap()
{
let ti = TilingInfo::from_target_tiles(
sb_size_log2,
frame_width,
frame_height,
frame_rate,
tile_cols_log2,
tile_rows_log2,
is_422_p,
);
assert_eq!(
ti.tile_cols_log2,
TilingInfo::tile_log2(1, ti.cols).unwrap()
);
assert_eq!(
ti.tile_rows_log2,
TilingInfo::tile_log2(1, ti.rows).unwrap()
);
}
}
}
}
}
}