📄 subband_pyramid3d.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 QccWAVSubbandPyramid3DInitialize(QccWAVSubbandPyramid3D *subband_pyramid){ if (subband_pyramid == NULL) return(0); QccStringMakeNull(subband_pyramid->filename); QccStringCopy(subband_pyramid->magic_num, QCCWAVSUBBANDPYRAMID3D_MAGICNUM); QccGetQccPackVersion(&subband_pyramid->major_version, &subband_pyramid->minor_version, NULL); subband_pyramid->transform_type = QCCWAVSUBBANDPYRAMID3D_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 QccWAVSubbandPyramid3DAlloc(QccWAVSubbandPyramid3D *subband_pyramid){ int return_value; if (subband_pyramid == NULL) return(0); if (subband_pyramid->volume != NULL) return(0); if ((subband_pyramid->volume = QccVolumeAlloc(subband_pyramid->num_frames, subband_pyramid->num_rows, subband_pyramid->num_cols)) == NULL) { QccErrorAddMessage("(QccWAVSubbandPyramid3DAlloc): Error calling QccVolumeAlloc()"); goto Error; } return_value = 0; goto Return; Error: QccWAVSubbandPyramid3DFree(subband_pyramid); return_value = 1; Return: return(return_value);}void QccWAVSubbandPyramid3DFree(QccWAVSubbandPyramid3D *subband_pyramid){ if (subband_pyramid == NULL) return; QccVolumeFree(subband_pyramid->volume, subband_pyramid->num_frames, subband_pyramid->num_rows); subband_pyramid->volume = NULL;}int QccWAVSubbandPyramid3DNumLevelsToNumSubbandsDyadic(int num_levels){ return(num_levels * 7 + 1);}int QccWAVSubbandPyramid3DNumLevelsToNumSubbandsPacket(int temporal_num_levels, int spatial_num_levels){ return(QccWAVSubbandPyramidNumLevelsToNumSubbands(spatial_num_levels) * (temporal_num_levels + 1));}int QccWAVSubbandPyramid3DNumSubbandsToNumLevelsDyadic(int num_subbands){ if (num_subbands <= 0) return(0); if ((num_subbands - 1) % 7) return(0); else return((num_subbands - 1) / 7);}int QccWAVSubbandPyramid3DCalcLevelFromSubbandDyadic(int subband, int num_levels){ if (!num_levels) return(0); if (!subband) return(num_levels); return(num_levels - (subband - 1) / 7);}int QccWAVSubbandPyramid3DCalcLevelFromSubbandPacket(int subband, int temporal_num_levels, int spatial_num_levels, int *temporal_level, int *spatial_level){ int spatial_num_subbands; spatial_num_subbands = QccWAVSubbandPyramidNumLevelsToNumSubbands(spatial_num_levels); if (temporal_level != NULL) *temporal_level = (subband < spatial_num_subbands) ? temporal_num_levels : temporal_num_levels - (subband / spatial_num_subbands) + 1; if (spatial_level != NULL) *spatial_level = QccWAVSubbandPyramidCalcLevelFromSubband(subband % spatial_num_subbands, spatial_num_levels); return(0);}int QccWAVSubbandPyramid3DSubbandSize(const QccWAVSubbandPyramid3D *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; QccWAVSubbandPyramid 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; QccWAVSubbandPyramidInitialize(&temp); if (subband < 0) return(0); if (subband_pyramid->transform_type == QCCWAVSUBBANDPYRAMID3D_DYADIC) { level = QccWAVSubbandPyramid3DCalcLevelFromSubbandDyadic(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 == QCCWAVSUBBANDPYRAMID3D_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 = QccWAVSubbandPyramidNumLevelsToNumSubbands(spatial_num_levels); QccWAVSubbandPyramid3DCalcLevelFromSubbandPacket(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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -