avformat/adtsenc: add adts_init()
authorJames Almer <jamrial@gmail.com>
Mon, 29 May 2017 21:12:51 +0000 (18:12 -0300)
committerJames Almer <jamrial@gmail.com>
Sun, 14 Jan 2018 12:57:42 +0000 (09:57 -0300)
Signed-off-by: James Almer <jamrial@gmail.com>
libavformat/adtsenc.c

index a24f99c..c24572f 100644 (file)
@@ -94,13 +94,11 @@ static int adts_decode_extradata(AVFormatContext *s, ADTSContext *adts, const ui
     return 0;
 }
 
-static int adts_write_header(AVFormatContext *s)
+static int adts_init(AVFormatContext *s)
 {
     ADTSContext *adts = s->priv_data;
     AVCodecParameters *par = s->streams[0]->codecpar;
 
-    if (adts->id3v2tag)
-        ff_id3v2_write_simple(s, 4, ID3v2_DEFAULT_MAGIC);
     if (par->extradata_size > 0)
         return adts_decode_extradata(s, adts, par->extradata,
                                      par->extradata_size);
@@ -108,6 +106,16 @@ static int adts_write_header(AVFormatContext *s)
     return 0;
 }
 
+static int adts_write_header(AVFormatContext *s)
+{
+    ADTSContext *adts = s->priv_data;
+
+    if (adts->id3v2tag)
+        ff_id3v2_write_simple(s, 4, ID3v2_DEFAULT_MAGIC);
+
+    return 0;
+}
+
 static int adts_write_frame_header(ADTSContext *ctx,
                                    uint8_t *buf, int size, int pce_size)
 {
@@ -220,6 +228,7 @@ AVOutputFormat ff_adts_muxer = {
     .priv_data_size    = sizeof(ADTSContext),
     .audio_codec       = AV_CODEC_ID_AAC,
     .video_codec       = AV_CODEC_ID_NONE,
+    .init              = adts_init,
     .write_header      = adts_write_header,
     .write_packet      = adts_write_packet,
     .write_trailer     = adts_write_trailer,