Commit ba6802de authored by Michael Niedermayer's avatar Michael Niedermayer

4MV motion estimation (not finished yet)

SAD functions rewritten (8x8 support & MMX2 optimizations)
HQ inter/intra decission
msmpeg4 encoding bugfix (MV where too long)

Originally committed as revision 362 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 52075cde
......@@ -61,9 +61,14 @@ extern int motion_estimation_method;
#define ME_X1 5
/* encoding support */
/* note not everything is supported yet */
#define CODEC_FLAG_HQ 0x0001 /* high quality (non real time) encoding */
#define CODEC_FLAG_QSCALE 0x0002 /* use fixed qscale */
#define CODEC_FLAG_4MV 0x0004 /* 4 MV per MB allowed */
#define CODEC_FLAG_B 0x0008 /* use B frames */
#define CODEC_FLAG_QPEL 0x0010 /* use qpel MC */
#define CODEC_FLAG_GMC 0x0020 /* use GMC */
/* codec capabilities */
......
This diff is collapsed.
......@@ -66,17 +66,21 @@ extern void (*sub_pixels_tab[4])(DCTELEM *block, const UINT8 *pixels, int line_s
/* motion estimation */
typedef int (*op_pixels_abs_func)(UINT8 *blk1, UINT8 *blk2, int line_size, int h);
typedef int (*op_pixels_abs_func)(UINT8 *blk1, UINT8 *blk2, int line_size);
extern op_pixels_abs_func pix_abs16x16;
extern op_pixels_abs_func pix_abs16x16_x2;
extern op_pixels_abs_func pix_abs16x16_y2;
extern op_pixels_abs_func pix_abs16x16_xy2;
int pix_abs16x16_c(UINT8 *blk1, UINT8 *blk2, int lx, int h);
int pix_abs16x16_x2_c(UINT8 *blk1, UINT8 *blk2, int lx, int h);
int pix_abs16x16_y2_c(UINT8 *blk1, UINT8 *blk2, int lx, int h);
int pix_abs16x16_xy2_c(UINT8 *blk1, UINT8 *blk2, int lx, int h);
extern op_pixels_abs_func pix_abs8x8;
extern op_pixels_abs_func pix_abs8x8_x2;
extern op_pixels_abs_func pix_abs8x8_y2;
extern op_pixels_abs_func pix_abs8x8_xy2;
int pix_abs16x16_c(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_x2_c(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_y2_c(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_xy2_c(UINT8 *blk1, UINT8 *blk2, int lx);
static inline int block_permute_op(int j)
{
......
......@@ -469,14 +469,8 @@ void h263_encode_mb(MpegEncContext * s,
}
/* encode each block */
if (s->h263_pred) {
for (i = 0; i < 6; i++) {
// mpeg4_encode_block(s, block[i], i);
}
} else {
for (i = 0; i < 6; i++) {
h263_encode_block(s, block[i], i);
}
for (i = 0; i < 6; i++) {
h263_encode_block(s, block[i], i);
}
}
......@@ -778,8 +772,8 @@ void h263_encode_init(MpegEncContext *s)
s->mv_penalty= mv_penalty; //FIXME exact table for msmpeg4 & h263p
// use fcodes >1 only for mpeg4 & h263 & h263p FIXME
if(s->h263_plus) s->fcode_tab= umv_fcode_tab;
else if(s->h263_pred) s->fcode_tab= fcode_tab;
if(s->h263_plus) s->fcode_tab= umv_fcode_tab;
else if(s->h263_pred && !s->h263_msmpeg4) s->fcode_tab= fcode_tab;
}
static void h263_encode_block(MpegEncContext * s, DCTELEM * block, int n)
......
......@@ -24,19 +24,34 @@
int mm_flags; /* multimedia extension flags */
int pix_abs16x16_mmx(UINT8 *blk1, UINT8 *blk2, int lx, int h);
int pix_abs16x16_sse(UINT8 *blk1, UINT8 *blk2, int lx, int h);
int pix_abs16x16_x2_mmx(UINT8 *blk1, UINT8 *blk2, int lx, int h);
int pix_abs16x16_y2_mmx(UINT8 *blk1, UINT8 *blk2, int lx, int h);
int pix_abs16x16_xy2_mmx(UINT8 *blk1, UINT8 *blk2, int lx, int h);
int pix_abs16x16_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_x2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_y2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_xy2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_x2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_y2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs16x16_xy2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs8x8_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs8x8_x2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs8x8_y2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs8x8_xy2_mmx(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs8x8_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs8x8_x2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs8x8_y2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
int pix_abs8x8_xy2_mmx2(UINT8 *blk1, UINT8 *blk2, int lx);
/* external functions, from idct_mmx.c */
void ff_mmx_idct(DCTELEM *block);
void ff_mmxext_idct(DCTELEM *block);
/* pixel operations */
static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001;
static const unsigned long long int mm_wtwo __attribute__ ((aligned(8))) = 0x0002000200020002;
static const unsigned long long int mm_wone __attribute__ ((aligned(8))) = 0x0001000100010001LL;
static const unsigned long long int mm_wtwo __attribute__ ((aligned(8))) = 0x0002000200020002LL;
//static const unsigned short mm_wone[4] __attribute__ ((aligned(8))) = { 0x1, 0x1, 0x1, 0x1 };
//static const unsigned short mm_wtwo[4] __attribute__ ((aligned(8))) = { 0x2, 0x2, 0x2, 0x2 };
......@@ -1035,10 +1050,14 @@ void dsputil_init_mmx(void)
put_pixels_clamped = put_pixels_clamped_mmx;
add_pixels_clamped = add_pixels_clamped_mmx;
pix_abs16x16 = pix_abs16x16_mmx;
pix_abs16x16_x2 = pix_abs16x16_x2_mmx;
pix_abs16x16_y2 = pix_abs16x16_y2_mmx;
pix_abs16x16 = pix_abs16x16_mmx;
pix_abs16x16_x2 = pix_abs16x16_x2_mmx;
pix_abs16x16_y2 = pix_abs16x16_y2_mmx;
pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx;
pix_abs8x8 = pix_abs8x8_mmx;
pix_abs8x8_x2 = pix_abs8x8_x2_mmx;
pix_abs8x8_y2 = pix_abs8x8_y2_mmx;
pix_abs8x8_xy2= pix_abs8x8_xy2_mmx;
av_fdct = fdct_mmx;
put_pixels_tab[0] = put_pixels_mmx;
......@@ -1067,10 +1086,16 @@ void dsputil_init_mmx(void)
sub_pixels_tab[3] = sub_pixels_xy2_mmx;
if (mm_flags & MM_MMXEXT) {
pix_abs16x16 = pix_abs16x16_sse;
}
if (mm_flags & MM_SSE) {
pix_abs16x16 = pix_abs16x16_mmx2;
pix_abs16x16_x2 = pix_abs16x16_x2_mmx2;
pix_abs16x16_y2 = pix_abs16x16_y2_mmx2;
pix_abs16x16_xy2= pix_abs16x16_xy2_mmx2;
pix_abs8x8 = pix_abs8x8_mmx2;
pix_abs8x8_x2 = pix_abs8x8_x2_mmx2;
pix_abs8x8_y2 = pix_abs8x8_y2_mmx2;
pix_abs8x8_xy2= pix_abs8x8_xy2_mmx2;
put_pixels_tab[1] = put_pixels_x2_sse;
put_pixels_tab[2] = put_pixels_y2_sse;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -65,7 +65,7 @@ typedef struct MpegEncContext {
int qmax; /* max qscale */
int max_qdiff; /* max qscale difference between frames */
int encoding; /* true if we are encoding (vs decoding) */
int hq; /* set if CODEC_FLAG_HQ is used in AVCodecContext.flags */
int flags; /* AVCodecContext.flags (HQ, MV4, ...) */
/* the following fields are managed internally by the encoder */
/* bit output */
......@@ -141,8 +141,16 @@ typedef struct MpegEncContext {
int mb_x, mb_y;
int mb_incr;
int mb_intra;
INT16 *mb_var; /* Table for MB variances */
char *mb_type; /* Table for MB type */
UINT16 *mb_var; /* Table for MB variances */
UINT8 *mb_type; /* Table for MB type */
#define MB_TYPE_INTRA 0x01
#define MB_TYPE_INTER 0x02
#define MB_TYPE_INTER4V 0x04
#define MB_TYPE_SKIPED 0x08
#define MB_TYPE_DIRECT 0x10
#define MB_TYPE_FORWARD 0x20
#define MB_TYPE_BACKWAD 0x40
#define MB_TYPE_BIDIR 0x80
int block_index[6];
int block_wrap[6];
......@@ -295,7 +303,10 @@ typedef struct MpegEncContext {
UINT8 *ptr_last_mb_line;
UINT32 mb_line_avgsize;
DCTELEM block[6][64] __align8;
DCTELEM (*block)[64]; /* points to one of the following blocks */
DCTELEM intra_block[6][64] __align8;
DCTELEM inter_block[6][64] __align8;
DCTELEM inter4v_block[6][64] __align8;
void (*dct_unquantize)(struct MpegEncContext *s,
DCTELEM *block, int n, int qscale);
} MpegEncContext;
......@@ -311,9 +322,8 @@ void MPV_common_init_mmx(MpegEncContext *s);
/* motion_est.c */
int estimate_motion(MpegEncContext *s,
int mb_x, int mb_y,
int *mx_ptr, int *my_ptr);
void estimate_motion(MpegEncContext *s,
int mb_x, int mb_y);
/* mpeg12.c */
extern INT16 default_intra_matrix[64];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment