📄 videoinedgedetection_system.h
字号:
/*****************************************************************************
Copyright (c) 2006 Analog Devices, Inc. All Rights Reserved.
This software is proprietary and confidential to Analog Devices, Inc.
and its licensors.
*****************************************************************************
$RCSfile: VideoInEdgeDetection_System.h,v $
$Revision: 1.4 $
$Date: 2006/07/28 05:11:05 $
Project: BlackfinSDK (Edge Detection on ITU656 Video In)
Title: System Services defines for Edge Detection on ITU 656 Video In
Author(s): bmk
Revised by:
Description:
Defines, Data structures & Functions used for Edge Detection
on ITU656 Video In
References:
None
*****************************************************************************
Tab Setting: 4
Target Processor: ADSP-BF5xx
Target Tools Revision: ADSP VisualDSP++ v4.5
******************************************************************************
Modification History:
====================
$Log: VideoInEdgeDetection_System.h,v $
Revision 1.4 2006/07/28 05:11:05 bmk
modified code for actual NTSC resolution
Previous rev- 720 x 480, now - 720 x 486
Revision 1.3 2006/07/06 07:26:28 bmk
modified project to use video utility file macros
Revision 1.2 2006/07/04 05:33:20 bmk
added Slide-show mode for BF533
Revision 1.1 2006/06/30 01:33:55 bmk
Initial entry
*****************************************************************************/
#ifndef __VIDEOINEDGEDETECTION_SYSTEM_H__
#define __VIDEOINEDGEDETECTION_SYSTEM_H__
/*********************************************************************
Includes
*********************************************************************/
#include <services/services.h> // system services include
#include <drivers/adi_dev.h> // device manager include
#include <VideoInEdgeDetection.h> // Video In Edge Detection includes
/*********************************************************************
Typedefs & defines
*********************************************************************/
// Falgs used to manage edge Detection operation and update system functionality
typedef struct EDGE_DETECTION_SYSTEM_FLAGS {
// Sobel Edge Detection status flag (TRUE = Edge Detection complete)
volatile unsigned char SobelDone : 1;
// Video select flag (TRUE=sobel out/FALSE=original video out)
volatile unsigned char SobelEnable : 1;
// Update Video Mode flag (TRUE=update video mode)
volatile unsigned char UpdateVideoMode : 1;
// Flag to indicate whether there is any real need to update video mode
volatile unsigned char UpdateVideoFlag : 1;
// Pause Video/Frame capture flag (TRUE = Pause enable(BF561)/capture new video frame(BF533))
volatile unsigned char Pause_Frame_Capture : 1;
// Pause Video enabled or Frame capture mode - field copy done flag
volatile unsigned char FieldcopyDone : 1;
// update the video in/out buffers via Video In callback function
volatile unsigned char UpdateVideoInBufs : 1;
// update the video in/out buffers via Video Out callback finction
volatile unsigned char UpdateVideoOutBufs : 1;
// Flag to terminate(FALSE) or keep running(TRUE) the application
volatile unsigned char KeepRunningFlag : 1;
// ITU656 Video Mode (NTSC/PAL/No Video)
volatile unsigned char ITU656_Mode : 3;
} EDGE_DETECTION_SYSTEM_FLAGS;
// Flags used to manage Sobel Edge Detection buffer operation
typedef struct SOBEL_FLAGS {
volatile unsigned char InitSobelOut :1; // Flag to indicate MDMA_Sobel_Out init status
volatile unsigned char SobelInBuf0Done :1; // Sobel In Buffer0 Done flag (true indicates buffer has Video_In_Bufx luma values)
volatile unsigned char SobelInBuf1Done :1; // Sobel In Buffer1 Done flag (true indicates buffer has Video_In_Bufx luma values)
volatile unsigned char SobelOutBuf0Done:1; // Sobel Out Buffer0 Done flag (true indicates buffer has edge detected values)
volatile unsigned char SobelOutBuf1Done:1; // Sobel Out Buffer1 Done flag (true indicates buffer has edge detected values)
volatile unsigned char SobelInMDMALock :1; // Sobel In MDMA stream lock (true indicates the stream is in use)
volatile unsigned char SobelOutMDMALock:1; // Sobel Out MDMA stream lock (true indicates the stream is in use)
volatile unsigned char SobelInBufID :1; // Sobel In Buffer ID ready to copy luma values from Video_In_Buf
volatile unsigned char SobelOutBufID :1; // Sobel Out Buffer ID ready to copy luma values to Video_Out_Buf
} SOBEL_FLAGS;
// Flags used to manage Push Button trigger status
// corresponding push button related operations will start only after the button is released
typedef struct PB_TRIGGER_FLAGS {
volatile unsigned char Frame_Capture :1; // BF533 - Frame Capture Button
volatile unsigned char Video_Mode :1; // BF561 - Update Video Mode Button
volatile unsigned char Toggle_Display :1; // BF561/BF533 - Toggle display Button
} PB_TRIGGER_FLAGS;
// 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
};
/*********************************************************************
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 Defines
**********************************************************************
Push Buttons used in this application & its functionality
*********************************************************/
#if defined(__ADSPBF561__) // for ADSP-BF561 Ez-Kit Lite
// Ez-Kit button to pause video dataflow
/*** Video can be paused only in BF561 built application ***/
#define PAUSE_FRAME_CAPTURE_BUTTON ADI_FLAG_PF5 // SW6 for BF561
// Ez-Kit button to toggle video out between original image and edge detected image
#define TOGGLE_DISPLAY_BUTTON ADI_FLAG_PF6 // SW7 for BF561
// Ez-Kit button to update ITU656 Video Mode
// Press this button to synchronize input/output video mode (NTSC/PAL)
#define UPDATE_VIDEO_MODE_BUTTON ADI_FLAG_PF7 // SW8 for BF561
// Ez-Kit button to terminate this app
#define TERMINATE_BUTTON ADI_FLAG_PF8 // SW9 for BF561
#elif defined(__ADSPBF533__) // for ADSP-BF533 Ez-Kit Lite
// Ez-Kit button to capture a frame for Edge detection
#define PAUSE_FRAME_CAPTURE_BUTTON ADI_FLAG_PF8 // SW4 for BF533
// Ez-Kit button to toggle video out between original image and edge detected image
#define TOGGLE_DISPLAY_BUTTON ADI_FLAG_PF10 // SW6 for BF533
// Ez-Kit button to terminate this app
#define TERMINATE_BUTTON ADI_FLAG_PF11 // SW7 for BF533
#endif
#if defined(__ADSPBF533__) // for ADSP-BF533 Ez-Kit Lite
// delay in milliseconds to stabilise 7183 after reset
#define ADV7183_DELAY 500
#if defined(VIDEO_IN_SLIDE_SHOW) // Conditional compilation macro to enable slide show mode
#define FRAME_CAPTURE_FREQUENCY 35 // captures new frame after # frames (add ADV7183_DELAY with capture time)
#endif
#endif
/*********************************************************************
Function prototypes
*********************************************************************/
/**** Initialization Functions ****/
void InitSystem (void); // Initialises EZ kit & Video Parameters
void InstallSystemServices (void); // Installs system services
void InstallVideoEncoder (void); // Installs video encoder (ADV717x)
void InstallVideoDecoder (void); // Installs video decoder (ADV7183)
/**** Video Mode/Buffer Management Functions ****/
void Format_Video_Out_Frames (void); // Formats Sobel video out frame buffers to specified video mode
void UpdateVideoMode (void); // Updates Video input mode
void UpdateADV717xVideoMode (void); // Updates ADV717x operating video mode
/**** Functions to handle video dataflow ****/
void EnableVideoIn ( // Enables/Disables video in
bool dataflow // TRUE(Enable)/FALSE(disable) dataflow
);
void EnableVideoOut ( // Enables/Disables video out
bool dataflow // TRUE(Enable)/FALSE(disable) dataflow
);
/**** Functions to handle Video Buffers ****/
void SubmitVideoOutBuffers (void); // Prepares & submits Video Output buffers
void SubmitVideoInBuffers (void); // Prepares & submits Video Input buffers
/**** Functions to handle MDMA ****/
void ConfigureMDMA (void); // Configures MDMA for sobel edge detection
/**** Sobel Edge Detection Functions ****/
void SobelInInit ( // Start Vedio In to Sobel In buffer streaming
u32 *pBuffer // address of Video_In_Buf to be used for Edge Detection
);
void do_SobelEdgeDetection (void); // Performs Sobel Edge detection on Video In Frame
/**** 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 ButtonPressed ( // Ez-Kit Button press callback service routine
void *AppHandle, // Application Handle
u32 Event, // Event that generated callback
void *pArg // client handle
);
/**** Termination functions ****/
void TerminateSystem (void); // Function to terminate this app
void CloseMDMA_Streams (void); // Closes MDMA streams
/*********************************************************************
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 ADV7183 device driver
extern ADI_DEV_DEVICE_HANDLE ADV7183DeviceHandle;
// handle to the ADV717x device driver
extern ADI_DEV_DEVICE_HANDLE ADV717xDeviceHandle;
/*****************************************
Variables
*****************************************/
// System flags
extern EDGE_DETECTION_SYSTEM_FLAGS SystemFlag;
// pointer to paused video 2D buffer
extern volatile u32 *pPausedBuffer;
// System flags for Push Button Trigger status
extern PB_TRIGGER_FLAGS PBFlag;
/*****************
Video parameters
*****************/
// Video data per line (bytes)
extern u32 DataPerLine;
// Number of lines per ITU656 video frame (bytes)
extern u32 FrameLines;
// 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;
// Sobel buffer row size (for valid Edge Detected data only)
extern u16 SobelRowSize;
// ITU656 video frame - Active field spilt to # number of blocks
extern u8 SobelFieldBlocks;
// Number of Sobel Blocks for ITU656 video frame
extern u16 SobelBlockCount;
#if defined(__ADSPBF533__)
#if defined(VIDEO_IN_SLIDE_SHOW) // Conditional compilation macro to enable slide show mode
// count to compare frame capture frequency
extern u32 SlideShowFrameCount;
#endif
#endif
#endif // __VIDEOINEDGEDETECTION_SYSTEM_H__
/*****/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -