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

📄 subband_pyramid3d.c

📁 spiht for linux this is used to decod and encode vedio i wich all enjoy
💻 C
📖 第 1 页 / 共 4 页
字号:
                if (QccWAVSubbandPyramidSubbandSize(&temp,                                            subband % spatial_num_subbands,                                            &num_rows,                                            &num_cols))          {            QccErrorAddMessage("(QccWAVSubbandPyramid3DSubbandSize): Error calling QccWAVSubbandPyramidSubbandSize()");            return(1);          }      }    if (!num_frames || !num_rows || !num_cols)    num_frames = num_rows = num_cols = 0;    if (subband_num_frames != NULL)    *subband_num_frames = num_frames;  if (subband_num_rows != NULL)    *subband_num_rows = num_rows;  if (subband_num_cols != NULL)    *subband_num_cols = num_cols;    return(0);}int QccWAVSubbandPyramid3DSubbandOffsets(const QccWAVSubbandPyramid3D                                         *subband_pyramid,                                         int subband,					 int *frame_offset,					 int *row_offset,                                         int *col_offset){  int subband_num_frames;  int subband_num_rows;  int subband_num_cols;  int spatial_num_levels = subband_pyramid->spatial_num_levels;  int temporal_num_levels = subband_pyramid->temporal_num_levels;  int spatial_num_subbands;  int level;  QccWAVSubbandPyramid3D temp;  QccWAVSubbandPyramid temp2;  QccWAVSubbandPyramid3DInitialize(&temp);  QccWAVSubbandPyramidInitialize(&temp2);  if (subband < 0)    return(0);  if (subband_pyramid->transform_type == QCCWAVSUBBANDPYRAMID3D_DYADIC)    {      temp.spatial_num_levels =      temp.temporal_num_levels =        QccWAVSubbandPyramid3DCalcLevelFromSubbandDyadic(subband,                                                         spatial_num_levels);      temp.num_frames = subband_pyramid->num_frames;      temp.num_rows = subband_pyramid->num_rows;      temp.num_cols = subband_pyramid->num_cols;      temp.origin_frame = subband_pyramid->origin_frame;      temp.origin_row = subband_pyramid->origin_row;      temp.origin_col = subband_pyramid->origin_col;      temp.subsample_pattern_frame =        subband_pyramid->subsample_pattern_frame;      temp.subsample_pattern_row =        subband_pyramid->subsample_pattern_row;      temp.subsample_pattern_col =        subband_pyramid->subsample_pattern_col;      temp.transform_type = QCCWAVSUBBANDPYRAMID3D_DYADIC;      if (QccWAVSubbandPyramid3DSubbandSize(&temp,                                            0,                                            &subband_num_frames,                                            &subband_num_rows,                                            &subband_num_cols))        {          QccErrorAddMessage("(QccWAVSubbandPyramid3DSubbandOffsets): Error calling QccWAVSubbandPyramid3DSubbandSize()");          return(1);        }            if (!subband)        {          *frame_offset = 0;          *row_offset = 0;          *col_offset = 0;        }      else        switch ((subband - 1) % 7)          {          case 0:            *frame_offset = 0;            *row_offset = subband_num_rows;            *col_offset = 0;            break;          case 1:            *frame_offset = 0;            *row_offset = 0;            *col_offset = subband_num_cols;            break;          case 2:            *frame_offset = subband_num_frames;            *row_offset = 0;            *col_offset = 0;            break;          case 3:            *frame_offset = 0;            *row_offset = subband_num_rows;            *col_offset = subband_num_cols;            break;          case 4:            *frame_offset = subband_num_frames;            *row_offset = subband_num_rows;            *col_offset = 0;            break;          case 5:            *frame_offset = subband_num_frames;            *row_offset = 0;            *col_offset = subband_num_cols;            break;          case 6:            *frame_offset = subband_num_frames;            *row_offset = subband_num_rows;            *col_offset = subband_num_cols;            break;          }    }  else    if (subband_pyramid->transform_type == QCCWAVSUBBANDPYRAMID3D_PACKET)      {        temp2.num_levels = spatial_num_levels;        temp2.num_rows = subband_pyramid->num_rows;        temp2.num_cols = subband_pyramid->num_cols;        temp2.origin_row = subband_pyramid->origin_row;        temp2.origin_col = subband_pyramid->origin_col;        temp2.subsample_pattern_row =          subband_pyramid->subsample_pattern_row;        temp2.subsample_pattern_col =          subband_pyramid->subsample_pattern_col;        spatial_num_subbands =          QccWAVSubbandPyramidNumLevelsToNumSubbands(spatial_num_levels);        QccWAVSubbandPyramid3DCalcLevelFromSubbandPacket(subband,                                                         temporal_num_levels,                                                         spatial_num_levels,                                                         &level,                                                         NULL);        if (subband < spatial_num_subbands)          *frame_offset = 0;        else          *frame_offset =            QccWAVWaveletDWTSubbandLength(subband_pyramid->num_frames,                                          level,                                          0,                                          subband_pyramid->origin_frame,                                          subband_pyramid->subsample_pattern_frame);                if (QccWAVSubbandPyramidSubbandOffsets(&temp2,                                               subband % spatial_num_subbands,                                               row_offset,                                               col_offset))          {            QccErrorAddMessage("(QccWAVSubbandPyramid3DSubbandOffsets): Error calling QccWAVSubbandPyramidSubbandOffsets()");            return(1);          }      }    return(0);}int QccWAVSubbandPyramid3DPrint(const QccWAVSubbandPyramid3D *subband_pyramid){  int frame, row, col;  if (QccFilePrintFileInfo(subband_pyramid->filename,                           subband_pyramid->magic_num,                           subband_pyramid->major_version,                           subband_pyramid->minor_version))    return(1);  printf("Transform type: ");  switch (subband_pyramid->transform_type)    {    case QCCWAVSUBBANDPYRAMID3D_DYADIC:      printf("dyadic\n");      printf("Levels of decomposition: %d\n",             subband_pyramid->spatial_num_levels);      break;    case QCCWAVSUBBANDPYRAMID3D_PACKET:      printf("packet\n");      printf("Levels of decomposition:\n");      printf("  temporal: %d\n", subband_pyramid->temporal_num_levels);      printf("   spatial: %d\n", subband_pyramid->spatial_num_levels);      break;    default:      printf("unknown\n");    }  printf("Size: %dx%dx%d (cols x rows x frames)\n",         subband_pyramid->num_cols,         subband_pyramid->num_rows,	 subband_pyramid->num_frames);  printf("Origin: (%d, %d, %d)\n",         subband_pyramid->origin_frame,	 subband_pyramid->origin_row,         subband_pyramid->origin_col);  printf("\nVolume:\n\n");  for (frame = 0; frame < subband_pyramid->num_frames; frame++)    {      printf("======================== Frame %d ===========================\n",             frame);      for (row = 0; row < subband_pyramid->num_rows; row++)        {          for (col = 0; col < subband_pyramid->num_cols; col++)            printf("% 10.4f ", subband_pyramid->volume[frame][row][col]);          printf("\n");        }    }  return(0);}static int QccWAVSubbandPyramid3DReadHeader(FILE *infile,                                            QccWAVSubbandPyramid3D                                            *subband_pyramid){    if ((infile == NULL) || (subband_pyramid == NULL))    return(0);    if (QccFileReadMagicNumber(infile,                             subband_pyramid->magic_num,                             &subband_pyramid->major_version,                             &subband_pyramid->minor_version))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading magic number in %s",                         subband_pyramid->filename);      return(1);    }    if (strcmp(subband_pyramid->magic_num, QCCWAVSUBBANDPYRAMID3D_MAGICNUM))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): %s is not of subband-pyramid (%s) type",                         subband_pyramid->filename,                         QCCWAVSUBBANDPYRAMID3D_MAGICNUM);      return(1);    }    fscanf(infile, "%d", &(subband_pyramid->transform_type));  if (ferror(infile) || feof(infile))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading transform type in %s",                         subband_pyramid->filename);      return(1);    }    if (QccFileSkipWhiteSpace(infile, 0))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading transform type in %s",                         subband_pyramid->filename);      return(1);    }    switch (subband_pyramid->transform_type)    {    case QCCWAVSUBBANDPYRAMID3D_DYADIC:      fscanf(infile, "%d", &(subband_pyramid->spatial_num_levels));      if (ferror(infile) || feof(infile))        {          QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of levels in %s",                             subband_pyramid->filename);          return(1);        }      subband_pyramid->temporal_num_levels =        subband_pyramid->spatial_num_levels;      if (QccFileSkipWhiteSpace(infile, 0))        {          QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of levels in %s",                             subband_pyramid->filename);          return(1);        }      break;    case QCCWAVSUBBANDPYRAMID3D_PACKET:      fscanf(infile, "%d", &(subband_pyramid->temporal_num_levels));      if (ferror(infile) || feof(infile))        {          QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of temporal levels in %s",                             subband_pyramid->filename);          return(1);        }      if (QccFileSkipWhiteSpace(infile, 0))        {          QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of spatial levels in %s",                             subband_pyramid->filename);          return(1);        }      fscanf(infile, "%d", &(subband_pyramid->spatial_num_levels));      if (ferror(infile) || feof(infile))        {          QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of spatial levels in %s",                             subband_pyramid->filename);          return(1);        }      if (QccFileSkipWhiteSpace(infile, 0))        {          QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of temporal levels in %s",                             subband_pyramid->filename);          return(1);        }      break;    default:      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Unknown transform type (%d) in %s",                         subband_pyramid->transform_type,                         subband_pyramid->filename);      return(1);    }  fscanf(infile, "%d", &(subband_pyramid->num_cols));  if (ferror(infile) || feof(infile))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of columns in %s",                         subband_pyramid->filename);      return(1);    }    if (QccFileSkipWhiteSpace(infile, 0))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of columns in %s",                         subband_pyramid->filename);      return(1);    }    fscanf(infile, "%d", &(subband_pyramid->num_rows));  if (ferror(infile) || feof(infile))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of rows in %s",                         subband_pyramid->filename);      return(1);    }    if (QccFileSkipWhiteSpace(infile, 0))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of rows in %s",                         subband_pyramid->filename);      return(1);    }    fscanf(infile, "%d", &(subband_pyramid->num_frames));  if (ferror(infile) || feof(infile))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of frames in %s",                         subband_pyramid->filename);      return(1);    }    if (QccFileSkipWhiteSpace(infile, 0))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading number of frames in %s",                         subband_pyramid->filename);      return(1);    }    fscanf(infile, "%*1[\n]");  if (ferror(infile) || feof(infile))    {      QccErrorAddMessage("(QccWAVSubbandPyramid3DReadHeader): Error reading subband pyramid %s",                         subband_pyramid->filename);      return(1);    }    return(0);}int QccWAVSubbandPyramid3DRead(QccWAVSubbandPyramid3D *subband_pyramid){  FILE *infile = NULL;  int frame, row, col;  if (subband_pyramid == NULL)    return(0);  if ((infile = QccFileOpen(subband_pyramid->filename, "r")) == NULL)

⌨️ 快捷键说明

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