]> git.sesse.net Git - ffmpeg/blob - libavcodec/intrax8.h
intrax8: Check and propagate errors from ff_intrax8_common_init
[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 "intrax8dsp.h"
25
26 typedef struct IntraX8Context {
27     VLC *j_ac_vlc[4]; // they point to the static j_mb_vlc
28     VLC *j_orient_vlc;
29     VLC *j_dc_vlc[3];
30
31     int use_quant_matrix;
32
33     // set by ff_intrax8_common_init
34     uint8_t *prediction_table; // 2 * (mb_w * 2)
35     ScanTable scantable[3];
36
37     // set by the caller codec
38     MpegEncContext *s;
39     IntraX8DSPContext dsp;
40     int quant;
41     int dquant;
42     int qsum;
43
44     // calculated per frame
45     int quant_dc_chroma;
46     int divide_quant_dc_luma;
47     int divide_quant_dc_chroma;
48
49     // changed per block
50     int edges;
51     int flat_dc;
52     int predicted_dc;
53     int raw_orient;
54     int chroma_orient;
55     int orient;
56     int est_run;
57 } IntraX8Context;
58
59 /**
60  * Initialize IntraX8 frame decoder.
61  * Requires valid MpegEncContext with valid s->mb_width before calling.
62  * @param w pointer to IntraX8Context
63  * @param s pointer to MpegEncContext of the parent codec
64  * @return 0 on success, a negative AVERROR value on error
65  */
66 int ff_intrax8_common_init(IntraX8Context *w, MpegEncContext *const s);
67
68 /**
69  * Destroy IntraX8 frame structure.
70  * @param w pointer to IntraX8Context
71  */
72 void ff_intrax8_common_end(IntraX8Context *w);
73
74 /**
75  * Decode single IntraX8 frame.
76  * The parent codec must fill s->loopfilter and s->gb (bitstream).
77  * The parent codec must call ff_mpv_frame_start() before calling this function.
78  * The parent codec must call ff_mpv_frame_end() after calling this function.
79  * This function does not use ff_mpv_decode_mb().
80  * @param w pointer to IntraX8Context
81  * @param dquant doubled quantizer, it would be odd in case of VC-1 halfpq==1.
82  * @param quant_offset offset away from zero
83  */
84 int ff_intrax8_decode_picture(IntraX8Context *w, int quant, int halfpq);
85
86 #endif /* AVCODEC_INTRAX8_H */