]> git.sesse.net Git - vlc/blob - src/video_decoder/vdec_motion_inner.c
D�but du portage BeOS. Beaucoup de fuchiers ont �t� modifi� car il a fallu
[vlc] / src / video_decoder / vdec_motion_inner.c
1 /*****************************************************************************
2  * vdec_motion.c : motion compensation routines
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  *
6  * Authors:
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public
19  * License along with this program; if not, write to the
20  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <sys/types.h>                        /* on BSD, uio.h needs types.h */
28 #include <sys/uio.h>                                          /* for input.h */
29
30 #include "threads.h"
31 #include "config.h"
32 #include "common.h"
33 #include "mtime.h"
34 #include "plugins.h"
35
36 #include "intf_msg.h"
37
38 #include "input.h"
39 #include "decoder_fifo.h"
40 #include "video.h"
41 #include "video_output.h"
42
43 #include "vdec_idct.h"
44 #include "video_decoder.h"
45 #include "vdec_motion.h"
46
47 #include "vpar_blocks.h"
48 #include "vpar_headers.h"
49 #include "vpar_synchro.h"
50 #include "video_parser.h"
51 #include "video_fifo.h"
52
53 #define __MotionComponent_x_y_copy(width,height)                        \
54 void MotionComponent_x_y_copy_##width##_##height(yuv_data_t * p_src,    \
55                                                  yuv_data_t * p_dest,   \
56                                                  int i_stride)          \
57 {                                                                       \
58     int i_x, i_y;                                                       \
59                                                                         \
60     for( i_y = 0; i_y < height; i_y ++ )                                \
61     {                                                                   \
62         for( i_x = 0; i_x < width; i_x++ )                              \
63         {                                                               \
64             p_dest[i_x] = p_src[i_x];                                   \
65         }                                                               \
66         p_dest += i_stride;                                             \
67         p_src += i_stride;                                              \
68     }                                                                   \
69 }
70
71 #define __MotionComponent_X_y_copy(width,height)                        \
72 void MotionComponent_X_y_copy_##width##_##height(yuv_data_t * p_src,    \
73                                                  yuv_data_t * p_dest,   \
74                                                  int i_stride)          \
75 {                                                                       \
76     int i_x, i_y;                                                       \
77                                                                         \
78     for( i_y = 0; i_y < height; i_y ++ )                                \
79     {                                                                   \
80         for( i_x = 0; i_x < width; i_x++ )                              \
81         {                                                               \
82             p_dest[i_x] = (unsigned int)(p_src[i_x]                     \
83                                          + p_src[i_x + 1]               \
84                                          + 1) >> 1;                     \
85         }                                                               \
86         p_dest += i_stride;                                             \
87         p_src += i_stride;                                              \
88     }                                                                   \
89 }
90
91 #define __MotionComponent_x_Y_copy(width,height)                        \
92 void MotionComponent_x_Y_copy_##width##_##height(yuv_data_t * p_src,    \
93                                                  yuv_data_t * p_dest,   \
94                                                  int i_stride,          \
95                                                  int i_step)            \
96 {                                                                       \
97     int i_x, i_y;                                                       \
98                                                                         \
99     for( i_y = 0; i_y < height; i_y ++ )                                \
100     {                                                                   \
101         for( i_x = 0; i_x < width; i_x++ )                              \
102         {                                                               \
103             p_dest[i_x] = (unsigned int)(p_src[i_x]                     \
104                                          + p_src[i_x + i_step]          \
105                                          + 1) >> 1;                     \
106         }                                                               \
107         p_dest += i_stride;                                             \
108         p_src += i_stride;                                              \
109     }                                                                   \
110 }
111
112 #define __MotionComponent_X_Y_copy(width,height)                        \
113 void MotionComponent_X_Y_copy_##width##_##height(yuv_data_t * p_src,    \
114                                                  yuv_data_t * p_dest,   \
115                                                  int i_stride,          \
116                                                  int i_step)            \
117 {                                                                       \
118     int i_x, i_y;                                                       \
119                                                                         \
120     for( i_y = 0; i_y < height; i_y ++ )                                \
121     {                                                                   \
122         for( i_x = 0; i_x < width; i_x++ )                              \
123         {                                                               \
124             p_dest[i_x] = (unsigned int)(p_src[i_x]                     \
125                                          + p_src[i_x + 1]               \
126                                          + p_src[i_x + i_step]          \
127                                          + p_src[i_x + i_step + 1]      \
128                                          + 2) >> 2;                     \
129         }                                                               \
130         p_dest += i_stride;                                             \
131         p_src += i_stride;                                              \
132     }                                                                   \
133 }
134
135 #define __MotionComponent_x_y_avg(width,height)                         \
136 void MotionComponent_x_y_avg_##width##_##height(yuv_data_t * p_src,     \
137                                                 yuv_data_t * p_dest,    \
138                                                 int i_stride)           \
139 {                                                                       \
140     int i_x, i_y;                                                       \
141     unsigned int i_dummy;                                               \
142                                                                         \
143     for( i_y = 0; i_y < height; i_y ++ )                                \
144     {                                                                   \
145         for( i_x = 0; i_x < width; i_x++ )                              \
146         {                                                               \
147             i_dummy = p_dest[i_x] + p_src[i_x];                         \
148             p_dest[i_x] = (i_dummy + 1) >> 1;                           \
149         }                                                               \
150         p_dest += i_stride;                                             \
151         p_src += i_stride;                                              \
152     }                                                                   \
153 }
154
155 #define __MotionComponent_X_y_avg(width,height)                         \
156 void MotionComponent_X_y_avg_##width##_##height(yuv_data_t * p_src,     \
157                                                 yuv_data_t * p_dest,    \
158                                                 int i_stride)           \
159 {                                                                       \
160     int i_x, i_y;                                                       \
161     unsigned int i_dummy;                                               \
162                                                                         \
163     for( i_y = 0; i_y < height; i_y ++ )                                \
164     {                                                                   \
165         for( i_x = 0; i_x < width; i_x++ )                              \
166         {                                                               \
167             i_dummy = p_dest[i_x] + ((unsigned int)(p_src[i_x]          \
168                                                     + p_src[i_x + 1]    \
169                                                     + 1) >> 1);         \
170             p_dest[i_x] = (i_dummy + 1) >> 1;                           \
171         }                                                               \
172         p_dest += i_stride;                                             \
173         p_src += i_stride;                                              \
174     }                                                                   \
175 }
176
177 #define __MotionComponent_x_Y_avg(width,height)                         \
178 void MotionComponent_x_Y_avg_##width##_##height(yuv_data_t * p_src,     \
179                                                 yuv_data_t * p_dest,    \
180                                                 int i_stride,           \
181                                                 int i_step)             \
182 {                                                                       \
183     int i_x, i_y;                                                       \
184     unsigned int i_dummy;                                               \
185                                                                         \
186     for( i_y = 0; i_y < height; i_y ++ )                                \
187     {                                                                   \
188         for( i_x = 0; i_x < width; i_x++ )                              \
189         {                                                               \
190             i_dummy =                                                   \
191                 p_dest[i_x] + ((unsigned int)(p_src[i_x]                \
192                                               + p_src[i_x + i_step]     \
193                                               + 1) >> 1);               \
194             p_dest[i_x] = (i_dummy + 1) >> 1;                           \
195         }                                                               \
196         p_dest += i_stride;                                             \
197         p_src += i_stride;                                              \
198     }                                                                   \
199 }
200
201 #define __MotionComponent_X_Y_avg(width,height)                         \
202 void MotionComponent_X_Y_avg_##width##_##height(yuv_data_t * p_src,     \
203                                                 yuv_data_t * p_dest,    \
204                                                 int i_stride,           \
205                                                 int i_step)             \
206 {                                                                       \
207     int i_x, i_y;                                                       \
208     unsigned int i_dummy;                                               \
209                                                                         \
210     for( i_y = 0; i_y < height; i_y ++ )                                \
211     {                                                                   \
212         for( i_x = 0; i_x < width; i_x++ )                              \
213         {                                                               \
214             i_dummy =                                                   \
215                 p_dest[i_x] + ((unsigned int)(p_src[i_x]                \
216                                               + p_src[i_x + 1]          \
217                                               + p_src[i_x + i_step]     \
218                                               + p_src[i_x + i_step + 1] \
219                                               + 2) >> 2);               \
220             p_dest[i_x] = (i_dummy + 1) >> 1;                           \
221         }                                                               \
222         p_dest += i_stride;                                             \
223         p_src += i_stride;                                              \
224     }                                                                   \
225 }
226
227 #define __MotionComponents(width,height)        \
228 __MotionComponent_x_y_copy(width,height)        \
229 __MotionComponent_X_y_copy(width,height)        \
230 __MotionComponent_x_Y_copy(width,height)        \
231 __MotionComponent_X_Y_copy(width,height)        \
232 __MotionComponent_x_y_avg(width,height)         \
233 __MotionComponent_X_y_avg(width,height)         \
234 __MotionComponent_x_Y_avg(width,height)         \
235 __MotionComponent_X_Y_avg(width,height)
236
237 __MotionComponents (16,16)      /* 444, 422, 420 */
238 __MotionComponents (16,8)       /* 444, 422, 420 */
239 __MotionComponents (8,8)        /* 422, 420 */
240 __MotionComponents (8,4)        /* 420 */
241 #if 0
242 __MotionComponents (8,16)       /* 422 */
243 #endif