Implement the missing requirements from H.266 (V3) p. 106 on the position and size of subpictures whose dimensions are provided explicitly.
Showing the changes to libavcodec (1 of 1 file). Show all
Unified · Split
| @@ -1061,7 +1061,7 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, · 1060 unmodified lines | |||
| 1061 | unsigned int ctb_log2_size_y, min_cb_log2_size_y, | 1061 | unsigned int ctb_log2_size_y, min_cb_log2_size_y, |
| 1062 | min_qt_log2_size_intra_y, min_qt_log2_size_inter_y, | 1062 | min_qt_log2_size_intra_y, min_qt_log2_size_inter_y, |
| 1063 | ctb_size_y, max_num_merge_cand, tmp_width_val, tmp_height_val; | 1063 | ctb_size_y, max_num_merge_cand, tmp_width_val, tmp_height_val; |
| 1064 | uint8_t qp_bd_offset; | 1064 | uint8_t qp_bd_offset, sub_width_c, sub_height_c; |
| 1065 | 1065 | ||
| 1066 | static const uint8_t h266_sub_width_c[] = { | 1066 | static const uint8_t h266_sub_width_c[] = { |
| 1067 | 1, 2, 2, 1 | 1067 | 1, 2, 2, 1 |
| @@ -1089,6 +1089,9 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, · 21 unmodified lines | |||
| 1089 | 1089 | ||
| 1090 | u(3, sps_max_sublayers_minus1, 0, VVC_MAX_SUBLAYERS - 1); | 1090 | u(3, sps_max_sublayers_minus1, 0, VVC_MAX_SUBLAYERS - 1); |
| 1091 | u(2, sps_chroma_format_idc, 0, 3); | 1091 | u(2, sps_chroma_format_idc, 0, 3); |
| 1092 | sub_width_c = h266_sub_width_c[current->sps_chroma_format_idc]; | ||
| 1093 | sub_height_c = h266_sub_height_c[current->sps_chroma_format_idc]; | ||
| 1094 | |||
| 1092 | u(2, sps_log2_ctu_size_minus5, 0, 3); | 1095 | u(2, sps_log2_ctu_size_minus5, 0, 3); |
| 1093 | ctb_log2_size_y = current->sps_log2_ctu_size_minus5 + 5; | 1096 | ctb_log2_size_y = current->sps_log2_ctu_size_minus5 + 5; |
| 1094 | ctb_size_y = 1 << ctb_log2_size_y; | 1097 | ctb_size_y = 1 << ctb_log2_size_y; |
| @@ -1110,8 +1113,6 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, · 15 unmodified lines | |||
| 1110 | 1113 | ||
| 1111 | flag(sps_conformance_window_flag); | 1114 | flag(sps_conformance_window_flag); |
| 1112 | if (current->sps_conformance_window_flag) { | 1115 | if (current->sps_conformance_window_flag) { |
| 1113 | uint8_t sub_width_c = h266_sub_width_c[current->sps_chroma_format_idc]; | ||
| 1114 | uint8_t sub_height_c = h266_sub_height_c[current->sps_chroma_format_idc]; | ||
| 1115 | uint16_t width = current->sps_pic_width_max_in_luma_samples / sub_width_c; | 1116 | uint16_t width = current->sps_pic_width_max_in_luma_samples / sub_width_c; |
| 1116 | uint16_t height = current->sps_pic_height_max_in_luma_samples / sub_height_c; | 1117 | uint16_t height = current->sps_pic_height_max_in_luma_samples / sub_height_c; |
| 1117 | ue(sps_conf_win_left_offset, 0, width); | 1118 | ue(sps_conf_win_left_offset, 0, width); |
| @@ -1160,19 +1161,37 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, · 42 unmodified lines | |||
| 1160 | } | 1161 | } |
| 1161 | for (i = 1; i <= current->sps_num_subpics_minus1; i++) { | 1162 | for (i = 1; i <= current->sps_num_subpics_minus1; i++) { |
| 1162 | if (!current->sps_subpic_same_size_flag) { | 1163 | if (!current->sps_subpic_same_size_flag) { |
| 1163 | if (current->sps_pic_width_max_in_luma_samples > ctb_size_y) | 1164 | if (current->sps_pic_width_max_in_luma_samples > ctb_size_y) { |
| 1164 | ubs(wlen, sps_subpic_ctu_top_left_x[i], 1, i); | 1165 | const unsigned int win_right_edge = |
| 1165 | else | 1166 | current->sps_pic_width_max_in_luma_samples |
| 1167 | - current->sps_conf_win_right_offset * sub_width_c; | ||
| 1168 | us(wlen, sps_subpic_ctu_top_left_x[i], 0, | ||
| 1169 | AV_CEIL_RSHIFT(win_right_edge, ctb_log2_size_y) - 1, | ||
| 1170 | 1, i); | ||
| 1171 | } else | ||
| 1166 | infer(sps_subpic_ctu_top_left_x[i], 0); | 1172 | infer(sps_subpic_ctu_top_left_x[i], 0); |
| 1167 | if (current->sps_pic_height_max_in_luma_samples > | 1173 | if (current->sps_pic_height_max_in_luma_samples > |
| 1168 | ctb_size_y) | 1174 | ctb_size_y) { |
| 1169 | ubs(hlen, sps_subpic_ctu_top_left_y[i], 1, i); | 1175 | const unsigned int win_bottom_edge = |
| 1170 | else | 1176 | current->sps_pic_height_max_in_luma_samples |
| 1177 | - current->sps_conf_win_bottom_offset * sub_height_c; | ||
| 1178 | us(hlen, sps_subpic_ctu_top_left_y[i], 0, | ||
| 1179 | AV_CEIL_RSHIFT(win_bottom_edge, ctb_log2_size_y) - 1, | ||
| 1180 | 1, i); | ||
| 1181 | } else | ||
| 1171 | infer(sps_subpic_ctu_top_left_y[i], 0); | 1182 | infer(sps_subpic_ctu_top_left_y[i], 0); |
| 1172 | if (i < current->sps_num_subpics_minus1 && | 1183 | if (i < current->sps_num_subpics_minus1 && |
| 1173 | current->sps_pic_width_max_in_luma_samples > | 1184 | current->sps_pic_width_max_in_luma_samples > |
| 1174 | ctb_size_y) { | 1185 | ctb_size_y) { |
| 1175 | ubs(wlen, sps_subpic_width_minus1[i], 1, i); | 1186 | const unsigned int win_left_edge = |
| 1187 | current->sps_conf_win_left_offset * sub_width_c; | ||
| 1188 | const unsigned int win_left_edge_ctus = | ||
| 1189 | AV_CEIL_RSHIFT(win_left_edge, ctb_log2_size_y); | ||
| 1190 | us(wlen, sps_subpic_width_minus1[i], | ||
| 1191 | win_left_edge_ctus > current->sps_subpic_ctu_top_left_x[i] | ||
| 1192 | ? win_left_edge_ctus - current->sps_subpic_ctu_top_left_x[i] | ||
| 1193 | : 0, | ||
| 1194 | MAX_UINT_BITS(wlen), 1, i); | ||
| 1176 | } else { | 1195 | } else { |
| 1177 | infer(sps_subpic_width_minus1[i], | 1196 | infer(sps_subpic_width_minus1[i], |
| 1178 | tmp_width_val - | 1197 | tmp_width_val - |
| @@ -1181,7 +1200,15 @@ static int FUNC(sps)(CodedBitstreamContext *ctx, RWContext *rw, · 2 unmodified lines | |||
| 1181 | if (i < current->sps_num_subpics_minus1 && | 1200 | if (i < current->sps_num_subpics_minus1 && |
| 1182 | current->sps_pic_height_max_in_luma_samples > | 1201 | current->sps_pic_height_max_in_luma_samples > |
| 1183 | ctb_size_y) { | 1202 | ctb_size_y) { |
| 1184 | ubs(hlen, sps_subpic_height_minus1[i], 1, i); | 1203 | const unsigned int win_top_edge = |
| 1204 | current->sps_conf_win_top_offset * sub_height_c; | ||
| 1205 | const unsigned int win_top_edge_ctus = | ||
| 1206 | AV_CEIL_RSHIFT(win_top_edge, ctb_log2_size_y); | ||
| 1207 | us(hlen, sps_subpic_height_minus1[i], | ||
| 1208 | win_top_edge_ctus > current->sps_subpic_ctu_top_left_y[i] | ||
| 1209 | ? win_top_edge_ctus - current->sps_subpic_ctu_top_left_y[i] | ||
| 1210 | : 0, | ||
| 1211 | MAX_UINT_BITS(wlen), 1, i); | ||
| 1185 | } else { | 1212 | } else { |
| 1186 | infer(sps_subpic_height_minus1[i], | 1213 | infer(sps_subpic_height_minus1[i], |
| 1187 | tmp_height_val - | 1214 | tmp_height_val - |