Skip to content

Commit

Permalink
Updated SDL's YUV support, many thanks to Adrien Descamps
Browse files Browse the repository at this point in the history
New functions get and set the YUV colorspace conversion mode:
	SDL_SetYUVConversionMode()
	SDL_GetYUVConversionMode()
	SDL_GetYUVConversionModeForResolution()

SDL_ConvertPixels() converts between all supported RGB and YUV formats, with SSE acceleration for converting from planar YUV formats (YV12, NV12, etc) to common RGB/RGBA formats.

Added a new test program, testyuv, to verify correctness and speed of YUV conversion functionality.
  • Loading branch information
slouken committed Nov 13, 2017
1 parent c317ab9 commit a6a4e27
Show file tree
Hide file tree
Showing 60 changed files with 8,367 additions and 4,309 deletions.
12 changes: 7 additions & 5 deletions .hgignore
Expand Up @@ -70,14 +70,19 @@ test/controllermap
test/loopwave
test/loopwavequeue
test/testatomic
test/testaudiocapture
test/testaudiohotplug
test/testaudioinfo
test/testautomation
test/testbounds
test/testcustomcursor
test/testdisplayinfo
test/testdraw2
test/testdrawchessboard
test/testdropfile
test/testerror
test/testfile
test/testfilesystem
test/testgamecontroller
test/testgesture
test/testgl2
Expand All @@ -99,7 +104,7 @@ test/testnative
test/testoverlay2
test/testplatform
test/testpower
test/testfilesystem
test/testqsort
test/testrelative
test/testrendercopyex
test/testrendertarget
Expand All @@ -117,11 +122,8 @@ test/testtimer
test/testver
test/testviewport
test/testwm2
test/testbounds
test/testyuv
test/torturethread
test/testdisplayinfo
test/testqsort
test/testaudiocapture
test/*.exe
test/*.dSYM
buildbot
Expand Down
1 change: 1 addition & 0 deletions Android.mk
Expand Up @@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \
$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
$(wildcard $(LOCAL_PATH)/src/video/*.c) \
$(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
$(wildcard $(LOCAL_PATH)/src/video/yuv2rgb/*.c) \
$(wildcard $(LOCAL_PATH)/src/test/*.c))

LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Expand Up @@ -357,6 +357,7 @@ file(GLOB SOURCE_FILES
${SDL2_SOURCE_DIR}/src/thread/*.c
${SDL2_SOURCE_DIR}/src/timer/*.c
${SDL2_SOURCE_DIR}/src/video/*.c)
${SDL2_SOURCE_DIR}/src/video/yuv2rgb/*.c)


if(ASSERTIONS STREQUAL "auto")
Expand Down
8 changes: 6 additions & 2 deletions VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
Expand Up @@ -117,7 +117,7 @@
<ClInclude Include="..\..\src\joystick\windows\SDL_windowsjoystick_c.h" />
<ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h" />
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h" />
<ClInclude Include="..\..\src\render\mmx.h" />
<ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" />
<ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h" />
<ClInclude Include="..\..\src\render\opengles2\SDL_shaders_gles2.h" />
<ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
Expand Down Expand Up @@ -155,12 +155,14 @@
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
<ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtgamebar_cpp.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmessagebox.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtopengles.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h" />
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
Expand Down Expand Up @@ -251,11 +253,11 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
<ClCompile Include="..\..\src\render\SDL_render.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
<ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
<ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
Expand Down Expand Up @@ -305,6 +307,7 @@
<ClCompile Include="..\..\src\video\SDL_stretch.c" />
<ClCompile Include="..\..\src\video\SDL_surface.c" />
<ClCompile Include="..\..\src\video\SDL_video.c" />
<ClCompile Include="..\..\src\video\SDL_yuv.c" />
<ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
Expand Down Expand Up @@ -369,6 +372,7 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{89e9b32e-a86a-47c3-a948-d2b1622925ce}</ProjectGuid>
Expand Down
24 changes: 18 additions & 6 deletions VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj.filters
Expand Up @@ -267,9 +267,6 @@
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\mmx.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h">
<Filter>Source Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -411,6 +408,15 @@
<ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\SDL_yuv_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c">
Expand Down Expand Up @@ -551,9 +557,6 @@
<ClCompile Include="..\..\src\render\SDL_render.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\SDL_yuv_mmx.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -737,5 +740,14 @@
<ClCompile Include="..\..\src\haptic\windows\SDL_xinputhaptic.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\video\SDL_yuv.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj
Expand Up @@ -235,7 +235,7 @@
<ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
<ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h" />
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h" />
<ClInclude Include="..\..\src\render\mmx.h" />
<ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" />
<ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h" />
<ClInclude Include="..\..\src\render\opengles2\SDL_shaders_gles2.h" />
<ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
Expand Down Expand Up @@ -272,12 +272,14 @@
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
<ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtgamebar_cpp.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmessagebox.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtopengles.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h" />
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
Expand Down Expand Up @@ -350,11 +352,11 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
<ClCompile Include="..\..\src\render\SDL_render.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
<ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
<ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
Expand Down Expand Up @@ -404,6 +406,7 @@
<ClCompile Include="..\..\src\video\SDL_stretch.c" />
<ClCompile Include="..\..\src\video\SDL_surface.c" />
<ClCompile Include="..\..\src\video\SDL_video.c" />
<ClCompile Include="..\..\src\video\SDL_yuv.c" />
<ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
Expand Down Expand Up @@ -452,6 +455,7 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsPhone\v$(TargetPlatformVersion)\Microsoft.Cpp.WindowsPhone.$(TargetPlatformVersion).targets" />
Expand Down
24 changes: 18 additions & 6 deletions VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters
Expand Up @@ -216,9 +216,6 @@
<ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\mmx.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\SDL_sysrender.h">
<Filter>Source Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -375,6 +372,15 @@
<ClInclude Include="..\..\src\SDL_dataqueue.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\SDL_yuv_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h">
<Filter>Source Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c">
Expand Down Expand Up @@ -467,9 +473,6 @@
<ClCompile Include="..\..\src\render\SDL_render.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\SDL_yuv_mmx.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -683,5 +686,14 @@
<ClCompile Include="..\..\src\SDL_dataqueue.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\video\SDL_yuv.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project>
8 changes: 6 additions & 2 deletions VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
Expand Up @@ -101,7 +101,7 @@
<ClInclude Include="..\..\src\joystick\SDL_sysjoystick.h" />
<ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h" />
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h" />
<ClInclude Include="..\..\src\render\mmx.h" />
<ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" />
<ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h" />
<ClInclude Include="..\..\src\render\opengles2\SDL_shaders_gles2.h" />
<ClInclude Include="..\..\src\render\SDL_d3dmath.h" />
Expand Down Expand Up @@ -138,12 +138,14 @@
<ClInclude Include="..\..\src\video\SDL_RLEaccel_c.h" />
<ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtevents_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtgamebar_cpp.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmessagebox.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtmouse_c.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtopengles.h" />
<ClInclude Include="..\..\src\video\winrt\SDL_winrtvideo_cpp.h" />
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
Expand Down Expand Up @@ -216,11 +218,11 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_render_gles2.c" />
<ClCompile Include="..\..\src\render\opengles2\SDL_shaders_gles2.c" />
<ClCompile Include="..\..\src\render\SDL_d3dmath.c" />
<ClCompile Include="..\..\src\render\SDL_render.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
<ClCompile Include="..\..\src\render\software\SDL_blendfillrect.c" />
<ClCompile Include="..\..\src\render\software\SDL_blendline.c" />
Expand Down Expand Up @@ -271,6 +273,7 @@
<ClCompile Include="..\..\src\video\SDL_stretch.c" />
<ClCompile Include="..\..\src\video\SDL_surface.c" />
<ClCompile Include="..\..\src\video\SDL_video.c" />
<ClCompile Include="..\..\src\video\SDL_yuv.c" />
<ClCompile Include="..\..\src\video\winrt\SDL_winrtevents.cpp">
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</CompileAsWinRT>
Expand Down Expand Up @@ -319,6 +322,7 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</CompileAsWinRT>
</ClCompile>
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{48fadc0e-964d-4dab-bced-372e0ad19577}</ProjectGuid>
Expand Down
20 changes: 14 additions & 6 deletions VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters
Expand Up @@ -252,9 +252,6 @@
<ClInclude Include="..\..\src\render\direct3d11\SDL_render_winrt.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\mmx.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\opengles2\SDL_gles2funcs.h">
<Filter>Source Files</Filter>
</ClInclude>
Expand Down Expand Up @@ -384,6 +381,13 @@
<ClInclude Include="..\..\src\SDL_dataqueue.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\SDL_yuv_c.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c">
Expand Down Expand Up @@ -515,9 +519,6 @@
<ClCompile Include="..\..\src\render\SDL_render.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\SDL_yuv_mmx.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c">
<Filter>Source Files</Filter>
</ClCompile>
Expand Down Expand Up @@ -695,5 +696,12 @@
<ClCompile Include="..\..\src\SDL_dataqueue.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\video\SDL_yuv.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
</ItemGroup>
</Project>

0 comments on commit a6a4e27

Please sign in to comment.