History

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

Sasi Inguva committed 9 years ago

Commit e7e1fbc1 parent df884e04 files · +25 −17Browse files

Unified · Split

4 files
  1. libavformat/movenc.c +15 −7
  2. tests/ref/fate/adtstoasc_ticket3715 +2 −2
  3. tests/ref/fate/copy-psp +2 −2
  4. tests/ref/fate/movenc +6 −6
libavformat/movenc.c+15−7
@@ -2208,14 +2208,16 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track) · 2207 unmodified lines
22082208 (AVRational){1, 1000},
22092209 (AVRational){1, 48000});
22102210
2211− if (track->entry) {
2212− sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries));
2213− if (!sgpd_entries)
2214− return AVERROR(ENOMEM);
2215− }
2211+ if (!track->entry)
2212+ return 0;
22162213
2217− av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS);
2214+ sgpd_entries = av_malloc_array(track->entry, sizeof(*sgpd_entries));
2215+ if (!sgpd_entries)
2216+ return AVERROR(ENOMEM);
22182217
2218+ av_assert0(track->par->codec_id == AV_CODEC_ID_OPUS || track->par->codec_id == AV_CODEC_ID_AAC);
2219+
2220+ if (track->par->codec_id == AV_CODEC_ID_OPUS) {
22192221 for (i = 0; i < track->entry; i++) {
22202222 int roll_samples_remaining = roll_samples;
22212223 int distance = 0;
@@ -2242,6 +2244,12 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track) · 20 unmodified lines
22422244 sgpd_entries[entries].group_description_index = distance ? ++group : 0;
22432245 }
22442246 }
2247+ } else {
2248+ entries++;
2249+ sgpd_entries[entries].count = track->sample_count;
2250+ sgpd_entries[entries].roll_distance = 1;
2251+ sgpd_entries[entries].group_description_index = ++group;
2252+ }
22452253 entries++;
22462254
22472255 if (!group) {
@@ -2304,7 +2312,7 @@ static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext · 56 unmodified lines
23042312 if (track->cenc.aes_ctr) {
23052313 ff_mov_cenc_write_stbl_atoms(&track->cenc, pb);
23062314 }
2307− if (track->par->codec_id == AV_CODEC_ID_OPUS) {
2315+ if (track->par->codec_id == AV_CODEC_ID_OPUS || track->par->codec_id == AV_CODEC_ID_AAC) {
23082316 mov_preroll_write_stbl_atoms(pb, track);
23092317 }
23102318 return update_size(pb, pos);
tests/ref/fate/adtstoasc_ticket3715+2−2
@@ -1,5 +1,5 @@
1−ef8ce3cbd1d86113e7c991a816086068 *tests/data/fate/adtstoasc_ticket3715.mov
2−33270 tests/data/fate/adtstoasc_ticket3715.mov
1+0221e04333e6ac432fa42960502f0d5a *tests/data/fate/adtstoasc_ticket3715.mov
2+33324 tests/data/fate/adtstoasc_ticket3715.mov
33 #extradata 0: 2, 0x00340022
44 #tb 0: 1/44100
55 #media_type 0: audio
tests/ref/fate/copy-psp+2−2
@@ -1,5 +1,5 @@
1−6889223644fc560069c8591984175a62 *tests/data/fate/copy-psp.psp
2−2041379 tests/data/fate/copy-psp.psp
1+cada61453a2483ef8ba1fb82c8bbff25 *tests/data/fate/copy-psp.psp
2+2041433 tests/data/fate/copy-psp.psp
33 #extradata 0: 51, 0xaf6d1012
44 #extradata 1: 2, 0x00b200a1
55 #tb 0: 1/90000
tests/ref/fate/movenc+6−6
@@ -1,18 +1,18 @@
11 write_data len 36, time nopts, type header atom ftyp
2−write_data len 2335, time nopts, type header atom -
2+write_data len 2389, time nopts, type header atom -
33 write_data len 788, time 1000000, type sync atom moof
44 write_data len 110, time nopts, type trailer atom -
5−214242e9c7c93171d2f47f5b47776559 3269 non-empty-moov
5+17a37691eba8b858cf15e60aa9a7dbf7 3323 non-empty-moov
66 write_data len 36, time nopts, type header atom ftyp
7−write_data len 2667, time nopts, type header atom -
7+write_data len 2721, time nopts, type header atom -
88 write_data len 908, time 966667, type sync atom moof
99 write_data len 110, time nopts, type trailer atom -
10−44467d568a3cc38d414fd8ed4b2a968f 3721 non-empty-moov-elst
10+0026ffe059c06c592021f972bf2c5e79 3775 non-empty-moov-elst
1111 write_data len 36, time nopts, type header atom ftyp
12−write_data len 2575, time nopts, type header atom -
12+write_data len 2629, time nopts, type header atom -
1313 write_data len 908, time 1000000, type sync atom moof
1414 write_data len 110, time nopts, type trailer atom -
15−de22b98a3885f9b4b83cdd48ff46aeb9 3629 non-empty-moov-no-elst
15+c184e168ac1e5bb3d9c70e580ab6179c 3683 non-empty-moov-no-elst
1616 write_data len 20, time nopts, type header atom ftyp
1717 write_data len 1171, time nopts, type header atom -
1818 write_data len 728, time 0, type sync atom moof

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t