Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-11 Thread Michael Niedermayer
On Thu, Nov 09, 2017 at 04:11:22PM -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 | 33 
> +++
>  3 files changed, 58 insertions(+), 11 deletions(-)
>  create mode 100644 tests/ref/fate/mov-elst-ends-betn-b-and-i

will apply

thanks

[...]
-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-09 Thread Sasi Inguva
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 00..d6f325bba2
--- /de

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-09 Thread Sasi Inguva
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] 

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-09 Thread Michael Niedermayer
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 ..."


signature.asc
Desc

[FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-08 Thread Sasi Inguva
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

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 00..ee7c6389ad
--- /de

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-08 Thread Sasi Inguva
Updated the fate test after
http://git.videolan.org/?p=ffmpeg.git;a=commit;h=c2a8f0fcbe57ea9ccaa864130f078af10516c3c1
. Sending the updated patch.

On Thu, Nov 2, 2017 at 4:23 PM, Michael Niedermayer 
wrote:

> On Wed, Nov 01, 2017 at 02:27:50PM -0700, Sasi Inguva wrote:
> > Pls find attached, the FATE sample.
>
> uplaoded
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> There will always be a question for which you do not know the correct
> answer.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-02 Thread Michael Niedermayer
On Wed, Nov 01, 2017 at 02:27:50PM -0700, Sasi Inguva wrote:
> Pls find attached, the FATE sample.

uplaoded

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

There will always be a question for which you do not know the correct answer.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-01 Thread Sasi Inguva
This patch is not an alternative. Both patches are required to fix
t/6699 . Once
one of the patches is submitted, i will update the fate tests in the other
patch.

On Wed, Nov 1, 2017 at 5:11 PM, Michael Niedermayer 
wrote:

> On Wed, Nov 01, 2017 at 02:26:45PM -0700, 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
>
> Is this inteded as an alternaive to your other patch ?
> both together fail fate:
>
> [...]
> --- ./tests/ref/fate/mov-elst-ends-betn-b-and-i 2017-11-02
> 00:56:36.199196931 +0100
> +++ tests/data/fate/mov-elst-ends-betn-b-and-i  2017-11-02
> 01:03:01.739201528 +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
> TESTmp3-float-conf-si

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-01 Thread Michael Niedermayer
On Wed, Nov 01, 2017 at 02:26:45PM -0700, 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

Is this inteded as an alternaive to your other patch ?
both together fail fate:

[...]
--- ./tests/ref/fate/mov-elst-ends-betn-b-and-i 2017-11-02 00:56:36.199196931 
+0100
+++ tests/data/fate/mov-elst-ends-betn-b-and-i  2017-11-02 01:03:01.739201528 
+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
TESTmp3-float-conf-si
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
make: *** Waiting for unfinished jobs


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


signature.asc
Description: Digital sign

[FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-01 Thread Sasi Inguva
Partially fixes t/6699.
---
 libavformat/mov.c  | 32 +---
 tests/fate/mov.mak |  4 
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 60f0228e2d..e716e5ba9e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3232,6 +3232,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;
@@ -3347,6 +3348,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) ?
@@ -3459,18 +3461,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 6815e4feca..e444b1459d 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -9,6 +9,7 @@ FATE_MOV = fate-mov-3elist \
fate-mov-invalid-elst-entry-count \
fate-mov-gpmf-remux \
fate-mov-440hz-10ms \
+   fate-mov-elst-ends-betn-b-and-i \
 
 FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \
fate-mov-zombie \
@@ -41,6 +42,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
 
-- 
2.15.0.403.gc27cc4dac6-goog

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-01 Thread Sasi Inguva
Pls find attached, the FATE sample.


On Wed, Nov 1, 2017 at 2:26 PM, 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
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 60f0228e2d..e716e5ba9e 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -3232,6 +3232,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;
> @@ -3347,6 +3348,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) ?
> @@ -3459,18 +3461,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 6815e4feca..e444b1459d 100644
> --- a/tests/fate/mov.mak
> +++ b/tests/fate/mov.mak
> @@ -9,6 +9,7 @@ FATE_MOV = fate-mov-3elist \
> fate-mov-invalid-elst-entry-count \
> fate-mov-gpmf-remux \
> fate-mov-440hz-10ms \
> +   fate-mov-elst-ends-betn-b-and-i \
>
>  FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \
> fate-mov-zombie \
> @@ -41,6 +42,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
> +
>  # Mak

[FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-01 Thread Sasi Inguva
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

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 60f0228e2d..e716e5ba9e 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -3232,6 +3232,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;
@@ -3347,6 +3348,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) ?
@@ -3459,18 +3461,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 6815e4feca..e444b1459d 100644
--- a/tests/fate/mov.mak
+++ b/tests/fate/mov.mak
@@ -9,6 +9,7 @@ FATE_MOV = fate-mov-3elist \
fate-mov-invalid-elst-entry-count \
fate-mov-gpmf-remux \
fate-mov-440hz-10ms \
+   fate-mov-elst-ends-betn-b-and-i \
 
 FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \
fate-mov-zombie \
@@ -41,6 +42,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 00..ee7c6389ad
--

Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Parse upto 2 keyframes after the edit list end in mov_fix_index.

2017-11-01 Thread Sasi Inguva
Forgot to attach the FATE ref file. sending the patch again.

On Wed, Nov 1, 2017 at 2:23 PM, Sasi Inguva  wrote:

> Partially fixes t/6699.
> ---
>  libavformat/mov.c  | 32 +---
>  tests/fate/mov.mak |  4 
>  2 files changed, 25 insertions(+), 11 deletions(-)
>
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 60f0228e2d..e716e5ba9e 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -3232,6 +3232,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;
> @@ -3347,6 +3348,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) ?
> @@ -3459,18 +3461,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 6815e4feca..e444b1459d 100644
> --- a/tests/fate/mov.mak
> +++ b/tests/fate/mov.mak
> @@ -9,6 +9,7 @@ FATE_MOV = fate-mov-3elist \
> fate-mov-invalid-elst-entry-count \
> fate-mov-gpmf-remux \
> fate-mov-440hz-10ms \
> +   fate-mov-elst-ends-betn-b-and-i \
>
>  FATE_MOV_FFPROBE = fate-mov-aac-2048-priming \
> fate-mov-zombie \
> @@ -41,6 +42,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
>
> --
> 2.15.0.403.gc27c