vp3dsp_init.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 David Conrad <lessen42@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (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 GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #include <stdint.h>
22 
23 #include "libavutil/attributes.h"
24 #include "libavutil/cpu.h"
25 #include "libavutil/x86/cpu.h"
26 #include "libavutil/x86/asm.h"
27 #include "libavcodec/avcodec.h"
28 #include "libavcodec/dsputil.h"
29 #include "libavcodec/vp3dsp.h"
30 #include "config.h"
31 
32 void ff_vp3_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block);
33 void ff_vp3_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block);
34 
35 void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, int16_t *block);
36 void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, int16_t *block);
37 
38 void ff_vp3_idct_dc_add_mmxext(uint8_t *dest, int line_size,
39  int16_t *block);
40 
42  int *bounding_values);
44  int *bounding_values);
45 
46 #if HAVE_INLINE_ASM
47 
48 #define MOVQ_BFE(regd) \
49  __asm__ volatile ( \
50  "pcmpeqd %%"#regd", %%"#regd" \n\t" \
51  "paddb %%"#regd", %%"#regd" \n\t" ::)
52 
53 #define PAVGBP_MMX_NO_RND(rega, regb, regr, regc, regd, regp) \
54  "movq "#rega", "#regr" \n\t" \
55  "movq "#regc", "#regp" \n\t" \
56  "pand "#regb", "#regr" \n\t" \
57  "pand "#regd", "#regp" \n\t" \
58  "pxor "#rega", "#regb" \n\t" \
59  "pxor "#regc", "#regd" \n\t" \
60  "pand %%mm6, "#regb" \n\t" \
61  "pand %%mm6, "#regd" \n\t" \
62  "psrlq $1, "#regb" \n\t" \
63  "psrlq $1, "#regd" \n\t" \
64  "paddb "#regb", "#regr" \n\t" \
65  "paddb "#regd", "#regp" \n\t"
66 
67 static void put_vp_no_rnd_pixels8_l2_mmx(uint8_t *dst, const uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h)
68 {
69 // START_TIMER
70  MOVQ_BFE(mm6);
71  __asm__ volatile(
72  "1: \n\t"
73  "movq (%1), %%mm0 \n\t"
74  "movq (%2), %%mm1 \n\t"
75  "movq (%1,%4), %%mm2 \n\t"
76  "movq (%2,%4), %%mm3 \n\t"
77  PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
78  "movq %%mm4, (%3) \n\t"
79  "movq %%mm5, (%3,%4) \n\t"
80 
81  "movq (%1,%4,2), %%mm0 \n\t"
82  "movq (%2,%4,2), %%mm1 \n\t"
83  "movq (%1,%5), %%mm2 \n\t"
84  "movq (%2,%5), %%mm3 \n\t"
85  "lea (%1,%4,4), %1 \n\t"
86  "lea (%2,%4,4), %2 \n\t"
87  PAVGBP_MMX_NO_RND(%%mm0, %%mm1, %%mm4, %%mm2, %%mm3, %%mm5)
88  "movq %%mm4, (%3,%4,2) \n\t"
89  "movq %%mm5, (%3,%5) \n\t"
90  "lea (%3,%4,4), %3 \n\t"
91  "subl $4, %0 \n\t"
92  "jnz 1b \n\t"
93  :"+r"(h), "+r"(a), "+r"(b), "+r"(dst)
94  :"r"((x86_reg)stride), "r"((x86_reg)3L*stride)
95  :"memory");
96 // STOP_TIMER("put_vp_no_rnd_pixels8_l2_mmx")
97 }
98 #endif /* HAVE_INLINE_ASM */
99 
101 {
102  int cpuflags = av_get_cpu_flags();
103 
104 #if HAVE_INLINE_ASM
105  c->put_no_rnd_pixels_l2 = put_vp_no_rnd_pixels8_l2_mmx;
106 #endif /* HAVE_INLINE_ASM */
107 
108 #if ARCH_X86_32
109  if (EXTERNAL_MMX(cpuflags)) {
112  }
113 #endif
114 
115  if (EXTERNAL_MMXEXT(cpuflags)) {
117 
118  if (!(flags & CODEC_FLAG_BITEXACT)) {
121  }
122  }
123 
124  if (EXTERNAL_SSE2(cpuflags)) {
127  }
128 }
#define EXTERNAL_MMX(flags)
Definition: x86/cpu.h:33
void ff_vp3_v_loop_filter_mmxext(uint8_t *src, int stride, int *bounding_values)
void(* put_no_rnd_pixels_l2)(uint8_t *dst, const uint8_t *a, const uint8_t *b, ptrdiff_t stride, int h)
Copy 8xH pixels from source to destination buffer using a bilinear filter with no rounding (i...
Definition: vp3dsp.h:36
int stride
Definition: mace.c:144
Macro definitions for various function/variable attributes.
void ff_vp3_idct_add_sse2(uint8_t *dest, int line_size, int16_t *block)
void(* idct_add)(uint8_t *dest, int line_size, int16_t *block)
Definition: vp3dsp.h:42
uint8_t
#define av_cold
Definition: attributes.h:78
#define b
Definition: input.c:42
#define CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
#define EXTERNAL_SSE2(flags)
Definition: x86/cpu.h:36
void ff_vp3_idct_put_sse2(uint8_t *dest, int line_size, int16_t *block)
external API header
void(* idct_put)(uint8_t *dest, int line_size, int16_t *block)
Definition: vp3dsp.h:41
void ff_vp3_idct_dc_add_mmxext(uint8_t *dest, int line_size, int16_t *block)
void ff_vp3_idct_add_mmx(uint8_t *dest, int line_size, int16_t *block)
#define L(x)
dest
Definition: start.py:60
AVS_Value src
Definition: avisynth_c.h:523
void(* h_loop_filter)(uint8_t *src, int stride, int *bounding_values)
Definition: vp3dsp.h:45
int av_get_cpu_flags(void)
Return the flags which specify extensions supported by the CPU.
Definition: cpu.c:30
void ff_vp3_h_loop_filter_mmxext(uint8_t *src, int stride, int *bounding_values)
static int flags
Definition: cpu.c:23
#define EXTERNAL_MMXEXT(flags)
Definition: x86/cpu.h:34
static double c[64]
av_cold void ff_vp3dsp_init_x86(VP3DSPContext *c, int flags)
Definition: vp3dsp_init.c:100
void ff_vp3_idct_put_mmx(uint8_t *dest, int line_size, int16_t *block)
DSP utils.
int x86_reg
else dst[i][x+y *dst_stride[i]]
Definition: vf_mcdeint.c:160
void(* v_loop_filter)(uint8_t *src, int stride, int *bounding_values)
Definition: vp3dsp.h:44
void(* idct_dc_add)(uint8_t *dest, int line_size, int16_t *block)
Definition: vp3dsp.h:43