summaryrefslogtreecommitdiff
path: root/libavformat/movenc.c
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2019-12-01 13:10:48 -0300
committerJames Almer <jamrial@gmail.com>2019-12-21 11:57:28 -0300
commit245ace4e2d3f3ecccb5501c7830b05c2cfa6a663 (patch)
tree5cd14fc37be2af1451383b2375d7dd3a9bd0384c /libavformat/movenc.c
parent58ac7608160b4fd3f696f07cd68f5e340f0f6832 (diff)
avformat/movenc: ensure we don't write the major brand as a compatible brand more than once
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavformat/movenc.c')
-rw-r--r--libavformat/movenc.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index c13578e13f..907d0a049f 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -4801,20 +4801,32 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s)
// Write the major brand as the first compatible brand as well
mov_write_ftyp_tag_internal(pb, s, has_h264, has_video, 0);
+ // Write compatible brands, ensuring that we don't write the major brand as a
+ // compatible brand a second time.
if (mov->mode == MODE_ISM) {
ffio_wfourcc(pb, "piff");
- } else if (!(mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)) {
- ffio_wfourcc(pb, "isom");
- ffio_wfourcc(pb, "iso2");
- if (has_h264)
- ffio_wfourcc(pb, "avc1");
+ } else if (mov->mode != MODE_MOV) {
+ // We add tfdt atoms when fragmenting, signal this with the iso6 compatible
+ // brand. This is compatible with users that don't understand tfdt.
+ if (mov->flags & FF_MOV_FLAG_FRAGMENT)
+ ffio_wfourcc(pb, "iso6");
+ if (mov->mode != MODE_MP4) {
+ if (mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)
+ ffio_wfourcc(pb, "iso5");
+ else if (mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS)
+ ffio_wfourcc(pb, "iso4");
+ }
+ // Brands prior to iso5 can't be signaled when using default-base-is-moof
+ if (!(mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF)) {
+ // write isom for mp4 only if it it's not the major brand already.
+ if (mov->mode != MODE_MP4 || mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS)
+ ffio_wfourcc(pb, "isom");
+ ffio_wfourcc(pb, "iso2");
+ if (has_h264)
+ ffio_wfourcc(pb, "avc1");
+ }
}
- // We add tfdt atoms when fragmenting, signal this with the iso6 compatible
- // brand. This is compatible with users that don't understand tfdt.
- if (mov->flags & FF_MOV_FLAG_FRAGMENT && mov->mode != MODE_ISM)
- ffio_wfourcc(pb, "iso6");
-
if (mov->mode == MODE_MP4)
ffio_wfourcc(pb, "mp41");