I tested how much millisecond it takes to render 1028*720 picture into the texture by below code. I got the result in milliseconds in between the values (47 to 75) .
Due to this , i get the latency, as i m trying to display 30 frames per second, which means maximum of 33.3 milliseconds is needed to render.
SDL_RenderPresent(renderer) might be waiting for Vsync, that’s probably why
the time is so high. Do all your game loop work before calling
SDL_RenderPresent(),
because it will block while waiting for Vsync. To test whether that is
indeed happening, measure the time taken by SDL_RenderPresent().
I tested how much millisecond it takes to render 1028*720 picture into
the texture by below code. I got the result in milliseconds in between the
values (47 to 75) .
Due to this , i get the latency, as i m trying to display 30 frames per
second, which means maximum of 33.3 milliseconds is needed to render.
Thanks, and sure i will check with how much time it is been taken for RenderPresent alone.
What i m doing this: There is a global variable pFrame, which is getting populated with frame by thead, and pushes the event to display.
So, my main event loop is something like:
while (SDL_PollEvent (&event)) {
…
case DISPLAY_MY_FRAME:
/// Here i do
SDL_UpdateYUVTexture(bmp, NULL, pFrame->data[0], pFrame->linesize[0], pFrame->data[1], pFrame->linesize[1],
pFrame->data[2], pFrame->linesize[2]);
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, bmp, NULL, NULL);
SDL_RenderPresent(renderer);
eTime = SDL_GetTicks ();
LOGE (" Time taken for Rendering... %ld ", eTime - sTime);
Which platform are you working on? Windows? Android? iOS?
Why are you calling SDL_UpdateYUVTexture() every frame?
Are you rendering a video? If not, you can just call it once, outside
the rendering loop.
SDL_UpdateYUVTexture() can be a slow function, because the underlying
renderer may not support a YUV texture natively, and in that case
SDL_UpdateYUVTexture() has to do YUV -> RGB conversion in software, and
that can be slow.On 6/3/2014 6:20 PM, keestu wrote:
I checked the time taken for each API.
SDL_UpdateYUVTexture takes more milliseconds, whereas other APIs are
mostly 0 to 1 ms.
It is in Android platform, and i am trying video streaming from RTSP server, To get this done, i use ffmpeg, and whenever i get a complete picture from ffmpeg, i update the texture SDL_UpdateYUVTexture ().
Do u mean Converting YUV to RGB brings down the rendering time? Also, i am not sure if SDL uses hardware acceleration?. If so how to find ?
In-built SDL Renderers on mobile platforms (OpenGLES1 & OpenGLES2) do not
support hardware accelerated YUV textures. It only supports RGB 32 Bit. So
this means SDL is converting YUV data to RBG internally. And that code is
written in C. So it might not be fast enough for your purposes.
Possible Solutions:
Most mobile platforms should offer Hardware Accelerated YUV textures.
You could edit SDL’s OpenGL ES1/ES2 video renderer to add support for
accelerated YUV.
Get a smaller sized video frame from the server (512x384) and convert
it, then upscale it when blitting to the renderer.
Switch to JAVA. Maybe android has an API to do what you are doing. In
that case you wouldn’t need to use SDL at all.
It is in Android platform, and i am trying video streaming from RTSP
server, To get this done, i use ffmpeg, and whenever i get a complete
picture from ffmpeg, i update the texture SDL_UpdateYUVTexture ().
Do u mean Converting YUV to RGB brings down the rendering time? Also, i am
not sure if SDL uses hardware acceleration?. If so how to find ?
Thanks for the reply. If i understand correctly your statement, then “Converting YUV to RGB” enables using Hardware acceleration?, If not how about using OpenGL in SDL?
Thanks for the reply. If i understand correctly your statement, then
"Converting YUV to RGB" enables using Hardware acceleration?, If not how
about using OpenGL in SDL?
It is in Android platform, and i am trying video streaming from RTSP
server, To get this done, i use ffmpeg, and whenever i get a complete
picture from ffmpeg, i update the texture SDL_UpdateYUVTexture ().
Do u mean Converting YUV to RGB brings down the rendering time? Also, i am
not sure if SDL uses hardware acceleration?. If so how to find ?