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