?? rdwtblock.c
字號:
int return_value; double search_row, search_col; double current_window_size; double final_search_step; double current_search_step; int mv_row, mv_col; QccVIDRDWTBlockBlockInitialize(¤t_block); QccVIDRDWTBlockBlockInitialize(&reference_block); current_block.blocksize = blocksize; if (QccVIDRDWTBlockBlockAlloc(¤t_block)) { QccErrorAddMessage("(QccVIDRDWTBlockMotionEstimation): Error calling QccVIDRDWTBlockBlockAlloc()"); goto Error; } reference_block.blocksize = blocksize; if (QccVIDRDWTBlockBlockAlloc(&reference_block)) { QccErrorAddMessage("(QccVIDRDWTBlockMotionEstimation): Error calling QccVIDRDWTBlockBlockAlloc()"); goto Error; } num_rows = current_subband_pyramid->num_rows; num_cols = current_subband_pyramid->num_cols; num_levels = current_subband_pyramid->num_levels; num_phases = (1 << num_levels); switch (subpixel_accuracy) { case QCCVID_ME_FULLPIXEL: final_search_step = 1.0; break; case QCCVID_ME_HALFPIXEL: final_search_step = 0.5; break; case QCCVID_ME_QUARTERPIXEL: final_search_step = 0.25; break; case QCCVID_ME_EIGHTHPIXEL: final_search_step = 0.125; break; default: QccErrorAddMessage("(QccVIDRDWTBlockMotionEstimation): Unrecognized subpixel accuracy"); goto Error; } for (row = 0; row < num_rows; row += blocksize) for (col = 0; col < num_cols; col += blocksize) { if (QccVIDRDWTBlockExtractBlock(current_subband_pyramid, ¤t_block, row, col, num_rows, num_cols, num_levels)) { QccErrorAddMessage("(QccVIDRDWTBlockMotionEstimation): Error calling QccVIDRDWTBlockExtractBlock()"); goto Error; } mv_row = row / blocksize; mv_col = col / blocksize; horizontal_motion->image[mv_row][mv_col] = 0.0; vertical_motion->image[mv_row][mv_col] = 0.0; for (current_search_step = 1.0; current_search_step >= final_search_step; current_search_step /= 2) { search_row = row + vertical_motion->image[mv_row][mv_col]; search_col = col + horizontal_motion->image[mv_row][mv_col]; current_window_size = (current_search_step == 1.0) ? (double)QCCVIDRDWTBLOCK_WINDOWSIZE : current_search_step; if (QccVIDRDWTBlockMotionEstimationSearch(reference_frame_phases, ¤t_block, &reference_block, num_rows, num_cols, num_levels, search_row, search_col, current_window_size, current_search_step, subpixel_accuracy, &u, &v)) { QccErrorAddMessage("(QccVIDRDWTBlockMotionEstimation): Error calling QccVIDRDWTBlockMotionEstimationSearch()"); goto Error; } horizontal_motion->image[mv_row][mv_col] += u; vertical_motion->image[mv_row][mv_col] += v; } } return_value = 0; goto Return; Error: return_value = 1; Return: QccVIDRDWTBlockBlockFree(¤t_block); QccVIDRDWTBlockBlockFree(&reference_block); return(return_value);}static int QccVIDRDWTBlockMotionCompensation(QccWAVSubbandPyramid ****reference_frame_phases, QccWAVSubbandPyramid *current_subband_pyramid, QccIMGImageComponent *horizontal_motion, QccIMGImageComponent *vertical_motion, int blocksize, int subpixel_accuracy){ int row, col; int num_rows, num_cols; int num_levels; int num_phases; int subsample_pattern_row, subsample_pattern_col; double reference_frame_row, reference_frame_col; int integer_row, integer_col; int subpixel_row, subpixel_col; int num_subpixels; QccVIDRDWTBlockBlock reference_block; QccWAVSubbandPyramid predicted_frame; int return_value; QccVIDRDWTBlockBlockInitialize(&reference_block); QccWAVSubbandPyramidInitialize(&predicted_frame); reference_block.blocksize = blocksize; if (QccVIDRDWTBlockBlockAlloc(&reference_block)) { QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Error calling QccVIDRDWTBlockBlockAlloc()"); goto Error; } num_rows = current_subband_pyramid->num_rows; num_cols = current_subband_pyramid->num_cols; num_levels = current_subband_pyramid->num_levels; num_phases = (1 << num_levels); switch (subpixel_accuracy) { case QCCVID_ME_FULLPIXEL: num_subpixels = 1; break; case QCCVID_ME_HALFPIXEL: num_subpixels = 2; break; case QCCVID_ME_QUARTERPIXEL: num_subpixels = 4; break; case QCCVID_ME_EIGHTHPIXEL: num_subpixels = 8; break; default: QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Unrecognized subpixel accuracy"); return(1); } predicted_frame.num_levels = num_levels; predicted_frame.num_rows = num_rows; predicted_frame.num_cols = num_cols; if (QccWAVSubbandPyramidAlloc(&predicted_frame)) { QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Error calling QccWAVSubbandPyramidAlloc()"); goto Error; } for (row = 0; row < num_rows; row += blocksize) for (col = 0; col < num_cols; col += blocksize) { reference_frame_col = horizontal_motion->image [row / blocksize] [col / blocksize] + col; reference_frame_row = vertical_motion->image [row / blocksize] [col / blocksize] + row; integer_row = (int)floor(reference_frame_row); integer_col = (int)floor(reference_frame_col); subpixel_row = (int)((reference_frame_row - integer_row) * num_subpixels); subpixel_col = (int)(fabs(reference_frame_col - integer_col) * num_subpixels); subsample_pattern_row = QccMathModulus(integer_row, num_phases); subsample_pattern_col = QccMathModulus(integer_col, num_phases); if (QccVIDRDWTBlockExtractBlock(&reference_frame_phases [subpixel_row][subpixel_col] [subsample_pattern_row] [subsample_pattern_col], &reference_block, integer_row, integer_col, num_rows, num_cols, num_levels)) { QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Error calling ExtractWaveletBlock()"); goto Error; } if (QccVIDRDWTBlockInsertBlock(&predicted_frame, &reference_block, row, col, num_rows, num_cols, num_levels)) { QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Error calling QccVIDRDWTBlockInsertBlock()"); goto Error; } } for (row = 0; row < num_rows; row++) for (col = 0; col < num_cols; col++) current_subband_pyramid->matrix[row][col] -= predicted_frame.matrix[row][col]; return_value = 0; goto Return; Error: return_value = 1; Return: QccVIDRDWTBlockBlockFree(&reference_block); QccWAVSubbandPyramidFree(&predicted_frame); return(return_value);}static int QccVIDRDWTBlockInverseMotionCompensation(QccWAVSubbandPyramid ****reference_frame_phases, QccWAVSubbandPyramid *current_subband_pyramid, QccIMGImageComponent *horizontal_motion, QccIMGImageComponent *vertical_motion, int blocksize, int subpixel_accuracy){ int row, col; int num_rows, num_cols; int num_levels; int num_phases; int subsample_pattern_row, subsample_pattern_col; double reference_frame_row, reference_frame_col; int integer_row, integer_col; int subpixel_row, subpixel_col; int num_subpixels; QccVIDRDWTBlockBlock reference_block; QccWAVSubbandPyramid predicted_frame; int return_value; QccVIDRDWTBlockBlockInitialize(&reference_block); QccWAVSubbandPyramidInitialize(&predicted_frame); reference_block.blocksize = blocksize; if (QccVIDRDWTBlockBlockAlloc(&reference_block)) { QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Error calling QccVIDRDWTBlockBlockAlloc()"); goto Error; } num_rows = current_subband_pyramid->num_rows; num_cols = current_subband_pyramid->num_cols; num_levels = current_subband_pyramid->num_levels; num_phases = (1 << num_levels); switch (subpixel_accuracy) { case QCCVID_ME_FULLPIXEL: num_subpixels = 1; break; case QCCVID_ME_HALFPIXEL: num_subpixels = 2; break; case QCCVID_ME_QUARTERPIXEL: num_subpixels = 4; break; case QCCVID_ME_EIGHTHPIXEL: num_subpixels = 8; break; default: QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Unrecognized subpixel accuracy"); return(1); } predicted_frame.num_levels = num_levels; predicted_frame.num_rows = num_rows; predicted_frame.num_cols = num_cols; if (QccWAVSubbandPyramidAlloc(&predicted_frame)) { QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Error calling QccWAVSubbandPyramidAlloc()"); goto Error; } for (row = 0; row < num_rows; row += blocksize) for (col = 0; col < num_cols; col += blocksize) { reference_frame_col = horizontal_motion->image [row / blocksize] [col / blocksize] + col; reference_frame_row = vertical_motion->image [row / blocksize] [col / blocksize] + row; integer_row = (int)floor(reference_frame_row); integer_col = (int)floor(reference_frame_col); subpixel_row = (int)((reference_frame_row - integer_row) * num_subpixels); subpixel_col = (int)(fabs(reference_frame_col - integer_col) * num_subpixels); subsample_pattern_row = QccMathModulus(integer_row, num_phases); subsample_pattern_col = QccMathModulus(integer_col, num_phases); if (QccVIDRDWTBlockExtractBlock(&reference_frame_phases [subpixel_row][subpixel_col] [subsample_pattern_row] [subsample_pattern_col], &reference_block, integer_row, integer_col, num_rows, num_cols, num_levels)) { QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Error calling ExtractWaveletBlock()"); goto Error; } if (QccVIDRDWTBlockInsertBlock(&predicted_frame, &reference_block, row, col, num_rows, num_cols, num_levels)) { QccErrorAddMessage("(QccVIDRDWTBlockInverseMotionCompensation): Error calling QccVIDRDWTBlockInsertBlock()"); goto Error; } } for (row = 0; row < num_rows; row++) for (col = 0; col < num_cols; col++) current_subband_pyramid->matrix[row][col] +=
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -