]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/dsicin.c
Use AV_METADATA_DONT_STRDUP* / use av_malloced metadata instead of strduped
[ffmpeg] / libavformat / dsicin.c
index f274eadf8626c141c3e6b867569cab240290d211..ba94babbfedd780795c76fa2ea68220c04861cfc 100644 (file)
  */
 
 /**
- * @file dsicin.c
+ * @file libavformat/dsicin.c
  * Delphine Software International CIN file demuxer
  */
 
+#include "libavutil/intreadwrite.h"
 #include "avformat.h"
 
 
@@ -58,15 +59,12 @@ typedef struct CinDemuxContext {
 
 static int cin_probe(AVProbeData *p)
 {
-    if (p->buf_size < 18)
-        return 0;
-
     /* header starts with this special marker */
-    if (LE_32(&p->buf[0]) != 0x55AA0000)
+    if (AV_RL32(&p->buf[0]) != 0x55AA0000)
         return 0;
 
     /* for accuracy, check some header field values */
-    if (LE_32(&p->buf[12]) != 22050 || p->buf[16] != 16 || p->buf[17] != 0)
+    if (AV_RL32(&p->buf[12]) != 22050 || p->buf[16] != 16 || p->buf[17] != 0)
         return 0;
 
     return AVPROBE_SCORE_MAX;
@@ -95,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);
@@ -111,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;
@@ -124,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;
@@ -133,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;
 }
@@ -150,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;
@@ -160,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;
 
@@ -181,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++;
@@ -192,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;
@@ -201,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;
@@ -216,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,