1 /***************************************************************************
2  * Video decoder for the W996[87]CF driver for Linux.                      *
3  *                                                                         *
4  * Copyright (C) 2003 by Luca Risolia <luca.risolia@studio.unibo.it>       *
5  *                                                                         *
6  * This program is free software; you can redistribute it and/or modify    *
7  * it under the terms of the GNU General Public License as published by    *
8  * the Free Software Foundation; either version 2 of the License, or       *
9  * (at your option) any later version.                                     *
10  *                                                                         *
11  * This program is distributed in the hope that it will be useful,         *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
14  * GNU General Public License for more details.                            *
15  *                                                                         *
16  * You should have received a copy of the GNU General Public License       *
17  * along with this program; if not, write to the Free Software             *
18  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.               *
19  ***************************************************************************/
20 
21 #ifndef _W9968CF_DECODER_H_
22 #define _W9968CF_DECODER_H_
23 
24 /* Comment/uncomment this for high/low quality of compressed video */
25 #define W9968CF_DEC_FAST_LOWQUALITY_VIDEO
26 
27 #ifdef W9968CF_DEC_FAST_LOWQUALITY_VIDEO
28 static const unsigned char Y_QUANTABLE[64] = {
29 	16,  11,  10,  16,  24,  40,  51,  61,
30 	12,  12,  14,  19,  26,  58,  60,  55,
31 	14,  13,  16,  24,  40,  57,  69,  56,
32 	14,  17,  22,  29,  51,  87,  80,  62,
33 	18,  22,  37,  56,  68, 109, 103,  77,
34 	24,  35,  55,  64,  81, 104, 113,  92,
35 	49,  64,  78,  87, 103, 121, 120, 101,
36 	72,  92,  95,  98, 112, 100, 103,  99
37 };
38 
39 static const unsigned char UV_QUANTABLE[64] = {
40 	17,  18,  24,  47,  99,  99,  99,  99,
41 	18,  21,  26,  66,  99,  99,  99,  99,
42 	24,  26,  56,  99,  99,  99,  99,  99,
43 	47,  66,  99,  99,  99,  99,  99,  99,
44 	99,  99,  99,  99,  99,  99,  99,  99,
45 	99,  99,  99,  99,  99,  99,  99,  99,
46 	99,  99,  99,  99,  99,  99,  99,  99,
47 	99,  99,  99,  99,  99,  99,  99,  99
48 };
49 #else
50 static const unsigned char Y_QUANTABLE[64] = {
51 	 8,   5,   5,   8,  12,  20,  25,  30,
52 	 6,   6,   7,   9,  13,  29,  30,  27,
53 	 7,   6,   8,  12,  20,  28,  34,  28,
54 	 7,   8,  11,  14,  25,  43,  40,  31,
55 	 9,  11,  18,  28,  34,  54,  51,  38,
56 	12,  17,  27,  32,  40,  52,  56,  46,
57 	24,  32,  39,  43,  51,  60,  60,  50,
58 	36,  46,  47,  49,  56,  50,  51,  49
59 };
60 
61 static const unsigned char UV_QUANTABLE[64] = {
62 	 8,   9,  12,  23,  49,  49,  49,  49,
63 	 9,  10,  13,  33,  49,  49,  49,  49,
64 	12,  13,  28,  49,  49,  49,  49,  49,
65 	23,  33,  49,  49,  49,  49,  49,  49,
66 	49,  49,  49,  49,  49,  49,  49,  49,
67 	49,  49,  49,  49,  49,  49,  49,  49,
68 	49,  49,  49,  49,  49,  49,  49,  49,
69 	49,  49,  49,  49,  49,  49,  49,  49
70 };
71 #endif
72 
73 #define W9968CF_DEC_ERR_CORRUPTED_DATA  -1
74 #define W9968CF_DEC_ERR_BUF_OVERFLOW    -2
75 #define W9968CF_DEC_ERR_NO_SOI          -3
76 #define W9968CF_DEC_ERR_NO_SOF0         -4
77 #define W9968CF_DEC_ERR_NO_SOS          -5
78 #define W9968CF_DEC_ERR_NO_EOI          -6
79 
80 extern void w9968cf_init_decoder(void);
81 extern int w9968cf_check_headers(const unsigned char* Pin,
82                                  const unsigned long BUF_SIZE);
83 extern int w9968cf_decode(const char* Pin, const unsigned long BUF_SIZE,
84                           const unsigned W, const unsigned H, char* Pout);
85 
86 #endif /* _W9968CF_DECODER_H_ */
87