?? convert.c
字號:
/*
* Copyright 2003 by Texas Instruments Incorporated.
* All rights reserved. Property of Texas Instruments Incorporated.
* Restricted rights to use, duplicate or disclose this code are
* granted through contract.
*
*/
#include <csl.h>
#include <csl_dat.h>
#include <csl_cache.h>
#include <stdio.h>
#include "h264dma.h"
#include "appResources.h"
#include "appThreads.h"
#pragma DATA_SECTION(int_mem_temp, ".INTPROCBUFF");
#pragma DATA_ALIGN(int_mem_temp, MEMALIGN);
unsigned char int_mem_temp[360];
#pragma DATA_SECTION(buffy, ".EXTPROCBUFF");
#pragma DATA_SECTION(buffcr, ".EXTPROCBUFF");
#pragma DATA_SECTION(buffcb, ".EXTPROCBUFF");
#pragma DATA_ALIGN(buffy, MEMALIGN);
#pragma DATA_ALIGN(buffcr, MEMALIGN);
#pragma DATA_ALIGN(buffcb, MEMALIGN);
/* Input for this func will 4:2:2 data. This function
* will convert the data to 4:2:0 and will also reformat
* the data to be contiguous at MB level.
*/
//Temp buffer for 422 to 420
unsigned char buffy[352*288];
unsigned char buffcr[176*288];
unsigned char buffcb[176*288];
void preprocess(unsigned char *inbuff[],unsigned char *outbuff[])
{
int i,j,cnt,k,outId;
unsigned char *pSrcY = inbuff[0];
unsigned char *pSrcU = inbuff[1];
unsigned char *pSrcV = inbuff[2];
unsigned char *pDstY = outbuff[0];
unsigned char *pDstU = outbuff[1];
unsigned char *pDstV = outbuff[2];
DAT_open(DAT_CHAANY,DAT_PRI_LOW,0);
for(i=0;i<288;i++)
{
cnt = 1440*i;
for(j=0;j<352;j+=8)
{
k=2*j+cnt;
int_mem_temp[j+0] = *(pSrcY +8 +k);//(*(pSrcY+k+0) + *(pSrcY+k+1) +*(pSrcY+k+720) + *(pSrcY+k+721)+2)/4;
int_mem_temp[j+1] = *(pSrcY +8 +k+2);//(*(pSrcY+k+2) + *(pSrcY+k+3) +*(pSrcY+k+722) + *(pSrcY+k+723)+2)/4;
int_mem_temp[j+2] = *(pSrcY +8 +k+4);//(*(pSrcY+k+4) + *(pSrcY+k+5) +*(pSrcY+k+724) + *(pSrcY+k+725)+2)/4;
int_mem_temp[j+3] = *(pSrcY +8 +k+6);//(*(pSrcY+k+6) + *(pSrcY+k+7) +*(pSrcY+k+726) + *(pSrcY+k+727)+2)/4;
int_mem_temp[j+4] = *(pSrcY +8 +k+8);//(*(pSrcY+k+8) + *(pSrcY+k+9) +*(pSrcY+k+728) + *(pSrcY+k+729)+2)/4;
int_mem_temp[j+5] = *(pSrcY +8 +k+10);//(*(pSrcY+k+10)+ *(pSrcY+k+11)+*(pSrcY+k+730) + *(pSrcY+k+731)+2)/4;
int_mem_temp[j+6] = *(pSrcY +8 +k+12);//(*(pSrcY+k+12)+ *(pSrcY+k+13)+*(pSrcY+k+732) + *(pSrcY+k+733)+2)/4;
int_mem_temp[j+7] = *(pSrcY +8 +k+14);//(*(pSrcY+k+14)+ *(pSrcY+k+15)+*(pSrcY+k+734) + *(pSrcY+k+735)+2)/4;
}
// memcpy(pDstY+i*360,int_mem_temp,352);
outId = DAT_copy(int_mem_temp,pDstY+i*352,352);
}
for(i=0;i<144;i++)
{
cnt = 1440*i;
for(j=0;j<176;j+=4)
{
k=2*j+cnt;
int_mem_temp[j+0] = *(pSrcU +4 +k+0);//(*(pSrcU+k+0)+ *(pSrcU+k+1)+*(pSrcU+k+720)+*(pSrcU+k+721)+2)/4;
int_mem_temp[j+1] = *(pSrcU +4 +k+2);//(*(pSrcU+k+2)+ *(pSrcU+k+3)+*(pSrcU+k+722)+*(pSrcU+k+723)+2)/4;
int_mem_temp[j+2] = *(pSrcU +4 +k+4);//(*(pSrcU+k+4)+ *(pSrcU+k+5)+*(pSrcU+k+724)+*(pSrcU+k+725)+2)/4;
int_mem_temp[j+3] = *(pSrcU +4 +k+6);//(*(pSrcU+k+6)+ *(pSrcU+k+7)+*(pSrcU+k+726)+*(pSrcU+k+727)+2)/4;
}
// memcpy(pDstU+ 2*i*184, int_mem_temp,176);
// memcpy(pDstU+(2*i+1)*184,int_mem_temp,176);
outId = DAT_copy(int_mem_temp,pDstU+ i*176,176);
// outId = DAT_copy(int_mem_temp,pDstU+ 2*i*176,176);
// outId = DAT_copy(int_mem_temp,pDstU+(2*i+1)*176,176);
}
for(i=0;i<144;i++)
{
cnt = 1440*i;
for(j=0;j<176;j+=4)
{
k=cnt+2*j;
int_mem_temp[j+0] =*(pSrcV +4 +k+0);//(*(pSrcV+k+0)+ *(pSrcV+k+1)+*(pSrcV+k+720)+ *(pSrcV+k+721)+2)/4;
int_mem_temp[j+1] =*(pSrcV +4 +k+2);//(*(pSrcV+k+2)+ *(pSrcV+k+3)+*(pSrcV+k+722)+ *(pSrcV+k+723)+2)/4;
int_mem_temp[j+2] =*(pSrcV +4 +k+4);//(*(pSrcV+k+4)+ *(pSrcV+k+5)+*(pSrcV+k+724)+ *(pSrcV+k+725)+2)/4;
int_mem_temp[j+3] =*(pSrcV +4 +k+6);//(*(pSrcV+k+6)+ *(pSrcV+k+7)+*(pSrcV+k+726)+ *(pSrcV+k+727)+2)/4;
}
// memcpy(pDstV+ 2*i*184, int_mem_temp,176);
// memcpy(pDstV+(2*i+1)*184,int_mem_temp,176);
outId = DAT_copy(int_mem_temp,pDstV+ i*176,176);
// outId = DAT_copy(int_mem_temp,pDstV+ 2*i*176,176);
// outId = DAT_copy(int_mem_temp,pDstV+(2*i+1)*176,176);
}
DAT_wait(outId);
DAT_close();
}
/*
void preprocess(unsigned char *inbuff[],unsigned char *outbuff[])
{
int i,j,cnt,k,outId;
unsigned char *pSrcY = inbuff[0];
unsigned char *pSrcU = inbuff[1];
unsigned char *pSrcV = inbuff[2];
unsigned char *pDstY = outbuff[0];
unsigned char *pDstU = outbuff[1];
unsigned char *pDstV = outbuff[2];
DAT_open(DAT_CHAANY,DAT_PRI_LOW,0);
for(i=0;i<288;i++)
{
cnt = 1440*i;
for(j=0;j<352;j+=8)
{
k=2*j+cnt;
int_mem_temp[j+0] = (*(pSrcY+k+0) + *(pSrcY+k+1) +*(pSrcY+k+720) + *(pSrcY+k+721)+2)/4;
int_mem_temp[j+1] = (*(pSrcY+k+2) + *(pSrcY+k+3) +*(pSrcY+k+722) + *(pSrcY+k+723)+2)/4;
int_mem_temp[j+2] = (*(pSrcY+k+4) + *(pSrcY+k+5) +*(pSrcY+k+724) + *(pSrcY+k+725)+2)/4;
int_mem_temp[j+3] = (*(pSrcY+k+6) + *(pSrcY+k+7) +*(pSrcY+k+726) + *(pSrcY+k+727)+2)/4;
int_mem_temp[j+4] = (*(pSrcY+k+8) + *(pSrcY+k+9) +*(pSrcY+k+728) + *(pSrcY+k+729)+2)/4;
int_mem_temp[j+5] = (*(pSrcY+k+10)+ *(pSrcY+k+11)+*(pSrcY+k+730) + *(pSrcY+k+731)+2)/4;
int_mem_temp[j+6] = (*(pSrcY+k+12)+ *(pSrcY+k+13)+*(pSrcY+k+732) + *(pSrcY+k+733)+2)/4;
int_mem_temp[j+7] = (*(pSrcY+k+14)+ *(pSrcY+k+15)+*(pSrcY+k+734) + *(pSrcY+k+735)+2)/4;
}
// memcpy(pDstY+i*360,int_mem_temp,352);
outId = DAT_copy(int_mem_temp,pDstY+i*352,352);
}
for(i=0;i<144;i++)
{
cnt = 1440*i;
for(j=0;j<176;j+=4)
{
k=2*j+cnt;
int_mem_temp[j+0] = (*(pSrcU+k+0)+ *(pSrcU+k+1)+*(pSrcU+k+720)+*(pSrcU+k+721)+2)/4;
int_mem_temp[j+1] = (*(pSrcU+k+2)+ *(pSrcU+k+3)+*(pSrcU+k+722)+*(pSrcU+k+723)+2)/4;
int_mem_temp[j+2] = (*(pSrcU+k+4)+ *(pSrcU+k+5)+*(pSrcU+k+724)+*(pSrcU+k+725)+2)/4;
int_mem_temp[j+3] = (*(pSrcU+k+6)+ *(pSrcU+k+7)+*(pSrcU+k+726)+*(pSrcU+k+727)+2)/4;
}
// memcpy(pDstU+ 2*i*184, int_mem_temp,176);
// memcpy(pDstU+(2*i+1)*184,int_mem_temp,176);
outId = DAT_copy(int_mem_temp,pDstU+ i*176,176);
// outId = DAT_copy(int_mem_temp,pDstU+ 2*i*176,176);
// outId = DAT_copy(int_mem_temp,pDstU+(2*i+1)*176,176);
}
for(i=0;i<144;i++)
{
cnt = 1440*i;
for(j=0;j<176;j+=4)
{
k=cnt+2*j;
int_mem_temp[j+0] =(*(pSrcV+k+0)+ *(pSrcV+k+1)+*(pSrcV+k+720)+ *(pSrcV+k+721)+2)/4;
int_mem_temp[j+1] =(*(pSrcV+k+2)+ *(pSrcV+k+3)+*(pSrcV+k+722)+ *(pSrcV+k+723)+2)/4;
int_mem_temp[j+2] =(*(pSrcV+k+4)+ *(pSrcV+k+5)+*(pSrcV+k+724)+ *(pSrcV+k+725)+2)/4;
int_mem_temp[j+3] =(*(pSrcV+k+6)+ *(pSrcV+k+7)+*(pSrcV+k+726)+ *(pSrcV+k+727)+2)/4;
}
// memcpy(pDstV+ 2*i*184, int_mem_temp,176);
// memcpy(pDstV+(2*i+1)*184,int_mem_temp,176);
outId = DAT_copy(int_mem_temp,pDstV+ i*176,176);
// outId = DAT_copy(int_mem_temp,pDstV+ 2*i*176,176);
// outId = DAT_copy(int_mem_temp,pDstV+(2*i+1)*176,176);
}
DAT_wait(outId);
}
*/
void yuv422to420( unsigned char *frameIn[],unsigned char *frm_out[], int width, int height,int pitch)
{
#ifdef FORMAT_CIF
unsigned char *buffer[3];
buffer[0] = buffy;
buffer[1] = buffcb;
buffer[2] = buffcr;
CACHE_wbL2(buffer[0], 360*288,CACHE_WAIT);
CACHE_wbL2(buffer[1], 368*144,CACHE_WAIT);
CACHE_wbL2(buffer[2], 368*144,CACHE_WAIT);
preprocess(frameIn,frm_out);
#else
unsigned char *pSrcY = frameIn[0];
unsigned char *pSrcU = frameIn[1];
unsigned char *pSrcV = frameIn[2];
unsigned char *pDestY = frm_out[0];
unsigned char *pDestU = frm_out[1];
unsigned char *pDestV = frm_out[2];
unsigned int qdma_countY, qdma_idxY, qdma_optY;
unsigned int qdma_countU, qdma_idxU, qdma_optU;
unsigned int qdma_countV, qdma_idxV, qdma_optV;
int rowindex;
int ch_width = width>>1;
int ch_height = height >>1;
/*
unsigned char *buffer[3];
#ifdef FORMAT_CIF
buffer[0] = buffy;
buffer[1] = buffcb;
buffer[2] = buffcr;
CACHE_wbL2(buffer[0], 360*288,CACHE_WAIT);
CACHE_wbL2(buffer[1], 368*144,CACHE_WAIT);
CACHE_wbL2(buffer[2], 368*144,CACHE_WAIT);
// preprocess(frameIn,buffer);
// pSrcY = buffer[0];
// pSrcU = buffer[1];
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -