]> git.sesse.net Git - ffmpeg/blob - libavcodec/intrax8.h
libopusdec: fix out-of-bounds read
[ffmpeg] / libavcodec / intrax8.h
1 /*
2  * This file is part of Libav.
3  *
4  * Libav 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  * Libav 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 Libav; 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_INTRAX8_H
20 #define AVCODEC_INTRAX8_H
21
22 #include "blockdsp.h"
23 #include "get_bits.h"
24 #include "idctdsp.h"
25 #include "intrax8dsp.h"
26 #include "mpegpicture.h"
27
28 typedef struct IntraX8Context {
29     VLC *j_ac_vlc[4]; // they point to the static j_mb_vlc
30     VLC *j_orient_vlc;
31     VLC *j_dc_vlc[3];
32
33     int use_quant_matrix;
34
35     // set by ff_intrax8_common_init
36     uint8_t *prediction_table; // 2 * (mb_w * 2)
37     ScanTable scantable[3];
38     AVCodecContext *avctx;
39     int *block_last_index;  ///< last nonzero coefficient in block
40     int16_t (*block)[64];
41
42     // set by the caller codec
43     IntraX8DSPContext dsp;
44     IDCTDSPContext idsp;
45     BlockDSPContext bdsp;
46     int quant;
47     int dquant;
48     int qsum;
49     int loopfilter;
50     AVFrame *frame;
51     GetBitContext *gb;
52
53     // calculated per frame
54     int quant_dc_chroma;
55     int divide_quant_dc_luma;
56     int divide_quant_dc_chroma;
57     uint8_t *dest[3];
58     uint8_t scratchpad[42]; // size of the block is fixed (8x8 plus padding)
59
60     // changed per block
61     int edges;
62     int flat_dc;
63     int predicted_dc;
64     int raw_orient;
65     int chroma_orient;
66     int orient;
67     int est_run;
68
69     // block props
70     int mb_x, mb_y;
71     int mb_width, mb_height;
72 } IntraX8Context;
73
74 /**
75  * Initialize IntraX8 frame decoder.
76  * @param avctx pointer to AVCodecContext
77  * @param w pointer to IntraX8Context
78  * @param idsp pointer to IDCTDSPContext
79  * @param block pointer to block array
80  * @param block_last_index pointer to index array
81  * @param mb_width macroblock width
82  * @param mb_height macroblock height
83  * @return 0 on success, a negative AVERROR value on error
84  */
85 int ff_intrax8_common_init(AVCodecContext *avctx,
86                            IntraX8Context *w, IDCTDSPContext *idsp,
87                            int16_t (*block)[64],
88                            int block_last_index[12],
89                            int mb_width, int mb_height);
90
91 /**
92  * Destroy IntraX8 frame structure.
93  * @param w pointer to IntraX8Context
94  */
95 void ff_intrax8_common_end(IntraX8Context *w);
96
97 /**
98  * Decode single IntraX8 frame.
99  * @param w pointer to IntraX8Context
100  * @param pict the output Picture containing an AVFrame
101  * @param gb open bitstream reader
102  * @param mb_x pointer to the x coordinate of the current macroblock
103  * @param mb_y pointer to the y coordinate of the current macroblock
104  * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
105  * @param quant_offset offset away from zero
106  * @param loopfilter enable filter after decoding a block
107  */
108 int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict,
109                               GetBitContext *gb, int *mb_x, int *mb_y,
110                               int quant, int halfpq,
111                               int loopfilter, int lowdelay);
112
113 #endif /* AVCODEC_INTRAX8_H */