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

📄 dca200f.cpp

📁 Vxworks 下的视频采集程序
💻 CPP
字号:
#include <stdio.h>
#include <stdlib.h>
//#include <conio.h>  
//#include <malloc.h> 
#include <string.h>
#include "xdefine.h"
#include "pci.h" 
#include "DCA200f.h" 
#include "readini.h"
#include "w99200f.h" 

// Register Test
extern BOOL W99200WriteReg(int index, int value);

void LVE(void);// Live video encoding
void LVPT(void);// Live video pass through  
void LVSS(void);// Live video snap shot
void SFE(void);// Single frame encoding
void WFR(void);// Write a frame
void RFR(void);// Read a frame  
void AUDIOFIFO(void); // 11/18 Adding
void RSDram(void);
void WSDram(void);

// UTL Function
extern BOOL UTL_LVE(char *szFileName, int dwLimit, int iUseMaster);//iUsemaster=1: Master mode, otherwise is not master mode
extern BOOL UTL_LVPT(void);  
extern BOOL UTL_LVSS(int);
extern BOOL UTL_SFE(int Size_H, int Size_V,int Compress);
extern BOOL UTL_WFR(int Size_H, int Size_V);
extern BOOL UTL_RFR(int Size_H, int Size_V); 
extern BOOL UTL_AUDIOFIFO(char *szFileName, int dwLimit);
extern BOOL UTL_LE(char *szVideoFileName, char *szAudioFileName, int dwLimit, int iUseMaster);

char input_file[60];
char output_file[60];

// 5/6 otis adding
                       
// For SFE Parameters;
int _SFE_FrameSizeX;
int _SFE_FrameSizeY;
char  _SFE_InFileName[60]; 
char  _SFE_OutFileName[60];  


// For LVE Parameters
int _LVE_PictureResoultion=1; // Reg:Video_Format
int _LVE_RC_Mtehod=0; //Constant BitRate
int _LVE_Bitrate=1024000;
int _LVE_Duration=5; // 5 Seconds 
char  _LVE_OutFileName[60];
  
// For Common Parameters
int _CaptureType;
int _CompressMethod;
int _Quality=1;
int _VideoStard=0; //NTSC:0 ; PAL:2, SQUARE:1


// For SA7113 / SA7114
int iSA;                      
//***********************************************************************
//   (C)Copyright WINBOND ELECTRONICS CORP. 1995, L340, all right reserved
//   Product  :DOS Capture Application Program for W99200F
//   Boards   :
//   Chips    :W99200F
//   Date     :1999/3/22
//   Author   :Winbond(PH31 WYM)
//   Purpose  :Perform Capture Video 
//   Sources  :DCA200F.cpp
//             pci.h DCA200F.h
//***********************************************************************

//***********************************************************************
//  (C)Copyright Advanced Micro Peripherals Ltd 2001
//  Modifications: Added command line parameters to record to given filename
//                 removed SA7113 code
//                 added function to record audio and video at the same time
//                 removed batch testing                    
    
void DCA200F(int argc, char *argv[])
{
  char cKey;
  int iExit=0; 
  BOOL bRes; 
  int nTemp;
  char szFileName[20]="";
  int nLimit=0;
  BOOL bAudio=FALSE;


  for (nTemp=1;nTemp<=argc-1;nTemp++)
  {

    if (strcmp(argv[nTemp],"/P")==0)
    {
        _VideoStard=2;
    }
    else if (strcmp(argv[nTemp], "/L")==0)
    {
        nTemp++;
        nLimit=atoi(argv[nTemp]);
    }        
    else if (strcmp(argv[nTemp], "/B")==0)
    {
        nTemp++;
        _LVE_Bitrate=atoi(argv[nTemp]);
    }        
    else if (strcmp(argv[nTemp], "/A")==0)
    {
        bAudio=TRUE;
    }
    else if (nTemp==1)  //must be filename
    {
        strcpy(szFileName,argv[nTemp]);
    }

  }
 
  // Start To Detect Mpeg1000
  if ( !PCI_BIOSPresent () )
  {
     printf ( "Cannot detect PCI bios\n" );
     return;
  }                                  
  PCI_SetDeviceIndex (0);  
  // GetDevice
  if ( PCI_GetDevice ( (UINT)DeviceID,VendorID ) )
  {
     unsigned long ulTmp;
        // Get the I/O base port
     if ( PCI_GetIOBase(&ulTmp)==FALSE)
        printf ( "\nGetIOBase Error,,;");
     _IOBase = ulTmp;
  }
  else
  {
     printf ( "Cannot find device\n" );    
     return;
  }  
  // Enddinf for Detect W99200F PCI Board
  
  iSA=2;   
  
  W99200WriteReg( PCR,0x60 ); 
  W99200WriteReg(Vint_enable, 0x00);// 6/25 close all interrupt
  
  if (argc>1)
  {
//        strcpy(szFileName,argv[1]);
    if (strcmp(szFileName,"")!=0) //a filename has been given
    {
      if (bAudio)
        bRes=UTL_AUDIOFIFO(szFileName, nLimit);      
      else
        bRes=UTL_LVE(szFileName, nLimit,1);
      if (bRes)
        printf("Successful capture\n");
      else
        printf("capture failed\n");
        return;
    }
  }  
                         
  printf(" \n ********** DOS CAPTURE APPLICATION FOR MPEG1000 ********** ");  
  printf ( TESTITEMS ); 
  printf (" \n Please Select Test Item -> ");
  while (1)
  {
    cKey =getchar();
    switch (cKey)
    {
      case '1':LVE();  
               break;
      case '2':LVPT();  
               break;
      case '3':LVSS();
               break; 
      case '4':SFE();
               break; 
      case '5':WFR();
               break;
      case '6':RFR();
               break;
      case '7': UTL_LE("video.mpg", "audio.pcm", 0, 1);
                break;

      case '8':AUDIOFIFO(); // 11/18 Adding
               break;                                                                  
      case '0':iExit=1;  
               break;
      default :printf (" \n Incorrect input! ");   
               break;                    
    }// end switch(cSelect) 
    if ( iExit==1)
       break; 
    printf ( TESTITEMS ); 
    printf (" \n Please Select Test Item -> ");    
  } // end while (1)
}


 
//**************************************************************************
//    Function    :LVE
//    Description :Live video encoding
//    Return      :None
//************************************************************************** 
void LVE()// Live video encoding
{ 
  BOOL bRes;
  int Use_Master=2; 
  strcpy(_LVE_OutFileName,"LVE.MPG");
  printf (" \n Use Master Mode (1) Yes (2) No -> "); // 6/17 adding  
  scanf("%d",&Use_Master);  
  bRes=UTL_LVE(_LVE_OutFileName, 0,Use_Master);
  if ( bRes== FALSE)
     printf("\n Live video encoding: error !!!");
}   

//**************************************************************************
//    Function    :LVPT()
//    Description :Live video pass through
//    Return      :None
//************************************************************************** 
void LVPT()
{     
  BOOL bRes; 
  bRes=UTL_LVPT(); 
  if ( bRes== FALSE)
     printf("\n Live video pass through: error !!!");
} 

//**************************************************************************
//    Function    :LVSS()
//    Description :Live video snap shot
//    Return      :None
//**************************************************************************  
void LVSS()
{ 
  BOOL bRes; 
  int iSize;
  int dH,dV;
  int iCop;
  
  dH=dV=0x00;
  printf (" \n ***** Live video snap shot ***** ");
  if ( _VideoStard == 0 ) // NTSC  
    printf ( "\n Please Select the Video Format(NTSC) < 0 ->Full(704*480); 1 ->SIF(352*240); 2 ->QSIF(176*112) >: ");
  else
    printf ( "\n Please Select the Video Format(PAL) < 0 ->Full(704*576); 1 ->SIF(352*288); 2 ->QSIF(176*144) >: ");
  scanf("%ld",&iSize);
  if ( iSize == 0 )
    bRes=UTL_LVSS(0);
  else  if (  iSize == 1 )
    bRes=UTL_LVSS(1);
  else
    bRes=UTL_LVSS(2);
  if ( bRes== FALSE)
  { 
     printf("\n Live video snap shot: error !!!");
     return;
  }
  //  Single frame encoding
  printf ( "\n Please Select the Compress Method<YUV -> 0 ; MPEG -> 1 ; JPEG -> 2 >: ");
  scanf("%ld",&iCop);
  if ( (iCop != 1) && (iCop !=2 ) && (iCop !=0 ))
  {
     printf("\n Input Error !!!");
     return ; 
  }
  printf ( "\n Please Input the Encoded File Name ---> ");
  scanf("%s",_SFE_OutFileName); 
  if ( _VideoStard == 0 ) // for NTSC
  {
    if ( iSize == 0 )
    {
        dH=704;
        dV=480;
    }
    else if (  iSize == 1 )
    {
        dH=352;
        dV=240;
    }
    else
    {
        dH=176;
        dV=112;
    }
  }
  else // for PAL
  {
     if ( iSize == 0 )
    {
        dH=704;
        dV=576;
    }
    else if (  iSize == 1 )
    {
        dH=352;
        dV=288;
    }
    else
    {
        dH=176;
        dV=144;
    }
  }
  if ( iCop == 0) 
    UTL_RFR(dH,dV); //YUV data
  else
    bRes=UTL_SFE(dH,dV,iCop);
}

//**************************************************************************
//    Function    :SFE()
//    Description :Single frame encoding 
//    Return      :None
//**************************************************************************  
void SFE() 
{ 
  BOOL bRes; 
  int dH,dV;
  int iCop;
  dH=dV=0x00; 
  
  printf (" \n ***** Single Frame Encoding ***** "); 
  printf ( "\n Please Select the Compress Method<MPEG -> 1 ; JPEG -> 2 >: ");
  scanf("%ld",&iCop);
  if ( (iCop != 1) && (iCop !=2 ))
  {
     printf("\n Input Error !!!");
     return ; 
  }
  printf ( "\n Please Input the Encoded File Name ---> ");
  scanf("%s",_SFE_OutFileName);
  printf ( "\n Please Input Frame Horizontal (Dec) ---> ");
  scanf("%ld",&dH);
  printf ( "\n Please Input Frame Vertical (Dec) ---> ");
  scanf("%ld",&dV);
  bRes=UTL_SFE(dH,dV,iCop);
  if ( bRes== FALSE) 
     printf("\n Single frame encoding: error !!!");
}

//**************************************************************************
//    Function    :WFR()
//    Description :Write a frame  
//    Return      :None
//**************************************************************************  
void WFR()
{ 
  BOOL bRes;
  int dH,dV;
  dH=dV=0x00; 

  printf (" \n ***** Write Frame Mode ***** ");
  printf ( "\n Please Input the File Name ---> ");
  scanf("%s",_SFE_InFileName);
  printf ( "\n Please Input Frame Horizontal (Dec) ---> ");
  scanf("%ld",&dH);
  printf ( "\n Please Input Frame Vertical (Dec) ---> ");
  scanf("%ld",&dV);
  bRes=UTL_WFR(dH,dV);
  if ( bRes== FALSE)
     printf("\n Write a frame: error !!!");
} 

//**************************************************************************
//    Function    :RFR()
//    Description :Read a frame
//    Return      :None
//**************************************************************************
void RFR()
{
  BOOL bRes;
  bRes=UTL_RFR(1,1);
  if ( bRes== FALSE)
     printf("\n Read a frame: error !!!");
}   


void AUDIOFIFO(void)
{
  UTL_AUDIOFIFO("audio.pcm", 0);    
  return;
}


⌨️ 快捷键说明

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