Coverage Report

Created: 2026-07-12 08:57

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/vlc/contrib/contrib-build/bpg/libavcodec/golomb.h
Line
Count
Source
1
/*
2
 * exp golomb vlc stuff
3
 * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
4
 * Copyright (c) 2004 Alex Beregszaszi
5
 *
6
 * This file is part of FFmpeg.
7
 *
8
 * FFmpeg is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * FFmpeg is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with FFmpeg; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 */
22
23
/**
24
 * @file
25
 * @brief
26
 *     exp golomb vlc stuff
27
 * @author Michael Niedermayer <michaelni@gmx.at> and Alex Beregszaszi
28
 */
29
30
#ifndef AVCODEC_GOLOMB_H
31
#define AVCODEC_GOLOMB_H
32
33
#include <stdint.h>
34
35
#include "get_bits.h"
36
#include "put_bits.h"
37
38
#define INVALID_VLC           0x80000000
39
40
extern const uint8_t ff_golomb_vlc_len[512];
41
extern const uint8_t ff_ue_golomb_vlc_code[512];
42
extern const  int8_t ff_se_golomb_vlc_code[512];
43
extern const uint8_t ff_ue_golomb_len[256];
44
45
extern const uint8_t ff_interleaved_golomb_vlc_len[256];
46
extern const uint8_t ff_interleaved_ue_golomb_vlc_code[256];
47
extern const  int8_t ff_interleaved_se_golomb_vlc_code[256];
48
extern const uint8_t ff_interleaved_dirac_golomb_vlc_code[256];
49
50
#ifdef CONFIG_SMALL
51
unsigned get_ue_golomb_long(GetBitContext *gb);
52
53
static inline int get_ue_golomb(GetBitContext *gb)
54
0
{
55
0
    return get_ue_golomb_long(gb);
56
0
}
Unexecuted instantiation: hevc_filter.c:get_ue_golomb
Unexecuted instantiation: hevc.c:get_ue_golomb
Unexecuted instantiation: hevc_ps.c:get_ue_golomb
Unexecuted instantiation: hevc_sei.c:get_ue_golomb
Unexecuted instantiation: golomb.c:get_ue_golomb
57
#else
58
/**
59
 * Read an unsigned Exp-Golomb code in the range 0 to UINT32_MAX-1.
60
 */
61
static inline unsigned get_ue_golomb_long(GetBitContext *gb)
62
{
63
    unsigned buf, log;
64
65
    buf = show_bits_long(gb, 32);
66
    log = 31 - av_log2(buf);
67
    skip_bits_long(gb, log);
68
69
    return get_bits_long(gb, log + 1) - 1;
70
}
71
72
/**
73
 * read unsigned exp golomb code.
74
 */
75
static inline int get_ue_golomb(GetBitContext *gb)
76
{
77
    unsigned int buf;
78
79
    OPEN_READER(re, gb);
80
    UPDATE_CACHE(re, gb);
81
    buf = GET_CACHE(re, gb);
82
83
    if (buf >= (1 << 27)) {
84
        buf >>= 32 - 9;
85
        LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
86
        CLOSE_READER(re, gb);
87
88
        return ff_ue_golomb_vlc_code[buf];
89
    } else {
90
        int log = 2 * av_log2(buf) - 31;
91
        LAST_SKIP_BITS(re, gb, 32 - log);
92
        CLOSE_READER(re, gb);
93
        if (CONFIG_FTRAPV && log < 0) {
94
            av_log(0, AV_LOG_ERROR, "Invalid UE golomb code\n");
95
            return AVERROR_INVALIDDATA;
96
        }
97
        buf >>= log;
98
        buf--;
99
100
        return buf;
101
    }
102
}
103
#endif
104
105
/**
106
 * read unsigned exp golomb code, constraint to a max of 31.
107
 * the return value is undefined if the stored value exceeds 31.
108
 */
109
static inline int get_ue_golomb_31(GetBitContext *gb)
110
0
{
111
0
    unsigned int buf;
112
0
113
0
    OPEN_READER(re, gb);
114
0
    UPDATE_CACHE(re, gb);
115
0
    buf = GET_CACHE(re, gb);
116
0
117
0
    buf >>= 32 - 9;
118
0
    LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
119
0
    CLOSE_READER(re, gb);
120
0
121
0
    return ff_ue_golomb_vlc_code[buf];
122
0
}
Unexecuted instantiation: hevc_filter.c:get_ue_golomb_31
Unexecuted instantiation: hevc.c:get_ue_golomb_31
Unexecuted instantiation: hevc_ps.c:get_ue_golomb_31
Unexecuted instantiation: hevc_sei.c:get_ue_golomb_31
Unexecuted instantiation: golomb.c:get_ue_golomb_31
123
124
static inline unsigned svq3_get_ue_golomb(GetBitContext *gb)
125
0
{
126
0
    uint32_t buf;
127
0
128
0
    OPEN_READER(re, gb);
129
0
    UPDATE_CACHE(re, gb);
130
0
    buf = GET_CACHE(re, gb);
131
0
132
0
    if (buf & 0xAA800000) {
133
0
        buf >>= 32 - 8;
134
0
        LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
135
0
        CLOSE_READER(re, gb);
136
0
137
0
        return ff_interleaved_ue_golomb_vlc_code[buf];
138
0
    } else {
139
0
        unsigned ret = 1;
140
0
141
0
        do {
142
0
            buf >>= 32 - 8;
143
0
            LAST_SKIP_BITS(re, gb,
144
0
                           FFMIN(ff_interleaved_golomb_vlc_len[buf], 8));
145
0
146
0
            if (ff_interleaved_golomb_vlc_len[buf] != 9) {
147
0
                ret <<= (ff_interleaved_golomb_vlc_len[buf] - 1) >> 1;
148
0
                ret  |= ff_interleaved_dirac_golomb_vlc_code[buf];
149
0
                break;
150
0
            }
151
0
            ret = (ret << 4) | ff_interleaved_dirac_golomb_vlc_code[buf];
152
0
            UPDATE_CACHE(re, gb);
153
0
            buf = GET_CACHE(re, gb);
154
0
        } while (ret<0x8000000U && BITS_AVAILABLE(re, gb));
155
0
156
0
        CLOSE_READER(re, gb);
157
0
        return ret - 1;
158
0
    }
159
0
}
Unexecuted instantiation: hevc_filter.c:svq3_get_ue_golomb
Unexecuted instantiation: hevc.c:svq3_get_ue_golomb
Unexecuted instantiation: hevc_ps.c:svq3_get_ue_golomb
Unexecuted instantiation: hevc_sei.c:svq3_get_ue_golomb
Unexecuted instantiation: golomb.c:svq3_get_ue_golomb
160
161
/**
162
 * read unsigned truncated exp golomb code.
163
 */
164
static inline int get_te0_golomb(GetBitContext *gb, int range)
165
0
{
166
0
    av_assert2(range >= 1);
167
0
168
0
    if (range == 1)
169
0
        return 0;
170
0
    else if (range == 2)
171
0
        return get_bits1(gb) ^ 1;
172
0
    else
173
0
        return get_ue_golomb(gb);
174
0
}
Unexecuted instantiation: hevc_filter.c:get_te0_golomb
Unexecuted instantiation: hevc.c:get_te0_golomb
Unexecuted instantiation: hevc_ps.c:get_te0_golomb
Unexecuted instantiation: hevc_sei.c:get_te0_golomb
Unexecuted instantiation: golomb.c:get_te0_golomb
175
176
/**
177
 * read unsigned truncated exp golomb code.
178
 */
179
static inline int get_te_golomb(GetBitContext *gb, int range)
180
0
{
181
0
    av_assert2(range >= 1);
182
0
183
0
    if (range == 2)
184
0
        return get_bits1(gb) ^ 1;
185
0
    else
186
0
        return get_ue_golomb(gb);
187
0
}
Unexecuted instantiation: hevc_filter.c:get_te_golomb
Unexecuted instantiation: hevc.c:get_te_golomb
Unexecuted instantiation: hevc_ps.c:get_te_golomb
Unexecuted instantiation: hevc_sei.c:get_te_golomb
Unexecuted instantiation: golomb.c:get_te_golomb
188
189
#ifdef CONFIG_SMALL
190
int get_se_golomb_long(GetBitContext *gb);
191
192
static inline int get_se_golomb(GetBitContext *gb)
193
0
{
194
0
    return get_se_golomb_long(gb);
195
0
}
Unexecuted instantiation: hevc_filter.c:get_se_golomb
Unexecuted instantiation: hevc.c:get_se_golomb
Unexecuted instantiation: hevc_ps.c:get_se_golomb
Unexecuted instantiation: hevc_sei.c:get_se_golomb
Unexecuted instantiation: golomb.c:get_se_golomb
196
#else
197
static inline int get_se_golomb_long(GetBitContext *gb)
198
{
199
    unsigned int buf = get_ue_golomb_long(gb);
200
201
    if (buf & 1)
202
        buf = (buf + 1) >> 1;
203
    else
204
        buf = -(buf >> 1);
205
206
    return buf;
207
}
208
209
/**
210
 * read signed exp golomb code.
211
 */
212
static inline int get_se_golomb(GetBitContext *gb)
213
{
214
    unsigned int buf;
215
216
    OPEN_READER(re, gb);
217
    UPDATE_CACHE(re, gb);
218
    buf = GET_CACHE(re, gb);
219
220
    if (buf >= (1 << 27)) {
221
        buf >>= 32 - 9;
222
        LAST_SKIP_BITS(re, gb, ff_golomb_vlc_len[buf]);
223
        CLOSE_READER(re, gb);
224
225
        return ff_se_golomb_vlc_code[buf];
226
    } else {
227
        int log = av_log2(buf);
228
        LAST_SKIP_BITS(re, gb, 31 - log);
229
        UPDATE_CACHE(re, gb);
230
        buf = GET_CACHE(re, gb);
231
232
        buf >>= log;
233
234
        LAST_SKIP_BITS(re, gb, 32 - log);
235
        CLOSE_READER(re, gb);
236
237
        if (buf & 1)
238
            buf = -(buf >> 1);
239
        else
240
            buf = (buf >> 1);
241
242
        return buf;
243
    }
244
}
245
#endif
246
247
static inline int svq3_get_se_golomb(GetBitContext *gb)
248
0
{
249
0
    unsigned int buf;
250
0
251
0
    OPEN_READER(re, gb);
252
0
    UPDATE_CACHE(re, gb);
253
0
    buf = GET_CACHE(re, gb);
254
0
255
0
    if (buf & 0xAA800000) {
256
0
        buf >>= 32 - 8;
257
0
        LAST_SKIP_BITS(re, gb, ff_interleaved_golomb_vlc_len[buf]);
258
0
        CLOSE_READER(re, gb);
259
0
260
0
        return ff_interleaved_se_golomb_vlc_code[buf];
261
0
    } else {
262
0
        int log;
263
0
        LAST_SKIP_BITS(re, gb, 8);
264
0
        UPDATE_CACHE(re, gb);
265
0
        buf |= 1 | (GET_CACHE(re, gb) >> 8);
266
0
267
0
        if ((buf & 0xAAAAAAAA) == 0)
268
0
            return INVALID_VLC;
269
0
270
0
        for (log = 31; (buf & 0x80000000) == 0; log--)
271
0
            buf = (buf << 2) - ((buf << log) >> (log - 1)) + (buf >> 30);
272
0
273
0
        LAST_SKIP_BITS(re, gb, 63 - 2 * log - 8);
274
0
        CLOSE_READER(re, gb);
275
0
276
0
        return (signed) (((((buf << log) >> log) - 1) ^ -(buf & 0x1)) + 1) >> 1;
277
0
    }
278
0
}
Unexecuted instantiation: hevc_filter.c:svq3_get_se_golomb
Unexecuted instantiation: hevc.c:svq3_get_se_golomb
Unexecuted instantiation: hevc_ps.c:svq3_get_se_golomb
Unexecuted instantiation: hevc_sei.c:svq3_get_se_golomb
Unexecuted instantiation: golomb.c:svq3_get_se_golomb
279
280
static inline int dirac_get_se_golomb(GetBitContext *gb)
281
0
{
282
0
    uint32_t ret = svq3_get_ue_golomb(gb);
283
0
284
0
    if (ret) {
285
0
        uint32_t buf;
286
0
        OPEN_READER(re, gb);
287
0
        UPDATE_CACHE(re, gb);
288
0
        buf = SHOW_SBITS(re, gb, 1);
289
0
        LAST_SKIP_BITS(re, gb, 1);
290
0
        ret = (ret ^ buf) - buf;
291
0
        CLOSE_READER(re, gb);
292
0
    }
293
0
294
0
    return ret;
295
0
}
Unexecuted instantiation: hevc_filter.c:dirac_get_se_golomb
Unexecuted instantiation: hevc.c:dirac_get_se_golomb
Unexecuted instantiation: hevc_ps.c:dirac_get_se_golomb
Unexecuted instantiation: hevc_sei.c:dirac_get_se_golomb
Unexecuted instantiation: golomb.c:dirac_get_se_golomb
296
297
/**
298
 * read unsigned golomb rice code (ffv1).
299
 */
300
static inline int get_ur_golomb(GetBitContext *gb, int k, int limit,
301
                                int esc_len)
302
0
{
303
0
    unsigned int buf;
304
0
    int log;
305
0
306
0
    OPEN_READER(re, gb);
307
0
    UPDATE_CACHE(re, gb);
308
0
    buf = GET_CACHE(re, gb);
309
0
310
0
    log = av_log2(buf);
311
0
312
0
    if (log > 31 - limit) {
313
0
        buf >>= log - k;
314
0
        buf  += (30 - log) << k;
315
0
        LAST_SKIP_BITS(re, gb, 32 + k - log);
316
0
        CLOSE_READER(re, gb);
317
0
318
0
        return buf;
319
0
    } else {
320
0
        LAST_SKIP_BITS(re, gb, limit);
321
0
        UPDATE_CACHE(re, gb);
322
0
323
0
        buf = SHOW_UBITS(re, gb, esc_len);
324
0
325
0
        LAST_SKIP_BITS(re, gb, esc_len);
326
0
        CLOSE_READER(re, gb);
327
0
328
0
        return buf + limit - 1;
329
0
    }
330
0
}
Unexecuted instantiation: hevc_filter.c:get_ur_golomb
Unexecuted instantiation: hevc.c:get_ur_golomb
Unexecuted instantiation: hevc_ps.c:get_ur_golomb
Unexecuted instantiation: hevc_sei.c:get_ur_golomb
Unexecuted instantiation: golomb.c:get_ur_golomb
331
332
/**
333
 * read unsigned golomb rice code (jpegls).
334
 */
335
static inline int get_ur_golomb_jpegls(GetBitContext *gb, int k, int limit,
336
                                       int esc_len)
337
0
{
338
0
    unsigned int buf;
339
0
    int log;
340
0
341
0
    OPEN_READER(re, gb);
342
0
    UPDATE_CACHE(re, gb);
343
0
    buf = GET_CACHE(re, gb);
344
0
345
0
    log = av_log2(buf);
346
0
347
0
    if (log - k >= 32 - MIN_CACHE_BITS + (MIN_CACHE_BITS == 32) &&
348
0
        32 - log < limit) {
349
0
        buf >>= log - k;
350
0
        buf  += (30 - log) << k;
351
0
        LAST_SKIP_BITS(re, gb, 32 + k - log);
352
0
        CLOSE_READER(re, gb);
353
0
354
0
        return buf;
355
0
    } else {
356
0
        int i;
357
0
        for (i = 0; i < limit && SHOW_UBITS(re, gb, 1) == 0; i++) {
358
0
            if (gb->size_in_bits <= re_index)
359
0
                return -1;
360
0
            LAST_SKIP_BITS(re, gb, 1);
361
0
            UPDATE_CACHE(re, gb);
362
0
        }
363
0
        SKIP_BITS(re, gb, 1);
364
0
365
0
        if (i < limit - 1) {
366
0
            if (k) {
367
0
                buf = SHOW_UBITS(re, gb, k);
368
0
                LAST_SKIP_BITS(re, gb, k);
369
0
            } else {
370
0
                buf = 0;
371
0
            }
372
0
373
0
            CLOSE_READER(re, gb);
374
0
            return buf + (i << k);
375
0
        } else if (i == limit - 1) {
376
0
            buf = SHOW_UBITS(re, gb, esc_len);
377
0
            LAST_SKIP_BITS(re, gb, esc_len);
378
0
            CLOSE_READER(re, gb);
379
0
380
0
            return buf + 1;
381
0
        } else
382
0
            return -1;
383
0
    }
384
0
}
Unexecuted instantiation: hevc_filter.c:get_ur_golomb_jpegls
Unexecuted instantiation: hevc.c:get_ur_golomb_jpegls
Unexecuted instantiation: hevc_ps.c:get_ur_golomb_jpegls
Unexecuted instantiation: hevc_sei.c:get_ur_golomb_jpegls
Unexecuted instantiation: golomb.c:get_ur_golomb_jpegls
385
386
/**
387
 * read signed golomb rice code (ffv1).
388
 */
389
static inline int get_sr_golomb(GetBitContext *gb, int k, int limit,
390
                                int esc_len)
391
0
{
392
0
    int v = get_ur_golomb(gb, k, limit, esc_len);
393
0
394
0
    v++;
395
0
    if (v & 1)
396
0
        return v >> 1;
397
0
    else
398
0
        return -(v >> 1);
399
0
400
0
//    return (v>>1) ^ -(v&1);
401
0
}
Unexecuted instantiation: hevc_filter.c:get_sr_golomb
Unexecuted instantiation: hevc.c:get_sr_golomb
Unexecuted instantiation: hevc_ps.c:get_sr_golomb
Unexecuted instantiation: hevc_sei.c:get_sr_golomb
Unexecuted instantiation: golomb.c:get_sr_golomb
402
403
/**
404
 * read signed golomb rice code (flac).
405
 */
406
static inline int get_sr_golomb_flac(GetBitContext *gb, int k, int limit,
407
                                     int esc_len)
408
0
{
409
0
    int v = get_ur_golomb_jpegls(gb, k, limit, esc_len);
410
0
    return (v >> 1) ^ -(v & 1);
411
0
}
Unexecuted instantiation: hevc_filter.c:get_sr_golomb_flac
Unexecuted instantiation: hevc.c:get_sr_golomb_flac
Unexecuted instantiation: hevc_ps.c:get_sr_golomb_flac
Unexecuted instantiation: hevc_sei.c:get_sr_golomb_flac
Unexecuted instantiation: golomb.c:get_sr_golomb_flac
412
413
/**
414
 * read unsigned golomb rice code (shorten).
415
 */
416
static inline unsigned int get_ur_golomb_shorten(GetBitContext *gb, int k)
417
0
{
418
0
    return get_ur_golomb_jpegls(gb, k, INT_MAX, 0);
419
0
}
Unexecuted instantiation: hevc_filter.c:get_ur_golomb_shorten
Unexecuted instantiation: hevc.c:get_ur_golomb_shorten
Unexecuted instantiation: hevc_ps.c:get_ur_golomb_shorten
Unexecuted instantiation: hevc_sei.c:get_ur_golomb_shorten
Unexecuted instantiation: golomb.c:get_ur_golomb_shorten
420
421
/**
422
 * read signed golomb rice code (shorten).
423
 */
424
static inline int get_sr_golomb_shorten(GetBitContext *gb, int k)
425
0
{
426
0
    int uvar = get_ur_golomb_jpegls(gb, k + 1, INT_MAX, 0);
427
0
    if (uvar & 1)
428
0
        return ~(uvar >> 1);
429
0
    else
430
0
        return uvar >> 1;
431
0
}
Unexecuted instantiation: hevc_filter.c:get_sr_golomb_shorten
Unexecuted instantiation: hevc.c:get_sr_golomb_shorten
Unexecuted instantiation: hevc_ps.c:get_sr_golomb_shorten
Unexecuted instantiation: hevc_sei.c:get_sr_golomb_shorten
Unexecuted instantiation: golomb.c:get_sr_golomb_shorten
432
433
#ifdef TRACE
434
435
static inline int get_ue(GetBitContext *s, const char *file, const char *func,
436
                         int line)
437
{
438
    int show = show_bits(s, 24);
439
    int pos  = get_bits_count(s);
440
    int i    = get_ue_golomb(s);
441
    int len  = get_bits_count(s) - pos;
442
    int bits = show >> (24 - len);
443
444
    print_bin(bits, len);
445
446
    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d ue  @%5d in %s %s:%d\n",
447
           bits, len, i, pos, file, func, line);
448
449
    return i;
450
}
451
452
static inline int get_se(GetBitContext *s, const char *file, const char *func,
453
                         int line)
454
{
455
    int show = show_bits(s, 24);
456
    int pos  = get_bits_count(s);
457
    int i    = get_se_golomb(s);
458
    int len  = get_bits_count(s) - pos;
459
    int bits = show >> (24 - len);
460
461
    print_bin(bits, len);
462
463
    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d se  @%5d in %s %s:%d\n",
464
           bits, len, i, pos, file, func, line);
465
466
    return i;
467
}
468
469
static inline int get_te(GetBitContext *s, int r, char *file, const char *func,
470
                         int line)
471
{
472
    int show = show_bits(s, 24);
473
    int pos  = get_bits_count(s);
474
    int i    = get_te0_golomb(s, r);
475
    int len  = get_bits_count(s) - pos;
476
    int bits = show >> (24 - len);
477
478
    print_bin(bits, len);
479
480
    av_log(NULL, AV_LOG_DEBUG, "%5d %2d %3d te  @%5d in %s %s:%d\n",
481
           bits, len, i, pos, file, func, line);
482
483
    return i;
484
}
485
486
#define get_ue_golomb(a) get_ue(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
487
#define get_se_golomb(a) get_se(a, __FILE__, __PRETTY_FUNCTION__, __LINE__)
488
#define get_te_golomb(a, r)  get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
489
#define get_te0_golomb(a, r) get_te(a, r, __FILE__, __PRETTY_FUNCTION__, __LINE__)
490
491
#endif /* TRACE */
492
493
/**
494
 * write unsigned exp golomb code.
495
 */
496
static inline void set_ue_golomb(PutBitContext *pb, int i)
497
0
{
498
0
    av_assert2(i >= 0);
499
0
500
0
#if 0
501
0
    if (i = 0) {
502
0
        put_bits(pb, 1, 1);
503
0
        return;
504
0
    }
505
0
#endif
506
0
    if (i < 256)
507
0
        put_bits(pb, ff_ue_golomb_len[i], i + 1);
508
0
    else {
509
0
        int e = av_log2(i + 1);
510
0
        put_bits(pb, 2 * e + 1, i + 1);
511
0
    }
512
0
}
Unexecuted instantiation: hevc_filter.c:set_ue_golomb
Unexecuted instantiation: hevc.c:set_ue_golomb
Unexecuted instantiation: hevc_ps.c:set_ue_golomb
Unexecuted instantiation: hevc_sei.c:set_ue_golomb
Unexecuted instantiation: golomb.c:set_ue_golomb
513
514
/**
515
 * write truncated unsigned exp golomb code.
516
 */
517
static inline void set_te_golomb(PutBitContext *pb, int i, int range)
518
0
{
519
0
    av_assert2(range >= 1);
520
0
    av_assert2(i <= range);
521
0
522
0
    if (range == 2)
523
0
        put_bits(pb, 1, i ^ 1);
524
0
    else
525
0
        set_ue_golomb(pb, i);
526
0
}
Unexecuted instantiation: hevc_filter.c:set_te_golomb
Unexecuted instantiation: hevc.c:set_te_golomb
Unexecuted instantiation: hevc_ps.c:set_te_golomb
Unexecuted instantiation: hevc_sei.c:set_te_golomb
Unexecuted instantiation: golomb.c:set_te_golomb
527
528
/**
529
 * write signed exp golomb code. 16 bits at most.
530
 */
531
static inline void set_se_golomb(PutBitContext *pb, int i)
532
0
{
533
0
#if 0
534
0
    if (i <= 0)
535
0
        i = -2 * i;
536
0
    else
537
0
        i = 2 * i - 1;
538
0
#elif 1
539
0
    i = 2 * i - 1;
540
0
    if (i < 0)
541
0
        i ^= -1;    //FIXME check if gcc does the right thing
542
0
#else
543
0
    i  = 2 * i - 1;
544
0
    i ^= (i >> 31);
545
0
#endif
546
0
    set_ue_golomb(pb, i);
547
0
}
Unexecuted instantiation: hevc_filter.c:set_se_golomb
Unexecuted instantiation: hevc.c:set_se_golomb
Unexecuted instantiation: hevc_ps.c:set_se_golomb
Unexecuted instantiation: hevc_sei.c:set_se_golomb
Unexecuted instantiation: golomb.c:set_se_golomb
548
549
/**
550
 * write unsigned golomb rice code (ffv1).
551
 */
552
static inline void set_ur_golomb(PutBitContext *pb, int i, int k, int limit,
553
                                 int esc_len)
554
0
{
555
0
    int e;
556
0
557
0
    av_assert2(i >= 0);
558
0
559
0
    e = i >> k;
560
0
    if (e < limit)
561
0
        put_bits(pb, e + k + 1, (1 << k) + (i & ((1 << k) - 1)));
562
0
    else
563
0
        put_bits(pb, limit + esc_len, i - limit + 1);
564
0
}
Unexecuted instantiation: hevc_filter.c:set_ur_golomb
Unexecuted instantiation: hevc.c:set_ur_golomb
Unexecuted instantiation: hevc_ps.c:set_ur_golomb
Unexecuted instantiation: hevc_sei.c:set_ur_golomb
Unexecuted instantiation: golomb.c:set_ur_golomb
565
566
/**
567
 * write unsigned golomb rice code (jpegls).
568
 */
569
static inline void set_ur_golomb_jpegls(PutBitContext *pb, int i, int k,
570
                                        int limit, int esc_len)
571
0
{
572
0
    int e;
573
0
574
0
    av_assert2(i >= 0);
575
0
576
0
    e = (i >> k) + 1;
577
0
    if (e < limit) {
578
0
        while (e > 31) {
579
0
            put_bits(pb, 31, 0);
580
0
            e -= 31;
581
0
        }
582
0
        put_bits(pb, e, 1);
583
0
        if (k)
584
0
            put_sbits(pb, k, i);
585
0
    } else {
586
0
        while (limit > 31) {
587
0
            put_bits(pb, 31, 0);
588
0
            limit -= 31;
589
0
        }
590
0
        put_bits(pb, limit, 1);
591
0
        put_bits(pb, esc_len, i - 1);
592
0
    }
593
0
}
Unexecuted instantiation: hevc_filter.c:set_ur_golomb_jpegls
Unexecuted instantiation: hevc.c:set_ur_golomb_jpegls
Unexecuted instantiation: hevc_ps.c:set_ur_golomb_jpegls
Unexecuted instantiation: hevc_sei.c:set_ur_golomb_jpegls
Unexecuted instantiation: golomb.c:set_ur_golomb_jpegls
594
595
/**
596
 * write signed golomb rice code (ffv1).
597
 */
598
static inline void set_sr_golomb(PutBitContext *pb, int i, int k, int limit,
599
                                 int esc_len)
600
0
{
601
0
    int v;
602
0
603
0
    v  = -2 * i - 1;
604
0
    v ^= (v >> 31);
605
0
606
0
    set_ur_golomb(pb, v, k, limit, esc_len);
607
0
}
Unexecuted instantiation: hevc_filter.c:set_sr_golomb
Unexecuted instantiation: hevc.c:set_sr_golomb
Unexecuted instantiation: hevc_ps.c:set_sr_golomb
Unexecuted instantiation: hevc_sei.c:set_sr_golomb
Unexecuted instantiation: golomb.c:set_sr_golomb
608
609
/**
610
 * write signed golomb rice code (flac).
611
 */
612
static inline void set_sr_golomb_flac(PutBitContext *pb, int i, int k,
613
                                      int limit, int esc_len)
614
0
{
615
0
    int v;
616
0
617
0
    v  = -2 * i - 1;
618
0
    v ^= (v >> 31);
619
0
620
0
    set_ur_golomb_jpegls(pb, v, k, limit, esc_len);
621
0
}
Unexecuted instantiation: hevc_filter.c:set_sr_golomb_flac
Unexecuted instantiation: hevc.c:set_sr_golomb_flac
Unexecuted instantiation: hevc_ps.c:set_sr_golomb_flac
Unexecuted instantiation: hevc_sei.c:set_sr_golomb_flac
Unexecuted instantiation: golomb.c:set_sr_golomb_flac
622
623
#endif /* AVCODEC_GOLOMB_H */