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.12 2001/01/05 18:46:44 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 *****************************************************************************/
39 #include "stream_control.h"
40 #include "input_ext-dec.h"
43 #include "video_output.h"
45 #include "vdec_idct.h"
46 #include "video_decoder.h"
47 #include "vdec_motion.h"
49 #include "vpar_blocks.h"
50 #include "vpar_headers.h"
51 #include "vpar_synchro.h"
52 #include "video_parser.h"
53 #include "video_fifo.h"
55 #define __MotionComponent_x_y_copy(width,height) \
56 void MotionComponent_x_y_copy_##width##_##height(yuv_data_t * p_src, \
57 yuv_data_t * p_dest, \
62 for( i_y = 0; i_y < height; i_y ++ ) \
64 for( i_x = 0; i_x < width; i_x++ ) \
66 p_dest[i_x] = p_src[i_x]; \
73 #define __MotionComponent_X_y_copy(width,height) \
74 void MotionComponent_X_y_copy_##width##_##height(yuv_data_t * p_src, \
75 yuv_data_t * p_dest, \
80 for( i_y = 0; i_y < height; i_y ++ ) \
82 for( i_x = 0; i_x < width; i_x++ ) \
84 p_dest[i_x] = (unsigned int)(p_src[i_x] \
93 #define __MotionComponent_x_Y_copy(width,height) \
94 void MotionComponent_x_Y_copy_##width##_##height(yuv_data_t * p_src, \
95 yuv_data_t * p_dest, \
100 for( i_y = 0; i_y < height; i_y ++ ) \
102 for( i_x = 0; i_x < width; i_x++ ) \
104 p_dest[i_x] = (unsigned int)(p_src[i_x] \
105 + p_src[i_x + i_stride] \
108 p_dest += i_stride; \
113 #define __MotionComponent_X_Y_copy(width,height) \
114 void MotionComponent_X_Y_copy_##width##_##height(yuv_data_t * p_src, \
115 yuv_data_t * p_dest, \
120 for( i_y = 0; i_y < height; i_y ++ ) \
122 for( i_x = 0; i_x < width; i_x++ ) \
124 p_dest[i_x] = (unsigned int)(p_src[i_x] \
126 + p_src[i_x + i_stride] \
127 + p_src[i_x + i_stride + 1] \
130 p_dest += i_stride; \
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, \
141 unsigned int i_dummy; \
143 for( i_y = 0; i_y < height; i_y ++ ) \
145 for( i_x = 0; i_x < width; i_x++ ) \
147 i_dummy = p_dest[i_x] + p_src[i_x]; \
148 p_dest[i_x] = (i_dummy + 1) >> 1; \
150 p_dest += i_stride; \
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, \
161 unsigned int i_dummy; \
163 for( i_y = 0; i_y < height; i_y ++ ) \
165 for( i_x = 0; i_x < width; i_x++ ) \
167 i_dummy = p_dest[i_x] + ((unsigned int)(p_src[i_x] \
170 p_dest[i_x] = (i_dummy + 1) >> 1; \
172 p_dest += i_stride; \
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, \
183 unsigned int i_dummy; \
185 for( i_y = 0; i_y < height; i_y ++ ) \
187 for( i_x = 0; i_x < width; i_x++ ) \
190 p_dest[i_x] + ((unsigned int)(p_src[i_x] \
191 + p_src[i_x + i_stride] \
193 p_dest[i_x] = (i_dummy + 1) >> 1; \
195 p_dest += i_stride; \
200 #define __MotionComponent_X_Y_avg(width,height) \
201 void MotionComponent_X_Y_avg_##width##_##height(yuv_data_t * p_src, \
202 yuv_data_t * p_dest, \
206 unsigned int i_dummy; \
208 for( i_y = 0; i_y < height; i_y ++ ) \
210 for( i_x = 0; i_x < width; i_x++ ) \
213 p_dest[i_x] + ((unsigned int)(p_src[i_x] \
215 + p_src[i_x + i_stride] \
216 + p_src[i_x + i_stride + 1] \
218 p_dest[i_x] = (i_dummy + 1) >> 1; \
220 p_dest += i_stride; \
225 #define __MotionComponents(width,height) \
226 __MotionComponent_x_y_copy(width,height) \
227 __MotionComponent_X_y_copy(width,height) \
228 __MotionComponent_x_Y_copy(width,height) \
229 __MotionComponent_X_Y_copy(width,height) \
230 __MotionComponent_x_y_avg(width,height) \
231 __MotionComponent_X_y_avg(width,height) \
232 __MotionComponent_x_Y_avg(width,height) \
233 __MotionComponent_X_Y_avg(width,height)
235 __MotionComponents (16,16) /* 444, 422, 420 */
236 __MotionComponents (16,8) /* 444, 422, 420 */
237 __MotionComponents (8,8) /* 422, 420 */
238 __MotionComponents (8,4) /* 420 */
240 __MotionComponents (8,16) /* 422 */