📄 video_ntsc_pal.c
字号:
/* ( */
/* const unsigned char *in_data, // Input image data // */
/* unsigned char *out_data, // Output image data // */
/* short cols, short rows // Image dimensions // */
/* ) */
/* */
/* The IMG_sobel filter is applied to the input image. The input image */
/* dimensions are given by the arguments 'cols' and 'rows'. The */
/* output image is 'cols' pixels wide and 'rows - 2' pixels tall. */
/* */
/* DESCRIPTION */
/* */
/* To see how the implementation is going to work on the input */
/* buffer, lets imagine we have the following input buffer: */
/* lets imagine we have the following input buffer: */
/* */
/* yyyyyyyyyyyyyyyy */
/* yxxxxxxxxxxxxxxy */
/* yxxxxxxxxxxxxxxy */
/* yxxxxxxxxxxxxxxy */
/* yxxxxxxxxxxxxxxy */
/* yyyyyyyyyyyyyyyy */
/* */
/* The output buffer would be: */
/* */
/* tXXXXXXXXXXXXXXz */
/* zXXXXXXXXXXXXXXz */
/* zXXXXXXXXXXXXXXz */
/* zXXXXXXXXXXXXXXt */
/* */
/* Where: */
/* */
/* X = IMG_sobel(x) The algorithm is applied to that pixel. */
/* The correct output is obtained, the data */
/* around the pixels we work on is used */
/* */
/* t Whatever was in the output buffer in that */
/* position is kept there. */
/* */
/* z = IMG_sobel(y) The algorithm is applied to that pixel. */
/* The output is not meaningful, because the */
/* necessary data to process the pixel is not */
/* available. This is because for each output */
/* pixel we need input pixels from the right and */
/* from the left of the output pixel. But this */
/* data doesn't exist. */
/* */
/* This means that we will only process (rows-2) lines. Then, we */
/* will process all the pixels inside each line. Even though the */
/* results for the first and last pixels in each line will not */
/* be relevant, it makes the control much simpler and ends up */
/* saving cycles. */
/* */
/* Also the fist pixel in the first processed line and the */
/* last pixel in the last processed line will not be computed. */
/* It is not necessary, since the results would be bogus, and */
/* not computing them saves some time. */
/* */
/* The following horizontal and vertical masks that are */
/* applied to the input buffer to obtain one output pixel. */
/* */
/* Horizontal: */
/* -1 -2 -1 */
/* 0 0 0 */
/* 1 2 1 */
/* */
/* Vertical: */
/* -1 0 1 */
/* -2 0 2 */
/* -1 0 1 */
/* */
/* ASSUMPTIONS */
/* n/a */
/* */
/* NOTES */
/* The values of the left-most and right-most pixels on each line */
/* of the output are not well-defined. */
/* ------------------------------------------------------------------------ */
/* Copyright (c) 2002 Texas Instruments, Incorporated. */
/* All Rights Reserved. */
/* ======================================================================== */
void IMG_sobel
(
const unsigned char *restrict in, /* Input image data */
unsigned char *restrict out, /* Output image data */
short cols, short rows /* Image dimensions */
)
{
int H, O, V, i;
int i00, i01, i02;
int i10, i12;
int i20, i21, i22;
int w = cols;
/* -------------------------------------------------------------------- */
/* Iterate over entire image as a single, continuous raster line. */
/* -------------------------------------------------------------------- */
for (i = 0; i < cols*(rows-2) - 2; i++)
{
/* ---------------------------------------------------------------- */
/* Read in the required 3x3 region from the input. */
/* ---------------------------------------------------------------- */
i00=in[i ]; i01=in[i +1]; i02=in[i +2];
i10=in[i+ w]; i12=in[i+ w+2];
i20=in[i+2*w]; i21=in[i+2*w+1]; i22=in[i+2*w+2];
/* ---------------------------------------------------------------- */
/* Apply horizontal and vertical filter masks. The final filter */
/* output is the sum of the absolute values of these filters. */
/* ---------------------------------------------------------------- */
H = - i00 - 2*i01 - i02 +
+ i20 + 2*i21 + i22;
V = - i00 + i02
- 2*i10 + 2*i12
- i20 + i22;
O = abs(H) + abs(V);
/* ---------------------------------------------------------------- */
/* Clamp to 8-bit range. The output is always positive due to */
/* the absolute value, so we only need to check for overflow. */
/* ---------------------------------------------------------------- */
if (O > 255) O = 255;
/* ---------------------------------------------------------------- */
/* Store it. */
/* ---------------------------------------------------------------- */
out[i + 1] = O;
}
}
/*
* ImageProcess of soble algorithm
*/
void myImageProcess()
{
Int i = 0;
IMG_sobel(capFrameBuf->frame.iFrm.y1,Y1,720,numLines);
IMG_sobel(capFrameBuf->frame.iFrm.cb1,CB1,720/2,numLines);
IMG_sobel(capFrameBuf->frame.iFrm.cr1,CR1,720/2,numLines);
for(i = 0; i < numLines; i ++)
{
DAT_copy(capFrameBuf->frame.iFrm.y1 + i * capLinePitch,
disFrameBuf->frame.iFrm.y1 + i * disLinePitch,
numPixels>>1);
DAT_copy(Y1+ i * capLinePitch ,
disFrameBuf->frame.iFrm.y1 + i * disLinePitch+360,
numPixels>>1);
DAT_copy(capFrameBuf->frame.iFrm.cb1 + i * (capLinePitch >> 1),
disFrameBuf->frame.iFrm.cb1 + i * (disLinePitch >> 1),
numPixels>>2 );
DAT_copy(CB1 + i * (capLinePitch >> 1),
disFrameBuf->frame.iFrm.cb1 + i * (disLinePitch >> 1)+(disLinePitch >> 2),
numPixels>>2 );
DAT_copy(capFrameBuf->frame.iFrm.cr1 + i * (capLinePitch >> 1),
disFrameBuf->frame.iFrm.cr1 + i * (disLinePitch >> 1),
numPixels>>2);
DAT_copy(CR1 + i * (capLinePitch >> 1),
disFrameBuf->frame.iFrm.cr1 + i * (disLinePitch >> 1)+(disLinePitch >> 2),
numPixels>>2);
}
}
void VidDisMode(Int displaymode)
{
*((volatile unsigned int *)0x01b4c010) =0x00000004|*((volatile unsigned int *)0x01b4c010); //configure video mode
*((volatile unsigned int *)0x01b4c014) =0x00000004|*((volatile unsigned int *)0x01b4c014);
switch(displaymode)
{
case 0 : *((volatile unsigned int *)0x01b4c01c) = 0x00000004; break;
case 1 : *((volatile unsigned int *)0x01b4c01c) = 0x00000004; break;
case 2 : *((volatile unsigned int *)0x01b4c01c) = 0x00000000; break;
default : *((volatile unsigned int *)0x01b4c01c) = 0x00000004;
}
}
/* ======================================================================== */
/* Copyright (c) 2003 Wintech Digital System Technology Corp. */
/* All Rights Reserved. */
/* ======================================================================== */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -