File: dpx_unpack.comp

package info (click to toggle)
chromium 145.0.7632.159-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,976,224 kB
  • sloc: cpp: 36,198,469; ansic: 7,634,080; javascript: 3,564,060; python: 1,649,622; xml: 838,470; asm: 717,087; pascal: 185,708; sh: 88,786; perl: 88,718; objc: 79,984; sql: 59,811; cs: 42,452; fortran: 24,101; makefile: 21,144; tcl: 15,277; php: 14,022; yacc: 9,066; ruby: 7,553; awk: 3,720; lisp: 3,233; lex: 1,328; ada: 727; jsp: 228; sed: 36
file content (86 lines) | stat: -rw-r--r-- 2,473 bytes parent folder | download | duplicates (3)
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
84
85
86
/*
 * Copyright (c) 2025 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
 */

uint32_t read_data(uint off)
{
#ifdef BIG_ENDIAN
    return reverse4(data[off]);
#else
    return data[off];
#endif
}

#ifdef PACKED_10BIT
i16vec4 parse_packed_in_32(ivec2 pos, int stride)
{
    uint32_t d = read_data(pos.y*stride + pos.x);
    i16vec4 v;
    d = d << 10 | d >> 22 & 0x3FFFFF;
    v[0] = int16_t(d & 0x3FF);
    d = d << 10 | d >> 22 & 0x3FFFFF;
    v[1] = int16_t(d & 0x3FF);
    d = d << 10 | d >> 22 & 0x3FFFFF;
    v[2] = int16_t(d & 0x3FF);
    v[3] = int16_t(0);
    return v;
}
#else
i16vec4 parse_packed_in_32(ivec2 pos, int stride)
{
    uint line_size = stride*BITS_PER_COMP*COMPONENTS;
    line_size += line_size & 31;
    line_size += need_align << 3;

    uint line_off = pos.y*line_size;
    uint pix_off = pos.x*BITS_PER_COMP*COMPONENTS;

    uint off = (line_off + pix_off) >> 5;
    uint bit = pix_off & 0x1f;

    uint32_t d0 = read_data(off + 0);
    uint32_t d1 = read_data(off + 1);

    uint64_t combined = (uint64_t(d1) << 32) | d0;
    combined >>= bit;

    return i16vec4(combined,
                   combined >> (BITS_PER_COMP*1),
                   combined >> (BITS_PER_COMP*2),
                   combined >> (BITS_PER_COMP*3)) &
           int16_t((1 << BITS_PER_COMP) - 1);
}
#endif

void main(void)
{
    ivec2 pos = ivec2(gl_GlobalInvocationID.xy);
    if (!IS_WITHIN(pos, imageSize(dst[0])))
        return;

    i16vec4 p = parse_packed_in_32(pos, imageSize(dst[0]).x);

#if NB_IMAGES == 1
    imageStore(dst[0], pos, p);
#else
    const ivec4 fmt_lut = COMPONENTS == 1 ? ivec4(0) : ivec4(2, 0, 1, 3);
    for (uint i = 0; i < COMPONENTS; i++)
        imageStore(dst[fmt_lut[i]], pos, i16vec4(p[i]));
#endif
}