Reviewed-by: Ronald S. Bultje <rsbultje@gmail.com>
Signed-off-by: James Almer <jamrial@gmail.com>
... | ... |
@@ -25,6 +25,7 @@ |
25 | 25 |
#include "libavcodec/mpeg4audio.h" |
26 | 26 |
#include "libavutil/opt.h" |
27 | 27 |
#include "avformat.h" |
28 |
+#include "internal.h" |
|
28 | 29 |
#include "rawenc.h" |
29 | 30 |
|
30 | 31 |
#define MAX_EXTRADATA_SIZE 1024 |
... | ... |
@@ -153,11 +154,6 @@ static int latm_write_packet(AVFormatContext *s, AVPacket *pkt) |
153 | 153 |
if (s->streams[0]->codec->codec_id == AV_CODEC_ID_AAC_LATM) |
154 | 154 |
return ff_raw_write_packet(s, pkt); |
155 | 155 |
|
156 |
- if (pkt->size > 2 && pkt->data[0] == 0xff && (pkt->data[1] >> 4) == 0xf) { |
|
157 |
- av_log(s, AV_LOG_ERROR, "ADTS header detected - ADTS will not be incorrectly muxed into LATM\n"); |
|
158 |
- return AVERROR_INVALIDDATA; |
|
159 |
- } |
|
160 |
- |
|
161 | 156 |
if (!s->streams[0]->codec->extradata) { |
162 | 157 |
if(pkt->size > 2 && pkt->data[0] == 0x56 && (pkt->data[1] >> 4) == 0xe && |
163 | 158 |
(AV_RB16(pkt->data + 1) & 0x1FFF) + 3 == pkt->size) |
... | ... |
@@ -217,6 +213,19 @@ too_large: |
217 | 217 |
return AVERROR_INVALIDDATA; |
218 | 218 |
} |
219 | 219 |
|
220 |
+static int latm_check_bitstream(struct AVFormatContext *s, const AVPacket *pkt) |
|
221 |
+{ |
|
222 |
+ int ret = 1; |
|
223 |
+ AVStream *st = s->streams[pkt->stream_index]; |
|
224 |
+ |
|
225 |
+ if (st->codec->codec_id == AV_CODEC_ID_AAC) { |
|
226 |
+ if (pkt->size > 2 && (AV_RB16(pkt->data) & 0xfff0) == 0xfff0) |
|
227 |
+ ret = ff_stream_add_bitstream_filter(st, "aac_adtstoasc", NULL); |
|
228 |
+ } |
|
229 |
+ |
|
230 |
+ return ret; |
|
231 |
+} |
|
232 |
+ |
|
220 | 233 |
AVOutputFormat ff_latm_muxer = { |
221 | 234 |
.name = "latm", |
222 | 235 |
.long_name = NULL_IF_CONFIG_SMALL("LOAS/LATM"), |
... | ... |
@@ -228,5 +237,6 @@ AVOutputFormat ff_latm_muxer = { |
228 | 228 |
.write_header = latm_write_header, |
229 | 229 |
.write_packet = latm_write_packet, |
230 | 230 |
.priv_class = &latm_muxer_class, |
231 |
+ .check_bitstream= latm_check_bitstream, |
|
231 | 232 |
.flags = AVFMT_NOTIMESTAMPS, |
232 | 233 |
}; |