]> git.sesse.net Git - vlc/blobdiff - modules/video_output/msw/directx.c
Factorized Direct3DLockSurface/DirectXLock.
[vlc] / modules / video_output / msw / directx.c
index b53ea84197aea987fdc74c73f76dbc08ddc5ea99..4e3da313c9fb034bb7b675fe9ee425a02213993b 100644 (file)
@@ -1223,31 +1223,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)