mirror of https://git.ffmpeg.org/ffmpeg.git
avcodec/vvcdec: implement update_hmvp for IBC
Signed-off-by: Wu Jianhua <toqsxw@outlook.com> Signed-off-by: Nuo Mi <nuomi2021@gmail.com>
This commit is contained in:
parent
5a388d2cc6
commit
09946dc40b
|
@ -1717,10 +1717,15 @@ static int inter_data(VVCLocalContext *lc)
|
||||||
} else {
|
} else {
|
||||||
ret = mvp_data(lc);
|
ret = mvp_data(lc);
|
||||||
}
|
}
|
||||||
if (!pu->merge_gpm_flag && !pu->inter_affine_flag && !pu->merge_subblock_flag) {
|
|
||||||
|
if (cu->pred_mode == MODE_IBC)
|
||||||
|
{
|
||||||
|
ff_vvc_update_hmvp(lc, mi);
|
||||||
|
} else if (!pu->merge_gpm_flag && !pu->inter_affine_flag && !pu->merge_subblock_flag) {
|
||||||
refine_regular_subblock(lc);
|
refine_regular_subblock(lc);
|
||||||
ff_vvc_update_hmvp(lc, mi);
|
ff_vvc_update_hmvp(lc, mi);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pu->dmvr_flag)
|
if (!pu->dmvr_flag)
|
||||||
fill_dmvr_info(lc->fc, cu->x0, cu->y0, cu->cb_width, cu->cb_height);
|
fill_dmvr_info(lc->fc, cu->x0, cu->y0, cu->cb_width, cu->cb_height);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -2394,8 +2399,8 @@ int ff_vvc_coding_tree_unit(VVCLocalContext *lc,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (rx == pps->ctb_to_col_bd[rx]) {
|
if (rx == pps->ctb_to_col_bd[rx]) {
|
||||||
//fix me for ibc
|
|
||||||
ep->num_hmvp = 0;
|
ep->num_hmvp = 0;
|
||||||
|
ep->num_hmvp_ibc = 0;
|
||||||
ep->is_first_qg = ry == pps->ctb_to_row_bd[ry] || !ctu_idx;
|
ep->is_first_qg = ry == pps->ctb_to_row_bd[ry] || !ctu_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -357,8 +357,11 @@ typedef struct EntryPoint {
|
||||||
int ctu_end;
|
int ctu_end;
|
||||||
|
|
||||||
uint8_t is_first_qg; // first quantization group
|
uint8_t is_first_qg; // first quantization group
|
||||||
|
|
||||||
MvField hmvp[MAX_NUM_HMVP_CANDS]; ///< HmvpCandList
|
MvField hmvp[MAX_NUM_HMVP_CANDS]; ///< HmvpCandList
|
||||||
int num_hmvp; ///< NumHmvpCand
|
int num_hmvp; ///< NumHmvpCand
|
||||||
|
MvField hmvp_ibc[MAX_NUM_HMVP_CANDS]; ///< HmvpIbcCandList
|
||||||
|
int num_hmvp_ibc; ///< NumHmvpIbcCand
|
||||||
} EntryPoint;
|
} EntryPoint;
|
||||||
|
|
||||||
typedef struct VVCLocalContext {
|
typedef struct VVCLocalContext {
|
||||||
|
|
|
@ -1758,34 +1758,49 @@ static av_always_inline int is_greater_mer(const VVCFrameContext *fc, const int
|
||||||
y0_br >> plevel > y0 >> plevel;
|
y0_br >> plevel > y0 >> plevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void update_hmvp(MvField *hmvp, int *num_hmvp, const MvField *mvf,
|
||||||
|
int (*compare)(const MvField *n, const MvField *o))
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < *num_hmvp; i++) {
|
||||||
|
if (compare(mvf, hmvp + i)) {
|
||||||
|
(*num_hmvp)--;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (i == MAX_NUM_HMVP_CANDS) {
|
||||||
|
(*num_hmvp)--;
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
memmove(hmvp + i, hmvp + i + 1, (*num_hmvp - i) * sizeof(MvField));
|
||||||
|
hmvp[(*num_hmvp)++] = *mvf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int compare_l0_mv(const MvField *n, const MvField *o)
|
||||||
|
{
|
||||||
|
return IS_SAME_MV(&n->mv[L0], &o->mv[L0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//8.6.2.4 Derivation process for IBC history-based block vector candidates
|
||||||
//8.5.2.16 Updating process for the history-based motion vector predictor candidate list
|
//8.5.2.16 Updating process for the history-based motion vector predictor candidate list
|
||||||
void ff_vvc_update_hmvp(VVCLocalContext *lc, const MotionInfo *mi)
|
void ff_vvc_update_hmvp(VVCLocalContext *lc, const MotionInfo *mi)
|
||||||
{
|
{
|
||||||
const VVCFrameContext *fc = lc->fc;
|
const VVCFrameContext *fc = lc->fc;
|
||||||
const CodingUnit *cu = lc->cu;
|
const CodingUnit *cu = lc->cu;
|
||||||
const int min_pu_width = fc->ps.pps->min_pu_width;
|
const int min_pu_width = fc->ps.pps->min_pu_width;
|
||||||
const MvField* tab_mvf = fc->tab.mvf;
|
const MvField *tab_mvf = fc->tab.mvf;
|
||||||
EntryPoint* ep = lc->ep;
|
EntryPoint *ep = lc->ep;
|
||||||
const MvField *mvf;
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (!is_greater_mer(fc, cu->x0, cu->y0, cu->x0 + cu->cb_width, cu->y0 + cu->cb_height))
|
if (cu->pred_mode == MODE_IBC) {
|
||||||
return;
|
if (cu->cb_width * cu->cb_height <= 16)
|
||||||
mvf = &TAB_MVF(cu->x0, cu->y0);
|
return;
|
||||||
|
update_hmvp(ep->hmvp_ibc, &ep->num_hmvp_ibc, &TAB_MVF(cu->x0, cu->y0), compare_l0_mv);
|
||||||
for (i = 0; i < ep->num_hmvp; i++) {
|
} else {
|
||||||
if (compare_mv_ref_idx(mvf, ep->hmvp + i)) {
|
if (!is_greater_mer(fc, cu->x0, cu->y0, cu->x0 + cu->cb_width, cu->y0 + cu->cb_height))
|
||||||
ep->num_hmvp--;
|
return;
|
||||||
break;
|
update_hmvp(ep->hmvp, &ep->num_hmvp, &TAB_MVF(cu->x0, cu->y0), compare_mv_ref_idx);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (i == MAX_NUM_HMVP_CANDS) {
|
|
||||||
ep->num_hmvp--;
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
memmove(ep->hmvp + i, ep->hmvp + i + 1, (ep->num_hmvp - i) * sizeof(MvField));
|
|
||||||
ep->hmvp[ep->num_hmvp++] = *mvf;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MvField* ff_vvc_get_mvf(const VVCFrameContext *fc, const int x0, const int y0)
|
MvField* ff_vvc_get_mvf(const VVCFrameContext *fc, const int x0, const int y0)
|
||||||
|
|
Loading…
Reference in New Issue