@@ -44,12 +44,14 @@ pub struct TilingInfo {
44
44
pub min_tile_rows_log2 : usize ,
45
45
pub max_tile_rows_log2 : usize ,
46
46
pub sb_size_log2 : usize ,
47
+ pub min_tiles_log2 : usize ,
47
48
}
48
49
49
50
impl TilingInfo {
50
51
pub fn from_target_tiles (
51
52
sb_size_log2 : usize , frame_width : usize , frame_height : usize ,
52
53
frame_rate : f64 , tile_cols_log2 : usize , tile_rows_log2 : usize ,
54
+ is_422_p : bool ,
53
55
) -> Self {
54
56
// <https://aomediacodec.github.io/av1-spec/#tile-info-syntax>
55
57
@@ -87,7 +89,26 @@ impl TilingInfo {
87
89
88
90
let tile_cols_log2 =
89
91
tile_cols_log2. max ( min_tile_cols_log2) . min ( max_tile_cols_log2) ;
90
- let tile_width_sb = sb_cols. align_power_of_two_and_shift ( tile_cols_log2) ;
92
+ let tile_width_sb_pre =
93
+ sb_cols. align_power_of_two_and_shift ( tile_cols_log2) ;
94
+
95
+ // If this is 4:2:2, our UV horizontal is subsampled but not our
96
+ // vertical. Loop Restoration Units must be square, so they
97
+ // will always have an even number of horizontal superblocks. For
98
+ // tiles and LRUs to align, tile_width_sb must be even in 4:2:2
99
+ // video.
100
+
101
+ // This is only relevant when doing loop restoration RDO inline
102
+ // with block/superblock encoding, that is, where tiles are
103
+ // relevant. If (when) we introduce optionally delaying loop-filter
104
+ // encode to after the partitioning loop, we won't need to make
105
+ // any 4:2:2 adjustment.
106
+
107
+ let tile_width_sb = if is_422_p {
108
+ ( tile_width_sb_pre + 1 ) >> 1 << 1
109
+ } else {
110
+ tile_width_sb_pre
111
+ } ;
91
112
92
113
let min_tile_rows_log2 = if min_tiles_log2 > tile_cols_log2 {
93
114
min_tiles_log2 - tile_cols_log2
@@ -123,6 +144,7 @@ impl TilingInfo {
123
144
min_tile_rows_log2,
124
145
max_tile_rows_log2,
125
146
sb_size_log2,
147
+ min_tiles_log2,
126
148
}
127
149
}
128
150
@@ -240,6 +262,7 @@ pub mod test {
240
262
frame_rate,
241
263
0 ,
242
264
0 ,
265
+ false ,
243
266
) ;
244
267
assert_eq ! ( 1 , ti. cols) ;
245
268
assert_eq ! ( 1 , ti. rows) ;
@@ -253,6 +276,7 @@ pub mod test {
253
276
frame_rate,
254
277
1 ,
255
278
1 ,
279
+ false ,
256
280
) ;
257
281
assert_eq ! ( 2 , ti. cols) ;
258
282
assert_eq ! ( 2 , ti. rows) ;
@@ -266,6 +290,7 @@ pub mod test {
266
290
frame_rate,
267
291
2 ,
268
292
2 ,
293
+ false ,
269
294
) ;
270
295
assert_eq ! ( 3 , ti. cols) ;
271
296
assert_eq ! ( 3 , ti. rows) ;
@@ -280,6 +305,7 @@ pub mod test {
280
305
frame_rate,
281
306
10 ,
282
307
8 ,
308
+ false ,
283
309
) ;
284
310
assert_eq ! ( 3 , ti. cols) ;
285
311
assert_eq ! ( 3 , ti. rows) ;
@@ -293,6 +319,7 @@ pub mod test {
293
319
frame_rate,
294
320
0 ,
295
321
0 ,
322
+ false ,
296
323
) ;
297
324
assert_eq ! ( 1 , ti. cols) ;
298
325
assert_eq ! ( 1 , ti. rows) ;
@@ -336,6 +363,7 @@ pub mod test {
336
363
frame_rate,
337
364
1 ,
338
365
1 ,
366
+ false ,
339
367
) ;
340
368
let mut iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
341
369
assert_eq ! ( 4 , iter. len( ) ) ;
@@ -359,6 +387,7 @@ pub mod test {
359
387
frame_rate,
360
388
2 ,
361
389
2 ,
390
+ false ,
362
391
) ;
363
392
let mut iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
364
393
assert_eq ! ( 9 , iter. len( ) ) ;
@@ -406,6 +435,7 @@ pub mod test {
406
435
fi. config . frame_rate ( ) ,
407
436
2 ,
408
437
2 ,
438
+ false ,
409
439
) ;
410
440
let iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
411
441
let tile_states = iter. map ( |ctx| ctx. ts ) . collect :: < Vec < _ > > ( ) ;
@@ -484,6 +514,7 @@ pub mod test {
484
514
fi. config . frame_rate ( ) ,
485
515
2 ,
486
516
2 ,
517
+ false ,
487
518
) ;
488
519
let iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
489
520
let tbs = iter. map ( |ctx| ctx. tb ) . collect :: < Vec < _ > > ( ) ;
@@ -524,6 +555,7 @@ pub mod test {
524
555
fi. config . frame_rate ( ) ,
525
556
2 ,
526
557
2 ,
558
+ false ,
527
559
) ;
528
560
let iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
529
561
let mut tile_states = iter. map ( |ctx| ctx. ts ) . collect :: < Vec < _ > > ( ) ;
@@ -588,6 +620,7 @@ pub mod test {
588
620
fi. config . frame_rate ( ) ,
589
621
2 ,
590
622
2 ,
623
+ false ,
591
624
) ;
592
625
let iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
593
626
let mut tile_states = iter. map ( |ctx| ctx. ts ) . collect :: < Vec < _ > > ( ) ;
@@ -628,6 +661,7 @@ pub mod test {
628
661
fi. config . frame_rate ( ) ,
629
662
1 ,
630
663
1 ,
664
+ false ,
631
665
) ;
632
666
let iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
633
667
let mut tile_states = iter. map ( |ctx| ctx. ts ) . collect :: < Vec < _ > > ( ) ;
@@ -690,6 +724,7 @@ pub mod test {
690
724
fi. config . frame_rate ( ) ,
691
725
2 ,
692
726
2 ,
727
+ false ,
693
728
) ;
694
729
let iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
695
730
let mut tile_states = iter. map ( |ctx| ctx. ts ) . collect :: < Vec < _ > > ( ) ;
@@ -734,6 +769,7 @@ pub mod test {
734
769
fi. config . frame_rate ( ) ,
735
770
2 ,
736
771
2 ,
772
+ false ,
737
773
) ;
738
774
let iter = ti. tile_iter_mut ( & mut fs, & mut fb) ;
739
775
let mut tbs = iter. map ( |ctx| ctx. tb ) . collect :: < Vec < _ > > ( ) ;
0 commit comments