?? sfq.c
字號:
filtered_variances = subband_images[parent_subband]; filtered_variances.image = NULL; if (QccIMGImageComponentAlloc(&variances)) { QccErrorAddMessage("(QccWAVsfqDecodeReconstructZerotree): Error calling QccIMGImageComponentAlloc()"); goto QccError; } if (QccIMGImageComponentAlloc(&filtered_variances)) { QccErrorAddMessage("(QccWAVsfqDecodeReconstructZerotree): Error calling QccIMGImageComponentAlloc()"); goto QccError; } for (row = 0; row < zerotree->num_rows[parent_subband]; row++) for (col = 0; col < zerotree->num_cols[parent_subband]; col++) { filtered_variances.image[row][col] = 0.0; if (QccWAVZerotreeNullSymbol(zerotree->zerotree [parent_subband][row][col])) variances.image[row][col] = 0.0; else variances.image[row][col] = subband_images[parent_subband].image[row][col] * subband_images[parent_subband].image[row][col]; } if (QccIMGImageComponentFilterSeparable(&variances, &filtered_variances, &filter, &filter, QCCFILTER_SYMMETRIC_EXTENSION)) { QccErrorAddMessage("(QccWAVsfqDecodeReconstructZerotree): Error calling QccIMGImageComponentFilterSeparable()"); goto QccError; } high_variance = -MAXDOUBLE; low_variance = MAXDOUBLE; for (row = 0, variance_index = 0; row < zerotree->num_rows[subband]; row++) for (col = 0; col < zerotree->num_cols[subband]; col++) if (!QccWAVZerotreeNullSymbol(zerotree->zerotree[subband][row][col])) { parent_variance = filtered_variances.image[row / 2][col / 2]; if (variance_index == high_tree_thresholds[subband]) high_variance = parent_variance; if (variance_index == low_tree_thresholds[subband]) low_variance = parent_variance; variance_index++; } /****/ printf("Subband: %d %f %f %d %d\n", subband, high_variance, low_variance, high_tree_thresholds[subband], low_tree_thresholds[subband]); for (row = 0; row < zerotree->num_rows[subband]; row++) for (col = 0; col < zerotree->num_cols[subband]; col++) if (!QccWAVZerotreeNullSymbol(zerotree->zerotree[subband][row][col])) { parent_variance = filtered_variances.image[row / 2][col / 2]; if (parent_variance > high_variance) zerotree->zerotree[subband][row][col] = QCCWAVZEROTREE_SYMBOLSIGNIFICANT; else /*****/ if (parent_variance < low_variance) zerotree->zerotree[subband][row][col] = QCCWAVZEROTREE_SYMBOLZTROOT; else zerotree->zerotree[subband][row][col] = zerotree_symbols[(*zerotree_index)++]; if (zerotree->zerotree[subband][row][col] == QCCWAVZEROTREE_SYMBOLZTROOT) QccWAVZerotreeCarveOutZerotree(zerotree, subband, row, col); } return_value = 0; goto QccReturn; QccError: return_value = 1; QccReturn: QccIMGImageComponentFree(&variances); QccIMGImageComponentFree(&filtered_variances); return(return_value);}static int QccWAVsfqDecodeReconstructSubband(QccWAVZerotree *zerotree, QccChannel *channels, int subband, const QccSQScalarQuantizer *highpass_quantizer, const QccSQScalarQuantizer *baseband_quantizer, QccIMGImageComponent *subband_images){ int return_value; int row, col, channel_index; if (QccChannelDenormalize(&(channels[subband]))) { QccErrorAddMessage("(QccWAVsfqDecodeReconstructSubband): Error calling QccChannelDenormalize()"); goto QccError; } for (row = 0, channel_index = 0; row < zerotree->num_rows[subband]; row++) for (col = 0; col < zerotree->num_cols[subband]; col++) if (!QccWAVZerotreeNullSymbol(zerotree->zerotree[subband][row][col])) { if (QccSQInverseScalarQuantization(channels [subband].channel_symbols [channel_index++], (subband) ? highpass_quantizer : baseband_quantizer, &(subband_images [subband].image[row][col]))) { QccErrorAddMessage("(QccWAVsfqDecodeReconstructSubband): Error calling QccSQInverseScalarQuantization()"); goto QccError; } } else subband_images[subband].image[row][col] = 0.0; return_value = 0; goto QccReturn; QccError: return_value = 1; QccReturn: return(return_value);}int QccWAVsfqDecode(QccBitBuffer *input_buffer, QccIMGImageComponent *output_image, QccWAVZerotree *zerotree, const QccSQScalarQuantizer *baseband_quantizer, const QccSQScalarQuantizer *highpass_quantizer, int *high_tree_thresholds, int *low_tree_thresholds, QccChannel *channels, const QccWAVWavelet *wavelet, const QccWAVPerceptualWeights *perceptual_weights){ int return_value; int num_subbands; int subband; QccIMGImageComponent *subband_images = NULL; QccWAVSubbandPyramid subband_pyramid; int *zerotree_symbols = NULL; QccENTArithmeticModel *model = NULL; int num_contexts; int *num_symbols = NULL; int zerotree_index; if ((output_image == NULL) || (zerotree == NULL) || (baseband_quantizer == NULL) || (highpass_quantizer == NULL) || (channels == NULL) || (wavelet == NULL)) return(0); num_subbands = zerotree->num_subbands; if ((zerotree_symbols = (int *)malloc(sizeof(int) * zerotree->image_num_rows * zerotree->image_num_cols)) == NULL) { QccErrorAddMessage("(QccWAVsfqDecode): Error allocating memory"); goto QccError; } if (QccWAVsfqDisassembleBitstreamZerotree(num_subbands, high_tree_thresholds, low_tree_thresholds, zerotree_symbols, input_buffer)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVsfqDisassembleBitstreamZerotree()"); goto QccError; } if ((subband_images = (QccIMGImageComponent *)malloc(sizeof(QccIMGImageComponent) * num_subbands)) == NULL) { QccErrorAddMessage("(QccWAVsfqDecode): Error allocating memory"); goto QccError; } for (subband = 0; subband < num_subbands; subband++) { QccIMGImageComponentInitialize(&subband_images[subband]); subband_images[subband].num_rows = zerotree->num_rows[subband]; subband_images[subband].num_cols = zerotree->num_cols[subband]; if (QccIMGImageComponentAlloc(&(subband_images[subband]))) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccIMGImageComponentAlloc()"); goto QccError; } } num_contexts = zerotree->num_subbands; if ((num_symbols = (int *)malloc(sizeof(int) * num_contexts)) == NULL) { QccErrorAddMessage("(QccWAVsfqDecode): Error allocating memory"); goto QccError; } for (subband = 0; subband < zerotree->num_subbands; subband++) num_symbols[subband] = channels[subband].alphabet_size; if ((model = QccENTArithmeticDecodeStart(input_buffer, num_symbols, num_contexts, NULL, QCCENT_ANYNUMBITS)) == NULL) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccENTArithmeticDecodeStart()"); goto QccError; } for (subband = 0, zerotree_index = 0; subband < num_subbands; subband++) { if (QccWAVsfqDecodeReconstructZerotree(zerotree, zerotree_symbols, &zerotree_index, high_tree_thresholds, low_tree_thresholds, subband, subband_images)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVsfqDecodeReconstructZerotree()"); goto QccError; } if (QccWAVsfqDisassembleBitstreamChannel(model, zerotree, channels, subband, input_buffer)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVsfqDisassembleBitstreamChannel()"); goto QccError; } if (QccWAVsfqDecodeReconstructSubband(zerotree, channels, subband, highpass_quantizer, baseband_quantizer, subband_images)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVsfqDecodeReconstructSubband()"); goto QccError; } } QccWAVSubbandPyramidInitialize(&subband_pyramid); subband_pyramid.num_rows = zerotree->image_num_rows; subband_pyramid.num_cols = zerotree->image_num_cols; subband_pyramid.num_levels = zerotree->num_levels; if (QccWAVSubbandPyramidAlloc(&subband_pyramid)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVSubbandPyramidAlloc()"); goto QccError; } if (QccWAVSubbandPyramidAssembleFromImageComponent(subband_images, &subband_pyramid)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVSubbandPyramidAssembleFromImageComponent()"); goto QccError; } if (perceptual_weights != NULL) if (QccWAVPerceptualWeightsRemove(&subband_pyramid, perceptual_weights)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVPerceptualWeightsRemove()"); QccErrorExit(); } if (zerotree->num_levels) if (QccWAVSubbandPyramidInverseDWT(&subband_pyramid, wavelet)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVWaveletSynthesisSubbandPyramid()"); goto QccError; } if (QccWAVSubbandPyramidAddMean(&subband_pyramid, zerotree->image_mean)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccWAVSubbandPyramidAddMean()"); goto QccError; } if (QccMatrixCopy(output_image->image, subband_pyramid.matrix, subband_pyramid.num_rows, subband_pyramid.num_cols)) { QccErrorAddMessage("(QccWAVsfqDecode): Error calling QccMatrixCopy()"); goto QccError; } QccIMGImageComponentSetMin(output_image); QccIMGImageComponentSetMax(output_image); return_value = 0; goto QccReturn; QccError: return_value = 1; QccReturn: if (zerotree_symbols != NULL) QccFree(zerotree_symbols); if (subband_images != NULL) { for (subband = 0; subband < num_subbands; subband++) QccIMGImageComponentFree(&(subband_images[subband])); QccFree(subband_images); } QccWAVSubbandPyramidFree(&subband_pyramid); QccENTArithmeticFreeModel(model); if (num_symbols != NULL) QccFree(num_symbols); return(return_value);}int QccWAVsfqAssembleBitstreamHeader(const QccWAVZerotree *zerotree, const QccSQScalarQuantizer *mean_quantizer, const QccSQScalarQuantizer *baseband_quantizer, const QccSQScalarQuantizer *highpass_quantizer, const int *high_tree_thresholds, const int *low_tree_thresholds, QccBitBuffer *output_buffer, int *num_output_bits){ int return_value; int mean_partition; int no_tree_prediction; int subband, row, col; int num_nonnull_symbols; if ((zerotree == NULL) || (output_buffer == NULL)) return(0); no_tree_prediction = ((high_tree_thresholds == NULL) && (low_tree_thresholds == NULL)); if (QccBitBufferPutChar(output_buffer, (char)no_tree_prediction)) { QccErrorAddMessage("(QccWAVsfqAssembleBitstreamHeader): Error calling QccBitBufferPutChar()"); goto QccError; } if (QccBitBufferPutChar(output_buffer, (char)zerotree->num_levels)) { QccErrorAddMessage("(QccWAVsfqAsse
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -