📄 iekc64_video.h
字号:
#ifndef _VIDEO_H_
#define _VIDEO_H_
#include <csl_stdinc.h>
#include <csl_edma.h>
#include "iekc64_error.h"
#include "iekc64.h"
#ifdef __cplusplus
extern "C" {
#endif
/*=======================================================================*//*!
\defgroup VIDEO VIDEO - Video capture and generation module
\brief This module is related to video capture and generation.
The Video module is subdivsed in two sub-modules :
\li VIN (Video INput) for video capture
\li VOUT (Video OUTput) for video generation
The following paragraphs details the working of these two sub-modules
<h3> Video Input </h3>
<b> How does it work ?</b>
The VIN Module captures video into frames.
Frames are allocated contiguously in a circular buffer allocated by
the user before opening the module. This buffer must be large enough
to allow at least 4 frames to be stored. Using a 4 frames buffer is the
best way to insure that you won't have any overlapping between the
background capture and the processing.
If your process needs to work on more than 1 frame (for example when
working on motion estimation), you don't need to copy frames to another
buffer, you just have to create a buffer large enough and tell the VIN
module to always leave the last N frames unused.
In CIF or QCIF resolution, we also use the first reload table available.
When we want to update the address for next frame transfert, we update the destination
address in reload table.
In FULL resolution mode, as we have I and P frames , we need to use 4 reload tables.
These tables are dynamically allocated by CSL.
The first two reload tables are used for a complete picture (I+P). When we want to
update a picture, we first update the destination address in the 2 remaining reload
tables and then we link the first P reload table on the I remaing reload table.
And so on.
<b> Opening the module </b>
You open the module by calling the VIN_open() function. This function
initializes the hardware and the software with the parameters given in the
IEKC64_VIDEOIN structure. You must use the default configuration,
IEKC64_VIDEOIN_DEFAULT, to initialize your own configuration but the
fields nFramesInBuffer, nFramesToKeep and pCaptureBuffer must be set
before calling the VIN_open() function. nFramesInBuffer must be equal to nFramesToKeep + 3.
The default configuration structure field description is:
<small>
dwSize = sizeof(IEKC64_VIDEOIN) <br>
Standard = NTSC <br>
Resolution = RES_NTSC_CIF <br>
FrameFormat = YUV422PIXEL <br>
VideoInSelect = COMPOSITE <br>
nTemporalDecimationFactor = 1 <br>
isOneShot = FALSE <br>
nFramesInBuffer = 0 <br>
nFramesToKeep = 1 <br>
pCaptureBuffer = NULL <br>
dwDmaPri = EDMA_OPT_PRI_HIGH <br>
dwInputTcc = EDMA_CHA_GPINT1 <br>
dwExtIntrVideoIn = IRQ_EVT_EXTINT4 <br>
</small>
<b> Starting the capture </b>
A call to VIN_start() activates the capture process. The video signal
is digitized. It may be spatialy and temporaly down-sampled if asked.
Digital value is then stored into the capture buffer using DMA. DMA
mechanism is hidden to the user by IEKLIB.
Each new picture is stored into next frame in the buffer.
<b> Getting next frame </b>
VIN_getFrame() givesthe next frame pointer from the input buffer.
If no new frame is avaiable, depending on the timeout value, you will
get an error or wait until the timeout ends or a new frame is captured.
<b> Ending capture </b>
VIN_stop() allowsthe capture to be paused. After a VIN_stop, capture can be
re-started with the same parameters with VIN_start().
VIN_close() frees all the resources allocated by the VIN Module (DMA,
interrupts, ...).
If you need to change capture parameters, you must close and re-open
the module.
<h3> Video Output </h3>
<b> How does it work ? </b>
The VOUT Module generates video from frames provided by the user.
Frames are allocated by the user. Their memory location is not important,
as far as each frame start is aligned on a 32 bit word boudary. Frames
for video generation don't need to be contiguously allocated in the
same buffer like the ones used for video capture. They even don't need
to be allocated before opening the module. The user can allocate any
number of frames from 1 to memory limits.
When using 1 single frame, it is possible to work into the frame while it
is displayed. Depending on the refresh rate that can cause some
artifacts.
In CIF resolution, we also use the first reload table available.
When we want to update the address for next frame transfert, we update the source
address in reload table and in the current EDMA transfert
In FULL resolution mode, as we have I and P frames, we need to use 4 reload tables.
These tables are dynamically allocated by CSL.
The first two reload tables are used for a complete picture (I+P). When we want to
update a picture, we first update the source address in the 2 remaining reload tables
and then we link the first P reload table on the I remaing reload table.
And so on.
<b> Opening the module </b>
You open the module by calling the VOUT_open() function. This function
initializes the hardware and the software with the parameters given in the
IEKC64_VIDEOOUT structure. You must use the default configuration,
IEKC64_VIDEOOUT_DEFAULT, to initialize your own configuration before calling
the VOUT_open() function.
The default configuration structure field description is:
<small>
dwSize = sizeof(IEKC64_VIDEOOUT) <br>
Standard = NTSC <br>
Resolution = RES_NTSC_CIF<br>
FrameFormat = YUV422PIXEL<br>
VideoOutSelect = COMPOSITE<br>
dwDmaPri = EDMA_OPT_PRI_HIGH<br>
dwMotinorTcc = EDMA_CHA_GPINT2<br>
dwVgaTcc = EDMA_CHA_GPINT2<br>
dwExtIntrMonitorVideoOut = IRQ_EVT_EXTINT5 <br>
dwExtIntrVgaVideoOut = IRQ_EVT_EXTINT5 <br>
</small>
<b> Starting the generation </b>
A call to VOUT_start() pre-activates the capture process.
There will be no video generation until the first call to VOUT_putFrame().
<b> Outputing a frame </b>
With VOUT_putFrame() the user provides the pointer to the next frame
to be generated.
The frame data will is sent to the hardware using DMA. DMA mechanism is
hidden to the user by IEKLIB. You must insure that the buffer provided to the
VOUT_putFrame() function will not be over overwrited before 80 ms ( 2 more
VOUT_putFrame() function call).
If no new VOUT_putFrame() is done before a next frame is required by
the hardware, the module keeps on generating the same frame.
An optional timeout allow the call to block until either the given frame
effectively becomes the active frame or the timeout ends.
<b> Ending generation </b>
VOUT_stop() allows the generation to be paused. After a VOUT_stop,
generation can be re-started with the same parameters with VOUT_start().
VOUT_close() frees all the resources allocated by the VOUT Module (DMA,
interrupts, ...).
If you need to change generation parameters, you must close and
re-open the module.
</P>*//*==============================================================*//*@{*/
/*--------------------------------------------------------------------------*/
/*! Defines the video standard used for capture or generation
*/
typedef enum
{
//! This selects the european standard
PAL = 0,
//! This selects the american standard
NTSC
} IEKC64_VIDEO_STANDARD;
/*--------------------------------------------------------------------------*/
/*! Defines the video resolution used for capture or generation
*/
typedef enum
{
//! PAL full screen 720x576
RES_PAL_FULL = 0,
//! PAL CIF 720x288 (Generate 2 frames, You need to have buffer size 720*576 for input)
RES_PAL_2CIF,
//! PAL CIF 352x288
RES_PAL_CIF,
//! PAL QCIF 176x144 (This value is not allowed for generation (VOUT))
RES_PAL_QCIF,
//! NTSC full screen 720x480
RES_NTSC_FULL,
//! NTSC full screen 720x240 (Generate 2 frames, You need to have buffer size 720*480 for input)
RES_NTSC_2CIF,
//! NTSC CIF 352x240
RES_NTSC_CIF,
//! NTSC QCIF 176*128 (This value is not allowed for generation (VOUT))
RES_NTSC_QCIF,
//! This selects PAL FULL video resolution for VGA
RES_VGA_PAL_720X576,
//! This selects PAL CIF video resolution for VGA
RES_VGA_PAL_352X576,
//! This selects NTSC FULL video resolution for VGA
RES_VGA_NTSC_720X480,
//! This selects PAL CIF video resolution for VGA
RES_VGA_NTSC_352X480,
//! This selects 800x600 video resolution for VGA
RES_VGA_800X600,
//! This selects 1024X768 video resolution for VGA
RES_VGA_1024X768
} IEKC64_VIDEO_RESOLUTION;
/*--------------------------------------------------------------------------*/
/*! Defines the frame format used for capture or generation.<br>
*/
typedef enum
{
//! This selects storage format in YUV422 pixels (16 bits pixels)
YUV422PIXEL = 0,
//! This selects storage format in RGB565 pixels (16 bits pixels) for VGA
RGB565PIXEL
}
IEKC64_VIDEO_FRAME_FORMAT;
/*--------------------------------------------------------------------------*/
/*! Defines the board input or output.
*/
typedef enum
{
//! This selects the CVBS (composite) input or ouput
COMPOSITE = 0,
//! This selects the Y/C (S-video) input or output
YC,
//! This selects the VGA output (mode ACE3)
VGA,
//! This selects the VGA output (mode PDT) (Only available on TMS DSP)
VGAPDT,
//! This selects all outputs (VOUT only) execpt VGA output
ALL = 255
}
IEKC64_VIDEO_INOUT_SELECT;
/*--------------------------------------------------------------------------*/
/*! Initialization parameters for VIN_open().
All fields have to be set before the call.
*/
typedef struct
{
/*! This field must contains the IEKC64_VIDEOIN structure size
*/
Uint32 dwSize;
/*! This field holds the video standard present at input
*/
IEKC64_VIDEO_STANDARD Standard;
/*! This field holds the resolution at which the frames have to
be captured
*/
IEKC64_VIDEO_RESOLUTION Resolution;
/*! This field holds the frame format in which frames have to be
stored
*/
IEKC64_VIDEO_FRAME_FORMAT FrameFormat;
/*! This field selects the board input on which video will be captured
*/
IEKC64_VIDEO_INOUT_SELECT VideoInSelect;
/*! This field indicates if all frames from the video input have
to be captured or if a temporal decimation has to be applied. If this
parameter is set to N, then only 1 picture over N will be captured.
Value range is from 1 to 63.
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -