]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/idcin.c
segfault fix
[ffmpeg] / libavformat / idcin.c
index 9d13aa56346fb77c0b285deb5dd8cf72a17bf601..164cf556c6c26559fe17f2b650891c36a00a35d2 100644 (file)
 
 #include "avformat.h"
 
-#define LE_16(x)  ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
-#define LE_32(x)  ((((uint8_t*)(x))[3] << 24) | \
-                   (((uint8_t*)(x))[2] << 16) | \
-                   (((uint8_t*)(x))[1] << 8) | \
-                    ((uint8_t*)(x))[0])
-
 #define HUFFMAN_TABLE_SIZE (64 * 1024)
 #define FRAME_PTS_INC (90000 / 14)
 
@@ -160,6 +154,7 @@ 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;
@@ -172,7 +167,7 @@ static int idcin_read_header(AVFormatContext *s,
     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;
 
@@ -182,6 +177,7 @@ 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;
@@ -211,10 +207,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;
 }
 
@@ -232,17 +224,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++)
@@ -264,12 +256,12 @@ static int idcin_read_packet(AVFormatContext *s,
         url_fseek(pb, 4, SEEK_CUR);
         chunk_size -= 4;
         if (av_new_packet(pkt, chunk_size))
-            ret = -EIO;
+            ret = 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;
+            ret = AVERROR_IO;
     } else {
         /* send out the audio chunk */
         if (idcin->current_audio_chunk)
@@ -277,12 +269,12 @@ static int idcin_read_packet(AVFormatContext *s,
         else
             chunk_size = idcin->audio_chunk_size1;
         if (av_new_packet(pkt, chunk_size))
-            return -EIO;
+            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;
+            ret = AVERROR_IO;
 
         idcin->current_audio_chunk ^= 1;
         idcin->pts += FRAME_PTS_INC;