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

📄 mpeg2_params.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
📖 第 1 页 / 共 2 页
字号:
  {    warning("Warning: setting repeat_first_field = 0");    repeat_first_field = 0;  }  if( progressive_frame )  {    if( FieldPicture )    {      warning("Warning: setting FieldPicture = 0");      FieldPicture = 0;    }    if( !frame_pred_frame_dct[0] )    {      warning("Warning: setting frame_pred_frame_dct[I_TYPE] = 1");      frame_pred_frame_dct[0] = 1;    }    if( !frame_pred_frame_dct[1] )    {      warning("Warning: setting frame_pred_frame_dct[P_TYPE] = 1");      frame_pred_frame_dct[1] = 1;    }    if( !frame_pred_frame_dct[2] )    {      warning("Warning: setting frame_pred_frame_dct[B_TYPE] = 1");      frame_pred_frame_dct[2] = 1;    }  }  if (prog_seq && !repeat_first_field && top_field_first)  {    warning("Warning: setting top_field_first = 0");    top_field_first = 0;  }  if( pMotionData[0].SearchWidthF >    (1 << (pMotionData[0].forw_hor_f_code+2)) - 1 )  {    warning("Warning: reducing forward horizontal search range");    pMotionData[0].SearchWidthF =      (1 << (pMotionData[0].forw_hor_f_code+2)) - 1;  }  if( pMotionData[0].SearchHeightF >    (1 << (pMotionData[0].forw_vert_f_code+2)) - 1 )  {    warning("Warning: reducing forward vertical search range");    pMotionData[0].SearchHeightF =      (1 << (pMotionData[0].forw_vert_f_code+2)) - 1;  }  for(i = 1; i < IPDistance; i++)  {    if( pMotionData[i].SearchWidthF >      (1 << (pMotionData[i].forw_hor_f_code+2)) - 1 )    {      warning("Warning: reducing forward horizontal search range");      pMotionData[i].SearchWidthF =        (1 << (pMotionData[i].forw_hor_f_code+2)) - 1;    }    if( pMotionData[i].SearchHeightF >      (1 << (pMotionData[i].forw_vert_f_code+2)) - 1 )    {      warning("Warning: reducing forward vertical search range");      pMotionData[i].SearchHeightF =        (1 << (pMotionData[i].forw_vert_f_code+2)) - 1;    }    if( pMotionData[i].SearchWidthB >      (1 << (pMotionData[i].back_hor_f_code+2)) - 1 )    {      warning("Warning: reducing backward horizontal search range");      pMotionData[i].SearchWidthB =        (1 << (pMotionData[i].back_hor_f_code+2)) - 1;    }    if( pMotionData[i].SearchHeightB >      (1 << (pMotionData[i].back_vert_f_code+2)) - 1 )    {      warning("Warning: reducing backward vertical search range");      pMotionData[i].SearchHeightB =        (1 << (pMotionData[i].back_vert_f_code+2)) - 1;    }  }  return ret;}IppStatus ippMPEG2EncoderParams::ReadOldParamFile(const vm_char *ParFileName,                                                  vm_char *SrcFileName,                                                  int *Width,                                                  int *Height,                                                  int *NumFramesToEncode,                                                  int *BitRate){  int i;  FILE *InputFile;  vm_char line[PAR_STRLEN];  IppStatus ret, ret2;  int dst_width, dst_height; // not used  chroma_format = CHROMA420;  ProfileID = MP;  LevelID   = 6;  intra_dc_precision = 1;  repeat_first_field = 0;  if( !(InputFile = vm_file_open(ParFileName,VM_STRING("rt"))) )  {    vm_string_sprintf(err_warn_message, __VM_STRING("Couldn't open parameter file %s\n"), ParFileName);    return ippStsErr;  }  vm_file_gets( idStr, PAR_STRLEN, InputFile );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%s"), SrcFileName );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%s"), IntraQMatrixFName );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%s"), NonIntraQMatrixFName );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), NumFramesToEncode );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), &gopSize );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), &IPDistance);  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), Width );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), Height );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), &aspectRatio );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), &frame_rate_code );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), BitRate );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d %d %d"), &nonLinearQScale[0],    &nonLinearQScale[1],    &nonLinearQScale[2] );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), &dst_width );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), &dst_height );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d %d %d"), &frame_pred_frame_dct[0],    &frame_pred_frame_dct[1],    &frame_pred_frame_dct[2] );  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d"), &progressive_frame );  prog_seq = progressive_frame; // not differntiated in old  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d %d %d"),    &intraVLCFormat[0],    &intraVLCFormat[1],    &intraVLCFormat[2] );  line[0]=0;  vm_file_gets( line, PAR_STRLEN, InputFile ); vm_string_sscanf(line, VM_STRING("%d %s"), &LogMask,TemplateLogFile);  if( gopSize < 1 )    error("N must be positive");  if( IPDistance < 1 )    error("M must be positive");  if( gopSize%IPDistance != 0 )    error("N must be an integer multiple of M");  pMotionData = (MotionData*)ippsMalloc_8u( IPDistance * sizeof(MotionData));  if( !pMotionData )    error("ippsMalloc_8u failed\n");  for(i = 0; i < IPDistance; i++)  {    pMotionData[i].forw_hor_f_code = 1;    pMotionData[i].forw_vert_f_code = 1;    pMotionData[i].back_hor_f_code = 1;    pMotionData[i].back_vert_f_code = 1;    pMotionData[i].SearchWidthF = 7;    pMotionData[i].SearchHeightF = 7;    pMotionData[i].SearchWidthB = 7;    pMotionData[i].SearchHeightB = 7;    vm_file_gets( line, PAR_STRLEN, InputFile );    vm_string_sscanf(line, VM_STRING("%d %d %d %d"),      &pMotionData[i].forw_hor_f_code,      &pMotionData[i].forw_vert_f_code,      &pMotionData[i].SearchWidthF,      &pMotionData[i].SearchHeightF );    if (i) {      vm_file_gets( line, PAR_STRLEN, InputFile );      vm_string_sscanf(line, VM_STRING("%d %d %d %d"),        &pMotionData[i].back_hor_f_code,        &pMotionData[i].back_vert_f_code,        &pMotionData[i].SearchWidthB,        &pMotionData[i].SearchHeightB );    }  }  fclose( InputFile );  // check parameters correctness  ret = Profile_and_Level_Checks();  if (ret < 0) return ret;  ret2 = RelationChecks();  if (ret2 < 0) return ret2;  if (ret2 != ippStsOk) ret = ret2;  ret2 = ReadQMatrices();  if (ret2 < 0) return ret2;  if (ret2 != ippStsOk) ret = ret2;  return ret;}IppStatus ippMPEG2EncoderParams::ReadParamFile(const vm_char *ParFileName,                                               vm_char *SrcFileName,                                               int *Width,                                               int *Height,                                               int *NumFramesToEncode,                                               int *BitRate){  int i;  int h, m, s, f;  FILE *InputFile;  vm_char line[PAR_STRLEN];  int P;  int r,Xi,Xb,Xp,d0i,d0p,d0b; /* rate control */  double avg_act; /* rate control */  vm_char tplref[PAR_STRLEN]; // patern for reconstructed frames. unused  double tmp;  IppStatus ret, ret2;  int numStartFrame, dst_width, dst_height; // not used  if (!(InputFile = vm_file_open(ParFileName, VM_STRING("rt"))))  {    vm_string_sprintf(err_warn_message, __VM_STRING("Couldn't open parameter file %s\n"), ParFileName);    return ippStsErr;  }  vm_file_gets(idStr, PAR_STRLEN,InputFile);  if( vm_string_strstr(idStr, VM_STRING("Intel IPP")) != NULL ||      vm_string_strstr(idStr, VM_STRING("UMC")) != NULL ) {    fclose(InputFile);    return ReadOldParamFile(ParFileName, SrcFileName, Width, Height, NumFramesToEncode, BitRate);  }  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%s"),SrcFileName);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%s"),tplref);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%s"),IntraQMatrixFName);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%s"),NonIntraQMatrixFName);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%s"),TemplateLogFile);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&inputtype);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),NumFramesToEncode);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&numStartFrame);       // ignored  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d:%d:%d:%d"),&h,&m,&s,&f);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&gopSize);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&IPDistance);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&mpeg1);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&FieldPicture);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),Width);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),Height);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&aspectRatio);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&frame_rate_code);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%lf"),&tmp); *BitRate = (int)tmp;  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&VBV_BufferSize);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&low_delay);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&constrparms);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&ProfileID);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&LevelID);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&prog_seq);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&chroma_format);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&video_format);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&color_primaries);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&transfer_characteristics);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&matrix_coefficients);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&dst_width);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&dst_height);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&intra_dc_precision);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&top_field_first);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d %d %d"),    frame_pred_frame_dct,frame_pred_frame_dct+1,frame_pred_frame_dct+2);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d %d %d"),    conceal_tab,conceal_tab+1,conceal_tab+2);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d %d %d"),    nonLinearQScale,nonLinearQScale+1,nonLinearQScale+2);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d %d %d"),    intraVLCFormat,intraVLCFormat+1,intraVLCFormat+2);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d %d %d"),    altscan_tab,altscan_tab+1,altscan_tab+2);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&repeat_first_field);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&progressive_frame);  /* intra slice interval refresh period */  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&P);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&r);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%lf"),&avg_act);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&Xi);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&Xp);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&Xb);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&d0i);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&d0p);  vm_file_gets(line,PAR_STRLEN,InputFile); vm_string_sscanf(line, VM_STRING("%d"),&d0b);  if( gopSize < 1 )    error("N must be positive");  if( IPDistance < 1 )    error("M must be positive");  if( gopSize%IPDistance != 0 )    error("N must be an integer multiple of M");  pMotionData = (MotionData*)ippsMalloc_8u( IPDistance * sizeof(MotionData));  if( !pMotionData )    error("ippsMalloc_8u failed\n");  for(i = 0; i < IPDistance; i++)  {    pMotionData[i].forw_hor_f_code = 1;    pMotionData[i].forw_vert_f_code = 1;    pMotionData[i].back_hor_f_code = 1;    pMotionData[i].back_vert_f_code = 1;    pMotionData[i].SearchWidthF = 7;    pMotionData[i].SearchHeightF = 7;    pMotionData[i].SearchWidthB = 7;    pMotionData[i].SearchHeightB = 7;    vm_file_gets( line, PAR_STRLEN, InputFile );    vm_string_sscanf(line, VM_STRING("%d %d %d %d"),      &pMotionData[i].forw_hor_f_code,      &pMotionData[i].forw_vert_f_code,      &pMotionData[i].SearchWidthF,      &pMotionData[i].SearchHeightF );    if (i) {      vm_file_gets( line, PAR_STRLEN, InputFile );      vm_string_sscanf(line, VM_STRING("%d %d %d %d"),        &pMotionData[i].back_hor_f_code,        &pMotionData[i].back_vert_f_code,        &pMotionData[i].SearchWidthB,        &pMotionData[i].SearchHeightB );    }  }  fclose( InputFile );  for (i=0; i<3; i++)  {    frame_pred_frame_dct[i] = !!frame_pred_frame_dct[i];    conceal_tab[i] = !!conceal_tab[i];    nonLinearQScale[i] = !!nonLinearQScale[i];    intraVLCFormat[i] = !!intraVLCFormat[i];    altscan_tab[i] = !!altscan_tab[i];  }  repeat_first_field = !!repeat_first_field;  progressive_frame = !!progressive_frame;  // check parameters correctness  ret = Profile_and_Level_Checks();  if (ret < 0) return ret;  ret2 = RelationChecks();  if (ret2 < 0) return ret2;  if (ret2 != ippStsOk) ret = ret2;  ret2 = ReadQMatrices();  if (ret2 < 0) return ret2;  if (ret2 != ippStsOk) ret = ret2;  return ret;}

⌨️ 快捷键说明

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