]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/a64.c
doc: Improve the channelsplit example
[ffmpeg] / libavformat / a64.c
index 15a0475703f576d35ed677b3143e3b0e0cf960ee..c8e8e646b52d7c2b9b257736a907867cf93baffa 100644 (file)
@@ -25,7 +25,7 @@
 #include "avformat.h"
 #include "rawenc.h"
 
-static int a64_write_header(struct AVFormatContext *s)
+static int a64_write_header(AVFormatContext *s)
 {
     AVCodecContext *avctx = s->streams[0]->codec;
     uint8_t header[5] = {
@@ -35,6 +35,12 @@ static int a64_write_header(struct AVFormatContext *s)
         0x00, //charset_lifetime (multi only)
         0x00  //fps in 50/fps;
     };
+
+    if (avctx->extradata_size < 4) {
+        av_log(s, AV_LOG_ERROR, "Missing extradata\n");
+        return AVERROR_INVALIDDATA;
+    }
+
     switch (avctx->codec->id) {
     case AV_CODEC_ID_A64_MULTI:
         header[2] = 0x00;
@@ -47,7 +53,7 @@ static int a64_write_header(struct AVFormatContext *s)
         header[4] = 3;
         break;
     default:
-        return AVERROR(EINVAL);
+        return AVERROR_INVALIDDATA;
     }
     avio_write(s->pb, header, 2);
     return 0;