]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/ipmovie.c
avfilter: Remove deprecated resample_lavr_opts
[ffmpeg] / libavformat / ipmovie.c
index 7f5a8c62ef69bb79a0e268c3bc47082c4fb407fa..9118d7d807bfb5e02be5f7c9cb27ebcb37499d49 100644 (file)
@@ -47,6 +47,7 @@
 #define CHUNK_SHUTDOWN     0x0004
 #define CHUNK_END          0x0005
 /* these last types are used internally */
+#define CHUNK_HAVE_PACKET  0xFFFB
 #define CHUNK_DONE         0xFFFC
 #define CHUNK_NOMEM        0xFFFD
 #define CHUNK_EOF          0xFFFE
@@ -154,7 +155,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
         av_log(s->avf, AV_LOG_TRACE, "sending audio frame with pts %"PRId64" (%d audio frames)\n",
                 pkt->pts, s->audio_frame_count);
 
-        chunk_type = CHUNK_VIDEO;
+        chunk_type = CHUNK_HAVE_PACKET;
 
     } else if (s->frame_format) {
 
@@ -194,7 +195,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
 
         if (avio_read(pb, pkt->data + 8, s->video_chunk_size) !=
             s->video_chunk_size) {
-            av_packet_unref(pkt);
             return CHUNK_EOF;
         }
 
@@ -205,7 +205,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
 
             if (avio_read(pb, pkt->data + 8 + s->video_chunk_size,
                 s->decode_map_chunk_size) != s->decode_map_chunk_size) {
-                av_packet_unref(pkt);
                 return CHUNK_EOF;
             }
         }
@@ -217,7 +216,6 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
 
             if (avio_read(pb, pkt->data + 8 + s->video_chunk_size + s->decode_map_chunk_size,
                 s->skip_map_chunk_size) != s->skip_map_chunk_size) {
-                av_packet_unref(pkt);
                 return CHUNK_EOF;
             }
         }
@@ -233,7 +231,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
 
         s->video_pts += s->frame_pts_inc;
 
-        chunk_type = CHUNK_VIDEO;
+        chunk_type = CHUNK_HAVE_PACKET;
 
     } else {
 
@@ -562,28 +560,11 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
             break;
 
         case OPCODE_VIDEO_DATA_06:
-            av_log(s->avf, AV_LOG_TRACE, "set video data format 0x06\n");
-            s->frame_format = 0x06;
-
-            /* log position and move on for now */
-            s->video_chunk_offset = avio_tell(pb);
-            s->video_chunk_size = opcode_size;
-            avio_skip(pb, opcode_size);
-            break;
-
         case OPCODE_VIDEO_DATA_10:
-            av_log(s->avf, AV_LOG_TRACE, "set video data format 0x10\n");
-            s->frame_format = 0x10;
-
-            /* log position and move on for now */
-            s->video_chunk_offset = avio_tell(pb);
-            s->video_chunk_size = opcode_size;
-            avio_skip(pb, opcode_size);
-            break;
-
         case OPCODE_VIDEO_DATA_11:
-            av_log(s->avf, AV_LOG_TRACE, "set video data format 0x11\n");
-            s->frame_format = 0x11;
+            s->frame_format = opcode_type;
+            av_log(s->avf, AV_LOG_TRACE, "set video data format 0x%02X\n",
+                   opcode_type);
 
             /* log position and move on for now */
             s->video_chunk_offset = avio_tell(pb);
@@ -605,16 +586,12 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
     /* make a note of where the stream is sitting */
     s->next_chunk_offset = avio_tell(pb);
 
-    /* dispatch the first of any pending packets */
-    if ((chunk_type == CHUNK_VIDEO) || (chunk_type == CHUNK_AUDIO_ONLY))
-        chunk_type = load_ipmovie_packet(s, pb, pkt);
-
     return chunk_type;
 }
 
 static const char signature[] = "Interplay MVE File\x1A\0\x1A";
 
-static int ipmovie_probe(AVProbeData *p)
+static int ipmovie_probe(const AVProbeData *p)
 {
     const uint8_t *b = p->buf;
     const uint8_t *b_end = p->buf + p->buf_size - sizeof(signature);
@@ -631,7 +608,6 @@ static int ipmovie_read_header(AVFormatContext *s)
 {
     IPMVEContext *ipmovie = s->priv_data;
     AVIOContext *pb = s->pb;
-    AVPacket pkt;
     AVStream *st;
     unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
     int chunk_type, i;
@@ -646,13 +622,6 @@ static int ipmovie_read_header(AVFormatContext *s)
         if (avio_feof(pb))
             return AVERROR_EOF;
     }
-    /* initialize private context members */
-    ipmovie->video_pts = ipmovie->audio_frame_count = 0;
-    ipmovie->audio_chunk_offset = ipmovie->video_chunk_offset =
-    ipmovie->decode_map_chunk_offset = ipmovie->skip_map_chunk_offset = 0;
-    ipmovie->decode_map_chunk_size = ipmovie->video_chunk_size =
-    ipmovie->skip_map_chunk_size = 0;
-    ipmovie->send_buffer = ipmovie->frame_format = 0;
 
     /* on the first read, this will position the stream at the first chunk */
     ipmovie->next_chunk_offset = avio_tell(pb) + 4;
@@ -661,8 +630,9 @@ static int ipmovie_read_header(AVFormatContext *s)
         ipmovie->palette[i] = 0xFFU << 24;
 
     /* process the first chunk which should be CHUNK_INIT_VIDEO */
-    if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_VIDEO)
+    if (process_ipmovie_chunk(ipmovie, pb, NULL) != CHUNK_INIT_VIDEO) {
         return AVERROR_INVALIDDATA;
+    }
 
     /* peek ahead to the next chunk-- if it is an init audio chunk, process
      * it; if it is the first video chunk, this is a silent file */
@@ -674,8 +644,9 @@ static int ipmovie_read_header(AVFormatContext *s)
 
     if (chunk_type == CHUNK_VIDEO)
         ipmovie->audio_type = AV_CODEC_ID_NONE;  /* no audio */
-    else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
+    else if (process_ipmovie_chunk(ipmovie, pb, s->internal->parse_pkt) != CHUNK_INIT_AUDIO) {
         return AVERROR_INVALIDDATA;
+    }
 
     /* initialize the stream decoders */
     st = avformat_new_stream(s, NULL);
@@ -706,23 +677,27 @@ static int ipmovie_read_packet(AVFormatContext *s,
     int ret;
 
     for (;;) {
-    ret = process_ipmovie_chunk(ipmovie, pb, pkt);
-    if (ret == CHUNK_BAD)
-        ret = AVERROR_INVALIDDATA;
-    else if (ret == CHUNK_EOF)
-        ret = AVERROR(EIO);
-    else if (ret == CHUNK_NOMEM)
-        ret = AVERROR(ENOMEM);
-    else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN)
-        ret = AVERROR_EOF;
-    else if (ret == CHUNK_VIDEO)
-        ret = 0;
-    else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO)
-        continue;
-    else
-        continue;
-
-    return ret;
+        ret = process_ipmovie_chunk(ipmovie, pb, pkt);
+        /* dispatch the first of any pending packets */
+        if ((ret == CHUNK_VIDEO) || (ret == CHUNK_AUDIO_ONLY))
+            ret = load_ipmovie_packet(ipmovie, pb, pkt);
+
+        if (ret == CHUNK_BAD)
+            ret = AVERROR_INVALIDDATA;
+        else if (ret == CHUNK_EOF)
+            ret = AVERROR(EIO);
+        else if (ret == CHUNK_NOMEM)
+            ret = AVERROR(ENOMEM);
+        else if (ret == CHUNK_END || ret == CHUNK_SHUTDOWN)
+            ret = AVERROR_EOF;
+        else if (ret == CHUNK_HAVE_PACKET)
+            ret = 0;
+        else if (ret == CHUNK_INIT_VIDEO || ret == CHUNK_INIT_AUDIO)
+            continue;
+        else
+            continue;
+
+        return ret;
     }
 }