]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/amr.c
avformat/hlsenc: Remove deprecated localtime options
[ffmpeg] / libavformat / amr.c
index eccbbde5b0218e36fd27920850908d88539b9242..e4f8e4d8606a19b044cb749dc4cff09e59fdd6a7 100644 (file)
@@ -29,6 +29,7 @@ Only mono files are supported.
 #include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
+#include "rawenc.h"
 
 typedef struct {
     uint64_t cumulated_size;
@@ -62,12 +63,6 @@ static int amr_write_header(AVFormatContext *s)
     }
     return 0;
 }
-
-static int amr_write_packet(AVFormatContext *s, AVPacket *pkt)
-{
-    avio_write(s->pb, pkt->data, pkt->size);
-    return 0;
-}
 #endif /* CONFIG_AMR_MUXER */
 
 static int amr_probe(const AVProbeData *p)
@@ -89,13 +84,15 @@ static int amr_read_header(AVFormatContext *s)
     AVStream *st;
     uint8_t header[9];
 
-    avio_read(pb, header, 6);
+    if (avio_read(pb, header, 6) != 6)
+        return AVERROR_INVALIDDATA;
 
     st = avformat_new_stream(s, NULL);
     if (!st)
         return AVERROR(ENOMEM);
     if (memcmp(header, AMR_header, 6)) {
-        avio_read(pb, header + 6, 3);
+        if (avio_read(pb, header + 6, 3) != 3)
+            return AVERROR_INVALIDDATA;
         if (memcmp(header, AMRWB_header, 9)) {
             return -1;
         }
@@ -294,7 +291,7 @@ AVOutputFormat ff_amr_muxer = {
     .audio_codec       = AV_CODEC_ID_AMR_NB,
     .video_codec       = AV_CODEC_ID_NONE,
     .write_header      = amr_write_header,
-    .write_packet      = amr_write_packet,
+    .write_packet      = ff_raw_write_packet,
     .flags             = AVFMT_NOTIMESTAMPS,
 };
 #endif