⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rdwtblock.c

📁 QccPack implementation in C
💻 C
📖 第 1 页 / 共 5 页
字号:
    if (QccVIDMotionVectorsDecode(motion_vector_horizontal,                                  motion_vector_vertical,                                  NULL,                                  subpixel_accuracy,                                  input_buffer))      {        QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccVIDMotionVectorsDecode()");        goto Error;      }  current_frame->num_levels = num_levels;  if (QccMatrixZero(current_frame->matrix,                    num_rows, num_cols))    {      QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccMatrixZero()");      goto Error;    }  if (QccSPIHTDecodeHeader(input_buffer,                           &num_levels,                           &num_rows,                           &num_cols,                           &image_mean,                           &max_coefficient_bits,                           &arithmetic_coded))    {      QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccSPIHTDecodeHeader()");      goto Error;    }  if (QccSPIHTDecode2(input_buffer,                      current_frame,                      NULL,                      max_coefficient_bits,                      start_position + target_bit_cnt,                      arithmetic_coded))    {      QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame):Error calling QccSPIHTDecode2()");      goto Error;    }    if (QccBitBufferFlush(input_buffer))    {      QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame):Error calling QccBitBufferFlush()");      goto Error;    }  if (!intraframe)    if (QccVIDRDWTBlockInverseMotionCompensation(reference_frame_phases,                                                 current_frame,                                                 motion_vector_horizontal,                                                 motion_vector_vertical,                                                 blocksize,                                                 subpixel_accuracy))      {	QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccVIDRDWTBlockInverseMotionCompensation()");        goto Error;      }    if (QccWAVSubbandPyramidInverseDWT(current_frame,                                     wavelet))    {      QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccWAVSubbandPyramidInverseDWT()");      return(1);    }    if (intraframe)    if (QccWAVSubbandPyramidAddMean(current_frame,                                    image_mean))      {        QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccWAVSubbandPyramidAddMean()");        return(1);      }  if (QccWAVWaveletRedundantDWT2D(current_frame->matrix,				  reconstructed_frame_rdwt,				  num_rows,				  num_cols,				  num_levels,                                  wavelet))    {      QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccWAVWaveletRedundantDWT2D()");      goto Error;    }    if (QccVIDRDWTBlockCreateReferenceFrame(reconstructed_frame_rdwt,                                          reference_frame_rdwt,                                          num_rows,                                          num_cols,                                          reference_num_rows,                                          reference_num_cols,                                          num_levels,                                          subpixel_accuracy,                                          filter1,                                          filter2,                                          filter3))    {      QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccVIDRDWTBlockCreateReferenceFrame()");      goto Error;    }  if (QccVIDRDWTBlockExtractPhases(reference_frame_rdwt,                                   reference_frame_phases,                                   num_rows,                                   num_cols,                                   reference_num_rows,                                   reference_num_cols,                                   num_levels,                                   subpixel_accuracy,                                   wavelet))    {      QccErrorAddMessage("(QccVIDRDWTBlockDecodeFrame): Error calling QccVIDRDWTBlockExtractPhases()");      goto Error;    }  return_value = 0;  goto Return; Error:  return_value = 1; Return:  return(return_value);}int QccVIDRDWTBlockEncode(QccIMGImageSequence *image_sequence,                          const QccFilter *filter1,                          const QccFilter *filter2,                          const QccFilter *filter3,                          int subpixel_accuracy,                          QccBitBuffer *output_buffer,                          int blocksize,                          int num_levels,                          int target_bit_cnt,                          const QccWAVWavelet *wavelet,                          const QccString mv_filename,                          int read_motion_vectors,                          int quiet){  int return_value;  QccWAVSubbandPyramid current_frame;  QccMatrix *reconstructed_frame_rdwt = NULL;  QccMatrix *reference_frame_rdwt = NULL;  QccWAVSubbandPyramid ****reference_frame_phases = NULL;  QccIMGImageComponent motion_vector_horizontal;  QccIMGImageComponent motion_vector_vertical;  QccVIDMotionVectorsTable mvd_table;  int frame = 0;  int num_subbands;  int num_rows, num_cols;  int reference_num_rows, reference_num_cols;  QccBitBuffer input_buffer;  QccVIDRDWTBlockStatistics statistics;  QccBitBufferInitialize(&input_buffer);  QccWAVSubbandPyramidInitialize(&current_frame);  QccIMGImageComponentInitialize(&motion_vector_horizontal);  QccIMGImageComponentInitialize(&motion_vector_vertical);  QccVIDMotionVectorsTableInitialize(&mvd_table);  num_subbands = QccWAVSubbandPyramidNumLevelsToNumSubbands(num_levels);    if (QccIMGImageSequenceStartRead(image_sequence))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccIMGImageSequenceStartRead()");      goto Error;    }  if (QccIMGImageGetSize(&image_sequence->current_frame,                         &num_rows, &num_cols))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccIMGImageGetSize()");      goto Error;    }    if ((num_rows % blocksize) || (num_cols % blocksize))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Image size is not an integer multiple of block size");      goto Error;    }  if (blocksize < (1 << num_levels))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Block size is too small for specified number of levels");      goto Error;    }  current_frame.num_rows = num_rows;  current_frame.num_cols = num_cols;  current_frame.num_levels = 0;  current_frame.matrix = image_sequence->current_frame.Y.image;  motion_vector_horizontal.num_rows =    num_rows / blocksize;  motion_vector_horizontal.num_cols =    num_cols / blocksize;  if (QccIMGImageComponentAlloc(&motion_vector_horizontal))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccIMGImageComponentAlloc()");      goto Error;    }  motion_vector_vertical.num_rows =    num_rows / blocksize;  motion_vector_vertical.num_cols =    num_cols / blocksize;  if (QccIMGImageComponentAlloc(&motion_vector_vertical))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccIMGImageComponentAlloc()");      goto Error;    }    if (QccVIDMotionEstimationCalcReferenceFrameSize(num_rows,                                                   num_cols,                                                   &reference_num_rows,                                                   &reference_num_cols,                                                   subpixel_accuracy))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccVIDMotionEstimationCalcReferenceFrameSize()");      goto Error;    }  if ((reconstructed_frame_rdwt =       QccWAVWaveletRedundantDWT2DAlloc(num_rows,                                        num_cols,                                        num_levels)) == NULL)    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccWAVWaveletRedundantDWT2DAlloc()");      goto Error;    }    if ((reference_frame_rdwt =       QccWAVWaveletRedundantDWT2DAlloc(reference_num_rows,                                        reference_num_cols,                                        num_levels)) == NULL)    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccWAVWaveletRedundantDWT2DAlloc()");      goto Error;    }    if ((reference_frame_phases =       QccVIDRDWTBlockRDWTPhasesAlloc(num_levels,                                      num_rows,                                      num_cols,                                      subpixel_accuracy)) == NULL)    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccVIDRDWTBlockRDWTPhasesAlloc()");      goto Error;    }  QccStringCopy(input_buffer.filename, output_buffer->filename);  input_buffer.type = QCCBITBUFFER_INPUT;  if (QccBitBufferStart(&input_buffer))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccBitBufferStart()");      goto Error;    }    if (QccVIDRDWTBlockEncodeHeader(output_buffer,                                  num_rows,                                  num_cols,                                  image_sequence->start_frame_num,                                  image_sequence->end_frame_num,                                  blocksize,                                  num_levels,                                  target_bit_cnt))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccVIDRDWTBlockEncodeHeader()");      goto Error;    }    if (QccVIDRDWTBlockDecodeHeader(&input_buffer,                                  NULL, NULL, NULL, NULL, NULL, NULL, NULL))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncodeFrame): Error calling QccVIDRDWTBlockDecodeHeader()");      goto Error;    }    if (QccVIDMotionVectorsTableCreate(&mvd_table))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccVIDMotionVectorsTableCreate()");      goto Error;    }    if (!quiet)    {      printf("===========================================================\n");      printf("\n");      printf("  RDWT Block -- encoding sequence:\n      %s\n         to\n      %s\n\n",             image_sequence->filename,             output_buffer->filename);      printf("   Frame size: %d x %d\n",             num_cols, num_rows);      printf("  Start frame: %d\n",             image_sequence->start_frame_num);      printf("    End frame: %d\n\n",             image_sequence->end_frame_num);      printf("===========================================================\n");      printf("\n");    }  if (!quiet)    printf("  Frame: %d\n",           image_sequence->start_frame_num);  if (QccVIDRDWTBlockEncodeFrame(&current_frame,                                 reconstructed_frame_rdwt,                                 reference_frame_rdwt,                                 reference_frame_phases,                                 blocksize,                                 num_levels,                                 subpixel_accuracy,                                 wavelet,                                 output_buffer,                                 &input_buffer,                                 &mvd_table,                                 NULL,                                 NULL,                                 0,                                 target_bit_cnt,                                 &statistics,                                 filter1,                                 filter2,                                 filter3))    {      QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccVIDRDWTBlockEncodeFrame()");      goto Error;    }    if (!quiet)    QccVIDRDWTBlockPrintStatistics(&statistics);  for (frame = image_sequence->start_frame_num + 1;       frame <= image_sequence->end_frame_num;       frame++)    {      if (!quiet)        printf("  Frame: %d\n", frame);            if (QccIMGImageSequenceIncrementFrameNum(image_sequence))	{	  QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccIMGImageSequenceIncrementFrameNum()");	  goto Error;	}            if (QccIMGImageSequenceReadFrame(image_sequence))	{	  QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccIMGImageSequenceReadFrame()");	  goto Error;	}            if ((mv_filename != NULL) && read_motion_vectors)        if (QccVIDMotionVectorsReadFile(&motion_vector_horizontal,                                        &motion_vector_vertical,                                        mv_filename,                                        frame))          {            QccErrorAddMessage("(QccVIDRDWTBlockEncode): Error calling QccVIDMotionVectorsReadFile()");            goto Error;          }      if (QccVIDRDWTBlockEncodeFrame(&current_frame,                                     reconstructed_frame_rdwt,                                     reference_frame_rdwt,                                     reference_frame_phases,                                     blocksize,             

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -