This source file includes following definitions.
- ff_update_block_index
- get_bits_diff
- ff_h263_round_chroma
#ifndef AVCODEC_MPEGVIDEO_H
#define AVCODEC_MPEGVIDEO_H
#include <float.h>
#include "avcodec.h"
#include "blockdsp.h"
#include "error_resilience.h"
#include "fdctdsp.h"
#include "get_bits.h"
#include "h264chroma.h"
#include "h263dsp.h"
#include "hpeldsp.h"
#include "idctdsp.h"
#include "me_cmp.h"
#include "mpegvideodsp.h"
#include "mpegvideoencdsp.h"
#include "pixblockdsp.h"
#include "put_bits.h"
#include "ratecontrol.h"
#include "parser.h"
#include "mpeg12data.h"
#include "qpeldsp.h"
#include "rl.h"
#include "thread.h"
#include "videodsp.h"
#include "libavutil/opt.h"
#include "libavutil/timecode.h"
#define FRAME_SKIPPED 100
enum OutputFormat {
FMT_MPEG1,
FMT_H261,
FMT_H263,
FMT_MJPEG,
};
#define MAX_FCODE 7
#define MAX_MV 4096
#define MAX_THREADS 32
#define MAX_PICTURE_COUNT 36
#define MAX_B_FRAMES 16
#define ME_MAP_SIZE 64
#define MAX_MB_BYTES (30*16*16*3/8 + 120)
#define INPLACE_OFFSET 16
#define EDGE_WIDTH 16
#define SEQ_END_CODE 0x000001b7
#define SEQ_START_CODE 0x000001b3
#define GOP_START_CODE 0x000001b8
#define PICTURE_START_CODE 0x00000100
#define SLICE_MIN_START_CODE 0x00000101
#define SLICE_MAX_START_CODE 0x000001af
#define EXT_START_CODE 0x000001b5
#define USER_START_CODE 0x000001b2
extern const uint8_t ff_alternate_horizontal_scan[64];
extern const uint8_t ff_alternate_vertical_scan[64];
struct MpegEncContext;
typedef struct Picture{
struct AVFrame *f;
ThreadFrame tf;
AVBufferRef *qscale_table_buf;
int8_t *qscale_table;
AVBufferRef *motion_val_buf[2];
int16_t (*motion_val[2])[2];
AVBufferRef *mb_type_buf;
uint32_t *mb_type;
AVBufferRef *mbskip_table_buf;
uint8_t *mbskip_table;
AVBufferRef *ref_index_buf[2];
int8_t *ref_index[2];
AVBufferRef *mb_var_buf;
uint16_t *mb_var;
AVBufferRef *mc_mb_var_buf;
uint16_t *mc_mb_var;
int alloc_mb_width;
int alloc_mb_height;
AVBufferRef *mb_mean_buf;
uint8_t *mb_mean;
AVBufferRef *hwaccel_priv_buf;
void *hwaccel_picture_private;
int field_picture;
int64_t mb_var_sum;
int64_t mc_mb_var_sum;
int b_frame_score;
int needs_realloc;
int reference;
int shared;
uint64_t error[AV_NUM_DATA_POINTERS];
} Picture;
typedef struct MotionEstContext{
AVCodecContext *avctx;
int skip;
int co_located_mv[4][2];
int direct_basis_mv[4][2];
uint8_t *scratchpad;
uint8_t *best_mb;
uint8_t *temp_mb[2];
uint8_t *temp;
int best_bits;
uint32_t *map;
uint32_t *score_map;
unsigned map_generation;
int pre_penalty_factor;
int penalty_factor;
int sub_penalty_factor;
int mb_penalty_factor;
int flags;
int sub_flags;
int mb_flags;
int pre_pass;
int dia_size;
int xmin;
int xmax;
int ymin;
int ymax;
int pred_x;
int pred_y;
uint8_t *src[4][4];
uint8_t *ref[4][4];
int stride;
int uvstride;
int64_t mc_mb_var_sum_temp;
int64_t mb_var_sum_temp;
int scene_change_score;
op_pixels_func (*hpel_put)[4];
op_pixels_func (*hpel_avg)[4];
qpel_mc_func (*qpel_put)[16];
qpel_mc_func (*qpel_avg)[16];
uint8_t (*mv_penalty)[MAX_MV*2+1];
uint8_t *current_mv_penalty;
int (*sub_motion_search)(struct MpegEncContext * s,
int *mx_ptr, int *my_ptr, int dmin,
int src_index, int ref_index,
int size, int h);
}MotionEstContext;
typedef struct MpegEncContext {
AVClass *class;
int y_dc_scale, c_dc_scale;
int ac_pred;
int block_last_index[12];
int h263_aic;
ScanTable inter_scantable;
ScanTable intra_scantable;
ScanTable intra_h_scantable;
ScanTable intra_v_scantable;
struct AVCodecContext *avctx;
int width, height;
int gop_size;
int intra_only;
int bit_rate;
enum OutputFormat out_format;
int h263_pred;
int pb_frame;
int h263_plus;
int h263_flv;
enum AVCodecID codec_id;
int fixed_qscale;
int encoding;
int flags;
int flags2;
int max_b_frames;
int luma_elim_threshold;
int chroma_elim_threshold;
int strict_std_compliance;
int workaround_bugs;
int codec_tag;
int stream_codec_tag;
int context_initialized;
int input_picture_number;
int coded_picture_number;
int picture_number;
int picture_in_gop_number;
int mb_width, mb_height;
int mb_stride;
int b8_stride;
int h_edge_pos, v_edge_pos;
int mb_num;
ptrdiff_t linesize;
ptrdiff_t uvlinesize;
Picture *picture;
Picture **input_picture;
Picture **reordered_input_picture;
int64_t user_specified_pts;
int64_t dts_delta;
int64_t reordered_pts;
PutBitContext pb;
int start_mb_y;
int end_mb_y;
struct MpegEncContext *thread_context[MAX_THREADS];
int slice_context_count;
Picture last_picture;
Picture next_picture;
Picture new_picture;
Picture current_picture;
Picture *last_picture_ptr;
Picture *next_picture_ptr;
Picture *current_picture_ptr;
int last_dc[3];
int16_t *dc_val_base;
int16_t *dc_val[3];
const uint8_t *y_dc_scale_table;
const uint8_t *c_dc_scale_table;
const uint8_t *chroma_qscale_table;
uint8_t *coded_block_base;
uint8_t *coded_block;
int16_t (*ac_val_base)[16];
int16_t (*ac_val[3])[16];
int mb_skipped;
uint8_t *mbskip_table;
uint8_t *mbintra_table;
uint8_t *cbp_table;
uint8_t *pred_dir_table;
uint8_t *edge_emu_buffer;
uint8_t *rd_scratchpad;
uint8_t *obmc_scratchpad;
uint8_t *b_scratchpad;
int qscale;
int chroma_qscale;
unsigned int lambda;
unsigned int lambda2;
int *lambda_table;
int adaptive_quant;
int dquant;
int closed_gop;
int pict_type;
int vbv_delay;
int last_pict_type;
int last_non_b_pict_type;
int droppable;
int frame_rate_index;
AVRational mpeg2_frame_rate_ext;
int last_lambda_for[5];
int skipdct;
int unrestricted_mv;
int h263_long_vectors;
BlockDSPContext bdsp;
FDCTDSPContext fdsp;
H264ChromaContext h264chroma;
HpelDSPContext hdsp;
IDCTDSPContext idsp;
MECmpContext mecc;
MpegVideoDSPContext mdsp;
MpegvideoEncDSPContext mpvencdsp;
PixblockDSPContext pdsp;
QpelDSPContext qdsp;
VideoDSPContext vdsp;
H263DSPContext h263dsp;
int f_code;
int b_code;
int16_t (*p_mv_table_base)[2];
int16_t (*b_forw_mv_table_base)[2];
int16_t (*b_back_mv_table_base)[2];
int16_t (*b_bidir_forw_mv_table_base)[2];
int16_t (*b_bidir_back_mv_table_base)[2];
int16_t (*b_direct_mv_table_base)[2];
int16_t (*p_field_mv_table_base[2][2])[2];
int16_t (*b_field_mv_table_base[2][2][2])[2];
int16_t (*p_mv_table)[2];
int16_t (*b_forw_mv_table)[2];
int16_t (*b_back_mv_table)[2];
int16_t (*b_bidir_forw_mv_table)[2];
int16_t (*b_bidir_back_mv_table)[2];
int16_t (*b_direct_mv_table)[2];
int16_t (*p_field_mv_table[2][2])[2];
int16_t (*b_field_mv_table[2][2][2])[2];
uint8_t (*p_field_select_table[2]);
uint8_t (*b_field_select_table[2][2]);
int me_method;
int mv_dir;
#define MV_DIR_FORWARD 1
#define MV_DIR_BACKWARD 2
#define MV_DIRECT 4
int mv_type;
#define MV_TYPE_16X16 0
#define MV_TYPE_8X8 1
#define MV_TYPE_16X8 2
#define MV_TYPE_FIELD 3
#define MV_TYPE_DMV 4
int mv[2][4][2];
int field_select[2][2];
int last_mv[2][2][2];
uint8_t *fcode_tab;
int16_t direct_scale_mv[2][64];
MotionEstContext me;
int no_rounding;
int mb_x, mb_y;
int mb_skip_run;
int mb_intra;
uint16_t *mb_type;
int block_index[6];
int block_wrap[6];
uint8_t *dest[3];
int *mb_index2xy;
uint16_t intra_matrix[64];
uint16_t chroma_intra_matrix[64];
uint16_t inter_matrix[64];
uint16_t chroma_inter_matrix[64];
int intra_quant_bias;
int inter_quant_bias;
int min_qcoeff;
int max_qcoeff;
int ac_esc_length;
uint8_t *intra_ac_vlc_length;
uint8_t *intra_ac_vlc_last_length;
uint8_t *intra_chroma_ac_vlc_length;
uint8_t *intra_chroma_ac_vlc_last_length;
uint8_t *inter_ac_vlc_length;
uint8_t *inter_ac_vlc_last_length;
uint8_t *luma_dc_vlc_length;
#define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
int coded_score[12];
int (*q_intra_matrix)[64];
int (*q_chroma_intra_matrix)[64];
int (*q_inter_matrix)[64];
uint16_t (*q_intra_matrix16)[2][64];
uint16_t (*q_chroma_intra_matrix16)[2][64];
uint16_t (*q_inter_matrix16)[2][64];
int (*dct_error_sum)[64];
int dct_count[2];
uint16_t (*dct_offset)[64];
int64_t total_bits;
int frame_bits;
int stuffing_bits;
int next_lambda;
RateControlContext rc_context;
int mv_bits;
int header_bits;
int i_tex_bits;
int p_tex_bits;
int i_count;
int f_count;
int b_count;
int skip_count;
int misc_bits;
int last_bits;
int resync_mb_x;
int resync_mb_y;
GetBitContext last_resync_gb;
int mb_num_left;
int next_p_frame_damaged;
int err_recognition;
ParseContext parse_context;
int gob_index;
int obmc;
int mb_info;
int prev_mb_info, last_mb_info;
uint8_t *mb_info_ptr;
int mb_info_size;
int ehc_mode;
int umvplus;
int h263_aic_dir;
int h263_slice_structured;
int alt_inter_vlc;
int modified_quant;
int loop_filter;
int custom_pcf;
int time_increment_bits;
int last_time_base;
int time_base;
int64_t time;
int64_t last_non_b_time;
uint16_t pp_time;
uint16_t pb_time;
uint16_t pp_field_time;
uint16_t pb_field_time;
int real_sprite_warping_points;
int sprite_offset[2][2];
int sprite_delta[2][2];
int mcsel;
int quant_precision;
int quarter_sample;
int aspect_ratio_info;
int sprite_warping_accuracy;
int data_partitioning;
int partitioned_frame;
int low_delay;
int vo_type;
PutBitContext tex_pb;
PutBitContext pb2;
int mpeg_quant;
int padding_bug_score;
int divx_packed;
uint8_t *bitstream_buffer;
int bitstream_buffer_size;
unsigned int allocated_bitstream_buffer_size;
int rv10_version;
int rv10_first_dc_coded[3];
struct MJpegContext *mjpeg_ctx;
int esc_pos;
int mv_table_index;
int rl_table_index;
int rl_chroma_table_index;
int dc_table_index;
int use_skip_mb_code;
int slice_height;
int first_slice_line;
int flipflop_rounding;
int msmpeg4_version;
int per_mb_rl_table;
int esc3_level_length;
int esc3_run_length;
int (*ac_stats)[2][MAX_LEVEL+1][MAX_RUN+1][2];
int inter_intra_pred;
int mspel;
GetBitContext gb;
int gop_picture_number;
int last_mv_dir;
uint8_t *vbv_delay_ptr;
int progressive_sequence;
int mpeg_f_code[2][2];
int picture_structure;
int intra_dc_precision;
int frame_pred_frame_dct;
int top_field_first;
int concealment_motion_vectors;
int q_scale_type;
int intra_vlc_format;
int alternate_scan;
int seq_disp_ext;
int repeat_first_field;
int chroma_420_type;
int chroma_format;
#define CHROMA_420 1
#define CHROMA_422 2
#define CHROMA_444 3
int chroma_x_shift;
int chroma_y_shift;
int progressive_frame;
int full_pel[2];
int interlaced_dct;
int first_field;
int drop_frame_timecode;
int scan_offset;
int rtp_mode;
char *tc_opt_str;
AVTimecode tc;
uint8_t *ptr_lastgob;
int swap_uv;
int pack_pblocks;
int16_t (*pblocks[12])[64];
int16_t (*block)[64];
int16_t (*blocks)[12][64];
int (*decode_mb)(struct MpegEncContext *s, int16_t block[6][64]);
#define SLICE_OK 0
#define SLICE_ERROR -1
#define SLICE_END -2
#define SLICE_NOEND -3
void (*dct_unquantize_mpeg1_intra)(struct MpegEncContext *s,
int16_t *block, int n, int qscale);
void (*dct_unquantize_mpeg1_inter)(struct MpegEncContext *s,
int16_t *block, int n, int qscale);
void (*dct_unquantize_mpeg2_intra)(struct MpegEncContext *s,
int16_t *block, int n, int qscale);
void (*dct_unquantize_mpeg2_inter)(struct MpegEncContext *s,
int16_t *block, int n, int qscale);
void (*dct_unquantize_h263_intra)(struct MpegEncContext *s,
int16_t *block, int n, int qscale);
void (*dct_unquantize_h263_inter)(struct MpegEncContext *s,
int16_t *block, int n, int qscale);
void (*dct_unquantize_intra)(struct MpegEncContext *s,
int16_t *block, int n, int qscale);
void (*dct_unquantize_inter)(struct MpegEncContext *s,
int16_t *block, int n, int qscale);
int (*dct_quantize)(struct MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow);
int (*fast_dct_quantize)(struct MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow);
void (*denoise_dct)(struct MpegEncContext *s, int16_t *block);
int mpv_flags;
int quantizer_noise_shaping;
float rc_qsquish;
float rc_qmod_amp;
int rc_qmod_freq;
float rc_initial_cplx;
float rc_buffer_aggressivity;
float border_masking;
int lmin, lmax;
char *rc_eq;
float *cplx_tab, *bits_tab;
int context_reinit;
ERContext er;
int error_rate;
AVFrame *tmp_frames[MAX_B_FRAMES + 2];
} MpegEncContext;
#define FF_MPV_FLAG_SKIP_RD 0x0001
#define FF_MPV_FLAG_STRICT_GOP 0x0002
#define FF_MPV_FLAG_QP_RD 0x0004
#define FF_MPV_FLAG_CBP_RD 0x0008
#define FF_MPV_FLAG_NAQ 0x0010
#define FF_MPV_FLAG_MV0 0x0020
#ifndef FF_MPV_OFFSET
#define FF_MPV_OFFSET(x) offsetof(MpegEncContext, x)
#endif
#define FF_MPV_OPT_FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM)
#define FF_MPV_COMMON_OPTS \
{ "mpv_flags", "Flags common for all mpegvideo-based encoders.", FF_MPV_OFFSET(mpv_flags), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "skip_rd", "RD optimal MB level residual skipping", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_SKIP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "strict_gop", "Strictly enforce gop size", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_STRICT_GOP }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "qp_rd", "Use rate distortion optimization for qp selection", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_QP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "cbp_rd", "use rate distortion optimization for CBP", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_CBP_RD }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "naq", "normalize adaptive quantization", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_NAQ }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "mv0", "always try a mb with mv=<0,0>", 0, AV_OPT_TYPE_CONST, { .i64 = FF_MPV_FLAG_MV0 }, 0, 0, FF_MPV_OPT_FLAGS, "mpv_flags" },\
{ "luma_elim_threshold", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)",\
FF_MPV_OFFSET(luma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\
{ "chroma_elim_threshold", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)",\
FF_MPV_OFFSET(chroma_elim_threshold), AV_OPT_TYPE_INT, { .i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS },\
{ "quantizer_noise_shaping", NULL, FF_MPV_OFFSET(quantizer_noise_shaping), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\
{ "error_rate", "Simulate errors in the bitstream to test error concealment.", \
FF_MPV_OFFSET(error_rate), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, INT_MAX, FF_MPV_OPT_FLAGS },\
{"qsquish", "how to keep quantizer between qmin and qmax (0 = clip, 1 = use differentiable function)", \
FF_MPV_OFFSET(rc_qsquish), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, 0, 99, FF_MPV_OPT_FLAGS}, \
{"rc_qmod_amp", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_amp), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
{"rc_qmod_freq", "experimental quantizer modulation", FF_MPV_OFFSET(rc_qmod_freq), AV_OPT_TYPE_INT, {.i64 = 0 }, INT_MIN, INT_MAX, FF_MPV_OPT_FLAGS}, \
{"rc_eq", "Set rate control equation. When computing the expression, besides the standard functions " \
"defined in the section 'Expression Evaluation', the following functions are available: " \
"bits2qp(bits), qp2bits(qp). Also the following constants are available: iTex pTex tex mv " \
"fCode iCount mcVar var isI isP isB avgQP qComp avgIITex avgPITex avgPPTex avgBPTex avgTex.", \
FF_MPV_OFFSET(rc_eq), AV_OPT_TYPE_STRING, .flags = FF_MPV_OPT_FLAGS }, \
{"rc_init_cplx", "initial complexity for 1-pass encoding", FF_MPV_OFFSET(rc_initial_cplx), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
{"rc_buf_aggressivity", "currently useless", FF_MPV_OFFSET(rc_buffer_aggressivity), AV_OPT_TYPE_FLOAT, {.dbl = 1.0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
{"border_mask", "increase the quantizer for macroblocks close to borders", FF_MPV_OFFSET(border_masking), AV_OPT_TYPE_FLOAT, {.dbl = 0 }, -FLT_MAX, FLT_MAX, FF_MPV_OPT_FLAGS}, \
{"lmin", "minimum Lagrange factor (VBR)", FF_MPV_OFFSET(lmin), AV_OPT_TYPE_INT, {.i64 = 2*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \
{"lmax", "maximum Lagrange factor (VBR)", FF_MPV_OFFSET(lmax), AV_OPT_TYPE_INT, {.i64 = 31*FF_QP2LAMBDA }, 0, INT_MAX, FF_MPV_OPT_FLAGS }, \
extern const AVOption ff_mpv_generic_options[];
#define FF_MPV_GENERIC_CLASS(name) \
static const AVClass name ## _class = {\
.class_name = #name " encoder",\
.item_name = av_default_item_name,\
.option = ff_mpv_generic_options,\
.version = LIBAVUTIL_VERSION_INT,\
};
void ff_mpv_common_defaults(MpegEncContext *s);
void ff_dct_encode_init_x86(MpegEncContext *s);
int ff_mpv_common_init(MpegEncContext *s);
void ff_mpv_common_init_arm(MpegEncContext *s);
void ff_mpv_common_init_axp(MpegEncContext *s);
void ff_mpv_common_init_neon(MpegEncContext *s);
void ff_mpv_common_init_ppc(MpegEncContext *s);
void ff_mpv_common_init_x86(MpegEncContext *s);
int ff_mpv_common_frame_size_change(MpegEncContext *s);
void ff_mpv_common_end(MpegEncContext *s);
void ff_mpv_decode_defaults(MpegEncContext *s);
void ff_mpv_decode_init(MpegEncContext *s, AVCodecContext *avctx);
void ff_mpv_decode_mb(MpegEncContext *s, int16_t block[12][64]);
void ff_mpv_report_decode_progress(MpegEncContext *s);
int ff_mpv_frame_start(MpegEncContext *s, AVCodecContext *avctx);
void ff_mpv_frame_end(MpegEncContext *s);
int ff_mpv_lowest_referenced_row(MpegEncContext *s, int dir);
int ff_mpv_encode_init(AVCodecContext *avctx);
void ff_mpv_encode_init_x86(MpegEncContext *s);
int ff_mpv_encode_end(AVCodecContext *avctx);
int ff_mpv_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
const AVFrame *frame, int *got_packet);
void ff_clean_intra_table_entries(MpegEncContext *s);
void ff_mpeg_draw_horiz_band(MpegEncContext *s, int y, int h);
void ff_mpeg_flush(AVCodecContext *avctx);
void ff_print_debug_info(MpegEncContext *s, Picture *p, AVFrame *pict);
void ff_print_debug_info2(AVCodecContext *avctx, AVFrame *pict, uint8_t *mbskip_table,
uint32_t *mbtype_table, int8_t *qscale_table, int16_t (*motion_val[2])[2],
int *low_delay,
int mb_width, int mb_height, int mb_stride, int quarter_sample);
int ff_mpv_export_qp_table(MpegEncContext *s, AVFrame *f, Picture *p, int qp_type);
void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix);
int ff_find_unused_picture(MpegEncContext *s, int shared);
int ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src);
void ff_set_qscale(MpegEncContext * s, int qscale);
void ff_mpv_idct_init(MpegEncContext *s);
int ff_dct_encode_init(MpegEncContext *s);
void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64],
const uint16_t *quant_matrix, int bias, int qmin, int qmax, int intra);
int ff_dct_quantize_c(MpegEncContext *s, int16_t *block, int n, int qscale, int *overflow);
void ff_init_block_index(MpegEncContext *s);
void ff_mpv_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb,
uint8_t *dest_cr, int dir,
uint8_t **ref_picture,
op_pixels_func (*pix_op)[4],
qpel_mc_func (*qpix_op)[16]);
int ff_alloc_picture(MpegEncContext *s, Picture *pic, int shared);
void ff_block_permute(int16_t *block, uint8_t *permutation, const uint8_t *scantable, int last);
static inline void ff_update_block_index(MpegEncContext *s){
const int block_size= 8 >> s->avctx->lowres;
s->block_index[0]+=2;
s->block_index[1]+=2;
s->block_index[2]+=2;
s->block_index[3]+=2;
s->block_index[4]++;
s->block_index[5]++;
s->dest[0]+= 2*block_size;
s->dest[1]+= block_size;
s->dest[2]+= block_size;
}
static inline int get_bits_diff(MpegEncContext *s){
const int bits= put_bits_count(&s->pb);
const int last= s->last_bits;
s->last_bits = bits;
return bits - last;
}
static inline int ff_h263_round_chroma(int x){
static const uint8_t h263_chroma_roundtab[16] = {
0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1,
};
return h263_chroma_roundtab[x & 0xf] + (x >> 3);
}
void ff_estimate_p_frame_motion(MpegEncContext * s,
int mb_x, int mb_y);
void ff_estimate_b_frame_motion(MpegEncContext * s,
int mb_x, int mb_y);
int ff_get_best_fcode(MpegEncContext * s, int16_t (*mv_table)[2], int type);
void ff_fix_long_p_mvs(MpegEncContext * s);
void ff_fix_long_mvs(MpegEncContext * s, uint8_t *field_select_table, int field_select,
int16_t (*mv_table)[2], int f_code, int type, int truncate);
int ff_init_me(MpegEncContext *s);
int ff_pre_estimate_p_frame_motion(MpegEncContext * s, int mb_x, int mb_y);
int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr,
int P[10][2], int src_index, int ref_index, int16_t (*last_mv)[2],
int ref_mv_scale, int size, int h);
int ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index,
int ref_index, int size, int h, int add_rate);
extern const uint8_t ff_mpeg1_dc_scale_table[128];
extern const uint8_t * const ff_mpeg2_dc_scale_table[4];
void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number);
void ff_mpeg1_encode_mb(MpegEncContext *s,
int16_t block[8][64],
int motion_x, int motion_y);
void ff_mpeg1_encode_init(MpegEncContext *s);
void ff_mpeg1_encode_slice_header(MpegEncContext *s);
extern const uint8_t ff_aic_dc_scale_table[32];
extern const uint8_t ff_h263_chroma_qscale_table[32];
int ff_rv10_encode_picture_header(MpegEncContext *s, int picture_number);
int ff_rv_decode_dc(MpegEncContext *s, int n);
void ff_rv20_encode_picture_header(MpegEncContext *s, int picture_number);
void ff_msmpeg4_encode_picture_header(MpegEncContext * s, int picture_number);
void ff_msmpeg4_encode_ext_header(MpegEncContext * s);
void ff_msmpeg4_encode_mb(MpegEncContext * s,
int16_t block[6][64],
int motion_x, int motion_y);
int ff_msmpeg4_decode_picture_header(MpegEncContext * s);
int ff_msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size);
int ff_msmpeg4_decode_init(AVCodecContext *avctx);
int ff_msmpeg4_encode_init(MpegEncContext *s);
int ff_wmv2_decode_picture_header(MpegEncContext * s);
int ff_wmv2_decode_secondary_picture_header(MpegEncContext * s);
void ff_wmv2_add_mb(MpegEncContext *s, int16_t block[6][64], uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr);
void ff_mspel_motion(MpegEncContext *s,
uint8_t *dest_y, uint8_t *dest_cb, uint8_t *dest_cr,
uint8_t **ref_picture, op_pixels_func (*pix_op)[4],
int motion_x, int motion_y, int h);
int ff_wmv2_encode_picture_header(MpegEncContext * s, int picture_number);
void ff_wmv2_encode_mb(MpegEncContext * s,
int16_t block[6][64],
int motion_x, int motion_y);
int ff_mpeg_ref_picture(MpegEncContext *s, Picture *dst, Picture *src);
void ff_mpeg_unref_picture(MpegEncContext *s, Picture *picture);
void ff_free_picture_tables(Picture *pic);
#endif