[vlc-commits] [Git][videolan/vlc][3.0.x] 7 commits: d3d11_scaler: fix position when the source as a SAR

Steve Lhomme (@robUx4) gitlab at videolan.org
Sat May 27 05:51:20 UTC 2023



Steve Lhomme pushed to branch 3.0.x at VideoLAN / VLC


Commits:
4f39d5b4 by Steve Lhomme at 2023-05-26T06:48:34+02:00
d3d11_scaler: fix position when the source as a SAR

(cherry picked from commit 233bd70227619a5c38c449d3c31f592545702bd4)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

- - - - -
51dd20cc by Steve Lhomme at 2023-05-26T06:57:38+02:00
direct3d11: use a custom d3d_fmt for the pool

This will allow the VideoProcessor to use its own internal format, which
also needs to be know when creating the shaders.

- - - - -
70f0f418 by Steve Lhomme at 2023-05-26T06:57:38+02:00
direct3d11: initialize the VideoProcessor before the shaders

This will allow the VideoProcessor to use its own internal format.

- - - - -
a592a95e by Steve Lhomme at 2023-05-26T06:57:38+02:00
direct3d11: get the d3d_format from the d3d11_scaler

It could select a different format than the one the decoder sends.

(cherry picked from commit 894142a0cb0b4b33c9a3f56579b67b315a1e8a11)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

- - - - -
54cfa3e7 by Steve Lhomme at 2023-05-26T06:57:38+02:00
d3d11_scaler: force RGBA output from the video processor

(cherry picked from commit 1f529133a4440d3fc0b04a77cb06638aebe32170)
Signed-off-by: Steve Lhomme <robux4 at ycbcr.xyz>

- - - - -
408c3420 by Steve Lhomme at 2023-05-26T07:23:38+02:00
direct3d11: use accurate logging of Scaler mode

If we fallback to linear the log was wrong.

- - - - -
f3dd90c6 by Steve Lhomme at 2023-05-26T07:29:36+02:00
d3d11_scaler: don't use upscaler with software chroma

This was already the case before 1f529133a4440d3fc0b04a77cb06638aebe32170.
We can't feed the VideoProcessor with DXGI_FORMAT_UNKNOWN.

- - - - -


3 changed files:

- modules/video_output/win32/d3d11_scaler.cpp
- modules/video_output/win32/d3d11_scaler.h
- modules/video_output/win32/direct3d11.c


Changes:

=====================================
modules/video_output/win32/d3d11_scaler.cpp
=====================================
@@ -42,7 +42,7 @@ static const d3d_format_t *GetDirectRenderingFormat(vlc_object_t *vd, d3d11_devi
 }
 
 d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *vd, d3d11_device_t *d3d_dev, vlc_fourcc_t i_chroma,
-                                   bool super_res)
+                                   bool super_res, const d3d_format_t **out_fmt)
 {
     bool canProcess = !super_res;
     // NVIDIA 530+ driver
@@ -64,7 +64,20 @@ d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *vd, d3d11_device_t *d3d_dev, vl
         return nullptr;
     }
 
-    const d3d_format_t *fmt = GetDirectRenderingFormat(vd, d3d_dev, i_chroma);
+    if ((*out_fmt)->formatTexture == DXGI_FORMAT_UNKNOWN)
+    {
+        msg_Warn(vd, "chroma upscale of %4.4s not supported", (char*)&i_chroma);
+        return nullptr;
+    }
+    const d3d_format_t *fmt = nullptr;
+    if ((*out_fmt)->bitsPerChannel > 10)
+        fmt = GetDirectRenderingFormat(vd, d3d_dev, VLC_CODEC_RGBA64);
+    if (fmt == nullptr && (*out_fmt)->bitsPerChannel > 8)
+        fmt = GetDirectRenderingFormat(vd, d3d_dev, VLC_CODEC_RGBA10);
+    if (fmt == nullptr)
+        fmt = GetDirectRenderingFormat(vd, d3d_dev, VLC_CODEC_RGBA);
+    if (fmt == nullptr)
+        fmt = GetDirectRenderingFormat(vd, d3d_dev, VLC_CODEC_BGRA);
     if (fmt == nullptr || fmt->formatTexture == DXGI_FORMAT_UNKNOWN)
     {
         msg_Warn(vd, "chroma upscale of %4.4s not supported", (char*)&i_chroma);
@@ -92,6 +105,7 @@ d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *vd, d3d11_device_t *d3d_dev, vl
 
     scaleProc->d3d_fmt = fmt;
     scaleProc->super_res = super_res;
+    *out_fmt = scaleProc->d3d_fmt;
     return scaleProc;
 error:
     delete scaleProc;
@@ -135,6 +149,9 @@ int D3D11_UpscalerUpdate(vlc_object_t *vd, d3d11_scaler *scaleProc, d3d11_device
     quad_fmt->i_width = quad_fmt->i_visible_width = out_width;
     quad_fmt->i_y_offset = 0;
     quad_fmt->i_height = quad_fmt->i_visible_height = out_height;
+    quad_fmt->i_sar_num = 1;
+    quad_fmt->i_sar_den = 1;
+    quad_fmt->b_color_range_full = true;
 
     if (scaleProc->Width == out_width && scaleProc->Height == out_height &&
         memcmp(&scaleProc->place, &place, sizeof(place)) == 0)


=====================================
modules/video_output/win32/d3d11_scaler.h
=====================================
@@ -20,7 +20,7 @@ extern "C" {
 
 struct d3d11_scaler;
 
-struct d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *, d3d11_device_t*, vlc_fourcc_t i_chroma, bool super_res);
+struct d3d11_scaler *D3D11_UpscalerCreate(vlc_object_t *, d3d11_device_t*, vlc_fourcc_t i_chroma, bool super_res, const d3d_format_t **);
 void D3D11_UpscalerDestroy(struct d3d11_scaler *);
 int D3D11_UpscalerUpdate(vlc_object_t *, struct d3d11_scaler *, d3d11_device_t*,
                          const video_format_t *, video_format_t *,


=====================================
modules/video_output/win32/direct3d11.c
=====================================
@@ -112,6 +112,7 @@ struct vout_display_sys_t
 {
     vout_display_sys_win32_t sys;
     video_format_t           pool_fmt;
+    const d3d_format_t       *pool_d3dfmt;
 
     int                      log_level;
 
@@ -396,7 +397,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
         }
     }
 
-    if (sys->picQuad.formatInfo->formatTexture == DXGI_FORMAT_UNKNOWN)
+    if (sys->pool_d3dfmt->formatTexture == DXGI_FORMAT_UNKNOWN)
         sys->sys.pool = picture_pool_NewFromFormat( &sys->pool_fmt, pool_size );
     else
     {
@@ -407,7 +408,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
             /* only provide enough for the filters, we can still do direct rendering */
             slices = __MIN(slices, 6);
 
-        if (AllocateTextures(vd, &sys->d3d_dev, sys->picQuad.formatInfo, &sys->pool_fmt, slices, textures))
+        if (AllocateTextures(vd, &sys->d3d_dev, sys->pool_d3dfmt, &sys->pool_fmt, slices, textures))
             goto error;
 
         pictures = calloc(pool_size, sizeof(*pictures));
@@ -431,7 +432,7 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
             }
 
             picsys->slice_index = picture_count < slices ? picture_count : 0;
-            picsys->formatTexture = sys->picQuad.formatInfo->formatTexture;
+            picsys->formatTexture = sys->pool_d3dfmt->formatTexture;
             picsys->context = sys->d3d_dev.d3dcontext;
 
             picture_resource_t resource = {
@@ -455,11 +456,11 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned pool_size)
         if (is_d3d11_opaque(sys->pool_fmt.i_chroma) && !sys->legacy_shader)
 #endif
         {
-            sys->picQuad.resourceCount = DxgiResourceCount(sys->picQuad.formatInfo);
+            sys->picQuad.resourceCount = DxgiResourceCount(sys->pool_d3dfmt);
             for (picture_count = 0; picture_count < slices; picture_count++) {
                 if (!pictures[picture_count]->p_sys->texture[0])
                     continue;
-                if (D3D11_AllocateShaderView(vd, sys->d3d_dev.d3ddevice, sys->picQuad.formatInfo,
+                if (D3D11_AllocateShaderView(vd, sys->d3d_dev.d3ddevice, sys->pool_d3dfmt,
                                        pictures[picture_count]->p_sys->texture, picture_count,
                                        pictures[picture_count]->p_sys->resourceView))
                     goto error;
@@ -1456,12 +1457,12 @@ static void InitScaleProcessor(vout_display_t *vd)
         return;
 
     sys->scaleProc = D3D11_UpscalerCreate(VLC_OBJECT(vd), &sys->d3d_dev, sys->quad_fmt.i_chroma,
-                                          sys->upscaleMode == upscale_SuperResolution);
+                                          sys->upscaleMode == upscale_SuperResolution,
+                                          &sys->picQuad.formatInfo);
     if (sys->scaleProc == NULL)
         sys->upscaleMode = upscale_LinearSampler;
 
-    msg_Dbg(vd, "Using %s scaler", sys->upscaleMode != upscale_SuperResolution ?
-            "Video Processor": "Super Resolution");
+    msg_Dbg(vd, "Using %s scaler", ppsz_upscale_mode_text[sys->upscaleMode]);
 }
 
 static int Direct3D11Open(vout_display_t *vd, bool external_device)
@@ -1519,6 +1520,22 @@ static int Direct3D11Open(vout_display_t *vd, bool external_device)
 
     D3D11SetColorSpace(vd);
 
+    char *psz_upscale = var_InheritString(vd, "d3d11-upscale-mode");
+    if (strcmp("linear", psz_upscale) == 0)
+        sys->upscaleMode = upscale_LinearSampler;
+    else if (strcmp("point", psz_upscale) == 0)
+        sys->upscaleMode = upscale_PointSampler;
+    else if (strcmp("processor", psz_upscale) == 0)
+        sys->upscaleMode = upscale_VideoProcessor;
+    else if (strcmp("super", psz_upscale) == 0)
+        sys->upscaleMode = upscale_SuperResolution;
+    else
+    {
+        msg_Warn(vd, "unknown upscale mode %s, using linear sampler", psz_upscale);
+        sys->upscaleMode = upscale_LinearSampler;
+    }
+    free(psz_upscale);
+
     video_format_t fmt;
     video_format_Copy(&fmt, &vd->source);
     int err = SetupOutputFormat(vd, &fmt);
@@ -1546,27 +1563,10 @@ static int Direct3D11Open(vout_display_t *vd, bool external_device)
             return err;
     }
 
-    char *psz_upscale = var_InheritString(vd, "d3d11-upscale-mode");
-    if (strcmp("linear", psz_upscale) == 0)
-        sys->upscaleMode = upscale_LinearSampler;
-    else if (strcmp("point", psz_upscale) == 0)
-        sys->upscaleMode = upscale_PointSampler;
-    else if (strcmp("processor", psz_upscale) == 0)
-        sys->upscaleMode = upscale_VideoProcessor;
-    else if (strcmp("super", psz_upscale) == 0)
-        sys->upscaleMode = upscale_SuperResolution;
-    else
-    {
-        msg_Warn(vd, "unknown upscale mode %s, using linear sampler", psz_upscale);
-        sys->upscaleMode = upscale_LinearSampler;
-    }
-    free(psz_upscale);
-
     video_format_Init(&sys->quad_fmt, vd->source.i_chroma);
     video_format_Copy(&sys->quad_fmt, &vd->source);
     if (sys->upscaleMode == upscale_VideoProcessor || sys->upscaleMode == upscale_SuperResolution)
         sys->sys.src_fmt = &sys->quad_fmt;
-    InitScaleProcessor(vd);
 
     video_format_Copy(&sys->pool_fmt, &fmt);
 
@@ -1675,6 +1675,7 @@ static int SetupOutputFormat(vout_display_t *vd, video_format_t *fmt)
        msg_Err(vd, "Could not get a suitable texture pixel format");
        return VLC_EGENERIC;
     }
+    sys->pool_d3dfmt = sys->picQuad.formatInfo;
 
     msg_Dbg( vd, "Using pixel format %s for chroma %4.4s", sys->picQuad.formatInfo->name,
                  (char *)&fmt->i_chroma );
@@ -1686,6 +1687,8 @@ static int SetupOutputFormat(vout_display_t *vd, video_format_t *fmt)
     if (!sys->d3dregion_format)
         sys->d3dregion_format = GetBlendableFormat(vd, VLC_CODEC_BGRA);
 
+    InitScaleProcessor(vd);
+
     if (Direct3D11CreateFormatResources(vd, fmt)) {
         msg_Err(vd, "Failed to allocate format resources");
         return VLC_EGENERIC;



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/90e7e1c3fc2544119a3ca1cf0e4e41508bf173c8...f3dd90c6b2c3390315e6010511830a75337063e9

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/90e7e1c3fc2544119a3ca1cf0e4e41508bf173c8...f3dd90c6b2c3390315e6010511830a75337063e9
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list