]> git.sesse.net Git - vlc/blob - plugins/idct/block_c.h
* Altivec IDCT and motion compensation, based on Paul Mackerras's mpeg2dec
[vlc] / plugins / idct / block_c.h
1 /*****************************************************************************
2  * block_c.h: Macroblock copy functions in C
3  *****************************************************************************
4  * Copyright (C) 1999, 2000, 2001 VideoLAN
5  * $Id: block_c.h,v 1.1 2001/09/05 16:07:49 massiot Exp $
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Static variables
26  *****************************************************************************
27  * We can keep them static since they will always contain the same values.
28  *****************************************************************************/
29 static u8  pi_crop_buf[VDEC_CROPRANGE];
30 static u8 *pi_crop;
31
32 /*****************************************************************************
33  * InitBlock: initialize the crop table
34  *****************************************************************************/
35 static void InitBlock ( )
36 {
37     int i_dummy;
38
39     /* Init crop table */
40     pi_crop = pi_crop_buf + (VDEC_CROPRANGE >> 1);
41
42     for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ )
43     {
44         pi_crop[i_dummy] = 0;
45     }
46
47     for( ; i_dummy < 255; i_dummy ++ )
48     {
49         pi_crop[i_dummy] = i_dummy;
50     }
51
52     for( ; i_dummy < (VDEC_CROPRANGE >> 1) -1; i_dummy++ )
53     {
54         pi_crop[i_dummy] = 255;
55     }
56 }
57
58 /*****************************************************************************
59  * AddBlock: add a block
60  *****************************************************************************/
61 static __inline__ void AddBlock( dctelem_t * p_block, yuv_data_t * p_data,
62                                  int i_incr )
63 {
64     int i = 8;
65
66     do {
67         p_data[0] = pi_crop[ p_data[0] + p_block[0] ];
68         p_data[1] = pi_crop[ p_data[1] + p_block[1] ];
69         p_data[2] = pi_crop[ p_data[2] + p_block[2] ];
70         p_data[3] = pi_crop[ p_data[3] + p_block[3] ];
71         p_data[4] = pi_crop[ p_data[4] + p_block[4] ];
72         p_data[5] = pi_crop[ p_data[5] + p_block[5] ];
73         p_data[6] = pi_crop[ p_data[6] + p_block[6] ];
74         p_data[7] = pi_crop[ p_data[7] + p_block[7] ];
75
76         p_data += i_incr;
77         p_block += 8;
78     } while( --i );
79 }
80
81 /*****************************************************************************
82  * CopyBlock: copy a block
83  *****************************************************************************/
84 static __inline__ void CopyBlock( dctelem_t * p_block, yuv_data_t * p_data,
85                                   int i_incr )
86 {
87     int i = 8;
88
89     do {
90         p_data[0] = pi_crop[ p_block[0] ];
91         p_data[1] = pi_crop[ p_block[1] ];
92         p_data[2] = pi_crop[ p_block[2] ];
93         p_data[3] = pi_crop[ p_block[3] ];
94         p_data[4] = pi_crop[ p_block[4] ];
95         p_data[5] = pi_crop[ p_block[5] ];
96         p_data[6] = pi_crop[ p_block[6] ];
97         p_data[7] = pi_crop[ p_block[7] ];
98
99         p_data += i_incr;
100         p_block += 8;
101     } while( --i );
102 }
103