summaryrefslogtreecommitdiff
path: root/libavformat
diff options
context:
space:
mode:
authorSasi Inguva <isasi-at-google.com@ffmpeg.org>2017-08-08 17:00:19 -0700
committerMichael Niedermayer <michael@niedermayer.cc>2017-08-10 02:43:53 +0200
commite7e1fbc49bf64e1a1d19e2a469dd1962d4bdb770 (patch)
tree5190ec8d4bf5c1d28ff465b58cba1e86e7d01dcf /libavformat
parentdf884e038f5dc95f55ef07500b5b99b722835f8a (diff)
lavf/movenc.c: Set sgpd and sbgp atoms to represent decoder delay for AAC.
According to https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html and ISO-IEC-14496-12 Section 10.1.1.1 and 10.1.1.3 Signed-off-by: Sasi Inguva <isasi@google.com> Reviewed-by: Derek Buitenhuis <derek.buitenhuis@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/movenc.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 0e5b45d150..5c53ab24e0 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -2208,14 +2208,16 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
(AVRational){1, 1000},
(AVRational){1, 48000});
- if (track->entry) {
- sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries));
- if (!sgpd_entries)
- return AVERROR(ENOMEM);
- }
+ if (!track->entry)
+ return 0;
- av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS);
+ sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries));
+ if (!sgpd_entries)
+ return AVERROR(ENOMEM);
+ av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS || track->par->codec_id == AV_CODEC_ID_AAC);
+
+ if (track->par->codec_id == AV_CODEC_ID_OPUS) {
for (i = 0; i < track->entry; i++) {
int roll_samples_remaining = roll_samples;
int distance = 0;
@@ -2242,6 +2244,12 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track)
sgpd_entries[entries].group_description_index = distance ? ++group : 0;
}
}
+ } else {
+ entries++;
+ sgpd_entries[entries].count = track->sample_count;
+ sgpd_entries[entries].roll_distance = 1;
+ sgpd_entries[entries].group_description_index = ++group;
+ }
entries++;
if (!group) {
@@ -2304,7 +2312,7 @@ static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext
if (track->cenc.aes_ctr) {
ff_mov_cenc_write_stbl_atoms(&track->cenc, pb);
}
- if (track->par->codec_id == AV_CODEC_ID_OPUS) {
+ if (track->par->codec_id == AV_CODEC_ID_OPUS || track->par->codec_id == AV_CODEC_ID_AAC) {
mov_preroll_write_stbl_atoms(pb, track);
}
return update_size(pb, pos);