博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
嵌入式linux------SDL移植(am335x下显示yuv420)
阅读量:6762 次
发布时间:2019-06-26

本文共 1589 字,大约阅读时间需要 5 分钟。

#include
#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

參考:   http://blog.csdn.net/mao0514/article/details/10007873

你可能感兴趣的文章
单例模式
查看>>
.NET实现多个不同有效时间Session方案思考
查看>>
移动端常见问题及解决方案
查看>>
Github 使用的Markdown语言
查看>>
UVA 247 - Calling Circles (Floyd)
查看>>
Exchange: How to get Mailbox size in Exchange Shell?
查看>>
SqlBulkCopy使用心得
查看>>
几点要求自己也可以借鉴
查看>>
Highcharts的一些属性
查看>>
Django 中间件
查看>>
学城项目知识点整理及源码
查看>>
sqlServer,oracle中case关键字的用法
查看>>
表驱动法之保险费率
查看>>
苹果硅胶套市场空间上百亿:合作厂商利润达30%
查看>>
娇俏2011年春装
查看>>
备份还原oracle数据库
查看>>
[转载] AUML——FIPA Modeling Technical Committee
查看>>
Samba Server Configuration - Simple
查看>>
【ZZ】大型数据库应用解决方案总结 | 菜鸟教程
查看>>
Apr. 2th
查看>>