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
Showing the changes to libavformat (1 of 4 files). Show all
Unified · Split
| @@ -2208,14 +2208,16 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track) · 2207 unmodified lines | ||
| 2208 | 2208 | (AVRational){1, 1000}, |
| 2209 | 2209 | (AVRational){1, 48000}); |
| 2210 | 2210 | |
| 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; | |
| 2216 | 2213 | |
| 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); | |
| 2218 | 2217 | |
| 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) { | |
| 2219 | 2221 | for (i = 0; i < track->entry; i++) { |
| 2220 | 2222 | int roll_samples_remaining = roll_samples; |
| 2221 | 2223 | int distance = 0; |
| @@ -2242,6 +2244,12 @@ static int mov_preroll_write_stbl_atoms(AVIOContext *pb, MOVTrack *track) · 20 unmodified lines | ||
| 2242 | 2244 | sgpd_entries[entries].group_description_index = distance ? ++group : 0; |
| 2243 | 2245 | } |
| 2244 | 2246 | } |
| 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 | + } | |
| 2245 | 2253 | entries++; |
| 2246 | 2254 | |
| 2247 | 2255 | if (!group) { |
| @@ -2304,7 +2312,7 @@ static int mov_write_stbl_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext · 56 unmodified lines | ||
| 2304 | 2312 | if (track->cenc.aes_ctr) { |
| 2305 | 2313 | ff_mov_cenc_write_stbl_atoms(&track->cenc, pb); |
| 2306 | 2314 | } |
| 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) { | |
| 2308 | 2316 | mov_preroll_write_stbl_atoms(pb, track); |
| 2309 | 2317 | } |
| 2310 | 2318 | return update_size(pb, pos); |