DM642 video capture and playback program basic framework

Source: Internet
Author: User

void Tskvideoloopback ()

{

Set the number of rows displayed

Numlinesdis = Evmdm642_vdisparamschan.imgvsizefld1;

Set the number of rows collected

Numlinescap = evmdm642_vcapparamschan.fldystop1–

evmdm642_vcapparamschan.fldystrt1+1;

Take the smaller number of rows processed by the program

Numlines = (Numlinesdis > Numlinescap)? Numlinescap:numlinesdis;

#ifdef _loopback

Set the pixels to display per row

Numpixels = EVMDM642_VCAPPARAMSCHAN.FLDXSTOP1-

evmdm642_vcapparamschan.fldxstrt1+1;

Capture the total pixels of an image row

Caplinepitch = EVMDM642_VCAPPARAMSCHAN.FLDXSTOP1-

evmdm642_vcapparamschan.fldxstrt1+1;

Displays the total pixels of the image row

Dislinepitch = Evmdm642_vdisparamschan.imghsizefld1;

#endif

Numlines *= 2; /* Both fields */

Allocating storage buffers for capturing and displaying images

Evmdm642_vcapparamschan.segid = Externalheap;

Evmdm642_vdisparamschan.segid = Externalheap;

EVMDM642_VDISPARAMSSAA7104.HI2C = EVMDM642_I2C_HI2C;

EVMDM642_VCAPPARAMSTVP5150A.HI2C = EVMDM642_I2C_HI2C;

Set up and initialize the object of the acquisition device

#ifdef _loopback

#ifdef _VP2

Capchan = Fvid_create ("/VP2CAPTURE/A/1",

Iom_input, &status, (PTR) &evmdm642_vcapparamschan, NULL);

#else

Capchan = Fvid_create ("/vp0capture/a/0",

Iom_input, &status, (PTR) &evmdm642_vcapparamschan, NULL);

#endif

#endif

Creating and initializing display device objects

Dischan = Fvid_create ("/vp1display", Iom_output,

&status, (PTR) &evmdm642_vdisparamschan, NULL);

To ensure that the acquisition and display devices are working properly, set the drive

Fvid_control (Dischan, Vport_cmd_edc_base + edc_config,

(PTR) &evmdm642_vdisparamssaa7104);

#ifdef _loopback

Fvid_control (Capchan, Vport_cmd_edc_base + edc_config,

(PTR) &evmdm642_vcapparamstvp5150a);

#endif

Start capture and display operations

Fvid_control (Dischan, Vport_cmd_start, NULL);

#ifdef _loopback

Fvid_control (Capchan, Vport_cmd_start, NULL);

#endif

Allocate a buffer for capturing and displaying a frame of image storage

Fvid_alloc (Dischan, &disframebuf);

#ifdef _loopback

Fvid_alloc (Capchan, &capframebuf);

#endif

Frames + +;

while (1)

{

#ifdef _loopback

Int i;

Copy the contents of the capture buffer into the display buffer

for (i = 0; i < numlines; i + +) {

Dat_copy (capframebuf->frame.ifrm.y1 + i * caplinepitch,

Disframebuf->frame.ifrm.y1 + i * dislinepitch,

Numpixels);

Dat_copy (CAPFRAMEBUF->FRAME.IFRM.CB1 + i * (caplinepitch >> 1),

DISFRAMEBUF->FRAME.IFRM.CB1 + i * (dislinepitch >> 1),

NUMPIXELS>>1);

Dat_copy (CAPFRAMEBUF->FRAME.IFRM.CR1 + i * (caplinepitch >> 1),

DISFRAMEBUF->FRAME.IFRM.CR1 + i * (dislinepitch >> 1),

NUMPIXELS>>1);

}

Fvid_exchange (Capchan, &capframebuf);

#else//If capture is defined, the fill image is buffered to 8 strips

Fillfrmbuf (&DISFRAMEBUF->FRAME.IFRM,

Evmdm642_vdisparamschan.imghsizefld1,

evmdm642_vdisparamschan.imgvsizefld1+

Evmdm642_vdisparamschan.imgvsizefld2, frames% 360);

#endif

Sends a frame image from the display buffer to the display device

Fvid_exchange (Dischan, &disframebuf);

Process Next Frame image

Frames + +;

}

}

Produces a 8-stripe pattern that moves toward pan left:

#include <std.h>
#include <csl_cache.h>
#include <fvid.h>
#include <csl_dat.h>
#include "Colorbar.h"


/* Static function declaration defines the Y CB cr value for each color white yellow turquoise blue black */
static void Generatecolorbar (uint8* y, uint8* CB, uint8* CR, Int linesize);

#define WHITE_Y 180
#define WHITE_CB 128
#define WHITE_CR 128

#define YELLOW_Y 162
#define YELLOW_CB 44
#define YELLOW_CR 142

#define CYAN_Y 131
#define CYAN_CB 156
#define CYAN_CR 44

#define GREEN_Y 112
#define GREEN_CB 72
#define GREEN_CR 58

#define MAGENTA_Y 84
#define MAGENTA_CB 184
#define MAGENTA_CR 198

#define RED_Y 65
#define RED_CB 100
#define RED_CR 212

#define BLUE_Y 35
#define BLUE_CB 212
#define BLUE_CR 114

#define BLACK_Y 16
#define BLACK_CB 129
#define BLACK_CR 129

/* Defines arrays to hold a line of image for color bar generating */
#pragma data_align (Imgliney, 8);
#pragma data_align (IMGLINECB, 8);
#pragma data_align (IMGLINECR, 8);

Static Uint8 imgliney[1920 * 3];
Static Uint8 imglinecb[960 * 3];
Static Uint8 imglinecr[960 * 3];

/*
* ======== Fillfrmbuf ========
* This function is fill a frame with color bar of Y/CB/CR format.
*/

void Fillfrmbuf (fvid_iframe* frame, int linesz, int numlines, int offset)
{
Int i;
static INT init = 0;
INT ID;
if (!init) {
Generatecolorbar (Imgliney, IMGLINECB, IMGLINECR, Linesz);
Cache_clean (cache_l2all, NULL, NULL);
init = 1;
}
for (i = 0; i < numlines; i + +) {
Dat_copy (Imgliney + offset * 2, frame->y1 + Linesz * I, Linesz);
Dat_copy (IMGLINECB + offset, FRAME-&GT;CB1 + (Linesz >> 1) * I,
(Linesz >> 1));
id = dat_copy (imglinecr + offset, frame->cr1+ (Linesz >> 1) * I,
(Linesz >> 1));
}
Dat_wait (ID);
}

/*
* ======== Generatecolorbar ========
* This function generates a line of color bar with Y/CB/CR format.
*/

static void Generatecolorbar (uint8* y, uint8* CB, uint8* CR, Int linesize)
{
Int i;
Int fillsize = linesize >> 3;
Int K;

if (Fillsize & 0x1) {
Fillsi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.