Revision 8e624c1c libavcodec/vp8.c

View differences:

libavcodec/vp8.c
24 24

  
25 25
#include "libavutil/imgutils.h"
26 26
#include "avcodec.h"
27
#include "vp56.h"
27
#include "vp8.h"
28 28
#include "vp8data.h"
29
#include "vp8dsp.h"
30
#include "h264pred.h"
31 29
#include "rectangle.h"
32 30

  
33 31
#if ARCH_ARM
34 32
#   include "arm/vp8.h"
35 33
#endif
36 34

  
37
typedef struct {
38
    uint8_t filter_level;
39
    uint8_t inner_limit;
40
    uint8_t inner_filter;
41
} VP8FilterStrength;
42

  
43
typedef struct {
44
    uint8_t skip;
45
    // todo: make it possible to check for at least (i4x4 or split_mv)
46
    // in one op. are others needed?
47
    uint8_t mode;
48
    uint8_t ref_frame;
49
    uint8_t partitioning;
50
    VP56mv mv;
51
    VP56mv bmv[16];
52
} VP8Macroblock;
53

  
54
typedef struct {
55
    AVCodecContext *avctx;
56
    DSPContext dsp;
57
    VP8DSPContext vp8dsp;
58
    H264PredContext hpc;
59
    vp8_mc_func put_pixels_tab[3][3][3];
60
    AVFrame frames[4];
61
    AVFrame *framep[4];
62
    uint8_t *edge_emu_buffer;
63
    VP56RangeCoder c;   ///< header context, includes mb modes and motion vectors
64
    int profile;
65

  
66
    int mb_width;   /* number of horizontal MB */
67
    int mb_height;  /* number of vertical MB */
68
    int linesize;
69
    int uvlinesize;
70

  
71
    int keyframe;
72
    int invisible;
73
    int update_last;    ///< update VP56_FRAME_PREVIOUS with the current one
74
    int update_golden;  ///< VP56_FRAME_NONE if not updated, or which frame to copy if so
75
    int update_altref;
76
    int deblock_filter;
77

  
78
    /**
79
     * If this flag is not set, all the probability updates
80
     * are discarded after this frame is decoded.
81
     */
82
    int update_probabilities;
83

  
84
    /**
85
     * All coefficients are contained in separate arith coding contexts.
86
     * There can be 1, 2, 4, or 8 of these after the header context.
87
     */
88
    int num_coeff_partitions;
89
    VP56RangeCoder coeff_partition[8];
90

  
91
    VP8Macroblock *macroblocks;
92
    VP8Macroblock *macroblocks_base;
93
    VP8FilterStrength *filter_strength;
94

  
95
    uint8_t *intra4x4_pred_mode_top;
96
    uint8_t intra4x4_pred_mode_left[4];
97
    uint8_t *segmentation_map;
98

  
99
    /**
100
     * Cache of the top row needed for intra prediction
101
     * 16 for luma, 8 for each chroma plane
102
     */
103
    uint8_t (*top_border)[16+8+8];
104

  
105
    /**
106
     * For coeff decode, we need to know whether the above block had non-zero
107
     * coefficients. This means for each macroblock, we need data for 4 luma
108
     * blocks, 2 u blocks, 2 v blocks, and the luma dc block, for a total of 9
109
     * per macroblock. We keep the last row in top_nnz.
110
     */
111
    uint8_t (*top_nnz)[9];
112
    DECLARE_ALIGNED(8, uint8_t, left_nnz)[9];
113

  
114
    /**
115
     * This is the index plus one of the last non-zero coeff
116
     * for each of the blocks in the current macroblock.
117
     * So, 0 -> no coeffs
118
     *     1 -> dc-only (special transform)
119
     *     2+-> full transform
120
     */
121
    DECLARE_ALIGNED(16, uint8_t, non_zero_count_cache)[6][4];
122
    DECLARE_ALIGNED(16, DCTELEM, block)[6][4][16];
123
    DECLARE_ALIGNED(16, DCTELEM, block_dc)[16];
124
    uint8_t intra4x4_pred_mode_mb[16];
125

  
126
    int chroma_pred_mode;    ///< 8x8c pred mode of the current macroblock
127
    int segment;             ///< segment of the current macroblock
128
    VP56mv mv_min;
129
    VP56mv mv_max;
130

  
131
    int mbskip_enabled;
132
    int sign_bias[4]; ///< one state [0, 1] per ref frame type
133
    int ref_count[3];
134

  
135
    /**
136
     * Base parameters for segmentation, i.e. per-macroblock parameters.
137
     * These must be kept unchanged even if segmentation is not used for
138
     * a frame, since the values persist between interframes.
139
     */
140
    struct {
141
        int enabled;
142
        int absolute_vals;
143
        int update_map;
144
        int8_t base_quant[4];
145
        int8_t filter_level[4];     ///< base loop filter level
146
    } segmentation;
147

  
148
    /**
149
     * Macroblocks can have one of 4 different quants in a frame when
150
     * segmentation is enabled.
151
     * If segmentation is disabled, only the first segment's values are used.
152
     */
153
    struct {
154
        // [0] - DC qmul  [1] - AC qmul
155
        int16_t luma_qmul[2];
156
        int16_t luma_dc_qmul[2];    ///< luma dc-only block quant
157
        int16_t chroma_qmul[2];
158
    } qmat[4];
159

  
160
    struct {
161
        int simple;
162
        int level;
163
        int sharpness;
164
    } filter;
165

  
166
    struct {
167
        int enabled;    ///< whether each mb can have a different strength based on mode/ref
168

  
169
        /**
170
         * filter strength adjustment for the following macroblock modes:
171
         * [0-3] - i16x16 (always zero)
172
         * [4]   - i4x4
173
         * [5]   - zero mv
174
         * [6]   - inter modes except for zero or split mv
175
         * [7]   - split mv
176
         *  i16x16 modes never have any adjustment
177
         */
178
        int8_t mode[VP8_MVMODE_SPLIT+1];
179

  
180
        /**
181
         * filter strength adjustment for macroblocks that reference:
182
         * [0] - intra / VP56_FRAME_CURRENT
183
         * [1] - VP56_FRAME_PREVIOUS
184
         * [2] - VP56_FRAME_GOLDEN
185
         * [3] - altref / VP56_FRAME_GOLDEN2
186
         */
187
        int8_t ref[4];
188
    } lf_delta;
189

  
190
    /**
191
     * These are all of the updatable probabilities for binary decisions.
192
     * They are only implictly reset on keyframes, making it quite likely
193
     * for an interframe to desync if a prior frame's header was corrupt
194
     * or missing outright!
195
     */
196
    struct {
197
        uint8_t segmentid[3];
198
        uint8_t mbskip;
199
        uint8_t intra;
200
        uint8_t last;
201
        uint8_t golden;
202
        uint8_t pred16x16[4];
203
        uint8_t pred8x8c[3];
204
        /* Padded to allow overreads */
205
        uint8_t token[4][17][3][NUM_DCT_TOKENS-1];
206
        uint8_t mvc[2][19];
207
    } prob[2];
208
} VP8Context;
209

  
210 35
static void vp8_decode_flush(AVCodecContext *avctx)
211 36
{
212 37
    VP8Context *s = avctx->priv_data;

Also available in: Unified diff