嵌入式linux------SDL移植(am335x下显示yuv420)

简介: <pre name="code" class="cpp">#include<stdio.h>#include "/usr/local/ffmpeg_arm/include/SDL/SDL.h"char *bmp_name[3] = {"000.bmp","111.bmp","222.bmp"};int main(){ int i=0; int w = 720
#include<stdio.h>
#include "/usr/local/ffmpeg_arm/include/SDL/SDL.h"
char *bmp_name[3] = {"000.bmp","111.bmp","222.bmp"};
int main()
{
    int i=0;
    int w = 720;
    int h = 576,retu;
    unsigned char* pY;
    unsigned char* pU;
    unsigned char* pV;
    FILE* fp;
    SDL_Rect rect;
    //The images
    SDL_Surface* hello = NULL;
    SDL_Surface* screen = NULL;

    //Start SDL
   // SDL_Init( SDL_INIT_EVERYTHING );
      SDL_Init(SDL_INIT_VIDEO);

    //Set up screen
    screen = SDL_SetVideoMode( 1024, 768, 32, SDL_SWSURFACE );
    SDL_Overlay* overlay = SDL_CreateYUVOverlay(w, h, SDL_YV12_OVERLAY, screen);
    pY = (unsigned char*)malloc(w*h);
    pU = (unsigned char*)malloc(w*h/4);
    pV = (unsigned char*)malloc(w*h/4);
    
    SDL_LockSurface(screen);
    SDL_LockYUVOverlay(overlay);

    fp = fopen("1.yuv", "rb");

    while (!feof(fp))
    {		
        fread(pY, 1, w*h, fp);
        fread(pU, 1, w*h/4, fp);
        fread(pV, 1, w*h/4, fp);
		
        memcpy(overlay->pixels[0], pY, w*h);
        memcpy(overlay->pixels[1], pV, w*h/4);
        memcpy(overlay->pixels[2], pU, w*h/4);
		
       
		
        SDL_UnlockYUVOverlay(overlay);
        SDL_UnlockSurface(screen);
		
        rect.w = w;
        rect.h = h;
        rect.x = rect.y = 0;
        SDL_DisplayYUVOverlay(overlay, &rect);
		
        SDL_Delay(40);
		
        i += 1;
		
    }
	 fclose(fp);
    free(pY);
    free(pU);
    free(pV);
	
	
    SDL_FreeYUVOverlay(overlay);
    SDL_FreeSurface(screen);
    //Quit SDL
    SDL_Quit();

    return 0;
}

编译命令:arm-linux-gcc yuv420.c -o yuv -lpthread libSDL.a

参考:MFC下用sdl 显示bmp、rgb、yuv      http://blog.csdn.net/mao0514/article/details/10007873

相关文章
|
20天前
|
JSON 机器人 Linux
推荐一款嵌入式Linux开源框架与封装-cpp-tbox
推荐一款嵌入式Linux开源框架与封装-cpp-tbox
50 3
|
8天前
|
Linux 编译器 测试技术
嵌入式 Linux 下的 LVGL 移植
嵌入式 Linux 下的 LVGL 移植
|
16天前
|
Linux 计算机视觉
Linux交叉编译opencv并移植ARM端
通过以上步骤,你可以在Linux上交叉编译OpenCV,并将生成的库文件和头文件移植到ARM平台上,从而在ARM上使用OpenCV。 买CN2云服务器,免备案服务器,高防服务器,就选蓝易云。百度搜索:蓝易云
33 0
|
21天前
|
Linux
嵌入式Linux系统(NUC980)tf卡出错处理errors=remount-ro改为errors=continue
嵌入式Linux系统(NUC980)tf卡出错处理errors=remount-ro改为errors=continue
7 1
|
21天前
|
安全 Linux
嵌入式Linux系统关闭串口调试信息的输出
嵌入式Linux系统关闭串口调试信息的输出
13 1
|
21天前
|
Linux 编译器 网络安全
嵌入式Linux移植dropbear
嵌入式Linux移植dropbear
19 3
|
21天前
|
存储 Ubuntu Linux
制作一个嵌入式Linux的应用程序升级文件
制作一个嵌入式Linux的应用程序升级文件
12 2
|
21天前
|
传感器 Linux API
嵌入式Linux串口编程简介
嵌入式Linux串口编程简介
18 1
|
22天前
|
编解码 Ubuntu 算法
【Linux】NUC977移植使用MQTT(基于mosquitto)
【Linux】NUC977移植使用MQTT(基于mosquitto)
|
28天前
|
存储 安全 Linux
嵌入式Linux系统bringup 启动全景解析
嵌入式Linux系统bringup 启动全景解析
70 0