vvcdec: add motion vector decoder

Co-authored-by: Xu Mu <toxumu@outlook.com>
Co-authored-by: Frank Plowman <post@frankplowman.com>
Co-authored-by: Shaun Loo <shaunloo10@gmail.com>
Co-authored-by: Wu Jianhua <toqsxw@outlook.com>
This commit is contained in:
Nuo Mi 2023-12-05 22:45:11 +08:00
parent c1a3d17491
commit 603d0bd171
5 changed files with 1865 additions and 0 deletions

View File

@ -4,5 +4,6 @@ clean::
OBJS-$(CONFIG_VVC_DECODER) += vvc/vvc_cabac.o \
vvc/vvc_ctu.o \
vvc/vvc_data.o \
vvc/vvc_mvs.o \
vvc/vvc_ps.o \
vvc/vvc_refs.o \

View File

@ -20,7 +20,25 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "vvc_cabac.h"
#include "vvc_ctu.h"
#include "vvc_mvs.h"
void ff_vvc_set_neighbour_available(VVCLocalContext *lc,
const int x0, const int y0, const int w, const int h)
{
const int log2_ctb_size = lc->fc->ps.sps->ctb_log2_size_y;
const int x0b = av_mod_uintp2(x0, log2_ctb_size);
const int y0b = av_mod_uintp2(y0, log2_ctb_size);
lc->na.cand_up = (lc->ctb_up_flag || y0b);
lc->na.cand_left = (lc->ctb_left_flag || x0b);
lc->na.cand_up_left = (x0b || y0b) ? lc->na.cand_left && lc->na.cand_up : lc->ctb_up_left_flag;
lc->na.cand_up_right_sap =
(x0b + w == 1 << log2_ctb_size) ? lc->ctb_up_right_flag && !y0b : lc->na.cand_up;
lc->na.cand_up_right = lc->na.cand_up_right_sap && (x0 + w) < lc->end_of_tiles_x;
}
void ff_vvc_ep_init_stat_coeff(EntryPoint *ep,
const int bit_depth, const int persistent_rice_adaptation_enabled_flag)

View File

@ -459,6 +459,8 @@ typedef struct ALFParams {
uint8_t applied[3];
} ALFParams;
//utils
void ff_vvc_set_neighbour_available(VVCLocalContext *lc, int x0, int y0, int w, int h);
void ff_vvc_ep_init_stat_coeff(EntryPoint *ep, int bit_depth, int persistent_rice_adaptation_enabled_flag);
#endif // AVCODEC_VVC_VVC_CTU_H

1798
libavcodec/vvc/vvc_mvs.c Normal file

File diff suppressed because it is too large Load Diff

46
libavcodec/vvc/vvc_mvs.h Normal file
View File

@ -0,0 +1,46 @@
/*
* VVC motion vector decoder
*
* Copyright (C) 2023 Nuo Mi
*
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef AVCODEC_VVC_VVC_MVS_H
#define AVCODEC_VVC_VVC_MVS_H
#include "vvcdec.h"
void ff_vvc_round_mv(Mv *mv, int lshift, int rshift);
void ff_vvc_clip_mv(Mv *mv);
void ff_vvc_mv_scale(Mv *dst, const Mv *src, int td, int tb);
void ff_vvc_luma_mv_merge_mode(VVCLocalContext *lc, int merge_idx, int ciip_flag, MvField *mv);
void ff_vvc_luma_mv_merge_gpm(VVCLocalContext *lc, const int merge_gpm_idx[2], MvField *mv);
void ff_vvc_mvp(VVCLocalContext *lc, const int *mvp_lx_flag, const int amvr_shift, MotionInfo *mi);
void ff_vvc_sb_mv_merge_mode(VVCLocalContext *lc, int merge_subblock_idx, PredictionUnit *pu);
void ff_vvc_affine_mvp(VVCLocalContext *lc, const int *mvp_lx_flag, const int amvr_shift, MotionInfo* mi);
void ff_vvc_store_sb_mvs(const VVCLocalContext *lc, PredictionUnit *pu);
void ff_vvc_store_mv(const VVCLocalContext *lc, const MotionInfo *mi);
void ff_vvc_store_mvf(const VVCLocalContext *lc, const MvField *mvf);
void ff_vvc_store_gpm_mvf(const VVCLocalContext *lc, const PredictionUnit* pu);
void ff_vvc_update_hmvp(VVCLocalContext *lc, const MotionInfo *mi);
int ff_vvc_no_backward_pred_flag(const VVCLocalContext *lc);
MvField* ff_vvc_get_mvf(const VVCFrameContext *fc, const int x0, const int y0);
void ff_vvc_set_mvf(const VVCLocalContext *lc, const int x0, const int y0, const int w, const int h, const MvField *mvf);
void ff_vvc_set_intra_mvf(const VVCLocalContext *lc);
#endif //AVCODEC_VVC_VVC_MVS_H