网站公告列表

  没有公告

加入收藏
设为首页
联系站长
您现在的位置: 61IC中国电子在线 >> DSP >> 代码示例 >> TI DSP代码示例 >> C6000 >> 文章正文
  验证DAM6416P的视频I/O功能代码         ★★★ 【字体:
验证DAM6416P的视频I/O功能代码
作者:61IC    文章来源:本站原创    点击数:    更新时间:2007-1-23    

验证DAM6416P的视频I/O功能,帮助用户了解如何创建一个视频应用程序。

/*!
==============================================================================
        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];
 
  }
 }

}

               欢迎点击进入:TI德州中文网   (国内唯一针对TI应用的中文技术网站)    文章录入:admin    责任编辑:admin 
  • 上一篇文章:

  • 下一篇文章:
  • 发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    最新热点 最新推荐 相关文章
    没有相关文章
      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    站长:61IC 湘ICP备05002478号