changeset 34216:66cdad95f543

Fixes for palette allocation handling.
author reimar
date Sat, 05 Nov 2011 18:20:44 +0000
parents 70e6cffc6bb9
children aafe86a9a6e8
files libmpcodecs/vd_ffmpeg.c libmpcodecs/vf.c
diffstat 2 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/vd_ffmpeg.c	Sat Nov 05 16:35:50 2011 +0000
+++ b/libmpcodecs/vd_ffmpeg.c	Sat Nov 05 18:20:44 2011 +0000
@@ -709,9 +709,6 @@
     }
 
     if (mpi) {
-        // Palette support: free palette buffer allocated in get_buffer
-        if (mpi->bpp == 8)
-            av_freep(&mpi->planes[1]);
         // release mpi (in case MPI_IMGTYPE_NUMBERED is used, e.g. for VDPAU)
         mpi->usage_count--;
     }
--- a/libmpcodecs/vf.c	Sat Nov 05 16:35:50 2011 +0000
+++ b/libmpcodecs/vf.c	Sat Nov 05 18:20:44 2011 +0000
@@ -338,6 +338,7 @@
     break;
   }
   if(mpi){
+    int missing_palette = !(mpi->flags & MP_IMGFLAG_RGB_PALETTE) && (mp_imgflag & MP_IMGFLAG_RGB_PALETTE);
     mpi->type=mp_imgtype;
     mpi->w=vf->w; mpi->h=vf->h;
     // keep buffer allocation status & color flags only:
@@ -346,12 +347,14 @@
     // accept restrictions, draw_slice and palette flags only:
     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;
-    if(mpi->width!=w2 || mpi->height!=h){
+    if(mpi->width!=w2 || mpi->height!=h || 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){
+            if(mpi->width<w2 || mpi->height<h || missing_palette){
                 // need to re-allocate buffer memory:
-                av_free(mpi->planes[0]);
+                av_freep(&mpi->planes[0]);
+                if (mpi->flags & MP_IMGFLAG_RGB_PALETTE)
+                    av_freep(&mpi->planes[1]);
                 mpi->flags&=~MP_IMGFLAG_ALLOCATED;
                 mp_msg(MSGT_VFILTER,MSGL_V,"vf.c: have to REALLOCATE buffer memory :(\n");
             }