[cvs] / xvidcore / src / quant / quant_matrix.c Repository:
ViewVC logotype

Diff of /xvidcore/src/quant/quant_matrix.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1, Fri Mar 8 02:44:55 2002 UTC revision 1.5, Wed Jun 12 20:38:40 2002 UTC
# Line 1  Line 1 
1  /**************************************************************************  #include "quant_matrix.h"
  *  
  *    XVID MPEG-4 VIDEO CODEC  
  *    mpeg-4 quantization matrix stuff  
  *  
  *    This program is an implementation of a part of one or more MPEG-4  
  *    Video tools as specified in ISO/IEC 14496-2 standard.  Those intending  
  *    to use this software module in hardware or software products are  
  *    advised that its use may infringe existing patents or copyrights, and  
  *    any such use would be at such party's own risk.  The original  
  *    developer of this software module and his/her company, and subsequent  
  *    editors and their companies, will have no liability for use of this  
  *    software or modifications or derivatives thereof.  
  *  
  *    This program is free software; you can redistribute it and/or modify  
  *    it under the terms of the GNU General Public License as published by  
  *    the Free Software Foundation; either version 2 of the License, or  
  *    (at your option) any later version.  
  *  
  *    This program is distributed in the hope that it will be useful,  
  *    but WITHOUT ANY WARRANTY; without even the implied warranty of  
  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  
  *    GNU General Public License for more details.  
  *  
  *    You should have received a copy of the GNU General Public License  
  *    along with this program; if not, write to the Free Software  
  *    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  
  *  
  *************************************************************************/  
   
 /**************************************************************************  
  *  
  *    History:  
  *  
  *      2.3.2002    inital version <suxen_drol@hotmail.com>  
  *  
  *************************************************************************/  
2    
3  #include "common.h"  #define FIX(X) (1 << 16) / (X) + 1
4    
5    uint8_t custom_intra_matrix = 0;
6    uint8_t custom_inter_matrix = 0;
7    
8  static const int16_t default_intra_matrix[64] = {  uint8_t default_intra_matrix[64] = {
9       8,17,18,19,21,23,25,27,       8,17,18,19,21,23,25,27,
10      17,18,19,21,23,25,27,28,      17,18,19,21,23,25,27,28,
11      20,21,22,23,24,26,28,30,      20,21,22,23,24,26,28,30,
# Line 50  Line 16 
16      27,28,30,32,35,38,41,45      27,28,30,32,35,38,41,45
17  };  };
18    
19  static const int16_t default_inter_matrix[64] = {  int16_t intra_matrix[64] = {
20            8, 17, 18, 19, 21, 23, 25, 27,
21            17, 18, 19, 21, 23, 25, 27, 28,
22            20, 21, 22, 23, 24, 26, 28, 30,
23            21, 22, 23, 24, 26, 28, 30, 32,
24            22, 23, 24, 26, 28, 30, 32, 35,
25            23, 24, 26, 28, 30, 32, 35, 38,
26            25, 26, 28, 30, 32, 35, 38, 41,
27            27, 28, 30, 32, 35, 38, 41, 45
28    };
29    
30    int16_t intra_matrix_fix[64] = {
31            FIX(8), FIX(17), FIX(18), FIX(19), FIX(21), FIX(23), FIX(25), FIX(27),
32            FIX(17), FIX(18), FIX(19), FIX(21), FIX(23), FIX(25), FIX(27), FIX(28),
33            FIX(20), FIX(21), FIX(22), FIX(23), FIX(24), FIX(26), FIX(28), FIX(30),
34            FIX(21), FIX(22), FIX(23), FIX(24), FIX(26), FIX(28), FIX(30), FIX(32),
35            FIX(22), FIX(23), FIX(24), FIX(26), FIX(28), FIX(30), FIX(32), FIX(35),
36            FIX(23), FIX(24), FIX(26), FIX(28), FIX(30), FIX(32), FIX(35), FIX(38),
37            FIX(25), FIX(26), FIX(28), FIX(30), FIX(32), FIX(35), FIX(38), FIX(41),
38            FIX(27), FIX(28), FIX(30), FIX(32), FIX(35), FIX(38), FIX(41), FIX(45)
39    };
40    
41    uint8_t default_inter_matrix[64] = {
42      16,17,18,19,20,21,22,23,      16,17,18,19,20,21,22,23,
43      17,18,19,20,21,22,23,24,      17,18,19,20,21,22,23,24,
44      18,19,20,21,22,23,24,25,      18,19,20,21,22,23,24,25,
# Line 61  Line 49 
49      23,24,25,27,28,30,31,33      23,24,25,27,28,30,31,33
50  };  };
51    
52    int16_t inter_matrix[64] = {
53            16, 17, 18, 19, 20, 21, 22, 23,
54            17, 18, 19, 20, 21, 22, 23, 24,
55            18, 19, 20, 21, 22, 23, 24, 25,
56            19, 20, 21, 22, 23, 24, 26, 27,
57            20, 21, 22, 23, 25, 26, 27, 28,
58            21, 22, 23, 24, 26, 27, 28, 30,
59            22, 23, 24, 26, 27, 28, 30, 31,
60            23, 24, 25, 27, 28, 30, 31, 33
61    };
62    
63    int16_t inter_matrix_fix[64] = {
64            FIX(16), FIX(17), FIX(18), FIX(19), FIX(20), FIX(21), FIX(22), FIX(23),
65            FIX(17), FIX(18), FIX(19), FIX(20), FIX(21), FIX(22), FIX(23), FIX(24),
66            FIX(18), FIX(19), FIX(20), FIX(21), FIX(22), FIX(23), FIX(24), FIX(25),
67            FIX(19), FIX(20), FIX(21), FIX(22), FIX(23), FIX(24), FIX(26), FIX(27),
68            FIX(20), FIX(21), FIX(22), FIX(23), FIX(25), FIX(26), FIX(27), FIX(28),
69            FIX(21), FIX(22), FIX(23), FIX(24), FIX(26), FIX(27), FIX(28), FIX(30),
70            FIX(22), FIX(23), FIX(24), FIX(26), FIX(27), FIX(28), FIX(30), FIX(31),
71            FIX(23), FIX(24), FIX(25), FIX(27), FIX(28), FIX(30), FIX(31), FIX(33)
72    };
73    
74    uint8_t
75    get_intra_matrix_status(void)
76    {
77            return custom_intra_matrix;
78    }
79    
80    uint8_t
81    get_inter_matrix_status(void)
82    {
83            return custom_inter_matrix;
84    }
85    
86  void quant4_intra_init(QMATRIX * qmatrix, int use_default)  void
87    set_intra_matrix_status(uint8_t status)
88  {  {
89          if (use_default)          custom_intra_matrix = status;
90    }
91    
92    void
93    set_inter_matrix_status(uint8_t status)
94          {          {
95                  memcpy(qmatrix->intra, default_intra_matrix, 64 * sizeof (int16_t));          custom_inter_matrix = status;
96          }          }
97    
98  #ifdef ARCH_X86  int16_t *
99          // TODO: generate mmx tables  get_intra_matrix(void)
100  #endif  {
101            return intra_matrix;
102    }
103    
104    int16_t *
105    get_inter_matrix(void)
106    {
107            return inter_matrix;
108  }  }
109    
110    uint8_t *
111    get_default_intra_matrix(void)
112    {
113            return default_intra_matrix;
114    }
115    
116  void quant4_inter_init(QMATRIX * qmatrix, int use_default)  uint8_t *
117    get_default_inter_matrix(void)
118  {  {
119          if (use_default)          return default_inter_matrix;
120    }
121    
122    uint8_t
123    set_intra_matrix(uint8_t * matrix)
124          {          {
125                  memcpy(qmatrix->inter, default_inter_matrix, 64 * sizeof (int16_t));          int i, change = 0;
126    
127            custom_intra_matrix = 0;
128    
129            for (i = 0; i < 64; i++) {
130                    if ((int16_t) default_intra_matrix[i] != matrix[i])
131                            custom_intra_matrix = 1;
132                    if (intra_matrix[i] != matrix[i])
133                            change = 1;
134    
135                    intra_matrix[i] = (int16_t) matrix[i];
136                    intra_matrix_fix[i] = FIX(intra_matrix[i]);
137            }
138            return custom_intra_matrix | change;
139          }          }
140    
141  #ifdef ARCH_X86  
142          // TODO: generate mmx tables  uint8_t
143  #endif  set_inter_matrix(uint8_t * matrix)
144    {
145            int i, change = 0;
146    
147            custom_inter_matrix = 0;
148    
149            for (i = 0; i < 64; i++) {
150                    if ((int16_t) default_inter_matrix[i] != matrix[i])
151                            custom_inter_matrix = 1;
152                    if (inter_matrix[i] != matrix[i])
153                            change = 1;
154    
155                    inter_matrix[i] = (int16_t) matrix[i];
156                    inter_matrix_fix[i] = FIX(inter_matrix[i]);
157            }
158            return custom_inter_matrix | change;
159  }  }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.5

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4