[vlc-commits] direct3d9: Fix subpictures display.

Hugo Beauzée-Luyssen git at videolan.org
Tue May 23 18:50:37 CEST 2017


vlc | branch: master | Hugo Beauzée-Luyssen <hugo at beauzee.fr> | Tue May 23 18:00:48 2017 +0200| [a2bacc7e6fa6dda7d1005a001b6589b861750bcd] | committer: Hugo Beauzée-Luyssen

direct3d9: Fix subpictures display.

This partially reverts 52799c39e166b249df73b376bd3a18bb486367e1

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

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

diff --git a/modules/video_output/win32/direct3d9.c b/modules/video_output/win32/direct3d9.c
index d0700d249c..1d79a2f1f7 100644
--- a/modules/video_output/win32/direct3d9.c
+++ b/modules/video_output/win32/direct3d9.c
@@ -1629,8 +1629,8 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
         }
         if (!d3dr->texture) {
             d3dr->format = sys->d3dregion_format;
-            d3dr->width  = r->fmt.i_width;
-            d3dr->height = r->fmt.i_height;
+            d3dr->width  = r->fmt.i_visible_width;
+            d3dr->height = r->fmt.i_visible_height;
             hr = IDirect3DDevice9_CreateTexture(sys->d3ddev,
                                                 d3dr->width, d3dr->height,
                                                 1,
@@ -1656,21 +1656,23 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
         if (SUCCEEDED(hr)) {
             uint8_t  *dst_data   = lock.pBits;
             int       dst_pitch  = lock.Pitch;
-            uint8_t  *src_data   = r->p_picture->p->p_pixels;
+            const int src_offset = r->fmt.i_y_offset * r->p_picture->p->i_pitch +
+                                   r->fmt.i_x_offset * r->p_picture->p->i_pixel_pitch;
+            uint8_t  *src_data   = &r->p_picture->p->p_pixels[src_offset];
             int       src_pitch  = r->p_picture->p->i_pitch;
 
             if (d3dr->format == D3DFMT_A8B8G8R8) {
-                if (dst_pitch == r->p_picture->p->i_pitch) {
-                    memcpy(dst_data, src_data, r->fmt.i_height * dst_pitch);
+                if (dst_pitch == r->p_picture->p->i_visible_pitch) {
+                    memcpy(dst_data, src_data, r->fmt.i_visible_height * dst_pitch);
                 } else {
-                    int copy_pitch = __MIN(dst_pitch, r->p_picture->p->i_pitch);
-                    for (unsigned y = 0; y < r->fmt.i_height; y++) {
+                    int copy_pitch = __MIN(dst_pitch, r->p_picture->p->i_visible_pitch);
+                    for (unsigned y = 0; y < r->fmt.i_visible_height; y++) {
                         memcpy(&dst_data[y * dst_pitch], &src_data[y * src_pitch], copy_pitch);
                     }
                 }
             } else {
-                int copy_pitch = __MIN(dst_pitch, r->p_picture->p->i_pitch);
-                for (unsigned y = 0; y < r->fmt.i_height; y++) {
+                int copy_pitch = __MIN(dst_pitch, r->p_picture->p->i_visible_pitch);
+                for (unsigned y = 0; y < r->fmt.i_visible_height; y++) {
                     for (int x = 0; x < copy_pitch; x += 4) {
                         dst_data[y * dst_pitch + x + 0] = src_data[y * src_pitch + x + 2];
                         dst_data[y * dst_pitch + x + 1] = src_data[y * src_pitch + x + 1];
@@ -1693,9 +1695,9 @@ static void Direct3D9ImportSubpicture(vout_display_t *vd,
 
         RECT dst;
         dst.left   = video.left + scale_w * r->i_x,
-        dst.right  = dst.left + scale_w * r->fmt.i_width,
+        dst.right  = dst.left + scale_w * r->fmt.i_visible_width,
         dst.top    = video.top  + scale_h * r->i_y,
-        dst.bottom = dst.top  + scale_h * r->fmt.i_height,
+        dst.bottom = dst.top  + scale_h * r->fmt.i_visible_height,
         Direct3D9SetupVertices(d3dr->vertex, NULL, NULL,
                               &dst, subpicture->i_alpha * r->i_alpha / 255, ORIENT_NORMAL);
     }



More information about the vlc-commits mailing list