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>
pull/28/merge
James Almer 8 years ago
parent 8b3ec51de8
commit 210388a197
  1. 17
      libavformat/adtsenc.c

@ -149,11 +149,28 @@ static int adts_write_frame_header(ADTSContext *ctx,
static int adts_write_packet(AVFormatContext *s, AVPacket *pkt) static int adts_write_packet(AVFormatContext *s, AVPacket *pkt)
{ {
ADTSContext *adts = s->priv_data; ADTSContext *adts = s->priv_data;
AVCodecParameters *par = s->streams[0]->codecpar;
AVIOContext *pb = s->pb; AVIOContext *pb = s->pb;
uint8_t buf[ADTS_HEADER_SIZE]; uint8_t buf[ADTS_HEADER_SIZE];
if (!pkt->size) if (!pkt->size)
return 0; 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) { if (adts->write_adts) {
int err = adts_write_frame_header(adts, buf, pkt->size, int err = adts_write_frame_header(adts, buf, pkt->size,
adts->pce_size); adts->pce_size);

Loading…
Cancel
Save