]> git.sesse.net Git - vlc/blob - plugins/idct/vdec_block_c.c
* Fixed a problem with field streams not working with new video decoder.
[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.6 2001/08/22 17:21:45 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 /* 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>
37
38 #include "config.h"
39 #include "common.h"
40 #include "threads.h"
41 #include "mtime.h"
42
43 #include "intf_msg.h"
44
45 #include "vdec_idct.h"
46
47 #include "modules.h"
48 #include "modules_export.h"
49
50 /*****************************************************************************
51  * Static variables
52  *****************************************************************************
53  * We can keep them static since they will always contain the same values.
54  *****************************************************************************/
55 static u8  pi_crop_buf[VDEC_CROPRANGE];
56 static u8 *pi_crop;
57
58 /*****************************************************************************
59  * vdec_InitDecode: initialize video decoder thread
60  *****************************************************************************/
61 void _M( vdec_InitDecode ) ( )
62 {
63     int i_dummy;
64
65     /* Init crop table */
66     pi_crop = pi_crop_buf + (VDEC_CROPRANGE >> 1);
67
68     for( i_dummy = -(VDEC_CROPRANGE >> 1); i_dummy < 0; i_dummy++ )
69     {
70         pi_crop[i_dummy] = 0;
71     }
72
73     for( ; i_dummy < 255; i_dummy ++ )
74     {
75         pi_crop[i_dummy] = i_dummy;
76     }
77
78     for( ; i_dummy < (VDEC_CROPRANGE >> 1) -1; i_dummy++ )
79     {
80         pi_crop[i_dummy] = 255;
81     }
82 }
83
84 /*****************************************************************************
85  * vdec_AddBlock : add a block
86  *****************************************************************************/
87 void _M( vdec_AddBlock ) ( dctelem_t * p_block, yuv_data_t * p_data,
88                            int i_incr )
89 {
90     int i = 8;
91
92     do {
93         p_data[0] = pi_crop[ p_data[0] + p_block[0] ];
94         p_data[1] = pi_crop[ p_data[1] + p_block[1] ];
95         p_data[2] = pi_crop[ p_data[2] + p_block[2] ];
96         p_data[3] = pi_crop[ p_data[3] + p_block[3] ];
97         p_data[4] = pi_crop[ p_data[4] + p_block[4] ];
98         p_data[5] = pi_crop[ p_data[5] + p_block[5] ];
99         p_data[6] = pi_crop[ p_data[6] + p_block[6] ];
100         p_data[7] = pi_crop[ p_data[7] + p_block[7] ];
101
102         p_data += i_incr;
103         p_block += 8;
104     } while( --i );
105 }
106
107 /*****************************************************************************
108  * vdec_CopyBlock : copy a block
109  *****************************************************************************/
110 void _M( vdec_CopyBlock )( dctelem_t * p_block, yuv_data_t * p_data,
111                            int i_incr )
112 {
113     int i = 8;
114
115     do {
116         p_data[0] = pi_crop[ p_block[0] ];
117         p_data[1] = pi_crop[ p_block[1] ];
118         p_data[2] = pi_crop[ p_block[2] ];
119         p_data[3] = pi_crop[ p_block[3] ];
120         p_data[4] = pi_crop[ p_block[4] ];
121         p_data[5] = pi_crop[ p_block[5] ];
122         p_data[6] = pi_crop[ p_block[6] ];
123         p_data[7] = pi_crop[ p_block[7] ];
124
125         p_data += i_incr;
126         p_block += 8;
127     } while( --i );
128 }
129