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.
Unified · Split
| @@ -1257,11 +1257,19 @@ int ff_vvc_pred_mode_ibc_flag(VVCLocalContext *lc, const int is_chroma) · 1256 unmodified lines | ||
| 1257 | 1257 | return GET_CABAC(PRED_MODE_IBC_FLAG + inc); |
| 1258 | 1258 | } |
| 1259 | 1259 | |
| 1260 | +static av_always_inline | |
| 1261 | +uint8_t get_mip_inc(VVCLocalContext *lc, const uint8_t *ctx) | |
| 1262 | +{ | |
| 1263 | + uint8_t left = 0, top = 0; | |
| 1264 | + get_left_top(lc, &left, &top, lc->cu->x0, lc->cu->y0, ctx, ctx); | |
| 1265 | + return (left & 1) + (top & 1); | |
| 1266 | +} | |
| 1267 | + | |
| 1260 | 1268 | int ff_vvc_intra_mip_flag(VVCLocalContext *lc, const uint8_t *intra_mip_flag) |
| 1261 | 1269 | { |
| 1262 | 1270 | const int w = lc->cu->cb_width; |
| 1263 | 1271 | const int h = lc->cu->cb_height; |
| 1264 | − const int inc = (w > h * 2 || h > w * 2) ? 3 : get_inc(lc, intra_mip_flag); | |
| 1272 | + const int inc = (w > h * 2 || h > w * 2) ? 3 : get_mip_inc(lc, intra_mip_flag); | |
| 1265 | 1273 | return GET_CABAC(INTRA_MIP_FLAG + inc); |
| 1266 | 1274 | } |
| 1267 | 1275 | |
| @@ -946,6 +946,12 @@ static void derive_chroma_intra_pred_mode(VVCLocalContext *lc, · 945 unmodified lines | ||
| 946 | 946 | } |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | +static av_always_inline uint8_t pack_mip_info(int intra_mip_flag, | |
| 950 | + int intra_mip_transposed_flag, int intra_mip_mode) | |
| 951 | +{ | |
| 952 | + return (intra_mip_mode << 2) | (intra_mip_transposed_flag << 1) | intra_mip_flag; | |
| 953 | +} | |
| 954 | + | |
| 949 | 955 | static void intra_luma_pred_modes(VVCLocalContext *lc) |
| 950 | 956 | { |
| 951 | 957 | VVCFrameContext *fc = lc->fc; |
| @@ -974,9 +980,9 @@ static void intra_luma_pred_modes(VVCLocalContext *lc) · 22 unmodified lines | ||
| 974 | 980 | int x = y_cb * pps->min_cb_width + x_cb; |
| 975 | 981 | for (int y = 0; y < (cb_height>>log2_min_cb_size); y++) { |
| 976 | 982 | int width = cb_width>>log2_min_cb_size; |
| 977 | − memset(&fc->tab.imf[x], cu->intra_mip_flag, width); | |
| 978 | − memset(&fc->tab.imtf[x], intra_mip_transposed_flag, width); | |
| 979 | − memset(&fc->tab.imm[x], intra_mip_mode, width); | |
| 983 | + const uint8_t mip_info = pack_mip_info(cu->intra_mip_flag, | |
| 984 | + intra_mip_transposed_flag, intra_mip_mode); | |
| 985 | + memset(&fc->tab.imf[x], mip_info, width); | |
| 980 | 986 | x += pps->min_cb_width; |
| 981 | 987 | } |
| 982 | 988 | cu->intra_pred_mode_y = intra_mip_mode; |
| @@ -128,7 +128,6 @@ static void min_cb_tl_init(TabList *l, VVCFrameContext *fc) · 127 unmodified lines | ||
| 128 | 128 | tl_init(l, 1, changed); |
| 129 | 129 | |
| 130 | 130 | TL_ADD(imf, pic_size_in_min_cb); |
| 131 | − TL_ADD(imm, pic_size_in_min_cb); | |
| 132 | 131 | |
| 133 | 132 | for (int i = LUMA; i <= CHROMA; i++) |
| 134 | 133 | 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) · 8 unmodified lines | ||
| 143 | 142 | tl_init(l, 0, changed); |
| 144 | 143 | |
| 145 | 144 | TL_ADD(skip, pic_size_in_min_cb); |
| 146 | − TL_ADD(imtf, pic_size_in_min_cb); | |
| 147 | 145 | TL_ADD(ipm, pic_size_in_min_cb); |
| 148 | 146 | |
| 149 | 147 | for (int i = LUMA; i <= CHROMA; i++) { |
| @@ -161,9 +161,7 @@ typedef struct VVCFrameContext { · 160 unmodified lines | ||
| 161 | 161 | uint8_t *skip; ///< CuSkipFlag[][] |
| 162 | 162 | uint8_t *ispmf; ///< intra_sub_partitions_mode_flag |
| 163 | 163 | uint8_t *msm[2]; ///< MttSplitMode[][][] in 32 pixels |
| 164 | − uint8_t *imf; ///< IntraMipFlag[][] | |
| 165 | − uint8_t *imtf; ///< intra_mip_transposed_flag[][] | |
| 166 | − uint8_t *imm; ///< intra_mip_mode[][] | |
| 164 | + uint8_t *imf; ///< IntraMipFlag[][], intra_mip_transposed_flag[][], intra_mip_mode[][] | |
| 167 | 165 | uint8_t *ipm; ///< IntraPredModeY[][] |
| 168 | 166 | uint8_t *cpm[2]; ///< CuPredMode[][][] |
| 169 | 167 | uint8_t *msf; ///< MergeSubblockFlag[][] |
| @@ -44,6 +44,15 @@ static int vvc_sad(const int16_t *src0, const int16_t *src1, int dx, int dy, · 43 unmodified lines | ||
| 44 | 44 | return sad; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | +static av_always_inline void unpack_mip_info(int *intra_mip_transposed_flag, | |
| 48 | + int *intra_mip_mode, const uint8_t mip_info) | |
| 49 | +{ | |
| 50 | + if (intra_mip_transposed_flag) | |
| 51 | + *intra_mip_transposed_flag = (mip_info >> 1) & 0x1; | |
| 52 | + if (intra_mip_mode) | |
| 53 | + *intra_mip_mode = (mip_info >> 2) & 0xf; | |
| 54 | +} | |
| 55 | + | |
| 47 | 56 | typedef struct IntraEdgeParams { |
| 48 | 57 | uint8_t* top; |
| 49 | 58 | uint8_t* left; |
| @@ -627,8 +627,9 @@ static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0, · 626 unmodified lines | ||
| 627 | 627 | FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc); |
| 628 | 628 | |
| 629 | 629 | if (is_intra_mip) { |
| 630 | − int intra_mip_transposed_flag = SAMPLE_CTB(fc->tab.imtf, x_cb, y_cb); | |
| 631 | − int intra_mip_mode = SAMPLE_CTB(fc->tab.imm, x_cb, y_cb); | |
| 630 | + int intra_mip_transposed_flag; | |
| 631 | + int intra_mip_mode; | |
| 632 | + unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag); | |
| 632 | 633 | |
| 633 | 634 | fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left, |
| 634 | 635 | w, h, stride, intra_mip_mode, intra_mip_transposed_flag); |