1 /*****************************************************************************
2 * vdec_motion_inner.c : motion compensation inner routines
3 *****************************************************************************
4 * Copyright (C) 1999, 2000 VideoLAN
5 * $Id: vdec_motion_inner.c,v 1.10 2000/12/21 17:19:52 massiot Exp $
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
8 * Jean-Marc Dressler <polux@via.ecp.fr>
9 * Michel Lespinasse <walken@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
28 *****************************************************************************/
31 #include <sys/types.h> /* on BSD, uio.h needs types.h */
32 #include <sys/uio.h> /* for input.h */
42 #include "stream_control.h"
43 #include "input_ext-dec.h"
46 #include "video_output.h"
48 #include "vdec_idct.h"
49 #include "video_decoder.h"
50 #include "vdec_motion.h"
52 #include "vpar_blocks.h"
53 #include "vpar_headers.h"
54 #include "vpar_synchro.h"
55 #include "video_parser.h"
56 #include "video_fifo.h"
58 #define __MotionComponent_x_y_copy(width,height) \
59 void MotionComponent_x_y_copy_##width##_##height(yuv_data_t * p_src, \
60 yuv_data_t * p_dest, \
65 for( i_y = 0; i_y < height; i_y ++ ) \
67 for( i_x = 0; i_x < width; i_x++ ) \
69 p_dest[i_x] = p_src[i_x]; \
76 #define __MotionComponent_X_y_copy(width,height) \
77 void MotionComponent_X_y_copy_##width##_##height(yuv_data_t * p_src, \
78 yuv_data_t * p_dest, \
83 for( i_y = 0; i_y < height; i_y ++ ) \
85 for( i_x = 0; i_x < width; i_x++ ) \
87 p_dest[i_x] = (unsigned int)(p_src[i_x] \
96 #define __MotionComponent_x_Y_copy(width,height) \
97 void MotionComponent_x_Y_copy_##width##_##height(yuv_data_t * p_src, \
98 yuv_data_t * p_dest, \
103 for( i_y = 0; i_y < height; i_y ++ ) \
105 for( i_x = 0; i_x < width; i_x++ ) \
107 p_dest[i_x] = (unsigned int)(p_src[i_x] \
108 + p_src[i_x + i_stride] \
111 p_dest += i_stride; \
116 #define __MotionComponent_X_Y_copy(width,height) \
117 void MotionComponent_X_Y_copy_##width##_##height(yuv_data_t * p_src, \
118 yuv_data_t * p_dest, \
123 for( i_y = 0; i_y < height; i_y ++ ) \
125 for( i_x = 0; i_x < width; i_x++ ) \
127 p_dest[i_x] = (unsigned int)(p_src[i_x] \
129 + p_src[i_x + i_stride] \
130 + p_src[i_x + i_stride + 1] \
133 p_dest += i_stride; \
138 #define __MotionComponent_x_y_avg(width,height) \
139 void MotionComponent_x_y_avg_##width##_##height(yuv_data_t * p_src, \
140 yuv_data_t * p_dest, \
144 unsigned int i_dummy; \
146 for( i_y = 0; i_y < height; i_y ++ ) \
148 for( i_x = 0; i_x < width; i_x++ ) \
150 i_dummy = p_dest[i_x] + p_src[i_x]; \
151 p_dest[i_x] = (i_dummy + 1) >> 1; \
153 p_dest += i_stride; \
158 #define __MotionComponent_X_y_avg(width,height) \
159 void MotionComponent_X_y_avg_##width##_##height(yuv_data_t * p_src, \
160 yuv_data_t * p_dest, \
164 unsigned int i_dummy; \
166 for( i_y = 0; i_y < height; i_y ++ ) \
168 for( i_x = 0; i_x < width; i_x++ ) \
170 i_dummy = p_dest[i_x] + ((unsigned int)(p_src[i_x] \
173 p_dest[i_x] = (i_dummy + 1) >> 1; \
175 p_dest += i_stride; \
180 #define __MotionComponent_x_Y_avg(width,height) \
181 void MotionComponent_x_Y_avg_##width##_##height(yuv_data_t * p_src, \
182 yuv_data_t * p_dest, \
186 unsigned int i_dummy; \
188 for( i_y = 0; i_y < height; i_y ++ ) \
190 for( i_x = 0; i_x < width; i_x++ ) \
193 p_dest[i_x] + ((unsigned int)(p_src[i_x] \
194 + p_src[i_x + i_stride] \
196 p_dest[i_x] = (i_dummy + 1) >> 1; \
198 p_dest += i_stride; \
203 #define __MotionComponent_X_Y_avg(width,height) \
204 void MotionComponent_X_Y_avg_##width##_##height(yuv_data_t * p_src, \
205 yuv_data_t * p_dest, \
209 unsigned int i_dummy; \
211 for( i_y = 0; i_y < height; i_y ++ ) \
213 for( i_x = 0; i_x < width; i_x++ ) \
216 p_dest[i_x] + ((unsigned int)(p_src[i_x] \
218 + p_src[i_x + i_stride] \
219 + p_src[i_x + i_stride + 1] \
221 p_dest[i_x] = (i_dummy + 1) >> 1; \
223 p_dest += i_stride; \
228 #define __MotionComponents(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_copy(width,height) \
233 __MotionComponent_x_y_avg(width,height) \
234 __MotionComponent_X_y_avg(width,height) \
235 __MotionComponent_x_Y_avg(width,height) \
236 __MotionComponent_X_Y_avg(width,height)
238 __MotionComponents (16,16) /* 444, 422, 420 */
239 __MotionComponents (16,8) /* 444, 422, 420 */
240 __MotionComponents (8,8) /* 422, 420 */
241 __MotionComponents (8,4) /* 420 */
243 __MotionComponents (8,16) /* 422 */