[vlc-devel] [PATCH 1/5] [RFC] win32: add CommonUpdatePicture as it will be needed by the core

Steve Lhomme robux4 at gmail.com
Thu May 28 17:20:49 CEST 2015


---
the D3D11 pool needs to map its writable buffers this way
---
 modules/video_output/Makefile.am      |   9 ++-
 modules/video_output/msw/common.c     |  68 -----------------------
 modules/video_output/msw/common.h     |   1 -
 modules/video_output/msw/direct3d11.c |   2 +
 modules/video_output/msw/direct3d9.c  |   1 +
 modules/video_output/msw/directdraw.c |   1 +
 src/win32/picture.c                   | 102 ++++++++++++++++++++++++++++++++++
 src/win32/picture.h                   |  32 +++++++++++
 8 files changed, 144 insertions(+), 72 deletions(-)
 create mode 100644 src/win32/picture.c
 create mode 100644 src/win32/picture.h

diff --git a/modules/video_output/Makefile.am b/modules/video_output/Makefile.am
index 2c8f930..d7aef95 100644
--- a/modules/video_output/Makefile.am
+++ b/modules/video_output/Makefile.am
@@ -173,7 +173,8 @@ libdirect3d9_plugin_la_SOURCES = video_output/msw/direct3d9.c \
 	video_output/msw/common.c video_output/msw/common.h \
 	video_output/msw/events.c video_output/msw/events.h \
 	video_output/msw/builtin_shaders.h \
-	video_output/msw/win32touch.c video_output/msw/win32touch.h
+	video_output/msw/win32touch.c video_output/msw/win32touch.h \
+	../src/win32/picture.c ../src/win32/picture.h
 libdirect3d9_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) \
 	-DMODULE_NAME_IS_direct3d9
 libdirect3d9_plugin_la_LIBADD = -lgdi32 -lole32 -luuid
@@ -182,7 +183,8 @@ vout_LTLIBRARIES += $(LTLIBdirect3d9)
 EXTRA_LTLIBRARIES += libdirect3d9_plugin.la
 
 libdirect3d11_plugin_la_SOURCES = video_output/msw/direct3d11.c \
- video_output/msw/common.c video_output/msw/common.h
+	video_output/msw/common.c video_output/msw/common.h \
+	../src/win32/picture.c ../src/win32/picture.h
 libdirect3d11_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) \
  -DMODULE_NAME_IS_direct3d11
 if !HAVE_WINSTORE
@@ -200,7 +202,8 @@ EXTRA_LTLIBRARIES += libdirect3d11_plugin.la
 libdirectdraw_plugin_la_SOURCES = video_output/msw/directdraw.c \
 	video_output/msw/common.c video_output/msw/common.h \
 	video_output/msw/events.c video_output/msw/events.h \
-	video_output/msw/win32touch.c video_output/msw/win32touch.h
+	video_output/msw/win32touch.c video_output/msw/win32touch.h \
+	../src/win32/picture.c ../src/win32/picture.h
 libdirectdraw_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) \
 	-DMODULE_NAME_IS_directdraw
 libdirectdraw_plugin_la_LIBADD = -luser32 -lgdi32 -lole32 -luuid
diff --git a/modules/video_output/msw/common.c b/modules/video_output/msw/common.c
index 1e5b5f7..aea0c90 100644
--- a/modules/video_output/msw/common.c
+++ b/modules/video_output/msw/common.c
@@ -203,74 +203,6 @@ void CommonDisplay(vout_display_t *vd)
 }
 #endif
 
-/**
- * It updates a picture data/pitches.
- */
-int CommonUpdatePicture(picture_t *picture, picture_t **fallback,
-                        uint8_t *data, unsigned pitch)
-{
-    if (fallback) {
-        if (*fallback == NULL) {
-            *fallback = picture_NewFromFormat(&picture->format);
-            if (*fallback == NULL)
-                return VLC_EGENERIC;
-        }
-        for (int n = 0; n < picture->i_planes; n++) {
-            const plane_t *src = &(*fallback)->p[n];
-            plane_t       *dst = &picture->p[n];
-            dst->p_pixels = src->p_pixels;
-            dst->i_pitch  = src->i_pitch;
-            dst->i_lines  = src->i_lines;
-        }
-        return VLC_SUCCESS;
-    }
-    /* fill in buffer info in first plane */
-    picture->p->p_pixels = data;
-    picture->p->i_pitch  = pitch;
-    picture->p->i_lines  = picture->format.i_visible_height;
-
-    /*  Fill chroma planes for biplanar YUV */
-    if (picture->format.i_chroma == VLC_CODEC_NV12 ||
-        picture->format.i_chroma == VLC_CODEC_NV21) {
-
-        for (int n = 1; n < picture->i_planes; n++) {
-            const plane_t *o = &picture->p[n-1];
-            plane_t *p = &picture->p[n];
-
-            p->p_pixels = o->p_pixels + o->i_lines * o->i_pitch;
-            p->i_pitch  = pitch;
-            p->i_lines  = picture->format.i_visible_height;
-        }
-        /* The dx/d3d buffer is always allocated as NV12 */
-        if (vlc_fourcc_AreUVPlanesSwapped(picture->format.i_chroma, VLC_CODEC_NV12)) {
-            /* TODO : Swap NV21 UV planes to match NV12 */
-            return VLC_EGENERIC;
-        }
-    }
-
-    /*  Fill chroma planes for planar YUV */
-    if (picture->format.i_chroma == VLC_CODEC_I420 ||
-        picture->format.i_chroma == VLC_CODEC_J420 ||
-        picture->format.i_chroma == VLC_CODEC_YV12) {
-
-        for (int n = 1; n < picture->i_planes; n++) {
-            const plane_t *o = &picture->p[n-1];
-            plane_t *p = &picture->p[n];
-
-            p->p_pixels = o->p_pixels + o->i_lines * o->i_pitch;
-            p->i_pitch  = pitch / 2;
-            p->i_lines  = picture->format.i_visible_height / 2;
-        }
-        /* The dx/d3d buffer is always allocated as YV12 */
-        if (vlc_fourcc_AreUVPlanesSwapped(picture->format.i_chroma, VLC_CODEC_YV12)) {
-            uint8_t *p_tmp = picture->p[1].p_pixels;
-            picture->p[1].p_pixels = picture->p[2].p_pixels;
-            picture->p[2].p_pixels = p_tmp;
-        }
-    }
-    return VLC_SUCCESS;
-}
-
 void AlignRect(RECT *r, int align_boundary, int align_size)
 {
     if (align_boundary)
diff --git a/modules/video_output/msw/common.h b/modules/video_output/msw/common.h
index fa03735..903414e 100644
--- a/modules/video_output/msw/common.h
+++ b/modules/video_output/msw/common.h
@@ -261,7 +261,6 @@ void CommonClean(vout_display_t *);
 void CommonManage(vout_display_t *);
 int  CommonControl(vout_display_t *, int , va_list );
 void CommonDisplay(vout_display_t *);
-int  CommonUpdatePicture(picture_t *, picture_t **, uint8_t *, unsigned);
 
 void UpdateRects (vout_display_t *,
                   const vout_display_cfg_t *,
diff --git a/modules/video_output/msw/direct3d11.c b/modules/video_output/msw/direct3d11.c
index 5ecb2ba..6a5dad6 100644
--- a/modules/video_output/msw/direct3d11.c
+++ b/modules/video_output/msw/direct3d11.c
@@ -34,6 +34,8 @@
 #include <d3d11.h>
 #include <d3dx9math.h>
 
+#include "../../src/win32/picture.h"
+
 /* avoided until we can pass ISwapchainPanel without c++/cx mode
 # include <windows.ui.xaml.media.dxinterop.h> */
 
diff --git a/modules/video_output/msw/direct3d9.c b/modules/video_output/msw/direct3d9.c
index db96275..2d31f94 100644
--- a/modules/video_output/msw/direct3d9.c
+++ b/modules/video_output/msw/direct3d9.c
@@ -50,6 +50,7 @@
 
 #include "common.h"
 #include "builtin_shaders.h"
+#include "../../src/win32/picture.h"
 
 /*****************************************************************************
  * Module descriptor
diff --git a/modules/video_output/msw/directdraw.c b/modules/video_output/msw/directdraw.c
index cee7d47..de815e9 100644
--- a/modules/video_output/msw/directdraw.c
+++ b/modules/video_output/msw/directdraw.c
@@ -51,6 +51,7 @@
 #include <commctrl.h>       /* ListView_(Get|Set)* */
 
 #include "common.h"
+#include "../../src/win32/picture.h"
 
 /* Unicode function "DirectDrawEnumerateExW" has been desactivated
    since in some cases this function fails and the callbacks are not
diff --git a/src/win32/picture.c b/src/win32/picture.c
new file mode 100644
index 0000000..8e3b008
--- /dev/null
+++ b/src/win32/picture.c
@@ -0,0 +1,102 @@
+/*****************************************************************************
+ * common.c: Windows picture handling code
+ *****************************************************************************
+ * Copyright (C) 2001-2009 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Gildas Bazin <gbazin at videolan.org>
+ *          Martell Malone <martellmalone at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble: This file contains the functions related to the init of the vout
+ *           structure, the common display code, the screensaver, but not the
+ *           events and the Window Creation (events.c)
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+
+#include "picture.h"
+
+int CommonUpdatePicture(picture_t *picture, picture_t **fallback,
+                        uint8_t *data, unsigned pitch)
+{
+    if (fallback) {
+        if (*fallback == NULL) {
+            *fallback = picture_NewFromFormat(&picture->format);
+            if (*fallback == NULL)
+                return VLC_EGENERIC;
+        }
+        for (int n = 0; n < picture->i_planes; n++) {
+            const plane_t *src = &(*fallback)->p[n];
+            plane_t       *dst = &picture->p[n];
+            dst->p_pixels = src->p_pixels;
+            dst->i_pitch  = src->i_pitch;
+            dst->i_lines  = src->i_lines;
+        }
+        return VLC_SUCCESS;
+    }
+    /* fill in buffer info in first plane */
+    picture->p->p_pixels = data;
+    picture->p->i_pitch  = pitch;
+    picture->p->i_lines  = picture->format.i_visible_height;
+
+    /*  Fill chroma planes for biplanar YUV */
+    if (picture->format.i_chroma == VLC_CODEC_NV12 ||
+        picture->format.i_chroma == VLC_CODEC_NV21) {
+
+        for (int n = 1; n < picture->i_planes; n++) {
+            const plane_t *o = &picture->p[n-1];
+            plane_t *p = &picture->p[n];
+
+            p->p_pixels = o->p_pixels + o->i_lines * o->i_pitch;
+            p->i_pitch  = pitch;
+            p->i_lines  = picture->format.i_visible_height;
+        }
+        /* The dx/d3d buffer is always allocated as NV12 */
+        if (vlc_fourcc_AreUVPlanesSwapped(picture->format.i_chroma, VLC_CODEC_NV12)) {
+            /* TODO : Swap NV21 UV planes to match NV12 */
+            return VLC_EGENERIC;
+        }
+    }
+
+    /*  Fill chroma planes for planar YUV */
+    if (picture->format.i_chroma == VLC_CODEC_I420 ||
+        picture->format.i_chroma == VLC_CODEC_J420 ||
+        picture->format.i_chroma == VLC_CODEC_YV12) {
+
+        for (int n = 1; n < picture->i_planes; n++) {
+            const plane_t *o = &picture->p[n-1];
+            plane_t *p = &picture->p[n];
+
+            p->p_pixels = o->p_pixels + o->i_lines * o->i_pitch;
+            p->i_pitch  = pitch / 2;
+            p->i_lines  = picture->format.i_visible_height / 2;
+        }
+        /* The dx/d3d buffer is always allocated as YV12 */
+        if (vlc_fourcc_AreUVPlanesSwapped(picture->format.i_chroma, VLC_CODEC_YV12)) {
+            uint8_t *p_tmp = picture->p[1].p_pixels;
+            picture->p[1].p_pixels = picture->p[2].p_pixels;
+            picture->p[2].p_pixels = p_tmp;
+        }
+    }
+    return VLC_SUCCESS;
+}
diff --git a/src/win32/picture.h b/src/win32/picture.h
new file mode 100644
index 0000000..9b1d51e
--- /dev/null
+++ b/src/win32/picture.h
@@ -0,0 +1,32 @@
+/*****************************************************************************
+ * picture.h: Windows picture handling header file
+ *****************************************************************************
+ * Copyright (C) 2001-2009 VLC authors and VideoLAN
+ * $Id$
+ *
+ * Authors: Gildas Bazin <gbazin at videolan.org>
+ *          Damien Fouilleul <damienf at videolan.org>
+ *          Martell Malone <martellmalone at gmail.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#include "vlc_picture.h"
+
+/**
+ * It updates a picture data/pitches.
+ */
+int  CommonUpdatePicture(picture_t *pic, picture_t **fallback, uint8_t *data, unsigned pitch);
+
-- 
2.4.0




More information about the vlc-devel mailing list