diff options
Diffstat (limited to 'libavformat/adtsenc.c')
-rw-r--r-- | libavformat/adtsenc.c | 17 |
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); |