📄 spiht3d.c
字号:
static int QccSPIHT3DGetOffspring(QccWAVSubbandPyramid3D *subband_pyramid, int frame, int row, int col, int *offspring_frame, int *offspring_row, int *offspring_col, int block_size, int zerotree_type){ int baseband; int spatial_baseband; int baseband_num_frames; int baseband_num_rows; int baseband_num_cols; int num_offspring; if (!subband_pyramid->temporal_num_levels && !subband_pyramid->spatial_num_levels) return(0); QccWAVSubbandPyramid3DSubbandSize(subband_pyramid, 0, &baseband_num_frames, &baseband_num_rows, &baseband_num_cols); spatial_baseband = ((row < baseband_num_rows) && (col < baseband_num_cols)); baseband = ((frame < baseband_num_frames) && spatial_baseband); if ((zerotree_type == QCCSPIHT3D_ZEROTREE_DYADIC) || (zerotree_type == QCCSPIHT3D_ZEROTREE_PACKET)) { if ((2 * frame >= subband_pyramid->num_frames) || (2 * row >= subband_pyramid->num_rows) || (2 * col >= subband_pyramid->num_cols)) return(0); if (baseband) { num_offspring = 7; offspring_frame[0] = frame; offspring_row[0] = row + baseband_num_rows; offspring_col[0] = col; offspring_frame[1] = frame; offspring_row[1] = row; offspring_col[1] = col + baseband_num_cols; offspring_frame[2] = frame + baseband_num_frames; offspring_row[2] = row; offspring_col[2] = col; offspring_frame[3] = frame; offspring_row[3] = row + baseband_num_rows; offspring_col[3] = col + baseband_num_cols; offspring_frame[4] = frame + baseband_num_frames; offspring_row[4] = row + baseband_num_rows; offspring_col[4] = col; offspring_frame[5] = frame + baseband_num_frames; offspring_row[5] = row; offspring_col[5] = col + baseband_num_cols; offspring_frame[6] = frame + baseband_num_frames; offspring_row[6] = row + baseband_num_rows; offspring_col[6] = col + baseband_num_cols; } else { num_offspring = 8; offspring_frame[0] = frame * 2; offspring_row[0] = row * 2; offspring_col[0] = col * 2; offspring_frame[1] = frame * 2; offspring_row[1] = row * 2 + block_size; offspring_col[1] = col * 2; offspring_frame[2] = frame * 2; offspring_row[2] = row * 2; offspring_col[2] = col * 2 + block_size; offspring_frame[3] = frame * 2 + block_size; offspring_row[3] = row * 2; offspring_col[3] = col * 2; offspring_frame[4] = frame * 2; offspring_row[4] = row * 2 + block_size; offspring_col[4] = col * 2 + block_size; offspring_frame[5] = frame * 2 + block_size; offspring_row[5] = row * 2 + block_size; offspring_col[5] = col * 2; offspring_frame[6] = frame * 2 + block_size; offspring_row[6] = row * 2; offspring_col[6] = col * 2 + block_size; offspring_frame[7] = frame * 2 + block_size; offspring_row[7] = row * 2 + block_size; offspring_col[7] = col * 2 + block_size; } } else { if (baseband) if (frame + baseband_num_frames >= subband_pyramid->num_frames) { if ((row + baseband_num_rows >= subband_pyramid->num_rows) || (col + baseband_num_cols >= subband_pyramid->num_cols)) return(0); num_offspring = 3; offspring_frame[0] = frame; offspring_row[0] = row + baseband_num_rows; offspring_col[0] = col; offspring_frame[1] = frame; offspring_row[1] = row; offspring_col[1] = col + baseband_num_cols; offspring_frame[2] = frame; offspring_row[2] = row + baseband_num_rows; offspring_col[2] = col + baseband_num_cols; } else if ((row + baseband_num_rows >= subband_pyramid->num_rows) || (col + baseband_num_cols >= subband_pyramid->num_cols)) { num_offspring = 1; offspring_frame[0] = frame + baseband_num_frames; offspring_row[0] = row; offspring_col[0] = col; } else { num_offspring = 4; offspring_frame[0] = frame; offspring_row[0] = row + baseband_num_rows; offspring_col[0] = col; offspring_frame[1] = frame; offspring_row[1] = row; offspring_col[1] = col + baseband_num_cols; offspring_frame[2] = frame; offspring_row[2] = row + baseband_num_rows; offspring_col[2] = col + baseband_num_cols; offspring_frame[3] = frame + baseband_num_frames; offspring_row[3] = row; offspring_col[3] = col; } else if (spatial_baseband) if (2 * frame >= subband_pyramid->num_frames) { if ((row + baseband_num_rows >= subband_pyramid->num_rows) || (col + baseband_num_cols >= subband_pyramid->num_cols)) return(0); num_offspring = 3; offspring_frame[0] = frame; offspring_row[0] = row + baseband_num_rows; offspring_col[0] = col; offspring_frame[1] = frame; offspring_row[1] = row; offspring_col[1] = col + baseband_num_cols; offspring_frame[2] = frame; offspring_row[2] = row + baseband_num_rows; offspring_col[2] = col + baseband_num_cols; } else if ((row + baseband_num_rows >= subband_pyramid->num_rows) || (col + baseband_num_cols >= subband_pyramid->num_cols)) { num_offspring = 2; offspring_frame[0] = frame * 2; offspring_row[0] = row; offspring_col[0] = col; offspring_frame[1] = frame * 2 + block_size; offspring_row[1] = row; offspring_col[1] = col; } else { num_offspring = 5; offspring_frame[0] = frame; offspring_row[0] = row + baseband_num_rows; offspring_col[0] = col; offspring_frame[1] = frame; offspring_row[1] = row; offspring_col[1] = col + baseband_num_cols; offspring_frame[2] = frame; offspring_row[2] = row + baseband_num_rows; offspring_col[2] = col + baseband_num_cols; offspring_frame[3] = frame * 2; offspring_row[3] = row; offspring_col[3] = col; offspring_frame[4] = frame * 2 + block_size; offspring_row[4] = row; offspring_col[4] = col; } else { if ((2 * row >= subband_pyramid->num_rows) || (2 * col >= subband_pyramid->num_cols)) return(0); num_offspring = 4; offspring_frame[0] = frame; offspring_row[0] = row * 2; offspring_col[0] = col * 2; offspring_frame[1] = frame; offspring_row[1] = row * 2 + block_size; offspring_col[1] = col * 2; offspring_frame[2] = frame; offspring_row[2] = row * 2; offspring_col[2] = col * 2 + block_size; offspring_frame[3] = frame; offspring_row[3] = row * 2 + block_size; offspring_col[3] = col * 2 + block_size; } } return(num_offspring);}static int QccSPIHT3DDescendantsOutsideMask(QccWAVSubbandPyramid3D *subband_pyramid, QccWAVSubbandPyramid3D *mask, int frame, int row, int col, int block_size, int zerotree_type);static int QccSPIHT3DOutsideMask(QccWAVSubbandPyramid3D *subband_pyramid, QccWAVSubbandPyramid3D *mask, int frame, int row, int col, int block_size, int zerotree_type){ int block_frame, block_row, block_col; if (mask == NULL) return(0); for (block_frame = 0; block_frame < block_size; block_frame++) for (block_row = 0; block_row < block_size; block_row++) for (block_col = 0; block_col < block_size; block_col++) if (!QccAlphaTransparent(mask->volume [frame + block_frame] [row + block_row][col + block_col])) return(0); if (!QccSPIHT3DDescendantsOutsideMask(subband_pyramid, mask, frame, row, col, block_size, zerotree_type)) return(0); return(1);}static int QccSPIHT3DDescendantsOutsideMask(QccWAVSubbandPyramid3D *subband_pyramid, QccWAVSubbandPyramid3D *mask, int frame, int row, int col, int block_size, int zerotree_type){ int offspring_frame[8]; int offspring_row[8]; int offspring_col[8]; int num_offspring; int offspring; if (mask == NULL) return(0); num_offspring = QccSPIHT3DGetOffspring(subband_pyramid, frame, row, col, offspring_frame, offspring_row, offspring_col, block_size, zerotree_type); if (!num_offspring) return(1); for (offspring = 0; offspring < num_offspring; offspring++) if (!QccSPIHT3DOutsideMask(subband_pyramid, mask, offspring_frame[offspring], offspring_row[offspring], offspring_col[offspring], block_size, zerotree_type)) return(0); return(1);}static int QccSPIHT3DAlgorithmInitialize(QccWAVSubbandPyramid3D *subband_pyramid, QccWAVSubbandPyramid3D *mask, QccList *LIP, QccList *LIS, int block_size, int zerotree_type){ int subband_num_frames, subband_num_rows, subband_num_cols; int frame, row, col; QccSPIHT3DCoefficientBlock coefficient_block; QccListNode *new_node; if (QccWAVSubbandPyramid3DSubbandSize(subband_pyramid, 0, &subband_num_frames, &subband_num_rows, &subband_num_cols)) { QccErrorAddMessage("(QccSPIHT3DAlgorithmInitialize): Error calling QccWAVSubbandPyramid3DSubbandSize()"); return(1); } for (frame = 0; frame < subband_num_frames; frame += block_size) for (row = 0; row < subband_num_rows; row += block_size) for (col = 0; col < subband_num_cols; col += block_size) if (!QccSPIHT3DOutsideMask(subband_pyramid, mask, frame, row, col, block_size, zerotree_type)) { coefficient_block.frame = frame; coefficient_block.row = row; coefficient_block.col = col; coefficient_block.type = QCCSPIHT3D_TYPE_A; coefficient_block.state = 0; if ((new_node = QccListCreateNode(sizeof(QccSPIHT3DCoefficientBlock), (void *)(&coefficient_block))) == NULL) { QccErrorAddMessage("(QccSPIHT3DAlgorithmInitialize): Error calling QccListCreateNode()"); return(1); } if (QccListAppendNode(LIP, new_node)) { QccErrorAddMessage("(QccSPIHT3DAlgorithmInitialize): Error calling QccListAppendNode()"); return(1); } if ((new_node = QccListCreateNode(sizeof(QccSPIHT3DCoefficientBlock), (void *)(&coefficient_block))) == NULL) { QccErrorAddMessage("(QccSPIHT3DAlgorithmInitialize): Error calling QccListCreateNode()"); return(1); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -