[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.2, Fri Mar 8 19:16:35 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 intra_matrix_changed;
6    uint8_t inter_matrix_changed;
7    
8  static const int16_t default_intra_matrix[64] = {  int16_t 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_fix[64] = {
20         FIX(8),FIX(17),FIX(18),FIX(19),FIX(21),FIX(23),FIX(25),FIX(27),
21        FIX(17),FIX(18),FIX(19),FIX(21),FIX(23),FIX(25),FIX(27),FIX(28),
22        FIX(20),FIX(21),FIX(22),FIX(23),FIX(24),FIX(26),FIX(28),FIX(30),
23        FIX(21),FIX(22),FIX(23),FIX(24),FIX(26),FIX(28),FIX(30),FIX(32),
24        FIX(22),FIX(23),FIX(24),FIX(26),FIX(28),FIX(30),FIX(32),FIX(35),
25        FIX(23),FIX(24),FIX(26),FIX(28),FIX(30),FIX(32),FIX(35),FIX(38),
26        FIX(25),FIX(26),FIX(28),FIX(30),FIX(32),FIX(35),FIX(38),FIX(41),
27        FIX(27),FIX(28),FIX(30),FIX(32),FIX(35),FIX(38),FIX(41),FIX(45)
28    };
29    
30    int16_t inter_matrix[64] = {
31      16,17,18,19,20,21,22,23,      16,17,18,19,20,21,22,23,
32      17,18,19,20,21,22,23,24,      17,18,19,20,21,22,23,24,
33      18,19,20,21,22,23,24,25,      18,19,20,21,22,23,24,25,
# Line 61  Line 38 
38      23,24,25,27,28,30,31,33      23,24,25,27,28,30,31,33
39  };  };
40    
41    int16_t inter_matrix_fix[64] = {
42        FIX(16),FIX(17),FIX(18),FIX(19),FIX(20),FIX(21),FIX(22),FIX(23),
43        FIX(17),FIX(18),FIX(19),FIX(20),FIX(21),FIX(22),FIX(23),FIX(24),
44        FIX(18),FIX(19),FIX(20),FIX(21),FIX(22),FIX(23),FIX(24),FIX(25),
45        FIX(19),FIX(20),FIX(21),FIX(22),FIX(23),FIX(24),FIX(26),FIX(27),
46        FIX(20),FIX(21),FIX(22),FIX(23),FIX(25),FIX(26),FIX(27),FIX(28),
47        FIX(21),FIX(22),FIX(23),FIX(24),FIX(26),FIX(27),FIX(28),FIX(30),
48        FIX(22),FIX(23),FIX(24),FIX(26),FIX(27),FIX(28),FIX(30),FIX(31),
49        FIX(23),FIX(24),FIX(25),FIX(27),FIX(28),FIX(30),FIX(31),FIX(33)
50    };
51    
52  void quant4_intra_init(QMATRIX * qmatrix, int use_default)  uint8_t get_intra_matrix_status(void) {
53  {          return intra_matrix_changed;
         if (use_default)  
         {  
                 memcpy(qmatrix->intra, default_intra_matrix, 64 * sizeof (int16_t));  
54          }          }
55    
56  #ifdef ARCH_X86  uint8_t get_inter_matrix_status(void) {
57          // TODO: generate mmx tables          return inter_matrix_changed;
58  #endif  }
59    
60    void set_intra_matrix_status(uint8_t status) {
61            intra_matrix_changed = status;
62  }  }
63    
64    void set_inter_matrix_status(uint8_t status) {
65            inter_matrix_changed = status;
66    }
67    
68  void quant4_inter_init(QMATRIX * qmatrix, int use_default)  int16_t *get_intra_matrix(void) {
69  {          return intra_matrix;
70          if (use_default)  }
71    
72    int16_t *get_inter_matrix(void) {
73            return inter_matrix;
74    }
75    
76    uint8_t set_intra_matrix(uint8_t *matrix)
77          {          {
78                  memcpy(qmatrix->inter, default_inter_matrix, 64 * sizeof (int16_t));          int i;
79    
80            intra_matrix_changed = 0;
81    
82            for(i = 0; i < 64; i++) {
83                    if(intra_matrix[i] != matrix[i])
84                            intra_matrix_changed = 1;
85    
86                    intra_matrix[i] = (int16_t) matrix[i];
87                    intra_matrix_fix[i] = FIX(intra_matrix[i]);
88            }
89            return intra_matrix_changed;
90          }          }
91    
92  #ifdef ARCH_X86  
93          // TODO: generate mmx tables  uint8_t set_inter_matrix(uint8_t *matrix)
94  #endif  {
95            int i;
96    
97            inter_matrix_changed = 0;
98    
99            for(i = 0; i < 64; i++) {
100                    if(inter_matrix[i] != matrix[i])
101                            inter_matrix_changed = 1;
102    
103                    inter_matrix[i] = (int16_t) matrix[i];
104                    inter_matrix_fix[i] = FIX(inter_matrix[i]);
105            }
106            return inter_matrix_changed;
107  }  }

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

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