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.1 2001/05/06 04:32:02 sam 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 *****************************************************************************/
43 #include "input_ext-dec.h"
46 #include "video_output.h"
48 #include "vdec_motion.h"
49 #include "video_decoder.h"
51 #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 #include "vdec_block.h"
60 /*****************************************************************************
62 *****************************************************************************
63 * We can keep them static since they will always contain the same values.
64 *****************************************************************************/
65 static u8 pi_crop_buf[VDEC_CROPRANGE];
68 /*****************************************************************************
69 * vdec_Init: initialize video decoder thread
70 *****************************************************************************/
71 void _M( vdec_Init ) ( vdec_thread_t *p_vdec )
76 pi_crop = pi_crop_buf + (VDEC_CROPRANGE >> 1);
78 for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ )
83 for( ; i_dummy < 255; i_dummy ++ )
85 pi_crop[i_dummy] = i_dummy;
88 for( ; i_dummy < (VDEC_CROPRANGE >> 1) -1; i_dummy++ )
90 pi_crop[i_dummy] = 255;
94 /*****************************************************************************
95 * AddBlock : add a block
96 *****************************************************************************/
97 static __inline__ void AddBlock( vdec_thread_t * p_vdec, dctelem_t * p_block,
98 yuv_data_t * p_data, int i_incr )
102 for( i_y = 0; i_y < 8; i_y++ )
104 for( i_x = 0; i_x < 8; i_x++ )
106 *p_data = pi_crop[*p_data + *p_block++];
113 /*****************************************************************************
114 * CopyBlock : copy a block
115 *****************************************************************************/
116 static __inline__ void CopyBlock( vdec_thread_t * p_vdec, dctelem_t * p_block,
117 yuv_data_t * p_data, int i_incr )
121 for( i_y = 0; i_y < 8; i_y++ )
123 for( i_x = 0; i_x < 8; i_x++ )
125 *p_data++ = pi_crop[*p_block++];
131 void _M( vdec_DecodeMacroblockC ) ( vdec_thread_t *p_vdec, macroblock_t * p_mb )
133 if( !(p_mb->i_mb_type & MB_INTRA) )
136 * Motion Compensation (ISO/IEC 13818-2 section 7.6)
138 if( p_mb->pf_motion == 0 )
140 intf_WarnMsg( 2, "pf_motion set to NULL" );
144 p_mb->pf_motion( p_mb );
147 DECODEBLOCKSC( AddBlock )
151 DECODEBLOCKSC( CopyBlock )
155 * Decoding is finished, release the macroblock and free
158 vpar_ReleaseMacroblock( &p_vdec->p_vpar->vfifo, p_mb );
161 void _M( vdec_DecodeMacroblockBW ) ( vdec_thread_t *p_vdec,
162 macroblock_t * p_mb )
164 if( !(p_mb->i_mb_type & MB_INTRA) )
167 * Motion Compensation (ISO/IEC 13818-2 section 7.6)
169 if( p_mb->pf_motion == 0 )
171 intf_WarnMsg( 2, "pf_motion set to NULL" );
175 p_mb->pf_motion( p_mb );
178 DECODEBLOCKSBW( AddBlock )
182 DECODEBLOCKSBW( CopyBlock )
186 * Decoding is finished, release the macroblock and free
189 vpar_ReleaseMacroblock( &p_vdec->p_vpar->vfifo, p_mb );