mirror of https://github.com/FFmpeg/FFmpeg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.0 KiB
84 lines
3.0 KiB
5 months ago
|
/*
|
||
|
* 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);
|
||
|
}
|