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

📄 camera_process.c

📁 MTK6225 支持的200W像素的代码
💻 C
📖 第 1 页 / 共 5 页
字号:
	max_zf_tmp=exposure_window.exposure_window_height*10/target_height;
#elif(defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))
	max_zf=exposure_window.exposure_window_width*10/(target_width+2);
	max_zf_tmp=exposure_window.exposure_window_height*10/(target_height+2);
#endif

	if(max_zf_tmp < max_zf)
		max_zf = max_zf_tmp;

	if(max_zf < 10)
		max_zf = 10;

	if(max_zf > 40)
		max_zf = 40;

	return max_zf;
#endif
}

void	align_center_point(void)
{
	kal_uint16 isp_org_center_x=0,isp_org_center_y=0, isp_center_x=0,isp_center_y=0;
	kal_int8 delta_center_x=0,delta_center_y=0;

	isp_org_center_x=exposure_window.grab_start_x + (exposure_window.exposure_window_width&0xFFFE)/2;
	isp_org_center_y=exposure_window.grab_start_y + (exposure_window.exposure_window_height&0xFFFE)/2;
	if(isp_digital_zoom_factor!=10)
	{
		isp_center_x=isp_grab_start_x + isp_grab_width/2;
		isp_center_y=isp_grab_start_y + isp_grab_height/2;
		delta_center_x=isp_org_center_x-isp_center_x;
		delta_center_y=isp_org_center_y-isp_center_y;
		if(delta_center_x==1)
			isp_grab_width+=2;
		else if(delta_center_x==2)
			isp_grab_start_x+=2;
		else if(delta_center_x==-1)
			isp_grab_width-=2;
		else if(delta_center_x==-2)
			isp_grab_start_x-=2;

		if(delta_center_y==1)
			isp_grab_height+=2;
		else if(delta_center_y==2)
			isp_grab_start_y+=2;
		else if(delta_center_y==-1)
			isp_grab_height-=2;
		else if(delta_center_y==-2)
			isp_grab_start_y-=2;
	}
}

/*************************************************************************
* FUNCTION
*	isp_digital_zoom
*
* DESCRIPTION
*	This function is for setting the digital zoom factor
*
* PARAMETERS
*	zoom_factor : ISP digital zoom factor
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void isp_digital_zoom(kal_uint8 zoom_factor)
{
#if (defined(ISP_SUPPORT))
	kal_uint32 save_irq_mask;
	kal_uint16 temp_grab_size;

	if ((isp_operation_state!=ISP_PREVIEW_STATE)&&
		 (isp_operation_state!=ISP_MPEG4_ENCODE_STATE)&&
		 (isp_operation_state!=ISP_MJPEG_ENCODE_STATE)&&
		 (isp_operation_state!=ISP_VIDEO_FULLDUPLEX_ENCODE_STATE))
		ASSERT(0);
	isp_digital_zoom_factor=zoom_factor;

	save_irq_mask=SaveAndSetIRQMask();
	if (isp_digital_zoom_flag==KAL_TRUE)
		isp_digital_zoom_flag=KAL_FALSE;
	RestoreIRQMask(save_irq_mask);

#if (!defined(YUV_SENSOR_SUPPORT))
	isp_grab_width= ((exposure_window.exposure_window_width * ISP_MIN_DIGITAL_ZOOM_FACTOR)/isp_digital_zoom_factor)&0xFFFE ;
	isp_grab_height=((exposure_window.exposure_window_height * ISP_MIN_DIGITAL_ZOOM_FACTOR)/isp_digital_zoom_factor)&0xFFFE ;

	isp_grab_start_x=exposure_window.grab_start_x+ (((exposure_window.exposure_window_width-isp_grab_width)>>1)&0xFFFE);
	isp_grab_start_y=exposure_window.grab_start_y+ (((exposure_window.exposure_window_height-isp_grab_height)>>1)&0xFFFE);

	if (isp_operation_state==ISP_PREVIEW_STATE)
	{
		if ((isp_preview_config_data.target_width * exposure_window.exposure_window_height) >=
			 (isp_preview_config_data.target_height * exposure_window.exposure_window_width))
		{	/* x limit */
			temp_grab_size=isp_grab_height;
			isp_grab_height=(isp_grab_width * isp_preview_config_data.target_height/
								 isp_preview_config_data.target_width)&0xFFFE;
			isp_grab_start_y+=(((temp_grab_size-isp_grab_height)>>1)&0xFFFE);
		}
		else
		{	/* y limit */
			temp_grab_size=isp_grab_width;
			isp_grab_width=(isp_grab_height * isp_preview_config_data.target_width/
								isp_preview_config_data.target_height)&0xFFFE;
			isp_grab_start_x+=(((temp_grab_size-isp_grab_width)>>1)&0xFFFE);
		}
	}
	else if ((isp_operation_state==ISP_MPEG4_ENCODE_STATE) || (isp_operation_state==ISP_VIDEO_FULLDUPLEX_ENCODE_STATE))
	{
		if ((mpeg4_encode_data.mpeg4_image_width * exposure_window.exposure_window_height) >=
			 (mpeg4_encode_data.mpeg4_image_height * exposure_window.exposure_window_width))
		{	/* x limit */
			temp_grab_size=isp_grab_height;
			isp_grab_height=(isp_grab_width * mpeg4_encode_data.mpeg4_image_height/
								 mpeg4_encode_data.mpeg4_image_width)&0xFFFE;
			isp_grab_start_y+=(((temp_grab_size-isp_grab_height)>>1)&0xFFFE);
		}
		else
		{	/* y limit */
			temp_grab_size=isp_grab_width;
			isp_grab_width=(isp_grab_height * mpeg4_encode_data.mpeg4_image_width/
								mpeg4_encode_data.mpeg4_image_height)&0xFFFE;
			isp_grab_start_x+=(((temp_grab_size-isp_grab_width)>>1)&0xFFFE);
		}
	}
	
	isp_grab_start_x-=(((isp_grab_width*(isp_horizontal_subsample-1))>>1)&0xFFFE);
	isp_grab_start_y-=((isp_grab_height*(isp_vertical_subsample-1))>>1);
	
	align_center_point();

#if (defined(DRV_ISP_6219_SERIES))
	if ((isp_grab_width<=MAX_RESIZER_INPUT_WIDTH) && (isp_grab_height<=MAX_RESIZER_INPUT_HEIGHT))
	{
		isp_sub_sample_mode=CAMERA_SUB_SAMPLE_1_1;
		if (isp_operation_state==ISP_PREVIEW_STATE)
		{
		isp_preview_config_data.source_width=isp_grab_width;
		isp_preview_config_data.source_height=isp_grab_height;
	}
		else
		{
			mpeg4_encode_data.image_source_width=isp_grab_width;
			mpeg4_encode_data.image_source_height=isp_grab_height;
		}
	}
	else if ((isp_grab_width<=(MAX_RESIZER_INPUT_WIDTH<<1)) && (isp_grab_height<=(MAX_RESIZER_INPUT_HEIGHT<<1)))
	{
		isp_sub_sample_mode=CAMERA_SUB_SAMPLE_1_2;
		if (isp_operation_state==ISP_PREVIEW_STATE)
		{
		isp_preview_config_data.source_width=isp_grab_width>>1;
		isp_preview_config_data.source_height=isp_grab_height>>1;
	}
		else
		{
			mpeg4_encode_data.image_source_width=isp_grab_width>>1;
			mpeg4_encode_data.image_source_height=isp_grab_height>>1;
		}
	}
	else if ((isp_grab_width<=(MAX_RESIZER_INPUT_WIDTH<<2)) && (isp_grab_height<=(MAX_RESIZER_INPUT_HEIGHT<<2)))
	{
		isp_sub_sample_mode=CAMERA_SUB_SAMPLE_1_4;
		if (isp_operation_state==ISP_PREVIEW_STATE)
		{
		isp_preview_config_data.source_width=isp_grab_width>>2;
		isp_preview_config_data.source_height=isp_grab_height>>2;
		}
		else
		{
			mpeg4_encode_data.image_source_width=isp_grab_width>>2;
			mpeg4_encode_data.image_source_height=isp_grab_height>>2;
		}
	}
	else if ((isp_grab_width<=(MAX_RESIZER_INPUT_WIDTH<<3)) && (isp_grab_height<=(MAX_RESIZER_INPUT_HEIGHT<<3)))
	{
		isp_sub_sample_mode=CAMERA_SUB_SAMPLE_1_8;
		if (isp_operation_state==ISP_PREVIEW_STATE)
		{
		isp_preview_config_data.source_width=isp_grab_width>>3;
		isp_preview_config_data.source_height=isp_grab_height>>3;
	}
		else
		{
			mpeg4_encode_data.image_source_width=isp_grab_width>>3;
			mpeg4_encode_data.image_source_height=isp_grab_height>>3;
		}
	}
#elif(defined(DRV_ISP_6227_SERIES)||defined(DRV_ISP_6225_SERIES)||defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))
	//Camera Preview
	if((isp_grab_width>(isp_preview_config_data.target_width<<2)) ||
		(isp_grab_height>(isp_preview_config_data.target_height<<2)))
	{ /* grab size > taget size *4 => ISP subsample 4x */
		isp_preview_config_data.source_width=isp_grab_width>>2;
		isp_preview_config_data.source_height=isp_grab_height>>2;
	}
	else if((isp_grab_width>(isp_preview_config_data.target_width<<1)) ||
		(isp_grab_height>(isp_preview_config_data.target_height<<1)))
	{ /* grab size > taget size *2 => ISP subsample 2x */
		isp_preview_config_data.source_width=isp_grab_width>>1;
		isp_preview_config_data.source_height=isp_grab_height>>1;
	}
	else
	{
		if((isp_grab_width>=isp_preview_config_data.target_width+2)&&
			(isp_grab_height>=isp_preview_config_data.target_height+2))
		{
			isp_preview_config_data.source_width=isp_preview_config_data.target_width+2;
			isp_preview_config_data.source_height=isp_preview_config_data.target_height+2;
		}
		else
		{
			if((isp_grab_width==isp_preview_config_data.target_width)&&
				(isp_grab_height==isp_preview_config_data.target_height))
			{
				isp_preview_config_data.source_width=isp_grab_width-2;
				isp_preview_config_data.source_height=isp_grab_height-2;
			}
			else
			{
				isp_preview_config_data.source_width=isp_grab_width;
				isp_preview_config_data.source_height=isp_grab_height;
			}

		}
	}

	//Video Encode
	if((isp_grab_width>(mpeg4_encode_data.mpeg4_image_width<<2)) ||
		(isp_grab_height>(mpeg4_encode_data.mpeg4_image_height<<2)))
	{	/* grab size > taget size *4 => ISP subsample 4x */
		mpeg4_encode_data.image_source_width=isp_grab_width>>2;
		mpeg4_encode_data.image_source_height=isp_grab_height>>2;
	}
	else if((isp_grab_width>(mpeg4_encode_data.mpeg4_image_width<<1)) ||
		(isp_grab_height>(mpeg4_encode_data.mpeg4_image_height<<1)))
	{	/* grab size > taget size *2 => ISP subsample 2x */
		mpeg4_encode_data.image_source_width=isp_grab_width>>1;
		mpeg4_encode_data.image_source_height=isp_grab_height>>1;
	}
	else
	{
		if((isp_grab_width>=mpeg4_encode_data.mpeg4_image_width+2)&&
			(isp_grab_height>=mpeg4_encode_data.mpeg4_image_height+2))
		{
			mpeg4_encode_data.image_source_width=mpeg4_encode_data.mpeg4_image_width+2;
			mpeg4_encode_data.image_source_height=mpeg4_encode_data.mpeg4_image_height+2;
		}
		else
		{
			if((isp_grab_width==mpeg4_encode_data.mpeg4_image_width)&&
				(isp_grab_height==mpeg4_encode_data.mpeg4_image_height))
			{
				mpeg4_encode_data.image_source_width=isp_grab_width-2;
				mpeg4_encode_data.image_source_height=isp_grab_height-2;
			}
			else
			{
				mpeg4_encode_data.image_source_width=isp_grab_width;
				mpeg4_encode_data.image_source_height=isp_grab_height;
			}
		}
	}
#if(defined(DRV_ISP_6228_SERIES)||defined(DRV_ISP_6229_SERIES))
	ipp_preview_data.image_src_width=isp_preview_config_data.source_width;
	ipp_preview_data.image_src_height=isp_preview_config_data.source_height;
	ipp_video_encode_data.image_src_width=mpeg4_encode_data.image_source_width;
	ipp_video_encode_data.image_src_height=mpeg4_encode_data.image_source_height;
#endif
#endif

#else
	isp_yuv_digital_zoom(zoom_factor);
#endif /* YUV_SENSOR_SUPPORT */

	save_irq_mask=SaveAndSetIRQMask();
	isp_digital_zoom_flag=KAL_TRUE;
	ENABLE_CAMERA_FRAME_READY_INT;
	RestoreIRQMask(save_irq_mask);

	isp_preview_config_data.zoom_factor=isp_digital_zoom_factor;

#if (!(defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6225_SERIES)))
	apply_camera_shading_to_reg(CAMERA_COMP_PREVIEW_NORMAL_SET);
	if(camera_oper_data.preview_defect_table_enable==KAL_TRUE)
	{
		load_defect_table_para(DEFECT_MODE_PREVIEW);
		ENABLE_DEFECT_CORRECTION;
	}
	else
		DISABLE_DEFECT_CORRECTION;
#endif
	camera_process_stage|=LEAVE_ISP_DIGITAL_ZOOM;
#endif
}

/*************************************************************************
* FUNCTION
*	isp_fast_zoom_setting
*
* DESCRIPTION
*	This function start/stop fast zoom function
*
* PARAMETERS
*	zoom_data : the parameters for fast zoom in
*
* RETURNS
*	None
*
* GLOBALS AFFECTED
*
*************************************************************************/
void isp_fast_zoom_setting(isp_fast_zoom_struct zoom_data)
{
#if (defined(ISP_SUPPORT))
	isp_fast_zoom_data.start=zoom_data.start;
	isp_fast_zoom_data.zoom_in=zoom_data.zoom_in;
	isp_fast_zoom_data.zoom_limit=zoom_data.zoom_limit;
	isp_fast_zoom_data.zoom_step=zoom_data.zoom_step;
	isp_fast_zoom_data.zoom_speed=zoom_data.zoom_speed;
	fast_zoom_count=0;
	if(isp_fast_zoom_data.start==KAL_TRUE)
	{
		isp_digital_zoom_flag=KAL_TRUE;
		ENABLE_CAMERA_FRAME_READY_INT;
	}
	else	/* stop fast zoom in */
	{
#if (!(defined(DRV_ISP_6219_SERIES)||defined(DRV_ISP_6225_SERIES)))
	apply_camera_shading_to_reg(CAMERA_COMP_PREVIEW_NORMAL_SET);
	if(camera_oper_data.preview_defect_table_enable==KAL_TRUE)
	{
		load_defect_table_para(DEFECT_MODE_PREVIEW);
		ENABLE_DEFECT_CORRECTION;
	}
	else
		DISABLE_DEFECT_CORRECTION;
#endif
	}
	camera_process_stage|=LEAVE_ISP_FAST_ZOOM_SETTING;
#endif
}

kal_uint8 get_isp_digital_zoom_factor(void)
{
#if (defined(ISP_SUPPORT))
	return  isp_digital_zoom_factor;
#endif
}

kal_uint8 isp_led_setting(kal_bool light)
{
#if (!defined(DRV_ISP_6219_SERIES))
	if(image_sensor_func->set_flashlight!=0)
	{
		if(light==KAL_TRUE)
			image_sensor_func->set_flashlight(KAL_TRUE);
		else
			image_sensor_func->set_flashlight(KAL_FALSE);

		return KAL_TRUE;
	}
	else
		return KAL_FALSE;
#endif
}

/*************************************************************************
* FUNCTION
*	camera_preview_process
*
* DESCRIPTION
*	This function starts camera preview
*
* PARAMETERS
*	isp_data : the parameters for camera preview process
*

⌨️ 快捷键说明

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