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

📄 jpeg_mjpeg_system.h

📁 这个是balckfin533/561的MPEG和Mjpeg的源代码
💻 H
字号:
/*****************************************************************************
Copyright(c) 2005 Analog Devices, Inc.  All Rights Reserved. This software is 
proprietary and confidential to Analog Devices, Inc. and its licensors.
******************************************************************************

$RCSfile: jpeg_mjpeg_system.h,v $
$Revision: 1.3 $
$Date: 2006/11/03 07:12:08 $

Project:	BlackfinSDK (JPEG-MJPEG)
Title:		System defines
Author(s):	bmk
Revised by:

Description:
			System level definitions for JPEG-MJPEG

References:
			

******************************************************************************
Tab Setting:			4
Target Processor:		ADSP-BF5xx
Target Tools Revision:	ADSP VisualDSP++ v4.5
******************************************************************************

Modification History:
====================
$Log: jpeg_mjpeg_system.h,v $
Revision 1.3  2006/11/03 07:12:08  bmk
SDK 2.0  files - Initial Entry

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

#ifndef __JPEG_MJPEG_SYSTEM_H__
#define __JPEG_MJPEG_SYSTEM_H__

#include <cplb.h> 					// Required for caching
#include <stdlib.h>					// display results
#include <stdio.h>					// I/O includes
#include <services/services.h>		// system service includes
#include <drivers/adi_dev.h>		// device manager includes
#include <SDK-ezkitutilities.h>		// EZ-Kit utility includes
#include <adi_itu656.h>				// ITU656 video utility includes

/****************************************************
Macros
****************************************************/

#define DO_CYCLE_COUNTS 			// Debug Macro to enable cycle measurements

/****************************************************
Max Allowable Image Sizes

The decoder will process any image or motion sequence 
up to this size, but display only the portion that fits 
on the screen. The YUV buffer will contain the entire image. 
The defines below are only due to memory usage.
You may increase them as you wish.
		
Maximum encodeable/decodeable JPEG file size for 
this app would be PAL video sized image. Images larger 
than display resolution will be clipped.

For MJPEG, maximum file size and quality factor 
(for both decoding & encoding) depends on processor 
DMA bus size. Please refer JPEG-MJPEG reference documents 
for more information.
****************************************************/
// YUV buffer size is set to decode files upto SVGA resolution (which includes padding)
#define		MAX_JPEG_IMAGE_WIDTH		800
#define		MAX_JPEG_IMAGE_HEIGHT		608

// Number of YUV Buffers used (JPEG uses only 1, MJPEG uses all)
#define		NUM_YUV_BUFS				4
// size of a single YUV Buffer
// size to support only selected ITU656 frame & YUV400/YUV420/YUV422 image format
#define		SINGLE_YUV_BUF_SIZE			(MAX_JPEG_IMAGE_WIDTH * MAX_JPEG_IMAGE_HEIGHT * 2)
// YUV buffer size (includes all YUV buffers used in this app)
#define		YUV_BUF_SIZE				(SINGLE_YUV_BUF_SIZE * NUM_YUV_BUFS)

// Number of 2D video out buffers used
#define 	NUM_VIDEO_OUT_BUFS			2
// Number of 2D video in buffers used
#define 	NUM_VIDEO_IN_BUFS			2
// ITU656 Buffer size
// Maximum size alocated (as PAL frame)
#define		ITU656_BUF_SIZE				PAL_VIDEO_FRAME_SIZE

// ITU656 Video Frame Rate
#define		ITU656_NTSC_FRAME_RATE		30
#define		ITU656_PAL_FRAME_RATE		25

// Delay (in milli seconds) to allow video codecs to synchronize
#define		VIDEO_CODEC_SYNC_DELAY		500

// MDMA channels for YUV <-> video (ITU656) frame conversion
#if defined(__ADSPBF561__)		// for BF561

// MDMA 1 in DMA controller 1
#define	YUV_ITU656_MDMA_SRC_CHANNEL		ADI_DMA_MDMA1_S1
#define	YUV_ITU656_MDMA_DEST_CHANNEL	ADI_DMA_MDMA1_D1

#elif defined(__ADSPBF533__)	// for BF533

// MDMA for BF533
#define	YUV_ITU656_MDMA_SRC_CHANNEL		ADI_DMA_MDMA_S1
#define	YUV_ITU656_MDMA_DEST_CHANNEL	ADI_DMA_MDMA_D1

#endif

// Processor DMA bus size
#if defined(__ADSPBF561__)
// 4 bytes (PPI uses DMA0 & BF561 DMA0 bus size is 32bits)
#define	DMA_BUS_SIZE					4
#elif defined(__ADSPBF533__)
// 2 bytes (PPI uses DMA & BF533 DMA bus size is 16bits)
#define	DMA_BUS_SIZE					2
#endif

/****************************************************
Ez-Kit push button(s) for JPEG-MJPEG
****************************************************/
// Push button to capture incoming video & encode it to JPEG/MJPEG File
#if defined(__ADSPBF533__)

#define JPEG_MJPEG_RECORD_BUTTON 		0		// SW4 for BF533
#define JPEG_MJPEG_REC_BUTTON_ID 		"SW4"

#elif defined(__ADSPBF561__)

#define JPEG_MJPEG_RECORD_BUTTON 		0		// SW6 for BF561
#define JPEG_MJPEG_REC_BUTTON_ID 		"SW6"

#endif

/****************************************************
JPEG-MJPEG file paths on host 
****************************************************/
// note that these paths are relative to the location of the host application
// path to where JPEG images are installed
#define		ROOT_DIR 					"..\\"
// jpeg file(s) location
#define     IMAGE_DIR_JPEG	        	"Media\\JPEG\\"	
// motion jpeg file(s) location
#define     IMAGE_DIR_MJPEG	       	 	"Media\\MJPEG\\"

// list of *.avi files to decode
#define		MJPEG_LIST_FILE         	"mjpeg_list.txt"
// MJPEG (*.avi) encoder "specification" file
#define     MJPEG_SPEC_FILE         	"mjpeg_encoder_spec.txt"
// list of *.avi files to decode
#define     JPEG_LIST_FILE          	"jpeg_list.txt"
// JPEG encoder "specification" file
#define     JPEG_SPEC_FILE          	"jpeg_encoder_spec.txt"
// above 'txt' files location
#define     SPEC_DIR		        	"..\\Multimedia\\JPEG-MJPEG\\"

#define     MAX_FILE_NAME_LEN					100
#define     MAX_PATH_NAME_LEN					300

#define		PROMPT_FOR_FILE_SETTINGS			1
#define		GET_FILE_SETTINGS_FROM_TXT_FILE		2

/******************************************************
Device (Codec) parameters
******************************************************/

enum						// supported coding algorithm(s)
{
	CODING_ALGORITHM_JPEG,	// Jpeg
	CODING_ALGORITHM_MJPEG	// Motion Jpeg
};

enum 						// coding action
{
	CODING_ACTION_ENCODE,	// Encoding
	CODING_ACTION_DECODE	// Decoding
};

// ITU656 Video Modes supported by this application
enum
{
    NO_VIDEO_INPUT,		// No Video Input detected
    ITU656_NTSC,		// NTSC Interlaced Video
    ITU656_PAL,			// PAL Interlaced Video
};

/******************************************************
Globals
******************************************************/
// Device Driver and System Services Handles
// handle to the callback service Manager
extern	ADI_DCB_HANDLE					DCBManagerHandle;
// handle to the DMA Manager
extern	ADI_DMA_MANAGER_HANDLE 			DMAManagerHandle;
// handle to the Device Manager
extern	ADI_DEV_MANAGER_HANDLE 			DeviceManagerHandle;
// handle to the ADV717x device driver
extern	ADI_DEV_DEVICE_HANDLE 			ADV717xDeviceHandle;	
// handle to the ADV717x device driver
extern	ADI_DEV_DEVICE_HANDLE 			ADV7183DeviceHandle;
// handle to the USB device driver
extern	ADI_DEV_DEVICE_HANDLE 			USBDeviceHandle;	

// Video parameters
// Video data per line (bytes)
extern u32	DataPerLine;
// Number of lines per ITU656 video frame (bytes)
extern u32	FrameLines;
// Number of Active lines per ITU656 video frame (bytes)
extern u32	ActiveFrameLines;
// Number of bytes to skip to reach active video data in a single line
extern u32	ActiveVideoSkip;
// Number of bytes to skip to reach active video frame field1 (odd frame)
extern u32	Field1Skip;
// Number of bytes to skip to reach active video frame field2 (even frame)
extern u32	Field2Skip;
// Video Input/Output mode
extern u8	VideoMode;
// Selected Video Output mode
extern u8	OutputVideoMode;

// coding parameters
extern u8 	Coding_Algorithm;	// coding algorithm (JPEG/MJPEG)
extern u8 	Coding_Action;		// coding action (Encode/Decode)
extern u8 	File_Settings;		// JPEG/MJPEG Encoder/Decoder file settings

// Buffer pointers
// Pointer to buffers containing YUV data of decoded JPEG image 
extern u8 	*pYUVBufs[];
// Pointer to buffers containing JPEG/MJPEG image in ITU656 frame format
extern u8 	*pITU656Frames[];

// YUV <-> ITU656 conversion parameters
extern u32				JPEGImageWidth;		// Actual width of JPEG image to be encoded/decoded
extern u32				JPEGImageHeight;	// Actual height of JPEG image to be encoded/decoded
extern unsigned int		JPEGFrameFormat;	// Frame format of decoded JPEG/MJPEG file
// Pointer to Video frame /YUV buffer ready for YUV <-> Video frame (ITU656) conversion (to update MDMA source descriptor)
extern volatile u8		*pSrcDescStartAddr;
// Pointer to YUV/Video frame buffer ready for YUV <-> Video frame (ITU656) conversion (to update MDMA destination descriptor)
extern volatile u8		*pDestDescStartAddr;

// Semaphores used for handshaking btwn ISR and foreground code.
extern volatile bool	StartMDMA;				// controls MDMA used for YUV <-> ITU656 conversion
extern volatile bool	FrameReady;				// TRUE when a video frame is ready to display
extern volatile u8		BufferLevel;			// # of YUV buffers filled with YUV data and ready for processing
extern volatile u8		YUV_MDMA_BufID;			// next YUV buffer to be processed by MDMA (YUV buffer corresponding to this ID)
extern volatile u8		MJPEG_YUV_BufID;		// next YUV buffer to be used by MJPEG encoder/decoder(YUV buffer corresponding to this ID)
extern volatile u32   	VideoFrameCounter;		// # frames received/transmitted by PPI
extern volatile u32 	FrameDroppedCounter;	// # frames dropped while encoding/decoding MJPEG files
extern volatile bool	VideoFrameCompletedFlag;// TRUE when PPI is done capturing a video frame
extern volatile bool 	isMJEInputDataAvailable;// is data available for MJPEG encoder?
extern volatile bool 	isMJDInputDataAvailable;// is data available for MJPEG decoder?

// JPEG Frame background
extern char	JPEGImageBackground[];

/*************************
Function Prototypes
*************************/

/*** Initialization Functions ***/
void 	InitSystem						(void);			// Initialises EZ kit & system parameters
void 	InstallMemory					(void);			// Initialises & calls Cache/Heap install for JPEG
void 	InstallSystemServices			(void);			// Installs system services (like DMA, Callback etc.,)
void 	InstallVideoEncoder				(void);			// Installs video encoder (ADV717x)
void 	InstallVideoDecoder				(void);			// Installs video decoder (ADV7183)
int 	InstallCodecHeaps				(void);			// Installs Heap
void 	ResetVideoCodecs				(void);			// Reset video codecs

/**** JPEG/MJPEG image handling functions ****/
int 	do_JPEG_Decode					(void);			// File Handling JPEG decoding
int 	do_JPEG_Encode					(void);			// File Handling JPEG encoding
int 	do_MJPEG_Decode					(void);			// File Handling MJPEG decoding
int 	do_MJPEG_Encode					(void);			// File Handling MJPEG encoding

/**** USB I/O functions ****/
u32		PerformUSBIO					(void);			// Performs USB I/O
u32		SetCodecParameters 				(				// Set Device parameters in relevance to selected user option
		u32 							*UserOptions	// pointer to array of user selected options
);	

/*** YUV <-> ITU656 conversion (MDMA) functions ***/
void 	SetupMDMA_YUV_ITU656 			(void);			// Initialises Descriptors for MDMA (for YUV <-> ITU656 conversion)
void	SetupMDMA_YUV420toITU656 		(void);			// Configures MDMA Descriptors for YUV420 to ITU656 conversion
void	SetupMDMA_ITU656toYUV420 		(void);			// Configures MDMA Descriptors for ITU656 to YUV420 conversion
void 	Update_MDMA_DescAddr			(void);			// Update source & destination Descriptor addresses for YUV <-> video (ITU656) frame conversion
void	UpdateInputVideoMode			(void);			// Automatically updates Input Video mode
void 	KickOffMDMA_YUV_ITU656			(void);			// Kicks off MDMA for YUV <-> ITU656 frame conversion
void 	FreeMDMA_YUV_ITU656				(void);			// Frees MDMA channels used for YUV <-> ITU656 conversion

/**** Functions to handle Video Buffers ****/
void	SubmitVideoOutBufs				(void);			// Prepares & submits Video Output buffers
void	SubmitVideoInBufs				(void);			// Prepares & submits Video Input buffers

/**** Service routines for System service Callbacks ****/
void 	VideoIn							(				// Video In callback service routine
		void 							*AppHandle, 	// Application Handle
		u32  							Event,			// Event that generated callback
		void 							*pArg			// client handle
);
void 	VideoOut						(				// Video Out callback service routine
		void 							*AppHandle, 	// Application Handle
		u32  							Event,			// Event that generated callback
		void 							*pArg			// client handle
);
void 	USB_Callback					(				// Net2272 callback service routine
		void 							*AppHandle, 	// Application Handle
		u32  							Event,			// Event that generated callback
		void 							*pArg			// client handle
);

#endif // __JPEG_MJPEG_SYSTEM_H__

/*****/

⌨️ 快捷键说明

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