2011-08-09 11:00:09 +02:00
|
|
|
/*
|
|
|
|
* RV40 decoder motion compensation functions x86-optimised
|
|
|
|
* Copyright (c) 2008 Konstantin Shishkov
|
|
|
|
*
|
2012-08-31 12:04:17 +02:00
|
|
|
* This file is part of FFmpeg.
|
2011-08-09 11:00:09 +02:00
|
|
|
*
|
2012-08-31 12:04:17 +02:00
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
2011-08-09 11:00:09 +02:00
|
|
|
* 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.
|
|
|
|
*
|
2012-08-31 12:04:17 +02:00
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
2011-08-09 11:00:09 +02:00
|
|
|
* 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
|
2012-08-31 12:04:17 +02:00
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
2011-08-09 11:00:09 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* RV40 decoder motion compensation functions x86-optimised
|
2012-04-19 22:36:17 +02:00
|
|
|
* 2,0 and 0,2 have h264 equivalents.
|
|
|
|
* 3,3 is bugged in the rv40 format and maps to _xy2 version
|
2011-08-09 11:00:09 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "libavcodec/rv34dsp.h"
|
2012-08-06 15:49:32 +02:00
|
|
|
#include "libavutil/mem.h"
|
2012-08-29 19:01:05 +02:00
|
|
|
#include "libavutil/x86/cpu.h"
|
2012-06-21 11:44:53 +02:00
|
|
|
#include "dsputil_mmx.h"
|
2011-08-09 11:00:09 +02:00
|
|
|
|
2012-08-29 11:14:17 +02:00
|
|
|
#if HAVE_YASM
|
2011-08-09 11:00:09 +02:00
|
|
|
void ff_put_rv40_chroma_mc8_mmx (uint8_t *dst, uint8_t *src,
|
|
|
|
int stride, int h, int x, int y);
|
|
|
|
void ff_avg_rv40_chroma_mc8_mmx2 (uint8_t *dst, uint8_t *src,
|
|
|
|
int stride, int h, int x, int y);
|
|
|
|
void ff_avg_rv40_chroma_mc8_3dnow(uint8_t *dst, uint8_t *src,
|
|
|
|
int stride, int h, int x, int y);
|
|
|
|
|
|
|
|
void ff_put_rv40_chroma_mc4_mmx (uint8_t *dst, uint8_t *src,
|
|
|
|
int stride, int h, int x, int y);
|
|
|
|
void ff_avg_rv40_chroma_mc4_mmx2 (uint8_t *dst, uint8_t *src,
|
|
|
|
int stride, int h, int x, int y);
|
|
|
|
void ff_avg_rv40_chroma_mc4_3dnow(uint8_t *dst, uint8_t *src,
|
|
|
|
int stride, int h, int x, int y);
|
|
|
|
|
rv40: x86 SIMD for biweight
Provide MMX, SSE2 and SSSE3 versions, with a fast-path when the weights are
multiples of 512 (which is often the case when the values round up nicely).
*_TIMER report for the 16x16 and 8x8 cases:
C:
9015 decicycles in 16, 524257 runs, 31 skips
2656 decicycles in 8, 524271 runs, 17 skips
MMX:
4156 decicycles in 16, 262090 runs, 54 skips
1206 decicycles in 8, 262131 runs, 13 skips
MMX on fast-path:
2760 decicycles in 16, 524222 runs, 66 skips
995 decicycles in 8, 524252 runs, 36 skips
SSE2:
2163 decicycles in 16, 262131 runs, 13 skips
832 decicycles in 8, 262137 runs, 7 skips
SSE2 with fast path:
1783 decicycles in 16, 524276 runs, 12 skips
711 decicycles in 8, 524283 runs, 5 skips
SSSE3:
2117 decicycles in 16, 262136 runs, 8 skips
814 decicycles in 8, 262143 runs, 1 skips
SSSE3 with fast path:
1315 decicycles in 16, 524285 runs, 3 skips
578 decicycles in 8, 524286 runs, 2 skips
This means around a 4% speedup for some sequences.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-01-12 00:11:15 +01:00
|
|
|
#define DECLARE_WEIGHT(opt) \
|
2012-03-19 22:46:28 +01:00
|
|
|
void ff_rv40_weight_func_rnd_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
|
|
|
|
int w1, int w2, ptrdiff_t stride); \
|
|
|
|
void ff_rv40_weight_func_rnd_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
|
|
|
|
int w1, int w2, ptrdiff_t stride); \
|
|
|
|
void ff_rv40_weight_func_nornd_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
|
|
|
|
int w1, int w2, ptrdiff_t stride); \
|
|
|
|
void ff_rv40_weight_func_nornd_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
|
|
|
|
int w1, int w2, ptrdiff_t stride);
|
2012-05-10 23:44:04 +02:00
|
|
|
DECLARE_WEIGHT(mmx2)
|
rv40: x86 SIMD for biweight
Provide MMX, SSE2 and SSSE3 versions, with a fast-path when the weights are
multiples of 512 (which is often the case when the values round up nicely).
*_TIMER report for the 16x16 and 8x8 cases:
C:
9015 decicycles in 16, 524257 runs, 31 skips
2656 decicycles in 8, 524271 runs, 17 skips
MMX:
4156 decicycles in 16, 262090 runs, 54 skips
1206 decicycles in 8, 262131 runs, 13 skips
MMX on fast-path:
2760 decicycles in 16, 524222 runs, 66 skips
995 decicycles in 8, 524252 runs, 36 skips
SSE2:
2163 decicycles in 16, 262131 runs, 13 skips
832 decicycles in 8, 262137 runs, 7 skips
SSE2 with fast path:
1783 decicycles in 16, 524276 runs, 12 skips
711 decicycles in 8, 524283 runs, 5 skips
SSSE3:
2117 decicycles in 16, 262136 runs, 8 skips
814 decicycles in 8, 262143 runs, 1 skips
SSSE3 with fast path:
1315 decicycles in 16, 524285 runs, 3 skips
578 decicycles in 8, 524286 runs, 2 skips
This means around a 4% speedup for some sequences.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-01-12 00:11:15 +01:00
|
|
|
DECLARE_WEIGHT(sse2)
|
|
|
|
DECLARE_WEIGHT(ssse3)
|
|
|
|
|
2012-04-19 22:36:17 +02:00
|
|
|
/** @{ */
|
|
|
|
/**
|
|
|
|
* Define one qpel function.
|
|
|
|
* LOOPSIZE must be already set to the number of pixels processed per
|
|
|
|
* iteration in the inner loop of the called functions.
|
|
|
|
* COFF(x) must be already defined so as to provide the offset into any
|
|
|
|
* array of coeffs used by the called function for the qpel position x.
|
|
|
|
*/
|
|
|
|
#define QPEL_FUNC_DECL(OP, SIZE, PH, PV, OPT) \
|
|
|
|
static void OP ## rv40_qpel ##SIZE ##_mc ##PH ##PV ##OPT(uint8_t *dst, \
|
|
|
|
uint8_t *src, \
|
|
|
|
int stride) \
|
|
|
|
{ \
|
|
|
|
int i; \
|
|
|
|
if (PH && PV) { \
|
|
|
|
DECLARE_ALIGNED(16, uint8_t, tmp)[SIZE * (SIZE + 5)]; \
|
|
|
|
uint8_t *tmpptr = tmp + SIZE * 2; \
|
|
|
|
src -= stride * 2; \
|
|
|
|
\
|
|
|
|
for (i = 0; i < SIZE; i += LOOPSIZE) \
|
|
|
|
ff_put_rv40_qpel_h ##OPT(tmp + i, SIZE, src + i, stride, \
|
|
|
|
SIZE + 5, HCOFF(PH)); \
|
|
|
|
for (i = 0; i < SIZE; i += LOOPSIZE) \
|
|
|
|
ff_ ##OP ##rv40_qpel_v ##OPT(dst + i, stride, tmpptr + i, \
|
|
|
|
SIZE, SIZE, VCOFF(PV)); \
|
|
|
|
} else if (PV) { \
|
|
|
|
for (i = 0; i < SIZE; i += LOOPSIZE) \
|
|
|
|
ff_ ##OP ##rv40_qpel_v ## OPT(dst + i, stride, src + i, \
|
|
|
|
stride, SIZE, VCOFF(PV)); \
|
|
|
|
} else { \
|
|
|
|
for (i = 0; i < SIZE; i += LOOPSIZE) \
|
|
|
|
ff_ ##OP ##rv40_qpel_h ## OPT(dst + i, stride, src + i, \
|
|
|
|
stride, SIZE, HCOFF(PH)); \
|
|
|
|
} \
|
|
|
|
};
|
|
|
|
|
|
|
|
/** Declare functions for sizes 8 and 16 and given operations
|
|
|
|
* and qpel position. */
|
|
|
|
#define QPEL_FUNCS_DECL(OP, PH, PV, OPT) \
|
|
|
|
QPEL_FUNC_DECL(OP, 8, PH, PV, OPT) \
|
|
|
|
QPEL_FUNC_DECL(OP, 16, PH, PV, OPT)
|
|
|
|
|
|
|
|
/** Declare all functions for all sizes and qpel positions */
|
|
|
|
#define QPEL_MC_DECL(OP, OPT) \
|
|
|
|
void ff_ ##OP ##rv40_qpel_h ##OPT(uint8_t *dst, ptrdiff_t dstStride, \
|
|
|
|
const uint8_t *src, \
|
|
|
|
ptrdiff_t srcStride, \
|
|
|
|
int len, int m); \
|
|
|
|
void ff_ ##OP ##rv40_qpel_v ##OPT(uint8_t *dst, ptrdiff_t dstStride, \
|
|
|
|
const uint8_t *src, \
|
|
|
|
ptrdiff_t srcStride, \
|
|
|
|
int len, int m); \
|
|
|
|
QPEL_FUNCS_DECL(OP, 0, 1, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 0, 3, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 1, 0, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 1, 1, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 1, 2, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 1, 3, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 2, 1, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 2, 2, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 2, 3, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 3, 0, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 3, 1, OPT) \
|
|
|
|
QPEL_FUNCS_DECL(OP, 3, 2, OPT)
|
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#define LOOPSIZE 8
|
|
|
|
#define HCOFF(x) (32 * (x - 1))
|
|
|
|
#define VCOFF(x) (32 * (x - 1))
|
|
|
|
QPEL_MC_DECL(put_, _ssse3)
|
|
|
|
QPEL_MC_DECL(avg_, _ssse3)
|
|
|
|
|
|
|
|
#undef LOOPSIZE
|
|
|
|
#undef HCOFF
|
|
|
|
#undef VCOFF
|
|
|
|
#define LOOPSIZE 8
|
|
|
|
#define HCOFF(x) (64 * (x - 1))
|
|
|
|
#define VCOFF(x) (64 * (x - 1))
|
|
|
|
QPEL_MC_DECL(put_, _sse2)
|
|
|
|
QPEL_MC_DECL(avg_, _sse2)
|
|
|
|
|
|
|
|
#if ARCH_X86_32
|
|
|
|
#undef LOOPSIZE
|
|
|
|
#undef HCOFF
|
|
|
|
#undef VCOFF
|
|
|
|
#define LOOPSIZE 4
|
|
|
|
#define HCOFF(x) (64 * (x - 1))
|
|
|
|
#define VCOFF(x) (64 * (x - 1))
|
|
|
|
|
|
|
|
QPEL_MC_DECL(put_, _mmx)
|
|
|
|
|
|
|
|
#define ff_put_rv40_qpel_h_mmx2 ff_put_rv40_qpel_h_mmx
|
|
|
|
#define ff_put_rv40_qpel_v_mmx2 ff_put_rv40_qpel_v_mmx
|
|
|
|
QPEL_MC_DECL(avg_, _mmx2)
|
|
|
|
|
|
|
|
#define ff_put_rv40_qpel_h_3dnow ff_put_rv40_qpel_h_mmx
|
|
|
|
#define ff_put_rv40_qpel_v_3dnow ff_put_rv40_qpel_v_mmx
|
|
|
|
QPEL_MC_DECL(avg_, _3dnow)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** @{ */
|
|
|
|
/** Set one function */
|
|
|
|
#define QPEL_FUNC_SET(OP, SIZE, PH, PV, OPT) \
|
|
|
|
c-> OP ## pixels_tab[2 - SIZE / 8][4 * PV + PH] = OP ## rv40_qpel ##SIZE ## _mc ##PH ##PV ##OPT;
|
|
|
|
|
|
|
|
/** Set functions put and avg for sizes 8 and 16 and a given qpel position */
|
|
|
|
#define QPEL_FUNCS_SET(OP, PH, PV, OPT) \
|
|
|
|
QPEL_FUNC_SET(OP, 8, PH, PV, OPT) \
|
|
|
|
QPEL_FUNC_SET(OP, 16, PH, PV, OPT)
|
|
|
|
|
|
|
|
/** Set all functions for all sizes and qpel positions */
|
|
|
|
#define QPEL_MC_SET(OP, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 0, 1, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 0, 3, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 1, 0, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 1, 1, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 1, 2, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 1, 3, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 2, 1, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 2, 2, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 2, 3, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 3, 0, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 3, 1, OPT) \
|
|
|
|
QPEL_FUNCS_SET (OP, 3, 2, OPT)
|
|
|
|
/** @} */
|
|
|
|
|
2012-08-29 11:14:17 +02:00
|
|
|
#endif /* HAVE_YASM */
|
2012-06-10 03:26:24 +02:00
|
|
|
|
2011-08-09 11:00:09 +02:00
|
|
|
void ff_rv40dsp_init_x86(RV34DSPContext *c, DSPContext *dsp)
|
|
|
|
{
|
|
|
|
#if HAVE_YASM
|
2012-01-30 09:39:16 +01:00
|
|
|
int mm_flags = av_get_cpu_flags();
|
|
|
|
|
2012-08-29 19:01:05 +02:00
|
|
|
if (EXTERNAL_MMX(mm_flags)) {
|
2011-08-09 11:00:09 +02:00
|
|
|
c->put_chroma_pixels_tab[0] = ff_put_rv40_chroma_mc8_mmx;
|
|
|
|
c->put_chroma_pixels_tab[1] = ff_put_rv40_chroma_mc4_mmx;
|
2012-10-05 19:54:10 +02:00
|
|
|
#if HAVE_MMX_INLINE
|
2012-04-19 22:36:17 +02:00
|
|
|
c->put_pixels_tab[0][15] = ff_put_rv40_qpel16_mc33_mmx;
|
|
|
|
c->put_pixels_tab[1][15] = ff_put_rv40_qpel8_mc33_mmx;
|
|
|
|
c->avg_pixels_tab[0][15] = ff_avg_rv40_qpel16_mc33_mmx;
|
|
|
|
c->avg_pixels_tab[1][15] = ff_avg_rv40_qpel8_mc33_mmx;
|
2012-10-05 19:54:10 +02:00
|
|
|
#endif /* HAVE_MMX_INLINE */
|
2012-04-19 22:36:17 +02:00
|
|
|
#if ARCH_X86_32
|
|
|
|
QPEL_MC_SET(put_, _mmx)
|
|
|
|
#endif
|
2011-08-09 11:00:09 +02:00
|
|
|
}
|
2012-08-29 19:01:05 +02:00
|
|
|
if (EXTERNAL_MMXEXT(mm_flags)) {
|
2011-08-09 11:00:09 +02:00
|
|
|
c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_mmx2;
|
|
|
|
c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_mmx2;
|
2012-05-10 23:44:04 +02:00
|
|
|
c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_mmx2;
|
|
|
|
c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_mmx2;
|
|
|
|
c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_mmx2;
|
|
|
|
c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_mmx2;
|
2012-04-19 22:36:17 +02:00
|
|
|
#if ARCH_X86_32
|
|
|
|
QPEL_MC_SET(avg_, _mmx2)
|
|
|
|
#endif
|
2012-08-29 19:01:05 +02:00
|
|
|
} else if (EXTERNAL_AMD3DNOW(mm_flags)) {
|
2011-08-09 11:00:09 +02:00
|
|
|
c->avg_chroma_pixels_tab[0] = ff_avg_rv40_chroma_mc8_3dnow;
|
|
|
|
c->avg_chroma_pixels_tab[1] = ff_avg_rv40_chroma_mc4_3dnow;
|
2012-04-19 22:36:17 +02:00
|
|
|
#if ARCH_X86_32
|
|
|
|
QPEL_MC_SET(avg_, _3dnow)
|
|
|
|
#endif
|
2011-08-09 11:00:09 +02:00
|
|
|
}
|
2012-08-29 19:01:05 +02:00
|
|
|
if (EXTERNAL_SSE2(mm_flags)) {
|
2012-03-19 22:46:28 +01:00
|
|
|
c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_sse2;
|
|
|
|
c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_sse2;
|
|
|
|
c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_sse2;
|
|
|
|
c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_sse2;
|
2012-04-19 22:36:17 +02:00
|
|
|
QPEL_MC_SET(put_, _sse2)
|
|
|
|
QPEL_MC_SET(avg_, _sse2)
|
rv40: x86 SIMD for biweight
Provide MMX, SSE2 and SSSE3 versions, with a fast-path when the weights are
multiples of 512 (which is often the case when the values round up nicely).
*_TIMER report for the 16x16 and 8x8 cases:
C:
9015 decicycles in 16, 524257 runs, 31 skips
2656 decicycles in 8, 524271 runs, 17 skips
MMX:
4156 decicycles in 16, 262090 runs, 54 skips
1206 decicycles in 8, 262131 runs, 13 skips
MMX on fast-path:
2760 decicycles in 16, 524222 runs, 66 skips
995 decicycles in 8, 524252 runs, 36 skips
SSE2:
2163 decicycles in 16, 262131 runs, 13 skips
832 decicycles in 8, 262137 runs, 7 skips
SSE2 with fast path:
1783 decicycles in 16, 524276 runs, 12 skips
711 decicycles in 8, 524283 runs, 5 skips
SSSE3:
2117 decicycles in 16, 262136 runs, 8 skips
814 decicycles in 8, 262143 runs, 1 skips
SSSE3 with fast path:
1315 decicycles in 16, 524285 runs, 3 skips
578 decicycles in 8, 524286 runs, 2 skips
This means around a 4% speedup for some sequences.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-01-12 00:11:15 +01:00
|
|
|
}
|
2012-08-29 19:01:05 +02:00
|
|
|
if (EXTERNAL_SSSE3(mm_flags)) {
|
2012-03-19 22:46:28 +01:00
|
|
|
c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_ssse3;
|
|
|
|
c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_ssse3;
|
|
|
|
c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_ssse3;
|
|
|
|
c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_ssse3;
|
2012-04-19 22:36:17 +02:00
|
|
|
QPEL_MC_SET(put_, _ssse3)
|
|
|
|
QPEL_MC_SET(avg_, _ssse3)
|
rv40: x86 SIMD for biweight
Provide MMX, SSE2 and SSSE3 versions, with a fast-path when the weights are
multiples of 512 (which is often the case when the values round up nicely).
*_TIMER report for the 16x16 and 8x8 cases:
C:
9015 decicycles in 16, 524257 runs, 31 skips
2656 decicycles in 8, 524271 runs, 17 skips
MMX:
4156 decicycles in 16, 262090 runs, 54 skips
1206 decicycles in 8, 262131 runs, 13 skips
MMX on fast-path:
2760 decicycles in 16, 524222 runs, 66 skips
995 decicycles in 8, 524252 runs, 36 skips
SSE2:
2163 decicycles in 16, 262131 runs, 13 skips
832 decicycles in 8, 262137 runs, 7 skips
SSE2 with fast path:
1783 decicycles in 16, 524276 runs, 12 skips
711 decicycles in 8, 524283 runs, 5 skips
SSSE3:
2117 decicycles in 16, 262136 runs, 8 skips
814 decicycles in 8, 262143 runs, 1 skips
SSSE3 with fast path:
1315 decicycles in 16, 524285 runs, 3 skips
578 decicycles in 8, 524286 runs, 2 skips
This means around a 4% speedup for some sequences.
Signed-off-by: Diego Biurrun <diego@biurrun.de>
2012-01-12 00:11:15 +01:00
|
|
|
}
|
2012-08-29 15:05:53 +02:00
|
|
|
#endif /* HAVE_YASM */
|
2011-08-09 11:00:09 +02:00
|
|
|
}
|