?? video2video.c
字號:
/*!
==============================================================================
Video2Video
目的:驗證DAM6416P的視頻I/O功能。幫助用戶了解如何創建一個視頻應用程序。
內容:采集PAL制式的標準模擬視頻信號,并進行輸出。
運行方式:PCI方式和脫機運行方式。
運行環境:CCS2.2 or later(if any)
Copyright 2003 Wintech Digital. All Rights Reserved.
=============================================================================*/
#include <stdio.h>
#include <csl.h>
#include <std.h>
#include <sys.h>
#include <tsk.h>
#include <log.h>
#include "iekc64.h"
//
// Depending on the demo configuration (PAL/NTSC, FULL/CIF)
// prepare some constants
//
// DEMO_PAL is already defined in the compiler options
// for Debug_PAL build configuration
#ifdef PAL_DEMO_CIF
#define DEMO_STANDARD (PAL)
#define DEMO_RES (RES_PAL_CIF)
#define WIDTH (352)
#define HEIGHT (288)
#endif
#ifdef NTSC_DEMO_CIF
#define DEMO_STANDARD (NTSC)
#define DEMO_RES (RES_NTSC_CIF)
#define WIDTH (352)
#define HEIGHT (240)
#endif
#ifdef PAL_DEMO_FULL
#define DEMO_STANDARD (PAL)
#define DEMO_RES (RES_PAL_FULL)
#define WIDTH (720)
#define HEIGHT (576)
#endif
#ifdef NTSC_DEMO_FULL
#define DEMO_STANDARD (NTSC)
#define DEMO_RES (RES_NTSC_FULL)
#define WIDTH (720)
#define HEIGHT (480)
#endif
#define FRAME_SIZE_IN_PIXELS (WIDTH*HEIGHT) //frame size
// DSP/BIOS object
extern Uint32 seg_sdrama;
extern far LOG_Obj myLOG;
// Define image buffers
#define Frames_Count 4 // frames in the buffer
#define Frames_ToKeep 1 // frames to be kept in the buffer
// YUV422 pixels are 16 bits word, so Uint16
Uint16 CaptureBuffer[FRAME_SIZE_IN_PIXELS*Frames_Count]; //the capture buffer
Uint16 OutputBuffer[2][FRAME_SIZE_IN_PIXELS]; //ping-pong structure for output
Uint16* pVideoOutFrame=NULL; //output frame pointer
Uint8 outVideoIndex=0; //output frame index
// Function definition
void tsk_main(void); //main task
void simpledelay(Uint16 delay_count); //a simple delay funciton
//
// Function implementation
//
//a simple delay funciton
void simpledelay(Uint16 delay_count)
{
int i;
for (i=0;i<delay_count; i++)
{
asm(" nop ");
}
}
void main(void)
{
IEKC64_STATUS status;
TSK_Attrs attrs;
//
// Remember you should call CSL_init() first when using CSL of DSP/BIOS
//
CSL_init();
//
// This is the first API call you need
// It is mandatory to initialize the board
//
status = IEKC64_init();
if (!IEKC64_SUCCESS(status))
{
printf( "IEKC64_Init() failed with 0x%08X\n", status );
abort();
}
// Toggle the on board LEDs
// First turn off all LEDs
LED_set( BRACKET_RED, OFF );
LED_set( BRACKET_GREEN, OFF );
LED_set( ONBOARD_GREEN, OFF );
LED_set( ONBOARD_YELLOW, OFF );
LED_set( ONBOARD_RED, OFF );
// Now toggle
LED_set( ONBOARD_GREEN, ON );
simpledelay(1000);
LED_set( ONBOARD_YELLOW, ON );
simpledelay(1000);
LED_set( ONBOARD_RED, ON );
simpledelay(1000);
LED_set( BRACKET_RED, ON );
simpledelay(1000);
LED_set( BRACKET_GREEN, ON );
simpledelay(5000);
// Turn off again
LED_set( BRACKET_RED, OFF );
LED_set( BRACKET_GREEN, OFF );
LED_set( ONBOARD_GREEN, OFF );
LED_set( ONBOARD_YELLOW, OFF );
LED_set( ONBOARD_RED, OFF );
// Notice for the users!!!
// Put your application specific initialization function here!
//
// Now create the main task
attrs = TSK_ATTRS;
attrs.priority = 4;
attrs.stacksize = 9024;
attrs.stackseg = seg_sdrama;
TSK_create((Fxn)tsk_main, &attrs);
// After the main() exit, DSP/BIOS will be entered.
}
// This is the main task which will be entered after the DSP/BIOS was run
void tsk_main(void)
{
IEKC64_STATUS status;
Uint32 boardCpuClock;
Uint32 dspBiosCpuClock;
Uint32 i=0;
Uint16* temp_address1=NULL;
Uint16* temp_address2=NULL;
static Uint32 index=1;
IEKC64_VIDEOOUT videoOut = IEKC64_VIDEOOUT_DEFAULT;
IEKC64_VIDEOIN videoIn = IEKC64_VIDEOIN_DEFAULT;
// Video moudle definition
Handle hVin; // video input handle
Handle hVout; // video output handle
// Check CPU frequency configuration
// 函數的返回值為 IEKC64_cpuClock,
// 而同時*pDspBiosClock被賦予由DSP/BIOS反算得到的DSP Speed。
boardCpuClock=IEKC64_getCpuClock(&dspBiosCpuClock);
LOG_printf(&myLOG, "DSP clock frequency: %u Mhz\n", boardCpuClock);
LOG_printf(&myLOG, "DSP/BIOS clock frequency: %u Mhz\n", dspBiosCpuClock);
if(boardCpuClock != dspBiosCpuClock)
{
LOG_printf(&myLOG, "WARNING: Board clock is different from DSP/BIOS configuration file clock.\n");
// turn on the red LED to indicate the difference
LED_set( ONBOARD_RED, ON );
}
//
// Now we prepare the VIN & VOUT moudle configurations
//
videoIn.Standard=DEMO_STANDARD;
videoIn.Resolution=DEMO_RES;
videoIn.FrameFormat=YUV422PIXEL;
videoIn.VideoInSelect=COMPOSITE;
videoIn.nTemporalDecimationFactor=1;
videoIn.isOneShot=FALSE;
videoIn.nFramesInBuffer=Frames_Count;
videoIn.nFramesToKeep=Frames_ToKeep;
videoIn.pCaptureBuffer=(Uint32*)CaptureBuffer;
videoOut.Standard=DEMO_STANDARD;
videoOut.Resolution=DEMO_RES;
videoOut.FrameFormat=YUV422PIXEL;
videoOut.VideoOutSelect=COMPOSITE;
//
// Let's open VIN & VOUT
//
status = VIN_open(&videoIn,&hVin);
if (!IEKC64_SUCCESS(status))
{
LOG_printf(&myLOG, "VIN_open() failed with 0x%08X\n", status );
abort();
}
status = VOUT_open(&videoOut,&hVout);
if (!IEKC64_SUCCESS(status))
{
LOG_printf(&myLOG, "VOUT_open() failed with 0x%08X\n", status );
abort();
}
//
// Let's start video acquire & generation
//
status = VOUT_start(hVout);
if (!IEKC64_SUCCESS(status))
{
LOG_printf(&myLOG, "VOUT_start() failed with 0x%08X\n", status );
abort();
}
status = VIN_start(hVin);
if (!IEKC64_SUCCESS(status))
{
LOG_printf(&myLOG, "VIN_start() failed with 0x%08X\n", status );
abort();
}
// Init the output frame pointer
outVideoIndex=0;
pVideoOutFrame=&OutputBuffer[0][0];
LOG_printf(&myLOG, "Video2Video Example Starts!\n\n");
// The following is the simplest way to use the VIDEO moudle
// It creats a infinit loop in which a new frame is captured
// and then sent to output directly
while(1)
{
// ouput LOG information
LOG_printf(&myLOG, "Video2Video Example. Getting Video Frame index:%d !\n", index++);
// toggle the green LED
if (index%20)
LED_set( ONBOARD_GREEN, OFF );
else
LED_set( ONBOARD_GREEN, ON );
//
// Try to get a frame at input
//
status = VIN_getFrame(hVin, (void**)&temp_address1,IEKC64_VIDEO_WAIT_INFINITE);
//
// If we have it, display it
//
if (IEKC64_SUCCESS(status))
{
//
// If we have the new frame, we can process it
// For simplicity reasons, we just move the input frame data to
// the ouput frame without any processing
// Porcessing begins!
// We just move data here without any processing
temp_address2=pVideoOutFrame;
for (i=0;i<FRAME_SIZE_IN_PIXELS;i++)
*(temp_address2++) = *(temp_address1++);
// Notice for the users!!!
// Put your specific processing codes here!
//
// Porcessing ends!
// Now output the frame
VOUT_putFrame(hVout, pVideoOutFrame,IEKC64_VIDEO_NO_WAIT);
// update the index and output frame pointer
outVideoIndex=(outVideoIndex+1)%2;
pVideoOutFrame=&OutputBuffer[outVideoIndex][0];
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -