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

Steve Lhomme git at videolan.org
Thu Mar 23 15:16:20 CET 2017


vlc/vlc-2.2 | branch: master | Steve Lhomme <robux4 at videolabs.io> | Thu Mar 23 15:06:50 2017 +0100| [ba313729689218a26b648428b80f629eeb72aa51] | 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.

Manually cherry-picked from d0b92b9b4d35a39589a6c58247f307e95cc78140

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

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

 modules/video_output/msw/common.h   |  2 ++
 modules/video_output/msw/direct3d.c | 19 ++++++++++++++++---
 2 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/modules/video_output/msw/common.h b/modules/video_output/msw/common.h
index 5ddf85e..d35b4f3 100644
--- a/modules/video_output/msw/common.h
+++ b/modules/video_output/msw/common.h
@@ -154,6 +154,8 @@ struct vout_display_sys_t
     D3DCAPS9                d3dcaps;
     LPDIRECT3DDEVICE9       d3ddev;
     D3DPRESENT_PARAMETERS   d3dpp;
+    D3DTEXTUREFILTERTYPE    minFilter;
+    D3DTEXTUREFILTERTYPE    magFilter;
 
     // scene objects
     LPDIRECT3DTEXTURE9      d3dtex;
diff --git a/modules/video_output/msw/direct3d.c b/modules/video_output/msw/direct3d.c
index acb0fa0..3d89c74 100644
--- a/modules/video_output/msw/direct3d.c
+++ b/modules/video_output/msw/direct3d.c
@@ -1106,19 +1106,25 @@ static int Direct3DCreateScene(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 ( 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 ( 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
@@ -1463,7 +1469,14 @@ static int Direct3DImportPicture(vout_display_t *vd,
 
     /* Copy picture surface into texture surface
      * color space conversion happen here */
-    hr = IDirect3DDevice9_StretchRect(sys->d3ddev, source, &vd->sys->rect_src_clipped, destination, NULL, D3DTEXF_NONE );
+    D3DTEXTUREFILTERTYPE filterType;
+    if (sys->rect_src_clipped.right < sys->rect_dest_clipped.right)
+        filterType = sys->magFilter;
+    else if (sys->rect_src_clipped.right > sys->rect_dest_clipped.right)
+        filterType = sys->minFilter;
+    else
+        filterType = D3DTEXF_NONE;
+    hr = IDirect3DDevice9_StretchRect(sys->d3ddev, source, &sys->rect_src_clipped, destination, NULL, filterType );
     IDirect3DSurface9_Release(destination);
     if (FAILED(hr)) {
         msg_Dbg(vd, "%s:%d (hr=0x%0lX)", __FUNCTION__, __LINE__, hr);



More information about the vlc-commits mailing list