]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/takdec.c
avformat: Constify all muxer/demuxers
[ffmpeg] / libavformat / takdec.c
index ee96c279927b082bfe347155c011f108ba893592..46c500efefbfac0d751b50bc1b084ea046dc7647 100644 (file)
@@ -31,6 +31,8 @@
 #include "rawdec.h"
 
 typedef struct TAKDemuxContext {
+    AVClass *class;
+    int     raw_packet_size;
     int     mlast_frame;
     int64_t data_end;
 } TAKDemuxContext;
@@ -80,6 +82,8 @@ static int tak_read_header(AVFormatContext *s)
 
         switch (type) {
         case TAK_METADATA_STREAMINFO:
+            if (st->codecpar->extradata)
+                return AVERROR_INVALIDDATA;
         case TAK_METADATA_LAST_FRAME:
         case TAK_METADATA_ENCODER:
             if (size <= 3)
@@ -146,7 +150,7 @@ static int tak_read_header(AVFormatContext *s)
 
             ret = avpriv_tak_parse_streaminfo(&ti, buffer, size -3);
             if (ret < 0)
-                return AVERROR_INVALIDDATA;
+                goto end;
             if (ti.samples > 0)
                 st->duration = ti.samples;
             st->codecpar->bits_per_coded_sample = ti.bps;
@@ -160,8 +164,10 @@ static int tak_read_header(AVFormatContext *s)
             st->codecpar->extradata_size        = size - 3;
             buffer                           = NULL;
         } else if (type == TAK_METADATA_LAST_FRAME) {
-            if (size != 11)
-                return AVERROR_INVALIDDATA;
+            if (size != 11) {
+                ret = AVERROR_INVALIDDATA;
+                goto end;
+            }
             init_get_bits8(&gb, buffer, size - 3);
             tc->mlast_frame = 1;
             tc->data_end    = get_bits64(&gb, TAK_LAST_FRAME_POS_BITS) +
@@ -176,6 +182,9 @@ static int tak_read_header(AVFormatContext *s)
     }
 
     return AVERROR_EOF;
+end:
+    av_freep(&buffer);
+    return ret;
 }
 
 static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
@@ -204,7 +213,8 @@ static int raw_read_packet(AVFormatContext *s, AVPacket *pkt)
     return ret;
 }
 
-AVInputFormat ff_tak_demuxer = {
+FF_RAW_DEMUXER_CLASS(tak)
+const AVInputFormat ff_tak_demuxer = {
     .name           = "tak",
     .long_name      = NULL_IF_CONFIG_SMALL("raw TAK"),
     .priv_data_size = sizeof(TAKDemuxContext),
@@ -214,4 +224,5 @@ AVInputFormat ff_tak_demuxer = {
     .flags          = AVFMT_GENERIC_INDEX,
     .extensions     = "tak",
     .raw_codec_id   = AV_CODEC_ID_TAK,
+    .priv_class     = &tak_demuxer_class,
 };