aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/vulkan/ffv1_enc.comp
blob: 880d3a37f09418d0d48e9f7a5c0246abfdea429b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
 * FFv1 codec
 *
 * Copyright (c) 2024 Lynne <dev@lynne.ee>
 *
 * This file is part of FFmpeg.
 *
 * FFmpeg is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * FFmpeg is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with FFmpeg; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 */

void encode_slice(inout SliceContext sc, const uint slice_idx)
{
    int bits = bits_per_raw_sample;

#ifndef GOLOMB
    if (sc.slice_coding_mode == 1) {
        for (int p = 0; p < planes; p++) {

            int h = sc.slice_dim.y;
            if (p > 0 && p < 3)
                h >>= chroma_shift.y;

            for (int y = 0; y < h; y++)
                encode_line_pcm(sc, y, p, 0, bits);
        }
    } else
#endif
    {
        uint64_t slice_state_off = uint64_t(slice_state) +
                                   slice_idx*plane_state_size*codec_planes;

        for (int p = 0; p < planes; p++) {
            int run_index = 0;

            int h = sc.slice_dim.y;
            if (p > 0 && p < 3)
                h >>= chroma_shift.y;

            for (int y = 0; y < h; y++)
                encode_line(sc, slice_state_off, y, p, 0, bits, run_index);

            /* For the second chroma plane, reuse the first plane's state */
            if (p != 1)
                slice_state_off += plane_state_size;
        }
    }

    finalize_slice(sc, slice_idx);
}

void main(void)
{
    const uint slice_idx = gl_WorkGroupID.y*gl_NumWorkGroups.x + gl_WorkGroupID.x;
    encode_slice(slice_ctx[slice_idx], slice_idx);
}