Coverage Report

Created: 2026-04-01 07:42

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ffmpeg/libavcodec/vvc/intra_template.c
Line
Count
Source
1
/*
2
 * VVC intra prediction DSP
3
 *
4
 * Copyright (C) 2021-2023 Nuomi
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with FFmpeg; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22
23
#include "libavcodec/bit_depth_template.c"
24
25
#include "intra.h"
26
27
6.41G
#define POS(x, y) src[(x) + stride * (y)]
28
29
static av_always_inline void FUNC(cclm_linear_pred)(VVCFrameContext *fc, const int x0, const int y0,
30
    const int w, const int h, const pixel* pdsy, const int *a, const int *b, const int *k)
31
973k
{
32
973k
    const VVCSPS *sps = fc->ps.sps;
33
2.91M
    for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) {
34
1.94M
        const int c_idx = i + 1;
35
1.94M
        const int x = x0 >> sps->hshift[c_idx];
36
1.94M
        const int y = y0 >> sps->vshift[c_idx];
37
1.94M
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
38
1.94M
        pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
39
27.5M
        for (int y = 0; y < h; y++) {
40
538M
            for (int x = 0; x < w; x++) {
41
513M
                const int dsy = pdsy[y * w + x];
42
513M
                const int pred = ((dsy * a[i]) >> k[i]) + b[i];
43
513M
                POS(x, y) = CLIP(pred);
44
513M
            }
45
25.6M
        }
46
1.94M
    }
47
973k
}
dsp.c:cclm_linear_pred_12
Line
Count
Source
31
9.05k
{
32
9.05k
    const VVCSPS *sps = fc->ps.sps;
33
27.1k
    for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) {
34
18.1k
        const int c_idx = i + 1;
35
18.1k
        const int x = x0 >> sps->hshift[c_idx];
36
18.1k
        const int y = y0 >> sps->vshift[c_idx];
37
18.1k
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
38
18.1k
        pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
39
91.7k
        for (int y = 0; y < h; y++) {
40
485k
            for (int x = 0; x < w; x++) {
41
411k
                const int dsy = pdsy[y * w + x];
42
411k
                const int pred = ((dsy * a[i]) >> k[i]) + b[i];
43
411k
                POS(x, y) = CLIP(pred);
44
411k
            }
45
73.6k
        }
46
18.1k
    }
47
9.05k
}
dsp.c:cclm_linear_pred_10
Line
Count
Source
31
963k
{
32
963k
    const VVCSPS *sps = fc->ps.sps;
33
2.89M
    for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) {
34
1.92M
        const int c_idx = i + 1;
35
1.92M
        const int x = x0 >> sps->hshift[c_idx];
36
1.92M
        const int y = y0 >> sps->vshift[c_idx];
37
1.92M
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
38
1.92M
        pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
39
27.4M
        for (int y = 0; y < h; y++) {
40
538M
            for (int x = 0; x < w; x++) {
41
512M
                const int dsy = pdsy[y * w + x];
42
512M
                const int pred = ((dsy * a[i]) >> k[i]) + b[i];
43
512M
                POS(x, y) = CLIP(pred);
44
512M
            }
45
25.5M
        }
46
1.92M
    }
47
963k
}
dsp.c:cclm_linear_pred_8
Line
Count
Source
31
96
{
32
96
    const VVCSPS *sps = fc->ps.sps;
33
288
    for (int i = 0; i < VVC_MAX_SAMPLE_ARRAYS - 1; i++) {
34
192
        const int c_idx = i + 1;
35
192
        const int x = x0 >> sps->hshift[c_idx];
36
192
        const int y = y0 >> sps->vshift[c_idx];
37
192
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
38
192
        pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
39
960
        for (int y = 0; y < h; y++) {
40
3.87k
            for (int x = 0; x < w; x++) {
41
3.10k
                const int dsy = pdsy[y * w + x];
42
3.10k
                const int pred = ((dsy * a[i]) >> k[i]) + b[i];
43
3.10k
                POS(x, y) = CLIP(pred);
44
3.10k
            }
45
768
        }
46
192
    }
47
96
}
48
49
#define MAX_PICK_POS 4
50
24.0M
#define TOP  0
51
19.6M
#define LEFT 1
52
53
static av_always_inline void FUNC(cclm_get_params_default)(int *a, int *b, int *k)
54
4.61k
{
55
13.8k
    for (int i = 0; i < 2; i++) {
56
9.23k
        a[i] = k[i] = 0;
57
9.23k
        b[i] = 1 << (BIT_DEPTH - 1);
58
9.23k
    }
59
4.61k
}
dsp.c:cclm_get_params_default_12
Line
Count
Source
54
3.39k
{
55
10.1k
    for (int i = 0; i < 2; i++) {
56
6.79k
        a[i] = k[i] = 0;
57
6.79k
        b[i] = 1 << (BIT_DEPTH - 1);
58
6.79k
    }
59
3.39k
}
dsp.c:cclm_get_params_default_10
Line
Count
Source
54
1.16k
{
55
3.50k
    for (int i = 0; i < 2; i++) {
56
2.33k
        a[i] = k[i] = 0;
57
2.33k
        b[i] = 1 << (BIT_DEPTH - 1);
58
2.33k
    }
59
1.16k
}
dsp.c:cclm_get_params_default_8
Line
Count
Source
54
52
{
55
156
    for (int i = 0; i < 2; i++) {
56
104
        a[i] = k[i] = 0;
57
104
        b[i] = 1 << (BIT_DEPTH - 1);
58
104
    }
59
52
}
60
61
static av_always_inline int FUNC(cclm_get_select_pos)(const VVCLocalContext *lc,
62
    const int x, const int y, const int w, const int h, const int avail_t, const int avail_l,
63
    int cnt[2], int pos[2][MAX_PICK_POS])
64
973k
{
65
973k
    const enum IntraPredMode mode = lc->cu->intra_pred_mode_c;
66
973k
    const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM;
67
973k
    int num_samp[2];
68
69
973k
    if (mode == INTRA_LT_CCLM) {
70
911k
        num_samp[TOP]  = avail_t ? w : 0;
71
911k
        num_samp[LEFT] = avail_l ? h : 0;
72
911k
    } else {
73
62.0k
        num_samp[TOP] = (avail_t && mode == INTRA_T_CCLM) ? ff_vvc_get_top_available(lc,  x, y, w + FFMIN(w, h), 1) : 0;
74
62.0k
        num_samp[LEFT] = (avail_l && mode == INTRA_L_CCLM) ? ff_vvc_get_left_available(lc, x, y, h + FFMIN(w, h), 1) : 0;
75
62.0k
    }
76
973k
    if (!num_samp[TOP] && !num_samp[LEFT]) {
77
4.61k
        return 0;
78
4.61k
    }
79
2.90M
    for (int i = TOP; i <= LEFT; i++) {
80
1.93M
        const int start = num_samp[i] >> (2 + num_is4);
81
1.93M
        const int step  = FFMAX(1, num_samp[i] >> (1 + num_is4)) ;
82
1.93M
        cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1);
83
5.80M
        for (int c = 0; c < cnt[i]; c++)
84
3.87M
            pos[i][c] = start + c * step;
85
1.93M
    }
86
968k
    return 1;
87
973k
}
dsp.c:cclm_get_select_pos_12
Line
Count
Source
64
9.05k
{
65
9.05k
    const enum IntraPredMode mode = lc->cu->intra_pred_mode_c;
66
9.05k
    const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM;
67
9.05k
    int num_samp[2];
68
69
9.05k
    if (mode == INTRA_LT_CCLM) {
70
4.10k
        num_samp[TOP]  = avail_t ? w : 0;
71
4.10k
        num_samp[LEFT] = avail_l ? h : 0;
72
4.94k
    } else {
73
4.94k
        num_samp[TOP] = (avail_t && mode == INTRA_T_CCLM) ? ff_vvc_get_top_available(lc,  x, y, w + FFMIN(w, h), 1) : 0;
74
4.94k
        num_samp[LEFT] = (avail_l && mode == INTRA_L_CCLM) ? ff_vvc_get_left_available(lc, x, y, h + FFMIN(w, h), 1) : 0;
75
4.94k
    }
76
9.05k
    if (!num_samp[TOP] && !num_samp[LEFT]) {
77
3.39k
        return 0;
78
3.39k
    }
79
16.9k
    for (int i = TOP; i <= LEFT; i++) {
80
11.3k
        const int start = num_samp[i] >> (2 + num_is4);
81
11.3k
        const int step  = FFMAX(1, num_samp[i] >> (1 + num_is4)) ;
82
11.3k
        cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1);
83
33.9k
        for (int c = 0; c < cnt[i]; c++)
84
22.6k
            pos[i][c] = start + c * step;
85
11.3k
    }
86
5.65k
    return 1;
87
9.05k
}
dsp.c:cclm_get_select_pos_10
Line
Count
Source
64
963k
{
65
963k
    const enum IntraPredMode mode = lc->cu->intra_pred_mode_c;
66
963k
    const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM;
67
963k
    int num_samp[2];
68
69
963k
    if (mode == INTRA_LT_CCLM) {
70
906k
        num_samp[TOP]  = avail_t ? w : 0;
71
906k
        num_samp[LEFT] = avail_l ? h : 0;
72
906k
    } else {
73
57.0k
        num_samp[TOP] = (avail_t && mode == INTRA_T_CCLM) ? ff_vvc_get_top_available(lc,  x, y, w + FFMIN(w, h), 1) : 0;
74
57.0k
        num_samp[LEFT] = (avail_l && mode == INTRA_L_CCLM) ? ff_vvc_get_left_available(lc, x, y, h + FFMIN(w, h), 1) : 0;
75
57.0k
    }
76
963k
    if (!num_samp[TOP] && !num_samp[LEFT]) {
77
1.16k
        return 0;
78
1.16k
    }
79
2.88M
    for (int i = TOP; i <= LEFT; i++) {
80
1.92M
        const int start = num_samp[i] >> (2 + num_is4);
81
1.92M
        const int step  = FFMAX(1, num_samp[i] >> (1 + num_is4)) ;
82
1.92M
        cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1);
83
5.77M
        for (int c = 0; c < cnt[i]; c++)
84
3.84M
            pos[i][c] = start + c * step;
85
1.92M
    }
86
962k
    return 1;
87
963k
}
dsp.c:cclm_get_select_pos_8
Line
Count
Source
64
96
{
65
96
    const enum IntraPredMode mode = lc->cu->intra_pred_mode_c;
66
96
    const int num_is4 = !avail_t || !avail_l || mode != INTRA_LT_CCLM;
67
96
    int num_samp[2];
68
69
96
    if (mode == INTRA_LT_CCLM) {
70
5
        num_samp[TOP]  = avail_t ? w : 0;
71
5
        num_samp[LEFT] = avail_l ? h : 0;
72
91
    } else {
73
91
        num_samp[TOP] = (avail_t && mode == INTRA_T_CCLM) ? ff_vvc_get_top_available(lc,  x, y, w + FFMIN(w, h), 1) : 0;
74
91
        num_samp[LEFT] = (avail_l && mode == INTRA_L_CCLM) ? ff_vvc_get_left_available(lc, x, y, h + FFMIN(w, h), 1) : 0;
75
91
    }
76
96
    if (!num_samp[TOP] && !num_samp[LEFT]) {
77
52
        return 0;
78
52
    }
79
132
    for (int i = TOP; i <= LEFT; i++) {
80
88
        const int start = num_samp[i] >> (2 + num_is4);
81
88
        const int step  = FFMAX(1, num_samp[i] >> (1 + num_is4)) ;
82
88
        cnt[i] = FFMIN(num_samp[i], (1 + num_is4) << 1);
83
264
        for (int c = 0; c < cnt[i]; c++)
84
176
            pos[i][c] = start + c * step;
85
88
    }
86
44
    return 1;
87
96
}
88
89
static av_always_inline void FUNC(cclm_select_luma_444)(const pixel *src, const int step,
90
    const int cnt, const int pos[MAX_PICK_POS],  pixel *sel_luma)
91
25.2k
{
92
75.6k
    for (int i = 0; i < cnt; i++)
93
50.4k
        sel_luma[i] = src[pos[i] * step];
94
25.2k
}
dsp.c:cclm_select_luma_444_12
Line
Count
Source
91
9.99k
{
92
29.9k
    for (int i = 0; i < cnt; i++)
93
19.9k
        sel_luma[i] = src[pos[i] * step];
94
9.99k
}
dsp.c:cclm_select_luma_444_10
Line
Count
Source
91
15.1k
{
92
45.4k
    for (int i = 0; i < cnt; i++)
93
30.3k
        sel_luma[i] = src[pos[i] * step];
94
15.1k
}
dsp.c:cclm_select_luma_444_8
Line
Count
Source
91
70
{
92
210
    for (int i = 0; i < cnt; i++)
93
140
        sel_luma[i] = src[pos[i] * step];
94
70
}
95
96
static av_always_inline void FUNC(cclm_select_luma)(const VVCFrameContext *fc,
97
    const int x0, const int y0, const int avail_t, const int avail_l, const int cnt[2], const int pos[2][MAX_PICK_POS],
98
    pixel *sel_luma)
99
968k
{
100
968k
    const VVCSPS *sps = fc->ps.sps;
101
102
968k
    const int b_ctu_boundary = !av_zero_extend(y0, sps->ctb_log2_size_y);
103
968k
    const int hs = sps->hshift[1];
104
968k
    const int vs = sps->vshift[1];
105
968k
    const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel);
106
107
968k
    if (!hs && !vs) {
108
12.6k
        const pixel* src = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
109
12.6k
        FUNC(cclm_select_luma_444)(src - avail_t * stride, 1, cnt[TOP], pos[TOP], sel_luma);
110
12.6k
        FUNC(cclm_select_luma_444)(src - avail_l, stride, cnt[LEFT], pos[LEFT], sel_luma + cnt[TOP]);
111
955k
    } else {
112
        // top
113
955k
        if (vs && !b_ctu_boundary) {
114
748k
            const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride;
115
2.22M
            for (int i = 0; i < cnt[TOP]; i++) {
116
1.47M
                const int x = pos[TOP][i] << hs;
117
1.47M
                const pixel *src = source + x;
118
1.47M
                const int has_left = x || avail_l;
119
1.47M
                const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
120
1.47M
                if (sps->r->sps_chroma_vertical_collocated_flag) {
121
872k
                    sel_luma[i] = (POS(0, -1) + l + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
122
872k
                } else {
123
603k
                    const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1);
124
603k
                    sel_luma[i] = (l + l1 + 2 * (POS(0, 0) + POS(0, 1)) + POS(1, 0) + POS(1, 1) + 4) >> 3;
125
603k
                }
126
1.47M
            }
127
748k
        } else {
128
207k
            const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride;
129
591k
            for (int i = 0; i < cnt[TOP]; i++) {
130
384k
                const int x = pos[TOP][i] << hs;
131
384k
                const pixel *src = source + x;
132
384k
                const int has_left = x || avail_l;
133
384k
                const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
134
384k
                sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
135
384k
            }
136
207k
        }
137
138
        // left
139
955k
        {
140
955k
            const pixel *left;
141
955k
            const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l;
142
955k
            left = source - avail_l;
143
144
2.91M
            for (int i = 0; i < cnt[LEFT]; i++) {
145
1.96M
                const int y = pos[LEFT][i] << vs;
146
1.96M
                const int offset = y * stride;
147
1.96M
                const pixel *l   = left + offset;
148
1.96M
                const pixel *src = source + offset;
149
1.96M
                pixel pred;
150
1.96M
                if (!vs) {
151
160
                    pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
152
1.96M
                } else {
153
1.96M
                    if (sps->r->sps_chroma_vertical_collocated_flag) {
154
1.19M
                        const int has_top = y || avail_t;
155
1.19M
                        const pixel t = has_top ? POS(0, -1) : POS(0, 0);
156
1.19M
                        pred = (*l + t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
157
1.19M
                    } else {
158
768k
                        pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
159
768k
                    }
160
1.96M
                }
161
1.96M
                sel_luma[i + cnt[TOP]] = pred;
162
1.96M
            }
163
955k
        }
164
955k
    }
165
968k
}
dsp.c:cclm_select_luma_12
Line
Count
Source
99
5.65k
{
100
5.65k
    const VVCSPS *sps = fc->ps.sps;
101
102
5.65k
    const int b_ctu_boundary = !av_zero_extend(y0, sps->ctb_log2_size_y);
103
5.65k
    const int hs = sps->hshift[1];
104
5.65k
    const int vs = sps->vshift[1];
105
5.65k
    const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel);
106
107
5.65k
    if (!hs && !vs) {
108
4.99k
        const pixel* src = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
109
4.99k
        FUNC(cclm_select_luma_444)(src - avail_t * stride, 1, cnt[TOP], pos[TOP], sel_luma);
110
4.99k
        FUNC(cclm_select_luma_444)(src - avail_l, stride, cnt[LEFT], pos[LEFT], sel_luma + cnt[TOP]);
111
4.99k
    } else {
112
        // top
113
659
        if (vs && !b_ctu_boundary) {
114
0
            const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride;
115
0
            for (int i = 0; i < cnt[TOP]; i++) {
116
0
                const int x = pos[TOP][i] << hs;
117
0
                const pixel *src = source + x;
118
0
                const int has_left = x || avail_l;
119
0
                const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
120
0
                if (sps->r->sps_chroma_vertical_collocated_flag) {
121
0
                    sel_luma[i] = (POS(0, -1) + l + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
122
0
                } else {
123
0
                    const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1);
124
0
                    sel_luma[i] = (l + l1 + 2 * (POS(0, 0) + POS(0, 1)) + POS(1, 0) + POS(1, 1) + 4) >> 3;
125
0
                }
126
0
            }
127
659
        } else {
128
659
            const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride;
129
3.29k
            for (int i = 0; i < cnt[TOP]; i++) {
130
2.63k
                const int x = pos[TOP][i] << hs;
131
2.63k
                const pixel *src = source + x;
132
2.63k
                const int has_left = x || avail_l;
133
2.63k
                const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
134
2.63k
                sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
135
2.63k
            }
136
659
        }
137
138
        // left
139
659
        {
140
659
            const pixel *left;
141
659
            const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l;
142
659
            left = source - avail_l;
143
144
659
            for (int i = 0; i < cnt[LEFT]; i++) {
145
0
                const int y = pos[LEFT][i] << vs;
146
0
                const int offset = y * stride;
147
0
                const pixel *l   = left + offset;
148
0
                const pixel *src = source + offset;
149
0
                pixel pred;
150
0
                if (!vs) {
151
0
                    pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
152
0
                } else {
153
0
                    if (sps->r->sps_chroma_vertical_collocated_flag) {
154
0
                        const int has_top = y || avail_t;
155
0
                        const pixel t = has_top ? POS(0, -1) : POS(0, 0);
156
0
                        pred = (*l + t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
157
0
                    } else {
158
0
                        pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
159
0
                    }
160
0
                }
161
0
                sel_luma[i + cnt[TOP]] = pred;
162
0
            }
163
659
        }
164
659
    }
165
5.65k
}
dsp.c:cclm_select_luma_10
Line
Count
Source
99
962k
{
100
962k
    const VVCSPS *sps = fc->ps.sps;
101
102
962k
    const int b_ctu_boundary = !av_zero_extend(y0, sps->ctb_log2_size_y);
103
962k
    const int hs = sps->hshift[1];
104
962k
    const int vs = sps->vshift[1];
105
962k
    const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel);
106
107
962k
    if (!hs && !vs) {
108
7.57k
        const pixel* src = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
109
7.57k
        FUNC(cclm_select_luma_444)(src - avail_t * stride, 1, cnt[TOP], pos[TOP], sel_luma);
110
7.57k
        FUNC(cclm_select_luma_444)(src - avail_l, stride, cnt[LEFT], pos[LEFT], sel_luma + cnt[TOP]);
111
955k
    } else {
112
        // top
113
955k
        if (vs && !b_ctu_boundary) {
114
748k
            const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride;
115
2.22M
            for (int i = 0; i < cnt[TOP]; i++) {
116
1.47M
                const int x = pos[TOP][i] << hs;
117
1.47M
                const pixel *src = source + x;
118
1.47M
                const int has_left = x || avail_l;
119
1.47M
                const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
120
1.47M
                if (sps->r->sps_chroma_vertical_collocated_flag) {
121
872k
                    sel_luma[i] = (POS(0, -1) + l + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
122
872k
                } else {
123
603k
                    const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1);
124
603k
                    sel_luma[i] = (l + l1 + 2 * (POS(0, 0) + POS(0, 1)) + POS(1, 0) + POS(1, 1) + 4) >> 3;
125
603k
                }
126
1.47M
            }
127
748k
        } else {
128
206k
            const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride;
129
588k
            for (int i = 0; i < cnt[TOP]; i++) {
130
381k
                const int x = pos[TOP][i] << hs;
131
381k
                const pixel *src = source + x;
132
381k
                const int has_left = x || avail_l;
133
381k
                const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
134
381k
                sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
135
381k
            }
136
206k
        }
137
138
        // left
139
955k
        {
140
955k
            const pixel *left;
141
955k
            const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l;
142
955k
            left = source - avail_l;
143
144
2.91M
            for (int i = 0; i < cnt[LEFT]; i++) {
145
1.96M
                const int y = pos[LEFT][i] << vs;
146
1.96M
                const int offset = y * stride;
147
1.96M
                const pixel *l   = left + offset;
148
1.96M
                const pixel *src = source + offset;
149
1.96M
                pixel pred;
150
1.96M
                if (!vs) {
151
160
                    pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
152
1.96M
                } else {
153
1.96M
                    if (sps->r->sps_chroma_vertical_collocated_flag) {
154
1.19M
                        const int has_top = y || avail_t;
155
1.19M
                        const pixel t = has_top ? POS(0, -1) : POS(0, 0);
156
1.19M
                        pred = (*l + t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
157
1.19M
                    } else {
158
768k
                        pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
159
768k
                    }
160
1.96M
                }
161
1.96M
                sel_luma[i + cnt[TOP]] = pred;
162
1.96M
            }
163
955k
        }
164
955k
    }
165
962k
}
dsp.c:cclm_select_luma_8
Line
Count
Source
99
44
{
100
44
    const VVCSPS *sps = fc->ps.sps;
101
102
44
    const int b_ctu_boundary = !av_zero_extend(y0, sps->ctb_log2_size_y);
103
44
    const int hs = sps->hshift[1];
104
44
    const int vs = sps->vshift[1];
105
44
    const ptrdiff_t stride = fc->frame->linesize[0] / sizeof(pixel);
106
107
44
    if (!hs && !vs) {
108
35
        const pixel* src = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
109
35
        FUNC(cclm_select_luma_444)(src - avail_t * stride, 1, cnt[TOP], pos[TOP], sel_luma);
110
35
        FUNC(cclm_select_luma_444)(src - avail_l, stride, cnt[LEFT], pos[LEFT], sel_luma + cnt[TOP]);
111
35
    } else {
112
        // top
113
9
        if (vs && !b_ctu_boundary) {
114
0
            const pixel *source = (pixel *)fc->frame->data[0] + x0 + (y0 - 2) * stride;
115
0
            for (int i = 0; i < cnt[TOP]; i++) {
116
0
                const int x = pos[TOP][i] << hs;
117
0
                const pixel *src = source + x;
118
0
                const int has_left = x || avail_l;
119
0
                const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
120
0
                if (sps->r->sps_chroma_vertical_collocated_flag) {
121
0
                    sel_luma[i] = (POS(0, -1) + l + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
122
0
                } else {
123
0
                    const pixel l1 = has_left ? POS(-1, 1) : POS(0, 1);
124
0
                    sel_luma[i] = (l + l1 + 2 * (POS(0, 0) + POS(0, 1)) + POS(1, 0) + POS(1, 1) + 4) >> 3;
125
0
                }
126
0
            }
127
9
        } else {
128
9
            const pixel *source = (pixel*)fc->frame->data[0] + x0 + (y0 - 1) * stride;
129
45
            for (int i = 0; i < cnt[TOP]; i++) {
130
36
                const int x = pos[TOP][i] << hs;
131
36
                const pixel *src = source + x;
132
36
                const int has_left = x || avail_l;
133
36
                const pixel l = has_left ? POS(-1, 0) : POS(0, 0);
134
36
                sel_luma[i] = (l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
135
36
            }
136
9
        }
137
138
        // left
139
9
        {
140
9
            const pixel *left;
141
9
            const pixel *source = (pixel *)fc->frame->data[0] + x0 + y0 * stride - (1 + hs) * avail_l;
142
9
            left = source - avail_l;
143
144
9
            for (int i = 0; i < cnt[LEFT]; i++) {
145
0
                const int y = pos[LEFT][i] << vs;
146
0
                const int offset = y * stride;
147
0
                const pixel *l   = left + offset;
148
0
                const pixel *src = source + offset;
149
0
                pixel pred;
150
0
                if (!vs) {
151
0
                    pred = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
152
0
                } else {
153
0
                    if (sps->r->sps_chroma_vertical_collocated_flag) {
154
0
                        const int has_top = y || avail_t;
155
0
                        const pixel t = has_top ? POS(0, -1) : POS(0, 0);
156
0
                        pred = (*l + t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
157
0
                    } else {
158
0
                        pred = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
159
0
                    }
160
0
                }
161
0
                sel_luma[i + cnt[TOP]] = pred;
162
0
            }
163
9
        }
164
9
    }
165
44
}
166
167
static av_always_inline void FUNC(cclm_select_chroma)(const VVCFrameContext *fc,
168
    const int x, const int y, const int cnt[2], const int pos[2][MAX_PICK_POS],
169
    pixel sel[][MAX_PICK_POS * 2])
170
968k
{
171
2.90M
    for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
172
1.93M
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
173
174
        //top
175
1.93M
        const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride;
176
5.72M
        for (int i = 0; i < cnt[TOP]; i++) {
177
3.78M
            sel[c_idx][i] = src[pos[TOP][i]];
178
3.78M
        }
179
180
        //left
181
1.93M
        src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride;
182
5.89M
        for (int i = 0; i < cnt[LEFT]; i++) {
183
3.95M
            sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride];
184
3.95M
        }
185
1.93M
    }
186
968k
}
dsp.c:cclm_select_chroma_12
Line
Count
Source
170
5.65k
{
171
16.9k
    for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
172
11.3k
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
173
174
        //top
175
11.3k
        const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride;
176
53.1k
        for (int i = 0; i < cnt[TOP]; i++) {
177
41.8k
            sel[c_idx][i] = src[pos[TOP][i]];
178
41.8k
        }
179
180
        //left
181
11.3k
        src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride;
182
14.6k
        for (int i = 0; i < cnt[LEFT]; i++) {
183
3.35k
            sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride];
184
3.35k
        }
185
11.3k
    }
186
5.65k
}
dsp.c:cclm_select_chroma_10
Line
Count
Source
170
962k
{
171
2.88M
    for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
172
1.92M
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
173
174
        //top
175
1.92M
        const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride;
176
5.67M
        for (int i = 0; i < cnt[TOP]; i++) {
177
3.74M
            sel[c_idx][i] = src[pos[TOP][i]];
178
3.74M
        }
179
180
        //left
181
1.92M
        src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride;
182
5.88M
        for (int i = 0; i < cnt[LEFT]; i++) {
183
3.95M
            sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride];
184
3.95M
        }
185
1.92M
    }
186
962k
}
dsp.c:cclm_select_chroma_8
Line
Count
Source
170
44
{
171
132
    for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
172
88
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
173
174
        //top
175
88
        const pixel *src = (pixel*)fc->frame->data[c_idx] + x + (y - 1)* stride;
176
416
        for (int i = 0; i < cnt[TOP]; i++) {
177
328
            sel[c_idx][i] = src[pos[TOP][i]];
178
328
        }
179
180
        //left
181
88
        src = (pixel*)fc->frame->data[c_idx] + x - 1 + y * stride;
182
112
        for (int i = 0; i < cnt[LEFT]; i++) {
183
24
            sel[c_idx][i + cnt[TOP]] = src[pos[LEFT][i] * stride];
184
24
        }
185
88
    }
186
44
}
187
188
static av_always_inline int FUNC(cclm_select_samples)(const VVCLocalContext *lc,
189
    const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l,
190
    pixel sel[][MAX_PICK_POS * 2])
191
973k
{
192
973k
    const VVCFrameContext *fc = lc->fc;
193
973k
    const VVCSPS *sps   = fc->ps.sps;
194
973k
    const int x  = x0 >> sps->hshift[1];
195
973k
    const int y  = y0 >> sps->vshift[1];
196
973k
    int cnt[2], pos[2][MAX_PICK_POS];
197
198
973k
    if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos))
199
4.61k
        return 0;
200
201
968k
    FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]);
202
968k
    FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel);
203
204
968k
    if (cnt[TOP] + cnt[LEFT] == 2) {
205
2.87k
        for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
206
2.15k
            sel[c_idx][3] = sel[c_idx][0];
207
2.15k
            sel[c_idx][2] = sel[c_idx][1];
208
2.15k
            sel[c_idx][0] = sel[c_idx][1];
209
2.15k
            sel[c_idx][1] = sel[c_idx][3];
210
2.15k
        }
211
718
    }
212
968k
    return 1;
213
973k
}
dsp.c:cclm_select_samples_12
Line
Count
Source
191
9.05k
{
192
9.05k
    const VVCFrameContext *fc = lc->fc;
193
9.05k
    const VVCSPS *sps   = fc->ps.sps;
194
9.05k
    const int x  = x0 >> sps->hshift[1];
195
9.05k
    const int y  = y0 >> sps->vshift[1];
196
9.05k
    int cnt[2], pos[2][MAX_PICK_POS];
197
198
9.05k
    if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos))
199
3.39k
        return 0;
200
201
5.65k
    FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]);
202
5.65k
    FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel);
203
204
5.65k
    if (cnt[TOP] + cnt[LEFT] == 2) {
205
0
        for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
206
0
            sel[c_idx][3] = sel[c_idx][0];
207
0
            sel[c_idx][2] = sel[c_idx][1];
208
0
            sel[c_idx][0] = sel[c_idx][1];
209
0
            sel[c_idx][1] = sel[c_idx][3];
210
0
        }
211
0
    }
212
5.65k
    return 1;
213
9.05k
}
dsp.c:cclm_select_samples_10
Line
Count
Source
191
963k
{
192
963k
    const VVCFrameContext *fc = lc->fc;
193
963k
    const VVCSPS *sps   = fc->ps.sps;
194
963k
    const int x  = x0 >> sps->hshift[1];
195
963k
    const int y  = y0 >> sps->vshift[1];
196
963k
    int cnt[2], pos[2][MAX_PICK_POS];
197
198
963k
    if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos))
199
1.16k
        return 0;
200
201
962k
    FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]);
202
962k
    FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel);
203
204
962k
    if (cnt[TOP] + cnt[LEFT] == 2) {
205
2.87k
        for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
206
2.15k
            sel[c_idx][3] = sel[c_idx][0];
207
2.15k
            sel[c_idx][2] = sel[c_idx][1];
208
2.15k
            sel[c_idx][0] = sel[c_idx][1];
209
2.15k
            sel[c_idx][1] = sel[c_idx][3];
210
2.15k
        }
211
718
    }
212
962k
    return 1;
213
963k
}
dsp.c:cclm_select_samples_8
Line
Count
Source
191
96
{
192
96
    const VVCFrameContext *fc = lc->fc;
193
96
    const VVCSPS *sps   = fc->ps.sps;
194
96
    const int x  = x0 >> sps->hshift[1];
195
96
    const int y  = y0 >> sps->vshift[1];
196
96
    int cnt[2], pos[2][MAX_PICK_POS];
197
198
96
    if (!FUNC(cclm_get_select_pos)(lc, x, y, w, h, avail_t, avail_l, cnt, pos))
199
52
        return 0;
200
201
44
    FUNC(cclm_select_luma)(fc, x0, y0, avail_t, avail_l, cnt, pos, sel[LUMA]);
202
44
    FUNC(cclm_select_chroma)(fc, x, y, cnt, pos, sel);
203
204
44
    if (cnt[TOP] + cnt[LEFT] == 2) {
205
0
        for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
206
0
            sel[c_idx][3] = sel[c_idx][0];
207
0
            sel[c_idx][2] = sel[c_idx][1];
208
0
            sel[c_idx][0] = sel[c_idx][1];
209
0
            sel[c_idx][1] = sel[c_idx][3];
210
0
        }
211
0
    }
212
44
    return 1;
213
96
}
214
215
static av_always_inline void FUNC(cclm_get_min_max)(
216
    const pixel sel[][MAX_PICK_POS * 2], int *min, int *max)
217
968k
{
218
968k
    int min_grp_idx[] = { 0, 2 };
219
968k
    int max_grp_idx[] = { 1, 3 };
220
221
968k
    if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]])
222
460k
        FFSWAP(int, min_grp_idx[0], min_grp_idx[1]);
223
968k
    if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]])
224
386k
        FFSWAP(int, max_grp_idx[0], max_grp_idx[1]);
225
968k
    if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) {
226
55.7k
        FFSWAP(int, min_grp_idx[0], max_grp_idx[0]);
227
55.7k
        FFSWAP(int, min_grp_idx[1], max_grp_idx[1]);
228
55.7k
    }
229
968k
    if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]])
230
769k
        FFSWAP(int, min_grp_idx[1], max_grp_idx[0]);
231
3.87M
    for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
232
2.90M
        max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1;
233
2.90M
        min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1;
234
2.90M
    }
235
968k
}
dsp.c:cclm_get_min_max_12
Line
Count
Source
217
5.65k
{
218
5.65k
    int min_grp_idx[] = { 0, 2 };
219
5.65k
    int max_grp_idx[] = { 1, 3 };
220
221
5.65k
    if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]])
222
4.59k
        FFSWAP(int, min_grp_idx[0], min_grp_idx[1]);
223
5.65k
    if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]])
224
4.42k
        FFSWAP(int, max_grp_idx[0], max_grp_idx[1]);
225
5.65k
    if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) {
226
2.38k
        FFSWAP(int, min_grp_idx[0], max_grp_idx[0]);
227
2.38k
        FFSWAP(int, min_grp_idx[1], max_grp_idx[1]);
228
2.38k
    }
229
5.65k
    if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]])
230
2.71k
        FFSWAP(int, min_grp_idx[1], max_grp_idx[0]);
231
22.6k
    for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
232
16.9k
        max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1;
233
16.9k
        min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1;
234
16.9k
    }
235
5.65k
}
dsp.c:cclm_get_min_max_10
Line
Count
Source
217
962k
{
218
962k
    int min_grp_idx[] = { 0, 2 };
219
962k
    int max_grp_idx[] = { 1, 3 };
220
221
962k
    if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]])
222
455k
        FFSWAP(int, min_grp_idx[0], min_grp_idx[1]);
223
962k
    if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]])
224
382k
        FFSWAP(int, max_grp_idx[0], max_grp_idx[1]);
225
962k
    if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) {
226
53.3k
        FFSWAP(int, min_grp_idx[0], max_grp_idx[0]);
227
53.3k
        FFSWAP(int, min_grp_idx[1], max_grp_idx[1]);
228
53.3k
    }
229
962k
    if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]])
230
767k
        FFSWAP(int, min_grp_idx[1], max_grp_idx[0]);
231
3.85M
    for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
232
2.88M
        max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1;
233
2.88M
        min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1;
234
2.88M
    }
235
962k
}
dsp.c:cclm_get_min_max_8
Line
Count
Source
217
44
{
218
44
    int min_grp_idx[] = { 0, 2 };
219
44
    int max_grp_idx[] = { 1, 3 };
220
221
44
    if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][min_grp_idx[1]])
222
8
        FFSWAP(int, min_grp_idx[0], min_grp_idx[1]);
223
44
    if (sel[LUMA][max_grp_idx[0]] > sel[LUMA][max_grp_idx[1]])
224
37
        FFSWAP(int, max_grp_idx[0], max_grp_idx[1]);
225
44
    if (sel[LUMA][min_grp_idx[0]] > sel[LUMA][max_grp_idx[1]]) {
226
6
        FFSWAP(int, min_grp_idx[0], max_grp_idx[0]);
227
6
        FFSWAP(int, min_grp_idx[1], max_grp_idx[1]);
228
6
    }
229
44
    if (sel[LUMA][min_grp_idx[1]] > sel[LUMA][max_grp_idx[0]])
230
38
        FFSWAP(int, min_grp_idx[1], max_grp_idx[0]);
231
176
    for (int c_idx = 0; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
232
132
        max[c_idx] = (sel[c_idx][max_grp_idx[0]] + sel[c_idx][max_grp_idx[1]] + 1) >> 1;
233
132
        min[c_idx] = (sel[c_idx][min_grp_idx[0]] + sel[c_idx][min_grp_idx[1]] + 1) >> 1;
234
132
    }
235
44
}
236
237
static av_always_inline void FUNC(cclm_get_params)(const VVCLocalContext *lc,
238
    const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l,
239
    int *a, int *b, int *k)
240
973k
{
241
973k
    pixel sel[VVC_MAX_SAMPLE_ARRAYS][MAX_PICK_POS * 2];
242
973k
    int max[VVC_MAX_SAMPLE_ARRAYS], min[VVC_MAX_SAMPLE_ARRAYS];
243
973k
    int diff;
244
245
973k
    if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) {
246
4.61k
        FUNC(cclm_get_params_default)(a, b, k);
247
4.61k
        return;
248
4.61k
    }
249
250
968k
    FUNC(cclm_get_min_max)(sel, min, max);
251
252
968k
    diff = max[LUMA] - min[LUMA];
253
968k
    if (diff == 0) {
254
171k
        for (int i = 0; i < 2; i++) {
255
114k
            a[i] = k[i] = 0;
256
114k
            b[i] = min[i + 1];
257
114k
        }
258
57.1k
        return;
259
57.1k
    }
260
2.73M
    for (int i = 0; i < 2; i++) {
261
1.82M
        const static int div_sig_table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0};
262
1.82M
        const int diffc = max[i + 1] - min[i + 1];
263
1.82M
        int  x = av_log2(diff);
264
1.82M
        int  y, v, sign, add;
265
1.82M
        const int norm_diff = ((diff << 4) >> x) & 15;
266
1.82M
        x += (norm_diff) ? 1 : 0;
267
1.82M
        y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0;
268
1.82M
        v = div_sig_table[norm_diff] | 8;
269
1.82M
        add = (1 << y >> 1);
270
1.82M
        a[i] = (diffc * v + add) >> y;
271
1.82M
        k[i] = FFMAX(1, 3 + x -y);
272
1.82M
        sign = a[i] < 0 ? -1 : (a[i] > 0);
273
1.82M
        a[i] = ((3 + x - y) < 1) ?  sign * 15 : a[i];
274
1.82M
        b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]);
275
1.82M
    }
276
277
911k
}
dsp.c:cclm_get_params_12
Line
Count
Source
240
9.05k
{
241
9.05k
    pixel sel[VVC_MAX_SAMPLE_ARRAYS][MAX_PICK_POS * 2];
242
9.05k
    int max[VVC_MAX_SAMPLE_ARRAYS], min[VVC_MAX_SAMPLE_ARRAYS];
243
9.05k
    int diff;
244
245
9.05k
    if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) {
246
3.39k
        FUNC(cclm_get_params_default)(a, b, k);
247
3.39k
        return;
248
3.39k
    }
249
250
5.65k
    FUNC(cclm_get_min_max)(sel, min, max);
251
252
5.65k
    diff = max[LUMA] - min[LUMA];
253
5.65k
    if (diff == 0) {
254
540
        for (int i = 0; i < 2; i++) {
255
360
            a[i] = k[i] = 0;
256
360
            b[i] = min[i + 1];
257
360
        }
258
180
        return;
259
180
    }
260
16.4k
    for (int i = 0; i < 2; i++) {
261
10.9k
        const static int div_sig_table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0};
262
10.9k
        const int diffc = max[i + 1] - min[i + 1];
263
10.9k
        int  x = av_log2(diff);
264
10.9k
        int  y, v, sign, add;
265
10.9k
        const int norm_diff = ((diff << 4) >> x) & 15;
266
10.9k
        x += (norm_diff) ? 1 : 0;
267
10.9k
        y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0;
268
10.9k
        v = div_sig_table[norm_diff] | 8;
269
10.9k
        add = (1 << y >> 1);
270
10.9k
        a[i] = (diffc * v + add) >> y;
271
10.9k
        k[i] = FFMAX(1, 3 + x -y);
272
10.9k
        sign = a[i] < 0 ? -1 : (a[i] > 0);
273
10.9k
        a[i] = ((3 + x - y) < 1) ?  sign * 15 : a[i];
274
10.9k
        b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]);
275
10.9k
    }
276
277
5.47k
}
dsp.c:cclm_get_params_10
Line
Count
Source
240
963k
{
241
963k
    pixel sel[VVC_MAX_SAMPLE_ARRAYS][MAX_PICK_POS * 2];
242
963k
    int max[VVC_MAX_SAMPLE_ARRAYS], min[VVC_MAX_SAMPLE_ARRAYS];
243
963k
    int diff;
244
245
963k
    if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) {
246
1.16k
        FUNC(cclm_get_params_default)(a, b, k);
247
1.16k
        return;
248
1.16k
    }
249
250
962k
    FUNC(cclm_get_min_max)(sel, min, max);
251
252
962k
    diff = max[LUMA] - min[LUMA];
253
962k
    if (diff == 0) {
254
170k
        for (int i = 0; i < 2; i++) {
255
113k
            a[i] = k[i] = 0;
256
113k
            b[i] = min[i + 1];
257
113k
        }
258
56.9k
        return;
259
56.9k
    }
260
2.71M
    for (int i = 0; i < 2; i++) {
261
1.81M
        const static int div_sig_table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0};
262
1.81M
        const int diffc = max[i + 1] - min[i + 1];
263
1.81M
        int  x = av_log2(diff);
264
1.81M
        int  y, v, sign, add;
265
1.81M
        const int norm_diff = ((diff << 4) >> x) & 15;
266
1.81M
        x += (norm_diff) ? 1 : 0;
267
1.81M
        y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0;
268
1.81M
        v = div_sig_table[norm_diff] | 8;
269
1.81M
        add = (1 << y >> 1);
270
1.81M
        a[i] = (diffc * v + add) >> y;
271
1.81M
        k[i] = FFMAX(1, 3 + x -y);
272
1.81M
        sign = a[i] < 0 ? -1 : (a[i] > 0);
273
1.81M
        a[i] = ((3 + x - y) < 1) ?  sign * 15 : a[i];
274
1.81M
        b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]);
275
1.81M
    }
276
277
905k
}
dsp.c:cclm_get_params_8
Line
Count
Source
240
96
{
241
96
    pixel sel[VVC_MAX_SAMPLE_ARRAYS][MAX_PICK_POS * 2];
242
96
    int max[VVC_MAX_SAMPLE_ARRAYS], min[VVC_MAX_SAMPLE_ARRAYS];
243
96
    int diff;
244
245
96
    if (!FUNC(cclm_select_samples)(lc, x0, y0, w, h, avail_t, avail_l, sel)) {
246
52
        FUNC(cclm_get_params_default)(a, b, k);
247
52
        return;
248
52
    }
249
250
44
    FUNC(cclm_get_min_max)(sel, min, max);
251
252
44
    diff = max[LUMA] - min[LUMA];
253
44
    if (diff == 0) {
254
0
        for (int i = 0; i < 2; i++) {
255
0
            a[i] = k[i] = 0;
256
0
            b[i] = min[i + 1];
257
0
        }
258
0
        return;
259
0
    }
260
132
    for (int i = 0; i < 2; i++) {
261
88
        const static int div_sig_table[] = {0, 7, 6, 5, 5, 4, 4, 3, 3, 2, 2, 1, 1, 1, 1, 0};
262
88
        const int diffc = max[i + 1] - min[i + 1];
263
88
        int  x = av_log2(diff);
264
88
        int  y, v, sign, add;
265
88
        const int norm_diff = ((diff << 4) >> x) & 15;
266
88
        x += (norm_diff) ? 1 : 0;
267
88
        y = abs(diffc) > 0 ? av_log2(abs(diffc)) + 1 : 0;
268
88
        v = div_sig_table[norm_diff] | 8;
269
88
        add = (1 << y >> 1);
270
88
        a[i] = (diffc * v + add) >> y;
271
88
        k[i] = FFMAX(1, 3 + x -y);
272
88
        sign = a[i] < 0 ? -1 : (a[i] > 0);
273
88
        a[i] = ((3 + x - y) < 1) ?  sign * 15 : a[i];
274
88
        b[i] = min[i + 1] - ((a[i] * min[0]) >> k[i]);
275
88
    }
276
277
44
}
278
279
#undef TOP
280
#undef LEFT
281
282
static av_always_inline void FUNC(cclm_get_luma_rec_pixels)(const VVCFrameContext *fc,
283
    const int x0, const int y0, const int w, const int h, const int avail_t, const int avail_l,
284
    pixel *pdsy)
285
973k
{
286
973k
    const int hs            = fc->ps.sps->hshift[1];
287
973k
    const int vs            = fc->ps.sps->vshift[1];
288
973k
    const ptrdiff_t stride  = fc->frame->linesize[0] / sizeof(pixel);
289
973k
    const pixel *source     = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
290
973k
    const pixel *left       = source - avail_l;
291
973k
    const pixel *top        = source - avail_t * stride;
292
293
973k
    const VVCSPS *sps = fc->ps.sps;
294
973k
    if (!hs && !vs) {
295
350k
        for (int i = 0; i < h; i++)
296
334k
            memcpy(pdsy + i * w, source + i * stride, w * sizeof(pixel));
297
15.3k
        return;
298
15.3k
    }
299
13.4M
    for (int i = 0; i < h; i++) {
300
12.4M
        const pixel *src  = source;
301
12.4M
        const pixel *l = left;
302
12.4M
        const pixel *t = top;
303
12.4M
        if (!vs) {
304
83.3k
            for (int j = 0; j < w; j++) {
305
75.3k
                pixel pred  = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
306
75.3k
                pdsy[i * w + j] = pred;
307
75.3k
                src += 2;
308
75.3k
                l = src - 1;
309
75.3k
            }
310
311
12.4M
        } else {
312
12.4M
            if (sps->r->sps_chroma_vertical_collocated_flag)  {
313
196M
                for (int j = 0; j < w; j++) {
314
187M
                    pixel pred  = (*l + *t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
315
187M
                    pdsy[i * w + j] = pred;
316
187M
                    src += 2;
317
187M
                    t += 2;
318
187M
                    l = src - 1;
319
187M
                }
320
8.93M
            } else {
321
57.7M
                for (int j = 0; j < w; j++) {
322
54.2M
                    pixel pred  = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
323
324
54.2M
                    pdsy[i * w + j] = pred;
325
54.2M
                    src += 2;
326
54.2M
                    l = src - 1;
327
54.2M
                }
328
3.53M
            }
329
12.4M
        }
330
12.4M
        source += (stride << vs);
331
12.4M
        left   += (stride << vs);
332
12.4M
        top    = source - stride;
333
12.4M
    }
334
957k
}
dsp.c:cclm_get_luma_rec_pixels_12
Line
Count
Source
285
9.05k
{
286
9.05k
    const int hs            = fc->ps.sps->hshift[1];
287
9.05k
    const int vs            = fc->ps.sps->vshift[1];
288
9.05k
    const ptrdiff_t stride  = fc->frame->linesize[0] / sizeof(pixel);
289
9.05k
    const pixel *source     = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
290
9.05k
    const pixel *left       = source - avail_l;
291
9.05k
    const pixel *top        = source - avail_t * stride;
292
293
9.05k
    const VVCSPS *sps = fc->ps.sps;
294
9.05k
    if (!hs && !vs) {
295
39.0k
        for (int i = 0; i < h; i++)
296
31.3k
            memcpy(pdsy + i * w, source + i * stride, w * sizeof(pixel));
297
7.68k
        return;
298
7.68k
    }
299
6.85k
    for (int i = 0; i < h; i++) {
300
5.48k
        const pixel *src  = source;
301
5.48k
        const pixel *l = left;
302
5.48k
        const pixel *t = top;
303
5.48k
        if (!vs) {
304
27.4k
            for (int j = 0; j < w; j++) {
305
21.9k
                pixel pred  = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
306
21.9k
                pdsy[i * w + j] = pred;
307
21.9k
                src += 2;
308
21.9k
                l = src - 1;
309
21.9k
            }
310
311
5.48k
        } else {
312
0
            if (sps->r->sps_chroma_vertical_collocated_flag)  {
313
0
                for (int j = 0; j < w; j++) {
314
0
                    pixel pred  = (*l + *t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
315
0
                    pdsy[i * w + j] = pred;
316
0
                    src += 2;
317
0
                    t += 2;
318
0
                    l = src - 1;
319
0
                }
320
0
            } else {
321
0
                for (int j = 0; j < w; j++) {
322
0
                    pixel pred  = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
323
324
0
                    pdsy[i * w + j] = pred;
325
0
                    src += 2;
326
0
                    l = src - 1;
327
0
                }
328
0
            }
329
0
        }
330
5.48k
        source += (stride << vs);
331
5.48k
        left   += (stride << vs);
332
5.48k
        top    = source - stride;
333
5.48k
    }
334
1.37k
}
dsp.c:cclm_get_luma_rec_pixels_10
Line
Count
Source
285
963k
{
286
963k
    const int hs            = fc->ps.sps->hshift[1];
287
963k
    const int vs            = fc->ps.sps->vshift[1];
288
963k
    const ptrdiff_t stride  = fc->frame->linesize[0] / sizeof(pixel);
289
963k
    const pixel *source     = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
290
963k
    const pixel *left       = source - avail_l;
291
963k
    const pixel *top        = source - avail_t * stride;
292
293
963k
    const VVCSPS *sps = fc->ps.sps;
294
963k
    if (!hs && !vs) {
295
310k
        for (int i = 0; i < h; i++)
296
302k
            memcpy(pdsy + i * w, source + i * stride, w * sizeof(pixel));
297
7.60k
        return;
298
7.60k
    }
299
13.4M
    for (int i = 0; i < h; i++) {
300
12.4M
        const pixel *src  = source;
301
12.4M
        const pixel *l = left;
302
12.4M
        const pixel *t = top;
303
12.4M
        if (!vs) {
304
55.6k
            for (int j = 0; j < w; j++) {
305
53.2k
                pixel pred  = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
306
53.2k
                pdsy[i * w + j] = pred;
307
53.2k
                src += 2;
308
53.2k
                l = src - 1;
309
53.2k
            }
310
311
12.4M
        } else {
312
12.4M
            if (sps->r->sps_chroma_vertical_collocated_flag)  {
313
196M
                for (int j = 0; j < w; j++) {
314
187M
                    pixel pred  = (*l + *t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
315
187M
                    pdsy[i * w + j] = pred;
316
187M
                    src += 2;
317
187M
                    t += 2;
318
187M
                    l = src - 1;
319
187M
                }
320
8.93M
            } else {
321
57.7M
                for (int j = 0; j < w; j++) {
322
54.2M
                    pixel pred  = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
323
324
54.2M
                    pdsy[i * w + j] = pred;
325
54.2M
                    src += 2;
326
54.2M
                    l = src - 1;
327
54.2M
                }
328
3.53M
            }
329
12.4M
        }
330
12.4M
        source += (stride << vs);
331
12.4M
        left   += (stride << vs);
332
12.4M
        top    = source - stride;
333
12.4M
    }
334
956k
}
dsp.c:cclm_get_luma_rec_pixels_8
Line
Count
Source
285
96
{
286
96
    const int hs            = fc->ps.sps->hshift[1];
287
96
    const int vs            = fc->ps.sps->vshift[1];
288
96
    const ptrdiff_t stride  = fc->frame->linesize[0] / sizeof(pixel);
289
96
    const pixel *source     = (pixel*)fc->frame->data[0] + x0 + y0 * stride;
290
96
    const pixel *left       = source - avail_l;
291
96
    const pixel *top        = source - avail_t * stride;
292
293
96
    const VVCSPS *sps = fc->ps.sps;
294
96
    if (!hs && !vs) {
295
430
        for (int i = 0; i < h; i++)
296
344
            memcpy(pdsy + i * w, source + i * stride, w * sizeof(pixel));
297
86
        return;
298
86
    }
299
50
    for (int i = 0; i < h; i++) {
300
40
        const pixel *src  = source;
301
40
        const pixel *l = left;
302
40
        const pixel *t = top;
303
40
        if (!vs) {
304
200
            for (int j = 0; j < w; j++) {
305
160
                pixel pred  = (*l + 2 * POS(0, 0) + POS(1, 0) + 2) >> 2;
306
160
                pdsy[i * w + j] = pred;
307
160
                src += 2;
308
160
                l = src - 1;
309
160
            }
310
311
40
        } else {
312
0
            if (sps->r->sps_chroma_vertical_collocated_flag)  {
313
0
                for (int j = 0; j < w; j++) {
314
0
                    pixel pred  = (*l + *t + 4 * POS(0, 0) + POS(1, 0) + POS(0, 1) + 4) >> 3;
315
0
                    pdsy[i * w + j] = pred;
316
0
                    src += 2;
317
0
                    t += 2;
318
0
                    l = src - 1;
319
0
                }
320
0
            } else {
321
0
                for (int j = 0; j < w; j++) {
322
0
                    pixel pred  = (*l + *(l + stride) + 2 * POS(0, 0) + 2 * POS(0, 1) + POS(1, 0) + POS(1, 1) + 4) >> 3;
323
324
0
                    pdsy[i * w + j] = pred;
325
0
                    src += 2;
326
0
                    l = src - 1;
327
0
                }
328
0
            }
329
0
        }
330
40
        source += (stride << vs);
331
40
        left   += (stride << vs);
332
40
        top    = source - stride;
333
40
    }
334
10
}
335
336
static av_always_inline void FUNC(cclm_pred_default)(VVCFrameContext *fc,
337
    const int x, const int y, const int w, const int h, const int avail_t, const int avail_l)
338
39.2k
{
339
117k
    for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
340
78.5k
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
341
78.5k
        pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride;
342
434k
        for (int i = 0; i < h; i++) {
343
3.05M
            for (int j = 0; j < w; j++) {
344
2.69M
                dst[j] = 1 << (BIT_DEPTH - 1);
345
2.69M
            }
346
355k
            dst += stride;
347
355k
        }
348
78.5k
    }
349
39.2k
}
dsp.c:cclm_pred_default_12
Line
Count
Source
338
9.71k
{
339
29.1k
    for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
340
19.4k
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
341
19.4k
        pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride;
342
99.8k
        for (int i = 0; i < h; i++) {
343
577k
            for (int j = 0; j < w; j++) {
344
496k
                dst[j] = 1 << (BIT_DEPTH - 1);
345
496k
            }
346
80.4k
            dst += stride;
347
80.4k
        }
348
19.4k
    }
349
9.71k
}
dsp.c:cclm_pred_default_10
Line
Count
Source
338
1.60k
{
339
4.80k
    for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
340
3.20k
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
341
3.20k
        pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride;
342
48.9k
        for (int i = 0; i < h; i++) {
343
1.28M
            for (int j = 0; j < w; j++) {
344
1.23M
                dst[j] = 1 << (BIT_DEPTH - 1);
345
1.23M
            }
346
45.7k
            dst += stride;
347
45.7k
        }
348
3.20k
    }
349
1.60k
}
dsp.c:cclm_pred_default_8
Line
Count
Source
338
27.9k
{
339
83.9k
    for (int c_idx = 1; c_idx < VVC_MAX_SAMPLE_ARRAYS; c_idx++) {
340
55.9k
        const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
341
55.9k
        pixel *dst = (pixel*)fc->frame->data[c_idx] + x + y * stride;
342
285k
        for (int i = 0; i < h; i++) {
343
1.19M
            for (int j = 0; j < w; j++) {
344
962k
                dst[j] = 1 << (BIT_DEPTH - 1);
345
962k
            }
346
229k
            dst += stride;
347
229k
        }
348
55.9k
    }
349
27.9k
}
350
351
//8.4.5.2.14 Specification of INTRA_LT_CCLM, INTRA_L_CCLM and INTRA_T_CCLM intra prediction mode
352
static void FUNC(intra_cclm_pred)(const VVCLocalContext *lc, const int x0, const int y0,
353
    const int width, const int height)
354
1.01M
{
355
1.01M
    VVCFrameContext *fc     = lc->fc;
356
1.01M
    const VVCSPS *sps = fc->ps.sps;
357
1.01M
    const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0);
358
1.01M
    const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0);
359
1.01M
    const int hs = sps->hshift[1];
360
1.01M
    const int vs = sps->vshift[1];
361
1.01M
    const int x  = x0 >> hs;
362
1.01M
    const int y  = y0 >> vs;
363
1.01M
    const int w  = width >> hs;
364
1.01M
    const int h  = height >> vs;
365
1.01M
    int a[2], b[2], k[2];
366
367
1.01M
    pixel dsy[MAX_TB_SIZE * MAX_TB_SIZE];
368
1.01M
    if (!avail_t && !avail_l) {
369
39.2k
        FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l);
370
39.2k
        return;
371
39.2k
    }
372
973k
    FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy);
373
973k
    FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k);
374
973k
    FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k);
375
973k
}
dsp.c:intra_cclm_pred_12
Line
Count
Source
354
18.7k
{
355
18.7k
    VVCFrameContext *fc     = lc->fc;
356
18.7k
    const VVCSPS *sps = fc->ps.sps;
357
18.7k
    const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0);
358
18.7k
    const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0);
359
18.7k
    const int hs = sps->hshift[1];
360
18.7k
    const int vs = sps->vshift[1];
361
18.7k
    const int x  = x0 >> hs;
362
18.7k
    const int y  = y0 >> vs;
363
18.7k
    const int w  = width >> hs;
364
18.7k
    const int h  = height >> vs;
365
18.7k
    int a[2], b[2], k[2];
366
367
18.7k
    pixel dsy[MAX_TB_SIZE * MAX_TB_SIZE];
368
18.7k
    if (!avail_t && !avail_l) {
369
9.71k
        FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l);
370
9.71k
        return;
371
9.71k
    }
372
9.05k
    FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy);
373
9.05k
    FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k);
374
9.05k
    FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k);
375
9.05k
}
dsp.c:intra_cclm_pred_10
Line
Count
Source
354
965k
{
355
965k
    VVCFrameContext *fc     = lc->fc;
356
965k
    const VVCSPS *sps = fc->ps.sps;
357
965k
    const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0);
358
965k
    const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0);
359
965k
    const int hs = sps->hshift[1];
360
965k
    const int vs = sps->vshift[1];
361
965k
    const int x  = x0 >> hs;
362
965k
    const int y  = y0 >> vs;
363
965k
    const int w  = width >> hs;
364
965k
    const int h  = height >> vs;
365
965k
    int a[2], b[2], k[2];
366
367
965k
    pixel dsy[MAX_TB_SIZE * MAX_TB_SIZE];
368
965k
    if (!avail_t && !avail_l) {
369
1.60k
        FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l);
370
1.60k
        return;
371
1.60k
    }
372
963k
    FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy);
373
963k
    FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k);
374
963k
    FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k);
375
963k
}
dsp.c:intra_cclm_pred_8
Line
Count
Source
354
28.0k
{
355
28.0k
    VVCFrameContext *fc     = lc->fc;
356
28.0k
    const VVCSPS *sps = fc->ps.sps;
357
28.0k
    const int avail_t = ff_vvc_get_top_available(lc, x0, y0, 1, 0);
358
28.0k
    const int avail_l = ff_vvc_get_left_available(lc, x0, y0, 1, 0);
359
28.0k
    const int hs = sps->hshift[1];
360
28.0k
    const int vs = sps->vshift[1];
361
28.0k
    const int x  = x0 >> hs;
362
28.0k
    const int y  = y0 >> vs;
363
28.0k
    const int w  = width >> hs;
364
28.0k
    const int h  = height >> vs;
365
28.0k
    int a[2], b[2], k[2];
366
367
28.0k
    pixel dsy[MAX_TB_SIZE * MAX_TB_SIZE];
368
28.0k
    if (!avail_t && !avail_l) {
369
27.9k
        FUNC(cclm_pred_default)(fc, x, y, w, h, avail_t, avail_l);
370
27.9k
        return;
371
27.9k
    }
372
96
    FUNC(cclm_get_luma_rec_pixels)(fc, x0, y0, w, h, avail_t, avail_l, dsy);
373
96
    FUNC(cclm_get_params) (lc, x0, y0, w, h, avail_t, avail_l, a, b, k);
374
96
    FUNC(cclm_linear_pred)(fc, x0, y0, w, h, dsy, a, b, k);
375
96
}
376
377
static int FUNC(lmcs_sum_samples)(const pixel *start, ptrdiff_t stride, const int avail, const int target_size)
378
155k
{
379
155k
    const int size = FFMIN(avail, target_size);
380
155k
    int sum = 0;
381
10.0M
    for (int i = 0; i < size; i++) {
382
9.90M
        sum += *start;
383
9.90M
        start += stride;
384
9.90M
    }
385
155k
    sum += *(start - stride) * (target_size - size);
386
155k
    return sum;
387
155k
}
Unexecuted instantiation: dsp.c:lmcs_sum_samples_12
dsp.c:lmcs_sum_samples_10
Line
Count
Source
378
155k
{
379
155k
    const int size = FFMIN(avail, target_size);
380
155k
    int sum = 0;
381
10.0M
    for (int i = 0; i < size; i++) {
382
9.90M
        sum += *start;
383
9.90M
        start += stride;
384
9.90M
    }
385
155k
    sum += *(start - stride) * (target_size - size);
386
155k
    return sum;
387
155k
}
Unexecuted instantiation: dsp.c:lmcs_sum_samples_8
388
389
// 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples
390
static int FUNC(lmcs_derive_chroma_scale)(VVCLocalContext *lc, const int x0, const int y0)
391
516k
{
392
516k
    VVCFrameContext *fc = lc->fc;
393
516k
    const VVCLMCS *lmcs = &fc->ps.lmcs;
394
516k
    const int size_y    = FFMIN(fc->ps.sps->ctb_size_y, 64);
395
396
516k
    const int x = x0 & ~(size_y - 1);
397
516k
    const int y = y0 & ~(size_y - 1);
398
516k
    if (lc->lmcs.x_vpdu != x || lc->lmcs.y_vpdu != y) {
399
83.4k
        int cnt = 0, luma = 0, i;
400
83.4k
        const pixel *src = (const pixel *)(fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift));
401
83.4k
        const ptrdiff_t stride = fc->frame->linesize[LUMA] / sizeof(pixel);
402
83.4k
        const int avail_t = ff_vvc_get_top_available (lc, x, y, 1, 0);
403
83.4k
        const int avail_l = ff_vvc_get_left_available(lc, x, y, 1, 0);
404
83.4k
        if (avail_l) {
405
80.4k
            luma += FUNC(lmcs_sum_samples)(src - 1, stride, fc->ps.pps->height - y, size_y);
406
80.4k
            cnt = size_y;
407
80.4k
        }
408
83.4k
        if (avail_t) {
409
74.8k
            luma += FUNC(lmcs_sum_samples)(src - stride, 1, fc->ps.pps->width - x, size_y);
410
74.8k
            cnt += size_y;
411
74.8k
        }
412
83.4k
        if (cnt)
413
82.5k
            luma = (luma + (cnt >> 1)) >> av_log2(cnt);
414
834
        else
415
834
            luma = 1 << (BIT_DEPTH - 1);
416
417
667k
        for (i = lmcs->min_bin_idx; i <= lmcs->max_bin_idx; i++) {
418
663k
            if (luma < lmcs->pivot[i + 1])
419
79.2k
                break;
420
663k
        }
421
83.4k
        i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1);
422
423
83.4k
        lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i];
424
83.4k
        lc->lmcs.x_vpdu = x;
425
83.4k
        lc->lmcs.y_vpdu = y;
426
83.4k
    }
427
516k
    return lc->lmcs.chroma_scale;
428
516k
}
dsp.c:lmcs_derive_chroma_scale_12
Line
Count
Source
391
20
{
392
20
    VVCFrameContext *fc = lc->fc;
393
20
    const VVCLMCS *lmcs = &fc->ps.lmcs;
394
20
    const int size_y    = FFMIN(fc->ps.sps->ctb_size_y, 64);
395
396
20
    const int x = x0 & ~(size_y - 1);
397
20
    const int y = y0 & ~(size_y - 1);
398
20
    if (lc->lmcs.x_vpdu != x || lc->lmcs.y_vpdu != y) {
399
10
        int cnt = 0, luma = 0, i;
400
10
        const pixel *src = (const pixel *)(fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift));
401
10
        const ptrdiff_t stride = fc->frame->linesize[LUMA] / sizeof(pixel);
402
10
        const int avail_t = ff_vvc_get_top_available (lc, x, y, 1, 0);
403
10
        const int avail_l = ff_vvc_get_left_available(lc, x, y, 1, 0);
404
10
        if (avail_l) {
405
0
            luma += FUNC(lmcs_sum_samples)(src - 1, stride, fc->ps.pps->height - y, size_y);
406
0
            cnt = size_y;
407
0
        }
408
10
        if (avail_t) {
409
0
            luma += FUNC(lmcs_sum_samples)(src - stride, 1, fc->ps.pps->width - x, size_y);
410
0
            cnt += size_y;
411
0
        }
412
10
        if (cnt)
413
0
            luma = (luma + (cnt >> 1)) >> av_log2(cnt);
414
10
        else
415
10
            luma = 1 << (BIT_DEPTH - 1);
416
417
80
        for (i = lmcs->min_bin_idx; i <= lmcs->max_bin_idx; i++) {
418
80
            if (luma < lmcs->pivot[i + 1])
419
10
                break;
420
80
        }
421
10
        i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1);
422
423
10
        lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i];
424
10
        lc->lmcs.x_vpdu = x;
425
10
        lc->lmcs.y_vpdu = y;
426
10
    }
427
20
    return lc->lmcs.chroma_scale;
428
20
}
dsp.c:lmcs_derive_chroma_scale_10
Line
Count
Source
391
516k
{
392
516k
    VVCFrameContext *fc = lc->fc;
393
516k
    const VVCLMCS *lmcs = &fc->ps.lmcs;
394
516k
    const int size_y    = FFMIN(fc->ps.sps->ctb_size_y, 64);
395
396
516k
    const int x = x0 & ~(size_y - 1);
397
516k
    const int y = y0 & ~(size_y - 1);
398
516k
    if (lc->lmcs.x_vpdu != x || lc->lmcs.y_vpdu != y) {
399
83.3k
        int cnt = 0, luma = 0, i;
400
83.3k
        const pixel *src = (const pixel *)(fc->frame->data[LUMA] + y * fc->frame->linesize[LUMA] + (x << fc->ps.sps->pixel_shift));
401
83.3k
        const ptrdiff_t stride = fc->frame->linesize[LUMA] / sizeof(pixel);
402
83.3k
        const int avail_t = ff_vvc_get_top_available (lc, x, y, 1, 0);
403
83.3k
        const int avail_l = ff_vvc_get_left_available(lc, x, y, 1, 0);
404
83.3k
        if (avail_l) {
405
80.4k
            luma += FUNC(lmcs_sum_samples)(src - 1, stride, fc->ps.pps->height - y, size_y);
406
80.4k
            cnt = size_y;
407
80.4k
        }
408
83.3k
        if (avail_t) {
409
74.8k
            luma += FUNC(lmcs_sum_samples)(src - stride, 1, fc->ps.pps->width - x, size_y);
410
74.8k
            cnt += size_y;
411
74.8k
        }
412
83.3k
        if (cnt)
413
82.5k
            luma = (luma + (cnt >> 1)) >> av_log2(cnt);
414
824
        else
415
824
            luma = 1 << (BIT_DEPTH - 1);
416
417
667k
        for (i = lmcs->min_bin_idx; i <= lmcs->max_bin_idx; i++) {
418
663k
            if (luma < lmcs->pivot[i + 1])
419
79.2k
                break;
420
663k
        }
421
83.3k
        i = FFMIN(i, LMCS_MAX_BIN_SIZE - 1);
422
423
83.3k
        lc->lmcs.chroma_scale = lmcs->chroma_scale_coeff[i];
424
83.3k
        lc->lmcs.x_vpdu = x;
425
83.3k
        lc->lmcs.y_vpdu = y;
426
83.3k
    }
427
516k
    return lc->lmcs.chroma_scale;
428
516k
}
Unexecuted instantiation: dsp.c:lmcs_derive_chroma_scale_8
429
430
// 8.7.5.3 Picture reconstruction with luma dependent chroma residual scaling process for chroma samples
431
static void FUNC(lmcs_scale_chroma)(VVCLocalContext *lc, int *coeff,
432
    const int width, const int height, const int x0_cu, const int y0_cu)
433
516k
{
434
516k
    const int chroma_scale = FUNC(lmcs_derive_chroma_scale)(lc, x0_cu, y0_cu);
435
436
6.66M
    for (int y = 0; y < height; y++) {
437
120M
        for (int x = 0; x < width; x++) {
438
113M
            const int c = av_clip_intp2(*coeff, BIT_DEPTH);
439
440
113M
            if (c > 0)
441
73.1M
                *coeff = (c * chroma_scale + (1 << 10)) >> 11;
442
40.7M
            else
443
40.7M
                *coeff = -((-c * chroma_scale + (1 << 10)) >> 11);
444
113M
            coeff++;
445
113M
        }
446
6.15M
    }
447
516k
}
dsp.c:lmcs_scale_chroma_12
Line
Count
Source
433
20
{
434
20
    const int chroma_scale = FUNC(lmcs_derive_chroma_scale)(lc, x0_cu, y0_cu);
435
436
100
    for (int y = 0; y < height; y++) {
437
400
        for (int x = 0; x < width; x++) {
438
320
            const int c = av_clip_intp2(*coeff, BIT_DEPTH);
439
440
320
            if (c > 0)
441
160
                *coeff = (c * chroma_scale + (1 << 10)) >> 11;
442
160
            else
443
160
                *coeff = -((-c * chroma_scale + (1 << 10)) >> 11);
444
320
            coeff++;
445
320
        }
446
80
    }
447
20
}
dsp.c:lmcs_scale_chroma_10
Line
Count
Source
433
516k
{
434
516k
    const int chroma_scale = FUNC(lmcs_derive_chroma_scale)(lc, x0_cu, y0_cu);
435
436
6.66M
    for (int y = 0; y < height; y++) {
437
120M
        for (int x = 0; x < width; x++) {
438
113M
            const int c = av_clip_intp2(*coeff, BIT_DEPTH);
439
440
113M
            if (c > 0)
441
73.1M
                *coeff = (c * chroma_scale + (1 << 10)) >> 11;
442
40.7M
            else
443
40.7M
                *coeff = -((-c * chroma_scale + (1 << 10)) >> 11);
444
113M
            coeff++;
445
113M
        }
446
6.15M
    }
447
516k
}
Unexecuted instantiation: dsp.c:lmcs_scale_chroma_8
448
449
static av_always_inline void FUNC(ref_filter)(const pixel *left, const pixel *top,
450
    pixel *filtered_left, pixel *filtered_top, const int left_size, const int top_size,
451
    const int unfilter_last_one)
452
1.31M
{
453
1.31M
    filtered_left[-1] = filtered_top[-1] = (left[0] +  2 * left[-1] + top[0] + 2 ) >> 2;
454
35.9M
    for (int i = 0; i < left_size - unfilter_last_one; i++) {
455
34.6M
        filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2;
456
34.6M
    }
457
37.7M
    for (int i = 0; i < top_size - unfilter_last_one; i++) {
458
36.4M
        filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2;
459
36.4M
    }
460
1.31M
    if (unfilter_last_one) {
461
15.5k
        filtered_top[top_size - 1] = top[top_size - 1];
462
15.5k
        filtered_left[left_size - 1] = left[left_size - 1];
463
15.5k
    }
464
1.31M
}
dsp.c:ref_filter_12
Line
Count
Source
452
3.62k
{
453
3.62k
    filtered_left[-1] = filtered_top[-1] = (left[0] +  2 * left[-1] + top[0] + 2 ) >> 2;
454
39.8k
    for (int i = 0; i < left_size - unfilter_last_one; i++) {
455
36.2k
        filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2;
456
36.2k
    }
457
39.8k
    for (int i = 0; i < top_size - unfilter_last_one; i++) {
458
36.2k
        filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2;
459
36.2k
    }
460
3.62k
    if (unfilter_last_one) {
461
3
        filtered_top[top_size - 1] = top[top_size - 1];
462
3
        filtered_left[left_size - 1] = left[left_size - 1];
463
3
    }
464
3.62k
}
dsp.c:ref_filter_10
Line
Count
Source
452
1.30M
{
453
1.30M
    filtered_left[-1] = filtered_top[-1] = (left[0] +  2 * left[-1] + top[0] + 2 ) >> 2;
454
35.8M
    for (int i = 0; i < left_size - unfilter_last_one; i++) {
455
34.5M
        filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2;
456
34.5M
    }
457
37.7M
    for (int i = 0; i < top_size - unfilter_last_one; i++) {
458
36.4M
        filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2;
459
36.4M
    }
460
1.30M
    if (unfilter_last_one) {
461
15.4k
        filtered_top[top_size - 1] = top[top_size - 1];
462
15.4k
        filtered_left[left_size - 1] = left[left_size - 1];
463
15.4k
    }
464
1.30M
}
dsp.c:ref_filter_8
Line
Count
Source
452
672
{
453
672
    filtered_left[-1] = filtered_top[-1] = (left[0] +  2 * left[-1] + top[0] + 2 ) >> 2;
454
7.77k
    for (int i = 0; i < left_size - unfilter_last_one; i++) {
455
7.10k
        filtered_left[i] = (left[i- 1] + 2 * left[i] + left[i + 1] + 2) >> 2;
456
7.10k
    }
457
7.77k
    for (int i = 0; i < top_size - unfilter_last_one; i++) {
458
7.10k
        filtered_top[i] = (top[i-1] + 2 * top[i] + top[i + 1] + 2) >> 2;
459
7.10k
    }
460
672
    if (unfilter_last_one) {
461
76
        filtered_top[top_size - 1] = top[top_size - 1];
462
76
        filtered_left[left_size - 1] = left[left_size - 1];
463
76
    }
464
672
}
465
466
static av_always_inline void FUNC(prepare_intra_edge_params)(const VVCLocalContext *lc,
467
    IntraEdgeParams* edge, const pixel *src, const ptrdiff_t stride,
468
    const int x, int y, int w, int h, int c_idx, const int is_intra_mip,
469
    const int mode, const int ref_idx, const int need_pdpc)
470
4.52M
{
471
9.04M
#define EXTEND(ptr, val, len)         \
472
9.04M
do {                                  \
473
37.6M
    for (i = 0; i < (len); i++)       \
474
28.6M
        *(ptr + i) = val;             \
475
9.04M
} while (0)
476
4.52M
    const CodingUnit *cu = lc->cu;
477
4.52M
    const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode);
478
4.52M
    const int filter_flag = !ref_idx && w * h > 32 && !c_idx &&
479
2.12M
        cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag;
480
4.52M
    int cand_up_left      = lc->na.cand_up_left;
481
4.52M
    pixel  *left          = (pixel*)edge->left_array + MAX_TB_SIZE + 3;
482
4.52M
    pixel  *top           = (pixel*)edge->top_array  + MAX_TB_SIZE + 3;
483
4.52M
    pixel  *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3;
484
4.52M
    pixel  *filtered_top  = (pixel*)edge->filtered_top_array  + MAX_TB_SIZE + 3;
485
4.52M
    const int ref_line = ref_idx == 3 ? -4 : (-1 - ref_idx);
486
4.52M
    int left_size, top_size, unfilter_left_size, unfilter_top_size;
487
4.52M
    int left_available, top_available;
488
4.52M
    int refw, refh;
489
4.52M
    int intra_pred_angle, inv_angle;
490
4.52M
    int i;
491
492
4.52M
    if (is_intra_mip || mode == INTRA_PLANAR) {
493
2.62M
        left_size = h + 1;
494
2.62M
        top_size  = w + 1;
495
2.62M
        unfilter_left_size = left_size + filter_flag;
496
2.62M
        unfilter_top_size  = top_size  + filter_flag;
497
2.62M
    } else if (mode == INTRA_DC) {
498
465k
        unfilter_left_size = left_size = h;
499
465k
        unfilter_top_size = top_size  = w;
500
1.43M
    } else if (mode == INTRA_VERT) {
501
        //we may need 1 pixel to predict the top left.
502
162k
        unfilter_left_size = left_size = need_pdpc ? h : 1;
503
162k
        unfilter_top_size = top_size  = w;
504
1.26M
    } else if (mode == INTRA_HORZ) {
505
118k
        unfilter_left_size = left_size = h;
506
        //even need_pdpc == 0, we may need 1 pixel to predict the top left.
507
118k
        unfilter_top_size = top_size = need_pdpc ? w : 1;
508
1.14M
    } else {
509
1.14M
        if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) {
510
1.08M
            refw = w * 2;
511
1.08M
            refh = h * 2;
512
1.08M
        } else {
513
60.8k
            refw = cu->cb_width + w;
514
60.8k
            refh = cu->cb_height + h;
515
60.8k
        }
516
1.14M
        intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
517
1.14M
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
518
1.14M
        unfilter_top_size = top_size  = refw;
519
1.14M
        unfilter_left_size = left_size = refh;
520
1.14M
    }
521
522
4.52M
    left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx);
523
83.1M
    for (i = 0; i < left_available; i++)
524
78.6M
        left[i] = POS(ref_line, i);
525
526
4.52M
    top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx);
527
4.52M
    memcpy(top, src + ref_line * stride, top_available * sizeof(pixel));
528
529
9.10M
    for (int i = -1; i >= ref_line; i--) {
530
4.58M
        if (cand_up_left) {
531
4.22M
            left[i] = POS(ref_line, i);
532
4.22M
            top[i]  = POS(i, ref_line);
533
4.22M
        } else if (left_available) {
534
116k
            left[i] = top[i] = left[0];
535
245k
        } else if (top_available) {
536
115k
            left[i] = top[i] = top[0];
537
130k
        } else {
538
130k
            left[i] = top[i] = 1 << (BIT_DEPTH - 1);
539
130k
        }
540
4.58M
    }
541
542
4.52M
    EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available);
543
4.52M
    EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available);
544
545
4.52M
    if (ref_filter_flag) {
546
2.66M
        if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) {
547
1.31M
            const int unfilter_last_one = left_size == unfilter_left_size;
548
1.31M
            FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one);
549
1.31M
            left = filtered_left;
550
1.31M
            top  = filtered_top;
551
1.31M
        }
552
2.66M
    }
553
4.52M
    if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) {
554
1.43M
        if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) {
555
167k
            edge->filter_flag = 0;
556
1.26M
        } else {
557
1.26M
            const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18));
558
1.26M
            const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0};
559
1.26M
            const int ntbs = (av_log2(w) + av_log2(h)) >> 1;
560
1.26M
            edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2];
561
1.26M
        }
562
563
1.43M
        if (mode != INTRA_VERT && mode != INTRA_HORZ) {
564
1.14M
            if (mode >= INTRA_DIAG) {
565
633k
                if (intra_pred_angle < 0) {
566
329k
                    pixel *p = top - (ref_idx + 1);
567
4.34M
                    for (int x = -h; x < 0; x++) {
568
4.01M
                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h);
569
4.01M
                        p[x] = left[idx];
570
4.01M
                    }
571
329k
                } else {
572
936k
                    for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++)
573
632k
                        top[i] = top[refw - 1];
574
304k
                }
575
633k
            } else {
576
515k
                if (intra_pred_angle < 0) {
577
243k
                    pixel *p = left - (ref_idx + 1);
578
3.43M
                    for (int x = -w; x < 0; x++) {
579
3.19M
                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w);
580
3.19M
                        p[x] = top[idx];
581
3.19M
                    }
582
272k
                } else {
583
833k
                    for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++)
584
560k
                        left[i] = left[refh - 1];
585
272k
                }
586
515k
            }
587
1.14M
        }
588
1.43M
    }
589
4.52M
    edge->left = (uint8_t*)left;
590
4.52M
    edge->top  = (uint8_t*)top;
591
4.52M
}
dsp.c:prepare_intra_edge_params_12
Line
Count
Source
470
126k
{
471
126k
#define EXTEND(ptr, val, len)         \
472
126k
do {                                  \
473
126k
    for (i = 0; i < (len); i++)       \
474
126k
        *(ptr + i) = val;             \
475
126k
} while (0)
476
126k
    const CodingUnit *cu = lc->cu;
477
126k
    const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode);
478
126k
    const int filter_flag = !ref_idx && w * h > 32 && !c_idx &&
479
7.40k
        cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag;
480
126k
    int cand_up_left      = lc->na.cand_up_left;
481
126k
    pixel  *left          = (pixel*)edge->left_array + MAX_TB_SIZE + 3;
482
126k
    pixel  *top           = (pixel*)edge->top_array  + MAX_TB_SIZE + 3;
483
126k
    pixel  *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3;
484
126k
    pixel  *filtered_top  = (pixel*)edge->filtered_top_array  + MAX_TB_SIZE + 3;
485
126k
    const int ref_line = ref_idx == 3 ? -4 : (-1 - ref_idx);
486
126k
    int left_size, top_size, unfilter_left_size, unfilter_top_size;
487
126k
    int left_available, top_available;
488
126k
    int refw, refh;
489
126k
    int intra_pred_angle, inv_angle;
490
126k
    int i;
491
492
126k
    if (is_intra_mip || mode == INTRA_PLANAR) {
493
19.2k
        left_size = h + 1;
494
19.2k
        top_size  = w + 1;
495
19.2k
        unfilter_left_size = left_size + filter_flag;
496
19.2k
        unfilter_top_size  = top_size  + filter_flag;
497
107k
    } else if (mode == INTRA_DC) {
498
20.4k
        unfilter_left_size = left_size = h;
499
20.4k
        unfilter_top_size = top_size  = w;
500
86.9k
    } else if (mode == INTRA_VERT) {
501
        //we may need 1 pixel to predict the top left.
502
52.1k
        unfilter_left_size = left_size = need_pdpc ? h : 1;
503
52.1k
        unfilter_top_size = top_size  = w;
504
52.1k
    } else if (mode == INTRA_HORZ) {
505
13.8k
        unfilter_left_size = left_size = h;
506
        //even need_pdpc == 0, we may need 1 pixel to predict the top left.
507
13.8k
        unfilter_top_size = top_size = need_pdpc ? w : 1;
508
20.9k
    } else {
509
20.9k
        if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) {
510
20.6k
            refw = w * 2;
511
20.6k
            refh = h * 2;
512
20.6k
        } else {
513
357
            refw = cu->cb_width + w;
514
357
            refh = cu->cb_height + h;
515
357
        }
516
20.9k
        intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
517
20.9k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
518
20.9k
        unfilter_top_size = top_size  = refw;
519
20.9k
        unfilter_left_size = left_size = refh;
520
20.9k
    }
521
522
126k
    left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx);
523
216k
    for (i = 0; i < left_available; i++)
524
89.7k
        left[i] = POS(ref_line, i);
525
526
126k
    top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx);
527
126k
    memcpy(top, src + ref_line * stride, top_available * sizeof(pixel));
528
529
254k
    for (int i = -1; i >= ref_line; i--) {
530
127k
        if (cand_up_left) {
531
13.0k
            left[i] = POS(ref_line, i);
532
13.0k
            top[i]  = POS(i, ref_line);
533
114k
        } else if (left_available) {
534
14.9k
            left[i] = top[i] = left[0];
535
99.3k
        } else if (top_available) {
536
42.5k
            left[i] = top[i] = top[0];
537
56.8k
        } else {
538
56.8k
            left[i] = top[i] = 1 << (BIT_DEPTH - 1);
539
56.8k
        }
540
127k
    }
541
542
126k
    EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available);
543
126k
    EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available);
544
545
126k
    if (ref_filter_flag) {
546
17.9k
        if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) {
547
3.62k
            const int unfilter_last_one = left_size == unfilter_left_size;
548
3.62k
            FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one);
549
3.62k
            left = filtered_left;
550
3.62k
            top  = filtered_top;
551
3.62k
        }
552
17.9k
    }
553
126k
    if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) {
554
86.9k
        if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) {
555
4.49k
            edge->filter_flag = 0;
556
82.4k
        } else {
557
82.4k
            const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18));
558
82.4k
            const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0};
559
82.4k
            const int ntbs = (av_log2(w) + av_log2(h)) >> 1;
560
82.4k
            edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2];
561
82.4k
        }
562
563
86.9k
        if (mode != INTRA_VERT && mode != INTRA_HORZ) {
564
20.9k
            if (mode >= INTRA_DIAG) {
565
18.1k
                if (intra_pred_angle < 0) {
566
6.13k
                    pixel *p = top - (ref_idx + 1);
567
30.8k
                    for (int x = -h; x < 0; x++) {
568
24.7k
                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h);
569
24.7k
                        p[x] = left[idx];
570
24.7k
                    }
571
12.0k
                } else {
572
36.4k
                    for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++)
573
24.4k
                        top[i] = top[refw - 1];
574
12.0k
                }
575
18.1k
            } else {
576
2.85k
                if (intra_pred_angle < 0) {
577
1.29k
                    pixel *p = left - (ref_idx + 1);
578
10.5k
                    for (int x = -w; x < 0; x++) {
579
9.22k
                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w);
580
9.22k
                        p[x] = top[idx];
581
9.22k
                    }
582
1.55k
                } else {
583
4.67k
                    for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++)
584
3.11k
                        left[i] = left[refh - 1];
585
1.55k
                }
586
2.85k
            }
587
20.9k
        }
588
86.9k
    }
589
126k
    edge->left = (uint8_t*)left;
590
126k
    edge->top  = (uint8_t*)top;
591
126k
}
dsp.c:prepare_intra_edge_params_10
Line
Count
Source
470
4.26M
{
471
4.26M
#define EXTEND(ptr, val, len)         \
472
4.26M
do {                                  \
473
4.26M
    for (i = 0; i < (len); i++)       \
474
4.26M
        *(ptr + i) = val;             \
475
4.26M
} while (0)
476
4.26M
    const CodingUnit *cu = lc->cu;
477
4.26M
    const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode);
478
4.26M
    const int filter_flag = !ref_idx && w * h > 32 && !c_idx &&
479
2.10M
        cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag;
480
4.26M
    int cand_up_left      = lc->na.cand_up_left;
481
4.26M
    pixel  *left          = (pixel*)edge->left_array + MAX_TB_SIZE + 3;
482
4.26M
    pixel  *top           = (pixel*)edge->top_array  + MAX_TB_SIZE + 3;
483
4.26M
    pixel  *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3;
484
4.26M
    pixel  *filtered_top  = (pixel*)edge->filtered_top_array  + MAX_TB_SIZE + 3;
485
4.26M
    const int ref_line = ref_idx == 3 ? -4 : (-1 - ref_idx);
486
4.26M
    int left_size, top_size, unfilter_left_size, unfilter_top_size;
487
4.26M
    int left_available, top_available;
488
4.26M
    int refw, refh;
489
4.26M
    int intra_pred_angle, inv_angle;
490
4.26M
    int i;
491
492
4.26M
    if (is_intra_mip || mode == INTRA_PLANAR) {
493
2.58M
        left_size = h + 1;
494
2.58M
        top_size  = w + 1;
495
2.58M
        unfilter_left_size = left_size + filter_flag;
496
2.58M
        unfilter_top_size  = top_size  + filter_flag;
497
2.58M
    } else if (mode == INTRA_DC) {
498
436k
        unfilter_left_size = left_size = h;
499
436k
        unfilter_top_size = top_size  = w;
500
1.23M
    } else if (mode == INTRA_VERT) {
501
        //we may need 1 pixel to predict the top left.
502
104k
        unfilter_left_size = left_size = need_pdpc ? h : 1;
503
104k
        unfilter_top_size = top_size  = w;
504
1.13M
    } else if (mode == INTRA_HORZ) {
505
80.9k
        unfilter_left_size = left_size = h;
506
        //even need_pdpc == 0, we may need 1 pixel to predict the top left.
507
80.9k
        unfilter_top_size = top_size = need_pdpc ? w : 1;
508
1.05M
    } else {
509
1.05M
        if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) {
510
999k
            refw = w * 2;
511
999k
            refh = h * 2;
512
999k
        } else {
513
54.5k
            refw = cu->cb_width + w;
514
54.5k
            refh = cu->cb_height + h;
515
54.5k
        }
516
1.05M
        intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
517
1.05M
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
518
1.05M
        unfilter_top_size = top_size  = refw;
519
1.05M
        unfilter_left_size = left_size = refh;
520
1.05M
    }
521
522
4.26M
    left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx);
523
82.6M
    for (i = 0; i < left_available; i++)
524
78.3M
        left[i] = POS(ref_line, i);
525
526
4.26M
    top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx);
527
4.26M
    memcpy(top, src + ref_line * stride, top_available * sizeof(pixel));
528
529
8.58M
    for (int i = -1; i >= ref_line; i--) {
530
4.32M
        if (cand_up_left) {
531
4.18M
            left[i] = POS(ref_line, i);
532
4.18M
            top[i]  = POS(i, ref_line);
533
4.18M
        } else if (left_available) {
534
76.9k
            left[i] = top[i] = left[0];
535
76.9k
        } else if (top_available) {
536
38.6k
            left[i] = top[i] = top[0];
537
38.6k
        } else {
538
21.7k
            left[i] = top[i] = 1 << (BIT_DEPTH - 1);
539
21.7k
        }
540
4.32M
    }
541
542
4.26M
    EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available);
543
4.26M
    EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available);
544
545
4.26M
    if (ref_filter_flag) {
546
2.63M
        if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) {
547
1.30M
            const int unfilter_last_one = left_size == unfilter_left_size;
548
1.30M
            FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one);
549
1.30M
            left = filtered_left;
550
1.30M
            top  = filtered_top;
551
1.30M
        }
552
2.63M
    }
553
4.26M
    if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) {
554
1.23M
        if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) {
555
151k
            edge->filter_flag = 0;
556
1.08M
        } else {
557
1.08M
            const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18));
558
1.08M
            const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0};
559
1.08M
            const int ntbs = (av_log2(w) + av_log2(h)) >> 1;
560
1.08M
            edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2];
561
1.08M
        }
562
563
1.23M
        if (mode != INTRA_VERT && mode != INTRA_HORZ) {
564
1.05M
            if (mode >= INTRA_DIAG) {
565
598k
                if (intra_pred_angle < 0) {
566
310k
                    pixel *p = top - (ref_idx + 1);
567
4.25M
                    for (int x = -h; x < 0; x++) {
568
3.93M
                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h);
569
3.93M
                        p[x] = left[idx];
570
3.93M
                    }
571
310k
                } else {
572
884k
                    for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++)
573
596k
                        top[i] = top[refw - 1];
574
287k
                }
575
598k
            } else {
576
455k
                if (intra_pred_angle < 0) {
577
205k
                    pixel *p = left - (ref_idx + 1);
578
3.24M
                    for (int x = -w; x < 0; x++) {
579
3.03M
                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w);
580
3.03M
                        p[x] = top[idx];
581
3.03M
                    }
582
249k
                } else {
583
765k
                    for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++)
584
515k
                        left[i] = left[refh - 1];
585
249k
                }
586
455k
            }
587
1.05M
        }
588
1.23M
    }
589
4.26M
    edge->left = (uint8_t*)left;
590
4.26M
    edge->top  = (uint8_t*)top;
591
4.26M
}
dsp.c:prepare_intra_edge_params_8
Line
Count
Source
470
133k
{
471
133k
#define EXTEND(ptr, val, len)         \
472
133k
do {                                  \
473
133k
    for (i = 0; i < (len); i++)       \
474
133k
        *(ptr + i) = val;             \
475
133k
} while (0)
476
133k
    const CodingUnit *cu = lc->cu;
477
133k
    const int ref_filter_flag = is_intra_mip ? 0 : ff_vvc_ref_filter_flag_derive(mode);
478
133k
    const int filter_flag = !ref_idx && w * h > 32 && !c_idx &&
479
6.79k
        cu->isp_split_type == ISP_NO_SPLIT && ref_filter_flag;
480
133k
    int cand_up_left      = lc->na.cand_up_left;
481
133k
    pixel  *left          = (pixel*)edge->left_array + MAX_TB_SIZE + 3;
482
133k
    pixel  *top           = (pixel*)edge->top_array  + MAX_TB_SIZE + 3;
483
133k
    pixel  *filtered_left = (pixel*)edge->filtered_left_array + MAX_TB_SIZE + 3;
484
133k
    pixel  *filtered_top  = (pixel*)edge->filtered_top_array  + MAX_TB_SIZE + 3;
485
133k
    const int ref_line = ref_idx == 3 ? -4 : (-1 - ref_idx);
486
133k
    int left_size, top_size, unfilter_left_size, unfilter_top_size;
487
133k
    int left_available, top_available;
488
133k
    int refw, refh;
489
133k
    int intra_pred_angle, inv_angle;
490
133k
    int i;
491
492
133k
    if (is_intra_mip || mode == INTRA_PLANAR) {
493
20.2k
        left_size = h + 1;
494
20.2k
        top_size  = w + 1;
495
20.2k
        unfilter_left_size = left_size + filter_flag;
496
20.2k
        unfilter_top_size  = top_size  + filter_flag;
497
113k
    } else if (mode == INTRA_DC) {
498
9.22k
        unfilter_left_size = left_size = h;
499
9.22k
        unfilter_top_size = top_size  = w;
500
104k
    } else if (mode == INTRA_VERT) {
501
        //we may need 1 pixel to predict the top left.
502
5.50k
        unfilter_left_size = left_size = need_pdpc ? h : 1;
503
5.50k
        unfilter_top_size = top_size  = w;
504
98.5k
    } else if (mode == INTRA_HORZ) {
505
24.0k
        unfilter_left_size = left_size = h;
506
        //even need_pdpc == 0, we may need 1 pixel to predict the top left.
507
24.0k
        unfilter_top_size = top_size = need_pdpc ? w : 1;
508
74.5k
    } else {
509
74.5k
        if (cu->isp_split_type == ISP_NO_SPLIT || c_idx) {
510
68.4k
            refw = w * 2;
511
68.4k
            refh = h * 2;
512
68.4k
        } else {
513
6.03k
            refw = cu->cb_width + w;
514
6.03k
            refh = cu->cb_height + h;
515
6.03k
        }
516
74.5k
        intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
517
74.5k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
518
74.5k
        unfilter_top_size = top_size  = refw;
519
74.5k
        unfilter_left_size = left_size = refh;
520
74.5k
    }
521
522
133k
    left_available = ff_vvc_get_left_available(lc, x, y, unfilter_left_size, c_idx);
523
328k
    for (i = 0; i < left_available; i++)
524
194k
        left[i] = POS(ref_line, i);
525
526
133k
    top_available = ff_vvc_get_top_available(lc, x, y, unfilter_top_size, c_idx);
527
133k
    memcpy(top, src + ref_line * stride, top_available * sizeof(pixel));
528
529
267k
    for (int i = -1; i >= ref_line; i--) {
530
134k
        if (cand_up_left) {
531
23.8k
            left[i] = POS(ref_line, i);
532
23.8k
            top[i]  = POS(i, ref_line);
533
110k
        } else if (left_available) {
534
24.2k
            left[i] = top[i] = left[0];
535
85.8k
        } else if (top_available) {
536
34.4k
            left[i] = top[i] = top[0];
537
51.4k
        } else {
538
51.4k
            left[i] = top[i] = 1 << (BIT_DEPTH - 1);
539
51.4k
        }
540
134k
    }
541
542
133k
    EXTEND(top + top_available, top[top_available-1], unfilter_top_size - top_available);
543
133k
    EXTEND(left + left_available, left[left_available-1], unfilter_left_size - left_available);
544
545
133k
    if (ref_filter_flag) {
546
19.7k
        if (!ref_idx && w * h > 32 && !c_idx && cu->isp_split_type == ISP_NO_SPLIT ) {
547
672
            const int unfilter_last_one = left_size == unfilter_left_size;
548
672
            FUNC(ref_filter)(left, top, filtered_left, filtered_top, unfilter_left_size, unfilter_top_size, unfilter_last_one);
549
672
            left = filtered_left;
550
672
            top  = filtered_top;
551
672
        }
552
19.7k
    }
553
133k
    if (!is_intra_mip && mode != INTRA_PLANAR && mode != INTRA_DC) {
554
104k
        if (ref_filter_flag || ref_idx || cu->isp_split_type != ISP_NO_SPLIT) {
555
11.6k
            edge->filter_flag = 0;
556
92.4k
        } else {
557
92.4k
            const int min_dist_ver_hor = FFMIN(abs(mode - 50), abs(mode - 18));
558
92.4k
            const int intra_hor_ver_dist_thres[] = {24, 14, 2, 0, 0};
559
92.4k
            const int ntbs = (av_log2(w) + av_log2(h)) >> 1;
560
92.4k
            edge->filter_flag = min_dist_ver_hor > intra_hor_ver_dist_thres[ntbs - 2];
561
92.4k
        }
562
563
104k
        if (mode != INTRA_VERT && mode != INTRA_HORZ) {
564
74.5k
            if (mode >= INTRA_DIAG) {
565
17.3k
                if (intra_pred_angle < 0) {
566
12.1k
                    pixel *p = top - (ref_idx + 1);
567
61.5k
                    for (int x = -h; x < 0; x++) {
568
49.3k
                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, h);
569
49.3k
                        p[x] = left[idx];
570
49.3k
                    }
571
12.1k
                } else {
572
15.9k
                    for (int i = refw; i <= refw + FFMAX(1, w/h) * ref_idx + 1; i++)
573
10.7k
                        top[i] = top[refw - 1];
574
5.19k
                }
575
57.1k
            } else {
576
57.1k
                if (intra_pred_angle < 0) {
577
36.0k
                    pixel *p = left - (ref_idx + 1);
578
180k
                    for (int x = -w; x < 0; x++) {
579
144k
                        const int idx = -1 - ref_idx + FFMIN((x*inv_angle + 256) >> 9, w);
580
144k
                        p[x] = top[idx];
581
144k
                    }
582
36.0k
                } else {
583
63.5k
                    for (int i = refh; i <= refh + FFMAX(1, h/w) * ref_idx + 1; i++)
584
42.3k
                        left[i] = left[refh - 1];
585
21.1k
                }
586
57.1k
            }
587
74.5k
        }
588
104k
    }
589
133k
    edge->left = (uint8_t*)left;
590
133k
    edge->top  = (uint8_t*)top;
591
133k
}
592
593
//8.4.1 General decoding process for coding units coded in intra prediction mode
594
static void FUNC(intra_pred)(const VVCLocalContext *lc, int x0, int y0,
595
    const int width, const int height, int c_idx)
596
4.52M
{
597
4.52M
    VVCFrameContext *fc     = lc->fc;
598
4.52M
    const VVCSPS *sps = fc->ps.sps;
599
4.52M
    const VVCPPS *pps = fc->ps.pps;
600
4.52M
    const CodingUnit *cu = lc->cu;
601
4.52M
    const int log2_min_cb_size    = sps->min_cb_log2_size_y;
602
4.52M
    const int min_cb_width        = pps->min_cb_width;
603
4.52M
    const int x_cb                = x0 >> log2_min_cb_size;
604
4.52M
    const int y_cb                = y0 >> log2_min_cb_size;
605
606
4.52M
    const int hshift = fc->ps.sps->hshift[c_idx];
607
4.52M
    const int vshift = fc->ps.sps->vshift[c_idx];
608
4.52M
    const int x = x0 >> hshift;
609
4.52M
    const int y = y0 >> vshift;
610
4.52M
    const int w = width >> hshift;
611
4.52M
    const int h = height >> vshift;
612
4.52M
    const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
613
614
4.52M
    const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y;
615
4.52M
    const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode);
616
617
4.52M
    const int intra_mip_flag  = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb);
618
4.52M
    const int is_intra_mip    = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag);
619
4.52M
    const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx;
620
4.52M
    const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx);
621
622
623
4.52M
    pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
624
4.52M
    IntraEdgeParams edge;
625
626
4.52M
    FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc);
627
628
4.52M
    if (is_intra_mip) {
629
21.4k
        int intra_mip_transposed_flag;
630
21.4k
        int intra_mip_mode;
631
21.4k
        unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag);
632
633
21.4k
        fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left,
634
21.4k
                        w, h, stride, intra_mip_mode, intra_mip_transposed_flag);
635
4.50M
    } else if (mode == INTRA_PLANAR) {
636
2.60M
        fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride);
637
2.60M
    } else if (mode == INTRA_DC) {
638
465k
        fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride);
639
1.43M
    } else if (mode == INTRA_VERT) {
640
162k
        fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride);
641
1.26M
    } else if (mode == INTRA_HORZ) {
642
118k
        fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride);
643
1.14M
    } else {
644
1.14M
        if (mode >= INTRA_DIAG) {
645
633k
            fc->vvcdsp.intra.pred_angular_v((uint8_t *)src, edge.top, edge.left,
646
633k
                                  w, h, stride, c_idx, mode, ref_idx,
647
633k
                                  edge.filter_flag, need_pdpc);
648
633k
        } else {
649
515k
            fc->vvcdsp.intra.pred_angular_h((uint8_t *)src, edge.top, edge.left,
650
515k
                                  w, h, stride, c_idx, mode, ref_idx,
651
515k
                                  edge.filter_flag, need_pdpc);
652
515k
        }
653
1.14M
    }
654
4.52M
    if (need_pdpc) {
655
        //8.4.5.2.15 Position-dependent intra prediction sample filtering process
656
3.50M
        if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC ||
657
3.21M
            mode == INTRA_VERT || mode == INTRA_HORZ)) {
658
3.21M
            const int scale = (av_log2(w) + av_log2(h) - 2) >> 2;
659
3.21M
            const pixel *left = (pixel*)edge.left;
660
3.21M
            const pixel *top  = (pixel*)edge.top;
661
63.5M
            for (int y = 0; y < h; y++) {
662
1.73G
                for (int x = 0; x < w; x++) {
663
1.67G
                    int l, t, wl, wt, pred;
664
1.67G
                    pixel val;
665
1.67G
                    if (mode == INTRA_PLANAR || mode == INTRA_DC) {
666
1.61G
                        l  = left[y];
667
1.61G
                        t = top[x];
668
1.61G
                        wl = 32 >> FFMIN((x << 1) >> scale, 31);
669
1.61G
                        wt = 32 >> FFMIN((y << 1) >> scale, 31);
670
1.61G
                    } else {
671
57.4M
                        l  = left[y] - left[-1] + POS(x,y);
672
57.4M
                        t = top[x] - top[-1] + POS(x,y);
673
57.4M
                        wl = (mode == INTRA_VERT) ?  (32 >> FFMIN((x << 1) >> scale, 31)) : 0;
674
57.4M
                        wt = (mode == INTRA_HORZ) ?  (32 >> FFMIN((y << 1) >> scale, 31)) : 0;
675
57.4M
                    }
676
1.67G
                    val = POS(x, y);
677
1.67G
                    pred  = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6);
678
1.67G
                    POS(x, y) = CLIP(pred);
679
1.67G
                }
680
60.3M
            }
681
3.21M
        }
682
3.50M
    }
683
4.52M
}
dsp.c:intra_pred_12
Line
Count
Source
596
126k
{
597
126k
    VVCFrameContext *fc     = lc->fc;
598
126k
    const VVCSPS *sps = fc->ps.sps;
599
126k
    const VVCPPS *pps = fc->ps.pps;
600
126k
    const CodingUnit *cu = lc->cu;
601
126k
    const int log2_min_cb_size    = sps->min_cb_log2_size_y;
602
126k
    const int min_cb_width        = pps->min_cb_width;
603
126k
    const int x_cb                = x0 >> log2_min_cb_size;
604
126k
    const int y_cb                = y0 >> log2_min_cb_size;
605
606
126k
    const int hshift = fc->ps.sps->hshift[c_idx];
607
126k
    const int vshift = fc->ps.sps->vshift[c_idx];
608
126k
    const int x = x0 >> hshift;
609
126k
    const int y = y0 >> vshift;
610
126k
    const int w = width >> hshift;
611
126k
    const int h = height >> vshift;
612
126k
    const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
613
614
126k
    const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y;
615
126k
    const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode);
616
617
126k
    const int intra_mip_flag  = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb);
618
126k
    const int is_intra_mip    = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag);
619
126k
    const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx;
620
126k
    const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx);
621
622
623
126k
    pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
624
126k
    IntraEdgeParams edge;
625
626
126k
    FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc);
627
628
126k
    if (is_intra_mip) {
629
4.28k
        int intra_mip_transposed_flag;
630
4.28k
        int intra_mip_mode;
631
4.28k
        unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag);
632
633
4.28k
        fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left,
634
4.28k
                        w, h, stride, intra_mip_mode, intra_mip_transposed_flag);
635
122k
    } else if (mode == INTRA_PLANAR) {
636
15.0k
        fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride);
637
107k
    } else if (mode == INTRA_DC) {
638
20.4k
        fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride);
639
86.9k
    } else if (mode == INTRA_VERT) {
640
52.1k
        fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride);
641
52.1k
    } else if (mode == INTRA_HORZ) {
642
13.8k
        fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride);
643
20.9k
    } else {
644
20.9k
        if (mode >= INTRA_DIAG) {
645
18.1k
            fc->vvcdsp.intra.pred_angular_v((uint8_t *)src, edge.top, edge.left,
646
18.1k
                                  w, h, stride, c_idx, mode, ref_idx,
647
18.1k
                                  edge.filter_flag, need_pdpc);
648
18.1k
        } else {
649
2.85k
            fc->vvcdsp.intra.pred_angular_h((uint8_t *)src, edge.top, edge.left,
650
2.85k
                                  w, h, stride, c_idx, mode, ref_idx,
651
2.85k
                                  edge.filter_flag, need_pdpc);
652
2.85k
        }
653
20.9k
    }
654
126k
    if (need_pdpc) {
655
        //8.4.5.2.15 Position-dependent intra prediction sample filtering process
656
84.1k
        if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC ||
657
76.4k
            mode == INTRA_VERT || mode == INTRA_HORZ)) {
658
76.4k
            const int scale = (av_log2(w) + av_log2(h) - 2) >> 2;
659
76.4k
            const pixel *left = (pixel*)edge.left;
660
76.4k
            const pixel *top  = (pixel*)edge.top;
661
419k
            for (int y = 0; y < h; y++) {
662
2.59M
                for (int x = 0; x < w; x++) {
663
2.25M
                    int l, t, wl, wt, pred;
664
2.25M
                    pixel val;
665
2.25M
                    if (mode == INTRA_PLANAR || mode == INTRA_DC) {
666
1.10M
                        l  = left[y];
667
1.10M
                        t = top[x];
668
1.10M
                        wl = 32 >> FFMIN((x << 1) >> scale, 31);
669
1.10M
                        wt = 32 >> FFMIN((y << 1) >> scale, 31);
670
1.15M
                    } else {
671
1.15M
                        l  = left[y] - left[-1] + POS(x,y);
672
1.15M
                        t = top[x] - top[-1] + POS(x,y);
673
1.15M
                        wl = (mode == INTRA_VERT) ?  (32 >> FFMIN((x << 1) >> scale, 31)) : 0;
674
1.15M
                        wt = (mode == INTRA_HORZ) ?  (32 >> FFMIN((y << 1) >> scale, 31)) : 0;
675
1.15M
                    }
676
2.25M
                    val = POS(x, y);
677
2.25M
                    pred  = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6);
678
2.25M
                    POS(x, y) = CLIP(pred);
679
2.25M
                }
680
342k
            }
681
76.4k
        }
682
84.1k
    }
683
126k
}
dsp.c:intra_pred_10
Line
Count
Source
596
4.26M
{
597
4.26M
    VVCFrameContext *fc     = lc->fc;
598
4.26M
    const VVCSPS *sps = fc->ps.sps;
599
4.26M
    const VVCPPS *pps = fc->ps.pps;
600
4.26M
    const CodingUnit *cu = lc->cu;
601
4.26M
    const int log2_min_cb_size    = sps->min_cb_log2_size_y;
602
4.26M
    const int min_cb_width        = pps->min_cb_width;
603
4.26M
    const int x_cb                = x0 >> log2_min_cb_size;
604
4.26M
    const int y_cb                = y0 >> log2_min_cb_size;
605
606
4.26M
    const int hshift = fc->ps.sps->hshift[c_idx];
607
4.26M
    const int vshift = fc->ps.sps->vshift[c_idx];
608
4.26M
    const int x = x0 >> hshift;
609
4.26M
    const int y = y0 >> vshift;
610
4.26M
    const int w = width >> hshift;
611
4.26M
    const int h = height >> vshift;
612
4.26M
    const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
613
614
4.26M
    const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y;
615
4.26M
    const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode);
616
617
4.26M
    const int intra_mip_flag  = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb);
618
4.26M
    const int is_intra_mip    = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag);
619
4.26M
    const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx;
620
4.26M
    const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx);
621
622
623
4.26M
    pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
624
4.26M
    IntraEdgeParams edge;
625
626
4.26M
    FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc);
627
628
4.26M
    if (is_intra_mip) {
629
14.1k
        int intra_mip_transposed_flag;
630
14.1k
        int intra_mip_mode;
631
14.1k
        unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag);
632
633
14.1k
        fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left,
634
14.1k
                        w, h, stride, intra_mip_mode, intra_mip_transposed_flag);
635
4.24M
    } else if (mode == INTRA_PLANAR) {
636
2.57M
        fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride);
637
2.57M
    } else if (mode == INTRA_DC) {
638
436k
        fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride);
639
1.23M
    } else if (mode == INTRA_VERT) {
640
104k
        fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride);
641
1.13M
    } else if (mode == INTRA_HORZ) {
642
80.9k
        fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride);
643
1.05M
    } else {
644
1.05M
        if (mode >= INTRA_DIAG) {
645
598k
            fc->vvcdsp.intra.pred_angular_v((uint8_t *)src, edge.top, edge.left,
646
598k
                                  w, h, stride, c_idx, mode, ref_idx,
647
598k
                                  edge.filter_flag, need_pdpc);
648
598k
        } else {
649
455k
            fc->vvcdsp.intra.pred_angular_h((uint8_t *)src, edge.top, edge.left,
650
455k
                                  w, h, stride, c_idx, mode, ref_idx,
651
455k
                                  edge.filter_flag, need_pdpc);
652
455k
        }
653
1.05M
    }
654
4.26M
    if (need_pdpc) {
655
        //8.4.5.2.15 Position-dependent intra prediction sample filtering process
656
3.37M
        if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC ||
657
3.10M
            mode == INTRA_VERT || mode == INTRA_HORZ)) {
658
3.10M
            const int scale = (av_log2(w) + av_log2(h) - 2) >> 2;
659
3.10M
            const pixel *left = (pixel*)edge.left;
660
3.10M
            const pixel *top  = (pixel*)edge.top;
661
62.9M
            for (int y = 0; y < h; y++) {
662
1.72G
                for (int x = 0; x < w; x++) {
663
1.66G
                    int l, t, wl, wt, pred;
664
1.66G
                    pixel val;
665
1.66G
                    if (mode == INTRA_PLANAR || mode == INTRA_DC) {
666
1.61G
                        l  = left[y];
667
1.61G
                        t = top[x];
668
1.61G
                        wl = 32 >> FFMIN((x << 1) >> scale, 31);
669
1.61G
                        wt = 32 >> FFMIN((y << 1) >> scale, 31);
670
1.61G
                    } else {
671
56.0M
                        l  = left[y] - left[-1] + POS(x,y);
672
56.0M
                        t = top[x] - top[-1] + POS(x,y);
673
56.0M
                        wl = (mode == INTRA_VERT) ?  (32 >> FFMIN((x << 1) >> scale, 31)) : 0;
674
56.0M
                        wt = (mode == INTRA_HORZ) ?  (32 >> FFMIN((y << 1) >> scale, 31)) : 0;
675
56.0M
                    }
676
1.66G
                    val = POS(x, y);
677
1.66G
                    pred  = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6);
678
1.66G
                    POS(x, y) = CLIP(pred);
679
1.66G
                }
680
59.8M
            }
681
3.10M
        }
682
3.37M
    }
683
4.26M
}
dsp.c:intra_pred_8
Line
Count
Source
596
133k
{
597
133k
    VVCFrameContext *fc     = lc->fc;
598
133k
    const VVCSPS *sps = fc->ps.sps;
599
133k
    const VVCPPS *pps = fc->ps.pps;
600
133k
    const CodingUnit *cu = lc->cu;
601
133k
    const int log2_min_cb_size    = sps->min_cb_log2_size_y;
602
133k
    const int min_cb_width        = pps->min_cb_width;
603
133k
    const int x_cb                = x0 >> log2_min_cb_size;
604
133k
    const int y_cb                = y0 >> log2_min_cb_size;
605
606
133k
    const int hshift = fc->ps.sps->hshift[c_idx];
607
133k
    const int vshift = fc->ps.sps->vshift[c_idx];
608
133k
    const int x = x0 >> hshift;
609
133k
    const int y = y0 >> vshift;
610
133k
    const int w = width >> hshift;
611
133k
    const int h = height >> vshift;
612
133k
    const ptrdiff_t stride = fc->frame->linesize[c_idx] / sizeof(pixel);
613
614
133k
    const int pred_mode = c_idx ? cu->intra_pred_mode_c : cu->intra_pred_mode_y;
615
133k
    const int mode = ff_vvc_wide_angle_mode_mapping(cu, w, h, c_idx, pred_mode);
616
617
133k
    const int intra_mip_flag  = SAMPLE_CTB(fc->tab.imf, x_cb, y_cb);
618
133k
    const int is_intra_mip    = intra_mip_flag && (!c_idx || cu->mip_chroma_direct_flag);
619
133k
    const int ref_idx = c_idx ? 0 : cu->intra_luma_ref_idx;
620
133k
    const int need_pdpc = ff_vvc_need_pdpc(w, h, cu->bdpcm_flag[c_idx], mode, ref_idx);
621
622
623
133k
    pixel *src = (pixel*)fc->frame->data[c_idx] + x + y * stride;
624
133k
    IntraEdgeParams edge;
625
626
133k
    FUNC(prepare_intra_edge_params)(lc, &edge, src, stride, x, y, w, h, c_idx, is_intra_mip, mode, ref_idx, need_pdpc);
627
628
133k
    if (is_intra_mip) {
629
2.95k
        int intra_mip_transposed_flag;
630
2.95k
        int intra_mip_mode;
631
2.95k
        unpack_mip_info(&intra_mip_transposed_flag, &intra_mip_mode, intra_mip_flag);
632
633
2.95k
        fc->vvcdsp.intra.pred_mip((uint8_t *)src, edge.top, edge.left,
634
2.95k
                        w, h, stride, intra_mip_mode, intra_mip_transposed_flag);
635
130k
    } else if (mode == INTRA_PLANAR) {
636
17.3k
        fc->vvcdsp.intra.pred_planar((uint8_t *)src, edge.top, edge.left, w, h, stride);
637
113k
    } else if (mode == INTRA_DC) {
638
9.22k
        fc->vvcdsp.intra.pred_dc((uint8_t *)src, edge.top, edge.left, w, h, stride);
639
104k
    } else if (mode == INTRA_VERT) {
640
5.50k
        fc->vvcdsp.intra.pred_v((uint8_t *)src, edge.top, w, h, stride);
641
98.5k
    } else if (mode == INTRA_HORZ) {
642
24.0k
        fc->vvcdsp.intra.pred_h((uint8_t *)src, edge.left, w, h, stride);
643
74.5k
    } else {
644
74.5k
        if (mode >= INTRA_DIAG) {
645
17.3k
            fc->vvcdsp.intra.pred_angular_v((uint8_t *)src, edge.top, edge.left,
646
17.3k
                                  w, h, stride, c_idx, mode, ref_idx,
647
17.3k
                                  edge.filter_flag, need_pdpc);
648
57.1k
        } else {
649
57.1k
            fc->vvcdsp.intra.pred_angular_h((uint8_t *)src, edge.top, edge.left,
650
57.1k
                                  w, h, stride, c_idx, mode, ref_idx,
651
57.1k
                                  edge.filter_flag, need_pdpc);
652
57.1k
        }
653
74.5k
    }
654
133k
    if (need_pdpc) {
655
        //8.4.5.2.15 Position-dependent intra prediction sample filtering process
656
44.8k
        if (!is_intra_mip && (mode == INTRA_PLANAR || mode == INTRA_DC ||
657
38.0k
            mode == INTRA_VERT || mode == INTRA_HORZ)) {
658
38.0k
            const int scale = (av_log2(w) + av_log2(h) - 2) >> 2;
659
38.0k
            const pixel *left = (pixel*)edge.left;
660
38.0k
            const pixel *top  = (pixel*)edge.top;
661
212k
            for (int y = 0; y < h; y++) {
662
1.02M
                for (int x = 0; x < w; x++) {
663
851k
                    int l, t, wl, wt, pred;
664
851k
                    pixel val;
665
851k
                    if (mode == INTRA_PLANAR || mode == INTRA_DC) {
666
520k
                        l  = left[y];
667
520k
                        t = top[x];
668
520k
                        wl = 32 >> FFMIN((x << 1) >> scale, 31);
669
520k
                        wt = 32 >> FFMIN((y << 1) >> scale, 31);
670
520k
                    } else {
671
330k
                        l  = left[y] - left[-1] + POS(x,y);
672
330k
                        t = top[x] - top[-1] + POS(x,y);
673
330k
                        wl = (mode == INTRA_VERT) ?  (32 >> FFMIN((x << 1) >> scale, 31)) : 0;
674
330k
                        wt = (mode == INTRA_HORZ) ?  (32 >> FFMIN((y << 1) >> scale, 31)) : 0;
675
330k
                    }
676
851k
                    val = POS(x, y);
677
851k
                    pred  = val + ((wl * (l - val) + wt * (t - val) + 32) >> 6);
678
851k
                    POS(x, y) = CLIP(pred);
679
851k
                }
680
174k
            }
681
38.0k
        }
682
44.8k
    }
683
133k
}
684
685
//8.4.5.2.11 Specification of INTRA_PLANAR intra prediction mode
686
static av_always_inline void FUNC(pred_planar)(uint8_t *_src, const uint8_t *_top,
687
    const uint8_t *_left, const int w, const int h, const ptrdiff_t stride)
688
2.60M
{
689
2.60M
    int x, y;
690
2.60M
    pixel *src        = (pixel *)_src;
691
2.60M
    const pixel *top  = (const pixel *)_top;
692
2.60M
    const pixel *left = (const pixel *)_left;
693
2.60M
    const int logw  = av_log2(w);
694
2.60M
    const int logh  = av_log2(h);
695
2.60M
    const int size  =  w * h;
696
2.60M
    const int shift = (logw + logh + 1);
697
49.6M
    for (y = 0; y < h; y++) {
698
1.27G
        for (x = 0; x < w; x++) {
699
1.23G
            const int pred_v = ((h - 1 - y) * top[x]  + (y + 1) * left[h]) << logw;
700
1.23G
            const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh;
701
1.23G
            const int pred = (pred_v + pred_h + size) >> shift;
702
1.23G
            POS(x, y) = pred;
703
1.23G
        }
704
47.0M
    }
705
2.60M
}
dsp.c:pred_planar_12
Line
Count
Source
688
15.0k
{
689
15.0k
    int x, y;
690
15.0k
    pixel *src        = (pixel *)_src;
691
15.0k
    const pixel *top  = (const pixel *)_top;
692
15.0k
    const pixel *left = (const pixel *)_left;
693
15.0k
    const int logw  = av_log2(w);
694
15.0k
    const int logh  = av_log2(h);
695
15.0k
    const int size  =  w * h;
696
15.0k
    const int shift = (logw + logh + 1);
697
90.2k
    for (y = 0; y < h; y++) {
698
664k
        for (x = 0; x < w; x++) {
699
589k
            const int pred_v = ((h - 1 - y) * top[x]  + (y + 1) * left[h]) << logw;
700
589k
            const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh;
701
589k
            const int pred = (pred_v + pred_h + size) >> shift;
702
589k
            POS(x, y) = pred;
703
589k
        }
704
75.2k
    }
705
15.0k
}
dsp.c:pred_planar_10
Line
Count
Source
688
2.57M
{
689
2.57M
    int x, y;
690
2.57M
    pixel *src        = (pixel *)_src;
691
2.57M
    const pixel *top  = (const pixel *)_top;
692
2.57M
    const pixel *left = (const pixel *)_left;
693
2.57M
    const int logw  = av_log2(w);
694
2.57M
    const int logh  = av_log2(h);
695
2.57M
    const int size  =  w * h;
696
2.57M
    const int shift = (logw + logh + 1);
697
49.4M
    for (y = 0; y < h; y++) {
698
1.27G
        for (x = 0; x < w; x++) {
699
1.23G
            const int pred_v = ((h - 1 - y) * top[x]  + (y + 1) * left[h]) << logw;
700
1.23G
            const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh;
701
1.23G
            const int pred = (pred_v + pred_h + size) >> shift;
702
1.23G
            POS(x, y) = pred;
703
1.23G
        }
704
46.9M
    }
705
2.57M
}
dsp.c:pred_planar_8
Line
Count
Source
688
17.3k
{
689
17.3k
    int x, y;
690
17.3k
    pixel *src        = (pixel *)_src;
691
17.3k
    const pixel *top  = (const pixel *)_top;
692
17.3k
    const pixel *left = (const pixel *)_left;
693
17.3k
    const int logw  = av_log2(w);
694
17.3k
    const int logh  = av_log2(h);
695
17.3k
    const int size  =  w * h;
696
17.3k
    const int shift = (logw + logh + 1);
697
73.7k
    for (y = 0; y < h; y++) {
698
372k
        for (x = 0; x < w; x++) {
699
316k
            const int pred_v = ((h - 1 - y) * top[x]  + (y + 1) * left[h]) << logw;
700
316k
            const int pred_h = ((w - 1 - x) * left[y] + (x + 1) * top[w]) << logh;
701
316k
            const int pred = (pred_v + pred_h + size) >> shift;
702
316k
            POS(x, y) = pred;
703
316k
        }
704
56.4k
    }
705
17.3k
}
706
707
//8.4.5.2.3 MIP boundary sample downsampling process
708
static av_always_inline void FUNC(mip_downsampling)(int *reduced, const int boundary_size,
709
    const pixel *ref, const int n_tb_s)
710
42.8k
{
711
42.8k
    const int b_dwn = n_tb_s / boundary_size;
712
42.8k
    const int log2 = av_log2(b_dwn);
713
714
42.8k
    if (boundary_size == n_tb_s) {
715
18.8k
        for (int i = 0; i < n_tb_s; i++)
716
15.0k
            reduced[i] = ref[i];
717
3.76k
        return;
718
3.76k
    }
719
176k
    for (int i = 0; i < boundary_size; i++) {
720
137k
        int r;
721
137k
        r = *ref++;
722
562k
        for (int j = 1; j < b_dwn; j++)
723
425k
            r += *ref++;
724
137k
        reduced[i] = (r + (1 << (log2 - 1))) >> log2;
725
137k
    }
726
39.0k
}
dsp.c:mip_downsampling_12
Line
Count
Source
710
8.56k
{
711
8.56k
    const int b_dwn = n_tb_s / boundary_size;
712
8.56k
    const int log2 = av_log2(b_dwn);
713
714
8.56k
    if (boundary_size == n_tb_s) {
715
6.04k
        for (int i = 0; i < n_tb_s; i++)
716
4.83k
            reduced[i] = ref[i];
717
1.20k
        return;
718
1.20k
    }
719
35.1k
    for (int i = 0; i < boundary_size; i++) {
720
27.8k
        int r;
721
27.8k
        r = *ref++;
722
55.6k
        for (int j = 1; j < b_dwn; j++)
723
27.8k
            r += *ref++;
724
27.8k
        reduced[i] = (r + (1 << (log2 - 1))) >> log2;
725
27.8k
    }
726
7.35k
}
dsp.c:mip_downsampling_10
Line
Count
Source
710
28.3k
{
711
28.3k
    const int b_dwn = n_tb_s / boundary_size;
712
28.3k
    const int log2 = av_log2(b_dwn);
713
714
28.3k
    if (boundary_size == n_tb_s) {
715
12.0k
        for (int i = 0; i < n_tb_s; i++)
716
9.60k
            reduced[i] = ref[i];
717
2.40k
        return;
718
2.40k
    }
719
117k
    for (int i = 0; i < boundary_size; i++) {
720
91.7k
        int r;
721
91.7k
        r = *ref++;
722
470k
        for (int j = 1; j < b_dwn; j++)
723
379k
            r += *ref++;
724
91.7k
        reduced[i] = (r + (1 << (log2 - 1))) >> log2;
725
91.7k
    }
726
25.9k
}
dsp.c:mip_downsampling_8
Line
Count
Source
710
5.91k
{
711
5.91k
    const int b_dwn = n_tb_s / boundary_size;
712
5.91k
    const int log2 = av_log2(b_dwn);
713
714
5.91k
    if (boundary_size == n_tb_s) {
715
750
        for (int i = 0; i < n_tb_s; i++)
716
600
            reduced[i] = ref[i];
717
150
        return;
718
150
    }
719
23.9k
    for (int i = 0; i < boundary_size; i++) {
720
18.1k
        int r;
721
18.1k
        r = *ref++;
722
36.3k
        for (int j = 1; j < b_dwn; j++)
723
18.1k
            r += *ref++;
724
18.1k
        reduced[i] = (r + (1 << (log2 - 1))) >> log2;
725
18.1k
    }
726
5.76k
}
727
728
static av_always_inline void FUNC(mip_reduced_pred)(pixel *src, const ptrdiff_t stride,
729
    const int up_hor, const int up_ver, const int pred_size, const int *reduced, const int reduced_size,
730
    const int ow, const int temp0, const uint8_t *matrix, int is_transposed)
731
21.4k
{
732
21.4k
    src = &POS(up_hor - 1, up_ver - 1);
733
136k
    for (int y = 0; y < pred_size; y++) {
734
812k
        for (int x = 0; x < pred_size; x++) {
735
696k
            int pred = 0;
736
5.50M
            for (int i = 0; i < reduced_size; i++)
737
4.80M
                pred += reduced[i] * matrix[i];
738
696k
            matrix += reduced_size;
739
696k
            pred = ((pred + ow) >> 6) + temp0;
740
696k
            pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1);
741
696k
            if (is_transposed)
742
383k
                POS(y * up_hor, x * up_ver) = pred;
743
313k
            else
744
313k
                POS(x * up_hor, y * up_ver) = pred;
745
696k
        }
746
115k
    }
747
21.4k
}
dsp.c:mip_reduced_pred_12
Line
Count
Source
731
4.28k
{
732
4.28k
    src = &POS(up_hor - 1, up_ver - 1);
733
21.4k
    for (int y = 0; y < pred_size; y++) {
734
85.6k
        for (int x = 0; x < pred_size; x++) {
735
68.5k
            int pred = 0;
736
591k
            for (int i = 0; i < reduced_size; i++)
737
522k
                pred += reduced[i] * matrix[i];
738
68.5k
            matrix += reduced_size;
739
68.5k
            pred = ((pred + ow) >> 6) + temp0;
740
68.5k
            pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1);
741
68.5k
            if (is_transposed)
742
53.5k
                POS(y * up_hor, x * up_ver) = pred;
743
14.9k
            else
744
14.9k
                POS(x * up_hor, y * up_ver) = pred;
745
68.5k
        }
746
17.1k
    }
747
4.28k
}
dsp.c:mip_reduced_pred_10
Line
Count
Source
731
14.1k
{
732
14.1k
    src = &POS(up_hor - 1, up_ver - 1);
733
100k
    for (int y = 0; y < pred_size; y++) {
734
667k
        for (int x = 0; x < pred_size; x++) {
735
581k
            int pred = 0;
736
4.56M
            for (int i = 0; i < reduced_size; i++)
737
3.98M
                pred += reduced[i] * matrix[i];
738
581k
            matrix += reduced_size;
739
581k
            pred = ((pred + ow) >> 6) + temp0;
740
581k
            pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1);
741
581k
            if (is_transposed)
742
297k
                POS(y * up_hor, x * up_ver) = pred;
743
283k
            else
744
283k
                POS(x * up_hor, y * up_ver) = pred;
745
581k
        }
746
86.1k
    }
747
14.1k
}
dsp.c:mip_reduced_pred_8
Line
Count
Source
731
2.95k
{
732
2.95k
    src = &POS(up_hor - 1, up_ver - 1);
733
14.7k
    for (int y = 0; y < pred_size; y++) {
734
59.1k
        for (int x = 0; x < pred_size; x++) {
735
47.3k
            int pred = 0;
736
347k
            for (int i = 0; i < reduced_size; i++)
737
300k
                pred += reduced[i] * matrix[i];
738
47.3k
            matrix += reduced_size;
739
47.3k
            pred = ((pred + ow) >> 6) + temp0;
740
47.3k
            pred = av_clip(pred, 0, (1<<BIT_DEPTH) - 1);
741
47.3k
            if (is_transposed)
742
31.7k
                POS(y * up_hor, x * up_ver) = pred;
743
15.5k
            else
744
15.5k
                POS(x * up_hor, y * up_ver) = pred;
745
47.3k
        }
746
11.8k
    }
747
2.95k
}
748
749
static av_always_inline void FUNC(mip_upsampling_1d)(pixel *dst, const int dst_step, const int dst_stride, const int dst_height, const int factor,
750
    const pixel *boundary, const int boundary_step,  const int pred_size)
751
27.0k
{
752
753
327k
    for (int i = 0; i < dst_height; i++) {
754
300k
        const pixel *before = boundary;
755
300k
        const pixel *after  = dst - dst_step;
756
300k
        pixel *d = dst;
757
2.37M
        for (int j = 0; j < pred_size; j++) {
758
2.07M
            after += dst_step * factor;
759
8.92M
            for (int k = 1; k < factor; k++) {
760
6.84M
                int mid = (factor - k) * (*before) + k * (*after);
761
6.84M
                *d = (mid + factor / 2) / factor;
762
6.84M
                d += dst_step;
763
6.84M
            }
764
2.07M
            before = after;
765
2.07M
            d += dst_step;
766
2.07M
        }
767
300k
        boundary += boundary_step;
768
300k
        dst += dst_stride;
769
300k
    }
770
27.0k
}
dsp.c:mip_upsampling_1d_12
Line
Count
Source
751
6.55k
{
752
753
43.4k
    for (int i = 0; i < dst_height; i++) {
754
36.9k
        const pixel *before = boundary;
755
36.9k
        const pixel *after  = dst - dst_step;
756
36.9k
        pixel *d = dst;
757
184k
        for (int j = 0; j < pred_size; j++) {
758
147k
            after += dst_step * factor;
759
295k
            for (int k = 1; k < factor; k++) {
760
147k
                int mid = (factor - k) * (*before) + k * (*after);
761
147k
                *d = (mid + factor / 2) / factor;
762
147k
                d += dst_step;
763
147k
            }
764
147k
            before = after;
765
147k
            d += dst_step;
766
147k
        }
767
36.9k
        boundary += boundary_step;
768
36.9k
        dst += dst_stride;
769
36.9k
    }
770
6.55k
}
dsp.c:mip_upsampling_1d_10
Line
Count
Source
751
17.1k
{
752
753
261k
    for (int i = 0; i < dst_height; i++) {
754
244k
        const pixel *before = boundary;
755
244k
        const pixel *after  = dst - dst_step;
756
244k
        pixel *d = dst;
757
2.09M
        for (int j = 0; j < pred_size; j++) {
758
1.84M
            after += dst_step * factor;
759
8.46M
            for (int k = 1; k < factor; k++) {
760
6.62M
                int mid = (factor - k) * (*before) + k * (*after);
761
6.62M
                *d = (mid + factor / 2) / factor;
762
6.62M
                d += dst_step;
763
6.62M
            }
764
1.84M
            before = after;
765
1.84M
            d += dst_step;
766
1.84M
        }
767
244k
        boundary += boundary_step;
768
244k
        dst += dst_stride;
769
244k
    }
770
17.1k
}
dsp.c:mip_upsampling_1d_8
Line
Count
Source
751
3.32k
{
752
753
22.9k
    for (int i = 0; i < dst_height; i++) {
754
19.6k
        const pixel *before = boundary;
755
19.6k
        const pixel *after  = dst - dst_step;
756
19.6k
        pixel *d = dst;
757
98.2k
        for (int j = 0; j < pred_size; j++) {
758
78.5k
            after += dst_step * factor;
759
157k
            for (int k = 1; k < factor; k++) {
760
78.5k
                int mid = (factor - k) * (*before) + k * (*after);
761
78.5k
                *d = (mid + factor / 2) / factor;
762
78.5k
                d += dst_step;
763
78.5k
            }
764
78.5k
            before = after;
765
78.5k
            d += dst_step;
766
78.5k
        }
767
19.6k
        boundary += boundary_step;
768
19.6k
        dst += dst_stride;
769
19.6k
    }
770
3.32k
}
771
772
//8.4.5.2.2 Matrix-based intra sample prediction
773
static av_always_inline void FUNC(pred_mip)(uint8_t *_src, const uint8_t *_top,
774
    const uint8_t *_left, const int w, const int h, const ptrdiff_t stride,
775
    int mode_id, int is_transposed)
776
21.4k
{
777
21.4k
    pixel *src        = (pixel *)_src;
778
21.4k
    const pixel *top  = (const pixel *)_top;
779
21.4k
    const pixel *left = (const pixel *)_left;
780
781
21.4k
    const int size_id = ff_vvc_get_mip_size_id(w, h);
782
21.4k
    static const int boundary_sizes[] = {2, 4, 4};
783
21.4k
    static const int pred_sizes[] = {4, 4, 8};
784
21.4k
    const int boundary_size = boundary_sizes[size_id];
785
21.4k
    const int pred_size     = pred_sizes[size_id];
786
21.4k
    const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0);
787
21.4k
    const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id);
788
21.4k
    const int up_hor = w / pred_size;
789
21.4k
    const int up_ver = h / pred_size;
790
791
21.4k
    int reduced[16];
792
21.4k
    int *red_t  = reduced;
793
21.4k
    int *red_l  = reduced + boundary_size;
794
21.4k
    int off = 1, ow = 0;
795
21.4k
    int temp0;
796
797
21.4k
    if (is_transposed) {
798
13.2k
        FFSWAP(int*, red_t, red_l);
799
13.2k
    }
800
21.4k
    FUNC(mip_downsampling)(red_t, boundary_size, top, w);
801
21.4k
    FUNC(mip_downsampling)(red_l, boundary_size, left, h);
802
803
21.4k
    temp0 = reduced[0];
804
21.4k
    if (size_id != 2) {
805
14.0k
        off = 0;
806
14.0k
        ow = (1 << (BIT_DEPTH - 1)) - temp0;
807
14.0k
    } else {
808
7.38k
        ow = reduced[1] - temp0;
809
7.38k
    }
810
21.4k
    reduced[0] = ow;
811
145k
    for (int i = 1; i < in_size; i++) {
812
124k
        reduced[i] = reduced[i + off] - temp0;
813
124k
        ow += reduced[i];
814
124k
    }
815
21.4k
    ow = 32 - 32 * ow;
816
817
21.4k
    FUNC(mip_reduced_pred)(src, stride, up_hor, up_ver, pred_size, reduced, in_size, ow, temp0, matrix, is_transposed);
818
21.4k
    if (up_hor > 1 || up_ver > 1) {
819
16.7k
        if (up_hor > 1)
820
14.0k
            FUNC(mip_upsampling_1d)(&POS(0, up_ver - 1), 1, up_ver * stride, pred_size, up_hor, left + up_ver - 1, up_ver, pred_size);
821
16.7k
        if (up_ver > 1)
822
12.9k
            FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size);
823
16.7k
    }
824
21.4k
}
dsp.c:pred_mip_12
Line
Count
Source
776
4.28k
{
777
4.28k
    pixel *src        = (pixel *)_src;
778
4.28k
    const pixel *top  = (const pixel *)_top;
779
4.28k
    const pixel *left = (const pixel *)_left;
780
781
4.28k
    const int size_id = ff_vvc_get_mip_size_id(w, h);
782
4.28k
    static const int boundary_sizes[] = {2, 4, 4};
783
4.28k
    static const int pred_sizes[] = {4, 4, 8};
784
4.28k
    const int boundary_size = boundary_sizes[size_id];
785
4.28k
    const int pred_size     = pred_sizes[size_id];
786
4.28k
    const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0);
787
4.28k
    const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id);
788
4.28k
    const int up_hor = w / pred_size;
789
4.28k
    const int up_ver = h / pred_size;
790
791
4.28k
    int reduced[16];
792
4.28k
    int *red_t  = reduced;
793
4.28k
    int *red_l  = reduced + boundary_size;
794
4.28k
    int off = 1, ow = 0;
795
4.28k
    int temp0;
796
797
4.28k
    if (is_transposed) {
798
3.34k
        FFSWAP(int*, red_t, red_l);
799
3.34k
    }
800
4.28k
    FUNC(mip_downsampling)(red_t, boundary_size, top, w);
801
4.28k
    FUNC(mip_downsampling)(red_l, boundary_size, left, h);
802
803
4.28k
    temp0 = reduced[0];
804
4.28k
    if (size_id != 2) {
805
4.28k
        off = 0;
806
4.28k
        ow = (1 << (BIT_DEPTH - 1)) - temp0;
807
4.28k
    } else {
808
0
        ow = reduced[1] - temp0;
809
0
    }
810
4.28k
    reduced[0] = ow;
811
32.6k
    for (int i = 1; i < in_size; i++) {
812
28.3k
        reduced[i] = reduced[i + off] - temp0;
813
28.3k
        ow += reduced[i];
814
28.3k
    }
815
4.28k
    ow = 32 - 32 * ow;
816
817
4.28k
    FUNC(mip_reduced_pred)(src, stride, up_hor, up_ver, pred_size, reduced, in_size, ow, temp0, matrix, is_transposed);
818
4.28k
    if (up_hor > 1 || up_ver > 1) {
819
3.88k
        if (up_hor > 1)
820
3.47k
            FUNC(mip_upsampling_1d)(&POS(0, up_ver - 1), 1, up_ver * stride, pred_size, up_hor, left + up_ver - 1, up_ver, pred_size);
821
3.88k
        if (up_ver > 1)
822
3.07k
            FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size);
823
3.88k
    }
824
4.28k
}
dsp.c:pred_mip_10
Line
Count
Source
776
14.1k
{
777
14.1k
    pixel *src        = (pixel *)_src;
778
14.1k
    const pixel *top  = (const pixel *)_top;
779
14.1k
    const pixel *left = (const pixel *)_left;
780
781
14.1k
    const int size_id = ff_vvc_get_mip_size_id(w, h);
782
14.1k
    static const int boundary_sizes[] = {2, 4, 4};
783
14.1k
    static const int pred_sizes[] = {4, 4, 8};
784
14.1k
    const int boundary_size = boundary_sizes[size_id];
785
14.1k
    const int pred_size     = pred_sizes[size_id];
786
14.1k
    const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0);
787
14.1k
    const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id);
788
14.1k
    const int up_hor = w / pred_size;
789
14.1k
    const int up_ver = h / pred_size;
790
791
14.1k
    int reduced[16];
792
14.1k
    int *red_t  = reduced;
793
14.1k
    int *red_l  = reduced + boundary_size;
794
14.1k
    int off = 1, ow = 0;
795
14.1k
    int temp0;
796
797
14.1k
    if (is_transposed) {
798
7.90k
        FFSWAP(int*, red_t, red_l);
799
7.90k
    }
800
14.1k
    FUNC(mip_downsampling)(red_t, boundary_size, top, w);
801
14.1k
    FUNC(mip_downsampling)(red_l, boundary_size, left, h);
802
803
14.1k
    temp0 = reduced[0];
804
14.1k
    if (size_id != 2) {
805
6.78k
        off = 0;
806
6.78k
        ow = (1 << (BIT_DEPTH - 1)) - temp0;
807
7.38k
    } else {
808
7.38k
        ow = reduced[1] - temp0;
809
7.38k
    }
810
14.1k
    reduced[0] = ow;
811
93.9k
    for (int i = 1; i < in_size; i++) {
812
79.8k
        reduced[i] = reduced[i + off] - temp0;
813
79.8k
        ow += reduced[i];
814
79.8k
    }
815
14.1k
    ow = 32 - 32 * ow;
816
817
14.1k
    FUNC(mip_reduced_pred)(src, stride, up_hor, up_ver, pred_size, reduced, in_size, ow, temp0, matrix, is_transposed);
818
14.1k
    if (up_hor > 1 || up_ver > 1) {
819
11.1k
        if (up_hor > 1)
820
8.96k
            FUNC(mip_upsampling_1d)(&POS(0, up_ver - 1), 1, up_ver * stride, pred_size, up_hor, left + up_ver - 1, up_ver, pred_size);
821
11.1k
        if (up_ver > 1)
822
8.16k
            FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size);
823
11.1k
    }
824
14.1k
}
dsp.c:pred_mip_8
Line
Count
Source
776
2.95k
{
777
2.95k
    pixel *src        = (pixel *)_src;
778
2.95k
    const pixel *top  = (const pixel *)_top;
779
2.95k
    const pixel *left = (const pixel *)_left;
780
781
2.95k
    const int size_id = ff_vvc_get_mip_size_id(w, h);
782
2.95k
    static const int boundary_sizes[] = {2, 4, 4};
783
2.95k
    static const int pred_sizes[] = {4, 4, 8};
784
2.95k
    const int boundary_size = boundary_sizes[size_id];
785
2.95k
    const int pred_size     = pred_sizes[size_id];
786
2.95k
    const int in_size = 2 * boundary_size - ((size_id == 2) ? 1 : 0);
787
2.95k
    const uint8_t *matrix = ff_vvc_get_mip_matrix(size_id, mode_id);
788
2.95k
    const int up_hor = w / pred_size;
789
2.95k
    const int up_ver = h / pred_size;
790
791
2.95k
    int reduced[16];
792
2.95k
    int *red_t  = reduced;
793
2.95k
    int *red_l  = reduced + boundary_size;
794
2.95k
    int off = 1, ow = 0;
795
2.95k
    int temp0;
796
797
2.95k
    if (is_transposed) {
798
1.98k
        FFSWAP(int*, red_t, red_l);
799
1.98k
    }
800
2.95k
    FUNC(mip_downsampling)(red_t, boundary_size, top, w);
801
2.95k
    FUNC(mip_downsampling)(red_l, boundary_size, left, h);
802
803
2.95k
    temp0 = reduced[0];
804
2.95k
    if (size_id != 2) {
805
2.95k
        off = 0;
806
2.95k
        ow = (1 << (BIT_DEPTH - 1)) - temp0;
807
2.95k
    } else {
808
0
        ow = reduced[1] - temp0;
809
0
    }
810
2.95k
    reduced[0] = ow;
811
18.7k
    for (int i = 1; i < in_size; i++) {
812
15.8k
        reduced[i] = reduced[i + off] - temp0;
813
15.8k
        ow += reduced[i];
814
15.8k
    }
815
2.95k
    ow = 32 - 32 * ow;
816
817
2.95k
    FUNC(mip_reduced_pred)(src, stride, up_hor, up_ver, pred_size, reduced, in_size, ow, temp0, matrix, is_transposed);
818
2.95k
    if (up_hor > 1 || up_ver > 1) {
819
1.73k
        if (up_hor > 1)
820
1.59k
            FUNC(mip_upsampling_1d)(&POS(0, up_ver - 1), 1, up_ver * stride, pred_size, up_hor, left + up_ver - 1, up_ver, pred_size);
821
1.73k
        if (up_ver > 1)
822
1.73k
            FUNC(mip_upsampling_1d)(src, stride, 1, w, up_ver, top, 1, pred_size);
823
1.73k
    }
824
2.95k
}
825
826
static av_always_inline pixel FUNC(pred_dc_val)(const pixel *top, const pixel *left,
827
    const int w, const int h)
828
465k
{
829
465k
    pixel dc_val;
830
465k
    int sum = 0;
831
465k
    unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h);
832
465k
    const int shift = av_log2(offset);
833
465k
    offset >>= 1;
834
465k
    if (w >= h) {
835
11.8M
        for (int i = 0; i < w; i++)
836
11.4M
            sum += top[i];
837
399k
    }
838
465k
    if (w <= h) {
839
9.83M
        for (int i = 0; i < h; i++)
840
9.52M
            sum += left[i];
841
304k
    }
842
465k
    dc_val = (sum + offset) >> shift;
843
465k
    return dc_val;
844
465k
}
dsp.c:pred_dc_val_12
Line
Count
Source
828
20.4k
{
829
20.4k
    pixel dc_val;
830
20.4k
    int sum = 0;
831
20.4k
    unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h);
832
20.4k
    const int shift = av_log2(offset);
833
20.4k
    offset >>= 1;
834
20.4k
    if (w >= h) {
835
132k
        for (int i = 0; i < w; i++)
836
113k
            sum += top[i];
837
18.7k
    }
838
20.4k
    if (w <= h) {
839
64.8k
        for (int i = 0; i < h; i++)
840
53.6k
            sum += left[i];
841
11.2k
    }
842
20.4k
    dc_val = (sum + offset) >> shift;
843
20.4k
    return dc_val;
844
20.4k
}
dsp.c:pred_dc_val_10
Line
Count
Source
828
436k
{
829
436k
    pixel dc_val;
830
436k
    int sum = 0;
831
436k
    unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h);
832
436k
    const int shift = av_log2(offset);
833
436k
    offset >>= 1;
834
436k
    if (w >= h) {
835
11.6M
        for (int i = 0; i < w; i++)
836
11.2M
            sum += top[i];
837
371k
    }
838
436k
    if (w <= h) {
839
9.70M
        for (int i = 0; i < h; i++)
840
9.41M
            sum += left[i];
841
284k
    }
842
436k
    dc_val = (sum + offset) >> shift;
843
436k
    return dc_val;
844
436k
}
dsp.c:pred_dc_val_8
Line
Count
Source
828
9.22k
{
829
9.22k
    pixel dc_val;
830
9.22k
    int sum = 0;
831
9.22k
    unsigned int offset = (w == h) ? (w << 1) : FFMAX(w, h);
832
9.22k
    const int shift = av_log2(offset);
833
9.22k
    offset >>= 1;
834
9.22k
    if (w >= h) {
835
56.8k
        for (int i = 0; i < w; i++)
836
48.4k
            sum += top[i];
837
8.44k
    }
838
9.22k
    if (w <= h) {
839
63.4k
        for (int i = 0; i < h; i++)
840
54.2k
            sum += left[i];
841
9.17k
    }
842
9.22k
    dc_val = (sum + offset) >> shift;
843
9.22k
    return dc_val;
844
9.22k
}
845
846
//8.4.5.2.12 Specification of INTRA_DC intra prediction mode
847
static av_always_inline void FUNC(pred_dc)(uint8_t *_src, const uint8_t *_top,
848
    const uint8_t *_left, const int w, const int h, const ptrdiff_t stride)
849
465k
{
850
465k
    int x, y;
851
465k
    pixel *src          = (pixel *)_src;
852
465k
    const pixel *top    = (const pixel *)_top;
853
465k
    const pixel *left   = (const pixel *)_left;
854
465k
    const pixel dc      = FUNC(pred_dc_val)(top, left, w, h);
855
465k
    const pixel4 a      = PIXEL_SPLAT_X4(dc);
856
11.3M
    for (y = 0; y < h; y++) {
857
10.8M
        pixel *s = src;
858
107M
        for (x = 0; x < w; x += 4) {
859
96.6M
            AV_WN4P(s, a);
860
96.6M
            s += 4;
861
96.6M
        }
862
10.8M
        src += stride;
863
10.8M
    }
864
465k
}
dsp.c:pred_dc_12
Line
Count
Source
849
20.4k
{
850
20.4k
    int x, y;
851
20.4k
    pixel *src          = (pixel *)_src;
852
20.4k
    const pixel *top    = (const pixel *)_top;
853
20.4k
    const pixel *left   = (const pixel *)_left;
854
20.4k
    const pixel dc      = FUNC(pred_dc_val)(top, left, w, h);
855
20.4k
    const pixel4 a      = PIXEL_SPLAT_X4(dc);
856
110k
    for (y = 0; y < h; y++) {
857
89.9k
        pixel *s = src;
858
219k
        for (x = 0; x < w; x += 4) {
859
129k
            AV_WN4P(s, a);
860
129k
            s += 4;
861
129k
        }
862
89.9k
        src += stride;
863
89.9k
    }
864
20.4k
}
dsp.c:pred_dc_10
Line
Count
Source
849
436k
{
850
436k
    int x, y;
851
436k
    pixel *src          = (pixel *)_src;
852
436k
    const pixel *top    = (const pixel *)_top;
853
436k
    const pixel *left   = (const pixel *)_left;
854
436k
    const pixel dc      = FUNC(pred_dc_val)(top, left, w, h);
855
436k
    const pixel4 a      = PIXEL_SPLAT_X4(dc);
856
11.1M
    for (y = 0; y < h; y++) {
857
10.7M
        pixel *s = src;
858
107M
        for (x = 0; x < w; x += 4) {
859
96.4M
            AV_WN4P(s, a);
860
96.4M
            s += 4;
861
96.4M
        }
862
10.7M
        src += stride;
863
10.7M
    }
864
436k
}
dsp.c:pred_dc_8
Line
Count
Source
849
9.22k
{
850
9.22k
    int x, y;
851
9.22k
    pixel *src          = (pixel *)_src;
852
9.22k
    const pixel *top    = (const pixel *)_top;
853
9.22k
    const pixel *left   = (const pixel *)_left;
854
9.22k
    const pixel dc      = FUNC(pred_dc_val)(top, left, w, h);
855
9.22k
    const pixel4 a      = PIXEL_SPLAT_X4(dc);
856
63.6k
    for (y = 0; y < h; y++) {
857
54.4k
        pixel *s = src;
858
137k
        for (x = 0; x < w; x += 4) {
859
83.4k
            AV_WN4P(s, a);
860
83.4k
            s += 4;
861
83.4k
        }
862
54.4k
        src += stride;
863
54.4k
    }
864
9.22k
}
865
866
static av_always_inline void FUNC(pred_v)(uint8_t *_src, const uint8_t *_top,
867
    const int w, const int h, const ptrdiff_t stride)
868
162k
{
869
162k
    pixel *src          = (pixel *)_src;
870
162k
    const pixel *top    = (const pixel *)_top;
871
1.78M
    for (int y = 0; y < h; y++) {
872
1.62M
        memcpy(src, top, sizeof(pixel)  * w);
873
1.62M
        src += stride;
874
1.62M
    }
875
162k
}
dsp.c:pred_v_12
Line
Count
Source
868
52.1k
{
869
52.1k
    pixel *src          = (pixel *)_src;
870
52.1k
    const pixel *top    = (const pixel *)_top;
871
260k
    for (int y = 0; y < h; y++) {
872
207k
        memcpy(src, top, sizeof(pixel)  * w);
873
207k
        src += stride;
874
207k
    }
875
52.1k
}
dsp.c:pred_v_10
Line
Count
Source
868
104k
{
869
104k
    pixel *src          = (pixel *)_src;
870
104k
    const pixel *top    = (const pixel *)_top;
871
1.49M
    for (int y = 0; y < h; y++) {
872
1.39M
        memcpy(src, top, sizeof(pixel)  * w);
873
1.39M
        src += stride;
874
1.39M
    }
875
104k
}
dsp.c:pred_v_8
Line
Count
Source
868
5.50k
{
869
5.50k
    pixel *src          = (pixel *)_src;
870
5.50k
    const pixel *top    = (const pixel *)_top;
871
27.7k
    for (int y = 0; y < h; y++) {
872
22.2k
        memcpy(src, top, sizeof(pixel)  * w);
873
22.2k
        src += stride;
874
22.2k
    }
875
5.50k
}
876
877
static void FUNC(pred_h)(uint8_t *_src, const uint8_t *_left, const int w, const int h,
878
    const ptrdiff_t stride)
879
118k
{
880
118k
    pixel *src          = (pixel *)_src;
881
118k
    const pixel *left    = (const pixel *)_left;
882
1.40M
    for (int y = 0; y < h; y++) {
883
1.28M
        const pixel4 a = PIXEL_SPLAT_X4(left[y]);
884
7.96M
        for (int x = 0; x < w; x += 4) {
885
6.68M
            AV_WN4P(&POS(x, y), a);
886
6.68M
        }
887
1.28M
    }
888
118k
}
dsp.c:pred_h_12
Line
Count
Source
879
13.8k
{
880
13.8k
    pixel *src          = (pixel *)_src;
881
13.8k
    const pixel *left    = (const pixel *)_left;
882
82.2k
    for (int y = 0; y < h; y++) {
883
68.4k
        const pixel4 a = PIXEL_SPLAT_X4(left[y]);
884
139k
        for (int x = 0; x < w; x += 4) {
885
71.1k
            AV_WN4P(&POS(x, y), a);
886
71.1k
        }
887
68.4k
    }
888
13.8k
}
dsp.c:pred_h_10
Line
Count
Source
879
80.9k
{
880
80.9k
    pixel *src          = (pixel *)_src;
881
80.9k
    const pixel *left    = (const pixel *)_left;
882
1.20M
    for (int y = 0; y < h; y++) {
883
1.12M
        const pixel4 a = PIXEL_SPLAT_X4(left[y]);
884
7.63M
        for (int x = 0; x < w; x += 4) {
885
6.50M
            AV_WN4P(&POS(x, y), a);
886
6.50M
        }
887
1.12M
    }
888
80.9k
}
dsp.c:pred_h_8
Line
Count
Source
879
24.0k
{
880
24.0k
    pixel *src          = (pixel *)_src;
881
24.0k
    const pixel *left    = (const pixel *)_left;
882
121k
    for (int y = 0; y < h; y++) {
883
97.4k
        const pixel4 a = PIXEL_SPLAT_X4(left[y]);
884
197k
        for (int x = 0; x < w; x += 4) {
885
99.9k
            AV_WN4P(&POS(x, y), a);
886
99.9k
        }
887
97.4k
    }
888
24.0k
}
889
890
210M
#define INTRA_LUMA_FILTER(p)    CLIP((p[0] * f[0] + p[1] * f[1] + p[2] * f[2] + p[3] * f[3] + 32) >> 6)
891
58.3M
#define INTRA_CHROMA_FILTER(p)  (((32 - fact) * p[1] + fact * p[2] + 16) >> 5)
892
893
//8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes
894
static void FUNC(pred_angular_v)(uint8_t *_src, const uint8_t *_top, const uint8_t *_left,
895
    const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode,
896
    const int ref_idx, const int filter_flag, const int need_pdpc)
897
633k
{
898
633k
    pixel *src          = (pixel *)_src;
899
633k
    const pixel *left   = (const pixel *)_left;
900
633k
    const pixel *top    = (const pixel *)_top - (1 + ref_idx);
901
633k
    const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
902
633k
    int pos = (1 + ref_idx) * intra_pred_angle;
903
633k
    const int dp = intra_pred_angle;
904
633k
    const int is_luma = !c_idx;
905
633k
    int nscale, inv_angle;
906
907
633k
    if (need_pdpc) {
908
146k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
909
146k
        nscale = ff_vvc_nscale_derive(w, h, mode);
910
146k
    }
911
912
7.84M
    for (int y = 0; y < h; y++) {
913
7.20M
        const int idx   = (pos >> 5) + ref_idx;
914
7.20M
        const int fact = pos & 31;
915
7.20M
        if (!fact && (!is_luma || !filter_flag)) {
916
12.6M
            for (int x = 0; x < w; x++) {
917
11.9M
                const pixel *p = top + x + idx + 1;
918
11.9M
                POS(x, y) = *p;
919
11.9M
            }
920
6.50M
        } else {
921
6.50M
            if (!c_idx) {
922
4.39M
                const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
923
118M
                for (int x = 0; x < w; x++) {
924
113M
                    const pixel *p = top + x + idx;
925
113M
                    POS(x, y) = INTRA_LUMA_FILTER(p);
926
113M
                }
927
4.39M
            } else {
928
34.3M
                for (int x = 0; x < w; x++) {
929
32.2M
                    const pixel *p = top + x + idx;
930
32.2M
                    POS(x, y) = INTRA_CHROMA_FILTER(p);
931
32.2M
                }
932
2.11M
            }
933
6.50M
        }
934
7.20M
        if (need_pdpc) {
935
1.95M
            int inv_angle_sum = 256 + inv_angle;
936
16.0M
            for (int x = 0; x < FFMIN(w, 3 << nscale); x++) {
937
14.0M
                const pixel l   = left[y + (inv_angle_sum >> 9)];
938
14.0M
                const pixel val = POS(x, y);
939
14.0M
                const int wl    = 32 >> ((x << 1) >> nscale);
940
14.0M
                const int pred  = val + (((l - val) * wl + 32) >> 6);
941
14.0M
                POS(x, y) = CLIP(pred);
942
14.0M
                inv_angle_sum += inv_angle;
943
14.0M
            }
944
1.95M
        }
945
7.20M
        pos += dp;
946
7.20M
    }
947
633k
}
dsp.c:pred_angular_v_12
Line
Count
Source
897
18.1k
{
898
18.1k
    pixel *src          = (pixel *)_src;
899
18.1k
    const pixel *left   = (const pixel *)_left;
900
18.1k
    const pixel *top    = (const pixel *)_top - (1 + ref_idx);
901
18.1k
    const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
902
18.1k
    int pos = (1 + ref_idx) * intra_pred_angle;
903
18.1k
    const int dp = intra_pred_angle;
904
18.1k
    const int is_luma = !c_idx;
905
18.1k
    int nscale, inv_angle;
906
907
18.1k
    if (need_pdpc) {
908
3.60k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
909
3.60k
        nscale = ff_vvc_nscale_derive(w, h, mode);
910
3.60k
    }
911
912
111k
    for (int y = 0; y < h; y++) {
913
93.0k
        const int idx   = (pos >> 5) + ref_idx;
914
93.0k
        const int fact = pos & 31;
915
93.0k
        if (!fact && (!is_luma || !filter_flag)) {
916
176k
            for (int x = 0; x < w; x++) {
917
155k
                const pixel *p = top + x + idx + 1;
918
155k
                POS(x, y) = *p;
919
155k
            }
920
71.9k
        } else {
921
71.9k
            if (!c_idx) {
922
29.0k
                const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
923
251k
                for (int x = 0; x < w; x++) {
924
221k
                    const pixel *p = top + x + idx;
925
221k
                    POS(x, y) = INTRA_LUMA_FILTER(p);
926
221k
                }
927
42.8k
            } else {
928
377k
                for (int x = 0; x < w; x++) {
929
334k
                    const pixel *p = top + x + idx;
930
334k
                    POS(x, y) = INTRA_CHROMA_FILTER(p);
931
334k
                }
932
42.8k
            }
933
71.9k
        }
934
93.0k
        if (need_pdpc) {
935
22.7k
            int inv_angle_sum = 256 + inv_angle;
936
140k
            for (int x = 0; x < FFMIN(w, 3 << nscale); x++) {
937
118k
                const pixel l   = left[y + (inv_angle_sum >> 9)];
938
118k
                const pixel val = POS(x, y);
939
118k
                const int wl    = 32 >> ((x << 1) >> nscale);
940
118k
                const int pred  = val + (((l - val) * wl + 32) >> 6);
941
118k
                POS(x, y) = CLIP(pred);
942
118k
                inv_angle_sum += inv_angle;
943
118k
            }
944
22.7k
        }
945
93.0k
        pos += dp;
946
93.0k
    }
947
18.1k
}
dsp.c:pred_angular_v_10
Line
Count
Source
897
598k
{
898
598k
    pixel *src          = (pixel *)_src;
899
598k
    const pixel *left   = (const pixel *)_left;
900
598k
    const pixel *top    = (const pixel *)_top - (1 + ref_idx);
901
598k
    const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
902
598k
    int pos = (1 + ref_idx) * intra_pred_angle;
903
598k
    const int dp = intra_pred_angle;
904
598k
    const int is_luma = !c_idx;
905
598k
    int nscale, inv_angle;
906
907
598k
    if (need_pdpc) {
908
140k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
909
140k
        nscale = ff_vvc_nscale_derive(w, h, mode);
910
140k
    }
911
912
7.63M
    for (int y = 0; y < h; y++) {
913
7.03M
        const int idx   = (pos >> 5) + ref_idx;
914
7.03M
        const int fact = pos & 31;
915
7.03M
        if (!fact && (!is_luma || !filter_flag)) {
916
12.4M
            for (int x = 0; x < w; x++) {
917
11.7M
                const pixel *p = top + x + idx + 1;
918
11.7M
                POS(x, y) = *p;
919
11.7M
            }
920
6.37M
        } else {
921
6.37M
            if (!c_idx) {
922
4.32M
                const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
923
117M
                for (int x = 0; x < w; x++) {
924
113M
                    const pixel *p = top + x + idx;
925
113M
                    POS(x, y) = INTRA_LUMA_FILTER(p);
926
113M
                }
927
4.32M
            } else {
928
33.8M
                for (int x = 0; x < w; x++) {
929
31.7M
                    const pixel *p = top + x + idx;
930
31.7M
                    POS(x, y) = INTRA_CHROMA_FILTER(p);
931
31.7M
                }
932
2.05M
            }
933
6.37M
        }
934
7.03M
        if (need_pdpc) {
935
1.91M
            int inv_angle_sum = 256 + inv_angle;
936
15.8M
            for (int x = 0; x < FFMIN(w, 3 << nscale); x++) {
937
13.9M
                const pixel l   = left[y + (inv_angle_sum >> 9)];
938
13.9M
                const pixel val = POS(x, y);
939
13.9M
                const int wl    = 32 >> ((x << 1) >> nscale);
940
13.9M
                const int pred  = val + (((l - val) * wl + 32) >> 6);
941
13.9M
                POS(x, y) = CLIP(pred);
942
13.9M
                inv_angle_sum += inv_angle;
943
13.9M
            }
944
1.91M
        }
945
7.03M
        pos += dp;
946
7.03M
    }
947
598k
}
dsp.c:pred_angular_v_8
Line
Count
Source
897
17.3k
{
898
17.3k
    pixel *src          = (pixel *)_src;
899
17.3k
    const pixel *left   = (const pixel *)_left;
900
17.3k
    const pixel *top    = (const pixel *)_top - (1 + ref_idx);
901
17.3k
    const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
902
17.3k
    int pos = (1 + ref_idx) * intra_pred_angle;
903
17.3k
    const int dp = intra_pred_angle;
904
17.3k
    const int is_luma = !c_idx;
905
17.3k
    int nscale, inv_angle;
906
907
17.3k
    if (need_pdpc) {
908
2.32k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
909
2.32k
        nscale = ff_vvc_nscale_derive(w, h, mode);
910
2.32k
    }
911
912
94.0k
    for (int y = 0; y < h; y++) {
913
76.6k
        const int idx   = (pos >> 5) + ref_idx;
914
76.6k
        const int fact = pos & 31;
915
76.6k
        if (!fact && (!is_luma || !filter_flag)) {
916
81.3k
            for (int x = 0; x < w; x++) {
917
67.9k
                const pixel *p = top + x + idx + 1;
918
67.9k
                POS(x, y) = *p;
919
67.9k
            }
920
63.3k
        } else {
921
63.3k
            if (!c_idx) {
922
45.0k
                const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
923
303k
                for (int x = 0; x < w; x++) {
924
258k
                    const pixel *p = top + x + idx;
925
258k
                    POS(x, y) = INTRA_LUMA_FILTER(p);
926
258k
                }
927
45.0k
            } else {
928
155k
                for (int x = 0; x < w; x++) {
929
137k
                    const pixel *p = top + x + idx;
930
137k
                    POS(x, y) = INTRA_CHROMA_FILTER(p);
931
137k
                }
932
18.3k
            }
933
63.3k
        }
934
76.6k
        if (need_pdpc) {
935
14.0k
            int inv_angle_sum = 256 + inv_angle;
936
56.5k
            for (int x = 0; x < FFMIN(w, 3 << nscale); x++) {
937
42.4k
                const pixel l   = left[y + (inv_angle_sum >> 9)];
938
42.4k
                const pixel val = POS(x, y);
939
42.4k
                const int wl    = 32 >> ((x << 1) >> nscale);
940
42.4k
                const int pred  = val + (((l - val) * wl + 32) >> 6);
941
42.4k
                POS(x, y) = CLIP(pred);
942
42.4k
                inv_angle_sum += inv_angle;
943
42.4k
            }
944
14.0k
        }
945
76.6k
        pos += dp;
946
76.6k
    }
947
17.3k
}
948
949
//8.4.5.2.13 Specification of INTRA_ANGULAR2..INTRA_ANGULAR66 intra prediction modes
950
static void FUNC(pred_angular_h)(uint8_t *_src, const uint8_t *_top, const uint8_t *_left,
951
    const int w, const int h, const ptrdiff_t stride, const int c_idx, const int mode,
952
    const int ref_idx, const int filter_flag, const int need_pdpc)
953
515k
{
954
515k
    pixel *src          = (pixel *)_src;
955
515k
    const pixel *left   = (const pixel *)_left - (1 + ref_idx);
956
515k
    const pixel *top    = (const pixel *)_top;
957
515k
    const int is_luma = !c_idx;
958
515k
    const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
959
515k
    const int dp = intra_pred_angle;
960
515k
    int nscale = 0, inv_angle, inv_angle_sum;
961
962
515k
    if (need_pdpc) {
963
129k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
964
129k
        inv_angle_sum = 256 + inv_angle;
965
129k
        nscale = ff_vvc_nscale_derive(w, h, mode);
966
129k
    }
967
968
7.01M
    for (int y = 0; y < h; y++) {
969
6.50M
        int pos = (1 + ref_idx) * intra_pred_angle;
970
6.50M
        int wt;
971
6.50M
        if (need_pdpc)
972
2.39M
            wt = (32 >> FFMIN(31, (y * 2) >> nscale));
973
974
138M
        for (int x = 0; x < w; x++) {
975
132M
            const int idx  = (pos >> 5) + ref_idx;
976
132M
            const int fact = pos & 31;
977
132M
            const pixel *p = left + y + idx;
978
132M
            int pred;
979
132M
            if (!fact && (!is_luma || !filter_flag)) {
980
9.61M
                pred = p[1];
981
122M
            } else {
982
122M
                if (!c_idx) {
983
96.3M
                    const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
984
96.3M
                    pred = INTRA_LUMA_FILTER(p);
985
96.3M
                } else {
986
26.1M
                    pred = INTRA_CHROMA_FILTER(p);
987
26.1M
                }
988
122M
            }
989
132M
            if (need_pdpc) {
990
57.0M
                if (y < (3 << nscale)) {
991
16.0M
                    const pixel t = top[x + (inv_angle_sum >> 9)];
992
16.0M
                    pred = CLIP(pred + (((t - pred) * wt + 32) >> 6));
993
16.0M
                }
994
57.0M
            }
995
132M
            POS(x, y) = pred;
996
132M
            pos += dp;
997
132M
        }
998
6.50M
        if (need_pdpc)
999
2.39M
            inv_angle_sum += inv_angle;
1000
6.50M
    }
1001
515k
}
dsp.c:pred_angular_h_12
Line
Count
Source
953
2.85k
{
954
2.85k
    pixel *src          = (pixel *)_src;
955
2.85k
    const pixel *left   = (const pixel *)_left - (1 + ref_idx);
956
2.85k
    const pixel *top    = (const pixel *)_top;
957
2.85k
    const int is_luma = !c_idx;
958
2.85k
    const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
959
2.85k
    const int dp = intra_pred_angle;
960
2.85k
    int nscale = 0, inv_angle, inv_angle_sum;
961
962
2.85k
    if (need_pdpc) {
963
429
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
964
429
        inv_angle_sum = 256 + inv_angle;
965
429
        nscale = ff_vvc_nscale_derive(w, h, mode);
966
429
    }
967
968
15.2k
    for (int y = 0; y < h; y++) {
969
12.4k
        int pos = (1 + ref_idx) * intra_pred_angle;
970
12.4k
        int wt;
971
12.4k
        if (need_pdpc)
972
2.01k
            wt = (32 >> FFMIN(31, (y * 2) >> nscale));
973
974
98.7k
        for (int x = 0; x < w; x++) {
975
86.3k
            const int idx  = (pos >> 5) + ref_idx;
976
86.3k
            const int fact = pos & 31;
977
86.3k
            const pixel *p = left + y + idx;
978
86.3k
            int pred;
979
86.3k
            if (!fact && (!is_luma || !filter_flag)) {
980
4.32k
                pred = p[1];
981
81.9k
            } else {
982
81.9k
                if (!c_idx) {
983
31.5k
                    const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
984
31.5k
                    pred = INTRA_LUMA_FILTER(p);
985
50.4k
                } else {
986
50.4k
                    pred = INTRA_CHROMA_FILTER(p);
987
50.4k
                }
988
81.9k
            }
989
86.3k
            if (need_pdpc) {
990
10.4k
                if (y < (3 << nscale)) {
991
7.35k
                    const pixel t = top[x + (inv_angle_sum >> 9)];
992
7.35k
                    pred = CLIP(pred + (((t - pred) * wt + 32) >> 6));
993
7.35k
                }
994
10.4k
            }
995
86.3k
            POS(x, y) = pred;
996
86.3k
            pos += dp;
997
86.3k
        }
998
12.4k
        if (need_pdpc)
999
2.01k
            inv_angle_sum += inv_angle;
1000
12.4k
    }
1001
2.85k
}
dsp.c:pred_angular_h_10
Line
Count
Source
953
455k
{
954
455k
    pixel *src          = (pixel *)_src;
955
455k
    const pixel *left   = (const pixel *)_left - (1 + ref_idx);
956
455k
    const pixel *top    = (const pixel *)_top;
957
455k
    const int is_luma = !c_idx;
958
455k
    const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
959
455k
    const int dp = intra_pred_angle;
960
455k
    int nscale = 0, inv_angle, inv_angle_sum;
961
962
455k
    if (need_pdpc) {
963
126k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
964
126k
        inv_angle_sum = 256 + inv_angle;
965
126k
        nscale = ff_vvc_nscale_derive(w, h, mode);
966
126k
    }
967
968
6.71M
    for (int y = 0; y < h; y++) {
969
6.26M
        int pos = (1 + ref_idx) * intra_pred_angle;
970
6.26M
        int wt;
971
6.26M
        if (need_pdpc)
972
2.37M
            wt = (32 >> FFMIN(31, (y * 2) >> nscale));
973
974
137M
        for (int x = 0; x < w; x++) {
975
130M
            const int idx  = (pos >> 5) + ref_idx;
976
130M
            const int fact = pos & 31;
977
130M
            const pixel *p = left + y + idx;
978
130M
            int pred;
979
130M
            if (!fact && (!is_luma || !filter_flag)) {
980
9.59M
                pred = p[1];
981
121M
            } else {
982
121M
                if (!c_idx) {
983
95.3M
                    const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
984
95.3M
                    pred = INTRA_LUMA_FILTER(p);
985
95.3M
                } else {
986
25.9M
                    pred = INTRA_CHROMA_FILTER(p);
987
25.9M
                }
988
121M
            }
989
130M
            if (need_pdpc) {
990
56.9M
                if (y < (3 << nscale)) {
991
16.0M
                    const pixel t = top[x + (inv_angle_sum >> 9)];
992
16.0M
                    pred = CLIP(pred + (((t - pred) * wt + 32) >> 6));
993
16.0M
                }
994
56.9M
            }
995
130M
            POS(x, y) = pred;
996
130M
            pos += dp;
997
130M
        }
998
6.26M
        if (need_pdpc)
999
2.37M
            inv_angle_sum += inv_angle;
1000
6.26M
    }
1001
455k
}
dsp.c:pred_angular_h_8
Line
Count
Source
953
57.1k
{
954
57.1k
    pixel *src          = (pixel *)_src;
955
57.1k
    const pixel *left   = (const pixel *)_left - (1 + ref_idx);
956
57.1k
    const pixel *top    = (const pixel *)_top;
957
57.1k
    const int is_luma = !c_idx;
958
57.1k
    const int intra_pred_angle = ff_vvc_intra_pred_angle_derive(mode);
959
57.1k
    const int dp = intra_pred_angle;
960
57.1k
    int nscale = 0, inv_angle, inv_angle_sum;
961
962
57.1k
    if (need_pdpc) {
963
2.65k
        inv_angle = ff_vvc_intra_inv_angle_derive(intra_pred_angle);
964
2.65k
        inv_angle_sum = 256 + inv_angle;
965
2.65k
        nscale = ff_vvc_nscale_derive(w, h, mode);
966
2.65k
    }
967
968
287k
    for (int y = 0; y < h; y++) {
969
230k
        int pos = (1 + ref_idx) * intra_pred_angle;
970
230k
        int wt;
971
230k
        if (need_pdpc)
972
14.4k
            wt = (32 >> FFMIN(31, (y * 2) >> nscale));
973
974
1.19M
        for (int x = 0; x < w; x++) {
975
965k
            const int idx  = (pos >> 5) + ref_idx;
976
965k
            const int fact = pos & 31;
977
965k
            const pixel *p = left + y + idx;
978
965k
            int pred;
979
965k
            if (!fact && (!is_luma || !filter_flag)) {
980
8.55k
                pred = p[1];
981
956k
            } else {
982
956k
                if (!c_idx) {
983
883k
                    const int8_t *f = ff_vvc_intra_luma_filter[filter_flag][fact];
984
883k
                    pred = INTRA_LUMA_FILTER(p);
985
883k
                } else {
986
72.9k
                    pred = INTRA_CHROMA_FILTER(p);
987
72.9k
                }
988
956k
            }
989
965k
            if (need_pdpc) {
990
88.6k
                if (y < (3 << nscale)) {
991
45.4k
                    const pixel t = top[x + (inv_angle_sum >> 9)];
992
45.4k
                    pred = CLIP(pred + (((t - pred) * wt + 32) >> 6));
993
45.4k
                }
994
88.6k
            }
995
965k
            POS(x, y) = pred;
996
965k
            pos += dp;
997
965k
        }
998
230k
        if (need_pdpc)
999
14.4k
            inv_angle_sum += inv_angle;
1000
230k
    }
1001
57.1k
}
1002
1003
static void FUNC(ff_vvc_intra_dsp_init)(VVCIntraDSPContext *const intra)
1004
2.27M
{
1005
2.27M
    intra->lmcs_scale_chroma  = FUNC(lmcs_scale_chroma);
1006
2.27M
    intra->intra_cclm_pred    = FUNC(intra_cclm_pred);
1007
2.27M
    intra->intra_pred         = FUNC(intra_pred);
1008
2.27M
    intra->pred_planar        = FUNC(pred_planar);
1009
2.27M
    intra->pred_mip           = FUNC(pred_mip);
1010
2.27M
    intra->pred_dc            = FUNC(pred_dc);
1011
2.27M
    intra->pred_v             = FUNC(pred_v);
1012
2.27M
    intra->pred_h             = FUNC(pred_h);
1013
2.27M
    intra->pred_angular_v     = FUNC(pred_angular_v);
1014
2.27M
    intra->pred_angular_h     = FUNC(pred_angular_h);
1015
2.27M
}
dsp.c:ff_vvc_intra_dsp_init_12
Line
Count
Source
1004
715k
{
1005
715k
    intra->lmcs_scale_chroma  = FUNC(lmcs_scale_chroma);
1006
715k
    intra->intra_cclm_pred    = FUNC(intra_cclm_pred);
1007
715k
    intra->intra_pred         = FUNC(intra_pred);
1008
715k
    intra->pred_planar        = FUNC(pred_planar);
1009
715k
    intra->pred_mip           = FUNC(pred_mip);
1010
715k
    intra->pred_dc            = FUNC(pred_dc);
1011
715k
    intra->pred_v             = FUNC(pred_v);
1012
715k
    intra->pred_h             = FUNC(pred_h);
1013
715k
    intra->pred_angular_v     = FUNC(pred_angular_v);
1014
715k
    intra->pred_angular_h     = FUNC(pred_angular_h);
1015
715k
}
dsp.c:ff_vvc_intra_dsp_init_10
Line
Count
Source
1004
159k
{
1005
159k
    intra->lmcs_scale_chroma  = FUNC(lmcs_scale_chroma);
1006
159k
    intra->intra_cclm_pred    = FUNC(intra_cclm_pred);
1007
159k
    intra->intra_pred         = FUNC(intra_pred);
1008
159k
    intra->pred_planar        = FUNC(pred_planar);
1009
159k
    intra->pred_mip           = FUNC(pred_mip);
1010
159k
    intra->pred_dc            = FUNC(pred_dc);
1011
159k
    intra->pred_v             = FUNC(pred_v);
1012
159k
    intra->pred_h             = FUNC(pred_h);
1013
159k
    intra->pred_angular_v     = FUNC(pred_angular_v);
1014
159k
    intra->pred_angular_h     = FUNC(pred_angular_h);
1015
159k
}
dsp.c:ff_vvc_intra_dsp_init_8
Line
Count
Source
1004
1.40M
{
1005
1.40M
    intra->lmcs_scale_chroma  = FUNC(lmcs_scale_chroma);
1006
1.40M
    intra->intra_cclm_pred    = FUNC(intra_cclm_pred);
1007
1.40M
    intra->intra_pred         = FUNC(intra_pred);
1008
1.40M
    intra->pred_planar        = FUNC(pred_planar);
1009
1.40M
    intra->pred_mip           = FUNC(pred_mip);
1010
1.40M
    intra->pred_dc            = FUNC(pred_dc);
1011
1.40M
    intra->pred_v             = FUNC(pred_v);
1012
1.40M
    intra->pred_h             = FUNC(pred_h);
1013
1.40M
    intra->pred_angular_v     = FUNC(pred_angular_v);
1014
1.40M
    intra->pred_angular_h     = FUNC(pred_angular_h);
1015
1.40M
}