diff imgconvert.c @ 9217:53ec03e7ba40 libavcodec

Fix avpicture_get_size for non-paletted formats with a helper palette to not include the size of that palette. Also clarify its documentation.
author reimar
date Sat, 21 Mar 2009 10:25:20 +0000
parents fa58c81d8cde
children a15ec86bf752
line wrap: on
line diff
--- a/imgconvert.c	Sat Mar 21 01:54:31 2009 +0000
+++ b/imgconvert.c	Sat Mar 21 10:25:20 2009 +0000
@@ -786,6 +786,17 @@
 int avpicture_get_size(int pix_fmt, int width, int height)
 {
     AVPicture dummy_pict;
+    if(avcodec_check_dimensions(NULL, width, height))
+        return -1;
+    switch (pix_fmt) {
+    case PIX_FMT_RGB8:
+    case PIX_FMT_BGR8:
+    case PIX_FMT_RGB4_BYTE:
+    case PIX_FMT_BGR4_BYTE:
+    case PIX_FMT_GRAY8:
+        // do not include palette for these pseudo-paletted formats
+        return width * height;
+    }
     return avpicture_fill(&dummy_pict, NULL, pix_fmt, width, height);
 }
 
@@ -1125,7 +1136,7 @@
     int size;
     void *ptr;
 
-    size = avpicture_get_size(pix_fmt, width, height);
+    size = avpicture_fill(picture, NULL, pix_fmt, width, height);
     if(size<0)
         goto fail;
     ptr = av_malloc(size);