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