[vlc-commits] direct3d9: use point interpolation rather than none

Steve Lhomme git at videolan.org
Thu Mar 23 14:21:38 CET 2017


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Wed Mar 22 16:50:51 2017 +0100| [d0b92b9b4d35a39589a6c58247f307e95cc78140] | committer: Hugo Beauzée-Luyssen

direct3d9: use point interpolation rather than none

We could use linear interpolation but in software decoding the decoder pool is
not initialized with black so we would interpolate with uninitialized (green)
lines/colons.

Signed-off-by: Hugo Beauzée-Luyssen <hugo at beauzee.fr>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d0b92b9b4d35a39589a6c58247f307e95cc78140
---

 modules/video_output/win32/direct3d9.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index ae0c693..16b0678 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -127,6 +127,9 @@ struct vout_display_sys_t
     D3DPRESENT_PARAMETERS   d3dpp;
     bool                    use_d3d9ex;
 
+    D3DTEXTUREFILTERTYPE    minFilter;
+    D3DTEXTUREFILTERTYPE    magFilter;
+
     // scene objects
     LPDIRECT3DTEXTURE9      d3dtex;
     LPDIRECT3DVERTEXBUFFER9 d3dvtc;
@@ -1294,19 +1297,27 @@ static int Direct3D9CreateScene(vout_display_t *vd, const video_format_t *fmt)
     IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_ADDRESSV, D3DTADDRESS_CLAMP);
 
     // Set linear filtering quality
-    if (sys->d3dcaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFLINEAR) {
+    /* we can't use linear interpolation in software decoding, the pictures
+     * are not initialized to black */
+    if ( is_d3d9_opaque(vd->source.i_chroma) &&
+         sys->d3dcaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFLINEAR ) {
         //msg_Dbg(vd, "Using D3DTEXF_LINEAR for minification");
         IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
+        sys->minFilter = D3DTEXF_LINEAR;
     } else {
         //msg_Dbg(vd, "Using D3DTEXF_POINT for minification");
         IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
+        sys->minFilter = D3DTEXF_POINT;
     }
-    if (sys->d3dcaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR) {
+    if ( is_d3d9_opaque(vd->source.i_chroma) &&
+         sys->d3dcaps.TextureFilterCaps & D3DPTFILTERCAPS_MAGFLINEAR ) {
         //msg_Dbg(vd, "Using D3DTEXF_LINEAR for magnification");
         IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
+        sys->magFilter = D3DTEXF_LINEAR;
     } else {
         //msg_Dbg(vd, "Using D3DTEXF_POINT for magnification");
         IDirect3DDevice9_SetSamplerState(d3ddev, 0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
+        sys->magFilter = D3DTEXF_POINT;
     }
 
     // set maximum ambient light
@@ -1658,7 +1669,14 @@ static int Direct3D9ImportPicture(vout_display_t *vd,
 
     /* Copy picture surface into texture surface
      * color space conversion happen here */
-    hr = IDirect3DDevice9_StretchRect(sys->d3ddev, source, &vd->sys->sys.rect_src_clipped, destination, NULL, D3DTEXF_NONE );
+    D3DTEXTUREFILTERTYPE filterType;
+    if (sys->sys.rect_src_clipped.right < sys->sys.rect_dest_clipped.right)
+        filterType = sys->magFilter;
+    else if (sys->sys.rect_src_clipped.right > sys->sys.rect_dest_clipped.right)
+        filterType = sys->minFilter;
+    else
+        filterType = D3DTEXF_NONE;
+    hr = IDirect3DDevice9_StretchRect(sys->d3ddev, source, &sys->sys.rect_src_clipped, destination, NULL, filterType );
     IDirect3DSurface9_Release(destination);
     if (FAILED(hr)) {
         msg_Dbg(vd, "Failed IDirect3DDevice9_StretchRect: source 0x%p 0x%0lx",



More information about the vlc-commits mailing list