From patchwork Fri Nov 10 00:10:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasi Inguva X-Patchwork-Id: 5976 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.161.90 with SMTP id m26csp2700929jah; Thu, 9 Nov 2017 16:10:53 -0800 (PST) X-Google-Smtp-Source: AGs4zMbgtvzn1ES3EWsY6EVHAIm7/Pw6mS5rOL88tJnrE8uEBewDOO3bNc9vZhpBrRqH7EMtopCe X-Received: by 10.28.190.12 with SMTP id o12mr1285617wmf.4.1510272653842; Thu, 09 Nov 2017 16:10:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510272653; cv=none; d=google.com; s=arc-20160816; b=I9CfTzfq8ngkYsKXxPX38t4iDR3iaHZTYf6ABbvKOuKp7VN+KX7c+nFbSO98k7Ubc1 13s3+sSomduJrAsdUjMO1jOmtwfeVUvm8Ba8rYEuB7TV3Ff10UsywT2+RV699bFUv5Up agn9NmjtRve4ESI3IN6d2eJv2h2DB7ixzoSYAMzuk/yCohTNeQ7ZlyvgwPK7sVBcrqLh 3SVTxPIzECSbqmHOQALz0otNH6NVzgD8AzHQJ8zO1ndBxenVORiz6kYbW8P5k8S5vqZn jPm6C9Aq3Gvd0s56RWssLAQxy7bbCFQHJpBoxqxc1DTQibwbBY7wQX5702FXtRV1uWSO LcbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=Ecv2KSzkscUM8msUjS9WTO/tr1HDQuIWmvwUWJz2vpE=; b=siu4xGWFTpWV2CS+t0M58PDkM8Rak7xIPOEEIULSHZmG3w7PUYORmqsux/mVZkNfFA 2Z81N9fpAIS2CWRhmps+klLiSfWmg7dsjakEe/f1KTuu0Pm2+K0Sg/lu3cGMAuqOo3cI TmZ/caxQWoYWLcoP7+E3MaPbgnXtM/ZGXk+a5IFt/t/Vo12K1mioHmIxqOm+9oY1X2XE sFbew2LyjuL4WyDdKmMaZwv786Yyr8MU8g7EQvIxPIS6LMsic4/sDpFFvSz4DyskH5xI Hb/LHR4y/8F9A2OBzZYqqwc3H9OxDI/MEBqEMGGukTTOfSm8j6EwcgYDf6yJDv4e723o HwBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=nSnK5KSY; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s70si122779wmb.158.2017.11.09.16.10.53; Thu, 09 Nov 2017 16:10:53 -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 header.s=20161025 header.b=nSnK5KSY; 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 DB6326883A5; Fri, 10 Nov 2017 02:10:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vk0-f47.google.com (mail-vk0-f47.google.com [209.85.213.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 467CD68832E for ; Fri, 10 Nov 2017 02:10:32 +0200 (EET) Received: by mail-vk0-f47.google.com with SMTP id b18so2825458vkd.11 for ; Thu, 09 Nov 2017 16:10:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=VF664fbgWSPkkIE4g3Bu16KzRnHWpdIMp7sLl/9hJHM=; b=nSnK5KSYgWL5F/VPUgJbHbWeYGZJGMXwj6T1nt4H0EXEIWqIBuOGZX0mOturyN24PE nT9FgJ+0xDkS3aOZ69naK20qxJGsOwJzUHJrF4Lf2l8Fyc81/ARfxnZPXPJJjjABuFRI UsxT6+Q4EXG8vQVcz1cNGmb0O9sy2Wzts5Cb9jEYRkKNdH2lsOOw/+IlfqLtlm3C2Vbz KM9qictC3C+mg/jxj7Q/m7I1Ya/Fb/sOhwKwKoKG8pXsyIYh+Nl+OZZ3SleBYeUvbh13 P/DJLIuCN/oT5sxip1HvwJMpkxdeXfVFsM1/v7ZODfjjv8SsdDkfo2LgSKj9qAduYOUb NbkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=VF664fbgWSPkkIE4g3Bu16KzRnHWpdIMp7sLl/9hJHM=; b=QNyLsviRXFxg57CKAMvBP3KNwK9Oh6jFcGsnnNYOlfxXrleE2o9KjOsSPhTUmXLqtV encM29QL5CJd+MnHZS8fdoFP4G3A9D7M3Ax+I97M9TikRGSjNgEaJLd8H7SP7UCDnaWc vTEGlWj68kXqaH8jllyK2gO3K8+96c6Ld0ZX/UHgC4qEbDpb8ZR8c1IydR3GqZT6PULt pQn7+wycEIjqyNqsBih9AaH01P7SfkWqmbd6a04o7xE+Kw2fSIXMBHw6G3vBx1PmlNXC uyHbuQl6u1jcChgxY4jmHh5alZN+XN9foovOslH/8cGDgA2QmeflRsSIQi9toh6XXo14 d6sw== X-Gm-Message-State: AJaThX5xn4qrTASRIf0OuFdYN/EwdhteieZY526gG37OFBIbyYG5+MJe UgFQenfiolohd6GbYjOSCNN0UoXyh/dIxPbQDPCQah4N X-Received: by 10.31.81.6 with SMTP id f6mr1766821vkb.127.1510272643586; Thu, 09 Nov 2017 16:10:43 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.147.81 with HTTP; Thu, 9 Nov 2017 16:10:42 -0800 (PST) In-Reply-To: <20171109202211.GT6009@nb4> References: <20171109001346.8458-1-isasi@google.com> <20171109202211.GT6009@nb4> From: Sasi Inguva Date: Thu, 9 Nov 2017 16:10:42 -0800 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index. 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" Sorry, about this. i had uncommitted changes. Attaching the patch. On Thu, Nov 9, 2017 at 12:22 PM, Michael Niedermayer wrote: > On Wed, Nov 08, 2017 at 04:13:46PM -0800, Sasi Inguva wrote: > > Partially fixes t/6699. > > --- > > libavformat/mov.c | 32 > ++++++++++++++++++++----------- > > tests/fate/mov.mak | 4 ++++ > > tests/ref/fate/mov-elst-ends-betn-b-and-i | 31 > ++++++++++++++++++++++++++++++ > > 3 files changed, 56 insertions(+), 11 deletions(-) > > create mode 100644 tests/ref/fate/mov-elst-ends-betn-b-and-i > > seems not passing fate here or i did something silly > > --- ./tests/ref/fate/mov-elst-ends-betn-b-and-i 2017-11-09 21:14: > 14.425558802 +0100 > +++ tests/data/fate/mov-elst-ends-betn-b-and-i 2017-11-09 > 21:21:15.957563829 +0100 > @@ -7,25 +7,27 @@ > #dimensions 0: 320x240 > #sar 0: 1/1 > #stream#, dts, pts, duration, size, hash > -0, 0, 0, 1, 115200, > 4e5dc2b806e394cd666c968f736fecd0 > -0, 1, 1, 1, 115200, > 7a3c7473d44c5f60c07655f6fc0c2ac3 > -0, 2, 2, 1, 115200, > 038254422a603a3270c09cdcd149707b > -0, 3, 3, 1, 115200, > 7553b6b4547cb23ef8f0392ed5a5d4b0 > -0, 4, 4, 1, 115200, > 6d017ede7f446124af7308667cb0dc41 > -0, 5, 5, 1, 115200, > 77752f0288ae64f857732b8e62e47457 > -0, 6, 6, 1, 115200, > d656833951af99330625f7c6de7685c4 > -0, 7, 7, 1, 115200, > 14338b833e431e566ac98da841600bfe > -0, 8, 8, 1, 115200, > 07ea95d1659f3c4424a470a546d0df6e > -0, 9, 9, 1, 115200, > fd05b8cc83072f813e89d394d1f6efc6 > -0, 10, 10, 1, 115200, > 750b82ca5c7e901545e7b1aa69692426 > -0, 11, 11, 1, 115200, > 7347679ab09bc936047368b8caebcaff > -0, 12, 12, 1, 115200, > 63a23fdd57ac8462b9ffbcb12ab717b3 > -0, 13, 13, 1, 115200, > 705257a1c99693db233e2a3ee027adcf > -0, 14, 14, 1, 115200, > df861a2ec7a4ef70e82b1c28025e5a48 > -0, 15, 15, 1, 115200, > 2a8b403c077b6b43aa71eaf7d1537713 > -0, 16, 16, 1, 115200, > 973b5cd3ce473e3970dfa96045553172 > -0, 17, 17, 1, 115200, > fc612c0afeae3b6576b5ee2f3f119832 > -0, 18, 18, 1, 115200, > 97074fe5a0b6e7e8470729654092e56c > -0, 19, 19, 1, 115200, > 8cf9337201065335b3aa4da21dc9b37a > -0, 20, 20, 1, 115200, > 93ff3589294cc0673af3daee1e7fe42a > -0, 21, 21, 1, 115200, > c0b6fd870a022f374f9d6c697e8e293d > +0, 0, 0, 1, 115200, > e10741e5457e9326d5e992e6c05c3e32 > +0, 1, 1, 1, 115200, > 7e20f8729b6b53dc11791927bf4a5aec > +0, 2, 2, 1, 115200, > 4e5dc2b806e394cd666c968f736fecd0 > +0, 3, 3, 1, 115200, > 7a3c7473d44c5f60c07655f6fc0c2ac3 > +0, 4, 4, 1, 115200, > 038254422a603a3270c09cdcd149707b > +0, 5, 5, 1, 115200, > 7553b6b4547cb23ef8f0392ed5a5d4b0 > +0, 6, 6, 1, 115200, > 6d017ede7f446124af7308667cb0dc41 > +0, 7, 7, 1, 115200, > 77752f0288ae64f857732b8e62e47457 > +0, 8, 8, 1, 115200, > d656833951af99330625f7c6de7685c4 > +0, 9, 9, 1, 115200, > 14338b833e431e566ac98da841600bfe > +0, 10, 10, 1, 115200, > 07ea95d1659f3c4424a470a546d0df6e > +0, 11, 11, 1, 115200, > fd05b8cc83072f813e89d394d1f6efc6 > +0, 12, 12, 1, 115200, > 750b82ca5c7e901545e7b1aa69692426 > +0, 13, 13, 1, 115200, > 7347679ab09bc936047368b8caebcaff > +0, 14, 14, 1, 115200, > 63a23fdd57ac8462b9ffbcb12ab717b3 > +0, 15, 15, 1, 115200, > 705257a1c99693db233e2a3ee027adcf > +0, 16, 16, 1, 115200, > df861a2ec7a4ef70e82b1c28025e5a48 > +0, 17, 17, 1, 115200, > 2a8b403c077b6b43aa71eaf7d1537713 > +0, 18, 18, 1, 115200, > 973b5cd3ce473e3970dfa96045553172 > +0, 19, 19, 1, 115200, > fc612c0afeae3b6576b5ee2f3f119832 > +0, 20, 20, 1, 115200, > 97074fe5a0b6e7e8470729654092e56c > +0, 21, 21, 1, 115200, > 8cf9337201065335b3aa4da21dc9b37a > +0, 22, 22, 1, 115200, > 93ff3589294cc0673af3daee1e7fe42a > +0, 23, 23, 1, 115200, > c0b6fd870a022f374f9d6c697e8e293d > Test mov-elst-ends-betn-b-and-i failed. Look at > tests/data/fate/mov-elst-ends-betn-b-and-i.err for details. > make: *** [fate-mov-elst-ends-betn-b-and-i] Error 1 > > [...] > -- > Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB > > The real ebay dictionary, page 1 > "Used only once" - "Some unspecified defect prevented a second use" > "In good condition" - "Can be repaird by experienced expert" > "As is" - "You wouldnt want it even if you were payed for it, if you knew > ..." > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > From c27770076b8f8e556992ee9e83808a655a7dbdb3 Mon Sep 17 00:00:00 2001 From: Sasi Inguva Date: Wed, 1 Nov 2017 14:21:19 -0700 Subject: [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index. Partially fixes t/6699. --- libavformat/mov.c | 32 +++++++++++++++++++----------- tests/fate/mov.mak | 4 ++++ tests/ref/fate/mov-elst-ends-betn-b-and-i | 33 +++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 tests/ref/fate/mov-elst-ends-betn-b-and-i diff --git a/libavformat/mov.c b/libavformat/mov.c index 7954db6e47..436ae42cbb 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3295,6 +3295,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) int packet_skip_samples = 0; MOVIndexRange *current_index_range; int i; + int found_keyframe_after_edit = 0; if (!msc->elst_data || msc->elst_count <= 0 || nb_old <= 0) { return; @@ -3390,6 +3391,7 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // Iterate over index and arrange it according to edit list edit_list_start_encountered = 0; + found_keyframe_after_edit = 0; for (; current < e_old_end; current++, index++) { // check if frame outside edit list mark it for discard frame_duration = (current + 1 < e_old_end) ? @@ -3502,18 +3504,26 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) } // Break when found first key frame after edit entry completion - if (((curr_cts + frame_duration) >= (edit_list_duration + edit_list_media_time)) && + if ((curr_cts + frame_duration >= (edit_list_duration + edit_list_media_time)) && ((flags & AVINDEX_KEYFRAME) || ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)))) { - - if (ctts_data_old && ctts_sample_old != 0) { - if (add_ctts_entry(&msc->ctts_data, &msc->ctts_count, - &msc->ctts_allocated_size, - ctts_sample_old - edit_list_start_ctts_sample, - ctts_data_old[ctts_index_old].duration) == -1) { - av_log(mov->fc, AV_LOG_ERROR, "Cannot add CTTS entry %"PRId64" - {%"PRId64", %d}\n", - ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample, - ctts_data_old[ctts_index_old].duration); - break; + if (ctts_data_old) { + // If we have CTTS and this is the the first keyframe after edit elist, + // wait for one more, because there might be trailing B-frames after this I-frame + // that do belong to the edit. + if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO && found_keyframe_after_edit == 0) { + found_keyframe_after_edit = 1; + continue; + } + if (ctts_sample_old != 0) { + if (add_ctts_entry(&msc->ctts_data, &msc->ctts_count, + &msc->ctts_allocated_size, + ctts_sample_old - edit_list_start_ctts_sample, + ctts_data_old[ctts_index_old].duration) == -1) { + av_log(mov->fc, AV_LOG_ERROR, "Cannot add CTTS entry %"PRId64" - {%"PRId64", %d}\n", + ctts_index_old, ctts_sample_old - edit_list_start_ctts_sample, + ctts_data_old[ctts_index_old].duration); + break; + } } } break; diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index 01893a0767..76f66ff498 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -10,6 +10,7 @@ FATE_MOV = fate-mov-3elist \ fate-mov-gpmf-remux \ fate-mov-440hz-10ms \ fate-mov-ibi-elst-starts-b \ + fate-mov-elst-ends-betn-b-and-i \ FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \ fate-mov-zombie \ @@ -42,6 +43,9 @@ fate-mov-1elist-ends-last-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-1e # Makes sure that we handle timestamps of packets in case of multiple edit lists with one of them ending on a B-frame correctly. fate-mov-2elist-elist1-ends-bframe: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/mov-2elist-elist1-ends-bframe.mov +# Makes sure that if edit list ends on a B-frame but before the I-frame, then we output the B-frame but discard the I-frame. +fate-mov-elst-ends-betn-b-and-i: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/elst_ends_betn_b_and_i.mp4 + # Makes sure that we handle edit lists and start padding correctly. fate-mov-440hz-10ms: CMD = framemd5 -i $(TARGET_SAMPLES)/mov/440hz-10ms.m4a diff --git a/tests/ref/fate/mov-elst-ends-betn-b-and-i b/tests/ref/fate/mov-elst-ends-betn-b-and-i new file mode 100644 index 0000000000..d6f325bba2 --- /dev/null +++ b/tests/ref/fate/mov-elst-ends-betn-b-and-i @@ -0,0 +1,33 @@ +#format: frame checksums +#version: 2 +#hash: MD5 +#tb 0: 1/25 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 320x240 +#sar 0: 1/1 +#stream#, dts, pts, duration, size, hash +0, 0, 0, 1, 115200, e10741e5457e9326d5e992e6c05c3e32 +0, 1, 1, 1, 115200, 7e20f8729b6b53dc11791927bf4a5aec +0, 2, 2, 1, 115200, 4e5dc2b806e394cd666c968f736fecd0 +0, 3, 3, 1, 115200, 7a3c7473d44c5f60c07655f6fc0c2ac3 +0, 4, 4, 1, 115200, 038254422a603a3270c09cdcd149707b +0, 5, 5, 1, 115200, 7553b6b4547cb23ef8f0392ed5a5d4b0 +0, 6, 6, 1, 115200, 6d017ede7f446124af7308667cb0dc41 +0, 7, 7, 1, 115200, 77752f0288ae64f857732b8e62e47457 +0, 8, 8, 1, 115200, d656833951af99330625f7c6de7685c4 +0, 9, 9, 1, 115200, 14338b833e431e566ac98da841600bfe +0, 10, 10, 1, 115200, 07ea95d1659f3c4424a470a546d0df6e +0, 11, 11, 1, 115200, fd05b8cc83072f813e89d394d1f6efc6 +0, 12, 12, 1, 115200, 750b82ca5c7e901545e7b1aa69692426 +0, 13, 13, 1, 115200, 7347679ab09bc936047368b8caebcaff +0, 14, 14, 1, 115200, 63a23fdd57ac8462b9ffbcb12ab717b3 +0, 15, 15, 1, 115200, 705257a1c99693db233e2a3ee027adcf +0, 16, 16, 1, 115200, df861a2ec7a4ef70e82b1c28025e5a48 +0, 17, 17, 1, 115200, 2a8b403c077b6b43aa71eaf7d1537713 +0, 18, 18, 1, 115200, 973b5cd3ce473e3970dfa96045553172 +0, 19, 19, 1, 115200, fc612c0afeae3b6576b5ee2f3f119832 +0, 20, 20, 1, 115200, 97074fe5a0b6e7e8470729654092e56c +0, 21, 21, 1, 115200, 8cf9337201065335b3aa4da21dc9b37a +0, 22, 22, 1, 115200, 93ff3589294cc0673af3daee1e7fe42a +0, 23, 23, 1, 115200, c0b6fd870a022f374f9d6c697e8e293d -- 2.15.0.448.gf294e3d99a-goog