1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

put/avg_pixels16

fixing 2 small qpel bugs

Originally committed as revision 915 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2002-09-11 12:39:53 +00:00
parent 6b460aa387
commit b318477992
8 changed files with 957 additions and 398 deletions

File diff suppressed because it is too large Load Diff

View File

@ -74,14 +74,22 @@ void clear_blocks_c(DCTELEM *blocks);
/* add and put pixel (decoding) */
typedef void (*op_pixels_func)(UINT8 *block, const UINT8 *pixels, int line_size, int h);
typedef void (*qpel_mc_func)(UINT8 *dst, UINT8 *src, int dstStride, int srcStride, int mx, int my);
typedef void (*qpel_mc_func)(UINT8 *dst, UINT8 *src, int stride);
extern op_pixels_func put_pixels_tab[4];
extern op_pixels_func avg_pixels_tab[4];
extern op_pixels_func put_no_rnd_pixels_tab[4];
extern op_pixels_func avg_no_rnd_pixels_tab[4];
extern qpel_mc_func qpel_mc_rnd_tab[16];
extern qpel_mc_func qpel_mc_no_rnd_tab[16];
extern op_pixels_func put_pixels_tab[2][4];
extern op_pixels_func avg_pixels_tab[2][4];
extern op_pixels_func put_no_rnd_pixels_tab[2][4];
extern op_pixels_func avg_no_rnd_pixels_tab[2][4];
extern qpel_mc_func put_qpel_pixels_tab[2][16];
extern qpel_mc_func avg_qpel_pixels_tab[2][16];
extern qpel_mc_func put_no_rnd_qpel_pixels_tab[2][16];
extern qpel_mc_func avg_no_rnd_qpel_pixels_tab[2][16];
#define CALL_2X_PIXELS(a, b, n)\
static void a(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
b(block , pixels , line_size, h);\
b(block+n, pixels+n, line_size, h);\
}
/* motion estimation */

View File

@ -343,7 +343,7 @@ static void add_pixels_clamped_mmx(const DCTELEM *block, UINT8 *pixels, int line
} while (--i);
}
static void put_pixels_mmx(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void put_pixels8_mmx(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@ -369,6 +369,40 @@ static void put_pixels_mmx(UINT8 *block, const UINT8 *pixels, int line_size, int
);
}
static void put_pixels16_mmx(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
".balign 8 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq 8(%1), %%mm4 \n\t"
"movq (%1, %3), %%mm1 \n\t"
"movq 8(%1, %3), %%mm5 \n\t"
"movq %%mm0, (%2) \n\t"
"movq %%mm4, 8(%2) \n\t"
"movq %%mm1, (%2, %3) \n\t"
"movq %%mm5, 8(%2, %3) \n\t"
"addl %%eax, %1 \n\t"
"addl %%eax, %2 \n\t"
"movq (%1), %%mm0 \n\t"
"movq 8(%1), %%mm4 \n\t"
"movq (%1, %3), %%mm1 \n\t"
"movq 8(%1, %3), %%mm5 \n\t"
"movq %%mm0, (%2) \n\t"
"movq %%mm4, 8(%2) \n\t"
"movq %%mm1, (%2, %3) \n\t"
"movq %%mm5, 8(%2, %3) \n\t"
"addl %%eax, %1 \n\t"
"addl %%eax, %2 \n\t"
"subl $4, %0 \n\t"
"jnz 1b \n\t"
: "+g"(h), "+r" (pixels), "+r" (block)
: "r"(line_size)
: "%eax", "memory"
);
}
static void clear_blocks_mmx(DCTELEM *blocks)
{
__asm __volatile(
@ -424,25 +458,45 @@ void dsputil_init_mmx(void)
pix_abs8x8_y2 = pix_abs8x8_y2_mmx;
pix_abs8x8_xy2= pix_abs8x8_xy2_mmx;
put_pixels_tab[0] = put_pixels_mmx;
put_pixels_tab[1] = put_pixels_x2_mmx;
put_pixels_tab[2] = put_pixels_y2_mmx;
put_pixels_tab[3] = put_pixels_xy2_mmx;
put_pixels_tab[0][0] = put_pixels16_mmx;
put_pixels_tab[0][1] = put_pixels16_x2_mmx;
put_pixels_tab[0][2] = put_pixels16_y2_mmx;
put_pixels_tab[0][3] = put_pixels16_xy2_mmx;
put_no_rnd_pixels_tab[0] = put_pixels_mmx;
put_no_rnd_pixels_tab[1] = put_no_rnd_pixels_x2_mmx;
put_no_rnd_pixels_tab[2] = put_no_rnd_pixels_y2_mmx;
put_no_rnd_pixels_tab[3] = put_no_rnd_pixels_xy2_mmx;
put_no_rnd_pixels_tab[0][0] = put_pixels16_mmx;
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx;
put_no_rnd_pixels_tab[0][3] = put_no_rnd_pixels16_xy2_mmx;
avg_pixels_tab[0] = avg_pixels_mmx;
avg_pixels_tab[1] = avg_pixels_x2_mmx;
avg_pixels_tab[2] = avg_pixels_y2_mmx;
avg_pixels_tab[3] = avg_pixels_xy2_mmx;
avg_pixels_tab[0][0] = avg_pixels16_mmx;
avg_pixels_tab[0][1] = avg_pixels16_x2_mmx;
avg_pixels_tab[0][2] = avg_pixels16_y2_mmx;
avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx;
avg_no_rnd_pixels_tab[0] = avg_no_rnd_pixels_mmx;
avg_no_rnd_pixels_tab[1] = avg_no_rnd_pixels_x2_mmx;
avg_no_rnd_pixels_tab[2] = avg_no_rnd_pixels_y2_mmx;
avg_no_rnd_pixels_tab[3] = avg_no_rnd_pixels_xy2_mmx;
avg_no_rnd_pixels_tab[0][0] = avg_no_rnd_pixels16_mmx;
avg_no_rnd_pixels_tab[0][1] = avg_no_rnd_pixels16_x2_mmx;
avg_no_rnd_pixels_tab[0][2] = avg_no_rnd_pixels16_y2_mmx;
avg_no_rnd_pixels_tab[0][3] = avg_no_rnd_pixels16_xy2_mmx;
put_pixels_tab[1][0] = put_pixels8_mmx;
put_pixels_tab[1][1] = put_pixels8_x2_mmx;
put_pixels_tab[1][2] = put_pixels8_y2_mmx;
put_pixels_tab[1][3] = put_pixels8_xy2_mmx;
put_no_rnd_pixels_tab[1][0] = put_pixels8_mmx;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx;
put_no_rnd_pixels_tab[1][3] = put_no_rnd_pixels8_xy2_mmx;
avg_pixels_tab[1][0] = avg_pixels8_mmx;
avg_pixels_tab[1][1] = avg_pixels8_x2_mmx;
avg_pixels_tab[1][2] = avg_pixels8_y2_mmx;
avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx;
avg_no_rnd_pixels_tab[1][0] = avg_no_rnd_pixels8_mmx;
avg_no_rnd_pixels_tab[1][1] = avg_no_rnd_pixels8_x2_mmx;
avg_no_rnd_pixels_tab[1][2] = avg_no_rnd_pixels8_y2_mmx;
avg_no_rnd_pixels_tab[1][3] = avg_no_rnd_pixels8_xy2_mmx;
if (mm_flags & MM_MMXEXT) {
pix_abs16x16 = pix_abs16x16_mmx2;
@ -455,25 +509,45 @@ void dsputil_init_mmx(void)
pix_abs8x8_y2 = pix_abs8x8_y2_mmx2;
pix_abs8x8_xy2= pix_abs8x8_xy2_mmx2;
put_pixels_tab[1] = put_pixels_x2_mmx2;
put_pixels_tab[2] = put_pixels_y2_mmx2;
put_no_rnd_pixels_tab[1] = put_no_rnd_pixels_x2_mmx2;
put_no_rnd_pixels_tab[2] = put_no_rnd_pixels_y2_mmx2;
put_pixels_tab[0][1] = put_pixels16_x2_mmx2;
put_pixels_tab[0][2] = put_pixels16_y2_mmx2;
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx2;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx2;
avg_pixels_tab[0] = avg_pixels_mmx2;
avg_pixels_tab[1] = avg_pixels_x2_mmx2;
avg_pixels_tab[2] = avg_pixels_y2_mmx2;
avg_pixels_tab[3] = avg_pixels_xy2_mmx2;
avg_pixels_tab[0][0] = avg_pixels16_mmx2;
avg_pixels_tab[0][1] = avg_pixels16_x2_mmx2;
avg_pixels_tab[0][2] = avg_pixels16_y2_mmx2;
avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx2;
put_pixels_tab[1][1] = put_pixels8_x2_mmx2;
put_pixels_tab[1][2] = put_pixels8_y2_mmx2;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx2;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx2;
avg_pixels_tab[1][0] = avg_pixels8_mmx2;
avg_pixels_tab[1][1] = avg_pixels8_x2_mmx2;
avg_pixels_tab[1][2] = avg_pixels8_y2_mmx2;
avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx2;
} else if (mm_flags & MM_3DNOW) {
put_pixels_tab[1] = put_pixels_x2_3dnow;
put_pixels_tab[2] = put_pixels_y2_3dnow;
put_no_rnd_pixels_tab[1] = put_no_rnd_pixels_x2_3dnow;
put_no_rnd_pixels_tab[2] = put_no_rnd_pixels_y2_3dnow;
put_pixels_tab[0][1] = put_pixels16_x2_3dnow;
put_pixels_tab[0][2] = put_pixels16_y2_3dnow;
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_3dnow;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_3dnow;
avg_pixels_tab[0] = avg_pixels_3dnow;
avg_pixels_tab[1] = avg_pixels_x2_3dnow;
avg_pixels_tab[2] = avg_pixels_y2_3dnow;
avg_pixels_tab[3] = avg_pixels_xy2_3dnow;
avg_pixels_tab[0][0] = avg_pixels16_3dnow;
avg_pixels_tab[0][1] = avg_pixels16_x2_3dnow;
avg_pixels_tab[0][2] = avg_pixels16_y2_3dnow;
avg_pixels_tab[0][3] = avg_pixels16_xy2_3dnow;
put_pixels_tab[1][1] = put_pixels8_x2_3dnow;
put_pixels_tab[1][2] = put_pixels8_y2_3dnow;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_3dnow;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_3dnow;
avg_pixels_tab[1][0] = avg_pixels8_3dnow;
avg_pixels_tab[1][1] = avg_pixels8_x2_3dnow;
avg_pixels_tab[1][2] = avg_pixels8_y2_3dnow;
avg_pixels_tab[1][3] = avg_pixels8_xy2_3dnow;
}
/* idct */
@ -552,21 +626,22 @@ void bit_exact_idct_put(UINT8 *dest, int line_size, INT16 *block){
void dsputil_set_bit_exact_mmx(void)
{
if (mm_flags & MM_MMX) {
if (mm_flags & MM_MMXEXT) {
put_no_rnd_pixels_tab[1] = put_no_rnd_pixels_x2_mmx;
put_no_rnd_pixels_tab[2] = put_no_rnd_pixels_y2_mmx;
avg_pixels_tab[3] = avg_pixels_xy2_mmx;
/* MMX2 & 3DNOW */
put_no_rnd_pixels_tab[0][1] = put_no_rnd_pixels16_x2_mmx;
put_no_rnd_pixels_tab[0][2] = put_no_rnd_pixels16_y2_mmx;
avg_pixels_tab[0][3] = avg_pixels16_xy2_mmx;
put_no_rnd_pixels_tab[1][1] = put_no_rnd_pixels8_x2_mmx;
put_no_rnd_pixels_tab[1][2] = put_no_rnd_pixels8_y2_mmx;
avg_pixels_tab[1][3] = avg_pixels8_xy2_mmx;
if (mm_flags & MM_MMXEXT) {
pix_abs16x16_x2 = pix_abs16x16_x2_mmx;
pix_abs16x16_y2 = pix_abs16x16_y2_mmx;
pix_abs16x16_xy2 = pix_abs16x16_xy2_mmx;
pix_abs8x8_x2 = pix_abs8x8_x2_mmx;
pix_abs8x8_y2 = pix_abs8x8_y2_mmx;
pix_abs8x8_xy2= pix_abs8x8_xy2_mmx;
} else if (mm_flags & MM_3DNOW) {
put_no_rnd_pixels_tab[1] = put_no_rnd_pixels_x2_mmx;
put_no_rnd_pixels_tab[2] = put_no_rnd_pixels_y2_mmx;
avg_pixels_tab[3] = avg_pixels_xy2_mmx;
}
#ifdef SIMPLE_IDCT
if(ff_idct_put==gen_idct_put && ff_idct == simple_idct_mmx)

View File

@ -25,7 +25,7 @@
/* XXX: we use explicit registers to avoid a gcc 2.95.2 register asm
clobber bug - now it will work with 2.95.2 and also with -fPIC
*/
static void DEF(put_pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(put_pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@ -52,9 +52,49 @@ static void DEF(put_pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size,
:"r" (line_size)
:"%eax", "memory");
}
static void DEF(put_pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq (%1, %3), %%mm1 \n\t"
"movq 8(%1), %%mm2 \n\t"
"movq 8(%1, %3), %%mm3 \n\t"
PAVGB" 1(%1), %%mm0 \n\t"
PAVGB" 1(%1, %3), %%mm1 \n\t"
PAVGB" 9(%1), %%mm2 \n\t"
PAVGB" 9(%1, %3), %%mm3 \n\t"
"movq %%mm0, (%2) \n\t"
"movq %%mm1, (%2, %3) \n\t"
"movq %%mm2, 8(%2) \n\t"
"movq %%mm3, 8(%2, %3) \n\t"
"addl %%eax, %1 \n\t"
"addl %%eax, %2 \n\t"
"movq (%1), %%mm0 \n\t"
"movq (%1, %3), %%mm1 \n\t"
"movq 8(%1), %%mm2 \n\t"
"movq 8(%1, %3), %%mm3 \n\t"
PAVGB" 1(%1), %%mm0 \n\t"
PAVGB" 1(%1, %3), %%mm1 \n\t"
PAVGB" 9(%1), %%mm2 \n\t"
PAVGB" 9(%1, %3), %%mm3 \n\t"
"addl %%eax, %1 \n\t"
"movq %%mm0, (%2) \n\t"
"movq %%mm1, (%2, %3) \n\t"
"movq %%mm2, 8(%2) \n\t"
"movq %%mm3, 8(%2, %3) \n\t"
"addl %%eax, %2 \n\t"
"subl $4, %0 \n\t"
"jnz 1b \n\t"
:"+g"(h), "+S"(pixels), "+D"(block)
:"r" (line_size)
:"%eax", "memory");
}
/* GL: this function does incorrect rounding if overflow */
static void DEF(put_no_rnd_pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(put_no_rnd_pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BONE(mm6);
__asm __volatile(
@ -91,7 +131,7 @@ static void DEF(put_no_rnd_pixels_x2)(UINT8 *block, const UINT8 *pixels, int lin
:"%eax", "memory");
}
static void DEF(put_pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(put_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@ -122,7 +162,7 @@ static void DEF(put_pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size,
}
/* GL: this function does incorrect rounding if overflow */
static void DEF(put_no_rnd_pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(put_no_rnd_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BONE(mm6);
__asm __volatile(
@ -155,7 +195,7 @@ static void DEF(put_no_rnd_pixels_y2)(UINT8 *block, const UINT8 *pixels, int lin
:"%eax", "memory");
}
static void DEF(avg_pixels)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(avg_pixels8)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@ -183,7 +223,7 @@ static void DEF(avg_pixels)(UINT8 *block, const UINT8 *pixels, int line_size, in
:"%eax", "memory");
}
static void DEF(avg_pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(avg_pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@ -215,7 +255,7 @@ static void DEF(avg_pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size,
:"%eax", "memory");
}
static void DEF(avg_pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(avg_pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
@ -254,7 +294,7 @@ static void DEF(avg_pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size,
}
// Note this is not correctly rounded, but this function is only used for b frames so it doesnt matter
static void DEF(avg_pixels_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(avg_pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BONE(mm6);
__asm __volatile(
@ -294,3 +334,34 @@ static void DEF(avg_pixels_xy2)(UINT8 *block, const UINT8 *pixels, int line_size
:"r" (line_size)
:"%eax", "memory");
}
//FIXME the following could be optimized too ...
static void DEF(put_no_rnd_pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(put_no_rnd_pixels8_x2)(block , pixels , line_size, h);
DEF(put_no_rnd_pixels8_x2)(block+8, pixels+8, line_size, h);
}
static void DEF(put_pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(put_pixels8_y2)(block , pixels , line_size, h);
DEF(put_pixels8_y2)(block+8, pixels+8, line_size, h);
}
static void DEF(put_no_rnd_pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(put_no_rnd_pixels8_y2)(block , pixels , line_size, h);
DEF(put_no_rnd_pixels8_y2)(block+8, pixels+8, line_size, h);
}
static void DEF(avg_pixels16)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(avg_pixels8)(block , pixels , line_size, h);
DEF(avg_pixels8)(block+8, pixels+8, line_size, h);
}
static void DEF(avg_pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(avg_pixels8_x2)(block , pixels , line_size, h);
DEF(avg_pixels8_x2)(block+8, pixels+8, line_size, h);
}
static void DEF(avg_pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(avg_pixels8_y2)(block , pixels , line_size, h);
DEF(avg_pixels8_y2)(block+8, pixels+8, line_size, h);
}
static void DEF(avg_pixels16_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(avg_pixels8_xy2)(block , pixels , line_size, h);
DEF(avg_pixels8_xy2)(block+8, pixels+8, line_size, h);
}

View File

@ -22,7 +22,7 @@
*/
// put_pixels
static void DEF(put, pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(put, pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
__asm __volatile(
@ -54,7 +54,53 @@ static void DEF(put, pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size
:"eax", "memory");
}
static void DEF(put, pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(put, pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
__asm __volatile(
"lea (%3, %3), %%eax \n\t"
".balign 8 \n\t"
"1: \n\t"
"movq (%1), %%mm0 \n\t"
"movq 1(%1), %%mm1 \n\t"
"movq (%1, %3), %%mm2 \n\t"
"movq 1(%1, %3), %%mm3 \n\t"
PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
"movq %%mm4, (%2) \n\t"
"movq %%mm5, (%2, %3) \n\t"
"movq 8(%1), %%mm0 \n\t"
"movq 9(%1), %%mm1 \n\t"
"movq 8(%1, %3), %%mm2 \n\t"
"movq 9(%1, %3), %%mm3 \n\t"
PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
"movq %%mm4, 8(%2) \n\t"
"movq %%mm5, 8(%2, %3) \n\t"
"addl %%eax, %1 \n\t"
"addl %%eax, %2 \n\t"
"movq (%1), %%mm0 \n\t"
"movq 1(%1), %%mm1 \n\t"
"movq (%1, %3), %%mm2 \n\t"
"movq 1(%1, %3), %%mm3 \n\t"
PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
"movq %%mm4, (%2) \n\t"
"movq %%mm5, (%2, %3) \n\t"
"movq 8(%1), %%mm0 \n\t"
"movq 9(%1), %%mm1 \n\t"
"movq 8(%1, %3), %%mm2 \n\t"
"movq 9(%1, %3), %%mm3 \n\t"
PAVGBP(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
"movq %%mm4, 8(%2) \n\t"
"movq %%mm5, 8(%2, %3) \n\t"
"addl %%eax, %1 \n\t"
"addl %%eax, %2 \n\t"
"subl $4, %0 \n\t"
"jnz 1b \n\t"
:"+g"(h), "+S"(pixels), "+D"(block)
:"r"(line_size)
:"eax", "memory");
}
static void DEF(put, pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
__asm __volatile(
@ -83,7 +129,7 @@ static void DEF(put, pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size
:"eax", "memory");
}
static void DEF(put, pixels_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(put, pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_ZERO(mm7);
SET_RND(mm6); // =2 for rnd and =1 for no_rnd version
@ -151,7 +197,7 @@ static void DEF(put, pixels_xy2)(UINT8 *block, const UINT8 *pixels, int line_siz
// avg_pixels
// in case more speed is needed - unroling would certainly help
static void DEF(avg, pixels)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(avg, pixels8)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
@ -170,7 +216,30 @@ static void DEF(avg, pixels)(UINT8 *block, const UINT8 *pixels, int line_size, i
while (--h);
}
static void DEF(avg, pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(avg, pixels16)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
do {
__asm __volatile(
"movq %0, %%mm0 \n\t"
"movq %1, %%mm1 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
"movq %%mm2, %0 \n\t"
"movq 8%0, %%mm0 \n\t"
"movq 8%1, %%mm1 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
"movq %%mm2, 8%0 \n\t"
:"+m"(*block)
:"m"(*pixels)
:"memory");
pixels += line_size;
block += line_size;
}
while (--h);
}
static void DEF(avg, pixels8_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
@ -190,7 +259,33 @@ static void DEF(avg, pixels_x2)(UINT8 *block, const UINT8 *pixels, int line_size
} while (--h);
}
static void DEF(avg, pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(avg, pixels16_x2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
JUMPALIGN();
do {
__asm __volatile(
"movq %1, %%mm0 \n\t"
"movq 1%1, %%mm1 \n\t"
"movq %0, %%mm3 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
"movq %%mm0, %0 \n\t"
"movq 8%1, %%mm0 \n\t"
"movq 9%1, %%mm1 \n\t"
"movq 8%0, %%mm3 \n\t"
PAVGB(%%mm0, %%mm1, %%mm2, %%mm6)
PAVGB(%%mm3, %%mm2, %%mm0, %%mm6)
"movq %%mm0, 8%0 \n\t"
:"+m"(*block)
:"m"(*pixels)
:"memory");
pixels += line_size;
block += line_size;
} while (--h);
}
static void DEF(avg, pixels8_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_BFE(mm6);
__asm __volatile(
@ -230,7 +325,7 @@ static void DEF(avg, pixels_y2)(UINT8 *block, const UINT8 *pixels, int line_size
}
// this routine is 'slightly' suboptimal but mostly unused
static void DEF(avg, pixels_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
static void DEF(avg, pixels8_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h)
{
MOVQ_ZERO(mm7);
SET_RND(mm6); // =2 for rnd and =1 for no_rnd version
@ -303,3 +398,26 @@ static void DEF(avg, pixels_xy2)(UINT8 *block, const UINT8 *pixels, int line_siz
:"D"(block), "r"(line_size)
:"eax", "memory");
}
//FIXME optimize
static void DEF(put, pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(put, pixels8_y2)(block , pixels , line_size, h);
DEF(put, pixels8_y2)(block+8, pixels+8, line_size, h);
}
static void DEF(put, pixels16_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(put, pixels8_xy2)(block , pixels , line_size, h);
DEF(put, pixels8_xy2)(block+8, pixels+8, line_size, h);
}
static void DEF(avg, pixels16_y2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(avg, pixels8_y2)(block , pixels , line_size, h);
DEF(avg, pixels8_y2)(block+8, pixels+8, line_size, h);
}
static void DEF(avg, pixels16_xy2)(UINT8 *block, const UINT8 *pixels, int line_size, int h){
DEF(avg, pixels8_xy2)(block , pixels , line_size, h);
DEF(avg, pixels8_xy2)(block+8, pixels+8, line_size, h);
}

View File

@ -1337,8 +1337,7 @@ static inline int check_bidir_mv(MpegEncContext * s,
src_y = mb_y * 16 + (motion_fy >> 1);
ptr = s->last_picture[0] + (src_y * s->linesize) + src_x;
put_pixels_tab[dxy](dest_y , ptr , s->linesize, 16);
put_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16);
put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
fbmin += (mv_penalty[motion_bx-pred_bx] + mv_penalty[motion_by-pred_by])*s->qscale;
@ -1347,8 +1346,7 @@ static inline int check_bidir_mv(MpegEncContext * s,
src_y = mb_y * 16 + (motion_by >> 1);
ptr = s->next_picture[0] + (src_y * s->linesize) + src_x;
avg_pixels_tab[dxy](dest_y , ptr , s->linesize, 16);
avg_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16);
avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
fbmin += pix_abs16x16(s->new_picture[0] + mb_x*16 + mb_y*16*s->linesize, dest_y, s->linesize);
return fbmin;
@ -1433,8 +1431,7 @@ static inline int direct_search(MpegEncContext * s,
if (src_y == height) dxy &= ~2;
ptr = s->last_picture[0] + (src_y * s->linesize) + src_x;
put_pixels_tab[dxy](dest_y , ptr , s->linesize, 16);
put_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16);
put_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
dxy = ((motion_by & 1) << 1) | (motion_bx & 1);
src_x = (mb_x + bx) * 16 + (motion_bx >> 1);
@ -1444,8 +1441,7 @@ static inline int direct_search(MpegEncContext * s,
src_y = clip(src_y, -16, height);
if (src_y == height) dxy &= ~2;
avg_pixels_tab[dxy](dest_y , ptr , s->linesize, 16);
avg_pixels_tab[dxy](dest_y + 8, ptr + 8, s->linesize, 16);
avg_pixels_tab[0][dxy](dest_y , ptr , s->linesize, 16);
}
}

View File

@ -1063,18 +1063,19 @@ static inline void mpeg_motion(MpegEncContext *s,
UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
int dest_offset,
UINT8 **ref_picture, int src_offset,
int field_based, op_pixels_func *pix_op,
int field_based, op_pixels_func (*pix_op)[4],
int motion_x, int motion_y, int h)
{
UINT8 *ptr;
int dxy, offset, mx, my, src_x, src_y, height, v_edge_pos, linesize, uvlinesize;
int emu=0;
#if 0
if(s->quarter_sample)
{
motion_x>>=1;
motion_y>>=1;
}
#endif
dxy = ((motion_y & 1) << 1) | (motion_x & 1);
src_x = s->mb_x * 16 + (motion_x >> 1);
src_y = s->mb_y * (16 >> field_based) + (motion_y >> 1);
@ -1101,8 +1102,7 @@ if(s->quarter_sample)
emu=1;
}
}
pix_op[dxy](dest_y, ptr, linesize, h);
pix_op[dxy](dest_y + 8, ptr + 8, linesize, h);
pix_op[0][dxy](dest_y, ptr, linesize, h);
if(s->flags&CODEC_FLAG_GRAY) return;
@ -1136,22 +1136,22 @@ if(s->quarter_sample)
emulated_edge_mc(s, ptr, uvlinesize, 9, (h>>1)+1, src_x, src_y, s->h_edge_pos>>1, v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, uvlinesize, h >> 1);
pix_op[1][dxy](dest_cb + (dest_offset >> 1), ptr, uvlinesize, h >> 1);
ptr = ref_picture[2] + offset;
if(emu){
emulated_edge_mc(s, ptr, uvlinesize, 9, (h>>1)+1, src_x, src_y, s->h_edge_pos>>1, v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, uvlinesize, h >> 1);
pix_op[1][dxy](dest_cr + (dest_offset >> 1), ptr, uvlinesize, h >> 1);
}
static inline void qpel_motion(MpegEncContext *s,
UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
int dest_offset,
UINT8 **ref_picture, int src_offset,
int field_based, op_pixels_func *pix_op,
qpel_mc_func *qpix_op,
int field_based, op_pixels_func (*pix_op)[4],
qpel_mc_func (*qpix_op)[16],
int motion_x, int motion_y, int h)
{
UINT8 *ptr;
@ -1183,11 +1183,8 @@ static inline void qpel_motion(MpegEncContext *s,
emu=1;
}
}
qpix_op[dxy](dest_y , ptr , linesize, linesize, motion_x&3, motion_y&3);
qpix_op[dxy](dest_y + 8, ptr + 8, linesize, linesize, motion_x&3, motion_y&3);
qpix_op[dxy](dest_y + linesize*8 , ptr + linesize*8 , linesize, linesize, motion_x&3, motion_y&3);
qpix_op[dxy](dest_y + linesize*8 + 8, ptr + linesize*8 + 8, linesize, linesize, motion_x&3, motion_y&3);
qpix_op[0][dxy](dest_y, ptr, linesize);
if(s->flags&CODEC_FLAG_GRAY) return;
mx= (motion_x>>1) | (motion_x&1);
@ -1216,21 +1213,21 @@ static inline void qpel_motion(MpegEncContext *s,
emulated_edge_mc(s, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->h_edge_pos>>1, v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[dxy](dest_cb + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1);
pix_op[1][dxy](dest_cb + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1);
ptr = ref_picture[2] + offset;
if(emu){
emulated_edge_mc(s, ptr, s->uvlinesize, 9, (h>>1)+1, src_x, src_y, s->h_edge_pos>>1, v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[dxy](dest_cr + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1);
pix_op[1][dxy](dest_cr + (dest_offset >> 1), ptr, s->uvlinesize, h >> 1);
}
static inline void MPV_motion(MpegEncContext *s,
UINT8 *dest_y, UINT8 *dest_cb, UINT8 *dest_cr,
int dir, UINT8 **ref_picture,
op_pixels_func *pix_op, qpel_mc_func *qpix_op)
op_pixels_func (*pix_op)[4], qpel_mc_func (*qpix_op)[16])
{
int dxy, offset, mx, my, src_x, src_y, motion_x, motion_y;
int mb_x, mb_y, i;
@ -1243,19 +1240,10 @@ static inline void MPV_motion(MpegEncContext *s,
switch(s->mv_type) {
case MV_TYPE_16X16:
if(s->mcsel){
#if 0
mpeg_motion(s, dest_y, dest_cb, dest_cr, 0,
ref_picture, 0,
0, pix_op,
s->sprite_offset[0][0]>>3,
s->sprite_offset[0][1]>>3,
16);
#else
gmc1_motion(s, dest_y, dest_cb, dest_cr, 0,
ref_picture, 0,
16);
#endif
}else if(s->quarter_sample && dir==0){ //FIXME
}else if(s->quarter_sample){
qpel_motion(s, dest_y, dest_cb, dest_cr, 0,
ref_picture, 0,
0, pix_op, qpix_op,
@ -1293,7 +1281,7 @@ static inline void MPV_motion(MpegEncContext *s,
}
}
dest = dest_y + ((i & 1) * 8) + (i >> 1) * 8 * s->linesize;
pix_op[dxy](dest, ptr, s->linesize, 8);
pix_op[1][dxy](dest, ptr, s->linesize, 8);
}
if(s->flags&CODEC_FLAG_GRAY) break;
@ -1340,14 +1328,14 @@ static inline void MPV_motion(MpegEncContext *s,
emu=1;
}
}
pix_op[dxy](dest_cb, ptr, s->uvlinesize, 8);
pix_op[1][dxy](dest_cb, ptr, s->uvlinesize, 8);
ptr = ref_picture[2] + offset;
if(emu){
emulated_edge_mc(s, ptr, s->uvlinesize, 9, 9, src_x, src_y, s->h_edge_pos>>1, s->v_edge_pos>>1);
ptr= s->edge_emu_buffer;
}
pix_op[dxy](dest_cr, ptr, s->uvlinesize, 8);
pix_op[1][dxy](dest_cr, ptr, s->uvlinesize, 8);
break;
case MV_TYPE_FIELD:
if (s->picture_structure == PICT_FRAME) {
@ -1510,8 +1498,8 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
if (!(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) {
UINT8 *dest_y, *dest_cb, *dest_cr;
int dct_linesize, dct_offset;
op_pixels_func *op_pix;
qpel_mc_func *op_qpix;
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
/* avoid copy if macroblock skipped in last frame too
dont touch it for B-frames as they need the skip info from the next p-frame */
@ -1550,18 +1538,16 @@ void MPV_decode_mb(MpegEncContext *s, DCTELEM block[6][64])
if((!s->encoding) || (s->mb_type[mb_xy]&(s->mb_type[mb_xy]-1))){
if ((!s->no_rounding) || s->pict_type==B_TYPE){
op_pix = put_pixels_tab;
op_qpix= qpel_mc_rnd_tab;
op_qpix= put_qpel_pixels_tab;
}else{
op_pix = put_no_rnd_pixels_tab;
op_qpix= qpel_mc_no_rnd_tab;
op_qpix= put_no_rnd_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture, op_pix, op_qpix);
if ((!s->no_rounding) || s->pict_type==B_TYPE)
op_pix = avg_pixels_tab;
else
op_pix = avg_no_rnd_pixels_tab;
op_pix = avg_pixels_tab;
op_qpix= avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture, op_pix, op_qpix);
@ -1729,8 +1715,8 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
get_pixels(s->block[5], ptr, wrap);
}
}else{
op_pixels_func *op_pix;
qpel_mc_func *op_qpix;
op_pixels_func (*op_pix)[4];
qpel_mc_func (*op_qpix)[16];
UINT8 *dest_y, *dest_cb, *dest_cr;
UINT8 *ptr_y, *ptr_cb, *ptr_cr;
int wrap_y, wrap_c;
@ -1747,18 +1733,16 @@ static void encode_mb(MpegEncContext *s, int motion_x, int motion_y)
if ((!s->no_rounding) || s->pict_type==B_TYPE){
op_pix = put_pixels_tab;
op_qpix= qpel_mc_rnd_tab;
op_qpix= put_qpel_pixels_tab;
}else{
op_pix = put_no_rnd_pixels_tab;
op_qpix= qpel_mc_no_rnd_tab;
op_qpix= put_no_rnd_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_FORWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 0, s->last_picture, op_pix, op_qpix);
if ((!s->no_rounding) || s->pict_type==B_TYPE)
op_pix = avg_pixels_tab;
else
op_pix = avg_no_rnd_pixels_tab;
op_pix = avg_pixels_tab;
op_qpix= avg_qpel_pixels_tab;
}
if (s->mv_dir & MV_DIR_BACKWARD) {
MPV_motion(s, dest_y, dest_cb, dest_cr, 1, s->next_picture, op_pix, op_qpix);

View File

@ -839,8 +839,7 @@ static int svq1_motion_inter_block (bit_buffer_t *bitbuf,
src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1))*pitch];
dst = current;
put_pixels_tab[((mv.y & 1) << 1) | (mv.x & 1)](dst,src,pitch,16);
put_pixels_tab[((mv.y & 1) << 1) | (mv.x & 1)](dst+8,src+8,pitch,16);
put_pixels_tab[0][((mv.y & 1) << 1) | (mv.x & 1)](dst,src,pitch,16);
return 0;
}
@ -907,7 +906,7 @@ static int svq1_motion_inter_4v_block (bit_buffer_t *bitbuf,
src = &previous[(x + (pmv[i]->x >> 1)) + (y + (pmv[i]->y >> 1))*pitch];
dst = current;
put_pixels_tab[((pmv[i]->y & 1) << 1) | (pmv[i]->x & 1)](dst,src,pitch,8);
put_pixels_tab[1][((pmv[i]->y & 1) << 1) | (pmv[i]->x & 1)](dst,src,pitch,8);
/* select next block */
if (i & 1) {