]> git.sesse.net Git - vlc/blob - modules/video_filter/deinterlace/merge.h
LGPL
[vlc] / modules / video_filter / deinterlace / merge.h
1 /*****************************************************************************
2  * merge.h : Merge (line blending) routines for the VLC deinterlacer
3  *****************************************************************************
4  * Copyright (C) 2011 VLC authors and VideoLAN
5  * $Id$
6  *
7  * Author: Sam Hocevar <sam@zoy.org>                      (generic C routine)
8  *         Sigmund Augdal Helberg <sigmunau@videolan.org> (MMXEXT, 3DNow, SSE2)
9  *         Eric Petit <eric.petit@lapsus.org>             (Altivec)
10  *         RĂ©mi Denis-Courmont <remi@remlab.net>          (ARM NEON)
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU Lesser General Public License as published by
14  * the Free Software Foundation; either version 2.1 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU Lesser General Public License for more details.
21  *
22  * You should have received a copy of the GNU Lesser General Public License
23  * along with this program; if not, write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25  *****************************************************************************/
26
27 #ifndef VLC_DEINTERLACE_MERGE_H
28 #define VLC_DEINTERLACE_MERGE_H 1
29
30 /**
31  * \file
32  * Merge (line blending) routines for the VLC deinterlacer.
33  */
34
35 /*****************************************************************************
36  * Macros
37  *****************************************************************************/
38
39 /* Convenient Merge() and EndMerge() macros to pick the most appropriate
40    merge implementation automatically.
41
42    Note that you'll need to include vlc_filter.h and deinterlace.h
43    to use these.
44
45  * Note that the Open() call of the deinterlace filter automatically selects
46  * the most appropriate merge routine based on the CPU capabilities.
47  * You can call the most appropriate version automatically, from a function
48  * in the deinterlace filter, by using the Merge() macro.
49  *
50  * Note that the filter instance (p_filter) must be available for the Merge()
51  * macro to work, because it needs the detection result from the filter's
52  * Open().
53  *
54  * Macro syntax:
55  *   Merge( _p_dest, _p_s1, _p_s2, i_bytes );
56  *
57   * i_bytes > 0; no other restrictions. This holds for all versions of the
58  * merge routine.
59  *
60  */
61 #define Merge p_filter->p_sys->pf_merge
62
63 /*
64  * EndMerge() macro, which must be called after the merge is
65  * finished, if the Merge() macro was used to perform the merge.
66  */
67 #if defined(__i386__) || defined(__x86_64__)
68 # define EndMerge() \
69     if(p_filter->p_sys->pf_end_merge) (p_filter->p_sys->pf_end_merge)()
70 #else
71 # define EndMerge() (void)0
72 #endif
73
74 /*****************************************************************************
75  * Merge routines
76  *****************************************************************************/
77
78 /**
79  * Generic routine to blend 8 bit pixels from two picture lines.
80  * No inline assembler acceleration.
81  *
82  * @param _p_dest Target line. Blend result = (A + B)/2.
83  * @param _p_s1 Source line A.
84  * @param _p_s2 Source line B.
85  * @param i_bytes Number of bytes to merge.
86  * @see Open()
87  */
88 void Merge8BitGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
89                        size_t i_bytes );
90
91 /**
92  * Generic routine to blend 16 bit pixels from two picture lines.
93  * No inline assembler acceleration.
94  *
95  * @param _p_dest Target line. Blend result = (A + B)/2.
96  * @param _p_s1 Source line A.
97  * @param _p_s2 Source line B.
98  * @param i_bytes Number of *bytes* to merge.
99  * @see Open()
100  */
101 void Merge16BitGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
102                         size_t i_bytes );
103
104 #if defined(CAN_COMPILE_C_ALTIVEC)
105 /**
106  * Altivec routine to blend pixels from two picture lines.
107  *
108  * @param _p_dest Target
109  * @param _p_s1 Source line A
110  * @param _p_s2 Source line B
111  * @param i_bytes Number of bytes to merge
112  */
113 void MergeAltivec ( void *, const void *, const void *, size_t );
114 #endif
115
116 #if defined(CAN_COMPILE_MMXEXT)
117 /**
118  * MMXEXT routine to blend pixels from two picture lines.
119  *
120  * @param _p_dest Target
121  * @param _p_s1 Source line A
122  * @param _p_s2 Source line B
123  * @param i_bytes Number of bytes to merge
124  */
125 void MergeMMXEXT  ( void *, const void *, const void *, size_t );
126 #endif
127
128 #if defined(CAN_COMPILE_3DNOW)
129 /**
130  * 3DNow routine to blend pixels from two picture lines.
131  *
132  * @param _p_dest Target
133  * @param _p_s1 Source line A
134  * @param _p_s2 Source line B
135  * @param i_bytes Number of bytes to merge
136  */
137 void Merge3DNow   ( void *, const void *, const void *, size_t );
138 #endif
139
140 #if defined(CAN_COMPILE_SSE)
141 /**
142  * SSE2 routine to blend pixels from two picture lines.
143  *
144  * @param _p_dest Target
145  * @param _p_s1 Source line A
146  * @param _p_s2 Source line B
147  * @param i_bytes Number of bytes to merge
148  */
149 void Merge8BitSSE2( void *, const void *, const void *, size_t );
150 /**
151  * SSE2 routine to blend pixels from two picture lines.
152  *
153  * @param _p_dest Target
154  * @param _p_s1 Source line A
155  * @param _p_s2 Source line B
156  * @param i_bytes Number of bytes to merge
157  */
158 void Merge16BitSSE2( void *, const void *, const void *, size_t );
159 #endif
160
161 #if defined(CAN_COMPILE_ARM)
162 /**
163  * ARM NEON routine to blend pixels from two picture lines.
164  */
165 void merge8_arm_neon (void *, const void *, const void *, size_t);
166 void merge16_arm_neon (void *, const void *, const void *, size_t);
167
168 /**
169  * ARMv6 SIMD routine to blend pixels from two picture lines.
170  */
171 void merge8_armv6 (void *, const void *, const void *, size_t);
172 void merge16_armv6 (void *, const void *, const void *, size_t);
173 #endif
174
175 /*****************************************************************************
176  * EndMerge routines
177  *****************************************************************************/
178
179 #if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE)
180 /**
181  * MMX merge finalization routine.
182  *
183  * Must be called after an MMX merge is finished.
184  * This exits MMX mode (by executing the "emms" instruction).
185  *
186  * The EndMerge() macro detects whether this is needed, and calls if it is,
187  * so just use that.
188  */
189 void EndMMX       ( void );
190 #endif
191
192 #if defined(CAN_COMPILE_3DNOW)
193 /**
194  * 3DNow merge finalization routine.
195  *
196  * Must be called after a 3DNow merge is finished.
197  * This exits 3DNow mode (by executing the "femms" instruction).
198  *
199  * The EndMerge() macro detects whether this is needed, and calls if it is,
200  * so just use that.
201  */
202 void End3DNow     ( void );
203 #endif
204
205 #endif