]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/ipmovie.c
unified CAVLC level decoding LUT.
[ffmpeg] / libavformat / ipmovie.c
index e6470fa0ca9dfc5a85f00e0dd11732cbf82fa3a1..35c61ded9d5af24bda45bcd2f9209fdc0abda99a 100644 (file)
@@ -101,20 +101,20 @@ typedef struct IPMVEContext {
     unsigned int audio_bits;
     unsigned int audio_channels;
     unsigned int audio_sample_rate;
-    unsigned int audio_type;
+    enum CodecID audio_type;
     unsigned int audio_frame_count;
 
     int video_stream_index;
     int audio_stream_index;
 
-    offset_t audio_chunk_offset;
+    int64_t audio_chunk_offset;
     int audio_chunk_size;
-    offset_t video_chunk_offset;
+    int64_t video_chunk_offset;
     int video_chunk_size;
-    offset_t decode_map_chunk_offset;
+    int64_t decode_map_chunk_offset;
     int decode_map_chunk_size;
 
-    offset_t next_chunk_offset;
+    int64_t next_chunk_offset;
 
     AVPaletteControl palette_control;
 
@@ -227,7 +227,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
 
     /* see if there are any pending packets */
     chunk_type = load_ipmovie_packet(s, pb, pkt);
-    if ((chunk_type == CHUNK_VIDEO) && (chunk_type != CHUNK_DONE))
+    if (chunk_type != CHUNK_DONE)
         return chunk_type;
 
     /* read the next chunk, wherever the file happens to be pointing */
@@ -446,7 +446,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
             last_color = first_color + AV_RL16(&scratch[2]) - 1;
             /* sanity check (since they are 16 bit values) */
             if ((first_color > 0xFF) || (last_color > 0xFF)) {
-                debug_ipmovie("demux_ipmovie: set_palette indices out of range (%d -> %d)\n",
+                debug_ipmovie("demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
                     first_color, last_color);
                 chunk_type = CHUNK_BAD;
                 break;
@@ -507,8 +507,6 @@ static int process_ipmovie_chunk(IPMVEContext *s, ByteIOContext *pb,
 
 static int ipmovie_probe(AVProbeData *p)
 {
-    if (p->buf_size < IPMOVIE_SIGNATURE_SIZE)
-        return 0;
     if (strncmp(p->buf, IPMOVIE_SIGNATURE, IPMOVIE_SIGNATURE_SIZE) != 0)
         return 0;
 
@@ -518,8 +516,8 @@ static int ipmovie_probe(AVProbeData *p)
 static int ipmovie_read_header(AVFormatContext *s,
                                AVFormatParameters *ap)
 {
-    IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data;
-    ByteIOContext *pb = &s->pb;
+    IPMVEContext *ipmovie = s->priv_data;
+    ByteIOContext *pb = s->pb;
     AVPacket pkt;
     AVStream *st;
     unsigned char chunk_preamble[CHUNK_PREAMBLE_SIZE];
@@ -541,19 +539,19 @@ static int ipmovie_read_header(AVFormatContext *s,
      * it; if it is the first video chunk, this is a silent file */
     if (get_buffer(pb, chunk_preamble, CHUNK_PREAMBLE_SIZE) !=
         CHUNK_PREAMBLE_SIZE)
-        return AVERROR_IO;
+        return AVERROR(EIO);
     chunk_type = AV_RL16(&chunk_preamble[2]);
     url_fseek(pb, -CHUNK_PREAMBLE_SIZE, SEEK_CUR);
 
     if (chunk_type == CHUNK_VIDEO)
-        ipmovie->audio_type = 0;  /* no audio */
+        ipmovie->audio_type = CODEC_ID_NONE;  /* no audio */
     else if (process_ipmovie_chunk(ipmovie, pb, &pkt) != CHUNK_INIT_AUDIO)
         return AVERROR_INVALIDDATA;
 
     /* initialize the stream decoders */
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
     av_set_pts_info(st, 33, 1, 90000);
     ipmovie->video_stream_index = st->index;
     st->codec->codec_type = CODEC_TYPE_VIDEO;
@@ -568,7 +566,7 @@ static int ipmovie_read_header(AVFormatContext *s,
     if (ipmovie->audio_type) {
         st = av_new_stream(s, 0);
         if (!st)
-            return AVERROR_NOMEM;
+            return AVERROR(ENOMEM);
         av_set_pts_info(st, 33, 1, 90000);
         ipmovie->audio_stream_index = st->index;
         st->codec->codec_type = CODEC_TYPE_AUDIO;
@@ -576,12 +574,12 @@ static int ipmovie_read_header(AVFormatContext *s,
         st->codec->codec_tag = 0;  /* no tag */
         st->codec->channels = ipmovie->audio_channels;
         st->codec->sample_rate = ipmovie->audio_sample_rate;
-        st->codec->bits_per_sample = ipmovie->audio_bits;
+        st->codec->bits_per_coded_sample = ipmovie->audio_bits;
         st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
-            st->codec->bits_per_sample;
+            st->codec->bits_per_coded_sample;
         if (st->codec->codec_id == CODEC_ID_INTERPLAY_DPCM)
             st->codec->bit_rate /= 2;
-        st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
+        st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
     }
 
     return 0;
@@ -590,36 +588,30 @@ static int ipmovie_read_header(AVFormatContext *s,
 static int ipmovie_read_packet(AVFormatContext *s,
                                AVPacket *pkt)
 {
-    IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data;
-    ByteIOContext *pb = &s->pb;
+    IPMVEContext *ipmovie = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int ret;
 
     ret = process_ipmovie_chunk(ipmovie, pb, pkt);
     if (ret == CHUNK_BAD)
         ret = AVERROR_INVALIDDATA;
     else if (ret == CHUNK_EOF)
-        ret = AVERROR_IO;
+        ret = AVERROR(EIO);
     else if (ret == CHUNK_NOMEM)
-        ret = AVERROR_NOMEM;
-    else
+        ret = AVERROR(ENOMEM);
+    else if (ret == CHUNK_VIDEO)
         ret = 0;
+    else
+        ret = -1;
 
     return ret;
 }
 
-static int ipmovie_read_close(AVFormatContext *s)
-{
-//    IPMVEContext *ipmovie = (IPMVEContext *)s->priv_data;
-
-    return 0;
-}
-
 AVInputFormat ipmovie_demuxer = {
     "ipmovie",
-    "Interplay MVE format",
+    NULL_IF_CONFIG_SMALL("Interplay MVE format"),
     sizeof(IPMVEContext),
     ipmovie_probe,
     ipmovie_read_header,
     ipmovie_read_packet,
-    ipmovie_read_close,
 };