Statistics
| Branch: | Revision:

ffmpeg / libavcodec / mpegvideo.h @ bec89a84

History | View | Annotate | Download (32.6 KB)

1 de6d9b64 Fabrice Bellard
/*
2
 * Generic DCT based hybrid video encoder
3 ff4ec49e Fabrice Bellard
 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
4 de6d9b64 Fabrice Bellard
 *
5 ff4ec49e Fabrice Bellard
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9 de6d9b64 Fabrice Bellard
 *
10 ff4ec49e Fabrice Bellard
 * This library is distributed in the hope that it will be useful,
11 de6d9b64 Fabrice Bellard
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ff4ec49e Fabrice Bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14 de6d9b64 Fabrice Bellard
 *
15 ff4ec49e Fabrice Bellard
 * You should have received a copy of the GNU Lesser General Public
16
 * License along with this library; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 de6d9b64 Fabrice Bellard
 */
19
20 983e3246 Michael Niedermayer
/**
21
 * @file mpegvideo.h
22
 * mpegvideo header.
23
 */
24
 
25 cd4af68a Zdenek Kabelac
#ifndef AVCODEC_MPEGVIDEO_H
26
#define AVCODEC_MPEGVIDEO_H
27
28 5c91a675 Zdenek Kabelac
#include "dsputil.h"
29
30 277f4827 Michael Niedermayer
#define FRAME_SKIPED 100 ///< return value for header parsers if frame is not coded
31 eec1c6b9 Michael Niedermayer
32 de6d9b64 Fabrice Bellard
enum OutputFormat {
33
    FMT_MPEG1,
34
    FMT_H263,
35 9dbcbd92 Michael Niedermayer
    FMT_MJPEG, 
36 de6d9b64 Fabrice Bellard
};
37
38 1e491e29 Michael Niedermayer
#define EDGE_WIDTH 16
39
40 de6d9b64 Fabrice Bellard
#define MPEG_BUF_SIZE (16 * 1024)
41
42 ad324c93 Michael Niedermayer
#define QMAT_SHIFT_MMX 16
43
#define QMAT_SHIFT 22
44 2f349de2 Michael Niedermayer
45 45870f57 Michael Niedermayer
#define MAX_FCODE 7
46
#define MAX_MV 2048
47 1e491e29 Michael Niedermayer
48 0d1e9246 Michael Niedermayer
#define MAX_PICTURE_COUNT 15
49 45870f57 Michael Niedermayer
50 7f2fe444 Michael Niedermayer
#define ME_MAP_SIZE 64
51
#define ME_MAP_SHIFT 3
52
#define ME_MAP_MV_BITS 11
53
54 0151a6f5 Michael Niedermayer
/* run length table */
55
#define MAX_RUN    64
56
#define MAX_LEVEL  64
57
58 277f4827 Michael Niedermayer
#define I_TYPE FF_I_TYPE  ///< Intra
59
#define P_TYPE FF_P_TYPE  ///< Predicted
60
#define B_TYPE FF_B_TYPE  ///< Bi-dir predicted
61
#define S_TYPE FF_S_TYPE  ///< S(GMC)-VOP MPEG4
62 140cb663 Michael Niedermayer
63 9cdd6a24 Michael Niedermayer
typedef struct Predictor{
64
    double coeff;
65
    double count;
66
    double decay;
67
} Predictor;
68
69 8b4c7dbc Michael Niedermayer
typedef struct RateControlEntry{
70
    int pict_type;
71 c5d309f2 Michael Niedermayer
    float qscale;
72 8b4c7dbc Michael Niedermayer
    int mv_bits;
73
    int i_tex_bits;
74
    int p_tex_bits;
75
    int misc_bits;
76 0c1a9eda Zdenek Kabelac
    uint64_t expected_bits;
77 8b4c7dbc Michael Niedermayer
    int new_pict_type;
78
    float new_qscale;
79 3aa102be Michael Niedermayer
    int mc_mb_var_sum;
80
    int mb_var_sum;
81
    int i_count;
82
    int f_code;
83
    int b_code;
84 8b4c7dbc Michael Niedermayer
}RateControlEntry;
85
86 277f4827 Michael Niedermayer
/**
87
 * rate control context.
88
 */
89 8b4c7dbc Michael Niedermayer
typedef struct RateControlContext{
90
    FILE *stats_file;
91 277f4827 Michael Niedermayer
    int num_entries;              ///< number of RateControlEntries 
92 8b4c7dbc Michael Niedermayer
    RateControlEntry *entry;
93 277f4827 Michael Niedermayer
    int buffer_index;             ///< amount of bits in the video/audio buffer 
94 3aa102be Michael Niedermayer
    Predictor pred[5];
95 277f4827 Michael Niedermayer
    double short_term_qsum;       ///< sum of recent qscales 
96
    double short_term_qcount;     ///< count of recent qscales 
97
    double pass1_rc_eq_output_sum;///< sum of the output of the rc equation, this is used for normalization  
98
    double pass1_wanted_bits;     ///< bits which should have been outputed by the pass1 code (including complexity init) 
99 3aa102be Michael Niedermayer
    double last_qscale;
100 277f4827 Michael Niedermayer
    double last_qscale_for[5];    ///< last qscale for a specific pict type, used for max_diff & ipb factor stuff 
101 3aa102be Michael Niedermayer
    int last_mc_mb_var_sum;
102
    int last_mb_var_sum;
103 0c1a9eda Zdenek Kabelac
    uint64_t i_cplx_sum[5];
104
    uint64_t p_cplx_sum[5];
105
    uint64_t mv_bits_sum[5];
106
    uint64_t qscale_sum[5];
107 3aa102be Michael Niedermayer
    int frame_count[5];
108 947ac25a Michael Niedermayer
    int last_non_b_pict_type;
109 8b4c7dbc Michael Niedermayer
}RateControlContext;
110
111 277f4827 Michael Niedermayer
/**
112
 * Scantable.
113
 */
114 2ad1516a Michael Niedermayer
typedef struct ScanTable{
115 0c1a9eda Zdenek Kabelac
    const uint8_t *scantable;
116
    uint8_t permutated[64];
117
    uint8_t raster_end[64];
118 05c4072b Michael Niedermayer
#ifdef ARCH_POWERPC
119 277f4827 Michael Niedermayer
                /** Used by dct_quantise_alitvec to find last-non-zero */
120 0c1a9eda Zdenek Kabelac
    uint8_t __align8 inverse[64];
121 05c4072b Michael Niedermayer
#endif
122 2ad1516a Michael Niedermayer
} ScanTable;
123
124 277f4827 Michael Niedermayer
/**
125
 * Picture.
126
 */
127 1e491e29 Michael Niedermayer
typedef struct Picture{
128 492cd3a9 Michael Niedermayer
    FF_COMMON_FRAME
129 1e491e29 Michael Niedermayer
130 277f4827 Michael Niedermayer
    int mb_var_sum;             ///< sum of MB variance for current frame 
131
    int mc_mb_var_sum;          ///< motion compensated MB variance for current frame 
132
    uint16_t *mb_var;           ///< Table for MB variances 
133
    uint16_t *mc_mb_var;        ///< Table for motion compensated MB variances 
134
    uint8_t *mb_mean;           ///< Table for MB luminance 
135
    int32_t *mb_cmp_score;        ///< Table for MB cmp scores, for mb decission 
136 0d1e9246 Michael Niedermayer
    int b_frame_score;          /* */
137 1e491e29 Michael Niedermayer
} Picture;
138
139 d7425f59 Michael Niedermayer
typedef struct ParseContext{
140 0c1a9eda Zdenek Kabelac
    uint8_t *buffer;
141 d7425f59 Michael Niedermayer
    int index;
142
    int last_index;
143
    int buffer_size;
144
    int state;
145
    int frame_start_found;
146
} ParseContext;
147
148 1457ab52 Michael Niedermayer
struct MpegEncContext;
149
150 277f4827 Michael Niedermayer
/**
151
 * Motion estimation context.
152
 */
153 1457ab52 Michael Niedermayer
typedef struct MotionEstContext{
154 277f4827 Michael Niedermayer
    int skip;                          ///< set if ME is skiped for the current MB 
155
    int co_located_mv[4][2];           ///< mv from last p frame for direct mode ME 
156 1457ab52 Michael Niedermayer
    int direct_basis_mv[4][2];
157 277f4827 Michael Niedermayer
    uint8_t *scratchpad;               ///< data area for the me algo, so that the ME doesnt need to malloc/free 
158
    uint32_t *map;                     ///< map to avoid duplicate evaluations 
159
    uint32_t *score_map;               ///< map to store the scores 
160 1457ab52 Michael Niedermayer
    int map_generation;  
161 826f429a Michael Niedermayer
    int pre_penalty_factor;
162 1457ab52 Michael Niedermayer
    int penalty_factor;
163
    int sub_penalty_factor;
164 67725183 Michael Niedermayer
    int mb_penalty_factor;
165 277f4827 Michael Niedermayer
    int pre_pass;                      ///< = 1 for the pre pass 
166 826f429a Michael Niedermayer
    int dia_size;
167 277f4827 Michael Niedermayer
    uint16_t (*mv_penalty)[MAX_MV*2+1];  ///< amount of bits needed to encode a MV 
168 1457ab52 Michael Niedermayer
    int (*sub_motion_search)(struct MpegEncContext * s,
169
                                  int *mx_ptr, int *my_ptr, int dmin,
170
                                  int xmin, int ymin, int xmax, int ymax,
171
                                  int pred_x, int pred_y, Picture *ref_picture, 
172
                                  int n, int size, uint16_t * const mv_penalty);
173
    int (*motion_search[7])(struct MpegEncContext * s, int block,
174
                             int *mx_ptr, int *my_ptr,
175
                             int P[10][2], int pred_x, int pred_y,
176 826f429a Michael Niedermayer
                             int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2], 
177
                             int ref_mv_scale, uint16_t * const mv_penalty);
178
    int (*pre_motion_search)(struct MpegEncContext * s, int block,
179
                             int *mx_ptr, int *my_ptr,
180
                             int P[10][2], int pred_x, int pred_y,
181 b07a5980 Michael Niedermayer
                             int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2], 
182
                             int ref_mv_scale, uint16_t * const mv_penalty);
183 67725183 Michael Niedermayer
    int (*get_mb_score)(struct MpegEncContext * s, int mx, int my, int pred_x, int pred_y, Picture *ref_picture, 
184
                                  uint16_t * const mv_penalty);
185 1457ab52 Michael Niedermayer
}MotionEstContext;
186
187 277f4827 Michael Niedermayer
/**
188
 * MpegEncContext.
189
 */
190 de6d9b64 Fabrice Bellard
typedef struct MpegEncContext {
191 58f26ba9 Fabrice Bellard
    struct AVCodecContext *avctx;
192 de6d9b64 Fabrice Bellard
    /* the following parameters must be initialized before encoding */
193 277f4827 Michael Niedermayer
    int width, height;///< picture size. must be a multiple of 16 
194 de6d9b64 Fabrice Bellard
    int gop_size;
195 277f4827 Michael Niedermayer
    int frame_rate;   ///< number of frames per second 
196
    int intra_only;   ///< if true, only intra pictures are generated 
197
    int bit_rate;     ///< wanted bit rate 
198
    int bit_rate_tolerance; ///< amount of +- bits (>0)
199
    enum OutputFormat out_format; ///< output format 
200
    int h263_pred;    ///< use mpeg4/h263 ac/dc predictions 
201 d7e9533a Michael Niedermayer
202
/* the following codec id fields are deprecated in favor of codec_id */
203 277f4827 Michael Niedermayer
    int h263_plus;    ///< h263 plus headers 
204
    int h263_rv10;    ///< use RV10 variation for H263 
205
    int h263_msmpeg4; ///< generate MSMPEG4 compatible stream (deprecated, use msmpeg4_version instead)
206
    int h263_intel;   ///< use I263 intel h263 header 
207 d7e9533a Michael Niedermayer
    
208
    int codec_id;     /* see CODEC_ID_xxx */
209 277f4827 Michael Niedermayer
    int fixed_qscale; ///< fixed qscale if non zero 
210
    float qcompress;  ///< amount of qscale change between easy & hard scenes (0.0-1.0) 
211
    float qblur;      ///< amount of qscale smoothing over time (0.0-1.0) 
212
    int qmin;         ///< min qscale 
213
    int qmax;         ///< max qscale 
214
    int max_qdiff;    ///< max qscale difference between frames 
215
    int encoding;     ///< true if we are encoding (vs decoding) 
216
    int flags;        ///< AVCodecContext.flags (HQ, MV4, ...) 
217
    int max_b_frames; ///< max number of b-frames for encoding 
218 8b4c7dbc Michael Niedermayer
    int b_frame_strategy;
219 7f2fe444 Michael Niedermayer
    int luma_elim_threshold;
220
    int chroma_elim_threshold;
221 277f4827 Michael Niedermayer
    int strict_std_compliance; ///< strictly follow the std (MPEG4, ...) 
222
    int workaround_bugs;       ///< workaround bugs in encoders which cannot be detected automatically 
223 de6d9b64 Fabrice Bellard
    /* the following fields are managed internally by the encoder */
224
225 277f4827 Michael Niedermayer
    /** bit output */
226 de6d9b64 Fabrice Bellard
    PutBitContext pb;
227
228
    /* sequence parameters */
229
    int context_initialized;
230 9dbcbd92 Michael Niedermayer
    int input_picture_number;
231 de6d9b64 Fabrice Bellard
    int picture_number;
232 277f4827 Michael Niedermayer
    int picture_in_gop_number; ///< 0-> first pic in gop, ... 
233
    int b_frames_since_non_b;  ///< used for encoding, relative to not yet reordered input 
234
    int mb_width, mb_height;   ///< number of MBs horizontally & vertically 
235
    int h_edge_pos, v_edge_pos;///< horizontal / vertical position of the right/bottom edge (pixel replicateion)
236
    int mb_num;                ///< number of MBs of a picture 
237
    int linesize;              ///< line size, in bytes, may be different from width 
238
    int uvlinesize;            ///< line size, for chroma in bytes, may be different from width 
239
    Picture picture[MAX_PICTURE_COUNT]; ///< main picture buffer 
240
    Picture *input_picture[MAX_PICTURE_COUNT]; ///< next pictures on display order for encoding
241
    Picture *reordered_input_picture[MAX_PICTURE_COUNT]; ///< pointer to the next pictures in codedorder for encoding
242
    Picture last_picture;       ///< previous picture 
243
    Picture next_picture;       ///< previous picture (for bidir pred) 
244
    Picture new_picture;        ///< source picture for encoding 
245
    Picture current_picture;    ///< buffer to store the decompressed current picture 
246
    int last_dc[3];                ///< last DC values for MPEG1 
247
    int16_t *dc_val[3];            ///< used for mpeg4 DC prediction, all 3 arrays must be continuous 
248 de6d9b64 Fabrice Bellard
    int y_dc_scale, c_dc_scale;
249 277f4827 Michael Niedermayer
    uint8_t *y_dc_scale_table;     ///< qscale -> y_dc_scale table 
250
    uint8_t *c_dc_scale_table;     ///< qscale -> c_dc_scale table 
251
    uint8_t *coded_block;          ///< used for coded block pattern prediction (msmpeg4v3, wmv1)
252
    int16_t (*ac_val[3])[16];      ///< used for for mpeg4 AC prediction, all 3 arrays must be continuous 
253 de6d9b64 Fabrice Bellard
    int ac_pred;
254 277f4827 Michael Niedermayer
    uint8_t *prev_pict_types;     ///< previous picture types in bitstream order, used for mb skip 
255 f943e138 Michael Niedermayer
#define PREV_PICT_TYPES_BUFFER_SIZE 256
256 277f4827 Michael Niedermayer
    int mb_skiped;                ///< MUST BE SET only during DECODING 
257
    uint8_t *mbskip_table;        /**< used to avoid copy if macroblock skipped (for black regions for example) 
258 9dbcbd92 Michael Niedermayer
                                   and used for b-frame encoding & decoding (contains skip table of next P Frame) */
259 277f4827 Michael Niedermayer
    uint8_t *mbintra_table;       ///< used to avoid setting {ac, dc, cbp}-pred stuff to zero on inter MB decoding 
260
    uint8_t *cbp_table;           ///< used to store cbp, ac_pred for partitioned decoding 
261
    uint8_t *pred_dir_table;      ///< used to store pred_dir for partitioned decoding 
262 f7b47594 Michael Niedermayer
    uint8_t *allocated_edge_emu_buffer;
263 277f4827 Michael Niedermayer
    uint8_t *edge_emu_buffer;     ///< points into the middle of allocated_edge_emu_buffer  
264 de6d9b64 Fabrice Bellard
265 277f4827 Michael Niedermayer
    int qscale;                 ///< QP 
266
    float frame_qscale;         ///< qscale from the frame level rc FIXME remove
267
    int adaptive_quant;         ///< use adaptive quantization 
268
    int dquant;                 ///< qscale difference to prev qscale  
269
    int pict_type;              ///< I_TYPE, P_TYPE, B_TYPE, ... 
270 3aa102be Michael Niedermayer
    int last_pict_type;
271 277f4827 Michael Niedermayer
    int last_non_b_pict_type;   ///< used for mpeg4 gmc b-frames & ratecontrol 
272 de6d9b64 Fabrice Bellard
    int frame_rate_index;
273
    /* motion compensation */
274 277f4827 Michael Niedermayer
    int unrestricted_mv;        ///< mv can point outside of the coded picture 
275
    int h263_long_vectors;      ///< use horrible h263v1 long vector mode 
276
277
    DSPContext dsp;             ///< pointers for accelerated dsp fucntions 
278
    int f_code;                 ///< forward MV resolution 
279
    int b_code;                 ///< backward MV resolution for B Frames (mpeg4) 
280
    int16_t (*motion_val)[2];            ///< used for MV prediction (4MV per MB) 
281
    int16_t (*p_mv_table)[2];            ///< MV table (1MV per MB) p-frame encoding 
282
    int16_t (*b_forw_mv_table)[2];       ///< MV table (1MV per MB) forward mode b-frame encoding 
283
    int16_t (*b_back_mv_table)[2];       ///< MV table (1MV per MB) backward mode b-frame encoding 
284
    int16_t (*b_bidir_forw_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding 
285
    int16_t (*b_bidir_back_mv_table)[2]; ///< MV table (1MV per MB) bidir mode b-frame encoding 
286
    int16_t (*b_direct_mv_table)[2];     ///< MV table (1MV per MB) direct mode b-frame encoding 
287
    int me_method;                       ///< ME algorithm 
288 1fb4890b Michael Niedermayer
    int scene_change_score;
289 de6d9b64 Fabrice Bellard
    int mv_dir;
290
#define MV_DIR_BACKWARD  1
291
#define MV_DIR_FORWARD   2
292 277f4827 Michael Niedermayer
#define MV_DIRECT        4 ///< bidirectional mode where the difference equals the MV of the last P/S/I-Frame (mpeg4)
293 de6d9b64 Fabrice Bellard
    int mv_type;
294 277f4827 Michael Niedermayer
#define MV_TYPE_16X16       0   ///< 1 vector for the whole mb 
295
#define MV_TYPE_8X8         1   ///< 4 vectors (h263, mpeg4 4MV) 
296
#define MV_TYPE_16X8        2   ///< 2 vectors, one per 16x8 block  
297
#define MV_TYPE_FIELD       3   ///< 2 vectors, one per field  
298
#define MV_TYPE_DMV         4   ///< 2 vectors, special mpeg2 Dual Prime Vectors 
299
    /**motion vectors for a macroblock 
300 de6d9b64 Fabrice Bellard
       first coordinate : 0 = forward 1 = backward
301
       second "         : depend on type
302
       third  "         : 0 = x, 1 = y
303
    */
304
    int mv[2][4][2];
305
    int field_select[2][2];
306 277f4827 Michael Niedermayer
    int last_mv[2][2][2];             ///< last MV, used for MV prediction in MPEG1 & B-frame MPEG4 
307
    uint8_t *fcode_tab;               ///< smallest fcode needed for each MV 
308 1457ab52 Michael Niedermayer
    
309
    MotionEstContext me;
310 de6d9b64 Fabrice Bellard
311 277f4827 Michael Niedermayer
    int no_rounding;  /**< apply no rounding to motion compensation (MPEG4, msmpeg4, ...) 
312 91029be7 Michael Niedermayer
                        for b-frames rounding mode is allways 0 */
313 de6d9b64 Fabrice Bellard
314 277f4827 Michael Niedermayer
    int hurry_up;     /**< when set to 1 during decoding, b frames will be skiped
315 2417652e Michael Niedermayer
                         when set to 2 idct/dequant will be skipped too */
316 c5d309f2 Michael Niedermayer
                        
317 de6d9b64 Fabrice Bellard
    /* macroblock layer */
318
    int mb_x, mb_y;
319
    int mb_incr;
320
    int mb_intra;
321 277f4827 Michael Niedermayer
    uint8_t *mb_type;       ///< Table for MB type 
322 ba6802de Michael Niedermayer
#define MB_TYPE_INTRA    0x01
323
#define MB_TYPE_INTER    0x02
324
#define MB_TYPE_INTER4V  0x04
325
#define MB_TYPE_SKIPED   0x08
326 7f2fe444 Michael Niedermayer
#define MB_TYPE_GMC      0x10
327
328 ba6802de Michael Niedermayer
#define MB_TYPE_DIRECT   0x10
329
#define MB_TYPE_FORWARD  0x20
330 9dbcbd92 Michael Niedermayer
#define MB_TYPE_BACKWARD 0x40
331 ba6802de Michael Niedermayer
#define MB_TYPE_BIDIR    0x80
332 4278e7a6 Michael Niedermayer
333 277f4827 Michael Niedermayer
    int block_index[6]; ///< index to current MB in block based arrays with edges
334 4278e7a6 Michael Niedermayer
    int block_wrap[6];
335
336 277f4827 Michael Niedermayer
    /** matrix transmitted in the bitstream */
337 0c1a9eda Zdenek Kabelac
    uint16_t intra_matrix[64];
338
    uint16_t chroma_intra_matrix[64];
339
    uint16_t inter_matrix[64];
340
    uint16_t chroma_inter_matrix[64];
341 d7e9533a Michael Niedermayer
#define QUANT_BIAS_SHIFT 4
342 277f4827 Michael Niedermayer
    int intra_quant_bias;    ///< bias for the quantizer 
343
    int inter_quant_bias;    ///< bias for the quantizer 
344
    int min_qcoeff;          ///< minimum encodable coefficient 
345
    int max_qcoeff;          ///< maximum encodable coefficient 
346
    int ac_esc_length;       ///< num of bits needed to encode the longest esc 
347 477ab036 Michael Niedermayer
    uint8_t *intra_ac_vlc_length;
348
    uint8_t *intra_ac_vlc_last_length;
349
    uint8_t *inter_ac_vlc_length;
350
    uint8_t *inter_ac_vlc_last_length;
351 67725183 Michael Niedermayer
    uint8_t *luma_dc_vlc_length;
352
    uint8_t *chroma_dc_vlc_length;
353 c442d75c Michael Niedermayer
#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
354 477ab036 Michael Niedermayer
355 277f4827 Michael Niedermayer
    /** precomputed matrix (combine qscale and DCT renorm) */
356 05c4072b Michael Niedermayer
    int __align8 q_intra_matrix[32][64];
357
    int __align8 q_inter_matrix[32][64];
358 277f4827 Michael Niedermayer
    /** identical to the above but for MMX & these are not permutated */
359 0c1a9eda Zdenek Kabelac
    uint16_t __align8 q_intra_matrix16[32][64];
360
    uint16_t __align8 q_inter_matrix16[32][64];
361
    uint16_t __align8 q_intra_matrix16_bias[32][64];
362
    uint16_t __align8 q_inter_matrix16_bias[32][64];
363 277f4827 Michael Niedermayer
    int block_last_index[6];  ///< last non zero coefficient in block
364 2ad1516a Michael Niedermayer
    /* scantables */
365 05c4072b Michael Niedermayer
    ScanTable __align8 intra_scantable;
366 2ad1516a Michael Niedermayer
    ScanTable intra_h_scantable;
367
    ScanTable intra_v_scantable;
368 277f4827 Michael Niedermayer
    ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
369 de6d9b64 Fabrice Bellard
370 277f4827 Michael Niedermayer
    void *opaque;              ///< private data for the user
371 de6d9b64 Fabrice Bellard
372
    /* bit rate control */
373 9dbcbd92 Michael Niedermayer
    int I_frame_bits; //FIXME used in mpeg12 ...
374 0c1a9eda Zdenek Kabelac
    int64_t wanted_bits;
375
    int64_t total_bits;
376 277f4827 Michael Niedermayer
    int frame_bits;                ///< bits used for the current frame 
377
    RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c
378 9cdd6a24 Michael Niedermayer
379 098eefe1 Michael Niedermayer
    /* statistics, used for 2-pass encoding */
380
    int mv_bits;
381
    int header_bits;
382
    int i_tex_bits;
383
    int p_tex_bits;
384
    int i_count;
385 66370d3f Michael Niedermayer
    int f_count;
386
    int b_count;
387 098eefe1 Michael Niedermayer
    int skip_count;
388 277f4827 Michael Niedermayer
    int misc_bits; ///< cbp, mb_type
389
    int last_bits; ///< temp var used for calculating the above vars
390 7f2fe444 Michael Niedermayer
    
391
    /* error concealment / resync */
392 277f4827 Michael Niedermayer
    uint8_t *error_status_table;       ///< table of the error status of each MB  
393
#define VP_START            1          ///< current MB is the first after a resync marker 
394 4d2858de Michael Niedermayer
#define AC_ERROR            2
395
#define DC_ERROR            4
396
#define MV_ERROR            8
397
#define AC_END              16
398
#define DC_END              32
399
#define MV_END              64
400
//FIXME some prefix?
401
    
402 277f4827 Michael Niedermayer
    int resync_mb_x;                 ///< x position of last resync marker 
403
    int resync_mb_y;                 ///< y position of last resync marker 
404
    GetBitContext last_resync_gb;    ///< used to search for the next resync marker 
405
    int mb_num_left;                 ///< number of MBs left in this video packet (for partitioned Slices only)
406
    int next_p_frame_damaged;        ///< set if the next p frame is damaged, to avoid showing trashed b frames 
407 7f2fe444 Michael Niedermayer
    int error_resilience;
408 d7425f59 Michael Niedermayer
    
409
    ParseContext parse_context;
410 098eefe1 Michael Niedermayer
411 102d3908 Juanjo
    /* H.263 specific */
412
    int gob_number;
413 644d98a4 Juanjo
    int gob_index;
414 d140623f Juanjo
        
415 544286b3 Juanjo
    /* H.263+ specific */
416 277f4827 Michael Niedermayer
    int umvplus;                    ///< == H263+ && unrestricted_mv 
417
    int h263_aic;                   ///< Advanded INTRA Coding (AIC) 
418
    int h263_aic_dir;               ///< AIC direction: 0 = left, 1 = top 
419 544286b3 Juanjo
    
420 de6d9b64 Fabrice Bellard
    /* mpeg4 specific */
421 6f91bcd1 Michael Niedermayer
    int time_increment_resolution;
422 277f4827 Michael Niedermayer
    int time_increment_bits;        ///< number of bits to represent the fractional part of time 
423 9dbcbd92 Michael Niedermayer
    int last_time_base;
424 277f4827 Michael Niedermayer
    int time_base;                  ///< time in seconds of last I,P,S Frame 
425
    int64_t time;                   ///< time of current frame  
426 0c1a9eda Zdenek Kabelac
    int64_t last_non_b_time;
427 277f4827 Michael Niedermayer
    uint16_t pp_time;               ///< time distance between the last 2 p,s,i frames 
428
    uint16_t pb_time;               ///< time distance between the last b and p,s,i frame 
429 0c1a9eda Zdenek Kabelac
    uint16_t pp_field_time;
430 277f4827 Michael Niedermayer
    uint16_t pb_field_time;         ///< like above, just for interlaced 
431 1a565432 Fabrice Bellard
    int shape;
432
    int vol_sprite_usage;
433 cc9ba006 Michael Niedermayer
    int sprite_width;
434
    int sprite_height;
435
    int sprite_left;
436
    int sprite_top;
437
    int sprite_brightness_change;
438 73c8e514 Michael Niedermayer
    int num_sprite_warping_points;
439 44eb4951 Michael Niedermayer
    int real_sprite_warping_points;
440 277f4827 Michael Niedermayer
    int sprite_offset[2][2];         ///< sprite offset[isChroma][isMVY] 
441
    int sprite_delta[2][2];          ///< sprite_delta [isY][isMVY]  
442
    int sprite_shift[2];             ///< sprite shift [isChroma] 
443 73c8e514 Michael Niedermayer
    int mcsel;
444 1a565432 Fabrice Bellard
    int quant_precision;
445 277f4827 Michael Niedermayer
    int quarter_sample;              ///< 1->qpel, 0->half pel ME/MC  
446 cc9ba006 Michael Niedermayer
    int scalability;
447 0fd90455 Michael Niedermayer
    int hierachy_type;
448
    int enhancement_type;
449 cc9ba006 Michael Niedermayer
    int new_pred;
450
    int reduced_res_vop;
451
    int aspect_ratio_info;
452 e769f053 Alex Beregszaszi
    int aspected_width;
453
    int aspected_height;
454 cc9ba006 Michael Niedermayer
    int sprite_warping_accuracy;
455
    int low_latency_sprite;
456 277f4827 Michael Niedermayer
    int data_partitioning;           ///< data partitioning flag from header 
457
    int partitioned_frame;           ///< is current frame partitioned 
458
    int rvlc;                        ///< reversible vlc 
459
    int resync_marker;               ///< could this stream contain resync markers
460
    int low_delay;                   ///< no reordering needed / has no b-frames 
461 1ff662cc Michael Niedermayer
    int vo_type;
462 277f4827 Michael Niedermayer
    int vol_control_parameters;      ///< does the stream contain the low_delay flag, used to workaround buggy encoders 
463
    PutBitContext tex_pb;            ///< used for data partitioned VOPs 
464
    PutBitContext pb2;               ///< used for data partitioned VOPs 
465 7f2fe444 Michael Niedermayer
#define PB_BUFFER_SIZE 1024*256
466
    uint8_t *tex_pb_buffer;          
467
    uint8_t *pb2_buffer;
468 d930ef19 Michael Niedermayer
    int mpeg_quant;
469 bea669e5 Michael Niedermayer
#define CO_LOCATED_TYPE_4MV     1
470
#define CO_LOCATED_TYPE_FIELDMV 2
471 277f4827 Michael Niedermayer
    int8_t *co_located_type_table;     ///< 4mv & field_mv info for next b frame 
472
    int16_t (*field_mv_table)[2][2];   ///< used for interlaced b frame decoding 
473
    int8_t (*field_select_table)[2];   ///< wtf, no really another table for interlaced b frames 
474
    int t_frame;                       ///< time distance of first I -> B, used for interlaced b frames 
475
    int padding_bug_score;             ///< used to detect the VERY common padding bug in MPEG4 
476 44eb4951 Michael Niedermayer
477
    /* divx specific, used to workaround (many) bugs in divx5 */
478
    int divx_version;
479
    int divx_build;
480 eec1c6b9 Michael Niedermayer
#define BITSTREAM_BUFFER_SIZE 1024*256
481 0c1a9eda Zdenek Kabelac
    uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them
482 eec1c6b9 Michael Niedermayer
    int bitstream_buffer_size;
483
    
484 7da71a5c Michael Niedermayer
    int xvid_build;
485
    
486 4d2858de Michael Niedermayer
    /* lavc specific stuff, used to workaround bugs in libavcodec */
487
    int ffmpeg_version;
488
    int lavc_build;
489
    
490 de6d9b64 Fabrice Bellard
    /* RV10 specific */
491 277f4827 Michael Niedermayer
    int rv10_version; ///< RV10 version: 0 or 3 
492 de6d9b64 Fabrice Bellard
    int rv10_first_dc_coded[3];
493
    
494
    /* MJPEG specific */
495
    struct MJpegContext *mjpeg_ctx;
496 277f4827 Michael Niedermayer
    int mjpeg_vsample[3];       ///< vertical sampling factors, default = {2, 1, 1} 
497
    int mjpeg_hsample[3];       ///< horizontal sampling factors, default = {2, 1, 1} 
498
    int mjpeg_write_tables;     ///< do we want to have quantisation- and huffmantables in the jpeg file ? 
499
    int mjpeg_data_only_frames; ///< frames only with SOI, SOS and EOI markers 
500 de6d9b64 Fabrice Bellard
501
    /* MSMPEG4 specific */
502
    int mv_table_index;
503
    int rl_table_index;
504
    int rl_chroma_table_index;
505
    int dc_table_index;
506
    int use_skip_mb_code;
507 277f4827 Michael Niedermayer
    int slice_height;      ///< in macroblocks 
508
    int first_slice_line;  ///< used in mpeg4 too to handle resync markers 
509 ae40484c Michael Niedermayer
    int flipflop_rounding;
510 277f4827 Michael Niedermayer
    int msmpeg4_version;   ///< 0=not msmpeg4, 1=mp41, 2=mp42, 3=mp43/divx3 4=wmv1/7 5=wmv2/8
511 0151a6f5 Michael Niedermayer
    int per_mb_rl_table;
512
    int esc3_level_length;
513
    int esc3_run_length;
514 277f4827 Michael Niedermayer
    /** [mb_intra][isChroma][level][run][last] */
515 6b460aa3 Michael Niedermayer
    int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2];
516 de0f2f4c Michael Niedermayer
    int inter_intra_pred;
517 1457ab52 Michael Niedermayer
    int mspel;
518 0151a6f5 Michael Niedermayer
519 de6d9b64 Fabrice Bellard
    /* decompression specific */
520
    GetBitContext gb;
521
522 1e491e29 Michael Niedermayer
    /* Mpeg1 specific */
523 277f4827 Michael Niedermayer
    int fake_picture_number; ///< picture number at the bitstream frame rate 
524
    int gop_picture_number;  ///< index of the first picture of a GOP based on fake_pic_num & mpeg1 specific 
525
    int last_mv_dir;         ///< last mv_dir, used for b frame encoding 
526 1e491e29 Michael Niedermayer
    
527 de6d9b64 Fabrice Bellard
    /* MPEG2 specific - I wish I had not to support this mess. */
528
    int progressive_sequence;
529
    int mpeg_f_code[2][2];
530
    int picture_structure;
531
/* picture type */
532
#define PICT_TOP_FIELD     1
533
#define PICT_BOTTOM_FIELD  2
534
#define PICT_FRAME         3
535
536
    int intra_dc_precision;
537
    int frame_pred_frame_dct;
538
    int top_field_first;
539
    int concealment_motion_vectors;
540
    int q_scale_type;
541
    int intra_vlc_format;
542
    int alternate_scan;
543
    int repeat_first_field;
544
    int chroma_420_type;
545
    int progressive_frame;
546
    int mpeg2;
547
    int full_pel[2];
548
    int interlaced_dct;
549
    int first_slice;
550 dfb476cb Michael Niedermayer
    int first_field;
551 644d98a4 Juanjo
    
552
    /* RTP specific */
553 81401c1f Juanjo
    /* These are explained on avcodec.h */
554 644d98a4 Juanjo
    int rtp_mode;
555
    int rtp_payload_size;
556 81401c1f Juanjo
    void (*rtp_callback)(void *data, int size, int packet_number);
557 0c1a9eda Zdenek Kabelac
    uint8_t *ptr_lastgob;
558
    uint8_t *ptr_last_mb_line;
559
    uint32_t mb_line_avgsize;
560 644d98a4 Juanjo
    
561 277f4827 Michael Niedermayer
    DCTELEM (*block)[64]; ///< points to one of the following blocks 
562 91029be7 Michael Niedermayer
    DCTELEM blocks[2][6][64] __align8; // for HQ mode we need to keep the best block
563 4d2858de Michael Niedermayer
    int (*decode_mb)(struct MpegEncContext *s, DCTELEM block[6][64]); // used by some codecs to avoid a switch()
564
#define SLICE_OK         0
565
#define SLICE_ERROR     -1
566
#define SLICE_END       -2 //end marker found
567
#define SLICE_NOEND     -3 //no end marker or error found but mb count exceeded
568
    
569 9dbf1ddd Michael Niedermayer
    void (*dct_unquantize_mpeg1)(struct MpegEncContext *s, 
570 67309e49 Michael Niedermayer
                           DCTELEM *block/*align 16*/, int n, int qscale);
571 9dbf1ddd Michael Niedermayer
    void (*dct_unquantize_mpeg2)(struct MpegEncContext *s, 
572 67309e49 Michael Niedermayer
                           DCTELEM *block/*align 16*/, int n, int qscale);
573 3bf43d42 Michael Niedermayer
    void (*dct_unquantize_h263)(struct MpegEncContext *s, 
574 67309e49 Michael Niedermayer
                           DCTELEM *block/*align 16*/, int n, int qscale);
575 3bf43d42 Michael Niedermayer
    void (*dct_unquantize)(struct MpegEncContext *s, // unquantizer to use (mpeg4 can use both)
576 67309e49 Michael Niedermayer
                           DCTELEM *block/*align 16*/, int n, int qscale);
577
    int (*dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
578 3a87ac94 Michael Niedermayer
    int (*fast_dct_quantize)(struct MpegEncContext *s, DCTELEM *block/*align 16*/, int n, int qscale, int *overflow);
579 de6d9b64 Fabrice Bellard
} MpegEncContext;
580
581 4d2858de Michael Niedermayer
582 defdfc9a Alex Beregszaszi
int DCT_common_init(MpegEncContext *s);
583 de6d9b64 Fabrice Bellard
int MPV_common_init(MpegEncContext *s);
584
void MPV_common_end(MpegEncContext *s);
585
void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64]);
586 d6db1c9c Michael Niedermayer
int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx);
587 de6d9b64 Fabrice Bellard
void MPV_frame_end(MpegEncContext *s);
588 1457ab52 Michael Niedermayer
int MPV_encode_init(AVCodecContext *avctx);
589
int MPV_encode_end(AVCodecContext *avctx);
590
int MPV_encode_picture(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data);
591 21af69f7 Fabrice Bellard
#ifdef HAVE_MMX
592
void MPV_common_init_mmx(MpegEncContext *s);
593
#endif
594 e0580f8c Falk H├╝ffner
#ifdef ARCH_ALPHA
595
void MPV_common_init_axp(MpegEncContext *s);
596
#endif
597 c7e07931 Martin Olschewski
#ifdef HAVE_MLIB
598
void MPV_common_init_mlib(MpegEncContext *s);
599
#endif
600 5917d17c Leon van Stuivenberg
#ifdef HAVE_MMI
601
void MPV_common_init_mmi(MpegEncContext *s);
602
#endif
603 83f238cb Zdenek Kabelac
#ifdef ARCH_ARMV4L
604 d43b10ec Zdenek Kabelac
void MPV_common_init_armv4l(MpegEncContext *s);
605 83f238cb Zdenek Kabelac
#endif
606 05c4072b Michael Niedermayer
#ifdef ARCH_POWERPC
607
void MPV_common_init_ppc(MpegEncContext *s);
608
#endif
609 0c1a9eda Zdenek Kabelac
extern void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w);
610 7f2fe444 Michael Niedermayer
void ff_conceal_past_errors(MpegEncContext *s, int conceal_all);
611 0c1a9eda Zdenek Kabelac
void ff_copy_bits(PutBitContext *pb, uint8_t *src, int length);
612 7f2fe444 Michael Niedermayer
void ff_clean_intra_table_entries(MpegEncContext *s);
613 0c1a9eda Zdenek Kabelac
void ff_init_scantable(MpegEncContext *s, ScanTable *st, const uint8_t *src_scantable);
614 4d2858de Michael Niedermayer
void ff_error_resilience(MpegEncContext *s);
615 640950c7 Michael Niedermayer
void ff_draw_horiz_band(MpegEncContext *s, int y, int h);
616 0c1a9eda Zdenek Kabelac
void ff_emulated_edge_mc(MpegEncContext *s, uint8_t *src, int linesize, int block_w, int block_h, 
617 1457ab52 Michael Niedermayer
                                    int src_x, int src_y, int w, int h);
618 59b571c1 Michael Niedermayer
char ff_get_pict_type_char(int pict_type);
619 b7a22d84 Michael Niedermayer
int ff_combine_frame( MpegEncContext *s, int next, uint8_t **buf, int *buf_size);
620 59b571c1 Michael Niedermayer
621 a33c7159 Michael Niedermayer
extern enum PixelFormat ff_yuv420p_list[2];
622 de6d9b64 Fabrice Bellard
623 4d2858de Michael Niedermayer
static inline void ff_init_block_index(MpegEncContext *s){
624
    s->block_index[0]= s->block_wrap[0]*(s->mb_y*2 + 1) - 1 + s->mb_x*2;
625
    s->block_index[1]= s->block_wrap[0]*(s->mb_y*2 + 1)     + s->mb_x*2;
626
    s->block_index[2]= s->block_wrap[0]*(s->mb_y*2 + 2) - 1 + s->mb_x*2;
627
    s->block_index[3]= s->block_wrap[0]*(s->mb_y*2 + 2)     + s->mb_x*2;
628
    s->block_index[4]= s->block_wrap[4]*(s->mb_y + 1)                    + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
629
    s->block_index[5]= s->block_wrap[4]*(s->mb_y + 1 + s->mb_height + 2) + s->block_wrap[0]*(s->mb_height*2 + 2) + s->mb_x;
630
}
631
632
static inline void ff_update_block_index(MpegEncContext *s){
633
    s->block_index[0]+=2;
634
    s->block_index[1]+=2;
635
    s->block_index[2]+=2;
636
    s->block_index[3]+=2;
637
    s->block_index[4]++;
638
    s->block_index[5]++;
639
}
640
641
642 de6d9b64 Fabrice Bellard
/* motion_est.c */
643 9dbcbd92 Michael Niedermayer
void ff_estimate_p_frame_motion(MpegEncContext * s,
644
                             int mb_x, int mb_y);
645
void ff_estimate_b_frame_motion(MpegEncContext * s,
646
                             int mb_x, int mb_y);
647
int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type);
648
void ff_fix_long_p_mvs(MpegEncContext * s);
649
void ff_fix_long_b_mvs(MpegEncContext * s, int16_t (*mv_table)[2], int f_code, int type);
650 1457ab52 Michael Niedermayer
void ff_init_me(MpegEncContext *s);
651 f5fb6b34 Michael Niedermayer
int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y);
652 de6d9b64 Fabrice Bellard
653 4d2858de Michael Niedermayer
654 de6d9b64 Fabrice Bellard
/* mpeg12.c */
655 0c1a9eda Zdenek Kabelac
extern const int16_t ff_mpeg1_default_intra_matrix[64];
656
extern const int16_t ff_mpeg1_default_non_intra_matrix[64];
657
extern uint8_t ff_mpeg1_dc_scale_table[128];
658 de6d9b64 Fabrice Bellard
659
void mpeg1_encode_picture_header(MpegEncContext *s, int picture_number);
660
void mpeg1_encode_mb(MpegEncContext *s,
661
                     DCTELEM block[6][64],
662
                     int motion_x, int motion_y);
663 0151a6f5 Michael Niedermayer
void ff_mpeg1_encode_init(MpegEncContext *s);
664 de6d9b64 Fabrice Bellard
665 4d2858de Michael Niedermayer
666 277f4827 Michael Niedermayer
/** RLTable. */
667 de6d9b64 Fabrice Bellard
typedef struct RLTable {
668 277f4827 Michael Niedermayer
    int n;                         ///< number of entries of table_vlc minus 1 
669
    int last;                      ///< number of values for last = 0 
670 0c1a9eda Zdenek Kabelac
    const uint16_t (*table_vlc)[2];
671
    const int8_t *table_run;
672
    const int8_t *table_level;
673 277f4827 Michael Niedermayer
    uint8_t *index_run[2];         ///< encoding only 
674
    int8_t *max_level[2];          ///< encoding & decoding 
675
    int8_t *max_run[2];            ///< encoding & decoding 
676
    VLC vlc;                       ///< decoding only deprected FIXME remove
677
    RL_VLC_ELEM *rl_vlc[32];       ///< decoding only 
678 de6d9b64 Fabrice Bellard
} RLTable;
679
680
void init_rl(RLTable *rl);
681
void init_vlc_rl(RLTable *rl);
682
683 3232bc88 Zdenek Kabelac
static inline int get_rl_index(const RLTable *rl, int last, int run, int level)
684 de6d9b64 Fabrice Bellard
{
685
    int index;
686
    index = rl->index_run[last][run];
687
    if (index >= rl->n)
688
        return rl->n;
689
    if (level > rl->max_level[last][run])
690
        return rl->n;
691
    return index + level - 1;
692
}
693
694 0c1a9eda Zdenek Kabelac
extern uint8_t ff_mpeg4_y_dc_scale_table[32];
695
extern uint8_t ff_mpeg4_c_dc_scale_table[32];
696
extern const int16_t ff_mpeg4_default_intra_matrix[64];
697
extern const int16_t ff_mpeg4_default_non_intra_matrix[64];
698 1457ab52 Michael Niedermayer
int ff_h263_decode_init(AVCodecContext *avctx);
699
int ff_h263_decode_frame(AVCodecContext *avctx, 
700
                             void *data, int *data_size,
701 0c1a9eda Zdenek Kabelac
                             uint8_t *buf, int buf_size);
702 1457ab52 Michael Niedermayer
int ff_h263_decode_end(AVCodecContext *avctx);
703 de6d9b64 Fabrice Bellard
void h263_encode_mb(MpegEncContext *s, 
704
                    DCTELEM block[6][64],
705
                    int motion_x, int motion_y);
706 d6231b9e Michael Niedermayer
void mpeg4_encode_mb(MpegEncContext *s, 
707
                    DCTELEM block[6][64],
708
                    int motion_x, int motion_y);
709 de6d9b64 Fabrice Bellard
void h263_encode_picture_header(MpegEncContext *s, int picture_number);
710 644d98a4 Juanjo
int h263_encode_gob_header(MpegEncContext * s, int mb_line);
711 0c1a9eda Zdenek Kabelac
int16_t *h263_pred_motion(MpegEncContext * s, int block, 
712 de6d9b64 Fabrice Bellard
                        int *px, int *py);
713 0e15384d Michael Niedermayer
void mpeg4_pred_ac(MpegEncContext * s, DCTELEM *block, int n, 
714 de6d9b64 Fabrice Bellard
                   int dir);
715 91029be7 Michael Niedermayer
void ff_set_mpeg4_time(MpegEncContext * s, int picture_number);
716 de6d9b64 Fabrice Bellard
void mpeg4_encode_picture_header(MpegEncContext *s, int picture_number);
717 45870f57 Michael Niedermayer
void h263_encode_init(MpegEncContext *s);
718 de6d9b64 Fabrice Bellard
void h263_decode_init_vlc(MpegEncContext *s);
719
int h263_decode_picture_header(MpegEncContext *s);
720 4d2858de Michael Niedermayer
int ff_h263_decode_gob_header(MpegEncContext *s);
721 b704e742 Michael Niedermayer
int ff_mpeg4_decode_picture_header(MpegEncContext * s, GetBitContext *gb);
722
723
724 de6d9b64 Fabrice Bellard
int intel_h263_decode_picture_header(MpegEncContext *s);
725 4d2858de Michael Niedermayer
int ff_h263_decode_mb(MpegEncContext *s,
726
                      DCTELEM block[6][64]);
727 de6d9b64 Fabrice Bellard
int h263_get_picture_format(int width, int height);
728 7f2fe444 Michael Niedermayer
void ff_mpeg4_encode_video_packet_header(MpegEncContext *s);
729
void ff_mpeg4_clean_buffers(MpegEncContext *s);
730
void ff_mpeg4_stuffing(PutBitContext * pbc);
731
void ff_mpeg4_init_partitions(MpegEncContext *s);
732
void ff_mpeg4_merge_partitions(MpegEncContext *s);
733 c5d309f2 Michael Niedermayer
void ff_clean_mpeg4_qscales(MpegEncContext *s);
734 9e4c6948 Michael Niedermayer
void ff_clean_h263_qscales(MpegEncContext *s);
735 4d2858de Michael Niedermayer
int ff_mpeg4_decode_partitions(MpegEncContext *s);
736
int ff_mpeg4_get_video_packet_prefix_length(MpegEncContext *s);
737
int ff_h263_resync(MpegEncContext *s);
738
int ff_h263_get_gob_height(MpegEncContext *s);
739 1457ab52 Michael Niedermayer
void ff_mpeg4_set_direct_mv(MpegEncContext *s, int mx, int my);
740 67725183 Michael Niedermayer
inline int ff_h263_round_chroma(int x);
741 4d2858de Michael Niedermayer
742 de6d9b64 Fabrice Bellard
743
/* rv10.c */
744
void rv10_encode_picture_header(MpegEncContext *s, int picture_number);
745
int rv_decode_dc(MpegEncContext *s, int n);
746
747 4d2858de Michael Niedermayer
748 de6d9b64 Fabrice Bellard
/* msmpeg4.c */
749
void msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number);
750 ae40484c Michael Niedermayer
void msmpeg4_encode_ext_header(MpegEncContext * s);
751 de6d9b64 Fabrice Bellard
void msmpeg4_encode_mb(MpegEncContext * s, 
752
                       DCTELEM block[6][64],
753
                       int motion_x, int motion_y);
754
int msmpeg4_decode_picture_header(MpegEncContext * s);
755 ae40484c Michael Niedermayer
int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size);
756 0151a6f5 Michael Niedermayer
int ff_msmpeg4_decode_init(MpegEncContext *s);
757
void ff_msmpeg4_encode_init(MpegEncContext *s);
758 1457ab52 Michael Niedermayer
int ff_wmv2_decode_picture_header(MpegEncContext * s);
759
void ff_wmv2_add_mb(MpegEncContext *s, DCTELEM block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
760
void ff_mspel_motion(MpegEncContext *s,
761 0c1a9eda Zdenek Kabelac
                               uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
762
                               uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
763 1457ab52 Michael Niedermayer
                               int motion_x, int motion_y, int h);
764
int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number);
765
void ff_wmv2_encode_mb(MpegEncContext * s, 
766
                       DCTELEM block[6][64],
767
                       int motion_x, int motion_y);
768 de6d9b64 Fabrice Bellard
769 4d2858de Michael Niedermayer
/* mjpegenc.c */
770 de6d9b64 Fabrice Bellard
int mjpeg_init(MpegEncContext *s);
771
void mjpeg_close(MpegEncContext *s);
772
void mjpeg_encode_mb(MpegEncContext *s, 
773
                     DCTELEM block[6][64]);
774
void mjpeg_picture_header(MpegEncContext *s);
775
void mjpeg_picture_trailer(MpegEncContext *s);
776 8b4c7dbc Michael Niedermayer
777 4d2858de Michael Niedermayer
778 8b4c7dbc Michael Niedermayer
/* rate control */
779
int ff_rate_control_init(MpegEncContext *s);
780 c5d309f2 Michael Niedermayer
float ff_rate_estimate_qscale(MpegEncContext *s);
781 8b4c7dbc Michael Niedermayer
void ff_write_pass1_stats(MpegEncContext *s);
782
void ff_rate_control_uninit(MpegEncContext *s);
783 5c91a675 Zdenek Kabelac
double ff_eval(char *s, double *const_value, const char **const_name,
784
               double (**func1)(void *, double), const char **func1_name,
785 3aa102be Michael Niedermayer
               double (**func2)(void *, double, double), char **func2_name,
786
               void *opaque);
787
788 8b4c7dbc Michael Niedermayer
789 cd4af68a Zdenek Kabelac
#endif /* AVCODEC_MPEGVIDEO_H */