]> git.sesse.net Git - vlc/blob - modules/video_filter/deinterlace/merge.h
Psyche/sharpen: Add chroma checks to prevent crashes
[vlc] / modules / video_filter / deinterlace / merge.h
1 /*****************************************************************************
2  * merge.h : Merge (line blending) routines for the VLC deinterlacer
3  *****************************************************************************
4  * Copyright (C) 2011 the VideoLAN team
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
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.
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 General Public License for more details.
21  *
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  *****************************************************************************/
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 #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
47
48 /*****************************************************************************
49  * Merge routines
50  *****************************************************************************/
51
52 /**
53  * Generic routine to blend pixels from two picture lines.
54  * No inline assembler acceleration.
55  *
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.
60  *
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
63  * Open().
64  *
65  * Macro syntax:
66  *   Merge( _p_dest, _p_s1, _p_s2, i_bytes );
67  *
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.
70  *
71  * i_bytes > 0; no other restrictions. This holds for all versions of the
72  * merge routine.
73  *
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.
78  * @see Open()
79  */
80 void MergeGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
81                    size_t i_bytes );
82
83 #if defined(CAN_COMPILE_C_ALTIVEC)
84 /**
85  * Altivec routine to blend pixels from two picture lines.
86  *
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
91  */
92 void MergeAltivec ( void *, const void *, const void *, size_t );
93 #endif
94
95 #if defined(CAN_COMPILE_MMXEXT)
96 /**
97  * MMXEXT routine to blend pixels from two picture lines.
98  *
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
103  */
104 void MergeMMXEXT  ( void *, const void *, const void *, size_t );
105 #endif
106
107 #if defined(CAN_COMPILE_3DNOW)
108 /**
109  * 3DNow routine to blend pixels from two picture lines.
110  *
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
115  */
116 void Merge3DNow   ( void *, const void *, const void *, size_t );
117 #endif
118
119 #if defined(CAN_COMPILE_SSE)
120 /**
121  * SSE2 routine to blend pixels from two picture lines.
122  *
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
127  */
128 void MergeSSE2    ( void *, const void *, const void *, size_t );
129 #endif
130
131 #if defined __ARM_NEON__
132 /**
133  * ARM NEON routine to blend pixels from two picture lines.
134  *
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
139  */
140 void MergeNEON (void *, const void *, const void *, size_t);
141 #endif
142
143 /*****************************************************************************
144  * EndMerge routines
145  *****************************************************************************/
146
147 #if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE)
148 /**
149  * MMX merge finalization routine.
150  *
151  * Must be called after an MMX merge is finished.
152  * This exits MMX mode (by executing the "emms" instruction).
153  *
154  * The EndMerge() macro detects whether this is needed, and calls if it is,
155  * so just use that.
156  */
157 void EndMMX       ( void );
158 #endif
159
160 #if defined(CAN_COMPILE_3DNOW)
161 /**
162  * 3DNow merge finalization routine.
163  *
164  * Must be called after a 3DNow merge is finished.
165  * This exits 3DNow mode (by executing the "femms" instruction).
166  *
167  * The EndMerge() macro detects whether this is needed, and calls if it is,
168  * so just use that.
169  */
170 void End3DNow     ( void );
171 #endif
172
173 #endif