]> git.sesse.net Git - vlc/blob - plugins/idct/vdec_idct.c
* Fixed a few warnings with gcc 3.0.
[vlc] / plugins / idct / vdec_idct.c
1 /*****************************************************************************
2  * vdec_idct.c : common IDCT functions
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: vdec_idct.c,v 1.1 2001/05/06 04:32:02 sam Exp $
6  *
7  * Authors: GaĆ«l Hendryckx <jimmy@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 "config.h"
39 #include "common.h"
40 #include "threads.h"
41 #include "mtime.h"
42
43 #include "video.h"
44 #include "video_output.h"
45
46 #include "video_decoder.h"
47
48 #include "modules.h"
49
50 #include "vdec_idct.h"
51
52 /*****************************************************************************
53  * vdec_InitIDCT : initialize datas for vdec_SparseIDCT
54  *****************************************************************************/
55 void _M( vdec_InitIDCT ) (vdec_thread_t * p_vdec)
56 {
57     int i;
58
59     dctelem_t * p_pre = p_vdec->p_pre_idct;
60     memset( p_pre, 0, 64*64*sizeof(dctelem_t) );
61
62     for( i=0 ; i < 64 ; i++ )
63     {
64         p_pre[i*64+i] = 1 << SPARSE_SCALE_FACTOR;
65         _M( vdec_IDCT )( p_vdec, &p_pre[i*64], 0) ;
66     }
67     return;
68 }
69
70 /*****************************************************************************
71  * vdec_SparseIDCT : IDCT function for sparse matrices
72  *****************************************************************************/
73 void _M( vdec_SparseIDCT ) ( vdec_thread_t * p_vdec, dctelem_t * p_block,
74                              int i_sparse_pos)
75 {
76     short int val;
77     int * dp;
78     int v;
79     short int * p_dest;
80     short int * p_source;
81     int coeff, rr;
82
83     /* If DC Coefficient. */
84     if ( i_sparse_pos == 0 )
85     {
86         dp=(int *)p_block;
87         val=RIGHT_SHIFT((*p_block + 4), 3);
88         /* Compute int to assign.  This speeds things up a bit */
89         v = ((val & 0xffff) | (val << 16));
90         dp[0] = v;     dp[1] = v;     dp[2] = v;     dp[3] = v;
91         dp[4] = v;     dp[5] = v;     dp[6] = v;     dp[7] = v;
92         dp[8] = v;     dp[9] = v;     dp[10] = v;    dp[11] = v;
93         dp[12] = v;    dp[13] = v;    dp[14] = v;    dp[15] = v;
94         dp[16] = v;    dp[17] = v;    dp[18] = v;    dp[19] = v;
95         dp[20] = v;    dp[21] = v;    dp[22] = v;    dp[23] = v;
96         dp[24] = v;    dp[25] = v;    dp[26] = v;    dp[27] = v;
97         dp[28] = v;    dp[29] = v;    dp[30] = v;    dp[31] = v;
98         return;
99     }
100     /* Some other coefficient. */
101     p_dest = (s16*)p_block;
102     p_source = (s16*)&p_vdec->p_pre_idct[i_sparse_pos];
103     coeff = (int)p_dest[i_sparse_pos];
104     for( rr=0 ; rr < 4 ; rr++ )
105     {
106         p_dest[0] = (p_source[0] * coeff) >> SPARSE_SCALE_FACTOR;
107         p_dest[1] = (p_source[1] * coeff) >> SPARSE_SCALE_FACTOR;
108         p_dest[2] = (p_source[2] * coeff) >> SPARSE_SCALE_FACTOR;
109         p_dest[3] = (p_source[3] * coeff) >> SPARSE_SCALE_FACTOR;
110         p_dest[4] = (p_source[4] * coeff) >> SPARSE_SCALE_FACTOR;
111         p_dest[5] = (p_source[5] * coeff) >> SPARSE_SCALE_FACTOR;
112         p_dest[6] = (p_source[6] * coeff) >> SPARSE_SCALE_FACTOR;
113         p_dest[7] = (p_source[7] * coeff) >> SPARSE_SCALE_FACTOR;
114         p_dest[8] = (p_source[8] * coeff) >> SPARSE_SCALE_FACTOR;
115         p_dest[9] = (p_source[9] * coeff) >> SPARSE_SCALE_FACTOR;
116         p_dest[10] = (p_source[10] * coeff) >> SPARSE_SCALE_FACTOR;
117         p_dest[11] = (p_source[11] * coeff) >> SPARSE_SCALE_FACTOR;
118         p_dest[12] = (p_source[12] * coeff) >> SPARSE_SCALE_FACTOR;
119         p_dest[13] = (p_source[13] * coeff) >> SPARSE_SCALE_FACTOR;
120         p_dest[14] = (p_source[14] * coeff) >> SPARSE_SCALE_FACTOR;
121         p_dest[15] = (p_source[15] * coeff) >> SPARSE_SCALE_FACTOR;
122         p_dest += 16;
123         p_source += 16;
124     }
125     return;
126 }
127