]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/dsicin.c
Dont try generic seek if seek request before first index entry and backward.
[ffmpeg] / libavformat / dsicin.c
index 61e5e39a3a6d8ca2df0e529b12dc282574f637a8..ba94babbfedd780795c76fa2ea68220c04861cfc 100644 (file)
  */
 
 /**
- * @file dsicin.c
+ * @file libavformat/dsicin.c
  * Delphine Software International CIN file demuxer
  */
 
+#include "libavutil/intreadwrite.h"
 #include "avformat.h"
 
 
@@ -92,9 +93,9 @@ static int cin_read_file_header(CinDemuxContext *cin, ByteIOContext *pb) {
 static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap)
 {
     int rc;
-    CinDemuxContext *cin = (CinDemuxContext *)s->priv_data;
+    CinDemuxContext *cin = s->priv_data;
     CinFileHeader *hdr = &cin->file_header;
-    ByteIOContext *pb = &s->pb;
+    ByteIOContext *pb = s->pb;
     AVStream *st;
 
     rc = cin_read_file_header(cin, pb);
@@ -108,7 +109,7 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap)
     /* initialize the video decoder stream */
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
 
     av_set_pts_info(st, 32, 1, 12);
     cin->video_stream_index = st->index;
@@ -121,7 +122,7 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap)
     /* initialize the audio decoder stream */
     st = av_new_stream(s, 0);
     if (!st)
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
 
     av_set_pts_info(st, 32, 1, 22050);
     cin->audio_stream_index = st->index;
@@ -130,9 +131,9 @@ static int cin_read_header(AVFormatContext *s, AVFormatParameters *ap)
     st->codec->codec_tag = 0;  /* no tag */
     st->codec->channels = 1;
     st->codec->sample_rate = 22050;
-    st->codec->bits_per_sample = 16;
-    st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_sample * st->codec->channels;
-    st->codec->block_align = st->codec->channels * st->codec->bits_per_sample;
+    st->codec->bits_per_coded_sample = 16;
+    st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample * st->codec->channels;
+    st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
 
     return 0;
 }
@@ -147,7 +148,7 @@ static int cin_read_frame_header(CinDemuxContext *cin, ByteIOContext *pb) {
     hdr->audio_frame_size = get_le32(pb);
 
     if (url_feof(pb) || url_ferror(pb))
-        return AVERROR_IO;
+        return AVERROR(EIO);
 
     if (get_le32(pb) != 0xAA55AA55)
         return AVERROR_INVALIDDATA;
@@ -157,8 +158,8 @@ static int cin_read_frame_header(CinDemuxContext *cin, ByteIOContext *pb) {
 
 static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    CinDemuxContext *cin = (CinDemuxContext *)s->priv_data;
-    ByteIOContext *pb = &s->pb;
+    CinDemuxContext *cin = s->priv_data;
+    ByteIOContext *pb = s->pb;
     CinFrameHeader *hdr = &cin->frame_header;
     int rc, palette_type, pkt_size;
 
@@ -178,7 +179,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
         pkt_size = (palette_type + 3) * hdr->pal_colors_count + hdr->video_frame_size;
 
         if (av_new_packet(pkt, 4 + pkt_size))
-            return AVERROR_NOMEM;
+            return AVERROR(ENOMEM);
 
         pkt->stream_index = cin->video_stream_index;
         pkt->pts = cin->video_stream_pts++;
@@ -189,7 +190,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
         pkt->data[3] = hdr->video_frame_type;
 
         if (get_buffer(pb, &pkt->data[4], pkt_size) != pkt_size)
-            return AVERROR_IO;
+            return AVERROR(EIO);
 
         /* sound buffer will be processed on next read_packet() call */
         cin->audio_buffer_size = hdr->audio_frame_size;
@@ -198,14 +199,14 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
 
     /* audio packet */
     if (av_new_packet(pkt, cin->audio_buffer_size))
-        return AVERROR_NOMEM;
+        return AVERROR(ENOMEM);
 
     pkt->stream_index = cin->audio_stream_index;
     pkt->pts = cin->audio_stream_pts;
     cin->audio_stream_pts += cin->audio_buffer_size * 2 / cin->file_header.audio_frame_size;
 
     if (get_buffer(pb, pkt->data, cin->audio_buffer_size) != cin->audio_buffer_size)
-        return AVERROR_IO;
+        return AVERROR(EIO);
 
     cin->audio_buffer_size = 0;
     return 0;
@@ -213,7 +214,7 @@ static int cin_read_packet(AVFormatContext *s, AVPacket *pkt)
 
 AVInputFormat dsicin_demuxer = {
     "dsicin",
-    "Delphine Software International CIN format",
+    NULL_IF_CONFIG_SMALL("Delphine Software International CIN format"),
     sizeof(CinDemuxContext),
     cin_probe,
     cin_read_header,