[vlc-commits] chroma: copy: fix tests losing the last U/V lines when using odd dimensions

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


vlc/vlc-3.0 | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Apr 17 14:50:48 2018 +0200| [4bda761c82c1b86ab92ad545516431a345c99359] | committer: Thomas Guillem

chroma: copy: fix tests losing the last U/V lines when using odd dimensions

Do do this we need to know that NV12 requires 2 octets per UV pixel which was
not possible with the 1/1 height fraction.

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

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

 modules/video_chroma/copy.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/modules/video_chroma/copy.c b/modules/video_chroma/copy.c
index 67b92ebbf1..8547a6b1f7 100644
--- a/modules/video_chroma/copy.c
+++ b/modules/video_chroma/copy.c
@@ -1141,8 +1141,8 @@ static picture_t *pic_new_unaligned(const video_format_t *fmt)
     picture_resource_t rsc = { .pf_destroy = pic_rsc_destroy };
     for (unsigned i = 0; i < dsc->plane_count; i++)
     {
-        rsc.p[i].i_lines = ((fmt->i_visible_height + 1) & ~ 1) * dsc->p[i].h.num / dsc->p[i].h.den;
-        rsc.p[i].i_pitch = ((fmt->i_visible_width + 1) & ~ 1) * dsc->pixel_size * dsc->p[i].w.num / dsc->p[i].w.den;
+        rsc.p[i].i_lines = ((fmt->i_visible_height + (dsc->p[i].h.den - 1)) / dsc->p[i].h.den) * dsc->p[i].h.num;
+        rsc.p[i].i_pitch = ((fmt->i_visible_width + (dsc->p[i].w.den - 1)) / dsc->p[i].w.den) * dsc->p[i].w.num * dsc->pixel_size;
         rsc.p[i].p_pixels = malloc(rsc.p[i].i_lines * rsc.p[i].i_pitch);
         assert(rsc.p[i].p_pixels);
     }



More information about the vlc-commits mailing list