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.2 2001/06/07 15:27:44 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 #include "modules_inner.h"
28 /*****************************************************************************
30 *****************************************************************************/
40 #define __MotionComponent_x_y_copy(width,height) \
41 void _M(MotionComponent_x_y_copy_##width##_##height)(yuv_data_t *p_src, \
47 for( i_y = 0; i_y < height; i_y ++ ) \
49 for( i_x = 0; i_x < width; i_x++ ) \
51 p_dest[i_x] = p_src[i_x]; \
58 #define __MotionComponent_X_y_copy(width,height) \
59 void _M(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] = (unsigned int)(p_src[i_x] \
78 #define __MotionComponent_x_Y_copy(width,height) \
79 void _M(MotionComponent_x_Y_copy_##width##_##height)(yuv_data_t *p_src, \
80 yuv_data_t * p_dest, \
85 for( i_y = 0; i_y < height; i_y ++ ) \
87 for( i_x = 0; i_x < width; i_x++ ) \
89 p_dest[i_x] = (unsigned int)(p_src[i_x] \
90 + p_src[i_x + i_stride] \
98 #define __MotionComponent_X_Y_copy(width,height) \
99 void _M(MotionComponent_X_Y_copy_##width##_##height)(yuv_data_t *p_src, \
100 yuv_data_t * p_dest, \
105 for( i_y = 0; i_y < height; i_y ++ ) \
107 for( i_x = 0; i_x < width; i_x++ ) \
109 p_dest[i_x] = (unsigned int)(p_src[i_x] \
111 + p_src[i_x + i_stride] \
112 + p_src[i_x + i_stride + 1] \
115 p_dest += i_stride; \
120 #define __MotionComponent_x_y_avg(width,height) \
121 void _M(MotionComponent_x_y_avg_##width##_##height)(yuv_data_t * p_src, \
122 yuv_data_t * p_dest, \
126 unsigned int i_dummy; \
128 for( i_y = 0; i_y < height; i_y ++ ) \
130 for( i_x = 0; i_x < width; i_x++ ) \
132 i_dummy = p_dest[i_x] + p_src[i_x]; \
133 p_dest[i_x] = (i_dummy + 1) >> 1; \
135 p_dest += i_stride; \
140 #define __MotionComponent_X_y_avg(width,height) \
141 void _M(MotionComponent_X_y_avg_##width##_##height)(yuv_data_t * p_src, \
142 yuv_data_t * p_dest, \
146 unsigned int i_dummy; \
148 for( i_y = 0; i_y < height; i_y ++ ) \
150 for( i_x = 0; i_x < width; i_x++ ) \
152 i_dummy = p_dest[i_x] + ((unsigned int)(p_src[i_x] \
155 p_dest[i_x] = (i_dummy + 1) >> 1; \
157 p_dest += i_stride; \
162 #define __MotionComponent_x_Y_avg(width,height) \
163 void _M(MotionComponent_x_Y_avg_##width##_##height)(yuv_data_t * p_src, \
164 yuv_data_t * p_dest, \
168 unsigned int i_dummy; \
170 for( i_y = 0; i_y < height; i_y ++ ) \
172 for( i_x = 0; i_x < width; i_x++ ) \
175 p_dest[i_x] + ((unsigned int)(p_src[i_x] \
176 + p_src[i_x + i_stride] \
178 p_dest[i_x] = (i_dummy + 1) >> 1; \
180 p_dest += i_stride; \
185 #define __MotionComponent_X_Y_avg(width,height) \
186 void _M(MotionComponent_X_Y_avg_##width##_##height)(yuv_data_t * p_src, \
187 yuv_data_t * p_dest, \
191 unsigned int i_dummy; \
193 for( i_y = 0; i_y < height; i_y ++ ) \
195 for( i_x = 0; i_x < width; i_x++ ) \
198 p_dest[i_x] + ((unsigned int)(p_src[i_x] \
200 + p_src[i_x + i_stride] \
201 + p_src[i_x + i_stride + 1] \
203 p_dest[i_x] = (i_dummy + 1) >> 1; \
205 p_dest += i_stride; \
210 #define __MotionComponents(width,height) \
211 __MotionComponent_x_y_copy(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_avg(width,height) \
216 __MotionComponent_X_y_avg(width,height) \
217 __MotionComponent_x_Y_avg(width,height) \
218 __MotionComponent_X_Y_avg(width,height)
220 __MotionComponents (16,16) /* 444, 422, 420 */
221 __MotionComponents (16,8) /* 444, 422, 420 */
222 __MotionComponents (8,8) /* 422, 420 */
223 __MotionComponents (8,4) /* 420 */
225 __MotionComponents (8,16) /* 422 */