diff options
author | James Almer <jamrial@gmail.com> | 2017-04-13 16:06:02 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2017-05-24 20:28:00 -0300 |
commit | 8b3ec51de8a04f4442297f2f835e925cab7b0597 (patch) | |
tree | 9138ff96f9356846824a5e5ae1e027d83102ad79 /libavformat | |
parent | 7631f14bb35e8467d4ffaaa2b34e60614eb37c71 (diff) | |
download | ffmpeg-8b3ec51de8a04f4442297f2f835e925cab7b0597.tar.gz |
avformat/latmenc: check packet side data for AAC extradata updates
This is in preparation for a following patch.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/latmenc.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c index 43ca4821cb..c919976d49 100644 --- a/libavformat/latmenc.c +++ b/libavformat/latmenc.c @@ -146,20 +146,34 @@ static void latm_write_frame_header(AVFormatContext *s, PutBitContext *bs) static int latm_write_packet(AVFormatContext *s, AVPacket *pkt) { LATMContext *ctx = s->priv_data; + AVCodecParameters *par = s->streams[0]->codecpar; AVIOContext *pb = s->pb; PutBitContext bs; int i, len; uint8_t loas_header[] = "\x56\xe0\x00"; - if (s->streams[0]->codecpar->codec_id == AV_CODEC_ID_AAC_LATM) + if (par->codec_id == AV_CODEC_ID_AAC_LATM) return ff_raw_write_packet(s, pkt); - if (!s->streams[0]->codecpar->extradata) { + if (!par->extradata) { if(pkt->size > 2 && pkt->data[0] == 0x56 && (pkt->data[1] >> 4) == 0xe && (AV_RB16(pkt->data + 1) & 0x1FFF) + 3 == pkt->size) return ff_raw_write_packet(s, pkt); - else - return AVERROR_INVALIDDATA; + else { + 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) { + if (latm_decode_extradata(ctx, side_data, side_data_size) < 0) + return AVERROR_INVALIDDATA; + ret = ff_alloc_extradata(par, side_data_size); + if (ret < 0) + return ret; + memcpy(par->extradata, side_data, side_data_size); + } + } } if (pkt->size > 0x1fff) |