?? tce.c
字號(hào):
if (QccWAVSubbandPyramidSubbandSize(image_subband_pyramid,
subband,
&subband_num_rows,
&subband_num_cols))
{
QccErrorAddMessage("(QccWAVtceDecodeInverseDWT): Error calling QccWAVSubbandPyramidSubbandSize()");
return(1);
}
if (QccWAVSubbandPyramidSubbandOffsets(image_subband_pyramid,
subband,
&subband_origin_row,
&subband_origin_col))
{
QccErrorAddMessage("(QccWAVtceDecodeInverseDWT): Error calling QccWAVSubbandPyramidSubbandOffsets()");
return(1);
}
for (row = 0; row < subband_num_rows; row++)
for (col = 0; col < subband_num_cols; col++)
{
if (sign_array[subband_origin_row + row]
[subband_origin_col + col])
image_subband_pyramid->matrix
[subband_origin_row + row][subband_origin_col + col] *= -1;
image_subband_pyramid->matrix
[subband_origin_row + row][subband_origin_col + col] *=
stepsize;
}
}
else
{
for (row = 0; row < image_subband_pyramid->num_rows; row++)
for (col = 0; col < image_subband_pyramid->num_cols; col++)
if (sign_array[row][col])
image_subband_pyramid->matrix[row][col] *= -1;
}
if (QccWAVSubbandPyramidInverseDWT(image_subband_pyramid,wavelet))
{
QccErrorAddMessage("(QccWAVtceDecodeInverseDWT): Error calling QccWAVSubbandPyramidInverseDWT()");
return(1);
}
if (QccWAVSubbandPyramidAddMean(image_subband_pyramid, image_mean))
{
QccErrorAddMessage("(QccWAVtceDecodeInverseDWT): Error calling QccWAVSubbandPyramidAddMean()");
return(1);
}
if (QccMatrixCopy(image->image,
image_subband_pyramid->matrix,
image->num_rows, image->num_cols))
{
QccErrorAddMessage("(QccWAVtceDecodeInverseDWT): Error calling QccMatrixCopy()");
return(1);
}
if (QccIMGImageComponentSetMaxMin(image))
{
QccErrorAddMessage("(QccWAVtceDecodeInverseDWT): Error calling QccIMGImageComponentSetMaxMin()");
return(1);
}
return(0);
}
int QccWAVtceDecodeHeader(QccBitBuffer *input_buffer,
int *num_levels,
int *num_rows,
int *num_cols,
double *image_mean,
double *stepsize,
int *max_coefficient_bits)
{
int return_value;
unsigned char ch;
if (QccBitBufferGetChar(input_buffer, &ch))
{
QccErrorAddMessage("(QccWAVtceDecodeHeader): Error calling QccBitBufferPuChar()");
goto Error;
}
*num_levels = (int)ch;
if (QccBitBufferGetInt(input_buffer, num_rows))
{
QccErrorAddMessage("(QccWAVtceDecodeHeader): Error calling QccBitBufferGetInt()");
goto Error;
}
if (QccBitBufferGetInt(input_buffer, num_cols))
{
QccErrorAddMessage("(QccWAVtceDecodeHeader): Error calling QccBitBufferGetInt()");
goto Error;
}
if (QccBitBufferGetDouble(input_buffer, image_mean))
{
QccErrorAddMessage("(QccWAVtceDecodeHeader): Error calling QccBitBufferGetDouble()");
goto Error;
}
if (QccBitBufferGetDouble(input_buffer, stepsize))
{
QccErrorAddMessage("(QccWAVtceDecodeHeader): Error calling QccBitBufferGetDouble()");
goto Error;
}
if (QccBitBufferGetInt(input_buffer, max_coefficient_bits))
{
QccErrorAddMessage("(QccWAVtceDecodeHeader): Error calling QccBitBufferGetChar()");
goto Error;
}
return_value = 0;
goto Return;
Error:
return_value = 1;
Return:
return(return_value);
}
int QccWAVtceDecode(QccBitBuffer *input_buffer,
QccIMGImageComponent *image,
int num_levels,
const QccWAVWavelet *wavelet,
double image_mean,
double stepsize,
int max_coefficient_bits,
int target_bit_cnt)
{
int return_value;
QccENTArithmeticModel *model = NULL;
QccWAVSubbandPyramid image_subband_pyramid;
char **sign_array = NULL;
char **significance_map = NULL;
double **p_estimation = NULL;
int *max_bits = NULL;
double *subband_significance = NULL;
double threshold;
int row, col;
int num_symbols[1] = { 2 };
int num_subbands;
QccWAVWavelet lazy_wavelet_transform;
int bitplane_cnt = 0;
if (image == NULL)
return(0);
if (input_buffer == NULL)
return(0);
if (wavelet == NULL)
return(0);
num_subbands = QccWAVSubbandPyramidNumLevelsToNumSubbands(num_levels);
if ((max_bits = (int *)malloc(sizeof(int) * num_subbands)) == NULL)
{
QccErrorAddMessage("(QccWAVtceDecode): Error allocating memory");
goto Error;
}
if (QccWAVtceDecodeBitPlaneInfo(input_buffer,
num_subbands,
max_bits,
max_coefficient_bits))
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccWAVtceEncodeBitPlaneInfo()");
goto Error;
}
QccWAVSubbandPyramidInitialize(&image_subband_pyramid);
QccWAVWaveletInitialize(&lazy_wavelet_transform);
image_subband_pyramid.num_levels = num_levels;
image_subband_pyramid.num_rows = image->num_rows;
image_subband_pyramid.num_cols = image->num_cols;
if (QccWAVSubbandPyramidAlloc(&image_subband_pyramid))
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccWAVSubbandPyramidAlloc()");
goto Error;
}
if ((sign_array = (char **)malloc(sizeof(char *) * image->num_rows)) == NULL)
{
QccErrorAddMessage("(QccWAVtceDecode): Error allocating memory");
goto Error;
}
for (row = 0; row < image->num_rows; row++)
if ((sign_array[row] =
(char *)malloc(sizeof(char) * image->num_cols)) == NULL)
{
QccErrorAddMessage("(QccWAVtceDecode): Error allocating memory");
goto Error;
}
if ((significance_map =
(char **)malloc(sizeof(char *) * image->num_rows)) == NULL)
{
QccErrorAddMessage("(QccWAVtceDecode): Error allocating memory");
goto Error;
}
for (row = 0; row < image->num_rows; row++)
if ((significance_map[row] =
(char *)malloc(sizeof(char) * image->num_cols)) == NULL)
{
QccErrorAddMessage("(QccWAVtceDecode): Error allocating memory");
goto Error;
}
for (row = 0; row < image->num_rows; row++)
for (col = 0; col < image->num_cols; col++)
{
image_subband_pyramid.matrix[row][col] = 0.0;
sign_array[row][col] = 0;
significance_map[row][col] = QCCTCE_Z;
}
if ((p_estimation =
(double **)malloc(sizeof(double *) * image->num_rows)) == NULL)
{
QccErrorAddMessage("(QccWAVtceEncode): Error allocating memory");
goto Error;
}
for (row = 0; row < image->num_rows; row++)
if ((p_estimation[row] =
(double *)malloc(sizeof(double) * image->num_cols)) == NULL)
{
QccErrorAddMessage("(QccWAVtceEncode): Error allocating memory");
goto Error;
}
for (row = 0; row < image->num_rows; row++)
for (col = 0; col < image->num_cols; col++)
p_estimation[row][col] = 0.0000001;
if ((subband_significance =
(double*)calloc(num_subbands,sizeof(double))) == NULL)
{
QccErrorAddMessage("(QccWAVtceDecode): Error allocating memory");
goto Error;
}
if ((model = QccENTArithmeticDecodeStart(input_buffer,
num_symbols,
1,
NULL,
target_bit_cnt)) == NULL)
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccENTArithmeticDecodeStart()");
goto Error;
}
QccENTArithmeticSetModelAdaption(model, QCCENT_NONADAPTIVE);
threshold = pow((double)2, (double)max_coefficient_bits);
if (stepsize <= 0)
while (1)
{
return_value = QccWAVtceNZNPass(&image_subband_pyramid,
significance_map,
sign_array,
threshold,
p_estimation,
subband_significance,
model,
input_buffer,
max_bits);
if (return_value == 1)
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccWAVtceNZNPass()");
goto Error;
}
else
{
if (return_value == 2)
goto Finished;
}
return_value = QccWAVtceIPPass(&image_subband_pyramid,
significance_map,
sign_array,
threshold,
p_estimation,
subband_significance,
model,
input_buffer,
max_bits);
if (return_value == 1)
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccWAVtceIPPass()");
goto Error;
}
else
{
if (return_value == 2)
goto Finished;
}
return_value = QccWAVtceSPass(&image_subband_pyramid,
significance_map,
threshold,
model,
input_buffer,
max_bits);
if (return_value == 1)
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccWAVtceSPass()");
goto Error;
}
else
{
if (return_value == 2)
goto Finished;
}
bitplane_cnt++;
threshold /= 2.0;
else
while (threshold > 0.75)
{
return_value = QccWAVtceNZNPass(&image_subband_pyramid,
significance_map,
sign_array,
threshold,
p_estimation,
subband_significance,
model,
input_buffer,
max_bits);
if (return_value == 1)
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccWAVtceNZNPass()");
goto Error;
}
else
{
if (return_value == 2)
goto Finished;
}
return_value = QccWAVtceIPPass(&image_subband_pyramid,
significance_map,
sign_array,
threshold,
p_estimation,
subband_significance,
model,
input_buffer,
max_bits);
if (return_value == 1)
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccWAVtceIPPass()");
goto Error;
}
else
{
if (return_value == 2)
goto Finished;
}
return_value = QccWAVtceSPass(&image_subband_pyramid,
significance_map,
threshold,
model,
input_buffer,
max_bits);
if (return_value == 1)
{
QccErrorAddMessage("(QccWAVtceDecode): Error calling QccWAVtceSPass()");
goto Error;
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -