]> git.sesse.net Git - vlc/blob - plugins/idct/vdec_block_c.c
* fixed stupid bug in stupid ConvertPrintfFormatString() function
[vlc] / plugins / idct / vdec_block_c.c
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.8 2001/12/09 17:01:36 sam 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 /* MODULE_NAME defined in Makefile together with -DBUILTIN */
25 #ifdef BUILTIN
26 #   include "modules_inner.h"
27 #else
28 #   define _M( foo ) foo
29 #endif
30
31 /*****************************************************************************
32  * Preamble
33  *****************************************************************************/
34 #include "defs.h"
35
36 #include <string.h>                                    /* memcpy(), memset() */
37
38 #include "common.h"
39 #include "intf_msg.h"                        /* intf_DbgMsg(), intf_ErrMsg() */
40 #include "threads.h"
41 #include "mtime.h"
42
43 #include "vdec_idct.h"
44
45 #include "modules.h"
46 #include "modules_export.h"
47
48 /*****************************************************************************
49  * Static variables
50  *****************************************************************************
51  * We can keep them static since they will always contain the same values.
52  *****************************************************************************/
53 static u8  pi_crop_buf[VDEC_CROPRANGE];
54 static u8 *pi_crop;
55
56 /*****************************************************************************
57  * vdec_InitDecode: initialize video decoder thread
58  *****************************************************************************/
59 void _M( vdec_InitDecode ) ( )
60 {
61     int i_dummy;
62
63     /* Init crop table */
64     pi_crop = pi_crop_buf + (VDEC_CROPRANGE >> 1);
65
66     for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ )
67     {
68         pi_crop[i_dummy] = 0;
69     }
70
71     for( ; i_dummy < 255; i_dummy ++ )
72     {
73         pi_crop[i_dummy] = i_dummy;
74     }
75
76     for( ; i_dummy < (VDEC_CROPRANGE >> 1) -1; i_dummy++ )
77     {
78         pi_crop[i_dummy] = 255;
79     }
80 }
81
82 /*****************************************************************************
83  * vdec_AddBlock : add a block
84  *****************************************************************************/
85 void _M( vdec_AddBlock ) ( dctelem_t * p_block, yuv_data_t * p_data,
86                            int i_incr )
87 {
88     int i = 8;
89
90     do {
91         p_data[0] = pi_crop[ p_data[0] + p_block[0] ];
92         p_data[1] = pi_crop[ p_data[1] + p_block[1] ];
93         p_data[2] = pi_crop[ p_data[2] + p_block[2] ];
94         p_data[3] = pi_crop[ p_data[3] + p_block[3] ];
95         p_data[4] = pi_crop[ p_data[4] + p_block[4] ];
96         p_data[5] = pi_crop[ p_data[5] + p_block[5] ];
97         p_data[6] = pi_crop[ p_data[6] + p_block[6] ];
98         p_data[7] = pi_crop[ p_data[7] + p_block[7] ];
99
100         p_data += i_incr;
101         p_block += 8;
102     } while( --i );
103 }
104
105 /*****************************************************************************
106  * vdec_CopyBlock : copy a block
107  *****************************************************************************/
108 void _M( vdec_CopyBlock )( dctelem_t * p_block, yuv_data_t * p_data,
109                            int i_incr )
110 {
111     int i = 8;
112
113     do {
114         p_data[0] = pi_crop[ p_block[0] ];
115         p_data[1] = pi_crop[ p_block[1] ];
116         p_data[2] = pi_crop[ p_block[2] ];
117         p_data[3] = pi_crop[ p_block[3] ];
118         p_data[4] = pi_crop[ p_block[4] ];
119         p_data[5] = pi_crop[ p_block[5] ];
120         p_data[6] = pi_crop[ p_block[6] ];
121         p_data[7] = pi_crop[ p_block[7] ];
122
123         p_data += i_incr;
124         p_block += 8;
125     } while( --i );
126 }
127