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_around(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
00079 run = 0;
00080 nonzero = TRUE;
00081 }
00082 else
00083 {
00084 ++run;
00085 *m7++ = 0;
00086 }
00087 }
00088 else
00089 {
00090 ++run;
00091 ++m7;
00092 }
00093 }
00094
00095 *DCL = 0;
00096
00097 return nonzero;
00098 }
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111 int quant_dc4x2_around(Macroblock *currMB, int **tblock, int qp, int* DCLevel, int* DCRun,
00112 LevelQuantParams *q_params_4x4, int **fadjust, const byte (*pos_scan)[2])
00113 {
00114 QuantParameters *p_Quant = currMB->p_Img->p_Quant;
00115 Boolean is_cavlc = (currMB->p_slice->symbol_mode == CAVLC);
00116 int i,j, coeff_ctr;
00117
00118 int *m7;
00119 int scaled_coeff;
00120
00121 int level, run = 0;
00122 int nonzero = FALSE;
00123 int qp_per = p_Quant->qp_per_matrix[qp];
00124 int q_bits = Q_BITS + qp_per + 1;
00125 const byte *p_scan = &pos_scan[0][0];
00126 int* DCL = &DCLevel[0];
00127 int* DCR = &DCRun[0];
00128
00129
00130 for (coeff_ctr = 0; coeff_ctr < 8; ++coeff_ctr)
00131 {
00132 j = *p_scan++;
00133 i = *p_scan++;
00134
00135 m7 = &tblock[j][i];
00136
00137 if (*m7 != 0)
00138 {
00139 scaled_coeff = iabs (*m7) * q_params_4x4->ScaleComp;
00140 level = (scaled_coeff + (q_params_4x4->OffsetComp << 1) ) >> q_bits;
00141
00142 if (level != 0)
00143 {
00144 if (is_cavlc)
00145 level = imin(level, CAVLC_LEVEL_LIMIT);
00146 level = isignab(level, *m7);
00147
00148 *m7 = ((level * q_params_4x4->InvScaleComp) << qp_per);
00149
00150 *DCL++ = level;
00151 *DCR++ = run;
00152
00153 run = 0;
00154 nonzero = TRUE;
00155 }
00156 else
00157 {
00158 ++run;
00159 *m7 = 0;
00160 }
00161 }
00162 else
00163 {
00164 ++run;
00165 }
00166 }
00167
00168 *DCL = 0;
00169
00170 return nonzero;
00171 }
00172
00173
00174