[vlc-commits] commit: Factorized Direct3DLockSurface/DirectXLock. (Laurent Aimar )

git at videolan.org git at videolan.org
Mon Jul 19 23:24:35 CEST 2010


vlc/vlc-1.1 | branch: master | Laurent Aimar <fenrir at videolan.org> | Mon Jul 19 21:58:47 2010 +0200| [55014eb883c18c4f2e4c71f1755386161a2cbe34] | committer: Jean-Baptiste Kempf 

Factorized Direct3DLockSurface/DirectXLock.

There is a little difference in Direct3DLockSurface as it now also
sets the height field, but it should have no functionnal changes.
(cherry picked from commit a0530f4ab42c5e9dbd1b21e5a44c95d208254c55)

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

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

 modules/video_output/msw/common.c   |   33 +++++++++++++++++++++++++++++++++
 modules/video_output/msw/common.h   |    1 +
 modules/video_output/msw/direct3d.c |   24 +-----------------------
 modules/video_output/msw/directx.c  |   26 +-------------------------
 4 files changed, 36 insertions(+), 48 deletions(-)

diff --git a/modules/video_output/msw/common.c b/modules/video_output/msw/common.c
index 47c2958..0cf4240 100644
--- a/modules/video_output/msw/common.c
+++ b/modules/video_output/msw/common.c
@@ -218,6 +218,39 @@ void CommonDisplay(vout_display_t *vd)
     sys->is_first_display = false;
 }
 
+/**
+ * It updates a picture data/pitches.
+ */
+void CommonUpdatePicture(picture_t *picture,
+                         uint8_t *data, unsigned pitch)
+{
+    /* fill in buffer info in first plane */
+    picture->p->p_pixels = data;
+    picture->p->i_pitch  = pitch;
+    picture->p->i_lines  = picture->format.i_height;
+
+    /*  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_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;
+        }
+    }
+}
+
 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 291d8e0..463adf6 100644
--- a/modules/video_output/msw/common.h
+++ b/modules/video_output/msw/common.h
@@ -236,6 +236,7 @@ void CommonClean(vout_display_t *);
 void CommonManage(vout_display_t *);
 int  CommonControl(vout_display_t *, int , va_list );
 void CommonDisplay(vout_display_t *);
+void CommonUpdatePicture(picture_t *, uint8_t *, unsigned);
 
 void UpdateRects (vout_display_t *,
                   const vout_display_cfg_t *,
diff --git a/modules/video_output/msw/direct3d.c b/modules/video_output/msw/direct3d.c
index 17183c0..05efc81 100644
--- a/modules/video_output/msw/direct3d.c
+++ b/modules/video_output/msw/direct3d.c
@@ -758,29 +758,7 @@ static int Direct3DLockSurface(picture_t *picture)
         return VLC_EGENERIC;
     }
 
-    /* fill in buffer info in first plane */
-    picture->p->p_pixels = d3drect.pBits;
-    picture->p->i_pitch  = d3drect.Pitch;
-
-    /*  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  = d3drect.Pitch / 2;
-        }
-        /* The 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;
-        }
-    }
+    CommonUpdatePicture(picture, d3drect.pBits, d3drect.Pitch);
     return VLC_SUCCESS;
 }
 /**
diff --git a/modules/video_output/msw/directx.c b/modules/video_output/msw/directx.c
index 73feb9b..dae4dda 100644
--- a/modules/video_output/msw/directx.c
+++ b/modules/video_output/msw/directx.c
@@ -1215,31 +1215,7 @@ static int DirectXLock(picture_t *picture)
                            picture->p_sys->surface, &ddsd))
         return VLC_EGENERIC;
 
-    /* fill in buffer info in first plane */
-    picture->p->p_pixels = ddsd.lpSurface;
-    picture->p->i_pitch  = ddsd.lPitch;
-    picture->p->i_lines  = picture->format.i_height;
-
-    /*  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  = ddsd.lPitch / 2;
-            p->i_lines  = picture->format.i_height / 2;
-        }
-        /* The dx 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;
-        }
-    }
+    CommonUpdatePicture(picture, ddsd.lpSurface, ddsd.lPitch);
     return VLC_SUCCESS;
 }
 static void DirectXUnlock(picture_t *picture)



More information about the vlc-commits mailing list