changeset 35380:b18c14526662

Fix incorrect mp_image allocations when the input format changes. Should fix crashes when decoding JPEG images with different subsampling.
author reimar
date Sun, 25 Nov 2012 14:18:12 +0000
parents 2b49f4c8c47f
children 746e2e0577b2
files libmpcodecs/vf.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vf.c	Sun Nov 25 14:17:23 2012 +0000
+++ b/libmpcodecs/vf.c	Sun Nov 25 14:18:12 2012 +0000
@@ -358,15 +358,16 @@
     mpi->flags|=mp_imgflag&(MP_IMGFLAGMASK_RESTRICTIONS|MP_IMGFLAG_DRAW_CALLBACK|MP_IMGFLAG_RGB_PALETTE);
     if(!vf->draw_slice) mpi->flags&=~MP_IMGFLAG_DRAW_CALLBACK;
     missing_palette = !(mpi->flags & MP_IMGFLAG_RGB_PALETTE) && (mp_imgflag & MP_IMGFLAG_RGB_PALETTE);
-    if(mpi->width!=w2 || mpi->height!=h || missing_palette){
+    if(mpi->width!=w2 || mpi->height!=h || mpi->imgfmt != outfmt || missing_palette){
 //      printf("vf.c: MPI parameters changed!  %dx%d -> %dx%d   \n", mpi->width,mpi->height,w2,h);
         if(mpi->flags&MP_IMGFLAG_ALLOCATED){
-            if(mpi->width<w2 || mpi->height<h || missing_palette){
+            if(mpi->width<w2 || mpi->height<h || mpi->imgfmt != outfmt || missing_palette){
                 // need to re-allocate buffer memory:
                 av_freep(&mpi->planes[0]);
                 if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
                     av_freep(&mpi->planes[1]);
                 mpi->flags&=~MP_IMGFLAG_ALLOCATED;
+                mpi->bpp = 0;
                 mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory in vf_%s :(\n",
                        vf->info->name);
             }