]> git.sesse.net Git - vlc/blob - modules/video_filter/deinterlace/merge.h
Refactored deinterlacer module
[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>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 #ifndef VLC_DEINTERLACE_MERGE_H
25 #define VLC_DEINTERLACE_MERGE_H 1
26
27 /**
28  * \file
29  * Merge (line blending) routines for the VLC deinterlacer.
30  */
31
32 #ifdef HAVE_CONFIG_H
33 #   include "config.h"
34 #endif
35
36 /*****************************************************************************
37  * Macros
38  *****************************************************************************/
39
40 /* Convenient Merge() and EndMerge() macros to pick the most appropriate
41    merge implementation automatically.
42
43    Note that you'll need to include vlc_filter.h and deinterlace.h
44    to use these.
45 */
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
48
49 /*****************************************************************************
50  * Merge routines
51  *****************************************************************************/
52
53 /**
54  * Generic routine to blend pixels from two picture lines.
55  * No inline assembler acceleration.
56  *
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.
61  *
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
64  * Open().
65  *
66  * Macro syntax:
67  *   Merge( _p_dest, _p_s1, _p_s2, i_bytes );
68  *
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.
71  *
72  * i_bytes > 0; no other restrictions. This holds for all versions of the
73  * merge routine.
74  *
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.
79  * @see Open()
80  */
81 void MergeGeneric( void *_p_dest, const void *_p_s1, const void *_p_s2,
82                    size_t i_bytes );
83
84 #if defined(CAN_COMPILE_C_ALTIVEC)
85 /**
86  * Altivec routine to blend pixels from two picture lines.
87  *
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
92  */
93 void MergeAltivec ( void *, const void *, const void *, size_t );
94 #endif
95
96 #if defined(CAN_COMPILE_MMXEXT)
97 /**
98  * MMXEXT routine to blend pixels from two picture lines.
99  *
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
104  */
105 void MergeMMXEXT  ( void *, const void *, const void *, size_t );
106 #endif
107
108 #if defined(CAN_COMPILE_3DNOW)
109 /**
110  * 3DNow routine to blend pixels from two picture lines.
111  *
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
116  */
117 void Merge3DNow   ( void *, const void *, const void *, size_t );
118 #endif
119
120 #if defined(CAN_COMPILE_SSE)
121 /**
122  * SSE2 routine to blend pixels from two picture lines.
123  *
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
128  */
129 void MergeSSE2    ( void *, const void *, const void *, size_t );
130 #endif
131
132 #if defined __ARM_NEON__
133 /**
134  * ARM NEON routine to blend pixels from two picture lines.
135  *
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
140  */
141 void MergeNEON (void *, const void *, const void *, size_t);
142 #endif
143
144 /*****************************************************************************
145  * EndMerge routines
146  *****************************************************************************/
147
148 #if defined(CAN_COMPILE_MMXEXT) || defined(CAN_COMPILE_SSE)
149 /**
150  * MMX merge finalization routine.
151  *
152  * Must be called after an MMX merge is finished.
153  * This exits MMX mode (by executing the "emms" instruction).
154  *
155  * The EndMerge() macro detects whether this is needed, and calls if it is,
156  * so just use that.
157  */
158 void EndMMX       ( void );
159 #endif
160
161 #if defined(CAN_COMPILE_3DNOW)
162 /**
163  * 3DNow merge finalization routine.
164  *
165  * Must be called after a 3DNow merge is finished.
166  * This exits 3DNow mode (by executing the "femms" instruction).
167  *
168  * The EndMerge() macro detects whether this is needed, and calls if it is,
169  * so just use that.
170  */
171 void End3DNow     ( void );
172 #endif
173
174 #endif