FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
libavfilter
x86
vf_eq.c
Go to the documentation of this file.
1
/*
2
*
3
* Original MPlayer filters by Richard Felker.
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
10
* (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
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License along
18
* with FFmpeg; if not, write to the Free Software Foundation, Inc.,
19
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
*/
21
22
#include "
libavutil/attributes.h
"
23
#include "
libavutil/cpu.h
"
24
#include "
libavutil/mem.h
"
25
#include "
libavutil/x86/asm.h
"
26
#include "
libavfilter/vf_eq.h
"
27
28
#if HAVE_MMX_INLINE && HAVE_6REGS
29
static
void
process_MMX(
EQParameters
*param,
uint8_t
*dst,
int
dst_stride,
30
const
uint8_t
*
src
,
int
src_stride,
int
w,
int
h
)
31
{
32
int
i;
33
int
pel;
34
int
dstep = dst_stride - w;
35
int
sstep = src_stride - w;
36
short
brvec[4];
37
short
contvec[4];
38
int
contrast = (
int
) (param->
contrast
* 256 * 16);
39
int
brightness = ((
int
) (100.0 * param->
brightness
+ 100.0) * 511) / 200 - 128 - contrast / 32;
40
41
brvec[0] = brvec[1] = brvec[2] = brvec[3] = brightness;
42
contvec[0] = contvec[1] = contvec[2] = contvec[3] = contrast;
43
44
while
(h--) {
45
__asm__
volatile
(
46
"movq (%5), %%mm3 \n\t"
47
"movq (%6), %%mm4 \n\t"
48
"pxor %%mm0, %%mm0 \n\t"
49
"movl %4, %%eax \n\t"
50
".p2align 4 \n\t"
51
"1: \n\t"
52
"movq (%0), %%mm1 \n\t"
53
"movq (%0), %%mm2 \n\t"
54
"punpcklbw %%mm0, %%mm1\n\t"
55
"punpckhbw %%mm0, %%mm2\n\t"
56
"psllw $4, %%mm1 \n\t"
57
"psllw $4, %%mm2 \n\t"
58
"pmulhw %%mm4, %%mm1 \n\t"
59
"pmulhw %%mm4, %%mm2 \n\t"
60
"paddw %%mm3, %%mm1 \n\t"
61
"paddw %%mm3, %%mm2 \n\t"
62
"packuswb %%mm2, %%mm1 \n\t"
63
"add $8, %0 \n\t"
64
"movq %%mm1, (%1) \n\t"
65
"add $8, %1 \n\t"
66
"decl %%eax \n\t"
67
"jnz 1b \n\t"
68
:
"=r"
(
src
),
"=r"
(dst)
69
:
"0"
(
src
),
"1"
(dst),
"r"
(w>>3),
"r"
(brvec),
"r"
(contvec)
70
:
"%eax"
71
);
72
73
for
(i = w&7; i; i--) {
74
pel = ((*src++ * contrast) >> 12) + brightness;
75
if
(pel & ~255)
76
pel = (-pel) >> 31;
77
*dst++ = pel;
78
}
79
80
src += sstep;
81
dst += dstep;
82
}
83
__asm__
volatile
(
"emms \n\t"
:::
"memory"
);
84
}
85
#endif
86
87
av_cold
void
ff_eq_init_x86
(
EQContext
*
eq
)
88
{
89
#if HAVE_MMX_INLINE && HAVE_6REGS
90
int
cpu_flags
=
av_get_cpu_flags
();
91
92
if
(cpu_flags &
AV_CPU_FLAG_MMX
) {
93
eq->
process
= process_MMX;
94
}
95
#endif
96
}
h
h
Definition:
vp9dsp_template.c:2038
EQParameters
Definition:
vf_eq.h:47
asm.h
mem.h
Memory handling functions.
EQParameters::contrast
double contrast
Definition:
vf_eq.h:53
cpu_flags
static atomic_int cpu_flags
Definition:
cpu.c:48
src
#define src
Definition:
vp8dsp.c:254
attributes.h
Macro definitions for various function/variable attributes.
uint8_t
uint8_t
Definition:
audio_convert.c:194
av_cold
#define av_cold
Definition:
attributes.h:82
ff_eq_init_x86
av_cold void ff_eq_init_x86(EQContext *eq)
Definition:
vf_eq.c:87
EQContext::process
void(* process)(struct EQParameters *par, uint8_t *dst, int dst_stride, const uint8_t *src, int src_stride, int w, int h)
Definition:
vf_eq.h:97
eq
#define eq(A, B)
Definition:
vf_xbr.c:91
EQContext
Definition:
vf_eq.h:58
EQParameters::brightness
double brightness
Definition:
vf_eq.h:53
vf_eq.h
cpu.h
AV_CPU_FLAG_MMX
#define AV_CPU_FLAG_MMX
standard MMX
Definition:
cpu.h:29
av_get_cpu_flags
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition:
cpu.c:89
int
int
Definition:
ffmpeg_filter.c:190
Generated on Fri Jan 12 2018 01:45:53 for FFmpeg by
1.8.6