r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / quicktime / decore50 / mp4_iquant.c
blob4fdd577b2a8f42b3850a05b145ee50f0c24a6120
1 /**************************************************************************
2 * *
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. *
12 * *
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. *
17 * *
18 * The complete Open DivX license can be found at *
19 * http://www.projectmayo.com/opendivx/license.php *
20 * *
21 **************************************************************************/
22 /**
23 * Copyright (C) 2001 - Project Mayo
25 * Andrea Graziani (Ag)
27 * DivX Advanced Research Center <darc@projectmayo.com>
29 **/
30 // mp4_iquant.c //
32 #include "mp4_vars.h"
34 #include "mp4_predict.h"
35 #include "mp4_iquant.h"
37 /**
38 * inverse quantization for intra blocks
39 **/
41 #define _iquant_h263(coeff, q_2scale, q_add) \
42 if ((coeff) > 0) \
43 { \
44 (coeff) = ((q_2scale) * (coeff)) + (q_add); \
45 } \
46 else \
47 if ((coeff) < 0)\
48 { \
49 (coeff) *= -1; \
50 (coeff) = ((q_2scale) * (coeff)) + (q_add); \
51 (coeff) *= -1; \
52 } \
54 /**
56 **/
58 // iquant type h.263, not optimized
59 // intraFlag is 0 or 1
60 __inline void iquant (short * psblock, int intraFlag)
62 int i;
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;
68 * count++;
69 * if(!(count % 1000))
70 * {
71 * printf("iquant %d\n", count);
72 * }
75 if(intraFlag)
76 for (i = 1; i < 64; i++)
78 _iquant_h263(psblock[i], q_2scale, q_add);
80 else
81 for (i = 0; i < 64; i++)
83 _iquant_h263(psblock[i], q_2scale, q_add);
88 void iquant_typefirst (short * psblock)
90 int i;
92 * static int count = 0;
93 * count++;
94 * if(!(count % 1000))
95 * {
96 * printf("iquant_typefirst %d\n", count);
97 * }
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;