mirror of https://github.com/FFmpeg/FFmpeg.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
188 lines
8.2 KiB
188 lines
8.2 KiB
13 years ago
|
/*
|
||
|
* Copyright (C) 2010 David Conrad
|
||
|
*
|
||
|
* This file is part of FFmpeg.
|
||
|
*
|
||
|
* FFmpeg is free software; you can redistribute it and/or
|
||
|
* modify it under the terms of the GNU Lesser General Public
|
||
|
* License as published by the Free Software Foundation; either
|
||
|
* version 2.1 of the License, or (at your option) any later version.
|
||
|
*
|
||
|
* FFmpeg 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
|
||
|
* Lesser General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU Lesser General Public
|
||
|
* License along with FFmpeg; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||
|
*/
|
||
|
|
||
11 years ago
|
#include "libavutil/x86/cpu.h"
|
||
9 years ago
|
#include "libavcodec/diracdsp.h"
|
||
11 years ago
|
#include "fpel.h"
|
||
13 years ago
|
|
||
9 years ago
|
DECL_DIRAC_PIXOP(put, mmx);
|
||
|
DECL_DIRAC_PIXOP(avg, mmx);
|
||
|
DECL_DIRAC_PIXOP(avg, mmxext);
|
||
|
|
||
|
void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
|
||
|
void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
|
||
|
void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
|
||
|
void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h);
|
||
|
|
||
|
void ff_add_rect_clamped_mmx(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
|
||
|
void ff_add_rect_clamped_sse2(uint8_t *, const uint16_t *, int, const int16_t *, int, int, int);
|
||
|
|
||
|
void ff_add_dirac_obmc8_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
|
||
|
void ff_add_dirac_obmc16_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
|
||
|
void ff_add_dirac_obmc32_mmx(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
|
||
|
|
||
|
void ff_add_dirac_obmc16_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
|
||
|
void ff_add_dirac_obmc32_sse2(uint16_t *dst, const uint8_t *src, int stride, const uint8_t *obmc_weight, int yblen);
|
||
|
|
||
13 years ago
|
void ff_put_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
|
||
|
void ff_put_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
|
||
|
void ff_put_signed_rect_clamped_mmx(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
|
||
|
void ff_put_signed_rect_clamped_sse2(uint8_t *dst, int dst_stride, const int16_t *src, int src_stride, int width, int height);
|
||
|
|
||
9 years ago
|
#if HAVE_YASM
|
||
|
|
||
13 years ago
|
#define HPEL_FILTER(MMSIZE, EXT) \
|
||
13 years ago
|
void ff_dirac_hpel_filter_v_ ## EXT(uint8_t *, const uint8_t *, int, int); \
|
||
|
void ff_dirac_hpel_filter_h_ ## EXT(uint8_t *, const uint8_t *, int); \
|
||
13 years ago
|
\
|
||
|
static void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \
|
||
13 years ago
|
const uint8_t *src, int stride, int width, int height) \
|
||
13 years ago
|
{ \
|
||
|
while( height-- ) \
|
||
|
{ \
|
||
|
ff_dirac_hpel_filter_v_ ## EXT(dstv-MMSIZE, src-MMSIZE, stride, width+MMSIZE+5); \
|
||
|
ff_dirac_hpel_filter_h_ ## EXT(dsth, src, width); \
|
||
|
ff_dirac_hpel_filter_h_ ## EXT(dstc, dstv, width); \
|
||
|
\
|
||
|
dsth += stride; \
|
||
|
dstv += stride; \
|
||
|
dstc += stride; \
|
||
|
src += stride; \
|
||
|
} \
|
||
|
}
|
||
13 years ago
|
|
||
13 years ago
|
#define PIXFUNC(PFX, IDX, EXT) \
|
||
13 years ago
|
/*MMXDISABLEDc->PFX ## _dirac_pixels_tab[0][IDX] = ff_ ## PFX ## _dirac_pixels8_ ## EXT;*/ \
|
||
13 years ago
|
c->PFX ## _dirac_pixels_tab[1][IDX] = ff_ ## PFX ## _dirac_pixels16_ ## EXT; \
|
||
|
c->PFX ## _dirac_pixels_tab[2][IDX] = ff_ ## PFX ## _dirac_pixels32_ ## EXT
|
||
|
|
||
11 years ago
|
#define DIRAC_PIXOP(OPNAME2, OPNAME, EXT)\
|
||
|
void ff_ ## OPNAME2 ## _dirac_pixels8_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
|
||
|
{\
|
||
|
if (h&3)\
|
||
|
ff_ ## OPNAME2 ## _dirac_pixels8_c(dst, src, stride, h);\
|
||
|
else\
|
||
|
OPNAME ## _pixels8_ ## EXT(dst, src[0], stride, h);\
|
||
|
}\
|
||
|
void ff_ ## OPNAME2 ## _dirac_pixels16_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
|
||
|
{\
|
||
|
if (h&3)\
|
||
|
ff_ ## OPNAME2 ## _dirac_pixels16_c(dst, src, stride, h);\
|
||
|
else\
|
||
|
OPNAME ## _pixels16_ ## EXT(dst, src[0], stride, h);\
|
||
|
}\
|
||
|
void ff_ ## OPNAME2 ## _dirac_pixels32_ ## EXT(uint8_t *dst, const uint8_t *src[5], int stride, int h)\
|
||
|
{\
|
||
|
if (h&3) {\
|
||
|
ff_ ## OPNAME2 ## _dirac_pixels32_c(dst, src, stride, h);\
|
||
|
} else {\
|
||
|
OPNAME ## _pixels16_ ## EXT(dst , src[0] , stride, h);\
|
||
|
OPNAME ## _pixels16_ ## EXT(dst+16, src[0]+16, stride, h);\
|
||
|
}\
|
||
|
}
|
||
|
|
||
|
DIRAC_PIXOP(put, ff_put, mmx)
|
||
|
DIRAC_PIXOP(avg, ff_avg, mmx)
|
||
|
DIRAC_PIXOP(avg, ff_avg, mmxext)
|
||
|
|
||
|
void ff_put_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
|
||
|
{
|
||
|
if (h&3)
|
||
|
ff_put_dirac_pixels16_c(dst, src, stride, h);
|
||
|
else
|
||
9 years ago
|
ff_put_pixels16_sse2(dst, src[0], stride, h);
|
||
11 years ago
|
}
|
||
|
void ff_avg_dirac_pixels16_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
|
||
|
{
|
||
|
if (h&3)
|
||
|
ff_avg_dirac_pixels16_c(dst, src, stride, h);
|
||
|
else
|
||
9 years ago
|
ff_avg_pixels16_sse2(dst, src[0], stride, h);
|
||
11 years ago
|
}
|
||
|
void ff_put_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
|
||
|
{
|
||
|
if (h&3) {
|
||
|
ff_put_dirac_pixels32_c(dst, src, stride, h);
|
||
|
} else {
|
||
9 years ago
|
ff_put_pixels16_sse2(dst , src[0] , stride, h);
|
||
|
ff_put_pixels16_sse2(dst+16, src[0]+16, stride, h);
|
||
11 years ago
|
}
|
||
|
}
|
||
|
void ff_avg_dirac_pixels32_sse2(uint8_t *dst, const uint8_t *src[5], int stride, int h)
|
||
|
{
|
||
|
if (h&3) {
|
||
|
ff_avg_dirac_pixels32_c(dst, src, stride, h);
|
||
|
} else {
|
||
9 years ago
|
ff_avg_pixels16_sse2(dst , src[0] , stride, h);
|
||
|
ff_avg_pixels16_sse2(dst+16, src[0]+16, stride, h);
|
||
11 years ago
|
}
|
||
|
}
|
||
|
|
||
9 years ago
|
#else // HAVE_YASM
|
||
|
|
||
|
#define HPEL_FILTER(MMSIZE, EXT) \
|
||
|
void dirac_hpel_filter_ ## EXT(uint8_t *dsth, uint8_t *dstv, uint8_t *dstc, \
|
||
|
const uint8_t *src, int stride, int width, int height);
|
||
|
|
||
|
#define PIXFUNC(PFX, IDX, EXT) do {} while (0)
|
||
|
|
||
|
#endif // HAVE_YASM
|
||
|
|
||
|
#if !ARCH_X86_64
|
||
|
HPEL_FILTER(8, mmx)
|
||
|
#endif
|
||
|
HPEL_FILTER(16, sse2)
|
||
|
|
||
|
void ff_diracdsp_init_x86(DiracDSPContext* c)
|
||
13 years ago
|
{
|
||
13 years ago
|
int mm_flags = av_get_cpu_flags();
|
||
13 years ago
|
|
||
11 years ago
|
if (EXTERNAL_MMX(mm_flags)) {
|
||
9 years ago
|
c->add_dirac_obmc[0] = ff_add_dirac_obmc8_mmx;
|
||
13 years ago
|
#if !ARCH_X86_64
|
||
9 years ago
|
c->add_dirac_obmc[1] = ff_add_dirac_obmc16_mmx;
|
||
|
c->add_dirac_obmc[2] = ff_add_dirac_obmc32_mmx;
|
||
|
c->dirac_hpel_filter = dirac_hpel_filter_mmx;
|
||
|
c->add_rect_clamped = ff_add_rect_clamped_mmx;
|
||
|
c->put_signed_rect_clamped[0] = (void *)ff_put_signed_rect_clamped_mmx;
|
||
13 years ago
|
#endif
|
||
9 years ago
|
PIXFUNC(put, 0, mmx);
|
||
|
PIXFUNC(avg, 0, mmx);
|
||
11 years ago
|
}
|
||
13 years ago
|
|
||
11 years ago
|
if (EXTERNAL_MMXEXT(mm_flags)) {
|
||
12 years ago
|
PIXFUNC(avg, 0, mmxext);
|
||
13 years ago
|
}
|
||
|
|
||
11 years ago
|
if (EXTERNAL_SSE2(mm_flags)) {
|
||
13 years ago
|
c->dirac_hpel_filter = dirac_hpel_filter_sse2;
|
||
|
c->add_rect_clamped = ff_add_rect_clamped_sse2;
|
||
9 years ago
|
c->put_signed_rect_clamped[0] = (void *)ff_put_signed_rect_clamped_sse2;
|
||
13 years ago
|
|
||
|
c->add_dirac_obmc[1] = ff_add_dirac_obmc16_sse2;
|
||
|
c->add_dirac_obmc[2] = ff_add_dirac_obmc32_sse2;
|
||
11 years ago
|
|
||
13 years ago
|
c->put_dirac_pixels_tab[1][0] = ff_put_dirac_pixels16_sse2;
|
||
|
c->avg_dirac_pixels_tab[1][0] = ff_avg_dirac_pixels16_sse2;
|
||
|
c->put_dirac_pixels_tab[2][0] = ff_put_dirac_pixels32_sse2;
|
||
|
c->avg_dirac_pixels_tab[2][0] = ff_avg_dirac_pixels32_sse2;
|
||
|
}
|
||
|
}
|