| 1 |
/* { dg-skip-if "exceeds eBPF stack limit" { bpf-*-* } } */ |
| 2 |
/* { dg-additional-options "-fpermissive" } */ |
| 3 |
|
| 4 |
typedef signed char int8_t; |
| 5 |
typedef short int16_t; |
| 6 |
typedef unsigned char uint8_t; |
| 7 |
typedef unsigned int uint32_t; |
| 8 |
|
| 9 |
union unaligned_32 {uint32_t l;} __attribute__((packed)) __attribute__((may_alias)); |
| 10 |
static inline uint32_t NEG_USR32(uint32_t a, int8_t s){return a << (32 - s);} |
| 11 |
typedef struct GetBitContext { const uint8_t *buffer, *buffer_end; int index;}GetBitContext; |
| 12 |
typedef struct VLC {int16_t (*table)[2];} VLC; |
| 13 |
static __attribute__((always_inline)) inline int get_vlc2(GetBitContext *s, int16_t (*table)[2], int bits, int max_depth) { |
| 14 |
unsigned int re_index= (s)->index; |
| 15 |
int re_cache= 0; |
| 16 |
{ |
| 17 |
int n, nb_bits; |
| 18 |
unsigned int index; |
| 19 |
index= NEG_USR32(re_cache, bits); |
| 20 |
n = table[index][1]; |
| 21 |
if(max_depth > 1 && n < 0){ |
| 22 |
re_cache= bswap_32((((const union unaligned_32 *) (((const uint8_t *)(s)->buffer)+(re_index>>3)))->l)) << (re_index&0x07); |
| 23 |
} |
| 24 |
} |
| 25 |
} |
| 26 |
typedef struct HYuvContext{GetBitContext gb; int decorrelate; int bitstream_bpp; uint8_t *temp[3]; VLC vlc[6];} HYuvContext; |
| 27 |
static __attribute__((always_inline)) inline void decode_bgr_1(HYuvContext *s, int count, int decorrelate, int alpha){ |
| 28 |
int i; |
| 29 |
int code = get_vlc2(&s->gb, s->vlc[3].table, 11, 1); |
| 30 |
if(code != -1){ |
| 31 |
s->temp[0][4*i+0] = get_vlc2(&s->gb, s->vlc[0].table, 11, 3); |
| 32 |
s->temp[0][4*i+1] = get_vlc2(&s->gb, s->vlc[1].table, 11, 3); |
| 33 |
s->temp[0][4*i+2] = get_vlc2(&s->gb, s->vlc[2].table, 11, 3); |
| 34 |
} |
| 35 |
} |
| 36 |
void decode_bgr_bitstream(HYuvContext *s, int count){ |
| 37 |
if(s->decorrelate){ |
| 38 |
if(s->bitstream_bpp==24) decode_bgr_1(s, count, 1, 0); |
| 39 |
else decode_bgr_1(s, count, 1, 1); |
| 40 |
} |
| 41 |
} |