summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2017-05-24 17:02:08 -0300
committerJames Almer <jamrial@gmail.com>2017-05-24 20:28:00 -0300
commit210388a1979d70d024ef4ebf1d97df56ce56b0c1 (patch)
tree51bf2466b1094f520dfc86c159d9fbadaa5e1c3c
parent8b3ec51de8a04f4442297f2f835e925cab7b0597 (diff)
downloadffmpeg-210388a1979d70d024ef4ebf1d97df56ce56b0c1.tar.gz
avcodec/adtsenc: check packet side data for AAC extradata updates
This is in preparation for the following patch. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--libavformat/adtsenc.c17
1 files changed, 17 insertions, 0 deletions
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);