File: upsample.cl

package info (click to toggle)
libclc 0.2.0%2Bgit20160907-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,540 kB
  • ctags: 968
  • sloc: lisp: 7,842; ansic: 1,787; python: 623; cpp: 74; makefile: 10; pascal: 7; sh: 1
file content (34 lines) | stat: -rw-r--r-- 1,510 bytes parent folder | download | duplicates (26)
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
#include <clc/clc.h>

#define __CLC_UPSAMPLE_IMPL(BGENTYPE, GENTYPE, UGENTYPE, GENSIZE) \
    _CLC_OVERLOAD _CLC_DEF BGENTYPE upsample(GENTYPE hi, UGENTYPE lo){ \
        return ((BGENTYPE)hi << GENSIZE) | lo; \
    } \
    _CLC_OVERLOAD _CLC_DEF BGENTYPE##2 upsample(GENTYPE##2 hi, UGENTYPE##2 lo){ \
        return (BGENTYPE##2){upsample(hi.s0, lo.s0), upsample(hi.s1, lo.s1)}; \
    } \
    _CLC_OVERLOAD _CLC_DEF BGENTYPE##3 upsample(GENTYPE##3 hi, UGENTYPE##3 lo){ \
        return (BGENTYPE##3){upsample(hi.s0, lo.s0), upsample(hi.s1, lo.s1), upsample(hi.s2, lo.s2)}; \
    } \
    _CLC_OVERLOAD _CLC_DEF BGENTYPE##4 upsample(GENTYPE##4 hi, UGENTYPE##4 lo){ \
        return (BGENTYPE##4){upsample(hi.lo, lo.lo), upsample(hi.hi, lo.hi)}; \
    } \
    _CLC_OVERLOAD _CLC_DEF BGENTYPE##8 upsample(GENTYPE##8 hi, UGENTYPE##8 lo){ \
        return (BGENTYPE##8){upsample(hi.lo, lo.lo), upsample(hi.hi, lo.hi)}; \
    } \
    _CLC_OVERLOAD _CLC_DEF BGENTYPE##16 upsample(GENTYPE##16 hi, UGENTYPE##16 lo){ \
        return (BGENTYPE##16){upsample(hi.lo, lo.lo), upsample(hi.hi, lo.hi)}; \
    } \

#define __CLC_UPSAMPLE_TYPES() \
    __CLC_UPSAMPLE_IMPL(short, char, uchar, 8) \
    __CLC_UPSAMPLE_IMPL(ushort, uchar, uchar, 8) \
    __CLC_UPSAMPLE_IMPL(int, short, ushort, 16) \
    __CLC_UPSAMPLE_IMPL(uint, ushort, ushort, 16) \
    __CLC_UPSAMPLE_IMPL(long, int, uint, 32) \
    __CLC_UPSAMPLE_IMPL(ulong, uint, uint, 32) \

__CLC_UPSAMPLE_TYPES()

#undef __CLC_UPSAMPLE_TYPES
#undef __CLC_UPSAMPLE_IMPL