@@ -198,8 +198,8 @@ static void intra_filter_reference(
198
198
refs -> filtered_initialized = true;
199
199
}
200
200
201
- const int_fast8_t ref_width = 2 * (1 << log2_width ) + 1 ;
202
- const int_fast8_t ref_height = 2 * (1 << log2_height ) + 1 ;
201
+ const int_fast16_t ref_width = 2 * (1 << ( log2_width ) ) + 1 ;
202
+ const int_fast16_t ref_height = 2 * (1 << ( log2_height ) ) + 1 ;
203
203
uvg_intra_ref * ref = & refs -> ref ;
204
204
uvg_intra_ref * filtered_ref = & refs -> filtered_ref ;
205
205
@@ -208,15 +208,15 @@ static void intra_filter_reference(
208
208
filtered_ref -> top [0 ] = filtered_ref -> left [0 ];
209
209
210
210
// Top to bottom
211
- for (int_fast8_t y = 1 ; y < ref_height - 1 ; ++ y ) {
211
+ for (int_fast16_t y = 1 ; y < ref_height - 1 ; ++ y ) {
212
212
uvg_pixel * p = & ref -> left [y ];
213
213
filtered_ref -> left [y ] = (p [-1 ] + 2 * p [0 ] + p [1 ] + 2 ) >> 2 ;
214
214
}
215
215
// Bottom left (not filtered)
216
216
filtered_ref -> left [ref_height - 1 ] = ref -> left [ref_height - 1 ];
217
217
218
218
// Left to right
219
- for (int_fast8_t x = 1 ; x < ref_width - 1 ; ++ x ) {
219
+ for (int_fast16_t x = 1 ; x < ref_width - 1 ; ++ x ) {
220
220
uvg_pixel * p = & ref -> top [x ];
221
221
filtered_ref -> top [x ] = (p [-1 ] + 2 * p [0 ] + p [1 ] + 2 ) >> 2 ;
222
222
}
@@ -712,7 +712,16 @@ static void intra_predict_regular(
712
712
}
713
713
714
714
if (used_ref == & refs -> filtered_ref && !refs -> filtered_initialized ) {
715
- intra_filter_reference (log2_width , log2_height , refs );
715
+ int temp_log2_width = log2_width ;
716
+ int temp_log2_height = log2_height ;
717
+ if (color == COLOR_Y && isp_mode == ISP_MODE_NO_ISP ) {
718
+ temp_log2_width = cur_cu -> log2_width ;
719
+ temp_log2_height = cur_cu -> log2_height ;
720
+ } else if (color != COLOR_Y ) {
721
+ temp_log2_width = cur_cu -> log2_chroma_width ;
722
+ temp_log2_height = cur_cu -> log2_chroma_height ;
723
+ }
724
+ intra_filter_reference (temp_log2_width , temp_log2_height , refs );
716
725
}
717
726
718
727
if (mode == 0 ) {
@@ -797,7 +806,7 @@ void uvg_intra_build_reference_any(
797
806
// Init pointers to LCUs reconstruction buffers, such that index 0 refers to block coordinate 0.
798
807
const uvg_pixel * left_ref ;
799
808
bool extra_ref = false;
800
- // On the left LCU edge, if left neighboring LCU is available,
809
+ // On the left LCU edge, if left neighboring LCU is available,
801
810
// left_ref needs to point to correct extra reference line if MRL is used.
802
811
if (luma_px -> x > 0 && lcu_px .x == 0 && multi_ref_index != 0 ) {
803
812
left_ref = & extra_ref_lines [multi_ref_index * 128 ];
@@ -836,7 +845,7 @@ void uvg_intra_build_reference_any(
836
845
837
846
const int log2_ratio = log2_width - log2_height ;
838
847
int s = MAX (0 , - log2_ratio );
839
- int mrl_extension = (multi_ref_index << s ) + 3 ;
848
+ int mrl_extension = (multi_ref_index << s ) + ( height << s ) + 2 ;
840
849
// Generate left reference.
841
850
if (luma_px -> x > 0 ) {
842
851
// Get the number of reference pixels based on the PU coordinate within the LCU.
@@ -870,15 +879,17 @@ void uvg_intra_build_reference_any(
870
879
871
880
// If first isp split, take samples as if it were normal square block
872
881
int tmp_h = is_first_isp_block ? cu_height * 2 : (isp_mode ? cu_height + height : height * 2 );
873
- for (int i = px_available_left ; i < tmp_h + mrl_extension ; ++ i ) {
882
+ int total_height = MIN (tmp_h + mrl_extension , INTRA_REF_LENGTH );
883
+ for (int i = px_available_left ; i < total_height ; ++ i ) {
874
884
out_left_ref [i + 1 + multi_ref_index ] = nearest_pixel ;
875
885
}
876
886
} else {
877
887
// If we are on the left edge, extend the first pixel of the top row.
878
888
uvg_pixel nearest_pixel = luma_px -> y > 0 ? top_border [0 ] : dc_val ;
879
889
// If first isp split, take samples as if it were normal square block
880
890
int tmp_h = is_first_isp_block ? cu_height * 2 : (isp_mode ? cu_height + height : height * 2 );
881
- for (int i = 0 ; i < tmp_h + mrl_extension ; i ++ ) {
891
+ int total_height = MIN (tmp_h + mrl_extension , INTRA_REF_LENGTH );
892
+ for (int i = 0 ; i < total_height ; i ++ ) {
882
893
// Reserve space for top left reference
883
894
out_left_ref [i + 1 + multi_ref_index ] = nearest_pixel ;
884
895
}
@@ -901,11 +912,11 @@ void uvg_intra_build_reference_any(
901
912
// LCU left border case
902
913
uvg_pixel * top_left_corner = & extra_ref_lines [multi_ref_index * 128 ];
903
914
switch (multi_ref_index ) {
904
- case 0 :
915
+ case 0 :
905
916
out_left_ref [0 ] = left_border [(-1 ) * left_stride ];
906
917
out_top_ref [0 ] = top_left_corner [MAX_REF_LINE_IDX - 1 ];
907
918
break ;
908
- case 1 :
919
+ case 1 :
909
920
for (int i = 0 ; i <= 1 ; ++ i ) {
910
921
out_left_ref [i ] = left_border [(i - 1 - 1 ) * left_stride ];
911
922
out_top_ref [i ] = top_left_corner [(128 * - i ) + MAX_REF_LINE_IDX - 1 - 1 ];
@@ -1002,7 +1013,7 @@ void uvg_intra_build_reference_any(
1002
1013
// Generate top reference.
1003
1014
int px_available_top ;
1004
1015
s = MAX (0 , log2_ratio );
1005
- mrl_extension = (multi_ref_index << s ) + 3 ;
1016
+ mrl_extension = (multi_ref_index << s ) + ( width << s ) + 2 ;
1006
1017
if (luma_px -> y > 0 ) {
1007
1018
// Get the number of reference pixels based on the PU coordinate within the LCU.
1008
1019
if (isp_mode && !is_first_isp_block && !is_chroma ) {
@@ -1018,7 +1029,7 @@ void uvg_intra_build_reference_any(
1018
1029
const int num_cus = uvg_count_available_edge_cus (cu_loc , lcu , false);
1019
1030
px_available_top = !is_chroma ? num_cus * 4 : num_cus * 2 ;
1020
1031
}
1021
-
1032
+
1022
1033
// Limit the number of available pixels based on block size and dimensions
1023
1034
// of the picture.
1024
1035
px_available_top = MIN (px_available_top , cu_width + pu_loc -> width );
@@ -1033,7 +1044,8 @@ void uvg_intra_build_reference_any(
1033
1044
1034
1045
// If first isp split, take samples as if it were normal square block
1035
1046
int tmp_w = is_first_isp_block ? cu_width * 2 : (isp_mode ? cu_width + width : width * 2 );
1036
- for (int i = px_available_top ; i < tmp_w + mrl_extension ; ++ i ) {
1047
+ int total_width = MIN (tmp_w + mrl_extension , INTRA_REF_LENGTH );
1048
+ for (int i = px_available_top ; i < total_width ; ++ i ) {
1037
1049
out_top_ref [i + 1 + multi_ref_index ] = nearest_pixel ;
1038
1050
}
1039
1051
} else {
@@ -1042,7 +1054,8 @@ void uvg_intra_build_reference_any(
1042
1054
1043
1055
// If first isp split, take samples as if it were normal square block
1044
1056
int tmp_w = is_first_isp_block ? cu_width * 2 : (isp_mode ? cu_width + width : width * 2 );
1045
- for (int i = 0 ; i < tmp_w + mrl_extension ; i ++ ) {
1057
+ int total_width = MIN (tmp_w + mrl_extension , INTRA_REF_LENGTH );
1058
+ for (int i = 0 ; i < total_width ; i ++ ) {
1046
1059
out_top_ref [i + 1 ] = nearest_pixel ;
1047
1060
}
1048
1061
}
@@ -1266,9 +1279,10 @@ void uvg_intra_build_reference_inner(
1266
1279
// If first isp split, take samples as if it were normal square block
1267
1280
const int log2_ratio = log2_width - log2_height ;
1268
1281
int s = MAX (0 , - log2_ratio );
1269
- int mrl_extension = (multi_ref_index << s ) + 3 ;
1282
+ int mrl_extension = (( multi_ref_index + 0 ) << s ) + ( height << s ) + 2 ;
1270
1283
int tmp_h = is_first_isp_block ? cu_height * 2 : (isp_mode ? cu_height + height : height * 2 );
1271
- for (; i < tmp_h + mrl_extension ; i += 4 ) {
1284
+ int total_height = MIN (tmp_h + mrl_extension , INTRA_REF_LENGTH - 2 );
1285
+ for (; i < total_height ; i += 4 ) {
1272
1286
out_left_ref [i + 1 ] = nearest_pixel ;
1273
1287
out_left_ref [i + 2 ] = nearest_pixel ;
1274
1288
out_left_ref [i + 3 ] = nearest_pixel ;
@@ -1314,9 +1328,10 @@ void uvg_intra_build_reference_inner(
1314
1328
1315
1329
// If first isp split, take samples as if it were normal square block
1316
1330
s = MAX (0 , - log2_ratio );
1317
- mrl_extension = (multi_ref_index << s ) + 3 ;
1331
+ mrl_extension = (( multi_ref_index + 0 ) << s ) + ( width << s ) + 2 ;
1318
1332
int tmp_w = is_first_isp_block ? cu_width * 2 : (isp_mode ? cu_width + width : width * 2 );
1319
- for (; i < tmp_w + mrl_extension ; i += 4 ) {
1333
+ int total_width = MIN (tmp_w + mrl_extension , INTRA_REF_LENGTH - 2 );
1334
+ for (; i < total_width ; i += 4 ) {
1320
1335
out_top_ref [i + 1 + multi_ref_index ] = nearest_pixel ;
1321
1336
out_top_ref [i + 2 + multi_ref_index ] = nearest_pixel ;
1322
1337
out_top_ref [i + 3 + multi_ref_index ] = nearest_pixel ;
0 commit comments