FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
apv_decode.h
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef AVCODEC_APV_DECODE_H
20 #define AVCODEC_APV_DECODE_H
21 
22 #include <stdint.h>
23 
24 #include "apv.h"
25 #include "avcodec.h"
26 #include "get_bits.h"
27 
28 
29 // Number of bits in the entropy look-up tables.
30 // It may be desirable to tune this per-architecture, as a larger LUT
31 // trades greater memory use for fewer instructions.
32 // (N bits -> 24*2^N bytes of tables; 9 -> 12KB of tables.)
33 #define APV_VLC_LUT_BITS 9
34 #define APV_VLC_LUT_SIZE (1 << APV_VLC_LUT_BITS)
35 
36 typedef struct APVSingleVLCLUTEntry {
37  uint16_t result; // Return value if not reading more.
38  uint8_t consume; // Number of bits to consume.
39  uint8_t more; // Whether to read additional bits.
41 
42 typedef struct APVMultiVLCLUTEntry {
43  // Number of symbols this bit stream resolves to.
44  uint8_t count;
45  // k_run after decoding all symbols.
46  uint8_t k_run : 2;
47  // k_level after decoding the first level symbol.
48  uint8_t k_level_0 : 3;
49  // k_level after decoding all symbols.
50  uint8_t k_level_1 : 3;
51  // Run output values.
52  uint8_t run[2];
53  // Level output values.
54  int16_t level[2];
55  // Bit index of the end of each code.
56  uint8_t offset[4];
58 
59 typedef struct APVVLCLUT {
60  // Single-symbol LUT for VLCs.
61  // Applies to all coefficients, but used only for DC coefficients
62  // in the decoder.
64  // Multi-symbol LUT for run/level combinations, decoding up to four
65  // symbols per step. Comes in two versions, which to use depends on
66  // whether the next symbol is a run or a level.
69 } APVVLCLUT;
70 
71 typedef struct APVEntropyState {
72  void *log_ctx;
73 
75 
76  // Previous DC level value.
77  int16_t prev_dc;
78  // k parameter implied by the previous DC level value.
79  uint8_t prev_k_dc;
80  // k parameter implied by the previous first AC level value.
81  uint8_t prev_k_level;
83 
84 
85 /**
86  * Build the decoder VLC look-up tables.
87  */
89 
90 /**
91  * Entropy decode a single 8x8 block to coefficients.
92  *
93  * Outputs nonzero coefficients only to the block row-major order
94  * (dezigzag is applied within the function). The output block
95  * must have been filled with zeroes before calling this function.
96  */
97 int ff_apv_entropy_decode_block(int16_t *restrict coeff,
98  GetBitContext *restrict gbc,
99  APVEntropyState *restrict state);
100 
101 #endif /* AVCODEC_APV_DECODE_H */
state
static struct @508 state
APVSingleVLCLUTEntry::result
uint16_t result
Definition: apv_decode.h:37
APVMultiVLCLUTEntry::run
uint8_t run[2]
Definition: apv_decode.h:52
APVVLCLUT::level_first_lut
APVMultiVLCLUTEntry level_first_lut[3][5][APV_VLC_LUT_SIZE]
Definition: apv_decode.h:68
GetBitContext
Definition: get_bits.h:108
decode_lut
static APVVLCLUT decode_lut
Definition: apv_decode.c:60
APV_VLC_LUT_SIZE
#define APV_VLC_LUT_SIZE
Definition: apv_decode.h:34
get_bits.h
ff_apv_entropy_build_decode_lut
void ff_apv_entropy_build_decode_lut(APVVLCLUT *decode_lut)
Build the decoder VLC look-up tables.
Definition: apv_entropy.c:62
APVSingleVLCLUTEntry
Definition: apv_decode.h:36
APVEntropyState
Definition: apv_decode.h:71
APVEntropyState::log_ctx
void * log_ctx
Definition: apv_decode.h:72
apv.h
APVEntropyState::prev_k_level
uint8_t prev_k_level
Definition: apv_decode.h:81
APVMultiVLCLUTEntry
Definition: apv_decode.h:42
APVVLCLUT::run_first_lut
APVMultiVLCLUTEntry run_first_lut[3][5][APV_VLC_LUT_SIZE]
Definition: apv_decode.h:67
APVMultiVLCLUTEntry::k_run
uint8_t k_run
Definition: apv_decode.h:46
APVMultiVLCLUTEntry::level
int16_t level[2]
Definition: apv_decode.h:54
APVEntropyState::prev_k_dc
uint8_t prev_k_dc
Definition: apv_decode.h:79
APVVLCLUT::single_lut
APVSingleVLCLUTEntry single_lut[6][APV_VLC_LUT_SIZE]
Definition: apv_decode.h:63
APVMultiVLCLUTEntry::offset
uint8_t offset[4]
Definition: apv_decode.h:56
APVSingleVLCLUTEntry::more
uint8_t more
Definition: apv_decode.h:39
avcodec.h
APVVLCLUT
Definition: apv_decode.h:59
APVMultiVLCLUTEntry::count
uint8_t count
Definition: apv_decode.h:44
APVMultiVLCLUTEntry::k_level_0
uint8_t k_level_0
Definition: apv_decode.h:48
coeff
static const double coeff[2][5]
Definition: vf_owdenoise.c:80
ff_apv_entropy_decode_block
int ff_apv_entropy_decode_block(int16_t *restrict coeff, GetBitContext *restrict gbc, APVEntropyState *restrict state)
Entropy decode a single 8x8 block to coefficients.
Definition: apv_entropy.c:208
APVSingleVLCLUTEntry::consume
uint8_t consume
Definition: apv_decode.h:38
APVEntropyState::prev_dc
int16_t prev_dc
Definition: apv_decode.h:77
APVEntropyState::decode_lut
const APVVLCLUT * decode_lut
Definition: apv_decode.h:74
APVMultiVLCLUTEntry::k_level_1
uint8_t k_level_1
Definition: apv_decode.h:50