FFmpeg
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vf_spp.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2003 Michael Niedermayer <michaelni@gmx.at>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with FFmpeg; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 
22 #include "libavutil/attributes.h"
23 #include "libavutil/cpu.h"
24 #include "libavfilter/vf_spp.h"
25 
26 #if HAVE_MMX_INLINE
27 static void store_slice_mmx(uint8_t *dst, const int16_t *src,
28  int dst_stride, int src_stride,
29  int width, int height, int log2_scale,
30  const uint8_t dither[8][8])
31 {
32  int y;
33 
34  for (y = 0; y < height; y++) {
35  uint8_t *dst1 = dst;
36  const int16_t *src1 = src;
37  __asm__ volatile(
38  "movq (%3), %%mm3 \n"
39  "movq (%3), %%mm4 \n"
40  "movd %4, %%mm2 \n"
41  "pxor %%mm0, %%mm0 \n"
42  "punpcklbw %%mm0, %%mm3 \n"
43  "punpckhbw %%mm0, %%mm4 \n"
44  "psraw %%mm2, %%mm3 \n"
45  "psraw %%mm2, %%mm4 \n"
46  "movd %5, %%mm2 \n"
47  "1: \n"
48  "movq (%0), %%mm0 \n"
49  "movq 8(%0), %%mm1 \n"
50  "paddw %%mm3, %%mm0 \n"
51  "paddw %%mm4, %%mm1 \n"
52  "psraw %%mm2, %%mm0 \n"
53  "psraw %%mm2, %%mm1 \n"
54  "packuswb %%mm1, %%mm0 \n"
55  "movq %%mm0, (%1) \n"
56  "add $16, %0 \n"
57  "add $8, %1 \n"
58  "cmp %2, %1 \n"
59  " jb 1b \n"
60  : "+r" (src1), "+r"(dst1)
61  : "r"(dst + width), "r"(dither[y]), "g"(log2_scale), "g"(MAX_LEVEL - log2_scale)
62  );
63  src += src_stride;
64  dst += dst_stride;
65  }
66 }
67 
68 #endif /* HAVE_MMX_INLINE */
69 
71 {
72 #if HAVE_MMX_INLINE
74 
75  if (cpu_flags & AV_CPU_FLAG_MMX) {
76  s->store_slice = store_slice_mmx;
77  }
78 #endif
79 }
src1
const pixel * src1
Definition: h264pred_template.c:420
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:109
cpu_flags
static atomic_int cpu_flags
Definition: cpu.c:56
av_cold
#define av_cold
Definition: attributes.h:90
s
#define s(width, name)
Definition: cbs_vp9.c:198
vf_spp.h
SPPContext
Definition: vf_spp.h:31
MAX_LEVEL
#define MAX_LEVEL
Definition: rl.h:36
height
#define height
Definition: dsp.h:89
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:87
cpu.h
attributes.h
__asm__
__asm__(".macro parse_r var r\n\t" "\\var = -1\n\t" _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) ".iflt \\var\n\t" ".error \"Unable to parse register name \\r\"\n\t" ".endif\n\t" ".endm")
AV_CPU_FLAG_MMX
#define AV_CPU_FLAG_MMX
standard MMX
Definition: cpu.h:30
width
#define width
Definition: dsp.h:89
src
#define src
Definition: vp8dsp.c:248
ff_spp_init_x86
av_cold void ff_spp_init_x86(SPPContext *s)
Definition: vf_spp.c:70
dither
static const uint8_t dither[8][8]
Definition: vf_fspp.c:62