| @@ -164,28 +164,6 @@ static void derive_transform_type(const VVCFrameContext *fc, const VVCLocalConte · 163 unmodified lines |
| 164 | 164 | *trv = mts_to_trv[cu->mts_idx]; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | | −static void add_residual_for_joint_coding_chroma(VVCLocalContext *lc, |
| 168 | | − const TransformUnit *tu, TransformBlock *tb, const int chroma_scale) |
| 169 | | −{ |
| 170 | | − const VVCFrameContext *fc = lc->fc; |
| 171 | | − const CodingUnit *cu = lc->cu; |
| 172 | | − const int c_sign = 1 - 2 * fc->ps.ph.r->ph_joint_cbcr_sign_flag; |
| 173 | | − const int shift = tu->coded_flag[1] ^ tu->coded_flag[2]; |
| 174 | | − const int c_idx = 1 + tu->coded_flag[1]; |
| 175 | | − const ptrdiff_t stride = fc->frame->linesize[c_idx]; |
| 176 | | − const int hs = fc->ps.sps->hshift[c_idx]; |
| 177 | | − const int vs = fc->ps.sps->vshift[c_idx]; |
| 178 | | − uint8_t *dst = &fc->frame->data[c_idx][(tb->y0 >> vs) * stride + |
| 179 | | − ((tb->x0 >> hs) << fc->ps.sps->pixel_shift)]; |
| 180 | | − if (chroma_scale) { |
| 181 | | − fc->vvcdsp.itx.pred_residual_joint(tb->coeffs, tb->coeffs, tb->tb_width, tb->tb_height, c_sign, shift); |
| 182 | | − fc->vvcdsp.intra.lmcs_scale_chroma(lc, tb->coeffs, tb->coeffs, tb->tb_width, tb->tb_height, cu->x0, cu->y0); |
| 183 | | − fc->vvcdsp.itx.add_residual(dst, tb->coeffs, tb->tb_width, tb->tb_height, stride); |
| 184 | | − } else { |
| 185 | | − fc->vvcdsp.itx.add_residual_joint(dst, tb->coeffs, tb->tb_width, tb->tb_height, stride, c_sign, shift); |
| 186 | | − } |
| 187 | | −} |
| 188 | | − |
| 189 | 167 | static int add_reconstructed_area(VVCLocalContext *lc, const int ch_type, const int x0, const int y0, const int w, const int h) |
| 190 | 168 | { |
| 191 | 169 | const VVCSPS *sps = lc->fc->ps.sps; |
| @@ -531,7 +509,7 @@ static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int tu_idx, · 339 unmodified lines |
| 531 | 509 | const ptrdiff_t stride = fc->frame->linesize[c_idx]; |
| 532 | 510 | const int hs = sps->hshift[c_idx]; |
| 533 | 511 | const int vs = sps->vshift[c_idx]; |
| 534 | | − uint8_t *dst = &fc->frame->data[c_idx][(tb->y0 >> vs) * stride + ((tb->x0 >> hs) << ps)]; |
| 512 | + const int has_jcbcr = tu->joint_cbcr_residual_flag && c_idx; |
| 535 | 513 | |
| 536 | 514 | if (cu->bdpcm_flag[tb->c_idx]) |
| 537 | 515 | transform_bdpcm(tb, lc, cu); |
| @@ -548,14 +526,25 @@ static void itransform(VVCLocalContext *lc, TransformUnit *tu, const int tu_idx, · 10 unmodified lines |
| 548 | 526 | itx_1d(fc, tb, trh, trv); |
| 549 | 527 | } |
| 550 | 528 | |
| 551 | | − if (chroma_scale) |
| 552 | | − fc->vvcdsp.intra.lmcs_scale_chroma(lc, temp, tb->coeffs, w, h, cu->x0, cu->y0); |
| 553 | | − // TODO: Address performance issue here by combining transform, lmcs_scale_chroma, and add_residual into one function. |
| 554 | | − // Complete this task before implementing ASM code. |
| 555 | | − fc->vvcdsp.itx.add_residual(dst, chroma_scale ? temp : tb->coeffs, w, h, stride); |
| 556 | | − |
| 557 | | − if (tu->joint_cbcr_residual_flag && tb->c_idx) |
| 558 | | − add_residual_for_joint_coding_chroma(lc, tu, tb, chroma_scale); |
| 529 | + for (int j = 0; j < 1 + has_jcbcr; j++) { |
| 530 | + const bool is_jcbcr = j > 0; |
| 531 | + const int jcbcr_idx = CB + tu->coded_flag[CB]; |
| 532 | + TransformBlock *jcbcr = &tu->tbs[jcbcr_idx - tu->tbs[0].c_idx]; |
| 533 | + const int c = is_jcbcr ? jcbcr_idx : tb->c_idx; |
| 534 | + int *coeffs = is_jcbcr ? jcbcr->coeffs : tb->coeffs; |
| 535 | + uint8_t *dst = &fc->frame->data[c][(tb->y0 >> vs) * stride + ((tb->x0 >> hs) << ps)]; |
| 536 | + |
| 537 | + if (!j && has_jcbcr) { |
| 538 | + const int c_sign = 1 - 2 * fc->ps.ph.r->ph_joint_cbcr_sign_flag; |
| 539 | + const int shift = tu->coded_flag[CB] ^ tu->coded_flag[CR]; |
| 540 | + fc->vvcdsp.itx.pred_residual_joint(jcbcr->coeffs, tb->coeffs, tb->tb_width, tb->tb_height, c_sign, shift); |
| 541 | + } |
| 542 | + if (chroma_scale) |
| 543 | + fc->vvcdsp.intra.lmcs_scale_chroma(lc, temp, coeffs, w, h, cu->x0, cu->y0); |
| 544 | + // TODO: Address performance issue here by combining transform, lmcs_scale_chroma, and add_residual into one function. |
| 545 | + // Complete this task before implementing ASM code. |
| 546 | + fc->vvcdsp.itx.add_residual(dst, chroma_scale ? temp : coeffs, w, h, stride); |
| 547 | + } |
| 559 | 548 | } |
| 560 | 549 | } |
| 561 | 550 | } |