00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "contributors.h"
00017
00018 #include <math.h>
00019
00020 #include "global.h"
00021 #include "q_matrix.h"
00022 #include "quant4x4.h"
00023 #include "quantChroma.h"
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 int quant_dc2x2_normal(Macroblock *currMB, int **tblock, int qp, int* DCLevel, int* DCRun,
00038 LevelQuantParams *q_params_4x4, int **fadjust, const byte (*pos_scan)[2])
00039 {
00040 QuantParameters *p_Quant = currMB->p_Img->p_Quant;
00041 Boolean is_cavlc = (currMB->p_slice->symbol_mode == CAVLC);
00042 int coeff_ctr;
00043
00044 int *m7;
00045 int scaled_coeff;
00046
00047 int level, run = 0;
00048 int nonzero = FALSE;
00049 int qp_per = p_Quant->qp_per_matrix[qp];
00050 int q_bits = Q_BITS + qp_per + 1;
00051
00052 int* DCL = &DCLevel[0];
00053 int* DCR = &DCRun[0];
00054
00055 m7 = *tblock;
00056
00057
00058 for (coeff_ctr=0; coeff_ctr < 4; coeff_ctr++)
00059 {
00060
00061
00062 if (*m7)
00063 {
00064 scaled_coeff = iabs (*m7) * q_params_4x4->ScaleComp;
00065 level = (scaled_coeff + (q_params_4x4->OffsetComp << 1) ) >> q_bits;
00066
00067 if (level != 0)
00068 {
00069 if (is_cavlc)
00070 level = imin(level, CAVLC_LEVEL_LIMIT);
00071
00072 level = isignab(level, *m7);
00073
00074 *m7++ = ((level * q_params_4x4->InvScaleComp) << qp_per);
00075
00076 *DCL++ = level;
00077 *DCR++ = run;
00078 run = 0;
00079 nonzero = TRUE;
00080 }
00081 else
00082 {
00083 run++;
00084 *m7++ = 0;
00085 }
00086 }
00087 else
00088 {
00089 run++;
00090 m7++;
00091 }
00092 }
00093
00094 *DCL = 0;
00095
00096 return nonzero;
00097 }
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 int quant_dc4x2_normal(Macroblock *currMB, int **tblock, int qp, int* DCLevel, int* DCRun,
00111 LevelQuantParams *q_params_4x4, int **fadjust, const byte (*pos_scan)[2])
00112 {
00113 QuantParameters *p_Quant = currMB->p_Img->p_Quant;
00114 Boolean is_cavlc = (currMB->p_slice->symbol_mode == CAVLC);
00115 int i,j, coeff_ctr;
00116
00117 int *m7;
00118 int scaled_coeff;
00119
00120 int level, run = 0;
00121 int nonzero = FALSE;
00122 int qp_per = p_Quant->qp_per_matrix[qp];
00123 int q_bits = Q_BITS + qp_per + 1;
00124 const byte *p_scan = &pos_scan[0][0];
00125 int* DCL = &DCLevel[0];
00126 int* DCR = &DCRun[0];
00127
00128
00129 for (coeff_ctr = 0; coeff_ctr < 8; coeff_ctr++)
00130 {
00131 j = *p_scan++;
00132 i = *p_scan++;
00133
00134 m7 = &tblock[j][i];
00135
00136 if (*m7 != 0)
00137 {
00138 scaled_coeff = iabs (*m7) * q_params_4x4->ScaleComp;
00139 level = (scaled_coeff + (q_params_4x4->OffsetComp << 1) ) >> q_bits;
00140
00141 if (level != 0)
00142 {
00143 if (is_cavlc)
00144 level = imin(level, CAVLC_LEVEL_LIMIT);
00145 level = isignab(level, *m7);
00146
00147 *m7 = ((level * q_params_4x4->InvScaleComp) << qp_per);
00148
00149 *DCL++ = level;
00150 *DCR++ = run;
00151
00152 run = 0;
00153 nonzero = TRUE;
00154 }
00155 else
00156 {
00157 run++;
00158 *m7 = 0;
00159 }
00160 }
00161 else
00162 {
00163 run++;
00164 }
00165 }
00166
00167 *DCL = 0;
00168
00169 return nonzero;
00170 }
00171
00172
00173