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

📄 my_convert.c

📁 闻亭提供的DM642EVM板时频编码演示程序
💻 C
字号:
#include <csl.h>
#include <csl_dat.h>
#include <csl_cache.h>

#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 ;
}

⌨️ 快捷键说明

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