FFmpeg
Loading...
Searching...
No Matches
rv40dsp_init.c
Go to the documentation of this file.
1/*
2 * RV40 decoder motion compensation functions x86-optimised
3 * Copyright (c) 2008 Konstantin Shishkov
4 *
5 * This file is part of FFmpeg.
6 *
7 * FFmpeg is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * FFmpeg is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
22/**
23 * @file
24 * RV40 decoder motion compensation functions x86-optimised
25 * 2,0 and 0,2 have h264 equivalents.
26 * 3,3 is bugged in the rv40 format and maps to _xy2 version
27 */
28
29#include "libavcodec/rv34dsp.h"
32#include "libavutil/x86/cpu.h"
33#include "hpeldsp.h"
34
35#define DEFINE_FN(op, size, insn) \
36static void op##_rv40_qpel##size##_mc33_##insn(uint8_t *dst, const uint8_t *src, \
37 ptrdiff_t stride) \
38{ \
39 ff_##op##_pixels##size##_xy2_##insn(dst, src, stride, size); \
40}
41
42#define DECLARE_WEIGHT(opt) \
43void ff_rv40_weight_func_rnd_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
44 int w1, int w2, ptrdiff_t stride); \
45void ff_rv40_weight_func_rnd_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
46 int w1, int w2, ptrdiff_t stride); \
47void ff_rv40_weight_func_nornd_16_##opt(uint8_t *dst, uint8_t *src1, uint8_t *src2, \
48 int w1, int w2, ptrdiff_t stride); \
49void ff_rv40_weight_func_nornd_8_##opt (uint8_t *dst, uint8_t *src1, uint8_t *src2, \
50 int w1, int w2, ptrdiff_t stride);
52DECLARE_WEIGHT(ssse3)
53
54/** @{ */
55/**
56 * Define one qpel function.
57 * LOOPSIZE must be already set to the number of pixels processed per
58 * iteration in the inner loop of the called functions.
59 * COFF(x) must be already defined so as to provide the offset into any
60 * array of coeffs used by the called function for the qpel position x.
61 */
62#define QPEL_FUNC_DECL(OP, SIZE, PH, PV, OPT) \
63static void OP ## rv40_qpel ##SIZE ##_mc ##PH ##PV ##OPT(uint8_t *dst, \
64 const uint8_t *src, \
65 ptrdiff_t stride) \
66{ \
67 int i; \
68 if (PH && PV) { \
69 LOCAL_ALIGNED(16, uint8_t, tmp, [SIZE * (SIZE + 5)]); \
70 uint8_t *tmpptr = tmp + SIZE * 2; \
71 src -= stride * 2; \
72 \
73 for (i = 0; i < SIZE; i += LOOPSIZE) \
74 ff_put_rv40_qpel_h ##OPT(tmp + i, SIZE, src + i, stride, \
75 SIZE + 5, HCOFF(PH)); \
76 for (i = 0; i < SIZE; i += LOOPSIZE) \
77 ff_ ##OP ##rv40_qpel_v ##OPT(dst + i, stride, tmpptr + i, \
78 SIZE, SIZE, VCOFF(PV)); \
79 } else if (PV) { \
80 for (i = 0; i < SIZE; i += LOOPSIZE) \
81 ff_ ##OP ##rv40_qpel_v ## OPT(dst + i, stride, src + i, \
82 stride, SIZE, VCOFF(PV)); \
83 } else { \
84 for (i = 0; i < SIZE; i += LOOPSIZE) \
85 ff_ ##OP ##rv40_qpel_h ## OPT(dst + i, stride, src + i, \
86 stride, SIZE, HCOFF(PH)); \
87 } \
88}
89
90/** Declare functions for sizes 8 and 16 and given operations
91 * and qpel position. */
92#define QPEL_FUNCS_DECL(OP, PH, PV, OPT) \
93 QPEL_FUNC_DECL(OP, 8, PH, PV, OPT) \
94 QPEL_FUNC_DECL(OP, 16, PH, PV, OPT)
95
96/** Declare all functions for all sizes and qpel positions */
97#define QPEL_MC_DECL(OP, OPT) \
98void ff_ ##OP ##rv40_qpel_h ##OPT(uint8_t *dst, ptrdiff_t dstStride, \
99 const uint8_t *src, \
100 ptrdiff_t srcStride, \
101 int len, int m); \
102void ff_ ##OP ##rv40_qpel_v ##OPT(uint8_t *dst, ptrdiff_t dstStride, \
103 const uint8_t *src, \
104 ptrdiff_t srcStride, \
105 int len, int m); \
106QPEL_FUNCS_DECL(OP, 0, 1, OPT) \
107QPEL_FUNCS_DECL(OP, 0, 3, OPT) \
108QPEL_FUNCS_DECL(OP, 1, 0, OPT) \
109QPEL_FUNCS_DECL(OP, 1, 1, OPT) \
110QPEL_FUNCS_DECL(OP, 1, 2, OPT) \
111QPEL_FUNCS_DECL(OP, 1, 3, OPT) \
112QPEL_FUNCS_DECL(OP, 2, 1, OPT) \
113QPEL_FUNCS_DECL(OP, 2, 2, OPT) \
114QPEL_FUNCS_DECL(OP, 2, 3, OPT) \
115QPEL_FUNCS_DECL(OP, 3, 0, OPT) \
116QPEL_FUNCS_DECL(OP, 3, 1, OPT) \
117QPEL_FUNCS_DECL(OP, 3, 2, OPT)
118/** @} */
119
120#define LOOPSIZE 8
121#define HCOFF(x) (32 * ((x) - 1))
122#define VCOFF(x) (32 * ((x) - 1))
123QPEL_MC_DECL(put_, _ssse3)
124QPEL_MC_DECL(avg_, _ssse3)
125
126#undef LOOPSIZE
127#undef HCOFF
128#undef VCOFF
129#define LOOPSIZE 8
130#define HCOFF(x) (64 * ((x) - 1))
131#define VCOFF(x) (64 * ((x) - 1))
132QPEL_MC_DECL(put_, _sse2)
133QPEL_MC_DECL(avg_, _sse2)
134
135/** @{ */
136/** Set one function */
137#define QPEL_FUNC_SET(OP, SIZE, PH, PV, OPT) \
138 c-> OP ## pixels_tab[2 - SIZE / 8][4 * PV + PH] = OP ## rv40_qpel ##SIZE ## _mc ##PH ##PV ##OPT;
139
140/** Set functions put and avg for sizes 8 and 16 and a given qpel position */
141#define QPEL_FUNCS_SET(OP, PH, PV, OPT) \
142 QPEL_FUNC_SET(OP, 8, PH, PV, OPT) \
143 QPEL_FUNC_SET(OP, 16, PH, PV, OPT)
144
145/** Set all functions for all sizes and qpel positions */
146#define QPEL_MC_SET(OP, OPT) \
147QPEL_FUNCS_SET (OP, 0, 1, OPT) \
148QPEL_FUNCS_SET (OP, 0, 3, OPT) \
149QPEL_FUNCS_SET (OP, 1, 0, OPT) \
150QPEL_FUNCS_SET (OP, 1, 1, OPT) \
151QPEL_FUNCS_SET (OP, 1, 2, OPT) \
152QPEL_FUNCS_SET (OP, 1, 3, OPT) \
153QPEL_FUNCS_SET (OP, 2, 1, OPT) \
154QPEL_FUNCS_SET (OP, 2, 2, OPT) \
155QPEL_FUNCS_SET (OP, 2, 3, OPT) \
156QPEL_FUNCS_SET (OP, 3, 0, OPT) \
157QPEL_FUNCS_SET (OP, 3, 1, OPT) \
158QPEL_FUNCS_SET (OP, 3, 2, OPT)
159/** @} */
160
161DEFINE_FN(put, 8, ssse3)
162
163DEFINE_FN(put, 16, sse2)
164DEFINE_FN(put, 16, ssse3)
165
166DEFINE_FN(avg, 8, ssse3)
167
168DEFINE_FN(avg, 16, sse2)
169DEFINE_FN(avg, 16, ssse3)
170
171#define CHROMA_MC_FUNC(OP, SIZE, XMM) \
172void ff_rv40_ ## OP ## _chroma_mc ## SIZE ## _ ## XMM(uint8_t *dst, const uint8_t *src, \
173 ptrdiff_t stride, int h, int x, int y);\
174 c->OP ## _chroma_pixels_tab[SIZE == 4] = ff_rv40_ ## OP ## _chroma_mc ## SIZE ## _ ## XMM
175
177{
179
181 c->put_pixels_tab[0][15] = put_rv40_qpel16_mc33_sse2;
182 c->avg_pixels_tab[0][15] = avg_rv40_qpel16_mc33_sse2;
183 c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_sse2;
184 c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_sse2;
185 c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_sse2;
186 c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_sse2;
187 QPEL_MC_SET(put_, _sse2)
188 QPEL_MC_SET(avg_, _sse2)
189 }
191 CHROMA_MC_FUNC(put, 8, ssse3);
192 CHROMA_MC_FUNC(put, 4, ssse3);
193 CHROMA_MC_FUNC(avg, 8, ssse3);
194 CHROMA_MC_FUNC(avg, 4, ssse3);
195 c->put_pixels_tab[0][15] = put_rv40_qpel16_mc33_ssse3;
196 c->put_pixels_tab[1][15] = put_rv40_qpel8_mc33_ssse3;
197 c->avg_pixels_tab[0][15] = avg_rv40_qpel16_mc33_ssse3;
198 c->avg_pixels_tab[1][15] = avg_rv40_qpel8_mc33_ssse3;
199 c->rv40_weight_pixels_tab[0][0] = ff_rv40_weight_func_rnd_16_ssse3;
200 c->rv40_weight_pixels_tab[0][1] = ff_rv40_weight_func_rnd_8_ssse3;
201 c->rv40_weight_pixels_tab[1][0] = ff_rv40_weight_func_nornd_16_ssse3;
202 c->rv40_weight_pixels_tab[1][1] = ff_rv40_weight_func_nornd_8_ssse3;
203 QPEL_MC_SET(put_, _ssse3)
204 QPEL_MC_SET(avg_, _ssse3)
205 }
206}
#define avg(a, b, c, d)
Macro definitions for various function/variable attributes.
#define av_cold
Definition attributes.h:117
static atomic_int cpu_flags
Definition cpu.c:56
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition cpu.c:109
#define EXTERNAL_SSSE3(flags)
Definition cpu.h:59
#define EXTERNAL_SSE2(flags)
Definition cpu.h:53
RV30/40 decoder motion compensation functions.
static double c[64]
#define QPEL_MC_DECL(OP, OPT)
Declare all functions for all sizes and qpel positions.
av_cold void ff_rv40dsp_init_x86(RV34DSPContext *c)
#define DEFINE_FN(op, size, insn)
#define DECLARE_WEIGHT(opt)
#define CHROMA_MC_FUNC(OP, SIZE, XMM)
#define QPEL_MC_SET(OP, OPT)
Set all functions for all sizes and qpel positions.