www.pudn.com > SobelEdge_all_2.rar > my_convert.c


#include  
#include  
#include  
 
#pragma DATA_SECTION(int_mem_temp, ".user_data_int"); 
#pragma DATA_ALIGN(int_mem_temp, 128); 
unsigned char int_mem_temp[720]; 
 
/* 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. 
 */ 
 
void yuv422to420( char *frameIn[], char *frm_out[], 
                  int width, int height) 
{ 
    char *pSrcY = frameIn[0]; 
    char *pSrcU = frameIn[1]; 
    char *pSrcV = frameIn[2]; 
 
    char *pDestY = frm_out[0]; 
    char *pDestU = frm_out[1]; 
    char *pDestV = frm_out[2]; 
 
    unsigned int id; 
    unsigned int i; 
 
    for( i = 0; i < height; i++) 
    { 
        id = DAT_copy(pSrcY + (i * 720), int_mem_temp, 720); 
        id = DAT_copy(int_mem_temp,      pDestY + (i * 720),  720); 
        DAT_wait(id); 
    } 
 
    for( i = 0; i < (height >> 1); i++) 
    { 
        id = DAT_copy(pSrcU + (i * 720), int_mem_temp, 360); 
        id = DAT_copy(int_mem_temp,      pDestU + (i * 360),  360); 
        DAT_wait(id); 
    } 
 
    for( i = 0; i < (height >> 1); i++) 
    { 
        id = DAT_copy(pSrcV + (i * 720), int_mem_temp, 360); 
        id = DAT_copy(int_mem_temp,      pDestV + (i * 360),  360); 
        DAT_wait(id); 
    } 
 
    return ; 
} 
 
void yuv420to422( char *frameIn[], char *frm_out[], 
                int width, int height) 
{ 
    char *pSrcY = frameIn[0]; 
    char *pSrcU = frameIn[1]; 
    char *pSrcV = frameIn[2]; 
 
    char *pDestY = frm_out[0]; 
    char *pDestU = frm_out[1]; 
    char *pDestV = frm_out[2]; 
 
    unsigned int id; 
    unsigned int i; 
 
    for( i = 0; i < height; i++) 
    { 
        id = DAT_copy(pSrcY + (i * 720), int_mem_temp, 720); 
        id = DAT_copy(int_mem_temp,      pDestY + (i * 720),  720); 
        DAT_wait(id); 
    } 
 
    for( i = 0; i < (height >> 1); i++) 
    { 
        id = DAT_copy(pSrcU + (i * 360), int_mem_temp, 360); 
        id = DAT_copy(int_mem_temp,      pDestU + ((2 * i) * 360),   360); 
        id = DAT_copy(int_mem_temp,      pDestU + ((2*i + 1)* 360),  360); 
        DAT_wait(id); 
    } 
 
    for( i = 0; i < (height >> 1); i++) 
    { 
        id = DAT_copy(pSrcV + (i * 360), int_mem_temp, 360); 
        id = DAT_copy(int_mem_temp,      pDestV + ((2*i) * 360),    360); 
        id = DAT_copy(int_mem_temp,      pDestV + ((2*i+1) * 360),  360); 
        DAT_wait(id); 
    } 
 
   return ; 
}