blob: 42ae41b00a7c9e3d82dfad28666634ce8d9704e9
1 | /* |
2 | * Copyright (C) 2016 Open Broadcast Systems Ltd. |
3 | * Author 2016 Rostislav Pehlivanov <rpehlivanov@obe.tv> |
4 | * |
5 | * This file is part of FFmpeg. |
6 | * |
7 | * FFmpeg is free software; you can redistribute it and/or |
8 | * modify it under the terms of the GNU Lesser General Public |
9 | * License as published by the Free Software Foundation; either |
10 | * version 2.1 of the License, or (at your option) any later version. |
11 | * |
12 | * FFmpeg is distributed in the hope that it will be useful, |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | * Lesser General Public License for more details. |
16 | * |
17 | * You should have received a copy of the GNU Lesser General Public |
18 | * License along with FFmpeg; if not, write to the Free Software |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | */ |
21 | |
22 | #ifndef AVCODEC_DIRAC_VLC_H |
23 | #define AVCODEC_DIRAC_VLC_H |
24 | |
25 | #include "libavutil/avutil.h" |
26 | |
27 | /* Can be 32 bits wide for some performance gain on some machines, but it will |
28 | * incorrectly decode very long coefficients (usually only 1 or 2 per frame) */ |
29 | typedef uint64_t residual; |
30 | |
31 | #define LUT_BITS 8 |
32 | |
33 | /* Exactly 64 bytes */ |
34 | typedef struct DiracGolombLUT { |
35 | residual preamble, leftover; |
36 | int32_t ready[LUT_BITS]; |
37 | int32_t preamble_bits, leftover_bits, ready_num; |
38 | int8_t need_s, sign; |
39 | } DiracGolombLUT; |
40 | |
41 | av_cold int ff_dirac_golomb_reader_init(DiracGolombLUT **lut_ctx); |
42 | |
43 | int ff_dirac_golomb_read_32bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, |
44 | int bytes, uint8_t *dst, int coeffs); |
45 | |
46 | int ff_dirac_golomb_read_16bit(DiracGolombLUT *lut_ctx, const uint8_t *buf, |
47 | int bytes, uint8_t *_dst, int coeffs); |
48 | |
49 | av_cold void ff_dirac_golomb_reader_end(DiracGolombLUT **lut_ctx); |
50 | |
51 | #endif /* AVCODEC_DIRAC_VLC_H */ |
52 |