]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/idcin.c
enable mjpeg in swf
[ffmpeg] / libavformat / idcin.c
index ccb1d4b48f9470c18a3ae0cabad8947992aefd42..48d1e250d79d87a053edca4a53fbf10a96355385 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
  */
 
 /**
@@ -154,21 +156,22 @@ static int idcin_read_header(AVFormatContext *s,
     st = av_new_stream(s, 0);
     if (!st)
         return AVERROR_NOMEM;
+    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 -EIO;
+        return AVERROR_IO;
     /* 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) {
@@ -176,18 +179,19 @@ static int idcin_read_header(AVFormatContext *s,
         st = av_new_stream(s, 0);
         if (!st)
             return AVERROR_NOMEM;
+        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) *
@@ -205,10 +209,6 @@ static int idcin_read_header(AVFormatContext *s,
     idcin->next_chunk_is_video = 1;
     idcin->pts = 0;
 
-    /* set the pts reference (1 pts = 1/90000) */
-    s->pts_num = 1;
-    s->pts_den = 90000;
-
     return 0;
 }
 
@@ -226,17 +226,17 @@ static int idcin_read_packet(AVFormatContext *s,
     unsigned char palette_buffer[768];
 
     if (url_feof(&s->pb))
-        return -EIO;
+        return AVERROR_IO;
 
     if (idcin->next_chunk_is_video) {
         command = get_le32(pb);
         if (command == 2) {
-            return -EIO;
+            return AVERROR_IO;
         } else if (command == 1) {
             /* trigger a palette change */
             idcin->palctrl.palette_changed = 1;
             if (get_buffer(pb, palette_buffer, 768) != 768)
-                return -EIO;
+                return AVERROR_IO;
             /* scale the palette as necessary */
             palette_scale = 2;
             for (i = 0; i < 768; i++)
@@ -257,26 +257,22 @@ 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;
-        if (av_new_packet(pkt, chunk_size))
-            ret = -EIO;
+        ret= av_get_packet(pb, pkt, chunk_size);
+        if (ret != chunk_size)
+            return AVERROR_IO;
         pkt->stream_index = idcin->video_stream_index;
         pkt->pts = idcin->pts;
-        ret = get_buffer(pb, pkt->data, chunk_size);
-        if (ret != chunk_size)
-            ret = -EIO;
     } else {
         /* send out the audio chunk */
         if (idcin->current_audio_chunk)
             chunk_size = idcin->audio_chunk_size2;
         else
             chunk_size = idcin->audio_chunk_size1;
-        if (av_new_packet(pkt, chunk_size))
-            return -EIO;
+        ret= av_get_packet(pb, pkt, chunk_size);
+        if (ret != chunk_size)
+            return AVERROR_IO;
         pkt->stream_index = idcin->audio_stream_index;
         pkt->pts = idcin->pts;
-        ret = get_buffer(&s->pb, pkt->data, chunk_size);
-        if (ret != chunk_size)
-            ret = -EIO;
 
         idcin->current_audio_chunk ^= 1;
         idcin->pts += FRAME_PTS_INC;
@@ -294,7 +290,7 @@ static int idcin_read_close(AVFormatContext *s)
     return 0;
 }
 
-static AVInputFormat idcin_iformat = {
+AVInputFormat idcin_demuxer = {
     "idcin",
     "Id CIN format",
     sizeof(IdcinDemuxContext),
@@ -303,9 +299,3 @@ static AVInputFormat idcin_iformat = {
     idcin_read_packet,
     idcin_read_close,
 };
-
-int idcin_init(void)
-{
-    av_register_input_format(&idcin_iformat);
-    return 0;
-}