[vlc-devel] [PATCH] rawvid: fix the pitch/lines for 4:2:0 with odd dimensions

Steve Lhomme robux4 at ycbcr.xyz
Wed Apr 18 10:01:35 CEST 2018


---
 modules/demux/rawvid.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/demux/rawvid.c b/modules/demux/rawvid.c
index 60886ae6de..f8d5f973c9 100644
--- a/modules/demux/rawvid.c
+++ b/modules/demux/rawvid.c
@@ -349,8 +349,17 @@ valid:
                  (char*)&i_chroma );
         goto error;
     }
-    p_sys->frame_size = i_width * i_height
-                        * p_sys->fmt_video.video.i_bits_per_pixel / 8;
+    const vlc_chroma_description_t *dsc =
+            vlc_fourcc_GetChromaDescription(p_sys->fmt_video.video.i_chroma);
+    p_sys->frame_size = 0;
+    for (unsigned i=0; i<dsc->plane_count; i++)
+    {
+        unsigned pitch = (i_width + (dsc->p[i].w.den - 1))
+                         * dsc->p[i].w.num / dsc->p[i].w.den * dsc->pixel_size;
+        unsigned lines = (i_height + (dsc->p[i].h.den - 1))
+                         * dsc->p[i].h.num / dsc->p[i].h.den;
+        p_sys->frame_size += pitch * lines;
+    }
     p_sys->p_es_video = es_out_Add( p_demux->out, &p_sys->fmt_video );
 
     p_demux->pf_demux   = Demux;
-- 
2.16.2



More information about the vlc-devel mailing list