diff options
author | James Almer <jamrial@gmail.com> | 2016-03-26 01:42:35 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2016-03-30 21:58:48 -0300 |
commit | 9bf3d01d91479f78a0c3f02a706fa4dcc52617d3 (patch) | |
tree | 790fe53bd65496ea2ed93eade94b968bd71883f4 /libavformat | |
parent | a35a4a5774a196f8eefc8ef2994979a6c563e0c2 (diff) | |
download | ffmpeg-9bf3d01d91479f78a0c3f02a706fa4dcc52617d3.tar.gz |
avformat/latmenc: auto-insert aac_adtstoasc bitstream filter when needed
Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/latmenc.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/libavformat/latmenc.c b/libavformat/latmenc.c index db6977e585..9713b1b8ec 100644 --- a/libavformat/latmenc.c +++ b/libavformat/latmenc.c @@ -25,6 +25,7 @@ #include "libavcodec/mpeg4audio.h" #include "libavutil/opt.h" #include "avformat.h" +#include "internal.h" #include "rawenc.h" #define MAX_EXTRADATA_SIZE 1024 @@ -153,11 +154,6 @@ static int latm_write_packet(AVFormatContext *s, AVPacket *pkt) if (s->streams[0]->codec->codec_id == AV_CODEC_ID_AAC_LATM) return ff_raw_write_packet(s, pkt); - if (pkt->size > 2 && pkt->data[0] == 0xff && (pkt->data[1] >> 4) == 0xf) { - av_log(s, AV_LOG_ERROR, "ADTS header detected - ADTS will not be incorrectly muxed into LATM\n"); - return AVERROR_INVALIDDATA; - } - if (!s->streams[0]->codec->extradata) { if(pkt->size > 2 && pkt->data[0] == 0x56 && (pkt->data[1] >> 4) == 0xe && (AV_RB16(pkt->data + 1) & 0x1FFF) + 3 == pkt->size) @@ -217,6 +213,19 @@ too_large: return AVERROR_INVALIDDATA; } +static int latm_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) +{ + int ret = 1; + AVStream *st = s->streams[pkt->stream_index]; + + if (st->codec->codec_id == AV_CODEC_ID_AAC) { + if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) + ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL); + } + + return ret; +} + AVOutputFormat ff_latm_muxer = { .name = "latm", .long_name = NULL_IF_CONFIG_SMALL("LOAS/LATM"), @@ -228,5 +237,6 @@ AVOutputFormat ff_latm_muxer = { .write_header = latm_write_header, .write_packet = latm_write_packet, .priv_class = &latm_muxer_class, + .check_bitstream= latm_check_bitstream, .flags = AVFMT_NOTIMESTAMPS, }; |