+typedef struct RateControlEntry{
+ int pict_type;
+ float qscale;
+ int mv_bits;
+ int i_tex_bits;
+ int p_tex_bits;
+ int misc_bits;
+ UINT64 expected_bits;
+ int new_pict_type;
+ float new_qscale;
+ int mc_mb_var_sum;
+ int mb_var_sum;
+ int i_count;
+ int f_code;
+ int b_code;
+}RateControlEntry;
+
+typedef struct RateControlContext{
+ FILE *stats_file;
+ int num_entries; /* number of RateControlEntries */
+ RateControlEntry *entry;
+ int buffer_index; /* amount of bits in the video/audio buffer */
+ Predictor pred[5];
+ double short_term_qsum; /* sum of recent qscales */
+ double short_term_qcount; /* count of recent qscales */
+ double pass1_rc_eq_output_sum;/* sum of the output of the rc equation, this is used for normalization */
+ double pass1_wanted_bits; /* bits which should have been outputed by the pass1 code (including complexity init) */
+ double last_qscale;
+ double last_qscale_for[5]; /* last qscale for a specific pict type, used for max_diff & ipb factor stuff */
+ int last_mc_mb_var_sum;
+ int last_mb_var_sum;
+ UINT64 i_cplx_sum[5];
+ UINT64 p_cplx_sum[5];
+ UINT64 mv_bits_sum[5];
+ UINT64 qscale_sum[5];
+ int frame_count[5];
+ int last_non_b_pict_type;
+}RateControlContext;
+
+
+typedef struct ScanTable{
+ const UINT8 *scantable;
+ UINT8 permutated[64];
+ UINT8 raster_end[64];
+#ifdef ARCH_POWERPC
+ /* Used by dct_quantise_alitvec to find last-non-zero */
+ UINT8 __align8 inverse[64];
+#endif
+} ScanTable;
+
+typedef struct Picture{
+ FF_COMMON_FRAME
+
+ int mb_var_sum; /* sum of MB variance for current frame */
+ int mc_mb_var_sum; /* motion compensated MB variance for current frame */
+ uint16_t *mb_var; /* Table for MB variances */
+ uint16_t *mc_mb_var; /* Table for motion compensated MB variances */
+ uint8_t *mb_mean; /* Table for MB luminance */
+ int b_frame_score; /* */
+} Picture;
+
+typedef struct ParseContext{
+ UINT8 *buffer;
+ int index;
+ int last_index;
+ int buffer_size;
+ int state;
+ int frame_start_found;
+} ParseContext;
+
+struct MpegEncContext;
+
+typedef struct MotionEstContext{
+ int skip; /* set if ME is skiped for the current MB */
+ int co_located_mv[4][2]; /* mv from last p frame for direct mode ME */
+ int direct_basis_mv[4][2];
+ uint8_t *scratchpad; /* data area for the me algo, so that the ME doesnt need to malloc/free */
+ uint32_t *map; /* map to avoid duplicate evaluations */
+ uint32_t *score_map; /* map to store the scores */
+ int map_generation;
+ int pre_penalty_factor;
+ int penalty_factor;
+ int sub_penalty_factor;
+ int pre_pass; /* = 1 for the pre pass */
+ int dia_size;
+ UINT16 (*mv_penalty)[MAX_MV*2+1]; /* amount of bits needed to encode a MV */
+ int (*sub_motion_search)(struct MpegEncContext * s,
+ int *mx_ptr, int *my_ptr, int dmin,
+ int xmin, int ymin, int xmax, int ymax,
+ int pred_x, int pred_y, Picture *ref_picture,
+ int n, int size, uint16_t * const mv_penalty);
+ int (*motion_search[7])(struct MpegEncContext * s, int block,
+ int *mx_ptr, int *my_ptr,
+ int P[10][2], int pred_x, int pred_y,
+ int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2],
+ int ref_mv_scale, uint16_t * const mv_penalty);
+ int (*pre_motion_search)(struct MpegEncContext * s, int block,
+ int *mx_ptr, int *my_ptr,
+ int P[10][2], int pred_x, int pred_y,
+ int xmin, int ymin, int xmax, int ymax, Picture *ref_picture, int16_t (*last_mv)[2],
+ int ref_mv_scale, uint16_t * const mv_penalty);
+}MotionEstContext;
+