1 /*****************************************************************************
2 * vdec_block_c.c: Macroblock copy functions in C
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: vdec_block_c.c,v 1.5 2001/07/17 09:48:07 massiot Exp $
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
24 /* MODULE_NAME defined in Makefile together with -DBUILTIN */
26 # include "modules_inner.h"
28 # define _M( foo ) foo
31 /*****************************************************************************
33 *****************************************************************************/
45 #include "input_ext-dec.h"
48 #include "video_output.h"
50 #include "vdec_ext-plugins.h"
52 #include "vdec_block.h"
55 #include "modules_export.h"
57 /*****************************************************************************
59 *****************************************************************************
60 * We can keep them static since they will always contain the same values.
61 *****************************************************************************/
62 static u8 pi_crop_buf[VDEC_CROPRANGE];
65 /*****************************************************************************
66 * vdec_InitDecode: initialize video decoder thread
67 *****************************************************************************/
68 void _M( vdec_InitDecode ) ( vdec_thread_t *p_vdec )
73 pi_crop = pi_crop_buf + (VDEC_CROPRANGE >> 1);
75 for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ )
80 for( ; i_dummy < 255; i_dummy ++ )
82 pi_crop[i_dummy] = i_dummy;
85 for( ; i_dummy < (VDEC_CROPRANGE >> 1) -1; i_dummy++ )
87 pi_crop[i_dummy] = 255;
91 /*****************************************************************************
92 * AddBlock : add a block
93 *****************************************************************************/
94 static __inline__ void AddBlock( vdec_thread_t * p_vdec, dctelem_t * p_block,
95 yuv_data_t * p_data, int i_incr )
99 for( i_y = 0; i_y < 8; i_y++ )
101 for( i_x = 0; i_x < 8; i_x++ )
103 *p_data = pi_crop[*p_data + *p_block++];
110 /*****************************************************************************
111 * CopyBlock : copy a block
112 *****************************************************************************/
113 static __inline__ void CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block,
114 yuv_data_t * p_data, int i_incr )
118 for( i_y = 0; i_y < 8; i_y++ )
120 for( i_x = 0; i_x < 8; i_x++ )
122 *p_data++ = pi_crop[*p_block++];
128 void _M( vdec_DecodeMacroblockC ) ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
130 if( !(p_mb->i_mb_type & MB_INTRA) )
133 * Motion Compensation (ISO/IEC 13818-2 section 7.6)
135 if( p_mb->pf_motion == 0 )
137 intf_WarnMsg( 2, "pf_motion set to NULL" );
141 p_mb->pf_motion( p_mb );
144 DECODEBLOCKSC( AddBlock )
148 DECODEBLOCKSC( CopyBlock )
152 void _M( vdec_DecodeMacroblockBW ) ( vdec_thread_t *p_vdec,
153 macroblock_t * p_mb )
155 if( !(p_mb->i_mb_type & MB_INTRA) )
158 * Motion Compensation (ISO/IEC 13818-2 section 7.6)
160 if( p_mb->pf_motion == 0 )
162 intf_WarnMsg( 2, "pf_motion set to NULL" );
166 p_mb->pf_motion( p_mb );
169 DECODEBLOCKSBW( AddBlock )
173 DECODEBLOCKSBW( CopyBlock )