1 /*****************************************************************************
2 * merge.h : Merge (line blending) routines for the VLC deinterlacer
3 *****************************************************************************
4 * Copyright (C) 2011 the VideoLAN team
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
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 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 General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, 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 #define Merge p_filter->p_sys->pf_merge
46 #define EndMerge if(p_filter->p_sys->pf_end_merge) p_filter->p_sys->pf_end_merge
48 /*****************************************************************************
50 *****************************************************************************/
53 * Generic routine to blend pixels from two picture lines.
54 * No inline assembler acceleration.
56 * Note that the Open() call of the deinterlace filter automatically selects
57 * the most appropriate merge routine based on the CPU capabilities.
58 * You can call the most appropriate version automatically, from a function
59 * in the deinterlace filter, by using the Merge() macro.
61 * Note that the filter instance (p_filter) must be available for the Merge()
62 * macro to work, because it needs the detection result from the filter's
66 * Merge( _p_dest, _p_s1, _p_s2, i_bytes );
68 * See also the EndMerge() macro, which must be called after the merge is
69 * finished, if the Merge() macro was used to perform the merge.
71 * i_bytes > 0; no other restrictions. This holds for all versions of the
74 * @param _p_dest Target line. Blend result = (A + B)/2.
75 * @param _p_s1 Source line A.
76 * @param _p_s2 Source line B.
77 * @param i_bytes Number of bytes to merge.
80 void MergeGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
83 #if defined(CAN_COMPILE_C_ALTIVEC)
85 * Altivec routine to blend pixels from two picture lines.
87 * @param _p_dest Target
88 * @param _p_s1 Source line A
89 * @param _p_s2 Source line B
90 * @param i_bytes Number of bytes to merge
92 void MergeAltivec ( void *, const void *, const void *, size_t );
95 #if defined(CAN_COMPILE_MMXEXT)
97 * MMXEXT routine to blend pixels from two picture lines.
99 * @param _p_dest Target
100 * @param _p_s1 Source line A
101 * @param _p_s2 Source line B
102 * @param i_bytes Number of bytes to merge
104 void MergeMMXEXT ( void *, const void *, const void *, size_t );
107 #if defined(CAN_COMPILE_3DNOW)
109 * 3DNow routine to blend pixels from two picture lines.
111 * @param _p_dest Target
112 * @param _p_s1 Source line A
113 * @param _p_s2 Source line B
114 * @param i_bytes Number of bytes to merge
116 void Merge3DNow ( void *, const void *, const void *, size_t );
119 #if defined(CAN_COMPILE_SSE)
121 * SSE2 routine to blend pixels from two picture lines.
123 * @param _p_dest Target
124 * @param _p_s1 Source line A
125 * @param _p_s2 Source line B
126 * @param i_bytes Number of bytes to merge
128 void MergeSSE2 ( void *, const void *, const void *, size_t );
131 #if defined __ARM_NEON__
133 * ARM NEON routine to blend pixels from two picture lines.
135 * @param _p_dest Target
136 * @param _p_s1 Source line A
137 * @param _p_s2 Source line B
138 * @param i_bytes Number of bytes to merge
140 void MergeNEON (void *, const void *, const void *, size_t);
143 /*****************************************************************************
145 *****************************************************************************/
147 #if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE)
149 * MMX merge finalization routine.
151 * Must be called after an MMX merge is finished.
152 * This exits MMX mode (by executing the "emms" instruction).
154 * The EndMerge() macro detects whether this is needed, and calls if it is,
157 void EndMMX ( void );
160 #if defined(CAN_COMPILE_3DNOW)
162 * 3DNow merge finalization routine.
164 * Must be called after a 3DNow merge is finished.
165 * This exits 3DNow mode (by executing the "femms" instruction).
167 * The EndMerge() macro detects whether this is needed, and calls if it is,
170 void End3DNow ( void );