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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*
* 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_rgb(inout SliceContext sc, const uint slice_idx)
{
int bits = 9;
if (bits != 8 || sc.slice_coding_mode != 0)
bits = bits_per_raw_sample + int(sc.slice_coding_mode != 1);
int run_index = 0;
#ifndef GOLOMB
if (sc.slice_coding_mode == 1) {
if (transparency == 1) {
for (int y = 0; y < sc.slice_dim.y; y++) {
encode_line_pcm(sc, y, 0, 1, bits);
encode_line_pcm(sc, y, 0, 2, bits);
encode_line_pcm(sc, y, 0, 0, bits);
encode_line_pcm(sc, y, 0, 3, bits);
}
} else {
for (int y = 0; y < sc.slice_dim.y; y++) {
encode_line_pcm(sc, y, 0, 1, bits);
encode_line_pcm(sc, y, 0, 2, bits);
encode_line_pcm(sc, y, 0, 0, bits);
}
}
} else
#endif
{
uint64_t slice_state_off = uint64_t(slice_state) +
slice_idx*plane_state_size*codec_planes;
if (transparency == 1) {
for (int y = 0; y < sc.slice_dim.y; y++) {
encode_line(sc, slice_state_off + plane_state_size*0,
y, 0, 1, bits, run_index);
encode_line(sc, slice_state_off + plane_state_size*1,
y, 0, 2, bits, run_index);
encode_line(sc, slice_state_off + plane_state_size*1,
y, 0, 0, bits, run_index);
encode_line(sc, slice_state_off + plane_state_size*2,
y, 0, 3, bits, run_index);
}
} else {
for (int y = 0; y < sc.slice_dim.y; y++) {
encode_line(sc, slice_state_off + plane_state_size*0,
y, 0, 1, bits, run_index);
encode_line(sc, slice_state_off + plane_state_size*1,
y, 0, 2, bits, run_index);
encode_line(sc, slice_state_off + plane_state_size*1,
y, 0, 0, bits, run_index);
}
}
}
finalize_slice(sc, slice_idx);
}
void main(void)
{
const uint slice_idx = gl_WorkGroupID.y*gl_NumWorkGroups.x + gl_WorkGroupID.x;
encode_slice_rgb(slice_ctx[slice_idx], slice_idx);
}
|