[PATCH 5/9] Use av_image_alloc() in avpicture_alloc(), simplify.

Stefano Sabatini stefano.sabatini-lala
Tue Nov 9 23:36:44 CET 2010


---
 libavcodec/imgconvert.c |   19 ++++---------------
 1 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index a7d8812..df86d95 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -863,23 +863,12 @@ void ff_shrink88(uint8_t *dst, int dst_wrap,
 int avpicture_alloc(AVPicture *picture,
                     enum PixelFormat pix_fmt, int width, int height)
 {
-    int size;
-    void *ptr;
-
-    size = avpicture_fill(picture, NULL, pix_fmt, width, height);
-    if(size<0)
-        goto fail;
-    ptr = av_malloc(size);
-    if (!ptr)
-        goto fail;
-    avpicture_fill(picture, ptr, pix_fmt, width, height);
-    if(picture->data[1] && !picture->data[2])
-        ff_set_systematic_pal2((uint32_t*)picture->data[1], pix_fmt);
-
-    return 0;
- fail:
+    if (av_image_alloc(picture->data, picture->linesize, width, height, pix_fmt, 0) < 0) {
     memset(picture, 0, sizeof(AVPicture));
     return -1;
+    }
+
+    return 0;
 }
 
 void avpicture_free(AVPicture *picture)
-- 
1.7.1


--aT9PWwzfKXlsBJM1--



More information about the ffmpeg-devel mailing list