Patch clean

parent f8bb9ade
From d5713343015e0da9617239b5cbbcd713fe200965 Mon Sep 17 00:00:00 2001
From: Mohammed Danish <shaan3@gmail.com>
Date: Wed, 5 Jul 2017 17:32:57 +0530
Subject: [PATCH] Direct3D11 Changes
---
modules/video_output/win32/direct3d11.c | 287 ++++++++++++++++++++++++++++++--
1 file changed, 269 insertions(+), 18 deletions(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 9b6a879ef5..491d71865a 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -40,6 +40,7 @@
#define COBJMACROS
#include <initguid.h>
#include <d3d11.h>
+#include <dxgi1_2.h>
#include <dxgi1_5.h>
#include <d3dcompiler.h>
@@ -99,6 +100,7 @@ typedef struct
UINT PSConstantsCount;
ID3D11PixelShader *d3dpixelShader;
D3D11_VIEWPORT cropViewport;
+ D3D11_VIEWPORT cropRigthEyeViewport;
unsigned int i_x_offset;
unsigned int i_y_offset;
unsigned int i_width;
@@ -154,6 +156,7 @@ struct vout_display_sys_t
picture_sys_t stagingSys;
ID3D11RenderTargetView *d3drenderTargetView;
+ ID3D11RenderTargetView *d3drenderTargetViewRightEye;
ID3D11DepthStencilView *d3ddepthStencilView;
ID3D11VertexShader *flatVSShader;
@@ -162,6 +165,9 @@ struct vout_display_sys_t
/* copy from the decoder pool into picSquad before display
* Uses a Texture2D with slices rather than a Texture2DArray for the decoder */
bool legacy_shader;
+ bool stereo_enabled;
+ bool turnOn2D;
+ int source3DFormat;
// SPU
vlc_fourcc_t pSubpictureChromas[2];
@@ -510,6 +516,10 @@ static int Open(vlc_object_t *object)
{
vout_display_t *vd = (vout_display_t *)object;
+ if ( vd->source.i_chroma == VLC_CODEC_D3D9_OPAQUE ||
+ vd->source.i_chroma == VLC_CODEC_D3D9_OPAQUE_10B )
+ return VLC_EGENERIC;
+
#if !VLC_WINSTORE_APP
int ret = OpenHwnd(vd);
#else
@@ -802,6 +812,76 @@ static void DestroyDisplayPoolPicture(picture_t *picture)
free(p_sys);
free(picture);
}
+static int UpdateSwapChain(vout_display_t *vd, bool convertTo2D)
+{
+ vout_display_sys_t *sys = vd->sys;
+ IDXGIFactory2 *dxgifactory;
+ HRESULT hr;
+
+ DXGI_SWAP_CHAIN_DESC1 scd;
+ ZeroMemory( &scd, sizeof(scd));
+ scd.BufferCount = 2;
+ scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
+ scd.SampleDesc.Count = 1;
+ scd.SampleDesc.Quality = 0;
+ scd.Width = vd->source.i_visible_width;
+ scd.Height = vd->source.i_visible_height;
+ scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM; /* TODO: use DXGI_FORMAT_NV12 */
+ scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
+ scd.Stereo = TRUE;
+ scd.Scaling = DXGI_SCALING_NONE;
+ scd.Flags = 0;
+
+ if (convertTo2D)
+ scd.Stereo = FALSE;
+
+ IDXGIAdapter *dxgiadapter = D3D11DeviceAdapter(sys->d3ddevice);
+ if (FAILED(hr)) {
+ msg_Err(vd, "Could not get the DXGI Adapter");
+ return VLC_EGENERIC;
+ }
+
+ hr = IDXGIAdapter_GetParent(dxgiadapter, &IID_IDXGIFactory2, (void **)&dxgifactory);
+ IDXGIAdapter_Release(dxgiadapter);
+ if (FAILED(hr)) {
+ msg_Err(vd, "Could not get the DXGI Factory. (hr=0x%lX)", hr);
+ return VLC_EGENERIC;
+ }
+
+ //Release references to recreate the swapchain
+ if (sys->d3dcontext)
+ {
+ ID3D11DeviceContext_Flush(sys->d3dcontext);
+ }
+ if (sys->dxgiswapChain4)
+ {
+ IDXGISwapChain4_Release(sys->dxgiswapChain4);
+ sys->dxgiswapChain4 = NULL;
+ }
+ if (sys->dxgiswapChain)
+ {
+ IDXGISwapChain_Release(sys->dxgiswapChain);
+ sys->dxgiswapChain = NULL;
+ }
+ if (sys->d3drenderTargetView)
+ {
+ ID3D11RenderTargetView_Release(sys->d3drenderTargetView);
+ sys->d3drenderTargetView = NULL;
+ }
+ if (sys->d3drenderTargetViewRightEye)
+ {
+ ID3D11RenderTargetView_Release(sys->d3drenderTargetViewRightEye);
+ sys->d3drenderTargetViewRightEye = NULL;
+ }
+
+ hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)sys->d3ddevice,
+ sys->sys.hvideownd, &scd, NULL, NULL, &sys->dxgiswapChain);
+ IDXGIFactory2_Release(dxgifactory);
+ if (FAILED(hr)) {
+ msg_Err(vd, "Could not recreate the SwapChain. (hr=0x%lX)", hr);
+ return VLC_EGENERIC;
+ }
+}
static HRESULT UpdateBackBuffer(vout_display_t *vd)
{
@@ -821,14 +901,17 @@ static HRESULT UpdateBackBuffer(vout_display_t *vd)
ID3D11RenderTargetView_Release(sys->d3drenderTargetView);
sys->d3drenderTargetView = NULL;
}
+ if (sys->d3drenderTargetViewRightEye) {
+ ID3D11RenderTargetView_Release(sys->d3drenderTargetViewRightEye);
+ sys->d3drenderTargetView = NULL;
+ }
if (sys->d3ddepthStencilView) {
ID3D11DepthStencilView_Release(sys->d3ddepthStencilView);
sys->d3ddepthStencilView = NULL;
}
/* TODO detect is the size is the same as the output and switch to fullscreen mode */
- hr = IDXGISwapChain_ResizeBuffers(sys->dxgiswapChain, 0, i_width, i_height,
- DXGI_FORMAT_UNKNOWN, 0);
+ hr = IDXGISwapChain_ResizeBuffers(sys->dxgiswapChain, 2, i_width, i_height, DXGI_FORMAT_UNKNOWN, 0);
if (FAILED(hr)) {
msg_Err(vd, "Failed to resize the backbuffer. (hr=0x%lX)", hr);
return hr;
@@ -840,7 +923,29 @@ static HRESULT UpdateBackBuffer(vout_display_t *vd)
return hr;
}
- hr = ID3D11Device_CreateRenderTargetView(sys->d3ddevice, (ID3D11Resource *)pBackBuffer, NULL, &sys->d3drenderTargetView);
+ D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewDesc;
+ ZeroMemory( &renderTargetViewDesc, sizeof( D3D11_RENDER_TARGET_VIEW_DESC));
+ renderTargetViewDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ renderTargetViewDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
+ renderTargetViewDesc.Texture2DArray.MipSlice = 0;
+ renderTargetViewDesc.Texture2DArray.FirstArraySlice = 0;
+ renderTargetViewDesc.Texture2DArray.ArraySize = 1;
+
+ hr = ID3D11Device_CreateRenderTargetView(sys->d3ddevice, (ID3D11Resource *)pBackBuffer, &renderTargetViewDesc, &sys->d3drenderTargetView);
+
+ if (sys->stereo_enabled)
+ {
+ D3D11_RENDER_TARGET_VIEW_DESC renderTargetViewRightDesc;
+ ZeroMemory( &renderTargetViewRightDesc, sizeof( D3D11_RENDER_TARGET_VIEW_DESC));
+ renderTargetViewRightDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ renderTargetViewRightDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
+ renderTargetViewRightDesc.Texture2DArray.MipSlice = 0;
+ renderTargetViewRightDesc.Texture2DArray.FirstArraySlice = 1;
+ renderTargetViewRightDesc.Texture2DArray.ArraySize = 1;
+
+ hr = ID3D11Device_CreateRenderTargetView(sys->d3ddevice, (ID3D11Resource *)pBackBuffer, &renderTargetViewRightDesc, &sys->d3drenderTargetViewRightEye);
+ }
+
ID3D11Texture2D_Release(pBackBuffer);
if (FAILED(hr)) {
msg_Err(vd, "Failed to create the target view. (hr=0x%lX)", hr);
@@ -1061,8 +1166,7 @@ static int Control(vout_display_t *vd, int query, va_list args)
{
vout_display_sys_t *sys = vd->sys;
RECT size_before = sys->sys.rect_dest_clipped;
-
- int res = CommonControl( vd, query, args );
+ int res = CommonControl( vd, query, args );
if (query == VOUT_DISPLAY_CHANGE_VIEWPOINT)
{
@@ -1073,6 +1177,34 @@ static int Control(vout_display_t *vd, int query, va_list args)
res = VLC_SUCCESS;
}
}
+ else if (query == VOUT_DISPLAY_CHANGE_MULTIVIEW)
+ {
+ const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t*);
+ //Disable Stereoscopic 3D for 2D outputs
+ if ((cfg->multiview_format == S3D_RightOnly) || (cfg->multiview_format == S3D_LeftOnly))
+ {
+ if (!sys->turnOn2D)
+ {
+ sys->turnOn2D = true;
+ sys->stereo_enabled = false;
+ res = UpdateSwapChain(vd, true);
+ }
+ }
+ else if (cfg->multiview_format == S3D_Auto)
+ {
+
+ if (sys->turnOn2D)
+ {
+ sys->turnOn2D = false;
+ sys->stereo_enabled = true;
+ res = UpdateSwapChain(vd, false);
+ }
+ }
+
+ UpdateBackBuffer(vd);
+ UpdatePicQuadPosition(vd);
+ res = VLC_SUCCESS;
+ }
if (RECTWidth(size_before) != RECTWidth(sys->sys.rect_dest_clipped) ||
RECTHeight(size_before) != RECTHeight(sys->sys.rect_dest_clipped))
@@ -1152,7 +1284,7 @@ static void Prepare(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
#endif
}
-static void DisplayD3DPicture(vout_display_sys_t *sys, d3d_quad_t *quad, ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW])
+static void DisplayD3DPicture(vout_display_sys_t *sys, d3d_quad_t *quad, ID3D11ShaderResourceView *resourceView[D3D11_MAX_SHADER_VIEW], bool showRightEye)
{
UINT stride = sizeof(d3d_vertex_t);
UINT offset = 0;
@@ -1172,7 +1304,10 @@ static void DisplayD3DPicture(vout_display_sys_t *sys, d3d_quad_t *quad, ID3D11S
ID3D11DeviceContext_PSSetConstantBuffers(sys->d3dcontext, 0, quad->PSConstantsCount, quad->pPixelShaderConstants);
ID3D11DeviceContext_PSSetShaderResources(sys->d3dcontext, 0, D3D11_MAX_SHADER_VIEW, resourceView);
- ID3D11DeviceContext_RSSetViewports(sys->d3dcontext, 1, &quad->cropViewport);
+ if (showRightEye)
+ ID3D11DeviceContext_RSSetViewports(sys->d3dcontext, 1, &quad->cropRigthEyeViewport);
+ else
+ ID3D11DeviceContext_RSSetViewports(sys->d3dcontext, 1, &quad->cropViewport);
ID3D11DeviceContext_DrawIndexed(sys->d3dcontext, quad->indexCount, 0, 0);
}
@@ -1180,6 +1315,8 @@ static void DisplayD3DPicture(vout_display_sys_t *sys, d3d_quad_t *quad, ID3D11S
static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
{
vout_display_sys_t *sys = vd->sys;
+ int s3d_format_selection = var_InheritInteger (vd, "s3d-output");
+
#ifdef HAVE_ID3D11VIDEODECODER
if (sys->context_lock != INVALID_HANDLE_VALUE && is_d3d11_opaque(picture->format.i_chroma))
{
@@ -1198,10 +1335,23 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
/* Render the quad */
if (!is_d3d11_opaque(picture->format.i_chroma) || sys->legacy_shader)
- DisplayD3DPicture(sys, &sys->picQuad, sys->stagingSys.resourceView);
+ {
+ DisplayD3DPicture(sys, &sys->picQuad, sys->stagingSys.resourceView, false);
+ if (sys->stereo_enabled)
+ {
+ {
+ ID3D11DeviceContext_OMSetRenderTargets(sys->d3dcontext, 1, &sys->d3drenderTargetViewRightEye, sys->d3ddepthStencilView);
+ //if 3D is auto detect but not detected yet
+ if ((s3d_format_selection == S3D_Auto) && (sys->source3DFormat == MULTIVIEW_2D))
+ DisplayD3DPicture(sys, &sys->picQuad, sys->stagingSys.resourceView, false);
+ else
+ DisplayD3DPicture(sys, &sys->picQuad, sys->stagingSys.resourceView, true);
+ }
+ }
+ }
else {
picture_sys_t *p_sys = ActivePictureSys(picture);
- DisplayD3DPicture(sys, &sys->picQuad, p_sys->resourceView);
+ DisplayD3DPicture(sys, &sys->picQuad, p_sys->resourceView, false);
}
if (subpicture) {
@@ -1210,7 +1360,7 @@ static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpic
if (sys->d3dregions[i])
{
d3d_quad_t *quad = (d3d_quad_t *) sys->d3dregions[i]->p_sys;
- DisplayD3DPicture(sys, quad, quad->picSys.resourceView);
+ DisplayD3DPicture(sys, quad, quad->picSys.resourceView, false);
}
}
}
@@ -1447,7 +1597,18 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
{
vout_display_sys_t *sys = vd->sys;
IDXGIFactory2 *dxgifactory;
+ bool disable3D = false;
+ static int multiview_mode_remember = 0;
+ int s3d_format_selection = var_InheritInteger (vd, "s3d-output");
+ D3D_FEATURE_LEVEL featureLevels[] =
+ {
+ D3D_FEATURE_LEVEL_11_1,
+ D3D_FEATURE_LEVEL_11_0,
+ D3D_FEATURE_LEVEL_10_1,
+ D3D_FEATURE_LEVEL_10_0
+ };
+ D3D_FEATURE_LEVEL i_feature_level;
*fmt = vd->source;
#if !VLC_WINSTORE_APP
@@ -1495,10 +1656,11 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
};
for (UINT driver = 0; driver < ARRAYSIZE(driverAttempts); driver++) {
- D3D_FEATURE_LEVEL i_feature_level;
- hr = D3D11CreateDevice(NULL, driverAttempts[driver], NULL, creationFlags,
- NULL, 0, D3D11_SDK_VERSION,
+ {
+ hr = D3D11CreateDevice(NULL, driverAttempts[driver], NULL, creationFlags,
+ featureLevels, ARRAYSIZE(featureLevels), D3D11_SDK_VERSION,
&sys->d3ddevice, &i_feature_level, &sys->d3dcontext);
+ }
if (SUCCEEDED(hr)) {
#ifndef NDEBUG
msg_Dbg(vd, "Created the D3D11 device 0x%p ctx 0x%p type %d level %x.",
@@ -1514,6 +1676,11 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
return VLC_EGENERIC;
}
+ if (i_feature_level < D3D_FEATURE_LEVEL_10_0) {
+ msg_Dbg(vd, "Could not create the 3D11 device with required feture level for Stereoscopic 3D. 3D won't work.");
+ disable3D = true;
+ }
+
IDXGIAdapter *dxgiadapter = D3D11DeviceAdapter(sys->d3ddevice);
if (unlikely(dxgiadapter==NULL)) {
msg_Err(vd, "Could not get the DXGI Adapter");
@@ -1527,6 +1694,37 @@ static int Direct3D11Open(vout_display_t *vd, video_format_t *fmt)
return VLC_EGENERIC;
}
+ //Disable 3D if any format other than SBS is selected or if 3d is not supported by the system
+ sys->stereo_enabled = (disable3D) ? false : IDXGIFactory2_IsWindowedStereoEnabled(dxgifactory);
+ //Since the next immediate call doesn't have 3D state information which we need to use again
+ sys->source3DFormat = fmt->multiview_mode;
+
+ if (multiview_mode_remember != 0)
+ {
+ fmt->multiview_mode = multiview_mode_remember;
+ sys->source3DFormat = (multiview_mode_remember == MULTIVIEW_STEREO_SBS) ? MULTIVIEW_STEREO_SBS : MULTIVIEW_STEREO_TB;
+ multiview_mode_remember = 0;
+ }
+ else if ((fmt->multiview_mode == MULTIVIEW_STEREO_SBS) && (s3d_format_selection == S3D_Auto))
+ {
+ multiview_mode_remember = MULTIVIEW_STEREO_SBS;
+ }
+ else if ((fmt->multiview_mode == MULTIVIEW_STEREO_TB) && (s3d_format_selection == S3D_Auto))
+ {
+ multiview_mode_remember = MULTIVIEW_STEREO_TB;
+ }
+ else if ((fmt->multiview_mode == MULTIVIEW_2D) && (s3d_format_selection == S3D_Auto))
+ sys->stereo_enabled = false;
+
+ sys->stereo_enabled = !sys->turnOn2D ? sys->stereo_enabled : false ;
+ if (sys->stereo_enabled)
+ {
+ scd.Stereo = TRUE;
+ scd.Scaling = DXGI_SCALING_NONE;
+ scd.Flags = 0;
+ sys->turnOn2D = false;
+ }
+
hr = IDXGIFactory2_CreateSwapChainForHwnd(dxgifactory, (IUnknown *)sys->d3ddevice,
sys->sys.hvideownd, &scd, NULL, NULL, &sys->dxgiswapChain);
IDXGIFactory2_Release(dxgifactory);
@@ -1662,12 +1860,60 @@ static void Direct3D11Close(vout_display_t *vd)
static void UpdatePicQuadPosition(vout_display_t *vd)
{
vout_display_sys_t *sys = vd->sys;
+ int s3d_format_selection = var_InheritInteger (vd, "s3d-output");
+
+ if ((!sys->stereo_enabled) || ((sys->stereo_enabled) && (s3d_format_selection == S3D_Auto) && (sys->source3DFormat == MULTIVIEW_2D)))
+ {
+ sys->picQuad.cropViewport.Width = RECTWidth(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropViewport.Height = RECTHeight(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropViewport.TopLeftX = sys->sys.rect_dest_clipped.left;
+ sys->picQuad.cropViewport.TopLeftY = sys->sys.rect_dest_clipped.top;
+ }
+ //For stereoscopic side by side left-right format
+ else if (((s3d_format_selection == S3D_Stereo) || ( sys->source3DFormat == MULTIVIEW_STEREO_SBS)) && (sys->stereo_enabled))
+ {
+ sys->picQuad.cropViewport.Width = RECTWidth(sys->sys.rect_dest_clipped) * 2;
+ sys->picQuad.cropViewport.Height = RECTHeight(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropViewport.TopLeftX = sys->sys.rect_dest_clipped.left;
+ sys->picQuad.cropViewport.TopLeftY = sys->sys.rect_dest_clipped.top;
+
+ sys->picQuad.cropRigthEyeViewport.Width = RECTWidth(sys->sys.rect_dest_clipped) * 2;
+ sys->picQuad.cropRigthEyeViewport.Height = RECTHeight(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropRigthEyeViewport.TopLeftX = sys->sys.rect_dest_clipped.left - RECTWidth(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropRigthEyeViewport.TopLeftY = sys->sys.rect_dest_clipped.top;
+ sys->picQuad.cropRigthEyeViewport.MinDepth = 0.0f;
+ sys->picQuad.cropRigthEyeViewport.MaxDepth = 1.0f;
+ }
+ //For stereoscopic side by side top-bottom format
+ else if ((( sys->source3DFormat == MULTIVIEW_STEREO_TB)) && (sys->stereo_enabled))
+ {
+ sys->picQuad.cropViewport.Width = RECTWidth(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropViewport.Height = RECTHeight(sys->sys.rect_dest_clipped) * 2;
+ sys->picQuad.cropViewport.TopLeftX = sys->sys.rect_dest_clipped.left;
+ sys->picQuad.cropViewport.TopLeftY = sys->sys.rect_dest_clipped.top;
- sys->picQuad.cropViewport.Width = RECTWidth(sys->sys.rect_dest_clipped);
- sys->picQuad.cropViewport.Height = RECTHeight(sys->sys.rect_dest_clipped);
- sys->picQuad.cropViewport.TopLeftX = sys->sys.rect_dest_clipped.left;
- sys->picQuad.cropViewport.TopLeftY = sys->sys.rect_dest_clipped.top;
+ sys->picQuad.cropRigthEyeViewport.Width = RECTWidth(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropRigthEyeViewport.Height = RECTHeight(sys->sys.rect_dest_clipped) * 2;
+ sys->picQuad.cropRigthEyeViewport.TopLeftX = sys->sys.rect_dest_clipped.left;
+ sys->picQuad.cropRigthEyeViewport.TopLeftY = sys->sys.rect_dest_clipped.top - RECTHeight(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropRigthEyeViewport.MinDepth = 0.0f;
+ sys->picQuad.cropRigthEyeViewport.MaxDepth = 1.0f;
+ }
+ if (s3d_format_selection == S3D_LeftOnly)
+ {
+ sys->picQuad.cropViewport.Width = RECTWidth(sys->sys.rect_dest_clipped) * 2;
+ sys->picQuad.cropViewport.Height = RECTHeight(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropViewport.TopLeftX = sys->sys.rect_dest_clipped.left;
+ sys->picQuad.cropViewport.TopLeftY = sys->sys.rect_dest_clipped.top;
+ }
+ else if (s3d_format_selection == S3D_RightOnly)
+ {
+ sys->picQuad.cropViewport.Width = RECTWidth(sys->sys.rect_dest_clipped) * 2;
+ sys->picQuad.cropViewport.Height = RECTHeight(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropViewport.TopLeftX = sys->sys.rect_dest_clipped.left - RECTWidth(sys->sys.rect_dest_clipped);
+ sys->picQuad.cropViewport.TopLeftY = sys->sys.rect_dest_clipped.top;
+ }
sys->picQuad.cropViewport.MinDepth = 0.0f;
sys->picQuad.cropViewport.MaxDepth = 1.0f;
@@ -2107,7 +2353,7 @@ static int Direct3D11CreateResources(vout_display_t *vd, video_format_t *fmt)
ID3D11DepthStencilState_Release(pDepthStencilState);
}
- sys->legacy_shader = !CanUseTextureArray(vd);
+ sys->legacy_shader = sys->stereo_enabled ? TRUE : !CanUseTextureArray(vd);
vd->info.is_slow = !is_d3d11_opaque(fmt->i_chroma);
hr = CompilePixelShader(vd, sys->picQuadConfig, fmt->transfer, fmt->b_color_range_full, &sys->picQuadPixelShader);
@@ -2630,6 +2876,11 @@ static void Direct3D11DestroyResources(vout_display_t *vd)
ID3D11RenderTargetView_Release(sys->d3drenderTargetView);
sys->d3drenderTargetView = NULL;
}
+ if (sys->d3drenderTargetViewRightEye)
+ {
+ ID3D11RenderTargetView_Release(sys->d3drenderTargetViewRightEye);
+ sys->d3drenderTargetViewRightEye = NULL;
+ }
if (sys->d3ddepthStencilView)
{
ID3D11DepthStencilView_Release(sys->d3ddepthStencilView);
--
2.12.2.windows.2
From 650bfe272779ef04d6e98a6d01cbd1f8862d838c Mon Sep 17 00:00:00 2001
From: Mohammed Danish <shaan3@gmail.com>
Date: Wed, 5 Jul 2017 18:12:39 +0530
Subject: [PATCH 1/3] User selection of 3D output
---
include/vlc_common.h | 7 +++++++
src/libvlc-module.c | 15 +++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/include/vlc_common.h b/include/vlc_common.h
index 94ab07e7a1..c4380e34d6 100644
--- a/include/vlc_common.h
+++ b/include/vlc_common.h
@@ -345,6 +345,13 @@ struct vlc_list_t
vlc_value_t *p_values;
};
+typedef enum STEREOSCOPIC_3D_FORMATS {
+ S3D_Auto,
+ S3D_LeftOnly,
+ S3D_RightOnly,
+ S3D_Stereo,
+} STEREOSCOPIC_3D_FORMATS;
+
/*****************************************************************************
* Error values (shouldn't be exposed)
*****************************************************************************/
diff --git a/src/libvlc-module.c b/src/libvlc-module.c
index d3a446e832..6d6352c994 100644
--- a/src/libvlc-module.c
+++ b/src/libvlc-module.c
@@ -46,6 +46,18 @@
static const char *const ppsz_snap_formats[] =
{ "png", "jpg", "tiff" };
+#define S3D_FORMAT_TEXT N_("Stereo 3D file format")
+#define S3D_FORMAT_TEXT_LONGTEXT N_("Set the 3D file format manually"\
+ "Autodetect, Left Only, Right Only, Stereo")
+
+static const int sbs_formats[] = {
+ S3D_Auto, S3D_LeftOnly, S3D_RightOnly, S3D_Stereo,
+
+};
+static const char *const sbs_formats_text[] = {
+ N_("Auto-detect"), N_("Left Only"), N_("Right Only"), N_("Stereo"),
+};
+
/*****************************************************************************
* Configuration options for the core module. Each module will also separatly
* define its own configuration options.
@@ -1546,6 +1558,9 @@ vlc_module_begin ()
add_bool( "video-title-show", 1, VIDEO_TITLE_SHOW_TEXT,
VIDEO_TITLE_SHOW_LONGTEXT, false )
+ add_integer ("s3d-output", S3D_Auto, S3D_FORMAT_TEXT, S3D_FORMAT_TEXT_LONGTEXT, false)
+ change_integer_list (sbs_formats, sbs_formats_text)
+
change_safe()
add_integer( "video-title-timeout", 5000, VIDEO_TITLE_TIMEOUT_TEXT,
VIDEO_TITLE_TIMEOUT_LONGTEXT, false )
--
2.12.2.windows.2
From a2c8ef7c698566035b9500601fcc0a47508b71f3 Mon Sep 17 00:00:00 2001
From: Mohammed Danish <shaan3@gmail.com>
Date: Tue, 4 Jul 2017 15:18:13 +0200
Subject: [PATCH 1/2] avcodec: read the Stereo3D side data
---
modules/codec/avcodec/video.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index 2548098..d1fc6ce 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -844,6 +844,43 @@ static void DecodeSidedata( decoder_t *p_dec, const AVFrame *frame, picture_t *p
}
#endif
+#if LIBAVUTIL_VERSION_CHECK( 52, 20, 0, 58, 100 )
+ const AVFrameSideData *p_stereo3d_data =
+ av_frame_get_side_data( frame,
+ AV_FRAME_DATA_STEREO3D );
+ if( p_stereo3d_data )
+ {
+ const struct AVStereo3D *stereo_data =
+ (const AVStereo3D *) p_stereo3d_data->data;
+ switch (stereo_data->type)
+ {
+ case AV_STEREO3D_SIDEBYSIDE:
+ p_pic->format.multiview_mode = MULTIVIEW_STEREO_SBS;
+ break;
+ case AV_STEREO3D_TOPBOTTOM:
+ p_pic->format.multiview_mode = MULTIVIEW_STEREO_TB;
+ break;
+ case AV_STEREO3D_FRAMESEQUENCE:
+ p_pic->format.multiview_mode = MULTIVIEW_STEREO_FRAME;
+ break;
+ case AV_STEREO3D_COLUMNS:
+ p_pic->format.multiview_mode = MULTIVIEW_STEREO_ROW;
+ break;
+ case AV_STEREO3D_LINES:
+ p_pic->format.multiview_mode = MULTIVIEW_STEREO_COL;
+ break;
+ case AV_STEREO3D_CHECKERBOARD:
+ p_pic->format.multiview_mode = MULTIVIEW_STEREO_CHECKERBOARD;
+ break;
+ case AV_STEREO3D_2D:
+ default:
+ p_pic->format.multiview_mode = MULTIVIEW_2D;
+ break;
+ }
+ p_dec->fmt_out.video.multiview_mode = p_pic->format.multiview_mode;
+ }
+#endif
+
if (format_changed)
decoder_UpdateVideoFormat( p_dec );
--
2.10.1.windows.1
From 5b08c1206a06c20c77e3610fc5c469f75c8cf3aa Mon Sep 17 00:00:00 2001
From: Mohammed Danish <shaan3@gmail.com>
Date: Wed, 5 Jul 2017 19:29:46 +0530
Subject: [PATCH 2/3] GUI Changes
---
modules/gui/qt/menus.cpp | 4 ++++
src/libvlc.h | 5 +++++
src/video_output/vout_intf.c | 23 +++++++++++++++++++++++
3 files changed, 32 insertions(+)
diff --git a/modules/gui/qt/menus.cpp b/modules/gui/qt/menus.cpp
index 6395a0a068..b0fc88862f 100644
--- a/modules/gui/qt/menus.cpp
+++ b/modules/gui/qt/menus.cpp
@@ -241,6 +241,7 @@ static int VideoAutoMenuBuilder( playlist_t *pl, input_thread_t *p_input,
PUSH_PLVAR( "video-on-top" );
PUSH_PLVAR( "video-wallpaper" );
PUSH_VAR( "video-snapshot" );
+ PUSH_VAR( "s3d-output" );
PUSH_VAR( "zoom" );
PUSH_VAR( "autoscale" );
PUSH_VAR( "aspect-ratio" );
@@ -671,6 +672,9 @@ QMenu *VLCMenuBar::VideoMenu( intf_thread_t *p_intf, QMenu *current )
current->addMenu( rendererMenu );
current->addSeparator();
+ addActionWithSubmenu( current, "s3d-output", qtr( "&3D Output" ) );
+
+ current->addSeparator();
/* Surface modifiers */
addActionWithCheckbox( current, "fullscreen", qtr( "&Fullscreen" ) );
addActionWithCheckbox( current, "autoscale", qtr( "Always Fit &Window" ) );
diff --git a/src/libvlc.h b/src/libvlc.h
index 299795c549..c0a4c3feae 100644
--- a/src/libvlc.h
+++ b/src/libvlc.h
@@ -172,6 +172,11 @@ void vlc_objres_remove(vlc_object_t *obj, void *data,
#define ZOOM_ORIGINAL_KEY_TEXT N_("1:1 Original")
#define ZOOM_DOUBLE_KEY_TEXT N_("2:1 Double")
+#define S3D_SECTION N_("Multiview")
+#define S3D_AUTO_KEY_TEXT N_("Auto-detect")
+#define S3D_LEFT_ONLY_KEY_TEXT N_("Left Only")
+#define S3D_RIGHT_ONLY_KEY_TEXT N_("Right Only")
+#define S3D_SBS_STEREO_KEY_TEXT N_("Stereo")
/**
* Private LibVLC instance data.
*/
diff --git a/src/video_output/vout_intf.c b/src/video_output/vout_intf.c
index 631099c3ee..d6d1a7babf 100644
--- a/src/video_output/vout_intf.c
+++ b/src/video_output/vout_intf.c
@@ -81,6 +81,17 @@ static int ViewpointCallback( vlc_object_t *, char const *,
*****************************************************************************/
static const struct
{
+ int i_value;
+ char psz_label[12];
+} p_3D_output_format_values[] = {
+ { 0, N_("Auto-detect") },
+ { 1, N_("Left Only") },
+ { 2, N_("Right Only") },
+ { 3, N_("Stereo") },
+};
+
+static const struct
+{
double f_value;
char psz_label[13];
} p_zoom_values[] = {
@@ -185,6 +196,18 @@ void vout_IntfInit( vout_thread_t *p_vout )
var_AddCallback( p_vout, "zoom", ZoomCallback, NULL );
+ var_Create( p_vout, "s3d-output", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
+
+ text.psz_string = _("3d-output");
+ var_Change( p_vout, "s3d-output", VLC_VAR_SETTEXT, &text, NULL );
+
+ for( size_t i = 0; i < ARRAY_SIZE(p_3D_output_format_values); i++ )
+ {
+ val.i_int = p_3D_output_format_values[i].i_value;
+ text.psz_string = vlc_gettext( p_3D_output_format_values[i].psz_label );
+ var_Change( p_vout, "s3d-output", VLC_VAR_ADDCHOICE, &val, &text );
+ }
+
/* Crop offset vars */
var_Create( p_vout, "crop-left", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
var_Create( p_vout, "crop-top", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND );
--
2.12.2.windows.2
From d99bfffa5c84435741327f544b122eb9ef5799cd Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@videolabs.io>
Date: Tue, 4 Jul 2017 15:24:31 +0200
Subject: [PATCH 2/2] decoder: don't create a new vout when just the multiview
mode changes
Also don't call DecoderUpdateFormatLocked() again if it was called just before.
If the vout doesn't handle the multiview mode, recreating it won't change anything.
---
src/input/decoder.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/input/decoder.c b/src/input/decoder.c
index dac3137..a8500fd 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -418,8 +418,7 @@ static int vout_update_format( decoder_t *p_dec )
|| p_dec->fmt_out.i_codec != p_owner->fmt.video.i_chroma
|| (int64_t)p_dec->fmt_out.video.i_sar_num * p_owner->fmt.video.i_sar_den !=
(int64_t)p_dec->fmt_out.video.i_sar_den * p_owner->fmt.video.i_sar_num ||
- p_dec->fmt_out.video.orientation != p_owner->fmt.video.orientation ||
- p_dec->fmt_out.video.multiview_mode != p_owner->fmt.video.multiview_mode )
+ p_dec->fmt_out.video.orientation != p_owner->fmt.video.orientation )
{
vout_thread_t *p_vout;
@@ -533,14 +532,16 @@ static int vout_update_format( decoder_t *p_dec )
return -1;
}
}
-
+ else
if ( memcmp( &p_dec->fmt_out.video.mastering,
&p_owner->fmt.video.mastering,
sizeof(p_owner->fmt.video.mastering)) ||
p_dec->fmt_out.video.lighting.MaxCLL !=
p_owner->fmt.video.lighting.MaxCLL ||
p_dec->fmt_out.video.lighting.MaxFALL !=
- p_owner->fmt.video.lighting.MaxFALL)
+ p_owner->fmt.video.lighting.MaxFALL ||
+ p_dec->fmt_out.video.multiview_mode !=
+ p_owner->fmt.video.multiview_mode )
{
/* the format has changed but we don't need a new vout */
vlc_mutex_lock( &p_owner->lock );
--
2.10.1.windows.1
From 93600a8caf49745a344f4eebedd242cabb01b236 Mon Sep 17 00:00:00 2001
From: Mohammed Danish <shaan3@gmail.com>
Date: Wed, 5 Jul 2017 19:36:14 +0530
Subject: [PATCH 3/3] Callback changes for GUI
---
include/vlc_vout_display.h | 7 +++++++
include/vlc_vout_wrapper.h | 1 +
src/video_output/control.h | 1 +
src/video_output/display.c | 23 +++++++++++++++++++++++
src/video_output/video_output.c | 12 ++++++++++++
src/video_output/vout_internal.h | 1 +
src/video_output/vout_intf.c | 13 +++++++++++++
7 files changed, 58 insertions(+)