mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2024-12-23 12:43:46 +02:00
lavc/vvc: Use a bitfield to store MIP information
Reduces memory consumption by ~4MB for 1080p video with a maximum delay of 16 frames by packing various information related to MIP: * intra_mip_flag, 1 bit * intra_mip_transposed_flag, 1 bit * intra_mip_mode, 4 bits Into a single byte. Co-authored-by: Nuo Mi <nuomi2021@gmail.com> Signed-off-by: Frank Plowman <post@frankplowman.com>
This commit is contained in:
parent
914f89dbc6
commit
34c6ad0a07
@ -1257,11 +1257,19 @@ int ff_vvc_pred_mode_ibc_flag(VVCLocalContext *lc, const int is_chroma)
|
||||
return GET_CABAC(PRED_MODE_IBC_FLAG + inc);
|
||||
}
|
||||
|
||||
static av_always_inline
|
||||
uint8_t get_mip_inc(VVCLocalContext *lc, const uint8_t *ctx)
|
||||
{
|
||||
uint8_t left = 0, top = 0;
|
||||
get_left_top(lc, &left, &top, lc->cu->x0, lc->cu->y0, ctx, ctx);
|
||||
return (left & 1) + (top & 1);
|
||||
}
|
||||
|
||||
int ff_vvc_intra_mip_flag(VVCLocalContext *lc, const uint8_t *intra_mip_flag)
|
||||
{
|
||||
const int w = lc->cu->cb_width;
|
||||
const int h = lc->cu->cb_height;
|
||||
const int inc = (w > h * 2 || h > w * 2) ? 3 : get_inc(lc, intra_mip_flag);
|
||||
const int inc = (w > h * 2 || h > w * 2) ? 3 : get_mip_inc(lc, intra_mip_flag);
|
||||
return GET_CABAC(INTRA_MIP_FLAG + inc);
|
||||
}
|
||||
|
||||
|
@ -946,6 +946,12 @@ static void derive_chroma_intra_pred_mode(VVCLocalContext *lc,
|
||||
}
|
||||
}
|
||||
|
||||
static av_always_inline uint8_t pack_mip_info(int intra_mip_flag,
|
||||
int intra_mip_transposed_flag, int intra_mip_mode)
|
||||
{
|
||||
return (intra_mip_mode << 2) | (intra_mip_transposed_flag << 1) | intra_mip_flag;
|
||||
}
|
||||
|
||||
static void intra_luma_pred_modes(VVCLocalContext *lc)
|
||||
{
|
||||
VVCFrameContext *fc = lc->fc;
|
||||
@ -974,9 +980,9 @@ static void intra_luma_pred_modes(VVCLocalContext *lc)
|
||||
int x = y_cb * pps->min_cb_width + x_cb;
|
||||
for (int y = 0; y < (cb_height>>log2_min_cb_size); y++) {
|
||||
int width = cb_width>>log2_min_cb_size;
|
||||
memset(&fc->tab.imf[x], cu->intra_mip_flag, width);
|
||||
memset(&fc->tab.imtf[x], intra_mip_transposed_flag, width);
|
||||
memset(&fc->tab.imm[x], intra_mip_mode, width);
|
||||
const uint8_t mip_info = pack_mip_info(cu->intra_mip_flag,
|
||||
intra_mip_transposed_flag, intra_mip_mode);
|
||||
memset(&fc->tab.imf[x], mip_info, width);
|
||||
x += pps->min_cb_width;
|
||||
}
|
||||
cu->intra_pred_mode_y = intra_mip_mode;
|
||||
|
@ -128,7 +128,6 @@ static void min_cb_tl_init(TabList *l, VVCFrameContext *fc)
|
||||
tl_init(l, 1, changed);
|
||||
|
||||
TL_ADD(imf, pic_size_in_min_cb);
|
||||
TL_ADD(imm, pic_size_in_min_cb);
|
||||
|
||||
for (int i = LUMA; i <= CHROMA; i++)
|
||||
TL_ADD(cb_width[i], pic_size_in_min_cb); //is_a0_available requires this
|
||||
@ -143,7 +142,6 @@ static void min_cb_nz_tl_init(TabList *l, VVCFrameContext *fc)
|
||||
tl_init(l, 0, changed);
|
||||
|
||||
TL_ADD(skip, pic_size_in_min_cb);
|
||||
TL_ADD(imtf, pic_size_in_min_cb);
|
||||
TL_ADD(ipm, pic_size_in_min_cb);
|
||||
|
||||
for (int i = LUMA; i <= CHROMA; i++) {
|
||||
|
@ -161,9 +161,7 @@ typedef struct VVCFrameContext {
|
||||
uint8_t *skip; ///< CuSkipFlag[][]
|
||||
uint8_t *ispmf; ///< intra_sub_partitions_mode_flag
|
||||
uint8_t *msm[2]; ///< MttSplitMode[][][] in 32 pixels
|
||||
uint8_t *imf; ///< IntraMipFlag[][]
|
||||
uint8_t *imtf; ///< intra_mip_transposed_flag[][]
|
||||
uint8_t *imm; ///< intra_mip_mode[][]
|
||||
uint8_t *imf; ///< IntraMipFlag[][], intra_mip_transposed_flag[][], intra_mip_mode[][]
|
||||
uint8_t *ipm; ///< IntraPredModeY[][]
|
||||
uint8_t *cpm[2]; ///< CuPredMode[][][]
|
||||
uint8_t *msf; ///< MergeSubblockFlag[][]
|
||||
|
@ -44,6 +44,15 @@ static int vvc_sad(const int16_t *src0, const int16_t *src1, int dx, int dy,
|
||||
return sad;
|
||||
}
|
||||
|
||||
static av_always_inline void unpack_mip_info(int *intra_mip_transposed_flag,
|
||||
int *intra_mip_mode, const uint8_t mip_info)
|
||||
{
|
||||
if (intra_mip_transposed_flag)
|
||||
*intra_mip_transposed_flag = (mip_info >> 1) & 0x1;
|
||||
if (intra_mip_mode)
|
||||
*intra_mip_mode = (mip_info >> 2) & 0xf;
|
||||
}
|
||||
|
||||
typedef struct IntraEdgeParams {
|
||||
uint8_t* top;
|
||||
uint8_t* left;
|
||||
|
@ -627,8 +627,9 @@ static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0,
|
||||
FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc);
|
||||
|
||||
if (is_intra_mip) {
|
||||
int intra_mip_transposed_flag = SAMPLE_CTB(fc->tab.imtf, x_cb, y_cb);
|
||||
int intra_mip_mode = SAMPLE_CTB(fc->tab.imm, x_cb, y_cb);
|
||||
int intra_mip_transposed_flag;
|
||||
int intra_mip_mode;
|
||||
unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag);
|
||||
|
||||
fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left,
|
||||
w, h, stride, intra_mip_mode, intra_mip_transposed_flag);
|
||||
|
Loading…
Reference in New Issue
Block a user