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

📄 jpeg_mjpeg_system.c

📁 这个是balckfin533/561的MPEG和Mjpeg的源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
	
	return;
}

/*********************************************************************

	Function:		ResetVideoCodecs

	Description:	Resets video codec hardware

*********************************************************************/
section("sdram0_bank1_cache")
void ResetVideoCodecs (void)
{ 
	       
    // for Decode mode, Disable video decoder and Enable video encoder
    if (Coding_Action == CODING_ACTION_DECODE)
    {
// For BF533 & BF561, pull the video encoder from reset mode
#if defined (__ADSPBF533__) || defined (__ADSPBF561__)
		
    	// Disable video decoder (ADV7183)
		printf ("Disabling Video Decoder (ADV7183)...\n");
    	ezDisableVideoDecoder();
		// Enable video encoder (ADV717x)
		printf ("Enabling Video Encoder (ADV717x)...\n\n");		
		ezEnableVideoEncoder();
		// Delay to allow codecs to sync
		printf ("Waiting for codecs to synchronize...\n\n");
   		ezDelay (VIDEO_CODEC_SYNC_DELAY);	     
   		
#else
#error "*** ERROR: Application doesnot support this processor ***"
#endif
    }
    // for Encode mode, Disable video encoder and Enable video decoder
    else if (Coding_Action == CODING_ACTION_ENCODE)
    {
// For BF533 & BF561, pull the video decoder from reset mode
#if defined (__ADSPBF533__) || defined (__ADSPBF561__)
    	// Disable video encoder (ADV717x)
    	printf ("Disabling Video Encoder (ADV717x)...\n");
    	ezDisableVideoEncoder();	
		// Enable video decoder (ADV7183)
		// Delay to allow codecs to sync (for BF561 - ezEnableVideoDecoder function has a delay loop to sync codecs)
		printf ("Enabling Video Decoder (ADV7183)...\n\n");
		printf ("Waiting for codecs to synchronize...\n\n");		
		ezEnableVideoDecoder();
		
#if defined (__ADSPBF533__)
// BF533 - Application should provide delay to sync video codecs.
   		ezDelay (VIDEO_CODEC_SYNC_DELAY);		
#endif
   		
#else
#error "*** ERROR: Application doesnot support this processor ***"
#endif
    }

	return;
}
/*********************************************************************

	Function:		PerformIO

	Description:	Performs USB I/O

*********************************************************************/
section("sdram0_bank1_cache")
u32	PerformUSBIO()
{
    u32	Result = ADI_DEV_RESULT_SUCCESS;
	int	Codec_return_value = CODEC_SUCCESS;

	// Set USB as default I/O device
	Result = ConfigUSB_IO(USBDeviceHandle);
		
	// continue only if USB IO config is a success
	if (Result == ADI_DEV_RESULT_SUCCESS)
	{
		// Switch to selected coding algorithm
		switch (Coding_Algorithm)
		{
			// Case (select algorithm is JPEG)	
			case CODING_ALGORITHM_JPEG:
				// check the coding action
				if (Coding_Action == CODING_ACTION_DECODE)
					Codec_return_value = do_JPEG_Decode();	// start JPEG decoding
				else
					Codec_return_value = do_JPEG_Encode();	// start JPEG encoding
				break;
				    
	    	// Case (select algorithm is MJPEG)
			case CODING_ALGORITHM_MJPEG:
				// check the coding action
				if (Coding_Action == CODING_ACTION_DECODE)
					Codec_return_value = do_MJPEG_Decode();	// start MJPEG decoding
				else
					Codec_return_value = do_MJPEG_Encode();	// start MJPEG encoding
				break;
			
			default:
				fprintf( fperr, "Error: Invalid coding parameters\n" );
				break;
		}

		// Check if JPEG-MJPEG Encode/Decode operation is result
		if (Codec_return_value) 
			fprintf(fperr, "Codec aborted abnormally\n");

		// Done with JPEG-MJPEG Encoding/Decoding. Stop USB I/O
    	StopUSB_IO (USBDeviceHandle);
	}
	
	return (Result);
}

/*********************************************************************

	Function:		SetCodecParameters

	Description:	Set Device (Codec) parameters in relevance to
					selected user option

*********************************************************************/
section("sdram0_bank1_cache")
u32	SetCodecParameters (u32 *UserOptions)
{
    
	u32	Result = ADI_DEV_RESULT_SUCCESS;	// default return code

    // switch user option
    switch ((char)UserOptions[0])
    {
        // Case (JPEG Decoding)
        case '1':
        // Case (MJPEG Decoding)
        case '2':
        
        	// Decode JPEG/MJPEG file(s)
			Coding_Action = CODING_ACTION_DECODE;
			
			// JPEG or MJPEG ?
			if ((char)UserOptions[0] == '1')
				// Decode JPEG file(s)
				Coding_Algorithm = CODING_ALGORITHM_JPEG;
			else
				// Decode MJPEG file(s)
				Coding_Algorithm = CODING_ALGORITHM_MJPEG;
				
			// Video output mode?
			if ((char)UserOptions[2] == '1')
				// NTSC video out
				OutputVideoMode = ITU656_NTSC;
			else if ((char)UserOptions[2] == '2')
				// PAL video out
				OutputVideoMode = ITU656_PAL;
			else
				// default as NTSC video out
				OutputVideoMode = ITU656_NTSC;

			// JPEG/MJPEG Decoder file settings?
			if ((char)UserOptions[4] == '1')
				// Prompt for file location & settings
				File_Settings = PROMPT_FOR_FILE_SETTINGS;
			else if ((char)UserOptions[4] == '2')
				// Retrieve settings from '.txt' files under project directory
				File_Settings = GET_FILE_SETTINGS_FROM_TXT_FILE;
			else
				// Retrieve settings from '.txt' files under project directory
				File_Settings = GET_FILE_SETTINGS_FROM_TXT_FILE;
				
			break;
			
		// Case (JPEG Encoding)
        case '3':
        // Case (MJPEG Encoding)
        case '4':

        	// Encode to JPEG/MJPEG file
			Coding_Action = CODING_ACTION_ENCODE;
			
			// JPEG or MJPEG ?
			if ((char)UserOptions[0] == '3')
				// Encode to JPEG file
				Coding_Algorithm = CODING_ALGORITHM_JPEG;
			else
				// Encode to MJPEG file
				Coding_Algorithm = CODING_ALGORITHM_MJPEG;
				
			// Video source?
			if ((char)UserOptions[1] == '1')
				// ITU656 video input (this app only supports ITU656 input)
				{}
			
			// JPEG Encoder settings?
			if ((char)UserOptions[3] == '2')
				// Encode video/image to YUV 420 format
				JPEGFrameFormat = 1;	// YUV 420 format - will be sent to JPEG Encoder library
			else
				// default to encode video/image to YUV 420 format
				JPEGFrameFormat = 1;	// YUV 420 format - will be sent to JPEG Encoder library

			// JPEG/MJPEG Encoder file settings?
			if ((char)UserOptions[4] == '1')
				// Prompt for file location & settings
				File_Settings = PROMPT_FOR_FILE_SETTINGS;
			else if ((char)UserOptions[4] == '2')
				// Retrieve settings from '.txt' files under project directory
				File_Settings = GET_FILE_SETTINGS_FROM_TXT_FILE;
			else
				// Retrieve settings from '.txt' files under project directory
				File_Settings = GET_FILE_SETTINGS_FROM_TXT_FILE;
						
			break;
		
		default:
			Result = ADI_DEV_RESULT_FAILED;
			break;
    }
   
    return (Result);
}				
        
/*********************************************************************

	Function:		ExceptionHandler
					HWErrorHandler

	Description:	We should never get an exception or hardware error,
					but just in case we'll catch them and simply turn
					on all the LEDS should one ever occur.

*********************************************************************/
section("sdram0_bank1_nocache")
static ADI_INT_HANDLER(ExceptionHandler)	// exception handler
{
	printf("\nException Error occured!\n");
	ezTurnOnAllLEDs();
	while (1) ;
}

section("sdram0_bank1_nocache")
static ADI_INT_HANDLER(HWErrorHandler)		// hardware error handler
{
	printf("\nHardware Error occured!\n");
	ezTurnOnAllLEDs();
	while (1) ;
}

/*********************************************************************

    Function:       VideoInCallback

    Description:    Video In callback function (ADV7183)

*********************************************************************/
section ("Callback_Code")
static void VideoInCallback(
	void *AppHandle,
	u32  Event,
	void *pArg
){         
	// Call corresponding service routine   
	VideoIn(AppHandle,Event,pArg);
	return;
}

/*********************************************************************

    Function:       VideoOutCallback

    Description:    Video Out callback function (ADV717x)

*********************************************************************/
section ("Callback_Code")
static void VideoOutCallback(
	void *AppHandle,
	u32  Event,
	void *pArg
){         
	// Call corresponding service routine   
	VideoOut(AppHandle,Event,pArg);
	return;
}

/*********************************************************************

	Function:		NET2272_Callback

	Description:	USB I/O callback function for Net2272 device

*********************************************************************/
section ("Callback_Code")
static void NET2272_Callback(
	void 	*AppHandle,
	u32  	Event,
	void 	*pArg
){
    // Call corresponding service routine   
	USB_Callback(AppHandle,Event,pArg);
	return;
}	

/*****/

⌨️ 快捷键说明

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