]> git.sesse.net Git - vlc/blob - plugins/idct/idct_common.c
90b308207d823a25a411c485f0b6130c9044bc26
[vlc] / plugins / idct / idct_common.c
1 /*****************************************************************************
2  * idct_common.c : common IDCT functions
3  *****************************************************************************
4  * Copyright (C) 1999, 2000 VideoLAN
5  * $Id: idct_common.c,v 1.2 2001/01/15 06:18:23 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 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include "defs.h"
28
29 #include "config.h"
30 #include "common.h"
31 #include "threads.h"
32 #include "mtime.h"
33
34 #include "video.h"
35 #include "video_output.h"
36
37 #include "video_decoder.h"
38
39 #include "modules.h"
40
41 #include "idct.h"
42
43 void vdec_SparseIDCT ( vdec_thread_t * p_vdec, dctelem_t * p_block,
44                        int i_sparse_pos);
45
46 /*****************************************************************************
47  * vdec_SparseIDCT : IDCT function for sparse matrices
48  *****************************************************************************/
49 void vdec_SparseIDCT (vdec_thread_t * p_vdec, dctelem_t * p_block,
50                       int i_sparse_pos)
51 {
52     short int val;
53     int * dp;
54     int v;
55     short int * p_dest;
56     short int * p_source;
57     int coeff, rr;
58
59     /* If DC Coefficient. */
60     if ( i_sparse_pos == 0 )
61     {
62         dp=(int *)p_block;
63         val=RIGHT_SHIFT((*p_block + 4), 3);
64         /* Compute int to assign.  This speeds things up a bit */
65         v = ((val & 0xffff) | (val << 16));
66         dp[0] = v;     dp[1] = v;     dp[2] = v;     dp[3] = v;
67         dp[4] = v;     dp[5] = v;     dp[6] = v;     dp[7] = v;
68         dp[8] = v;     dp[9] = v;     dp[10] = v;    dp[11] = v;
69         dp[12] = v;    dp[13] = v;    dp[14] = v;    dp[15] = v;
70         dp[16] = v;    dp[17] = v;    dp[18] = v;    dp[19] = v;
71         dp[20] = v;    dp[21] = v;    dp[22] = v;    dp[23] = v;
72         dp[24] = v;    dp[25] = v;    dp[26] = v;    dp[27] = v;
73         dp[28] = v;    dp[29] = v;    dp[30] = v;    dp[31] = v;
74         return;
75     }
76     /* Some other coefficient. */
77     p_dest = (s16*)p_block;
78     p_source = (s16*)&p_vdec->p_pre_idct[i_sparse_pos];
79     coeff = (int)p_dest[i_sparse_pos];
80     for( rr=0 ; rr < 4 ; rr++ )
81     {
82         p_dest[0] = (p_source[0] * coeff) >> SPARSE_SCALE_FACTOR;
83         p_dest[1] = (p_source[1] * coeff) >> SPARSE_SCALE_FACTOR;
84         p_dest[2] = (p_source[2] * coeff) >> SPARSE_SCALE_FACTOR;
85         p_dest[3] = (p_source[3] * coeff) >> SPARSE_SCALE_FACTOR;
86         p_dest[4] = (p_source[4] * coeff) >> SPARSE_SCALE_FACTOR;
87         p_dest[5] = (p_source[5] * coeff) >> SPARSE_SCALE_FACTOR;
88         p_dest[6] = (p_source[6] * coeff) >> SPARSE_SCALE_FACTOR;
89         p_dest[7] = (p_source[7] * coeff) >> SPARSE_SCALE_FACTOR;
90         p_dest[8] = (p_source[8] * coeff) >> SPARSE_SCALE_FACTOR;
91         p_dest[9] = (p_source[9] * coeff) >> SPARSE_SCALE_FACTOR;
92         p_dest[10] = (p_source[10] * coeff) >> SPARSE_SCALE_FACTOR;
93         p_dest[11] = (p_source[11] * coeff) >> SPARSE_SCALE_FACTOR;
94         p_dest[12] = (p_source[12] * coeff) >> SPARSE_SCALE_FACTOR;
95         p_dest[13] = (p_source[13] * coeff) >> SPARSE_SCALE_FACTOR;
96         p_dest[14] = (p_source[14] * coeff) >> SPARSE_SCALE_FACTOR;
97         p_dest[15] = (p_source[15] * coeff) >> SPARSE_SCALE_FACTOR;
98         p_dest += 16;
99         p_source += 16;
100     }
101     return;
102 }
103