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

Steve Lhomme git at videolan.org
Wed Apr 18 10:50:17 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Apr 18 09:39:40 2018 +0200| [a66661c0e89c14460cb0d6a48b7ee41caaa60593] | committer: Steve Lhomme

rawvid: fix the pitch/lines for 4:2:0 with odd dimensions

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a66661c0e89c14460cb0d6a48b7ee41caaa60593
---

 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;



More information about the vlc-commits mailing list