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

📄 configfile.c

📁 avs-s最新代码,包括编码器和解码器源码
💻 C
📖 第 1 页 / 共 3 页
字号:
							{
								printf("\n Luma Sampling Rate invalid for level 4.2.\n");
								exit(-1);
							}
						}
					}
			if((long)(input->img_width)*(long)(input->img_height)/256>1620)
			{
				printf(" \n The number of macroblock per frame exceeds 1,620 for Level_4.2.\n");
				exit(-1);
			}
			
			if((long)(input->img_width)*(long)(input->img_height)*framerate[input->frame_rate_code-1]/256>40500)
			{
				printf(" \n The number of macroblock per second exceeds 40500 in Level_4.2.\n");
				exit(-1);
			}
			
			if(input->chroma_format>2)//4:0:0 WANGJP
			//if(input->chroma_format!=1&&input->chroma_format!=2)
			{
				printf("\n In level 4.2 only format 4:2:0 and 4:2:2 are supported.\n");
				exit(-1);
			}

			break;
		}

	case 0x40:
		{
			if(input->img_width>1920)
			{
				printf("\n Imgage Width exceeds level 6.0's restriction.\n");
				exit(-1);
			}
			else 
				if(input->img_height>1152)
					{
						printf("\n Image Height exceeds level 6.0's restriction.\n");
						exit(-1);
					}
				else
					{
						if((long)(input->img_width)*(long)(input->img_height)*(long)(framerate[input->frame_rate_code-1])>62668800)
							{
								printf("\n Luma Sampling Rate invalid for level 6.0.\n");
								exit(-1);
							}
					}	
			
			if((long)(input->img_width)*(long)(input->img_height)/256>8160)
			{
				printf(" \n The number of macroblock per frame exceeds 8160 for Level_6.0.\n");
				exit(-1);
			}
			
			if((long)(input->img_width)*(long)(input->img_height)*framerate[input->frame_rate_code-1]/256>244800)
			{
				printf(" \n The number of macroblock per second exceeds 244800 in Level_6.0.\n");
				exit(-1);
			}
			
			if(input->chroma_format>1)//4:0:0 WANGJP
			//if(input->chroma_format!=1)
			{
				printf("\n In level 6.0 only format 4:2:0 is supported.\n");
				exit(-1);
			}

			break;
		}

	case 0x42:
		{
			if(input->img_width>1920)
			{
				printf("\n Imgage Width exceeds level 6.2's restriction.\n");
				exit(-1);
			}
			else 
				if(input->img_height>1152)
					{
						printf("\n Imgage Height exceeds level 6.2's restriction.\n");
						exit(-1);
					}
				else
					{
						if((long)(input->img_width)*(long)(input->img_height)*(long)(framerate[input->frame_rate_code-1])>62668800)
							{
								printf("\n Luma Sampling Rate invalid for level 6.2.\n");
								exit(-1);
							}
					}
			
			if((long)(input->img_width)*(long)(input->img_height)/256>8160)
			{
				printf(" \n The number of macroblock per frame exceeds 8160 for Level_6.2.\n");
				exit(-1);
			}
			
			if((long)(input->img_width)*(long)(input->img_height)*framerate[input->frame_rate_code-1]/256>244800)
			{
				printf(" \n The number of macroblock per second exceeds 244800 in Level_6.2.\n");
				exit(-1);
			}
			
			if(input->chroma_format>2)//4:0:0 WANGJP
			//if(input->chroma_format!=1&&input->chroma_format!=2)
			{
				printf("\n In level 6.2 only format 4:2:0 and 4:2:2 are supported.\n");
				exit(-1);
			}

			break;
		}

	default: 
		{
		printf("\n No such level_ID. \n");
		exit(-1);
		}
	}
}
/*
*************************************************************************
* Function:Checks the input parameters for consistency.
* Input:
* Output:
* Return: 
* Attention:
*************************************************************************
*/

static void PatchInp ()
{
  // consistency check of QPs
	input->fixed_picture_qp = 1;/*lgp*/
  if (input->qp0 > MAX_QP || input->qp0 < MIN_QP)
  {
    snprintf(errortext, ET_SIZE, "Error input parameter quant_0,check configuration file");
    error (errortext, 400);
  }

  if (input->qpN > MAX_QP || input->qpN < MIN_QP)
  {
    snprintf(errortext, ET_SIZE, "Error input parameter quant_n,check configuration file");
    error (errortext, 400);
  }

  if (input->qpB > MAX_QP || input->qpB < MIN_QP)
  {
    snprintf(errortext, ET_SIZE, "Error input parameter quant_B,check configuration file");
    error (errortext, 400);
  }

  // consistency check no_multpred
  if (input->no_multpred<1) 
	  input->no_multpred=1;

  if (input->img_width % 16 != 0)   //add by wuzhongmou 0610
  {
    img->auto_crop_right = 16-(input->img_width % 16);
  }
  else
  {
    img->auto_crop_right=0;
  }
    if (input->InterlaceCodingOption!=FRAME_CODING)  //add by wuzhongmou 0610
  {
    if (input->img_height % 32 != 0)
    {
      img->auto_crop_bottom = 32-(input->img_height % 32);
    }
    else
    {
      img->auto_crop_bottom=0;
    }
  }
  else              
  {
    if (input->img_height % 16 != 0)     //add by wuzhongmou 0610
    {
      img->auto_crop_bottom = 16-(input->img_height % 16);
    }
    else
    {
      img->auto_crop_bottom=0;
    }
  }                                   //add by wuzhongmou 0610
  // check range of filter offsets
  if (input->alpha_c_offset > 6 || input->alpha_c_offset < -6)
  {
    snprintf(errortext, ET_SIZE, "Error input parameter LFAlphaC0Offset, check configuration file");
    error (errortext, 400);
  }

  if (input->beta_offset > 6 || input->beta_offset < -6)
  {
    snprintf(errortext, ET_SIZE, "Error input parameter LFBetaOffset, check configuration file");
    error (errortext, 400);
  }

  // Set block sizes
  input->blc_size[0][0]=16;
  input->blc_size[0][1]=16;
  input->blc_size[1][0]=16;
  input->blc_size[1][1]=16;
  input->blc_size[2][0]=16;
  input->blc_size[2][1]= 8;
  input->blc_size[3][0]= 8;
  input->blc_size[3][1]=16;
  input->blc_size[4][0]= 8;
  input->blc_size[4][1]= 8;

  // B picture consistency check
  if(input->successive_Bframe > input->jumpd)
  {
    snprintf(errortext, ET_SIZE, "Number of B-frames %d can not exceed the number of frames skipped", input->successive_Bframe);
    error (errortext, 400);
  }
  
  if(input->successive_Bframe==0)  //low_delay added by cjw 20070414
	input->low_delay=1;
  else
	input->low_delay=0;
  
  // Open Files
  if (strlen (input->infile) > 0 && (p_in=fopen(input->infile,"rb"))==NULL)
  {
    snprintf(errortext, ET_SIZE, "Input file %s does not exist",input->infile);    
  }
  
  if (strlen (input->ReconFile) > 0 && (p_dec=fopen(input->ReconFile, "wb"))==NULL)
  {
    snprintf(errortext, ET_SIZE, "Error open file %s", input->ReconFile);    
  }

  if (strlen (input->TraceFile) > 0 && (p_trace=fopen(input->TraceFile,"w"))==NULL)
  {
    snprintf(errortext, ET_SIZE, "Error open file %s", input->TraceFile);    
  }

  if(!input->slice_set_enable)   //added by mz, 2008.04
  {
	  if (input->slice_row_nr==0)
	  {
		  input->slice_row_nr=input->img_height/16;
	  }
  }
  // frame/field consistency check

  // input intra period and Seqheader check Add cjw, 20070327
  if(input->seqheader_period!=0 && input->intra_period==0)
  {
	 if(input->intra_period==0)
		snprintf(errortext, ET_SIZE, "\nintra_period  should not equal %d when seqheader_period equal %d", input->intra_period,input->seqheader_period);
	 error (errortext, 400);
  }

  // input intra period and Seqheader check Add cjw, 20070327
  if(input->seqheader_period==0 && input->vec_period!=0)
  {
	 snprintf(errortext, ET_SIZE, "\nvec_period  should not equal %d when seqheader_period equal %d", input->intra_period,input->seqheader_period);
	 error (errortext, 400);
  }

#ifdef REGION
  if( input->RegionPresentFlag )
  {
	  FILE* f;

	  if( NULL == ( f = fopen( input->RegionFile, "rt" )))
	  {
		  snprintf (errortext, ET_SIZE, "Cannot open region file %s.\n", input->RegionFile );
		  error ( errortext, 300);
	  }
	  ParseRegionFile( f, input->RegionFile );
	  fclose( f );
  }
#endif

  // Added by LiShao, Tsinghua, 20070327
  ProfileCheck();
  LevelCheck();
}

int ParseRegionFile( FILE* f, char* Filename )
{
	int i;
	char dumy[256];
	if( EOF  == fscanf( f, "region_num %d\n", &region->region_num ))
	{
		snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
		error (errortext, 300);
		return 0;
	}
	if( region->region_num < 1 )
	{
		snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
		error (errortext, 300);
		return 0;
	}

	for( i = 0; i < region->region_num; i++ )
	{
		if( EOF  == fscanf( f, "region_id %d\n", &region->region_id[i] ))
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}
		if( region->region_id[i] < 0 )
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}

		if( EOF == fscanf( f, "region_event_id %d\n", &region->region_event_id[i] ))
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}
		if( region->region_event_id[i] < 0 )
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}

		if( EOF == fscanf( f, "region_top_left_x %d\n", &region->region_top_left_x[i] ))
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}
		if( region->region_top_left_x[i] < 0 )
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}

		if( EOF == fscanf( f, "region_top_left_y %d\n", &region->region_top_left_y[i] ))
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}
		if( region->region_top_left_y[i] < 0 )
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}

		if( EOF == fscanf( f, "region_bottom_right_x %d\n", &region->region_bottom_right_x[i] ))
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}
		if( region->region_bottom_right_x[i] < 0 )
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}

		if( EOF == fscanf( f, "region_bottom_right_y %d\n", &region->region_bottom_right_y[i] ))
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}
		if( region->region_bottom_right_y[i] < 0 )
		{
			snprintf (errortext, ET_SIZE, "Invalid region file %s.\n", Filename);
			error (errortext, 300);
			return 0;
		}
	}
	return 1;
}

⌨️ 快捷键说明

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