[vlc-devel] [PATCH 1/2] vout: subtitles outside the video area in direct3d9

Jean-Baptiste Kempf jb at videolan.org
Fri Mar 3 16:04:31 CET 2017


Hello,

I don't think this can be any good: you cannot mix the core changes with
the D3D9 or the OpenGL ones.

Best,

On Thu, 2 Mar 2017, at 10:06, Salah-Eddin Shaban wrote:
> ---
>  include/vlc_vout_display.h             |  1 +
>  modules/video_output/win32/common.c    | 14 +++++++++++++-
>  modules/video_output/win32/direct3d9.c | 20 ++++++++++++--------
>  src/video_output/video_output.c        |  9 +++++++++
>  4 files changed, 35 insertions(+), 9 deletions(-)
> 
> diff --git a/include/vlc_vout_display.h b/include/vlc_vout_display.h
> index 46825be..05ea39b 100644
> --- a/include/vlc_vout_display.h
> +++ b/include/vlc_vout_display.h
> @@ -131,6 +131,7 @@ typedef struct {
>      bool has_hide_mouse;                    /* Is mouse automatically
>      hidden */
>      bool has_pictures_invalid;              /* Will
>      VOUT_DISPLAY_EVENT_PICTURES_INVALID be used */
>      bool needs_event_thread VLC_DEPRECATED; /* Will events (key at
>      least) be emitted using an independent thread */
> +    bool scale_spu_to_display;              /* Subpictures not
> restricted to video area */
>      const vlc_fourcc_t *subpicture_chromas; /* List of supported chromas
>      for subpicture rendering. */
>  } vout_display_info_t;
>  
> diff --git a/modules/video_output/win32/common.c
> b/modules/video_output/win32/common.c
> index f2b97b8..5fca339 100644
> --- a/modules/video_output/win32/common.c
> +++ b/modules/video_output/win32/common.c
> @@ -202,13 +202,25 @@ void UpdateRects(vout_display_t *vd,
>      EventThreadUpdateSourceAndPlace(sys->event, source, &place);
>  
>      if (sys->hvideownd)
> +#if defined(MODULE_NAME_IS_direct3d9)
> +        /* let the video window fill the whole display */
> +        SetWindowPos(sys->hvideownd, 0,
> +                     rect.left, rect.top, rect.right, rect.bottom,
> +                     SWP_NOCOPYBITS | SWP_NOZORDER |
> SWP_ASYNCWINDOWPOS);
> +#else
>          SetWindowPos(sys->hvideownd, 0,
>              place.x, place.y, place.width, place.height,
>              SWP_NOCOPYBITS | SWP_NOZORDER | SWP_ASYNCWINDOWPOS);
>  #endif
> +#endif
>  
>      /* Destination image position and dimensions */
> -#if (defined(MODULE_NAME_IS_direct3d9) ||
> defined(MODULE_NAME_IS_direct3d11)) && !VLC_WINSTORE_APP
> +#if defined(MODULE_NAME_IS_direct3d9) && !VLC_WINSTORE_APP
> +    rect_dest.left = place.x;
> +    rect_dest.right = rect_dest.left + place.width;
> +    rect_dest.top = place.y;
> +    rect_dest.bottom = rect_dest.top + place.height;
> +#elif defined(MODULE_NAME_IS_direct3d11) && !VLC_WINSTORE_APP
>      rect_dest.left = 0;
>      rect_dest.right = place.width;
>      rect_dest.top = 0;
> diff --git a/modules/video_output/win32/direct3d9.c
> b/modules/video_output/win32/direct3d9.c
> index f190e65..ef22af7 100644
> --- a/modules/video_output/win32/direct3d9.c
> +++ b/modules/video_output/win32/direct3d9.c
> @@ -262,6 +262,7 @@ static int Open(vlc_object_t *object)
>      info.has_double_click = true;
>      info.has_hide_mouse = false;
>      info.has_pictures_invalid = !is_d3d9_opaque(fmt.i_chroma);
> +    info.scale_spu_to_display = true;
>      if (var_InheritBool(vd, "direct3d9-hw-blending") &&
>          sys->d3dregion_format != D3DFMT_UNKNOWN &&
>          (sys->d3dcaps.SrcBlendCaps  & D3DPBLENDCAPS_SRCALPHA) &&
> @@ -428,6 +429,9 @@ static void Prepare(vout_display_t *vd, picture_t
> *picture, subpicture_t *subpic
>          return;
>      }
>  
> +    IDirect3DDevice9_Clear(vd->sys->d3ddev, 0, NULL, D3DCLEAR_TARGET,
> +                           D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
> +
>      d3d_region_t picture_region;
>      if (!Direct3D9ImportPicture(vd, &picture_region, surface)) {
>          picture_region.width = picture->format.i_visible_width;
> @@ -460,8 +464,8 @@ static void Display(vout_display_t *vd, picture_t
> *picture, subpicture_t *subpic
>  
>      // Present the back buffer contents to the display
>      // No stretching should happen here !
> -    const RECT src = sys->sys.rect_dest_clipped;
> -    const RECT dst = sys->sys.rect_dest_clipped;
> +    RECT src = { 0, 0, vd->cfg->display.width, vd->cfg->display.height
> };
> +    RECT dst = src;
>  
>      HRESULT hr;
>      if (sys->use_d3d9ex) {
> @@ -1766,15 +1770,15 @@ static void
> Direct3D9ImportSubpicture(vout_display_t *vd,
>              msg_Err(vd, "Failed to lock the texture");
>          }
>  
> -        /* Map the subpicture to sys->sys.rect_dest */
> -        const RECT video = sys->sys.rect_dest;
> -        const float scale_w = (float)(video.right  - video.left) /
> subpicture->i_original_picture_width;
> -        const float scale_h = (float)(video.bottom - video.top)  /
> subpicture->i_original_picture_height;
> +        /* Map the subpicture to the display */
> +        RECT display = { 0, 0, vd->cfg->display.width,
> vd->cfg->display.height };
> +        const float scale_w = (float)(display.right  - display.left) /
> subpicture->i_original_picture_width;
> +        const float scale_h = (float)(display.bottom - display.top)  /
> subpicture->i_original_picture_height;
>  
>          RECT dst;
> -        dst.left   = video.left + scale_w * r->i_x,
> +        dst.left   = display.left + scale_w * r->i_x,
>          dst.right  = dst.left + scale_w * r->fmt.i_visible_width,
> -        dst.top    = video.top  + scale_h * r->i_y,
> +        dst.top    = display.top  + scale_h * r->i_y,
>          dst.bottom = dst.top  + scale_h * r->fmt.i_visible_height,
>          Direct3D9SetupVertices(d3dr->vertex,
>                                &dst, subpicture->i_alpha * r->i_alpha /
>                                255, ORIENT_NORMAL);
> diff --git a/src/video_output/video_output.c
> b/src/video_output/video_output.c
> index 155d6a9..b13fe88 100644
> --- a/src/video_output/video_output.c
> +++ b/src/video_output/video_output.c
> @@ -912,6 +912,15 @@ static int ThreadDisplayRenderPicture(vout_thread_t
> *vout, bool is_forced)
>              fmt_spu.i_height         =
>              fmt_spu.i_visible_height = place.height;
>          }
> +
> +        if( vd->info.scale_spu_to_display )
> +        {
> +            fmt_spu.i_width          =
> +            fmt_spu.i_visible_width  = vd->cfg->display.width;
> +            fmt_spu.i_height         =
> +            fmt_spu.i_visible_height = vd->cfg->display.height;
> +        }
> +
>          subpicture_chromas = vd->info.subpicture_chromas;
>      } else {
>          if (do_early_spu) {
> -- 
> 2.6.6
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


-- 
Jean-Baptiste Kempf -  President
+33 672 704 734


More information about the vlc-devel mailing list