FFmpeg
Loading...
Searching...
No Matches
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#include <stdatomic.h>
24
25#include "apv.h"
26#include "apv_dsp.h"
27#include "cbs_apv.h"
28
29#include "cbs.h"
30#include "get_bits.h"
31#include "libavutil/frame.h"
32
33// Number of bits in the entropy look-up tables.
34// It may be desirable to tune this per-architecture, as a larger LUT
35// trades greater memory use for fewer instructions.
36// (N bits -> 24*2^N bytes of tables; 9 -> 12KB of tables.)
37#define APV_VLC_LUT_BITS 9
38#define APV_VLC_LUT_SIZE (1 << APV_VLC_LUT_BITS)
39
40typedef struct APVSingleVLCLUTEntry {
41 uint16_t result; // Return value if not reading more.
42 uint8_t consume; // Number of bits to consume.
43 uint8_t more; // Whether to read additional bits.
45
46typedef struct APVMultiVLCLUTEntry {
47 // Number of symbols this bit stream resolves to.
48 uint8_t count;
49 // k_run after decoding all symbols.
50 uint8_t k_run : 2;
51 // k_level after decoding the first level symbol.
52 uint8_t k_level_0 : 3;
53 // k_level after decoding all symbols.
54 uint8_t k_level_1 : 3;
55 // Run output values.
56 uint8_t run[2];
57 // Level output values.
58 int16_t level[2];
59 // Bit index of the end of each code.
60 uint8_t offset[4];
62
63typedef struct APVVLCLUT {
64 // Single-symbol LUT for VLCs.
65 // Applies to all coefficients, but used only for DC coefficients
66 // in the decoder.
68 // Multi-symbol LUT for run/level combinations, decoding up to four
69 // symbols per step. Comes in two versions, which to use depends on
70 // whether the next symbol is a run or a level.
73} APVVLCLUT;
74
75typedef struct APVEntropyState {
76 void *log_ctx;
77
79
80 // Previous DC level value.
81 int16_t prev_dc;
82 // k parameter implied by the previous DC level value.
83 uint8_t prev_k_dc;
84 // k parameter implied by the previous first AC level value.
85 uint8_t prev_k_level;
87
88typedef struct APVDerivedTileInfo {
89 uint8_t tile_cols;
90 uint8_t tile_rows;
91 uint16_t num_tiles;
92 // The spec uses an extra element on the end of these arrays
93 // not corresponding to any tile.
97
117
119
120/**
121 * Build the decoder VLC look-up tables.
122 */
124
125/**
126 * Entropy decode a single 8x8 block to coefficients.
127 *
128 * Outputs nonzero coefficients only to the block row-major order
129 * (dezigzag is applied within the function). The output block
130 * must have been filled with zeroes before calling this function.
131 */
132int ff_apv_entropy_decode_block(int16_t *restrict coeff,
133 GetBitContext *restrict gbc,
134 APVEntropyState *restrict state);
135
136#endif /* AVCODEC_APV_DECODE_H */
APVVLCLUT ff_apv_decode_lut
Definition apv_decode.c:48
#define APV_VLC_LUT_SIZE
Definition apv_decode.h:38
int ff_apv_entropy_decode_block(int16_t *restrict coeff, GetBitContext *restrict gbc, APVEntropyState *restrict state)
Entropy decode a single 8x8 block to coefficients.
void ff_apv_entropy_build_decode_lut(APVVLCLUT *decode_lut)
Build the decoder VLC look-up tables.
Definition apv_entropy.c:62
intptr_t atomic_int
Definition stdatomic.h:55
static struct @346255127015250356166251341105367306144006377143 state
reference-counted frame API
bitstream reader API header.
@ APV_MAX_TILE_COLS
Definition apv.h:75
@ APV_MAX_TILE_ROWS
Definition apv.h:76
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
atomic_int tile_errors
Definition apv_decode.h:109
APVRawFrame * cur_raw_frame
Definition apv_decode.h:104
uint8_t warned_unknown_pbu_types
Definition apv_decode.h:115
CodedBitstreamFragment au
Definition apv_decode.h:102
uint8_t warned_additional_frames
Definition apv_decode.h:114
APVDSPContext dsp
Definition apv_decode.h:100
enum AVPixelFormat pix_fmt
Definition apv_decode.h:111
CodedBitstreamContext * cbc
Definition apv_decode.h:99
AVPacket * pkt
Definition apv_decode.h:106
APVDerivedTileInfo tile_info
Definition apv_decode.h:103
void * hwaccel_picture_private
Definition apv_decode.h:108
AVFrame * output_frame
Definition apv_decode.h:107
uint16_t col_starts[APV_MAX_TILE_COLS+1]
Definition apv_decode.h:94
uint16_t row_starts[APV_MAX_TILE_ROWS+1]
Definition apv_decode.h:95
int16_t prev_dc
Definition apv_decode.h:81
const APVVLCLUT * decode_lut
Definition apv_decode.h:78
uint8_t prev_k_level
Definition apv_decode.h:85
uint8_t prev_k_dc
Definition apv_decode.h:83
uint8_t offset[4]
Definition apv_decode.h:60
APVMultiVLCLUTEntry run_first_lut[3][5][APV_VLC_LUT_SIZE]
Definition apv_decode.h:71
APVMultiVLCLUTEntry level_first_lut[3][5][APV_VLC_LUT_SIZE]
Definition apv_decode.h:72
APVSingleVLCLUTEntry single_lut[6][APV_VLC_LUT_SIZE]
Definition apv_decode.h:67
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
This structure stores compressed data.
Definition packet.h:580
Context structure for coded bitstream operations.
Definition cbs.h:226
Coded bitstream fragment structure, combining one or more units.
Definition cbs.h:129
static const double coeff[2][5]