| @@ -482,98 +482,48 @@ static int ciip_derive_intra_weight(const VVCLocalContext *lc, const int x0, con · 481 unmodified lines |
| 482 | 482 | return w; |
| 483 | 483 | } |
| 484 | 484 | |
| 485 | | −static void pred_regular_luma(VVCLocalContext *lc, const int hf_idx, const int vf_idx, const MvField *mv, |
| 486 | | − const int x0, const int y0, const int sbw, const int sbh, const MvField *orig_mv, const int sb_bdof_flag) |
| 485 | +static void pred_regular(VVCLocalContext *lc, const MvField *mvf, const MvField *orig_mvf, |
| 486 | + const int x0, const int y0, const int sbw, const int sbh, const int sb_bdof_flag, const int c_start) |
| 487 | 487 | { |
| 488 | | − const SliceContext *sc = lc->sc; |
| 489 | | − const VVCFrameContext *fc = lc->fc; |
| 490 | | − const int ciip_flag = lc->cu->ciip_flag; |
| 491 | | − uint8_t *dst = POS(0, x0, y0); |
| 492 | | − const ptrdiff_t dst_stride = fc->frame->linesize[0]; |
| 493 | | − uint8_t *inter = ciip_flag ? (uint8_t *)lc->ciip_tmp1 : dst; |
| 494 | | − const ptrdiff_t inter_stride = ciip_flag ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride; |
| 495 | | − VVCFrame *ref[2]; |
| 496 | | − |
| 497 | | − if (pred_get_refs(lc, ref, mv) < 0) |
| 498 | | − return; |
| 499 | | − |
| 500 | | − if (mv->pred_flag != PF_BI) { |
| 501 | | − const int lx = mv->pred_flag - PF_L0; |
| 502 | | − mc_uni(lc, inter, inter_stride, ref[lx]->frame, mv, |
| 503 | | − x0, y0, sbw, sbh, LUMA, hf_idx, vf_idx); |
| 504 | | − } else { |
| 505 | | − mc_bi(lc, inter, inter_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv, |
| 506 | | − x0, y0, sbw, sbh, LUMA, sb_bdof_flag, hf_idx, vf_idx); |
| 507 | | − } |
| 508 | | − |
| 509 | | − if (ciip_flag) { |
| 510 | | − const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh); |
| 511 | | − fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 0); |
| 512 | | − if (sc->sh.r->sh_lmcs_used_flag) |
| 513 | | − fc->vvcdsp.lmcs.filter(inter, inter_stride, sbw, sbh, &fc->ps.lmcs.fwd_lut); |
| 514 | | − fc->vvcdsp.inter.put_ciip(dst, dst_stride, sbw, sbh, inter, inter_stride, intra_weight); |
| 515 | | − |
| 516 | | − } |
| 517 | | −} |
| 518 | | − |
| 519 | | −static void pred_regular_chroma(VVCLocalContext *lc, const MvField *mv, |
| 520 | | − const int x0, const int y0, const int sbw, const int sbh, const MvField *orig_mv, const int dmvr_flag) |
| 521 | | −{ |
| 522 | | − const VVCFrameContext *fc = lc->fc; |
| 523 | | − const int hs = fc->ps.sps->hshift[1]; |
| 524 | | − const int vs = fc->ps.sps->vshift[1]; |
| 525 | | − const int x0_c = x0 >> hs; |
| 526 | | − const int y0_c = y0 >> vs; |
| 527 | | − const int w_c = sbw >> hs; |
| 528 | | − const int h_c = sbh >> vs; |
| 529 | | − const int do_ciip = lc->cu->ciip_flag && (w_c > 2); |
| 530 | | − |
| 531 | | − uint8_t* dst1 = POS(1, x0, y0); |
| 532 | | − uint8_t* dst2 = POS(2, x0, y0); |
| 533 | | − const ptrdiff_t dst1_stride = fc->frame->linesize[1]; |
| 534 | | − const ptrdiff_t dst2_stride = fc->frame->linesize[2]; |
| 535 | | − |
| 536 | | − uint8_t *inter1 = do_ciip ? (uint8_t *)lc->ciip_tmp1 : dst1; |
| 537 | | − const ptrdiff_t inter1_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst1_stride; |
| 538 | | − |
| 539 | | − uint8_t *inter2 = do_ciip ? (uint8_t *)lc->ciip_tmp2 : dst2; |
| 540 | | − const ptrdiff_t inter2_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst2_stride; |
| 541 | | − |
| 542 | | − //fix me |
| 543 | | − const int hf_idx = 0; |
| 544 | | − const int vf_idx = 0; |
| 488 | + const VVCFrameContext *fc = lc->fc; |
| 489 | + const int c_end = fc->ps.sps->r->sps_chroma_format_idc ? CR : LUMA; |
| 545 | 490 | VVCFrame *ref[2]; |
| 546 | 491 | |
| 547 | | − if (pred_get_refs(lc, ref, mv) < 0) |
| 492 | + if (pred_get_refs(lc, ref, mvf) < 0) |
| 548 | 493 | return; |
| 549 | 494 | |
| 550 | | − if (mv->pred_flag != PF_BI) { |
| 551 | | − const int lx = mv->pred_flag - PF_L0; |
| 552 | | − if (!ref[lx]) |
| 553 | | − return; |
| 554 | | − |
| 555 | | − mc_uni(lc, inter1, inter1_stride, ref[lx]->frame, mv, |
| 556 | | − x0_c, y0_c, w_c, h_c, CB, hf_idx, vf_idx); |
| 557 | | − mc_uni(lc, inter2, inter2_stride, ref[lx]->frame, mv, |
| 558 | | − x0_c, y0_c, w_c, h_c, CR, hf_idx, vf_idx); |
| 559 | | − } else { |
| 560 | | − if (!ref[0] || !ref[1]) |
| 561 | | − return; |
| 562 | | − |
| 563 | | − mc_bi(lc, inter1, inter1_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv, |
| 564 | | − x0_c, y0_c, w_c, h_c, CB, 0, hf_idx, vf_idx); |
| 565 | | − |
| 566 | | − mc_bi(lc, inter2, inter2_stride, ref[0]->frame, ref[1]->frame, mv, orig_mv, |
| 567 | | − x0_c, y0_c, w_c, h_c, CR, 0, hf_idx, vf_idx); |
| 568 | | − |
| 569 | | − } |
| 570 | | − if (do_ciip) { |
| 571 | | − const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh); |
| 572 | | − fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 1); |
| 573 | | − fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, 2); |
| 574 | | − fc->vvcdsp.inter.put_ciip(dst1, dst1_stride, w_c, h_c, inter1, inter1_stride, intra_weight); |
| 575 | | − fc->vvcdsp.inter.put_ciip(dst2, dst2_stride, w_c, h_c, inter2, inter2_stride, intra_weight); |
| 576 | | − |
| 495 | + for (int c_idx = c_start; c_idx <= c_end; c_idx++) { |
| 496 | + uint8_t *dst = POS(c_idx, x0, y0); |
| 497 | + const ptrdiff_t dst_stride = fc->frame->linesize[c_idx]; |
| 498 | + const int hs = fc->ps.sps->hshift[c_idx]; |
| 499 | + const int vs = fc->ps.sps->vshift[c_idx]; |
| 500 | + const int x = x0 >> hs; |
| 501 | + const int y = y0 >> vs; |
| 502 | + const int w = sbw >> hs; |
| 503 | + const int h = sbh >> vs; |
| 504 | + const int is_luma = !c_idx; |
| 505 | + const int do_ciip = lc->cu->ciip_flag && (is_luma || (w > 2)); |
| 506 | + uint8_t *inter = do_ciip ? (uint8_t *)lc->ciip_tmp : dst; |
| 507 | + const ptrdiff_t inter_stride = do_ciip ? (MAX_PB_SIZE * sizeof(uint16_t)) : dst_stride; |
| 508 | + const int hf_idx = is_luma ? lc->cu->pu.mi.hpel_if_idx : 0; |
| 509 | + const int vf_idx = is_luma ? lc->cu->pu.mi.hpel_if_idx : 0; |
| 510 | + const int do_bdof = is_luma && sb_bdof_flag; |
| 511 | + |
| 512 | + if (mvf->pred_flag != PF_BI) { |
| 513 | + const int lx = mvf->pred_flag - PF_L0; |
| 514 | + mc_uni(lc, inter, inter_stride, ref[lx]->frame, mvf, |
| 515 | + x, y, w, h, c_idx, hf_idx, vf_idx); |
| 516 | + } else { |
| 517 | + mc_bi(lc, inter, inter_stride, ref[0]->frame, ref[1]->frame, mvf, orig_mvf, |
| 518 | + x, y, w, h, c_idx, do_bdof, hf_idx, vf_idx); |
| 519 | + } |
| 520 | + if (do_ciip) { |
| 521 | + const int intra_weight = ciip_derive_intra_weight(lc, x0, y0, sbw, sbh); |
| 522 | + fc->vvcdsp.intra.intra_pred(lc, x0, y0, sbw, sbh, c_idx); |
| 523 | + if (!c_idx && lc->sc->sh.r->sh_lmcs_used_flag) |
| 524 | + fc->vvcdsp.lmcs.filter(inter, inter_stride, w, h, &fc->ps.lmcs.fwd_lut); |
| 525 | + fc->vvcdsp.inter.put_ciip(dst, dst_stride, w, h, inter, inter_stride, intra_weight); |
| 526 | + } |
| 577 | 527 | } |
| 578 | 528 | } |
| 579 | 529 | |
| @@ -720,7 +670,6 @@ static void derive_sb_mv(VVCLocalContext *lc, MvField *mv, MvField *orig_mv, int · 140 unmodified lines |
| 720 | 670 | |
| 721 | 671 | static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) |
| 722 | 672 | { |
| 723 | | − const VVCFrameContext *fc = lc->fc; |
| 724 | 673 | const CodingUnit *cu = lc->cu; |
| 725 | 674 | PredictionUnit *pu = &lc->cu->pu; |
| 726 | 675 | const MotionInfo *mi = &pu->mi; |
| @@ -742,9 +691,7 @@ static void pred_regular_blk(VVCLocalContext *lc, const int skip_ciip) · 15 unmodified lines |
| 742 | 691 | ff_vvc_set_neighbour_available(lc, x0, y0, sbw, sbh); |
| 743 | 692 | |
| 744 | 693 | derive_sb_mv(lc, &mv, &orig_mv, &sb_bdof_flag, x0, y0, sbw, sbh); |
| 745 | | − pred_regular_luma(lc, mi->hpel_if_idx, mi->hpel_if_idx, &mv, x0, y0, sbw, sbh, &orig_mv, sb_bdof_flag); |
| 746 | | − if (fc->ps.sps->r->sps_chroma_format_idc) |
| 747 | | − pred_regular_chroma(lc, &mv, x0, y0, sbw, sbh, &orig_mv, pu->dmvr_flag); |
| 694 | + pred_regular(lc, &mv, &orig_mv, x0, y0, sbw, sbh, sb_bdof_flag, LUMA); |
| 748 | 695 | } |
| 749 | 696 | } |
| 750 | 697 | } |
| @@ -804,9 +751,9 @@ static void pred_affine_blk(VVCLocalContext *lc) · 53 unmodified lines |
| 804 | 751 | if (fc->ps.sps->r->sps_chroma_format_idc) { |
| 805 | 752 | if (!av_mod_uintp2(sby, vs) && !av_mod_uintp2(sbx, hs)) { |
| 806 | 753 | MvField mvc; |
| 807 | | − derive_affine_mvc(&mvc, fc, mv, x, y, sbw, sbh); |
| 808 | | − pred_regular_chroma(lc, &mvc, x, y, sbw<<hs, sbh<<vs, NULL, 0); |
| 809 | 754 | |
| 755 | + derive_affine_mvc(&mvc, fc, mv, x, y, sbw, sbh); |
| 756 | + pred_regular(lc, &mvc, NULL, x, y, sbw << hs, sbh << vs, 0, CB); |
| 810 | 757 | } |
| 811 | 758 | } |
| 812 | 759 | |