]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/idcin.c
Discard two symbols from libswscale.
[ffmpeg] / libavformat / idcin.c
index aecc1098ddc8606e1e9e1ea39e37c0aa1edaf5c3..e113f4de1f3dd6f8a319b8867087ae42e8391a2d 100644 (file)
@@ -2,19 +2,21 @@
  * Id Quake II CIN File Demuxer
  * Copyright (c) 2003 The ffmpeg Project
  *
- * 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
  */
 
 /**
@@ -102,32 +104,28 @@ static int idcin_probe(AVProbeData *p)
      * audio channels: 0 for no audio, or 1 or 2
      */
 
-    /* cannot proceed without 20 bytes */
-    if (p->buf_size < 20)
-        return 0;
-
     /* check the video width */
-    number = LE_32(&p->buf[0]);
+    number = AV_RL32(&p->buf[0]);
     if ((number == 0) || (number > 1024))
        return 0;
 
     /* check the video height */
-    number = LE_32(&p->buf[4]);
+    number = AV_RL32(&p->buf[4]);
     if ((number == 0) || (number > 1024))
        return 0;
 
     /* check the audio sample rate */
-    number = LE_32(&p->buf[8]);
+    number = AV_RL32(&p->buf[8]);
     if ((number != 0) && ((number < 8000) | (number > 48000)))
         return 0;
 
     /* check the audio bytes/sample */
-    number = LE_32(&p->buf[12]);
+    number = AV_RL32(&p->buf[12]);
     if (number > 2)
         return 0;
 
     /* check the audio channels */
-    number = LE_32(&p->buf[16]);
+    number = AV_RL32(&p->buf[16]);
     if (number > 2)
         return 0;
 
@@ -138,8 +136,8 @@ static int idcin_probe(AVProbeData *p)
 static int idcin_read_header(AVFormatContext *s,
                              AVFormatParameters *ap)
 {
-    ByteIOContext *pb = &s->pb;
-    IdcinDemuxContext *idcin = (IdcinDemuxContext *)s->priv_data;
+    ByteIOContext *pb = s->pb;
+    IdcinDemuxContext *idcin = s->priv_data;
     AVStream *st;
     unsigned int width, height;
     unsigned int sample_rate, bytes_per_sample, channels;
@@ -153,43 +151,43 @@ static int idcin_read_header(AVFormatContext *s,
 
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
     av_set_pts_info(st, 33, 1, 90000);
     idcin->video_stream_index = st->index;
-    st->codec.codec_type = CODEC_TYPE_VIDEO;
-    st->codec.codec_id = CODEC_ID_IDCIN;
-    st->codec.codec_tag = 0;  /* no fourcc */
-    st->codec.width = width;
-    st->codec.height = height;
+    st->codec->codec_type = CODEC_TYPE_VIDEO;
+    st->codec->codec_id = CODEC_ID_IDCIN;
+    st->codec->codec_tag = 0;  /* no fourcc */
+    st->codec->width = width;
+    st->codec->height = height;
 
     /* load up the Huffman tables into extradata */
-    st->codec.extradata_size = HUFFMAN_TABLE_SIZE;
-    st->codec.extradata = av_malloc(HUFFMAN_TABLE_SIZE);
-    if (get_buffer(pb, st->codec.extradata, HUFFMAN_TABLE_SIZE) !=
+    st->codec->extradata_size = HUFFMAN_TABLE_SIZE;
+    st->codec->extradata = av_malloc(HUFFMAN_TABLE_SIZE);
+    if (get_buffer(pb, st->codec->extradata, HUFFMAN_TABLE_SIZE) !=
         HUFFMAN_TABLE_SIZE)
-        return AVERROR_IO;
+        return AVERROR(EIO);
     /* save a reference in order to transport the palette */
-    st->codec.palctrl = &idcin->palctrl;
+    st->codec->palctrl = &idcin->palctrl;
 
     /* if sample rate is 0, assume no audio */
     if (sample_rate) {
         idcin->audio_present = 1;
         st = av_new_stream(s, 0);
         if (!st)
-            return AVERROR_NOMEM;
+            return AVERROR(ENOMEM);
         av_set_pts_info(st, 33, 1, 90000);
         idcin->audio_stream_index = st->index;
-        st->codec.codec_type = CODEC_TYPE_AUDIO;
-        st->codec.codec_tag = 1;
-        st->codec.channels = channels;
-        st->codec.sample_rate = sample_rate;
-        st->codec.bits_per_sample = bytes_per_sample * 8;
-        st->codec.bit_rate = sample_rate * bytes_per_sample * 8 * channels;
-        st->codec.block_align = bytes_per_sample * channels;
+        st->codec->codec_type = CODEC_TYPE_AUDIO;
+        st->codec->codec_tag = 1;
+        st->codec->channels = channels;
+        st->codec->sample_rate = sample_rate;
+        st->codec->bits_per_sample = bytes_per_sample * 8;
+        st->codec->bit_rate = sample_rate * bytes_per_sample * 8 * channels;
+        st->codec->block_align = bytes_per_sample * channels;
         if (bytes_per_sample == 1)
-            st->codec.codec_id = CODEC_ID_PCM_U8;
+            st->codec->codec_id = CODEC_ID_PCM_U8;
         else
-            st->codec.codec_id = CODEC_ID_PCM_S16LE;
+            st->codec->codec_id = CODEC_ID_PCM_S16LE;
 
         if (sample_rate % 14 != 0) {
             idcin->audio_chunk_size1 = (sample_rate / 14) *
@@ -216,25 +214,25 @@ static int idcin_read_packet(AVFormatContext *s,
     int ret;
     unsigned int command;
     unsigned int chunk_size;
-    IdcinDemuxContext *idcin = (IdcinDemuxContext *)s->priv_data;
-    ByteIOContext *pb = &s->pb;
+    IdcinDemuxContext *idcin = s->priv_data;
+    ByteIOContext *pb = s->pb;
     int i;
     int palette_scale;
     unsigned char r, g, b;
     unsigned char palette_buffer[768];
 
-    if (url_feof(&s->pb))
-        return AVERROR_IO;
+    if (url_feof(s->pb))
+        return AVERROR(EIO);
 
     if (idcin->next_chunk_is_video) {
         command = get_le32(pb);
         if (command == 2) {
-            return AVERROR_IO;
+            return AVERROR(EIO);
         } else if (command == 1) {
             /* trigger a palette change */
             idcin->palctrl.palette_changed = 1;
             if (get_buffer(pb, palette_buffer, 768) != 768)
-                return AVERROR_IO;
+                return AVERROR(EIO);
             /* scale the palette as necessary */
             palette_scale = 2;
             for (i = 0; i < 768; i++)
@@ -255,9 +253,9 @@ static int idcin_read_packet(AVFormatContext *s,
         /* skip the number of decoded bytes (always equal to width * height) */
         url_fseek(pb, 4, SEEK_CUR);
         chunk_size -= 4;
-        ret= av_get_packet(pb, pkt, chunk_size); 
+        ret= av_get_packet(pb, pkt, chunk_size);
         if (ret != chunk_size)
-            return AVERROR_IO;
+            return AVERROR(EIO);
         pkt->stream_index = idcin->video_stream_index;
         pkt->pts = idcin->pts;
     } else {
@@ -268,7 +266,7 @@ static int idcin_read_packet(AVFormatContext *s,
             chunk_size = idcin->audio_chunk_size1;
         ret= av_get_packet(pb, pkt, chunk_size);
         if (ret != chunk_size)
-            return AVERROR_IO;
+            return AVERROR(EIO);
         pkt->stream_index = idcin->audio_stream_index;
         pkt->pts = idcin->pts;
 
@@ -288,7 +286,7 @@ static int idcin_read_close(AVFormatContext *s)
     return 0;
 }
 
-static AVInputFormat idcin_iformat = {
+AVInputFormat idcin_demuxer = {
     "idcin",
     "Id CIN format",
     sizeof(IdcinDemuxContext),
@@ -297,9 +295,3 @@ static AVInputFormat idcin_iformat = {
     idcin_read_packet,
     idcin_read_close,
 };
-
-int idcin_init(void)
-{
-    av_register_input_format(&idcin_iformat);
-    return 0;
-}