[FFmpeg-cvslog] avcodec/adtsenc: check packet side data for AAC extradata updates

James Almer git at videolan.org
Thu May 25 02:30:56 EEST 2017


ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed May 24 17:02:08 2017 -0300| [210388a1979d70d024ef4ebf1d97df56ce56b0c1] | committer: James Almer

avcodec/adtsenc: check packet side data for AAC extradata updates

This is in preparation for the following patch.

Signed-off-by: James Almer <jamrial at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=210388a1979d70d024ef4ebf1d97df56ce56b0c1
---

 libavformat/adtsenc.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/libavformat/adtsenc.c b/libavformat/adtsenc.c
index 5e006dd38f..a046c2f2f4 100644
--- a/libavformat/adtsenc.c
+++ b/libavformat/adtsenc.c
@@ -149,11 +149,28 @@ static int adts_write_frame_header(ADTSContext *ctx,
 static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
     ADTSContext *adts = s->priv_data;
+    AVCodecParameters *par = s->streams[0]->codecpar;
     AVIOContext *pb = s->pb;
     uint8_t buf[ADTS_HEADER_SIZE];
 
     if (!pkt->size)
         return 0;
+    if (!par->extradata_size) {
+        uint8_t *side_data;
+        int side_data_size = 0, ret;
+
+        side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+                                            &side_data_size);
+        if (side_data_size) {
+            ret = adts_decode_extradata(s, adts, side_data, side_data_size);
+            if (ret < 0)
+                return ret;
+            ret = ff_alloc_extradata(par, side_data_size);
+            if (ret < 0)
+                return ret;
+            memcpy(par->extradata, side_data, side_data_size);
+        }
+    }
     if (adts->write_adts) {
         int err = adts_write_frame_header(adts, buf, pkt->size,
                                              adts->pce_size);



More information about the ffmpeg-cvslog mailing list