| @@ -348,6 +348,83 @@ static int pps_add_ctus(VVCPPS *pps, int *off, const int ctu_x, const int ctu_y, · 347 unmodified lines |
| 348 | 348 | return *off - start; |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | +static void pps_single_slice_picture(VVCPPS *pps, int *off) |
| 352 | +{ |
| 353 | + for (int j = 0; j < pps->r->num_tile_rows; j++) { |
| 354 | + for (int i = 0; i < pps->r->num_tile_columns; i++) { |
| 355 | + pps->num_ctus_in_slice[0] = pps_add_ctus(pps, off, |
| 356 | + pps->col_bd[i], pps->row_bd[j], |
| 357 | + pps->r->col_width_val[i], pps->r->row_height_val[j]); |
| 358 | + } |
| 359 | + } |
| 360 | +} |
| 361 | + |
| 362 | +static void subpic_tiles(int *tile_x, int *tile_y, int *tile_x_end, int *tile_y_end, |
| 363 | + const VVCSPS *sps, const VVCPPS *pps, const int i) |
| 364 | +{ |
| 365 | + const int rx = sps->r->sps_subpic_ctu_top_left_x[i]; |
| 366 | + const int ry = sps->r->sps_subpic_ctu_top_left_y[i]; |
| 367 | + |
| 368 | + *tile_x = *tile_y = 0; |
| 369 | + |
| 370 | + while (pps->col_bd[*tile_x] != rx) |
| 371 | + (*tile_x)++; |
| 372 | + |
| 373 | + while (pps->row_bd[*tile_y] != ry) |
| 374 | + (*tile_y)++; |
| 375 | + |
| 376 | + *tile_x_end = (*tile_x); |
| 377 | + *tile_y_end = (*tile_y); |
| 378 | + |
| 379 | + while (pps->col_bd[*tile_x_end] < rx + sps->r->sps_subpic_width_minus1[i] + 1) |
| 380 | + (*tile_x_end)++; |
| 381 | + |
| 382 | + while (pps->row_bd[*tile_y_end] < ry + sps->r->sps_subpic_height_minus1[i] + 1) |
| 383 | + (*tile_y_end)++; |
| 384 | +} |
| 385 | + |
| 386 | +static void pps_subpic_less_than_one_tile_slice(VVCPPS *pps, const VVCSPS *sps, const int i, const int tx, const int ty, int *off) |
| 387 | +{ |
| 388 | + pps->num_ctus_in_slice[i] = pps_add_ctus(pps, off, |
| 389 | + pps->col_bd[tx], pps->row_bd[ty], |
| 390 | + pps->r->col_width_val[tx], sps->r->sps_subpic_height_minus1[i] + 1); |
| 391 | +} |
| 392 | + |
| 393 | +static void pps_subpic_one_or_more_tiles_slice(VVCPPS *pps, const int tile_x, const int tile_y, const int x_end, const int y_end, const int i, int *off) |
| 394 | +{ |
| 395 | + for (int ty = tile_y; ty < y_end; ty++) { |
| 396 | + for (int tx = tile_x; tx < x_end; tx++) { |
| 397 | + pps->num_ctus_in_slice[i] += pps_add_ctus(pps, off, |
| 398 | + pps->col_bd[tx], pps->row_bd[ty], |
| 399 | + pps->r->col_width_val[tx], pps->r->row_height_val[ty]); |
| 400 | + } |
| 401 | + } |
| 402 | +} |
| 403 | + |
| 404 | +static void pps_subpic_slice(VVCPPS *pps, const VVCSPS *sps, const int i, int *off) |
| 405 | +{ |
| 406 | + int tx, ty, x_end, y_end; |
| 407 | + |
| 408 | + pps->slice_start_offset[i] = *off; |
| 409 | + pps->num_ctus_in_slice[i] = 0; |
| 410 | + |
| 411 | + subpic_tiles(&tx, &ty, &x_end, &y_end, sps, pps, i); |
| 412 | + if (ty + 1 == y_end && sps->r->sps_subpic_height_minus1[i] + 1 < pps->r->row_height_val[ty]) |
| 413 | + pps_subpic_less_than_one_tile_slice(pps, sps, i, tx, ty, off); |
| 414 | + else |
| 415 | + pps_subpic_one_or_more_tiles_slice(pps, tx, ty, x_end, y_end, i, off); |
| 416 | +} |
| 417 | + |
| 418 | +static void pps_single_slice_per_subpic(VVCPPS *pps, const VVCSPS *sps, int *off) |
| 419 | +{ |
| 420 | + if (!sps->r->sps_subpic_info_present_flag) { |
| 421 | + pps_single_slice_picture(pps, off); |
| 422 | + } else { |
| 423 | + for (int i = 0; i < pps->r->pps_num_slices_in_pic_minus1 + 1; i++) |
| 424 | + pps_subpic_slice(pps, sps, i, off); |
| 425 | + } |
| 426 | +} |
| 427 | + |
| 351 | 428 | static int pps_one_tile_slices(VVCPPS *pps, const int tile_idx, int i, int *off) |
| 352 | 429 | { |
| 353 | 430 | const H266RawPPS *r = pps->r; |
| @@ -383,18 +460,22 @@ static void pps_multi_tiles_slice(VVCPPS *pps, const int tile_idx, const int i, · 29 unmodified lines |
| 383 | 460 | } |
| 384 | 461 | } |
| 385 | 462 | |
| 386 | | −static void pps_rect_slice(VVCPPS* pps) |
| 463 | +static void pps_rect_slice(VVCPPS *pps, const VVCSPS *sps) |
| 387 | 464 | { |
| 388 | | − const H266RawPPS* r = pps->r; |
| 465 | + const H266RawPPS *r = pps->r; |
| 389 | 466 | int tile_idx = 0, off = 0; |
| 390 | 467 | |
| 468 | + if (r->pps_single_slice_per_subpic_flag) { |
| 469 | + pps_single_slice_per_subpic(pps, sps, &off); |
| 470 | + return; |
| 471 | + } |
| 472 | + |
| 391 | 473 | for (int i = 0; i < r->pps_num_slices_in_pic_minus1 + 1; i++) { |
| 392 | 474 | if (!r->pps_slice_width_in_tiles_minus1[i] && |
| 393 | 475 | !r->pps_slice_height_in_tiles_minus1[i]) { |
| 394 | 476 | i = pps_one_tile_slices(pps, tile_idx, i, &off); |
| 395 | 477 | } else { |
| 396 | 478 | pps_multi_tiles_slice(pps, tile_idx, i, &off); |
| 397 | | − |
| 398 | 479 | } |
| 399 | 480 | tile_idx = next_tile_idx(tile_idx, i, r); |
| 400 | 481 | } |
| @@ -413,14 +494,14 @@ static void pps_no_rect_slice(VVCPPS* pps) · 12 unmodified lines |
| 413 | 494 | } |
| 414 | 495 | } |
| 415 | 496 | |
| 416 | | −static int pps_slice_map(VVCPPS *pps) |
| 497 | +static int pps_slice_map(VVCPPS *pps, const VVCSPS *sps) |
| 417 | 498 | { |
| 418 | 499 | pps->ctb_addr_in_slice = av_calloc(pps->ctb_count, sizeof(*pps->ctb_addr_in_slice)); |
| 419 | 500 | if (!pps->ctb_addr_in_slice) |
| 420 | 501 | return AVERROR(ENOMEM); |
| 421 | 502 | |
| 422 | 503 | if (pps->r->pps_rect_slice_flag) |
| 423 | | − pps_rect_slice(pps); |
| 504 | + pps_rect_slice(pps, sps); |
| 424 | 505 | else |
| 425 | 506 | pps_no_rect_slice(pps); |
| 426 | 507 | |
| @@ -446,7 +527,7 @@ static int pps_derive(VVCPPS *pps, const VVCSPS *sps) · 19 unmodified lines |
| 446 | 527 | if (ret < 0) |
| 447 | 528 | return ret; |
| 448 | 529 | |
| 449 | | − ret = pps_slice_map(pps); |
| 530 | + ret = pps_slice_map(pps, sps); |
| 450 | 531 | if (ret < 0) |
| 451 | 532 | return ret; |
| 452 | 533 | |