📄 dm642main.c
字号:
/********************************************************************/
/* Copyright 2004 by BTECH Incorporated. */
/* All rights reserved. Property of BTECH Incorporated. */
/* Restricted rights to use, duplicate or disclose this code are */
/* granted through contract. */
/* */
/********************************************************************/
/********************************************************************/
/* 图像反色 */
/********************************************************************/
#include <csl.h>
#include <csl_emifa.h>
#include <csl_i2c.h>
#include <csl_gpio.h>
#include <csl_irq.h>
#include <csl_chip.h>
#include <csl_dat.h>
#include <csl_cache.h>
#include "iic.h"
#include "vportcap.h"
#include "vportdis.h"
#include "TVP51xx.h"
#include "TVP51xx.h"
#include "evmdm642.h"
#include "saa7105.h"
#define COLOR_DISP //是否彩色显示
int portNumber;
/*图像句柄的声明*/
VP_Handle vpHchannel0;
VP_Handle vpHchannel1;
VP_Handle vpHchannel2;
/*确定图像的参数*/
const int numPixels = 720;//每行720个像素
const int numLines = 576;//每帧576行(PAL)
const int flamesize = 720*576;
/*确定处理的范围*/
/*A */
/* */
/* D*/
const int intAPixels = 190;
const int intALines = 59;
const int intDPixels = 530;
const int intDLines = 229;
/*****画矩形边框函数的声明*****/
void drawRectangle();
/*****进行图像反色处理*********/
void videoReverse();
extern Uint8 capChaAYSpace[720*588];
extern Uint8 capChaACbSpace[360*588];
extern Uint8 capChaACrSpace[360*588];
extern Uint8 disChaAYSpace[720*588];
extern Uint8 disChaACbSpace[360*588];
extern Uint8 disChaACrSpace[360*588];
#pragma DATA_SECTION(tmpChaAYSpace, ".external")
Uint8 tmpChaAYSpace[720*588];
/*采集与显示缓冲区的首址*/
Uint32 capYbuffer ;
Uint32 capCbbuffer ;
Uint32 capCrbuffer ;
Uint32 disYbuffer ;
Uint32 disCbbuffer ;
Uint32 disCrbuffer ;
Uint32 tempYbuffer ; //临时
/*图像格式标志*/
Uint8 NTSCorPAL = 0;
extern far void vectors();
extern volatile Uint32 capNewFrame;
extern volatile Uint32 disNewFrame;
/*此程序可将四个采集口的数据经过Video Port0送出*/
void main()
{
int i;
// int dp_id,dp_id2;
sysinit();
/*----------------------------------------------------------*/
capYbuffer = (Uint32)capChaAYSpace;
capCbbuffer = (Uint32)capChaACbSpace;
capCrbuffer = (Uint32)capChaACrSpace;
disYbuffer = (Uint32)disChaAYSpace;
disCbbuffer = (Uint32)disChaACbSpace;
disCrbuffer = (Uint32)disChaACrSpace;
tempYbuffer = (Uint32)tmpChaAYSpace;
/*----------------------------------------------------------*/
/*初始化Video Port1*/
/*将Vedio Port1设为采集输入*/
portNumber = 1;
vpHchannel1 = bt656_8bit_ncfc(portNumber);
bt656_capture_start(vpHchannel1);
/*等待第一帧数据采集完成*/
while(capNewFrame == 0){}
/*将数据存入显示缓冲区,并清采集完成的标志*/
capNewFrame =0;
for(i=0;i<numLines;i++)
{
/*传送临时Y缓冲区*/
DAT_copy((void *)(capYbuffer + i * numPixels),
(void *)(tempYbuffer + i * numPixels),
numPixels);
}
/*画边框*/
drawRectangle();
/*进行图像反色处理*/
videoReverse();
/*给显示缓存区内的UV赋值*/
for(i=0;i<0x33ae0;i++)
{
*((Uint8 *)(disCrbuffer +i)) =0x80;
*((Uint8 *)(disCbbuffer +i)) =0x80;
}
for(i=0;i<numLines;i++)
{
/*传送Y缓冲区*/
DAT_copy((void *)(tempYbuffer + i * numPixels),
(void *)(disYbuffer + i * numPixels),
numPixels);
}
/*启动显示模块*/
bt656_display_start(vpHchannel2);
/*建立显示的实时循环*/
/*此循环中没有将采集缓存区中的UV值传给显示缓存区*/
/*此时显示缓存区的UV值为0x80*/
for(;;)
{
/*当采集区的数据已经采集好*/
if(capNewFrame == 1)
{
/*将数据装入显示缓冲区,并清采集完成的标志*/
capNewFrame =0;
for(i=0;i<numLines;i++)
{
/*传送临时Y缓冲区*/
DAT_copy((void *)(capYbuffer + i * numPixels),
(void *)(tempYbuffer + i * numPixels),
numPixels);
#ifdef COLOR_DISP //是否彩色显示
/*传送Cb缓冲区*/
DAT_copy((void *)(capCbbuffer + i * (numPixels >> 1)),
(void *)(disCbbuffer + i * (numPixels >> 1)),
numPixels>>1);
/*传送Cr缓冲区*/
DAT_copy((void *)(capCrbuffer + i * (numPixels >> 1)),
(void *)(disCrbuffer + i * (numPixels >> 1)),
numPixels>>1);
#endif
}
DAT_wait(DAT_XFRID_WAITALL);
/*画边框*/
drawRectangle();
/*进行图像反色处理*/
videoReverse();
}
/*当显示缓冲区的数据已空*/
if(disNewFrame == 1)
{
disNewFrame =0;
for(i=0;i<numLines;i++)
{
/*传送Y缓冲区*/
DAT_copy((void *)(tempYbuffer + i * numPixels),
(void *)(disYbuffer + i * numPixels),
numPixels);
}
DAT_wait(DAT_XFRID_WAITALL);
}
EVMDM642_GPIO_ledblink();//led blink for every frame.by hj
}
for(;;)
{}
/*----------------------------------------------------------*/
/*采集与回放*/
}
/*画矩形边框函数的定义*/
void drawRectangle()
{
int i,j;
/*画上边*/
//奇数行
for(i=intALines-4;i<intALines;i++) //边框长度
{
for(j=intAPixels-6;j<intDPixels+6;j++) //奇数行边框宽度
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0x00;
}
}
//偶数行
for(i=numLines/2+intALines-4;i<numLines/2+intALines;i++) //边框长度
{
for(j=intAPixels-6;j<intDPixels+6;j++) //偶数行边框宽度
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0x00;
}
}
/*画下边*/
//奇数行
for(i=intDLines;i<intDLines+4;i++)//边框长度
{
for(j=intAPixels-6;j<intDPixels+6;j++) //奇数行边框宽度
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0x00;
}
}
//偶数行
for(i=numLines/2+intDLines;i<numLines/2+intDLines+4;i++)//边框长度
{
for(j=intAPixels-6;j<intDPixels+6;j++) //偶数行边框宽度
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0x00;
}
}
/*画左边*/
//奇数行
for(i=intALines;i<intDLines;i++)//边框长度
{
for(j=intAPixels-6;j<intAPixels;j++) //奇数行边框宽度
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0x00;
}
}
//偶数行
for(i=numLines/2+intALines;i<numLines/2+intDLines;i++)//边框长度
{
for(j=intAPixels-6;j<intAPixels;j++) //偶数行边框宽度
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0x00;
}
}
/*画右边*/
//奇数行
for(i=intALines;i<intDLines;i++)//边框长度
{
for(j=intDPixels;j<intDPixels+6;j++) //奇数行边框宽度
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0x00;
}
}
//偶数行
for(i=numLines/2+intALines;i<numLines/2+intDLines;i++)//边框长度
{
for(j=intDPixels;j<intDPixels+6;j++) //偶数行边框宽度
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0x00;
}
}
}
/*进行图像反色处理*/
void videoReverse()
{
int i,j;
Uint8 data;
//方框内奇数行
for(i=intALines;i<intDLines;i++) //行数
{
for(j=intAPixels;j<intDPixels;j++) //像素个数/每行
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0xFF - (*(Uint8 *)(tempYbuffer + i*numPixels + j));
}
}
//方框内偶数行
for(i=numLines/2+intALines;i<numLines/2+intDLines;i++)//行数 0xFF-
{
for(j=intAPixels;j<intDPixels;j++) //像素个数/每行
{
*(Uint8 *)(tempYbuffer + i*numPixels + j) = 0xFF - (*(Uint8 *)(tempYbuffer + i*numPixels + j));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -