1 /*****************************************************************************
2 * merge.h : Merge (line blending) routines for the VLC deinterlacer
3 *****************************************************************************
4 * Copyright (C) 2011 VLC authors and VideoLAN
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)
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.
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.
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 *****************************************************************************/
27 #ifndef VLC_DEINTERLACE_MERGE_H
28 #define VLC_DEINTERLACE_MERGE_H 1
32 * Merge (line blending) routines for the VLC deinterlacer.
35 /*****************************************************************************
37 *****************************************************************************/
39 /* Convenient Merge() and EndMerge() macros to pick the most appropriate
40 merge implementation automatically.
42 Note that you'll need to include vlc_filter.h and deinterlace.h
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.
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
55 * Merge( _p_dest, _p_s1, _p_s2, i_bytes );
57 * i_bytes > 0; no other restrictions. This holds for all versions of the
61 #define Merge p_filter->p_sys->pf_merge
64 * EndMerge() macro, which must be called after the merge is
65 * finished, if the Merge() macro was used to perform the merge.
67 #if defined(__i386__) || defined(__x86_64__)
69 if(p_filter->p_sys->pf_end_merge) (p_filter->p_sys->pf_end_merge)()
71 # define EndMerge() (void)0
74 /*****************************************************************************
76 *****************************************************************************/
79 * Generic routine to blend 8 bit pixels from two picture lines.
80 * No inline assembler acceleration.
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.
88 void Merge8BitGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
92 * Generic routine to blend 16 bit pixels from two picture lines.
93 * No inline assembler acceleration.
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.
101 void Merge16BitGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
104 #if defined(CAN_COMPILE_C_ALTIVEC)
106 * Altivec routine to blend pixels from two picture lines.
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
113 void MergeAltivec ( void *, const void *, const void *, size_t );
116 #if defined(CAN_COMPILE_MMXEXT)
118 * MMXEXT routine to blend pixels from two picture lines.
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
125 void MergeMMXEXT ( void *, const void *, const void *, size_t );
128 #if defined(CAN_COMPILE_3DNOW)
130 * 3DNow routine to blend pixels from two picture lines.
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
137 void Merge3DNow ( void *, const void *, const void *, size_t );
140 #if defined(CAN_COMPILE_SSE)
142 * SSE2 routine to blend pixels from two picture lines.
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
149 void Merge8BitSSE2( void *, const void *, const void *, size_t );
151 * SSE2 routine to blend pixels from two picture lines.
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
158 void Merge16BitSSE2( void *, const void *, const void *, size_t );
161 #if defined(CAN_COMPILE_ARM)
163 * ARM NEON routine to blend pixels from two picture lines.
165 void merge8_arm_neon (void *, const void *, const void *, size_t);
166 void merge16_arm_neon (void *, const void *, const void *, size_t);
169 * ARMv6 SIMD routine to blend pixels from two picture lines.
171 void merge8_armv6 (void *, const void *, const void *, size_t);
172 void merge16_armv6 (void *, const void *, const void *, size_t);
175 /*****************************************************************************
177 *****************************************************************************/
179 #if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE)
181 * MMX merge finalization routine.
183 * Must be called after an MMX merge is finished.
184 * This exits MMX mode (by executing the "emms" instruction).
186 * The EndMerge() macro detects whether this is needed, and calls if it is,
189 void EndMMX ( void );
192 #if defined(CAN_COMPILE_3DNOW)
194 * 3DNow merge finalization routine.
196 * Must be called after a 3DNow merge is finished.
197 * This exits 3DNow mode (by executing the "femms" instruction).
199 * The EndMerge() macro detects whether this is needed, and calls if it is,
202 void End3DNow ( void );