Commit 2f149146 authored by Steve Lhomme's avatar Steve Lhomme

update patchset

the patches are now in 3.0
parent 2523dcf9
From 7a4e50ee418eed84581eb9da839befd7512469d8 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Thu, 14 Sep 2017 12:35:43 +0200
Subject: [PATCH 13/20] video_output: adapt the late threshold to the frame
rate if there's one
---
src/video_output/video_output.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index 640d999..dfe2a3b 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -862,9 +862,14 @@ static int ThreadDisplayPreparePicture(vout_thread_t *vout, bool reuse, bool fra
decoded = picture_fifo_Pop(vout->p->decoder_fifo);
if (decoded) {
if (is_late_dropped && !decoded->b_force) {
+ mtime_t late_threshold;
+ if (decoded->format.i_frame_rate && decoded->format.i_frame_rate_base)
+ late_threshold = ((CLOCK_FREQ/2) * decoded->format.i_frame_rate_base) / decoded->format.i_frame_rate;
+ else
+ late_threshold = VOUT_DISPLAY_LATE_THRESHOLD;
const mtime_t predicted = mdate() + 0; /* TODO improve */
const mtime_t late = predicted - decoded->date;
- if (late > VOUT_DISPLAY_LATE_THRESHOLD) {
+ if (late > late_threshold) {
msg_Warn(vout, "picture is too late to be displayed (missing %"PRId64" ms)", late/1000);
picture_Release(decoded);
vout_statistic_AddLost(&vout->p->statistic, 1);
--
2.10.1.windows.1
From b70db3006308f9b319881203d6d4165d26861656 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 19 Feb 2018 17:30:50 +0100
Subject: [PATCH 14/20] d3d11va: fix leak on error
---
modules/codec/avcodec/d3d11va.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index ac6d6bc..0ffb06a 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -420,6 +420,8 @@ static int D3dCreateDevice(vlc_va_t *va)
hr = ID3D11DeviceContext_QueryInterface(sys->d3d_dev.d3dcontext, &IID_ID3D11VideoContext, &d3dvidctx);
if (FAILED(hr)) {
msg_Err(va, "Could not Query ID3D11VideoContext Interface. (hr=0x%lX)", hr);
+ ID3D11DeviceContext_Release(sys->d3d_dev.d3dcontext);
+ ID3D11Device_Release(sys->d3d_dev.d3ddevice);
return VLC_EGENERIC;
}
sys->d3dvidctx = d3dvidctx;
--
2.10.1.windows.1
From cf91ff601df2d68ffd75dc9951023946d8232951 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 19 Feb 2018 15:24:41 +0100
Subject: [PATCH 15/20] d3d11va: try to decode to P010 with 10 bits decoders
---
modules/codec/avcodec/d3d11va.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 0ffb06a..bf6dcf5 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -530,6 +530,7 @@ static int DxGetInputList(vlc_va_t *va, input_list_t *p_list)
}
extern const GUID DXVA_ModeHEVC_VLD_Main10;
+extern const GUID DXVA_ModeVP9_VLD_10bit_Profile2;
static bool CanUseIntelHEVC(vlc_va_t *va)
{
vlc_va_sys_t *sys = va->sys;
@@ -569,6 +570,8 @@ static int DxSetupOutput(vlc_va_t *va, const GUID *input, const video_format_t *
int idx = 0;
if ( sys->render != DXGI_FORMAT_UNKNOWN )
processorInput[idx++] = sys->render;
+ if (IsEqualGUID(input, &DXVA_ModeHEVC_VLD_Main10) || IsEqualGUID(input, &DXVA_ModeVP9_VLD_10bit_Profile2))
+ processorInput[idx++] = DXGI_FORMAT_P010;
processorInput[idx++] = DXGI_FORMAT_NV12;
processorInput[idx++] = DXGI_FORMAT_420_OPAQUE;
processorInput[idx++] = DXGI_FORMAT_UNKNOWN;
--
2.10.1.windows.1
From 81113b0341fc775613b3db60a45b179156bc27e0 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 19 Feb 2018 12:37:04 +0100
Subject: [PATCH 16/20] direct3d11: only lock the picture if it's plane based
---
modules/video_output/win32/direct3d11.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index ab2a31e..3d13959 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -661,7 +661,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
.picture = pictures,
.picture_count = pool_size,
};
- if (vd->info.is_slow) {
+ if (vd->info.is_slow && !is_d3d11_opaque(surface_fmt.i_chroma)) {
pool_cfg.lock = Direct3D11MapPoolTexture;
//pool_cfg.unlock = Direct3D11UnmapPoolTexture;
}
--
2.10.1.windows.1
From 25c418eee1c7e6285a0417082606521400379cec Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 19 Feb 2018 17:31:33 +0100
Subject: [PATCH 17/20] d3d11va: reuse the global UWP context if possible
---
modules/codec/avcodec/d3d11va.c | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index bf6dcf5..4a83ab1 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -409,12 +409,26 @@ static int D3dCreateDevice(vlc_va_t *va)
return VLC_SUCCESS;
}
- /* */
- hr = D3D11_CreateDevice(va, &sys->hd3d, true, &sys->d3d_dev);
- if (FAILED(hr)) {
- msg_Err(va, "D3D11CreateDevice failed. (hr=0x%lX)", hr);
- return VLC_EGENERIC;
+#if VLC_WINSTORE_APP
+ sys->d3d_dev.d3dcontext = var_InheritInteger(va, "winrt-d3dcontext");
+ if (likely(sys->d3d_dev.d3dcontext))
+ {
+ ID3D11Device* d3ddevice = NULL;
+ ID3D11DeviceContext_GetDevice(sys->d3d_dev.d3dcontext, &sys->d3d_dev.d3ddevice);
+ ID3D11DeviceContext_AddRef(sys->d3d_dev.d3dcontext);
+ ID3D11Device_Release(sys->d3d_dev.d3ddevice);
}
+#endif
+
+ /* */
+ if (!sys->d3d_dev.d3ddevice)
+ {
+ hr = D3D11_CreateDevice(va, &sys->hd3d, true, &sys->d3d_dev);
+ if (FAILED(hr)) {
+ msg_Err(va, "D3D11CreateDevice failed. (hr=0x%lX)", hr);
+ return VLC_EGENERIC;
+ }
+ }
void *d3dvidctx = NULL;
hr = ID3D11DeviceContext_QueryInterface(sys->d3d_dev.d3dcontext, &IID_ID3D11VideoContext, &d3dvidctx);
--
2.10.1.windows.1
From 518bbcce8b2ea3fbffe1ec22559a66f6824c2bd8 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 19 Feb 2018 12:39:10 +0100
Subject: [PATCH 18/20] directx_va: adjust the Xbox constraints
It can't handle 4K aligned to 128 but is fine when aligned to 16.
---
modules/codec/avcodec/d3d11va.c | 2 +-
modules/codec/avcodec/directx_va.c | 8 ++++++--
modules/codec/avcodec/directx_va.h | 2 +-
modules/codec/avcodec/dxva2.c | 2 +-
4 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/modules/codec/avcodec/d3d11va.c b/modules/codec/avcodec/d3d11va.c
index 4a83ab1..de4ebea 100644
--- a/modules/codec/avcodec/d3d11va.c
+++ b/modules/codec/avcodec/d3d11va.c
@@ -378,7 +378,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
if (err!=VLC_SUCCESS)
goto error;
- err = directx_va_Setup(va, &sys->dx_sys, ctx, fmt);
+ err = directx_va_Setup(va, &sys->dx_sys, ctx, fmt, isXboxHardware(sys->d3d_dev.d3ddevice));
if (err != VLC_SUCCESS)
goto error;
diff --git a/modules/codec/avcodec/directx_va.c b/modules/codec/avcodec/directx_va.c
index a2bb530..75a56f9 100644
--- a/modules/codec/avcodec/directx_va.c
+++ b/modules/codec/avcodec/directx_va.c
@@ -284,7 +284,7 @@ char *directx_va_GetDecoderName(const GUID *guid)
/* */
int directx_va_Setup(vlc_va_t *va, directx_sys_t *dx_sys, const AVCodecContext *avctx,
- const es_format_t *fmt)
+ const es_format_t *fmt, int flag_xbox)
{
/* */
if (FindVideoServiceConversion(va, dx_sys, fmt, avctx)) {
@@ -307,7 +307,11 @@ int directx_va_Setup(vlc_va_t *va, directx_sys_t *dx_sys, const AVCodecContext *
case AV_CODEC_ID_HEVC:
/* the HEVC DXVA2 spec asks for 128 pixel aligned surfaces to ensure
all coding features have enough room to work with */
- surface_alignment = 128;
+ /* On the Xbox 1/S, the decoder cannot do 4K aligned to 128 but is OK with 64 */
+ if (flag_xbox)
+ surface_alignment = 16;
+ else
+ surface_alignment = 128;
surface_count += 16;
break;
case AV_CODEC_ID_H264:
diff --git a/modules/codec/avcodec/directx_va.h b/modules/codec/avcodec/directx_va.h
index 7dbef97..b8e62aa 100644
--- a/modules/codec/avcodec/directx_va.h
+++ b/modules/codec/avcodec/directx_va.h
@@ -80,7 +80,7 @@ typedef struct
int directx_va_Open(vlc_va_t *, directx_sys_t *);
void directx_va_Close(vlc_va_t *, directx_sys_t *);
-int directx_va_Setup(vlc_va_t *, directx_sys_t *, const AVCodecContext *avctx, const es_format_t *);
+int directx_va_Setup(vlc_va_t *, directx_sys_t *, const AVCodecContext *avctx, const es_format_t *, int flag_xbox);
char *directx_va_GetDecoderName(const GUID *guid);
#endif /* AVCODEC_DIRECTX_VA_H */
diff --git a/modules/codec/avcodec/dxva2.c b/modules/codec/avcodec/dxva2.c
index 25de31d..42f5172 100644
--- a/modules/codec/avcodec/dxva2.c
+++ b/modules/codec/avcodec/dxva2.c
@@ -315,7 +315,7 @@ static int Open(vlc_va_t *va, AVCodecContext *ctx, enum PixelFormat pix_fmt,
if (err!=VLC_SUCCESS)
goto error;
- err = directx_va_Setup(va, &sys->dx_sys, ctx, fmt);
+ err = directx_va_Setup(va, &sys->dx_sys, ctx, fmt, 0);
if (err != VLC_SUCCESS)
goto error;
--
2.10.1.windows.1
From c5b8856cf468de16db1a95de8e709405ca8bab93 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 19 Feb 2018 14:47:48 +0100
Subject: [PATCH 19/20] avcodec: limit the amount of threads to 6 for UWP apps
This will also limit the amount of memory used
---
modules/codec/avcodec/video.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/modules/codec/avcodec/video.c b/modules/codec/avcodec/video.c
index abb6bdd..9df2c41 100644
--- a/modules/codec/avcodec/video.c
+++ b/modules/codec/avcodec/video.c
@@ -542,7 +542,11 @@ int InitVideoDec( vlc_object_t *obj )
i_thread_count++;
//FIXME: take in count the decoding time
+#if VLC_WINSTORE_APP
+ i_thread_count = __MIN( i_thread_count, 6 );
+#else
i_thread_count = __MIN( i_thread_count, p_codec->id == AV_CODEC_ID_HEVC ? 10 : 6 );
+#endif
}
i_thread_count = __MIN( i_thread_count, p_codec->id == AV_CODEC_ID_HEVC ? 32 : 16 );
msg_Dbg( p_dec, "allowing %d thread(s) for decoding", i_thread_count );
--
2.10.1.windows.1
From 1cb366c0dcbcf0234386c03d2f2a50de511e2293 Mon Sep 17 00:00:00 2001
From: Steve Lhomme <robux4@ycbcr.xyz>
Date: Mon, 19 Feb 2018 14:50:10 +0100
Subject: [PATCH 20/20] direct3d11: limit the amount of pool slices on Winstore
apps
They're limited in memory and don't like too many slices. In most cases
the d3d11va pool will be used instead.
---
modules/video_output/win32/direct3d11.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/modules/video_output/win32/direct3d11.c b/modules/video_output/win32/direct3d11.c
index 3d13959..46630ca 100644
--- a/modules/video_output/win32/direct3d11.c
+++ b/modules/video_output/win32/direct3d11.c
@@ -587,6 +587,13 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
surface_fmt.i_width = sys->picQuad.i_width;
surface_fmt.i_height = sys->picQuad.i_height;
+#if VLC_WINSTORE_APP
+ /* Phones and the Xbox are memory constrained, rely on the d3d11va pool
+ * which is always smaller, we still get direct rendering from the decoder */
+ if (is_d3d11_opaque(surface_fmt.i_chroma))
+ pool_size = __MIN(pool_size, 6);
+#endif
+
if (SetupQuad( vd, &surface_fmt, &sys->picQuad, &sys->sys.rect_src_clipped,
sys->picQuadConfig, sys->picQuadPixelShader,
surface_fmt.projection_mode, vd->fmt.orientation ) != VLC_SUCCESS) {
--
2.10.1.windows.1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment