]> git.sesse.net Git - ffmpeg/blob - libavcodec/intrax8.h
intrax8: Keep a reference to the GetBitContext reader
[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 "get_bits.h"
23 #include "mpegvideo.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
39     // set by the caller codec
40     MpegEncContext *s;
41     IntraX8DSPContext dsp;
42     IDCTDSPContext idsp;
43     int quant;
44     int dquant;
45     int qsum;
46     int loopfilter;
47     AVFrame *frame;
48     GetBitContext *gb;
49
50     // calculated per frame
51     int quant_dc_chroma;
52     int divide_quant_dc_luma;
53     int divide_quant_dc_chroma;
54     uint8_t *dest[3];
55     uint8_t scratchpad[42]; // size of the block is fixed (8x8 plus padding)
56
57     // changed per block
58     int edges;
59     int flat_dc;
60     int predicted_dc;
61     int raw_orient;
62     int chroma_orient;
63     int orient;
64     int est_run;
65 } IntraX8Context;
66
67 /**
68  * Initialize IntraX8 frame decoder.
69  * Requires valid MpegEncContext with valid s->mb_width before calling.
70  * @param w pointer to IntraX8Context
71  * @param idsp pointer to IDCTDSPContext
72  * @param s pointer to MpegEncContext of the parent codec
73  * @return 0 on success, a negative AVERROR value on error
74  */
75 int ff_intrax8_common_init(IntraX8Context *w, IDCTDSPContext *idsp,
76                            MpegEncContext *const s);
77
78 /**
79  * Destroy IntraX8 frame structure.
80  * @param w pointer to IntraX8Context
81  */
82 void ff_intrax8_common_end(IntraX8Context *w);
83
84 /**
85  * Decode single IntraX8 frame.
86  * The parent codec must call ff_mpv_frame_start() before calling this function.
87  * The parent codec must call ff_mpv_frame_end() after calling this function.
88  * This function does not use ff_mpv_decode_mb().
89  * @param w pointer to IntraX8Context
90  * @param pict the output Picture containing an AVFrame
91  * @param gb open bitstream reader
92  * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
93  * @param quant_offset offset away from zero
94  * @param loopfilter enable filter after decoding a block
95  */
96 int ff_intrax8_decode_picture(IntraX8Context *w, Picture *pict,
97                               GetBitContext *gb,
98                               int quant, int halfpq, int loopfilter);
99
100 #endif /* AVCODEC_INTRAX8_H */