]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/soxdec.c
omx: Add support for broadcom OMX on raspberry pi
[ffmpeg] / libavformat / soxdec.c
index 7661bf1f8f690a99fcb947643c48a920e20a0c1b..ee3d1dc560b2e69772ae8388f94c884581005232 100644 (file)
  */
 
 #include "libavutil/intreadwrite.h"
-#include "libavutil/intfloat_readwrite.h"
+#include "libavutil/intfloat.h"
 #include "libavutil/dict.h"
 #include "avformat.h"
+#include "internal.h"
 #include "pcm.h"
 #include "sox.h"
 
@@ -43,33 +44,32 @@ static int sox_probe(AVProbeData *p)
     return 0;
 }
 
-static int sox_read_header(AVFormatContext *s,
-                           AVFormatParameters *ap)
+static int sox_read_header(AVFormatContext *s)
 {
     AVIOContext *pb = s->pb;
     unsigned header_size, comment_size;
     double sample_rate, sample_rate_frac;
     AVStream *st;
 
-    st = av_new_stream(s, 0);
+    st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
 
-    st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;
 
     if (avio_rl32(pb) == SOX_TAG) {
-        st->codec->codec_id = CODEC_ID_PCM_S32LE;
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_S32LE;
         header_size         = avio_rl32(pb);
         avio_skip(pb, 8); /* sample count */
-        sample_rate         = av_int2dbl(avio_rl64(pb));
-        st->codec->channels = avio_rl32(pb);
+        sample_rate         = av_int2double(avio_rl64(pb));
+        st->codecpar->channels = avio_rl32(pb);
         comment_size        = avio_rl32(pb);
     } else {
-        st->codec->codec_id = CODEC_ID_PCM_S32BE;
+        st->codecpar->codec_id = AV_CODEC_ID_PCM_S32BE;
         header_size         = avio_rb32(pb);
         avio_skip(pb, 8); /* sample count */
-        sample_rate         = av_int2dbl(avio_rb64(pb));
-        st->codec->channels = avio_rb32(pb);
+        sample_rate         = av_int2double(avio_rb64(pb));
+        st->codecpar->channels = avio_rb32(pb);
         comment_size        = avio_rb32(pb);
     }
 
@@ -90,7 +90,7 @@ static int sox_read_header(AVFormatContext *s,
                sample_rate_frac);
 
     if ((header_size + 4) & 7 || header_size < SOX_FIXED_HDR + comment_size
-        || st->codec->channels > 65535) /* Reserve top 16 bits */ {
+        || st->codecpar->channels > 65535) /* Reserve top 16 bits */ {
         av_log(s, AV_LOG_ERROR, "invalid header\n");
         return -1;
     }
@@ -109,15 +109,15 @@ static int sox_read_header(AVFormatContext *s,
 
     avio_skip(pb, header_size - SOX_FIXED_HDR - comment_size);
 
-    st->codec->sample_rate           = sample_rate;
-    st->codec->bits_per_coded_sample = 32;
-    st->codec->bit_rate              = st->codec->sample_rate *
-                                       st->codec->bits_per_coded_sample *
-                                       st->codec->channels;
-    st->codec->block_align           = st->codec->bits_per_coded_sample *
-                                       st->codec->channels / 8;
+    st->codecpar->sample_rate           = sample_rate;
+    st->codecpar->bits_per_coded_sample = 32;
+    st->codecpar->bit_rate              = st->codecpar->sample_rate *
+                                          st->codecpar->bits_per_coded_sample *
+                                          st->codecpar->channels;
+    st->codecpar->block_align           = st->codecpar->bits_per_coded_sample *
+                                          st->codecpar->channels / 8;
 
-    av_set_pts_info(st, 64, 1, st->codec->sample_rate);
+    avpriv_set_pts_info(st, 64, 1, st->codecpar->sample_rate);
 
     return 0;
 }
@@ -132,7 +132,7 @@ static int sox_read_packet(AVFormatContext *s,
     if (s->pb->eof_reached)
         return AVERROR_EOF;
 
-    size = SOX_SAMPLES*s->streams[0]->codec->block_align;
+    size = SOX_SAMPLES*s->streams[0]->codecpar->block_align;
     ret = av_get_packet(s->pb, pkt, size);
     if (ret < 0)
         return AVERROR(EIO);
@@ -143,12 +143,10 @@ static int sox_read_packet(AVFormatContext *s,
 }
 
 AVInputFormat ff_sox_demuxer = {
-    "sox",
-    NULL_IF_CONFIG_SMALL("SoX native format"),
-    0,
-    sox_probe,
-    sox_read_header,
-    sox_read_packet,
-    NULL,
-    pcm_read_seek,
+    .name           = "sox",
+    .long_name      = NULL_IF_CONFIG_SMALL("SoX native"),
+    .read_probe     = sox_probe,
+    .read_header    = sox_read_header,
+    .read_packet    = sox_read_packet,
+    .read_seek      = ff_pcm_read_seek,
 };