?? sfq.c
字號:
{ QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccVectorSortComponents()"); goto QccError; } printf("Subband %d, num nonull %d\n", child_subband, num_variances); { int i; printf("subband %d\n", child_subband); for (i = 0; i < num_variances; i++) printf("%d %f %f\n", zerotree_symbols[addresses[i]], sorted_variances[i], delta_J_vector[addresses[i]]); } if (QccWAVsfqZerotreeFindThresholdHigh(sorted_variances, zerotree_symbols, delta_J_vector, addresses, num_variances, lambda, &first_zero_position)) { QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccWAVsfqZerotreeFindThresholdHigh()"); goto QccError; } high_tree_thresholds[child_subband] = addresses[first_zero_position]; /* printf("Subband %d\n", child_subband); { int i; printf("subband %d\n", child_subband); for (i = 0; i < num_variances; i++) printf("%f %d\n", sorted_variances[i], zerotree_symbols[addresses[i]]); } */ if (QccWAVsfqZerotreeFindThresholdLow(sorted_variances, zerotree_symbols, delta_J_vector, addresses, num_variances, lambda, first_zero_position, &last_one_position)) { QccErrorAddMessage("(QccWAVsfqZerotreePrediction): Error calling QccWAVsfqZerotreeFindThresholdLow()"); goto QccError; } low_tree_thresholds[child_subband] = addresses[last_one_position]; /* printf("Subband %d\n", child_subband); { int i; printf("subband %d\n", child_subband); for (i = 0; i < num_variances; i++) printf("%f %d\n", sorted_variances[i], zerotree_symbols[addresses[i]]); } */ for (variance_index = 0, row = 0; row < zerotree->num_rows[child_subband]; row++) for (col = 0; col < zerotree->num_cols[child_subband]; col++) if (!QccWAVZerotreeNullSymbol(zerotree->zerotree [child_subband][row][col])) { zerotree->zerotree[child_subband][row][col] = zerotree_symbols[variance_index]; if (zerotree->zerotree[child_subband][row][col] == QCCWAVZEROTREE_SYMBOLZTROOT) QccWAVZerotreeCarveOutZerotree(zerotree, child_subband, row, col); else QccWAVZerotreeUndoZerotree(zerotree, child_subband, row, col); high_variance = (high_tree_thresholds[child_subband] >= 0) ? parent_variances[high_tree_thresholds[child_subband]] : -MAXDOUBLE; low_variance = (low_tree_thresholds[child_subband] >= 0) ? parent_variances[low_tree_thresholds[child_subband]] : MAXDOUBLE; /*****/ if ((parent_variances[variance_index] > high_variance) || (parent_variances[variance_index] < low_variance)) zerotree->zerotree[child_subband][row][col] = QCCWAVZEROTREE_SYMBOLTEMP; variance_index++; } /****/ printf("Subband: %d %f %f %d %d\n", child_subband, parent_variances[high_tree_thresholds[child_subband]], parent_variances[low_tree_thresholds[child_subband]], high_tree_thresholds[child_subband], low_tree_thresholds[child_subband]); /* if (parent_variances[high_tree_thresholds[child_subband]] <= parent_variances[low_tree_thresholds[child_subband]]) printf("*** ERROR ***\n"); */ } return_value = 0; goto QccReturn; QccError: return_value = 1; QccReturn: QccIMGImageComponentFree(&filtered_variances); QccVectorFree(parent_variances); QccVectorFree(sorted_variances); QccVectorFree(delta_J_vector); if (zerotree_symbols != NULL) QccFree(zerotree_symbols); return(return_value);}static int QccWAVsfqPruneZerotree(QccVector *squared_subband_images, QccIMGImageComponent *quantized_variances, QccVector *distortion, QccChannel *channels, QccWAVZerotree *zerotree, QccSQScalarQuantizer *quantizer, double lambda, int *high_tree_thresholds, int *low_tree_thresholds){ int return_value; int num_subbands; int subband; QccVector *J = NULL; QccVector *residue_tree_J = NULL; QccVector *delta_J = NULL; QccVector codeword_lengths = NULL; int zerotree_changed; int row, col; int cost_index; num_subbands = zerotree->num_subbands; if ((codeword_lengths = QccVectorAlloc(quantizer->num_levels)) == NULL) { QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccVectorAlloc()"); goto QccError; } if ((J = (QccVector *)malloc(sizeof(QccVector)*num_subbands)) == NULL) { QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error allocating memory"); goto QccError; } if ((residue_tree_J = (QccVector *)malloc(sizeof(QccVector)*num_subbands)) == NULL) { QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error allocating memory"); goto QccError; } if ((delta_J = (QccVector *)malloc(sizeof(QccVector)*num_subbands)) == NULL) { QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error allocating memory"); goto QccError; } for (subband = QCCWAVSFQ_ZEROTREE_STARTSUBBAND; subband < num_subbands; subband++) { if ((J[subband] = QccVectorAlloc(channels[subband].channel_length)) == NULL) { QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccVectorAlloc()"); goto QccError; } if ((residue_tree_J[subband] = QccVectorAlloc(channels[subband].channel_length)) == NULL) { QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccVectorAlloc()"); goto QccError; } if ((delta_J[subband] = QccVectorAlloc(channels[subband].channel_length)) == NULL) { QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccVectorAlloc()"); goto QccError; } } do { /* printf("Pruning iteration %d\n", iteration); iteration++; */ zerotree_changed = 0; QccWAVsfqCalcCodewordLengths(codeword_lengths, quantizer->num_levels, channels, zerotree); for (subband = num_subbands - 1; subband >= QCCWAVSFQ_ZEROTREE_STARTSUBBAND; subband--) { for (row = 0, cost_index = 0; row < zerotree->num_rows[subband]; row++) for (col = 0; col < zerotree->num_cols[subband]; col++, cost_index++) { if (!QccWAVZerotreeNullSymbol(zerotree->zerotree [subband][row][col])) { J[subband][cost_index] = (subband) ? distortion[subband][cost_index] + lambda * codeword_lengths[channels[subband].channel_symbols [cost_index]] : 0.0; if (zerotree->zerotree[subband][row][col] == QCCWAVZEROTREE_SYMBOLSIGNIFICANT) residue_tree_J[subband][cost_index] = QccWAVsfqSelectMinimumCost(zerotree, subband, row, col, cost_index, J, residue_tree_J, delta_J, squared_subband_images, &zerotree_changed); } else J[subband][cost_index] = 0.0; } } } while (zerotree_changed); if ((high_tree_thresholds != NULL) && (low_tree_thresholds != NULL)) for (subband = 0; subband < zerotree->num_subbands - 6; subband++) if (QccWAVsfqZerotreePrediction(&quantized_variances[subband], zerotree, delta_J, subband, lambda, high_tree_thresholds, low_tree_thresholds)) { QccErrorAddMessage("(QccWAVsfqPruneZerotree): Error calling QccWAVsfqZerotreePrediction()"); goto QccError; } return_value = 0; goto QccReturn; QccError: return_value = 1; QccReturn: if (codeword_lengths != NULL) QccVectorFree(codeword_lengths); if (J != NULL) { for (subband = QCCWAVSFQ_ZEROTREE_STARTSUBBAND; subband < num_subbands; subband++) QccVectorFree(J[subband]); QccFree(J); } if (residue_tree_J != NULL) { for (subband = QCCWAVSFQ_ZEROTREE_STARTSUBBAND; subband < num_subbands; subband++) QccVectorFree(residue_tree_J[subband]); QccFree(residue_tree_J); } if (delta_J != NULL) { for (subband = QCCWAVSFQ_ZEROTREE_STARTSUBBAND; subband < num_subbands; subband++) QccVectorFree(delta_J[subband]); QccFree(delta_J); } return(return_value);}static int QccWAVsfqHighpassEncodeProcess(QccIMGImageComponent *subband_images, QccIMGImageComponent *quantized_subband_images, QccVector *squared_subband_images, QccWAVZerotree *zerotree, QccSQScalarQuantizer *highpass_quantizer, QccChannel *channels, double lambda, int *high_tree_thresholds, int *low_tree_thresholds, double *distortion, double *rate, QccIMGImageComponent *reconstructed_baseband){ int return_value; int num_subbands; int subband; QccVector *distortion_vector = NULL; int row, col; int image_index, total_num_symbols; int num_nonnull_symbols = 0; int num_predicted_symbols = 0; num_subbands = zerotree->num_subbands; if ((distortion_vector = (QccVector *)malloc(sizeof(QccVector)*num_subbands)) == NULL) { QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error allocating memory"); goto QccError; } for (subband = 0; subband < num_subbands; subband++) if ((distortion_vector[subband] = QccVectorAlloc(channels[subband].channel_length)) == NULL) { QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error calling QccVectorAlloc()"); goto QccError; } for (subband = 1; subband < num_subbands; subband++) { if (QccIMGImageComponentScalarQuantize(&(subband_images[subband]), highpass_quantizer, distortion_vector[subband], &(channels[subband]))) { QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error calling QccIMGImageComponentScalarQuantize()"); goto QccError; } if (QccIMGImageComponentInverseScalarQuantize(&(channels[subband]), highpass_quantizer, &(quantized_subband_images[subband]))) { QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error calling QccIMGImageComponentInverseScalarQuantize()"); goto QccError; } if (QccChannelNormalize(&(channels[subband]))) { QccErrorAddMessage("(QccWAVsfqHighpassEncodeProcess): Error calling QccChannelNormalize()"); goto QccError; } } for (row = 0; row < reconstructed_baseband->num_rows; row++) for (col = 0; col < reconstructed_baseband->num_cols; col++) quantized_subband_images[0].image[row][col] = reconstructed_baseband->image[row][col]; for (subband = 0; subband < num_subbands; subband++) for (row = 0, image_index = 0; row < subband_images[subband].num_rows; row++) for (col = 0; col < subband_images[subband].num_cols; col++, image_index++) { squared_subband_images[subband][image_index] = subband_images[subband].image[row][col] * subband_images[subband].image[row][col];
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -