[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.4, Sun Mar 10 00:30:55 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  void quant4_intra_init(QMATRIX * qmatrix, int use_default)  int16_t inter_matrix_fix[64] = {
64  {      FIX(16),FIX(17),FIX(18),FIX(19),FIX(20),FIX(21),FIX(22),FIX(23),
65          if (use_default)      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                  memcpy(qmatrix->intra, default_intra_matrix, 64 * sizeof (int16_t));      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 get_intra_matrix_status(void) {
75            return custom_intra_matrix;
76          }          }
77    
78  #ifdef ARCH_X86  uint8_t get_inter_matrix_status(void) {
79          // TODO: generate mmx tables          return custom_inter_matrix;
80  #endif  }
81    
82    void set_intra_matrix_status(uint8_t status) {
83            custom_intra_matrix = status;
84  }  }
85    
86    void set_inter_matrix_status(uint8_t status) {
87            custom_inter_matrix = status;
88    }
89    
90  void quant4_inter_init(QMATRIX * qmatrix, int use_default)  int16_t *get_intra_matrix(void) {
91  {          return intra_matrix;
92          if (use_default)  }
93    
94    int16_t *get_inter_matrix(void) {
95            return inter_matrix;
96    }
97    
98    uint8_t *get_default_intra_matrix(void) {
99            return default_intra_matrix;
100    }
101    
102    uint8_t *get_default_inter_matrix(void) {
103            return default_inter_matrix;
104    }
105    
106    uint8_t set_intra_matrix(uint8_t *matrix)
107          {          {
108                  memcpy(qmatrix->inter, default_inter_matrix, 64 * sizeof (int16_t));          int i, change = 0;
109    
110            custom_intra_matrix = 0;
111    
112            for(i = 0; i < 64; i++) {
113                    if((int16_t) default_intra_matrix[i] != matrix[i])
114                            custom_intra_matrix = 1;
115                    if(intra_matrix[i] != matrix[i])
116                            change = 1;
117    
118                    intra_matrix[i] = (int16_t) matrix[i];
119                    intra_matrix_fix[i] = FIX(intra_matrix[i]);
120            }
121            return custom_intra_matrix | change;
122          }          }
123    
124  #ifdef ARCH_X86  
125          // TODO: generate mmx tables  uint8_t set_inter_matrix(uint8_t *matrix)
126  #endif  {
127            int i, change = 0;
128    
129            custom_inter_matrix = 0;
130    
131            for(i = 0; i < 64; i++) {
132                    if((int16_t) default_inter_matrix[i] != matrix[i])
133                            custom_inter_matrix = 1;
134                    if(inter_matrix[i] != matrix[i])
135                            change = 1;
136    
137                    inter_matrix[i] = (int16_t) matrix[i];
138                    inter_matrix_fix[i] = FIX(inter_matrix[i]);
139            }
140            return custom_inter_matrix | change;
141  }  }

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

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