]> git.sesse.net Git - vlc/blob - plugins/idct/vdec_idct.c
* dvdcss_readv optimisations for Win32. We now send only one read command
[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.3 2001/07/25 08:41:21 gbazin 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 <stdlib.h>                                              /* malloc() */
37 #include <string.h>                                    /* memcpy(), memset() */
38
39 #include "config.h"
40 #include "common.h"
41 #include "threads.h"
42 #include "mtime.h"
43
44 #include "video.h"
45 #include "video_output.h"
46
47 #include "modules.h"
48
49 #include "vdec_ext-plugins.h"
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     dctelem_t * p_pre;
59
60     p_vdec->p_idct_data = malloc( sizeof(dctelem_t) * 64 * 64 );
61     p_pre = (dctelem_t *) p_vdec->p_idct_data;
62     memset( p_pre, 0, 64 * 64 * sizeof(dctelem_t) );
63
64     for( i=0 ; i < 64 ; i++ )
65     {
66         p_pre[i*64+i] = 1 << SPARSE_SCALE_FACTOR;
67         _M( vdec_IDCT )( p_vdec, &p_pre[i*64], 0) ;
68     }
69     return;
70 }
71
72 /*****************************************************************************
73  * vdec_SparseIDCT : IDCT function for sparse matrices
74  *****************************************************************************/
75 void _M( vdec_SparseIDCT ) ( void * p_idct_data,
76                              dctelem_t * p_block, int i_sparse_pos )
77 {
78     short int val;
79     int * dp;
80     int v;
81     short int * p_dest;
82     short int * p_source;
83     int coeff, rr;
84     dctelem_t * p_pre = (dctelem_t *) p_idct_data;
85
86     /* If DC Coefficient. */
87     if ( i_sparse_pos == 0 )
88     {
89         dp=(int *)p_block;
90         val=RIGHT_SHIFT((*p_block + 4), 3);
91         /* Compute int to assign.  This speeds things up a bit */
92         v = ((val & 0xffff) | (val << 16));
93         dp[0] = v;     dp[1] = v;     dp[2] = v;     dp[3] = v;
94         dp[4] = v;     dp[5] = v;     dp[6] = v;     dp[7] = v;
95         dp[8] = v;     dp[9] = v;     dp[10] = v;    dp[11] = v;
96         dp[12] = v;    dp[13] = v;    dp[14] = v;    dp[15] = v;
97         dp[16] = v;    dp[17] = v;    dp[18] = v;    dp[19] = v;
98         dp[20] = v;    dp[21] = v;    dp[22] = v;    dp[23] = v;
99         dp[24] = v;    dp[25] = v;    dp[26] = v;    dp[27] = v;
100         dp[28] = v;    dp[29] = v;    dp[30] = v;    dp[31] = v;
101         return;
102     }
103     /* Some other coefficient. */
104     p_dest = (s16*)p_block;
105     p_source = (s16*)&p_pre[i_sparse_pos * 64];
106     coeff = (int)p_dest[i_sparse_pos];
107     for( rr=0 ; rr < 4 ; rr++ )
108     {
109         p_dest[0] = (p_source[0] * coeff) >> SPARSE_SCALE_FACTOR;
110         p_dest[1] = (p_source[1] * coeff) >> SPARSE_SCALE_FACTOR;
111         p_dest[2] = (p_source[2] * coeff) >> SPARSE_SCALE_FACTOR;
112         p_dest[3] = (p_source[3] * coeff) >> SPARSE_SCALE_FACTOR;
113         p_dest[4] = (p_source[4] * coeff) >> SPARSE_SCALE_FACTOR;
114         p_dest[5] = (p_source[5] * coeff) >> SPARSE_SCALE_FACTOR;
115         p_dest[6] = (p_source[6] * coeff) >> SPARSE_SCALE_FACTOR;
116         p_dest[7] = (p_source[7] * coeff) >> SPARSE_SCALE_FACTOR;
117         p_dest[8] = (p_source[8] * coeff) >> SPARSE_SCALE_FACTOR;
118         p_dest[9] = (p_source[9] * coeff) >> SPARSE_SCALE_FACTOR;
119         p_dest[10] = (p_source[10] * coeff) >> SPARSE_SCALE_FACTOR;
120         p_dest[11] = (p_source[11] * coeff) >> SPARSE_SCALE_FACTOR;
121         p_dest[12] = (p_source[12] * coeff) >> SPARSE_SCALE_FACTOR;
122         p_dest[13] = (p_source[13] * coeff) >> SPARSE_SCALE_FACTOR;
123         p_dest[14] = (p_source[14] * coeff) >> SPARSE_SCALE_FACTOR;
124         p_dest[15] = (p_source[15] * coeff) >> SPARSE_SCALE_FACTOR;
125         p_dest += 16;
126         p_source += 16;
127     }
128     return;
129 }
130