]> git.sesse.net Git - ffmpeg/commitdiff
- Fix memory leak and others bugs for ppmpipe. Thanks to Rudolf Opalla.
authorJuanjo <pulento@users.sourceforge.net>
Tue, 2 Apr 2002 15:07:01 +0000 (15:07 +0000)
committerJuanjo <pulento@users.sourceforge.net>
Tue, 2 Apr 2002 15:07:01 +0000 (15:07 +0000)
Originally committed as revision 373 to svn://svn.ffmpeg.org/ffmpeg/trunk

ffmpeg.c
libav/img.c

index 5edd33dc7ba547bb33cc12c273dbd6fa5bc795fe..7310df492935fb99d17aa0d4d54d6bef0cfe6ef7 100644 (file)
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -302,15 +302,14 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
     UINT8 *buf, *src, *dest;
     int size, j, i;
 
-    size = avpicture_get_size(pix_fmt, w, h);
-    buf = malloc(size);
-    if (!buf)
-        return;
-
     /* XXX: not efficient, should add test if we can take
        directly the AVPicture */
     switch(pix_fmt) {
     case PIX_FMT_YUV420P:
+        size = avpicture_get_size(pix_fmt, w, h);
+        buf = malloc(size);
+        if (!buf)
+            return;
         dest = buf;
         for(i=0;i<3;i++) {
             if (i == 1) {
@@ -328,6 +327,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
     case PIX_FMT_YUV422P:
         size = (w * h) * 2; 
         buf = malloc(size);
+        if (!buf)
+            return;
         dest = buf;
         for(i=0;i<3;i++) {
             if (i == 1) {
@@ -344,6 +345,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
     case PIX_FMT_YUV444P:
         size = (w * h) * 3; 
         buf = malloc(size);
+        if (!buf)
+            return;
         dest = buf;
         for(i=0;i<3;i++) {
             src = picture->data[i];
@@ -357,6 +360,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
     case PIX_FMT_YUV422:
         size = (w * h) * 2; 
         buf = malloc(size);
+        if (!buf)
+            return;
         dest = buf;
         src = picture->data[0];
         for(j=0;j<h;j++) {
@@ -369,6 +374,8 @@ static void write_picture(AVFormatContext *s, int index, AVPicture *picture,
     case PIX_FMT_BGR24:
         size = (w * h) * 3; 
         buf = malloc(size);
+        if (!buf)
+            return;
         dest = buf;
         src = picture->data[0];
         for(j=0;j<h;j++) {
index 710530b831577b2469fc1eed3bc09472938be491..e793d43d09f2a84d47da2c39fb8f9ccb1a59f229 100644 (file)
@@ -169,10 +169,14 @@ static int img_read_packet(AVFormatContext *s1, AVPacket *pkt)
     int ret;
     ByteIOContext f1, *f;
 
+/*
+    This if-statement destroys pipes - I do not see why it is necessary
     if (get_frame_filename(filename, sizeof(filename),
                            s->path, s->img_number) < 0)
         return -EIO;
-    
+*/
+    get_frame_filename(filename, sizeof(filename),
+                       s->path, s->img_number);
     if (!s->is_pipe) {
         f = &f1;
         if (url_fopen(f, filename, URL_RDONLY) < 0)
@@ -547,10 +551,14 @@ static int img_write_packet(AVFormatContext *s, int stream_index,
         return -EIO;
     }
     
+/*
+    This if-statement destroys pipes - I do not see why it is necessary
     if (get_frame_filename(filename, sizeof(filename), 
                            img->path, img->img_number) < 0)
         return -EIO;
-
+*/
+    get_frame_filename(filename, sizeof(filename), 
+                       img->path, img->img_number);
     if (!img->is_pipe) {
         pb = &pb1;
         if (url_fopen(pb, filename, URL_WRONLY) < 0)