From patchwork Mon Jan 9 17:23:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasi Inguva X-Patchwork-Id: 2144 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp7148736vsb; Mon, 9 Jan 2017 09:25:30 -0800 (PST) X-Received: by 10.28.131.72 with SMTP id f69mr4752606wmd.135.1483982730111; Mon, 09 Jan 2017 09:25:30 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s93si8733881wrc.21.2017.01.09.09.25.29; Mon, 09 Jan 2017 09:25:30 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 57ECD68A415; Mon, 9 Jan 2017 19:25:20 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pg0-f42.google.com (mail-pg0-f42.google.com [74.125.83.42]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DBDCB68003F for ; Mon, 9 Jan 2017 19:25:13 +0200 (EET) Received: by mail-pg0-f42.google.com with SMTP id 14so31847055pgg.1 for ; Mon, 09 Jan 2017 09:25:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pinSqzkJQg0cmwn+f8NweVafpy8+579G4Wdyo/GQfo0=; b=lQCNPXT5V1Id4j7MVOFmkJQwyvq83LPKy8jqZgNSEHKWYhoIsAOVW/9FptSuj8vLBS uTHf6gfoI5CVfu7A6wNmF5eJLsCIJbHQyoPpT8dGiJyzrxIz+5w9/1neFm4mjBvUw7zW UaKr0RDE7biRexhgUAWjvz6HkCXAw/Jqa7NYfFFPps0gJJnFIhygmkh/hB0k8upz1W2r ANEGYGrsbXT8sK7wFd3vpaUwztuLdRFB7lZZKABIQnEhC7FkZtD2XYtKt6y47jOcFDLc KKFZbSMZ/IHGz3YGxfDDOKvDAm80auETXa5gXg0dDh9iWfFqUC3ImwK0q2X/ivEhF1St gl7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pinSqzkJQg0cmwn+f8NweVafpy8+579G4Wdyo/GQfo0=; b=DoUZIfYveWHO8SmgDH9+y8lWZ/WltZJX0yCwcxpWujrDIXShy5DYV49g+5lCZ5jBWn JrKuSJZcNbEMcV0q592ulFtNUYOjZjtErs1+MXDsR2zpvimFODR7KMLm3ZV/p1JvNGi5 h4ZSwcbv14MllDbcbdDFtytb5luxm7CQ+PutMO4HwLAaK+QEjkC9n7UzxmaceAP+LJA/ FtPlTdqiKy64uBesdlRXMcBOoHaRdg2cLHGaLAzgHFvcTlxbaKs44xaCBkhSMI8nH7MQ 8gztq5TCI2m5dZtUU+AIyBNwWIczHuOqE8xudenmX3Ao9PNjRVKObcguuED/8lkSyCWU tSyA== X-Gm-Message-State: AIkVDXJUc/ADeadRnwX7estpdsPipa16aZudb9+3LsV8cvOqNMcOq2rQWxHYGdU+hLL+eYqf X-Received: by 10.84.224.199 with SMTP id k7mr36628073pln.25.1483982719376; Mon, 09 Jan 2017 09:25:19 -0800 (PST) Received: from isasi.mtv.corp.google.com ([172.27.82.89]) by smtp.gmail.com with ESMTPSA id p2sm25009485pgd.17.2017.01.09.09.25.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Jan 2017 09:25:18 -0800 (PST) From: Sasi Inguva To: ffmpeg-devel@ffmpeg.org Date: Mon, 9 Jan 2017 09:23:38 -0800 Message-Id: <20170109172338.27926-1-isasi@google.com> X-Mailer: git-send-email 2.11.0.390.gc69c2f50cf-goog In-Reply-To: <20170109110811.31d85d16@debian> References: <20170109110811.31d85d16@debian> Subject: [FFmpeg-devel] [PATCH] lavf/mov.c: Add -editlist_fix_index option for mov format. 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 Cc: Sasi Inguva MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Adding an MOV format option to turn on/off the editlist supporting code, introduced in https://github.com/FFmpeg/FFmpeg/commit/ca6cae73db207f17a0d5507609de12842d8f0ca3 Signed-off-by: Sasi Inguva --- libavformat/isom.h | 1 + libavformat/mov.c | 28 ++++++++++++++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 12cefc9ade..ff3a234c48 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -225,6 +225,7 @@ typedef struct MOVContext { unsigned int nb_chapter_tracks; int use_absolute_path; int ignore_editlist; + int editlist_fix_index; int ignore_chapters; int seek_individually; int64_t next_root_atom; ///< offset of the next root atom diff --git a/libavformat/mov.c b/libavformat/mov.c index d1b929174d..c7f0461978 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3227,7 +3227,7 @@ static void mov_build_index(MOVContext *mov, AVStream *st) uint64_t stream_size = 0; if (sc->elst_count) { - int i, edit_start_index = 0; + int i, edit_start_index = 0, multiple_edits = 0; int64_t empty_duration = 0; // empty duration of the first edit list entry int64_t start_time = 0; // start time of the media @@ -3240,15 +3240,28 @@ static void mov_build_index(MOVContext *mov, AVStream *st) edit_start_index = 1; } else if (i == edit_start_index && e->time >= 0) { start_time = e->time; + } else { + multiple_edits = 1; } } + if (multiple_edits && !mov->editlist_fix_index) + av_log(mov->fc, AV_LOG_WARNING, "multiple edit list entries, " + "Use -editlist_fix_index to correctly decode otherwise " + "a/v desync might occur\n"); + /* adjust first dts according to edit list */ if ((empty_duration || start_time) && mov->time_scale > 0) { if (empty_duration) empty_duration = av_rescale(empty_duration, sc->time_scale, mov->time_scale); sc->time_offset = start_time - empty_duration; + if (!mov->editlist_fix_index) + current_dts = -sc->time_offset; } + + if (!multiple_edits && !mov->editlist_fix_index && + st->codecpar->codec_id == AV_CODEC_ID_AAC && start_time > 0) + sc->start_pad = start_time; } /* only use old uncompressed audio chunk demuxing when stts specifies it */ @@ -3482,8 +3495,10 @@ static void mov_build_index(MOVContext *mov, AVStream *st) } } - // Fix index according to edit lists. - mov_fix_index(mov, st); + if (!mov->ignore_editlist && mov->editlist_fix_index) { + // Fix index according to edit lists. + mov_fix_index(mov, st); + } } static int test_same_origin(const char *src, const char *ref) { @@ -6347,7 +6362,12 @@ static const AVOption mov_options[] = { "Seek each stream individually to the to the closest point", OFFSET(seek_individually), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, FLAGS}, - {"ignore_editlist", "", OFFSET(ignore_editlist), AV_OPT_TYPE_BOOL, {.i64 = 0}, + {"ignore_editlist", "Ignore the edit list atom.", OFFSET(ignore_editlist), AV_OPT_TYPE_BOOL, {.i64 = 0}, + 0, 1, FLAGS}, + {"editlist_fix_index", + "Modify the AVIndex according to the editlists." + "Use this option to decode in the order specified by the edits.", + OFFSET(editlist_fix_index), AV_OPT_TYPE_BOOL, {.i64 = 1}, 0, 1, FLAGS}, {"ignore_chapters", "", OFFSET(ignore_chapters), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS},