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.3 2001/06/07 22:14:55 sam 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 #define MODULE_NAME motion
27 #include "modules_inner.h"
29 /*****************************************************************************
31 *****************************************************************************/
41 #define __MotionComponent_x_y_copy(width,height) \
42 void _M(MotionComponent_x_y_copy_##width##_##height)(yuv_data_t *p_src, \
48 for( i_y = 0; i_y < height; i_y ++ ) \
50 for( i_x = 0; i_x < width; i_x++ ) \
52 p_dest[i_x] = p_src[i_x]; \
59 #define __MotionComponent_X_y_copy(width,height) \
60 void _M(MotionComponent_X_y_copy_##width##_##height)(yuv_data_t *p_src, \
61 yuv_data_t * p_dest, \
66 for( i_y = 0; i_y < height; i_y ++ ) \
68 for( i_x = 0; i_x < width; i_x++ ) \
70 p_dest[i_x] = (unsigned int)(p_src[i_x] \
79 #define __MotionComponent_x_Y_copy(width,height) \
80 void _M(MotionComponent_x_Y_copy_##width##_##height)(yuv_data_t *p_src, \
81 yuv_data_t * p_dest, \
86 for( i_y = 0; i_y < height; i_y ++ ) \
88 for( i_x = 0; i_x < width; i_x++ ) \
90 p_dest[i_x] = (unsigned int)(p_src[i_x] \
91 + p_src[i_x + i_stride] \
99 #define __MotionComponent_X_Y_copy(width,height) \
100 void _M(MotionComponent_X_Y_copy_##width##_##height)(yuv_data_t *p_src, \
101 yuv_data_t * p_dest, \
106 for( i_y = 0; i_y < height; i_y ++ ) \
108 for( i_x = 0; i_x < width; i_x++ ) \
110 p_dest[i_x] = (unsigned int)(p_src[i_x] \
112 + p_src[i_x + i_stride] \
113 + p_src[i_x + i_stride + 1] \
116 p_dest += i_stride; \
121 #define __MotionComponent_x_y_avg(width,height) \
122 void _M(MotionComponent_x_y_avg_##width##_##height)(yuv_data_t * p_src, \
123 yuv_data_t * p_dest, \
127 unsigned int i_dummy; \
129 for( i_y = 0; i_y < height; i_y ++ ) \
131 for( i_x = 0; i_x < width; i_x++ ) \
133 i_dummy = p_dest[i_x] + p_src[i_x]; \
134 p_dest[i_x] = (i_dummy + 1) >> 1; \
136 p_dest += i_stride; \
141 #define __MotionComponent_X_y_avg(width,height) \
142 void _M(MotionComponent_X_y_avg_##width##_##height)(yuv_data_t * p_src, \
143 yuv_data_t * p_dest, \
147 unsigned int i_dummy; \
149 for( i_y = 0; i_y < height; i_y ++ ) \
151 for( i_x = 0; i_x < width; i_x++ ) \
153 i_dummy = p_dest[i_x] + ((unsigned int)(p_src[i_x] \
156 p_dest[i_x] = (i_dummy + 1) >> 1; \
158 p_dest += i_stride; \
163 #define __MotionComponent_x_Y_avg(width,height) \
164 void _M(MotionComponent_x_Y_avg_##width##_##height)(yuv_data_t * p_src, \
165 yuv_data_t * p_dest, \
169 unsigned int i_dummy; \
171 for( i_y = 0; i_y < height; i_y ++ ) \
173 for( i_x = 0; i_x < width; i_x++ ) \
176 p_dest[i_x] + ((unsigned int)(p_src[i_x] \
177 + p_src[i_x + i_stride] \
179 p_dest[i_x] = (i_dummy + 1) >> 1; \
181 p_dest += i_stride; \
186 #define __MotionComponent_X_Y_avg(width,height) \
187 void _M(MotionComponent_X_Y_avg_##width##_##height)(yuv_data_t * p_src, \
188 yuv_data_t * p_dest, \
192 unsigned int i_dummy; \
194 for( i_y = 0; i_y < height; i_y ++ ) \
196 for( i_x = 0; i_x < width; i_x++ ) \
199 p_dest[i_x] + ((unsigned int)(p_src[i_x] \
201 + p_src[i_x + i_stride] \
202 + p_src[i_x + i_stride + 1] \
204 p_dest[i_x] = (i_dummy + 1) >> 1; \
206 p_dest += i_stride; \
211 #define __MotionComponents(width,height) \
212 __MotionComponent_x_y_copy(width,height) \
213 __MotionComponent_X_y_copy(width,height) \
214 __MotionComponent_x_Y_copy(width,height) \
215 __MotionComponent_X_Y_copy(width,height) \
216 __MotionComponent_x_y_avg(width,height) \
217 __MotionComponent_X_y_avg(width,height) \
218 __MotionComponent_x_Y_avg(width,height) \
219 __MotionComponent_X_Y_avg(width,height)
221 __MotionComponents (16,16) /* 444, 422, 420 */
222 __MotionComponents (16,8) /* 444, 422, 420 */
223 __MotionComponents (8,8) /* 422, 420 */
224 __MotionComponents (8,4) /* 420 */
226 __MotionComponents (8,16) /* 422 */