]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/anm.c
mov: fix assigment check
[ffmpeg] / libavformat / anm.c
index 4d1b5f7620ed4c61f8a473ac68a4d3d91962445d..f78149285b7f0aeb1ecb19f0aec2ec0181d5cc51 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
+#include "internal.h"
 
 typedef struct {
     int base_record;
@@ -75,8 +76,7 @@ static int find_record(const AnmDemuxContext *anm, int record)
     return AVERROR_INVALIDDATA;
 }
 
-static int read_header(AVFormatContext *s,
-                       AVFormatParameters *ap)
+static int read_header(AVFormatContext *s)
 {
     AnmDemuxContext *anm = s->priv_data;
     AVIOContext *pb = s->pb;
@@ -85,8 +85,8 @@ static int read_header(AVFormatContext *s,
 
     avio_skip(pb, 4); /* magic number */
     if (avio_rl16(pb) != MAX_PAGES) {
-        av_log_ask_for_sample(s, "max_pages != " AV_STRINGIFY(MAX_PAGES) "\n");
-        return AVERROR_INVALIDDATA;
+        avpriv_request_sample(s, "max_pages != " AV_STRINGIFY(MAX_PAGES));
+        return AVERROR_PATCHWELCOME;
     }
 
     anm->nb_pages   = avio_rl16(pb);
@@ -97,11 +97,11 @@ static int read_header(AVFormatContext *s,
         return AVERROR_INVALIDDATA;
 
     /* video stream */
-    st = av_new_stream(s, 0);
+    st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
     st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
-    st->codec->codec_id   = CODEC_ID_ANM;
+    st->codec->codec_id   = AV_CODEC_ID_ANM;
     st->codec->codec_tag  = 0; /* no fourcc */
     st->codec->width      = avio_rl16(pb);
     st->codec->height     = avio_rl16(pb);
@@ -128,24 +128,23 @@ static int read_header(AVFormatContext *s,
 
     avio_skip(pb, 32); /* record_types */
     st->nb_frames = avio_rl32(pb);
-    av_set_pts_info(st, 64, 1, avio_rl16(pb));
+    avpriv_set_pts_info(st, 64, 1, avio_rl16(pb));
     avio_skip(pb, 58);
 
     /* color cycling and palette data */
     st->codec->extradata_size = 16*8 + 4*256;
     st->codec->extradata      = av_mallocz(st->codec->extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
     if (!st->codec->extradata) {
-        ret = AVERROR(ENOMEM);
-        goto close_and_return;
+        return AVERROR(ENOMEM);
     }
     ret = avio_read(pb, st->codec->extradata, st->codec->extradata_size);
     if (ret < 0)
-        goto close_and_return;
+        return ret;
 
     /* read page table */
     ret = avio_seek(pb, anm->page_table_offset, SEEK_SET);
     if (ret < 0)
-        goto close_and_return;
+        return ret;
 
     for (i = 0; i < MAX_PAGES; i++) {
         Page *p = &anm->pt[i];
@@ -157,20 +156,15 @@ static int read_header(AVFormatContext *s,
     /* find page of first frame */
     anm->page = find_record(anm, 0);
     if (anm->page < 0) {
-        ret = anm->page;
-        goto close_and_return;
+        return anm->page;
     }
 
     anm->record = -1;
     return 0;
 
 invalid:
-    av_log_ask_for_sample(s, NULL);
-    ret = AVERROR_INVALIDDATA;
-
-close_and_return:
-    av_close_input_stream(s);
-    return ret;
+    avpriv_request_sample(s, "Invalid header element");
+    return AVERROR_PATCHWELCOME;
 }
 
 static int read_packet(AVFormatContext *s,
@@ -226,10 +220,10 @@ repeat:
 }
 
 AVInputFormat ff_anm_demuxer = {
-    "anm",
-    NULL_IF_CONFIG_SMALL("Deluxe Paint Animation"),
-    sizeof(AnmDemuxContext),
-    probe,
-    read_header,
-    read_packet,
+    .name           = "anm",
+    .long_name      = NULL_IF_CONFIG_SMALL("Deluxe Paint Animation"),
+    .priv_data_size = sizeof(AnmDemuxContext),
+    .read_probe     = probe,
+    .read_header    = read_header,
+    .read_packet    = read_packet,
 };