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>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 #ifndef VLC_DEINTERLACE_MERGE_H
25 #define VLC_DEINTERLACE_MERGE_H 1
29 * Merge (line blending) routines for the VLC deinterlacer.
36 /*****************************************************************************
38 *****************************************************************************/
40 /* Convenient Merge() and EndMerge() macros to pick the most appropriate
41 merge implementation automatically.
43 Note that you'll need to include vlc_filter.h and deinterlace.h
46 #define Merge p_filter->p_sys->pf_merge
47 #define EndMerge if(p_filter->p_sys->pf_end_merge) p_filter->p_sys->pf_end_merge
49 /*****************************************************************************
51 *****************************************************************************/
54 * Generic routine to blend pixels from two picture lines.
55 * No inline assembler acceleration.
57 * Note that the Open() call of the deinterlace filter automatically selects
58 * the most appropriate merge routine based on the CPU capabilities.
59 * You can call the most appropriate version automatically, from a function
60 * in the deinterlace filter, by using the Merge() macro.
62 * Note that the filter instance (p_filter) must be available for the Merge()
63 * macro to work, because it needs the detection result from the filter's
67 * Merge( _p_dest, _p_s1, _p_s2, i_bytes );
69 * See also the EndMerge() macro, which must be called after the merge is
70 * finished, if the Merge() macro was used to perform the merge.
72 * i_bytes > 0; no other restrictions. This holds for all versions of the
75 * @param _p_dest Target line. Blend result = (A + B)/2.
76 * @param _p_s1 Source line A.
77 * @param _p_s2 Source line B.
78 * @param i_bytes Number of bytes to merge.
81 void MergeGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
84 #if defined(CAN_COMPILE_C_ALTIVEC)
86 * Altivec routine to blend pixels from two picture lines.
88 * @param _p_dest Target
89 * @param _p_s1 Source line A
90 * @param _p_s2 Source line B
91 * @param i_bytes Number of bytes to merge
93 void MergeAltivec ( void *, const void *, const void *, size_t );
96 #if defined(CAN_COMPILE_MMXEXT)
98 * MMXEXT routine to blend pixels from two picture lines.
100 * @param _p_dest Target
101 * @param _p_s1 Source line A
102 * @param _p_s2 Source line B
103 * @param i_bytes Number of bytes to merge
105 void MergeMMXEXT ( void *, const void *, const void *, size_t );
108 #if defined(CAN_COMPILE_3DNOW)
110 * 3DNow routine to blend pixels from two picture lines.
112 * @param _p_dest Target
113 * @param _p_s1 Source line A
114 * @param _p_s2 Source line B
115 * @param i_bytes Number of bytes to merge
117 void Merge3DNow ( void *, const void *, const void *, size_t );
120 #if defined(CAN_COMPILE_SSE)
122 * SSE2 routine to blend pixels from two picture lines.
124 * @param _p_dest Target
125 * @param _p_s1 Source line A
126 * @param _p_s2 Source line B
127 * @param i_bytes Number of bytes to merge
129 void MergeSSE2 ( void *, const void *, const void *, size_t );
132 #if defined __ARM_NEON__
134 * ARM NEON routine to blend pixels from two picture lines.
136 * @param _p_dest Target
137 * @param _p_s1 Source line A
138 * @param _p_s2 Source line B
139 * @param i_bytes Number of bytes to merge
141 void MergeNEON (void *, const void *, const void *, size_t);
144 /*****************************************************************************
146 *****************************************************************************/
148 #if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE)
150 * MMX merge finalization routine.
152 * Must be called after an MMX merge is finished.
153 * This exits MMX mode (by executing the "emms" instruction).
155 * The EndMerge() macro detects whether this is needed, and calls if it is,
158 void EndMMX ( void );
161 #if defined(CAN_COMPILE_3DNOW)
163 * 3DNow merge finalization routine.
165 * Must be called after a 3DNow merge is finished.
166 * This exits 3DNow mode (by executing the "femms" instruction).
168 * The EndMerge() macro detects whether this is needed, and calls if it is,
171 void End3DNow ( void );