]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/au.c
Merge commit '55aa03b9f8f11ebb7535424cc0e5635558590f49'
[ffmpeg] / libavformat / au.c
index 1fdaa9a822aba7e691a621f018431aaee8ce16aa..b3a793d7ff1a78b12562f36c1b02e4cbc457d933 100644 (file)
@@ -135,27 +135,12 @@ static int au_read_header(AVFormatContext *s)
     return 0;
 }
 
-static int au_read_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    int ret;
-
-    ret = av_get_packet(s->pb, pkt, BLOCK_SIZE *
-                        s->streams[0]->codec->block_align);
-    if (ret < 0)
-        return ret;
-
-    pkt->stream_index = 0;
-    pkt->duration     = ret / s->streams[0]->codec->block_align;
-
-    return 0;
-}
-
 AVInputFormat ff_au_demuxer = {
     .name        = "au",
     .long_name   = NULL_IF_CONFIG_SMALL("Sun AU"),
     .read_probe  = au_probe,
     .read_header = au_read_header,
-    .read_packet = au_read_packet,
+    .read_packet = ff_pcm_read_packet,
     .read_seek   = ff_pcm_read_seek,
     .codec_tag   = (const AVCodecTag* const []) { codec_au_tags, 0 },
 };
@@ -170,14 +155,14 @@ AVInputFormat ff_au_demuxer = {
 static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
 {
     if (!enc->codec_tag)
-        return -1;
+        return AVERROR(EINVAL);
 
     ffio_wfourcc(pb, ".snd");                   /* magic number */
     avio_wb32(pb, AU_HEADER_SIZE);              /* header size */
     avio_wb32(pb, AU_UNKNOWN_SIZE);             /* data size */
-    avio_wb32(pb, (uint32_t)enc->codec_tag);    /* codec ID */
+    avio_wb32(pb, enc->codec_tag);              /* codec ID */
     avio_wb32(pb, enc->sample_rate);
-    avio_wb32(pb, (uint32_t)enc->channels);
+    avio_wb32(pb, enc->channels);
     avio_wb64(pb, 0); /* annotation field */
 
     return 0;
@@ -186,9 +171,10 @@ static int put_au_header(AVIOContext *pb, AVCodecContext *enc)
 static int au_write_header(AVFormatContext *s)
 {
     AVIOContext *pb = s->pb;
+    int ret;
 
-    if (put_au_header(pb, s->streams[0]->codec) < 0)
-        return AVERROR(EINVAL);
+    if ((ret = put_au_header(pb, s->streams[0]->codec)) < 0)
+        return ret;
 
     avio_flush(pb);