[vlc-commits] [Git][videolan/vlc][master] 7 commits: chroma/copy: don't support NV21 UV swap

Steve Lhomme (@robUx4) gitlab at videolan.org
Fri Oct 20 16:14:46 UTC 2023



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
bcddcfad by Steve Lhomme at 2023-10-20T15:51:18+00:00
chroma/copy: don't support NV21 UV swap

We only support NV12/P010 and we don't support swapping UV data in semiplanar
formats.

- - - - -
b8ffe8e9 by Steve Lhomme at 2023-10-20T15:51:18+00:00
chroma/copy: check directly the chroma that needs UV swap

We only allow 2 chromas in this code: VLC_CODEC_I420 and VLC_CODEC_YV12.

vlc_fourcc_AreUVPlanesSwapped() only returns true for VLC_CODEC_I420.

- - - - -
8b11c220 by Steve Lhomme at 2023-10-20T15:51:18+00:00
fourcc: remove unused vlc_fourcc_AreUVPlanesSwapped()

- - - - -
a3333ea6 by Steve Lhomme at 2023-10-20T15:51:18+00:00
copy: move the I420 UV swapping code outside of picture_UpdatePlanes()

This is specific to windows mix with I420/YV12. It should not be in generic
code.

- - - - -
154df46c by Steve Lhomme at 2023-10-20T15:51:18+00:00
copy: handle the NV21 UV swapping issue outside of picture_UpdatePlanes()

- - - - -
72e4e537 by Steve Lhomme at 2023-10-20T15:51:18+00:00
direct3d11: remove dead code

We cannot get NV21 or I420 as sub pictures as we only accept RGBA.

- - - - -
5013f02b by Steve Lhomme at 2023-10-20T15:51:18+00:00
copy: return an error for chromas not handled by picture_UpdatePlanes()

We can't use the planes of the picture in that case.

- - - - -


8 changed files:

- include/vlc_fourcc.h
- modules/hw/d3d11/d3d11_surface.c
- modules/hw/d3d9/dxa9.c
- modules/video_chroma/copy.c
- modules/video_output/win32/direct3d11.cpp
- modules/video_output/win32/direct3d9.c
- src/libvlccore.sym
- src/misc/fourcc.c


Changes:

=====================================
include/vlc_fourcc.h
=====================================
@@ -790,12 +790,6 @@ VLC_API const vlc_fourcc_t * vlc_fourcc_GetFallback( vlc_fourcc_t );
  */
 VLC_API bool vlc_fourcc_IsYUV( vlc_fourcc_t );
 
-/**
- * It returns true if the two fourccs are equivalent if their U&V planes are
- * swapped.
- */
-VLC_API bool vlc_fourcc_AreUVPlanesSwapped(vlc_fourcc_t , vlc_fourcc_t );
-
 /**
  * Chroma related information.
  */


=====================================
modules/hw/d3d11/d3d11_surface.c
=====================================
@@ -540,6 +540,11 @@ static void NV12_D3D11(filter_t *p_filter, picture_t *src, picture_t *dst)
         }
 
         picture_UpdatePlanes(dst, lock.pData, lock.RowPitch);
+
+        /* The dx/d3d buffer is always allocated as YV12 */
+        if (dst->format.i_chroma == VLC_CODEC_I420)
+            picture_SwapUV( dst );
+
         picture_context_t *dst_pic_ctx = dst->context;
         dst->context = NULL; // some CPU filters won't like the mix of CPU/GPU
 
@@ -565,6 +570,11 @@ static void NV12_D3D11(filter_t *p_filter, picture_t *src, picture_t *dst)
         }
 
         picture_UpdatePlanes(sys->staging_pic, lock.pData, lock.RowPitch);
+
+        /* The dx/d3d buffer is always allocated as YV12 */
+        if (sys->staging_pic->format.i_chroma == VLC_CODEC_I420)
+            picture_SwapUV( sys->staging_pic );
+
         picture_context_t *staging_pic_ctx = sys->staging_pic->context;
         sys->staging_pic->context = NULL; // some CPU filters won't like the mix of CPU/GPU
 


=====================================
modules/hw/d3d9/dxa9.c
=====================================
@@ -241,6 +241,10 @@ static void YV12_D3D9(filter_t *p_filter, picture_t *src, picture_t *dst)
 
         picture_UpdatePlanes(dst, d3drect.pBits, d3drect.Pitch);
 
+        /* The dx/d3d buffer is always allocated as YV12 */
+        if (dst->format.i_chroma == VLC_CODEC_I420)
+            picture_SwapUV( dst );
+
         picture_CopyPixels(dst, src);
 
         dst->context = dst_pic_ctx;
@@ -257,6 +261,11 @@ static void YV12_D3D9(filter_t *p_filter, picture_t *src, picture_t *dst)
             return;
 
         picture_UpdatePlanes(sys->staging, d3drect.pBits, d3drect.Pitch);
+
+        /* The dx/d3d buffer is always allocated as YV12 */
+        if (sys->staging->format.i_chroma == VLC_CODEC_I420)
+            picture_SwapUV( sys->staging );
+
         picture_context_t *staging_pic_ctx = sys->staging->context;
         sys->staging->context = NULL; // some CPU filters won't like the mix of CPU/GPU
 


=====================================
modules/video_chroma/copy.c
=====================================
@@ -921,11 +921,7 @@ int picture_UpdatePlanes(picture_t *picture, uint8_t *data, unsigned pitch)
             assert(p->i_visible_pitch <= p->i_pitch);
             assert(p->i_visible_lines <= p->i_lines);
         }
-        /* 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;
-        }
+        return VLC_SUCCESS;
     }
 
     /*  Fill chroma planes for planar YUV */
@@ -941,11 +937,9 @@ int picture_UpdatePlanes(picture_t *picture, uint8_t *data, unsigned 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))
-            picture_SwapUV( picture );
+        return VLC_SUCCESS;
     }
-    return VLC_SUCCESS;
+    return VLC_ENOTSUP;
 }
 
 #ifdef COPY_TEST


=====================================
modules/video_output/win32/direct3d11.cpp
=====================================
@@ -1412,15 +1412,7 @@ static int Direct3D11MapSubpicture(vout_display_t *vd, int *subpicture_region_co
 
         hr = sys->d3d_dev->d3dcontext->Map(quad->picSys.resource[KNOWN_DXGI_INDEX], 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
         if( SUCCEEDED(hr) ) {
-            err = picture_UpdatePlanes(quad_picture, static_cast<uint8_t*>(mappedResource.pData), mappedResource.RowPitch);
-            if (err != VLC_SUCCESS) {
-                msg_Err(vd, "Failed to set the buffer on the SPU picture" );
-                sys->d3d_dev->d3dcontext->Unmap(quad->picSys.resource[KNOWN_DXGI_INDEX], 0);
-                picture_Release(quad_picture);
-                if ((*region)[i] == quad_picture)
-                    (*region)[i] = NULL;
-                continue;
-            }
+            picture_UpdatePlanes(quad_picture, static_cast<uint8_t*>(mappedResource.pData), mappedResource.RowPitch);
 
             picture_CopyPixels(quad_picture, r->p_picture);
 


=====================================
modules/video_output/win32/direct3d9.c
=====================================
@@ -1194,6 +1194,11 @@ static void Prepare(vout_display_t *vd, picture_t *picture,
 
         picture_t fake_pic = *picture;
         picture_UpdatePlanes(&fake_pic, d3drect.pBits, d3drect.Pitch);
+
+        /* The dx/d3d buffer is always allocated as YV12 */
+        if (fake_pic.format.i_chroma == VLC_CODEC_I420)
+            picture_SwapUV( &fake_pic );
+
         picture_CopyPixels(&fake_pic, picture);
         IDirect3DSurface9_UnlockRect(surface);
     }


=====================================
src/libvlccore.sym
=====================================
@@ -588,7 +588,6 @@ vlc_fourcc_IsYUV
 vlc_fourcc_GetRGBFallback
 vlc_fourcc_GetYUVFallback
 vlc_fourcc_GetFallback
-vlc_fourcc_AreUVPlanesSwapped
 vlc_getaddrinfo
 vlc_getaddrinfo_i11e
 vlc_getnameinfo


=====================================
src/misc/fourcc.c
=====================================
@@ -646,32 +646,6 @@ const vlc_fourcc_t *vlc_fourcc_GetFallback( vlc_fourcc_t i_fourcc )
             : vlc_fourcc_GetRGBFallback( i_fourcc );
 }
 
-bool vlc_fourcc_AreUVPlanesSwapped( vlc_fourcc_t a, vlc_fourcc_t b )
-{
-    static const vlc_fourcc_t pp_swapped[][4] = {
-        { VLC_CODEC_YV12, VLC_CODEC_I420, 0 },
-        { 0 }
-    };
-
-    for( int i = 0; pp_swapped[i][0]; i++ )
-    {
-        if( pp_swapped[i][0] == b )
-        {
-            vlc_fourcc_t t = a;
-            a = b;
-            b = t;
-        }
-        if( pp_swapped[i][0] != a )
-            continue;
-        for( int j = 1; pp_swapped[i][j]; j++ )
-        {
-            if( pp_swapped[i][j] == b )
-                return true;
-        }
-    }
-    return false;
-}
-
 bool vlc_fourcc_IsYUV(vlc_fourcc_t fcc)
 {
     for( unsigned i = 0; p_list_YUV[i]; i++ )



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ef73794165da2497bba1ab0272a3249c9625997c...5013f02bd0b2c1d79033c13d09afe94ce7e3579e

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ef73794165da2497bba1ab0272a3249c9625997c...5013f02bd0b2c1d79033c13d09afe94ce7e3579e
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list