X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Famr.c;h=e4f8e4d8606a19b044cb749dc4cff09e59fdd6a7;hb=520754476d9c2627b610fb9c508d0a85182d5a87;hp=42840a50a300ff23d6ddfa56a1410770f0fdbd59;hpb=e427ba5c68a522b26a45bf7c61016d9349fab43d;p=ffmpeg diff --git a/libavformat/amr.c b/libavformat/amr.c index 42840a50a30..e4f8e4d8606 100644 --- a/libavformat/amr.c +++ b/libavformat/amr.c @@ -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; @@ -60,13 +61,6 @@ static int amr_write_header(AVFormatContext *s) } else { return -1; } - avio_flush(pb); - 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 */ @@ -90,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; } @@ -154,7 +150,6 @@ static int amr_read_packet(AVFormatContext *s, AVPacket *pkt) read = avio_read(s->pb, pkt->data + 1, size - 1); if (read != size - 1) { - av_packet_unref(pkt); if (read < 0) return read; return AVERROR(EIO); @@ -296,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