]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/gifdec.c
cosmetical change of mp3_parse_xing() to prepare for upcoming VBRI tag support
[ffmpeg] / libavformat / gifdec.c
index 7ceadfd055bf2e1ee1d0573167c17e18e091aeb6..26cbe69962dab16d9adeadce3105f6e24ad392dc 100644 (file)
@@ -1,25 +1,25 @@
 /*
- * GIF decoder
+ * GIF demuxer
  * Copyright (c) 2003 Fabrice Bellard.
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avformat.h"
 
-int gif_write(ByteIOContext *pb, AVImageInfo *info);
-
 //#define DEBUG
 
 #define MAXBITS                 12
@@ -142,17 +142,6 @@ static int gif_video_probe(AVProbeData * pd)
     return 0;
 }
 
-static int gif_image_probe(AVProbeData * pd)
-{
-    if (pd->buf_size >= 24 &&
-        (memcmp(pd->buf, gif87a_sig, 6) == 0 ||
-         memcmp(pd->buf, gif89a_sig, 6) == 0))
-        return AVPROBE_SCORE_MAX - 1;
-    else
-        return 0;
-}
-
-
 static void GLZWDecodeInit(GifState * s, int csize)
 {
     /* read buffer */
@@ -316,13 +305,13 @@ static int gif_read_image(GifState *s)
     /* verify that all the image is inside the screen dimensions */
     if (left + width > s->screen_width ||
         top + height > s->screen_height)
-        return -EINVAL;
+        return AVERROR(EINVAL);
 
     /* build the palette */
     if (s->pix_fmt == PIX_FMT_RGB24) {
         line = av_malloc(width);
         if (!line)
-            return -ENOMEM;
+            return AVERROR(ENOMEM);
     } else {
         n = (1 << bits_per_pixel);
         spal = palette;
@@ -511,21 +500,21 @@ static int gif_parse_next_image(GifState *s)
         switch (code) {
         case ',':
             if (gif_read_image(s) < 0)
-                return AVERROR_IO;
+                return AVERROR(EIO);
             ret = 0;
             goto the_end;
         case ';':
             /* end of image */
-            ret = AVERROR_IO;
+            ret = AVERROR(EIO);
             goto the_end;
         case '!':
             if (gif_read_extension(s) < 0)
-                return AVERROR_IO;
+                return AVERROR(EIO);
             break;
         case EOF:
         default:
             /* error or errneous EOF */
-            ret = AVERROR_IO;
+            ret = AVERROR(EIO);
             goto the_end;
         }
     }
@@ -548,7 +537,7 @@ static int gif_read_header(AVFormatContext * s1,
     s->image_linesize = s->screen_width * 3;
     s->image_buf = av_malloc(s->screen_height * s->image_linesize);
     if (!s->image_buf)
-        return -ENOMEM;
+        return AVERROR(ENOMEM);
     s->pix_fmt = PIX_FMT_RGB24;
     /* now we are ready: build format streams */
     st = av_new_stream(s1, 0);
@@ -578,7 +567,7 @@ static int gif_read_packet(AVFormatContext * s1,
 
     /* XXX: avoid copying */
     if (av_new_packet(pkt, s->screen_width * s->screen_height * 3)) {
-        return AVERROR_IO;
+        return AVERROR(EIO);
     }
     pkt->stream_index = 0;
     memcpy(pkt->data, s->image_buf, s->screen_width * s->screen_height * 3);
@@ -592,34 +581,7 @@ static int gif_read_close(AVFormatContext *s1)
     return 0;
 }
 
-/* read gif as image */
-static int gif_read(ByteIOContext *f,
-                    int (*alloc_cb)(void *opaque, AVImageInfo *info), void *opaque)
-{
-    GifState s1, *s = &s1;
-    AVImageInfo info1, *info = &info1;
-    int ret;
-
-    memset(s, 0, sizeof(GifState));
-    s->f = f;
-    if (gif_read_header1(s) < 0)
-        return -1;
-    info->width = s->screen_width;
-    info->height = s->screen_height;
-    info->pix_fmt = PIX_FMT_PAL8;
-    ret = alloc_cb(opaque, info);
-    if (ret)
-        return ret;
-    s->image_buf = info->pict.data[0];
-    s->image_linesize = info->pict.linesize[0];
-    s->image_palette = (uint32_t *)info->pict.data[1];
-
-    if (gif_parse_next_image(s) < 0)
-        return -1;
-    return 0;
-}
-
-AVInputFormat gif_iformat =
+AVInputFormat gif_demuxer =
 {
     "gif",
     "gif format",
@@ -629,12 +591,3 @@ AVInputFormat gif_iformat =
     gif_read_packet,
     gif_read_close,
 };
-
-AVImageFormat gif_image_format = {
-    "gif",
-    "gif",
-    gif_image_probe,
-    gif_read,
-    (1 << PIX_FMT_PAL8),
-    gif_write,
-};