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

📄 header.c

📁 AVS视频编解码器 能实现视频图像的高效率压缩 能在VC上高速运行
💻 C
📖 第 1 页 / 共 2 页
字号:
			if (top_field_first == 1)
				NumberOfFrameCentreOffsets = 3;
			else
				NumberOfFrameCentreOffsets = 2;
		} else {
			NumberOfFrameCentreOffsets = 1;
		}
	} else {
		if (img->picture_structure == 0){
			NumberOfFrameCentreOffsets = 1;
		} else {
			if (repeat_first_field == 1)
				NumberOfFrameCentreOffsets = 3;
			else
				NumberOfFrameCentreOffsets = 2;
		}
	}

	for(i = 0; i < NumberOfFrameCentreOffsets; i++){
		frame_centre_horizontal_offset[i] = u_v(16, "frame_centre_horizontal_offset");
		u_v(1,"marker_bit");
		frame_centre_vertical_offset[i]   = u_v(16, "frame_centre_vertical_offset");
		u_v(1,"marker_bit");
	}

}

/*
*************************************************************************
* Function:user data //sw
* Input:
* Output:
* Return: 
* Attention:
*************************************************************************
*/

void user_data(char *buf,int startcodepos, int length)
{
  int user_data;
  int i;

  memcpy (currStream->streamBuffer, buf, length);

  currStream->code_len = currStream->bitstream_length = length;
  currStream->read_len = currStream->frame_bitoffset = (startcodepos+1)*8;
  
  for(i=0; i<length-4; i++)
    user_data = u_v (8, "user data");
}

/*
*************************************************************************
* Function:Copyright extension //sw
* Input:
* Output:
* Return: 
* Attention:
*************************************************************************
*/

void copyright_extension()
{
  int reserved_data;
	int marker_bit;
	
  copyright_flag       =  u_v(1,"copyright_flag");
  copyright_identifier =  u_v(8,"copyright_identifier");
  original_or_copy     =  u_v(1,"original_or_copy");
  
  /* reserved */
  reserved_data      = u_v(7,"reserved_data");
	marker_bit         = u_v(1,"marker_bit");
  copyright_number_1 = u_v(20,"copyright_number_1");
  marker_bit         = u_v(1,"marker_bit");
  copyright_number_2 = u_v(22,"copyright_number_2");
  marker_bit         = u_v(1,"marker_bit");
  copyright_number_3 = u_v(22,"copyright_number_3");

}


/*
*************************************************************************
* Function:Copyright extension //sw
* Input:
* Output:
* Return: 
* Attention:
*************************************************************************
*/

void cameraparameters_extension()
{
  //	int marker_bit1,marker_bit,marker_bit2;
  // float reserved_data;
  /* reserved */
 	u_v(1,"reserved");
	u_v(7,"camera id");
	u_v(1,"marker bit");
	u_v(22,"height_of_image_device");
	u_v(1,"marker bit");
	u_v(22,"focal_length");
	u_v(1,"marker bit");
	u_v(22,"f_number");
	u_v(1,"marker bit");
	u_v(22,"vertical_angle_of_view");
	u_v(1,"marker bit");

	u_v(16,"camera_position_x_upper");
	u_v(1,"marker bit");
	u_v(16,"camera_position_x_lower");
	u_v(1,"marker bit");

	u_v(16,"camera_position_y_upper");
	u_v(1,"marker bit");
	u_v(16,"camera_position_y_lower");
	u_v(1,"marker bit");

	u_v(16,"camera_position_z_upper");
	u_v(1,"marker bit");
	u_v(16,"camera_position_z_lower");
	u_v(1,"marker bit");
	

	u_v(22,"camera_direction_x");
	u_v(1,"marker bit");
	u_v(22,"camera_direction_y");
	u_v(1,"marker bit");
	u_v(22,"camera_direction_z");
	u_v(1,"marker bit");

	u_v(22,"image_plane_vertical_x");
	u_v(1,"marker bit");
	u_v(22,"image_plane_vertical_y");
	u_v(1,"marker bit");
	u_v(32,"image_plane_vertical_z");
	u_v(1,"marker bit");
	
	u_v(32,"reserved data");
}
/*
*************************************************************************
* Function:To calculate the poc values
          based upon JVT-F100d2
    POC200301: Until Jan 2003, this function will calculate the correct POC
      values, but the management of POCs in buffered pictures may need more work.
* Input:
* Output:
* Return: 
* Attention:
*************************************************************************
*/

void calc_picture_distance(struct img_par *img)
{
    static int flag = 0;
    // for POC mode 0:
    unsigned int        MaxPicDistanceLsb = (1<<8);
    flag ++;
    // for POC mode 1:
	
	// Calculate the MSBs of current picture
	if( img->pic_distance  <  img->PrevPicDistanceLsb  &&  
		( img->PrevPicDistanceLsb - img->pic_distance )  >=  ( MaxPicDistanceLsb / 2 ) )
		img->CurrPicDistanceMsb = img->PicDistanceMsb + MaxPicDistanceLsb;
	else if ( img->pic_distance  >  img->PrevPicDistanceLsb  &&
		( img->pic_distance - img->PrevPicDistanceLsb )  >  ( MaxPicDistanceLsb / 2 ) )
		img->CurrPicDistanceMsb = img->PicDistanceMsb - MaxPicDistanceLsb;
	else
		img->CurrPicDistanceMsb = img->PicDistanceMsb;
	
	// 2nd
	img->toppoc = img->CurrPicDistanceMsb + img->pic_distance;
	img->bottompoc = img->toppoc + img->delta_pic_order_cnt_bottom;
	
	// last: some post-processing. 
	if ( img->toppoc <= img->bottompoc )
		img->ThisPOC = img->framepoc = img->toppoc;
	else
		img->ThisPOC = img->framepoc = img->bottompoc;
	
	//frame pix  -  use toppoc/2
	img->tr_frm = img->ThisPOC/2;
	img->tr = img->ThisPOC;
	img->tr_fld = img->ThisPOC;	
	//moved from above for stuff that still uses img->tr

	if(img->type != B_IMG) 
	  {
		img->imgtr_last_prev_P = img->imgtr_last_P;//Lou 1016
		img->imgtr_last_P = img->imgtr_next_P;
		//img->imgtr_next_P = img->tr;		  //Commented by Xiaozhen Zheng, HiSilicon, 20070327
		img->imgtr_next_P = picture_distance; //Hisilicon Xiaozhen Zheng 20070327 
		img->Bframe_number=0;
	  }
	if(img->type==B_IMG)
	{
		img->Bframe_number++;
	}
}

/*
*************************************************************************
* Function:slice header  
* Input:
* Output:
* Return: 
* Attention:          // CJW Spec 9.4.3  6.30
///frame coding/////////
P		img->lum_scale[0]  fw[0] 
		img->lum_scale[1]  fw[1]			
B	    img->lum_scale[0]  fw[0]
		img->lum_scale[1]  bw[0]
///field coding////////
P		img->lum_scale[0]  fw[0] ; img->lum_scale[1]  fw[1] 
		img->lum_scale[2]  fw[2] ; img->lum_scale[3]  fw[3] 			
B		img->lum_scale[0]  fw[0] ; img->lum_scale[1]  bw[0] 
		img->lum_scale[2]  fw[1] ; img->lum_scale[3]  bw[1] 			
*************************************************************************
*/

void SliceHeader (char *buf,int startcodepos, int length)
{
	int i;
  
	//cjw 20060321
	int weight_para_num;
	int mb_row;		//Added by Xiaozhen Zheng, HiSilicon, 20070327
	int mb_index;	//Added by Xiaozhen Zheng, HiSilicon, 20070327
	int mb_width, mb_height;	//Added by Xiaozhen Zheng, HiSilicon, 20070327

	memcpy (currStream->streamBuffer, buf, length);
	currStream->code_len = currStream->bitstream_length = length;
	
	//currStream->read_len = currStream->frame_bitoffset = (startcodepos+1)*8; //delete by cjw 200600327
	currStream->read_len = currStream->frame_bitoffset = (startcodepos)*8; //cjw 20060327 read 24bit starcode prefix
	slice_vertical_position              = u_v  (8, "slice vertical position"); //cjw 20060327 read 8 bit
	
	if(vertical_size > 2800)              //add by wuzhongmou 200612
	slice_vertical_position_extension  = u_v  (3, "slice vertical position extension");

	//Added by Xiaozhen Zheng, HiSilicon, 20070327, Begin
	if (vertical_size > 2800) 
		mb_row = (slice_vertical_position_extension << 7) + slice_vertical_position;
	else
		mb_row = slice_vertical_position;

	mb_width  = (img->width + 15) >> 4;
	mb_height = 2 * ((img->height*2 + 31) >> 5);

	mb_index = mb_row * mb_width;

	if (img->type==I_IMG && (mb_index >= mb_width*mb_height/2) ) {
		second_IField = 1;
		img->type = P_IMG;
		pre_img_type = P_IMG;		
	}
	//Added by Xiaozhen Zheng, HiSilicon, 20070327, End

	
	
	if (!fixed_picture_qp)
	{
	fixed_slice_qp   = u_v  (1,"fixed_slice_qp");
    slice_qp         = u_v  (6,"slice_qp");

	img->qp=slice_qp;
	}

//	if(img->picture_structure == 0){  // field coding    //delete cjw 20060321
//		input->buf_cycle = input->buf_cycle * 2 ;
//	}

	if(img->type != I_IMG){
		img->slice_weighting_flag = u_v(1,"slice weighting flag");
		if(img->slice_weighting_flag)
		{
	  	   //cjw 20060321 Spec 9.4.3
		  if(second_IField && !img->picture_structure)  //I bottom
			weight_para_num=1;
		  else if(img->type==P_IMG && img->picture_structure)  //P frame coding
			weight_para_num=2;
		  else if(img->type==P_IMG && !img->picture_structure) //P field coding
			weight_para_num=4;
		  else if(img->type==B_IMG && img->picture_structure)  //B frame coding
			weight_para_num=2;
		  else if(img->type==B_IMG && !img->picture_structure) //B field coding
			weight_para_num=4;
		   
			for(i=0;i<weight_para_num;i++)    //cjw 20060321    
			{
				img->lum_scale[i]    = u_v(8,"luma scale");
		
				img->lum_shift[i] =i_8("luma shift");  //add by wuzhongmou 0610		
				u_1 ("insert bit");
				img->chroma_scale[i] = u_v(8,"chroma scale");
				img->chroma_shift[i] = i_8("chroma shift");//add by wuzhongmou 0610	
		 	    u_1 ("insert bit"); //cjw 20060321
			}
		  		 img->mb_weighting_flag    =u_v(1,"MB weighting flag");
		}
	}


}

/*
*************************************************************************
* Function:Error handling procedure. Print error message to stderr and exit
      with supplied code.
* Input:text
      Error message
* Output:
* Return: 
* Attention:
*************************************************************************
*/

void error(char *text, int code)
{
  fprintf(stderr, "%s\n", text);
  exit(code);
}

//Lou
int sign(int a , int b)
{
  int x;
	
  x=abs(a);

  if (b>0)
    return(x);
  else 
    return(-x);
}

⌨️ 快捷键说明

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