[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 10:50:20 CEST 2018


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Apr 17 14:50:48 2018 +0200| [2e1e458bdef09b113cc96cd990ac0eb41ae33f23] | committer: Steve Lhomme

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.

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

 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 2857733c1d..179a792bb2 100644
--- a/modules/video_chroma/copy.c
+++ b/modules/video_chroma/copy.c
@@ -1088,8 +1088,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