[vlc-commits] [Git][videolan/vlc][master] 13 commits: fourcc_list: add missing P010/P016

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Tue Dec 17 21:02:55 UTC 2024



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
43df9907 by Thomas Guillem at 2024-12-17T20:49:02+00:00
fourcc_list: add missing P010/P016

- - - - -
3dafc0a1 by Thomas Guillem at 2024-12-17T20:49:02+00:00
fourcc: add P012

- - - - -
3a9a6761 by Thomas Guillem at 2024-12-17T20:49:02+00:00
fourcc: add VAAPI 420 12bits

- - - - -
314034f9 by Thomas Guillem at 2024-12-17T20:49:02+00:00
vlc_vaapi: handle VLC_CODEC_VAAPI_420_12BPP

- - - - -
a5a55f61 by Thomas Guillem at 2024-12-17T20:49:02+00:00
opengl: sampler: don't shift P012

- - - - -
cc46cb6d by Thomas Guillem at 2024-12-17T20:49:02+00:00
interop_vaapi: add a function to get va_fourcc and sw_chroma

This will allow different chromas to share the same tex configuration.

- - - - -
8a37d252 by Thomas Guillem at 2024-12-17T20:49:02+00:00
interop_vaapi: get chroma desc from vlc_fourcc_t

It was using VA_FOURC_, that was matching for the 2 chromas we handled.

- - - - -
c9c2758a by Thomas Guillem at 2024-12-17T20:49:02+00:00
interop_vaapi: remove unused code

- - - - -
7bfeabad by Thomas Guillem at 2024-12-17T20:49:02+00:00
interop_vaapi: use GL_UNSIGNED_SHORT for P010

10bits need 2 bytes. This will improve VAAPI P010 quality.

- - - - -
9d8345e0 by Thomas Guillem at 2024-12-17T20:49:02+00:00
interop_vaapi: handle P012

VAAPI 2 planes Y/UV 4:2:0 10-bit.

- - - - -
bd513da8 by Thomas Guillem at 2024-12-17T20:49:02+00:00
interop_vaapi: remove unused variable

- - - - -
46f9bb6f by Thomas Guillem at 2024-12-17T20:49:02+00:00
avcodec: vaapi: print the string of the incompatible chroma

- - - - -
a5dd200f by Thomas Guillem at 2024-12-17T20:49:02+00:00
avcodec: vaapi: handle VLC_CODEC_VAAPI_420_12BPP

- - - - -


8 changed files:

- include/vlc_fourcc.h
- modules/codec/avcodec/vaapi.c
- modules/hw/vaapi/vlc_vaapi.c
- modules/hw/vaapi/vlc_vaapi.h
- modules/video_output/opengl/interop_vaapi.c
- modules/video_output/opengl/sampler.c
- src/misc/fourcc.c
- src/misc/fourcc_list.h


Changes:

=====================================
include/vlc_fourcc.h
=====================================
@@ -294,6 +294,8 @@
 #define VLC_CODEC_NV42            VLC_FOURCC('N','V','4','2')
 /* 2 planes Y/UV 4:2:0 10-bit MSB, little endian */
 #define VLC_CODEC_P010            VLC_FOURCC('P','0','1','0')
+/* 2 planes Y/UV 4:2:0 12-bit MSB, little endian */
+#define VLC_CODEC_P012            VLC_FOURCC('P','0','1','2')
 /* 2 planes Y/UV 4:2:0 16-bit, little endian */
 #define VLC_CODEC_P016            VLC_FOURCC('P','0','1','6')
 
@@ -454,6 +456,7 @@
 /* VAAPI opaque surface */
 #define VLC_CODEC_VAAPI_420 VLC_FOURCC('V','A','O','P') /* 4:2:0  8 bpc */
 #define VLC_CODEC_VAAPI_420_10BPP VLC_FOURCC('V','A','O','0') /* 4:2:0 10 bpc */
+#define VLC_CODEC_VAAPI_420_12BPP VLC_FOURCC('V','A','O','2') /* 4:2:0 12 bpc */
 
 /* MediaCodec/IOMX opaque buffer type */
 #define VLC_CODEC_ANDROID_OPAQUE  VLC_FOURCC('A','N','O','P')


=====================================
modules/codec/avcodec/vaapi.c
=====================================
@@ -238,6 +238,10 @@ static int Create(vlc_va_t *va, struct vlc_va_cfg *cfg)
             case AV_PIX_FMT_YUV420P10LE:
                 vlc_chroma = VLC_CODEC_VAAPI_420_10BPP;
                 break;
+            case AV_PIX_FMT_P012LE:
+            case AV_PIX_FMT_P012BE:
+                vlc_chroma = VLC_CODEC_VAAPI_420_12BPP;
+                break;
             default:
                 break;
         }
@@ -245,8 +249,9 @@ static int Create(vlc_va_t *va, struct vlc_va_cfg *cfg)
 
     if (vlc_chroma == 0)
     {
-        msg_Warn(va, "ffmpeg chroma not compatible with vlc: hw: %d, sw: %d",
-                 hwframes_ctx->format, hwframes_ctx->sw_format);
+        msg_Warn(va, "ffmpeg chroma not compatible with vlc: hw: %s, sw: %s",
+                 av_get_pix_fmt_name(hwframes_ctx->format),
+                 av_get_pix_fmt_name(hwframes_ctx->sw_format));
         av_buffer_unref(&hwframes_ref);
         return VLC_EGENERIC;
     }


=====================================
modules/hw/vaapi/vlc_vaapi.c
=====================================
@@ -55,6 +55,10 @@ vlc_chroma_to_vaapi(int i_vlc_chroma, unsigned *va_rt_format, int *va_fourcc)
             *va_rt_format = VA_RT_FORMAT_YUV420_10BPP;
             *va_fourcc = VA_FOURCC_P010;
             break;
+        case VLC_CODEC_VAAPI_420_12BPP:
+            *va_rt_format = VA_RT_FORMAT_YUV420_12;
+            *va_fourcc = VA_FOURCC_P012;
+            break;
         default:
             vlc_assert_unreachable();
     }


=====================================
modules/hw/vaapi/vlc_vaapi.h
=====================================
@@ -193,8 +193,15 @@ vlc_vaapi_PicGetDisplay(picture_t *pic);
 static inline bool
 vlc_vaapi_IsChromaOpaque(int i_vlc_chroma)
 {
-    return i_vlc_chroma == VLC_CODEC_VAAPI_420
-        || i_vlc_chroma == VLC_CODEC_VAAPI_420_10BPP;
+    switch (i_vlc_chroma)
+    {
+        case VLC_CODEC_VAAPI_420:
+        case VLC_CODEC_VAAPI_420_10BPP:
+        case VLC_CODEC_VAAPI_420_12BPP:
+            return true;
+        default:
+            return false;
+    }
 }
 
 void vlc_chroma_to_vaapi(int i_vlc_chroma, unsigned *va_rt_format, int *va_fourcc);


=====================================
modules/video_output/opengl/interop_vaapi.c
=====================================
@@ -126,8 +126,6 @@ vaegl_image_destroy(const struct vlc_gl_interop *interop, EGLImageKHR image)
 static void
 vaegl_release_last_pic(const struct vlc_gl_interop *interop, struct priv *priv)
 {
-    vlc_object_t *o = VLC_OBJECT(interop->gl);
-
     for (unsigned i = 0; i < priv->last.num_planes; ++i)
         vaegl_image_destroy(interop, priv->last.egl_images[i]);
 
@@ -152,36 +150,10 @@ vaegl_init_fourcc(struct priv *priv, unsigned va_fourcc)
             priv->drm_fourccs[1] = VLC_FOURCC('G', 'R', '8', '8');
             break;
         case VA_FOURCC_P010:
+        case VA_FOURCC_P012:
             priv->drm_fourccs[0] = VLC_FOURCC('R', '1', '6', ' ');
             priv->drm_fourccs[1] = VLC_FOURCC('G', 'R', '3', '2');
             break;
-#if 0
-        /* TODO: the following fourcc are not handled for now */
-        case VA_FOURCC_RGBA:
-            priv->drm_fourccs[0] = VLC_FOURCC('G', 'R', '3', '2');
-            break;
-        case VA_FOURCC_BGRA:
-            priv->drm_fourccs[0] = VLC_FOURCC('G', 'R', '3', '2');
-            break;
-        case VA_FOURCC_YV12:
-            priv->drm_fourccs[0] = VLC_FOURCC('R', '8', ' ', ' ');
-            priv->drm_fourccs[1] = VLC_FOURCC('R', '8', ' ', ' ');
-            priv->drm_fourccs[2] = VLC_FOURCC('R', '8', ' ', ' ');
-            break;
-        case VA_FOURCC_422H:
-            priv->drm_fourccs[0] = VLC_FOURCC('R', '8', ' ', ' ');
-            priv->drm_fourccs[1] = VLC_FOURCC('R', '8', ' ', ' ');
-            priv->drm_fourccs[2] = VLC_FOURCC('R', '8', ' ', ' ');
-            break;
-        case VA_FOURCC_UYVY:
-            priv->drm_fourccs[0] = VLC_FOURCC('R', '1', '6', ' ');
-            break;
-        case VA_FOURCC_444P:
-            priv->drm_fourccs[0] = VLC_FOURCC('R', '1', '6', ' ');
-            priv->drm_fourccs[1] = VLC_FOURCC('R', '1', '6', ' ');
-            priv->drm_fourccs[2] = VLC_FOURCC('R', '1', '6', ' ');
-            break;
-#endif
         default: return VLC_EGENERIC;
     }
     priv->fourcc = va_fourcc;
@@ -369,7 +341,8 @@ tc_va_check_interop_blacklist(const struct vlc_gl_interop *interop, VADisplay *v
 }
 
 static int
-tc_va_check_derive_image(const struct vlc_gl_interop *interop)
+tc_va_check_derive_image(const struct vlc_gl_interop *interop,
+                         vlc_fourcc_t sw_chroma)
 {
     vlc_object_t *o = VLC_OBJECT(interop->gl);
     struct priv *priv = interop->priv;
@@ -389,7 +362,8 @@ tc_va_check_derive_image(const struct vlc_gl_interop *interop)
     assert(va_image.format.fourcc == priv->fourcc);
 
     const vlc_chroma_description_t *image_desc =
-        vlc_fourcc_GetChromaDescription(va_image.format.fourcc);
+        vlc_fourcc_GetChromaDescription(sw_chroma);
+    assert(image_desc != NULL);
     assert(image_desc->plane_count == va_image.num_planes);
 
     VABufferInfo va_buffer_info = (VABufferInfo) {
@@ -434,6 +408,29 @@ done:
     return ret;
 }
 
+static void
+GetChromaVaFourcc(vlc_fourcc_t opaque_chroma, int *va_fourcc,
+                  vlc_fourcc_t *sw_chroma)
+{
+    switch (opaque_chroma)
+    {
+        case VLC_CODEC_VAAPI_420:
+            *va_fourcc = VA_FOURCC_NV12;
+            *sw_chroma = VLC_CODEC_NV12;
+            break;
+        case VLC_CODEC_VAAPI_420_10BPP:
+            *va_fourcc = VA_FOURCC_P010;
+            *sw_chroma = VLC_CODEC_P010;
+            break;
+        case VLC_CODEC_VAAPI_420_12BPP:
+            *va_fourcc = VA_FOURCC_P012;
+            *sw_chroma = VLC_CODEC_P012;
+            break;
+        default:
+            vlc_assert_unreachable();
+    }
+}
+
 static int
 Open(struct vlc_gl_interop *interop)
 {
@@ -460,13 +457,11 @@ Open(struct vlc_gl_interop *interop)
     priv->fourcc = 0;
 
     int va_fourcc;
-    int vlc_sw_chroma;
+    vlc_fourcc_t vlc_sw_chroma;
+    GetChromaVaFourcc(interop->fmt_in.i_chroma, &va_fourcc, &vlc_sw_chroma);
     switch (interop->fmt_in.i_chroma)
     {
-        case VLC_CODEC_VAAPI_420:
-            va_fourcc = VA_FOURCC_NV12;
-            vlc_sw_chroma = VLC_CODEC_NV12;
-
+        case VLC_CODEC_VAAPI_420: /* VLC_CODEC_NV12 */
             interop->tex_count = 2;
             interop->texs[0] = (struct vlc_gl_tex_cfg) {
                 .w = {1, 1},
@@ -484,10 +479,8 @@ Open(struct vlc_gl_interop *interop)
             };
 
             break;
-        case VLC_CODEC_VAAPI_420_10BPP:
-            va_fourcc = VA_FOURCC_P010;
-            vlc_sw_chroma = VLC_CODEC_P010;
-
+        case VLC_CODEC_VAAPI_420_10BPP: /* VLC_CODEC_P010 */
+        case VLC_CODEC_VAAPI_420_12BPP: /* VLC_CODEC_P012 */
             if (vlc_gl_interop_GetTexFormatSize(interop, GL_TEXTURE_2D, GL_RG,
                                                 GL_RG16, GL_UNSIGNED_SHORT) != 16)
                 goto error;
@@ -498,14 +491,14 @@ Open(struct vlc_gl_interop *interop)
                 .h = {1, 1},
                 .internal = GL_R16,
                 .format = GL_RED,
-                .type = GL_UNSIGNED_BYTE,
+                .type = GL_UNSIGNED_SHORT,
             };
             interop->texs[1] = (struct vlc_gl_tex_cfg) {
                 .w = {1, 2},
                 .h = {1, 2},
                 .internal = GL_RG16,
                 .format = GL_RG,
-                .type = GL_UNSIGNED_BYTE,
+                .type = GL_UNSIGNED_SHORT,
             };
 
             break;
@@ -559,7 +552,7 @@ Open(struct vlc_gl_interop *interop)
     if (tc_va_check_interop_blacklist(interop, priv->vadpy))
         goto error;
 
-    if (tc_va_check_derive_image(interop))
+    if (tc_va_check_derive_image(interop, vlc_sw_chroma))
         goto error;
 
     /* The pictures are uploaded upside-down */


=====================================
modules/video_output/opengl/sampler.c
=====================================
@@ -188,7 +188,8 @@ sampler_yuv_base_init(struct vlc_gl_sampler *sampler,
 
     if (desc->pixel_size == 2)
     {
-        if (desc->fcc != VLC_CODEC_P010 && desc->fcc != VLC_CODEC_P016) {
+        if (desc->fcc != VLC_CODEC_P010 && desc->fcc != VLC_CODEC_P012
+         && desc->fcc != VLC_CODEC_P016) {
             /* Do a bit shift if samples are stored on LSB. */
             float yuv_range_correction = (float)((1 << 16) - 1)
                                          / ((1 << desc->pixel_bits) - 1);


=====================================
src/misc/fourcc.c
=====================================
@@ -218,7 +218,7 @@ const char *vlc_fourcc_GetDescription(int cat, vlc_fourcc_t fourcc)
     VLC_CODEC_I420_16L, VLC_CODEC_I420_16B, VLC_CODEC_I420_12L, VLC_CODEC_I420_12B, VLC_CODEC_I420_10L, VLC_CODEC_I420_10B, VLC_CODEC_I420_9L, VLC_CODEC_I420_9B
 
 #define VLC_CODEC_YUV_SEMIPLANAR_420_16 \
-    VLC_CODEC_P010, VLC_CODEC_P016
+    VLC_CODEC_P010, VLC_CODEC_P012 ,VLC_CODEC_P016
 
 #define VLC_CODEC_YUV_SEMIPLANAR_422 \
     VLC_CODEC_NV16, VLC_CODEC_NV61
@@ -760,6 +760,7 @@ static const vlc_chroma_description_t p_list_chroma_description[] = {
     { VLC_CODEC_YUVA_444_12L,          PLANAR_16(4, 1, 1, 12) },
     { VLC_CODEC_YUVA_444_12B,          PLANAR_16(4, 1, 1, 12) },
     { VLC_CODEC_P010,                  SEMIPLANAR(2, 2, 10) },
+    { VLC_CODEC_P012,                  SEMIPLANAR(2, 2, 12) },
     { VLC_CODEC_P016,                  SEMIPLANAR(2, 2, 16) },
 
     { VLC_CODEC_YUYV,                  PACKED_FMT(2, 16) },
@@ -838,6 +839,7 @@ static const vlc_chroma_description_t p_list_chroma_description[] = {
 
     { VLC_CODEC_VAAPI_420,             FAKE_FMT() },
     { VLC_CODEC_VAAPI_420_10BPP,       FAKE_FMT() },
+    { VLC_CODEC_VAAPI_420_12BPP,       FAKE_FMT() },
 };
 
 #undef PACKED_FMT


=====================================
src/misc/fourcc_list.h
=====================================
@@ -920,6 +920,12 @@ static const staticentry_t p_list_video[] = {
         A("NV12"),
     B(VLC_CODEC_NV21, "Biplanar 4:2:0 Y/VU"),
         A("NV21"),
+    B(VLC_CODEC_P010, "Biplanar 4:2:0 Y/VU 10-bit LE"),
+        A("P010"),
+    B(VLC_CODEC_P012, "Biplanar 4:2:0 Y/VU 12-bit LE"),
+        A("P012"),
+    B(VLC_CODEC_P016, "Biplanar 4:2:0 Y/VU 16-bit LE"),
+        A("P016"),
     B(VLC_CODEC_NV16, "Biplanar 4:2:2 Y/UV"),
         A("NV16"),
     B(VLC_CODEC_NV61, "Biplanar 4:2:2 Y/VU"),
@@ -1242,6 +1248,9 @@ static const staticentry_t p_list_video[] = {
     B(VLC_CODEC_VAAPI_420_10BPP, "4:2:0 10bits VAAPI opaque"),
         A("VAO0"),
 
+    B(VLC_CODEC_VAAPI_420_12BPP, "4:2:0 12bits VAAPI opaque"),
+        A("VAO2"),
+
     B(VLC_CODEC_ANDROID_OPAQUE, "Android opaque"),
         A("ANOP"),
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4f2e94c3c82426bba9a8a07cc022849fb30ccc03...a5dd200fbb59aab47677420d365b2c8a1f20c190

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/4f2e94c3c82426bba9a8a07cc022849fb30ccc03...a5dd200fbb59aab47677420d365b2c8a1f20c190
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