Hi guys! This is my first post here.
I’m currently writing a simple multiplatform media player for windows and mac for internal use using ffmpeg and delphi xe5 and sdl 2.0.1 (mac mini - late 2012, core i5 dual core with HT and HD4000)
I have a problem only on mac, windows version is more then ok On mac i get just a blank black video output in SDL window. Also i get both RGBA and yuv420p frames from ffmeg, but use only first. Here is code example:
Using fixed texture width and height just for testing… No errors given with SDL, no exceptions… So what am i doing wrong? One thing i should say - when i try to get renderer drivers info with SDL_GetRenderDriverInfo i get a total mess both in windows and mac in drivers names. SDL_SetRenderDrawColor works on both platforms giving me red color as written in code. On mac when outputting texture it starts flickering red-black. Also on both platforms SDL window name has one first letter from ‘FX’, so only ‘F’, must it be ansi in bindings? That’s not critical, so the main problem is blank window on mac
Init:
Code:
if SDL_Init(SDL_INIT_EVERYTHING) < 0 then
raise exception.Create(‘SDL_Init error!!!’);
vidwin := SDL_CreateWindow(‘FX’, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, 800, 400, (SDL_WINDOW_OPENGL or SDL_WINDOW_RESIZABLE));
sdlRenderer := SDL_CreateRenderer(vidwin, -1, SDL_RENDERER_ACCELERATED);
if (SDL_SetRenderDrawColor(sdlRenderer, 255, 0, 0, 128)) <> 0 then
raise exception.Create(‘SDL_SetRenderDrawColor error!!!’);
if (SDL_RenderClear(sdlRenderer)) <> 0 then
raise exception.Create(‘SDL_RenderClear error!!!’);
SDL_RenderPresent(sdlRenderer);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, ‘linear’);
SDL_RenderSetLogicalSize(sdlRenderer, 1920, 1080);
sdlTexture := SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ARGB8888,
SDL_TEXTUREACCESS_STREAMING, 1920, 1080);
if sdlTexture = nil then
raise exception.Create(‘SDL_CreateTexture error!!!’);
Main video loop, ABitmap contains full frame:
Code:
if (ABitmap.Map(TMapAccess.maRead, srcbitdata)) then
begin
try
if (SDL_UpdateTexture(sdlTexture, 0, srcbitdata.Data, 1920 * sizeof(Uint32))) <> 0
then
raise exception.Create('SDL_UpdateTexture error in main cycle!!!');
if (SDL_RenderCopy(sdlRenderer, sdlTexture, 0 , 0)) <> 0 then
raise exception.Create('SDL_RenderCopy error in main cycle!!!');
SDL_RenderPresent(sdlRenderer);
finally
ABitmap.Unmap(srcbitdata);
end;
end;