]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/segafilm.c
configure: set HOSTCC to native compiler
[ffmpeg] / libavformat / segafilm.c
index 5990047f0b9cd2f78a9b20478c370cc0e9f506ef..27ff06bc28b5d41d5833e64543291c9b19f0830e 100644 (file)
@@ -36,7 +36,7 @@
 
 typedef struct {
   int stream;
-  offset_t sample_offset;
+  int64_t sample_offset;
   unsigned int sample_size;
   int64_t pts;
   int keyframe;
@@ -46,12 +46,12 @@ typedef struct FilmDemuxContext {
     int video_stream_index;
     int audio_stream_index;
 
-    unsigned int audio_type;
+    enum CodecID audio_type;
     unsigned int audio_samplerate;
     unsigned int audio_bits;
     unsigned int audio_channels;
 
-    unsigned int video_type;
+    enum CodecID video_type;
     unsigned int sample_count;
     film_sample_t *sample_table;
     unsigned int current_sample;
@@ -75,8 +75,8 @@ static int film_probe(AVProbeData *p)
 static int film_read_header(AVFormatContext *s,
                             AVFormatParameters *ap)
 {
-    FilmDemuxContext *film = (FilmDemuxContext *)s->priv_data;
-    ByteIOContext *pb = &s->pb;
+    FilmDemuxContext *film = s->priv_data;
+    ByteIOContext *pb = s->pb;
     AVStream *st;
     unsigned char scratch[256];
     int i;
@@ -89,7 +89,7 @@ static int film_read_header(AVFormatContext *s,
 
     /* load the main FILM header */
     if (get_buffer(pb, scratch, 16) != 16)
-        return AVERROR_IO;
+        return AVERROR(EIO);
     data_offset = AV_RB32(&scratch[4]);
     film->version = AV_RB32(&scratch[8]);
 
@@ -97,7 +97,7 @@ static int film_read_header(AVFormatContext *s,
     if (film->version == 0) {
         /* special case for Lemmings .film files; 20-byte header */
         if (get_buffer(pb, scratch, 20) != 20)
-            return AVERROR_IO;
+            return AVERROR(EIO);
         /* make some assumptions about the audio parameters */
         film->audio_type = CODEC_ID_PCM_S8;
         film->audio_samplerate = 22050;
@@ -106,8 +106,8 @@ static int film_read_header(AVFormatContext *s,
     } else {
         /* normal Saturn .cpk files; 32-byte header */
         if (get_buffer(pb, scratch, 32) != 32)
-            return AVERROR_IO;
-        film->audio_samplerate = AV_RB16(&scratch[24]);;
+            return AVERROR(EIO);
+        film->audio_samplerate = AV_RB16(&scratch[24]);
         film->audio_channels = scratch[21];
         film->audio_bits = scratch[22];
         if (film->audio_bits == 8)
@@ -115,7 +115,7 @@ static int film_read_header(AVFormatContext *s,
         else if (film->audio_bits == 16)
             film->audio_type = CODEC_ID_PCM_S16BE;
         else
-            film->audio_type = 0;
+            film->audio_type = CODEC_ID_NONE;
     }
 
     if (AV_RB32(&scratch[0]) != FDSC_TAG)
@@ -124,13 +124,13 @@ static int film_read_header(AVFormatContext *s,
     if (AV_RB32(&scratch[8]) == CVID_TAG) {
         film->video_type = CODEC_ID_CINEPAK;
     } else
-        film->video_type = 0;
+        film->video_type = CODEC_ID_NONE;
 
     /* initialize the decoder streams */
     if (film->video_type) {
         st = av_new_stream(s, 0);
         if (!st)
-            return AVERROR_NOMEM;
+            return AVERROR(ENOMEM);
         film->video_stream_index = st->index;
         st->codec->codec_type = CODEC_TYPE_VIDEO;
         st->codec->codec_id = film->video_type;
@@ -142,23 +142,23 @@ static int film_read_header(AVFormatContext *s,
     if (film->audio_type) {
         st = av_new_stream(s, 0);
         if (!st)
-            return AVERROR_NOMEM;
+            return AVERROR(ENOMEM);
         film->audio_stream_index = st->index;
         st->codec->codec_type = CODEC_TYPE_AUDIO;
         st->codec->codec_id = film->audio_type;
         st->codec->codec_tag = 1;
         st->codec->channels = film->audio_channels;
-        st->codec->bits_per_sample = film->audio_bits;
+        st->codec->bits_per_coded_sample = film->audio_bits;
         st->codec->sample_rate = film->audio_samplerate;
         st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
-            st->codec->bits_per_sample;
+            st->codec->bits_per_coded_sample;
         st->codec->block_align = st->codec->channels *
-            st->codec->bits_per_sample / 8;
+            st->codec->bits_per_coded_sample / 8;
     }
 
     /* load the sample table */
     if (get_buffer(pb, scratch, 16) != 16)
-        return AVERROR_IO;
+        return AVERROR(EIO);
     if (AV_RB32(&scratch[0]) != STAB_TAG)
         return AVERROR_INVALIDDATA;
     film->base_clock = AV_RB32(&scratch[8]);
@@ -175,7 +175,7 @@ static int film_read_header(AVFormatContext *s,
         /* load the next sample record and transfer it to an internal struct */
         if (get_buffer(pb, scratch, 16) != 16) {
             av_free(film->sample_table);
-            return AVERROR_IO;
+            return AVERROR(EIO);
         }
         film->sample_table[i].sample_offset =
             data_offset + AV_RB32(&scratch[0]);
@@ -203,15 +203,15 @@ static int film_read_header(AVFormatContext *s,
 static int film_read_packet(AVFormatContext *s,
                             AVPacket *pkt)
 {
-    FilmDemuxContext *film = (FilmDemuxContext *)s->priv_data;
-    ByteIOContext *pb = &s->pb;
+    FilmDemuxContext *film = s->priv_data;
+    ByteIOContext *pb = s->pb;
     film_sample_t *sample;
     int ret = 0;
     int i;
     int left, right;
 
     if (film->current_sample >= film->sample_count)
-        return AVERROR_IO;
+        return AVERROR(EIO);
 
     sample = &film->sample_table[film->current_sample];
 
@@ -223,14 +223,14 @@ static int film_read_packet(AVFormatContext *s,
         (film->video_type == CODEC_ID_CINEPAK)) {
         pkt->pos= url_ftell(pb);
         if (av_new_packet(pkt, sample->sample_size))
-            return AVERROR_NOMEM;
+            return AVERROR(ENOMEM);
         get_buffer(pb, pkt->data, sample->sample_size);
     } else if ((sample->stream == film->audio_stream_index) &&
         (film->audio_channels == 2)) {
         /* stereo PCM needs to be interleaved */
 
         if (av_new_packet(pkt, sample->sample_size))
-            return AVERROR_NOMEM;
+            return AVERROR(ENOMEM);
 
         /* make sure the interleave buffer is large enough */
         if (sample->sample_size > film->stereo_buffer_size) {
@@ -242,7 +242,7 @@ static int film_read_packet(AVFormatContext *s,
         pkt->pos= url_ftell(pb);
         ret = get_buffer(pb, film->stereo_buffer, sample->sample_size);
         if (ret != sample->sample_size)
-            ret = AVERROR_IO;
+            ret = AVERROR(EIO);
 
         left = 0;
         right = sample->sample_size / 2;
@@ -260,7 +260,7 @@ static int film_read_packet(AVFormatContext *s,
     } else {
         ret= av_get_packet(pb, pkt, sample->sample_size);
         if (ret != sample->sample_size)
-            ret = AVERROR_IO;
+            ret = AVERROR(EIO);
     }
 
     pkt->stream_index = sample->stream;
@@ -273,7 +273,7 @@ static int film_read_packet(AVFormatContext *s,
 
 static int film_read_close(AVFormatContext *s)
 {
-    FilmDemuxContext *film = (FilmDemuxContext *)s->priv_data;
+    FilmDemuxContext *film = s->priv_data;
 
     av_free(film->sample_table);
     av_free(film->stereo_buffer);
@@ -283,7 +283,7 @@ static int film_read_close(AVFormatContext *s)
 
 AVInputFormat segafilm_demuxer = {
     "film_cpk",
-    "Sega FILM/CPK format",
+    NULL_IF_CONFIG_SMALL("Sega FILM/CPK format"),
     sizeof(FilmDemuxContext),
     film_probe,
     film_read_header,