[MPlayer-cvslog] r38370 - trunk/libmpcodecs/mp_image.c

reimar subversion at mplayerhq.hu
Sun Aug 7 21:11:19 EEST 2022


Author: reimar
Date: Sun Aug  7 21:11:19 2022
New Revision: 38370

Log:
mp_image: ensure sufficient space in chroma planes.

For odd sized dimensions.
Fixes trac issue #2388.

Modified:
   trunk/libmpcodecs/mp_image.c

Modified: trunk/libmpcodecs/mp_image.c
==============================================================================
--- trunk/libmpcodecs/mp_image.c	Fri Jun  3 16:53:57 2022	(r38369)
+++ trunk/libmpcodecs/mp_image.c	Sun Aug  7 21:11:19 2022	(r38370)
@@ -163,6 +163,11 @@ void mp_image_setfmt(mp_image_t* mpi,uns
         mpi->bpp = mp_get_chroma_shift(out_fmt, &mpi->chroma_x_shift, &mpi->chroma_y_shift, NULL);
         mpi->chroma_width  = mpi->width  >> mpi->chroma_x_shift;
         mpi->chroma_height = mpi->height >> mpi->chroma_y_shift;
+        // ensure enough space for odd sizes
+        if ((mpi->chroma_width << mpi->chroma_x_shift) < mpi->width)
+            ++mpi->chroma_width;
+        if ((mpi->chroma_height << mpi->chroma_y_shift) < mpi->height)
+            ++mpi->chroma_height;
     }
     switch(out_fmt){
     case IMGFMT_I420:
@@ -241,7 +246,7 @@ void mp_image_setfmt(mp_image_t* mpi,uns
         mpi->bpp=12;
         mpi->num_planes=2;
         mpi->chroma_width=(mpi->width>>0);
-        mpi->chroma_height=(mpi->height>>1);
+        mpi->chroma_height=(mpi->height+1)>>1;
         mpi->chroma_x_shift=0;
         mpi->chroma_y_shift=1;
         return;


More information about the MPlayer-cvslog mailing list