File: ffv1_dec_reset.comp.glsl

package info (click to toggle)
ffmpeg 7%3A8.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 113,964 kB
  • sloc: ansic: 1,376,567; asm: 153,816; sh: 9,602; makefile: 5,414; cpp: 5,172; lisp: 1,771; perl: 1,463; objc: 1,058; python: 120; awk: 56; ruby: 51
file content (72 lines) | stat: -rw-r--r-- 2,403 bytes parent folder | download
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
/*
 * 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
 */

#pragma shader_stage(compute)
#extension GL_GOOGLE_include_directive : require

#define SB_QUALI readonly
#include "common.glsl"
#include "ffv1_common.glsl"

#ifdef GOLOMB
#define PS_SHIFT 3
layout (set = 1, binding = 1, scalar) writeonly buffer slice_state_buf {
    VlcState slice_vlc_state[];
};
#else
#define PS_SHIFT 2
layout (set = 1, binding = 1, scalar) writeonly buffer slice_state_buf {
    uint32_t slice_rc_state[];
};
#endif

void main(void)
{
    const uint slice_idx = gl_WorkGroupID.y*gl_NumWorkGroups.x + gl_WorkGroupID.x;

    if (!key_frame && !slice_ctx[slice_idx].slice_reset_contexts)
        return;

    const uint8_t qidx = slice_ctx[slice_idx].quant_table_idx[gl_WorkGroupID.z];

    uint contexts = context_count[qidx];
    uint plane_state_len = plane_state_size >> PS_SHIFT;
    uint offs = slice_idx*plane_state_len*codec_planes +
                gl_WorkGroupID.z*plane_state_len +
                gl_LocalInvocationID.x;

#ifdef GOLOMB
    for (uint x = gl_LocalInvocationID.x; x < contexts; x += gl_WorkGroupSize.x) {
        slice_vlc_state[offs].drift     =  int16_t(0);
        slice_vlc_state[offs].error_sum = uint16_t(4);
        slice_vlc_state[offs].bias      =   int8_t(0);
        slice_vlc_state[offs].count     =  uint8_t(1);
        offs += gl_WorkGroupSize.x;
    }
#else
    uint count_total = contexts*(CONTEXT_SIZE /* bytes */ >> 2 /* dwords */);
    for (uint x = gl_LocalInvocationID.x; x < count_total; x += gl_WorkGroupSize.x) {
        slice_rc_state[offs] = 0x80808080;
        offs += gl_WorkGroupSize.x;
    }
#endif
}