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

Steve Lhomme git at videolan.org
Wed Apr 18 11:03:03 CEST 2018


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Wed Apr 18 09:39:40 2018 +0200| [cf1139816b30cefa4b18cd0519be22b6ad569079] | committer: Thomas Guillem

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

(cherry picked from commit a66661c0e89c14460cb0d6a48b7ee41caaa60593)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>

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

 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 5abe796feb..345b93a733 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