From patchwork Mon Dec 2 16:18:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 16535 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1297844AAD0 for ; Mon, 2 Dec 2019 18:19:07 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id F3E9368AFEC; Mon, 2 Dec 2019 18:19:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qk1-f172.google.com (mail-qk1-f172.google.com [209.85.222.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B079868AFE4 for ; Mon, 2 Dec 2019 18:19:00 +0200 (EET) Received: by mail-qk1-f172.google.com with SMTP id m188so47960qkc.4 for ; Mon, 02 Dec 2019 08:19:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sBgS34X6l7TQACmYs/4j1TxXf5dn8Atnob3zjDcbiMg=; b=t9RRm6oLsOFdV8GtSuWZli54U86nasL5zpRNOaAAdF1qF4MPHNz+THoe4vMMz4YoCg Zr0uItNSuL/wCrMIc0a+8gRNyUI8tDKvNRF6OBYd4WvYVlUrZ9O2zh1KeW+V9C5KY9j+ BjGcjvhmTfaDVe/sbcErAYuMv+My1t8QiVKjEoHKXGqSFVzLkYS+tQdTeewFA5eyf2OZ sgOxDY+Hc5Yh1AsUNHu6eBFs4N7nvMgV10FIa/zwsWzgbLT8GDl39KeK09XeKw2scZZ5 auLo+LTLVPjBqWlQub7bW9hYMULkkIlPoAoKgJw0BcmB+vg1+i4mqtj6Iu7TXPTHdxZq QEvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sBgS34X6l7TQACmYs/4j1TxXf5dn8Atnob3zjDcbiMg=; b=EnWHh4lPsGiQXDJ7k07F5AZ/AguGw4TlCVetz5b5u5kwxTDvcCh0W/GGtOSZmrlD9/ bk/yTqJLVAYaAmBFECiHRKcxQFPsbCfJtonwtJTHKPrxJT2lxa6LQObsA70098YdVY58 CfIjDZLAvOOnXrdxyLLg6UO4oaMDC02xwSociZ7t3tXlDhKaHAZCkCpGelIO8wLB+Ayl Fp1HcJYlyR1tGbSpOfhwF/8Mb0HqQiR382ApbD3OXjryl9KUKMuYHgW1MkQtJsW8+nnT farUHvO6YulLapQWjJB/FdJpcQXyPAAQINjL1IyoUkHCfclX96xhjpGDvmO9t5zN7Fjz WLZw== X-Gm-Message-State: APjAAAUceIg/v5hIaO6hB/5e9hluAgptkc4Lg7VWvcQkU2iKN5WBH2vf dGsDxo8QFmsGicBAAi0v5cQsyuM0 X-Google-Smtp-Source: APXvYqwSj+17luzYJ96e4kFeQ2GvVHaY+pea4yzJz0eB/2cRh23FLzXCOmbo6qdBqe0n8XG7EbWP/w== X-Received: by 2002:a37:48f:: with SMTP id 137mr33577511qke.25.1575303539382; Mon, 02 Dec 2019 08:18:59 -0800 (PST) Received: from localhost.localdomain ([181.23.79.171]) by smtp.gmail.com with ESMTPSA id u67sm14592561qkf.115.2019.12.02.08.18.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 08:18:59 -0800 (PST) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Dec 2019 13:18:38 -0300 Message-Id: <20191202161838.1746-3-jamrial@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191202161838.1746-1-jamrial@gmail.com> References: <20191202161838.1746-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avformat/movenc: use iso6 major brand when signed CTS offsets are used in trun boxes X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: James Almer --- libavformat/movenc.c | 15 +++++++++++---- tests/ref/fate/movenc | 8 ++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index a632882ab2..bffd56644a 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -4756,6 +4756,9 @@ static void mov_write_ftyp_tag_internal(AVIOContext *pb, AVFormatContext *s, minor = has_h264 ? 0x20000 : 0x10000; } else if (mov->mode == MODE_PSP) ffio_wfourcc(pb, "MSNV"); + else if (mov->mode == MODE_MP4 && mov->flags & FF_MOV_FLAG_FRAGMENT && + mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS) + ffio_wfourcc(pb, "iso6"); // Required when using signed CTS offsets in trun boxes else if (mov->mode == MODE_MP4 && mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF) ffio_wfourcc(pb, "iso5"); // Required when using default-base-is-moof else if (mov->mode == MODE_MP4 && mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS) @@ -4806,10 +4809,14 @@ static int mov_write_ftyp_tag(AVIOContext *pb, AVFormatContext *s) ffio_wfourcc(pb, "piff"); } 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) { + // brand, if not already the major brand. This is compatible with users that + // don't understand tfdt. + if (mov->mode == MODE_MP4) { + if (mov->flags & FF_MOV_FLAG_FRAGMENT && !(mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS)) + ffio_wfourcc(pb, "iso6"); + } else { + if (mov->flags & FF_MOV_FLAG_FRAGMENT) + ffio_wfourcc(pb, "iso6"); if (mov->flags & FF_MOV_FLAG_DEFAULT_BASE_MOOF) ffio_wfourcc(pb, "iso5"); else if (mov->flags & FF_MOV_FLAG_NEGATIVE_CTS_OFFSETS) diff --git a/tests/ref/fate/movenc b/tests/ref/fate/movenc index 68ce3f6cd9..5c6a054c1a 100644 --- a/tests/ref/fate/movenc +++ b/tests/ref/fate/movenc @@ -140,14 +140,14 @@ write_data len 668, time 1566667, type sync atom moof write_data len 440, time 2233333, type boundary atom moof write_data len 262, time nopts, type trailer atom - 47cc2460c4b18390c67991cf3251409b 4209 vfr-noduration-interleave -write_data len 1235, time nopts, type header atom ftyp +write_data len 1231, time nopts, type header atom ftyp write_data len 916, time 0, type sync atom moof write_data len 908, time 1000000, type sync atom moof write_data len 148, time nopts, type trailer atom - -c272739705fb78f9d9bffd4c6376c8ce 3207 delay-moov-elst-neg-cts -write_data len 40, time nopts, type header atom ftyp +c200a345c365dd35a31e7e62a9ae6c10 3203 delay-moov-elst-neg-cts +write_data len 36, time nopts, type header atom ftyp write_data len 1123, time nopts, type header atom - write_data len 1188, time 0, type sync atom moof write_data len 908, time 1033333, type sync atom moof write_data len 148, time nopts, type trailer atom - -26c05cd931471319def6f3d5257a6a7a 3407 empty-moov-neg-cts +38a287dc98272ba9da0a0bf8feb72fef 3403 empty-moov-neg-cts