2010-01-30 16:57:40 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2003-04-19 01:39:37 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
2005-11-18 14:39:25 +00:00
|
|
|
#include "config.h"
|
2013-12-17 01:39:45 +00:00
|
|
|
#include "common/msg.h"
|
|
|
|
#include "common/cpudetect.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_option.h"
|
2003-04-19 01:39:37 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/img_format.h"
|
|
|
|
#include "video/mp_image.h"
|
2003-04-19 01:39:37 +00:00
|
|
|
#include "vf.h"
|
2011-06-01 19:07:30 +00:00
|
|
|
#include "libavutil/attributes.h"
|
2003-04-19 01:39:37 +00:00
|
|
|
|
2003-12-15 02:58:23 +00:00
|
|
|
typedef void (pack_func_t)(unsigned char *dst, unsigned char *y,
|
2011-07-06 06:23:53 +00:00
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs);
|
2003-12-15 02:58:23 +00:00
|
|
|
|
|
|
|
struct vf_priv_s {
|
2011-07-06 06:23:53 +00:00
|
|
|
int mode;
|
|
|
|
pack_func_t *pack[2];
|
2003-12-15 02:58:23 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void pack_nn_C(unsigned char *dst, unsigned char *y,
|
2011-06-01 19:07:30 +00:00
|
|
|
unsigned char *u, unsigned char *v, int w,
|
|
|
|
int av_unused us, int av_unused vs)
|
2003-12-15 02:58:23 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
int j;
|
|
|
|
for (j = w/2; j; j--) {
|
|
|
|
*dst++ = *y++;
|
|
|
|
*dst++ = *u++;
|
|
|
|
*dst++ = *y++;
|
|
|
|
*dst++ = *v++;
|
|
|
|
}
|
2003-12-15 02:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pack_li_0_C(unsigned char *dst, unsigned char *y,
|
2011-07-06 06:23:53 +00:00
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs)
|
2003-12-15 02:58:23 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
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++;
|
|
|
|
}
|
2003-12-15 02:58:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pack_li_1_C(unsigned char *dst, unsigned char *y,
|
2011-07-06 06:23:53 +00:00
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs)
|
2003-12-15 02:58:23 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
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-12-15 02:58:23 +00:00
|
|
|
}
|
|
|
|
|
2009-01-16 09:21:21 +00:00
|
|
|
#if HAVE_MMX
|
2003-12-15 02:58:23 +00:00
|
|
|
static void pack_nn_MMX(unsigned char *dst, unsigned char *y,
|
2011-06-01 19:07:30 +00:00
|
|
|
unsigned char *u, unsigned char *v, int w,
|
|
|
|
int av_unused us, int av_unused vs)
|
2003-04-19 01:39:37 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
__asm__ volatile (""
|
configure: remove check for .align semantics
The check determined whether the argument for .align is in bytes, or
log2(bytes). Apparently it's always in bytes for ELF i386 systems, and
this check is used for x86 inline assembler only. Even if this
assumption should be wrong, it likely won't cause much damage: the
existing code uses it only in the form ".align 4", which means in the
worst case it will try to align to 16 bytes, which doesn't cause any
problems (unless the object file format does not support such a high
alignment).
Update the filters that used this.
Quoting the GNU as manual:
For other systems, including ppc, i386 using a.out format, arm and
strongarm, it is the number of low-order zero bits the location counter
must have after advancement. For example `.align 3' advances the
location counter until it a multiple of 8. If the location counter is
already a multiple of 8, no change is needed.
2013-01-13 13:10:43 +00:00
|
|
|
".align 4 \n\t"
|
2011-07-06 06:23:53 +00:00
|
|
|
"1: \n\t"
|
|
|
|
"movq (%0), %%mm1 \n\t"
|
|
|
|
"movq (%0), %%mm2 \n\t"
|
|
|
|
"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"
|
|
|
|
|
|
|
|
"add $8, %0 \n\t"
|
|
|
|
"add $4, %1 \n\t"
|
|
|
|
"add $4, %2 \n\t"
|
|
|
|
"movq %%mm1, (%3) \n\t"
|
|
|
|
"movq %%mm2, 8(%3) \n\t"
|
|
|
|
"add $16, %3 \n\t"
|
|
|
|
"decl %4 \n\t"
|
|
|
|
"jnz 1b \n\t"
|
|
|
|
"emms \n\t"
|
|
|
|
:
|
|
|
|
: "r" (y), "r" (u), "r" (v), "r" (dst), "r" (w/8)
|
|
|
|
: "memory"
|
|
|
|
);
|
2011-06-01 19:07:30 +00:00
|
|
|
pack_nn_C(dst, y, u, v, (w&7), 0, 0);
|
2003-04-19 01:39:37 +00:00
|
|
|
}
|
2003-12-15 04:07:17 +00:00
|
|
|
|
2009-09-14 14:47:56 +00:00
|
|
|
#if HAVE_EBX_AVAILABLE
|
2003-12-15 04:07:17 +00:00
|
|
|
static void pack_li_0_MMX(unsigned char *dst, unsigned char *y,
|
2011-07-06 06:23:53 +00:00
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs)
|
2003-12-15 04:07:17 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
__asm__ volatile (""
|
|
|
|
"push %%"REG_BP" \n\t"
|
2009-01-16 09:21:21 +00:00
|
|
|
#if ARCH_X86_64
|
2011-07-06 06:23:53 +00:00
|
|
|
"mov %6, %%"REG_BP" \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
#else
|
2011-07-06 06:23:53 +00:00
|
|
|
"movl 4(%%"REG_d"), %%"REG_BP" \n\t"
|
|
|
|
"movl (%%"REG_d"), %%"REG_d" \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
#endif
|
2011-07-06 06:23:53 +00:00
|
|
|
"pxor %%mm0, %%mm0 \n\t"
|
|
|
|
|
configure: remove check for .align semantics
The check determined whether the argument for .align is in bytes, or
log2(bytes). Apparently it's always in bytes for ELF i386 systems, and
this check is used for x86 inline assembler only. Even if this
assumption should be wrong, it likely won't cause much damage: the
existing code uses it only in the form ".align 4", which means in the
worst case it will try to align to 16 bytes, which doesn't cause any
problems (unless the object file format does not support such a high
alignment).
Update the filters that used this.
Quoting the GNU as manual:
For other systems, including ppc, i386 using a.out format, arm and
strongarm, it is the number of low-order zero bits the location counter
must have after advancement. For example `.align 3' advances the
location counter until it a multiple of 8. If the location counter is
already a multiple of 8, no change is needed.
2013-01-13 13:10:43 +00:00
|
|
|
".align 4 \n\t"
|
2011-07-06 06:23:53 +00:00
|
|
|
".Lli0: \n\t"
|
|
|
|
"movq (%%"REG_S"), %%mm1 \n\t"
|
|
|
|
"movq (%%"REG_S"), %%mm2 \n\t"
|
|
|
|
|
|
|
|
"movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
|
|
|
|
"movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm6 \n\t"
|
|
|
|
"movq (%%"REG_a"), %%mm3 \n\t"
|
|
|
|
"movq (%%"REG_b"), %%mm5 \n\t"
|
|
|
|
"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"
|
|
|
|
"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"
|
|
|
|
|
|
|
|
"movq %%mm1, (%%"REG_D") \n\t"
|
|
|
|
"movq %%mm2, 8(%%"REG_D") \n\t"
|
|
|
|
|
|
|
|
"movq 8(%%"REG_S"), %%mm1 \n\t"
|
|
|
|
"movq 8(%%"REG_S"), %%mm2 \n\t"
|
|
|
|
|
|
|
|
"movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
|
|
|
|
"movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
|
|
|
|
"punpckhbw %%mm0, %%mm4 \n\t"
|
|
|
|
"punpckhbw %%mm0, %%mm6 \n\t"
|
|
|
|
"movq (%%"REG_a"), %%mm3 \n\t"
|
|
|
|
"movq (%%"REG_b"), %%mm5 \n\t"
|
|
|
|
"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"
|
|
|
|
"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"
|
|
|
|
|
|
|
|
"add $16, %%"REG_S" \n\t"
|
|
|
|
"add $8, %%"REG_a" \n\t"
|
|
|
|
"add $8, %%"REG_b" \n\t"
|
|
|
|
|
|
|
|
"movq %%mm1, 16(%%"REG_D") \n\t"
|
|
|
|
"movq %%mm2, 24(%%"REG_D") \n\t"
|
|
|
|
"add $32, %%"REG_D" \n\t"
|
|
|
|
|
|
|
|
"decl %%ecx \n\t"
|
|
|
|
"jnz .Lli0 \n\t"
|
|
|
|
"emms \n\t"
|
|
|
|
"pop %%"REG_BP" \n\t"
|
|
|
|
:
|
|
|
|
: "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16),
|
2009-01-16 09:21:21 +00:00
|
|
|
#if ARCH_X86_64
|
2011-07-06 06:23:53 +00:00
|
|
|
"d" ((x86_reg)us), "r" ((x86_reg)vs)
|
2004-10-21 11:55:20 +00:00
|
|
|
#else
|
2011-07-06 06:23:53 +00:00
|
|
|
"d" (&us)
|
2004-10-21 11:55:20 +00:00
|
|
|
#endif
|
2011-07-06 06:23:53 +00:00
|
|
|
: "memory"
|
|
|
|
);
|
|
|
|
pack_li_0_C(dst, y, u, v, (w&15), us, vs);
|
2003-12-15 04:07:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void pack_li_1_MMX(unsigned char *dst, unsigned char *y,
|
2011-07-06 06:23:53 +00:00
|
|
|
unsigned char *u, unsigned char *v, int w, int us, int vs)
|
2003-12-15 04:07:17 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
__asm__ volatile (""
|
|
|
|
"push %%"REG_BP" \n\t"
|
2009-01-16 09:21:21 +00:00
|
|
|
#if ARCH_X86_64
|
2011-07-06 06:23:53 +00:00
|
|
|
"mov %6, %%"REG_BP" \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
#else
|
2011-07-06 06:23:53 +00:00
|
|
|
"movl 4(%%"REG_d"), %%"REG_BP" \n\t"
|
|
|
|
"movl (%%"REG_d"), %%"REG_d" \n\t"
|
2004-10-21 11:55:20 +00:00
|
|
|
#endif
|
2011-07-06 06:23:53 +00:00
|
|
|
"pxor %%mm0, %%mm0 \n\t"
|
|
|
|
|
configure: remove check for .align semantics
The check determined whether the argument for .align is in bytes, or
log2(bytes). Apparently it's always in bytes for ELF i386 systems, and
this check is used for x86 inline assembler only. Even if this
assumption should be wrong, it likely won't cause much damage: the
existing code uses it only in the form ".align 4", which means in the
worst case it will try to align to 16 bytes, which doesn't cause any
problems (unless the object file format does not support such a high
alignment).
Update the filters that used this.
Quoting the GNU as manual:
For other systems, including ppc, i386 using a.out format, arm and
strongarm, it is the number of low-order zero bits the location counter
must have after advancement. For example `.align 3' advances the
location counter until it a multiple of 8. If the location counter is
already a multiple of 8, no change is needed.
2013-01-13 13:10:43 +00:00
|
|
|
".align 4 \n\t"
|
2011-07-06 06:23:53 +00:00
|
|
|
".Lli1: \n\t"
|
|
|
|
"movq (%%"REG_S"), %%mm1 \n\t"
|
|
|
|
"movq (%%"REG_S"), %%mm2 \n\t"
|
|
|
|
|
|
|
|
"movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
|
|
|
|
"movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm4 \n\t"
|
|
|
|
"punpcklbw %%mm0, %%mm6 \n\t"
|
|
|
|
"movq (%%"REG_a"), %%mm3 \n\t"
|
|
|
|
"movq (%%"REG_b"), %%mm5 \n\t"
|
|
|
|
"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"
|
|
|
|
"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"
|
|
|
|
|
|
|
|
"movq %%mm1, (%%"REG_D") \n\t"
|
|
|
|
"movq %%mm2, 8(%%"REG_D") \n\t"
|
|
|
|
|
|
|
|
"movq 8(%%"REG_S"), %%mm1 \n\t"
|
|
|
|
"movq 8(%%"REG_S"), %%mm2 \n\t"
|
|
|
|
|
|
|
|
"movq (%%"REG_a",%%"REG_d",2), %%mm4 \n\t"
|
|
|
|
"movq (%%"REG_b",%%"REG_BP",2), %%mm6 \n\t"
|
|
|
|
"punpckhbw %%mm0, %%mm4 \n\t"
|
|
|
|
"punpckhbw %%mm0, %%mm6 \n\t"
|
|
|
|
"movq (%%"REG_a"), %%mm3 \n\t"
|
|
|
|
"movq (%%"REG_b"), %%mm5 \n\t"
|
|
|
|
"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"
|
|
|
|
"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"
|
|
|
|
|
|
|
|
"add $16, %%"REG_S" \n\t"
|
|
|
|
"add $8, %%"REG_a" \n\t"
|
|
|
|
"add $8, %%"REG_b" \n\t"
|
|
|
|
|
|
|
|
"movq %%mm1, 16(%%"REG_D") \n\t"
|
|
|
|
"movq %%mm2, 24(%%"REG_D") \n\t"
|
|
|
|
"add $32, %%"REG_D" \n\t"
|
|
|
|
|
|
|
|
"decl %%ecx \n\t"
|
|
|
|
"jnz .Lli1 \n\t"
|
|
|
|
"emms \n\t"
|
|
|
|
"pop %%"REG_BP" \n\t"
|
|
|
|
:
|
|
|
|
: "S" (y), "D" (dst), "a" (u), "b" (v), "c" (w/16),
|
2009-01-16 09:21:21 +00:00
|
|
|
#if ARCH_X86_64
|
2011-07-06 06:23:53 +00:00
|
|
|
"d" ((x86_reg)us), "r" ((x86_reg)vs)
|
2004-10-21 11:55:20 +00:00
|
|
|
#else
|
2011-07-06 06:23:53 +00:00
|
|
|
"d" (&us)
|
2004-10-21 11:55:20 +00:00
|
|
|
#endif
|
2011-07-06 06:23:53 +00:00
|
|
|
: "memory"
|
|
|
|
);
|
|
|
|
pack_li_1_C(dst, y, u, v, (w&15), us, vs);
|
2003-12-15 04:07:17 +00:00
|
|
|
}
|
2009-09-14 14:47:56 +00:00
|
|
|
#endif /* HAVE_EBX_AVAILABLE */
|
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],
|
2011-07-06 06:23:53 +00:00
|
|
|
int dststride, int srcstride[3], int w, int h, pack_func_t *pack[2])
|
2003-04-19 01:39:37 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
int i;
|
|
|
|
unsigned char *y, *u, *v;
|
|
|
|
int ys = srcstride[0], us = srcstride[1], vs = srcstride[2];
|
|
|
|
int a, b;
|
|
|
|
|
|
|
|
y = src[0];
|
|
|
|
u = src[1];
|
|
|
|
v = src[2];
|
|
|
|
|
|
|
|
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;
|
|
|
|
if ((i&3) == 1) {
|
|
|
|
u -= us;
|
|
|
|
v -= vs;
|
|
|
|
} else {
|
|
|
|
u += us;
|
|
|
|
v += vs;
|
|
|
|
}
|
|
|
|
dst += dststride;
|
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
static struct mp_image *filter(struct vf_instance *vf, struct mp_image *mpi)
|
2003-04-19 01:39:37 +00:00
|
|
|
{
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
mp_image_t *dmpi = vf_alloc_out_image(vf);
|
|
|
|
mp_image_copy_attributes(dmpi, mpi);
|
2003-04-19 01:39:37 +00:00
|
|
|
|
|
|
|
|
2011-07-06 06:23:53 +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
|
|
|
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
talloc_free(mpi);
|
|
|
|
return dmpi;
|
2003-04-19 01:39:37 +00:00
|
|
|
}
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int config(struct vf_instance *vf,
|
2011-07-06 06:23:53 +00:00
|
|
|
int width, int height, int d_width, int d_height,
|
|
|
|
unsigned int flags, unsigned int outfmt)
|
2003-04-19 01:39:37 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
/* FIXME - also support UYVY output? */
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
return vf_next_config(vf, width, height, d_width, d_height, flags, IMGFMT_YUYV);
|
2003-04-19 01:39:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-05-29 14:15:55 +00:00
|
|
|
static int query_format(struct vf_instance *vf, unsigned int fmt)
|
2003-04-19 01:39:37 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
/* FIXME - really any YUV 4:2:0 input format should work */
|
|
|
|
switch (fmt) {
|
video: decouple internal pixel formats from FourCCs
mplayer's video chain traditionally used FourCCs for pixel formats. For
example, it used IMGFMT_YV12 for 4:2:0 YUV, which was defined to the
string 'YV12' interpreted as unsigned int. Additionally, it used to
encode information into the numeric values of some formats. The RGB
formats had their bit depth and endian encoded into the least
significant byte. Extended planar formats (420P10 etc.) had chroma
shift, endian, and component bit depth encoded. (This has been removed
in recent commits.)
Replace the FourCC mess with a simple enum. Remove all the redundant
formats like YV12/I420/IYUV. Replace some image format names by
something more intuitive, most importantly IMGFMT_YV12 -> IMGFMT_420P.
Add img_fourcc.h, which contains the old IDs for code that actually uses
FourCCs. Change the way demuxers, that output raw video, identify the
video format: they set either MP_FOURCC_RAWVIDEO or MP_FOURCC_IMGFMT to
request the rawvideo decoder, and sh_video->imgfmt specifies the pixel
format. Like the previous hack, this is supposed to avoid the need for
a complete codecs.cfg entry per format, or other lookup tables. (Note
that the RGB raw video FourCCs mostly rely on ffmpeg's mappings for NUT
raw video, but this is still considered better than adding a raw video
decoder - even if trivial, it would be full of annoying lookup tables.)
The TV code has not been tested.
Some corrective changes regarding endian and other image format flags
creep in.
2012-12-23 19:03:30 +00:00
|
|
|
case IMGFMT_420P:
|
|
|
|
return vf_next_query_format(vf,IMGFMT_YUYV);
|
2011-07-06 06:23:53 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2003-04-19 01:39:37 +00:00
|
|
|
}
|
|
|
|
|
2013-12-03 23:01:38 +00:00
|
|
|
static int vf_open(vf_instance_t *vf)
|
2003-04-19 01:39:37 +00:00
|
|
|
{
|
2011-07-06 06:23:53 +00:00
|
|
|
vf->config=config;
|
|
|
|
vf->query_format=query_format;
|
video/filter: change filter API, use refcounting, remove filter DR
Change the entire filter API to use reference counted images instead
of vf_get_image().
Remove filter "direct rendering". This was useful for vf_expand and (in
rare cases) vf_sub: DR allowed these filters to pass a cropped image to
the filters before them. Then, on filtering, the image was "uncropped",
so that black bars could be added around the image without copying. This
means that in some cases, vf_expand will be slower (-vf gradfun,expand
for example).
Note that another form of DR used for in-place filters has been replaced
by simpler logic. Instead of trying to do DR, filters can check if the
image is writeable (with mp_image_is_writeable()), and do true in-place
if that's the case. This affects filters like vf_gradfun and vf_sub.
Everything has to support strides now. If something doesn't, making a
copy of the image data is required.
2012-11-05 13:25:04 +00:00
|
|
|
vf->filter=filter;
|
2011-07-06 06:23:53 +00:00
|
|
|
|
2011-06-01 19:07:30 +00:00
|
|
|
pack_nn = pack_nn_C;
|
2011-07-06 06:23:53 +00:00
|
|
|
pack_li_0 = pack_li_0_C;
|
|
|
|
pack_li_1 = pack_li_1_C;
|
2009-01-16 09:21:21 +00:00
|
|
|
#if HAVE_MMX
|
2011-07-06 06:23:53 +00:00
|
|
|
if(gCpuCaps.hasMMX) {
|
2011-06-01 19:07:30 +00:00
|
|
|
pack_nn = pack_nn_MMX;
|
2009-09-14 14:47:56 +00:00
|
|
|
#if HAVE_EBX_AVAILABLE
|
2011-07-06 06:23:53 +00:00
|
|
|
pack_li_0 = pack_li_0_MMX;
|
|
|
|
pack_li_1 = pack_li_1_MMX;
|
2009-09-14 14:47:56 +00:00
|
|
|
#endif
|
2011-07-06 06:23:53 +00:00
|
|
|
}
|
2003-04-19 01:39:37 +00:00
|
|
|
#endif
|
2003-12-15 02:58:23 +00:00
|
|
|
|
2011-07-06 06:23:53 +00:00
|
|
|
switch(vf->priv->mode) {
|
|
|
|
case 0:
|
|
|
|
vf->priv->pack[0] = vf->priv->pack[1] = pack_nn;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
vf->priv->pack[0] = pack_li_0;
|
|
|
|
vf->priv->pack[1] = pack_li_1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
2003-04-19 01:39:37 +00:00
|
|
|
}
|
|
|
|
|
2013-12-03 22:35:28 +00:00
|
|
|
#define OPT_BASE_STRUCT struct vf_priv_s
|
2007-12-02 14:57:15 +00:00
|
|
|
const vf_info_t vf_info_ilpack = {
|
2013-10-23 17:06:42 +00:00
|
|
|
.description = "4:2:0 planar -> 4:2:2 packed reinterlacer",
|
|
|
|
.name = "ilpack",
|
|
|
|
.open = vf_open,
|
2013-12-03 22:35:28 +00:00
|
|
|
.priv_size = sizeof(struct vf_priv_s),
|
|
|
|
.priv_defaults = &(const struct vf_priv_s){
|
|
|
|
.mode = 1,
|
|
|
|
},
|
|
|
|
.options = (const struct m_option[]){
|
|
|
|
OPT_INTRANGE("mode", mode, 0, 0, 1),
|
|
|
|
{0}
|
|
|
|
},
|
2003-04-19 01:39:37 +00:00
|
|
|
};
|