Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
d1ebcdff by Steve Lhomme at 2026-02-01T08:52:18+00:00
picture: check each plane dimension doesn't overflow

- - - - -
51f3dc6e by Steve Lhomme at 2026-02-01T08:52:18+00:00
picture: remove assert on plane dimension ratios

We don't care what the format is like as long as it fits in our max dimensions.

- - - - -
ec1111d0 by Steve Lhomme at 2026-02-01T08:52:18+00:00
avcodec/chroma: map AV_PIX_FMT_NV24/42 to VLC_CODEC_NV24/42

Added in 5de4f1d871d60886b9630531fa8c34cad13cc9dd, aka libavutil 56.27.100.
We require libavutil 56.31.100.

- - - - -


2 changed files:

- modules/codec/avcodec/chroma.c
- src/misc/picture.c


Changes:

=====================================
modules/codec/avcodec/chroma.c
=====================================
@@ -60,6 +60,8 @@ static const struct vlc_chroma_ffmpeg chroma_table[] =
     {VLC_CODEC_NV12, AV_PIX_FMT_NV12,  COLOR_RANGE_UNDEF },
     {VLC_CODEC_NV21, AV_PIX_FMT_NV21,  COLOR_RANGE_UNDEF },
     {VLC_CODEC_NV16, AV_PIX_FMT_NV16,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_NV24, AV_PIX_FMT_NV24,  COLOR_RANGE_UNDEF },
+    {VLC_CODEC_NV42, AV_PIX_FMT_NV42,  COLOR_RANGE_UNDEF },
 
     {VLC_CODEC_I420_9L, AV_PIX_FMT_YUV420P9LE,  COLOR_RANGE_UNDEF },
     {VLC_CODEC_I420_9B, AV_PIX_FMT_YUV420P9BE,  COLOR_RANGE_UNDEF },


=====================================
src/misc/picture.c
=====================================
@@ -169,24 +169,32 @@ int picture_Setup( picture_t *p_picture, const 
video_format_t *restrict fmt )
     width = width / i_modulo_w * i_modulo_w;
     height = height / i_modulo_h * i_modulo_h;
 
-    /* plane_t uses 'int'. */
-    if (unlikely(width > INT_MAX) || unlikely(height > INT_MAX))
-        return VLC_EGENERIC;
-
     for( unsigned i = 0; i < p_dsc->plane_count; i++ )
     {
         plane_t *p = &p_picture->p[i];
         const vlc_rational_t *h = &p_dsc->p[i].h;
         const vlc_rational_t *w = &p_dsc->p[i].w;
 
-        /* A plane cannot be over-sampled. This could lead to overflow. */
-        assert(h->den >= h->num);
-        assert(w->den >= w->num);
+        unsigned mul_height;
+        if (unlikely(ckd_mul(&mul_height, height, h->num)))
+            return VLC_EGENERIC;
+        mul_height = mul_height / h->den;
+        if (unlikely(mul_height > INT_MAX))
+            return VLC_EGENERIC;
 
-        p->i_lines = height * h->num / h->den;
+        p->i_lines = mul_height;
         p->i_visible_lines = (fmt->i_visible_height + (h->den - 1)) / h->den * 
h->num;
 
-        p->i_pitch = width * w->num / w->den * p_dsc->pixel_size;
+        unsigned mul_width;
+        if (unlikely(ckd_mul(&mul_width, width, w->num)))
+            return VLC_EGENERIC;
+        mul_width = mul_width / w->den;
+        if (unlikely(ckd_mul(&mul_width, mul_width, p_dsc->pixel_size)))
+            return VLC_EGENERIC;
+        if (unlikely(mul_width > INT_MAX))
+            return VLC_EGENERIC;
+
+        p->i_pitch = mul_width;
         p->i_visible_pitch = (fmt->i_visible_width + (w->den - 1)) / w->den * 
w->num
                              * p_dsc->pixel_size;
         p->i_pixel_pitch = p_dsc->pixel_size;



View it on GitLab: 
https://code.videolan.org/videolan/vlc/-/compare/43d7d202031b3af096fd0a193640e4c39716cf1d...ec1111d07ae935505ea8146fe1af31bed24c7d0b

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


VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits

Reply via email to