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

📄 post_test.c

📁 s3c6400 ADS下官方测试程序
💻 C
📖 第 1 页 / 共 5 页
字号:
/*----------------------------------------------------------------------
 *
 * Filename: post_test.cpp
 *
 * Contents: Testing application of "class POST"
 *
 * Authors: Dhrama
 *
 * Notes:
 *
 * Copyright (c) 2003 SAMSUNG Electronics.
 *
 *----------------------------------------------------------------------
 */

 #include <stdio.h>

#include "def.h"
#include "option.h"
#include "library.h"
#include "sfr6400.h"
#include "system.h"
#include "sysc.h"
#include "post.h"
#include "post_test.h"
#include "lcd.h"
#include "glib.h"
#include "intc.h"
#include "camera.h"
#include "timer.h"


#if 0
#define IMG_YC420       "../images/420_240x320result(rotate90).yuv"
#define POST_YUV_FILE_NAME1      "D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/CatureYUV/Captured1.yuv"
#define POST_YUV_FILE_NAME2      "D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/CatureYUV/Captured2.yuv"

#define POST_IMAGE_PATTERN	0
#define POST_IMAGE_HEADER		1
#define POST_IMAGE_SORCE		POST_IMAGE_PATTERN

#define POST_IMAGE_BMP_SLIDE			(TRUE)

#if (POST_IMAGE_SORCE == POST_IMAGE_HEADER)
#include "Guitar240320_16rgb.h"
#include "Guitar240320_24.h"
#include "guitar240320_YCrYCb422.h"
#include "guitar240320_YCbYCr422.h"
#include "guitar240320_CrYCbY422.h"
#include "guitar240320_CbYCrY422.h"
#include "guitar240320_YCbYCr420.h"
#include "RacingGirl320240.h"
#include "sun320240_16bpp.h"
#include "Yepp320x240.h"
#endif
#endif

//rb1004 test
//#define LCD_INIT_TEST

//static GLIB oGlib;
//static LCDC oLcdc;
static POST oPost;
static POST oSc;

//static INTC oIntc;
//static CIM  oCim;

//static CSPACE eLcdBpp;
static CSPACE eSrcDataFmt;
static CSPACE eMidDataFmt;
static CSPACE eDstDataFmt;

static CSPACE eSrcDataFmt_Yuv;
static CSPACE eDstDataFmt_Yuv;

//static CSPACE eDstDataFmt_FifoOut; // From DMA TO FIFO
//static POST_FIFO_IF ePostFifoIf;

static POST_RUN_MODE ePostRunMode;

//static LCD_LOCAL_IN_DATA_FORMAT eLcdLocalDataFmt;

//static u32 uLcdFbAddr;

static u32 uLcdHSz, uLcdVSz;	
static u32 uSrcStartX, uSrcStartY;
static u32 uSrcCroppedHSz, uSrcCroppedVSz;

static u32 uMidImgHSz, uMidImgVSz;
static u32 uMidStartX, uMidStartY;
static u32 uMidScaledHSz, uMidScaledVSz;

static u32 uMid2ImgHSz, uMid2ImgVSz;
static u32 uMid2StartX, uMid2StartY;
static u32 uMid2ScaledHSz, uMid2ScaledVSz;

static u32 uImgHSz, uImgVSz;	
static u32 uDstStartX, uDstStartY;
static u32 uDstScaledHSz, uDstScaledVSz;

//static bool bIsR2Y2RFlag = false;

const static u32 uLcdStAddr = CODEC_MEM_ST; 

//static u32 uFrameCnt_Int = 0;
static u32 uNxtAddr1, uNxtAddr2;

//static u32 uIsrCnt;
const static u32 uMaxFrameCnt = 10;

bool bIsPollingOrInt = true; // true: Polling, false: Int

//rb1004
static u32 uSimpleTest;
static bool uPostIntOccured;

u8 *Image_Entertain[] = {	"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment1.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment2.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment3.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment4.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment5.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment6.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment7.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment8.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment9.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment10.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment11.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment12.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment13.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment14.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/entertainment15.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate1.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate2.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate3.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate4.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate5.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate6.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate7.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate8.bmp",
								"D:/MyDocument/AP/S3C6400/Software/6400_Test_Rev04/Components/multimedia/image/bmp/Illustrate9.bmp"
							};

////////////////////////////////////////////////////////////////////////////
//////////////////                         ISR Routine                         ///////////////////
////////////////////////////////////////////////////////////////////////////

void __irq PostISRDma(void)
{
	uPostIntOccured = TRUE;
	POST_ClearPending(&oPost);
	INTC_ClearVectAddr();
}


/*************************
  Function CSCR2Y ( Color space Convertor RGB to YCbCr)

  Input
  R[7:0], G[7:0], B[7:0]
  Return Value
  CSCR2Y[23:16] : Y
  CSCR2Y[15: 8] : Cb
  CSCR2Y[ 7: 0] : Cr
  Control by R2YCSEL
1: Wide Range
0: Narrow Range
 ************************/
int CSCR2Y_C(int R, int  G, int B, int R2YCSEL)
{
  //int		i;
  int		y;
  int		cb;
  int		cr;
  int		Y;
  int		Cb;
  int		Cr;
  int		R25;
  int		G50;
  int		B09;
  int		R14;
  int		G29;
  int		B43;
  int		R43;
  int		G36;
  int		B07;
  int		r25;
  int		g50;
  int		b09;
  int		r14;
  int		g29;
  int		b43;
  int		r43;
  int		g36;
  int		b07;

 // int             R25_8;
//  int             r25_8;
//int             G50_8;
//  int             g50_8;
//  int             B09_8;
//  int             b09_8;
//  int             R14_8;
 // int             r14_8;
  //int             G29_8;
 // int             g29_8;
//  int             B43_8;
//  int             b43_8;
//  int             R43_8;
//  int             r43_8;
//  int             G36_8;
//  int             g36_8;
//  int             B07_8;
//  int             b07_8;

  int		CSCR2Y;
  int		CSCR2y;


  R25     = (R<<6) + (R<<1);
  r25     = (R<<6) + (R<<3) + (R<<2) + (R);
  G50     = (G) + (G<<7);
  g50     = (G<<7) + (G<<4) + (G<<2) + (G<<1);
  B09     = (B<<4) + (B<<3) + (B);
  b09     = (B<<4) + (B<<3) + (B<<2) + (B);
  R14     = (R<<5) + (R<<2) + (R<<1);
  r14     = (R<<5) + (R<<3) + (R<<2);
  G29     = (G<<6) + (G<<3) + (G<<1);
  g29     = (G<<6) + (G<<4) + (G<<3) - (G);
  B43     = (B<<6) + (B<<5) + (B<<4);
  b43     = (B<<7) + (B<<1) + (B);
  R43     = (R<<6) + (R<<5) + (R<<4);
  r43     = (R<<7) + (R<<1) + (R);
  G36     = (G<<7) - (G<<5) - (G<<1);
  g36     = (G<<7) - (G<<4) - (G<<1);
  B07     = (B<<4) + (B<<1);
  b07     = (B<<4) + (B<<2) + (B);

   Y  =    (R25>>8)  + (G50>>8) + (B09>>8) + 16 ;
   Cb = (- (R14>>8)) - (G29>>8) + (B43>>8) + 128;
   Cr =    (R43>>8)  - (G36>>8) - (B07>>8) + 128;

// for saturation
   if ( Y > 235 ) Y = 235;
   else if ( Y < 16 ) Y = 16;
   else Y = Y;

   if ( Cb > 240 ) Cb = 240;
   else if ( Cb < 16 ) Cb = 16;
   else Cb = Cb;

   if ( Cr > 240 ) Cr = 240;
   else if ( Cr < 16 ) Cr = 16;
   else Cr = Cr;

   y  =    (r25>>8)  + (g50>>8) + (b09>>8);
   cb = (- (r14>>8)) - (g29>>8) + (b43>>8) + 128;
   cr =    (r43>>8)  - (g36>>8) - (b07>>8) + 128;

// for saturation
   if ( y > 255 ) y = 255;
   else if ( y < 0 ) y = 0;
   else y = y;

   if ( cb > 255 ) cb = 255;
   else if ( cb < 0 ) cb = 0;
   else cb = cb;
   
   if ( cr > 255 ) cr = 255;
   else if ( cr < 0 ) cr = 0;
   else cr = cr;

  /* R2YCSEL == 0 */ 
  CSCR2Y = 0x00ffffff & (((0xff&Y)<<16) + ((0xff&Cb)<<8) + ((0xff&Cr)<<0)); 
  /* R2YCSEL == 1 */
  CSCR2y = 0x00ffffff & (((0xff&y)<<16) + ((0xff&cb)<<8) + ((0xff&cr)<<0)); 


  /* for Monitor
     printf("r25 : %x\n", r25);
     printf("g50 : %x\n", g50);
     printf("b09 : %x\n", b09);
     printf("y : %x\n", y);
     printf("CSCR2y : %x\n", CSCR2y);
     printf("R : %x\n", R);
     printf("G : %x\n", G);
     printf("B : %x\n", B);
     printf("Y : %x\n", Y);
     printf("Cb : %x\n", Cb);
     printf("Cr : %x\n", Cr);

     printf("y : %x\n", y);
     printf("cb : %x\n", cb);
     printf("cr : %x\n", cr);

     printf("YCbCr wide: %x\n", CSCR2Y);
     printf("YCbCr narrow: %x\n", CSCR2y);
   */

  if (R2YCSEL) return CSCR2y;
  else	return CSCR2Y;

}


void CSCY2R (u32 y, u32 cb, u32 cr, u32 Y2RSel, u32  OutRGBFormat)
{
//	unsigned int i;
//	unsigned int horizontal, vertical;
	int s_cb;
	int s_cr;
	int r, g, b;

	if ( Y2RSel == 1 ) 
	{
		if ( y < 64 ) y = 64;
		else if ( y > 940 ) y = 940;
		else y = y;

		if ( cb < 64 ) cb = 64;
		else if ( cb > 960 ) cb = 960;
		else cb = cb;

		if ( cr < 64 ) cr = 64;
		else if ( cr > 960 ) cr = 960;
		else cr = cr;
	}

	if ( Y2RSel == 2 )
	{

		if (cb > 512) 
		{
			cb = cb - 512;
			s_cb = 1;
		} 
		else if ( cb == 0 ) 
		{
			cb = 511;
			s_cb = -1;
		} else 
		{
			cb = 512 - cb;
			s_cb = -1;
		}

		if (cr >= 512) 
		{
			cr = cr - 512;
			s_cr = 1;
		} 
		else if ( cr == 0 ) 
		{
			cr = 511;
			s_cr = -1;
		} 
		else 
		{
			cr = 512 - cr;
			s_cr = -1;
		}
		r = y + s_cr * (((cr<<4) + (cr<<2) + (cr<<1)) >> 4); 
		g = y - s_cr * (((cr<<3) + (cr<<1) + cr) >> 4) - s_cb * (((cb<<4) + (cb<<2) + cb) >> 6);
		b = y + s_cb * (((cb<<2) + (cb<<1) + cb) >> 2);

	}
	else if ( Y2RSel == 1 ) 
	{

		y = y - 64;

		if (cb >= 512) 
		{
			cb = cb - 512;
			s_cb = 1;
		} 
		else 
		{
			cb = 512 - cb;
			s_cb = -1;
		}

		if (cr >= 512) 
		{
			cr = cr - 512;
			s_cr = 1;
		} 
		else 
		{
			cr = 512 - cr;
			s_cr = -1;
		}
		r = (((y<<7) + (y<<4) + (y<<2) + y) >>7 ) + s_cr * (((cr<<4) + (cr<<3) + (cr<<1) + cr) >>4 );
		g = (((y<<7) + (y<<4) + (y<<2) + y) >>7 ) - s_cr * (((cr<<3) + (cr<<2) + cr) >>4 ) - 
		    s_cb * (((cb<<4) + (cb<<3) + cb) >>6 );
		b = (((y<<7) + (y<<4) + (y<<2) + y) >>7 ) + s_cb * ((cb<<1) + (cb>>8));

	}
	else 
	{
		UART_Printf ("Y2R CSC Selection Error\n");
	}

	if ( r > 1023 ) r = 1023;
	else if ( r < 0 ) r = 0;

	if ( g > 1023 ) g = 1023;
	else if ( g < 0 ) g = 0;
	
	if ( b > 1023 ) b = 1023;
	else if ( b < 0 ) b = 0;

⌨️ 快捷键说明

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