1 /**************************************************************************
3 * This code has been developed by Andrea Graziani. This software is an *
4 * implementation of a part of one or more MPEG-4 Video tools as *
5 * specified in ISO/IEC 14496-2 standard. Those intending to use this *
6 * software module in hardware or software products are advised that its *
7 * use may infringe existing patents or copyrights, and any such use *
8 * would be at such party's own risk. The original developer of this *
9 * software module and his/her company, and subsequent editors and their *
10 * companies (including Project Mayo), will have no liability for use of *
11 * this software or modifications or derivatives thereof. *
13 * Project Mayo gives users of the Codec a license to this software *
14 * module or modifications thereof for use in hardware or software *
15 * products claiming conformance to the MPEG-4 Video Standard as *
16 * described in the Open DivX license. *
18 * The complete Open DivX license can be found at *
19 * http://www.projectmayo.com/opendivx/license.php *
21 **************************************************************************/
23 * Copyright (C) 2001 - Project Mayo
25 * Andrea Graziani (Ag)
27 * DivX Advanced Research Center <darc@projectmayo.com>
34 #include "mp4_predict.h"
35 #include "mp4_iquant.h"
38 * inverse quantization for intra blocks
41 #define _iquant_h263(coeff, q_2scale, q_add) \
44 (coeff) = ((q_2scale) * (coeff)) + (q_add); \
50 (coeff) = ((q_2scale) * (coeff)) + (q_add); \
58 // iquant type h.263, not optimized
59 // intraFlag is 0 or 1
60 __inline
void iquant (short * psblock
, int intraFlag
)
63 int q_scale
= mp4_state
->hdr
.quantizer
;
64 int q_2scale
= q_scale
<< 1;
65 int q_add
= (q_scale
& 1) ? q_scale
: (q_scale
- 1);
67 * static int count = 0;
71 * printf("iquant %d\n", count);
76 for (i
= 1; i
< 64; i
++)
78 _iquant_h263(psblock
[i
], q_2scale
, q_add
);
81 for (i
= 0; i
< 64; i
++)
83 _iquant_h263(psblock
[i
], q_2scale
, q_add
);
88 void iquant_typefirst (short * psblock
)
92 * static int count = 0;
96 * printf("iquant_typefirst %d\n", count);
100 for (i
= 1; i
< 64; i
++)
102 if (psblock
[i
] != 0) {
103 psblock
[i
] = (psblock
[i
] * 2 * mp4_state
->hdr
.quantizer
*
104 mp4_tables
->intra_quant_matrix
[mp4_tables
->zig_zag_scan
[i
]]) >> 4;