Dear All,
I am playing with SDL in android, and is it meaningful to display Texture of pixel format SDL_PIXELFORMAT_UYVY , with SDL_UpdateYUVTexture ?
Following is my Pseudo Code.
- Window
screen = SDL_CreateWindow (“Test ffmpeg”,SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 1280, 720, SDL_WINDOW_SHOWN|SDL_WINDOW_ALLOW_HIGHDPI );
- Context to convert native pixel format to PIX_FMT_UYVY422
pSwsCtx = sws_getContext (1280, 720, pCodecCtx->pix_fmt, 1280, 720, PIX_FMT_UYVY422, SWS_BICUBIC, NULL, NULL, NULL);
- Texture with SDL_PIXELFORMAT_UYVY
bmp = SDL_CreateTexture (renderer, SDL_PIXELFORMAT_UYVY, SDL_TEXTUREACCESS_STREAMING,1280, 720);
-
For each Frame,
avpicture_fill((AVPicture *)pFrameUYVY422, picture_buf_yuv, PIX_FMT_YUV420P, 1280,720); sws_scale(pSwsCtx, (const uint8_t * const *) pFrame->data, pFrame->linesize, 0, pCodecCtx->height, pFrameUYVY422->data, pFrameUYVY422->linesize); SDL_UpdateYUVTexture(bmp, NULL, pFrameUYVY422->data[0], pFrameUYVY422->linesize[0], pFrameUYVY422->data[1], pFrameUYVY422->linesize[1], pFrameUYVY422->data[2], pFrameUYVY422->linesize[2]);
-
Handle SDL Event
-
Render Copy, and RenderPresent.
-
Repeat to (4).