📄 subband_pyramid3d_int.c
字号:
/* * * QccPack: Quantization, compression, and coding libraries * Copyright (C) 1997-2009 James E. Fowler * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, * MA 02139, USA. * */#include "libQccPack.h"int QccWAVSubbandPyramid3DIntInitialize(QccWAVSubbandPyramid3DInt *subband_pyramid){ if (subband_pyramid == NULL) return(0); QccStringMakeNull(subband_pyramid->filename); QccStringCopy(subband_pyramid->magic_num, QCCWAVSUBBANDPYRAMID3DINT_MAGICNUM); QccGetQccPackVersion(&subband_pyramid->major_version, &subband_pyramid->minor_version, NULL); subband_pyramid->transform_type = QCCWAVSUBBANDPYRAMID3DINT_PACKET; subband_pyramid->temporal_num_levels = 0; subband_pyramid->spatial_num_levels = 0; subband_pyramid->num_frames = 0; subband_pyramid->num_rows = 0; subband_pyramid->num_cols = 0; subband_pyramid->origin_frame = 0; subband_pyramid->origin_row = 0; subband_pyramid->origin_col = 0; subband_pyramid->subsample_pattern_frame = 0; subband_pyramid->subsample_pattern_row = 0; subband_pyramid->subsample_pattern_col = 0; subband_pyramid->volume = NULL; return(0);}int QccWAVSubbandPyramid3DIntAlloc(QccWAVSubbandPyramid3DInt *subband_pyramid){ int return_value; if (subband_pyramid == NULL) return(0); if (subband_pyramid->volume != NULL) return(0); if ((subband_pyramid->volume = QccVolumeIntAlloc(subband_pyramid->num_frames, subband_pyramid->num_rows, subband_pyramid->num_cols)) == NULL) { QccErrorAddMessage("(QccWAVSubbandPyramid3DIntAlloc): Error calling QccVolumeIntAlloc()"); goto Error; } return_value = 0; goto Return; Error: QccWAVSubbandPyramid3DIntFree(subband_pyramid); return_value = 1; Return: return(return_value);}void QccWAVSubbandPyramid3DIntFree(QccWAVSubbandPyramid3DInt *subband_pyramid){ if (subband_pyramid == NULL) return; QccVolumeIntFree(subband_pyramid->volume, subband_pyramid->num_frames, subband_pyramid->num_rows); subband_pyramid->volume = NULL;}int QccWAVSubbandPyramid3DIntNumLevelsToNumSubbandsDyadic(int num_levels){ return(QccWAVSubbandPyramid3DNumLevelsToNumSubbandsDyadic(num_levels));}int QccWAVSubbandPyramid3DIntNumLevelsToNumSubbandsPacket(int temporal_num_levels, int spatial_num_levels){ return(QccWAVSubbandPyramid3DNumLevelsToNumSubbandsPacket(temporal_num_levels, spatial_num_levels));}int QccWAVSubbandPyramid3DIntNumSubbandsToNumLevelsDyadic(int num_subbands){ return(QccWAVSubbandPyramid3DNumSubbandsToNumLevelsDyadic(num_subbands));}int QccWAVSubbandPyramid3DIntCalcLevelFromSubbandDyadic(int subband, int num_levels){ return(QccWAVSubbandPyramid3DCalcLevelFromSubbandDyadic(subband, num_levels));}int QccWAVSubbandPyramid3DIntCalcLevelFromSubbandPacket(int subband, int temporal_num_levels, int spatial_num_levels, int *temporal_level, int *spatial_level){ return(QccWAVSubbandPyramid3DCalcLevelFromSubbandPacket(subband, temporal_num_levels, spatial_num_levels, temporal_level, spatial_level));}int QccWAVSubbandPyramid3DIntSubbandSize(const QccWAVSubbandPyramid3DInt *subband_pyramid, int subband, int *subband_num_frames, int *subband_num_rows, int *subband_num_cols){ int num_frames = 0; int num_rows = 0; int num_cols = 0; int level; QccWAVSubbandPyramidInt temp; int spatial_num_levels = subband_pyramid->spatial_num_levels; int temporal_num_levels = subband_pyramid->temporal_num_levels; int origin_frame = subband_pyramid->origin_frame; int origin_row = subband_pyramid->origin_row; int origin_col = subband_pyramid->origin_col; int subsample_pattern_frame = subband_pyramid->subsample_pattern_frame; int subsample_pattern_row = subband_pyramid->subsample_pattern_row; int subsample_pattern_col = subband_pyramid->subsample_pattern_col; int spatial_num_subbands; QccWAVSubbandPyramidIntInitialize(&temp); if (subband < 0) return(0); if (subband_pyramid->transform_type == QCCWAVSUBBANDPYRAMID3DINT_DYADIC) { level = QccWAVSubbandPyramid3DIntCalcLevelFromSubbandDyadic(subband, spatial_num_levels); if (!subband) { num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, 0, origin_frame, subsample_pattern_frame); num_rows = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_rows, level, 0, origin_row, subsample_pattern_row); num_cols = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_cols, level, 0, origin_col, subsample_pattern_col); } else switch ((subband - 1) % 7) { case 0: num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, 0, origin_frame, subsample_pattern_frame); num_rows = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_rows, level, 1, origin_row, subsample_pattern_row); num_cols = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_cols, level, 0, origin_col, subsample_pattern_col); break; case 1: num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, 0, origin_frame, subsample_pattern_frame); num_rows = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_rows, level, 0, origin_row, subsample_pattern_row); num_cols = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_cols, level, 1, origin_col, subsample_pattern_col); break; case 2: num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, 1, origin_frame, subsample_pattern_frame); num_rows = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_rows, level, 0, origin_row, subsample_pattern_row); num_cols = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_cols, level, 0, origin_col, subsample_pattern_col); break; case 3: num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, 0, origin_frame, subsample_pattern_frame); num_rows = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_rows, level, 1, origin_row, subsample_pattern_row); num_cols = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_cols, level, 1, origin_col, subsample_pattern_col); break; case 4: num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, 1, origin_frame, subsample_pattern_frame); num_rows = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_rows, level, 1, origin_row, subsample_pattern_row); num_cols = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_cols, level, 0, origin_col, subsample_pattern_col); break; case 5: num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, 1, origin_frame, subsample_pattern_frame); num_rows = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_rows, level, 0, origin_row, subsample_pattern_row); num_cols = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_cols, level, 1, origin_col, subsample_pattern_col); break; case 6: num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, 1, origin_frame, subsample_pattern_frame); num_rows = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_rows, level, 1, origin_row, subsample_pattern_row); num_cols = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_cols, level, 1, origin_col, subsample_pattern_col); break; } } else if (subband_pyramid->transform_type == QCCWAVSUBBANDPYRAMID3DINT_PACKET) { temp.num_levels = spatial_num_levels; temp.num_rows = subband_pyramid->num_rows; temp.num_cols = subband_pyramid->num_cols; temp.origin_row = origin_row; temp.origin_col = origin_col; temp.subsample_pattern_row = subsample_pattern_row; temp.subsample_pattern_col = subsample_pattern_col; spatial_num_subbands = QccWAVSubbandPyramidIntNumLevelsToNumSubbands(spatial_num_levels); QccWAVSubbandPyramid3DIntCalcLevelFromSubbandPacket(subband, temporal_num_levels, spatial_num_levels, &level, NULL); num_frames = QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames, level, (subband >= spatial_num_subbands), origin_frame, subsample_pattern_frame); if (QccWAVSubbandPyramidIntSubbandSize(&temp, subband % spatial_num_subbands, &num_rows, &num_cols)) { QccErrorAddMessage("(QccWAVSubbandPyramid3DIntSubbandSize): Error calling QccWAVSubbandPyramidIntSubbandSize()"); return(1); } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -