summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.hgignore12
-rwxr-xr-xAndroid.mk1
-rw-r--r--CMakeLists.txt1
-rw-r--r--VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj8
-rw-r--r--VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj.filters24
-rw-r--r--VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj8
-rw-r--r--VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters24
-rw-r--r--VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj8
-rw-r--r--VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters20
-rw-r--r--VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj8
-rw-r--r--VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj.filters24
-rw-r--r--VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj8
-rw-r--r--VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters48
-rw-r--r--VisualC/SDL.sln11
-rw-r--r--VisualC/SDL/SDL.vcxproj11
-rw-r--r--VisualC/SDL/SDL.vcxproj.filters10
-rw-r--r--VisualC/tests/testyuv/testyuv.vcxproj229
-rwxr-xr-xXcode-iOS/SDL/SDL.xcodeproj/project.pbxproj72
-rw-r--r--Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj2
-rw-r--r--Xcode-iOS/Test/Info.plist2
-rwxr-xr-xXcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj117
-rwxr-xr-xXcode/SDL/SDL.xcodeproj/project.pbxproj51
-rwxr-xr-xconfigure1
-rw-r--r--configure.in1
-rw-r--r--include/SDL_surface.h25
-rw-r--r--src/dynapi/SDL_dynapi_overrides.h3
-rw-r--r--src/dynapi/SDL_dynapi_procs.h3
-rw-r--r--src/render/SDL_yuv_mmx.c409
-rw-r--r--src/render/SDL_yuv_sw.c1153
-rw-r--r--src/render/SDL_yuv_sw_c.h10
-rw-r--r--src/render/direct3d/SDL_render_d3d.c414
-rw-r--r--src/render/direct3d/SDL_shaders_d3d.c274
-rw-r--r--src/render/direct3d/SDL_shaders_d3d.h (renamed from src/render/SDL_yuv_mmx_c.h)16
-rwxr-xr-x[-rw-r--r--]src/render/direct3d11/SDL_render_d3d11.c851
-rwxr-xr-xsrc/render/direct3d11/SDL_shaders_d3d11.c1957
-rwxr-xr-xsrc/render/direct3d11/SDL_shaders_d3d11.h43
-rw-r--r--src/render/mmx.h642
-rw-r--r--src/render/opengl/SDL_render_gl.c38
-rw-r--r--src/render/opengl/SDL_shaders_gl.c371
-rw-r--r--src/render/opengl/SDL_shaders_gl.h12
-rw-r--r--src/render/opengles2/SDL_render_gles2.c53
-rw-r--r--src/render/opengles2/SDL_shaders_gles2.c343
-rw-r--r--src/render/opengles2/SDL_shaders_gles2.h20
-rw-r--r--src/video/SDL_pixels.c24
-rw-r--r--src/video/SDL_pixels_c.h1
-rw-r--r--src/video/SDL_surface.c660
-rw-r--r--src/video/SDL_yuv.c1834
-rw-r--r--src/video/SDL_yuv_c.h30
-rw-r--r--src/video/yuv2rgb/LICENSE27
-rw-r--r--src/video/yuv2rgb/README.md63
-rw-r--r--src/video/yuv2rgb/yuv_rgb.c687
-rw-r--r--src/video/yuv2rgb/yuv_rgb.h380
-rw-r--r--src/video/yuv2rgb/yuv_rgb_sse_func.h498
-rw-r--r--src/video/yuv2rgb/yuv_rgb_std_func.h220
-rw-r--r--test/Makefile.in28
-rw-r--r--test/testoverlay2.c115
-rw-r--r--test/testyuv.bmpbin0 -> 739398 bytes
-rw-r--r--test/testyuv.c455
-rw-r--r--test/testyuv_cvt.c300
-rw-r--r--test/testyuv_cvt.h16
60 files changed, 8367 insertions, 4309 deletions
diff --git a/.hgignore b/.hgignore
index 636b7ab19..d4c66b856 100644
--- a/.hgignore
+++ b/.hgignore
@@ -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
@@ -99,7 +104,7 @@ test/testnative
test/testoverlay2
test/testplatform
test/testpower
-test/testfilesystem
+test/testqsort
test/testrelative
test/testrendercopyex
test/testrendertarget
@@ -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
diff --git a/Android.mk b/Android.mk
index d593d68d2..e70ededaf 100755
--- a/Android.mk
+++ b/Android.mk
@@ -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
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1be707e6b..2329d391b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -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")
diff --git a/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj b/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
index 5564b185c..841a0b966 100644
--- a/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
+++ b/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj
@@ -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" />
@@ -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" />
@@ -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" />
@@ -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>
@@ -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>
diff --git a/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj.filters b/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj.filters
index f23cd1890..5a2068996 100644
--- a/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj.filters
+++ b/VisualC-WinRT/UWP_VS2015/SDL-UWP.vcxproj.filters
@@ -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>
@@ -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">
@@ -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>
@@ -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> \ No newline at end of file
diff --git a/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj b/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj
index 183e427f4..2091df090 100644
--- a/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj
+++ b/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj
@@ -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" />
@@ -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" />
@@ -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" />
@@ -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>
@@ -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" />
diff --git a/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters b/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters
index 304c0472d..9aafdce6c 100644
--- a/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters
+++ b/VisualC-WinRT/WinPhone80_VS2012/SDL-WinPhone80.vcxproj.filters
@@ -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>
@@ -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">
@@ -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>
@@ -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> \ No newline at end of file
diff --git a/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj b/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
index c291871b2..f7b887cc6 100644
--- a/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
+++ b/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj
@@ -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" />
@@ -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" />
@@ -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" />
@@ -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>
@@ -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>
diff --git a/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters b/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters
index badba57cc..4bfbe8302 100644
--- a/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters
+++ b/VisualC-WinRT/WinPhone81_VS2013/SDL-WinPhone81.vcxproj.filters
@@ -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>
@@ -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">
@@ -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>
@@ -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> \ No newline at end of file
diff --git a/VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj b/VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj
index f29cd42ac..2e1fc8ba6 100644
--- a/VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj
+++ b/VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj
@@ -114,11 +114,11 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">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" />
@@ -168,6 +168,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>
@@ -232,6 +233,7 @@
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</CompileAsWinRT>
<CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</CompileAsWinRT>
</ClCompile>
+ <ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\include\begin_code.h" />
@@ -323,7 +325,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" />
@@ -361,12 +363,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>
<PropertyGroup Label="Globals">
<ProjectGuid>{aeaea3a2-d4e6-45b1-8ec6-53d84287fc14}</ProjectGuid>
diff --git a/VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj.filters b/VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj.filters
index 5c601be17..3e2f4c68e 100644
--- a/VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj.filters
+++ b/VisualC-WinRT/WinRT80_VS2012/SDL-WinRT80.vcxproj.filters
@@ -220,9 +220,6 @@
<ClCompile Include="..\..\src\audio\xaudio2\SDL_xaudio2_winrthelpers.cpp">
<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>
@@ -322,6 +319,15 @@
<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>
<ItemGroup>
<ClInclude Include="..\..\include\begin_code.h">
@@ -444,9 +450,6 @@
<ClInclude Include="..\..\src\video\SDL_blit_slow.h">
<Filter>Source Files</Filter>
</ClInclude>
- <ClInclude Include="..\..\src\render\mmx.h">
- <Filter>Source Files</Filter>
- </ClInclude>
<ClInclude Include="..\..\include\SDL_config.h">
<Filter>Header Files</Filter>
</ClInclude>
@@ -723,6 +726,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>
<Filter Include="Header Files">
diff --git a/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj b/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj
index ec044385b..d3f34d7a2 100644
--- a/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj
+++ b/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj
@@ -116,7 +116,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" />
@@ -152,12 +152,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" />
@@ -248,11 +250,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" />
@@ -303,6 +305,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>
@@ -367,6 +370,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>{c8df6173-06a1-4f56-a9bc-2002596b30e9}</ProjectGuid>
diff --git a/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters b/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters
index f6b398a97..b499c70a8 100644
--- a/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters
+++ b/VisualC-WinRT/WinRT81_VS2013/SDL-WinRT81.vcxproj.filters
@@ -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>
@@ -384,9 +381,6 @@
<ClInclude Include="..\..\src\joystick\windows\SDL_dinputjoystick_c.h">
<Filter>Source Files</Filter>
</ClInclude>
- <ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h" />
- <ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h" />
- <ClInclude Include="..\..\src\haptic\windows\SDL_xinputhaptic_c.h" />
<ClInclude Include="..\..\src\thread\windows\SDL_systhread_c.h">
<Filter>Source Files</Filter>
</ClInclude>
@@ -396,6 +390,24 @@
<ClInclude Include="..\..\src\SDL_dataqueue.h">
<Filter>Source Files</Filter>
</ClInclude>
+ <ClInclude Include="..\..\src\haptic\windows\SDL_dinputhaptic_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\haptic\windows\SDL_windowshaptic_c.h">
+ <Filter>Source Files</Filter>
+ </ClInclude>
+ <ClInclude Include="..\..\src\haptic\windows\SDL_xinputhaptic_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">
@@ -527,9 +539,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>
@@ -695,9 +704,6 @@
<ClCompile Include="..\..\src\joystick\windows\SDL_dinputjoystick.c">
<Filter>Source Files</Filter>
</ClCompile>
- <ClCompile Include="..\..\src\haptic\windows\SDL_windowshaptic.c" />
- <ClCompile Include="..\..\src\haptic\windows\SDL_xinputhaptic.c" />
- <ClCompile Include="..\..\src\haptic\windows\SDL_dinputhaptic.c" />
<ClCompile Include="..\..\src\thread\windows\SDL_sysmutex.c">
<Filter>Source Files</Filter>
</ClCompile>
@@ -719,5 +725,23 @@
<ClCompile Include="..\..\src\SDL_dataqueue.c">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\haptic\windows\SDL_dinputhaptic.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <ClCompile Include="..\..\src\haptic\windows\SDL_windowshaptic.c">
+ <Filter>Source Files</Filter>
+ </ClCompile>
+ <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> \ No newline at end of file
diff --git a/VisualC/SDL.sln b/VisualC/SDL.sln
index 5feee2409..b30d4eb54 100644
--- a/VisualC/SDL.sln
+++ b/VisualC/SDL.sln
@@ -50,6 +50,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "controllermap", "tests\cont
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testvulkan", "tests\testvulkan\testvulkan.vcxproj", "{0D604DFD-AAB6-442C-9368-F91A344146AB}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testyuv", "tests\testyuv\testyuv.vcxproj", "{40FB7794-D3C3-4CFE-BCF4-A80C97635682}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
@@ -250,6 +252,14 @@ Global
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|Win32.Build.0 = Release|Win32
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|x64.ActiveCfg = Release|x64
{0D604DFD-AAB6-442C-9368-F91A344146AB}.Release|x64.Build.0 = Release|x64
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682}.Debug|Win32.ActiveCfg = Debug|Win32
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682}.Debug|Win32.Build.0 = Debug|Win32
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682}.Debug|x64.ActiveCfg = Debug|x64
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682}.Debug|x64.Build.0 = Debug|x64
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682}.Release|Win32.ActiveCfg = Release|Win32
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682}.Release|Win32.Build.0 = Release|Win32
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682}.Release|x64.ActiveCfg = Release|x64
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -276,5 +286,6 @@ Global
{E9558DFE-1961-4DD4-B09B-DD0EEFD5C315} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
{55812185-D13C-4022-9C81-32E0F4A08306} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
{0D604DFD-AAB6-442C-9368-F91A344146AB} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
+ {40FB7794-D3C3-4CFE-BCF4-A80C97635682} = {D69D5741-611F-4E14-8541-1FEE94F50B5A}
EndGlobalSection
EndGlobal
diff --git a/VisualC/SDL/SDL.vcxproj b/VisualC/SDL/SDL.vcxproj
index 24fd72238..a4fb4478d 100644
--- a/VisualC/SDL/SDL.vcxproj
+++ b/VisualC/SDL/SDL.vcxproj
@@ -78,6 +78,7 @@
<CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <LibraryPath Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">C:\Program Files %28x86%29\Microsoft DirectX SDK %28June 2010%29\Lib\x86;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<PreBuildEvent>
@@ -324,7 +325,8 @@
<ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h" />
<ClInclude Include="..\..\src\libm\math_libm.h" />
<ClInclude Include="..\..\src\libm\math_private.h" />
- <ClInclude Include="..\..\src\render\mmx.h" />
+ <ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" />
+ <ClInclude Include="..\..\src\render\direct3d\SDL_shaders_d3d.h" />
<ClInclude Include="..\..\src\render\opengl\SDL_glfuncs.h" />
<ClInclude Include="..\..\src\render\opengl\SDL_shaders_gl.h" />
<ClInclude Include="..\..\src\render\opengles\SDL_glesfuncs.h" />
@@ -358,6 +360,7 @@
<ClInclude Include="..\..\src\video\SDL_shape_internals.h" />
<ClInclude Include="..\..\src\video\SDL_sysvideo.h" />
<ClInclude Include="..\..\src\video\SDL_vulkan_internal.h" />
+ <ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
<ClInclude Include="..\..\src\video\windows\SDL_vkeys.h" />
<ClInclude Include="..\..\src\video\windows\SDL_windowsclipboard.h" />
<ClInclude Include="..\..\src\video\windows\SDL_windowsevents.h" />
@@ -372,6 +375,7 @@
<ClInclude Include="..\..\src\video\windows\SDL_windowsvulkan.h" />
<ClInclude Include="..\..\src\video\windows\SDL_windowswindow.h" />
<ClInclude Include="..\..\src\video\windows\wmmsg.h" />
+ <ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\atomic\SDL_atomic.c" />
@@ -434,15 +438,16 @@
<ClCompile Include="..\..\src\loadso\windows\SDL_sysloadso.c" />
<ClCompile Include="..\..\src\power\SDL_power.c" />
<ClCompile Include="..\..\src\power\windows\SDL_syspower.c" />
+ <ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
<ClCompile Include="..\..\src\render\direct3d\SDL_render_d3d.c" />
<ClCompile Include="..\..\src\render\direct3d11\SDL_render_d3d11.c" />
+ <ClCompile Include="..\..\src\render\direct3d\SDL_shaders_d3d.c" />
<ClCompile Include="..\..\src\render\opengl\SDL_render_gl.c" />
<ClCompile Include="..\..\src\render\opengl\SDL_shaders_gl.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" />
@@ -494,6 +499,7 @@
<ClCompile Include="..\..\src\video\SDL_surface.c" />
<ClCompile Include="..\..\src\video\SDL_video.c" />
<ClCompile Include="..\..\src\video\SDL_vulkan_utils.c" />
+ <ClCompile Include="..\..\src\video\SDL_yuv.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowsclipboard.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowsevents.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowsframebuffer.c" />
@@ -507,6 +513,7 @@
<ClCompile Include="..\..\src\video\windows\SDL_windowsvideo.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowsvulkan.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowswindow.c" />
+ <ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\main\windows\version.rc" />
diff --git a/VisualC/SDL/SDL.vcxproj.filters b/VisualC/SDL/SDL.vcxproj.filters
index fb00991bf..dcfd74a70 100644
--- a/VisualC/SDL/SDL.vcxproj.filters
+++ b/VisualC/SDL/SDL.vcxproj.filters
@@ -262,7 +262,6 @@
<ClInclude Include="..\..\src\joystick\windows\SDL_xinputjoystick_c.h" />
<ClInclude Include="..\..\src\libm\math_libm.h" />
<ClInclude Include="..\..\src\libm\math_private.h" />
- <ClInclude Include="..\..\src\render\mmx.h" />
<ClInclude Include="..\..\src\render\opengl\SDL_glfuncs.h" />
<ClInclude Include="..\..\src\render\opengl\SDL_shaders_gl.h" />
<ClInclude Include="..\..\src\render\opengles\SDL_glesfuncs.h" />
@@ -310,6 +309,10 @@
<ClInclude Include="..\..\src\video\windows\SDL_windowsvulkan.h" />
<ClInclude Include="..\..\src\video\windows\SDL_windowswindow.h" />
<ClInclude Include="..\..\src\video\windows\wmmsg.h" />
+ <ClInclude Include="..\..\src\video\SDL_yuv_c.h" />
+ <ClInclude Include="..\..\src\video\yuv2rgb\yuv_rgb.h" />
+ <ClInclude Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.h" />
+ <ClInclude Include="..\..\src\render\direct3d\SDL_shaders_d3d.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\libm\e_atan2.c" />
@@ -439,12 +442,15 @@
<ClCompile Include="..\..\src\core\windows\SDL_xinput.c" />
<ClCompile Include="..\..\src\haptic\windows\SDL_xinputhaptic.c" />
<ClCompile Include="..\..\src\joystick\windows\SDL_xinputjoystick.c" />
- <ClCompile Include="..\..\src\render\SDL_yuv_mmx.c" />
<ClCompile Include="..\..\src\render\SDL_yuv_sw.c" />
<ClCompile Include="..\..\src\audio\wasapi\SDL_wasapi.c" />
<ClCompile Include="..\..\src\video\SDL_vulkan_utils.c" />
<ClCompile Include="..\..\src\video\windows\SDL_windowsvulkan.c" />
<ClCompile Include="..\..\src\libm\e_fmod.c" />
+ <ClCompile Include="..\..\src\video\SDL_yuv.c" />
+ <ClCompile Include="..\..\src\video\yuv2rgb\yuv_rgb.c" />
+ <ClCompile Include="..\..\src\render\direct3d11\SDL_shaders_d3d11.c" />
+ <ClCompile Include="..\..\src\render\direct3d\SDL_shaders_d3d.c" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="..\..\src\main\windows\version.rc" />
diff --git a/VisualC/tests/testyuv/testyuv.vcxproj b/VisualC/tests/testyuv/testyuv.vcxproj
new file mode 100644
index 000000000..c5738c67d
--- /dev/null
+++ b/VisualC/tests/testyuv/testyuv.vcxproj
@@ -0,0 +1,229 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{40FB7794-D3C3-4CFE-BCF4-A80C97635682}</ProjectGuid>
+ <RootNamespace>testyuv</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC70.props" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Platform)\$(Configuration)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Platform)\$(Configuration)\</IntDir>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>.\Release/testyuv.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <AdditionalIncludeDirectories>$(SolutionDir)/../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <Midl>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>.\Release/testyuv.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <AdditionalIncludeDirectories>$(SolutionDir)/../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ <Link>
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>Win32</TargetEnvironment>
+ <TypeLibraryName>.\Debug/testyuv.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>$(SolutionDir)/../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <Midl>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MkTypLibCompatible>true</MkTypLibCompatible>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <TargetEnvironment>X64</TargetEnvironment>
+ <TypeLibraryName>.\Debug/testyuv.tlb</TypeLibraryName>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <AdditionalIncludeDirectories>$(SolutionDir)/../include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+ <AdditionalUsingDirectories>%(AdditionalUsingDirectories)</AdditionalUsingDirectories>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <WarningLevel>Level3</WarningLevel>
+ <DebugInformationFormat>OldStyle</DebugInformationFormat>
+ </ClCompile>
+ <ResourceCompile>
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <Culture>0x0409</Culture>
+ </ResourceCompile>
+ <Link>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\..\SDL\SDL.vcxproj">
+ <Project>{81ce8daf-ebb2-4761-8e45-b71abcca8c68}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
+ <ProjectReference Include="..\..\SDLmain\SDLmain.vcxproj">
+ <Project>{da956fd3-e142-46f2-9dd5-c78bebb56b7a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
+ <ProjectReference Include="..\..\SDLtest\SDLtest.vcxproj">
+ <Project>{da956fd3-e143-46f2-9fe5-c77bebc56b1a}</Project>
+ <Private>false</Private>
+ <CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
+ </ProjectReference>
+ </ItemGroup>
+ <ItemGroup>
+ <CustomBuild Include="..\..\..\test\testyuv.bmp">
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Copying %(Filename)%(Extension)</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">copy %(FullPath) $(ProjectDir)\
+</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Copying %(Filename)%(Extension)</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">copy %(FullPath) $(ProjectDir)\
+</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Copying %(Filename)%(Extension)</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">copy %(FullPath) $(ProjectDir)\
+</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
+ <Message Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Copying %(Filename)%(Extension)</Message>
+ <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">copy %(FullPath) $(ProjectDir)\
+</Command>
+ <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)\%(Filename)%(Extension);%(Outputs)</Outputs>
+ </CustomBuild>
+ </ItemGroup>
+ <ItemGroup>
+ <ClCompile Include="..\..\..\test\testyuv.c" />
+ <ClCompile Include="..\..\..\test\testyuv_cvt.c" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="..\..\..\test\testyuv_cvt.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
index 72cd2adf4..4557c94f0 100755
--- a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
@@ -52,8 +52,6 @@
041B2CF212FA0F680087D585 /* SDL_sysrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2CEB12FA0F680087D585 /* SDL_sysrender.h */; };
0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */; };
0420497111E6F03D007E7EC9 /* SDL_clipboardevents.c in Sources */ = {isa = PBXBuildFile; fileRef = 0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */; };
- 04409BA612FA989600FB9AA8 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409BA212FA989600FB9AA8 /* mmx.h */; };
- 04409BA712FA989600FB9AA8 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409BA312FA989600FB9AA8 /* SDL_yuv_mmx.c */; };
04409BA812FA989600FB9AA8 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409BA412FA989600FB9AA8 /* SDL_yuv_sw_c.h */; };
04409BA912FA989600FB9AA8 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409BA512FA989600FB9AA8 /* SDL_yuv_sw.c */; };
0442EC5012FE1C1E004C9285 /* SDL_render_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 0442EC4E12FE1C1E004C9285 /* SDL_render_sw_c.h */; };
@@ -119,6 +117,17 @@
AA0F8495178D5F1A00823F9D /* SDL_systls.c in Sources */ = {isa = PBXBuildFile; fileRef = AA0F8494178D5F1A00823F9D /* SDL_systls.c */; };
AA126AD41617C5E7005ABC8F /* SDL_uikitmodes.h in Headers */ = {isa = PBXBuildFile; fileRef = AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */; };
AA126AD51617C5E7005ABC8F /* SDL_uikitmodes.m in Sources */ = {isa = PBXBuildFile; fileRef = AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */; };
+ AA13B3491FB8B27800D9FEE6 /* SDL_egl_c.h in Headers */ = {isa = PBXBuildFile; fileRef = AA13B3431FB8B27700D9FEE6 /* SDL_egl_c.h */; };
+ AA13B34A1FB8B27800D9FEE6 /* SDL_shape.c in Sources */ = {isa = PBXBuildFile; fileRef = AA13B3441FB8B27800D9FEE6 /* SDL_shape.c */; };
+ AA13B34B1FB8B27800D9FEE6 /* SDL_shape_internals.h in Headers */ = {isa = PBXBuildFile; fileRef = AA13B3451FB8B27800D9FEE6 /* SDL_shape_internals.h */; };
+ AA13B34C1FB8B27800D9FEE6 /* SDL_rect_c.h in Headers */ = {isa = PBXBuildFile; fileRef = AA13B3461FB8B27800D9FEE6 /* SDL_rect_c.h */; };
+ AA13B34D1FB8B27800D9FEE6 /* SDL_egl.c in Sources */ = {isa = PBXBuildFile; fileRef = AA13B3471FB8B27800D9FEE6 /* SDL_egl.c */; };
+ AA13B34E1FB8B27800D9FEE6 /* SDL_yuv_c.h in Headers */ = {isa = PBXBuildFile; fileRef = AA13B3481FB8B27800D9FEE6 /* SDL_yuv_c.h */; };
+ AA13B3501FB8B3CC00D9FEE6 /* SDL_yuv.c in Sources */ = {isa = PBXBuildFile; fileRef = AA13B34F1FB8B3CC00D9FEE6 /* SDL_yuv.c */; };
+ AA13B3571FB8B46400D9FEE6 /* yuv_rgb_std_func.h in Headers */ = {isa = PBXBuildFile; fileRef = AA13B3531FB8B46300D9FEE6 /* yuv_rgb_std_func.h */; };
+ AA13B3581FB8B46400D9FEE6 /* yuv_rgb_sse_func.h in Headers */ = {isa = PBXBuildFile; fileRef = AA13B3541FB8B46300D9FEE6 /* yuv_rgb_sse_func.h */; };
+ AA13B3591FB8B46400D9FEE6 /* yuv_rgb.h in Headers */ = {isa = PBXBuildFile; fileRef = AA13B3551FB8B46300D9FEE6 /* yuv_rgb.h */; };
+ AA13B35A1FB8B46400D9FEE6 /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = AA13B3561FB8B46300D9FEE6 /* yuv_rgb.c */; };
AA628ADB159369E3005138DD /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AD9159369E3005138DD /* SDL_rotate.c */; };
AA628ADC159369E3005138DD /* SDL_rotate.h in Headers */ = {isa = PBXBuildFile; fileRef = AA628ADA159369E3005138DD /* SDL_rotate.h */; };
AA704DD6162AA90A0076D1C1 /* SDL_dropevents_c.h in Headers */ = {isa = PBXBuildFile; fileRef = AA704DD4162AA90A0076D1C1 /* SDL_dropevents_c.h */; };
@@ -222,7 +231,6 @@
FAB598681BB5C31600BE72C5 /* SDL_render_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC4F12FE1C1E004C9285 /* SDL_render_sw.c */; };
FAB5986A1BB5C31600BE72C5 /* SDL_rotate.c in Sources */ = {isa = PBXBuildFile; fileRef = AA628AD9159369E3005138DD /* SDL_rotate.c */; };
FAB5986D1BB5C31600BE72C5 /* SDL_render.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2CEA12FA0F680087D585 /* SDL_render.c */; };
- FAB5986F1BB5C31600BE72C5 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409BA312FA989600FB9AA8 /* SDL_yuv_mmx.c */; };
FAB598711BB5C31600BE72C5 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409BA512FA989600FB9AA8 /* SDL_yuv_sw.c */; };
FAB598721BB5C31600BE72C5 /* SDL_getenv.c in Sources */ = {isa = PBXBuildFile; fileRef = FD3F4A700DEA620800C5B771 /* SDL_getenv.c */; };
FAB598731BB5C31600BE72C5 /* SDL_iconv.c in Sources */ = {isa = PBXBuildFile; fileRef = FD3F4A710DEA620800C5B771 /* SDL_iconv.c */; };
@@ -358,8 +366,6 @@
041B2CEB12FA0F680087D585 /* SDL_sysrender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysrender.h; sourceTree = "<group>"; };
0420496E11E6F03D007E7EC9 /* SDL_clipboardevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_clipboardevents_c.h; sourceTree = "<group>"; };
0420496F11E6F03D007E7EC9 /* SDL_clipboardevents.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_clipboardevents.c; sourceTree = "<group>"; };
- 04409BA212FA989600FB9AA8 /* mmx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mmx.h; sourceTree = "<group>"; };
- 04409BA312FA989600FB9AA8 /* SDL_yuv_mmx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_mmx.c; sourceTree = "<group>"; };
04409BA412FA989600FB9AA8 /* SDL_yuv_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_sw_c.h; sourceTree = "<group>"; };
04409BA512FA989600FB9AA8 /* SDL_yuv_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_sw.c; sourceTree = "<group>"; };
0442EC4E12FE1C1E004C9285 /* SDL_render_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_render_sw_c.h; sourceTree = "<group>"; };
@@ -424,6 +430,17 @@
AA0F8494178D5F1A00823F9D /* SDL_systls.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_systls.c; sourceTree = "<group>"; };
AA126AD21617C5E6005ABC8F /* SDL_uikitmodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_uikitmodes.h; sourceTree = "<group>"; };
AA126AD31617C5E6005ABC8F /* SDL_uikitmodes.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SDL_uikitmodes.m; sourceTree = "<group>"; };
+ AA13B3431FB8B27700D9FEE6 /* SDL_egl_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_egl_c.h; sourceTree = "<group>"; };
+ AA13B3441FB8B27800D9FEE6 /* SDL_shape.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_shape.c; sourceTree = "<group>"; };
+ AA13B3451FB8B27800D9FEE6 /* SDL_shape_internals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_shape_internals.h; sourceTree = "<group>"; };
+ AA13B3461FB8B27800D9FEE6 /* SDL_rect_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rect_c.h; sourceTree = "<group>"; };
+ AA13B3471FB8B27800D9FEE6 /* SDL_egl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_egl.c; sourceTree = "<group>"; };
+ AA13B3481FB8B27800D9FEE6 /* SDL_yuv_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_c.h; sourceTree = "<group>"; };
+ AA13B34F1FB8B3CC00D9FEE6 /* SDL_yuv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv.c; sourceTree = "<group>"; };
+ AA13B3531FB8B46300D9FEE6 /* yuv_rgb_std_func.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_std_func.h; sourceTree = "<group>"; };
+ AA13B3541FB8B46300D9FEE6 /* yuv_rgb_sse_func.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb_sse_func.h; sourceTree = "<group>"; };
+ AA13B3551FB8B46300D9FEE6 /* yuv_rgb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb.h; sourceTree = "<group>"; };
+ AA13B3561FB8B46300D9FEE6 /* yuv_rgb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yuv_rgb.c; sourceTree = "<group>"; };
AA628AD9159369E3005138DD /* SDL_rotate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_rotate.c; sourceTree = "<group>"; };
AA628ADA159369E3005138DD /* SDL_rotate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_rotate.h; sourceTree = "<group>"; };
AA704DD4162AA90A0076D1C1 /* SDL_dropevents_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_dropevents_c.h; sourceTree = "<group>"; };
@@ -608,10 +625,8 @@
041B2CE812FA0F680087D585 /* opengles */,
0402A85412FE70C600CECEE3 /* opengles2 */,
041B2CEC12FA0F680087D585 /* software */,
- 04409BA212FA989600FB9AA8 /* mmx.h */,
041B2CEA12FA0F680087D585 /* SDL_render.c */,
041B2CEB12FA0F680087D585 /* SDL_sysrender.h */,
- 04409BA312FA989600FB9AA8 /* SDL_yuv_mmx.c */,
04409BA412FA989600FB9AA8 /* SDL_yuv_sw_c.h */,
04409BA512FA989600FB9AA8 /* SDL_yuv_sw.c */,
);
@@ -760,6 +775,17 @@
path = steam;
sourceTree = "<group>";
};
+ AA13B3521FB8B41700D9FEE6 /* yuv2rgb */ = {
+ isa = PBXGroup;
+ children = (
+ AA13B3541FB8B46300D9FEE6 /* yuv_rgb_sse_func.h */,
+ AA13B3531FB8B46300D9FEE6 /* yuv_rgb_std_func.h */,
+ AA13B3561FB8B46300D9FEE6 /* yuv_rgb.c */,
+ AA13B3551FB8B46300D9FEE6 /* yuv_rgb.h */,
+ );
+ path = yuv2rgb;
+ sourceTree = "<group>";
+ };
FD3F4A6F0DEA620800C5B771 /* stdlib */ = {
isa = PBXGroup;
children = (
@@ -1070,10 +1096,9 @@
FDA682420DF2374D00F98A1A /* video */ = {
isa = PBXGroup;
children = (
- FD689F090E26E5D900F90B21 /* uikit */,
FDA685F40DF244C800F98A1A /* dummy */,
- FDA683000DF2374E00F98A1A /* SDL_blit.c */,
- FDA683010DF2374E00F98A1A /* SDL_blit.h */,
+ FD689F090E26E5D900F90B21 /* uikit */,
+ AA13B3521FB8B41700D9FEE6 /* yuv2rgb */,
FDA683020DF2374E00F98A1A /* SDL_blit_0.c */,
FDA683030DF2374E00F98A1A /* SDL_blit_1.c */,
FDA683040DF2374E00F98A1A /* SDL_blit_A.c */,
@@ -1084,20 +1109,29 @@
FDA683090DF2374E00F98A1A /* SDL_blit_N.c */,
FDA6830A0DF2374E00F98A1A /* SDL_blit_slow.c */,
0463873A0F0B5B7D0041FD65 /* SDL_blit_slow.h */,
+ FDA683000DF2374E00F98A1A /* SDL_blit.c */,
+ FDA683010DF2374E00F98A1A /* SDL_blit.h */,
FDA6830B0DF2374E00F98A1A /* SDL_bmp.c */,
044E5FB711E606EB0076F181 /* SDL_clipboard.c */,
+ AA13B3431FB8B27700D9FEE6 /* SDL_egl_c.h */,
+ AA13B3471FB8B27800D9FEE6 /* SDL_egl.c */,
0463873E0F0B5B7D0041FD65 /* SDL_fillrect.c */,
- FDA6830F0DF2374E00F98A1A /* SDL_pixels.c */,
FDA683100DF2374E00F98A1A /* SDL_pixels_c.h */,
+ FDA6830F0DF2374E00F98A1A /* SDL_pixels.c */,
+ AA13B3461FB8B27800D9FEE6 /* SDL_rect_c.h */,
FDA683110DF2374E00F98A1A /* SDL_rect.c */,
- FDA683150DF2374E00F98A1A /* SDL_RLEaccel.c */,
FDA683160DF2374E00F98A1A /* SDL_RLEaccel_c.h */,
+ FDA683150DF2374E00F98A1A /* SDL_RLEaccel.c */,
+ AA13B3451FB8B27800D9FEE6 /* SDL_shape_internals.h */,
+ AA13B3441FB8B27800D9FEE6 /* SDL_shape.c */,
FDA683170DF2374E00F98A1A /* SDL_stretch.c */,
FDA683190DF2374E00F98A1A /* SDL_surface.c */,
FDA6831A0DF2374E00F98A1A /* SDL_sysvideo.h */,
FDA6831B0DF2374E00F98A1A /* SDL_video.c */,
4D75171D1EE1D98200820EEA /* SDL_vulkan_internal.h */,
4D75171E1EE1D98200820EEA /* SDL_vulkan_utils.c */,
+ AA13B34F1FB8B3CC00D9FEE6 /* SDL_yuv.c */,
+ AA13B3481FB8B27800D9FEE6 /* SDL_yuv_c.h */,
);
name = video;
path = ../../src/video;
@@ -1144,20 +1178,24 @@
56A6703818565E760007D20F /* SDL_dynapi.h in Headers */,
FD689FCF0E26E9D400F90B21 /* SDL_uikitappdelegate.h in Headers */,
56A6703518565E760007D20F /* SDL_dynapi_overrides.h in Headers */,
+ AA13B3571FB8B46400D9FEE6 /* yuv_rgb_std_func.h in Headers */,
047677BD0EA76A31008ABAF1 /* SDL_syshaptic.h in Headers */,
046387420F0B5B7D0041FD65 /* SDL_blit_slow.h in Headers */,
006E9888119552DD001DE610 /* SDL_rwopsbundlesupport.h in Headers */,
0420497011E6F03D007E7EC9 /* SDL_clipboardevents_c.h in Headers */,
+ AA13B34C1FB8B27800D9FEE6 /* SDL_rect_c.h in Headers */,
+ AA13B3581FB8B46400D9FEE6 /* yuv_rgb_sse_func.h in Headers */,
04BA9D6311EF474A00B60E01 /* SDL_gesture_c.h in Headers */,
04BA9D6511EF474A00B60E01 /* SDL_touch_c.h in Headers */,
041B2CF212FA0F680087D585 /* SDL_sysrender.h in Headers */,
- 04409BA612FA989600FB9AA8 /* mmx.h in Headers */,
04409BA812FA989600FB9AA8 /* SDL_yuv_sw_c.h in Headers */,
+ AA13B3591FB8B46400D9FEE6 /* yuv_rgb.h in Headers */,
04F7807712FB751400FC43C0 /* SDL_blendfillrect.h in Headers */,
04F7807912FB751400FC43C0 /* SDL_blendline.h in Headers */,
04F7807B12FB751400FC43C0 /* SDL_blendpoint.h in Headers */,
04F7807C12FB751400FC43C0 /* SDL_draw.h in Headers */,
04F7807E12FB751400FC43C0 /* SDL_drawline.h in Headers */,
+ AA13B34E1FB8B27800D9FEE6 /* SDL_yuv_c.h in Headers */,
04F7808012FB751400FC43C0 /* SDL_drawpoint.h in Headers */,
04F7808412FB753F00FC43C0 /* SDL_nullframebuffer_c.h in Headers */,
A7A9EEAA1F702631002A5589 /* SDL_steamcontroller.h in Headers */,
@@ -1178,6 +1216,7 @@
AA75589F1595D55500BBD41B /* SDL_config_iphoneos.h in Headers */,
AA7558A01595D55500BBD41B /* SDL_config.h in Headers */,
AA7558A11595D55500BBD41B /* SDL_copying.h in Headers */,
+ AA13B3491FB8B27800D9FEE6 /* SDL_egl_c.h in Headers */,
AA7558A21595D55500BBD41B /* SDL_cpuinfo.h in Headers */,
AA7558A31595D55500BBD41B /* SDL_endian.h in Headers */,
AA7558A41595D55500BBD41B /* SDL_error.h in Headers */,
@@ -1188,6 +1227,7 @@
AA7558A81595D55500BBD41B /* SDL_hints.h in Headers */,
566726461DF72CF5001DD3DB /* SDL_dataqueue.h in Headers */,
AA7558AA1595D55500BBD41B /* SDL_joystick.h in Headers */,
+ AA13B34B1FB8B27800D9FEE6 /* SDL_shape_internals.h in Headers */,
AA7558AB1595D55500BBD41B /* SDL_keyboard.h in Headers */,
AA7558AC1595D55500BBD41B /* SDL_keycode.h in Headers */,
AA7558AD1595D55500BBD41B /* SDL_loadso.h in Headers */,
@@ -1407,7 +1447,6 @@
FAB598681BB5C31600BE72C5 /* SDL_render_sw.c in Sources */,
FAB5986A1BB5C31600BE72C5 /* SDL_rotate.c in Sources */,
FAB5986D1BB5C31600BE72C5 /* SDL_render.c in Sources */,
- FAB5986F1BB5C31600BE72C5 /* SDL_yuv_mmx.c in Sources */,
FAB598711BB5C31600BE72C5 /* SDL_yuv_sw.c in Sources */,
FAB598721BB5C31600BE72C5 /* SDL_getenv.c in Sources */,
FAB598731BB5C31600BE72C5 /* SDL_iconv.c in Sources */,
@@ -1501,6 +1540,7 @@
FD3F4A7A0DEA620800C5B771 /* SDL_stdlib.c in Sources */,
FDA6844D0DF2374E00F98A1A /* SDL_blit.c in Sources */,
FDA6844F0DF2374E00F98A1A /* SDL_blit_0.c in Sources */,
+ AA13B3501FB8B3CC00D9FEE6 /* SDL_yuv.c in Sources */,
FDA684500DF2374E00F98A1A /* SDL_blit_1.c in Sources */,
566726451DF72CF5001DD3DB /* SDL_dataqueue.c in Sources */,
FDA684510DF2374E00F98A1A /* SDL_blit_A.c in Sources */,
@@ -1513,6 +1553,7 @@
FDA6845E0DF2374E00F98A1A /* SDL_rect.c in Sources */,
FDA684620DF2374E00F98A1A /* SDL_RLEaccel.c in Sources */,
FDA684640DF2374E00F98A1A /* SDL_stretch.c in Sources */,
+ AA13B34D1FB8B27800D9FEE6 /* SDL_egl.c in Sources */,
FDA684660DF2374E00F98A1A /* SDL_surface.c in Sources */,
FDA684680DF2374E00F98A1A /* SDL_video.c in Sources */,
FDA685FB0DF244C800F98A1A /* SDL_nullevents.c in Sources */,
@@ -1520,6 +1561,7 @@
FD5F9D2F0E0E08B3008E885B /* SDL_joystick.c in Sources */,
FD689F030E26E5B600F90B21 /* SDL_sysjoystick.m in Sources */,
FD689F1D0E26E5D900F90B21 /* SDL_uikitevents.m in Sources */,
+ AA13B35A1FB8B46400D9FEE6 /* yuv_rgb.c in Sources */,
FD689F1F0E26E5D900F90B21 /* SDL_uikitopengles.m in Sources */,
FD689F210E26E5D900F90B21 /* SDL_uikitvideo.m in Sources */,
FD689F230E26E5D900F90B21 /* SDL_uikitview.m in Sources */,
@@ -1542,7 +1584,6 @@
04FFAB8B12E23B8D00BA343D /* SDL_atomic.c in Sources */,
04FFAB8C12E23B8D00BA343D /* SDL_spinlock.c in Sources */,
041B2CF112FA0F680087D585 /* SDL_render.c in Sources */,
- 04409BA712FA989600FB9AA8 /* SDL_yuv_mmx.c in Sources */,
04409BA912FA989600FB9AA8 /* SDL_yuv_sw.c in Sources */,
04F7807612FB751400FC43C0 /* SDL_blendfillrect.c in Sources */,
04F7807812FB751400FC43C0 /* SDL_blendline.c in Sources */,
@@ -1553,6 +1594,7 @@
0442EC5112FE1C1E004C9285 /* SDL_render_sw.c in Sources */,
0442EC5312FE1C28004C9285 /* SDL_render_gles.c in Sources */,
0442EC5512FE1C3F004C9285 /* SDL_hints.c in Sources */,
+ AA13B34A1FB8B27800D9FEE6 /* SDL_shape.c in Sources */,
0402A85812FE70C600CECEE3 /* SDL_render_gles2.c in Sources */,
0402A85912FE70C600CECEE3 /* SDL_shaders_gles2.c in Sources */,
04BAC09D1300C1290055DE28 /* SDL_log.c in Sources */,
diff --git a/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj b/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj
index 99afeb1ee..89e381e0a 100644
--- a/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/SDLtest/SDL2test.xcodeproj/project.pbxproj
@@ -318,6 +318,7 @@
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -326,6 +327,7 @@
isa = XCBuildConfiguration;
buildSettings = {
EXECUTABLE_PREFIX = lib;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
diff --git a/Xcode-iOS/Test/Info.plist b/Xcode-iOS/Test/Info.plist
index c0f1179d3..cd3c096da 100644
--- a/Xcode-iOS/Test/Info.plist
+++ b/Xcode-iOS/Test/Info.plist
@@ -22,7 +22,5 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
- <key>NSMainNibFile</key>
- <string></string>
</dict>
</plist>
diff --git a/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj b/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
index 2e9cbb3a3..519d1507b 100755
--- a/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
+++ b/Xcode-iOS/Test/TestiPhoneOS.xcodeproj/project.pbxproj
@@ -36,6 +36,22 @@
56ED0508118A8FE400A56AA6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89D0E2D111A00EA573E /* Foundation.framework */; };
56ED0509118A8FE400A56AA6 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89E0E2D111A00EA573E /* CoreAudio.framework */; };
56ED0511118A904200A56AA6 /* testpower.c in Sources */ = {isa = PBXBuildFile; fileRef = 56ED0510118A904200A56AA6 /* testpower.c */; };
+ AA13B3171FB8AEBC00D9FEE6 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FABA34761D8B4EAD00915323 /* AVFoundation.framework */; };
+ AA13B3181FB8AEBC00D9FEE6 /* libSDL2test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AA1EE452176059230029C7A5 /* libSDL2test.a */; };
+ AA13B3191FB8AEBC00D9FEE6 /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = FD1B48B80E3131CA007AB34E /* libSDL2.a */; };
+ AA13B31A1FB8AEBC00D9FEE6 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA684F7A1BAF1A4400DCFD1A /* GameController.framework */; };
+ AA13B31B1FB8AEBC00D9FEE6 /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FA8B4BAC1967076F00F8EB7C /* CoreMotion.framework */; };
+ AA13B31C1FB8AEBC00D9FEE6 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8980E2D111A00EA573E /* AudioToolbox.framework */; };
+ AA13B31D1FB8AEBC00D9FEE6 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A8990E2D111A00EA573E /* QuartzCore.framework */; };
+ AA13B31E1FB8AEBC00D9FEE6 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89A0E2D111A00EA573E /* OpenGLES.framework */; };
+ AA13B31F1FB8AEBC00D9FEE6 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89B0E2D111A00EA573E /* CoreGraphics.framework */; };
+ AA13B3201FB8AEBC00D9FEE6 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89C0E2D111A00EA573E /* UIKit.framework */; };
+ AA13B3211FB8AEBC00D9FEE6 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89D0E2D111A00EA573E /* Foundation.framework */; };
+ AA13B3221FB8AEBC00D9FEE6 /* CoreAudio.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FDA8A89E0E2D111A00EA573E /* CoreAudio.framework */; };
+ AA13B32F1FB8AF0C00D9FEE6 /* testyuv.bmp in Resources */ = {isa = PBXBuildFile; fileRef = AA13B32E1FB8AF0C00D9FEE6 /* testyuv.bmp */; };
+ AA13B3301FB8AF2300D9FEE6 /* testyuv.bmp in Resources */ = {isa = PBXBuildFile; fileRef = AA13B32E1FB8AF0C00D9FEE6 /* testyuv.bmp */; };
+ AA13B35D1FB8B4E200D9FEE6 /* testyuv.c in Sources */ = {isa = PBXBuildFile; fileRef = AA13B35B1FB8B4D600D9FEE6 /* testyuv.c */; };
+ AA13B3611FB8B52500D9FEE6 /* testyuv_cvt.c in Sources */ = {isa = PBXBuildFile; fileRef = AA13B35E1FB8B50D00D9FEE6 /* testyuv_cvt.c */; };
AA1EE470176059D00029C7A5 /* libSDL2test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AA1EE452176059230029C7A5 /* libSDL2test.a */; };
AA1EE47117605A7F0029C7A5 /* libSDL2test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AA1EE452176059230029C7A5 /* libSDL2test.a */; };
AA1EE47417605B5C0029C7A5 /* libSDL2test.a in Frameworks */ = {isa = PBXBuildFile; fileRef = AA1EE452176059230029C7A5 /* libSDL2test.a */; };
@@ -407,6 +423,10 @@
1D6058910D05DD3D006BFB54 /* testwm2.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testwm2.app; sourceTree = BUILT_PRODUCTS_DIR; };
56ED050D118A8FE400A56AA6 /* testpower.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testpower.app; sourceTree = BUILT_PRODUCTS_DIR; };
56ED0510118A904200A56AA6 /* testpower.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testpower.c; path = ../../test/testpower.c; sourceTree = SOURCE_ROOT; };
+ AA13B3261FB8AEBC00D9FEE6 /* testyuv.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testyuv.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ AA13B32E1FB8AF0C00D9FEE6 /* testyuv.bmp */ = {isa = PBXFileReference; lastKnownFileType = image.bmp; name = testyuv.bmp; path = ../../test/testyuv.bmp; sourceTree = "<group>"; };
+ AA13B35B1FB8B4D600D9FEE6 /* testyuv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testyuv.c; path = ../../test/testyuv.c; sourceTree = "<group>"; };
+ AA13B35E1FB8B50D00D9FEE6 /* testyuv_cvt.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testyuv_cvt.c; path = ../../test/testyuv_cvt.c; sourceTree = "<group>"; };
AA1EE44D176059220029C7A5 /* SDL2test.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = SDL2test.xcodeproj; path = ../SDLtest/SDL2test.xcodeproj; sourceTree = "<group>"; };
AAE7DEEC14CBB1E100DF1A0E /* testscale.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testscale.app; sourceTree = BUILT_PRODUCTS_DIR; };
AAE7DF4514CBB43900DF1A0E /* testscale.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testscale.c; path = ../../test/testscale.c; sourceTree = "<group>"; };
@@ -552,6 +572,25 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ AA13B3161FB8AEBC00D9FEE6 /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AA13B3171FB8AEBC00D9FEE6 /* AVFoundation.framework in Frameworks */,
+ AA13B3181FB8AEBC00D9FEE6 /* libSDL2test.a in Frameworks */,
+ AA13B3191FB8AEBC00D9FEE6 /* libSDL2.a in Frameworks */,
+ AA13B31A1FB8AEBC00D9FEE6 /* GameController.framework in Frameworks */,
+ AA13B31B1FB8AEBC00D9FEE6 /* CoreMotion.framework in Frameworks */,
+ AA13B31C1FB8AEBC00D9FEE6 /* AudioToolbox.framework in Frameworks */,
+ AA13B31D1FB8AEBC00D9FEE6 /* QuartzCore.framework in Frameworks */,
+ AA13B31E1FB8AEBC00D9FEE6 /* OpenGLES.framework in Frameworks */,
+ AA13B31F1FB8AEBC00D9FEE6 /* CoreGraphics.framework in Frameworks */,
+ AA13B3201FB8AEBC00D9FEE6 /* UIKit.framework in Frameworks */,
+ AA13B3211FB8AEBC00D9FEE6 /* Foundation.framework in Frameworks */,
+ AA13B3221FB8AEBC00D9FEE6 /* CoreAudio.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
AAE7DEE014CBB1E100DF1A0E /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
@@ -1003,6 +1042,7 @@
FA3D99341BC4E644002C96C8 /* testgamecontroller-TV.app */,
FABA34911D8B575200915323 /* testaudiocapture.app */,
FABA34AA1D8B582100915323 /* loopwav-TV.app */,
+ AA13B3261FB8AEBC00D9FEE6 /* testyuv.app */,
);
name = Products;
sourceTree = "<group>";
@@ -1051,9 +1091,9 @@
FDA8A73B0E2D0F0400EA573E /* src */ = {
isa = PBXGroup;
children = (
- FABA34931D8B578200915323 /* testaudiocapture.c */,
047A63F013285CD100CD7973 /* checkkeys.c */,
FDA8A78B0E2D0F3D00EA573E /* loopwave.c */,
+ FABA34931D8B578200915323 /* testaudiocapture.c */,
FDA8A7410E2D0F1600EA573E /* testaudioinfo.c */,
FDC430090F0D86BF009C87E1 /* testdraw2.c */,
FDA8A7470E2D0F1600EA573E /* testerror.c */,
@@ -1076,6 +1116,8 @@
FDA8A75A0E2D0F1600EA573E /* testtimer.c */,
FDA8A75B0E2D0F1600EA573E /* testver.c */,
FDA8A75F0E2D0F1600EA573E /* testwm2.c */,
+ AA13B35E1FB8B50D00D9FEE6 /* testyuv_cvt.c */,
+ AA13B35B1FB8B4D600D9FEE6 /* testyuv.c */,
FDA8A7610E2D0F1600EA573E /* torturethread.c */,
);
name = src;
@@ -1103,12 +1145,13 @@
FA0EF2281BAF4487000E07A6 /* axis.bmp */,
FA0EF2291BAF4487000E07A6 /* button.bmp */,
FA0EF22A1BAF4487000E07A6 /* controllermap.bmp */,
- FDD2C18A0E2E52FE00B7A85F /* utf8.txt */,
FDA8AAD90E2D33B000EA573E /* icon.bmp */,
FDA8AADA0E2D33BA00EA573E /* moose.dat */,
FDA8AADB0E2D33BA00EA573E /* picture.xbm */,
FDA8AADE0E2D33C100EA573E /* sample.bmp */,
FDA8AAE20E2D33C600EA573E /* sample.wav */,
+ AA13B32E1FB8AF0C00D9FEE6 /* testyuv.bmp */,
+ FDD2C18A0E2E52FE00B7A85F /* utf8.txt */,
);
name = Resources;
sourceTree = "<group>";
@@ -1184,6 +1227,23 @@
productReference = 56ED050D118A8FE400A56AA6 /* testpower.app */;
productType = "com.apple.product-type.application";
};
+ AA13B3111FB8AEBC00D9FEE6 /* testyuv */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = AA13B3231FB8AEBC00D9FEE6 /* Build configuration list for PBXNativeTarget "testyuv" */;
+ buildPhases = (
+ AA13B3121FB8AEBC00D9FEE6 /* Resources */,
+ AA13B3141FB8AEBC00D9FEE6 /* Sources */,
+ AA13B3161FB8AEBC00D9FEE6 /* Frameworks */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = testyuv;
+ productName = Test;
+ productReference = AA13B3261FB8AEBC00D9FEE6 /* testyuv.app */;
+ productType = "com.apple.product-type.application";
+ };
AAE7DEDA14CBB1E100DF1A0E /* testscale */ = {
isa = PBXNativeTarget;
buildConfigurationList = AAE7DEE914CBB1E100DF1A0E /* Build configuration list for PBXNativeTarget "testscale" */;
@@ -1584,6 +1644,9 @@
attributes = {
LastUpgradeCheck = 0630;
TargetAttributes = {
+ AA13B3111FB8AEBC00D9FEE6 = {
+ DevelopmentTeam = EH385AYQ6F;
+ };
FA3D99331BC4E644002C96C8 = {
CreatedOnToolsVersion = 7.1;
};
@@ -1643,6 +1706,7 @@
FDD2C5740E2E8C7400B7A85F /* testtimer */,
FDD2C5B30E2E8CFC00B7A85F /* testver */,
1D6058900D05DD3D006BFB54 /* testwm2 */,
+ AA13B3111FB8AEBC00D9FEE6 /* testyuv */,
FDD2C6E20E2E959E00B7A85F /* torturethread */,
);
};
@@ -1692,6 +1756,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
+ AA13B32F1FB8AF0C00D9FEE6 /* testyuv.bmp in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -1710,6 +1775,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ AA13B3121FB8AEBC00D9FEE6 /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AA13B3301FB8AF2300D9FEE6 /* testyuv.bmp in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
AAE7DEDB14CBB1E100DF1A0E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
@@ -1926,6 +1999,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
+ AA13B3141FB8AEBC00D9FEE6 /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ AA13B3611FB8B52500D9FEE6 /* testyuv_cvt.c in Sources */,
+ AA13B35D1FB8B4E200D9FEE6 /* testyuv.c in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
AAE7DEDD14CBB1E100DF1A0E /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
@@ -2185,6 +2267,24 @@
};
name = Release;
};
+ AA13B3241FB8AEBC00D9FEE6 /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DEVELOPMENT_TEAM = EH385AYQ6F;
+ INFOPLIST_FILE = Info.plist;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Debug;
+ };
+ AA13B3251FB8AEBC00D9FEE6 /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ DEVELOPMENT_TEAM = EH385AYQ6F;
+ INFOPLIST_FILE = Info.plist;
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ };
+ name = Release;
+ };
AAE7DEEA14CBB1E100DF1A0E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
@@ -2221,8 +2321,10 @@
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ ENABLE_BITCODE = NO;
GCC_OPTIMIZATION_LEVEL = 0;
HEADER_SEARCH_PATHS = ../../include;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
@@ -2235,7 +2337,9 @@
isa = XCBuildConfiguration;
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = ../../include;
+ IPHONEOS_DEPLOYMENT_TARGET = 8.0;
OTHER_LDFLAGS = "-ObjC";
"PROVISIONING_PROFILE[sdk=iphoneos*]" = "";
SDKROOT = iphoneos;
@@ -2696,6 +2800,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
+ AA13B3231FB8AEBC00D9FEE6 /* Build configuration list for PBXNativeTarget "testyuv" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ AA13B3241FB8AEBC00D9FEE6 /* Debug */,
+ AA13B3251FB8AEBC00D9FEE6 /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
AAE7DEE914CBB1E100DF1A0E /* Build configuration list for PBXNativeTarget "testscale" */ = {
isa = XCConfigurationList;
buildConfigurations = (
diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
index 4208d9af9..aada0f3e6 100755
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
@@ -25,12 +25,8 @@
0435673F1303160F00BA5428 /* SDL_shaders_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0435673D1303160F00BA5428 /* SDL_shaders_gl.h */; };
043567401303160F00BA5428 /* SDL_shaders_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 0435673C1303160F00BA5428 /* SDL_shaders_gl.c */; };
043567411303160F00BA5428 /* SDL_shaders_gl.h in Headers */ = {isa = PBXBuildFile; fileRef = 0435673D1303160F00BA5428 /* SDL_shaders_gl.h */; };
- 04409B9112FA97ED00FB9AA8 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8D12FA97ED00FB9AA8 /* mmx.h */; };
- 04409B9212FA97ED00FB9AA8 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */; };
04409B9312FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */; };
04409B9412FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */; };
- 04409B9512FA97ED00FB9AA8 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8D12FA97ED00FB9AA8 /* mmx.h */; };
- 04409B9612FA97ED00FB9AA8 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */; };
04409B9712FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */; };
04409B9812FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */; };
0442EC1812FE1BBA004C9285 /* SDL_render_gl.c in Sources */ = {isa = PBXBuildFile; fileRef = 0442EC1712FE1BBA004C9285 /* SDL_render_gl.c */; };
@@ -540,6 +536,10 @@
AA75585E1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA75585F1595D4D800BBD41B /* SDL.h in Headers */ = {isa = PBXBuildFile; fileRef = AA7557F91595D4D800BBD41B /* SDL.h */; settings = {ATTRIBUTES = (Public, ); }; };
AA8167541F5E727800518735 /* SDL_vulkan.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D4820431F0F10B400EDC31C /* SDL_vulkan.h */; settings = {ATTRIBUTES = (Public, ); }; };
+ AA9A7F111FB0206400FED37F /* yuv_rgb.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9A7F0F1FB0206300FED37F /* yuv_rgb.h */; };
+ AA9A7F121FB0206400FED37F /* yuv_rgb.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9A7F101FB0206300FED37F /* yuv_rgb.c */; };
+ AA9A7F151FB0209D00FED37F /* SDL_yuv.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9A7F131FB0209C00FED37F /* SDL_yuv.c */; };
+ AA9A7F161FB0209D00FED37F /* SDL_yuv_c.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9A7F141FB0209C00FED37F /* SDL_yuv_c.h */; };
AA9E4093163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */; };
AA9E4094163BE51E007A2AD0 /* SDL_x11messagebox.c in Sources */ = {isa = PBXBuildFile; fileRef = AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */; };
AA9FF95A1637CBF9000DF050 /* SDL_messagebox.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */; settings = {ATTRIBUTES = (Public, ); }; };
@@ -644,7 +644,6 @@
DB313FB617554B71006C0E22 /* SDL_x11video.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFD412E6671800899322 /* SDL_x11video.h */; };
DB313FB717554B71006C0E22 /* SDL_x11window.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFFD612E6671800899322 /* SDL_x11window.h */; };
DB313FB817554B71006C0E22 /* SDL_sysrender.h in Headers */ = {isa = PBXBuildFile; fileRef = 041B2C9F12FA0D680087D585 /* SDL_sysrender.h */; };
- DB313FB917554B71006C0E22 /* mmx.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8D12FA97ED00FB9AA8 /* mmx.h */; };
DB313FBA17554B71006C0E22 /* SDL_yuv_sw_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */; };
DB313FBB17554B71006C0E22 /* SDL_nullframebuffer_c.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7803712FB748500FC43C0 /* SDL_nullframebuffer_c.h */; };
DB313FBC17554B71006C0E22 /* SDL_blendfillrect.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F7803E12FB74A200FC43C0 /* SDL_blendfillrect.h */; };
@@ -801,7 +800,6 @@
DB31405617554B71006C0E22 /* SDL_x11video.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFD312E6671800899322 /* SDL_x11video.c */; };
DB31405717554B71006C0E22 /* SDL_x11window.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFFD512E6671800899322 /* SDL_x11window.c */; };
DB31405817554B71006C0E22 /* SDL_render.c in Sources */ = {isa = PBXBuildFile; fileRef = 041B2C9E12FA0D680087D585 /* SDL_render.c */; };
- DB31405917554B71006C0E22 /* SDL_yuv_mmx.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */; };
DB31405A17554B71006C0E22 /* SDL_yuv_sw.c in Sources */ = {isa = PBXBuildFile; fileRef = 04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */; };
DB31405B17554B71006C0E22 /* SDL_nullframebuffer.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7803812FB748500FC43C0 /* SDL_nullframebuffer.c */; };
DB31405C17554B71006C0E22 /* SDL_blendfillrect.c in Sources */ = {isa = PBXBuildFile; fileRef = 04F7803D12FB74A200FC43C0 /* SDL_blendfillrect.c */; };
@@ -852,8 +850,6 @@
041B2C9F12FA0D680087D585 /* SDL_sysrender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_sysrender.h; sourceTree = "<group>"; };
0435673C1303160F00BA5428 /* SDL_shaders_gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_shaders_gl.c; sourceTree = "<group>"; };
0435673D1303160F00BA5428 /* SDL_shaders_gl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_shaders_gl.h; sourceTree = "<group>"; };
- 04409B8D12FA97ED00FB9AA8 /* mmx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = mmx.h; sourceTree = "<group>"; };
- 04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_mmx.c; sourceTree = "<group>"; };
04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_sw_c.h; sourceTree = "<group>"; };
04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv_sw.c; sourceTree = "<group>"; };
0442EC1712FE1BBA004C9285 /* SDL_render_gl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_render_gl.c; sourceTree = "<group>"; };
@@ -1104,6 +1100,10 @@
AA7557F71595D4D800BBD41B /* SDL_version.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_version.h; sourceTree = "<group>"; };
AA7557F81595D4D800BBD41B /* SDL_video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_video.h; sourceTree = "<group>"; };
AA7557F91595D4D800BBD41B /* SDL.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL.h; sourceTree = "<group>"; };
+ AA9A7F0F1FB0206300FED37F /* yuv_rgb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = yuv_rgb.h; sourceTree = "<group>"; };
+ AA9A7F101FB0206300FED37F /* yuv_rgb.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = yuv_rgb.c; sourceTree = "<group>"; };
+ AA9A7F131FB0209C00FED37F /* SDL_yuv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_yuv.c; sourceTree = "<group>"; };
+ AA9A7F141FB0209C00FED37F /* SDL_yuv_c.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_yuv_c.h; sourceTree = "<group>"; };
AA9E4092163BE51E007A2AD0 /* SDL_x11messagebox.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_x11messagebox.c; sourceTree = "<group>"; };
AA9FF9591637CBF9000DF050 /* SDL_messagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_messagebox.h; sourceTree = "<group>"; };
AABCC38B164063D200AB8930 /* SDL_cocoamessagebox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SDL_cocoamessagebox.h; sourceTree = "<group>"; };
@@ -1264,10 +1264,8 @@
children = (
041B2C9A12FA0D680087D585 /* opengl */,
041B2CA012FA0D680087D585 /* software */,
- 04409B8D12FA97ED00FB9AA8 /* mmx.h */,
041B2C9E12FA0D680087D585 /* SDL_render.c */,
041B2C9F12FA0D680087D585 /* SDL_sysrender.h */,
- 04409B8E12FA97ED00FB9AA8 /* SDL_yuv_mmx.c */,
04409B8F12FA97ED00FB9AA8 /* SDL_yuv_sw_c.h */,
04409B9012FA97ED00FB9AA8 /* SDL_yuv_sw.c */,
);
@@ -1568,8 +1566,7 @@
04BDFEC112E6671800899322 /* cocoa */,
04BDFEE712E6671800899322 /* dummy */,
04BDFFB712E6671800899322 /* x11 */,
- 04BDFF4E12E6671800899322 /* SDL_blit.c */,
- 04BDFF4F12E6671800899322 /* SDL_blit.h */,
+ AA9A7F0E1FB0200B00FED37F /* yuv2rgb */,
04BDFF5012E6671800899322 /* SDL_blit_0.c */,
04BDFF5112E6671800899322 /* SDL_blit_1.c */,
04BDFF5212E6671800899322 /* SDL_blit_A.c */,
@@ -1580,22 +1577,26 @@
04BDFF5712E6671800899322 /* SDL_blit_N.c */,
04BDFF5812E6671800899322 /* SDL_blit_slow.c */,
04BDFF5912E6671800899322 /* SDL_blit_slow.h */,
+ 04BDFF4E12E6671800899322 /* SDL_blit.c */,
+ 04BDFF4F12E6671800899322 /* SDL_blit.h */,
04BDFF5A12E6671800899322 /* SDL_bmp.c */,
04BDFF5B12E6671800899322 /* SDL_clipboard.c */,
04BDFF6012E6671800899322 /* SDL_fillrect.c */,
- 04BDFF6512E6671800899322 /* SDL_pixels.c */,
04BDFF6612E6671800899322 /* SDL_pixels_c.h */,
+ 04BDFF6512E6671800899322 /* SDL_pixels.c */,
04BDFF6712E6671800899322 /* SDL_rect.c */,
- 04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */,
04BDFF7012E6671800899322 /* SDL_RLEaccel_c.h */,
- 04BDFF7112E6671800899322 /* SDL_shape.c */,
+ 04BDFF6F12E6671800899322 /* SDL_RLEaccel.c */,
04BDFF7212E6671800899322 /* SDL_shape_internals.h */,
+ 04BDFF7112E6671800899322 /* SDL_shape.c */,
04BDFF7312E6671800899322 /* SDL_stretch.c */,
04BDFF7412E6671800899322 /* SDL_surface.c */,
04BDFF7512E6671800899322 /* SDL_sysvideo.h */,
04BDFF7612E6671800899322 /* SDL_video.c */,
4D16644C1EDD6023003DE88E /* SDL_vulkan_internal.h */,
4D16644D1EDD6023003DE88E /* SDL_vulkan_utils.c */,
+ AA9A7F141FB0209C00FED37F /* SDL_yuv_c.h */,
+ AA9A7F131FB0209C00FED37F /* SDL_yuv.c */,
);
name = video;
path = ../../src/video;
@@ -1763,6 +1764,16 @@
name = dynapi;
sourceTree = "<group>";
};
+ AA9A7F0E1FB0200B00FED37F /* yuv2rgb */ = {
+ isa = PBXGroup;
+ children = (
+ AA9A7F101FB0206300FED37F /* yuv_rgb.c */,
+ AA9A7F0F1FB0206300FED37F /* yuv_rgb.h */,
+ );
+ name = yuv2rgb;
+ path = ../../src/video/yuv2rgb;
+ sourceTree = SOURCE_ROOT;
+ };
BEC562FE0761C0E800A33029 /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
@@ -1882,6 +1893,7 @@
04BD004B12E6671800899322 /* SDL_events_c.h in Headers */,
04BD004D12E6671800899322 /* SDL_gesture_c.h in Headers */,
04BD004F12E6671800899322 /* SDL_keyboard_c.h in Headers */,
+ AA9A7F111FB0206400FED37F /* yuv_rgb.h in Headers */,
04BD005112E6671800899322 /* SDL_mouse_c.h in Headers */,
04BD005312E6671800899322 /* SDL_sysevents.h in Headers */,
04BD005512E6671800899322 /* SDL_touch_c.h in Headers */,
@@ -1937,7 +1949,7 @@
04BD01F712E6671800899322 /* SDL_x11video.h in Headers */,
04BD01F912E6671800899322 /* SDL_x11window.h in Headers */,
041B2CA612FA0D680087D585 /* SDL_sysrender.h in Headers */,
- 04409B9112FA97ED00FB9AA8 /* mmx.h in Headers */,
+ AA9A7F161FB0209D00FED37F /* SDL_yuv_c.h in Headers */,
04409B9312FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */,
04F7803912FB748500FC43C0 /* SDL_nullframebuffer_c.h in Headers */,
04F7804A12FB74A200FC43C0 /* SDL_blendfillrect.h in Headers */,
@@ -2094,7 +2106,6 @@
AAC07100195606770073DCDF /* SDL_opengles2_gl2ext.h in Headers */,
04BD041112E6671800899322 /* SDL_x11window.h in Headers */,
041B2CAC12FA0D680087D585 /* SDL_sysrender.h in Headers */,
- 04409B9512FA97ED00FB9AA8 /* mmx.h in Headers */,
04409B9712FA97ED00FB9AA8 /* SDL_yuv_sw_c.h in Headers */,
04F7803B12FB748500FC43C0 /* SDL_nullframebuffer_c.h in Headers */,
04F7805612FB74A200FC43C0 /* SDL_blendfillrect.h in Headers */,
@@ -2249,7 +2260,6 @@
AAC07101195606770073DCDF /* SDL_opengles2_gl2ext.h in Headers */,
DB313FB717554B71006C0E22 /* SDL_x11window.h in Headers */,
DB313FB817554B71006C0E22 /* SDL_sysrender.h in Headers */,
- DB313FB917554B71006C0E22 /* mmx.h in Headers */,
DB313FBA17554B71006C0E22 /* SDL_yuv_sw_c.h in Headers */,
DB313FBB17554B71006C0E22 /* SDL_nullframebuffer_c.h in Headers */,
DB313FBC17554B71006C0E22 /* SDL_blendfillrect.h in Headers */,
@@ -2475,6 +2485,7 @@
04BD00F412E6671800899322 /* SDL_cocoaclipboard.m in Sources */,
04BD00F612E6671800899322 /* SDL_cocoaevents.m in Sources */,
04BD00F812E6671800899322 /* SDL_cocoakeyboard.m in Sources */,
+ AA9A7F151FB0209D00FED37F /* SDL_yuv.c in Sources */,
04BD00FA12E6671800899322 /* SDL_cocoamodes.m in Sources */,
4D16644F1EDD6023003DE88E /* SDL_vulkan_utils.c in Sources */,
04BD00FC12E6671800899322 /* SDL_cocoamouse.m in Sources */,
@@ -2487,6 +2498,7 @@
04BD017512E6671800899322 /* SDL_blit.c in Sources */,
04BD017712E6671800899322 /* SDL_blit_0.c in Sources */,
04BD017812E6671800899322 /* SDL_blit_1.c in Sources */,
+ AA9A7F121FB0206400FED37F /* yuv_rgb.c in Sources */,
04BD017912E6671800899322 /* SDL_blit_A.c in Sources */,
04BD017A12E6671800899322 /* SDL_blit_auto.c in Sources */,
04BD017C12E6671800899322 /* SDL_blit_copy.c in Sources */,
@@ -2516,7 +2528,6 @@
04BD01F612E6671800899322 /* SDL_x11video.c in Sources */,
04BD01F812E6671800899322 /* SDL_x11window.c in Sources */,
041B2CA512FA0D680087D585 /* SDL_render.c in Sources */,
- 04409B9212FA97ED00FB9AA8 /* SDL_yuv_mmx.c in Sources */,
04409B9412FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */,
04F7803A12FB748500FC43C0 /* SDL_nullframebuffer.c in Sources */,
04F7804912FB74A200FC43C0 /* SDL_blendfillrect.c in Sources */,
@@ -2641,7 +2652,6 @@
04BD040E12E6671800899322 /* SDL_x11video.c in Sources */,
04BD041012E6671800899322 /* SDL_x11window.c in Sources */,
041B2CAB12FA0D680087D585 /* SDL_render.c in Sources */,
- 04409B9612FA97ED00FB9AA8 /* SDL_yuv_mmx.c in Sources */,
04409B9812FA97ED00FB9AA8 /* SDL_yuv_sw.c in Sources */,
04F7803C12FB748500FC43C0 /* SDL_nullframebuffer.c in Sources */,
04F7805512FB74A200FC43C0 /* SDL_blendfillrect.c in Sources */,
@@ -2764,7 +2774,6 @@
DB31405617554B71006C0E22 /* SDL_x11video.c in Sources */,
DB31405717554B71006C0E22 /* SDL_x11window.c in Sources */,
DB31405817554B71006C0E22 /* SDL_render.c in Sources */,
- DB31405917554B71006C0E22 /* SDL_yuv_mmx.c in Sources */,
DB31405A17554B71006C0E22 /* SDL_yuv_sw.c in Sources */,
DB31405B17554B71006C0E22 /* SDL_nullframebuffer.c in Sources */,
DB31405C17554B71006C0E22 /* SDL_blendfillrect.c in Sources */,
diff --git a/configure b/configure
index b233aca8e..743cd0552 100755
--- a/configure
+++ b/configure
@@ -16874,6 +16874,7 @@ SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
SOURCES="$SOURCES $srcdir/src/thread/*.c"
SOURCES="$SOURCES $srcdir/src/timer/*.c"
SOURCES="$SOURCES $srcdir/src/video/*.c"
+SOURCES="$SOURCES $srcdir/src/video/yuv2rgb/*.c"
# Check whether --enable-atomic was given.
diff --git a/configure.in b/configure.in
index f8b556eb6..e55d02e3e 100644
--- a/configure.in
+++ b/configure.in
@@ -343,6 +343,7 @@ SOURCES="$SOURCES $srcdir/src/stdlib/*.c"
SOURCES="$SOURCES $srcdir/src/thread/*.c"
SOURCES="$SOURCES $srcdir/src/timer/*.c"
SOURCES="$SOURCES $srcdir/src/video/*.c"
+SOURCES="$SOURCES $srcdir/src/video/yuv2rgb/*.c"
dnl Enable/disable various subsystems of the SDL library
diff --git a/include/SDL_surface.h b/include/SDL_surface.h
index 510690c9c..ab9ba1197 100644
--- a/include/SDL_surface.h
+++ b/include/SDL_surface.h
@@ -98,6 +98,17 @@ typedef int (SDLCALL *SDL_blit) (struct SDL_Surface * src, SDL_Rect * srcrect,
struct SDL_Surface * dst, SDL_Rect * dstrect);
/**
+ * \brief The formula used for converting between YUV and RGB
+ */
+typedef enum
+{
+ SDL_YUV_CONVERSION_JPEG, /**< Full range JPEG */
+ SDL_YUV_CONVERSION_BT601, /**< BT.601 (the default) */
+ SDL_YUV_CONVERSION_BT709, /**< BT.709 */
+ SDL_YUV_CONVERSION_AUTOMATIC /**< BT.601 for SD content, BT.709 for HD content */
+} SDL_YUV_CONVERSION_MODE;
+
+/**
* Allocate and free an RGB surface.
*
* If the depth is 4 or 8 bits, an empty palette is allocated for the surface.
@@ -509,6 +520,20 @@ extern DECLSPEC int SDLCALL SDL_LowerBlitScaled
(SDL_Surface * src, SDL_Rect * srcrect,
SDL_Surface * dst, SDL_Rect * dstrect);
+/**
+ * \brief Set the YUV conversion mode
+ */
+extern DECLSPEC void SDLCALL SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode);
+
+/**
+ * \brief Get the YUV conversion mode
+ */
+extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionMode(void);
+
+/**
+ * \brief Get the YUV conversion mode, returning the correct mode for the resolution when the current conversion mode is SDL_YUV_CONVERSION_AUTOMATIC
+ */
+extern DECLSPEC SDL_YUV_CONVERSION_MODE SDLCALL SDL_GetYUVConversionModeForResolution(int width, int height);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus
diff --git a/src/dynapi/SDL_dynapi_overrides.h b/src/dynapi/SDL_dynapi_overrides.h
index 5f2c0a428..cf61acf9b 100644
--- a/src/dynapi/SDL_dynapi_overrides.h
+++ b/src/dynapi/SDL_dynapi_overrides.h
@@ -660,3 +660,6 @@
#define SDL_scalbnf SDL_scalbnf_REAL
#define SDL_fmod SDL_fmod_REAL
#define SDL_fmodf SDL_fmodf_REAL
+#define SDL_SetYUVConversionMode SDL_SetYUVConversionMode_REAL
+#define SDL_GetYUVConversionMode SDL_GetYUVConversionMode_REAL
+#define SDL_GetYUVConversionModeForResolution SDL_GetYUVConversionModeForResolution_REAL
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 01b4da198..de2d48807 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -694,3 +694,6 @@ SDL_DYNAPI_PROC(float,SDL_powf,(float a, float b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_scalbnf,(float a, int b),(a,b),return)
SDL_DYNAPI_PROC(double,SDL_fmod,(double a, double b),(a,b),return)
SDL_DYNAPI_PROC(float,SDL_fmodf,(float a, float b),(a,b),return)
+SDL_DYNAPI_PROC(void,SDL_SetYUVConversionMode,(SDL_YUV_CONVERSION_MODE a),(a),)
+SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionMode,(void),(),return)
+SDL_DYNAPI_PROC(SDL_YUV_CONVERSION_MODE,SDL_GetYUVConversionModeForResolution,(int a, int b),(a,b),return)
diff --git a/src/render/SDL_yuv_mmx.c b/src/render/SDL_yuv_mmx.c
deleted file mode 100644
index 90da9f9b9..000000000
--- a/src/render/SDL_yuv_mmx.c
+++ /dev/null
@@ -1,409 +0,0 @@
-/*
- Simple DirectMedia Layer
- Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-*/
-#include "../SDL_internal.h"
-
-#include "SDL_yuv_mmx_c.h"
-
-#ifdef USE_MMX_ASSEMBLY
-
-#include "SDL_stdinc.h"
-
-#include "mmx.h"
-
-/* *INDENT-OFF* */
-
-static mmx_t MMX_0080w = { .ud = {0x00800080, 0x00800080} };
-static mmx_t MMX_00FFw = { .ud = {0x00ff00ff, 0x00ff00ff} };
-static mmx_t MMX_FF00w = { .ud = {0xff00ff00, 0xff00ff00} };
-
-static mmx_t MMX_Ycoeff = { .uw = {0x004a, 0x004a, 0x004a, 0x004a} };
-
-static mmx_t MMX_UbluRGB = { .uw = {0x0072, 0x0072, 0x0072, 0x0072} };
-static mmx_t MMX_VredRGB = { .uw = {0x0059, 0x0059, 0x0059, 0x0059} };
-static mmx_t MMX_UgrnRGB = { .uw = {0xffea, 0xffea, 0xffea, 0xffea} };
-static mmx_t MMX_VgrnRGB = { .uw = {0xffd2, 0xffd2, 0xffd2, 0xffd2} };
-
-static mmx_t MMX_Ublu5x5 = { .uw = {0x0081, 0x0081, 0x0081, 0x0081} };
-static mmx_t MMX_Vred5x5 = { .uw = {0x0066, 0x0066, 0x0066, 0x0066} };
-static mmx_t MMX_Ugrn565 = { .uw = {0xffe8, 0xffe8, 0xffe8, 0xffe8} };
-static mmx_t MMX_Vgrn565 = { .uw = {0xffcd, 0xffcd, 0xffcd, 0xffcd} };
-
-static mmx_t MMX_red565 = { .uw = {0xf800, 0xf800, 0xf800, 0xf800} };
-static mmx_t MMX_grn565 = { .uw = {0x07e0, 0x07e0, 0x07e0, 0x07e0} };
-
-/**
- This MMX assembler is my first assembler/MMX program ever.
- Thus it maybe buggy.
- Send patches to:
- mvogt@rhrk.uni-kl.de
-
- After it worked fine I have "obfuscated" the code a bit to have
- more parallism in the MMX units. This means I moved
- initilisation around and delayed other instruction.
- Performance measurement did not show that this brought any advantage
- but in theory it _should_ be faster this way.
-
- The overall performanve gain to the C based dither was 30%-40%.
- The MMX routine calculates 256bit=8RGB values in each cycle
- (4 for row1 & 4 for row2)
-
- The red/green/blue.. coefficents are taken from the mpeg_play
- player. They look nice, but I dont know if you can have
- better values, to avoid integer rounding errors.
-
-
- IMPORTANT:
- ==========
-
- It is a requirement that the cr/cb/lum are 8 byte aligned and
- the out are 16byte aligned or you will/may get segfaults
-
-*/
-
-void ColorRGBDitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod )
-{
- Uint32 *row1;
- Uint32 *row2;
-
- unsigned char* y = lum +cols*rows; /* Pointer to the end */
- int x = 0;
- row1 = (Uint32 *)out; /* 32 bit target */
- row2 = (Uint32 *)out+cols+mod; /* start of second row */
- mod = (mod+cols+mod)*4; /* increment for row1 in byte */
-
- __asm__ __volatile__ (
- ".align 8\n"
- "1:\n"
-
- /* create Cr (result in mm1) */
- "movd (%0),%%mm1\n" /* 0 0 0 0 v3 v2 v1 v0 */
- "pxor %%mm7,%%mm7\n" /* 00 00 00 00 00 00 00 00 */
- "movd (%2), %%mm2\n" /* 0 0 0 0 l3 l2 l1 l0 */
- "punpcklbw %%mm7,%%mm1\n" /* 0 v3 0 v2 00 v1 00 v0 */
- "punpckldq %%mm1,%%mm1\n" /* 00 v1 00 v0 00 v1 00 v0 */
- "psubw %9,%%mm1\n" /* mm1-128:r1 r1 r0 r0 r1 r1 r0 r0 */
-
- /* create Cr_g (result in mm0) */
- "movq %%mm1,%%mm0\n" /* r1 r1 r0 r0 r1 r1 r0 r0 */
- "pmullw %10,%%mm0\n" /* red*-46dec=0.7136*64 */
- "pmullw %11,%%mm1\n" /* red*89dec=1.4013*64 */
- "psraw $6, %%mm0\n" /* red=red/64 */
- "psraw $6, %%mm1\n" /* red=red/64 */
-
- /* create L1 L2 (result in mm2,mm4) */
- /* L2=lum+cols */
- "movq (%2,%4),%%mm3\n" /* 0 0 0 0 L3 L2 L1 L0 */
- "punpckldq %%mm3,%%mm2\n" /* L3 L2 L1 L0 l3 l2 l1 l0 */
- "movq %%mm2,%%mm4\n" /* L3 L2 L1 L0 l3 l2 l1 l0 */
- "pand %12,%%mm2\n" /* L3 0 L1 0 l3 0 l1 0 */
- "pand %13,%%mm4\n" /* 0 L2 0 L0 0 l2 0 l0 */
- "psrlw $8,%%mm2\n" /* 0 L3 0 L1 0 l3 0 l1 */
-
- /* create R (result in mm6) */
- "movq %%mm2,%%mm5\n" /* 0 L3 0 L1 0 l3 0 l1 */
- "movq %%mm4,%%mm6\n" /* 0 L2 0 L0 0 l2 0 l0 */
- "paddsw %%mm1, %%mm5\n" /* lum1+red:x R3 x R1 x r3 x r1 */
- "paddsw %%mm1, %%mm6\n" /* lum1+red:x R2 x R0 x r2 x r0 */
- "packuswb %%mm5,%%mm5\n" /* R3 R1 r3 r1 R3 R1 r3 r1 */
- "packuswb %%mm6,%%mm6\n" /* R2 R0 r2 r0 R2 R0 r2 r0 */
- "pxor %%mm7,%%mm7\n" /* 00 00 00 00 00 00 00 00 */
- "punpcklbw %%mm5,%%mm6\n" /* R3 R2 R1 R0 r3 r2 r1 r0 */
-
- /* create Cb (result in mm1) */
- "movd (%1), %%mm1\n" /* 0 0 0 0 u3 u2 u1 u0 */
- "punpcklbw %%mm7,%%mm1\n" /* 0 u3 0 u2 00 u1 00 u0 */
- "punpckldq %%mm1,%%mm1\n" /* 00 u1 00 u0 00 u1 00 u0 */
- "psubw %9,%%mm1\n" /* mm1-128:u1 u1 u0 u0 u1 u1 u0 u0 */
-
- /* create Cb_g (result in mm5) */
- "movq %%mm1,%%mm5\n" /* u1 u1 u0 u0 u1 u1 u0 u0 */
- "pmullw %14,%%mm5\n" /* blue*-109dec=1.7129*64 */
- "pmullw %15,%%mm1\n" /* blue*114dec=1.78125*64 */
- "psraw $6, %%mm5\n" /* blue=red/64 */
- "psraw $6, %%mm1\n" /* blue=blue/64 */
-
- /* create G (result in mm7) */
- "movq %%mm2,%%mm3\n" /* 0 L3 0 L1 0 l3 0 l1 */
- "movq %%mm4,%%mm7\n" /* 0 L2 0 L0 0 l2 0 l1 */
- "paddsw %%mm5, %%mm3\n" /* lum1+Cb_g:x G3t x G1t x g3t x g1t */
- "paddsw %%mm5, %%mm7\n" /* lum1+Cb_g:x G2t x G0t x g2t x g0t */
- "paddsw %%mm0, %%mm3\n" /* lum1+Cr_g:x G3 x G1 x g3 x g1 */
- "paddsw %%mm0, %%mm7\n" /* lum1+blue:x G2 x G0 x g2 x g0 */
- "packuswb %%mm3,%%mm3\n" /* G3 G1 g3 g1 G3 G1 g3 g1 */
- "packuswb %%mm7,%%mm7\n" /* G2 G0 g2 g0 G2 G0 g2 g0 */
- "punpcklbw %%mm3,%%mm7\n" /* G3 G2 G1 G0 g3 g2 g1 g0 */
-
- /* create B (result in mm5) */
- "movq %%mm2,%%mm3\n" /* 0 L3 0 L1 0 l3 0 l1 */
- "movq %%mm4,%%mm5\n" /* 0 L2 0 L0 0 l2 0 l1 */
- "paddsw %%mm1, %%mm3\n" /* lum1+blue:x B3 x B1 x b3 x b1 */
- "paddsw %%mm1, %%mm5\n" /* lum1+blue:x B2 x B0 x b2 x b0 */
- "packuswb %%mm3,%%mm3\n" /* B3 B1 b3 b1 B3 B1 b3 b1 */
- "packuswb %%mm5,%%mm5\n" /* B2 B0 b2 b0 B2 B0 b2 b0 */
- "punpcklbw %%mm3,%%mm5\n" /* B3 B2 B1 B0 b3 b2 b1 b0 */
-
- /* fill destination row1 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
-
- "pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */
- "pxor %%mm4,%%mm4\n" /* 0 0 0 0 0 0 0 0 */
- "movq %%mm6,%%mm1\n" /* R3 R2 R1 R0 r3 r2 r1 r0 */
- "movq %%mm5,%%mm3\n" /* B3 B2 B1 B0 b3 b2 b1 b0 */
-
- /* process lower lum */
- "punpcklbw %%mm4,%%mm1\n" /* 0 r3 0 r2 0 r1 0 r0 */
- "punpcklbw %%mm4,%%mm3\n" /* 0 b3 0 b2 0 b1 0 b0 */
- "movq %%mm1,%%mm2\n" /* 0 r3 0 r2 0 r1 0 r0 */
- "movq %%mm3,%%mm0\n" /* 0 b3 0 b2 0 b1 0 b0 */
- "punpcklwd %%mm1,%%mm3\n" /* 0 r1 0 b1 0 r0 0 b0 */
- "punpckhwd %%mm2,%%mm0\n" /* 0 r3 0 b3 0 r2 0 b2 */
-
- "pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */
- "movq %%mm7,%%mm1\n" /* G3 G2 G1 G0 g3 g2 g1 g0 */
- "punpcklbw %%mm1,%%mm2\n" /* g3 0 g2 0 g1 0 g0 0 */
- "punpcklwd %%mm4,%%mm2\n" /* 0 0 g1 0 0 0 g0 0 */
- "por %%mm3, %%mm2\n" /* 0 r1 g1 b1 0 r0 g0 b0 */
- "movq %%mm2,(%3)\n" /* wrote out ! row1 */
-
- "pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */
- "punpcklbw %%mm1,%%mm4\n" /* g3 0 g2 0 g1 0 g0 0 */
- "punpckhwd %%mm2,%%mm4\n" /* 0 0 g3 0 0 0 g2 0 */
- "por %%mm0, %%mm4\n" /* 0 r3 g3 b3 0 r2 g2 b2 */
- "movq %%mm4,8(%3)\n" /* wrote out ! row1 */
-
- /* fill destination row2 (needed are mm6=Rr,mm7=Gg,mm5=Bb) */
- /* this can be done "destructive" */
- "pxor %%mm2,%%mm2\n" /* 0 0 0 0 0 0 0 0 */
- "punpckhbw %%mm2,%%mm6\n" /* 0 R3 0 R2 0 R1 0 R0 */
- "punpckhbw %%mm1,%%mm5\n" /* G3 B3 G2 B2 G1 B1 G0 B0 */
- "movq %%mm5,%%mm1\n" /* G3 B3 G2 B2 G1 B1 G0 B0 */
- "punpcklwd %%mm6,%%mm1\n" /* 0 R1 G1 B1 0 R0 G0 B0 */
- "movq %%mm1,(%5)\n" /* wrote out ! row2 */
- "punpckhwd %%mm6,%%mm5\n" /* 0 R3 G3 B3 0 R2 G2 B2 */
- "movq %%mm5,8(%5)\n" /* wrote out ! row2 */
-
- "addl $4,%2\n" /* lum+4 */
- "leal 16(%3),%3\n" /* row1+16 */
- "leal 16(%5),%5\n" /* row2+16 */
- "addl $2,%0\n" /* cr+2 */
- "addl $2,%1\n" /* cb+2 */
-
- "addl $4,%6\n" /* x+4 */
- "cmpl %4,%6\n"
-
- "jl 1b\n"
- "addl %4,%2\n" /* lum += cols */
- "addl %8,%3\n" /* row1+= mod */
- "addl %8,%5\n" /* row2+= mod */
- "movl $0,%6\n" /* x=0 */
- "cmpl %7,%2\n"
- "jl 1b\n"
-
- "emms\n" /* reset MMX registers. */
- :
- : "r" (cr), "r"(cb),"r"(lum),
- "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
- "m"(MMX_0080w),"m"(MMX_VgrnRGB),"m"(MMX_VredRGB),
- "m"(MMX_FF00w),"m"(MMX_00FFw),"m"(MMX_UgrnRGB),
- "m"(MMX_UbluRGB)
- );
-}
-
-void Color565DitherYV12MMX1X( int *colortab, Uint32 *rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod )
-{
- Uint16 *row1;
- Uint16 *row2;
-
- unsigned char* y = lum +cols*rows; /* Pointer to the end */
- int x = 0;
- row1 = (Uint16 *)out; /* 16 bit target */
- row2 = (Uint16 *)out+cols+mod; /* start of second row */
- mod = (mod+cols+mod)*2; /* increment for row1 in byte */
-
- __asm__ __volatile__(
- ".align 8\n"
- "1:\n"
-
- "movd (%1), %%mm0\n" /* 4 Cb 0 0 0 0 u3 u2 u1 u0 */
- "pxor %%mm7, %%mm7\n"
- "movd (%0), %%mm1\n" /* 4 Cr 0 0 0 0 v3 v2 v1 v0 */
-
- "punpcklbw %%mm7, %%mm0\n" /* 4 W cb 0 u3 0 u2 0 u1 0 u0 */
- "punpcklbw %%mm7, %%mm1\n" /* 4 W cr 0 v3 0 v2 0 v1 0 v0 */
- "psubw %9, %%mm0\n"
- "psubw %9, %%mm1\n"
- "movq %%mm0, %%mm2\n" /* Cb 0 u3 0 u2 0 u1 0 u0 */
- "movq %%mm1, %%mm3\n" /* Cr */
- "pmullw %10, %%mm2\n" /* Cb2green 0 R3 0 R2 0 R1 0 R0 */
- "movq (%2), %%mm6\n" /* L1 l7 L6 L5 L4 L3 L2 L1 L0 */
- "pmullw %11, %%mm0\n" /* Cb2blue */
- "pand %12, %%mm6\n" /* L1 00 L6 00 L4 00 L2 00 L0 */
- "pmullw %13, %%mm3\n" /* Cr2green */
- "movq (%2), %%mm7\n" /* L2 */
- "pmullw %14, %%mm1\n" /* Cr2red */
- "psrlw $8, %%mm7\n" /* L2 00 L7 00 L5 00 L3 00 L1 */
- "pmullw %15, %%mm6\n" /* lum1 */
- "paddw %%mm3, %%mm2\n" /* Cb2green + Cr2green == green */
- "pmullw %15, %%mm7\n" /* lum2 */
-
- "movq %%mm6, %%mm4\n" /* lum1 */
- "paddw %%mm0, %%mm6\n" /* lum1 +blue 00 B6 00 B4 00 B2 00 B0 */
- "movq %%mm4, %%mm5\n" /* lum1 */
- "paddw %%mm1, %%mm4\n" /* lum1 +red 00 R6 00 R4 00 R2 00 R0 */
- "paddw %%mm2, %%mm5\n" /* lum1 +green 00 G6 00 G4 00 G2 00 G0 */
- "psraw $6, %%mm4\n" /* R1 0 .. 64 */
- "movq %%mm7, %%mm3\n" /* lum2 00 L7 00 L5 00 L3 00 L1 */
- "psraw $6, %%mm5\n" /* G1 - .. + */
- "paddw %%mm0, %%mm7\n" /* Lum2 +blue 00 B7 00 B5 00 B3 00 B1 */
- "psraw $6, %%mm6\n" /* B1 0 .. 64 */
- "packuswb %%mm4, %%mm4\n" /* R1 R1 */
- "packuswb %%mm5, %%mm5\n" /* G1 G1 */
- "packuswb %%mm6, %%mm6\n" /* B1 B1 */
- "punpcklbw %%mm4, %%mm4\n"
- "punpcklbw %%mm5, %%mm5\n"
-
- "pand %16, %%mm4\n"
- "psllw $3, %%mm5\n" /* GREEN 1 */
- "punpcklbw %%mm6, %%mm6\n"
- "pand %17, %%mm5\n"
- "pand %16, %%mm6\n"
- "por %%mm5, %%mm4\n" /* */
- "psrlw $11, %%mm6\n" /* BLUE 1 */
- "movq %%mm3, %%mm5\n" /* lum2 */
- "paddw %%mm1, %%mm3\n" /* lum2 +red 00 R7 00 R5 00 R3 00 R1 */
- "paddw %%mm2, %%mm5\n" /* lum2 +green 00 G7 00 G5 00 G3 00 G1 */
- "psraw $6, %%mm3\n" /* R2 */
- "por %%mm6, %%mm4\n" /* MM4 */
- "psraw $6, %%mm5\n" /* G2 */
- "movq (%2, %4), %%mm6\n" /* L3 load lum2 */
- "psraw $6, %%mm7\n"
- "packuswb %%mm3, %%mm3\n"
- "packuswb %%mm5, %%mm5\n"
- "packuswb %%mm7, %%mm7\n"
- "pand %12, %%mm6\n" /* L3 */
- "punpcklbw %%mm3, %%mm3\n"
- "punpcklbw %%mm5, %%mm5\n"
- "pmullw %15, %%mm6\n" /* lum3 */
- "punpcklbw %%mm7, %%mm7\n"
- "psllw $3, %%mm5\n" /* GREEN 2 */
- "pand %16, %%mm7\n"
- "pand %16, %%mm3\n"
- "psrlw $11, %%mm7\n" /* BLUE 2 */
- "pand %17, %%mm5\n"
- "por %%mm7, %%mm3\n"
- "movq (%2,%4), %%mm7\n" /* L4 load lum2 */
- "por %%mm5, %%mm3\n"
- "psrlw $8, %%mm7\n" /* L4 */
- "movq %%mm4, %%mm5\n"
- "punpcklwd %%mm3, %%mm4\n"
- "pmullw %15, %%mm7\n" /* lum4 */
- "punpckhwd %%mm3, %%mm5\n"
-
- "movq %%mm4, (%3)\n" /* write row1 */
- "movq %%mm5, 8(%3)\n" /* write row1 */
-
- "movq %%mm6, %%mm4\n" /* Lum3 */
- "paddw %%mm0, %%mm6\n" /* Lum3 +blue */
-
- "movq %%mm4, %%mm5\n" /* Lum3 */
- "paddw %%mm1, %%mm4\n" /* Lum3 +red */
- "paddw %%mm2, %%mm5\n" /* Lum3 +green */
- "psraw $6, %%mm4\n"
- "movq %%mm7, %%mm3\n" /* Lum4 */
- "psraw $6, %%mm5\n"
- "paddw %%mm0, %%mm7\n" /* Lum4 +blue */
- "psraw $6, %%mm6\n" /* Lum3 +blue */
- "movq %%mm3, %%mm0\n" /* Lum4 */
- "packuswb %%mm4, %%mm4\n"
- "paddw %%mm1, %%mm3\n" /* Lum4 +red */
- "packuswb %%mm5, %%mm5\n"
- "paddw %%mm2, %%mm0\n" /* Lum4 +green */
- "packuswb %%mm6, %%mm6\n"
- "punpcklbw %%mm4, %%mm4\n"
- "punpcklbw %%mm5, %%mm5\n"
- "punpcklbw %%mm6, %%mm6\n"
- "psllw $3, %%mm5\n" /* GREEN 3 */
- "pand %16, %%mm4\n"
- "psraw $6, %%mm3\n" /* psr 6 */
- "psraw $6, %%mm0\n"
- "pand %16, %%mm6\n" /* BLUE */
- "pand %17, %%mm5\n"
- "psrlw $11, %%mm6\n" /* BLUE 3 */
- "por %%mm5, %%mm4\n"
- "psraw $6, %%mm7\n"
- "por %%mm6, %%mm4\n"
- "packuswb %%mm3, %%mm3\n"
- "packuswb %%mm0, %%mm0\n"
- "packuswb %%mm7, %%mm7\n"
- "punpcklbw %%mm3, %%mm3\n"
- "punpcklbw %%mm0, %%mm0\n"
- "punpcklbw %%mm7, %%mm7\n"
- "pand %16, %%mm3\n"
- "pand %16, %%mm7\n" /* BLUE */
- "psllw $3, %%mm0\n" /* GREEN 4 */
- "psrlw $11, %%mm7\n"
- "pand %17, %%mm0\n"
- "por %%mm7, %%mm3\n"
- "por %%mm0, %%mm3\n"
-
- "movq %%mm4, %%mm5\n"
-
- "punpcklwd %%mm3, %%mm4\n"
- "punpckhwd %%mm3, %%mm5\n"
-
- "movq %%mm4, (%5)\n"
- "movq %%mm5, 8(%5)\n"
-
- "addl $8, %6\n"
- "addl $8, %2\n"
- "addl $4, %0\n"
- "addl $4, %1\n"
- "cmpl %4, %6\n"
- "leal 16(%3), %3\n"
- "leal 16(%5),%5\n" /* row2+16 */
-
- "jl 1b\n"
- "addl %4, %2\n" /* lum += cols */
- "addl %8, %3\n" /* row1+= mod */
- "addl %8, %5\n" /* row2+= mod */
- "movl $0, %6\n" /* x=0 */
- "cmpl %7, %2\n"
- "jl 1b\n"
- "emms\n"
- :
- : "r" (cr), "r"(cb),"r"(lum),
- "r"(row1),"r"(cols),"r"(row2),"m"(x),"m"(y),"m"(mod),
- "m"(MMX_0080w),"m"(MMX_Ugrn565),"m"(MMX_Ublu5x5),
- "m"(MMX_00FFw),"m"(MMX_Vgrn565),"m"(MMX_Vred5x5),
- "m"(MMX_Ycoeff),"m"(MMX_red565),"m"(MMX_grn565)
- );
-}
-
-/* *INDENT-ON* */
-
-#endif /* USE_MMX_ASSEMBLY */
-
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/SDL_yuv_sw.c b/src/render/SDL_yuv_sw.c
index 49fce6db2..0ca9c969e 100644
--- a/src/render/SDL_yuv_sw.c
+++ b/src/render/SDL_yuv_sw.c
@@ -22,1058 +22,15 @@
/* This is the software implementation of the YUV texture support */
-/* This code was derived from code carrying the following copyright notices:
-
- * Copyright (c) 1995 The Regents of the University of California.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice and the following
- * two paragraphs appear in all copies of this software.
- *
- * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
- * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
- * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
- * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
- * Copyright (c) 1995 Erik Corry
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement is
- * hereby granted, provided that the above copyright notice and the following
- * two paragraphs appear in all copies of this software.
- *
- * IN NO EVENT SHALL ERIK CORRY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
- * SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF
- * THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ERIK CORRY HAS BEEN ADVISED
- * OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ERIK CORRY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- * BASIS, AND ERIK CORRY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT,
- * UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
-
- * Portions of this software Copyright (c) 1995 Brown University.
- * All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose, without fee, and without written agreement
- * is hereby granted, provided that the above copyright notice and the
- * following two paragraphs appear in all copies of this software.
- *
- * IN NO EVENT SHALL BROWN UNIVERSITY BE LIABLE TO ANY PARTY FOR
- * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
- * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF BROWN
- * UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * BROWN UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- * BASIS, AND BROWN UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- */
-
#include "SDL_assert.h"
-#include "SDL_video.h"
-#include "SDL_cpuinfo.h"
-#include "SDL_yuv_sw_c.h"
-#include "SDL_yuv_mmx_c.h"
-
-
-/* The colorspace conversion functions */
-
-#ifdef USE_MMX_ASSEMBLY
-extern void Color565DitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod);
-extern void ColorRGBDitherYV12MMX1X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod);
-#endif
-
-static void
-Color16DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned short *row1;
- unsigned short *row2;
- unsigned char *lum2;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
-
- row1 = (unsigned short *) out;
- row2 = row1 + cols + mod;
- lum2 = lum + cols;
-
- mod += cols + mod;
-
- y = rows / 2;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- ++cr;
- ++cb;
-
- L = *lum++;
- *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
-
- L = *lum++;
- *row1++ = (unsigned short) (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
-
-
- /* Now, do second row. */
-
- L = *lum2++;
- *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
-
- L = *lum2++;
- *row2++ = (unsigned short) (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
- }
-
- /*
- * These values are at the start of the next line, (due
- * to the ++'s above),but they need to be at the start
- * of the line after that.
- */
- lum += cols;
- lum2 += cols;
- row1 += mod;
- row2 += mod;
- }
-}
-
-static void
-Color24DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int value;
- unsigned char *row1;
- unsigned char *row2;
- unsigned char *lum2;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
-
- row1 = out;
- row2 = row1 + cols * 3 + mod * 3;
- lum2 = lum + cols;
-
- mod += cols + mod;
- mod *= 3;
-
- y = rows / 2;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- ++cr;
- ++cb;
-
- L = *lum++;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- *row1++ = (value) & 0xFF;
- *row1++ = (value >> 8) & 0xFF;
- *row1++ = (value >> 16) & 0xFF;
-
- L = *lum++;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- *row1++ = (value) & 0xFF;
- *row1++ = (value >> 8) & 0xFF;
- *row1++ = (value >> 16) & 0xFF;
-
-
- /* Now, do second row. */
-
- L = *lum2++;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- *row2++ = (value) & 0xFF;
- *row2++ = (value >> 8) & 0xFF;
- *row2++ = (value >> 16) & 0xFF;
-
- L = *lum2++;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- *row2++ = (value) & 0xFF;
- *row2++ = (value >> 8) & 0xFF;
- *row2++ = (value >> 16) & 0xFF;
- }
-
- /*
- * These values are at the start of the next line, (due
- * to the ++'s above),but they need to be at the start
- * of the line after that.
- */
- lum += cols;
- lum2 += cols;
- row1 += mod;
- row2 += mod;
- }
-}
-
-static void
-Color32DitherYV12Mod1X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int *row1;
- unsigned int *row2;
- unsigned char *lum2;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = (cols + 1) / 2;
- /* not even dimensions */
- int skip_last_col = 0;
- int skip_last_row = 0;
-
- if ( (cols & 0x1) ) {
- skip_last_col = 1;
- }
-
- if ( (rows & 0x1) ) {
- skip_last_row = 1;
- }
-
- row1 = (unsigned int *) out;
- row2 = row1 + cols + mod;
- lum2 = lum + cols;
-
- mod += cols + mod;
-
- y = (rows + 1) / 2;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- ++cr;
- ++cb;
-
- L = *lum++;
- *row1++ = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-
- if (!(x == 0 && skip_last_col)) {
- L = *lum++;
- *row1++ = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- } /* skip col */
-
-
- if (!(y == 0 && skip_last_row)) {
-
- /* Now, do second row. */
-
- L = *lum2++;
- *row2++ = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-
- if (!(x == 1 && skip_last_col)) {
- L = *lum2++;
- *row2++ = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- } /* skip col */
- } /* skip row */
- }
-
- /*
- * These values are at the start of the next line, (due
- * to the ++'s above),but they need to be at the start
- * of the line after that.
- */
- lum += cols;
- lum2 += cols;
- row1 += mod;
- row2 += mod;
- }
-}
-
-/*
- * In this function I make use of a nasty trick. The tables have the lower
- * 16 bits replicated in the upper 16. This means I can write ints and get
- * the horisontal doubling for free (almost).
- */
-static void
-Color16DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int *row1 = (unsigned int *) out;
- const int next_row = cols + (mod / 2);
- unsigned int *row2 = row1 + 2 * next_row;
- unsigned char *lum2;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
-
- lum2 = lum + cols;
- mod = (next_row * 3) + (mod / 2);
-
- y = rows / 2;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- ++cr;
- ++cb;
-
- L = *lum++;
- row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
- row1++;
-
- L = *lum++;
- row1[0] = row1[next_row] = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
- row1++;
-
-
- /* Now, do second row. */
-
- L = *lum2++;
- row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
- row2++;
-
- L = *lum2++;
- row2[0] = row2[next_row] = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
- row2++;
- }
-
- /*
- * These values are at the start of the next line, (due
- * to the ++'s above),but they need to be at the start
- * of the line after that.
- */
- lum += cols;
- lum2 += cols;
- row1 += mod;
- row2 += mod;
- }
-}
-
-static void
-Color24DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int value;
- unsigned char *row1 = out;
- const int next_row = (cols * 2 + mod) * 3;
- unsigned char *row2 = row1 + 2 * next_row;
- unsigned char *lum2;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
-
- lum2 = lum + cols;
-
- mod = next_row * 3 + mod * 3;
-
- y = rows / 2;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- ++cr;
- ++cb;
-
- L = *lum++;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
- row1[next_row + 3 + 0] = (value) & 0xFF;
- row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
- row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
- row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
- row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
- row1 += 2 * 3;
-
- L = *lum++;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row1[0 + 0] = row1[3 + 0] = row1[next_row + 0] =
- row1[next_row + 3 + 0] = (value) & 0xFF;
- row1[0 + 1] = row1[3 + 1] = row1[next_row + 1] =
- row1[next_row + 3 + 1] = (value >> 8) & 0xFF;
- row1[0 + 2] = row1[3 + 2] = row1[next_row + 2] =
- row1[next_row + 3 + 2] = (value >> 16) & 0xFF;
- row1 += 2 * 3;
-
-
- /* Now, do second row. */
-
- L = *lum2++;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
- row2[next_row + 3 + 0] = (value) & 0xFF;
- row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
- row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
- row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
- row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
- row2 += 2 * 3;
-
- L = *lum2++;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row2[0 + 0] = row2[3 + 0] = row2[next_row + 0] =
- row2[next_row + 3 + 0] = (value) & 0xFF;
- row2[0 + 1] = row2[3 + 1] = row2[next_row + 1] =
- row2[next_row + 3 + 1] = (value >> 8) & 0xFF;
- row2[0 + 2] = row2[3 + 2] = row2[next_row + 2] =
- row2[next_row + 3 + 2] = (value >> 16) & 0xFF;
- row2 += 2 * 3;
- }
-
- /*
- * These values are at the start of the next line, (due
- * to the ++'s above),but they need to be at the start
- * of the line after that.
- */
- lum += cols;
- lum2 += cols;
- row1 += mod;
- row2 += mod;
- }
-}
-
-static void
-Color32DitherYV12Mod2X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int *row1 = (unsigned int *) out;
- const int next_row = cols * 2 + mod;
- unsigned int *row2 = row1 + 2 * next_row;
- unsigned char *lum2;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
-
- lum2 = lum + cols;
-
- mod = (next_row * 3) + mod;
-
- y = rows / 2;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- ++cr;
- ++cb;
-
- L = *lum++;
- row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
- (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row1 += 2;
-
- L = *lum++;
- row1[0] = row1[1] = row1[next_row] = row1[next_row + 1] =
- (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row1 += 2;
-
-
- /* Now, do second row. */
-
- L = *lum2++;
- row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
- (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row2 += 2;
-
- L = *lum2++;
- row2[0] = row2[1] = row2[next_row] = row2[next_row + 1] =
- (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row2 += 2;
- }
-
- /*
- * These values are at the start of the next line, (due
- * to the ++'s above),but they need to be at the start
- * of the line after that.
- */
- lum += cols;
- lum2 += cols;
- row1 += mod;
- row2 += mod;
- }
-}
-
-static void
-Color16DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned short *row;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
-
- row = (unsigned short *) out;
-
- y = rows;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- cr += 4;
- cb += 4;
-
- L = *lum;
- lum += 2;
- *row++ = (unsigned short) (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
-
- L = *lum;
- lum += 2;
- *row++ = (unsigned short) (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
-
- }
-
- row += mod;
- }
-}
-
-static void
-Color24DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int value;
- unsigned char *row;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
-
- row = (unsigned char *) out;
- mod *= 3;
- y = rows;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- cr += 4;
- cb += 4;
-
- L = *lum;
- lum += 2;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- *row++ = (value) & 0xFF;
- *row++ = (value >> 8) & 0xFF;
- *row++ = (value >> 16) & 0xFF;
-
- L = *lum;
- lum += 2;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- *row++ = (value) & 0xFF;
- *row++ = (value >> 8) & 0xFF;
- *row++ = (value >> 16) & 0xFF;
-
- }
- row += mod;
- }
-}
-
-static void
-Color32DitherYUY2Mod1X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int *row;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = (cols + 1) / 2;
- /* not even dimensions */
- int skip_last_col = 0;
- if ( (cols & 0x1) ) {
- skip_last_col = 1;
- }
-
- row = (unsigned int *) out;
- y = rows;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- cr += 4;
- cb += 4;
-
- L = *lum;
- lum += 2;
- *row++ = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
-
- L = *lum;
- lum += 2;
-
- if (!(x == 0 && skip_last_col)) {
- *row++ = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- } /* skip col */
-
- }
- row += mod;
- }
-}
-
-/*
- * In this function I make use of a nasty trick. The tables have the lower
- * 16 bits replicated in the upper 16. This means I can write ints and get
- * the horisontal doubling for free (almost).
- */
-static void
-Color16DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int *row = (unsigned int *) out;
- const int next_row = cols + (mod / 2);
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
-
- y = rows;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- cr += 4;
- cb += 4;
-
- L = *lum;
- lum += 2;
- row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
- row++;
-
- L = *lum;
- lum += 2;
- row[0] = row[next_row] = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] |
- rgb_2_pix[L + cb_b]);
- row++;
-
- }
- row += next_row;
- }
-}
-
-static void
-Color24DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int value;
- unsigned char *row = out;
- const int next_row = (cols * 2 + mod) * 3;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
- y = rows;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- cr += 4;
- cb += 4;
-
- L = *lum;
- lum += 2;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row[0 + 0] = row[3 + 0] = row[next_row + 0] =
- row[next_row + 3 + 0] = (value) & 0xFF;
- row[0 + 1] = row[3 + 1] = row[next_row + 1] =
- row[next_row + 3 + 1] = (value >> 8) & 0xFF;
- row[0 + 2] = row[3 + 2] = row[next_row + 2] =
- row[next_row + 3 + 2] = (value >> 16) & 0xFF;
- row += 2 * 3;
-
- L = *lum;
- lum += 2;
- value = (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row[0 + 0] = row[3 + 0] = row[next_row + 0] =
- row[next_row + 3 + 0] = (value) & 0xFF;
- row[0 + 1] = row[3 + 1] = row[next_row + 1] =
- row[next_row + 3 + 1] = (value >> 8) & 0xFF;
- row[0 + 2] = row[3 + 2] = row[next_row + 2] =
- row[next_row + 3 + 2] = (value >> 16) & 0xFF;
- row += 2 * 3;
-
- }
- row += next_row;
- }
-}
-
-static void
-Color32DitherYUY2Mod2X(int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod)
-{
- unsigned int *row = (unsigned int *) out;
- const int next_row = cols * 2 + mod;
- int x, y;
- int cr_r;
- int crb_g;
- int cb_b;
- int cols_2 = cols / 2;
- mod += mod;
- y = rows;
- while (y--) {
- x = cols_2;
- while (x--) {
- register int L;
-
- cr_r = 0 * 768 + 256 + colortab[*cr + 0 * 256];
- crb_g = 1 * 768 + 256 + colortab[*cr + 1 * 256]
- + colortab[*cb + 2 * 256];
- cb_b = 2 * 768 + 256 + colortab[*cb + 3 * 256];
- cr += 4;
- cb += 4;
-
- L = *lum;
- lum += 2;
- row[0] = row[1] = row[next_row] = row[next_row + 1] =
- (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row += 2;
-
- L = *lum;
- lum += 2;
- row[0] = row[1] = row[next_row] = row[next_row + 1] =
- (rgb_2_pix[L + cr_r] |
- rgb_2_pix[L + crb_g] | rgb_2_pix[L + cb_b]);
- row += 2;
-
-
- }
-
- row += next_row;
- }
-}
-
-/*
- * How many 1 bits are there in the Uint32.
- * Low performance, do not call often.
- */
-static int
-number_of_bits_set(Uint32 a)
-{
- if (!a)
- return 0;
- if (a & 1)
- return 1 + number_of_bits_set(a >> 1);
- return (number_of_bits_set(a >> 1));
-}
-
-/*
- * How many 0 bits are there at least significant end of Uint32.
- * Low performance, do not call often.
- */
-static int
-free_bits_at_bottom_nonzero(Uint32 a)
-{
- SDL_assert(a != 0);
- return (((Sint32) a) & 1l) ? 0 : 1 + free_bits_at_bottom_nonzero(a >> 1);
-}
-
-static SDL_INLINE int
-free_bits_at_bottom(Uint32 a)
-{
- return a ? free_bits_at_bottom_nonzero(a) : 32;
-}
-
-static int
-SDL_SW_SetupYUVDisplay(SDL_SW_YUVTexture * swdata, Uint32 target_format)
-{
- Uint32 *r_2_pix_alloc;
- Uint32 *g_2_pix_alloc;
- Uint32 *b_2_pix_alloc;
- int i;
- int bpp;
- Uint32 Rmask, Gmask, Bmask, Amask;
- int freebits;
-
- if (!SDL_PixelFormatEnumToMasks
- (target_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask) || bpp < 15) {
- return SDL_SetError("Unsupported YUV destination format");
- }
-
- swdata->target_format = target_format;
- r_2_pix_alloc = &swdata->rgb_2_pix[0 * 768];
- g_2_pix_alloc = &swdata->rgb_2_pix[1 * 768];
- b_2_pix_alloc = &swdata->rgb_2_pix[2 * 768];
-
- /*
- * Set up entries 0-255 in rgb-to-pixel value tables.
- */
- for (i = 0; i < 256; ++i) {
- r_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Rmask));
- freebits = free_bits_at_bottom(Rmask);
- if (freebits < 32) {
- r_2_pix_alloc[i + 256] <<= freebits;
- }
- r_2_pix_alloc[i + 256] |= Amask;
-
- g_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Gmask));
- freebits = free_bits_at_bottom(Gmask);
- if (freebits < 32) {
- g_2_pix_alloc[i + 256] <<= freebits;
- }
- g_2_pix_alloc[i + 256] |= Amask;
-
- b_2_pix_alloc[i + 256] = i >> (8 - number_of_bits_set(Bmask));
- freebits = free_bits_at_bottom(Bmask);
- if (freebits < 32) {
- b_2_pix_alloc[i + 256] <<= freebits;
- }
- b_2_pix_alloc[i + 256] |= Amask;
- }
-
- /*
- * If we have 16-bit output depth, then we double the value
- * in the top word. This means that we can write out both
- * pixels in the pixel doubling mode with one op. It is
- * harmless in the normal case as storing a 32-bit value
- * through a short pointer will lose the top bits anyway.
- */
- if (SDL_BYTESPERPIXEL(target_format) == 2) {
- for (i = 0; i < 256; ++i) {
- r_2_pix_alloc[i + 256] |= (r_2_pix_alloc[i + 256]) << 16;
- g_2_pix_alloc[i + 256] |= (g_2_pix_alloc[i + 256]) << 16;
- b_2_pix_alloc[i + 256] |= (b_2_pix_alloc[i + 256]) << 16;
- }
- }
-
- /*
- * Spread out the values we have to the rest of the array so that
- * we do not need to check for overflow.
- */
- for (i = 0; i < 256; ++i) {
- r_2_pix_alloc[i] = r_2_pix_alloc[256];
- r_2_pix_alloc[i + 512] = r_2_pix_alloc[511];
- g_2_pix_alloc[i] = g_2_pix_alloc[256];
- g_2_pix_alloc[i + 512] = g_2_pix_alloc[511];
- b_2_pix_alloc[i] = b_2_pix_alloc[256];
- b_2_pix_alloc[i + 512] = b_2_pix_alloc[511];
- }
-
- /* You have chosen wisely... */
- switch (swdata->format) {
- case SDL_PIXELFORMAT_YV12:
- case SDL_PIXELFORMAT_IYUV:
- if (SDL_BYTESPERPIXEL(target_format) == 2) {
-#ifdef USE_MMX_ASSEMBLY
- /* inline assembly functions */
- if (SDL_HasMMX() && (Rmask == 0xF800) &&
- (Gmask == 0x07E0) && (Bmask == 0x001F)
- && (swdata->w & 15) == 0) {
-/* printf("Using MMX 16-bit 565 dither\n"); */
- swdata->Display1X = Color565DitherYV12MMX1X;
- } else {
-/* printf("Using C 16-bit dither\n"); */
- swdata->Display1X = Color16DitherYV12Mod1X;
- }
-#else
- swdata->Display1X = Color16DitherYV12Mod1X;
-#endif
- swdata->Display2X = Color16DitherYV12Mod2X;
- }
- if (SDL_BYTESPERPIXEL(target_format) == 3) {
- swdata->Display1X = Color24DitherYV12Mod1X;
- swdata->Display2X = Color24DitherYV12Mod2X;
- }
- if (SDL_BYTESPERPIXEL(target_format) == 4) {
-#ifdef USE_MMX_ASSEMBLY
- /* inline assembly functions */
- if (SDL_HasMMX() && (Rmask == 0x00FF0000) &&
- (Gmask == 0x0000FF00) &&
- (Bmask == 0x000000FF) && (swdata->w & 15) == 0) {
-/* printf("Using MMX 32-bit dither\n"); */
- swdata->Display1X = ColorRGBDitherYV12MMX1X;
- } else {
-/* printf("Using C 32-bit dither\n"); */
- swdata->Display1X = Color32DitherYV12Mod1X;
- }
-#else
- swdata->Display1X = Color32DitherYV12Mod1X;
-#endif
- swdata->Display2X = Color32DitherYV12Mod2X;
- }
- break;
- case SDL_PIXELFORMAT_YUY2:
- case SDL_PIXELFORMAT_UYVY:
- case SDL_PIXELFORMAT_YVYU:
- if (SDL_BYTESPERPIXEL(target_format) == 2) {
- swdata->Display1X = Color16DitherYUY2Mod1X;
- swdata->Display2X = Color16DitherYUY2Mod2X;
- }
- if (SDL_BYTESPERPIXEL(target_format) == 3) {
- swdata->Display1X = Color24DitherYUY2Mod1X;
- swdata->Display2X = Color24DitherYUY2Mod2X;
- }
- if (SDL_BYTESPERPIXEL(target_format) == 4) {
- swdata->Display1X = Color32DitherYUY2Mod1X;
- swdata->Display2X = Color32DitherYUY2Mod2X;
- }
- break;
- case SDL_PIXELFORMAT_NV21:
- case SDL_PIXELFORMAT_NV12:
- /* no Display{1,2}X function */
- swdata->Display1X = NULL;
- swdata->Display2X = NULL;
- break;
-
- default:
- /* We should never get here (caught above) */
- break;
- }
+#include "SDL_yuv_sw_c.h"
- SDL_FreeSurface(swdata->display);
- swdata->display = NULL;
- return 0;
-}
SDL_SW_YUVTexture *
SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
{
SDL_SW_YUVTexture *swdata;
- int *Cr_r_tab;
- int *Cr_g_tab;
- int *Cb_g_tab;
- int *Cb_b_tab;
- int i;
- int CR, CB;
switch (format) {
case SDL_PIXELFORMAT_YV12:
@@ -1127,32 +84,14 @@ SDL_SW_CreateYUVTexture(Uint32 format, int w, int h)
break;
}
swdata->pixels = (Uint8 *) SDL_malloc(dst_size);
- }
- swdata->colortab = (int *) SDL_malloc(4 * 256 * sizeof(int));
- swdata->rgb_2_pix = (Uint32 *) SDL_malloc(3 * 768 * sizeof(Uint32));
- if (!swdata->pixels || !swdata->colortab || !swdata->rgb_2_pix) {
- SDL_SW_DestroyYUVTexture(swdata);
- SDL_OutOfMemory();
- return NULL;
- }
-
- /* Generate the tables for the display surface */
- Cr_r_tab = &swdata->colortab[0 * 256];
- Cr_g_tab = &swdata->colortab[1 * 256];
- Cb_g_tab = &swdata->colortab[2 * 256];
- Cb_b_tab = &swdata->colortab[3 * 256];
- for (i = 0; i < 256; i++) {
- /* Gamma correction (luminescence table) and chroma correction
- would be done here. See the Berkeley mpeg_play sources.
- */
- CB = CR = (i - 128);
- Cr_r_tab[i] = (int) ((0.419 / 0.299) * CR);
- Cr_g_tab[i] = (int) (-(0.299 / 0.419) * CR);
- Cb_g_tab[i] = (int) (-(0.114 / 0.331) * CB);
- Cb_b_tab[i] = (int) ((0.587 / 0.331) * CB);
+ if (!swdata->pixels) {
+ SDL_SW_DestroyYUVTexture(swdata);
+ SDL_OutOfMemory();
+ return NULL;
+ }
}
- /* Find the pitch and offset values for the overlay */
+ /* Find the pitch and offset values for the texture */
switch (format) {
case SDL_PIXELFORMAT_YV12:
case SDL_PIXELFORMAT_IYUV:
@@ -1300,8 +239,6 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect,
}
}
}
- break;
-
}
return 0;
}
@@ -1398,27 +335,16 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
Uint32 target_format, int w, int h, void *pixels,
int pitch)
{
- const int targetbpp = SDL_BYTESPERPIXEL(target_format);
int stretch;
- int scale_2x;
- Uint8 *lum, *Cr, *Cb;
- int mod;
-
- if (targetbpp == 0) {
- return SDL_SetError("Invalid target pixel format");
- }
/* Make sure we're set up to display in the desired format */
- if (target_format != swdata->target_format) {
- if (SDL_SW_SetupYUVDisplay(swdata, target_format) < 0) {
- return -1;
- }
+ if (target_format != swdata->target_format && swdata->display) {
+ SDL_FreeSurface(swdata->display);
+ swdata->display = NULL;
}
stretch = 0;
- scale_2x = 0;
- if (srcrect->x || srcrect->y || srcrect->w < swdata->w
- || srcrect->h < swdata->h) {
+ if (srcrect->x || srcrect->y || srcrect->w < swdata->w || srcrect->h < swdata->h) {
/* The source rectangle has been clipped.
Using a scratch surface is easier than adding clipped
source support to all the blitters, plus that would
@@ -1426,11 +352,7 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
*/
stretch = 1;
} else if ((srcrect->w != w) || (srcrect->h != h)) {
- if ((w == 2 * srcrect->w) && (h == 2 * srcrect->h)) {
- scale_2x = 1;
- } else {
- stretch = 1;
- }
+ stretch = 1;
}
if (stretch) {
int bpp;
@@ -1466,51 +388,10 @@ SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect,
pixels = swdata->stretch->pixels;
pitch = swdata->stretch->pitch;
}
- switch (swdata->format) {
- case SDL_PIXELFORMAT_YV12:
- lum = swdata->planes[0];
- Cr = swdata->planes[1];
- Cb = swdata->planes[2];
- break;
- case SDL_PIXELFORMAT_IYUV:
- lum = swdata->planes[0];
- Cr = swdata->planes[2];
- Cb = swdata->planes[1];
- break;
- case SDL_PIXELFORMAT_YUY2:
- lum = swdata->planes[0];
- Cr = lum + 3;
- Cb = lum + 1;
- break;
- case SDL_PIXELFORMAT_UYVY:
- lum = swdata->planes[0] + 1;
- Cr = lum + 1;
- Cb = lum - 1;
- break;
- case SDL_PIXELFORMAT_YVYU:
- lum = swdata->planes[0];
- Cr = lum + 1;
- Cb = lum + 3;
- break;
- case SDL_PIXELFORMAT_NV12:
- case SDL_PIXELFORMAT_NV21:
- return SDL_ConvertPixels(swdata->w, swdata->h,
- swdata->format, swdata->planes[0], swdata->pitches[0],
- target_format, pixels, pitch);
- break;
- default:
- return SDL_SetError("Unsupported YUV format in copy");
- }
- mod = (pitch / targetbpp);
-
- if (scale_2x) {
- mod -= (swdata->w * 2);
- swdata->Display2X(swdata->colortab, swdata->rgb_2_pix,
- lum, Cr, Cb, pixels, swdata->h, swdata->w, mod);
- } else {
- mod -= swdata->w;
- swdata->Display1X(swdata->colortab, swdata->rgb_2_pix,
- lum, Cr, Cb, pixels, swdata->h, swdata->w, mod);
+ if (SDL_ConvertPixels(swdata->w, swdata->h, swdata->format,
+ swdata->planes[0], swdata->pitches[0],
+ target_format, pixels, pitch) < 0) {
+ return -1;
}
if (stretch) {
SDL_Rect rect = *srcrect;
@@ -1524,8 +405,6 @@ SDL_SW_DestroyYUVTexture(SDL_SW_YUVTexture * swdata)
{
if (swdata) {
SDL_free(swdata->pixels);
- SDL_free(swdata->colortab);
- SDL_free(swdata->rgb_2_pix);
SDL_FreeSurface(swdata->stretch);
SDL_FreeSurface(swdata->display);
SDL_free(swdata);
diff --git a/src/render/SDL_yuv_sw_c.h b/src/render/SDL_yuv_sw_c.h
index 248dd45e2..5cd878666 100644
--- a/src/render/SDL_yuv_sw_c.h
+++ b/src/render/SDL_yuv_sw_c.h
@@ -30,16 +30,6 @@ struct SDL_SW_YUVTexture
Uint32 target_format;
int w, h;
Uint8 *pixels;
- int *colortab;
- Uint32 *rgb_2_pix;
- void (*Display1X) (int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod);
- void (*Display2X) (int *colortab, Uint32 * rgb_2_pix,
- unsigned char *lum, unsigned char *cr,
- unsigned char *cb, unsigned char *out,
- int rows, int cols, int mod);
/* These are just so we don't have to allocate them separately */
Uint16 pitches[3];
diff --git a/src/render/direct3d/SDL_render_d3d.c b/src/render/direct3d/SDL_render_d3d.c
index c40f699bb..04982481e 100644
--- a/src/render/direct3d/SDL_render_d3d.c
+++ b/src/render/direct3d/SDL_render_d3d.c
@@ -39,85 +39,7 @@
#include <d3d9.h>
#endif
-
-#ifdef ASSEMBLE_SHADER
-#pragma comment(lib, "d3dx9.lib")
-
-/**************************************************************************
- * ID3DXBuffer:
- * ------------
- * The buffer object is used by D3DX to return arbitrary size data.
- *
- * GetBufferPointer -
- * Returns a pointer to the beginning of the buffer.
- *
- * GetBufferSize -
- * Returns the size of the buffer, in bytes.
- **************************************************************************/
-
-typedef interface ID3DXBuffer ID3DXBuffer;
-typedef interface ID3DXBuffer *LPD3DXBUFFER;
-
-/* {8BA5FB08-5195-40e2-AC58-0D989C3A0102} */
-DEFINE_GUID(IID_ID3DXBuffer,
-0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2);
-
-#undef INTERFACE
-#define INTERFACE ID3DXBuffer
-
-typedef interface ID3DXBuffer {
- const struct ID3DXBufferVtbl FAR* lpVtbl;
-} ID3DXBuffer;
-typedef const struct ID3DXBufferVtbl ID3DXBufferVtbl;
-const struct ID3DXBufferVtbl
-{
- /* IUnknown */
- STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE;
- STDMETHOD_(ULONG, AddRef)(THIS) PURE;
- STDMETHOD_(ULONG, Release)(THIS) PURE;
-
- /* ID3DXBuffer */
- STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE;
- STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE;
-};
-
-HRESULT WINAPI
- D3DXAssembleShader(
- LPCSTR pSrcData,
- UINT SrcDataLen,
- CONST LPVOID* pDefines,
- LPVOID pInclude,
- DWORD Flags,
- LPD3DXBUFFER* ppShader,
- LPD3DXBUFFER* ppErrorMsgs);
-
-static void PrintShaderData(LPDWORD shader_data, DWORD shader_size)
-{
- OutputDebugStringA("const DWORD shader_data[] = {\n\t");
- {
- SDL_bool newline = SDL_FALSE;
- unsigned i;
- for (i = 0; i < shader_size / sizeof(DWORD); ++i) {
- char dword[11];
- if (i > 0) {
- if ((i%6) == 0) {
- newline = SDL_TRUE;
- }
- if (newline) {
- OutputDebugStringA(",\n ");
- newline = SDL_FALSE;
- } else {
- OutputDebugStringA(", ");
- }
- }
- SDL_snprintf(dword, sizeof(dword), "0x%8.8x", shader_data[i]);
- OutputDebugStringA(dword);
- }
- OutputDebugStringA("\n};\n");
- }
-}
-
-#endif /* ASSEMBLE_SHADER */
+#include "SDL_shaders_d3d.h"
/* Direct3D renderer implementation */
@@ -188,7 +110,7 @@ typedef struct
IDirect3DSurface9 *defaultRenderTarget;
IDirect3DSurface9 *currentRenderTarget;
void* d3dxDLL;
- LPDIRECT3DPIXELSHADER9 ps_yuv;
+ LPDIRECT3DPIXELSHADER9 shaders[NUM_SHADERS];
} D3D_RenderData;
typedef struct
@@ -197,6 +119,7 @@ typedef struct
int w, h;
DWORD usage;
Uint32 format;
+ D3DFORMAT d3dfmt;
IDirect3DTexture9 *texture;
IDirect3DTexture9 *staging;
} D3D_TextureRep;
@@ -313,6 +236,8 @@ PixelFormatToD3DFMT(Uint32 format)
return D3DFMT_A8R8G8B8;
case SDL_PIXELFORMAT_YV12:
case SDL_PIXELFORMAT_IYUV:
+ case SDL_PIXELFORMAT_NV12:
+ case SDL_PIXELFORMAT_NV21:
return D3DFMT_L8;
default:
return D3DFMT_UNKNOWN;
@@ -661,137 +586,19 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags)
/* Set up parameters for rendering */
D3D_InitRenderState(data);
- if (caps.MaxSimultaneousTextures >= 3)
- {
-#ifdef ASSEMBLE_SHADER
- /* This shader was created by running the following HLSL through the fxc compiler
- and then tuning the generated assembly.
-
- fxc /T fx_4_0 /O3 /Gfa /Fc yuv.fxc yuv.fx
-
- --- yuv.fx ---
- Texture2D g_txY;
- Texture2D g_txU;
- Texture2D g_txV;
-
- SamplerState samLinear
- {
- Filter = ANISOTROPIC;
- AddressU = Clamp;
- AddressV = Clamp;
- MaxAnisotropy = 1;
- };
-
- struct VS_OUTPUT
- {
- float2 TextureUV : TEXCOORD0;
- };
-
- struct PS_OUTPUT
- {
- float4 RGBAColor : SV_Target;
- };
-
- PS_OUTPUT YUV420( VS_OUTPUT In )
- {
- const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
- const float3 Rcoeff = {1.164, 0.000, 1.596};
- const float3 Gcoeff = {1.164, -0.391, -0.813};
- const float3 Bcoeff = {1.164, 2.018, 0.000};
-
- PS_OUTPUT Output;
- float2 TextureUV = In.TextureUV;
-
- float3 yuv;
- yuv.x = g_txY.Sample( samLinear, TextureUV ).r;
- yuv.y = g_txU.Sample( samLinear, TextureUV ).r;
- yuv.z = g_txV.Sample( samLinear, TextureUV ).r;
-
- yuv += offset;
- Output.RGBAColor.r = dot(yuv, Rcoeff);
- Output.RGBAColor.g = dot(yuv, Gcoeff);
- Output.RGBAColor.b = dot(yuv, Bcoeff);
- Output.RGBAColor.a = 1.0f;
-
- return Output;
- }
-
- technique10 RenderYUV420
- {
- pass P0
- {
- SetPixelShader( CompileShader( ps_4_0_level_9_0, YUV420() ) );
- }
- }
- */
- const char *shader_text =
- "ps_2_0\n"
- "def c0, -0.0627451017, -0.501960814, -0.501960814, 1\n"
- "def c1, 1.16400003, 0, 1.59599996, 0\n"
- "def c2, 1.16400003, -0.391000003, -0.813000023, 0\n"
- "def c3, 1.16400003, 2.01799989, 0, 0\n"
- "dcl t0.xy\n"
- "dcl v0.xyzw\n"
- "dcl_2d s0\n"
- "dcl_2d s1\n"
- "dcl_2d s2\n"
- "texld r0, t0, s0\n"
- "texld r1, t0, s1\n"
- "texld r2, t0, s2\n"
- "mov r0.y, r1.x\n"
- "mov r0.z, r2.x\n"
- "add r0.xyz, r0, c0\n"
- "dp3 r1.x, r0, c1\n"
- "dp3 r1.y, r0, c2\n"
- "dp2add r1.z, r0, c3, c3.z\n" /* Logically this is "dp3 r1.z, r0, c3" but the optimizer did its magic */
- "mov r1.w, c0.w\n"
- "mul r0, r1, v0\n" /* Not in the HLSL, multiply by vertex color */
- "mov oC0, r0\n"
- ;
- LPD3DXBUFFER pCode;
- LPD3DXBUFFER pErrorMsgs;
- LPDWORD shader_data = NULL;
- DWORD shader_size = 0;
- result = D3DXAssembleShader(shader_text, SDL_strlen(shader_text), NULL, NULL, 0, &pCode, &pErrorMsgs);
- if (!FAILED(result)) {
- shader_data = (DWORD*)pCode->lpVtbl->GetBufferPointer(pCode);
- shader_size = pCode->lpVtbl->GetBufferSize(pCode);
- PrintShaderData(shader_data, shader_size);
- } else {
- const char *error = (const char *)pErrorMsgs->lpVtbl->GetBufferPointer(pErrorMsgs);
- SDL_SetError("Couldn't assemble shader: %s", error);
- }
- if (shader_data != NULL)
-#else
- const DWORD shader_data[] = {
- 0xffff0200, 0x05000051, 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081,
- 0x3f800000, 0x05000051, 0xa00f0001, 0x3f94fdf4, 0x00000000, 0x3fcc49ba,
- 0x00000000, 0x05000051, 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5,
- 0x00000000, 0x05000051, 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000,
- 0x00000000, 0x0200001f, 0x80000000, 0xb0030000, 0x0200001f, 0x80000000,
- 0x900f0000, 0x0200001f, 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000,
- 0xa00f0801, 0x0200001f, 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000,
- 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
- 0x03000042, 0x800f0002, 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000,
- 0x80000001, 0x02000001, 0x80040000, 0x80000002, 0x03000002, 0x80070000,
- 0x80e40000, 0xa0e40000, 0x03000008, 0x80010001, 0x80e40000, 0xa0e40001,
- 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001,
- 0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000,
- 0x03000005, 0x800f0000, 0x80e40001, 0x90e40000, 0x02000001, 0x800f0800,
- 0x80e40000, 0x0000ffff
- };
-#endif
- {
- result = IDirect3DDevice9_CreatePixelShader(data->device, shader_data, &data->ps_yuv);
- if (!FAILED(result)) {
- renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
- renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
- } else {
+ if (caps.MaxSimultaneousTextures >= 3) {
+ int i;
+ for (i = 0; i < SDL_arraysize(data->shaders); ++i) {
+ result = D3D9_CreatePixelShader(data->device, (D3D9_Shader)i, &data->shaders[i]);
+ if (FAILED(result)) {
D3D_SetError("CreatePixelShader()", result);
}
}
+ if (data->shaders[SHADER_YUV_JPEG] && data->shaders[SHADER_YUV_BT601] && data->shaders[SHADER_YUV_BT709]) {
+ renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12;
+ renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV;
+ }
}
-
return renderer;
}
@@ -870,7 +677,7 @@ GetScaleQuality(void)
}
static int
-D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, int w, int h)
+D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD usage, Uint32 format, D3DFORMAT d3dfmt, int w, int h)
{
HRESULT result;
@@ -879,6 +686,7 @@ D3D_CreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD us
texture->h = h;
texture->usage = usage;
texture->format = format;
+ texture->d3dfmt = d3dfmt;
result = IDirect3DDevice9_CreateTexture(device, w, h, 1, usage,
PixelFormatToD3DFMT(format),
@@ -897,8 +705,7 @@ D3D_CreateStagingTexture(IDirect3DDevice9 *device, D3D_TextureRep *texture)
if (texture->staging == NULL) {
result = IDirect3DDevice9_CreateTexture(device, texture->w, texture->h, 1, 0,
- PixelFormatToD3DFMT(texture->format),
- D3DPOOL_SYSTEMMEM, &texture->staging, NULL);
+ texture->d3dfmt, D3DPOOL_SYSTEMMEM, &texture->staging, NULL);
if (FAILED(result)) {
return D3D_SetError("CreateTexture(D3DPOOL_SYSTEMMEM)", result);
}
@@ -934,7 +741,7 @@ D3D_BindTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, DWORD samp
}
static int
-D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, Uint32 format, int w, int h)
+D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture)
{
if (texture->texture) {
IDirect3DTexture9_Release(texture->texture);
@@ -948,7 +755,7 @@ D3D_RecreateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, Uint32
}
static int
-D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, Uint32 format, int x, int y, int w, int h, const void *pixels, int pitch)
+D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, int x, int y, int w, int h, const void *pixels, int pitch)
{
RECT d3drect;
D3DLOCKED_RECT locked;
@@ -972,8 +779,8 @@ D3D_UpdateTextureRep(IDirect3DDevice9 *device, D3D_TextureRep *texture, Uint32 f
}
src = (const Uint8 *)pixels;
- dst = locked.pBits;
- length = w * SDL_BYTESPERPIXEL(format);
+ dst = (Uint8 *)locked.pBits;
+ length = w * SDL_BYTESPERPIXEL(texture->format);
if (length == pitch && length == locked.Pitch) {
SDL_memcpy(dst, src, length*h);
} else {
@@ -1032,7 +839,7 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
usage = 0;
}
- if (D3D_CreateTextureRep(data->device, &texturedata->texture, usage, texture->format, texture->w, texture->h) < 0) {
+ if (D3D_CreateTextureRep(data->device, &texturedata->texture, usage, texture->format, PixelFormatToD3DFMT(texture->format), texture->w, texture->h) < 0) {
return -1;
}
@@ -1040,11 +847,11 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
texture->format == SDL_PIXELFORMAT_IYUV) {
texturedata->yuv = SDL_TRUE;
- if (D3D_CreateTextureRep(data->device, &texturedata->utexture, usage, texture->format, texture->w / 2, texture->h / 2) < 0) {
+ if (D3D_CreateTextureRep(data->device, &texturedata->utexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2) < 0) {
return -1;
}
- if (D3D_CreateTextureRep(data->device, &texturedata->vtexture, usage, texture->format, texture->w / 2, texture->h / 2) < 0) {
+ if (D3D_CreateTextureRep(data->device, &texturedata->vtexture, usage, texture->format, PixelFormatToD3DFMT(texture->format), (texture->w + 1) / 2, (texture->h + 1) / 2) < 0) {
return -1;
}
}
@@ -1061,16 +868,16 @@ D3D_RecreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
return 0;
}
- if (D3D_RecreateTextureRep(data->device, &texturedata->texture, texture->format, texture->w, texture->h) < 0) {
+ if (D3D_RecreateTextureRep(data->device, &texturedata->texture) < 0) {
return -1;
}
if (texturedata->yuv) {
- if (D3D_RecreateTextureRep(data->device, &texturedata->utexture, texture->format, texture->w / 2, texture->h / 2) < 0) {
+ if (D3D_RecreateTextureRep(data->device, &texturedata->utexture) < 0) {
return -1;
}
- if (D3D_RecreateTextureRep(data->device, &texturedata->vtexture, texture->format, texture->w / 2, texture->h / 2) < 0) {
+ if (D3D_RecreateTextureRep(data->device, &texturedata->vtexture) < 0) {
return -1;
}
}
@@ -1089,7 +896,7 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- if (D3D_UpdateTextureRep(data->device, &texturedata->texture, texture->format, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) {
+ if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, pixels, pitch) < 0) {
return -1;
}
@@ -1097,13 +904,13 @@ D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
/* Skip to the correct offset into the next texture */
pixels = (const void*)((const Uint8*)pixels + rect->h * pitch);
- if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->vtexture : &texturedata->utexture, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, pixels, pitch / 2) < 0) {
+ if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->vtexture : &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) {
return -1;
}
/* Skip to the correct offset into the next texture */
- pixels = (const void*)((const Uint8*)pixels + (rect->h * pitch)/4);
- if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->utexture : &texturedata->vtexture, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, pixels, pitch / 2) < 0) {
+ pixels = (const void*)((const Uint8*)pixels + ((rect->h + 1) / 2) * ((pitch + 1) / 2));
+ if (D3D_UpdateTextureRep(data->device, texture->format == SDL_PIXELFORMAT_YV12 ? &texturedata->utexture : &texturedata->vtexture, rect->x / 2, (rect->y + 1) / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, pixels, (pitch + 1) / 2) < 0) {
return -1;
}
}
@@ -1125,13 +932,13 @@ D3D_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- if (D3D_UpdateTextureRep(data->device, &texturedata->texture, texture->format, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) {
+ if (D3D_UpdateTextureRep(data->device, &texturedata->texture, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) {
return -1;
}
- if (D3D_UpdateTextureRep(data->device, &texturedata->utexture, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) {
+ if (D3D_UpdateTextureRep(data->device, &texturedata->utexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Uplane, Upitch) < 0) {
return -1;
}
- if (D3D_UpdateTextureRep(data->device, &texturedata->vtexture, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) {
+ if (D3D_UpdateTextureRep(data->device, &texturedata->vtexture, rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, Vplane, Vpitch) < 0) {
return -1;
}
return 0;
@@ -1610,12 +1417,59 @@ D3D_UpdateTextureScaleMode(D3D_RenderData *data, D3D_TextureData *texturedata, u
}
static int
+D3D_RenderSetupTextureState(SDL_Renderer * renderer, SDL_Texture * texture, LPDIRECT3DPIXELSHADER9 *shader)
+{
+ D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+ D3D_TextureData *texturedata;
+
+ *shader = NULL;
+
+ texturedata = (D3D_TextureData *)texture->driverdata;
+ if (!texturedata) {
+ SDL_SetError("Texture is not currently available");
+ return -1;
+ }
+
+ D3D_UpdateTextureScaleMode(data, texturedata, 0);
+
+ if (D3D_BindTextureRep(data->device, &texturedata->texture, 0) < 0) {
+ return -1;
+ }
+
+ if (texturedata->yuv) {
+ switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ *shader = data->shaders[SHADER_YUV_JPEG];
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ *shader = data->shaders[SHADER_YUV_BT601];
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ *shader = data->shaders[SHADER_YUV_BT709];
+ break;
+ default:
+ return SDL_SetError("Unsupported YUV conversion mode");
+ }
+
+ D3D_UpdateTextureScaleMode(data, texturedata, 1);
+ D3D_UpdateTextureScaleMode(data, texturedata, 2);
+
+ if (D3D_BindTextureRep(data->device, &texturedata->utexture, 1) < 0) {
+ return -1;
+ }
+ if (D3D_BindTextureRep(data->device, &texturedata->vtexture, 2) < 0) {
+ return -1;
+ }
+ }
+ return 0;
+}
+
+static int
D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * srcrect, const SDL_FRect * dstrect)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
- D3D_TextureData *texturedata;
- LPDIRECT3DPIXELSHADER9 shader = NULL;
+ LPDIRECT3DPIXELSHADER9 shader;
float minx, miny, maxx, maxy;
float minu, maxu, minv, maxv;
DWORD color;
@@ -1626,12 +1480,6 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- texturedata = (D3D_TextureData *)texture->driverdata;
- if (!texturedata) {
- SDL_SetError("Texture is not currently available");
- return -1;
- }
-
minx = dstrect->x - 0.5f;
miny = dstrect->y - 0.5f;
maxx = dstrect->x + dstrect->w - 0.5f;
@@ -1674,45 +1522,25 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
D3D_SetBlendMode(data, texture->blendMode);
- D3D_UpdateTextureScaleMode(data, texturedata, 0);
-
- if (D3D_BindTextureRep(data->device, &texturedata->texture, 0) < 0) {
+ if (D3D_RenderSetupTextureState(renderer, texture, &shader) < 0) {
return -1;
}
-
- if (texturedata->yuv) {
- shader = data->ps_yuv;
-
- D3D_UpdateTextureScaleMode(data, texturedata, 1);
- D3D_UpdateTextureScaleMode(data, texturedata, 2);
-
- if (D3D_BindTextureRep(data->device, &texturedata->utexture, 1) < 0) {
- return -1;
- }
- if (D3D_BindTextureRep(data->device, &texturedata->vtexture, 2) < 0) {
- return -1;
- }
- }
-
+
if (shader) {
result = IDirect3DDevice9_SetPixelShader(data->device, shader);
if (FAILED(result)) {
return D3D_SetError("SetShader()", result);
}
}
- result =
- IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
- vertices, sizeof(*vertices));
+ result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
+ vertices, sizeof(*vertices));
if (FAILED(result)) {
- return D3D_SetError("DrawPrimitiveUP()", result);
+ D3D_SetError("DrawPrimitiveUP()", result);
}
if (shader) {
- result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
- if (FAILED(result)) {
- return D3D_SetError("SetShader()", result);
- }
+ IDirect3DDevice9_SetPixelShader(data->device, NULL);
}
- return 0;
+ return FAILED(result) ? -1 : 0;
}
@@ -1722,7 +1550,6 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
const double angle, const SDL_FPoint * center, const SDL_RendererFlip flip)
{
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
- D3D_TextureData *texturedata;
LPDIRECT3DPIXELSHADER9 shader = NULL;
float minx, miny, maxx, maxy;
float minu, maxu, minv, maxv;
@@ -1736,12 +1563,6 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- texturedata = (D3D_TextureData *)texture->driverdata;
- if (!texturedata) {
- SDL_SetError("Texture is not currently available");
- return -1;
- }
-
centerx = center->x;
centery = center->y;
@@ -1798,54 +1619,37 @@ D3D_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
D3D_SetBlendMode(data, texture->blendMode);
+ if (D3D_RenderSetupTextureState(renderer, texture, &shader) < 0) {
+ return -1;
+ }
+
/* Rotate and translate */
modelMatrix = MatrixMultiply(
MatrixRotationZ((float)(M_PI * (float) angle / 180.0f)),
MatrixTranslation(dstrect->x + center->x - 0.5f, dstrect->y + center->y - 0.5f, 0));
IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
-
- D3D_UpdateTextureScaleMode(data, texturedata, 0);
-
- if (D3D_BindTextureRep(data->device, &texturedata->texture, 0) < 0) {
- return -1;
- }
-
- if (texturedata->yuv) {
- shader = data->ps_yuv;
-
- D3D_UpdateTextureScaleMode(data, texturedata, 1);
- D3D_UpdateTextureScaleMode(data, texturedata, 2);
-
- if (D3D_BindTextureRep(data->device, &texturedata->utexture, 1) < 0) {
- return -1;
- }
- if (D3D_BindTextureRep(data->device, &texturedata->vtexture, 2) < 0) {
- return -1;
- }
- }
-
+
if (shader) {
result = IDirect3DDevice9_SetPixelShader(data->device, shader);
if (FAILED(result)) {
- return D3D_SetError("SetShader()", result);
+ D3D_SetError("SetShader()", result);
+ goto done;
}
}
- result =
- IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
- vertices, sizeof(*vertices));
+ result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_TRIANGLEFAN, 2,
+ vertices, sizeof(*vertices));
if (FAILED(result)) {
- return D3D_SetError("DrawPrimitiveUP()", result);
+ D3D_SetError("DrawPrimitiveUP()", result);
}
+done:
if (shader) {
- result = IDirect3DDevice9_SetPixelShader(data->device, NULL);
- if (FAILED(result)) {
- return D3D_SetError("SetShader()", result);
- }
+ IDirect3DDevice9_SetPixelShader(data->device, NULL);
}
modelMatrix = MatrixIdentity();
IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, (D3DMATRIX*)&modelMatrix);
- return 0;
+
+ return FAILED(result) ? -1 : 0;
}
static int
@@ -1955,6 +1759,8 @@ D3D_DestroyRenderer(SDL_Renderer * renderer)
D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
if (data) {
+ int i;
+
/* Release the render target */
if (data->defaultRenderTarget) {
IDirect3DSurface9_Release(data->defaultRenderTarget);
@@ -1964,11 +1770,15 @@ D3D_DestroyRenderer(SDL_Renderer * renderer)
IDirect3DSurface9_Release(data->currentRenderTarget);
data->currentRenderTarget = NULL;
}
- if (data->ps_yuv) {
- IDirect3DPixelShader9_Release(data->ps_yuv);
+ for (i = 0; i < SDL_arraysize(data->shaders); ++i) {
+ if (data->shaders[i]) {
+ IDirect3DPixelShader9_Release(data->shaders[i]);
+ data->shaders[i] = NULL;
+ }
}
if (data->device) {
IDirect3DDevice9_Release(data->device);
+ data->device = NULL;
}
if (data->d3d) {
IDirect3D9_Release(data->d3d);
diff --git a/src/render/direct3d/SDL_shaders_d3d.c b/src/render/direct3d/SDL_shaders_d3d.c
new file mode 100644
index 000000000..37a0dd7d0
--- /dev/null
+++ b/src/render/direct3d/SDL_shaders_d3d.c
@@ -0,0 +1,274 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+#include "SDL_render.h"
+#include "SDL_system.h"
+
+#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED
+
+#include "../../core/windows/SDL_windows.h"
+
+#include <d3d9.h>
+
+#include "SDL_shaders_d3d.h"
+
+/* The shaders here were compiled with:
+
+ fxc /T ps_2_0 /Fo"<OUTPUT FILE>" "<INPUT FILE>"
+
+ Shader object code was converted to a list of DWORDs via the following
+ *nix style command (available separately from Windows + MSVC):
+
+ hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE>
+*/
+
+/* --- D3D9_PixelShader_YUV_JPEG.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureU : register(t1);
+ Texture2D theTextureV : register(t2);
+ SamplerState theSampler = sampler_state
+ {
+ addressU = Clamp;
+ addressV = Clamp;
+ mipfilter = NONE;
+ minfilter = LINEAR;
+ magfilter = LINEAR;
+ };
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {0.0, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
+ const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
+ const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.y = theTextureU.Sample(theSampler, input.tex).r;
+ yuv.z = theTextureV.Sample(theSampler, input.tex).r;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+*/
+static const DWORD D3D9_PixelShader_YUV_JPEG[] = {
+ 0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200,
+ 0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003,
+ 0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001,
+ 0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0,
+ 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478,
+ 0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874,
+ 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004,
+ 0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265,
+ 0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001,
+ 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820,
+ 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072,
+ 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000,
+ 0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f800000, 0x00000000, 0x3fb374bc, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000,
+ 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042,
+ 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000,
+ 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000,
+ 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008,
+ 0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000,
+ 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
+ 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
+ 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff
+};
+
+/* --- D3D9_PixelShader_YUV_BT601.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureU : register(t1);
+ Texture2D theTextureV : register(t2);
+ SamplerState theSampler = sampler_state
+ {
+ addressU = Clamp;
+ addressV = Clamp;
+ mipfilter = NONE;
+ minfilter = LINEAR;
+ magfilter = LINEAR;
+ };
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.1644, 0.0000, 1.5960};
+ const float3 Gcoeff = {1.1644, -0.3918, -0.8130};
+ const float3 Bcoeff = {1.1644, 2.0172, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.y = theTextureU.Sample(theSampler, input.tex).r;
+ yuv.z = theTextureV.Sample(theSampler, input.tex).r;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+*/
+static const DWORD D3D9_PixelShader_YUV_BT601[] = {
+ 0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200,
+ 0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003,
+ 0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001,
+ 0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0,
+ 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478,
+ 0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874,
+ 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004,
+ 0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265,
+ 0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001,
+ 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820,
+ 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072,
+ 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x00000000, 0x3fcc49ba, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000,
+ 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042,
+ 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000,
+ 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000,
+ 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008,
+ 0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000,
+ 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
+ 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
+ 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff
+};
+
+/* --- D3D9_PixelShader_YUV_BT709.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureU : register(t1);
+ Texture2D theTextureV : register(t2);
+ SamplerState theSampler = sampler_state
+ {
+ addressU = Clamp;
+ addressV = Clamp;
+ mipfilter = NONE;
+ minfilter = LINEAR;
+ magfilter = LINEAR;
+ };
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.1644, 0.0000, 1.7927};
+ const float3 Gcoeff = {1.1644, -0.2132, -0.5329};
+ const float3 Bcoeff = {1.1644, 2.1124, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.y = theTextureU.Sample(theSampler, input.tex).r;
+ yuv.z = theTextureV.Sample(theSampler, input.tex).r;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+*/
+static const DWORD D3D9_PixelShader_YUV_BT709[] = {
+ 0xffff0200, 0x0044fffe, 0x42415443, 0x0000001c, 0x000000d7, 0xffff0200,
+ 0x00000003, 0x0000001c, 0x00000100, 0x000000d0, 0x00000058, 0x00010003,
+ 0x00000001, 0x00000070, 0x00000000, 0x00000080, 0x00020003, 0x00000001,
+ 0x00000098, 0x00000000, 0x000000a8, 0x00000003, 0x00000001, 0x000000c0,
+ 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478,
+ 0xab005565, 0x00070004, 0x00040001, 0x00000001, 0x00000000, 0x53656874,
+ 0x6c706d61, 0x742b7265, 0x65546568, 0x72757478, 0xab005665, 0x00070004,
+ 0x00040001, 0x00000001, 0x00000000, 0x53656874, 0x6c706d61, 0x742b7265,
+ 0x65546568, 0x72757478, 0xab005965, 0x00070004, 0x00040001, 0x00000001,
+ 0x00000000, 0x325f7370, 0x4d00305f, 0x6f726369, 0x74666f73, 0x29522820,
+ 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072,
+ 0x36392e33, 0x312e3030, 0x34383336, 0xababab00, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x00000000, 0x3fe57732, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0x900f0000, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f, 0x90000000,
+ 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000042,
+ 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002, 0xb0e40000,
+ 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001, 0x80040000,
+ 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000008,
+ 0x80010001, 0x80e40000, 0xa0e40001, 0x03000008, 0x80020001, 0x80e40000,
+ 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
+ 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
+ 0x90e40000, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff
+};
+
+
+static const DWORD *D3D9_shaders[] = {
+ D3D9_PixelShader_YUV_JPEG,
+ D3D9_PixelShader_YUV_BT601,
+ D3D9_PixelShader_YUV_BT709,
+};
+
+HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, IDirect3DPixelShader9 **pixelShader)
+{
+ return IDirect3DDevice9_CreatePixelShader(d3dDevice, D3D9_shaders[shader], pixelShader);
+}
+
+#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/SDL_yuv_mmx_c.h b/src/render/direct3d/SDL_shaders_d3d.h
index d175ebf28..bf94a50b2 100644
--- a/src/render/SDL_yuv_mmx_c.h
+++ b/src/render/direct3d/SDL_shaders_d3d.h
@@ -18,11 +18,17 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
-#include "../SDL_internal.h"
+#include "../../SDL_internal.h"
-/* FIXME: This breaks on various versions of GCC and should be rewritten using intrinsics */
-#if 0 /* (__GNUC__ > 2) && defined(__i386__) && __OPTIMIZE__ && SDL_ASSEMBLY_ROUTINES && !defined(__clang__) */
-#define USE_MMX_ASSEMBLY 1
-#endif
+/* D3D9 shader implementation */
+
+typedef enum {
+ SHADER_YUV_JPEG,
+ SHADER_YUV_BT601,
+ SHADER_YUV_BT709,
+ NUM_SHADERS
+} D3D9_Shader;
+
+extern HRESULT D3D9_CreatePixelShader(IDirect3DDevice9 *d3dDevice, D3D9_Shader shader, IDirect3DPixelShader9 **pixelShader);
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/direct3d11/SDL_render_d3d11.c b/src/render/direct3d11/SDL_render_d3d11.c
index 73cf68013..3f51e5bfd 100644..100755
--- a/src/render/direct3d11/SDL_render_d3d11.c
+++ b/src/render/direct3d11/SDL_render_d3d11.c
@@ -29,10 +29,10 @@
#include "SDL_syswm.h"
#include "../SDL_sysrender.h"
#include "../SDL_d3dmath.h"
-/* #include "SDL_log.h" */
#include <d3d11_1.h>
+#include "SDL_shaders_d3d11.h"
#ifdef __WINRT__
@@ -88,6 +88,12 @@ typedef struct
ID3D11ShaderResourceView *mainTextureResourceViewU;
ID3D11Texture2D *mainTextureV;
ID3D11ShaderResourceView *mainTextureResourceViewV;
+
+ /* NV12 texture support */
+ SDL_bool nv12;
+ ID3D11Texture2D *mainTextureNV;
+ ID3D11ShaderResourceView *mainTextureResourceViewNV;
+
Uint8 *pixels;
int pitch;
SDL_Rect locked_rect;
@@ -116,9 +122,7 @@ typedef struct
ID3D11InputLayout *inputLayout;
ID3D11Buffer *vertexBuffer;
ID3D11VertexShader *vertexShader;
- ID3D11PixelShader *colorPixelShader;
- ID3D11PixelShader *texturePixelShader;
- ID3D11PixelShader *yuvPixelShader;
+ ID3D11PixelShader *pixelShaders[NUM_SHADERS];
int blendModesCount;
D3D11_BlendMode *blendModes;
ID3D11SamplerState *nearestPixelSampler;
@@ -170,553 +174,6 @@ static const GUID SDL_IID_ID3D11Debug = { 0x79cf2233, 0x7536, 0x4948, { 0x9d, 0x
#pragma GCC diagnostic pop
#endif
-/* Direct3D 11.x shaders
-
- SDL's shaders are compiled into SDL itself, to simplify distribution.
-
- All Direct3D 11.x shaders were compiled with the following:
-
- fxc /E"main" /T "<TYPE>" /Fo"<OUTPUT FILE>" "<INPUT FILE>"
-
- Variables:
- - <TYPE>: the type of shader. A table of utilized shader types is
- listed below.
- - <OUTPUT FILE>: where to store compiled output
- - <INPUT FILE>: where to read shader source code from
-
- Shader types:
- - ps_4_0_level_9_1: Pixel shader for Windows 8+, including Windows RT
- - vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT
- - ps_4_0_level_9_3: Pixel shader for Windows Phone 8
- - vs_4_0_level_9_3: Vertex shader for Windows Phone 8
-
-
- Shader object code was converted to a list of DWORDs via the following
- *nix style command (available separately from Windows + MSVC):
-
- hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE>
- */
-#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
-#define D3D11_USE_SHADER_MODEL_4_0_level_9_3
-#else
-#define D3D11_USE_SHADER_MODEL_4_0_level_9_1
-#endif
-
-/* The color-only-rendering pixel shader:
-
- --- D3D11_PixelShader_Colors.hlsl ---
- struct PixelShaderInput
- {
- float4 pos : SV_POSITION;
- float2 tex : TEXCOORD0;
- float4 color : COLOR0;
- };
-
- float4 main(PixelShaderInput input) : SV_TARGET
- {
- return input.color;
- }
-*/
-#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
-static const DWORD D3D11_PixelShader_Colors[] = {
- 0x43425844, 0xd74c28fe, 0xa1eb8804, 0x269d512a, 0x7699723d, 0x00000001,
- 0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
- 0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
- 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
- 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
- 0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
- 0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
- 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
- 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
- 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
- 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
- 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
- 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
- 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
- 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
- 0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
- 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
- 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
- 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
- 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
-};
-#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
-static const DWORD D3D11_PixelShader_Colors[] = {
- 0x43425844, 0x93f6ccfc, 0x5f919270, 0x7a11aa4f, 0x9148e931, 0x00000001,
- 0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
- 0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
- 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
- 0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
- 0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
- 0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
- 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
- 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
- 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
- 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
- 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
- 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
- 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
- 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
- 0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
- 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
- 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
- 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
- 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
-};
-#else
-#error "An appropriate 'colors' pixel shader is not defined."
-#endif
-
-/* The texture-rendering pixel shader:
-
- --- D3D11_PixelShader_Textures.hlsl ---
- Texture2D theTexture : register(t0);
- SamplerState theSampler : register(s0);
-
- struct PixelShaderInput
- {
- float4 pos : SV_POSITION;
- float2 tex : TEXCOORD0;
- float4 color : COLOR0;
- };
-
- float4 main(PixelShaderInput input) : SV_TARGET
- {
- return theTexture.Sample(theSampler, input.tex) * input.color;
- }
-*/
-#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
-static const DWORD D3D11_PixelShader_Textures[] = {
- 0x43425844, 0x6299b59f, 0x155258f2, 0x873ab86a, 0xfcbb6dcd, 0x00000001,
- 0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
- 0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
- 0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
- 0x00280000, 0x00000000, 0xffff0200, 0x0200001f, 0x80000000, 0xb0030000,
- 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
- 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
- 0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
- 0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
- 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
- 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
- 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
- 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
- 0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
- 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
- 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
- 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
- 0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
- 0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
- 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
- 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
- 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
- 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
- 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
- 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
- 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
- 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
- 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
- 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
- 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
-};
-#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
-static const DWORD D3D11_PixelShader_Textures[] = {
- 0x43425844, 0x5876569a, 0x01b6c87e, 0x8447454f, 0xc7f3ef10, 0x00000001,
- 0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
- 0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
- 0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
- 0x00280000, 0x00000000, 0xffff0201, 0x0200001f, 0x80000000, 0xb0030000,
- 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
- 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
- 0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
- 0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
- 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
- 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
- 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
- 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
- 0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
- 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
- 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
- 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
- 0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
- 0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
- 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
- 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
- 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
- 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
- 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
- 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
- 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
- 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
- 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
- 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
- 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
-};
-#else
-#error "An appropriate 'textures' pixel shader is not defined"
-#endif
-
-/* The yuv-rendering pixel shader:
-
- --- D3D11_PixelShader_YUV.hlsl ---
- Texture2D theTextureY : register(t0);
- Texture2D theTextureU : register(t1);
- Texture2D theTextureV : register(t2);
- SamplerState theSampler : register(s0);
-
- struct PixelShaderInput
- {
- float4 pos : SV_POSITION;
- float2 tex : TEXCOORD0;
- float4 color : COLOR0;
- };
-
- float4 main(PixelShaderInput input) : SV_TARGET
- {
- const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
- const float3 Rcoeff = {1.164, 0.000, 1.596};
- const float3 Gcoeff = {1.164, -0.391, -0.813};
- const float3 Bcoeff = {1.164, 2.018, 0.000};
-
- float4 Output;
-
- float3 yuv;
- yuv.x = theTextureY.Sample(theSampler, input.tex).r;
- yuv.y = theTextureU.Sample(theSampler, input.tex).r;
- yuv.z = theTextureV.Sample(theSampler, input.tex).r;
-
- yuv += offset;
- Output.r = dot(yuv, Rcoeff);
- Output.g = dot(yuv, Gcoeff);
- Output.b = dot(yuv, Bcoeff);
- Output.a = 1.0f;
-
- return Output * input.color;
- }
-
-*/
-#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
-static const DWORD D3D11_PixelShader_YUV[] = {
- 0x43425844, 0x2321c6c6, 0xf14df2d1, 0xc79d068d, 0x8e672abf, 0x00000001,
- 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
- 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
- 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
- 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
- 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051,
- 0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
- 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x05000051,
- 0xa00f0003, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x0200001f,
- 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
- 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
- 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
- 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002,
- 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001,
- 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000,
- 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001,
- 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000,
- 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
- 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
- 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853,
- 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000,
- 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
- 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555,
- 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
- 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
- 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
- 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
- 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
- 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2,
- 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
- 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
- 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
- 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012,
- 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f94fdf4, 0x3fcc49ba,
- 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
- 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000,
- 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002,
- 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000, 0x05000036, 0x00100082,
- 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000,
- 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453,
- 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005,
- 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c,
- 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7,
- 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001,
- 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
- 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005,
- 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874,
- 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568,
- 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369,
- 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
- 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00,
- 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
- 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
- 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
- 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
- 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
- 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
- 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
-};
-#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
-static const DWORD D3D11_PixelShader_YUV[] = {
- 0x43425844, 0x6ede7360, 0x45ff5f8a, 0x34ac92ba, 0xb865f5e0, 0x00000001,
- 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
- 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
- 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
- 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
- 0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051,
- 0xa00f0001, 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x400126e9, 0x05000051,
- 0xa00f0002, 0x3f94fdf4, 0xbec83127, 0xbf5020c5, 0x00000000, 0x0200001f,
- 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
- 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
- 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801,
- 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001,
- 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001,
- 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000,
- 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008,
- 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000,
- 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005,
- 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000,
- 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a,
- 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
- 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000,
- 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062,
- 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
- 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
- 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2,
- 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000,
- 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001,
- 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
- 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
- 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
- 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000,
- 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
- 0x3f94fdf4, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
- 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f94fdf4, 0xbec83127,
- 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046,
- 0x00000000, 0x00004002, 0x3f94fdf4, 0x400126e9, 0x00000000, 0x00000000,
- 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038,
- 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002,
- 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000,
- 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000,
- 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c,
- 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
- 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
- 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005,
- 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf,
- 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001,
- 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
- 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478,
- 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
- 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030,
- 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
- 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
- 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
- 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
- 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
- 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
- 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
- 0x45475241, 0xabab0054
-};
-#else
-#error "An appropriate 'yuv' pixel shader is not defined."
-#endif
-
-/* The sole vertex shader:
-
- --- D3D11_VertexShader.hlsl ---
- #pragma pack_matrix( row_major )
-
- cbuffer VertexShaderConstants : register(b0)
- {
- matrix model;
- matrix projectionAndView;
- };
-
- struct VertexShaderInput
- {
- float3 pos : POSITION;
- float2 tex : TEXCOORD0;
- float4 color : COLOR0;
- };
-
- struct VertexShaderOutput
- {
- float4 pos : SV_POSITION;
- float2 tex : TEXCOORD0;
- float4 color : COLOR0;
- };
-
- VertexShaderOutput main(VertexShaderInput input)
- {
- VertexShaderOutput output;
- float4 pos = float4(input.pos, 1.0f);
-
- // Transform the vertex position into projected space.
- pos = mul(pos, model);
- pos = mul(pos, projectionAndView);
- output.pos = pos;
-
- // Pass through texture coordinates and color values without transformation
- output.tex = input.tex;
- output.color = input.color;
-
- return output;
- }
-*/
-#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
-static const DWORD D3D11_VertexShader[] = {
- 0x43425844, 0x62dfae5f, 0x3e8bd8df, 0x9ec97127, 0x5044eefb, 0x00000001,
- 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
- 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
- 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
- 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0200,
- 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
- 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
- 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
- 0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
- 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
- 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
- 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
- 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
- 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
- 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
- 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
- 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
- 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
- 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
- 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
- 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
- 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
- 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
- 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
- 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
- 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
- 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
- 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
- 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
- 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
- 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
- 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
- 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
- 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
- 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
- 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
- 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
- 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
- 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
- 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
- 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
- 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
- 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
- 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
- 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
- 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
- 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
- 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
- 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
- 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
- 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
- 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
- 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
- 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
- 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
-};
-#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
-static const DWORD D3D11_VertexShader[] = {
- 0x43425844, 0x01a24e41, 0x696af551, 0x4b2a87d1, 0x82ea03f6, 0x00000001,
- 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
- 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
- 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
- 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0201,
- 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
- 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
- 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
- 0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
- 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
- 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
- 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
- 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
- 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
- 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
- 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
- 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
- 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
- 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
- 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
- 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
- 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
- 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
- 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
- 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
- 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
- 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
- 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
- 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
- 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
- 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
- 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
- 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
- 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
- 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
- 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
- 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
- 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
- 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
- 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
- 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
- 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
- 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
- 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
- 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
- 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
- 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
- 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
- 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
- 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
- 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
- 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
- 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
- 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
- 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
- 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
-};
-#else
-#error "An appropriate vertex shader is not defined."
-#endif
-
/* Direct3D 11.1 renderer implementation */
static SDL_Renderer *D3D11_CreateRenderer(SDL_Window * window, Uint32 flags);
@@ -773,12 +230,14 @@ SDL_RenderDriver D3D11_RenderDriver = {
SDL_RENDERER_PRESENTVSYNC |
SDL_RENDERER_TARGETTEXTURE
), /* flags. see SDL_RendererFlags */
- 4, /* num_texture_formats */
+ 6, /* num_texture_formats */
{ /* texture_formats */
SDL_PIXELFORMAT_ARGB8888,
SDL_PIXELFORMAT_RGB888,
SDL_PIXELFORMAT_YV12,
- SDL_PIXELFORMAT_IYUV
+ SDL_PIXELFORMAT_IYUV,
+ SDL_PIXELFORMAT_NV12,
+ SDL_PIXELFORMAT_NV21
},
0, /* max_texture_width: will be filled in later */
0 /* max_texture_height: will be filled in later */
@@ -787,7 +246,8 @@ SDL_RenderDriver D3D11_RenderDriver = {
Uint32
-D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat) {
+D3D11_DXGIFormatToSDLPixelFormat(DXGI_FORMAT dxgiFormat)
+{
switch (dxgiFormat) {
case DXGI_FORMAT_B8G8R8A8_UNORM:
return SDL_PIXELFORMAT_ARGB8888;
@@ -808,6 +268,8 @@ SDLPixelFormatToDXGIFormat(Uint32 sdlFormat)
return DXGI_FORMAT_B8G8R8X8_UNORM;
case SDL_PIXELFORMAT_YV12:
case SDL_PIXELFORMAT_IYUV:
+ case SDL_PIXELFORMAT_NV12: /* For the Y texture */
+ case SDL_PIXELFORMAT_NV21: /* For the Y texture */
return DXGI_FORMAT_R8_UNORM;
default:
return DXGI_FORMAT_UNKNOWN;
@@ -918,9 +380,9 @@ D3D11_ReleaseAll(SDL_Renderer * renderer)
SAFE_RELEASE(data->inputLayout);
SAFE_RELEASE(data->vertexBuffer);
SAFE_RELEASE(data->vertexShader);
- SAFE_RELEASE(data->colorPixelShader);
- SAFE_RELEASE(data->texturePixelShader);
- SAFE_RELEASE(data->yuvPixelShader);
+ for (i = 0; i < SDL_arraysize(data->pixelShaders); ++i) {
+ SAFE_RELEASE(data->pixelShaders[i]);
+ }
if (data->blendModesCount > 0) {
for (i = 0; i < data->blendModesCount; ++i) {
SAFE_RELEASE(data->blendModes[i].blendState);
@@ -1074,6 +536,7 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
IDXGIDevice1 *dxgiDevice = NULL;
HRESULT result = S_OK;
UINT creationFlags;
+ int i;
/* This array defines the set of DirectX hardware feature levels this app will support.
* Note the ordering should be preserved.
@@ -1091,14 +554,6 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
D3D_FEATURE_LEVEL_9_1
};
- /* Declare how the input layout for SDL's vertex shader will be setup: */
- const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
- {
- { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
- };
-
D3D11_BUFFER_DESC constantBufferDesc;
D3D11_SAMPLER_DESC samplerDesc;
D3D11_RASTERIZER_DESC rasterDesc;
@@ -1230,63 +685,14 @@ D3D11_CreateDeviceResources(SDL_Renderer * renderer)
goto done;
}
- /* Load in SDL's one and only vertex shader: */
- result = ID3D11Device_CreateVertexShader(data->d3dDevice,
- D3D11_VertexShader,
- sizeof(D3D11_VertexShader),
- NULL,
- &data->vertexShader
- );
- if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result);
- goto done;
- }
-
- /* Create an input layout for SDL's vertex shader: */
- result = ID3D11Device_CreateInputLayout(data->d3dDevice,
- vertexDesc,
- ARRAYSIZE(vertexDesc),
- D3D11_VertexShader,
- sizeof(D3D11_VertexShader),
- &data->inputLayout
- );
- if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result);
- goto done;
- }
-
- /* Load in SDL's pixel shaders */
- result = ID3D11Device_CreatePixelShader(data->d3dDevice,
- D3D11_PixelShader_Colors,
- sizeof(D3D11_PixelShader_Colors),
- NULL,
- &data->colorPixelShader
- );
- if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader ['color' shader]"), result);
- goto done;
- }
-
- result = ID3D11Device_CreatePixelShader(data->d3dDevice,
- D3D11_PixelShader_Textures,
- sizeof(D3D11_PixelShader_Textures),
- NULL,
- &data->texturePixelShader
- );
- if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader ['textures' shader]"), result);
+ if (D3D11_CreateVertexShader(data->d3dDevice, &data->vertexShader, &data->inputLayout) < 0) {
goto done;
}
- result = ID3D11Device_CreatePixelShader(data->d3dDevice,
- D3D11_PixelShader_YUV,
- sizeof(D3D11_PixelShader_YUV),
- NULL,
- &data->yuvPixelShader
- );
- if (FAILED(result)) {
- WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader ['yuv' shader]"), result);
- goto done;
+ for (i = 0; i < SDL_arraysize(data->pixelShaders); ++i) {
+ if (D3D11_CreatePixelShader(data->d3dDevice, (D3D11_Shader)i, &data->pixelShaders[i]) < 0) {
+ goto done;
+ }
}
/* Setup space to hold vertex shader constants: */
@@ -1829,8 +1235,8 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
texture->format == SDL_PIXELFORMAT_IYUV) {
textureData->yuv = SDL_TRUE;
- textureDesc.Width /= 2;
- textureDesc.Height /= 2;
+ textureDesc.Width = (textureDesc.Width + 1) / 2;
+ textureDesc.Height = (textureDesc.Height + 1) / 2;
result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
&textureDesc,
@@ -1855,6 +1261,28 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
}
}
+ if (texture->format == SDL_PIXELFORMAT_NV12 ||
+ texture->format == SDL_PIXELFORMAT_NV21) {
+ D3D11_TEXTURE2D_DESC nvTextureDesc = textureDesc;
+
+ textureData->nv12 = SDL_TRUE;
+
+ nvTextureDesc.Format = DXGI_FORMAT_R8G8_UNORM;
+ nvTextureDesc.Width = (textureDesc.Width + 1) / 2;
+ nvTextureDesc.Height = (textureDesc.Height + 1) / 2;
+
+ result = ID3D11Device_CreateTexture2D(rendererData->d3dDevice,
+ &nvTextureDesc,
+ NULL,
+ &textureData->mainTextureNV
+ );
+ if (FAILED(result)) {
+ D3D11_DestroyTexture(renderer, texture);
+ WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateTexture2D"), result);
+ return -1;
+ }
+ }
+
resourceViewDesc.Format = textureDesc.Format;
resourceViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
resourceViewDesc.Texture2D.MostDetailedMip = 0;
@@ -1893,6 +1321,23 @@ D3D11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
}
}
+ if (textureData->nv12) {
+ D3D11_SHADER_RESOURCE_VIEW_DESC nvResourceViewDesc = resourceViewDesc;
+
+ nvResourceViewDesc.Format = DXGI_FORMAT_R8G8_UNORM;
+
+ result = ID3D11Device_CreateShaderResourceView(rendererData->d3dDevice,
+ (ID3D11Resource *)textureData->mainTextureNV,
+ &nvResourceViewDesc,
+ &textureData->mainTextureResourceViewNV
+ );
+ if (FAILED(result)) {
+ D3D11_DestroyTexture(renderer, texture);
+ WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateShaderResourceView"), result);
+ return -1;
+ }
+ }
+
if (texture->access & SDL_TEXTUREACCESS_TARGET) {
D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
renderTargetViewDesc.Format = textureDesc.Format;
@@ -1937,7 +1382,7 @@ D3D11_DestroyTexture(SDL_Renderer * renderer,
}
static int
-D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, Uint32 format, int x, int y, int w, int h, const void *pixels, int pitch)
+D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *texture, int bpp, int x, int y, int w, int h, const void *pixels, int pitch)
{
ID3D11Texture2D *stagingTexture;
const Uint8 *src;
@@ -1981,7 +1426,7 @@ D3D11_UpdateTextureInternal(D3D11_RenderData *rendererData, ID3D11Texture2D *tex
src = (const Uint8 *)pixels;
dst = textureMemory.pData;
- length = w * SDL_BYTESPERPIXEL(format);
+ length = w * bpp;
if (length == pitch && length == textureMemory.RowPitch) {
SDL_memcpy(dst, src, length*h);
} else {
@@ -2032,7 +1477,7 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, texture->format, rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch) < 0) {
+ if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, srcPixels, srcPitch) < 0) {
return -1;
}
@@ -2040,13 +1485,22 @@ D3D11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
/* Skip to the correct offset into the next texture */
srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch);
- if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, srcPixels, srcPitch / 2) < 0) {
+ if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureV : textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2) < 0) {
+ return -1;
+ }
+
+ /* Skip to the correct offset into the next texture */
+ srcPixels = (const void*)((const Uint8*)srcPixels + ((rect->h + 1) / 2) * ((srcPitch + 1) / 2));
+ if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, (rect->w + 1) / 2, (rect->h + 1) / 2, srcPixels, (srcPitch + 1) / 2) < 0) {
return -1;
}
+ }
+ if (textureData->nv12) {
/* Skip to the correct offset into the next texture */
- srcPixels = (const void*)((const Uint8*)srcPixels + (rect->h * srcPitch) / 4);
- if (D3D11_UpdateTextureInternal(rendererData, texture->format == SDL_PIXELFORMAT_YV12 ? textureData->mainTextureU : textureData->mainTextureV, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, srcPixels, srcPitch / 2) < 0) {
+ srcPixels = (const void*)((const Uint8*)srcPixels + rect->h * srcPitch);
+
+ if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureNV, 2, rect->x / 2, rect->y / 2, ((rect->w + 1) / 2), (rect->h + 1) / 2, srcPixels, 2*((srcPitch + 1) / 2)) < 0) {
return -1;
}
}
@@ -2068,13 +1522,13 @@ D3D11_UpdateTextureYUV(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, texture->format, rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) {
+ if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTexture, SDL_BYTESPERPIXEL(texture->format), rect->x, rect->y, rect->w, rect->h, Yplane, Ypitch) < 0) {
return -1;
}
- if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureU, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) {
+ if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureU, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Uplane, Upitch) < 0) {
return -1;
}
- if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureV, texture->format, rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) {
+ if (D3D11_UpdateTextureInternal(rendererData, textureData->mainTextureV, SDL_BYTESPERPIXEL(texture->format), rect->x / 2, rect->y / 2, rect->w / 2, rect->h / 2, Vplane, Vpitch) < 0) {
return -1;
}
return 0;
@@ -2095,7 +1549,7 @@ D3D11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- if (textureData->yuv) {
+ if (textureData->yuv || textureData->nv12) {
/* It's more efficient to upload directly... */
if (!textureData->pixels) {
textureData->pitch = texture->w;
@@ -2178,7 +1632,7 @@ D3D11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture)
return;
}
- if (textureData->yuv) {
+ if (textureData->yuv || textureData->nv12) {
const SDL_Rect *rect = &textureData->locked_rect;
void *pixels =
(void *) ((Uint8 *) textureData->pixels + rect->y * textureData->pitch +
@@ -2594,7 +2048,7 @@ D3D11_RenderDrawPoints(SDL_Renderer * renderer,
D3D11_SetPixelShader(
renderer,
- rendererData->colorPixelShader,
+ rendererData->pixelShaders[SHADER_SOLID],
0,
NULL,
NULL);
@@ -2633,7 +2087,7 @@ D3D11_RenderDrawLines(SDL_Renderer * renderer,
D3D11_SetPixelShader(
renderer,
- rendererData->colorPixelShader,
+ rendererData->pixelShaders[SHADER_SOLID],
0,
NULL,
NULL);
@@ -2678,7 +2132,7 @@ D3D11_RenderFillRects(SDL_Renderer * renderer,
D3D11_SetPixelShader(
renderer,
- rendererData->colorPixelShader,
+ rendererData->pixelShaders[SHADER_SOLID],
0,
NULL,
NULL);
@@ -2689,20 +2143,91 @@ D3D11_RenderFillRects(SDL_Renderer * renderer,
return 0;
}
-static ID3D11SamplerState *
-D3D11_RenderGetSampler(SDL_Renderer * renderer, SDL_Texture * texture)
+static int
+D3D11_RenderSetupSampler(SDL_Renderer * renderer, SDL_Texture * texture)
{
D3D11_RenderData *rendererData = (D3D11_RenderData *) renderer->driverdata;
D3D11_TextureData *textureData = (D3D11_TextureData *) texture->driverdata;
+ ID3D11SamplerState *textureSampler;
switch (textureData->scaleMode) {
case D3D11_FILTER_MIN_MAG_MIP_POINT:
- return rendererData->nearestPixelSampler;
+ textureSampler = rendererData->nearestPixelSampler;
+ break;
case D3D11_FILTER_MIN_MAG_MIP_LINEAR:
- return rendererData->linearSampler;
+ textureSampler = rendererData->linearSampler;
+ break;
default:
- return NULL;
+ return SDL_SetError("Unknown scale mode: %d\n", textureData->scaleMode);
+ }
+
+ if (textureData->yuv) {
+ ID3D11ShaderResourceView *shaderResources[] = {
+ textureData->mainTextureResourceView,
+ textureData->mainTextureResourceViewU,
+ textureData->mainTextureResourceViewV
+ };
+ D3D11_Shader shader;
+
+ switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ shader = SHADER_YUV_JPEG;
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ shader = SHADER_YUV_BT601;
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ shader = SHADER_YUV_BT709;
+ break;
+ default:
+ return SDL_SetError("Unsupported YUV conversion mode");
+ }
+
+ D3D11_SetPixelShader(
+ renderer,
+ rendererData->pixelShaders[shader],
+ SDL_arraysize(shaderResources),
+ shaderResources,
+ textureSampler);
+
+ } else if (textureData->nv12) {
+ ID3D11ShaderResourceView *shaderResources[] = {
+ textureData->mainTextureResourceView,
+ textureData->mainTextureResourceViewNV,
+ };
+ D3D11_Shader shader;
+
+ switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ shader = texture->format == SDL_PIXELFORMAT_NV12 ? SHADER_NV12_JPEG : SHADER_NV21_JPEG;
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ shader = texture->format == SDL_PIXELFORMAT_NV12 ? SHADER_NV12_BT601 : SHADER_NV21_BT601;
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ shader = texture->format == SDL_PIXELFORMAT_NV12 ? SHADER_NV12_BT709 : SHADER_NV21_BT709;
+ break;
+ default:
+ return SDL_SetError("Unsupported YUV conversion mode");
+ }
+
+ D3D11_SetPixelShader(
+ renderer,
+ rendererData->pixelShaders[shader],
+ SDL_arraysize(shaderResources),
+ shaderResources,
+ textureSampler);
+
+ } else {
+ D3D11_SetPixelShader(
+ renderer,
+ rendererData->pixelShaders[SHADER_RGB],
+ 1,
+ &textureData->mainTextureResourceView,
+ textureSampler);
}
+
+ return 0;
}
static int
@@ -2714,7 +2239,6 @@ D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
float minu, maxu, minv, maxv;
Float4 color;
VertexPositionColor vertices[4];
- ID3D11SamplerState *textureSampler;
D3D11_RenderStartDrawOp(renderer);
D3D11_RenderSetBlendMode(renderer, texture->blendMode);
@@ -2769,26 +2293,8 @@ D3D11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- textureSampler = D3D11_RenderGetSampler(renderer, texture);
- if (textureData->yuv) {
- ID3D11ShaderResourceView *shaderResources[] = {
- textureData->mainTextureResourceView,
- textureData->mainTextureResourceViewU,
- textureData->mainTextureResourceViewV
- };
- D3D11_SetPixelShader(
- renderer,
- rendererData->yuvPixelShader,
- SDL_arraysize(shaderResources),
- shaderResources,
- textureSampler);
- } else {
- D3D11_SetPixelShader(
- renderer,
- rendererData->texturePixelShader,
- 1,
- &textureData->mainTextureResourceView,
- textureSampler);
+ if (D3D11_RenderSetupSampler(renderer, texture) < 0) {
+ return -1;
}
D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor));
@@ -2808,7 +2314,6 @@ D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
Float4X4 modelMatrix;
float minx, maxx, miny, maxy;
VertexPositionColor vertices[4];
- ID3D11SamplerState *textureSampler;
D3D11_RenderStartDrawOp(renderer);
D3D11_RenderSetBlendMode(renderer, texture->blendMode);
@@ -2885,26 +2390,8 @@ D3D11_RenderCopyEx(SDL_Renderer * renderer, SDL_Texture * texture,
return -1;
}
- textureSampler = D3D11_RenderGetSampler(renderer, texture);
- if (textureData->yuv) {
- ID3D11ShaderResourceView *shaderResources[] = {
- textureData->mainTextureResourceView,
- textureData->mainTextureResourceViewU,
- textureData->mainTextureResourceViewV
- };
- D3D11_SetPixelShader(
- renderer,
- rendererData->yuvPixelShader,
- SDL_arraysize(shaderResources),
- shaderResources,
- textureSampler);
- } else {
- D3D11_SetPixelShader(
- renderer,
- rendererData->texturePixelShader,
- 1,
- &textureData->mainTextureResourceView,
- textureSampler);
+ if (D3D11_RenderSetupSampler(renderer, texture) < 0) {
+ return -1;
}
D3D11_RenderFinishDrawOp(renderer, D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP, sizeof(vertices) / sizeof(VertexPositionColor));
diff --git a/src/render/direct3d11/SDL_shaders_d3d11.c b/src/render/direct3d11/SDL_shaders_d3d11.c
new file mode 100755
index 000000000..97fd038b4
--- /dev/null
+++ b/src/render/direct3d11/SDL_shaders_d3d11.c
@@ -0,0 +1,1957 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+#if SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED
+
+#include "SDL_stdinc.h"
+
+#define COBJMACROS
+#include "../../core/windows/SDL_windows.h"
+#include <d3d11_1.h>
+
+#include "SDL_shaders_d3d11.h"
+
+#define SDL_COMPOSE_ERROR(str) SDL_STRINGIFY_ARG(__FUNCTION__) ", " str
+
+
+/* Direct3D 11.x shaders
+
+ SDL's shaders are compiled into SDL itself, to simplify distribution.
+
+ All Direct3D 11.x shaders were compiled with the following:
+
+ fxc /E"main" /T "<TYPE>" /Fo"<OUTPUT FILE>" "<INPUT FILE>"
+
+ Variables:
+ - <TYPE>: the type of shader. A table of utilized shader types is
+ listed below.
+ - <OUTPUT FILE>: where to store compiled output
+ - <INPUT FILE>: where to read shader source code from
+
+ Shader types:
+ - ps_4_0_level_9_1: Pixel shader for Windows 8+, including Windows RT
+ - vs_4_0_level_9_1: Vertex shader for Windows 8+, including Windows RT
+ - ps_4_0_level_9_3: Pixel shader for Windows Phone 8
+ - vs_4_0_level_9_3: Vertex shader for Windows Phone 8
+
+
+ Shader object code was converted to a list of DWORDs via the following
+ *nix style command (available separately from Windows + MSVC):
+
+ hexdump -v -e '6/4 "0x%08.8x, " "\n"' <FILE>
+ */
+#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
+#define D3D11_USE_SHADER_MODEL_4_0_level_9_3
+#else
+#define D3D11_USE_SHADER_MODEL_4_0_level_9_1
+#endif
+
+/* The color-only-rendering pixel shader:
+
+ --- D3D11_PixelShader_Colors.hlsl ---
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ return input.color;
+ }
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_Colors[] = {
+ 0x43425844, 0xd74c28fe, 0xa1eb8804, 0x269d512a, 0x7699723d, 0x00000001,
+ 0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
+ 0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
+ 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
+ 0x00240000, 0xffff0200, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
+ 0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
+ 0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
+ 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
+ 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
+ 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
+ 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
+ 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
+ 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
+ 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
+ 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_Colors[] = {
+ 0x43425844, 0x93f6ccfc, 0x5f919270, 0x7a11aa4f, 0x9148e931, 0x00000001,
+ 0x00000240, 0x00000006, 0x00000038, 0x00000084, 0x000000c4, 0x00000140,
+ 0x00000198, 0x0000020c, 0x396e6f41, 0x00000044, 0x00000044, 0xffff0200,
+ 0x00000020, 0x00000024, 0x00240000, 0x00240000, 0x00240000, 0x00240000,
+ 0x00240000, 0xffff0201, 0x0200001f, 0x80000000, 0xb00f0001, 0x02000001,
+ 0x800f0800, 0xb0e40001, 0x0000ffff, 0x52444853, 0x00000038, 0x00000040,
+ 0x0000000e, 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2,
+ 0x00000000, 0x05000036, 0x001020f2, 0x00000000, 0x00101e46, 0x00000002,
+ 0x0100003e, 0x54415453, 0x00000074, 0x00000002, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x46454452, 0x00000050, 0x00000000, 0x00000000,
+ 0x00000000, 0x0000001c, 0xffff0400, 0x00000100, 0x0000001c, 0x7263694d,
+ 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072,
+ 0x6c69706d, 0x39207265, 0x2e30332e, 0x30303239, 0x3336312e, 0xab003438,
+ 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
+ 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000001, 0x00000003, 0x00000065, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
+ 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'colors' pixel shader is not defined."
+#endif
+
+/* The texture-rendering pixel shader:
+
+ --- D3D11_PixelShader_Textures.hlsl ---
+ Texture2D theTexture : register(t0);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ return theTexture.Sample(theSampler, input.tex) * input.color;
+ }
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_Textures[] = {
+ 0x43425844, 0x6299b59f, 0x155258f2, 0x873ab86a, 0xfcbb6dcd, 0x00000001,
+ 0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
+ 0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
+ 0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
+ 0x00280000, 0x00000000, 0xffff0200, 0x0200001f, 0x80000000, 0xb0030000,
+ 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
+ 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
+ 0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
+ 0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
+ 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
+ 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
+ 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
+ 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
+ 0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
+ 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
+ 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
+ 0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
+ 0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
+ 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
+ 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
+ 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
+ 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
+ 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
+ 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_Textures[] = {
+ 0x43425844, 0x5876569a, 0x01b6c87e, 0x8447454f, 0xc7f3ef10, 0x00000001,
+ 0x00000330, 0x00000006, 0x00000038, 0x000000c0, 0x0000015c, 0x000001d8,
+ 0x00000288, 0x000002fc, 0x396e6f41, 0x00000080, 0x00000080, 0xffff0200,
+ 0x00000058, 0x00000028, 0x00280000, 0x00280000, 0x00280000, 0x00240001,
+ 0x00280000, 0x00000000, 0xffff0201, 0x0200001f, 0x80000000, 0xb0030000,
+ 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000, 0xa00f0800,
+ 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800, 0x03000005, 0x800f0000,
+ 0x80e40000, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
+ 0x52444853, 0x00000094, 0x00000040, 0x00000025, 0x0300005a, 0x00106000,
+ 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x03001062,
+ 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
+ 0x001020f2, 0x00000000, 0x02000068, 0x00000001, 0x09000045, 0x001000f2,
+ 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
+ 0x00000000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000000,
+ 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x00000003,
+ 0x00000001, 0x00000000, 0x00000003, 0x00000001, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000a8,
+ 0x00000000, 0x00000000, 0x00000002, 0x0000001c, 0xffff0400, 0x00000100,
+ 0x00000072, 0x0000005c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000001, 0x00000067, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x53656874,
+ 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x694d0065, 0x736f7263,
+ 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564, 0x706d6f43,
+ 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336, 0xababab00,
+ 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
+ 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
+ 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'textures' pixel shader is not defined"
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_YUV_JPEG.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureU : register(t1);
+ Texture2D theTextureV : register(t2);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {0.0, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
+ const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
+ const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.y = theTextureU.Sample(theSampler, input.tex).r;
+ yuv.z = theTextureV.Sample(theSampler, input.tex).r;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_YUV_JPEG[] = {
+ 0x43425844, 0x10359e9c, 0x92c3d2c4, 0x00bf0cd5, 0x5ce8c499, 0x00000001,
+ 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
+ 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
+ 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
+ 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
+ 0xa00f0000, 0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051,
+ 0xa00f0001, 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x05000051,
+ 0xa00f0002, 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051,
+ 0xa00f0003, 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f,
+ 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
+ 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
+ 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
+ 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002,
+ 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001,
+ 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000,
+ 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001,
+ 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000,
+ 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
+ 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
+ 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853,
+ 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000,
+ 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
+ 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555,
+ 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
+ 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
+ 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
+ 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
+ 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2,
+ 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
+ 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
+ 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
+ 0x00000000, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012,
+ 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f800000, 0x3fb374bc,
+ 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
+ 0x00000000, 0x00004002, 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000,
+ 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002,
+ 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x05000036, 0x00100082,
+ 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000,
+ 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453,
+ 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005,
+ 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c,
+ 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001,
+ 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
+ 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874,
+ 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568,
+ 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369,
+ 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
+ 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00,
+ 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
+ 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
+ 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_YUV_JPEG[] = {
+ 0x43425844, 0x616d6673, 0x83174178, 0x15aac25d, 0x2a340487, 0x00000001,
+ 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
+ 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
+ 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
+ 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
+ 0xa00f0000, 0x00000000, 0xbf008081, 0x3f800000, 0x3fb374bc, 0x05000051,
+ 0xa00f0001, 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051,
+ 0xa00f0002, 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f,
+ 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
+ 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
+ 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801,
+ 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001,
+ 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001,
+ 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000,
+ 0x0400005a, 0x80010001, 0x80e80000, 0xa0ee0000, 0xa0000000, 0x03000008,
+ 0x80020001, 0x80e40000, 0xa0e40001, 0x0400005a, 0x80040001, 0x80e40000,
+ 0xa0e40002, 0xa0aa0002, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005,
+ 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000,
+ 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a,
+ 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
+ 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000,
+ 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062,
+ 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
+ 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2,
+ 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000,
+ 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001,
+ 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
+ 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
+ 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
+ 0x00000000, 0x00004002, 0x00000000, 0xbf008081, 0xbf008081, 0x00000000,
+ 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
+ 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
+ 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f800000, 0xbeb02de0,
+ 0xbf36cf42, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046,
+ 0x00000000, 0x00004002, 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000,
+ 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038,
+ 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002,
+ 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000,
+ 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000,
+ 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c,
+ 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
+ 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001,
+ 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
+ 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478,
+ 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
+ 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030,
+ 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
+ 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+ 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
+ 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
+ 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
+ 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
+ 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_YUV_BT601.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureU : register(t1);
+ Texture2D theTextureV : register(t2);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.1644, 0.0000, 1.5960};
+ const float3 Gcoeff = {1.1644, -0.3918, -0.8130};
+ const float3 Bcoeff = {1.1644, 2.0172, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.y = theTextureU.Sample(theSampler, input.tex).r;
+ yuv.z = theTextureV.Sample(theSampler, input.tex).r;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_YUV_BT601[] = {
+ 0x43425844, 0x628ec838, 0xbe9cec6a, 0xc9ee10bb, 0x63283218, 0x00000001,
+ 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
+ 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
+ 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
+ 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
+ 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051,
+ 0xa00f0001, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051,
+ 0xa00f0002, 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051,
+ 0xa00f0003, 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f,
+ 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
+ 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
+ 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
+ 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002,
+ 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001,
+ 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000,
+ 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001,
+ 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000,
+ 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
+ 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
+ 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853,
+ 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000,
+ 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
+ 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555,
+ 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
+ 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
+ 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
+ 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
+ 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2,
+ 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
+ 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
+ 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
+ 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012,
+ 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f950b0f, 0x3fcc49ba,
+ 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
+ 0x00000000, 0x00004002, 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000,
+ 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002,
+ 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x05000036, 0x00100082,
+ 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000,
+ 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453,
+ 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005,
+ 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c,
+ 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001,
+ 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
+ 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874,
+ 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568,
+ 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369,
+ 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
+ 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00,
+ 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
+ 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
+ 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_YUV_BT601[] = {
+ 0x43425844, 0x692b159b, 0xf58723cc, 0xf4ceac9e, 0x35eec738, 0x00000001,
+ 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
+ 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
+ 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
+ 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
+ 0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051,
+ 0xa00f0001, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x400119ce, 0x05000051,
+ 0xa00f0002, 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0200001f,
+ 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
+ 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
+ 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801,
+ 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001,
+ 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001,
+ 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000,
+ 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008,
+ 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000,
+ 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005,
+ 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000,
+ 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a,
+ 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
+ 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000,
+ 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062,
+ 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
+ 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2,
+ 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000,
+ 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001,
+ 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
+ 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
+ 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
+ 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000,
+ 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
+ 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
+ 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, 0xbec89a02,
+ 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046,
+ 0x00000000, 0x00004002, 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000,
+ 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038,
+ 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002,
+ 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000,
+ 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000,
+ 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c,
+ 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
+ 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001,
+ 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
+ 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478,
+ 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
+ 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030,
+ 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
+ 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+ 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
+ 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
+ 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
+ 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
+ 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_YUV_BT709.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureU : register(t1);
+ Texture2D theTextureV : register(t2);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.1644, 0.0000, 1.7927};
+ const float3 Gcoeff = {1.1644, -0.2132, -0.5329};
+ const float3 Bcoeff = {1.1644, 2.1124, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.y = theTextureU.Sample(theSampler, input.tex).r;
+ yuv.z = theTextureV.Sample(theSampler, input.tex).r;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_YUV_BT709[] = {
+ 0x43425844, 0x5045fa84, 0xc2908cce, 0x278dacc3, 0xd4276f8f, 0x00000001,
+ 0x000005e8, 0x00000006, 0x00000038, 0x000001dc, 0x000003bc, 0x00000438,
+ 0x00000540, 0x000005b4, 0x396e6f41, 0x0000019c, 0x0000019c, 0xffff0200,
+ 0x0000016c, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
+ 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0200, 0x05000051,
+ 0xa00f0000, 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051,
+ 0xa00f0001, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x05000051,
+ 0xa00f0002, 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051,
+ 0xa00f0003, 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f,
+ 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
+ 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
+ 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40800,
+ 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0002,
+ 0xb0e40000, 0xa0e40802, 0x02000001, 0x80020000, 0x80000001, 0x02000001,
+ 0x80040000, 0x80000002, 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000,
+ 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004, 0x80010001,
+ 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000,
+ 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003,
+ 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001,
+ 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853,
+ 0x000001d8, 0x00000040, 0x00000076, 0x0300005a, 0x00106000, 0x00000000,
+ 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858, 0x00107000,
+ 0x00000001, 0x00005555, 0x04001858, 0x00107000, 0x00000002, 0x00005555,
+ 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
+ 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
+ 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
+ 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
+ 0x00100022, 0x00000000, 0x0010000a, 0x00000001, 0x09000045, 0x001000f2,
+ 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000002, 0x00106000,
+ 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x0010000a, 0x00000001,
+ 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000, 0x00004002,
+ 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012,
+ 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f950b0f, 0x3fe57732,
+ 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001, 0x00100246,
+ 0x00000000, 0x00004002, 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000,
+ 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000, 0x00004002,
+ 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x05000036, 0x00100082,
+ 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2, 0x00000000,
+ 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e, 0x54415453,
+ 0x00000074, 0x0000000c, 0x00000002, 0x00000000, 0x00000003, 0x00000005,
+ 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x46454452, 0x00000100, 0x00000000, 0x00000000, 0x00000004, 0x0000001c,
+ 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001, 0x000000a7,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000, 0x00000001,
+ 0x0000000d, 0x000000b3, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
+ 0x00000001, 0x00000001, 0x0000000d, 0x000000bf, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000002, 0x00000001, 0x0000000d, 0x53656874,
+ 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568,
+ 0x72757478, 0x74005565, 0x65546568, 0x72757478, 0x4d005665, 0x6f726369,
+ 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c, 0x72656461, 0x6d6f4320,
+ 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030, 0x34383336, 0xababab00,
+ 0x4e475349, 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000,
+ 0x00000001, 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000,
+ 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f,
+ 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f,
+ 0x0000002c, 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_YUV_BT709[] = {
+ 0x43425844, 0x72d13260, 0xf6c36f65, 0x8b9b28f5, 0x5010733c, 0x00000001,
+ 0x000005c0, 0x00000006, 0x00000038, 0x000001b4, 0x00000394, 0x00000410,
+ 0x00000518, 0x0000058c, 0x396e6f41, 0x00000174, 0x00000174, 0xffff0200,
+ 0x00000144, 0x00000030, 0x00300000, 0x00300000, 0x00300000, 0x00240003,
+ 0x00300000, 0x00000000, 0x00010001, 0x00020002, 0xffff0201, 0x05000051,
+ 0xa00f0000, 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051,
+ 0xa00f0001, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x40073190, 0x05000051,
+ 0xa00f0002, 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0200001f,
+ 0x80000000, 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f,
+ 0x90000000, 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x0200001f,
+ 0x90000000, 0xa00f0802, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40801,
+ 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800, 0x02000001, 0x80020001,
+ 0x80000000, 0x03000042, 0x800f0000, 0xb0e40000, 0xa0e40802, 0x02000001,
+ 0x80040001, 0x80000000, 0x03000002, 0x80070000, 0x80e40001, 0xa0d40000,
+ 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001, 0x03000008,
+ 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000,
+ 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000, 0x03000005,
+ 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000,
+ 0x0000ffff, 0x52444853, 0x000001d8, 0x00000040, 0x00000076, 0x0300005a,
+ 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555,
+ 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x04001858, 0x00107000,
+ 0x00000002, 0x00005555, 0x03001062, 0x00101032, 0x00000001, 0x03001062,
+ 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000, 0x02000068,
+ 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045, 0x001000f2,
+ 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001, 0x00106000,
+ 0x00000000, 0x05000036, 0x00100022, 0x00000000, 0x0010000a, 0x00000001,
+ 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46,
+ 0x00000002, 0x00106000, 0x00000000, 0x05000036, 0x00100042, 0x00000000,
+ 0x0010000a, 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246,
+ 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000,
+ 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002,
+ 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x0a000010, 0x00100022,
+ 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, 0xbe5a511a,
+ 0xbf086c22, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046,
+ 0x00000000, 0x00004002, 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000,
+ 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038,
+ 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002,
+ 0x0100003e, 0x54415453, 0x00000074, 0x0000000c, 0x00000002, 0x00000000,
+ 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x46454452, 0x00000100, 0x00000000, 0x00000000,
+ 0x00000004, 0x0000001c, 0xffff0400, 0x00000100, 0x000000cb, 0x0000009c,
+ 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000001, 0x000000a7, 0x00000002, 0x00000005, 0x00000004, 0xffffffff,
+ 0x00000000, 0x00000001, 0x0000000d, 0x000000b3, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x000000bf,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000002, 0x00000001,
+ 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
+ 0x74005965, 0x65546568, 0x72757478, 0x74005565, 0x65546568, 0x72757478,
+ 0x4d005665, 0x6f726369, 0x74666f73, 0x29522820, 0x534c4820, 0x6853204c,
+ 0x72656461, 0x6d6f4320, 0x656c6970, 0x2e362072, 0x36392e33, 0x312e3030,
+ 0x34383336, 0xababab00, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
+ 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+ 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
+ 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
+ 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
+ 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
+ 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_NV12_JPEG.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureUV : register(t1);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {0.0, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
+ const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
+ const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_NV12_JPEG[] = {
+ 0x43425844, 0x8fb9c77a, 0xe9e39686, 0x62b0e0e9, 0xd2bf8183, 0x00000001,
+ 0x00000548, 0x00000006, 0x00000038, 0x000001b0, 0x00000348, 0x000003c4,
+ 0x000004a0, 0x00000514, 0x396e6f41, 0x00000170, 0x00000170, 0xffff0200,
+ 0x00000144, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000,
+ 0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
+ 0x02000001, 0x80060000, 0x80d20001, 0x03000002, 0x80070000, 0x80e40000,
+ 0xa0e40000, 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004,
+ 0x80010001, 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001,
+ 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003,
+ 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000,
+ 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
+ 0x52444853, 0x00000190, 0x00000040, 0x00000064, 0x0300005a, 0x00106000,
+ 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858,
+ 0x00107000, 0x00000001, 0x00005555, 0x03001062, 0x00101032, 0x00000001,
+ 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045,
+ 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001,
+ 0x00106000, 0x00000000, 0x05000036, 0x00100062, 0x00000000, 0x00100106,
+ 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000,
+ 0x00004002, 0x00000000, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f,
+ 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f800000,
+ 0x3fb374bc, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001,
+ 0x00100246, 0x00000000, 0x00004002, 0x3f800000, 0xbeb02de0, 0xbf36cf42,
+ 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000,
+ 0x00004002, 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x05000036,
+ 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2,
+ 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e,
+ 0x54415453, 0x00000074, 0x0000000a, 0x00000002, 0x00000000, 0x00000003,
+ 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x46454452, 0x000000d4, 0x00000000, 0x00000000, 0x00000003,
+ 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, 0x0000007c, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
+ 0x00000087, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000,
+ 0x00000001, 0x0000000d, 0x00000093, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x53656874, 0x6c706d61,
+ 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, 0x72757478,
+ 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53,
+ 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, 0x392e332e, 0x2e303036,
+ 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
+ 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+ 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
+ 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
+ 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
+ 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
+ 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_NV12_JPEG[] = {
+ 0x43425844, 0xe33e5d8b, 0x1b5f6461, 0x1afee99f, 0xcc345c04, 0x00000001,
+ 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c,
+ 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200,
+ 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000,
+ 0x00000000, 0xbf008081, 0x3f800000, 0x3fb374bc, 0x05000051, 0xa00f0001,
+ 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800,
+ 0x02000001, 0x80060001, 0x80d00000, 0x03000002, 0x80070000, 0x80e40001,
+ 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0ee0000, 0xa0000000,
+ 0x03000008, 0x80020001, 0x80e40000, 0xa0e40001, 0x0400005a, 0x80040001,
+ 0x80e40000, 0xa0e40002, 0xa0aa0002, 0x02000001, 0x80080001, 0xa0aa0000,
+ 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800,
+ 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064,
+ 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000,
+ 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062,
+ 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
+ 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2,
+ 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
+ 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062,
+ 0x00000000, 0x00100106, 0x00000001, 0x0a000000, 0x00100072, 0x00000000,
+ 0x00100246, 0x00000000, 0x00004002, 0x00000000, 0xbf008081, 0xbf008081,
+ 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000,
+ 0x00004002, 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x0a000010,
+ 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f800000,
+ 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001,
+ 0x00100046, 0x00000000, 0x00004002, 0x3f800000, 0x3fe2d0e5, 0x00000000,
+ 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000,
+ 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46,
+ 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002,
+ 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000,
+ 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0,
+ 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002,
+ 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d,
+ 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965,
+ 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074,
+ 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265,
+ 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c,
+ 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
+ 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554,
+ 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001,
+ 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_NV12_BT601.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureUV : register(t1);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.1644, 0.0000, 1.5960};
+ const float3 Gcoeff = {1.1644, -0.3918, -0.8130};
+ const float3 Bcoeff = {1.1644, 2.0172, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_NV12_BT601[] = {
+ 0x43425844, 0xd1d24a0c, 0x337c447a, 0x22b55cff, 0xb5c9c74b, 0x00000001,
+ 0x00000548, 0x00000006, 0x00000038, 0x000001b0, 0x00000348, 0x000003c4,
+ 0x000004a0, 0x00000514, 0x396e6f41, 0x00000170, 0x00000170, 0xffff0200,
+ 0x00000144, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
+ 0x02000001, 0x80060000, 0x80d20001, 0x03000002, 0x80070000, 0x80e40000,
+ 0xa0e40000, 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004,
+ 0x80010001, 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001,
+ 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003,
+ 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000,
+ 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
+ 0x52444853, 0x00000190, 0x00000040, 0x00000064, 0x0300005a, 0x00106000,
+ 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858,
+ 0x00107000, 0x00000001, 0x00005555, 0x03001062, 0x00101032, 0x00000001,
+ 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045,
+ 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001,
+ 0x00106000, 0x00000000, 0x05000036, 0x00100062, 0x00000000, 0x00100106,
+ 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000,
+ 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f,
+ 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f950b0f,
+ 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001,
+ 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, 0xbec89a02, 0xbf5020c5,
+ 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000,
+ 0x00004002, 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x05000036,
+ 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2,
+ 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e,
+ 0x54415453, 0x00000074, 0x0000000a, 0x00000002, 0x00000000, 0x00000003,
+ 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x46454452, 0x000000d4, 0x00000000, 0x00000000, 0x00000003,
+ 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, 0x0000007c, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
+ 0x00000087, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000,
+ 0x00000001, 0x0000000d, 0x00000093, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x53656874, 0x6c706d61,
+ 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, 0x72757478,
+ 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53,
+ 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, 0x392e332e, 0x2e303036,
+ 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
+ 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+ 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
+ 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
+ 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
+ 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
+ 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_NV12_BT601[] = {
+ 0x43425844, 0x84b8b692, 0x589b9edd, 0x51ef2f0b, 0xf7247962, 0x00000001,
+ 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c,
+ 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200,
+ 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x400119ce, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800,
+ 0x02000001, 0x80060001, 0x80d00000, 0x03000002, 0x80070000, 0x80e40001,
+ 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001,
+ 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001,
+ 0x80e40000, 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000,
+ 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800,
+ 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064,
+ 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000,
+ 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062,
+ 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
+ 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2,
+ 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
+ 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062,
+ 0x00000000, 0x00100106, 0x00000001, 0x0a000000, 0x00100072, 0x00000000,
+ 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081,
+ 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000,
+ 0x00004002, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010,
+ 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f,
+ 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001,
+ 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x400119ce, 0x00000000,
+ 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000,
+ 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46,
+ 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002,
+ 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000,
+ 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0,
+ 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002,
+ 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d,
+ 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965,
+ 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074,
+ 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265,
+ 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c,
+ 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
+ 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554,
+ 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001,
+ 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_NV12_BT709.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureUV : register(t1);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.1644, 0.0000, 1.7927};
+ const float3 Gcoeff = {1.1644, -0.2132, -0.5329};
+ const float3 Bcoeff = {1.1644, 2.1124, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.yz = theTextureUV.Sample(theSampler, input.tex).rg;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_NV12_BT709[] = {
+ 0x43425844, 0x40d1b8d5, 0xaf4b78b5, 0x907fd0b5, 0xa2d23686, 0x00000001,
+ 0x00000548, 0x00000006, 0x00000038, 0x000001b0, 0x00000348, 0x000003c4,
+ 0x000004a0, 0x00000514, 0x396e6f41, 0x00000170, 0x00000170, 0xffff0200,
+ 0x00000144, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
+ 0x02000001, 0x80060000, 0x80d20001, 0x03000002, 0x80070000, 0x80e40000,
+ 0xa0e40000, 0x03000005, 0x80080000, 0x80000000, 0xa0000001, 0x04000004,
+ 0x80010001, 0x80aa0000, 0xa0550001, 0x80ff0000, 0x03000008, 0x80020001,
+ 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001, 0x80e40000, 0xa0e40003,
+ 0xa0aa0003, 0x02000001, 0x80080001, 0xa0ff0000, 0x03000005, 0x800f0000,
+ 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800, 0x80e40000, 0x0000ffff,
+ 0x52444853, 0x00000190, 0x00000040, 0x00000064, 0x0300005a, 0x00106000,
+ 0x00000000, 0x04001858, 0x00107000, 0x00000000, 0x00005555, 0x04001858,
+ 0x00107000, 0x00000001, 0x00005555, 0x03001062, 0x00101032, 0x00000001,
+ 0x03001062, 0x001010f2, 0x00000002, 0x03000065, 0x001020f2, 0x00000000,
+ 0x02000068, 0x00000002, 0x09000045, 0x001000f2, 0x00000000, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000000, 0x00106000, 0x00000000, 0x09000045,
+ 0x001000f2, 0x00000001, 0x00101046, 0x00000001, 0x00107e46, 0x00000001,
+ 0x00106000, 0x00000000, 0x05000036, 0x00100062, 0x00000000, 0x00100106,
+ 0x00000001, 0x0a000000, 0x00100072, 0x00000000, 0x00100246, 0x00000000,
+ 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081, 0x00000000, 0x0a00000f,
+ 0x00100012, 0x00000001, 0x00100086, 0x00000000, 0x00004002, 0x3f950b0f,
+ 0x3fe57732, 0x00000000, 0x00000000, 0x0a000010, 0x00100022, 0x00000001,
+ 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f, 0xbe5a511a, 0xbf086c22,
+ 0x00000000, 0x0a00000f, 0x00100042, 0x00000001, 0x00100046, 0x00000000,
+ 0x00004002, 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x05000036,
+ 0x00100082, 0x00000001, 0x00004001, 0x3f800000, 0x07000038, 0x001020f2,
+ 0x00000000, 0x00100e46, 0x00000001, 0x00101e46, 0x00000002, 0x0100003e,
+ 0x54415453, 0x00000074, 0x0000000a, 0x00000002, 0x00000000, 0x00000003,
+ 0x00000005, 0x00000000, 0x00000000, 0x00000001, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000002, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x46454452, 0x000000d4, 0x00000000, 0x00000000, 0x00000003,
+ 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0, 0x0000007c, 0x00000003,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001, 0x00000001,
+ 0x00000087, 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000000,
+ 0x00000001, 0x0000000d, 0x00000093, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000001, 0x00000001, 0x0000000d, 0x53656874, 0x6c706d61,
+ 0x74007265, 0x65546568, 0x72757478, 0x74005965, 0x65546568, 0x72757478,
+ 0x00565565, 0x7263694d, 0x666f736f, 0x52282074, 0x4c482029, 0x53204c53,
+ 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265, 0x392e332e, 0x2e303036,
+ 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c, 0x00000003, 0x00000008,
+ 0x00000050, 0x00000000, 0x00000001, 0x00000003, 0x00000000, 0x0000000f,
+ 0x0000005c, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303,
+ 0x00000065, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f,
+ 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554, 0x44524f4f, 0x4c4f4300,
+ 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001, 0x00000008, 0x00000020,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x0000000f, 0x545f5653,
+ 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_NV12_BT709[] = {
+ 0x43425844, 0xa3bba187, 0x71b6afa9, 0x15998682, 0x2d545cae, 0x00000001,
+ 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c,
+ 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200,
+ 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x3fe57732, 0x00000000, 0x40073190, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800,
+ 0x02000001, 0x80060001, 0x80d00000, 0x03000002, 0x80070000, 0x80e40001,
+ 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001,
+ 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001,
+ 0x80e40000, 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000,
+ 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800,
+ 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064,
+ 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000,
+ 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062,
+ 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
+ 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2,
+ 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
+ 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062,
+ 0x00000000, 0x00100106, 0x00000001, 0x0a000000, 0x00100072, 0x00000000,
+ 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081,
+ 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000,
+ 0x00004002, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x0a000010,
+ 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f,
+ 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001,
+ 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x40073190, 0x00000000,
+ 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000,
+ 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46,
+ 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002,
+ 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000,
+ 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0,
+ 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002,
+ 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d,
+ 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965,
+ 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074,
+ 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265,
+ 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c,
+ 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
+ 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554,
+ 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001,
+ 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_NV21_JPEG.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureUV : register(t1);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {0.0, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.0000, 0.0000, 1.4020};
+ const float3 Gcoeff = {1.0000, -0.3441, -0.7141};
+ const float3 Bcoeff = {1.0000, 1.7720, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_NV21_JPEG[] = {
+ 0x43425844, 0x9c41f579, 0xfd1019d8, 0x7c27e3ae, 0x52e3a5ff, 0x00000001,
+ 0x00000554, 0x00000006, 0x00000038, 0x000001bc, 0x00000354, 0x000003d0,
+ 0x000004ac, 0x00000520, 0x396e6f41, 0x0000017c, 0x0000017c, 0xffff0200,
+ 0x00000150, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000,
+ 0x00000000, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
+ 0x02000001, 0x80020000, 0x80550001, 0x02000001, 0x80040000, 0x80000001,
+ 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000005, 0x80080000,
+ 0x80000000, 0xa0000001, 0x04000004, 0x80010001, 0x80aa0000, 0xa0550001,
+ 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a,
+ 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001,
+ 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001,
+ 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040,
+ 0x00000064, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000,
+ 0x00000000, 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555,
+ 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
+ 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
+ 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
+ 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
+ 0x00100062, 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072,
+ 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0x00000000, 0xbf008081,
+ 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086,
+ 0x00000000, 0x00004002, 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000,
+ 0x0a000010, 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002,
+ 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x0a00000f, 0x00100042,
+ 0x00000001, 0x00100046, 0x00000000, 0x00004002, 0x3f800000, 0x3fe2d0e5,
+ 0x00000000, 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001,
+ 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001,
+ 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a,
+ 0x00000002, 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4,
+ 0x00000000, 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100,
+ 0x000000a0, 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001,
+ 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
+ 0x74005965, 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f,
+ 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
+ 0x36207265, 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349,
+ 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
+ 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49,
+ 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c,
+ 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_NV21_JPEG[] = {
+ 0x43425844, 0x5705ccc9, 0xeb57571d, 0x8ce556e0, 0x2adef743, 0x00000001,
+ 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c,
+ 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200,
+ 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000,
+ 0x00000000, 0xbf008081, 0x3f800000, 0x3fb374bc, 0x05000051, 0xa00f0001,
+ 0x3f800000, 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f800000, 0x3fe2d0e5, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800,
+ 0x02000001, 0x80060001, 0x80c40000, 0x03000002, 0x80070000, 0x80e40001,
+ 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0ee0000, 0xa0000000,
+ 0x03000008, 0x80020001, 0x80e40000, 0xa0e40001, 0x0400005a, 0x80040001,
+ 0x80e40000, 0xa0e40002, 0xa0aa0002, 0x02000001, 0x80080001, 0xa0aa0000,
+ 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800,
+ 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064,
+ 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000,
+ 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062,
+ 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
+ 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2,
+ 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
+ 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062,
+ 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, 0x00000000,
+ 0x00100246, 0x00000000, 0x00004002, 0x00000000, 0xbf008081, 0xbf008081,
+ 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000,
+ 0x00004002, 0x3f800000, 0x3fb374bc, 0x00000000, 0x00000000, 0x0a000010,
+ 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f800000,
+ 0xbeb02de0, 0xbf36cf42, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001,
+ 0x00100046, 0x00000000, 0x00004002, 0x3f800000, 0x3fe2d0e5, 0x00000000,
+ 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000,
+ 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46,
+ 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002,
+ 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000,
+ 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0,
+ 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002,
+ 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d,
+ 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965,
+ 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074,
+ 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265,
+ 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c,
+ 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
+ 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554,
+ 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001,
+ 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_NV21_BT601.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureUV : register(t1);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.1644, 0.0000, 1.5960};
+ const float3 Gcoeff = {1.1644, -0.3918, -0.8130};
+ const float3 Bcoeff = {1.1644, 2.0172, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_NV21_BT601[] = {
+ 0x43425844, 0x7fc6cfdc, 0xba87a4ff, 0xa72685a6, 0xa051b38c, 0x00000001,
+ 0x00000554, 0x00000006, 0x00000038, 0x000001bc, 0x00000354, 0x000003d0,
+ 0x000004ac, 0x00000520, 0x396e6f41, 0x0000017c, 0x0000017c, 0xffff0200,
+ 0x00000150, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f950b0f, 0x400119ce, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
+ 0x02000001, 0x80020000, 0x80550001, 0x02000001, 0x80040000, 0x80000001,
+ 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000005, 0x80080000,
+ 0x80000000, 0xa0000001, 0x04000004, 0x80010001, 0x80aa0000, 0xa0550001,
+ 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a,
+ 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001,
+ 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001,
+ 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040,
+ 0x00000064, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000,
+ 0x00000000, 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555,
+ 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
+ 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
+ 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
+ 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
+ 0x00100062, 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072,
+ 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081,
+ 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086,
+ 0x00000000, 0x00004002, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000,
+ 0x0a000010, 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002,
+ 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042,
+ 0x00000001, 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x400119ce,
+ 0x00000000, 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001,
+ 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001,
+ 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a,
+ 0x00000002, 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4,
+ 0x00000000, 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100,
+ 0x000000a0, 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001,
+ 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
+ 0x74005965, 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f,
+ 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
+ 0x36207265, 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349,
+ 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
+ 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49,
+ 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c,
+ 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_NV21_BT601[] = {
+ 0x43425844, 0x1e92bca4, 0xfeb04e20, 0x3f4226b1, 0xc89c58ad, 0x00000001,
+ 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c,
+ 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200,
+ 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x400119ce, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800,
+ 0x02000001, 0x80060001, 0x80c40000, 0x03000002, 0x80070000, 0x80e40001,
+ 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001,
+ 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001,
+ 0x80e40000, 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000,
+ 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800,
+ 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064,
+ 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000,
+ 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062,
+ 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
+ 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2,
+ 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
+ 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062,
+ 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, 0x00000000,
+ 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081,
+ 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000,
+ 0x00004002, 0x3f950b0f, 0x3fcc49ba, 0x00000000, 0x00000000, 0x0a000010,
+ 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f,
+ 0xbec89a02, 0xbf5020c5, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001,
+ 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x400119ce, 0x00000000,
+ 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000,
+ 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46,
+ 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002,
+ 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000,
+ 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0,
+ 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002,
+ 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d,
+ 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965,
+ 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074,
+ 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265,
+ 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c,
+ 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
+ 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554,
+ 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001,
+ 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The yuv-rendering pixel shader:
+
+ --- D3D11_PixelShader_NV21_BT709.hlsl ---
+ Texture2D theTextureY : register(t0);
+ Texture2D theTextureUV : register(t1);
+ SamplerState theSampler : register(s0);
+
+ struct PixelShaderInput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ float4 main(PixelShaderInput input) : SV_TARGET
+ {
+ const float3 offset = {-0.0627451017, -0.501960814, -0.501960814};
+ const float3 Rcoeff = {1.1644, 0.0000, 1.7927};
+ const float3 Gcoeff = {1.1644, -0.2132, -0.5329};
+ const float3 Bcoeff = {1.1644, 2.1124, 0.0000};
+
+ float4 Output;
+
+ float3 yuv;
+ yuv.x = theTextureY.Sample(theSampler, input.tex).r;
+ yuv.yz = theTextureUV.Sample(theSampler, input.tex).gr;
+
+ yuv += offset;
+ Output.r = dot(yuv, Rcoeff);
+ Output.g = dot(yuv, Gcoeff);
+ Output.b = dot(yuv, Bcoeff);
+ Output.a = 1.0f;
+
+ return Output * input.color;
+ }
+
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_PixelShader_NV21_BT709[] = {
+ 0x43425844, 0x754ba6c4, 0xe321a747, 0x23680787, 0x6bb1bdcc, 0x00000001,
+ 0x00000554, 0x00000006, 0x00000038, 0x000001bc, 0x00000354, 0x000003d0,
+ 0x000004ac, 0x00000520, 0x396e6f41, 0x0000017c, 0x0000017c, 0xffff0200,
+ 0x00000150, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0200, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0xbf008081, 0x3f800000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x05000051, 0xa00f0003,
+ 0x3f950b0f, 0x40073190, 0x00000000, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40800, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40801,
+ 0x02000001, 0x80020000, 0x80550001, 0x02000001, 0x80040000, 0x80000001,
+ 0x03000002, 0x80070000, 0x80e40000, 0xa0e40000, 0x03000005, 0x80080000,
+ 0x80000000, 0xa0000001, 0x04000004, 0x80010001, 0x80aa0000, 0xa0550001,
+ 0x80ff0000, 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a,
+ 0x80040001, 0x80e40000, 0xa0e40003, 0xa0aa0003, 0x02000001, 0x80080001,
+ 0xa0ff0000, 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001,
+ 0x800f0800, 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040,
+ 0x00000064, 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000,
+ 0x00000000, 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555,
+ 0x03001062, 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002,
+ 0x03000065, 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045,
+ 0x001000f2, 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000,
+ 0x00106000, 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046,
+ 0x00000001, 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036,
+ 0x00100062, 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072,
+ 0x00000000, 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081,
+ 0xbf008081, 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086,
+ 0x00000000, 0x00004002, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000,
+ 0x0a000010, 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002,
+ 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0a00000f, 0x00100042,
+ 0x00000001, 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x40073190,
+ 0x00000000, 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001,
+ 0x3f800000, 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001,
+ 0x00101e46, 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a,
+ 0x00000002, 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4,
+ 0x00000000, 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100,
+ 0x000000a0, 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005,
+ 0x00000004, 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093,
+ 0x00000002, 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001,
+ 0x0000000d, 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478,
+ 0x74005965, 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f,
+ 0x52282074, 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d,
+ 0x36207265, 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349,
+ 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
+ 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49,
+ 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c,
+ 0x00000001, 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000000, 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_PixelShader_NV21_BT709[] = {
+ 0x43425844, 0xb6219b20, 0xb71bbcf7, 0xf361cc45, 0xc4d5f5be, 0x00000001,
+ 0x00000520, 0x00000006, 0x00000038, 0x00000188, 0x00000320, 0x0000039c,
+ 0x00000478, 0x000004ec, 0x396e6f41, 0x00000148, 0x00000148, 0xffff0200,
+ 0x0000011c, 0x0000002c, 0x002c0000, 0x002c0000, 0x002c0000, 0x00240002,
+ 0x002c0000, 0x00000000, 0x00010001, 0xffff0201, 0x05000051, 0xa00f0000,
+ 0xbd808081, 0xbf008081, 0x3f800000, 0x00000000, 0x05000051, 0xa00f0001,
+ 0x3f950b0f, 0x3fe57732, 0x00000000, 0x40073190, 0x05000051, 0xa00f0002,
+ 0x3f950b0f, 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0200001f, 0x80000000,
+ 0xb0030000, 0x0200001f, 0x80000000, 0xb00f0001, 0x0200001f, 0x90000000,
+ 0xa00f0800, 0x0200001f, 0x90000000, 0xa00f0801, 0x03000042, 0x800f0000,
+ 0xb0e40000, 0xa0e40801, 0x03000042, 0x800f0001, 0xb0e40000, 0xa0e40800,
+ 0x02000001, 0x80060001, 0x80c40000, 0x03000002, 0x80070000, 0x80e40001,
+ 0xa0d40000, 0x0400005a, 0x80010001, 0x80e80000, 0xa0e40001, 0xa0aa0001,
+ 0x03000008, 0x80020001, 0x80e40000, 0xa0e40002, 0x0400005a, 0x80040001,
+ 0x80e40000, 0xa0ec0001, 0xa0aa0001, 0x02000001, 0x80080001, 0xa0aa0000,
+ 0x03000005, 0x800f0000, 0x80e40001, 0xb0e40001, 0x02000001, 0x800f0800,
+ 0x80e40000, 0x0000ffff, 0x52444853, 0x00000190, 0x00000040, 0x00000064,
+ 0x0300005a, 0x00106000, 0x00000000, 0x04001858, 0x00107000, 0x00000000,
+ 0x00005555, 0x04001858, 0x00107000, 0x00000001, 0x00005555, 0x03001062,
+ 0x00101032, 0x00000001, 0x03001062, 0x001010f2, 0x00000002, 0x03000065,
+ 0x001020f2, 0x00000000, 0x02000068, 0x00000002, 0x09000045, 0x001000f2,
+ 0x00000000, 0x00101046, 0x00000001, 0x00107e46, 0x00000000, 0x00106000,
+ 0x00000000, 0x09000045, 0x001000f2, 0x00000001, 0x00101046, 0x00000001,
+ 0x00107e46, 0x00000001, 0x00106000, 0x00000000, 0x05000036, 0x00100062,
+ 0x00000000, 0x00100456, 0x00000001, 0x0a000000, 0x00100072, 0x00000000,
+ 0x00100246, 0x00000000, 0x00004002, 0xbd808081, 0xbf008081, 0xbf008081,
+ 0x00000000, 0x0a00000f, 0x00100012, 0x00000001, 0x00100086, 0x00000000,
+ 0x00004002, 0x3f950b0f, 0x3fe57732, 0x00000000, 0x00000000, 0x0a000010,
+ 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00004002, 0x3f950b0f,
+ 0xbe5a511a, 0xbf086c22, 0x00000000, 0x0a00000f, 0x00100042, 0x00000001,
+ 0x00100046, 0x00000000, 0x00004002, 0x3f950b0f, 0x40073190, 0x00000000,
+ 0x00000000, 0x05000036, 0x00100082, 0x00000001, 0x00004001, 0x3f800000,
+ 0x07000038, 0x001020f2, 0x00000000, 0x00100e46, 0x00000001, 0x00101e46,
+ 0x00000002, 0x0100003e, 0x54415453, 0x00000074, 0x0000000a, 0x00000002,
+ 0x00000000, 0x00000003, 0x00000005, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000002,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x46454452, 0x000000d4, 0x00000000,
+ 0x00000000, 0x00000003, 0x0000001c, 0xffff0400, 0x00000100, 0x000000a0,
+ 0x0000007c, 0x00000003, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000001, 0x00000001, 0x00000087, 0x00000002, 0x00000005, 0x00000004,
+ 0xffffffff, 0x00000000, 0x00000001, 0x0000000d, 0x00000093, 0x00000002,
+ 0x00000005, 0x00000004, 0xffffffff, 0x00000001, 0x00000001, 0x0000000d,
+ 0x53656874, 0x6c706d61, 0x74007265, 0x65546568, 0x72757478, 0x74005965,
+ 0x65546568, 0x72757478, 0x00565565, 0x7263694d, 0x666f736f, 0x52282074,
+ 0x4c482029, 0x53204c53, 0x65646168, 0x6f432072, 0x6c69706d, 0x36207265,
+ 0x392e332e, 0x2e303036, 0x38333631, 0xabab0034, 0x4e475349, 0x0000006c,
+ 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001, 0x00000003,
+ 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000001, 0x00000303, 0x00000065, 0x00000000, 0x00000000, 0x00000003,
+ 0x00000002, 0x00000f0f, 0x505f5653, 0x5449534f, 0x004e4f49, 0x43584554,
+ 0x44524f4f, 0x4c4f4300, 0xab00524f, 0x4e47534f, 0x0000002c, 0x00000001,
+ 0x00000008, 0x00000020, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x0000000f, 0x545f5653, 0x45475241, 0xabab0054
+};
+#else
+#error "An appropriate 'yuv' pixel shader is not defined."
+#endif
+
+/* The sole vertex shader:
+
+ --- D3D11_VertexShader.hlsl ---
+ #pragma pack_matrix( row_major )
+
+ cbuffer VertexShaderConstants : register(b0)
+ {
+ matrix model;
+ matrix projectionAndView;
+ };
+
+ struct VertexShaderInput
+ {
+ float3 pos : POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ struct VertexShaderOutput
+ {
+ float4 pos : SV_POSITION;
+ float2 tex : TEXCOORD0;
+ float4 color : COLOR0;
+ };
+
+ VertexShaderOutput main(VertexShaderInput input)
+ {
+ VertexShaderOutput output;
+ float4 pos = float4(input.pos, 1.0f);
+
+ // Transform the vertex position into projected space.
+ pos = mul(pos, model);
+ pos = mul(pos, projectionAndView);
+ output.pos = pos;
+
+ // Pass through texture coordinates and color values without transformation
+ output.tex = input.tex;
+ output.color = input.color;
+
+ return output;
+ }
+*/
+#if defined(D3D11_USE_SHADER_MODEL_4_0_level_9_1)
+static const DWORD D3D11_VertexShader[] = {
+ 0x43425844, 0x62dfae5f, 0x3e8bd8df, 0x9ec97127, 0x5044eefb, 0x00000001,
+ 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
+ 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
+ 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
+ 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0200,
+ 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
+ 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
+ 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
+ 0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
+ 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
+ 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
+ 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
+ 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
+ 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
+ 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
+ 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
+ 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
+ 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
+ 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
+ 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
+ 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
+ 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
+ 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
+ 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
+ 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
+ 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
+ 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
+ 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
+ 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
+ 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
+ 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
+ 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
+ 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
+ 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
+ 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
+ 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
+ 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
+ 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
+ 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
+ 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
+ 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
+ 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
+ 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
+ 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
+ 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
+};
+#elif defined(D3D11_USE_SHADER_MODEL_4_0_level_9_3)
+static const DWORD D3D11_VertexShader[] = {
+ 0x43425844, 0x01a24e41, 0x696af551, 0x4b2a87d1, 0x82ea03f6, 0x00000001,
+ 0x00000598, 0x00000006, 0x00000038, 0x0000016c, 0x00000334, 0x000003b0,
+ 0x000004b4, 0x00000524, 0x396e6f41, 0x0000012c, 0x0000012c, 0xfffe0200,
+ 0x000000f8, 0x00000034, 0x00240001, 0x00300000, 0x00300000, 0x00240000,
+ 0x00300001, 0x00000000, 0x00010008, 0x00000000, 0x00000000, 0xfffe0201,
+ 0x0200001f, 0x80000005, 0x900f0000, 0x0200001f, 0x80010005, 0x900f0001,
+ 0x0200001f, 0x80020005, 0x900f0002, 0x03000005, 0x800f0000, 0x90550000,
+ 0xa0e40002, 0x04000004, 0x800f0000, 0x90000000, 0xa0e40001, 0x80e40000,
+ 0x04000004, 0x800f0000, 0x90aa0000, 0xa0e40003, 0x80e40000, 0x03000002,
+ 0x800f0000, 0x80e40000, 0xa0e40004, 0x03000005, 0x800f0001, 0x80550000,
+ 0xa0e40006, 0x04000004, 0x800f0001, 0x80000000, 0xa0e40005, 0x80e40001,
+ 0x04000004, 0x800f0001, 0x80aa0000, 0xa0e40007, 0x80e40001, 0x04000004,
+ 0x800f0000, 0x80ff0000, 0xa0e40008, 0x80e40001, 0x04000004, 0xc0030000,
+ 0x80ff0000, 0xa0e40000, 0x80e40000, 0x02000001, 0xc00c0000, 0x80e40000,
+ 0x02000001, 0xe0030000, 0x90e40001, 0x02000001, 0xe00f0001, 0x90e40002,
+ 0x0000ffff, 0x52444853, 0x000001c0, 0x00010040, 0x00000070, 0x04000059,
+ 0x00208e46, 0x00000000, 0x00000008, 0x0300005f, 0x00101072, 0x00000000,
+ 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x001010f2, 0x00000002,
+ 0x04000067, 0x001020f2, 0x00000000, 0x00000001, 0x03000065, 0x00102032,
+ 0x00000001, 0x03000065, 0x001020f2, 0x00000002, 0x02000068, 0x00000002,
+ 0x08000038, 0x001000f2, 0x00000000, 0x00101556, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000001, 0x0a000032, 0x001000f2, 0x00000000, 0x00101006,
+ 0x00000000, 0x00208e46, 0x00000000, 0x00000000, 0x00100e46, 0x00000000,
+ 0x0a000032, 0x001000f2, 0x00000000, 0x00101aa6, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000002, 0x00100e46, 0x00000000, 0x08000000, 0x001000f2,
+ 0x00000000, 0x00100e46, 0x00000000, 0x00208e46, 0x00000000, 0x00000003,
+ 0x08000038, 0x001000f2, 0x00000001, 0x00100556, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000005, 0x0a000032, 0x001000f2, 0x00000001, 0x00100006,
+ 0x00000000, 0x00208e46, 0x00000000, 0x00000004, 0x00100e46, 0x00000001,
+ 0x0a000032, 0x001000f2, 0x00000001, 0x00100aa6, 0x00000000, 0x00208e46,
+ 0x00000000, 0x00000006, 0x00100e46, 0x00000001, 0x0a000032, 0x001020f2,
+ 0x00000000, 0x00100ff6, 0x00000000, 0x00208e46, 0x00000000, 0x00000007,
+ 0x00100e46, 0x00000001, 0x05000036, 0x00102032, 0x00000001, 0x00101046,
+ 0x00000001, 0x05000036, 0x001020f2, 0x00000002, 0x00101e46, 0x00000002,
+ 0x0100003e, 0x54415453, 0x00000074, 0x0000000b, 0x00000002, 0x00000000,
+ 0x00000006, 0x00000003, 0x00000000, 0x00000000, 0x00000001, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000003, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x46454452, 0x000000fc, 0x00000001, 0x00000054,
+ 0x00000001, 0x0000001c, 0xfffe0400, 0x00000100, 0x000000c6, 0x0000003c,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000001,
+ 0x00000001, 0x74726556, 0x68537865, 0x72656461, 0x736e6f43, 0x746e6174,
+ 0xabab0073, 0x0000003c, 0x00000002, 0x0000006c, 0x00000080, 0x00000000,
+ 0x00000000, 0x0000009c, 0x00000000, 0x00000040, 0x00000002, 0x000000a4,
+ 0x00000000, 0x000000b4, 0x00000040, 0x00000040, 0x00000002, 0x000000a4,
+ 0x00000000, 0x65646f6d, 0xabab006c, 0x00030002, 0x00040004, 0x00000000,
+ 0x00000000, 0x6a6f7270, 0x69746365, 0x6e416e6f, 0x65695664, 0x694d0077,
+ 0x736f7263, 0x2074666f, 0x20295228, 0x4c534c48, 0x61685320, 0x20726564,
+ 0x706d6f43, 0x72656c69, 0x332e3920, 0x32392e30, 0x312e3030, 0x34383336,
+ 0xababab00, 0x4e475349, 0x00000068, 0x00000003, 0x00000008, 0x00000050,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000707, 0x00000059,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x00000303, 0x00000062,
+ 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000f0f, 0x49534f50,
+ 0x4e4f4954, 0x58455400, 0x524f4f43, 0x4f430044, 0x00524f4c, 0x4e47534f,
+ 0x0000006c, 0x00000003, 0x00000008, 0x00000050, 0x00000000, 0x00000001,
+ 0x00000003, 0x00000000, 0x0000000f, 0x0000005c, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000001, 0x00000c03, 0x00000065, 0x00000000, 0x00000000,
+ 0x00000003, 0x00000002, 0x0000000f, 0x505f5653, 0x5449534f, 0x004e4f49,
+ 0x43584554, 0x44524f4f, 0x4c4f4300, 0xab00524f
+};
+#else
+#error "An appropriate vertex shader is not defined."
+#endif
+
+static struct
+{
+ const void *shader_data;
+ SIZE_T shader_size;
+} D3D11_shaders[] = {
+ { D3D11_PixelShader_Colors, sizeof(D3D11_PixelShader_Colors) },
+ { D3D11_PixelShader_Textures, sizeof(D3D11_PixelShader_Textures) },
+ { D3D11_PixelShader_YUV_JPEG, sizeof(D3D11_PixelShader_YUV_JPEG) },
+ { D3D11_PixelShader_YUV_BT601, sizeof(D3D11_PixelShader_YUV_BT601) },
+ { D3D11_PixelShader_YUV_BT709, sizeof(D3D11_PixelShader_YUV_BT709) },
+ { D3D11_PixelShader_NV12_JPEG, sizeof(D3D11_PixelShader_NV12_JPEG) },
+ { D3D11_PixelShader_NV12_BT601, sizeof(D3D11_PixelShader_NV12_BT601) },
+ { D3D11_PixelShader_NV12_BT709, sizeof(D3D11_PixelShader_NV12_BT709) },
+ { D3D11_PixelShader_NV21_JPEG, sizeof(D3D11_PixelShader_NV21_JPEG) },
+ { D3D11_PixelShader_NV21_BT601, sizeof(D3D11_PixelShader_NV21_BT601) },
+ { D3D11_PixelShader_NV21_BT709, sizeof(D3D11_PixelShader_NV21_BT709) },
+};
+
+int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout)
+{
+ /* Declare how the input layout for SDL's vertex shader will be setup: */
+ const D3D11_INPUT_ELEMENT_DESC vertexDesc[] =
+ {
+ { "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ { "COLOR", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 20, D3D11_INPUT_PER_VERTEX_DATA, 0 },
+ };
+ HRESULT result;
+
+ /* Load in SDL's one and only vertex shader: */
+ result = ID3D11Device_CreateVertexShader(d3dDevice,
+ D3D11_VertexShader,
+ sizeof(D3D11_VertexShader),
+ NULL,
+ vertexShader
+ );
+ if (FAILED(result)) {
+ return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateVertexShader"), result);
+ }
+
+ /* Create an input layout for SDL's vertex shader: */
+ result = ID3D11Device_CreateInputLayout(d3dDevice,
+ vertexDesc,
+ ARRAYSIZE(vertexDesc),
+ D3D11_VertexShader,
+ sizeof(D3D11_VertexShader),
+ inputLayout
+ );
+ if (FAILED(result)) {
+ return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreateInputLayout"), result);
+ }
+ return 0;
+}
+
+int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader)
+{
+ HRESULT result;
+
+ result = ID3D11Device_CreatePixelShader(d3dDevice,
+ D3D11_shaders[shader].shader_data,
+ D3D11_shaders[shader].shader_size,
+ NULL,
+ pixelShader
+ );
+ if (FAILED(result)) {
+ return WIN_SetErrorFromHRESULT(SDL_COMPOSE_ERROR("ID3D11Device1::CreatePixelShader"), result);
+ }
+ return 0;
+}
+
+#endif /* SDL_VIDEO_RENDER_D3D11 && !SDL_RENDER_DISABLED */
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/direct3d11/SDL_shaders_d3d11.h b/src/render/direct3d11/SDL_shaders_d3d11.h
new file mode 100755
index 000000000..5624be42c
--- /dev/null
+++ b/src/render/direct3d11/SDL_shaders_d3d11.h
@@ -0,0 +1,43 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../../SDL_internal.h"
+
+/* D3D11 shader implementation */
+
+typedef enum {
+ SHADER_SOLID,
+ SHADER_RGB,
+ SHADER_YUV_JPEG,
+ SHADER_YUV_BT601,
+ SHADER_YUV_BT709,
+ SHADER_NV12_JPEG,
+ SHADER_NV12_BT601,
+ SHADER_NV12_BT709,
+ SHADER_NV21_JPEG,
+ SHADER_NV21_BT601,
+ SHADER_NV21_BT709,
+ NUM_SHADERS
+} D3D11_Shader;
+
+extern int D3D11_CreateVertexShader(ID3D11Device1 *d3dDevice, ID3D11VertexShader **vertexShader, ID3D11InputLayout **inputLayout);
+extern int D3D11_CreatePixelShader(ID3D11Device1 *d3dDevice, D3D11_Shader shader, ID3D11PixelShader **pixelShader);
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/mmx.h b/src/render/mmx.h
deleted file mode 100644
index 3bd00ac23..000000000
--- a/src/render/mmx.h
+++ /dev/null
@@ -1,642 +0,0 @@
-/* mmx.h
-
- MultiMedia eXtensions GCC interface library for IA32.
-
- To use this library, simply include this header file
- and compile with GCC. You MUST have inlining enabled
- in order for mmx_ok() to work; this can be done by
- simply using -O on the GCC command line.
-
- Compiling with -DMMX_TRACE will cause detailed trace
- output to be sent to stderr for each mmx operation.
- This adds lots of code, and obviously slows execution to
- a crawl, but can be very useful for debugging.
-
- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT
- LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR ANY PARTICULAR PURPOSE.
-
- 1997-99 by H. Dietz and R. Fisher
-
- Notes:
- It appears that the latest gas has the pand problem fixed, therefore
- I'll undefine BROKEN_PAND by default.
-*/
-
-#ifndef _MMX_H
-#define _MMX_H
-
-
-/* Warning: at this writing, the version of GAS packaged
- with most Linux distributions does not handle the
- parallel AND operation mnemonic correctly. If the
- symbol BROKEN_PAND is defined, a slower alternative
- coding will be used. If execution of mmxtest results
- in an illegal instruction fault, define this symbol.
-*/
-#undef BROKEN_PAND
-
-
-/* The type of an value that fits in an MMX register
- (note that long long constant values MUST be suffixed
- by LL and unsigned long long values by ULL, lest
- they be truncated by the compiler)
-*/
-typedef union
-{
- long long q; /* Quadword (64-bit) value */
- unsigned long long uq; /* Unsigned Quadword */
- int d[2]; /* 2 Doubleword (32-bit) values */
- unsigned int ud[2]; /* 2 Unsigned Doubleword */
- short w[4]; /* 4 Word (16-bit) values */
- unsigned short uw[4]; /* 4 Unsigned Word */
- char b[8]; /* 8 Byte (8-bit) values */
- unsigned char ub[8]; /* 8 Unsigned Byte */
- float s[2]; /* Single-precision (32-bit) value */
-} __attribute__ ((aligned(8))) mmx_t; /* On an 8-byte (64-bit) boundary */
-
-
-#if 0
-/* Function to test if multimedia instructions are supported...
-*/
-inline extern int
-mm_support(void)
-{
- /* Returns 1 if MMX instructions are supported,
- 3 if Cyrix MMX and Extended MMX instructions are supported
- 5 if AMD MMX and 3DNow! instructions are supported
- 0 if hardware does not support any of these
- */
- register int rval = 0;
-
- __asm__ __volatile__(
- /* See if CPUID instruction is supported ... */
- /* ... Get copies of EFLAGS into eax and ecx */
- "pushf\n\t"
- "popl %%eax\n\t" "movl %%eax, %%ecx\n\t"
- /* ... Toggle the ID bit in one copy and store */
- /* to the EFLAGS reg */
- "xorl $0x200000, %%eax\n\t"
- "push %%eax\n\t" "popf\n\t"
- /* ... Get the (hopefully modified) EFLAGS */
- "pushf\n\t" "popl %%eax\n\t"
- /* ... Compare and test result */
- "xorl %%eax, %%ecx\n\t" "testl $0x200000, %%ecx\n\t" "jz NotSupported1\n\t" /* CPUID not supported */
- /* Get standard CPUID information, and
- go to a specific vendor section */
- "movl $0, %%eax\n\t" "cpuid\n\t"
- /* Check for Intel */
- "cmpl $0x756e6547, %%ebx\n\t"
- "jne TryAMD\n\t"
- "cmpl $0x49656e69, %%edx\n\t"
- "jne TryAMD\n\t"
- "cmpl $0x6c65746e, %%ecx\n"
- "jne TryAMD\n\t" "jmp Intel\n\t"
- /* Check for AMD */
- "\nTryAMD:\n\t"
- "cmpl $0x68747541, %%ebx\n\t"
- "jne TryCyrix\n\t"
- "cmpl $0x69746e65, %%edx\n\t"
- "jne TryCyrix\n\t"
- "cmpl $0x444d4163, %%ecx\n"
- "jne TryCyrix\n\t" "jmp AMD\n\t"
- /* Check for Cyrix */
- "\nTryCyrix:\n\t"
- "cmpl $0x69727943, %%ebx\n\t"
- "jne NotSupported2\n\t"
- "cmpl $0x736e4978, %%edx\n\t"
- "jne NotSupported3\n\t"
- "cmpl $0x64616574, %%ecx\n\t"
- "jne NotSupported4\n\t"
- /* Drop through to Cyrix... */
- /* Cyrix Section */
- /* See if extended CPUID level 80000001 is supported */
- /* The value of CPUID/80000001 for the 6x86MX is undefined
- according to the Cyrix CPU Detection Guide (Preliminary
- Rev. 1.01 table 1), so we'll check the value of eax for
- CPUID/0 to see if standard CPUID level 2 is supported.
- According to the table, the only CPU which supports level
- 2 is also the only one which supports extended CPUID levels.
- */
- "cmpl $0x2, %%eax\n\t" "jne MMXtest\n\t" /* Use standard CPUID instead */
- /* Extended CPUID supported (in theory), so get extended
- features */
- "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%eax\n\t" /* Test for MMX */
- "jz NotSupported5\n\t" /* MMX not supported */
- "testl $0x01000000, %%eax\n\t" /* Test for Ext'd MMX */
- "jnz EMMXSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\n" "EMMXSupported:\n\t" "movl $3, %0:\n\n\t" /* EMMX and MMX Supported */
- "jmp Return\n\t"
- /* AMD Section */
- "AMD:\n\t"
- /* See if extended CPUID is supported */
- "movl $0x80000000, %%eax\n\t" "cpuid\n\t" "cmpl $0x80000000, %%eax\n\t" "jl MMXtest\n\t" /* Use standard CPUID instead */
- /* Extended CPUID supported, so get extended features */
- "movl $0x80000001, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */
- "jz NotSupported6\n\t" /* MMX not supported */
- "testl $0x80000000, %%edx\n\t" /* Test for 3DNow! */
- "jnz ThreeDNowSupported\n\t" "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\n" "ThreeDNowSupported:\n\t" "movl $5, %0:\n\n\t" /* 3DNow! and MMX Supported */
- "jmp Return\n\t"
- /* Intel Section */
- "Intel:\n\t"
- /* Check for MMX */
- "MMXtest:\n\t" "movl $1, %%eax\n\t" "cpuid\n\t" "testl $0x00800000, %%edx\n\t" /* Test for MMX */
- "jz NotSupported7\n\t" /* MMX Not supported */
- "movl $1, %0:\n\n\t" /* MMX Supported */
- "jmp Return\n\t"
- /* Nothing supported */
- "\nNotSupported1:\n\t" "#movl $101, %0:\n\n\t" "\nNotSupported2:\n\t" "#movl $102, %0:\n\n\t" "\nNotSupported3:\n\t" "#movl $103, %0:\n\n\t" "\nNotSupported4:\n\t" "#movl $104, %0:\n\n\t" "\nNotSupported5:\n\t" "#movl $105, %0:\n\n\t" "\nNotSupported6:\n\t" "#movl $106, %0:\n\n\t" "\nNotSupported7:\n\t" "#movl $107, %0:\n\n\t" "movl $0, %0:\n\n\t" "Return:\n\t":"=a"(rval): /* no input */
- :"eax", "ebx", "ecx", "edx");
-
- /* Return */
- return (rval);
-}
-
-/* Function to test if mmx instructions are supported...
-*/
-inline extern int
-mmx_ok(void)
-{
- /* Returns 1 if MMX instructions are supported, 0 otherwise */
- return (mm_support() & 0x1);
-}
-#endif
-
-/* Helper functions for the instruction macros that follow...
- (note that memory-to-register, m2r, instructions are nearly
- as efficient as register-to-register, r2r, instructions;
- however, memory-to-memory instructions are really simulated
- as a convenience, and are only 1/3 as efficient)
-*/
-#ifdef MMX_TRACE
-
-/* Include the stuff for printing a trace to stderr...
-*/
-
-#define mmx_i2r(op, imm, reg) \
- { \
- mmx_t mmx_trace; \
- mmx_trace.uq = (imm); \
- printf(#op "_i2r(" #imm "=0x%08x%08x, ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- __asm__ __volatile__ ("movq %%" #reg ", %0" \
- : "=X" (mmx_trace) \
- : /* nothing */ ); \
- printf(#reg "=0x%08x%08x) => ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- __asm__ __volatile__ (#op " %0, %%" #reg \
- : /* nothing */ \
- : "X" (imm)); \
- __asm__ __volatile__ ("movq %%" #reg ", %0" \
- : "=X" (mmx_trace) \
- : /* nothing */ ); \
- printf(#reg "=0x%08x%08x\n", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- }
-
-#define mmx_m2r(op, mem, reg) \
- { \
- mmx_t mmx_trace; \
- mmx_trace = (mem); \
- printf(#op "_m2r(" #mem "=0x%08x%08x, ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- __asm__ __volatile__ ("movq %%" #reg ", %0" \
- : "=X" (mmx_trace) \
- : /* nothing */ ); \
- printf(#reg "=0x%08x%08x) => ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- __asm__ __volatile__ (#op " %0, %%" #reg \
- : /* nothing */ \
- : "X" (mem)); \
- __asm__ __volatile__ ("movq %%" #reg ", %0" \
- : "=X" (mmx_trace) \
- : /* nothing */ ); \
- printf(#reg "=0x%08x%08x\n", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- }
-
-#define mmx_r2m(op, reg, mem) \
- { \
- mmx_t mmx_trace; \
- __asm__ __volatile__ ("movq %%" #reg ", %0" \
- : "=X" (mmx_trace) \
- : /* nothing */ ); \
- printf(#op "_r2m(" #reg "=0x%08x%08x, ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- mmx_trace = (mem); \
- printf(#mem "=0x%08x%08x) => ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- __asm__ __volatile__ (#op " %%" #reg ", %0" \
- : "=X" (mem) \
- : /* nothing */ ); \
- mmx_trace = (mem); \
- printf(#mem "=0x%08x%08x\n", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- }
-
-#define mmx_r2r(op, regs, regd) \
- { \
- mmx_t mmx_trace; \
- __asm__ __volatile__ ("movq %%" #regs ", %0" \
- : "=X" (mmx_trace) \
- : /* nothing */ ); \
- printf(#op "_r2r(" #regs "=0x%08x%08x, ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- __asm__ __volatile__ ("movq %%" #regd ", %0" \
- : "=X" (mmx_trace) \
- : /* nothing */ ); \
- printf(#regd "=0x%08x%08x) => ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- __asm__ __volatile__ (#op " %" #regs ", %" #regd); \
- __asm__ __volatile__ ("movq %%" #regd ", %0" \
- : "=X" (mmx_trace) \
- : /* nothing */ ); \
- printf(#regd "=0x%08x%08x\n", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- }
-
-#define mmx_m2m(op, mems, memd) \
- { \
- mmx_t mmx_trace; \
- mmx_trace = (mems); \
- printf(#op "_m2m(" #mems "=0x%08x%08x, ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- mmx_trace = (memd); \
- printf(#memd "=0x%08x%08x) => ", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- __asm__ __volatile__ ("movq %0, %%mm0\n\t" \
- #op " %1, %%mm0\n\t" \
- "movq %%mm0, %0" \
- : "=X" (memd) \
- : "X" (mems)); \
- mmx_trace = (memd); \
- printf(#memd "=0x%08x%08x\n", \
- mmx_trace.d[1], mmx_trace.d[0]); \
- }
-
-#else
-
-/* These macros are a lot simpler without the tracing...
-*/
-
-#define mmx_i2r(op, imm, reg) \
- __asm__ __volatile__ (#op " %0, %%" #reg \
- : /* nothing */ \
- : "X" (imm) )
-
-#define mmx_m2r(op, mem, reg) \
- __asm__ __volatile__ (#op " %0, %%" #reg \
- : /* nothing */ \
- : "m" (mem))
-
-#define mmx_r2m(op, reg, mem) \
- __asm__ __volatile__ (#op " %%" #reg ", %0" \
- : "=m" (mem) \
- : /* nothing */ )
-
-#define mmx_r2r(op, regs, regd) \
- __asm__ __volatile__ (#op " %" #regs ", %" #regd)
-
-#define mmx_m2m(op, mems, memd) \
- __asm__ __volatile__ ("movq %0, %%mm0\n\t" \
- #op " %1, %%mm0\n\t" \
- "movq %%mm0, %0" \
- : "=X" (memd) \
- : "X" (mems))
-
-#endif
-
-
-/* 1x64 MOVe Quadword
- (this is both a load and a store...
- in fact, it is the only way to store)
-*/
-#define movq_m2r(var, reg) mmx_m2r(movq, var, reg)
-#define movq_r2m(reg, var) mmx_r2m(movq, reg, var)
-#define movq_r2r(regs, regd) mmx_r2r(movq, regs, regd)
-#define movq(vars, vard) \
- __asm__ __volatile__ ("movq %1, %%mm0\n\t" \
- "movq %%mm0, %0" \
- : "=X" (vard) \
- : "X" (vars))
-
-
-/* 1x32 MOVe Doubleword
- (like movq, this is both load and store...
- but is most useful for moving things between
- mmx registers and ordinary registers)
-*/
-#define movd_m2r(var, reg) mmx_m2r(movd, var, reg)
-#define movd_r2m(reg, var) mmx_r2m(movd, reg, var)
-#define movd_r2r(regs, regd) mmx_r2r(movd, regs, regd)
-#define movd(vars, vard) \
- __asm__ __volatile__ ("movd %1, %%mm0\n\t" \
- "movd %%mm0, %0" \
- : "=X" (vard) \
- : "X" (vars))
-
-
-/* 2x32, 4x16, and 8x8 Parallel ADDs
-*/
-#define paddd_m2r(var, reg) mmx_m2r(paddd, var, reg)
-#define paddd_r2r(regs, regd) mmx_r2r(paddd, regs, regd)
-#define paddd(vars, vard) mmx_m2m(paddd, vars, vard)
-
-#define paddw_m2r(var, reg) mmx_m2r(paddw, var, reg)
-#define paddw_r2r(regs, regd) mmx_r2r(paddw, regs, regd)
-#define paddw(vars, vard) mmx_m2m(paddw, vars, vard)
-
-#define paddb_m2r(var, reg) mmx_m2r(paddb, var, reg)
-#define paddb_r2r(regs, regd) mmx_r2r(paddb, regs, regd)
-#define paddb(vars, vard) mmx_m2m(paddb, vars, vard)
-
-
-/* 4x16 and 8x8 Parallel ADDs using Saturation arithmetic
-*/
-#define paddsw_m2r(var, reg) mmx_m2r(paddsw, var, reg)
-#define paddsw_r2r(regs, regd) mmx_r2r(paddsw, regs, regd)
-#define paddsw(vars, vard) mmx_m2m(paddsw, vars, vard)
-
-#define paddsb_m2r(var, reg) mmx_m2r(paddsb, var, reg)
-#define paddsb_r2r(regs, regd) mmx_r2r(paddsb, regs, regd)
-#define paddsb(vars, vard) mmx_m2m(paddsb, vars, vard)
-
-
-/* 4x16 and 8x8 Parallel ADDs using Unsigned Saturation arithmetic
-*/
-#define paddusw_m2r(var, reg) mmx_m2r(paddusw, var, reg)
-#define paddusw_r2r(regs, regd) mmx_r2r(paddusw, regs, regd)
-#define paddusw(vars, vard) mmx_m2m(paddusw, vars, vard)
-
-#define paddusb_m2r(var, reg) mmx_m2r(paddusb, var, reg)
-#define paddusb_r2r(regs, regd) mmx_r2r(paddusb, regs, regd)
-#define paddusb(vars, vard) mmx_m2m(paddusb, vars, vard)
-
-
-/* 2x32, 4x16, and 8x8 Parallel SUBs
-*/
-#define psubd_m2r(var, reg) mmx_m2r(psubd, var, reg)
-#define psubd_r2r(regs, regd) mmx_r2r(psubd, regs, regd)
-#define psubd(vars, vard) mmx_m2m(psubd, vars, vard)
-
-#define psubw_m2r(var, reg) mmx_m2r(psubw, var, reg)
-#define psubw_r2r(regs, regd) mmx_r2r(psubw, regs, regd)
-#define psubw(vars, vard) mmx_m2m(psubw, vars, vard)
-
-#define psubb_m2r(var, reg) mmx_m2r(psubb, var, reg)
-#define psubb_r2r(regs, regd) mmx_r2r(psubb, regs, regd)
-#define psubb(vars, vard) mmx_m2m(psubb, vars, vard)
-
-
-/* 4x16 and 8x8 Parallel SUBs using Saturation arithmetic
-*/
-#define psubsw_m2r(var, reg) mmx_m2r(psubsw, var, reg)
-#define psubsw_r2r(regs, regd) mmx_r2r(psubsw, regs, regd)
-#define psubsw(vars, vard) mmx_m2m(psubsw, vars, vard)
-
-#define psubsb_m2r(var, reg) mmx_m2r(psubsb, var, reg)
-#define psubsb_r2r(regs, regd) mmx_r2r(psubsb, regs, regd)
-#define psubsb(vars, vard) mmx_m2m(psubsb, vars, vard)
-
-
-/* 4x16 and 8x8 Parallel SUBs using Unsigned Saturation arithmetic
-*/
-#define psubusw_m2r(var, reg) mmx_m2r(psubusw, var, reg)
-#define psubusw_r2r(regs, regd) mmx_r2r(psubusw, regs, regd)
-#define psubusw(vars, vard) mmx_m2m(psubusw, vars, vard)
-
-#define psubusb_m2r(var, reg) mmx_m2r(psubusb, var, reg)
-#define psubusb_r2r(regs, regd) mmx_r2r(psubusb, regs, regd)
-#define psubusb(vars, vard) mmx_m2m(psubusb, vars, vard)
-
-
-/* 4x16 Parallel MULs giving Low 4x16 portions of results
-*/
-#define pmullw_m2r(var, reg) mmx_m2r(pmullw, var, reg)
-#define pmullw_r2r(regs, regd) mmx_r2r(pmullw, regs, regd)
-#define pmullw(vars, vard) mmx_m2m(pmullw, vars, vard)
-
-
-/* 4x16 Parallel MULs giving High 4x16 portions of results
-*/
-#define pmulhw_m2r(var, reg) mmx_m2r(pmulhw, var, reg)
-#define pmulhw_r2r(regs, regd) mmx_r2r(pmulhw, regs, regd)
-#define pmulhw(vars, vard) mmx_m2m(pmulhw, vars, vard)
-
-
-/* 4x16->2x32 Parallel Mul-ADD
- (muls like pmullw, then adds adjacent 16-bit fields
- in the multiply result to make the final 2x32 result)
-*/
-#define pmaddwd_m2r(var, reg) mmx_m2r(pmaddwd, var, reg)
-#define pmaddwd_r2r(regs, regd) mmx_r2r(pmaddwd, regs, regd)
-#define pmaddwd(vars, vard) mmx_m2m(pmaddwd, vars, vard)
-
-
-/* 1x64 bitwise AND
-*/
-#ifdef BROKEN_PAND
-#define pand_m2r(var, reg) \
- { \
- mmx_m2r(pandn, (mmx_t) -1LL, reg); \
- mmx_m2r(pandn, var, reg); \
- }
-#define pand_r2r(regs, regd) \
- { \
- mmx_m2r(pandn, (mmx_t) -1LL, regd); \
- mmx_r2r(pandn, regs, regd) \
- }
-#define pand(vars, vard) \
- { \
- movq_m2r(vard, mm0); \
- mmx_m2r(pandn, (mmx_t) -1LL, mm0); \
- mmx_m2r(pandn, vars, mm0); \
- movq_r2m(mm0, vard); \
- }
-#else
-#define pand_m2r(var, reg) mmx_m2r(pand, var, reg)
-#define pand_r2r(regs, regd) mmx_r2r(pand, regs, regd)
-#define pand(vars, vard) mmx_m2m(pand, vars, vard)
-#endif
-
-
-/* 1x64 bitwise AND with Not the destination
-*/
-#define pandn_m2r(var, reg) mmx_m2r(pandn, var, reg)
-#define pandn_r2r(regs, regd) mmx_r2r(pandn, regs, regd)
-#define pandn(vars, vard) mmx_m2m(pandn, vars, vard)
-
-
-/* 1x64 bitwise OR
-*/
-#define por_m2r(var, reg) mmx_m2r(por, var, reg)
-#define por_r2r(regs, regd) mmx_r2r(por, regs, regd)
-#define por(vars, vard) mmx_m2m(por, vars, vard)
-
-
-/* 1x64 bitwise eXclusive OR
-*/
-#define pxor_m2r(var, reg) mmx_m2r(pxor, var, reg)
-#define pxor_r2r(regs, regd) mmx_r2r(pxor, regs, regd)
-#define pxor(vars, vard) mmx_m2m(pxor, vars, vard)
-
-
-/* 2x32, 4x16, and 8x8 Parallel CoMPare for EQuality
- (resulting fields are either 0 or -1)
-*/
-#define pcmpeqd_m2r(var, reg) mmx_m2r(pcmpeqd, var, reg)
-#define pcmpeqd_r2r(regs, regd) mmx_r2r(pcmpeqd, regs, regd)
-#define pcmpeqd(vars, vard) mmx_m2m(pcmpeqd, vars, vard)
-
-#define pcmpeqw_m2r(var, reg) mmx_m2r(pcmpeqw, var, reg)
-#define pcmpeqw_r2r(regs, regd) mmx_r2r(pcmpeqw, regs, regd)
-#define pcmpeqw(vars, vard) mmx_m2m(pcmpeqw, vars, vard)
-
-#define pcmpeqb_m2r(var, reg) mmx_m2r(pcmpeqb, var, reg)
-#define pcmpeqb_r2r(regs, regd) mmx_r2r(pcmpeqb, regs, regd)
-#define pcmpeqb(vars, vard) mmx_m2m(pcmpeqb, vars, vard)
-
-
-/* 2x32, 4x16, and 8x8 Parallel CoMPare for Greater Than
- (resulting fields are either 0 or -1)
-*/
-#define pcmpgtd_m2r(var, reg) mmx_m2r(pcmpgtd, var, reg)
-#define pcmpgtd_r2r(regs, regd) mmx_r2r(pcmpgtd, regs, regd)
-#define pcmpgtd(vars, vard) mmx_m2m(pcmpgtd, vars, vard)
-
-#define pcmpgtw_m2r(var, reg) mmx_m2r(pcmpgtw, var, reg)
-#define pcmpgtw_r2r(regs, regd) mmx_r2r(pcmpgtw, regs, regd)
-#define pcmpgtw(vars, vard) mmx_m2m(pcmpgtw, vars, vard)
-
-#define pcmpgtb_m2r(var, reg) mmx_m2r(pcmpgtb, var, reg)
-#define pcmpgtb_r2r(regs, regd) mmx_r2r(pcmpgtb, regs, regd)
-#define pcmpgtb(vars, vard) mmx_m2m(pcmpgtb, vars, vard)
-
-
-/* 1x64, 2x32, and 4x16 Parallel Shift Left Logical
-*/
-#define psllq_i2r(imm, reg) mmx_i2r(psllq, imm, reg)
-#define psllq_m2r(var, reg) mmx_m2r(psllq, var, reg)
-#define psllq_r2r(regs, regd) mmx_r2r(psllq, regs, regd)
-#define psllq(vars, vard) mmx_m2m(psllq, vars, vard)
-
-#define pslld_i2r(imm, reg) mmx_i2r(pslld, imm, reg)
-#define pslld_m2r(var, reg) mmx_m2r(pslld, var, reg)
-#define pslld_r2r(regs, regd) mmx_r2r(pslld, regs, regd)
-#define pslld(vars, vard) mmx_m2m(pslld, vars, vard)
-
-#define psllw_i2r(imm, reg) mmx_i2r(psllw, imm, reg)
-#define psllw_m2r(var, reg) mmx_m2r(psllw, var, reg)
-#define psllw_r2r(regs, regd) mmx_r2r(psllw, regs, regd)
-#define psllw(vars, vard) mmx_m2m(psllw, vars, vard)
-
-
-/* 1x64, 2x32, and 4x16 Parallel Shift Right Logical
-*/
-#define psrlq_i2r(imm, reg) mmx_i2r(psrlq, imm, reg)
-#define psrlq_m2r(var, reg) mmx_m2r(psrlq, var, reg)
-#define psrlq_r2r(regs, regd) mmx_r2r(psrlq, regs, regd)
-#define psrlq(vars, vard) mmx_m2m(psrlq, vars, vard)
-
-#define psrld_i2r(imm, reg) mmx_i2r(psrld, imm, reg)
-#define psrld_m2r(var, reg) mmx_m2r(psrld, var, reg)
-#define psrld_r2r(regs, regd) mmx_r2r(psrld, regs, regd)
-#define psrld(vars, vard) mmx_m2m(psrld, vars, vard)
-
-#define psrlw_i2r(imm, reg) mmx_i2r(psrlw, imm, reg)
-#define psrlw_m2r(var, reg) mmx_m2r(psrlw, var, reg)
-#define psrlw_r2r(regs, regd) mmx_r2r(psrlw, regs, regd)
-#define psrlw(vars, vard) mmx_m2m(psrlw, vars, vard)
-
-
-/* 2x32 and 4x16 Parallel Shift Right Arithmetic
-*/
-#define psrad_i2r(imm, reg) mmx_i2r(psrad, imm, reg)
-#define psrad_m2r(var, reg) mmx_m2r(psrad, var, reg)
-#define psrad_r2r(regs, regd) mmx_r2r(psrad, regs, regd)
-#define psrad(vars, vard) mmx_m2m(psrad, vars, vard)
-
-#define psraw_i2r(imm, reg) mmx_i2r(psraw, imm, reg)
-#define psraw_m2r(var, reg) mmx_m2r(psraw, var, reg)
-#define psraw_r2r(regs, regd) mmx_r2r(psraw, regs, regd)
-#define psraw(vars, vard) mmx_m2m(psraw, vars, vard)
-
-
-/* 2x32->4x16 and 4x16->8x8 PACK and Signed Saturate
- (packs source and dest fields into dest in that order)
-*/
-#define packssdw_m2r(var, reg) mmx_m2r(packssdw, var, reg)
-#define packssdw_r2r(regs, regd) mmx_r2r(packssdw, regs, regd)
-#define packssdw(vars, vard) mmx_m2m(packssdw, vars, vard)
-
-#define packsswb_m2r(var, reg) mmx_m2r(packsswb, var, reg)
-#define packsswb_r2r(regs, regd) mmx_r2r(packsswb, regs, regd)
-#define packsswb(vars, vard) mmx_m2m(packsswb, vars, vard)
-
-
-/* 4x16->8x8 PACK and Unsigned Saturate
- (packs source and dest fields into dest in that order)
-*/
-#define packuswb_m2r(var, reg) mmx_m2r(packuswb, var, reg)
-#define packuswb_r2r(regs, regd) mmx_r2r(packuswb, regs, regd)
-#define packuswb(vars, vard) mmx_m2m(packuswb, vars, vard)
-
-
-/* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK Low
- (interleaves low half of dest with low half of source
- as padding in each result field)
-*/
-#define punpckldq_m2r(var, reg) mmx_m2r(punpckldq, var, reg)
-#define punpckldq_r2r(regs, regd) mmx_r2r(punpckldq, regs, regd)
-#define punpckldq(vars, vard) mmx_m2m(punpckldq, vars, vard)
-
-#define punpcklwd_m2r(var, reg) mmx_m2r(punpcklwd, var, reg)
-#define punpcklwd_r2r(regs, regd) mmx_r2r(punpcklwd, regs, regd)
-#define punpcklwd(vars, vard) mmx_m2m(punpcklwd, vars, vard)
-
-#define punpcklbw_m2r(var, reg) mmx_m2r(punpcklbw, var, reg)
-#define punpcklbw_r2r(regs, regd) mmx_r2r(punpcklbw, regs, regd)
-#define punpcklbw(vars, vard) mmx_m2m(punpcklbw, vars, vard)
-
-
-/* 2x32->1x64, 4x16->2x32, and 8x8->4x16 UNPaCK High
- (interleaves high half of dest with high half of source
- as padding in each result field)
-*/
-#define punpckhdq_m2r(var, reg) mmx_m2r(punpckhdq, var, reg)
-#define punpckhdq_r2r(regs, regd) mmx_r2r(punpckhdq, regs, regd)
-#define punpckhdq(vars, vard) mmx_m2m(punpckhdq, vars, vard)
-
-#define punpckhwd_m2r(var, reg) mmx_m2r(punpckhwd, var, reg)
-#define punpckhwd_r2r(regs, regd) mmx_r2r(punpckhwd, regs, regd)
-#define punpckhwd(vars, vard) mmx_m2m(punpckhwd, vars, vard)
-
-#define punpckhbw_m2r(var, reg) mmx_m2r(punpckhbw, var, reg)
-#define punpckhbw_r2r(regs, regd) mmx_r2r(punpckhbw, regs, regd)
-#define punpckhbw(vars, vard) mmx_m2m(punpckhbw, vars, vard)
-
-
-/* Empty MMx State
- (used to clean-up when going from mmx to float use
- of the registers that are shared by both; note that
- there is no float-to-mmx operation needed, because
- only the float tag word info is corruptible)
-*/
-#ifdef MMX_TRACE
-
-#define emms() \
- { \
- printf("emms()\n"); \
- __asm__ __volatile__ ("emms"); \
- }
-
-#else
-
-#define emms() __asm__ __volatile__ ("emms")
-
-#endif
-
-#endif
-/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/render/opengl/SDL_render_gl.c b/src/render/opengl/SDL_render_gl.c
index a950d8b81..edbc8641d 100644
--- a/src/render/opengl/SDL_render_gl.c
+++ b/src/render/opengl/SDL_render_gl.c
@@ -1349,13 +1349,37 @@ GL_SetupCopy(SDL_Renderer * renderer, SDL_Texture * texture)
GL_SetBlendMode(data, texture->blendMode);
- if (texturedata->yuv) {
- GL_SetShader(data, SHADER_YUV);
- } else if (texturedata->nv12) {
- if (texture->format == SDL_PIXELFORMAT_NV12) {
- GL_SetShader(data, SHADER_NV12);
- } else {
- GL_SetShader(data, SHADER_NV21);
+ if (texturedata->yuv || texturedata->nv12) {
+ switch (SDL_GetYUVConversionModeForResolution(texture->w, texture->h)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ if (texturedata->yuv) {
+ GL_SetShader(data, SHADER_YUV_JPEG);
+ } else if (texture->format == SDL_PIXELFORMAT_NV12) {
+ GL_SetShader(data, SHADER_NV12_JPEG);
+ } else {
+ GL_SetShader(data, SHADER_NV21_JPEG);
+ }
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ if (texturedata->yuv) {
+ GL_SetShader(data, SHADER_YUV_BT601);
+ } else if (texture->format == SDL_PIXELFORMAT_NV12) {
+ GL_SetShader(data, SHADER_NV12_BT601);
+ } else {
+ GL_SetShader(data, SHADER_NV21_BT601);
+ }
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ if (texturedata->yuv) {
+ GL_SetShader(data, SHADER_YUV_BT709);
+ } else if (texture->format == SDL_PIXELFORMAT_NV12) {
+ GL_SetShader(data, SHADER_NV12_BT709);
+ } else {
+ GL_SetShader(data, SHADER_NV21_BT709);
+ }
+ break;
+ default:
+ return SDL_SetError("Unsupported YUV conversion mode");
}
} else {
GL_SetShader(data, SHADER_RGB);
diff --git a/src/render/opengl/SDL_shaders_gl.c b/src/render/opengl/SDL_shaders_gl.c
index 6d0bf8437..c94fd925e 100644
--- a/src/render/opengl/SDL_shaders_gl.c
+++ b/src/render/opengl/SDL_shaders_gl.c
@@ -62,6 +62,151 @@ struct GL_ShaderContext
GL_ShaderData shaders[NUM_SHADERS];
};
+#define COLOR_VERTEX_SHADER \
+"varying vec4 v_color;\n" \
+"\n" \
+"void main()\n" \
+"{\n" \
+" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" \
+" v_color = gl_Color;\n" \
+"}" \
+
+#define TEXTURE_VERTEX_SHADER \
+"varying vec4 v_color;\n" \
+"varying vec2 v_texCoord;\n" \
+"\n" \
+"void main()\n" \
+"{\n" \
+" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" \
+" v_color = gl_Color;\n" \
+" v_texCoord = vec2(gl_MultiTexCoord0);\n" \
+"}" \
+
+#define JPEG_SHADER_CONSTANTS \
+"// YUV offset \n" \
+"const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n" \
+"\n" \
+"// RGB coefficients \n" \
+"const vec3 Rcoeff = vec3(1, 0.000, 1.402);\n" \
+"const vec3 Gcoeff = vec3(1, -0.3441, -0.7141);\n" \
+"const vec3 Bcoeff = vec3(1, 1.772, 0.000);\n" \
+
+#define BT601_SHADER_CONSTANTS \
+"// YUV offset \n" \
+"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
+"\n" \
+"// RGB coefficients \n" \
+"const vec3 Rcoeff = vec3(1.1644, 0.000, 1.596);\n" \
+"const vec3 Gcoeff = vec3(1.1644, -0.3918, -0.813);\n" \
+"const vec3 Bcoeff = vec3(1.1644, 2.0172, 0.000);\n" \
+
+#define BT709_SHADER_CONSTANTS \
+"// YUV offset \n" \
+"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
+"\n" \
+"// RGB coefficients \n" \
+"const vec3 Rcoeff = vec3(1.1644, 0.000, 1.7927);\n" \
+"const vec3 Gcoeff = vec3(1.1644, -0.2132, -0.5329);\n" \
+"const vec3 Bcoeff = vec3(1.1644, 2.1124, 0.000);\n" \
+
+#define YUV_SHADER_PROLOGUE \
+"varying vec4 v_color;\n" \
+"varying vec2 v_texCoord;\n" \
+"uniform sampler2D tex0; // Y \n" \
+"uniform sampler2D tex1; // U \n" \
+"uniform sampler2D tex2; // V \n" \
+"\n" \
+
+#define YUV_SHADER_BODY \
+"\n" \
+"void main()\n" \
+"{\n" \
+" vec2 tcoord;\n" \
+" vec3 yuv, rgb;\n" \
+"\n" \
+" // Get the Y value \n" \
+" tcoord = v_texCoord;\n" \
+" yuv.x = texture2D(tex0, tcoord).r;\n" \
+"\n" \
+" // Get the U and V values \n" \
+" tcoord *= UVCoordScale;\n" \
+" yuv.y = texture2D(tex1, tcoord).r;\n" \
+" yuv.z = texture2D(tex2, tcoord).r;\n" \
+"\n" \
+" // Do the color transform \n" \
+" yuv += offset;\n" \
+" rgb.r = dot(yuv, Rcoeff);\n" \
+" rgb.g = dot(yuv, Gcoeff);\n" \
+" rgb.b = dot(yuv, Bcoeff);\n" \
+"\n" \
+" // That was easy. :) \n" \
+" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
+"}" \
+
+#define NV12_SHADER_PROLOGUE \
+"varying vec4 v_color;\n" \
+"varying vec2 v_texCoord;\n" \
+"uniform sampler2D tex0; // Y \n" \
+"uniform sampler2D tex1; // U/V \n" \
+"\n" \
+
+#define NV12_SHADER_BODY \
+"\n" \
+"void main()\n" \
+"{\n" \
+" vec2 tcoord;\n" \
+" vec3 yuv, rgb;\n" \
+"\n" \
+" // Get the Y value \n" \
+" tcoord = v_texCoord;\n" \
+" yuv.x = texture2D(tex0, tcoord).r;\n" \
+"\n" \
+" // Get the U and V values \n" \
+" tcoord *= UVCoordScale;\n" \
+" yuv.yz = texture2D(tex1, tcoord).ra;\n" \
+"\n" \
+" // Do the color transform \n" \
+" yuv += offset;\n" \
+" rgb.r = dot(yuv, Rcoeff);\n" \
+" rgb.g = dot(yuv, Gcoeff);\n" \
+" rgb.b = dot(yuv, Bcoeff);\n" \
+"\n" \
+" // That was easy. :) \n" \
+" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
+"}" \
+
+#define NV21_SHADER_PROLOGUE \
+"varying vec4 v_color;\n" \
+"varying vec2 v_texCoord;\n" \
+"uniform sampler2D tex0; // Y \n" \
+"uniform sampler2D tex1; // U/V \n" \
+"\n" \
+
+#define NV21_SHADER_BODY \
+"\n" \
+"void main()\n" \
+"{\n" \
+" vec2 tcoord;\n" \
+" vec3 yuv, rgb;\n" \
+"\n" \
+" // Get the Y value \n" \
+" tcoord = v_texCoord;\n" \
+" yuv.x = texture2D(tex0, tcoord).r;\n" \
+"\n" \
+" // Get the U and V values \n" \
+" tcoord *= UVCoordScale;\n" \
+" yuv.yz = texture2D(tex1, tcoord).ar;\n" \
+"\n" \
+" // Do the color transform \n" \
+" yuv += offset;\n" \
+" rgb.r = dot(yuv, Rcoeff);\n" \
+" rgb.g = dot(yuv, Gcoeff);\n" \
+" rgb.b = dot(yuv, Bcoeff);\n" \
+"\n" \
+" // That was easy. :) \n" \
+" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" \
+"}" \
+
/*
* NOTE: Always use sampler2D, etc here. We'll #define them to the
* texture_rectangle versions if we choose to use that extension.
@@ -74,13 +219,7 @@ static const char *shader_source[NUM_SHADERS][2] =
/* SHADER_SOLID */
{
/* vertex shader */
-"varying vec4 v_color;\n"
-"\n"
-"void main()\n"
-"{\n"
-" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-" v_color = gl_Color;\n"
-"}",
+ COLOR_VERTEX_SHADER,
/* fragment shader */
"varying vec4 v_color;\n"
"\n"
@@ -93,15 +232,7 @@ static const char *shader_source[NUM_SHADERS][2] =
/* SHADER_RGB */
{
/* vertex shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"\n"
-"void main()\n"
-"{\n"
-" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-" v_color = gl_Color;\n"
-" v_texCoord = vec2(gl_MultiTexCoord0);\n"
-"}",
+ TEXTURE_VERTEX_SHADER,
/* fragment shader */
"varying vec4 v_color;\n"
"varying vec2 v_texCoord;\n"
@@ -113,156 +244,86 @@ static const char *shader_source[NUM_SHADERS][2] =
"}"
},
- /* SHADER_YUV */
+ /* SHADER_YUV_JPEG */
{
/* vertex shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"\n"
-"void main()\n"
-"{\n"
-" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-" v_color = gl_Color;\n"
-" v_texCoord = vec2(gl_MultiTexCoord0);\n"
-"}",
+ TEXTURE_VERTEX_SHADER,
/* fragment shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"uniform sampler2D tex0; // Y \n"
-"uniform sampler2D tex1; // U \n"
-"uniform sampler2D tex2; // V \n"
-"\n"
-"// YUV offset \n"
-"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
-"\n"
-"// RGB coefficients \n"
-"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n"
-"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n"
-"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n"
-"\n"
-"void main()\n"
-"{\n"
-" vec2 tcoord;\n"
-" vec3 yuv, rgb;\n"
-"\n"
-" // Get the Y value \n"
-" tcoord = v_texCoord;\n"
-" yuv.x = texture2D(tex0, tcoord).r;\n"
-"\n"
-" // Get the U and V values \n"
-" tcoord *= UVCoordScale;\n"
-" yuv.y = texture2D(tex1, tcoord).r;\n"
-" yuv.z = texture2D(tex2, tcoord).r;\n"
-"\n"
-" // Do the color transform \n"
-" yuv += offset;\n"
-" rgb.r = dot(yuv, Rcoeff);\n"
-" rgb.g = dot(yuv, Gcoeff);\n"
-" rgb.b = dot(yuv, Bcoeff);\n"
-"\n"
-" // That was easy. :) \n"
-" gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
-"}"
+ YUV_SHADER_PROLOGUE
+ JPEG_SHADER_CONSTANTS
+ YUV_SHADER_BODY
},
-
- /* SHADER_NV12 */
+ /* SHADER_YUV_BT601 */
{
/* vertex shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"\n"
-"void main()\n"
-"{\n"
-" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-" v_color = gl_Color;\n"
-" v_texCoord = vec2(gl_MultiTexCoord0);\n"
-"}",
+ TEXTURE_VERTEX_SHADER,
/* fragment shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"uniform sampler2D tex0; // Y \n"
-"uniform sampler2D tex1; // U/V \n"
-"\n"
-"// YUV offset \n"
-"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
-"\n"
-"// RGB coefficients \n"
-"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n"
-"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n"
-"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n"
-"\n"
-"void main()\n"
-"{\n"
-" vec2 tcoord;\n"
-" vec3 yuv, rgb;\n"
-"\n"
-" // Get the Y value \n"
-" tcoord = v_texCoord;\n"
-" yuv.x = texture2D(tex0, tcoord).r;\n"
-"\n"
-" // Get the U and V values \n"
-" tcoord *= UVCoordScale;\n"
-" yuv.yz = texture2D(tex1, tcoord).ra;\n"
-"\n"
-" // Do the color transform \n"
-" yuv += offset;\n"
-" rgb.r = dot(yuv, Rcoeff);\n"
-" rgb.g = dot(yuv, Gcoeff);\n"
-" rgb.b = dot(yuv, Bcoeff);\n"
-"\n"
-" // That was easy. :) \n"
-" gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
-"}"
+ YUV_SHADER_PROLOGUE
+ BT601_SHADER_CONSTANTS
+ YUV_SHADER_BODY
},
-
- /* SHADER_NV21 */
+ /* SHADER_YUV_BT709 */
{
/* vertex shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"\n"
-"void main()\n"
-"{\n"
-" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
-" v_color = gl_Color;\n"
-" v_texCoord = vec2(gl_MultiTexCoord0);\n"
-"}",
+ TEXTURE_VERTEX_SHADER,
/* fragment shader */
-"varying vec4 v_color;\n"
-"varying vec2 v_texCoord;\n"
-"uniform sampler2D tex0; // Y \n"
-"uniform sampler2D tex1; // U/V \n"
-"\n"
-"// YUV offset \n"
-"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n"
-"\n"
-"// RGB coefficients \n"
-"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n"
-"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n"
-"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n"
-"\n"
-"void main()\n"
-"{\n"
-" vec2 tcoord;\n"
-" vec3 yuv, rgb;\n"
-"\n"
-" // Get the Y value \n"
-" tcoord = v_texCoord;\n"
-" yuv.x = texture2D(tex0, tcoord).r;\n"
-"\n"
-" // Get the U and V values \n"
-" tcoord *= UVCoordScale;\n"
-" yuv.yz = texture2D(tex1, tcoord).ar;\n"
-"\n"
-" // Do the color transform \n"
-" yuv += offset;\n"
-" rgb.r = dot(yuv, Rcoeff);\n"
-" rgb.g = dot(yuv, Gcoeff);\n"
-" rgb.b = dot(yuv, Bcoeff);\n"
-"\n"
-" // That was easy. :) \n"
-" gl_FragColor = vec4(rgb, 1.0) * v_color;\n"
-"}"
+ YUV_SHADER_PROLOGUE
+ BT709_SHADER_CONSTANTS
+ YUV_SHADER_BODY
+ },
+ /* SHADER_NV12_JPEG */
+ {
+ /* vertex shader */
+ TEXTURE_VERTEX_SHADER,
+ /* fragment shader */
+ NV12_SHADER_PROLOGUE
+ JPEG_SHADER_CONSTANTS
+ NV12_SHADER_BODY
+ },
+ /* SHADER_NV12_BT601 */
+ {
+ /* vertex shader */
+ TEXTURE_VERTEX_SHADER,
+ /* fragment shader */
+ NV12_SHADER_PROLOGUE
+ BT601_SHADER_CONSTANTS
+ NV12_SHADER_BODY
+ },
+ /* SHADER_NV12_BT709 */
+ {
+ /* vertex shader */
+ TEXTURE_VERTEX_SHADER,
+ /* fragment shader */
+ NV12_SHADER_PROLOGUE
+ BT709_SHADER_CONSTANTS
+ NV12_SHADER_BODY
+ },
+ /* SHADER_NV21_JPEG */
+ {
+ /* vertex shader */
+ TEXTURE_VERTEX_SHADER,
+ /* fragment shader */
+ NV21_SHADER_PROLOGUE
+ JPEG_SHADER_CONSTANTS
+ NV21_SHADER_BODY
+ },
+ /* SHADER_NV21_BT601 */
+ {
+ /* vertex shader */
+ TEXTURE_VERTEX_SHADER,
+ /* fragment shader */
+ NV21_SHADER_PROLOGUE
+ BT601_SHADER_CONSTANTS
+ NV21_SHADER_BODY
+ },
+ /* SHADER_NV21_BT709 */
+ {
+ /* vertex shader */
+ TEXTURE_VERTEX_SHADER,
+ /* fragment shader */
+ NV21_SHADER_PROLOGUE
+ BT709_SHADER_CONSTANTS
+ NV21_SHADER_BODY
},
};
diff --git a/src/render/opengl/SDL_shaders_gl.h b/src/render/opengl/SDL_shaders_gl.h
index 9489b6116..6e22f74bb 100644
--- a/src/render/opengl/SDL_shaders_gl.h
+++ b/src/render/opengl/SDL_shaders_gl.h
@@ -26,9 +26,15 @@ typedef enum {
SHADER_NONE,
SHADER_SOLID,
SHADER_RGB,
- SHADER_YUV,
- SHADER_NV12,
- SHADER_NV21,
+ SHADER_YUV_JPEG,
+ SHADER_YUV_BT601,
+ SHADER_YUV_BT709,
+ SHADER_NV12_JPEG,
+ SHADER_NV12_BT601,
+ SHADER_NV12_BT709,
+ SHADER_NV21_JPEG,
+ SHADER_NV21_BT601,
+ SHADER_NV21_BT709,
NUM_SHADERS
} GL_Shader;
diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c
index bd343cf4f..4b09e3a04 100644
--- a/src/render/opengles2/SDL_render_gles2.c
+++ b/src/render/opengles2/SDL_render_gles2.c
@@ -950,7 +950,7 @@ static void GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *en
static GLES2_ProgramCacheEntry *GLES2_CacheProgram(SDL_Renderer *renderer,
GLES2_ShaderCacheEntry *vertex,
GLES2_ShaderCacheEntry *fragment);
-static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source);
+static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, int w, int h);
static GLES2_ProgramCacheEntry *
GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex,
@@ -1189,7 +1189,7 @@ GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry)
}
static int
-GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source)
+GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, int w, int h)
{
GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
GLES2_ShaderCacheEntry *vertex = NULL;
@@ -1216,13 +1216,52 @@ GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source)
ftype = GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC;
break;
case GLES2_IMAGESOURCE_TEXTURE_YUV:
- ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC;
+ switch (SDL_GetYUVConversionModeForResolution(w, h)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC;
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC;
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC;
+ break;
+ default:
+ SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
+ goto fault;
+ }
break;
case GLES2_IMAGESOURCE_TEXTURE_NV12:
- ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC;
+ switch (SDL_GetYUVConversionModeForResolution(w, h)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC;
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC;
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC;
+ break;
+ default:
+ SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
+ goto fault;
+ }
break;
case GLES2_IMAGESOURCE_TEXTURE_NV21:
- ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC;
+ switch (SDL_GetYUVConversionModeForResolution(w, h)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC;
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC;
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ ftype = GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC;
+ break;
+ default:
+ SDL_SetError("Unsupported YUV conversion mode: %d\n", SDL_GetYUVConversionModeForResolution(w, h));
+ goto fault;
+ }
break;
default:
goto fault;
@@ -1445,7 +1484,7 @@ GLES2_SetDrawingState(SDL_Renderer * renderer)
GLES2_SetTexCoords(data, SDL_FALSE);
/* Activate an appropriate shader and set the projection matrix */
- if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID) < 0) {
+ if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, 0, 0) < 0) {
return -1;
}
@@ -1707,7 +1746,7 @@ GLES2_SetupCopy(SDL_Renderer *renderer, SDL_Texture *texture)
}
}
- if (GLES2_SelectProgram(renderer, sourceType) < 0) {
+ if (GLES2_SelectProgram(renderer, sourceType, texture->w, texture->h) < 0) {
return -1;
}
diff --git a/src/render/opengles2/SDL_shaders_gles2.c b/src/render/opengles2/SDL_shaders_gles2.c
index 77d40b39c..8b3306b66 100644
--- a/src/render/opengles2/SDL_shaders_gles2.c
+++ b/src/render/opengles2/SDL_shaders_gles2.c
@@ -126,73 +126,154 @@ static const Uint8 GLES2_FragmentSrc_TextureBGRSrc_[] = " \
} \
";
+#define JPEG_SHADER_CONSTANTS \
+"// YUV offset \n" \
+"const vec3 offset = vec3(0, -0.501960814, -0.501960814);\n" \
+"\n" \
+"// RGB coefficients \n" \
+"const mat3 matrix = mat3( 1, 1, 1,\n" \
+" 0, -0.3441, 1.772,\n" \
+" 1.402, -0.7141, 0);\n" \
+
+#define BT601_SHADER_CONSTANTS \
+"// YUV offset \n" \
+"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
+"\n" \
+"// RGB coefficients \n" \
+"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \
+" 0, -0.3918, 2.0172,\n" \
+" 1.596, -0.813, 0);\n" \
+
+#define BT709_SHADER_CONSTANTS \
+"// YUV offset \n" \
+"const vec3 offset = vec3(-0.0627451017, -0.501960814, -0.501960814);\n" \
+"\n" \
+"// RGB coefficients \n" \
+"const mat3 matrix = mat3( 1.1644, 1.1644, 1.1644,\n" \
+" 0, -0.2132, 2.1124,\n" \
+" 1.7927, -0.5329, 0);\n" \
+
+
+#define YUV_SHADER_PROLOGUE \
+"precision mediump float;\n" \
+"uniform sampler2D u_texture;\n" \
+"uniform sampler2D u_texture_u;\n" \
+"uniform sampler2D u_texture_v;\n" \
+"uniform vec4 u_modulation;\n" \
+"varying vec2 v_texCoord;\n" \
+"\n" \
+
+#define YUV_SHADER_BODY \
+"\n" \
+"void main()\n" \
+"{\n" \
+" mediump vec3 yuv;\n" \
+" lowp vec3 rgb;\n" \
+"\n" \
+" // Get the YUV values \n" \
+" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
+" yuv.y = texture2D(u_texture_u, v_texCoord).r;\n" \
+" yuv.z = texture2D(u_texture_v, v_texCoord).r;\n" \
+"\n" \
+" // Do the color transform \n" \
+" yuv += offset;\n" \
+" rgb = matrix * yuv;\n" \
+"\n" \
+" // That was easy. :) \n" \
+" gl_FragColor = vec4(rgb, 1);\n" \
+" gl_FragColor *= u_modulation;\n" \
+"}" \
+
+#define NV12_SHADER_BODY \
+"\n" \
+"void main()\n" \
+"{\n" \
+" mediump vec3 yuv;\n" \
+" lowp vec3 rgb;\n" \
+"\n" \
+" // Get the YUV values \n" \
+" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
+" yuv.yz = texture2D(u_texture_u, v_texCoord).ra;\n" \
+"\n" \
+" // Do the color transform \n" \
+" yuv += offset;\n" \
+" rgb = matrix * yuv;\n" \
+"\n" \
+" // That was easy. :) \n" \
+" gl_FragColor = vec4(rgb, 1);\n" \
+" gl_FragColor *= u_modulation;\n" \
+"}" \
+
+#define NV21_SHADER_BODY \
+"\n" \
+"void main()\n" \
+"{\n" \
+" mediump vec3 yuv;\n" \
+" lowp vec3 rgb;\n" \
+"\n" \
+" // Get the YUV values \n" \
+" yuv.x = texture2D(u_texture, v_texCoord).r;\n" \
+" yuv.yz = texture2D(u_texture_u, v_texCoord).ar;\n" \
+"\n" \
+" // Do the color transform \n" \
+" yuv += offset;\n" \
+" rgb = matrix * yuv;\n" \
+"\n" \
+" // That was easy. :) \n" \
+" gl_FragColor = vec4(rgb, 1);\n" \
+" gl_FragColor *= u_modulation;\n" \
+"}" \
+
/* YUV to ABGR conversion */
-static const Uint8 GLES2_FragmentSrc_TextureYUVSrc_[] = " \
- precision mediump float; \
- uniform sampler2D u_texture; \
- uniform sampler2D u_texture_u; \
- uniform sampler2D u_texture_v; \
- uniform vec4 u_modulation; \
- varying vec2 v_texCoord; \
- \
- void main() \
- { \
- mediump vec3 yuv; \
- lowp vec3 rgb; \
- yuv.x = texture2D(u_texture, v_texCoord).r; \
- yuv.y = texture2D(u_texture_u, v_texCoord).r - 0.5; \
- yuv.z = texture2D(u_texture_v, v_texCoord).r - 0.5; \
- rgb = mat3( 1, 1, 1, \
- 0, -0.39465, 2.03211, \
- 1.13983, -0.58060, 0) * yuv; \
- gl_FragColor = vec4(rgb, 1); \
- gl_FragColor *= u_modulation; \
- } \
-";
+static const Uint8 GLES2_FragmentSrc_TextureYUVJPEGSrc_[] = \
+ YUV_SHADER_PROLOGUE \
+ JPEG_SHADER_CONSTANTS \
+ YUV_SHADER_BODY \
+;
+static const Uint8 GLES2_FragmentSrc_TextureYUVBT601Src_[] = \
+ YUV_SHADER_PROLOGUE \
+ BT601_SHADER_CONSTANTS \
+ YUV_SHADER_BODY \
+;
+static const Uint8 GLES2_FragmentSrc_TextureYUVBT709Src_[] = \
+ YUV_SHADER_PROLOGUE \
+ BT709_SHADER_CONSTANTS \
+ YUV_SHADER_BODY \
+;
/* NV12 to ABGR conversion */
-static const Uint8 GLES2_FragmentSrc_TextureNV12Src_[] = " \
- precision mediump float; \
- uniform sampler2D u_texture; \
- uniform sampler2D u_texture_u; \
- uniform vec4 u_modulation; \
- varying vec2 v_texCoord; \
- \
- void main() \
- { \
- mediump vec3 yuv; \
- lowp vec3 rgb; \
- yuv.x = texture2D(u_texture, v_texCoord).r; \
- yuv.yz = texture2D(u_texture_u, v_texCoord).ra - 0.5; \
- rgb = mat3( 1, 1, 1, \
- 0, -0.39465, 2.03211, \
- 1.13983, -0.58060, 0) * yuv; \
- gl_FragColor = vec4(rgb, 1); \
- gl_FragColor *= u_modulation; \
- } \
-";
+static const Uint8 GLES2_FragmentSrc_TextureNV12JPEGSrc_[] = \
+ YUV_SHADER_PROLOGUE \
+ JPEG_SHADER_CONSTANTS \
+ NV12_SHADER_BODY \
+;
+static const Uint8 GLES2_FragmentSrc_TextureNV12BT601Src_[] = \
+ YUV_SHADER_PROLOGUE \
+ BT601_SHADER_CONSTANTS \
+ NV12_SHADER_BODY \
+;
+static const Uint8 GLES2_FragmentSrc_TextureNV12BT709Src_[] = \
+ YUV_SHADER_PROLOGUE \
+ BT709_SHADER_CONSTANTS \
+ NV12_SHADER_BODY \
+;
/* NV21 to ABGR conversion */
-static const Uint8 GLES2_FragmentSrc_TextureNV21Src_[] = " \
- precision mediump float; \
- uniform sampler2D u_texture; \
- uniform sampler2D u_texture_u; \
- uniform vec4 u_modulation; \
- varying vec2 v_texCoord; \
- \
- void main() \
- { \
- mediump vec3 yuv; \
- lowp vec3 rgb; \
- yuv.x = texture2D(u_texture, v_texCoord).r; \
- yuv.yz = texture2D(u_texture_u, v_texCoord).ar - 0.5; \
- rgb = mat3( 1, 1, 1, \
- 0, -0.39465, 2.03211, \
- 1.13983, -0.58060, 0) * yuv; \
- gl_FragColor = vec4(rgb, 1); \
- gl_FragColor *= u_modulation; \
- } \
-";
+static const Uint8 GLES2_FragmentSrc_TextureNV21JPEGSrc_[] = \
+ YUV_SHADER_PROLOGUE \
+ JPEG_SHADER_CONSTANTS \
+ NV21_SHADER_BODY \
+;
+static const Uint8 GLES2_FragmentSrc_TextureNV21BT601Src_[] = \
+ YUV_SHADER_PROLOGUE \
+ BT601_SHADER_CONSTANTS \
+ NV21_SHADER_BODY \
+;
+static const Uint8 GLES2_FragmentSrc_TextureNV21BT709Src_[] = \
+ YUV_SHADER_PROLOGUE \
+ BT709_SHADER_CONSTANTS \
+ NV21_SHADER_BODY \
+;
static const GLES2_ShaderInstance GLES2_VertexSrc_Default = {
GL_VERTEX_SHADER,
@@ -236,25 +317,67 @@ static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureBGRSrc = {
GLES2_FragmentSrc_TextureBGRSrc_
};
-static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVSrc = {
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVJPEGSrc = {
GL_FRAGMENT_SHADER,
GLES2_SOURCE_SHADER,
- sizeof(GLES2_FragmentSrc_TextureYUVSrc_),
- GLES2_FragmentSrc_TextureYUVSrc_
+ sizeof(GLES2_FragmentSrc_TextureYUVJPEGSrc_),
+ GLES2_FragmentSrc_TextureYUVJPEGSrc_
};
-static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12Src = {
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT601Src = {
GL_FRAGMENT_SHADER,
GLES2_SOURCE_SHADER,
- sizeof(GLES2_FragmentSrc_TextureNV12Src_),
- GLES2_FragmentSrc_TextureNV12Src_
+ sizeof(GLES2_FragmentSrc_TextureYUVBT601Src_),
+ GLES2_FragmentSrc_TextureYUVBT601Src_
};
-static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21Src = {
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureYUVBT709Src = {
GL_FRAGMENT_SHADER,
GLES2_SOURCE_SHADER,
- sizeof(GLES2_FragmentSrc_TextureNV21Src_),
- GLES2_FragmentSrc_TextureNV21Src_
+ sizeof(GLES2_FragmentSrc_TextureYUVBT709Src_),
+ GLES2_FragmentSrc_TextureYUVBT709Src_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12JPEGSrc = {
+ GL_FRAGMENT_SHADER,
+ GLES2_SOURCE_SHADER,
+ sizeof(GLES2_FragmentSrc_TextureNV12JPEGSrc_),
+ GLES2_FragmentSrc_TextureNV12JPEGSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT601Src = {
+ GL_FRAGMENT_SHADER,
+ GLES2_SOURCE_SHADER,
+ sizeof(GLES2_FragmentSrc_TextureNV12BT601Src_),
+ GLES2_FragmentSrc_TextureNV12BT601Src_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT709Src = {
+ GL_FRAGMENT_SHADER,
+ GLES2_SOURCE_SHADER,
+ sizeof(GLES2_FragmentSrc_TextureNV21BT709Src_),
+ GLES2_FragmentSrc_TextureNV21BT709Src_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21JPEGSrc = {
+ GL_FRAGMENT_SHADER,
+ GLES2_SOURCE_SHADER,
+ sizeof(GLES2_FragmentSrc_TextureNV21JPEGSrc_),
+ GLES2_FragmentSrc_TextureNV21JPEGSrc_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV21BT601Src = {
+ GL_FRAGMENT_SHADER,
+ GLES2_SOURCE_SHADER,
+ sizeof(GLES2_FragmentSrc_TextureNV21BT601Src_),
+ GLES2_FragmentSrc_TextureNV21BT601Src_
+};
+
+static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureNV12BT709Src = {
+ GL_FRAGMENT_SHADER,
+ GLES2_SOURCE_SHADER,
+ sizeof(GLES2_FragmentSrc_TextureNV12BT709Src_),
+ GLES2_FragmentSrc_TextureNV12BT709Src_
};
@@ -304,24 +427,66 @@ static GLES2_Shader GLES2_FragmentShader_TextureBGRSrc = {
}
};
-static GLES2_Shader GLES2_FragmentShader_TextureYUVSrc = {
+static GLES2_Shader GLES2_FragmentShader_TextureYUVJPEGSrc = {
+ 1,
+ {
+ &GLES2_FragmentSrc_TextureYUVJPEGSrc
+ }
+};
+
+static GLES2_Shader GLES2_FragmentShader_TextureYUVBT601Src = {
+ 1,
+ {
+ &GLES2_FragmentSrc_TextureYUVBT601Src
+ }
+};
+
+static GLES2_Shader GLES2_FragmentShader_TextureYUVBT709Src = {
+ 1,
+ {
+ &GLES2_FragmentSrc_TextureYUVBT709Src
+ }
+};
+
+static GLES2_Shader GLES2_FragmentShader_TextureNV12JPEGSrc = {
+ 1,
+ {
+ &GLES2_FragmentSrc_TextureNV12JPEGSrc
+ }
+};
+
+static GLES2_Shader GLES2_FragmentShader_TextureNV12BT601Src = {
+ 1,
+ {
+ &GLES2_FragmentSrc_TextureNV12BT601Src
+ }
+};
+
+static GLES2_Shader GLES2_FragmentShader_TextureNV12BT709Src = {
+ 1,
+ {
+ &GLES2_FragmentSrc_TextureNV12BT709Src
+ }
+};
+
+static GLES2_Shader GLES2_FragmentShader_TextureNV21JPEGSrc = {
1,
{
- &GLES2_FragmentSrc_TextureYUVSrc
+ &GLES2_FragmentSrc_TextureNV21JPEGSrc
}
};
-static GLES2_Shader GLES2_FragmentShader_TextureNV12Src = {
+static GLES2_Shader GLES2_FragmentShader_TextureNV21BT601Src = {
1,
{
- &GLES2_FragmentSrc_TextureNV12Src
+ &GLES2_FragmentSrc_TextureNV21BT601Src
}
};
-static GLES2_Shader GLES2_FragmentShader_TextureNV21Src = {
+static GLES2_Shader GLES2_FragmentShader_TextureNV21BT709Src = {
1,
{
- &GLES2_FragmentSrc_TextureNV21Src
+ &GLES2_FragmentSrc_TextureNV21BT709Src
}
};
@@ -345,12 +510,24 @@ const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type)
return &GLES2_FragmentShader_TextureRGBSrc;
case GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC:
return &GLES2_FragmentShader_TextureBGRSrc;
- case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC:
- return &GLES2_FragmentShader_TextureYUVSrc;
- case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC:
- return &GLES2_FragmentShader_TextureNV12Src;
- case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC:
- return &GLES2_FragmentShader_TextureNV21Src;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC:
+ return &GLES2_FragmentShader_TextureYUVJPEGSrc;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC:
+ return &GLES2_FragmentShader_TextureYUVBT601Src;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC:
+ return &GLES2_FragmentShader_TextureYUVBT709Src;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC:
+ return &GLES2_FragmentShader_TextureNV12JPEGSrc;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC:
+ return &GLES2_FragmentShader_TextureNV12BT601Src;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC:
+ return &GLES2_FragmentShader_TextureNV12BT709Src;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC:
+ return &GLES2_FragmentShader_TextureNV21JPEGSrc;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC:
+ return &GLES2_FragmentShader_TextureNV21BT601Src;
+ case GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC:
+ return &GLES2_FragmentShader_TextureNV21BT709Src;
default:
return NULL;
}
diff --git a/src/render/opengles2/SDL_shaders_gles2.h b/src/render/opengles2/SDL_shaders_gles2.h
index 1f2667eb3..6be9c2fd1 100644
--- a/src/render/opengles2/SDL_shaders_gles2.h
+++ b/src/render/opengles2/SDL_shaders_gles2.h
@@ -20,11 +20,11 @@
*/
#include "../../SDL_internal.h"
-#if SDL_VIDEO_RENDER_OGL_ES2
-
#ifndef SDL_shaders_gles2_h_
#define SDL_shaders_gles2_h_
+#if SDL_VIDEO_RENDER_OGL_ES2
+
typedef struct GLES2_ShaderInstance
{
GLenum type;
@@ -47,17 +47,23 @@ typedef enum
GLES2_SHADER_FRAGMENT_TEXTURE_ARGB_SRC,
GLES2_SHADER_FRAGMENT_TEXTURE_BGR_SRC,
GLES2_SHADER_FRAGMENT_TEXTURE_RGB_SRC,
- GLES2_SHADER_FRAGMENT_TEXTURE_YUV_SRC,
- GLES2_SHADER_FRAGMENT_TEXTURE_NV12_SRC,
- GLES2_SHADER_FRAGMENT_TEXTURE_NV21_SRC
+ GLES2_SHADER_FRAGMENT_TEXTURE_YUV_JPEG_SRC,
+ GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT601_SRC,
+ GLES2_SHADER_FRAGMENT_TEXTURE_YUV_BT709_SRC,
+ GLES2_SHADER_FRAGMENT_TEXTURE_NV12_JPEG_SRC,
+ GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT601_SRC,
+ GLES2_SHADER_FRAGMENT_TEXTURE_NV12_BT709_SRC,
+ GLES2_SHADER_FRAGMENT_TEXTURE_NV21_JPEG_SRC,
+ GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT601_SRC,
+ GLES2_SHADER_FRAGMENT_TEXTURE_NV21_BT709_SRC,
} GLES2_ShaderType;
#define GLES2_SOURCE_SHADER (GLenum)-1
const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type);
-#endif /* SDL_shaders_gles2_h_ */
-
#endif /* SDL_VIDEO_RENDER_OGL_ES2 */
+#endif /* SDL_shaders_gles2_h_ */
+
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_pixels.c b/src/video/SDL_pixels.c
index 649303c58..2244ec592 100644
--- a/src/video/SDL_pixels.c
+++ b/src/video/SDL_pixels.c
@@ -749,30 +749,6 @@ SDL_DitherColors(SDL_Color * colors, int bpp)
}
/*
- * Calculate the pad-aligned scanline width of a surface
- */
-int
-SDL_CalculatePitch(SDL_Surface * surface)
-{
- int pitch;
-
- /* Surface should be 4-byte aligned for speed */
- pitch = surface->w * surface->format->BytesPerPixel;
- switch (surface->format->BitsPerPixel) {
- case 1:
- pitch = (pitch + 7) / 8;
- break;
- case 4:
- pitch = (pitch + 1) / 2;
- break;
- default:
- break;
- }
- pitch = (pitch + 3) & ~3; /* 4-byte aligning */
- return (pitch);
-}
-
-/*
* Match an RGB value to a particular palette index
*/
Uint8
diff --git a/src/video/SDL_pixels_c.h b/src/video/SDL_pixels_c.h
index e79e83102..89c07c760 100644
--- a/src/video/SDL_pixels_c.h
+++ b/src/video/SDL_pixels_c.h
@@ -34,7 +34,6 @@ extern int SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst);
extern void SDL_FreeBlitMap(SDL_BlitMap * map);
/* Miscellaneous functions */
-extern int SDL_CalculatePitch(SDL_Surface * surface);
extern void SDL_DitherColors(SDL_Color * colors, int bpp);
extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b, Uint8 a);
diff --git a/src/video/SDL_surface.c b/src/video/SDL_surface.c
index 38addea00..2e114284a 100644
--- a/src/video/SDL_surface.c
+++ b/src/video/SDL_surface.c
@@ -25,17 +25,8 @@
#include "SDL_blit.h"
#include "SDL_RLEaccel_c.h"
#include "SDL_pixels_c.h"
+#include "SDL_yuv_c.h"
-/* Private routines */
-static int
-SDL_ConvertPixels_YUV_to_ARGB8888(int width, int height,
- Uint32 src_format, const void *src,
- void *dst, int dst_pitch);
-
-static int
-SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height,
- const void *src, int src_pitch,
- Uint32 dst_format, void *dst);
/* Check to make sure we can safely check multiplication of surface w and pitch and it won't overflow size_t */
SDL_COMPILE_TIME_ASSERT(surface_size_assumptions,
@@ -44,6 +35,30 @@ SDL_COMPILE_TIME_ASSERT(surface_size_assumptions,
/* Public routines */
/*
+ * Calculate the pad-aligned scanline width of a surface
+ */
+int
+SDL_CalculatePitch(Uint32 format, int width)
+{
+ int pitch;
+
+ /* Surface should be 4-byte aligned for speed */
+ pitch = width * SDL_BYTESPERPIXEL(format);
+ switch (SDL_BITSPERPIXEL(format)) {
+ case 1:
+ pitch = (pitch + 7) / 8;
+ break;
+ case 4:
+ pitch = (pitch + 1) / 2;
+ break;
+ default:
+ break;
+ }
+ pitch = (pitch + 3) & ~3; /* 4-byte aligning */
+ return pitch;
+}
+
+/*
* Create an empty RGB surface of the appropriate depth using the given
* enum SDL_PIXELFORMAT_* format
*/
@@ -70,7 +85,7 @@ SDL_CreateRGBSurfaceWithFormat(Uint32 flags, int width, int height, int depth,
}
surface->w = width;
surface->h = height;
- surface->pitch = SDL_CalculatePitch(surface);
+ surface->pitch = SDL_CalculatePitch(format, width);
SDL_SetClipRect(surface, NULL);
if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
@@ -1138,135 +1153,27 @@ int SDL_ConvertPixels(int width, int height,
return SDL_InvalidParamError("dst_pitch");
}
+ if (SDL_ISPIXELFORMAT_FOURCC(src_format) && SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
+ return SDL_ConvertPixels_YUV_to_YUV(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
+ } else if (SDL_ISPIXELFORMAT_FOURCC(src_format)) {
+ return SDL_ConvertPixels_YUV_to_RGB(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
+ } else if (SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
+ return SDL_ConvertPixels_RGB_to_YUV(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
+ }
+
/* Fast path for same format copy */
if (src_format == dst_format) {
int i;
-
- if (SDL_ISPIXELFORMAT_FOURCC(src_format)) {
- switch (src_format) {
- case SDL_PIXELFORMAT_YUY2:
- case SDL_PIXELFORMAT_UYVY:
- case SDL_PIXELFORMAT_YVYU:
- /* Packed planes */
- width = 4 * ((width + 1) / 2);
- for (i = height; i--;) {
- SDL_memcpy(dst, src, width);
- src = (const Uint8*)src + src_pitch;
- dst = (Uint8*)dst + dst_pitch;
- }
- break;
- case SDL_PIXELFORMAT_YV12:
- case SDL_PIXELFORMAT_IYUV:
- case SDL_PIXELFORMAT_NV12:
- case SDL_PIXELFORMAT_NV21:
- {
- /* Y plane */
- for (i = height; i--;) {
- SDL_memcpy(dst, src, width);
- src = (const Uint8*)src + src_pitch;
- dst = (Uint8*)dst + dst_pitch;
- }
-
- /* not sure the pitch is relevant here.
- this also works to add the size of two chroma planes */
-#if 0
- SDL_memcpy(dst, src, 2 * ((width + 1)/2) * ((height+1)/2));
-#else
-
- if (src_format == SDL_PIXELFORMAT_YV12 || src_format == SDL_PIXELFORMAT_IYUV) {
- /* U and V planes are a quarter the size of the Y plane */
- width = (width + 1) / 2;
- height = (height + 1) / 2;
- src_pitch = (src_pitch + 1) / 2;
- dst_pitch = (dst_pitch + 1) / 2;
- for (i = height * 2; i--;) {
- SDL_memcpy(dst, src, width);
- src = (const Uint8*)src + src_pitch;
- dst = (Uint8*)dst + dst_pitch;
- }
- } else if (src_format == SDL_PIXELFORMAT_NV12 || src_format == SDL_PIXELFORMAT_NV21) {
- /* U/V plane is half the height of the Y plane */
- height = (height + 1) / 2;
- width = (width + 1) / 2;
- src_pitch = (src_pitch + 1) / 2;
- dst_pitch = (dst_pitch + 1) / 2;
- for (i = height; i--;) {
- SDL_memcpy(dst, src, 2 * width);
- src = (const Uint8*)src + 2 * src_pitch;
- dst = (Uint8*)dst + 2 * dst_pitch;
- }
- }
-#endif
- }
- break;
- default:
- return SDL_SetError("Unknown FOURCC pixel format");
- }
- } else {
- const int bpp = SDL_BYTESPERPIXEL(src_format);
- width *= bpp;
- for (i = height; i--;) {
- SDL_memcpy(dst, src, width);
- src = (const Uint8*)src + src_pitch;
- dst = (Uint8*)dst + dst_pitch;
- }
+ const int bpp = SDL_BYTESPERPIXEL(src_format);
+ width *= bpp;
+ for (i = height; i--;) {
+ SDL_memcpy(dst, src, width);
+ src = (const Uint8*)src + src_pitch;
+ dst = (Uint8*)dst + dst_pitch;
}
return 0;
}
- /* FOURCC to Any */
- if (SDL_ISPIXELFORMAT_FOURCC(src_format)) {
- /* FOURCC to ARGB8888 */
- if (dst_format == SDL_PIXELFORMAT_ARGB8888) {
- SDL_ConvertPixels_YUV_to_ARGB8888(width, height, src_format, src, dst, dst_pitch);
- return 0;
- }
- else /* FOURCC to not(ARGB8888) : need an intermediate conversion */
- {
- int ret;
- void *tmp = SDL_malloc(width * height * 4);
- if (tmp == NULL) {
- return -1;
- }
-
- /* convert src/FOURCC to tmp/ARGB8888 */
- SDL_ConvertPixels_YUV_to_ARGB8888(width, height, src_format, src, tmp, width * 4);
-
- /* convert tmp/ARGB8888 to dst/dst_format */
- ret = SDL_ConvertPixels(width, height, SDL_PIXELFORMAT_ARGB8888, tmp, width * 4, dst_format, dst, dst_pitch);
- SDL_free(tmp);
- return ret;
- }
- }
-
- /* Any to FOURCC */
- if (SDL_ISPIXELFORMAT_FOURCC(dst_format)) {
- /* ARGB8888 to FOURCC */
- if (src_format == SDL_PIXELFORMAT_ARGB8888) {
- SDL_ConvertPixels_ARGB8888_to_YUV(width, height, src, src_pitch, dst_format, dst);
- return 0;
- }
- else /* not(ARGB8888) to FOURCC : need an intermediate conversion */
- {
- int ret;
- void *tmp = SDL_malloc(width * height * 4);
- if (tmp == NULL) {
- return -1;
- }
- /* convert src/src_format to tmp/ARGB8888 */
- ret = SDL_ConvertPixels(width, height, src_format, src, src_pitch, SDL_PIXELFORMAT_ARGB8888, tmp, width * 4);
- if (ret == -1) {
- SDL_free(tmp);
- return ret;
- }
- /* convert tmp/ARGB8888 to dst/FOURCC */
- SDL_ConvertPixels_ARGB8888_to_YUV(width, height, tmp, width * 4, dst_format, dst);
-
- SDL_free(tmp);
- return 0;
- }
- }
-
if (!SDL_CreateSurfaceOnStack(width, height, src_format, nonconst_src,
src_pitch,
&src_surface, &src_fmt, &src_blitmap)) {
@@ -1322,491 +1229,4 @@ SDL_FreeSurface(SDL_Surface * surface)
SDL_free(surface);
}
-
-/* YUV-RGB conversion */
-#define CLAMP(val) ((val) > 0 ? ((val) < 255 ? (val) : 255) : 0)
-
-#if 1
-
-/* Coefficients from CCIR 601 */
-#define MAKE_Y(r, g, b) (int)( 0.29900f * (r) + 0.58700f * (g) + 0.11400f * (b))
-#define MAKE_U(r, g, b) (int)(-0.16874f * (r) - 0.33126f * (g) + 0.50000f * (b) + 128)
-#define MAKE_V(r, g, b) (int)( 0.50000f * (r) - 0.41869f * (g) - 0.08131f * (b) + 128)
-
-#define MAKE_R(y, u, v) CLAMP((int)((y) + 1.40200f * ((v) - 128)))
-#define MAKE_G(y, u, v) CLAMP((int)((y) - 0.34414f * ((u) - 128) - 0.71414f * ((v) - 128)))
-#define MAKE_B(y, u, v) CLAMP((int)((y) + 1.77200f * ((u) - 128) ))
-
-#else
-
-/* Coefficients from Video Demystified */
-#define MAKE_Y(r, g, b) ((( 66 * (r) + 129 * (g) + 25 * (b) + 128) >> 8) + 16)
-#define MAKE_U(r, g, b) ((( -38 * (r) - 74 * (g) + 112 * (b) + 128) >> 8) + 128)
-#define MAKE_V(r, g, b) ((( 112 * (r) - 94 * (g) - 18 * (b) + 128) >> 8) + 128)
-
-#define MAKE_R(y, u, v) CLAMP(( 298 * ((y) - 16) + 409 * ((v) - 128) + 128) >> 8)
-#define MAKE_G(y, u, v) CLAMP(( 298 * ((y) - 16) - 100 * ((u) - 128) - 208 * ((v) - 128) + 128) >> 8)
-#define MAKE_B(y, u, v) CLAMP(( 298 * ((y) - 16) + 516 * ((u) - 128) + 128) >> 8)
-
-#endif
-
-
-static int
-SDL_ConvertPixels_YUV_to_ARGB8888(int width, int height,
- Uint32 src_format, const void *src,
- void *dst, int dst_pitch)
-{
- const int sz_plane = width * height;
- const int sz_plane_chroma = ((width + 1) / 2) * ((height + 1) / 2);
- const int width_remainder = (width & 0x1);
- const int width_half = width / 2;
- const int curr_row_padding = dst_pitch - 4 * width;
- int i, j;
- Uint8 *curr_row = (Uint8*)dst;
-
- // SDL_Log("SDL_ConvertPixels_YUV_to_ARGB8888 (from %s)", SDL_GetPixelFormatName(src_format));
-
-#define WRITE_RGB_PIXEL(y, u, v) \
- *((Uint32*)curr_row) = \
- (MAKE_B((y), (u), (v)) \
- | (MAKE_G((y), (u), (v)) << 8) \
- | (MAKE_R((y), (u), (v)) << 16) \
- | 0xff000000); \
- curr_row += 4; \
-
- switch (src_format)
- {
- case SDL_PIXELFORMAT_YV12:
- case SDL_PIXELFORMAT_IYUV:
- case SDL_PIXELFORMAT_NV12:
- case SDL_PIXELFORMAT_NV21:
- {
- const Uint8 *plane_y = (const Uint8*)src;
-
- if (src_format == SDL_PIXELFORMAT_YV12 || src_format == SDL_PIXELFORMAT_IYUV)
- {
- const Uint8 *plane_u = (src_format == SDL_PIXELFORMAT_YV12 ? plane_y + sz_plane + sz_plane_chroma : plane_y + sz_plane);
- const Uint8 *plane_v = (src_format == SDL_PIXELFORMAT_YV12 ? plane_y + sz_plane : plane_y + sz_plane + sz_plane_chroma);
-
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- const Uint8 u = *plane_u++;
- const Uint8 v = *plane_v++;
- const Uint8 y = *plane_y++;
- const Uint8 y1 = *plane_y++;
- WRITE_RGB_PIXEL(y, u, v);
- WRITE_RGB_PIXEL(y1, u, v);
- }
- if (width_remainder) {
- const Uint8 u = *plane_u++;
- const Uint8 v = *plane_v++;
- const Uint8 y = *plane_y++;
- WRITE_RGB_PIXEL(y, u, v);
- }
- /* Re-use the same line of chroma planes */
- if ((j & 0x1) == 0x0) {
- plane_u -= width_half + width_remainder;
- plane_v -= width_half + width_remainder;
- }
- curr_row += curr_row_padding;
- }
- }
- else if (src_format == SDL_PIXELFORMAT_NV12)
- {
- const Uint8 *plane_interleaved_uv = plane_y + sz_plane;
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- const Uint8 y = *plane_y++;
- const Uint8 y1 = *plane_y++;
- const Uint8 u = *plane_interleaved_uv++;
- const Uint8 v = *plane_interleaved_uv++;
- WRITE_RGB_PIXEL(y, u, v);
- WRITE_RGB_PIXEL(y1, u, v);
- }
- if (width_remainder) {
- const Uint8 y = *plane_y++;
- const Uint8 u = *plane_interleaved_uv++;
- const Uint8 v = *plane_interleaved_uv++;
- WRITE_RGB_PIXEL(y, u, v);
- }
- /* Re-use the same line of chroma planes */
- if ((j & 0x1) == 0x0) {
- plane_interleaved_uv -= 2 * (width_half + width_remainder);
- }
- curr_row += curr_row_padding;
- }
- }
- else /* src_format == SDL_PIXELFORMAT_NV21 */
- {
- const Uint8 *plane_interleaved_uv = plane_y + sz_plane;
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- const Uint8 y = *plane_y++;
- const Uint8 y1 = *plane_y++;
- const Uint8 v = *plane_interleaved_uv++;
- const Uint8 u = *plane_interleaved_uv++;
- WRITE_RGB_PIXEL(y, u, v);
- WRITE_RGB_PIXEL(y1, u, v);
- }
- if (width_remainder) {
- const Uint8 y = *plane_y++;
- const Uint8 v = *plane_interleaved_uv++;
- const Uint8 u = *plane_interleaved_uv++;
- WRITE_RGB_PIXEL(y, u, v);
- }
- /* Re-use the same line of chroma planes */
- if ((j & 0x1) == 0x0) {
- plane_interleaved_uv -= 2 * (width_half + width_remainder);
- }
- curr_row += curr_row_padding;
- }
- }
- }
- break;
-
- case SDL_PIXELFORMAT_YUY2:
- case SDL_PIXELFORMAT_UYVY:
- case SDL_PIXELFORMAT_YVYU:
- {
- const Uint8 *plane = (const Uint8 *)src;
-
-#define READ_PACKED_YUV(var1, var2, var3, var4) \
- const Uint8 var1 = plane[0]; \
- const Uint8 var2 = plane[1]; \
- const Uint8 var3 = plane[2]; \
- const Uint8 var4 = plane[3]; \
- plane += 4; \
-
- if (src_format == SDL_PIXELFORMAT_YUY2) /* Y U Y1 V */
- {
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- READ_PACKED_YUV(y, u, y1, v);
- WRITE_RGB_PIXEL(y, u, v);
- WRITE_RGB_PIXEL(y1, u, v);
- }
- if (width_remainder) {
- READ_PACKED_YUV(y, u, y1, v);
- (void)y1; /* y1 unused */
- WRITE_RGB_PIXEL(y, u, v);
- }
- curr_row += curr_row_padding;
- }
- }
- else if (src_format == SDL_PIXELFORMAT_UYVY) /* U Y V Y1 */
- {
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- READ_PACKED_YUV(u, y, v, y1);
- WRITE_RGB_PIXEL(y, u, v);
- WRITE_RGB_PIXEL(y1, u, v);
- }
- if (width_remainder) {
- READ_PACKED_YUV(u, y, v, y1);
- (void) y1; /* y1 unused */
- WRITE_RGB_PIXEL(y, u, v);
- }
- curr_row += curr_row_padding;
- }
- }
- else if (src_format == SDL_PIXELFORMAT_YVYU) /* Y V Y1 U */
- {
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- READ_PACKED_YUV(y, v, y1, u);
- WRITE_RGB_PIXEL(y, u, v);
- WRITE_RGB_PIXEL(y1, u, v);
- }
- if (width_remainder) {
- READ_PACKED_YUV(y, v, y1, u);
- (void) y1; /* y1 unused */
- WRITE_RGB_PIXEL(y, u, v);
- }
- curr_row += curr_row_padding;
- }
- }
-#undef READ_PACKED_YUV
- }
- break;
- }
-#undef WRITE_RGB_PIXEL
- return 0;
-}
-
-static int
-SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int src_pitch, Uint32 dst_format, void *dst)
-{
- const int src_pitch_x_2 = src_pitch * 2;
- const int sz_plane = width * height;
- const int sz_plane_chroma = ((width + 1) / 2) * ((height + 1) / 2);
- const int height_half = height / 2;
- const int height_remainder = (height & 0x1);
- const int width_half = width / 2;
- const int width_remainder = (width & 0x1);
- int i, j;
-
- // SDL_Log("SDL_ConvertPixels_ARGB8888_to_YUV (to %s)", SDL_GetPixelFormatName(dst_format));
-
- switch (dst_format)
- {
- case SDL_PIXELFORMAT_YV12:
- case SDL_PIXELFORMAT_IYUV:
- case SDL_PIXELFORMAT_NV12:
- case SDL_PIXELFORMAT_NV21:
- {
- const Uint8 *curr_row, *next_row;
-
- Uint8 *plane_y = (Uint8*) dst;
- Uint8 *plane_u = (dst_format == SDL_PIXELFORMAT_YV12 ? plane_y + sz_plane + sz_plane_chroma : plane_y + sz_plane);
- Uint8 *plane_v = (dst_format == SDL_PIXELFORMAT_YV12 ? plane_y + sz_plane : plane_y + sz_plane + sz_plane_chroma);
- Uint8 *plane_interleaved_uv = plane_y + sz_plane;
-
- curr_row = (const Uint8*)src;
-
- /* Write Y plane */
- for (j = 0; j < height; j++) {
- for (i = 0; i < width; i++) {
- const Uint8 b = curr_row[4 * i + 0];
- const Uint8 g = curr_row[4 * i + 1];
- const Uint8 r = curr_row[4 * i + 2];
- *plane_y++ = MAKE_Y(r, g, b);
- }
- curr_row += src_pitch;
- }
-
- curr_row = (const Uint8*)src;
- next_row = (const Uint8*)src;
- next_row += src_pitch;
-
-#if 1
-/* slightly faster */
-#define READ_2x2_PIXELS \
- const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \
- const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \
- const Uint32 p3 = ((const Uint32 *)next_row)[2 * i]; \
- const Uint32 p4 = ((const Uint32 *)next_row)[2 * i + 1]; \
- const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff) + (p3 & 0x000000ff) + (p4 & 0x000000ff)) >> 2; \
- const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00) + (p3 & 0x0000ff00) + (p4 & 0x0000ff00)) >> 10; \
- const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000) + (p3 & 0x00ff0000) + (p4 & 0x00ff0000)) >> 18; \
-
-#else
-
-#define READ_2x2_PIXELS \
- const Uint8 b = (curr_row[8 * i + 0] + curr_row[8 * i + 4] \
- + next_row[8 * i + 0] + next_row[8 * i + 4] ) >> 2; \
- const Uint8 g = (curr_row[8 * i + 1] + curr_row[8 * i + 5] \
- + next_row[8 * i + 1] + next_row[8 * i + 5] ) >> 2; \
- const Uint8 r = (curr_row[8 * i + 2] + curr_row[8 * i + 6] \
- + next_row[8 * i + 2] + next_row[8 * i + 6] ) >> 2; \
-
-#endif
-
-#define READ_2x1_PIXELS \
- const Uint8 b = (curr_row[8 * i + 0] + next_row[8 * i + 0]) >> 1; \
- const Uint8 g = (curr_row[8 * i + 1] + next_row[8 * i + 1]) >> 1; \
- const Uint8 r = (curr_row[8 * i + 2] + next_row[8 * i + 2]) >> 1; \
-
-#define READ_1x2_PIXELS \
- const Uint8 b = (curr_row[8 * i + 0] + curr_row[8 * i + 4]) >> 1; \
- const Uint8 g = (curr_row[8 * i + 1] + curr_row[8 * i + 5]) >> 1; \
- const Uint8 r = (curr_row[8 * i + 2] + curr_row[8 * i + 6]) >> 1; \
-
-#define READ_1x1_PIXEL \
- const Uint8 b = curr_row[8 * i + 0]; \
- const Uint8 g = curr_row[8 * i + 1]; \
- const Uint8 r = curr_row[8 * i + 2]; \
-
- if (dst_format == SDL_PIXELFORMAT_YV12 || dst_format == SDL_PIXELFORMAT_IYUV)
- {
- /* Write UV planes, not interleaved */
- for (j = 0; j < height_half; j++) {
- for (i = 0; i < width_half; i++) {
- READ_2x2_PIXELS;
- *plane_u++ = MAKE_U(r, g, b);
- *plane_v++ = MAKE_V(r, g, b);
- }
- if (width_remainder) {
- READ_2x1_PIXELS;
- *plane_u++ = MAKE_U(r, g, b);
- *plane_v++ = MAKE_V(r, g, b);
- }
- curr_row += src_pitch_x_2;
- next_row += src_pitch_x_2;
- }
- if (height_remainder) {
- for (i = 0; i < width_half; i++) {
- READ_1x2_PIXELS;
- *plane_u++ = MAKE_U(r, g, b);
- *plane_v++ = MAKE_V(r, g, b);
- }
- if (width_remainder) {
- READ_1x1_PIXEL;
- *plane_u++ = MAKE_U(r, g, b);
- *plane_v++ = MAKE_V(r, g, b);
- }
- }
- }
- else if (dst_format == SDL_PIXELFORMAT_NV12)
- {
- for (j = 0; j < height_half; j++) {
- for (i = 0; i < width_half; i++) {
- READ_2x2_PIXELS;
- *plane_interleaved_uv++ = MAKE_U(r, g, b);
- *plane_interleaved_uv++ = MAKE_V(r, g, b);
- }
- if (width_remainder) {
- READ_2x1_PIXELS;
- *plane_interleaved_uv++ = MAKE_U(r, g, b);
- *plane_interleaved_uv++ = MAKE_V(r, g, b);
- }
- curr_row += src_pitch_x_2;
- next_row += src_pitch_x_2;
- }
- if (height_remainder) {
- for (i = 0; i < width_half; i++) {
- READ_1x2_PIXELS;
- *plane_interleaved_uv++ = MAKE_U(r, g, b);
- *plane_interleaved_uv++ = MAKE_V(r, g, b);
- }
- if (width_remainder) {
- READ_1x1_PIXEL;
- *plane_interleaved_uv++ = MAKE_U(r, g, b);
- *plane_interleaved_uv++ = MAKE_V(r, g, b);
- }
- }
- }
- else /* dst_format == SDL_PIXELFORMAT_NV21 */
- {
- for (j = 0; j < height_half; j++) {
- for (i = 0; i < width_half; i++) {
- READ_2x2_PIXELS;
- *plane_interleaved_uv++ = MAKE_V(r, g, b);
- *plane_interleaved_uv++ = MAKE_U(r, g, b);
- }
- if (width_remainder) {
- READ_2x1_PIXELS;
- *plane_interleaved_uv++ = MAKE_V(r, g, b);
- *plane_interleaved_uv++ = MAKE_U(r, g, b);
- }
- curr_row += src_pitch_x_2;
- next_row += src_pitch_x_2;
- }
- if (height_remainder) {
- for (i = 0; i < width_half; i++) {
- READ_1x2_PIXELS;
- *plane_interleaved_uv++ = MAKE_V(r, g, b);
- *plane_interleaved_uv++ = MAKE_U(r, g, b);
- }
- if (width_remainder) {
- READ_1x1_PIXEL;
- *plane_interleaved_uv++ = MAKE_V(r, g, b);
- *plane_interleaved_uv++ = MAKE_U(r, g, b);
- }
- }
- }
-#undef READ_2x2_PIXELS
-#undef READ_2x1_PIXELS
-#undef READ_1x2_PIXELS
-#undef READ_1x1_PIXEL
- }
- break;
-
- case SDL_PIXELFORMAT_YUY2:
- case SDL_PIXELFORMAT_UYVY:
- case SDL_PIXELFORMAT_YVYU:
- {
- const Uint8 *curr_row = (const Uint8*) src;
- Uint8 *plane = (Uint8*) dst;
-
-#define READ_TWO_RGB_PIXELS \
- const Uint8 b = curr_row[8 * i + 0]; \
- const Uint8 g = curr_row[8 * i + 1]; \
- const Uint8 r = curr_row[8 * i + 2]; \
- const Uint8 b1 = curr_row[8 * i + 4]; \
- const Uint8 g1 = curr_row[8 * i + 5]; \
- const Uint8 r1 = curr_row[8 * i + 6]; \
- const Uint8 B = (b + b1) >> 1; \
- const Uint8 G = (g + g1) >> 1; \
- const Uint8 R = (r + r1) >> 1; \
-
-#define READ_ONE_RGB_PIXEL \
- const Uint8 b = curr_row[8 * i + 0]; \
- const Uint8 g = curr_row[8 * i + 1]; \
- const Uint8 r = curr_row[8 * i + 2]; \
-
- /* Write YUV plane, packed */
- if (dst_format == SDL_PIXELFORMAT_YUY2)
- {
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- READ_TWO_RGB_PIXELS;
- /* Y U Y1 V */
- *plane++ = MAKE_Y(r, g, b);
- *plane++ = MAKE_U(R, G, B);
- *plane++ = MAKE_Y(r1, g1, b1);
- *plane++ = MAKE_V(R, G, B);
- }
- if (width_remainder) {
- READ_ONE_RGB_PIXEL;
- /* Y U Y V */
- *plane++ = MAKE_Y(r, g, b);
- *plane++ = MAKE_U(r, g, b);
- *plane++ = MAKE_Y(r, g, b);
- *plane++ = MAKE_V(r, g, b);
- }
- curr_row += src_pitch;
- }
- }
- else if (dst_format == SDL_PIXELFORMAT_UYVY)
- {
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- READ_TWO_RGB_PIXELS;
- /* U Y V Y1 */
- *plane++ = MAKE_U(R, G, B);
- *plane++ = MAKE_Y(r, g, b);
- *plane++ = MAKE_V(R, G, B);
- *plane++ = MAKE_Y(r1, g1, b1);
- }
- if (width_remainder) {
- READ_ONE_RGB_PIXEL;
- /* U Y V Y */
- *plane++ = MAKE_U(r, g, b);
- *plane++ = MAKE_Y(r, g, b);
- *plane++ = MAKE_V(r, g, b);
- *plane++ = MAKE_Y(r, g, b);
- }
- curr_row += src_pitch;
- }
- }
- else if (dst_format == SDL_PIXELFORMAT_YVYU)
- {
- for (j = 0; j < height; j++) {
- for (i = 0; i < width_half; i++) {
- READ_TWO_RGB_PIXELS;
- /* Y V Y1 U */
- *plane++ = MAKE_Y(r, g, b);
- *plane++ = MAKE_V(R, G, B);
- *plane++ = MAKE_Y(r1, g1, b1);
- *plane++ = MAKE_U(R, G, B);
- }
- if (width_remainder) {
- READ_ONE_RGB_PIXEL;
- /* Y V Y U */
- *plane++ = MAKE_Y(r, g, b);
- *plane++ = MAKE_V(r, g, b);
- *plane++ = MAKE_Y(r, g, b);
- *plane++ = MAKE_U(r, g, b);
- }
- curr_row += src_pitch;
- }
- }
-#undef READ_TWO_RGB_PIXELS
-#undef READ_ONE_RGB_PIXEL
- }
- break;
- }
- return 0;
-}
-
/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_yuv.c b/src/video/SDL_yuv.c
new file mode 100644
index 000000000..966de7f56
--- /dev/null
+++ b/src/video/SDL_yuv.c
@@ -0,0 +1,1834 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../SDL_internal.h"
+
+#include "SDL_endian.h"
+#include "SDL_video.h"
+#include "SDL_pixels_c.h"
+
+#include "yuv2rgb/yuv_rgb.h"
+
+#define SDL_YUV_SD_THRESHOLD 576
+
+
+static SDL_YUV_CONVERSION_MODE SDL_YUV_ConversionMode = SDL_YUV_CONVERSION_BT601;
+
+
+void SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_MODE mode)
+{
+ SDL_YUV_ConversionMode = mode;
+}
+
+SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionMode()
+{
+ return SDL_YUV_ConversionMode;
+}
+
+SDL_YUV_CONVERSION_MODE SDL_GetYUVConversionModeForResolution(int width, int height)
+{
+ SDL_YUV_CONVERSION_MODE mode = SDL_GetYUVConversionMode();
+ if (mode == SDL_YUV_CONVERSION_AUTOMATIC) {
+ if (height <= SDL_YUV_SD_THRESHOLD) {
+ mode = SDL_YUV_CONVERSION_BT601;
+ } else {
+ mode = SDL_YUV_CONVERSION_BT709;
+ }
+ }
+ return mode;
+}
+
+static int GetYUVConversionType(int width, int height, YCbCrType *yuv_type)
+{
+ switch (SDL_GetYUVConversionModeForResolution(width, height)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ *yuv_type = YCBCR_JPEG;
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ *yuv_type = YCBCR_601;
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ *yuv_type = YCBCR_709;
+ break;
+ default:
+ return SDL_SetError("Unexpected YUV conversion mode");
+ }
+ return 0;
+}
+
+static SDL_bool IsPlanar2x2Format(Uint32 format)
+{
+ return (format == SDL_PIXELFORMAT_YV12 ||
+ format == SDL_PIXELFORMAT_IYUV ||
+ format == SDL_PIXELFORMAT_NV12 ||
+ format == SDL_PIXELFORMAT_NV21);
+}
+
+static SDL_bool IsPacked4Format(Uint32 format)
+{
+ return (format == SDL_PIXELFORMAT_YUY2 ||
+ format == SDL_PIXELFORMAT_UYVY ||
+ format == SDL_PIXELFORMAT_YVYU);
+}
+
+static int GetYUVPlanes(int width, int height, Uint32 format, const void *yuv, int yuv_pitch,
+ const Uint8 **y, const Uint8 **u, const Uint8 **v, Uint32 *y_stride, Uint32 *uv_stride)
+{
+ const Uint8 *planes[3];
+ int pitches[3];
+
+ switch (format) {
+ case SDL_PIXELFORMAT_YV12:
+ case SDL_PIXELFORMAT_IYUV:
+ pitches[0] = yuv_pitch;
+ pitches[1] = (pitches[0] + 1) / 2;
+ pitches[2] = (pitches[0] + 1) / 2;
+ planes[0] = (const Uint8 *)yuv;
+ planes[1] = planes[0] + pitches[0] * height;
+ planes[2] = planes[1] + pitches[1] * ((height + 1) / 2);
+ break;
+ case SDL_PIXELFORMAT_YUY2:
+ case SDL_PIXELFORMAT_UYVY:
+ case SDL_PIXELFORMAT_YVYU:
+ pitches[0] = yuv_pitch;
+ planes[0] = (const Uint8 *)yuv;
+ break;
+ case SDL_PIXELFORMAT_NV12:
+ case SDL_PIXELFORMAT_NV21:
+ pitches[0] = yuv_pitch;
+ pitches[1] = 2 * ((pitches[0] + 1) / 2);
+ planes[0] = (const Uint8 *)yuv;
+ planes[1] = planes[0] + pitches[0] * height;
+ break;
+ default:
+ return SDL_SetError("GetYUVPlanes(): Unsupported YUV format: %s", SDL_GetPixelFormatName(format));
+ }
+
+ switch (format) {
+ case SDL_PIXELFORMAT_YV12:
+ *y = planes[0];
+ *y_stride = pitches[0];
+ *v = planes[1];
+ *u = planes[2];
+ *uv_stride = pitches[1];
+ break;
+ case SDL_PIXELFORMAT_IYUV:
+ *y = planes[0];
+ *y_stride = pitches[0];
+ *v = planes[2];
+ *u = planes[1];
+ *uv_stride = pitches[1];
+ break;
+ case SDL_PIXELFORMAT_YUY2:
+ *y = planes[0];
+ *y_stride = pitches[0];
+ *v = *y + 3;
+ *u = *y + 1;
+ *uv_stride = pitches[0];
+ break;
+ case SDL_PIXELFORMAT_UYVY:
+ *y = planes[0] + 1;
+ *y_stride = pitches[0];
+ *v = *y + 1;
+ *u = *y - 1;
+ *uv_stride = pitches[0];
+ break;
+ case SDL_PIXELFORMAT_YVYU:
+ *y = planes[0];
+ *y_stride = pitches[0];
+ *v = *y + 1;
+ *u = *y + 3;
+ *uv_stride = pitches[0];
+ break;
+ case SDL_PIXELFORMAT_NV12:
+ *y = planes[0];
+ *y_stride = pitches[0];
+ *u = planes[1];
+ *v = *u + 1;
+ *uv_stride = pitches[1];
+ break;
+ case SDL_PIXELFORMAT_NV21:
+ *y = planes[0];
+ *y_stride = pitches[0];
+ *v = planes[1];
+ *u = *v + 1;
+ *uv_stride = pitches[1];
+ break;
+ default:
+ /* Should have caught this above */
+ return SDL_SetError("GetYUVPlanes[2]: Unsupported YUV format: %s", SDL_GetPixelFormatName(format));
+ }
+ return 0;
+}
+
+static SDL_bool yuv_rgb_sse(
+ Uint32 src_format, Uint32 dst_format,
+ Uint32 width, Uint32 height,
+ const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
+ Uint8 *rgb, Uint32 rgb_stride,
+ YCbCrType yuv_type)
+{
+#ifdef __SSE2__
+ if (!SDL_HasSSE2()) {
+ return SDL_FALSE;
+ }
+
+ if (src_format == SDL_PIXELFORMAT_YV12 ||
+ src_format == SDL_PIXELFORMAT_IYUV) {
+
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_RGB565:
+ yuv420_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB24:
+ yuv420_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGBX8888:
+ case SDL_PIXELFORMAT_RGBA8888:
+ yuv420_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGRX8888:
+ case SDL_PIXELFORMAT_BGRA8888:
+ yuv420_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB888:
+ case SDL_PIXELFORMAT_ARGB8888:
+ yuv420_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGR888:
+ case SDL_PIXELFORMAT_ABGR8888:
+ yuv420_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ default:
+ break;
+ }
+ }
+
+ if (src_format == SDL_PIXELFORMAT_YUY2 ||
+ src_format == SDL_PIXELFORMAT_UYVY ||
+ src_format == SDL_PIXELFORMAT_YVYU) {
+
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_RGB565:
+ yuv422_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB24:
+ yuv422_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGBX8888:
+ case SDL_PIXELFORMAT_RGBA8888:
+ yuv422_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGRX8888:
+ case SDL_PIXELFORMAT_BGRA8888:
+ yuv422_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB888:
+ case SDL_PIXELFORMAT_ARGB8888:
+ yuv422_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGR888:
+ case SDL_PIXELFORMAT_ABGR8888:
+ yuv422_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ default:
+ break;
+ }
+ }
+
+ if (src_format == SDL_PIXELFORMAT_NV12 ||
+ src_format == SDL_PIXELFORMAT_NV21) {
+
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_RGB565:
+ yuvnv12_rgb565_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB24:
+ yuvnv12_rgb24_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGBX8888:
+ case SDL_PIXELFORMAT_RGBA8888:
+ yuvnv12_rgba_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGRX8888:
+ case SDL_PIXELFORMAT_BGRA8888:
+ yuvnv12_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB888:
+ case SDL_PIXELFORMAT_ARGB8888:
+ yuvnv12_argb_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGR888:
+ case SDL_PIXELFORMAT_ABGR8888:
+ yuvnv12_bgra_sseu(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ default:
+ break;
+ }
+ }
+#endif
+ return SDL_FALSE;
+}
+
+static SDL_bool yuv_rgb_std(
+ Uint32 src_format, Uint32 dst_format,
+ Uint32 width, Uint32 height,
+ const Uint8 *y, const Uint8 *u, const Uint8 *v, Uint32 y_stride, Uint32 uv_stride,
+ Uint8 *rgb, Uint32 rgb_stride,
+ YCbCrType yuv_type)
+{
+ if (src_format == SDL_PIXELFORMAT_YV12 ||
+ src_format == SDL_PIXELFORMAT_IYUV) {
+
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_RGB565:
+ yuv420_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB24:
+ yuv420_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGBX8888:
+ case SDL_PIXELFORMAT_RGBA8888:
+ yuv420_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGRX8888:
+ case SDL_PIXELFORMAT_BGRA8888:
+ yuv420_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB888:
+ case SDL_PIXELFORMAT_ARGB8888:
+ yuv420_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGR888:
+ case SDL_PIXELFORMAT_ABGR8888:
+ yuv420_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ default:
+ break;
+ }
+ }
+
+ if (src_format == SDL_PIXELFORMAT_YUY2 ||
+ src_format == SDL_PIXELFORMAT_UYVY ||
+ src_format == SDL_PIXELFORMAT_YVYU) {
+
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_RGB565:
+ yuv422_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB24:
+ yuv422_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGBX8888:
+ case SDL_PIXELFORMAT_RGBA8888:
+ yuv422_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGRX8888:
+ case SDL_PIXELFORMAT_BGRA8888:
+ yuv422_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB888:
+ case SDL_PIXELFORMAT_ARGB8888:
+ yuv422_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGR888:
+ case SDL_PIXELFORMAT_ABGR8888:
+ yuv422_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ default:
+ break;
+ }
+ }
+
+ if (src_format == SDL_PIXELFORMAT_NV12 ||
+ src_format == SDL_PIXELFORMAT_NV21) {
+
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_RGB565:
+ yuvnv12_rgb565_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB24:
+ yuvnv12_rgb24_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGBX8888:
+ case SDL_PIXELFORMAT_RGBA8888:
+ yuvnv12_rgba_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGRX8888:
+ case SDL_PIXELFORMAT_BGRA8888:
+ yuvnv12_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_RGB888:
+ case SDL_PIXELFORMAT_ARGB8888:
+ yuvnv12_argb_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_BGR888:
+ case SDL_PIXELFORMAT_ABGR8888:
+ yuvnv12_bgra_std(width, height, y, u, v, y_stride, uv_stride, rgb, rgb_stride, yuv_type);
+ return SDL_TRUE;
+ default:
+ break;
+ }
+ }
+ return SDL_FALSE;
+}
+
+int
+SDL_ConvertPixels_YUV_to_RGB(int width, int height,
+ Uint32 src_format, const void *src, int src_pitch,
+ Uint32 dst_format, void *dst, int dst_pitch)
+{
+ const Uint8 *y;
+ const Uint8 *u;
+ const Uint8 *v;
+ Uint32 y_stride;
+ Uint32 uv_stride;
+ YCbCrType yuv_type;
+
+ if (GetYUVPlanes(width, height, src_format, src, src_pitch, &y, &u, &v, &y_stride, &uv_stride) < 0) {
+ return -1;
+ }
+
+ if (GetYUVConversionType(width, height, &yuv_type) < 0) {
+ return -1;
+ }
+
+ if (yuv_rgb_sse(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8*)dst, dst_pitch, yuv_type)) {
+ return 0;
+ }
+
+ if (yuv_rgb_std(src_format, dst_format, width, height, y, u, v, y_stride, uv_stride, (Uint8*)dst, dst_pitch, yuv_type)) {
+ return 0;
+ }
+
+ /* No fast path for the RGB format, instead convert using an intermediate buffer */
+ if (dst_format != SDL_PIXELFORMAT_ARGB8888) {
+ int ret;
+ void *tmp;
+ int tmp_pitch = (width * sizeof(Uint32));
+
+ tmp = SDL_malloc(tmp_pitch * height);
+ if (tmp == NULL) {
+ return SDL_OutOfMemory();
+ }
+
+ /* convert src/src_format to tmp/ARGB8888 */
+ ret = SDL_ConvertPixels_YUV_to_RGB(width, height, src_format, src, src_pitch, SDL_PIXELFORMAT_ARGB8888, tmp, tmp_pitch);
+ if (ret < 0) {
+ SDL_free(tmp);
+ return ret;
+ }
+
+ /* convert tmp/ARGB8888 to dst/RGB */
+ ret = SDL_ConvertPixels(width, height, SDL_PIXELFORMAT_ARGB8888, tmp, tmp_pitch, dst_format, dst, dst_pitch);
+ SDL_free(tmp);
+ return ret;
+ }
+
+ return SDL_SetError("Unsupported YUV conversion");
+}
+
+struct RGB2YUVFactors
+{
+ int y_offset;
+ float y[3]; /* Rfactor, Gfactor, Bfactor */
+ float u[3]; /* Rfactor, Gfactor, Bfactor */
+ float v[3]; /* Rfactor, Gfactor, Bfactor */
+};
+
+static int
+SDL_ConvertPixels_ARGB8888_to_YUV(int width, int height, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch)
+{
+ const int src_pitch_x_2 = src_pitch * 2;
+ const int height_half = height / 2;
+ const int height_remainder = (height & 0x1);
+ const int width_half = width / 2;
+ const int width_remainder = (width & 0x1);
+ int i, j;
+
+ static struct RGB2YUVFactors RGB2YUVFactorTables[SDL_YUV_CONVERSION_BT709 + 1] =
+ {
+ /* ITU-T T.871 (JPEG) */
+ {
+ 0,
+ { 0.2990f, 0.5870f, 0.1140f },
+ { -0.1687f, -0.3313f, 0.5000f },
+ { 0.5000f, -0.4187f, -0.0813f },
+ },
+ /* ITU-R BT.601-7 */
+ {
+ 16,
+ { 0.2568f, 0.5041f, 0.0979f },
+ { -0.1482f, -0.2910f, 0.4392f },
+ { 0.4392f, -0.3678f, -0.0714f },
+ },
+ /* ITU-R BT.709-6 */
+ {
+ 16,
+ { 0.1826f, 0.6142f, 0.0620f },
+ {-0.1006f, -0.3386f, 0.4392f },
+ { 0.4392f, -0.3989f, -0.0403f },
+ },
+ };
+ const struct RGB2YUVFactors *cvt = &RGB2YUVFactorTables[SDL_GetYUVConversionModeForResolution(width, height)];
+
+#define MAKE_Y(r, g, b) (Uint8)((int)(cvt->y[0] * (r) + cvt->y[1] * (g) + cvt->y[2] * (b) + 0.5f) + cvt->y_offset)
+#define MAKE_U(r, g, b) (Uint8)((int)(cvt->u[0] * (r) + cvt->u[1] * (g) + cvt->u[2] * (b) + 0.5f) + 128)
+#define MAKE_V(r, g, b) (Uint8)((int)(cvt->v[0] * (r) + cvt->v[1] * (g) + cvt->v[2] * (b) + 0.5f) + 128)
+
+#define READ_2x2_PIXELS \
+ const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \
+ const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \
+ const Uint32 p3 = ((const Uint32 *)next_row)[2 * i]; \
+ const Uint32 p4 = ((const Uint32 *)next_row)[2 * i + 1]; \
+ const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000) + (p3 & 0x00ff0000) + (p4 & 0x00ff0000)) >> 18; \
+ const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00) + (p3 & 0x0000ff00) + (p4 & 0x0000ff00)) >> 10; \
+ const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff) + (p3 & 0x000000ff) + (p4 & 0x000000ff)) >> 2; \
+
+#define READ_2x1_PIXELS \
+ const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \
+ const Uint32 p2 = ((const Uint32 *)next_row)[2 * i]; \
+ const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000)) >> 17; \
+ const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00)) >> 9; \
+ const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff)) >> 1; \
+
+#define READ_1x2_PIXELS \
+ const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i]; \
+ const Uint32 p2 = ((const Uint32 *)curr_row)[2 * i + 1]; \
+ const Uint32 r = ((p1 & 0x00ff0000) + (p2 & 0x00ff0000)) >> 17; \
+ const Uint32 g = ((p1 & 0x0000ff00) + (p2 & 0x0000ff00)) >> 9; \
+ const Uint32 b = ((p1 & 0x000000ff) + (p2 & 0x000000ff)) >> 1; \
+
+#define READ_1x1_PIXEL \
+ const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \
+ const Uint32 r = (p & 0x00ff0000) >> 16; \
+ const Uint32 g = (p & 0x0000ff00) >> 8; \
+ const Uint32 b = (p & 0x000000ff); \
+
+#define READ_TWO_RGB_PIXELS \
+ const Uint32 p = ((const Uint32 *)curr_row)[2 * i]; \
+ const Uint32 r = (p & 0x00ff0000) >> 16; \
+ const Uint32 g = (p & 0x0000ff00) >> 8; \
+ const Uint32 b = (p & 0x000000ff); \
+ const Uint32 p1 = ((const Uint32 *)curr_row)[2 * i + 1]; \
+ const Uint32 r1 = (p1 & 0x00ff0000) >> 16; \
+ const Uint32 g1 = (p1 & 0x0000ff00) >> 8; \
+ const Uint32 b1 = (p1 & 0x000000ff); \
+ const Uint32 R = (r + r1)/2; \
+ const Uint32 G = (g + g1)/2; \
+ const Uint32 B = (b + b1)/2; \
+
+#define READ_ONE_RGB_PIXEL READ_1x1_PIXEL
+
+ switch (dst_format)
+ {
+ case SDL_PIXELFORMAT_YV12:
+ case SDL_PIXELFORMAT_IYUV:
+ case SDL_PIXELFORMAT_NV12:
+ case SDL_PIXELFORMAT_NV21:
+ {
+ const Uint8 *curr_row, *next_row;
+
+ Uint8 *plane_y;
+ Uint8 *plane_u;
+ Uint8 *plane_v;
+ Uint8 *plane_interleaved_uv;
+ Uint32 y_stride, uv_stride, y_skip, uv_skip;
+
+ GetYUVPlanes(width, height, dst_format, dst, dst_pitch,
+ (const Uint8 **)&plane_y, (const Uint8 **)&plane_u, (const Uint8 **)&plane_v,
+ &y_stride, &uv_stride);
+ plane_interleaved_uv = (plane_y + height * y_stride);
+ y_skip = (y_stride - width);
+
+ curr_row = (const Uint8*)src;
+
+ /* Write Y plane */
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ const Uint32 p1 = ((const Uint32 *)curr_row)[i];
+ const Uint32 r = (p1 & 0x00ff0000) >> 16;
+ const Uint32 g = (p1 & 0x0000ff00) >> 8;
+ const Uint32 b = (p1 & 0x000000ff);
+ *plane_y++ = MAKE_Y(r, g, b);
+ }
+ plane_y += y_skip;
+ curr_row += src_pitch;
+ }
+
+ curr_row = (const Uint8*)src;
+ next_row = (const Uint8*)src;
+ next_row += src_pitch;
+
+ if (dst_format == SDL_PIXELFORMAT_YV12 || dst_format == SDL_PIXELFORMAT_IYUV)
+ {
+ /* Write UV planes, not interleaved */
+ uv_skip = (uv_stride - (width + 1)/2);
+ for (j = 0; j < height_half; j++) {
+ for (i = 0; i < width_half; i++) {
+ READ_2x2_PIXELS;
+ *plane_u++ = MAKE_U(r, g, b);
+ *plane_v++ = MAKE_V(r, g, b);
+ }
+ if (width_remainder) {
+ READ_2x1_PIXELS;
+ *plane_u++ = MAKE_U(r, g, b);
+ *plane_v++ = MAKE_V(r, g, b);
+ }
+ plane_u += uv_skip;
+ plane_v += uv_skip;
+ curr_row += src_pitch_x_2;
+ next_row += src_pitch_x_2;
+ }
+ if (height_remainder) {
+ for (i = 0; i < width_half; i++) {
+ READ_1x2_PIXELS;
+ *plane_u++ = MAKE_U(r, g, b);
+ *plane_v++ = MAKE_V(r, g, b);
+ }
+ if (width_remainder) {
+ READ_1x1_PIXEL;
+ *plane_u++ = MAKE_U(r, g, b);
+ *plane_v++ = MAKE_V(r, g, b);
+ }
+ plane_u += uv_skip;
+ plane_v += uv_skip;
+ }
+ }
+ else if (dst_format == SDL_PIXELFORMAT_NV12)
+ {
+ uv_skip = (uv_stride - ((width + 1)/2)*2);
+ for (j = 0; j < height_half; j++) {
+ for (i = 0; i < width_half; i++) {
+ READ_2x2_PIXELS;
+ *plane_interleaved_uv++ = MAKE_U(r, g, b);
+ *plane_interleaved_uv++ = MAKE_V(r, g, b);
+ }
+ if (width_remainder) {
+ READ_2x1_PIXELS;
+ *plane_interleaved_uv++ = MAKE_U(r, g, b);
+ *plane_interleaved_uv++ = MAKE_V(r, g, b);
+ }
+ plane_interleaved_uv += uv_skip;
+ curr_row += src_pitch_x_2;
+ next_row += src_pitch_x_2;
+ }
+ if (height_remainder) {
+ for (i = 0; i < width_half; i++) {
+ READ_1x2_PIXELS;
+ *plane_interleaved_uv++ = MAKE_U(r, g, b);
+ *plane_interleaved_uv++ = MAKE_V(r, g, b);
+ }
+ if (width_remainder) {
+ READ_1x1_PIXEL;
+ *plane_interleaved_uv++ = MAKE_U(r, g, b);
+ *plane_interleaved_uv++ = MAKE_V(r, g, b);
+ }
+ }
+ }
+ else /* dst_format == SDL_PIXELFORMAT_NV21 */
+ {
+ uv_skip = (uv_stride - ((width + 1)/2)*2);
+ for (j = 0; j < height_half; j++) {
+ for (i = 0; i < width_half; i++) {
+ READ_2x2_PIXELS;
+ *plane_interleaved_uv++ = MAKE_V(r, g, b);
+ *plane_interleaved_uv++ = MAKE_U(r, g, b);
+ }
+ if (width_remainder) {
+ READ_2x1_PIXELS;
+ *plane_interleaved_uv++ = MAKE_V(r, g, b);
+ *plane_interleaved_uv++ = MAKE_U(r, g, b);
+ }
+ plane_interleaved_uv += uv_skip;
+ curr_row += src_pitch_x_2;
+ next_row += src_pitch_x_2;
+ }
+ if (height_remainder) {
+ for (i = 0; i < width_half; i++) {
+ READ_1x2_PIXELS;
+ *plane_interleaved_uv++ = MAKE_V(r, g, b);
+ *plane_interleaved_uv++ = MAKE_U(r, g, b);
+ }
+ if (width_remainder) {
+ READ_1x1_PIXEL;
+ *plane_interleaved_uv++ = MAKE_V(r, g, b);
+ *plane_interleaved_uv++ = MAKE_U(r, g, b);
+ }
+ }
+ }
+ }
+ break;
+
+ case SDL_PIXELFORMAT_YUY2:
+ case SDL_PIXELFORMAT_UYVY:
+ case SDL_PIXELFORMAT_YVYU:
+ {
+ const Uint8 *curr_row = (const Uint8*) src;
+ Uint8 *plane = (Uint8*) dst;
+ const int row_size = (4 * ((width + 1) / 2));
+ int plane_skip;
+
+ if (dst_pitch < row_size) {
+ return SDL_SetError("Destination pitch is too small, expected at least %d\n", row_size);
+ }
+ plane_skip = (dst_pitch - row_size);
+
+ /* Write YUV plane, packed */
+ if (dst_format == SDL_PIXELFORMAT_YUY2)
+ {
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width_half; i++) {
+ READ_TWO_RGB_PIXELS;
+ /* Y U Y1 V */
+ *plane++ = MAKE_Y(r, g, b);
+ *plane++ = MAKE_U(R, G, B);
+ *plane++ = MAKE_Y(r1, g1, b1);
+ *plane++ = MAKE_V(R, G, B);
+ }
+ if (width_remainder) {
+ READ_ONE_RGB_PIXEL;
+ /* Y U Y V */
+ *plane++ = MAKE_Y(r, g, b);
+ *plane++ = MAKE_U(r, g, b);
+ *plane++ = MAKE_Y(r, g, b);
+ *plane++ = MAKE_V(r, g, b);
+ }
+ plane += plane_skip;
+ curr_row += src_pitch;
+ }
+ }
+ else if (dst_format == SDL_PIXELFORMAT_UYVY)
+ {
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width_half; i++) {
+ READ_TWO_RGB_PIXELS;
+ /* U Y V Y1 */
+ *plane++ = MAKE_U(R, G, B);
+ *plane++ = MAKE_Y(r, g, b);
+ *plane++ = MAKE_V(R, G, B);
+ *plane++ = MAKE_Y(r1, g1, b1);
+ }
+ if (width_remainder) {
+ READ_ONE_RGB_PIXEL;
+ /* U Y V Y */
+ *plane++ = MAKE_U(r, g, b);
+ *plane++ = MAKE_Y(r, g, b);
+ *plane++ = MAKE_V(r, g, b);
+ *plane++ = MAKE_Y(r, g, b);
+ }
+ plane += plane_skip;
+ curr_row += src_pitch;
+ }
+ }
+ else if (dst_format == SDL_PIXELFORMAT_YVYU)
+ {
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width_half; i++) {
+ READ_TWO_RGB_PIXELS;
+ /* Y V Y1 U */
+ *plane++ = MAKE_Y(r, g, b);
+ *plane++ = MAKE_V(R, G, B);
+ *plane++ = MAKE_Y(r1, g1, b1);
+ *plane++ = MAKE_U(R, G, B);
+ }
+ if (width_remainder) {
+ READ_ONE_RGB_PIXEL;
+ /* Y V Y U */
+ *plane++ = MAKE_Y(r, g, b);
+ *plane++ = MAKE_V(r, g, b);
+ *plane++ = MAKE_Y(r, g, b);
+ *plane++ = MAKE_U(r, g, b);
+ }
+ plane += plane_skip;
+ curr_row += src_pitch;
+ }
+ }
+ }
+ break;
+
+ default:
+ return SDL_SetError("Unsupported YUV destination format: %s", SDL_GetPixelFormatName(dst_format));
+ }
+#undef MAKE_Y
+#undef MAKE_U
+#undef MAKE_V
+#undef READ_2x2_PIXELS
+#undef READ_2x1_PIXELS
+#undef READ_1x2_PIXELS
+#undef READ_1x1_PIXEL
+#undef READ_TWO_RGB_PIXELS
+#undef READ_ONE_RGB_PIXEL
+ return 0;
+}
+
+int
+SDL_ConvertPixels_RGB_to_YUV(int width, int height,
+ Uint32 src_format, const void *src, int src_pitch,
+ Uint32 dst_format, void *dst, int dst_pitch)
+{
+#if 0 /* Doesn't handle odd widths */
+ /* RGB24 to FOURCC */
+ if (src_format == SDL_PIXELFORMAT_RGB24) {
+ Uint8 *y;
+ Uint8 *u;
+ Uint8 *v;
+ Uint32 y_stride;
+ Uint32 uv_stride;
+ YCbCrType yuv_type;
+
+ if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch, (const Uint8 **)&y, (const Uint8 **)&u, (const Uint8 **)&v, &y_stride, &uv_stride) < 0) {
+ return -1;
+ }
+
+ if (GetYUVConversionType(width, height, &yuv_type) < 0) {
+ return -1;
+ }
+
+ rgb24_yuv420_std(width, height, src, src_pitch, y, u, v, y_stride, uv_stride, yuv_type);
+ return 0;
+ }
+#endif
+
+ /* ARGB8888 to FOURCC */
+ if (src_format == SDL_PIXELFORMAT_ARGB8888) {
+ return SDL_ConvertPixels_ARGB8888_to_YUV(width, height, src, src_pitch, dst_format, dst, dst_pitch);
+ }
+
+ /* not ARGB8888 to FOURCC : need an intermediate conversion */
+ {
+ int ret;
+ void *tmp;
+ int tmp_pitch = (width * sizeof(Uint32));
+
+ tmp = SDL_malloc(tmp_pitch * height);
+ if (tmp == NULL) {
+ return SDL_OutOfMemory();
+ }
+
+ /* convert src/src_format to tmp/ARGB8888 */
+ ret = SDL_ConvertPixels(width, height, src_format, src, src_pitch, SDL_PIXELFORMAT_ARGB8888, tmp, tmp_pitch);
+ if (ret == -1) {
+ SDL_free(tmp);
+ return ret;
+ }
+
+ /* convert tmp/ARGB8888 to dst/FOURCC */
+ ret = SDL_ConvertPixels_ARGB8888_to_YUV(width, height, tmp, tmp_pitch, dst_format, dst, dst_pitch);
+ SDL_free(tmp);
+ return ret;
+ }
+}
+
+static int
+SDL_ConvertPixels_YUV_to_YUV_Copy(int width, int height, Uint32 format,
+ const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int i;
+
+ if (IsPlanar2x2Format(format)) {
+ /* Y plane */
+ for (i = height; i--;) {
+ SDL_memcpy(dst, src, width);
+ src = (const Uint8*)src + src_pitch;
+ dst = (Uint8*)dst + dst_pitch;
+ }
+
+ if (format == SDL_PIXELFORMAT_YV12 || format == SDL_PIXELFORMAT_IYUV) {
+ /* U and V planes are a quarter the size of the Y plane, rounded up */
+ width = (width + 1) / 2;
+ height = (height + 1) / 2;
+ src_pitch = (src_pitch + 1) / 2;
+ dst_pitch = (dst_pitch + 1) / 2;
+ for (i = height * 2; i--;) {
+ SDL_memcpy(dst, src, width);
+ src = (const Uint8*)src + src_pitch;
+ dst = (Uint8*)dst + dst_pitch;
+ }
+ } else if (format == SDL_PIXELFORMAT_NV12 || format == SDL_PIXELFORMAT_NV21) {
+ /* U/V plane is half the height of the Y plane, rounded up */
+ height = (height + 1) / 2;
+ width = ((width + 1) / 2)*2;
+ src_pitch = ((src_pitch + 1) / 2)*2;
+ dst_pitch = ((dst_pitch + 1) / 2)*2;
+ for (i = height; i--;) {
+ SDL_memcpy(dst, src, width);
+ src = (const Uint8*)src + src_pitch;
+ dst = (Uint8*)dst + dst_pitch;
+ }
+ }
+ return 0;
+ }
+
+ if (IsPacked4Format(format)) {
+ /* Packed planes */
+ width = 4 * ((width + 1) / 2);
+ for (i = height; i--;) {
+ SDL_memcpy(dst, src, width);
+ src = (const Uint8*)src + src_pitch;
+ dst = (Uint8*)dst + dst_pitch;
+ }
+ return 0;
+ }
+
+ return SDL_SetError("SDL_ConvertPixels_YUV_to_YUV_Copy: Unsupported YUV format: %s", SDL_GetPixelFormatName(format));
+}
+
+static int
+SDL_ConvertPixels_SwapUVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int y;
+ const int UVwidth = (width + 1)/2;
+ const int UVheight = (height + 1)/2;
+
+ /* Skip the Y plane */
+ src = (const Uint8 *)src + height * src_pitch;
+ dst = (Uint8 *)dst + height * dst_pitch;
+
+ if (src == dst) {
+ int UVpitch = (dst_pitch + 1)/2;
+ Uint8 *tmp;
+ Uint8 *row1 = dst;
+ Uint8 *row2 = (Uint8 *)dst + UVheight * UVpitch;
+
+ /* Allocate a temporary row for the swap */
+ tmp = (Uint8 *)SDL_malloc(UVwidth);
+ if (!tmp) {
+ return SDL_OutOfMemory();
+ }
+ for (y = 0; y < UVheight; ++y) {
+ SDL_memcpy(tmp, row1, UVwidth);
+ SDL_memcpy(row1, row2, UVwidth);
+ SDL_memcpy(row2, tmp, UVwidth);
+ row1 += UVpitch;
+ row2 += UVpitch;
+ }
+ SDL_free(tmp);
+ } else {
+ const Uint8 *srcUV;
+ Uint8 *dstUV;
+ int srcUVPitch = ((src_pitch + 1)/2);
+ int dstUVPitch = ((dst_pitch + 1)/2);
+
+ /* Copy the first plane */
+ srcUV = (const Uint8 *)src;
+ dstUV = (Uint8 *)dst + UVheight * dstUVPitch;
+ for (y = 0; y < UVheight; ++y) {
+ SDL_memcpy(dstUV, srcUV, UVwidth);
+ srcUV += srcUVPitch;
+ dstUV += dstUVPitch;
+ }
+
+ /* Copy the second plane */
+ dstUV = (Uint8 *)dst;
+ for (y = 0; y < UVheight; ++y) {
+ SDL_memcpy(dstUV, srcUV, UVwidth);
+ srcUV += srcUVPitch;
+ dstUV += dstUVPitch;
+ }
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_PackUVPlanes_to_NV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV)
+{
+ int x, y;
+ const int UVwidth = (width + 1)/2;
+ const int UVheight = (height + 1)/2;
+ const int srcUVPitch = ((src_pitch + 1)/2);
+ const int srcUVPitchLeft = srcUVPitch - UVwidth;
+ const int dstUVPitch = ((dst_pitch + 1)/2)*2;
+ const int dstUVPitchLeft = dstUVPitch - UVwidth*2;
+ const Uint8 *src1, *src2;
+ Uint8 *dstUV;
+ Uint8 *tmp = NULL;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ /* Skip the Y plane */
+ src = (const Uint8 *)src + height * src_pitch;
+ dst = (Uint8 *)dst + height * dst_pitch;
+
+ if (src == dst) {
+ /* Need to make a copy of the buffer so we don't clobber it while converting */
+ tmp = (Uint8 *)SDL_malloc(2*UVheight*srcUVPitch);
+ if (!tmp) {
+ return SDL_OutOfMemory();
+ }
+ SDL_memcpy(tmp, src, 2*UVheight*srcUVPitch);
+ src = tmp;
+ }
+
+ if (reverseUV) {
+ src2 = (const Uint8 *)src;
+ src1 = src2 + UVheight * srcUVPitch;
+ } else {
+ src1 = (const Uint8 *)src;
+ src2 = src1 + UVheight * srcUVPitch;
+ }
+ dstUV = (Uint8 *)dst;
+
+ y = UVheight;
+ while (y--) {
+ x = UVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ while (x >= 16) {
+ __m128i u = _mm_loadu_si128((__m128i *)src1);
+ __m128i v = _mm_loadu_si128((__m128i *)src2);
+ __m128i uv1 = _mm_unpacklo_epi8(u, v);
+ __m128i uv2 = _mm_unpackhi_epi8(u, v);
+ _mm_storeu_si128((__m128i*)dstUV, uv1);
+ _mm_storeu_si128((__m128i*)(dstUV + 16), uv2);
+ src1 += 16;
+ src2 += 16;
+ dstUV += 32;
+ x -= 16;
+ }
+ }
+#endif
+ while (x--) {
+ *dstUV++ = *src1++;
+ *dstUV++ = *src2++;
+ }
+ src1 += srcUVPitchLeft;
+ src2 += srcUVPitchLeft;
+ dstUV += dstUVPitchLeft;
+ }
+
+ if (tmp) {
+ SDL_free(tmp);
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_SplitNV_to_UVPlanes(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch, SDL_bool reverseUV)
+{
+ int x, y;
+ const int UVwidth = (width + 1)/2;
+ const int UVheight = (height + 1)/2;
+ const int srcUVPitch = ((src_pitch + 1)/2)*2;
+ const int srcUVPitchLeft = srcUVPitch - UVwidth*2;
+ const int dstUVPitch = ((dst_pitch + 1)/2);
+ const int dstUVPitchLeft = dstUVPitch - UVwidth;
+ const Uint8 *srcUV;
+ Uint8 *dst1, *dst2;
+ Uint8 *tmp = NULL;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ /* Skip the Y plane */
+ src = (const Uint8 *)src + height * src_pitch;
+ dst = (Uint8 *)dst + height * dst_pitch;
+
+ if (src == dst) {
+ /* Need to make a copy of the buffer so we don't clobber it while converting */
+ tmp = (Uint8 *)SDL_malloc(UVheight*srcUVPitch);
+ if (!tmp) {
+ return SDL_OutOfMemory();
+ }
+ SDL_memcpy(tmp, src, UVheight*srcUVPitch);
+ src = tmp;
+ }
+
+ if (reverseUV) {
+ dst2 = (Uint8 *)dst;
+ dst1 = dst2 + UVheight * dstUVPitch;
+ } else {
+ dst1 = (Uint8 *)dst;
+ dst2 = dst1 + UVheight * dstUVPitch;
+ }
+ srcUV = (const Uint8 *)src;
+
+ y = UVheight;
+ while (y--) {
+ x = UVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ __m128i mask = _mm_set1_epi16(0x00FF);
+ while (x >= 16) {
+ __m128i uv1 = _mm_loadu_si128((__m128i*)srcUV);
+ __m128i uv2 = _mm_loadu_si128((__m128i*)(srcUV+16));
+ __m128i u1 = _mm_and_si128(uv1, mask);
+ __m128i u2 = _mm_and_si128(uv2, mask);
+ __m128i u = _mm_packus_epi16(u1, u2);
+ __m128i v1 = _mm_srli_epi16(uv1, 8);
+ __m128i v2 = _mm_srli_epi16(uv2, 8);
+ __m128i v = _mm_packus_epi16(v1, v2);
+ _mm_storeu_si128((__m128i*)dst1, u);
+ _mm_storeu_si128((__m128i*)dst2, v);
+ srcUV += 32;
+ dst1 += 16;
+ dst2 += 16;
+ x -= 16;
+ }
+ }
+#endif
+ while (x--) {
+ *dst1++ = *srcUV++;
+ *dst2++ = *srcUV++;
+ }
+ srcUV += srcUVPitchLeft;
+ dst1 += dstUVPitchLeft;
+ dst2 += dstUVPitchLeft;
+ }
+
+ if (tmp) {
+ SDL_free(tmp);
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_SwapNV(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int x, y;
+ const int UVwidth = (width + 1)/2;
+ const int UVheight = (height + 1)/2;
+ const int srcUVPitch = ((src_pitch + 1)/2)*2;
+ const int srcUVPitchLeft = (srcUVPitch - UVwidth*2)/sizeof(Uint16);
+ const int dstUVPitch = ((dst_pitch + 1)/2)*2;
+ const int dstUVPitchLeft = (dstUVPitch - UVwidth*2)/sizeof(Uint16);
+ const Uint16 *srcUV;
+ Uint16 *dstUV;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ /* Skip the Y plane */
+ src = (const Uint8 *)src + height * src_pitch;
+ dst = (Uint8 *)dst + height * dst_pitch;
+
+ srcUV = (const Uint16 *)src;
+ dstUV = (Uint16 *)dst;
+ y = UVheight;
+ while (y--) {
+ x = UVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ while (x >= 8) {
+ __m128i uv = _mm_loadu_si128((__m128i*)srcUV);
+ __m128i v = _mm_slli_epi16(uv, 8);
+ __m128i u = _mm_srli_epi16(uv, 8);
+ __m128i vu = _mm_or_si128(v, u);
+ _mm_storeu_si128((__m128i*)dstUV, vu);
+ srcUV += 8;
+ dstUV += 8;
+ x -= 8;
+ }
+ }
+#endif
+ while (x--) {
+ *dstUV++ = SDL_Swap16(*srcUV++);
+ }
+ srcUV += srcUVPitchLeft;
+ dstUV += dstUVPitchLeft;
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_Planar2x2_to_Planar2x2(int width, int height,
+ Uint32 src_format, const void *src, int src_pitch,
+ Uint32 dst_format, void *dst, int dst_pitch)
+{
+ if (src != dst) {
+ /* Copy Y plane */
+ int i;
+ const Uint8 *srcY = (const Uint8 *)src;
+ Uint8 *dstY = (Uint8 *)dst;
+ for (i = height; i--; ) {
+ SDL_memcpy(dstY, srcY, width);
+ srcY += src_pitch;
+ dstY += dst_pitch;
+ }
+ }
+
+ switch (src_format) {
+ case SDL_PIXELFORMAT_YV12:
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_IYUV:
+ return SDL_ConvertPixels_SwapUVPlanes(width, height, src, src_pitch, dst, dst_pitch);
+ case SDL_PIXELFORMAT_NV12:
+ return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, SDL_TRUE);
+ case SDL_PIXELFORMAT_NV21:
+ return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, SDL_FALSE);
+ default:
+ break;
+ }
+ break;
+ case SDL_PIXELFORMAT_IYUV:
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_YV12:
+ return SDL_ConvertPixels_SwapUVPlanes(width, height, src, src_pitch, dst, dst_pitch);
+ case SDL_PIXELFORMAT_NV12:
+ return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, SDL_FALSE);
+ case SDL_PIXELFORMAT_NV21:
+ return SDL_ConvertPixels_PackUVPlanes_to_NV(width, height, src, src_pitch, dst, dst_pitch, SDL_TRUE);
+ default:
+ break;
+ }
+ break;
+ case SDL_PIXELFORMAT_NV12:
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_YV12:
+ return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, SDL_TRUE);
+ case SDL_PIXELFORMAT_IYUV:
+ return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, SDL_FALSE);
+ case SDL_PIXELFORMAT_NV21:
+ return SDL_ConvertPixels_SwapNV(width, height, src, src_pitch, dst, dst_pitch);
+ default:
+ break;
+ }
+ break;
+ case SDL_PIXELFORMAT_NV21:
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_YV12:
+ return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, SDL_FALSE);
+ case SDL_PIXELFORMAT_IYUV:
+ return SDL_ConvertPixels_SplitNV_to_UVPlanes(width, height, src, src_pitch, dst, dst_pitch, SDL_TRUE);
+ case SDL_PIXELFORMAT_NV12:
+ return SDL_ConvertPixels_SwapNV(width, height, src, src_pitch, dst, dst_pitch);
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ return SDL_SetError("SDL_ConvertPixels_Planar2x2_to_Planar2x2: Unsupported YUV conversion: %s -> %s", SDL_GetPixelFormatName(src_format), SDL_GetPixelFormatName(dst_format));
+}
+
+#define PACKED4_TO_PACKED4_ROW_SSE2(shuffle) \
+ while (x >= 4) { \
+ __m128i yuv = _mm_loadu_si128((__m128i*)srcYUV); \
+ __m128i lo = _mm_unpacklo_epi8(yuv, _mm_setzero_si128()); \
+ __m128i hi = _mm_unpackhi_epi8(yuv, _mm_setzero_si128()); \
+ lo = _mm_shufflelo_epi16(lo, shuffle); \
+ lo = _mm_shufflehi_epi16(lo, shuffle); \
+ hi = _mm_shufflelo_epi16(hi, shuffle); \
+ hi = _mm_shufflehi_epi16(hi, shuffle); \
+ yuv = _mm_packus_epi16(lo, hi); \
+ _mm_storeu_si128((__m128i*)dstYUV, yuv); \
+ srcYUV += 16; \
+ dstYUV += 16; \
+ x -= 4; \
+ } \
+
+static int
+SDL_ConvertPixels_YUY2_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int x, y;
+ const int YUVwidth = (width + 1)/2;
+ const int srcYUVPitchLeft = (src_pitch - YUVwidth*4);
+ const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4);
+ const Uint8 *srcYUV = (const Uint8 *)src;
+ Uint8 *dstYUV = (Uint8 *)dst;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ y = height;
+ while (y--) {
+ x = YUVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(2, 3, 0, 1));
+ }
+#endif
+ while (x--) {
+ Uint8 Y1, U, Y2, V;
+
+ Y1 = srcYUV[0];
+ U = srcYUV[1];
+ Y2 = srcYUV[2];
+ V = srcYUV[3];
+ srcYUV += 4;
+
+ dstYUV[0] = U;
+ dstYUV[1] = Y1;
+ dstYUV[2] = V;
+ dstYUV[3] = Y2;
+ dstYUV += 4;
+ }
+ srcYUV += srcYUVPitchLeft;
+ dstYUV += dstYUVPitchLeft;
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_YUY2_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int x, y;
+ const int YUVwidth = (width + 1)/2;
+ const int srcYUVPitchLeft = (src_pitch - YUVwidth*4);
+ const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4);
+ const Uint8 *srcYUV = (const Uint8 *)src;
+ Uint8 *dstYUV = (Uint8 *)dst;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ y = height;
+ while (y--) {
+ x = YUVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(1, 2, 3, 0));
+ }
+#endif
+ while (x--) {
+ Uint8 Y1, U, Y2, V;
+
+ Y1 = srcYUV[0];
+ U = srcYUV[1];
+ Y2 = srcYUV[2];
+ V = srcYUV[3];
+ srcYUV += 4;
+
+ dstYUV[0] = Y1;
+ dstYUV[1] = V;
+ dstYUV[2] = Y2;
+ dstYUV[3] = U;
+ dstYUV += 4;
+ }
+ srcYUV += srcYUVPitchLeft;
+ dstYUV += dstYUVPitchLeft;
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_UYVY_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int x, y;
+ const int YUVwidth = (width + 1)/2;
+ const int srcYUVPitchLeft = (src_pitch - YUVwidth*4);
+ const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4);
+ const Uint8 *srcYUV = (const Uint8 *)src;
+ Uint8 *dstYUV = (Uint8 *)dst;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ y = height;
+ while (y--) {
+ x = YUVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(2, 3, 0, 1));
+ }
+#endif
+ while (x--) {
+ Uint8 Y1, U, Y2, V;
+
+ U = srcYUV[0];
+ Y1 = srcYUV[1];
+ V = srcYUV[2];
+ Y2 = srcYUV[3];
+ srcYUV += 4;
+
+ dstYUV[0] = Y1;
+ dstYUV[1] = U;
+ dstYUV[2] = Y2;
+ dstYUV[3] = V;
+ dstYUV += 4;
+ }
+ srcYUV += srcYUVPitchLeft;
+ dstYUV += dstYUVPitchLeft;
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_UYVY_to_YVYU(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int x, y;
+ const int YUVwidth = (width + 1)/2;
+ const int srcYUVPitchLeft = (src_pitch - YUVwidth*4);
+ const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4);
+ const Uint8 *srcYUV = (const Uint8 *)src;
+ Uint8 *dstYUV = (Uint8 *)dst;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ y = height;
+ while (y--) {
+ x = YUVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(0, 3, 2, 1));
+ }
+#endif
+ while (x--) {
+ Uint8 Y1, U, Y2, V;
+
+ U = srcYUV[0];
+ Y1 = srcYUV[1];
+ V = srcYUV[2];
+ Y2 = srcYUV[3];
+ srcYUV += 4;
+
+ dstYUV[0] = Y1;
+ dstYUV[1] = V;
+ dstYUV[2] = Y2;
+ dstYUV[3] = U;
+ dstYUV += 4;
+ }
+ srcYUV += srcYUVPitchLeft;
+ dstYUV += dstYUVPitchLeft;
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_YVYU_to_YUY2(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int x, y;
+ const int YUVwidth = (width + 1)/2;
+ const int srcYUVPitchLeft = (src_pitch - YUVwidth*4);
+ const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4);
+ const Uint8 *srcYUV = (const Uint8 *)src;
+ Uint8 *dstYUV = (Uint8 *)dst;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ y = height;
+ while (y--) {
+ x = YUVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(1, 2, 3, 0));
+ }
+#endif
+ while (x--) {
+ Uint8 Y1, U, Y2, V;
+
+ Y1 = srcYUV[0];
+ V = srcYUV[1];
+ Y2 = srcYUV[2];
+ U = srcYUV[3];
+ srcYUV += 4;
+
+ dstYUV[0] = Y1;
+ dstYUV[1] = U;
+ dstYUV[2] = Y2;
+ dstYUV[3] = V;
+ dstYUV += 4;
+ }
+ srcYUV += srcYUVPitchLeft;
+ dstYUV += dstYUVPitchLeft;
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_YVYU_to_UYVY(int width, int height, const void *src, int src_pitch, void *dst, int dst_pitch)
+{
+ int x, y;
+ const int YUVwidth = (width + 1)/2;
+ const int srcYUVPitchLeft = (src_pitch - YUVwidth*4);
+ const int dstYUVPitchLeft = (dst_pitch - YUVwidth*4);
+ const Uint8 *srcYUV = (const Uint8 *)src;
+ Uint8 *dstYUV = (Uint8 *)dst;
+#ifdef __SSE2__
+ const SDL_bool use_SSE2 = SDL_HasSSE2();
+#endif
+
+ y = height;
+ while (y--) {
+ x = YUVwidth;
+#ifdef __SSE2__
+ if (use_SSE2) {
+ PACKED4_TO_PACKED4_ROW_SSE2(_MM_SHUFFLE(2, 1, 0, 3));
+ }
+#endif
+ while (x--) {
+ Uint8 Y1, U, Y2, V;
+
+ Y1 = srcYUV[0];
+ V = srcYUV[1];
+ Y2 = srcYUV[2];
+ U = srcYUV[3];
+ srcYUV += 4;
+
+ dstYUV[0] = U;
+ dstYUV[1] = Y1;
+ dstYUV[2] = V;
+ dstYUV[3] = Y2;
+ dstYUV += 4;
+ }
+ srcYUV += srcYUVPitchLeft;
+ dstYUV += dstYUVPitchLeft;
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_Packed4_to_Packed4(int width, int height,
+ Uint32 src_format, const void *src, int src_pitch,
+ Uint32 dst_format, void *dst, int dst_pitch)
+{
+ switch (src_format) {
+ case SDL_PIXELFORMAT_YUY2:
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_UYVY:
+ return SDL_ConvertPixels_YUY2_to_UYVY(width, height, src, src_pitch, dst, dst_pitch);
+ case SDL_PIXELFORMAT_YVYU:
+ return SDL_ConvertPixels_YUY2_to_YVYU(width, height, src, src_pitch, dst, dst_pitch);
+ default:
+ break;
+ }
+ break;
+ case SDL_PIXELFORMAT_UYVY:
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_YUY2:
+ return SDL_ConvertPixels_UYVY_to_YUY2(width, height, src, src_pitch, dst, dst_pitch);
+ case SDL_PIXELFORMAT_YVYU:
+ return SDL_ConvertPixels_UYVY_to_YVYU(width, height, src, src_pitch, dst, dst_pitch);
+ default:
+ break;
+ }
+ break;
+ case SDL_PIXELFORMAT_YVYU:
+ switch (dst_format) {
+ case SDL_PIXELFORMAT_YUY2:
+ return SDL_ConvertPixels_YVYU_to_YUY2(width, height, src, src_pitch, dst, dst_pitch);
+ case SDL_PIXELFORMAT_UYVY:
+ return SDL_ConvertPixels_YVYU_to_UYVY(width, height, src, src_pitch, dst, dst_pitch);
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ return SDL_SetError("SDL_ConvertPixels_Packed4_to_Packed4: Unsupported YUV conversion: %s -> %s", SDL_GetPixelFormatName(src_format), SDL_GetPixelFormatName(dst_format));
+}
+
+static int
+SDL_ConvertPixels_Planar2x2_to_Packed4(int width, int height,
+ Uint32 src_format, const void *src, int src_pitch,
+ Uint32 dst_format, void *dst, int dst_pitch)
+{
+ int x, y;
+ const Uint8 *srcY1, *srcY2, *srcU, *srcV;
+ Uint32 srcY_pitch, srcUV_pitch;
+ Uint32 srcY_pitch_left, srcUV_pitch_left, srcUV_pixel_stride;
+ Uint8 *dstY1, *dstY2, *dstU1, *dstU2, *dstV1, *dstV2;
+ Uint32 dstY_pitch, dstUV_pitch;
+ Uint32 dst_pitch_left;
+
+ if (src == dst) {
+ return SDL_SetError("Can't change YUV plane types in-place");
+ }
+
+ if (GetYUVPlanes(width, height, src_format, src, src_pitch,
+ &srcY1, &srcU, &srcV, &srcY_pitch, &srcUV_pitch) < 0) {
+ return -1;
+ }
+ srcY2 = srcY1 + srcY_pitch;
+ srcY_pitch_left = (srcY_pitch - width);
+
+ if (src_format == SDL_PIXELFORMAT_NV12 || src_format == SDL_PIXELFORMAT_NV21) {
+ srcUV_pixel_stride = 2;
+ srcUV_pitch_left = (srcUV_pitch - 2*((width + 1)/2));
+ } else {
+ srcUV_pixel_stride = 1;
+ srcUV_pitch_left = (srcUV_pitch - ((width + 1)/2));
+ }
+
+ if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch,
+ (const Uint8 **)&dstY1, (const Uint8 **)&dstU1, (const Uint8 **)&dstV1,
+ &dstY_pitch, &dstUV_pitch) < 0) {
+ return -1;
+ }
+ dstY2 = dstY1 + dstY_pitch;
+ dstU2 = dstU1 + dstUV_pitch;
+ dstV2 = dstV1 + dstUV_pitch;
+ dst_pitch_left = (dstY_pitch - 4*((width + 1)/2));
+
+ /* Copy 2x2 blocks of pixels at a time */
+ for (y = 0; y < (height - 1); y += 2) {
+ for (x = 0; x < (width - 1); x += 2) {
+ /* Row 1 */
+ *dstY1 = *srcY1++;
+ dstY1 += 2;
+ *dstY1 = *srcY1++;
+ dstY1 += 2;
+ *dstU1 = *srcU;
+ *dstV1 = *srcV;
+
+ /* Row 2 */
+ *dstY2 = *srcY2++;
+ dstY2 += 2;
+ *dstY2 = *srcY2++;
+ dstY2 += 2;
+ *dstU2 = *srcU;
+ *dstV2 = *srcV;
+
+ srcU += srcUV_pixel_stride;
+ srcV += srcUV_pixel_stride;
+ dstU1 += 4;
+ dstU2 += 4;
+ dstV1 += 4;
+ dstV2 += 4;
+ }
+
+ /* Last column */
+ if (x == (width - 1)) {
+ /* Row 1 */
+ *dstY1 = *srcY1;
+ dstY1 += 2;
+ *dstY1 = *srcY1++;
+ dstY1 += 2;
+ *dstU1 = *srcU;
+ *dstV1 = *srcV;
+
+ /* Row 2 */
+ *dstY2 = *srcY2;
+ dstY2 += 2;
+ *dstY2 = *srcY2++;
+ dstY2 += 2;
+ *dstU2 = *srcU;
+ *dstV2 = *srcV;
+
+ srcU += srcUV_pixel_stride;
+ srcV += srcUV_pixel_stride;
+ dstU1 += 4;
+ dstU2 += 4;
+ dstV1 += 4;
+ dstV2 += 4;
+ }
+
+ srcY1 += srcY_pitch_left + srcY_pitch;
+ srcY2 += srcY_pitch_left + srcY_pitch;
+ srcU += srcUV_pitch_left;
+ srcV += srcUV_pitch_left;
+ dstY1 += dst_pitch_left + dstY_pitch;
+ dstY2 += dst_pitch_left + dstY_pitch;
+ dstU1 += dst_pitch_left + dstUV_pitch;
+ dstU2 += dst_pitch_left + dstUV_pitch;
+ dstV1 += dst_pitch_left + dstUV_pitch;
+ dstV2 += dst_pitch_left + dstUV_pitch;
+ }
+
+ /* Last row */
+ if (y == (height - 1)) {
+ for (x = 0; x < (width - 1); x += 2) {
+ /* Row 1 */
+ *dstY1 = *srcY1++;
+ dstY1 += 2;
+ *dstY1 = *srcY1++;
+ dstY1 += 2;
+ *dstU1 = *srcU;
+ *dstV1 = *srcV;
+
+ srcU += srcUV_pixel_stride;
+ srcV += srcUV_pixel_stride;
+ dstU1 += 4;
+ dstV1 += 4;
+ }
+
+ /* Last column */
+ if (x == (width - 1)) {
+ /* Row 1 */
+ *dstY1 = *srcY1;
+ dstY1 += 2;
+ *dstY1 = *srcY1++;
+ dstY1 += 2;
+ *dstU1 = *srcU;
+ *dstV1 = *srcV;
+
+ srcU += srcUV_pixel_stride;
+ srcV += srcUV_pixel_stride;
+ dstU1 += 4;
+ dstV1 += 4;
+ }
+ }
+ return 0;
+}
+
+static int
+SDL_ConvertPixels_Packed4_to_Planar2x2(int width, int height,
+ Uint32 src_format, const void *src, int src_pitch,
+ Uint32 dst_format, void *dst, int dst_pitch)
+{
+ int x, y;
+ const Uint8 *srcY1, *srcY2, *srcU1, *srcU2, *srcV1, *srcV2;
+ Uint32 srcY_pitch, srcUV_pitch;
+ Uint32 src_pitch_left;
+ Uint8 *dstY1, *dstY2, *dstU, *dstV;
+ Uint32 dstY_pitch, dstUV_pitch;
+ Uint32 dstY_pitch_left, dstUV_pitch_left, dstUV_pixel_stride;
+
+ if (src == dst) {
+ return SDL_SetError("Can't change YUV plane types in-place");
+ }
+
+ if (GetYUVPlanes(width, height, src_format, src, src_pitch,
+ &srcY1, &srcU1, &srcV1, &srcY_pitch, &srcUV_pitch) < 0) {
+ return -1;
+ }
+ srcY2 = srcY1 + srcY_pitch;
+ srcU2 = srcU1 + srcUV_pitch;
+ srcV2 = srcV1 + srcUV_pitch;
+ src_pitch_left = (srcY_pitch - 4*((width + 1)/2));
+
+ if (GetYUVPlanes(width, height, dst_format, dst, dst_pitch,
+ (const Uint8 **)&dstY1, (const Uint8 **)&dstU, (const Uint8 **)&dstV,
+ &dstY_pitch, &dstUV_pitch) < 0) {
+ return -1;
+ }
+ dstY2 = dstY1 + dstY_pitch;
+ dstY_pitch_left = (dstY_pitch - width);
+
+ if (dst_format == SDL_PIXELFORMAT_NV12 || dst_format == SDL_PIXELFORMAT_NV21) {
+ dstUV_pixel_stride = 2;
+ dstUV_pitch_left = (dstUV_pitch - 2*((width + 1)/2));
+ } else {
+ dstUV_pixel_stride = 1;
+ dstUV_pitch_left = (dstUV_pitch - ((width + 1)/2));
+ }
+
+ /* Copy 2x2 blocks of pixels at a time */
+ for (y = 0; y < (height - 1); y += 2) {
+ for (x = 0; x < (width - 1); x += 2) {
+ /* Row 1 */
+ *dstY1++ = *srcY1;
+ srcY1 += 2;
+ *dstY1++ = *srcY1;
+ srcY1 += 2;
+
+ /* Row 2 */
+ *dstY2++ = *srcY2;
+ srcY2 += 2;
+ *dstY2++ = *srcY2;
+ srcY2 += 2;
+
+ *dstU = (Uint8)(((Uint32)*srcU1 + *srcU2)/2);
+ *dstV = (Uint8)(((Uint32)*srcV1 + *srcV2)/2);
+
+ srcU1 += 4;
+ srcU2 += 4;
+ srcV1 += 4;
+ srcV2 += 4;
+ dstU += dstUV_pixel_stride;
+ dstV += dstUV_pixel_stride;
+ }
+
+ /* Last column */
+ if (x == (width - 1)) {
+ /* Row 1 */
+ *dstY1 = *srcY1;
+ srcY1 += 2;
+ *dstY1++ = *srcY1;
+ srcY1 += 2;
+
+ /* Row 2 */
+ *dstY2 = *srcY2;
+ srcY2 += 2;
+ *dstY2++ = *srcY2;
+ srcY2 += 2;
+
+ *dstU = (Uint8)(((Uint32)*srcU1 + *srcU2)/2);
+ *dstV = (Uint8)(((Uint32)*srcV1 + *srcV2)/2);
+
+ srcU1 += 4;
+ srcU2 += 4;
+ srcV1 += 4;
+ srcV2 += 4;
+ dstU += dstUV_pixel_stride;
+ dstV += dstUV_pixel_stride;
+ }
+
+ srcY1 += src_pitch_left + srcY_pitch;
+ srcY2 += src_pitch_left + srcY_pitch;
+ srcU1 += src_pitch_left + srcUV_pitch;
+ srcU2 += src_pitch_left + srcUV_pitch;
+ srcV1 += src_pitch_left + srcUV_pitch;
+ srcV2 += src_pitch_left + srcUV_pitch;
+ dstY1 += dstY_pitch_left + dstY_pitch;
+ dstY2 += dstY_pitch_left + dstY_pitch;
+ dstU += dstUV_pitch_left;
+ dstV += dstUV_pitch_left;
+ }
+
+ /* Last row */
+ if (y == (height - 1)) {
+ for (x = 0; x < (width - 1); x += 2) {
+ *dstY1++ = *srcY1;
+ srcY1 += 2;
+ *dstY1++ = *srcY1;
+ srcY1 += 2;
+
+ *dstU = *srcU1;
+ *dstV = *srcV1;
+
+ srcU1 += 4;
+ srcV1 += 4;
+ dstU += dstUV_pixel_stride;
+ dstV += dstUV_pixel_stride;
+ }
+
+ /* Last column */
+ if (x == (width - 1)) {
+ *dstY1 = *srcY1;
+ *dstU = *srcU1;
+ *dstV = *srcV1;
+ }
+ }
+ return 0;
+}
+
+int
+SDL_ConvertPixels_YUV_to_YUV(int width, int height,
+ Uint32 src_format, const void *src, int src_pitch,
+ Uint32 dst_format, void *dst, int dst_pitch)
+{
+ if (src_format == dst_format) {
+ if (src == dst) {
+ /* Nothing to do */
+ return 0;
+ }
+ return SDL_ConvertPixels_YUV_to_YUV_Copy(width, height, src_format, src, src_pitch, dst, dst_pitch);
+ }
+
+ if (IsPlanar2x2Format(src_format) && IsPlanar2x2Format(dst_format)) {
+ return SDL_ConvertPixels_Planar2x2_to_Planar2x2(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
+ } else if (IsPacked4Format(src_format) && IsPacked4Format(dst_format)) {
+ return SDL_ConvertPixels_Packed4_to_Packed4(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
+ } else if (IsPlanar2x2Format(src_format) && IsPacked4Format(dst_format)) {
+ return SDL_ConvertPixels_Planar2x2_to_Packed4(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
+ } else if (IsPacked4Format(src_format) && IsPlanar2x2Format(dst_format)) {
+ return SDL_ConvertPixels_Packed4_to_Planar2x2(width, height, src_format, src, src_pitch, dst_format, dst, dst_pitch);
+ } else {
+ return SDL_SetError("SDL_ConvertPixels_YUV_to_YUV: Unsupported YUV conversion: %s -> %s", SDL_GetPixelFormatName(src_format), SDL_GetPixelFormatName(dst_format));
+ }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/SDL_yuv_c.h b/src/video/SDL_yuv_c.h
new file mode 100644
index 000000000..c7b342d1e
--- /dev/null
+++ b/src/video/SDL_yuv_c.h
@@ -0,0 +1,30 @@
+/*
+ Simple DirectMedia Layer
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+#include "../SDL_internal.h"
+
+
+/* YUV conversion functions */
+
+extern int SDL_ConvertPixels_YUV_to_RGB(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch);
+extern int SDL_ConvertPixels_RGB_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch);
+extern int SDL_ConvertPixels_YUV_to_YUV(int width, int height, Uint32 src_format, const void *src, int src_pitch, Uint32 dst_format, void *dst, int dst_pitch);
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/src/video/yuv2rgb/LICENSE b/src/video/yuv2rgb/LICENSE
new file mode 100644
index 000000000..a76efd7be
--- /dev/null
+++ b/src/video/yuv2rgb/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2016, Adrien Descamps
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+
+* Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+* Neither the name of yuv2rgb nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/src/video/yuv2rgb/README.md b/src/video/yuv2rgb/README.md
new file mode 100644
index 000000000..5a3ef9046
--- /dev/null
+++ b/src/video/yuv2rgb/README.md
@@ -0,0 +1,63 @@
+From: https://github.com/descampsa/yuv2rgb
+# yuv2rgb
+C library for fast image conversion between yuv420p and rgb24.
+
+This is a simple library for optimized image conversion between YUV420p and rgb24.
+It was done mainly as an exercise to learn to use sse instrinsics, so there may still be room for optimization.
+
+For each conversion, a standard c optimized function and two sse function (with aligned and unaligned memory) are implemented.
+The sse version requires only SSE2, which is available on any reasonnably recent CPU.
+The library also supports the three different YUV (YCrCb to be correct) color spaces that exist (see comments in code), and others can be added simply.
+
+There is a simple test program, that convert a raw YUV file to rgb ppm format, and measure computation time.
+Optionnaly, it also compares the result and computation time with the ffmpeg implementation (that uses MMX), and with the IPP functions.
+
+To compile, simply do :
+
+ mkdir build
+ cd build
+ cmake -DCMAKE_BUILD_TYPE=Release ..
+ make
+
+The test program only support raw YUV files for the YUV420 format, and ppm for the RGB24 format.
+To generate a raw yuv file, you can use avconv:
+
+ avconv -i example.jpg -c:v rawvideo -pix_fmt yuv420p example.yuv
+
+To generate the rgb file, you can use the ImageMagick convert program:
+
+ convert example.jpg example.ppm
+
+Then, for YUV420 to RGB24 conversion, use the test program like that:
+
+ ./test_yuv_rgb yuv2rgb image.yuv 4096 2160 image
+
+The second and third parameters are image width and height (that are needed because not available in the raw YUV file), and fourth parameter is the output filename template (several output files will be generated, named for example output_sse.ppm, output_av.ppm, etc.)
+
+Similarly, for RGB24 to YUV420 conversion:
+
+ ./test_yuv_rgb yuv2rgb image.ppm image
+
+On my computer, the test program on a 4K image give the following for yuv2rgb:
+
+ Time will be measured in each configuration for 100 iterations...
+ Processing time (std) : 2.630193 sec
+ Processing time (sse2_unaligned) : 0.704394 sec
+ Processing time (ffmpeg_unaligned) : 1.221432 sec
+ Processing time (ipp_unaligned) : 0.636274 sec
+ Processing time (sse2_aligned) : 0.606648 sec
+ Processing time (ffmpeg_aligned) : 1.227100 sec
+ Processing time (ipp_aligned) : 0.636951 sec
+
+And for rgb2yuv:
+
+ Time will be measured in each configuration for 100 iterations...
+ Processing time (std) : 2.588675 sec
+ Processing time (sse2_unaligned) : 0.676625 sec
+ Processing time (ffmpeg_unaligned) : 3.385816 sec
+ Processing time (ipp_unaligned) : 0.593890 sec
+ Processing time (sse2_aligned) : 0.640630 sec
+ Processing time (ffmpeg_aligned) : 3.397952 sec
+ Processing time (ipp_aligned) : 0.579043 sec
+
+configuration : gcc 4.9.2, swscale 3.0.0, IPP 9.0.1, intel i7-5500U
diff --git a/src/video/yuv2rgb/yuv_rgb.c b/src/video/yuv2rgb/yuv_rgb.c
new file mode 100644
index 000000000..072ef5c11
--- /dev/null
+++ b/src/video/yuv2rgb/yuv_rgb.c
@@ -0,0 +1,687 @@
+// Copyright 2016 Adrien Descamps
+// Distributed under BSD 3-Clause License
+#include "../../SDL_internal.h"
+
+#include "yuv_rgb.h"
+
+#include "SDL_cpuinfo.h"
+/*#include <x86intrin.h>*/
+
+#define PRECISION 6
+#define PRECISION_FACTOR (1<<PRECISION)
+
+typedef struct
+{
+ uint8_t y_shift;
+ int16_t matrix[3][3];
+} RGB2YUVParam;
+// |Y| |y_shift| |matrix[0][0] matrix[0][1] matrix[0][2]| |R|
+// |U| = | 128 | + 1/PRECISION_FACTOR * |matrix[1][0] matrix[1][1] matrix[1][2]| * |G|
+// |V| | 128 | |matrix[2][0] matrix[2][1] matrix[2][2]| |B|
+
+typedef struct
+{
+ uint8_t y_shift;
+ int16_t y_factor;
+ int16_t v_r_factor;
+ int16_t u_g_factor;
+ int16_t v_g_factor;
+ int16_t u_b_factor;
+} YUV2RGBParam;
+// |R| |y_factor 0 v_r_factor| |Y-y_shift|
+// |G| = 1/PRECISION_FACTOR * |y_factor u_g_factor v_g_factor| * | U-128 |
+// |B| |y_factor u_b_factor 0 | | V-128 |
+
+#define V(value) (int16_t)((value*PRECISION_FACTOR)+0.5)
+
+// for ITU-T T.871, values can be found in section 7
+// for ITU-R BT.601-7 values are derived from equations in sections 2.5.1-2.5.3, assuming RGB is encoded using full range ([0-1]<->[0-255])
+// for ITU-R BT.709-6 values are derived from equations in sections 3.2-3.4, assuming RGB is encoded using full range ([0-1]<->[0-255])
+// all values are rounded to the fourth decimal
+
+static const YUV2RGBParam YUV2RGB[3] = {
+ // ITU-T T.871 (JPEG)
+ {/*.y_shift=*/ 0, /*.y_factor=*/ V(1.0), /*.v_r_factor=*/ V(1.402), /*.u_g_factor=*/ -V(0.3441), /*.v_g_factor=*/ -V(0.7141), /*.u_b_factor=*/ V(1.772)},
+ // ITU-R BT.601-7
+ {/*.y_shift=*/ 16, /*.y_factor=*/ V(1.1644), /*.v_r_factor=*/ V(1.596), /*.u_g_factor=*/ -V(0.3918), /*.v_g_factor=*/ -V(0.813), /*.u_b_factor=*/ V(2.0172)},
+ // ITU-R BT.709-6
+ {/*.y_shift=*/ 16, /*.y_factor=*/ V(1.1644), /*.v_r_factor=*/ V(1.7927), /*.u_g_factor=*/ -V(0.2132), /*.v_g_factor=*/ -V(0.5329), /*.u_b_factor=*/ V(2.1124)}
+};
+
+static const RGB2YUVParam RGB2YUV[3] = {
+ // ITU-T T.871 (JPEG)
+ {/*.y_shift=*/ 0, /*.matrix=*/ {{V(0.299), V(0.587), V(0.114)}, {-V(0.1687), -V(0.3313), V(0.5)}, {V(0.5), -V(0.4187), -V(0.0813)}}},
+ // ITU-R BT.601-7
+ {/*.y_shift=*/ 16, /*.matrix=*/ {{V(0.2568), V(0.5041), V(0.0979)}, {-V(0.1482), -V(0.291), V(0.4392)}, {V(0.4392), -V(0.3678), -V(0.0714)}}},
+ // ITU-R BT.709-6
+ {/*.y_shift=*/ 16, /*.matrix=*/ {{V(0.1826), V(0.6142), V(0.062)}, {-V(0.1006), -V(0.3386), V(0.4392)}, {V(0.4392), -V(0.3989), -V(0.0403)}}}
+};
+
+/* The various layouts of YUV data we support */
+#define YUV_FORMAT_420 1
+#define YUV_FORMAT_422 2
+#define YUV_FORMAT_NV12 3
+
+/* The various formats of RGB pixel that we support */
+#define RGB_FORMAT_RGB565 1
+#define RGB_FORMAT_RGB24 2
+#define RGB_FORMAT_RGBA 3
+#define RGB_FORMAT_BGRA 4
+#define RGB_FORMAT_ARGB 5
+#define RGB_FORMAT_ABGR 6
+
+// divide by PRECISION_FACTOR and clamp to [0:255] interval
+// input must be in the [-128*PRECISION_FACTOR:384*PRECISION_FACTOR] range
+static uint8_t clampU8(int32_t v)
+{
+ static const uint8_t lut[512] =
+ {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,
+ 47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,
+ 91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,
+ 126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,
+ 159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
+ 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,
+ 225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
+ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
+ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255
+ };
+ return lut[(v+128*PRECISION_FACTOR)>>PRECISION];
+}
+
+
+#define STD_FUNCTION_NAME yuv420_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv420_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv420_rgba_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv420_bgra_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv420_argb_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv420_abgr_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv422_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv422_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv422_rgba_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv422_bgra_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv422_argb_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuv422_abgr_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuvnv12_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuvnv12_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuvnv12_rgba_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuvnv12_bgra_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuvnv12_argb_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#include "yuv_rgb_std_func.h"
+
+#define STD_FUNCTION_NAME yuvnv12_abgr_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#include "yuv_rgb_std_func.h"
+
+void rgb24_yuv420_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *RGB, uint32_t RGB_stride,
+ uint8_t *Y, uint8_t *U, uint8_t *V, uint32_t Y_stride, uint32_t UV_stride,
+ YCbCrType yuv_type)
+{
+ const RGB2YUVParam *const param = &(RGB2YUV[yuv_type]);
+
+ uint32_t x, y;
+ for(y=0; y<(height-1); y+=2)
+ {
+ const uint8_t *rgb_ptr1=RGB+y*RGB_stride,
+ *rgb_ptr2=RGB+(y+1)*RGB_stride;
+
+ uint8_t *y_ptr1=Y+y*Y_stride,
+ *y_ptr2=Y+(y+1)*Y_stride,
+ *u_ptr=U+(y/2)*UV_stride,
+ *v_ptr=V+(y/2)*UV_stride;
+
+ for(x=0; x<(width-1); x+=2)
+ {
+ // compute yuv for the four pixels, u and v values are summed
+ int32_t y_tmp, u_tmp, v_tmp;
+
+ y_tmp = param->matrix[0][0]*rgb_ptr1[0] + param->matrix[0][1]*rgb_ptr1[1] + param->matrix[0][2]*rgb_ptr1[2];
+ u_tmp = param->matrix[1][0]*rgb_ptr1[0] + param->matrix[1][1]*rgb_ptr1[1] + param->matrix[1][2]*rgb_ptr1[2];
+ v_tmp = param->matrix[2][0]*rgb_ptr1[0] + param->matrix[2][1]*rgb_ptr1[1] + param->matrix[2][2]*rgb_ptr1[2];
+ y_ptr1[0]=clampU8(y_tmp+((param->y_shift)<<PRECISION));
+
+ y_tmp = param->matrix[0][0]*rgb_ptr1[3] + param->matrix[0][1]*rgb_ptr1[4] + param->matrix[0][2]*rgb_ptr1[5];
+ u_tmp += param->matrix[1][0]*rgb_ptr1[3] + param->matrix[1][1]*rgb_ptr1[4] + param->matrix[1][2]*rgb_ptr1[5];
+ v_tmp += param->matrix[2][0]*rgb_ptr1[3] + param->matrix[2][1]*rgb_ptr1[4] + param->matrix[2][2]*rgb_ptr1[5];
+ y_ptr1[1]=clampU8(y_tmp+((param->y_shift)<<PRECISION));
+
+ y_tmp = param->matrix[0][0]*rgb_ptr2[0] + param->matrix[0][1]*rgb_ptr2[1] + param->matrix[0][2]*rgb_ptr2[2];
+ u_tmp += param->matrix[1][0]*rgb_ptr2[0] + param->matrix[1][1]*rgb_ptr2[1] + param->matrix[1][2]*rgb_ptr2[2];
+ v_tmp += param->matrix[2][0]*rgb_ptr2[0] + param->matrix[2][1]*rgb_ptr2[1] + param->matrix[2][2]*rgb_ptr2[2];
+ y_ptr2[0]=clampU8(y_tmp+((param->y_shift)<<PRECISION));
+
+ y_tmp = param->matrix[0][0]*rgb_ptr2[3] + param->matrix[0][1]*rgb_ptr2[4] + param->matrix[0][2]*rgb_ptr2[5];
+ u_tmp += param->matrix[1][0]*rgb_ptr2[3] + param->matrix[1][1]*rgb_ptr2[4] + param->matrix[1][2]*rgb_ptr2[5];
+ v_tmp += param->matrix[2][0]*rgb_ptr2[3] + param->matrix[2][1]*rgb_ptr2[4] + param->matrix[2][2]*rgb_ptr2[5];
+ y_ptr2[1]=clampU8(y_tmp+((param->y_shift)<<PRECISION));
+
+ u_ptr[0] = clampU8(u_tmp/4+(128<<PRECISION));
+ v_ptr[0] = clampU8(v_tmp/4+(128<<PRECISION));
+
+ rgb_ptr1 += 6;
+ rgb_ptr2 += 6;
+ y_ptr1 += 2;
+ y_ptr2 += 2;
+ u_ptr += 1;
+ v_ptr += 1;
+ }
+ }
+}
+
+#ifdef __SSE2__
+
+#define SSE_FUNCTION_NAME yuv420_rgb565_sse
+#define STD_FUNCTION_NAME yuv420_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_rgb565_sseu
+#define STD_FUNCTION_NAME yuv420_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_rgb24_sse
+#define STD_FUNCTION_NAME yuv420_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_rgb24_sseu
+#define STD_FUNCTION_NAME yuv420_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_rgba_sse
+#define STD_FUNCTION_NAME yuv420_rgba_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_rgba_sseu
+#define STD_FUNCTION_NAME yuv420_rgba_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_bgra_sse
+#define STD_FUNCTION_NAME yuv420_bgra_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_bgra_sseu
+#define STD_FUNCTION_NAME yuv420_bgra_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_argb_sse
+#define STD_FUNCTION_NAME yuv420_argb_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_argb_sseu
+#define STD_FUNCTION_NAME yuv420_argb_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_abgr_sse
+#define STD_FUNCTION_NAME yuv420_abgr_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv420_abgr_sseu
+#define STD_FUNCTION_NAME yuv420_abgr_std
+#define YUV_FORMAT YUV_FORMAT_420
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_rgb565_sse
+#define STD_FUNCTION_NAME yuv422_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_rgb565_sseu
+#define STD_FUNCTION_NAME yuv422_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_rgb24_sse
+#define STD_FUNCTION_NAME yuv422_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_rgb24_sseu
+#define STD_FUNCTION_NAME yuv422_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_rgba_sse
+#define STD_FUNCTION_NAME yuv422_rgba_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_rgba_sseu
+#define STD_FUNCTION_NAME yuv422_rgba_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_bgra_sse
+#define STD_FUNCTION_NAME yuv422_bgra_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_bgra_sseu
+#define STD_FUNCTION_NAME yuv422_bgra_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_argb_sse
+#define STD_FUNCTION_NAME yuv422_argb_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_argb_sseu
+#define STD_FUNCTION_NAME yuv422_argb_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_abgr_sse
+#define STD_FUNCTION_NAME yuv422_abgr_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuv422_abgr_sseu
+#define STD_FUNCTION_NAME yuv422_abgr_std
+#define YUV_FORMAT YUV_FORMAT_422
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_rgb565_sse
+#define STD_FUNCTION_NAME yuvnv12_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_rgb565_sseu
+#define STD_FUNCTION_NAME yuvnv12_rgb565_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGB565
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_rgb24_sse
+#define STD_FUNCTION_NAME yuvnv12_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_rgb24_sseu
+#define STD_FUNCTION_NAME yuvnv12_rgb24_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGB24
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_rgba_sse
+#define STD_FUNCTION_NAME yuvnv12_rgba_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_rgba_sseu
+#define STD_FUNCTION_NAME yuvnv12_rgba_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_RGBA
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_bgra_sse
+#define STD_FUNCTION_NAME yuvnv12_bgra_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_bgra_sseu
+#define STD_FUNCTION_NAME yuvnv12_bgra_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_BGRA
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_argb_sse
+#define STD_FUNCTION_NAME yuvnv12_argb_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_argb_sseu
+#define STD_FUNCTION_NAME yuvnv12_argb_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_ARGB
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_abgr_sse
+#define STD_FUNCTION_NAME yuvnv12_abgr_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#define SSE_ALIGNED
+#include "yuv_rgb_sse_func.h"
+
+#define SSE_FUNCTION_NAME yuvnv12_abgr_sseu
+#define STD_FUNCTION_NAME yuvnv12_abgr_std
+#define YUV_FORMAT YUV_FORMAT_NV12
+#define RGB_FORMAT RGB_FORMAT_ABGR
+#include "yuv_rgb_sse_func.h"
+
+
+#define UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \
+R1 = _mm_unpacklo_epi8(RGB1, RGB4); \
+R2 = _mm_unpackhi_epi8(RGB1, RGB4); \
+G1 = _mm_unpacklo_epi8(RGB2, RGB5); \
+G2 = _mm_unpackhi_epi8(RGB2, RGB5); \
+B1 = _mm_unpacklo_epi8(RGB3, RGB6); \
+B2 = _mm_unpackhi_epi8(RGB3, RGB6);
+
+#define UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \
+RGB1 = _mm_unpacklo_epi8(R1, G2); \
+RGB2 = _mm_unpackhi_epi8(R1, G2); \
+RGB3 = _mm_unpacklo_epi8(R2, B1); \
+RGB4 = _mm_unpackhi_epi8(R2, B1); \
+RGB5 = _mm_unpacklo_epi8(G1, B2); \
+RGB6 = _mm_unpackhi_epi8(G1, B2); \
+
+#define UNPACK_RGB24_32(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \
+UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \
+UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \
+UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \
+UNPACK_RGB24_32_STEP2(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \
+UNPACK_RGB24_32_STEP1(RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, R1, R2, G1, G2, B1, B2) \
+
+#define RGB2YUV_16(R, G, B, Y, U, V) \
+Y = _mm_add_epi16(_mm_mullo_epi16(R, _mm_set1_epi16(param->matrix[0][0])), \
+ _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[0][1]))); \
+Y = _mm_add_epi16(Y, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[0][2]))); \
+Y = _mm_add_epi16(Y, _mm_set1_epi16((param->y_shift)<<PRECISION)); \
+Y = _mm_srai_epi16(Y, PRECISION); \
+U = _mm_add_epi16(_mm_mullo_epi16(R, _mm_set1_epi16(param->matrix[1][0])), \
+ _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[1][1]))); \
+U = _mm_add_epi16(U, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[1][2]))); \
+U = _mm_add_epi16(U, _mm_set1_epi16(128<<PRECISION)); \
+U = _mm_srai_epi16(U, PRECISION); \
+V = _mm_add_epi16(_mm_mullo_epi16(R, _mm_set1_epi16(param->matrix[2][0])), \
+ _mm_mullo_epi16(G, _mm_set1_epi16(param->matrix[2][1]))); \
+V = _mm_add_epi16(V, _mm_mullo_epi16(B, _mm_set1_epi16(param->matrix[2][2]))); \
+V = _mm_add_epi16(V, _mm_set1_epi16(128<<PRECISION)); \
+V = _mm_srai_epi16(V, PRECISION);
+
+#define RGB2YUV_32 \
+ __m128i r1, r2, b1, b2, g1, g2; \
+ __m128i r_16, g_16, b_16; \
+ __m128i y1_16, y2_16, u1_16, u2_16, v1_16, v2_16, y, u1, u2, v1, v2, u1_tmp, u2_tmp, v1_tmp, v2_tmp; \
+ __m128i rgb1 = LOAD_SI128((const __m128i*)(rgb_ptr1)), \
+ rgb2 = LOAD_SI128((const __m128i*)(rgb_ptr1+16)), \
+ rgb3 = LOAD_SI128((const __m128i*)(rgb_ptr1+32)), \
+ rgb4 = LOAD_SI128((const __m128i*)(rgb_ptr2)), \
+ rgb5 = LOAD_SI128((const __m128i*)(rgb_ptr2+16)), \
+ rgb6 = LOAD_SI128((const __m128i*)(rgb_ptr2+32)); \
+ /* unpack rgb24 data to r, g and b data in separate channels*/ \
+ UNPACK_RGB24_32(rgb1, rgb2, rgb3, rgb4, rgb5, rgb6, r1, r2, g1, g2, b1, b2) \
+ /* process pixels of first line */ \
+ r_16 = _mm_unpacklo_epi8(r1, _mm_setzero_si128()); \
+ g_16 = _mm_unpacklo_epi8(g1, _mm_setzero_si128()); \
+ b_16 = _mm_unpacklo_epi8(b1, _mm_setzero_si128()); \
+ RGB2YUV_16(r_16, g_16, b_16, y1_16, u1_16, v1_16) \
+ r_16 = _mm_unpackhi_epi8(r1, _mm_setzero_si128()); \
+ g_16 = _mm_unpackhi_epi8(g1, _mm_setzero_si128()); \
+ b_16 = _mm_unpackhi_epi8(b1, _mm_setzero_si128()); \
+ RGB2YUV_16(r_16, g_16, b_16, y2_16, u2_16, v2_16) \
+ y = _mm_packus_epi16(y1_16, y2_16); \
+ u1 = _mm_packus_epi16(u1_16, u2_16); \
+ v1 = _mm_packus_epi16(v1_16, v2_16); \
+ /* save Y values */ \
+ SAVE_SI128((__m128i*)(y_ptr1), y); \
+ /* process pixels of second line */ \
+ r_16 = _mm_unpacklo_epi8(r2, _mm_setzero_si128()); \
+ g_16 = _mm_unpacklo_epi8(g2, _mm_setzero_si128()); \
+ b_16 = _mm_unpacklo_epi8(b2, _mm_setzero_si128()); \
+ RGB2YUV_16(r_16, g_16, b_16, y1_16, u1_16, v1_16) \
+ r_16 = _mm_unpackhi_epi8(r2, _mm_setzero_si128()); \
+ g_16 = _mm_unpackhi_epi8(g2, _mm_setzero_si128()); \
+ b_16 = _mm_unpackhi_epi8(b2, _mm_setzero_si128()); \
+ RGB2YUV_16(r_16, g_16, b_16, y2_16, u2_16, v2_16) \
+ y = _mm_packus_epi16(y1_16, y2_16); \
+ u2 = _mm_packus_epi16(u1_16, u2_16); \
+ v2 = _mm_packus_epi16(v1_16, v2_16); \
+ /* save Y values */ \
+ SAVE_SI128((__m128i*)(y_ptr2), y); \
+ /* vertical subsampling of u/v values */ \
+ u1_tmp = _mm_avg_epu8(u1, u2); \
+ v1_tmp = _mm_avg_epu8(v1, v2); \
+ /* do the same again with next data */ \
+ rgb1 = LOAD_SI128((const __m128i*)(rgb_ptr1+48)); \
+ rgb2 = LOAD_SI128((const __m128i*)(rgb_ptr1+64)); \
+ rgb3 = LOAD_SI128((const __m128i*)(rgb_ptr1+80)); \
+ rgb4 = LOAD_SI128((const __m128i*)(rgb_ptr2+48)); \
+ rgb5 = LOAD_SI128((const __m128i*)(rgb_ptr2+64)); \
+ rgb6 = LOAD_SI128((const __m128i*)(rgb_ptr2+80)); \
+ /* unpack rgb24 data to r, g and b data in separate channels*/ \
+ UNPACK_RGB24_32(rgb1, rgb2, rgb3, rgb4, rgb5, rgb6, r1, r2, g1, g2, b1, b2) \
+ /* process pixels of first line */ \
+ r_16 = _mm_unpacklo_epi8(r1, _mm_setzero_si128()); \
+ g_16 = _mm_unpacklo_epi8(g1, _mm_setzero_si128()); \
+ b_16 = _mm_unpacklo_epi8(b1, _mm_setzero_si128()); \
+ RGB2YUV_16(r_16, g_16, b_16, y1_16, u1_16, v1_16) \
+ r_16 = _mm_unpackhi_epi8(r1, _mm_setzero_si128()); \
+ g_16 = _mm_unpackhi_epi8(g1, _mm_setzero_si128()); \
+ b_16 = _mm_unpackhi_epi8(b1, _mm_setzero_si128()); \
+ RGB2YUV_16(r_16, g_16, b_16, y2_16, u2_16, v2_16) \
+ y = _mm_packus_epi16(y1_16, y2_16); \
+ u1 = _mm_packus_epi16(u1_16, u2_16); \
+ v1 = _mm_packus_epi16(v1_16, v2_16); \
+ /* save Y values */ \
+ SAVE_SI128((__m128i*)(y_ptr1+16), y); \
+ /* process pixels of second line */ \
+ r_16 = _mm_unpacklo_epi8(r2, _mm_setzero_si128()); \
+ g_16 = _mm_unpacklo_epi8(g2, _mm_setzero_si128()); \
+ b_16 = _mm_unpacklo_epi8(b2, _mm_setzero_si128()); \
+ RGB2YUV_16(r_16, g_16, b_16, y1_16, u1_16, v1_16) \
+ r_16 = _mm_unpackhi_epi8(r2, _mm_setzero_si128()); \
+ g_16 = _mm_unpackhi_epi8(g2, _mm_setzero_si128()); \
+ b_16 = _mm_unpackhi_epi8(b2, _mm_setzero_si128()); \
+ RGB2YUV_16(r_16, g_16, b_16, y2_16, u2_16, v2_16) \
+ y = _mm_packus_epi16(y1_16, y2_16); \
+ u2 = _mm_packus_epi16(u1_16, u2_16); \
+ v2 = _mm_packus_epi16(v1_16, v2_16); \
+ /* save Y values */ \
+ SAVE_SI128((__m128i*)(y_ptr2+16), y); \
+ /* vertical subsampling of u/v values */ \
+ u2_tmp = _mm_avg_epu8(u1, u2); \
+ v2_tmp = _mm_avg_epu8(v1, v2); \
+ /* horizontal subsampling of u/v values */ \
+ u1 = _mm_packus_epi16(_mm_srl_epi16(u1_tmp, _mm_cvtsi32_si128(8)), _mm_srl_epi16(u2_tmp, _mm_cvtsi32_si128(8))); \
+ v1 = _mm_packus_epi16(_mm_srl_epi16(v1_tmp, _mm_cvtsi32_si128(8)), _mm_srl_epi16(v2_tmp, _mm_cvtsi32_si128(8))); \
+ u2 = _mm_packus_epi16(_mm_and_si128(u1_tmp, _mm_set1_epi16(0xFF)), _mm_and_si128(u2_tmp, _mm_set1_epi16(0xFF))); \
+ v2 = _mm_packus_epi16(_mm_and_si128(v1_tmp, _mm_set1_epi16(0xFF)), _mm_and_si128(v2_tmp, _mm_set1_epi16(0xFF))); \
+ u1 = _mm_avg_epu8(u1, u2); \
+ v1 = _mm_avg_epu8(v1, v2); \
+ SAVE_SI128((__m128i*)(u_ptr), u1); \
+ SAVE_SI128((__m128i*)(v_ptr), v1);
+
+void rgb24_yuv420_sse(uint32_t width, uint32_t height,
+ const uint8_t *RGB, uint32_t RGB_stride,
+ uint8_t *Y, uint8_t *U, uint8_t *V, uint32_t Y_stride, uint32_t UV_stride,
+ YCbCrType yuv_type)
+{
+ #define LOAD_SI128 _mm_load_si128
+ #define SAVE_SI128 _mm_stream_si128
+ const RGB2YUVParam *const param = &(RGB2YUV[yuv_type]);
+
+ uint32_t x, y;
+ for(y=0; y<(height-1); y+=2)
+ {
+ const uint8_t *rgb_ptr1=RGB+y*RGB_stride,
+ *rgb_ptr2=RGB+(y+1)*RGB_stride;
+
+ uint8_t *y_ptr1=Y+y*Y_stride,
+ *y_ptr2=Y+(y+1)*Y_stride,
+ *u_ptr=U+(y/2)*UV_stride,
+ *v_ptr=V+(y/2)*UV_stride;
+
+ for(x=0; x<(width-31); x+=32)
+ {
+ RGB2YUV_32
+
+ rgb_ptr1+=96;
+ rgb_ptr2+=96;
+ y_ptr1+=32;
+ y_ptr2+=32;
+ u_ptr+=16;
+ v_ptr+=16;
+ }
+ }
+ #undef LOAD_SI128
+ #undef SAVE_SI128
+}
+
+void rgb24_yuv420_sseu(uint32_t width, uint32_t height,
+ const uint8_t *RGB, uint32_t RGB_stride,
+ uint8_t *Y, uint8_t *U, uint8_t *V, uint32_t Y_stride, uint32_t UV_stride,
+ YCbCrType yuv_type)
+{
+ #define LOAD_SI128 _mm_loadu_si128
+ #define SAVE_SI128 _mm_storeu_si128
+ const RGB2YUVParam *const param = &(RGB2YUV[yuv_type]);
+
+ uint32_t x, y;
+ for(y=0; y<(height-1); y+=2)
+ {
+ const uint8_t *rgb_ptr1=RGB+y*RGB_stride,
+ *rgb_ptr2=RGB+(y+1)*RGB_stride;
+
+ uint8_t *y_ptr1=Y+y*Y_stride,
+ *y_ptr2=Y+(y+1)*Y_stride,
+ *u_ptr=U+(y/2)*UV_stride,
+ *v_ptr=V+(y/2)*UV_stride;
+
+ for(x=0; x<(width-31); x+=32)
+ {
+ RGB2YUV_32
+
+ rgb_ptr1+=96;
+ rgb_ptr2+=96;
+ y_ptr1+=32;
+ y_ptr2+=32;
+ u_ptr+=16;
+ v_ptr+=16;
+ }
+ }
+ #undef LOAD_SI128
+ #undef SAVE_SI128
+}
+
+
+#endif //__SSE2__
+
diff --git a/src/video/yuv2rgb/yuv_rgb.h b/src/video/yuv2rgb/yuv_rgb.h
new file mode 100644
index 000000000..512e90b0a
--- /dev/null
+++ b/src/video/yuv2rgb/yuv_rgb.h
@@ -0,0 +1,380 @@
+// Copyright 2016 Adrien Descamps
+// Distributed under BSD 3-Clause License
+
+// Provide optimized functions to convert images from 8bits yuv420 to rgb24 format
+
+// There are a few slightly different variations of the YCbCr color space with different parameters that
+// change the conversion matrix.
+// The three most common YCbCr color space, defined by BT.601, BT.709 and JPEG standard are implemented here.
+// See the respective standards for details
+// The matrix values used are derived from http://www.equasys.de/colorconversion.html
+
+// YUV420 is stored as three separate channels, with U and V (Cb and Cr) subsampled by a 2 factor
+// For conversion from yuv to rgb, no interpolation is done, and the same UV value are used for 4 rgb pixels. This
+// is suboptimal for image quality, but by far the fastest method.
+
+// For all methods, width and height should be even, if not, the last row/column of the result image won't be affected.
+// For sse methods, if the width if not divisable by 32, the last (width%32) pixels of each line won't be affected.
+
+#include <stdint.h>
+
+typedef enum
+{
+ YCBCR_JPEG,
+ YCBCR_601,
+ YCBCR_709
+} YCbCrType;
+
+// yuv to rgb, standard c implementation
+void yuv420_rgb565_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_rgb24_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_rgba_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_bgra_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_argb_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_abgr_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgb565_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgb24_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgba_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_bgra_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_argb_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_abgr_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgb565_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgb24_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgba_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_bgra_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_argb_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_abgr_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+// yuv to rgb, sse implementation
+// pointers must be 16 byte aligned, and strides must be divisable by 16
+void yuv420_rgb565_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_rgb24_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_rgba_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_bgra_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_argb_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_abgr_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgb565_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgb24_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgba_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_bgra_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_argb_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_abgr_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgb565_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgb24_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgba_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_bgra_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_argb_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_abgr_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+// yuv to rgb, sse implementation
+// pointers do not need to be 16 byte aligned
+void yuv420_rgb565_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_rgb24_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_rgba_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_bgra_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_argb_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv420_abgr_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgb565_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgb24_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_rgba_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_bgra_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_argb_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuv422_abgr_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgb565_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgb24_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_rgba_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_bgra_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_argb_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+void yuvnv12_abgr_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *y, const uint8_t *u, const uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ uint8_t *rgb, uint32_t rgb_stride,
+ YCbCrType yuv_type);
+
+
+// rgb to yuv, standard c implementation
+void rgb24_yuv420_std(
+ uint32_t width, uint32_t height,
+ const uint8_t *rgb, uint32_t rgb_stride,
+ uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ YCbCrType yuv_type);
+
+// rgb to yuv, sse implementation
+// pointers must be 16 byte aligned, and strides must be divisible by 16
+void rgb24_yuv420_sse(
+ uint32_t width, uint32_t height,
+ const uint8_t *rgb, uint32_t rgb_stride,
+ uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ YCbCrType yuv_type);
+
+// rgb to yuv, sse implementation
+// pointers do not need to be 16 byte aligned
+void rgb24_yuv420_sseu(
+ uint32_t width, uint32_t height,
+ const uint8_t *rgb, uint32_t rgb_stride,
+ uint8_t *y, uint8_t *u, uint8_t *v, uint32_t y_stride, uint32_t uv_stride,
+ YCbCrType yuv_type);
+
diff --git a/src/video/yuv2rgb/yuv_rgb_sse_func.h b/src/video/yuv2rgb/yuv_rgb_sse_func.h
new file mode 100644
index 000000000..0fe28a8ac
--- /dev/null
+++ b/src/video/yuv2rgb/yuv_rgb_sse_func.h
@@ -0,0 +1,498 @@
+// Copyright 2016 Adrien Descamps
+// Distributed under BSD 3-Clause License
+
+/* You need to define the following macros before including this file:
+ SSE_FUNCTION_NAME
+ STD_FUNCTION_NAME
+ YUV_FORMAT
+ RGB_FORMAT
+*/
+/* You may define the following macro, which affects generated code:
+ SSE_ALIGNED
+*/
+
+#ifdef SSE_ALIGNED
+/* Unaligned instructions seem faster, even on aligned data? */
+/*
+#define LOAD_SI128 _mm_load_si128
+#define SAVE_SI128 _mm_stream_si128
+*/
+#define LOAD_SI128 _mm_loadu_si128
+#define SAVE_SI128 _mm_storeu_si128
+#else
+#define LOAD_SI128 _mm_loadu_si128
+#define SAVE_SI128 _mm_storeu_si128
+#endif
+
+#define UV2RGB_16(U,V,R1,G1,B1,R2,G2,B2) \
+ r_tmp = _mm_mullo_epi16(V, _mm_set1_epi16(param->v_r_factor)); \
+ g_tmp = _mm_add_epi16( \
+ _mm_mullo_epi16(U, _mm_set1_epi16(param->u_g_factor)), \
+ _mm_mullo_epi16(V, _mm_set1_epi16(param->v_g_factor))); \
+ b_tmp = _mm_mullo_epi16(U, _mm_set1_epi16(param->u_b_factor)); \
+ R1 = _mm_unpacklo_epi16(r_tmp, r_tmp); \
+ G1 = _mm_unpacklo_epi16(g_tmp, g_tmp); \
+ B1 = _mm_unpacklo_epi16(b_tmp, b_tmp); \
+ R2 = _mm_unpackhi_epi16(r_tmp, r_tmp); \
+ G2 = _mm_unpackhi_epi16(g_tmp, g_tmp); \
+ B2 = _mm_unpackhi_epi16(b_tmp, b_tmp); \
+
+#define ADD_Y2RGB_16(Y1,Y2,R1,G1,B1,R2,G2,B2) \
+ Y1 = _mm_mullo_epi16(_mm_sub_epi16(Y1, _mm_set1_epi16(param->y_shift)), _mm_set1_epi16(param->y_factor)); \
+ Y2 = _mm_mullo_epi16(_mm_sub_epi16(Y2, _mm_set1_epi16(param->y_shift)), _mm_set1_epi16(param->y_factor)); \
+ \
+ R1 = _mm_srai_epi16(_mm_add_epi16(R1, Y1), PRECISION); \
+ G1 = _mm_srai_epi16(_mm_add_epi16(G1, Y1), PRECISION); \
+ B1 = _mm_srai_epi16(_mm_add_epi16(B1, Y1), PRECISION); \
+ R2 = _mm_srai_epi16(_mm_add_epi16(R2, Y2), PRECISION); \
+ G2 = _mm_srai_epi16(_mm_add_epi16(G2, Y2), PRECISION); \
+ B2 = _mm_srai_epi16(_mm_add_epi16(B2, Y2), PRECISION); \
+
+#define PACK_RGB565_32(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4) \
+{ \
+ __m128i red_mask, tmp1, tmp2, tmp3, tmp4; \
+\
+ red_mask = _mm_set1_epi16(0xF800); \
+ RGB1 = _mm_and_si128(_mm_unpacklo_epi8(_mm_setzero_si128(), R1), red_mask); \
+ RGB2 = _mm_and_si128(_mm_unpackhi_epi8(_mm_setzero_si128(), R1), red_mask); \
+ RGB3 = _mm_and_si128(_mm_unpacklo_epi8(_mm_setzero_si128(), R2), red_mask); \
+ RGB4 = _mm_and_si128(_mm_unpackhi_epi8(_mm_setzero_si128(), R2), red_mask); \
+ tmp1 = _mm_slli_epi16(_mm_srli_epi16(_mm_unpacklo_epi8(G1, _mm_setzero_si128()), 2), 5); \
+ tmp2 = _mm_slli_epi16(_mm_srli_epi16(_mm_unpackhi_epi8(G1, _mm_setzero_si128()), 2), 5); \
+ tmp3 = _mm_slli_epi16(_mm_srli_epi16(_mm_unpacklo_epi8(G2, _mm_setzero_si128()), 2), 5); \
+ tmp4 = _mm_slli_epi16(_mm_srli_epi16(_mm_unpackhi_epi8(G2, _mm_setzero_si128()), 2), 5); \
+ RGB1 = _mm_or_si128(RGB1, tmp1); \
+ RGB2 = _mm_or_si128(RGB2, tmp2); \
+ RGB3 = _mm_or_si128(RGB3, tmp3); \
+ RGB4 = _mm_or_si128(RGB4, tmp4); \
+ tmp1 = _mm_srli_epi16(_mm_unpacklo_epi8(B1, _mm_setzero_si128()), 3); \
+ tmp2 = _mm_srli_epi16(_mm_unpackhi_epi8(B1, _mm_setzero_si128()), 3); \
+ tmp3 = _mm_srli_epi16(_mm_unpacklo_epi8(B2, _mm_setzero_si128()), 3); \
+ tmp4 = _mm_srli_epi16(_mm_unpackhi_epi8(B2, _mm_setzero_si128()), 3); \
+ RGB1 = _mm_or_si128(RGB1, tmp1); \
+ RGB2 = _mm_or_si128(RGB2, tmp2); \
+ RGB3 = _mm_or_si128(RGB3, tmp3); \
+ RGB4 = _mm_or_si128(RGB4, tmp4); \
+}
+
+#define PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
+RGB1 = _mm_packus_epi16(_mm_and_si128(R1,_mm_set1_epi16(0xFF)), _mm_and_si128(R2,_mm_set1_epi16(0xFF))); \
+RGB2 = _mm_packus_epi16(_mm_and_si128(G1,_mm_set1_epi16(0xFF)), _mm_and_si128(G2,_mm_set1_epi16(0xFF))); \
+RGB3 = _mm_packus_epi16(_mm_and_si128(B1,_mm_set1_epi16(0xFF)), _mm_and_si128(B2,_mm_set1_epi16(0xFF))); \
+RGB4 = _mm_packus_epi16(_mm_srli_epi16(R1,8), _mm_srli_epi16(R2,8)); \
+RGB5 = _mm_packus_epi16(_mm_srli_epi16(G1,8), _mm_srli_epi16(G2,8)); \
+RGB6 = _mm_packus_epi16(_mm_srli_epi16(B1,8), _mm_srli_epi16(B2,8)); \
+
+#define PACK_RGB24_32_STEP2(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
+R1 = _mm_packus_epi16(_mm_and_si128(RGB1,_mm_set1_epi16(0xFF)), _mm_and_si128(RGB2,_mm_set1_epi16(0xFF))); \
+R2 = _mm_packus_epi16(_mm_and_si128(RGB3,_mm_set1_epi16(0xFF)), _mm_and_si128(RGB4,_mm_set1_epi16(0xFF))); \
+G1 = _mm_packus_epi16(_mm_and_si128(RGB5,_mm_set1_epi16(0xFF)), _mm_and_si128(RGB6,_mm_set1_epi16(0xFF))); \
+G2 = _mm_packus_epi16(_mm_srli_epi16(RGB1,8), _mm_srli_epi16(RGB2,8)); \
+B1 = _mm_packus_epi16(_mm_srli_epi16(RGB3,8), _mm_srli_epi16(RGB4,8)); \
+B2 = _mm_packus_epi16(_mm_srli_epi16(RGB5,8), _mm_srli_epi16(RGB6,8)); \
+
+#define PACK_RGB24_32(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
+PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
+PACK_RGB24_32_STEP2(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
+PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
+PACK_RGB24_32_STEP2(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
+PACK_RGB24_32_STEP1(R1, R2, G1, G2, B1, B2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6) \
+
+#define PACK_RGBA_32(R1, R2, G1, G2, B1, B2, A1, A2, RGB1, RGB2, RGB3, RGB4, RGB5, RGB6, RGB7, RGB8) \
+{ \
+ __m128i lo_ab, hi_ab, lo_gr, hi_gr; \
+\
+ lo_ab = _mm_unpacklo_epi8( A1, B1 ); \
+ hi_ab = _mm_unpackhi_epi8( A1, B1 ); \
+ lo_gr = _mm_unpacklo_epi8( G1, R1 ); \
+ hi_gr = _mm_unpackhi_epi8( G1, R1 ); \
+ RGB1 = _mm_unpacklo_epi16( lo_ab, lo_gr ); \
+ RGB2 = _mm_unpackhi_epi16( lo_ab, lo_gr ); \
+ RGB3 = _mm_unpacklo_epi16( hi_ab, hi_gr ); \
+ RGB4 = _mm_unpackhi_epi16( hi_ab, hi_gr ); \
+\
+ lo_ab = _mm_unpacklo_epi8( A2, B2 ); \
+ hi_ab = _mm_unpackhi_epi8( A2, B2 ); \
+ lo_gr = _mm_unpacklo_epi8( G2, R2 ); \
+ hi_gr = _mm_unpackhi_epi8( G2, R2 ); \
+ RGB5 = _mm_unpacklo_epi16( lo_ab, lo_gr ); \
+ RGB6 = _mm_unpackhi_epi16( lo_ab, lo_gr ); \
+ RGB7 = _mm_unpacklo_epi16( hi_ab, hi_gr ); \
+ RGB8 = _mm_unpackhi_epi16( hi_ab, hi_gr ); \
+}
+
+#if RGB_FORMAT == RGB_FORMAT_RGB565
+
+#define PACK_PIXEL \
+ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
+ \
+ PACK_RGB565_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, rgb_1, rgb_2, rgb_3, rgb_4) \
+ \
+ PACK_RGB565_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, rgb_5, rgb_6, rgb_7, rgb_8) \
+
+#elif RGB_FORMAT == RGB_FORMAT_RGB24
+
+#define PACK_PIXEL \
+ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6; \
+ __m128i rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12; \
+ \
+ PACK_RGB24_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6) \
+ \
+ PACK_RGB24_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, rgb_7, rgb_8, rgb_9, rgb_10, rgb_11, rgb_12) \
+
+#elif RGB_FORMAT == RGB_FORMAT_RGBA
+
+#define PACK_PIXEL \
+ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
+ __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \
+ __m128i a = _mm_set1_epi8( 0xFF ); \
+ \
+ PACK_RGBA_32(r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, a, a, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \
+ \
+ PACK_RGBA_32(r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, a, a, rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \
+
+#elif RGB_FORMAT == RGB_FORMAT_BGRA
+
+#define PACK_PIXEL \
+ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
+ __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \
+ __m128i a = _mm_set1_epi8( 0xFF ); \
+ \
+ PACK_RGBA_32(b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, a, a, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \
+ \
+ PACK_RGBA_32(b_8_21, b_8_22, g_8_21, g_8_22, r_8_21, r_8_22, a, a, rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \
+
+#elif RGB_FORMAT == RGB_FORMAT_ARGB
+
+#define PACK_PIXEL \
+ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
+ __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \
+ __m128i a = _mm_set1_epi8( 0xFF ); \
+ \
+ PACK_RGBA_32(a, a, r_8_11, r_8_12, g_8_11, g_8_12, b_8_11, b_8_12, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \
+ \
+ PACK_RGBA_32(a, a, r_8_21, r_8_22, g_8_21, g_8_22, b_8_21, b_8_22, rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \
+
+#elif RGB_FORMAT == RGB_FORMAT_ABGR
+
+#define PACK_PIXEL \
+ __m128i rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8; \
+ __m128i rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16; \
+ __m128i a = _mm_set1_epi8( 0xFF ); \
+ \
+ PACK_RGBA_32(a, a, b_8_11, b_8_12, g_8_11, g_8_12, r_8_11, r_8_12, rgb_1, rgb_2, rgb_3, rgb_4, rgb_5, rgb_6, rgb_7, rgb_8) \
+ \
+ PACK_RGBA_32(a, a, b_8_21, b_8_22, g_8_21, g_8_22, r_8_21, r_8_22, rgb_9, rgb_10, rgb_11, rgb_12, rgb_13, rgb_14, rgb_15, rgb_16) \
+
+#else
+#error PACK_PIXEL unimplemented
+#endif
+
+#if RGB_FORMAT == RGB_FORMAT_RGB565
+
+#define SAVE_LINE1 \
+ SAVE_SI128((__m128i*)(rgb_ptr1), rgb_1); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+16), rgb_2); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+32), rgb_3); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+48), rgb_4); \
+
+#define SAVE_LINE2 \
+ SAVE_SI128((__m128i*)(rgb_ptr2), rgb_5); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+16), rgb_6); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+32), rgb_7); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+48), rgb_8); \
+
+#elif RGB_FORMAT == RGB_FORMAT_RGB24
+
+#define SAVE_LINE1 \
+ SAVE_SI128((__m128i*)(rgb_ptr1), rgb_1); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+16), rgb_2); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+32), rgb_3); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+48), rgb_4); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+64), rgb_5); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+80), rgb_6); \
+
+#define SAVE_LINE2 \
+ SAVE_SI128((__m128i*)(rgb_ptr2), rgb_7); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+16), rgb_8); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+32), rgb_9); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+48), rgb_10); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+64), rgb_11); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+80), rgb_12); \
+
+#elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT == RGB_FORMAT_BGRA || \
+ RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT == RGB_FORMAT_ABGR
+
+#define SAVE_LINE1 \
+ SAVE_SI128((__m128i*)(rgb_ptr1), rgb_1); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+16), rgb_2); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+32), rgb_3); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+48), rgb_4); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+64), rgb_5); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+80), rgb_6); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+96), rgb_7); \
+ SAVE_SI128((__m128i*)(rgb_ptr1+112), rgb_8); \
+
+#define SAVE_LINE2 \
+ SAVE_SI128((__m128i*)(rgb_ptr2), rgb_9); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+16), rgb_10); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+32), rgb_11); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+48), rgb_12); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+64), rgb_13); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+80), rgb_14); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+96), rgb_15); \
+ SAVE_SI128((__m128i*)(rgb_ptr2+112), rgb_16); \
+
+#else
+#error SAVE_LINE unimplemented
+#endif
+
+#if YUV_FORMAT == YUV_FORMAT_420
+
+#define READ_Y(y_ptr) \
+ y = LOAD_SI128((const __m128i*)(y_ptr)); \
+
+#define READ_UV \
+ u = LOAD_SI128((const __m128i*)(u_ptr)); \
+ v = LOAD_SI128((const __m128i*)(v_ptr)); \
+
+#elif YUV_FORMAT == YUV_FORMAT_422
+
+#define READ_Y(y_ptr) \
+{ \
+ __m128i y1, y2; \
+ y1 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(y_ptr)), 8), 8); \
+ y2 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(y_ptr+16)), 8), 8); \
+ y = _mm_packus_epi16(y1, y2); \
+}
+
+#define READ_UV \
+{ \
+ __m128i u1, u2, u3, u4, v1, v2, v3, v4; \
+ u1 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(u_ptr)), 24), 24); \
+ u2 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(u_ptr+16)), 24), 24); \
+ u3 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(u_ptr+32)), 24), 24); \
+ u4 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(u_ptr+48)), 24), 24); \
+ u = _mm_packus_epi16(_mm_packs_epi32(u1, u2), _mm_packs_epi32(u3, u4)); \
+ v1 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(v_ptr)), 24), 24); \
+ v2 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(v_ptr+16)), 24), 24); \
+ v3 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(v_ptr+32)), 24), 24); \
+ v4 = _mm_srli_epi32(_mm_slli_epi32(LOAD_SI128((const __m128i*)(v_ptr+48)), 24), 24); \
+ v = _mm_packus_epi16(_mm_packs_epi32(v1, v2), _mm_packs_epi32(v3, v4)); \
+}
+
+#elif YUV_FORMAT == YUV_FORMAT_NV12
+
+#define READ_Y(y_ptr) \
+ y = LOAD_SI128((const __m128i*)(y_ptr)); \
+
+#define READ_UV \
+{ \
+ __m128i u1, u2, v1, v2; \
+ u1 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(u_ptr)), 8), 8); \
+ u2 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(u_ptr+16)), 8), 8); \
+ u = _mm_packus_epi16(u1, u2); \
+ v1 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(v_ptr)), 8), 8); \
+ v2 = _mm_srli_epi16(_mm_slli_epi16(LOAD_SI128((const __m128i*)(v_ptr+16)), 8), 8); \
+ v = _mm_packus_epi16(v1, v2); \
+}
+
+#else
+#error READ_UV unimplemented
+#endif
+
+#define YUV2RGB_32 \
+ __m128i r_tmp, g_tmp, b_tmp; \
+ __m128i r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2; \
+ __m128i r_uv_16_1, g_uv_16_1, b_uv_16_1, r_uv_16_2, g_uv_16_2, b_uv_16_2; \
+ __m128i y_16_1, y_16_2; \
+ __m128i y, u, v, u_16, v_16; \
+ __m128i r_8_11, g_8_11, b_8_11, r_8_21, g_8_21, b_8_21; \
+ __m128i r_8_12, g_8_12, b_8_12, r_8_22, g_8_22, b_8_22; \
+ \
+ READ_UV \
+ \
+ /* process first 16 pixels of first line */\
+ u_16 = _mm_unpacklo_epi8(u, _mm_setzero_si128()); \
+ v_16 = _mm_unpacklo_epi8(v, _mm_setzero_si128()); \
+ u_16 = _mm_add_epi16(u_16, _mm_set1_epi16(-128)); \
+ v_16 = _mm_add_epi16(v_16, _mm_set1_epi16(-128)); \
+ \
+ UV2RGB_16(u_16, v_16, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \
+ r_uv_16_1=r_16_1; g_uv_16_1=g_16_1; b_uv_16_1=b_16_1; \
+ r_uv_16_2=r_16_2; g_uv_16_2=g_16_2; b_uv_16_2=b_16_2; \
+ \
+ READ_Y(y_ptr1) \
+ y_16_1 = _mm_unpacklo_epi8(y, _mm_setzero_si128()); \
+ y_16_2 = _mm_unpackhi_epi8(y, _mm_setzero_si128()); \
+ \
+ ADD_Y2RGB_16(y_16_1, y_16_2, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \
+ \
+ r_8_11 = _mm_packus_epi16(r_16_1, r_16_2); \
+ g_8_11 = _mm_packus_epi16(g_16_1, g_16_2); \
+ b_8_11 = _mm_packus_epi16(b_16_1, b_16_2); \
+ \
+ /* process first 16 pixels of second line */\
+ r_16_1=r_uv_16_1; g_16_1=g_uv_16_1; b_16_1=b_uv_16_1; \
+ r_16_2=r_uv_16_2; g_16_2=g_uv_16_2; b_16_2=b_uv_16_2; \
+ \
+ READ_Y(y_ptr2) \
+ y_16_1 = _mm_unpacklo_epi8(y, _mm_setzero_si128()); \
+ y_16_2 = _mm_unpackhi_epi8(y, _mm_setzero_si128()); \
+ \
+ ADD_Y2RGB_16(y_16_1, y_16_2, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \
+ \
+ r_8_21 = _mm_packus_epi16(r_16_1, r_16_2); \
+ g_8_21 = _mm_packus_epi16(g_16_1, g_16_2); \
+ b_8_21 = _mm_packus_epi16(b_16_1, b_16_2); \
+ \
+ /* process last 16 pixels of first line */\
+ u_16 = _mm_unpackhi_epi8(u, _mm_setzero_si128()); \
+ v_16 = _mm_unpackhi_epi8(v, _mm_setzero_si128()); \
+ u_16 = _mm_add_epi16(u_16, _mm_set1_epi16(-128)); \
+ v_16 = _mm_add_epi16(v_16, _mm_set1_epi16(-128)); \
+ \
+ UV2RGB_16(u_16, v_16, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \
+ r_uv_16_1=r_16_1; g_uv_16_1=g_16_1; b_uv_16_1=b_16_1; \
+ r_uv_16_2=r_16_2; g_uv_16_2=g_16_2; b_uv_16_2=b_16_2; \
+ \
+ READ_Y(y_ptr1+16*y_pixel_stride) \
+ y_16_1 = _mm_unpacklo_epi8(y, _mm_setzero_si128()); \
+ y_16_2 = _mm_unpackhi_epi8(y, _mm_setzero_si128()); \
+ \
+ ADD_Y2RGB_16(y_16_1, y_16_2, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \
+ \
+ r_8_12 = _mm_packus_epi16(r_16_1, r_16_2); \
+ g_8_12 = _mm_packus_epi16(g_16_1, g_16_2); \
+ b_8_12 = _mm_packus_epi16(b_16_1, b_16_2); \
+ \
+ /* process last 16 pixels of second line */\
+ r_16_1=r_uv_16_1; g_16_1=g_uv_16_1; b_16_1=b_uv_16_1; \
+ r_16_2=r_uv_16_2; g_16_2=g_uv_16_2; b_16_2=b_uv_16_2; \
+ \
+ READ_Y(y_ptr2+16*y_pixel_stride) \
+ y_16_1 = _mm_unpacklo_epi8(y, _mm_setzero_si128()); \
+ y_16_2 = _mm_unpackhi_epi8(y, _mm_setzero_si128()); \
+ \
+ ADD_Y2RGB_16(y_16_1, y_16_2, r_16_1, g_16_1, b_16_1, r_16_2, g_16_2, b_16_2) \
+ \
+ r_8_22 = _mm_packus_epi16(r_16_1, r_16_2); \
+ g_8_22 = _mm_packus_epi16(g_16_1, g_16_2); \
+ b_8_22 = _mm_packus_epi16(b_16_1, b_16_2); \
+ \
+
+
+void SSE_FUNCTION_NAME(uint32_t width, uint32_t height,
+ const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride,
+ uint8_t *RGB, uint32_t RGB_stride,
+ YCbCrType yuv_type)
+{
+ const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]);
+#if YUV_FORMAT == YUV_FORMAT_420
+ const int y_pixel_stride = 1;
+ const int uv_pixel_stride = 1;
+ const int uv_x_sample_interval = 2;
+ const int uv_y_sample_interval = 2;
+#elif YUV_FORMAT == YUV_FORMAT_422
+ const int y_pixel_stride = 2;
+ const int uv_pixel_stride = 4;
+ const int uv_x_sample_interval = 2;
+ const int uv_y_sample_interval = 1;
+#elif YUV_FORMAT == YUV_FORMAT_NV12
+ const int y_pixel_stride = 1;
+ const int uv_pixel_stride = 2;
+ const int uv_x_sample_interval = 2;
+ const int uv_y_sample_interval = 2;
+#endif
+#if RGB_FORMAT == RGB_FORMAT_RGB565
+ const int rgb_pixel_stride = 2;
+#elif RGB_FORMAT == RGB_FORMAT_RGB24
+ const int rgb_pixel_stride = 3;
+#elif RGB_FORMAT == RGB_FORMAT_RGBA || RGB_FORMAT == RGB_FORMAT_BGRA || \
+ RGB_FORMAT == RGB_FORMAT_ARGB || RGB_FORMAT == RGB_FORMAT_ABGR
+ const int rgb_pixel_stride = 4;
+#else
+#error Unknown RGB pixel size
+#endif
+
+ if (width >= 32) {
+ uint32_t x, y;
+ for(y=0; y<(height-(uv_y_sample_interval-1)); y+=uv_y_sample_interval)
+ {
+ const uint8_t *y_ptr1=Y+y*Y_stride,
+ *y_ptr2=Y+(y+1)*Y_stride,
+ *u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
+ *v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
+
+ uint8_t *rgb_ptr1=RGB+y*RGB_stride,
+ *rgb_ptr2=RGB+(y+1)*RGB_stride;
+
+ for(x=0; x<(width-31); x+=32)
+ {
+ YUV2RGB_32
+ {
+ PACK_PIXEL
+ SAVE_LINE1
+ if (uv_y_sample_interval > 1)
+ {
+ SAVE_LINE2
+ }
+ }
+
+ y_ptr1+=32*y_pixel_stride;
+ y_ptr2+=32*y_pixel_stride;
+ u_ptr+=32*uv_pixel_stride/uv_x_sample_interval;
+ v_ptr+=32*uv_pixel_stride/uv_x_sample_interval;
+ rgb_ptr1+=32*rgb_pixel_stride;
+ rgb_ptr2+=32*rgb_pixel_stride;
+ }
+ }
+
+ /* Catch the last line, if needed */
+ if (uv_y_sample_interval == 2 && y == (height-1))
+ {
+ const uint8_t *y_ptr=Y+y*Y_stride,
+ *u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
+ *v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
+
+ uint8_t *rgb_ptr=RGB+y*RGB_stride;
+
+ STD_FUNCTION_NAME(width, 1, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type);
+ }
+ }
+
+ /* Catch the right column, if needed */
+ {
+ int converted = (width & ~31);
+ if (converted != width)
+ {
+ const uint8_t *y_ptr=Y+converted*y_pixel_stride,
+ *u_ptr=U+converted*uv_pixel_stride/uv_x_sample_interval,
+ *v_ptr=V+converted*uv_pixel_stride/uv_x_sample_interval;
+
+ uint8_t *rgb_ptr=RGB+converted*rgb_pixel_stride;
+
+ STD_FUNCTION_NAME(width-converted, height, y_ptr, u_ptr, v_ptr, Y_stride, UV_stride, rgb_ptr, RGB_stride, yuv_type);
+ }
+ }
+}
+
+#undef SSE_FUNCTION_NAME
+#undef STD_FUNCTION_NAME
+#undef YUV_FORMAT
+#undef RGB_FORMAT
+#undef SSE_ALIGNED
+#undef LOAD_SI128
+#undef SAVE_SI128
+#undef UV2RGB_16
+#undef ADD_Y2RGB_16
+#undef PACK_RGB24_32_STEP1
+#undef PACK_RGB24_32_STEP2
+#undef PACK_RGB24_32
+#undef PACK_RGBA_32
+#undef PACK_PIXEL
+#undef SAVE_LINE1
+#undef SAVE_LINE2
+#undef READ_Y
+#undef READ_UV
+#undef YUV2RGB_32
diff --git a/src/video/yuv2rgb/yuv_rgb_std_func.h b/src/video/yuv2rgb/yuv_rgb_std_func.h
new file mode 100644
index 000000000..bf4f48eab
--- /dev/null
+++ b/src/video/yuv2rgb/yuv_rgb_std_func.h
@@ -0,0 +1,220 @@
+// Copyright 2016 Adrien Descamps
+// Distributed under BSD 3-Clause License
+
+/* You need to define the following macros before including this file:
+ STD_FUNCTION_NAME
+ YUV_FORMAT
+ RGB_FORMAT
+*/
+
+#if RGB_FORMAT == RGB_FORMAT_RGB565
+
+#define PACK_PIXEL(rgb_ptr) \
+ *(Uint16 *)rgb_ptr = \
+ ((((Uint16)clampU8(y_tmp+r_tmp)) << 8 ) & 0xF800) | \
+ ((((Uint16)clampU8(y_tmp+g_tmp)) << 3) & 0x07E0) | \
+ (((Uint16)clampU8(y_tmp+b_tmp)) >> 3); \
+ rgb_ptr += 2; \
+
+#elif RGB_FORMAT == RGB_FORMAT_RGB24
+
+#define PACK_PIXEL(rgb_ptr) \
+ rgb_ptr[0] = clampU8(y_tmp+r_tmp); \
+ rgb_ptr[1] = clampU8(y_tmp+g_tmp); \
+ rgb_ptr[2] = clampU8(y_tmp+b_tmp); \
+ rgb_ptr += 3; \
+
+#elif RGB_FORMAT == RGB_FORMAT_RGBA
+
+#define PACK_PIXEL(rgb_ptr) \
+ *(Uint32 *)rgb_ptr = \
+ (((Uint32)clampU8(y_tmp+r_tmp)) << 24) | \
+ (((Uint32)clampU8(y_tmp+g_tmp)) << 16) | \
+ (((Uint32)clampU8(y_tmp+b_tmp)) << 8) | \
+ 0x000000FF; \
+ rgb_ptr += 4; \
+
+#elif RGB_FORMAT == RGB_FORMAT_BGRA
+
+#define PACK_PIXEL(rgb_ptr) \
+ *(Uint32 *)rgb_ptr = \
+ (((Uint32)clampU8(y_tmp+b_tmp)) << 24) | \
+ (((Uint32)clampU8(y_tmp+g_tmp)) << 16) | \
+ (((Uint32)clampU8(y_tmp+r_tmp)) << 8) | \
+ 0x000000FF; \
+ rgb_ptr += 4; \
+
+#elif RGB_FORMAT == RGB_FORMAT_ARGB
+
+#define PACK_PIXEL(rgb_ptr) \
+ *(Uint32 *)rgb_ptr = \
+ 0xFF000000 | \
+ (((Uint32)clampU8(y_tmp+r_tmp)) << 16) | \
+ (((Uint32)clampU8(y_tmp+g_tmp)) << 8) | \
+ (((Uint32)clampU8(y_tmp+b_tmp)) << 0); \
+ rgb_ptr += 4; \
+
+#elif RGB_FORMAT == RGB_FORMAT_ABGR
+
+#define PACK_PIXEL(rgb_ptr) \
+ *(Uint32 *)rgb_ptr = \
+ 0xFF000000 | \
+ (((Uint32)clampU8(y_tmp+b_tmp)) << 16) | \
+ (((Uint32)clampU8(y_tmp+g_tmp)) << 8) | \
+ (((Uint32)clampU8(y_tmp+r_tmp)) << 0); \
+ rgb_ptr += 4; \
+
+#else
+#error PACK_PIXEL unimplemented
+#endif
+
+
+void STD_FUNCTION_NAME(
+ uint32_t width, uint32_t height,
+ const uint8_t *Y, const uint8_t *U, const uint8_t *V, uint32_t Y_stride, uint32_t UV_stride,
+ uint8_t *RGB, uint32_t RGB_stride,
+ YCbCrType yuv_type)
+{
+ const YUV2RGBParam *const param = &(YUV2RGB[yuv_type]);
+#if YUV_FORMAT == YUV_FORMAT_420
+ const int y_pixel_stride = 1;
+ const int uv_pixel_stride = 1;
+ const int uv_x_sample_interval = 2;
+ const int uv_y_sample_interval = 2;
+#elif YUV_FORMAT == YUV_FORMAT_422
+ const int y_pixel_stride = 2;
+ const int uv_pixel_stride = 4;
+ const int uv_x_sample_interval = 2;
+ const int uv_y_sample_interval = 1;
+#elif YUV_FORMAT == YUV_FORMAT_NV12
+ const int y_pixel_stride = 1;
+ const int uv_pixel_stride = 2;
+ const int uv_x_sample_interval = 2;
+ const int uv_y_sample_interval = 2;
+#endif
+
+ uint32_t x, y;
+ for(y=0; y<(height-(uv_y_sample_interval-1)); y+=uv_y_sample_interval)
+ {
+ const uint8_t *y_ptr1=Y+y*Y_stride,
+ *y_ptr2=Y+(y+1)*Y_stride,
+ *u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
+ *v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
+
+ uint8_t *rgb_ptr1=RGB+y*RGB_stride,
+ *rgb_ptr2=RGB+(y+1)*RGB_stride;
+
+ for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval)
+ {
+ // Compute U and V contributions, common to the four pixels
+
+ int32_t u_tmp = ((*u_ptr)-128);
+ int32_t v_tmp = ((*v_ptr)-128);
+
+ int32_t r_tmp = (v_tmp*param->v_r_factor);
+ int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
+ int32_t b_tmp = (u_tmp*param->u_b_factor);
+
+ // Compute the Y contribution for each pixel
+
+ int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr1);
+
+ y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr1);
+
+ if (uv_y_sample_interval > 1) {
+ y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr2);
+
+ y_tmp = ((y_ptr2[y_pixel_stride]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr2);
+ }
+
+ y_ptr1+=2*y_pixel_stride;
+ y_ptr2+=2*y_pixel_stride;
+ u_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
+ v_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
+ }
+
+ /* Catch the last pixel, if needed */
+ if (uv_x_sample_interval == 2 && x == (width-1))
+ {
+ // Compute U and V contributions, common to the four pixels
+
+ int32_t u_tmp = ((*u_ptr)-128);
+ int32_t v_tmp = ((*v_ptr)-128);
+
+ int32_t r_tmp = (v_tmp*param->v_r_factor);
+ int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
+ int32_t b_tmp = (u_tmp*param->u_b_factor);
+
+ // Compute the Y contribution for each pixel
+
+ int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr1);
+
+ if (uv_y_sample_interval > 1) {
+ y_tmp = ((y_ptr2[0]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr2);
+ }
+ }
+ }
+
+ /* Catch the last line, if needed */
+ if (uv_y_sample_interval == 2 && y == (height-1))
+ {
+ const uint8_t *y_ptr1=Y+y*Y_stride,
+ *u_ptr=U+(y/uv_y_sample_interval)*UV_stride,
+ *v_ptr=V+(y/uv_y_sample_interval)*UV_stride;
+
+ uint8_t *rgb_ptr1=RGB+y*RGB_stride;
+
+ for(x=0; x<(width-(uv_x_sample_interval-1)); x+=uv_x_sample_interval)
+ {
+ // Compute U and V contributions, common to the four pixels
+
+ int32_t u_tmp = ((*u_ptr)-128);
+ int32_t v_tmp = ((*v_ptr)-128);
+
+ int32_t r_tmp = (v_tmp*param->v_r_factor);
+ int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
+ int32_t b_tmp = (u_tmp*param->u_b_factor);
+
+ // Compute the Y contribution for each pixel
+
+ int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr1);
+
+ y_tmp = ((y_ptr1[y_pixel_stride]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr1);
+
+ y_ptr1+=2*y_pixel_stride;
+ u_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
+ v_ptr+=2*uv_pixel_stride/uv_x_sample_interval;
+ }
+
+ /* Catch the last pixel, if needed */
+ if (uv_x_sample_interval == 2 && x == (width-1))
+ {
+ // Compute U and V contributions, common to the four pixels
+
+ int32_t u_tmp = ((*u_ptr)-128);
+ int32_t v_tmp = ((*v_ptr)-128);
+
+ int32_t r_tmp = (v_tmp*param->v_r_factor);
+ int32_t g_tmp = (u_tmp*param->u_g_factor + v_tmp*param->v_g_factor);
+ int32_t b_tmp = (u_tmp*param->u_b_factor);
+
+ // Compute the Y contribution for each pixel
+
+ int32_t y_tmp = ((y_ptr1[0]-param->y_shift)*param->y_factor);
+ PACK_PIXEL(rgb_ptr1);
+ }
+ }
+}
+
+#undef STD_FUNCTION_NAME
+#undef YUV_FORMAT
+#undef RGB_FORMAT
+#undef PACK_PIXEL
diff --git a/test/Makefile.in b/test/Makefile.in
index 0ac70e923..c625622aa 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -9,19 +9,23 @@ LIBS = @LIBS@
TARGETS = \
checkkeys$(EXE) \
+ controllermap$(EXE) \
loopwave$(EXE) \
loopwavequeue$(EXE) \
testatomic$(EXE) \
- testaudioinfo$(EXE) \
testaudiocapture$(EXE) \
+ testaudiohotplug$(EXE) \
+ testaudioinfo$(EXE) \
testautomation$(EXE) \
testbounds$(EXE) \
testcustomcursor$(EXE) \
+ testdisplayinfo$(EXE) \
testdraw2$(EXE) \
testdrawchessboard$(EXE) \
testdropfile$(EXE) \
testerror$(EXE) \
testfile$(EXE) \
+ testfilesystem$(EXE) \
testgamecontroller$(EXE) \
testgesture$(EXE) \
testgl2$(EXE) \
@@ -29,26 +33,26 @@ TARGETS = \
testgles2$(EXE) \
testhaptic$(EXE) \
testhittesting$(EXE) \
- testrumble$(EXE) \
testhotplug$(EXE) \
- testthread$(EXE) \
testiconv$(EXE) \
testime$(EXE) \
testintersections$(EXE) \
- testrelative$(EXE) \
testjoystick$(EXE) \
testkeys$(EXE) \
testloadso$(EXE) \
testlock$(EXE) \
+ testmessage$(EXE) \
testmultiaudio$(EXE) \
- testaudiohotplug$(EXE) \
testnative$(EXE) \
testoverlay2$(EXE) \
testplatform$(EXE) \
testpower$(EXE) \
- testfilesystem$(EXE) \
+ testqsort$(EXE) \
+ testrelative$(EXE) \
+ testrendercopyex$(EXE) \
testrendertarget$(EXE) \
testresample$(EXE) \
+ testrumble$(EXE) \
testscale$(EXE) \
testsem$(EXE) \
testshader$(EXE) \
@@ -56,17 +60,14 @@ TARGETS = \
testsprite2$(EXE) \
testspriteminimal$(EXE) \
teststreaming$(EXE) \
+ testthread$(EXE) \
testtimer$(EXE) \
testver$(EXE) \
testviewport$(EXE) \
+ testvulkan$(EXE) \
testwm2$(EXE) \
+ testyuv$(EXE) \
torturethread$(EXE) \
- testrendercopyex$(EXE) \
- testmessage$(EXE) \
- testdisplayinfo$(EXE) \
- testqsort$(EXE) \
- controllermap$(EXE) \
- testvulkan$(EXE) \
all: Makefile $(TARGETS) copydatafiles
@@ -266,6 +267,9 @@ testviewport$(EXE): $(srcdir)/testviewport.c
testwm2$(EXE): $(srcdir)/testwm2.c
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+testyuv$(EXE): $(srcdir)/testyuv.c
+ $(CC) -o $@ $^ $(CFLAGS) $(LIBS)
+
torturethread$(EXE): $(srcdir)/torturethread.c
$(CC) -o $@ $^ $(CFLAGS) $(LIBS)
diff --git a/test/testoverlay2.c b/test/testoverlay2.c
index 2145c4d36..7d01c8564 100644
--- a/test/testoverlay2.c
+++ b/test/testoverlay2.c
@@ -16,16 +16,14 @@
* *
********************************************************************************/
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
#endif
#include "SDL.h"
+#include "testyuv_cvt.h"
+
#define MOOSEPIC_W 64
#define MOOSEPIC_H 88
@@ -149,7 +147,6 @@ SDL_Renderer *renderer;
int paused = 0;
int i;
SDL_bool done = SDL_FALSE;
-Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
static int fpsdelay;
/* Call this instead of exit(), so we can clean up SDL: atexit() is evil. */
@@ -160,91 +157,6 @@ quit(int rc)
exit(rc);
}
-/* All RGB2YUV conversion code and some other parts of code has been taken from testoverlay.c */
-
-/* NOTE: These RGB conversion functions are not intended for speed,
- only as examples.
-*/
-
-void
-RGBtoYUV(Uint8 * rgb, int *yuv, int monochrome, int luminance)
-{
- if (monochrome) {
-#if 1 /* these are the two formulas that I found on the FourCC site... */
- yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
- yuv[1] = 128;
- yuv[2] = 128;
-#else
- yuv[0] = (int)(0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
- yuv[1] = 128;
- yuv[2] = 128;
-#endif
- } else {
-#if 1 /* these are the two formulas that I found on the FourCC site... */
- yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
- yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128);
- yuv[2] = (int)((rgb[0] - yuv[0]) * 0.713 + 128);
-#else
- yuv[0] = (0.257 * rgb[0]) + (0.504 * rgb[1]) + (0.098 * rgb[2]) + 16;
- yuv[1] = 128 - (0.148 * rgb[0]) - (0.291 * rgb[1]) + (0.439 * rgb[2]);
- yuv[2] = 128 + (0.439 * rgb[0]) - (0.368 * rgb[1]) - (0.071 * rgb[2]);
-#endif
- }
-
- if (luminance != 100) {
- yuv[0] = yuv[0] * luminance / 100;
- if (yuv[0] > 255)
- yuv[0] = 255;
- }
-}
-
-void
-ConvertRGBtoYV12(Uint8 *rgb, Uint8 *out, int w, int h,
- int monochrome, int luminance)
-{
- int x, y;
- int yuv[3];
- Uint8 *op[3];
-
- op[0] = out;
- op[1] = op[0] + w*h;
- op[2] = op[1] + w*h/4;
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- RGBtoYUV(rgb, yuv, monochrome, luminance);
- *(op[0]++) = yuv[0];
- if (x % 2 == 0 && y % 2 == 0) {
- *(op[1]++) = yuv[2];
- *(op[2]++) = yuv[1];
- }
- rgb += 3;
- }
- }
-}
-
-void
-ConvertRGBtoNV12(Uint8 *rgb, Uint8 *out, int w, int h,
- int monochrome, int luminance)
-{
- int x, y;
- int yuv[3];
- Uint8 *op[2];
-
- op[0] = out;
- op[1] = op[0] + w*h;
- for (y = 0; y < h; ++y) {
- for (x = 0; x < w; ++x) {
- RGBtoYUV(rgb, yuv, monochrome, luminance);
- *(op[0]++) = yuv[0];
- if (x % 2 == 0 && y % 2 == 0) {
- *(op[1]++) = yuv[1];
- *(op[1]++) = yuv[2];
- }
- rgb += 3;
- }
- }
-}
-
static void
PrintUsage(char *argv0)
{
@@ -307,7 +219,7 @@ loop()
if (!paused) {
i = (i + 1) % MOOSEFRAMES_COUNT;
- SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W*SDL_BYTESPERPIXEL(pixel_format));
+ SDL_UpdateTexture(MooseTexture, NULL, MooseFrame[i], MOOSEPIC_W);
}
SDL_RenderClear(renderer);
SDL_RenderCopy(renderer, MooseTexture, NULL, &displayrect);
@@ -329,11 +241,6 @@ main(int argc, char **argv)
int j;
int fps = 12;
int nodelay = 0;
-#ifdef TEST_NV12
- Uint32 pixel_format = SDL_PIXELFORMAT_NV12;
-#else
- Uint32 pixel_format = SDL_PIXELFORMAT_YV12;
-#endif
int scale = 5;
/* Enable standard application logging */
@@ -439,7 +346,7 @@ main(int argc, char **argv)
quit(4);
}
- MooseTexture = SDL_CreateTexture(renderer, pixel_format, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
+ MooseTexture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_YV12, SDL_TEXTUREACCESS_STREAMING, MOOSEPIC_W, MOOSEPIC_H);
if (!MooseTexture) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
free(RawMooseData);
@@ -461,17 +368,9 @@ main(int argc, char **argv)
rgb[2] = MooseColors[frame[j]].b;
rgb += 3;
}
- switch (pixel_format) {
- case SDL_PIXELFORMAT_YV12:
- ConvertRGBtoYV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
- break;
- case SDL_PIXELFORMAT_NV12:
- ConvertRGBtoNV12(MooseFrameRGB, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H, 0, 100);
- break;
- default:
- SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Unsupported pixel format\n");
- break;
- }
+ ConvertRGBtoYUV(SDL_PIXELFORMAT_YV12, MooseFrameRGB, MOOSEPIC_W*3, MooseFrame[i], MOOSEPIC_W, MOOSEPIC_H,
+ SDL_GetYUVConversionModeForResolution(MOOSEPIC_W, MOOSEPIC_H),
+ 0, 100);
}
free(RawMooseData);
diff --git a/test/testyuv.bmp b/test/testyuv.bmp
new file mode 100644
index 000000000..af32034b6
--- /dev/null
+++ b/test/testyuv.bmp
Binary files differ
diff --git a/test/testyuv.c b/test/testyuv.c
new file mode 100644
index 000000000..a4071d4c7
--- /dev/null
+++ b/test/testyuv.c
@@ -0,0 +1,455 @@
+/*
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
+*/
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "SDL.h"
+#include "SDL_test_font.h"
+#include "testyuv_cvt.h"
+
+
+/* 422 (YUY2, etc) formats are the largest */
+#define MAX_YUV_SURFACE_SIZE(W, H, P) (H*4*(W+P+1)/2)
+
+
+/* Return true if the YUV format is packed pixels */
+static SDL_bool is_packed_yuv_format(Uint32 format)
+{
+ return (format == SDL_PIXELFORMAT_YUY2 ||
+ format == SDL_PIXELFORMAT_UYVY ||
+ format == SDL_PIXELFORMAT_YVYU);
+}
+
+/* Create a surface with a good pattern for verifying YUV conversion */
+static SDL_Surface *generate_test_pattern(int pattern_size)
+{
+ SDL_Surface *pattern = SDL_CreateRGBSurfaceWithFormat(0, pattern_size, pattern_size, 0, SDL_PIXELFORMAT_RGB24);
+
+ if (pattern) {
+ int i, x, y;
+ Uint8 *p, c;
+ const int thickness = 2; /* Important so 2x2 blocks of color are the same, to avoid Cr/Cb interpolation over pixels */
+
+ /* R, G, B in alternating horizontal bands */
+ for (y = 0; y < pattern->h; y += thickness) {
+ for (i = 0; i < thickness; ++i) {
+ p = (Uint8 *)pattern->pixels + (y + i) * pattern->pitch + ((y/thickness) % 3);
+ for (x = 0; x < pattern->w; ++x) {
+ *p = 0xFF;
+ p += 3;
+ }
+ }
+ }
+
+ /* Black and white in alternating vertical bands */
+ c = 0xFF;
+ for (x = 1*thickness; x < pattern->w; x += 2*thickness) {
+ for (i = 0; i < thickness; ++i) {
+ p = (Uint8 *)pattern->pixels + (x + i)*3;
+ for (y = 0; y < pattern->h; ++y) {
+ SDL_memset(p, c, 3);
+ p += pattern->pitch;
+ }
+ }
+ if (c) {
+ c = 0x00;
+ } else {
+ c = 0xFF;
+ }
+ }
+ }
+ return pattern;
+}
+
+static SDL_bool verify_yuv_data(Uint32 format, const Uint8 *yuv, int yuv_pitch, SDL_Surface *surface)
+{
+ const int tolerance = 20;
+ const int size = (surface->h * surface->pitch);
+ Uint8 *rgb;
+ SDL_bool result = SDL_FALSE;
+
+ rgb = (Uint8 *)SDL_malloc(size);
+ if (!rgb) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory");
+ return SDL_FALSE;
+ }
+
+ if (SDL_ConvertPixels(surface->w, surface->h, format, yuv, yuv_pitch, surface->format->format, rgb, surface->pitch) == 0) {
+ int x, y;
+ result = SDL_TRUE;
+ for (y = 0; y < surface->h; ++y) {
+ const Uint8 *actual = rgb + y * surface->pitch;
+ const Uint8 *expected = (const Uint8 *)surface->pixels + y * surface->pitch;
+ for (x = 0; x < surface->w; ++x) {
+ int deltaR = (int)actual[0] - expected[0];
+ int deltaG = (int)actual[1] - expected[1];
+ int deltaB = (int)actual[2] - expected[2];
+ int distance = (deltaR * deltaR + deltaG * deltaG + deltaB * deltaB);
+ if (distance > tolerance) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Pixel at %d,%d was 0x%.2x,0x%.2x,0x%.2x, expected 0x%.2x,0x%.2x,0x%.2x, distance = %d\n", x, y, actual[0], actual[1], actual[2], expected[0], expected[1], expected[2], distance);
+ result = SDL_FALSE;
+ }
+ actual += 3;
+ expected += 3;
+ }
+ }
+ } else {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(format), SDL_GetPixelFormatName(surface->format->format), SDL_GetError());
+ }
+ SDL_free(rgb);
+
+ return result;
+}
+
+static int run_automated_tests(int pattern_size, int extra_pitch)
+{
+ const Uint32 formats[] = {
+ SDL_PIXELFORMAT_YV12,
+ SDL_PIXELFORMAT_IYUV,
+ SDL_PIXELFORMAT_NV12,
+ SDL_PIXELFORMAT_NV21,
+ SDL_PIXELFORMAT_YUY2,
+ SDL_PIXELFORMAT_UYVY,
+ SDL_PIXELFORMAT_YVYU
+ };
+ int i, j;
+ SDL_Surface *pattern = generate_test_pattern(pattern_size);
+ const int yuv_len = MAX_YUV_SURFACE_SIZE(pattern->w, pattern->h, extra_pitch);
+ Uint8 *yuv1 = (Uint8 *)SDL_malloc(yuv_len);
+ Uint8 *yuv2 = (Uint8 *)SDL_malloc(yuv_len);
+ int yuv1_pitch, yuv2_pitch;
+ int result = -1;
+
+ if (!pattern || !yuv1 || !yuv2) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't allocate test surfaces");
+ goto done;
+ }
+
+ /* Verify conversion from YUV formats */
+ for (i = 0; i < SDL_arraysize(formats); ++i) {
+ if (!ConvertRGBtoYUV(formats[i], pattern->pixels, pattern->pitch, yuv1, pattern->w, pattern->h, SDL_GetYUVConversionModeForResolution(pattern->w, pattern->h), 0, 100)) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "ConvertRGBtoYUV() doesn't support converting to %s\n", SDL_GetPixelFormatName(formats[i]));
+ goto done;
+ }
+ yuv1_pitch = CalculateYUVPitch(formats[i], pattern->w);
+ if (!verify_yuv_data(formats[i], yuv1, yuv1_pitch, pattern)) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to RGB\n", SDL_GetPixelFormatName(formats[i]));
+ goto done;
+ }
+ }
+
+ /* Verify conversion to YUV formats */
+ for (i = 0; i < SDL_arraysize(formats); ++i) {
+ yuv1_pitch = CalculateYUVPitch(formats[i], pattern->w) + extra_pitch;
+ if (SDL_ConvertPixels(pattern->w, pattern->h, pattern->format->format, pattern->pixels, pattern->pitch, formats[i], yuv1, yuv1_pitch) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
+ goto done;
+ }
+ if (!verify_yuv_data(formats[i], yuv1, yuv1_pitch, pattern)) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from RGB to %s\n", SDL_GetPixelFormatName(formats[i]));
+ goto done;
+ }
+ }
+
+ /* Verify conversion between YUV formats */
+ for (i = 0; i < SDL_arraysize(formats); ++i) {
+ for (j = 0; j < SDL_arraysize(formats); ++j) {
+ yuv1_pitch = CalculateYUVPitch(formats[i], pattern->w) + extra_pitch;
+ yuv2_pitch = CalculateYUVPitch(formats[j], pattern->w) + extra_pitch;
+ if (SDL_ConvertPixels(pattern->w, pattern->h, pattern->format->format, pattern->pixels, pattern->pitch, formats[i], yuv1, yuv1_pitch) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
+ goto done;
+ }
+ if (SDL_ConvertPixels(pattern->w, pattern->h, formats[i], yuv1, yuv1_pitch, formats[j], yuv2, yuv2_pitch) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]), SDL_GetError());
+ goto done;
+ }
+ if (!verify_yuv_data(formats[j], yuv2, yuv2_pitch, pattern)) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]));
+ goto done;
+ }
+ }
+ }
+
+ /* Verify conversion between YUV formats in-place */
+ for (i = 0; i < SDL_arraysize(formats); ++i) {
+ for (j = 0; j < SDL_arraysize(formats); ++j) {
+ if (is_packed_yuv_format(formats[i]) != is_packed_yuv_format(formats[j])) {
+ /* Can't change plane vs packed pixel layout in-place */
+ continue;
+ }
+
+ yuv1_pitch = CalculateYUVPitch(formats[i], pattern->w) + extra_pitch;
+ yuv2_pitch = CalculateYUVPitch(formats[j], pattern->w) + extra_pitch;
+ if (SDL_ConvertPixels(pattern->w, pattern->h, pattern->format->format, pattern->pixels, pattern->pitch, formats[i], yuv1, yuv1_pitch) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(pattern->format->format), SDL_GetPixelFormatName(formats[i]), SDL_GetError());
+ goto done;
+ }
+ if (SDL_ConvertPixels(pattern->w, pattern->h, formats[i], yuv1, yuv1_pitch, formats[j], yuv1, yuv2_pitch) < 0) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't convert %s to %s: %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]), SDL_GetError());
+ goto done;
+ }
+ if (!verify_yuv_data(formats[j], yuv1, yuv2_pitch, pattern)) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Failed conversion from %s to %s\n", SDL_GetPixelFormatName(formats[i]), SDL_GetPixelFormatName(formats[j]));
+ goto done;
+ }
+ }
+ }
+
+
+ result = 0;
+
+done:
+ SDL_free(yuv1);
+ SDL_free(yuv2);
+ SDL_FreeSurface(pattern);
+ return result;
+}
+
+int
+main(int argc, char **argv)
+{
+ struct {
+ SDL_bool enable_intrinsics;
+ int pattern_size;
+ int extra_pitch;
+ } automated_test_params[] = {
+ /* Test: even width and height */
+ { SDL_FALSE, 2, 0 },
+ { SDL_FALSE, 4, 0 },
+ /* Test: odd width and height */
+ { SDL_FALSE, 1, 0 },
+ { SDL_FALSE, 3, 0 },
+ /* Test: even width and height, extra pitch */
+ { SDL_FALSE, 2, 3 },
+ { SDL_FALSE, 4, 3 },
+ /* Test: odd width and height, extra pitch */
+ { SDL_FALSE, 1, 3 },
+ { SDL_FALSE, 3, 3 },
+ /* Test: even width and height with intrinsics */
+ { SDL_TRUE, 32, 0 },
+ /* Test: odd width and height with intrinsics */
+ { SDL_TRUE, 33, 0 },
+ { SDL_TRUE, 37, 0 },
+ /* Test: even width and height with intrinsics, extra pitch */
+ { SDL_TRUE, 32, 3 },
+ /* Test: odd width and height with intrinsics, extra pitch */
+ { SDL_TRUE, 33, 3 },
+ { SDL_TRUE, 37, 3 },
+ };
+ int arg = 1;
+ const char *filename;
+ SDL_Surface *original;
+ SDL_Surface *converted;
+ SDL_Window *window;
+ SDL_Renderer *renderer;
+ SDL_Texture *output[3];
+ const char *titles[3] = { "ORIGINAL", "SOFTWARE", "HARDWARE" };
+ char title[128];
+ const char *yuv_name;
+ const char *yuv_mode;
+ Uint32 rgb_format = SDL_PIXELFORMAT_RGBX8888;
+ Uint32 yuv_format = SDL_PIXELFORMAT_YV12;
+ int current = 0;
+ int pitch;
+ Uint8 *raw_yuv;
+ Uint32 then, now, i, iterations = 100;
+ SDL_bool should_run_automated_tests = SDL_FALSE;
+
+ while (argv[arg] && *argv[arg] == '-') {
+ if (SDL_strcmp(argv[arg], "--jpeg") == 0) {
+ SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_JPEG);
+ } else if (SDL_strcmp(argv[arg], "--bt601") == 0) {
+ SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_BT601);
+ } else if (SDL_strcmp(argv[arg], "--bt709") == 0) {
+ SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_BT709);
+ } else if (SDL_strcmp(argv[arg], "--auto") == 0) {
+ SDL_SetYUVConversionMode(SDL_YUV_CONVERSION_AUTOMATIC);
+ } else if (SDL_strcmp(argv[arg], "--yv12") == 0) {
+ yuv_format = SDL_PIXELFORMAT_YV12;
+ } else if (SDL_strcmp(argv[arg], "--iyuv") == 0) {
+ yuv_format = SDL_PIXELFORMAT_IYUV;
+ } else if (SDL_strcmp(argv[arg], "--yuy2") == 0) {
+ yuv_format = SDL_PIXELFORMAT_YUY2;
+ } else if (SDL_strcmp(argv[arg], "--uyvy") == 0) {
+ yuv_format = SDL_PIXELFORMAT_UYVY;
+ } else if (SDL_strcmp(argv[arg], "--yvyu") == 0) {
+ yuv_format = SDL_PIXELFORMAT_YVYU;
+ } else if (SDL_strcmp(argv[arg], "--nv12") == 0) {
+ yuv_format = SDL_PIXELFORMAT_NV12;
+ } else if (SDL_strcmp(argv[arg], "--nv21") == 0) {
+ yuv_format = SDL_PIXELFORMAT_NV21;
+ } else if (SDL_strcmp(argv[arg], "--rgb555") == 0) {
+ rgb_format = SDL_PIXELFORMAT_RGB555;
+ } else if (SDL_strcmp(argv[arg], "--rgb565") == 0) {
+ rgb_format = SDL_PIXELFORMAT_RGB565;
+ } else if (SDL_strcmp(argv[arg], "--rgb24") == 0) {
+ rgb_format = SDL_PIXELFORMAT_RGB24;
+ } else if (SDL_strcmp(argv[arg], "--argb") == 0) {
+ rgb_format = SDL_PIXELFORMAT_ARGB8888;
+ } else if (SDL_strcmp(argv[arg], "--abgr") == 0) {
+ rgb_format = SDL_PIXELFORMAT_ABGR8888;
+ } else if (SDL_strcmp(argv[arg], "--rgba") == 0) {
+ rgb_format = SDL_PIXELFORMAT_RGBA8888;
+ } else if (SDL_strcmp(argv[arg], "--bgra") == 0) {
+ rgb_format = SDL_PIXELFORMAT_BGRA8888;
+ } else if (SDL_strcmp(argv[arg], "--automated") == 0) {
+ should_run_automated_tests = SDL_TRUE;
+ } else {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Usage: %s [--jpeg|--bt601|-bt709|--auto] [--yv12|--iyuv|--yuy2|--uyvy|--yvyu|--nv12|--nv21] [--rgb555|--rgb565|--rgb24|--argb|--abgr|--rgba|--bgra] [image_filename]\n", argv[0]);
+ return 1;
+ }
+ ++arg;
+ }
+
+ /* Run automated tests */
+ if (should_run_automated_tests) {
+ for (i = 0; i < SDL_arraysize(automated_test_params); ++i) {
+ SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Running automated test, pattern size %d, extra pitch %d, intrinsics %s\n",
+ automated_test_params[i].pattern_size,
+ automated_test_params[i].extra_pitch,
+ automated_test_params[i].enable_intrinsics ? "enabled" : "disabled");
+ if (run_automated_tests(automated_test_params[i].pattern_size, automated_test_params[i].extra_pitch) < 0) {
+ return 2;
+ }
+ }
+ return 0;
+ }
+
+ if (argv[arg]) {
+ filename = argv[arg];
+ } else {
+ filename = "testyuv.bmp";
+ }
+ original = SDL_ConvertSurfaceFormat(SDL_LoadBMP(filename), SDL_PIXELFORMAT_RGB24, 0);
+ if (!original) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't load %s: %s\n", filename, SDL_GetError());
+ return 3;
+ }
+
+ raw_yuv = SDL_calloc(1, MAX_YUV_SURFACE_SIZE(original->w, original->h, 0));
+ ConvertRGBtoYUV(yuv_format, original->pixels, original->pitch, raw_yuv, original->w, original->h,
+ SDL_GetYUVConversionModeForResolution(original->w, original->h),
+ 0, 100);
+ pitch = CalculateYUVPitch(yuv_format, original->w);
+
+ converted = SDL_CreateRGBSurfaceWithFormat(0, original->w, original->h, 0, rgb_format);
+ if (!converted) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create converted surface: %s\n", SDL_GetError());
+ return 3;
+ }
+
+ then = SDL_GetTicks();
+ for ( i = 0; i < iterations; ++i ) {
+ SDL_ConvertPixels(original->w, original->h, yuv_format, raw_yuv, pitch, rgb_format, converted->pixels, converted->pitch);
+ }
+ now = SDL_GetTicks();
+ SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "%d iterations in %d ms, %.2fms each\n", iterations, (now - then), (float)(now - then)/iterations);
+
+ window = SDL_CreateWindow("YUV test",
+ SDL_WINDOWPOS_UNDEFINED,
+ SDL_WINDOWPOS_UNDEFINED,
+ original->w, original->h,
+ 0);
+ if (!window) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create window: %s\n", SDL_GetError());
+ return 4;
+ }
+
+ renderer = SDL_CreateRenderer(window, -1, 0);
+ if (!renderer) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create renderer: %s\n", SDL_GetError());
+ return 4;
+ }
+
+ output[0] = SDL_CreateTextureFromSurface(renderer, original);
+ output[1] = SDL_CreateTextureFromSurface(renderer, converted);
+ output[2] = SDL_CreateTexture(renderer, yuv_format, SDL_TEXTUREACCESS_STREAMING, original->w, original->h);
+ if (!output[0] || !output[1] || !output[2]) {
+ SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());
+ return 5;
+ }
+ SDL_UpdateTexture(output[2], NULL, raw_yuv, pitch);
+
+ yuv_name = SDL_GetPixelFormatName(yuv_format);
+ if (SDL_strncmp(yuv_name, "SDL_PIXELFORMAT_", 16) == 0) {
+ yuv_name += 16;
+ }
+
+ switch (SDL_GetYUVConversionModeForResolution(original->w, original->h)) {
+ case SDL_YUV_CONVERSION_JPEG:
+ yuv_mode = "JPEG";
+ break;
+ case SDL_YUV_CONVERSION_BT601:
+ yuv_mode = "BT.601";
+ break;
+ case SDL_YUV_CONVERSION_BT709:
+ yuv_mode = "BT.709";
+ break;
+ default:
+ yuv_mode = "UNKNOWN";
+ break;
+ }
+
+ { int done = 0;
+ while ( !done )
+ {
+ SDL_Event event;
+ while (SDL_PollEvent(&event) > 0) {
+ if (event.type == SDL_QUIT) {
+ done = 1;
+ }
+ if (event.type == SDL_KEYDOWN) {
+ if (event.key.keysym.sym == SDLK_ESCAPE) {
+ done = 1;
+ } else if (event.key.keysym.sym == SDLK_LEFT) {
+ --current;
+ } else if (event.key.keysym.sym == SDLK_RIGHT) {
+ ++current;
+ }
+ }
+ if (event.type == SDL_MOUSEBUTTONDOWN) {
+ if (event.button.x < (original->w/2)) {
+ --current;
+ } else {
+ ++current;
+ }
+ }
+ }
+
+ /* Handle wrapping */
+ if (current < 0) {
+ current += SDL_arraysize(output);
+ }
+ if (current >= SDL_arraysize(output)) {
+ current -= SDL_arraysize(output);
+ }
+
+ SDL_RenderClear(renderer);
+ SDL_RenderCopy(renderer, output[current], NULL, NULL);
+ SDL_SetRenderDrawColor(renderer, 0xFF, 0xFF, 0xFF, 0xFF);
+ if (current == 0) {
+ SDLTest_DrawString(renderer, 4, 4, titles[current]);
+ } else {
+ SDL_snprintf(title, sizeof(title), "%s %s %s", titles[current], yuv_name, yuv_mode);
+ SDLTest_DrawString(renderer, 4, 4, title);
+ }
+ SDL_RenderPresent(renderer);
+ SDL_Delay(10);
+ }
+ }
+ SDL_Quit();
+ return 0;
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/test/testyuv_cvt.c b/test/testyuv_cvt.c
new file mode 100644
index 000000000..977f034f2
--- /dev/null
+++ b/test/testyuv_cvt.c
@@ -0,0 +1,300 @@
+/*
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
+*/
+
+#include "SDL.h"
+
+#include "testyuv_cvt.h"
+
+
+static float clip3(float x, float y, float z)
+{
+ return ((z < x) ? x : ((z > y) ? y : z));
+}
+
+static void RGBtoYUV(Uint8 * rgb, int *yuv, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
+{
+ if (mode == SDL_YUV_CONVERSION_JPEG) {
+ /* Full range YUV */
+ yuv[0] = (int)(0.299 * rgb[0] + 0.587 * rgb[1] + 0.114 * rgb[2]);
+ yuv[1] = (int)((rgb[2] - yuv[0]) * 0.565 + 128);
+ yuv[2] = (int)((rgb[0] - yuv[0]) * 0.713 + 128);
+ } else {
+ // This formula is from Microsoft's documentation:
+ // https://msdn.microsoft.com/en-us/library/windows/desktop/dd206750(v=vs.85).aspx
+ // L = Kr * R + Kb * B + (1 - Kr - Kb) * G
+ // Y = floor(2^(M-8) * (219*(L-Z)/S + 16) + 0.5);
+ // U = clip3(0, (2^M)-1, floor(2^(M-8) * (112*(B-L) / ((1-Kb)*S) + 128) + 0.5));
+ // V = clip3(0, (2^M)-1, floor(2^(M-8) * (112*(R-L) / ((1-Kr)*S) + 128) + 0.5));
+ float S, Z, R, G, B, L, Kr, Kb, Y, U, V;
+
+ if (mode == SDL_YUV_CONVERSION_BT709) {
+ /* BT.709 */
+ Kr = 0.2126f;
+ Kb = 0.0722f;
+ } else {
+ /* BT.601 */
+ Kr = 0.299f;
+ Kb = 0.114f;
+ }
+
+ S = 255.0f;
+ Z = 0.0f;
+ R = rgb[0];
+ G = rgb[1];
+ B = rgb[2];
+ L = Kr * R + Kb * B + (1 - Kr - Kb) * G;
+ Y = (Uint8)SDL_floorf((219*(L-Z)/S + 16) + 0.5f);
+ U = (Uint8)clip3(0, 255, SDL_floorf((112.0f*(B-L) / ((1.0f-Kb)*S) + 128) + 0.5f));
+ V = (Uint8)clip3(0, 255, SDL_floorf((112.0f*(R-L) / ((1.0f-Kr)*S) + 128) + 0.5f));
+
+ yuv[0] = (Uint8)Y;
+ yuv[1] = (Uint8)U;
+ yuv[2] = (Uint8)V;
+ }
+
+ if (monochrome) {
+ yuv[1] = 128;
+ yuv[2] = 128;
+ }
+
+ if (luminance != 100) {
+ yuv[0] = yuv[0] * luminance / 100;
+ if (yuv[0] > 255)
+ yuv[0] = 255;
+ }
+}
+
+static void ConvertRGBtoPlanar2x2(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w, int h, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
+{
+ int x, y;
+ int yuv[4][3];
+ Uint8 *Y1, *Y2, *U, *V;
+ Uint8 *rgb1, *rgb2;
+ int rgb_row_advance = (pitch - w*3) + pitch;
+ int UV_advance;
+
+ rgb1 = src;
+ rgb2 = src + pitch;
+
+ Y1 = out;
+ Y2 = Y1 + w;
+ switch (format) {
+ case SDL_PIXELFORMAT_YV12:
+ V = (Y1 + h * w);
+ U = V + ((h + 1)/2)*((w + 1)/2);
+ UV_advance = 1;
+ break;
+ case SDL_PIXELFORMAT_IYUV:
+ U = (Y1 + h * w);
+ V = U + ((h + 1)/2)*((w + 1)/2);
+ UV_advance = 1;
+ break;
+ case SDL_PIXELFORMAT_NV12:
+ U = (Y1 + h * w);
+ V = U + 1;
+ UV_advance = 2;
+ break;
+ case SDL_PIXELFORMAT_NV21:
+ V = (Y1 + h * w);
+ U = V + 1;
+ UV_advance = 2;
+ break;
+ default:
+ SDL_assert(!"Unsupported planar YUV format");
+ return;
+ }
+
+ for (y = 0; y < (h - 1); y += 2) {
+ for (x = 0; x < (w - 1); x += 2) {
+ RGBtoYUV(rgb1, yuv[0], mode, monochrome, luminance);
+ rgb1 += 3;
+ *Y1++ = (Uint8)yuv[0][0];
+
+ RGBtoYUV(rgb1, yuv[1], mode, monochrome, luminance);
+ rgb1 += 3;
+ *Y1++ = (Uint8)yuv[1][0];
+
+ RGBtoYUV(rgb2, yuv[2], mode, monochrome, luminance);
+ rgb2 += 3;
+ *Y2++ = (Uint8)yuv[2][0];
+
+ RGBtoYUV(rgb2, yuv[3], mode, monochrome, luminance);
+ rgb2 += 3;
+ *Y2++ = (Uint8)yuv[3][0];
+
+ *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1] + yuv[2][1] + yuv[3][1])/4.0f + 0.5f);
+ U += UV_advance;
+
+ *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2] + yuv[2][2] + yuv[3][2])/4.0f + 0.5f);
+ V += UV_advance;
+ }
+ /* Last column */
+ if (x == (w - 1)) {
+ RGBtoYUV(rgb1, yuv[0], mode, monochrome, luminance);
+ rgb1 += 3;
+ *Y1++ = (Uint8)yuv[0][0];
+
+ RGBtoYUV(rgb2, yuv[2], mode, monochrome, luminance);
+ rgb2 += 3;
+ *Y2++ = (Uint8)yuv[2][0];
+
+ *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[2][1])/2.0f + 0.5f);
+ U += UV_advance;
+
+ *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[2][2])/2.0f + 0.5f);
+ V += UV_advance;
+ }
+ Y1 += w;
+ Y2 += w;
+ rgb1 += rgb_row_advance;
+ rgb2 += rgb_row_advance;
+ }
+ /* Last row */
+ if (y == (h - 1)) {
+ for (x = 0; x < (w - 1); x += 2) {
+ RGBtoYUV(rgb1, yuv[0], mode, monochrome, luminance);
+ rgb1 += 3;
+ *Y1++ = (Uint8)yuv[0][0];
+
+ RGBtoYUV(rgb1, yuv[1], mode, monochrome, luminance);
+ rgb1 += 3;
+ *Y1++ = (Uint8)yuv[1][0];
+
+ *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1])/2.0f + 0.5f);
+ U += UV_advance;
+
+ *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2])/2.0f + 0.5f);
+ V += UV_advance;
+ }
+ /* Last column */
+ if (x == (w - 1)) {
+ RGBtoYUV(rgb1, yuv[0], mode, monochrome, luminance);
+ *Y1++ = (Uint8)yuv[0][0];
+
+ *U = (Uint8)yuv[0][1];
+ U += UV_advance;
+
+ *V = (Uint8)yuv[0][2];
+ V += UV_advance;
+ }
+ }
+}
+
+static void ConvertRGBtoPacked4(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w, int h, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
+{
+ int x, y;
+ int yuv[2][3];
+ Uint8 *Y1, *Y2, *U, *V;
+ Uint8 *rgb;
+ int rgb_row_advance = (pitch - w*3);
+
+ rgb = src;
+
+ switch (format) {
+ case SDL_PIXELFORMAT_YUY2:
+ Y1 = out;
+ U = out+1;
+ Y2 = out+2;
+ V = out+3;
+ break;
+ case SDL_PIXELFORMAT_UYVY:
+ U = out;
+ Y1 = out+1;
+ V = out+2;
+ Y2 = out+3;
+ break;
+ case SDL_PIXELFORMAT_YVYU:
+ Y1 = out;
+ V = out+1;
+ Y2 = out+2;
+ U = out+3;
+ break;
+ default:
+ SDL_assert(!"Unsupported packed YUV format");
+ return;
+ }
+
+ for (y = 0; y < h; ++y) {
+ for (x = 0; x < (w - 1); x += 2) {
+ RGBtoYUV(rgb, yuv[0], mode, monochrome, luminance);
+ rgb += 3;
+ *Y1 = (Uint8)yuv[0][0];
+ Y1 += 4;
+
+ RGBtoYUV(rgb, yuv[1], mode, monochrome, luminance);
+ rgb += 3;
+ *Y2 = (Uint8)yuv[1][0];
+ Y2 += 4;
+
+ *U = (Uint8)SDL_floorf((yuv[0][1] + yuv[1][1])/2.0f + 0.5f);
+ U += 4;
+
+ *V = (Uint8)SDL_floorf((yuv[0][2] + yuv[1][2])/2.0f + 0.5f);
+ V += 4;
+ }
+ /* Last column */
+ if (x == (w - 1)) {
+ RGBtoYUV(rgb, yuv[0], mode, monochrome, luminance);
+ rgb += 3;
+ *Y2 = *Y1 = (Uint8)yuv[0][0];
+ Y1 += 4;
+ Y2 += 4;
+
+ *U = (Uint8)yuv[0][1];
+ U += 4;
+
+ *V = (Uint8)yuv[0][2];
+ V += 4;
+ }
+ rgb += rgb_row_advance;
+ }
+}
+
+SDL_bool ConvertRGBtoYUV(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w, int h, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance)
+{
+ switch (format)
+ {
+ case SDL_PIXELFORMAT_YV12:
+ case SDL_PIXELFORMAT_IYUV:
+ case SDL_PIXELFORMAT_NV12:
+ case SDL_PIXELFORMAT_NV21:
+ ConvertRGBtoPlanar2x2(format, src, pitch, out, w, h, mode, monochrome, luminance);
+ return SDL_TRUE;
+ case SDL_PIXELFORMAT_YUY2:
+ case SDL_PIXELFORMAT_UYVY:
+ case SDL_PIXELFORMAT_YVYU:
+ ConvertRGBtoPacked4(format, src, pitch, out, w, h, mode, monochrome, luminance);
+ return SDL_TRUE;
+ default:
+ return SDL_FALSE;
+ }
+}
+
+int CalculateYUVPitch(Uint32 format, int width)
+{
+ switch (format)
+ {
+ case SDL_PIXELFORMAT_YV12:
+ case SDL_PIXELFORMAT_IYUV:
+ case SDL_PIXELFORMAT_NV12:
+ case SDL_PIXELFORMAT_NV21:
+ return width;
+ case SDL_PIXELFORMAT_YUY2:
+ case SDL_PIXELFORMAT_UYVY:
+ case SDL_PIXELFORMAT_YVYU:
+ return 4*((width + 1)/2);
+ default:
+ return 0;
+ }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
diff --git a/test/testyuv_cvt.h b/test/testyuv_cvt.h
new file mode 100644
index 000000000..173a4e2f8
--- /dev/null
+++ b/test/testyuv_cvt.h
@@ -0,0 +1,16 @@
+/*
+ Copyright (C) 1997-2017 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely.
+*/
+
+/* These functions are designed for testing correctness, not for speed */
+
+extern SDL_bool ConvertRGBtoYUV(Uint32 format, Uint8 *src, int pitch, Uint8 *out, int w, int h, SDL_YUV_CONVERSION_MODE mode, int monochrome, int luminance);
+extern int CalculateYUVPitch(Uint32 format, int width);