2003-04-19 01:39:37 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
#include "../config.h"
|
|
|
|
#include "../mp_msg.h"
|
|
|
|
#include "../cpudetect.h"
|
|
|
|
|
|
|
|
#include "img_format.h"
|
|
|
|
#include "mp_image.h"
|
|
|
|
#include "vf.h"
|
|
|
|
|
|
|
|
#include "../libvo/fastmemcpy.h"
|
|
|
|
#include "../postproc/rgb2rgb.h"
|
|
|
|
|
2003-12-15 02:58:23 +00:00
|
|
|
typedef void (pack_func_t)(unsigned char *dst, unsigned char *y,
|
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs);
|
|
|
|
|
|
|
|
struct vf_priv_s {
|
|
|
|
int mode;
|
|
|
|
pack_func_t *pack[2];
|
|
|
|
};
|
|
|
|
|
|
|
|
static void pack_nn_C(unsigned char *dst, unsigned char *y,
|
|
|
|
unsigned char *u, unsigned char *v, int w)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
for (j = w/2; j; j--) {
|
|
|
|
*dst++ = *y++;
|
|
|
|
*dst++ = *u++;
|
|
|
|
*dst++ = *y++;
|
|
|
|
*dst++ = *v++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pack_li_0_C(unsigned char *dst, unsigned char *y,
|
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
for (j = w/2; j; j--) {
|
|
|
|
*dst++ = *y++;
|
|
|
|
*dst++ = (u[us+us] + 7*u[0])>>3;
|
|
|
|
*dst++ = *y++;
|
|
|
|
*dst++ = (v[vs+vs] + 7*v[0])>>3;
|
|
|
|
u++; v++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pack_li_1_C(unsigned char *dst, unsigned char *y,
|
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs)
|
|
|
|
{
|
|
|
|
int j;
|
|
|
|
for (j = w/2; j; j--) {
|
|
|
|
*dst++ = *y++;
|
|
|
|
*dst++ = (3*u[us+us] + 5*u[0])>>3;
|
|
|
|
*dst++ = *y++;
|
|
|
|
*dst++ = (3*v[vs+vs] + 5*v[0])>>3;
|
|
|
|
u++; v++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-19 01:39:37 +00:00
|
|
|
#ifdef HAVE_MMX
|
2003-12-15 02:58:23 +00:00
|
|
|
static void pack_nn_MMX(unsigned char *dst, unsigned char *y,
|
2003-04-19 01:39:37 +00:00
|
|
|
unsigned char *u, unsigned char *v, int w)
|
|
|
|
{
|
|
|
|
int j;
|
2003-12-15 02:58:23 +00:00
|
|
|
asm volatile (""
|
2003-04-19 01:39:37 +00:00
|
|
|
".balign 16 \n\t"
|
|
|
|
"1: \n\t"
|
|
|
|
"movq (%0), %%mm1 \n\t"
|
|
|
|
"movq (%0), %%mm2 \n\t"
|
2003-12-15 14:29:09 +00:00
|
|
|
"movq (%1), %%mm4 \n\t"
|
|
|
|
"movq (%2), %%mm6 \n\t"
|
|
|
|
"punpcklbw %%mm6, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm4, %%mm1 \n\t"
|
|
|
|
"punpckhbw %%mm4, %%mm2 \n\t"
|
2003-04-19 01:39:37 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"add $8, %0 \n\t"
|
|
|
|
"add $4, %1 \n\t"
|
|
|
|
"add $4, %2 \n\t"
|
2003-04-19 01:39:37 +00:00
|
|
|
"movq %%mm1, (%3) \n\t"
|
|
|
|
"movq %%mm2, 8(%3) \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"add $16, %3 \n\t"
|
2003-04-19 01:39:37 +00:00
|
|
|
"decl %4 \n\t"
|
|
|
|
"jnz 1b \n\t"
|
2003-12-15 02:58:23 +00:00
|
|
|
"emms \n\t"
|
2003-04-19 01:39:37 +00:00
|
|
|
:
|
|
|
|
: "r" (y), "r" (u), "r" (v), "r" (dst), "r" (w/8)
|
|
|
|
: "memory"
|
|
|
|
);
|
2003-12-15 02:58:23 +00:00
|
|
|
pack_nn_C(dst, y, u, v, (w&7));
|
2003-04-19 01:39:37 +00:00
|
|
|
}
|
2003-12-15 04:07:17 +00:00
|
|
|
|
|
|
|
static void pack_li_0_MMX(unsigned char *dst, unsigned char *y,
|
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs)
|
|
|
|
{
|
|
|
|
asm volatile (""
|
2004-10-21 11:55:20 +00:00
|
|
|
"push %%"REG_BP" \n\t"
|
|
|
|
#ifdef ARCH_X86_64
|
|
|
|
"mov %6, %%"REG_BP" \n\t"
|
|
|
|
#else
|
|
|
|
"movl 4(%%"REG_d"), %%"REG_BP" \n\t"
|
|
|
|
"movl (%%"REG_d"), %%"REG_d" \n\t"
|
|
|
|
#endif
|
2003-12-15 04:07:17 +00:00
|
|
|
"pxor %%mm0, %%mm0 \n\t"
|
|
|
|
|
|
|
|
".balign 16 \n\t"
|
|
|
|
".Lli0: \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_S"), %%mm1 \n\t"
|
|
|
|
"movq (%%"REG_S"), %%mm2 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
|
|
|
|
"movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
"punpcklbw %%mm0, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm6 \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_a"), %%mm3 \n\t"
|
|
|
|
"movq (%%"REG_b"), %%mm5 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
"punpcklbw %%mm0, %%mm3 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm5 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"psrlw $3, %%mm4 \n\t"
|
|
|
|
"psrlw $3, %%mm6 \n\t"
|
2003-12-15 14:29:09 +00:00
|
|
|
"packuswb %%mm4, %%mm4 \n\t"
|
|
|
|
"packuswb %%mm6, %%mm6 \n\t"
|
|
|
|
"punpcklbw %%mm6, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm4, %%mm1 \n\t"
|
|
|
|
"punpckhbw %%mm4, %%mm2 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq %%mm1, (%%"REG_D") \n\t"
|
|
|
|
"movq %%mm2, 8(%%"REG_D") \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq 8(%%"REG_S"), %%mm1 \n\t"
|
|
|
|
"movq 8(%%"REG_S"), %%mm2 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
|
|
|
|
"movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
"punpckhbw %%mm0, %%mm4 \n\t"
|
|
|
|
"punpckhbw %%mm0, %%mm6 \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_a"), %%mm3 \n\t"
|
|
|
|
"movq (%%"REG_b"), %%mm5 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
"punpckhbw %%mm0, %%mm3 \n\t"
|
|
|
|
"punpckhbw %%mm0, %%mm5 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"psrlw $3, %%mm4 \n\t"
|
|
|
|
"psrlw $3, %%mm6 \n\t"
|
2003-12-15 14:29:09 +00:00
|
|
|
"packuswb %%mm4, %%mm4 \n\t"
|
|
|
|
"packuswb %%mm6, %%mm6 \n\t"
|
|
|
|
"punpcklbw %%mm6, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm4, %%mm1 \n\t"
|
|
|
|
"punpckhbw %%mm4, %%mm2 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"add $16, %%"REG_S" \n\t"
|
|
|
|
"add $8, %%"REG_a" \n\t"
|
|
|
|
"add $8, %%"REG_b" \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq %%mm1, 16(%%"REG_D") \n\t"
|
|
|
|
"movq %%mm2, 24(%%"REG_D") \n\t"
|
|
|
|
"add $32, %%"REG_D" \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
|
|
|
"decl %%ecx \n\t"
|
|
|
|
"jnz .Lli0 \n\t"
|
|
|
|
"emms \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"pop %%"REG_BP" \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
:
|
2004-10-21 11:55:20 +00:00
|
|
|
: "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16),
|
|
|
|
#ifdef ARCH_X86_64
|
|
|
|
"d" ((long)us), "r" ((long)vs)
|
|
|
|
#else
|
|
|
|
"d" (&us)
|
|
|
|
#endif
|
2003-12-15 04:07:17 +00:00
|
|
|
: "memory"
|
|
|
|
);
|
|
|
|
pack_li_0_C(dst, y, u, v, (w&15), us, vs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void pack_li_1_MMX(unsigned char *dst, unsigned char *y,
|
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs)
|
|
|
|
{
|
|
|
|
asm volatile (""
|
2004-10-21 11:55:20 +00:00
|
|
|
"push %%"REG_BP" \n\t"
|
|
|
|
#ifdef ARCH_X86_64
|
|
|
|
"mov %6, %%"REG_BP" \n\t"
|
|
|
|
#else
|
|
|
|
"movl 4(%%"REG_d"), %%"REG_BP" \n\t"
|
|
|
|
"movl (%%"REG_d"), %%"REG_d" \n\t"
|
|
|
|
#endif
|
2003-12-15 04:07:17 +00:00
|
|
|
"pxor %%mm0, %%mm0 \n\t"
|
|
|
|
|
|
|
|
".balign 16 \n\t"
|
|
|
|
".Lli1: \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_S"), %%mm1 \n\t"
|
|
|
|
"movq (%%"REG_S"), %%mm2 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
|
|
|
|
"movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
"punpcklbw %%mm0, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm6 \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_a"), %%mm3 \n\t"
|
|
|
|
"movq (%%"REG_b"), %%mm5 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
"punpcklbw %%mm0, %%mm3 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm5 \n\t"
|
|
|
|
"movq %%mm4, %%mm7 \n\t"
|
|
|
|
"paddw %%mm4, %%mm4 \n\t"
|
|
|
|
"paddw %%mm7, %%mm4 \n\t"
|
|
|
|
"movq %%mm6, %%mm7 \n\t"
|
|
|
|
"paddw %%mm6, %%mm6 \n\t"
|
|
|
|
"paddw %%mm7, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"psrlw $3, %%mm4 \n\t"
|
|
|
|
"psrlw $3, %%mm6 \n\t"
|
2003-12-15 14:29:09 +00:00
|
|
|
"packuswb %%mm4, %%mm4 \n\t"
|
|
|
|
"packuswb %%mm6, %%mm6 \n\t"
|
|
|
|
"punpcklbw %%mm6, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm4, %%mm1 \n\t"
|
|
|
|
"punpckhbw %%mm4, %%mm2 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq %%mm1, (%%"REG_D") \n\t"
|
|
|
|
"movq %%mm2, 8(%%"REG_D") \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq 8(%%"REG_S"), %%mm1 \n\t"
|
|
|
|
"movq 8(%%"REG_S"), %%mm2 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
|
|
|
|
"movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
"punpckhbw %%mm0, %%mm4 \n\t"
|
|
|
|
"punpckhbw %%mm0, %%mm6 \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq (%%"REG_a"), %%mm3 \n\t"
|
|
|
|
"movq (%%"REG_b"), %%mm5 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
"punpckhbw %%mm0, %%mm3 \n\t"
|
|
|
|
"punpckhbw %%mm0, %%mm5 \n\t"
|
|
|
|
"movq %%mm4, %%mm7 \n\t"
|
|
|
|
"paddw %%mm4, %%mm4 \n\t"
|
|
|
|
"paddw %%mm7, %%mm4 \n\t"
|
|
|
|
"movq %%mm6, %%mm7 \n\t"
|
|
|
|
"paddw %%mm6, %%mm6 \n\t"
|
|
|
|
"paddw %%mm7, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"paddw %%mm3, %%mm4 \n\t"
|
|
|
|
"paddw %%mm5, %%mm6 \n\t"
|
|
|
|
"psrlw $3, %%mm4 \n\t"
|
|
|
|
"psrlw $3, %%mm6 \n\t"
|
2003-12-15 14:29:09 +00:00
|
|
|
"packuswb %%mm4, %%mm4 \n\t"
|
|
|
|
"packuswb %%mm6, %%mm6 \n\t"
|
|
|
|
"punpcklbw %%mm6, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm4, %%mm1 \n\t"
|
|
|
|
"punpckhbw %%mm4, %%mm2 \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"add $16, %%"REG_S" \n\t"
|
|
|
|
"add $8, %%"REG_a" \n\t"
|
|
|
|
"add $8, %%"REG_b" \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2004-10-21 11:55:20 +00:00
|
|
|
"movq %%mm1, 16(%%"REG_D") \n\t"
|
|
|
|
"movq %%mm2, 24(%%"REG_D") \n\t"
|
|
|
|
"add $32, %%"REG_D" \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
|
|
|
|
"decl %%ecx \n\t"
|
|
|
|
"jnz .Lli1 \n\t"
|
|
|
|
"emms \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
"pop %%"REG_BP" \n\t"
|
2003-12-15 04:07:17 +00:00
|
|
|
:
|
2004-10-21 11:55:20 +00:00
|
|
|
: "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16),
|
|
|
|
#ifdef ARCH_X86_64
|
|
|
|
"d" ((long)us), "r" ((long)vs)
|
|
|
|
#else
|
|
|
|
"d" (&us)
|
|
|
|
#endif
|
2003-12-15 04:07:17 +00:00
|
|
|
: "memory"
|
|
|
|
);
|
|
|
|
pack_li_1_C(dst, y, u, v, (w&15), us, vs);
|
|
|
|
}
|
2003-04-19 01:39:37 +00:00
|
|
|
#endif
|
|
|
|
|
2003-12-15 02:58:23 +00:00
|
|
|
static pack_func_t *pack_nn;
|
|
|
|
static pack_func_t *pack_li_0;
|
|
|
|
static pack_func_t *pack_li_1;
|
2003-04-19 01:39:37 +00:00
|
|
|
|
|
|
|
static void ilpack(unsigned char *dst, unsigned char *src[3],
|
2003-12-15 02:58:23 +00:00
|
|
|
int dststride, int srcstride[3], int w, int h, pack_func_t *pack[2])
|
2003-04-19 01:39:37 +00:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
unsigned char *y, *u, *v;
|
2003-12-15 02:58:23 +00:00
|
|
|
int ys = srcstride[0], us = srcstride[1], vs = srcstride[2];
|
|
|
|
int a, b;
|
2003-04-19 01:39:37 +00:00
|
|
|
|
|
|
|
y = src[0];
|
|
|
|
u = src[1];
|
|
|
|
v = src[2];
|
|
|
|
|
2003-12-15 02:58:23 +00:00
|
|
|
pack_nn(dst, y, u, v, w, 0, 0);
|
|
|
|
y += ys; dst += dststride;
|
|
|
|
pack_nn(dst, y, u+us, v+vs, w, 0, 0);
|
|
|
|
y += ys; dst += dststride;
|
|
|
|
for (i=2; i<h-2; i++) {
|
|
|
|
a = (i&2) ? 1 : -1;
|
|
|
|
b = (i&1) ^ ((i&2)>>1);
|
|
|
|
pack[b](dst, y, u, v, w, us*a, vs*a);
|
|
|
|
y += ys;
|
2003-04-19 01:39:37 +00:00
|
|
|
if ((i&3) == 1) {
|
2003-12-15 02:58:23 +00:00
|
|
|
u -= us;
|
|
|
|
v -= vs;
|
2003-04-19 01:39:37 +00:00
|
|
|
} else {
|
2003-12-15 02:58:23 +00:00
|
|
|
u += us;
|
|
|
|
v += vs;
|
2003-04-19 01:39:37 +00:00
|
|
|
}
|
|
|
|
dst += dststride;
|
|
|
|
}
|
2003-12-15 02:58:23 +00:00
|
|
|
pack_nn(dst, y, u, v, w, 0, 0);
|
|
|
|
y += ys; dst += dststride; u += us; v += vs;
|
|
|
|
pack_nn(dst, y, u, v, w, 0, 0);
|
2003-04-19 01:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int put_image(struct vf_instance_s* vf, mp_image_t *mpi)
|
|
|
|
{
|
|
|
|
mp_image_t *dmpi;
|
|
|
|
|
|
|
|
// hope we'll get DR buffer:
|
|
|
|
dmpi=vf_get_image(vf->next, IMGFMT_YUY2,
|
|
|
|
MP_IMGTYPE_TEMP, MP_IMGFLAG_ACCEPT_STRIDE,
|
|
|
|
mpi->w, mpi->h);
|
|
|
|
|
2003-12-15 02:58:23 +00:00
|
|
|
ilpack(dmpi->planes[0], mpi->planes, dmpi->stride[0], mpi->stride, mpi->w, mpi->h, vf->priv->pack);
|
2003-04-19 01:39:37 +00:00
|
|
|
|
|
|
|
return vf_next_put_image(vf,dmpi);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int config(struct vf_instance_s* vf,
|
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt)
|
|
|
|
{
|
|
|
|
/* FIXME - also support UYVY output? */
|
|
|
|
return vf_next_config(vf, width, height, d_width, d_height, flags, IMGFMT_YUY2);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int query_format(struct vf_instance_s* vf, unsigned int fmt)
|
|
|
|
{
|
|
|
|
/* FIXME - really any YUV 4:2:0 input format should work */
|
|
|
|
switch (fmt) {
|
|
|
|
case IMGFMT_YV12:
|
|
|
|
case IMGFMT_IYUV:
|
|
|
|
case IMGFMT_I420:
|
|
|
|
return vf_next_query_format(vf,IMGFMT_YUY2);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int open(vf_instance_t *vf, char* args)
|
|
|
|
{
|
|
|
|
vf->config=config;
|
|
|
|
vf->query_format=query_format;
|
|
|
|
vf->put_image=put_image;
|
2003-12-15 02:58:23 +00:00
|
|
|
vf->priv = calloc(1, sizeof(struct vf_priv_s));
|
|
|
|
vf->priv->mode = 1;
|
|
|
|
if (args) sscanf(args, "%d", &vf->priv->mode);
|
2003-04-19 01:39:37 +00:00
|
|
|
|
2003-12-15 02:58:23 +00:00
|
|
|
pack_nn = (pack_func_t *)pack_nn_C;
|
|
|
|
pack_li_0 = pack_li_0_C;
|
|
|
|
pack_li_1 = pack_li_1_C;
|
2003-04-19 01:39:37 +00:00
|
|
|
#ifdef HAVE_MMX
|
2003-12-15 04:07:17 +00:00
|
|
|
if(gCpuCaps.hasMMX) {
|
|
|
|
pack_nn = (pack_func_t *)pack_nn_MMX;
|
|
|
|
pack_li_0 = pack_li_0_MMX;
|
|
|
|
pack_li_1 = pack_li_1_MMX;
|
|
|
|
}
|
2003-04-19 01:39:37 +00:00
|
|
|
#endif
|
2003-12-15 02:58:23 +00:00
|
|
|
|
|
|
|
switch(vf->priv->mode) {
|
|
|
|
case 0:
|
|
|
|
vf->priv->pack[0] = vf->priv->pack[1] = pack_nn;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mp_msg(MSGT_VFILTER, MSGL_WARN,
|
|
|
|
"ilpack: unknown mode %d (fallback to linear)\n",
|
|
|
|
vf->priv->mode);
|
|
|
|
case 1:
|
|
|
|
vf->priv->pack[0] = pack_li_0;
|
|
|
|
vf->priv->pack[1] = pack_li_1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-04-19 01:39:37 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
vf_info_t vf_info_ilpack = {
|
|
|
|
"4:2:0 planar -> 4:2:2 packed reinterlacer",
|
|
|
|
"ilpack",
|
|
|
|
"Richard Felker",
|
|
|
|
"",
|
|
|
|
open,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|