?? tskvideoinput0.c
字號:
/*
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006-2008 Beijing, pengzhen (pengzhenxp@yahoo.com.cn) //
// //
///////////////////////////////////////////////////////////////////////////////
*/
/**
** scale from Yuv422 (704*288 ) to Yuv420 (352*288 )
** scale from Yuv422 (640*240 ) to Yuv420 (320*240 )
*/
//#pragma CODE_SECTION(scale_422_to_420_4x1_c, ".user_data_int");
static /*inline*/ void scale_422_to_420_4x1_c( Yuv420_Queue * dest, FVID_Frame * src,
int width , int height )
{
char * buffer_on_chip = m_buffer_on_chip ; /* the DSP's on-chip memory */
char * y_out = dest->m_pBuf_y ;
char * u_out = dest->m_pBuf_u ;
char * v_out = dest->m_pBuf_v ;
char * y_in = src->frame.iFrm.y1 ;
char * u_in = src->frame.iFrm.cb1 ;
char * v_in = src->frame.iFrm.cr1 ;
int width0 = width << 1 ; /* D1 */
int width_c = width >> 1 ; /* Yuv420 */
int width1 = width >> 5 ; /* 2*4*sizeof(int) = 32 = 2^^5 */
int * lpTmp1 ;
int * lpTmp2 ;
int * lpTmp3 ;
int * lpTmp4 ;
int i, j, id ;
//CACHE_flush(CACHE_L2ALL, 0, 0);
//CACHE_clean(CACHE_L2ALL, 0, 0);
/* the DSP's on-chip memory */
//alloc_mem_on_chip(buffer_on_chip, (width0 << 1) ) ; /* two lines */
/* Y */
#define scale_y_4x1_0() \
*lpTmp2 ++ = _packl4( lpTmp1[1], lpTmp1[0] ) ; lpTmp1 +=2 ; \
*lpTmp2 ++ = _packl4( lpTmp1[1], lpTmp1[0] ) ; lpTmp1 +=2 ; \
#define scale_y_4x1_1() scale_y_4x1_0() scale_y_4x1_0() scale_y_4x1_0() scale_y_4x1_0()
#define scale_y_4x1() j = width1 ; while ( j -- ) { scale_y_4x1_1() }
/* U,V */
#define scale_c_4x1_0() \
*lpTmp3 ++ = _avgu4( _packl4( lpTmp1[1], lpTmp1[0] ), \
_packl4( lpTmp2[1], lpTmp2[0] ) ) ; \
lpTmp1 +=2 ; lpTmp2 +=2 ; \
#define scale_c_4x1_1() scale_c_4x1_0() scale_c_4x1_0() scale_c_4x1_0() scale_c_4x1_0()
#define scale_c_4x1() j = width1 ; while ( j -- ) { scale_c_4x1_1() }
/* Y */
i = height ;
while ( i -- )
{
lpTmp1 = (int * )( buffer_on_chip ) ;
lpTmp3 = lpTmp2 = (int * )( buffer_on_chip + width0 ) ;
id = DAT_copy(y_in, lpTmp1, width0 ) ; /* DMA */
/* if( DAT_busy(id) ) */ { DAT_wait( id ) ; }
/* scale */
scale_y_4x1()
DAT_copy(lpTmp3, y_out, width ) ;
y_in += width0 ; /* next line */
y_out += width ;
}
height >>= 1 ; /* Yuv420 */
/* U */
i = height ;
while ( i -- )
{
lpTmp1 = (int * )( buffer_on_chip ) ;
lpTmp2 = (int * )( buffer_on_chip + width ) ;
lpTmp4 = lpTmp3 = (int * )( buffer_on_chip + width0 ) ;
id = DAT_copy(u_in, lpTmp1, width0 ) ; /* DMA */
/*if( DAT_busy(id) )*/ { DAT_wait( id ) ; } /* two lines */
/* scale */
scale_c_4x1()
DAT_copy(lpTmp4, u_out, width_c ) ;
u_in += width0 ; /* next line */
u_out += width_c ;
}
/* V */
i = height ;
while ( i -- )
{
lpTmp1 = (int * )( buffer_on_chip ) ;
lpTmp2 = (int * )( buffer_on_chip + width ) ;
lpTmp4 = lpTmp3 = (int * )( buffer_on_chip + width0 ) ;
id = DAT_copy(v_in, lpTmp1, width0 ) ; /* DMA */
/*if( DAT_busy(id) )*/ { DAT_wait( id ) ; } /* two lines */
/* scale */
scale_c_4x1()
id = DAT_copy(lpTmp4, v_out, width_c ) ;
v_in += width0 ; /* next line */
v_out += width_c ;
}
// /* if( DAT_busy(id) )*/ { DAT_wait( id ) ; }
/* the DSP's on-chip memory */
//free_mem_on_chip(buffer_on_chip, (width0 << 1) ) ;
#undef scale_y_4x1_0
#undef scale_y_4x1_1
#undef scale_y_4x1
#undef scale_c_4x1_0
#undef scale_c_4x1_1
#undef scale_c_4x1
//CACHE_flush(CACHE_L2ALL, 0, 0);
//CACHE_clean(CACHE_L2ALL, 0, 0);
}
//#pragma CODE_SECTION(scale_422_to_420_c, ".user_data_int");
static /*inline*/ void scale_422_to_420_c( Yuv420_Queue * dest, FVID_Frame * src,
int width , int height )
{
char * buffer_on_chip ; /* the DSP's on-chip memory */
int buffer_cnt = (width << 4); /* 2 width; 4 height; 2 buffer */
char * y_out = dest->m_pBuf_y ;
char * u_out = dest->m_pBuf_u ;
char * v_out = dest->m_pBuf_v ;
char * y_in = src->frame.iFrm.y1 ;
char * u_in = src->frame.iFrm.cb1 ;
char * v_in = src->frame.iFrm.cr1 ;
int width0 = width << 1 ; /* D1 */
int width_c = width >> 1 ; /* Yuv420 */
int width1 = width >> 5 ; /* 2*4*sizeof(int) = 32 = 2^^5 */
int * lpTmp1 ;
int * lpTmp2 ;
int * lpTmp3 ;
int * lpTmp4 ;
int i, j, id ;
//CACHE_flush(CACHE_L2ALL, 0, 0);
//CACHE_clean(CACHE_L2ALL, 0, 0);
/* the DSP's on-chip memory */
buffer_on_chip = MEM_alloc( intHeap, buffer_cnt, 8 ) ; /* 2 lines */
if( ! buffer_on_chip ) { scale_422_to_420_4x1_c( dest, src, width, height ) ; return ; } /* error */
/* Y */
#define scale_y_4x4_0() \
*lpTmp2 ++ = _packl4( lpTmp1[1], lpTmp1[0] ) ; lpTmp1 +=2 ; \
*lpTmp2 ++ = _packl4( lpTmp1[1], lpTmp1[0] ) ; lpTmp1 +=2 ; \
#define scale_y_4x4_1() scale_y_4x4_0() scale_y_4x4_0() scale_y_4x4_0() scale_y_4x4_0()
#define scale_y_4x4() j = width1 ; while ( j -- ) { scale_y_4x4_1() }
/* U,V */
#define scale_c_4x4_0() \
*lpTmp3 ++ = _avgu4( _packl4( lpTmp1[1], lpTmp1[0] ), \
_packl4( lpTmp2[1], lpTmp2[0] ) ) ; \
lpTmp1 +=2 ; lpTmp2 +=2 ; \
#define scale_c_4x4_1() scale_c_4x4_0() scale_c_4x4_0() scale_c_4x4_0() scale_c_4x4_0()
#define scale_c_4x4() j = width1 ; while ( j -- ) { scale_c_4x4_1() }
/* 4 lines */
width <<=2 ;
width0 <<=2 ;
width_c <<=2 ;
height >>= 2 ;
/* Y */
i = height ;
while ( i -- )
{
lpTmp1 = (int * )( buffer_on_chip ) ;
lpTmp3 = lpTmp2 = (int * )( buffer_on_chip + width0 ) ;
id = DAT_copy(y_in, lpTmp1, width0 ) ; /* DMA */
/*if( DAT_busy(id) )*/ { DAT_wait( id ) ; }
/* scale */
scale_y_4x4()
scale_y_4x4()
scale_y_4x4()
scale_y_4x4()
//CACHE_flush(CACHE_L1D, lpTmp3, width>>2 ) ;
DAT_copy(lpTmp3, y_out, width ) ;
y_in += width0 ; /* next line */
y_out += width ;
}
width >>=2 ;
height >>= 1 ; /* Yuv420 */
/* U */
i = height ;
while ( i -- )
{
lpTmp1 = (int * )( buffer_on_chip ) ;
lpTmp2 = (int * )( buffer_on_chip + width ) ;
lpTmp4 = lpTmp3 = (int * )( buffer_on_chip + width0 ) ;
id = DAT_copy(u_in, lpTmp1, width0 ) ; /* DMA */
/*if( DAT_busy(id) )*/ { DAT_wait( id ) ; } /* 2 lines */
/* scale */
scale_c_4x4()
scale_c_4x4()
scale_c_4x4()
scale_c_4x4()
//CACHE_flush(CACHE_L1D, lpTmp4, width_c>>2 ) ;
DAT_copy(lpTmp4, u_out, width_c ) ;
u_in += width0 ; /* next line */
u_out += width_c ;
}
/* V */
i = height ;
while ( i -- )
{
lpTmp1 = (int * )( buffer_on_chip ) ;
lpTmp2 = (int * )( buffer_on_chip + width ) ;
lpTmp4 = lpTmp3 = (int * )( buffer_on_chip + width0 ) ;
id = DAT_copy(v_in, lpTmp1, width0 ) ; /* DMA */
/*if( DAT_busy(id) )*/ { DAT_wait( id ) ; } /* 2 lines */
/* scale */
scale_c_4x4()
scale_c_4x4()
scale_c_4x4()
scale_c_4x4()
//CACHE_flush(CACHE_L1D, lpTmp4, width_c>>2 ) ;
id = DAT_copy(lpTmp4, v_out, width_c ) ;
v_in += width0 ; /* next line */
v_out += width_c ;
}
/*if( DAT_busy(id) )*/ { DAT_wait( id ) ; }
/* the DSP's on-chip memory */
/*if( buffer_on_chip ) */ MEM_free( intHeap, buffer_on_chip, buffer_cnt ) ;
#undef scale_y_4x4_0
#undef scale_y_4x4_1
#undef scale_y_4x4
#undef scale_c_4x4_0
#undef scale_c_4x4_1
#undef scale_c_4x4
//CACHE_flush(CACHE_L2ALL, 0, 0);
//CACHE_clean(CACHE_L2ALL, 0, 0);
}
/**
** dma copy
*/
static /*inline*/ void dma_copy_420_c( Yuv420_Queue * dest, FVID_Frame * src,
int width, int height )
{
char * y_in = src->frame.iFrm.y1 ;
char * u_in = src->frame.iFrm.cb1 ;
char * v_in = src->frame.iFrm.cr1 ;
char * y_out = dest->m_pBuf_y ;
char * u_out = dest->m_pBuf_u ;
char * v_out = dest->m_pBuf_v ;
int width_c = width>>1 ; /* Yuv420 */
int i , id ;
/* Y */
#if 1
DAT_copy2d( DAT_2D2D, y_in, y_out, width, height, width) ;
#else
i = height ;
while( i-- )
{
DAT_copy(y_in, y_out, width) ;
y_in += width ;
y_out += width ;
}
#endif /* 1 */
height >>= 1 ; /* Yuv420 */
/* U */
i = height ;
while( i-- )
{
DAT_copy(u_in, u_out, width_c) ;
u_in += width ;
u_out += width_c ;
}
/* V */
i = height ;
while( i-- )
{
id = DAT_copy(v_in, v_out, width_c) ;
v_in += width ;
v_out += width_c ;
}
DAT_wait( id ) ;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -