diff mbox

[FFmpeg-devel] lavf/mov: Do not fail hard for more mov atoms

Message ID CAB0OVGrZgaz9YimqCT-RP3SwOJW8JDP2FjvXdM7nw6dyHPKvHw@mail.gmail.com
State Accepted
Headers show

Commit Message

Carl Eugen Hoyos Jan. 14, 2019, 11:46 a.m. UTC
2019-01-14 10:05 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>:
> On Sun, Jan 13, 2019 at 11:14:52PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch fixes ticket #7679.
>>
>> Please comment, Carl Eugen
>
>>  mov.c |   12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>> a2759589f6ab06b09057969490ffc13291965144
>> 0001-lavf-mov-Do-not-fail-hard-for-more-invalid-atoms.patch
>> From ea6afa36d5ceb6e027176f051e7886f0648e3ac2 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> Date: Sun, 13 Jan 2019 23:07:06 +0100
>> Subject: [PATCH] lavf/mov: Do not fail hard for more invalid atoms.
>>
>> This is what several other players do and what FFmpeg already does for the
>> sidx atom.
>>
>> Fixes ticket #7679.
>> ---
>>  libavformat/mov.c |   12 ++++++------
>>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> If a atom is ignored/discarded it should not have changed state of other
> things. This patch would break out after some fields are updated

Thank you, new patch attached.

Please review, Carl Eugen

Comments

Michael Niedermayer Jan. 14, 2019, 8:07 p.m. UTC | #1
On Mon, Jan 14, 2019 at 12:46:08PM +0100, Carl Eugen Hoyos wrote:
> 2019-01-14 10:05 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>:
> > On Sun, Jan 13, 2019 at 11:14:52PM +0100, Carl Eugen Hoyos wrote:
> >> Hi!
> >>
> >> Attached patch fixes ticket #7679.
> >>
> >> Please comment, Carl Eugen
> >
> >>  mov.c |   12 ++++++------
> >>  1 file changed, 6 insertions(+), 6 deletions(-)
> >> a2759589f6ab06b09057969490ffc13291965144
> >> 0001-lavf-mov-Do-not-fail-hard-for-more-invalid-atoms.patch
> >> From ea6afa36d5ceb6e027176f051e7886f0648e3ac2 Mon Sep 17 00:00:00 2001
> >> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> >> Date: Sun, 13 Jan 2019 23:07:06 +0100
> >> Subject: [PATCH] lavf/mov: Do not fail hard for more invalid atoms.
> >>
> >> This is what several other players do and what FFmpeg already does for the
> >> sidx atom.
> >>
> >> Fixes ticket #7679.
> >> ---
> >>  libavformat/mov.c |   12 ++++++------
> >>  1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > If a atom is ignored/discarded it should not have changed state of other
> > things. This patch would break out after some fields are updated
> 
> Thank you, new patch attached.
> 
> Please review, Carl Eugen

>  mov.c |   18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 1365cf6b728c8e296042420e67d58d4121b7119b  0001-lavf-mov-Do-not-fail-hard-for-more-invalid-atoms.patch
> From 4206aa40f9a3de7081c340a1da206132ed365272 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
> Date: Mon, 14 Jan 2019 12:44:01 +0100
> Subject: [PATCH] lavf/mov: Do not fail hard for more invalid atoms.
> 
> This is what several other players do and what FFmpeg already does for the sidx atom.
> 
> Fixes ticket #7679.
> ---
>  libavformat/mov.c |   18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)

should be ok

thanks

[...]
Carl Eugen Hoyos Jan. 14, 2019, 9:37 p.m. UTC | #2
2019-01-14 21:07 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>:
> On Mon, Jan 14, 2019 at 12:46:08PM +0100, Carl Eugen Hoyos wrote:
>> 2019-01-14 10:05 GMT+01:00, Michael Niedermayer <michael@niedermayer.cc>:
>> > On Sun, Jan 13, 2019 at 11:14:52PM +0100, Carl Eugen Hoyos wrote:
>> >> Hi!
>> >>
>> >> Attached patch fixes ticket #7679.
>> >>
>> >> Please comment, Carl Eugen
>> >
>> >>  mov.c |   12 ++++++------
>> >>  1 file changed, 6 insertions(+), 6 deletions(-)
>> >> a2759589f6ab06b09057969490ffc13291965144
>> >> 0001-lavf-mov-Do-not-fail-hard-for-more-invalid-atoms.patch
>> >> From ea6afa36d5ceb6e027176f051e7886f0648e3ac2 Mon Sep 17 00:00:00 2001
>> >> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> >> Date: Sun, 13 Jan 2019 23:07:06 +0100
>> >> Subject: [PATCH] lavf/mov: Do not fail hard for more invalid atoms.
>> >>
>> >> This is what several other players do and what FFmpeg already does for
>> >> the
>> >> sidx atom.
>> >>
>> >> Fixes ticket #7679.
>> >> ---
>> >>  libavformat/mov.c |   12 ++++++------
>> >>  1 file changed, 6 insertions(+), 6 deletions(-)
>> >
>> > If a atom is ignored/discarded it should not have changed state of
>> > other
>> > things. This patch would break out after some fields are updated
>>
>> Thank you, new patch attached.
>>
>> Please review, Carl Eugen
>
>>  mov.c |   18 +++++++++---------
>>  1 file changed, 9 insertions(+), 9 deletions(-)
>> 1365cf6b728c8e296042420e67d58d4121b7119b
>> 0001-lavf-mov-Do-not-fail-hard-for-more-invalid-atoms.patch
>> From 4206aa40f9a3de7081c340a1da206132ed365272 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
>> Date: Mon, 14 Jan 2019 12:44:01 +0100
>> Subject: [PATCH] lavf/mov: Do not fail hard for more invalid atoms.
>>
>> This is what several other players do and what FFmpeg already does for the
>> sidx atom.
>>
>> Fixes ticket #7679.
>> ---
>>  libavformat/mov.c |   18 +++++++++---------
>>  1 file changed, 9 insertions(+), 9 deletions(-)
>
> should be ok

Patch applied.

Thank you, Carl Eugen
diff mbox

Patch

From 4206aa40f9a3de7081c340a1da206132ed365272 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos <ceffmpeg@gmail.com>
Date: Mon, 14 Jan 2019 12:44:01 +0100
Subject: [PATCH] lavf/mov: Do not fail hard for more invalid atoms.

This is what several other players do and what FFmpeg already does for the sidx atom.

Fixes ticket #7679.
---
 libavformat/mov.c |   18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 970cd87..9b9739f 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4550,17 +4550,17 @@  static int mov_read_tfhd(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     track_id = avio_rb32(pb);
     if (!track_id)
         return AVERROR_INVALIDDATA;
-    frag->track_id = track_id;
-    set_frag_stream(&c->frag_index, track_id);
     for (i = 0; i < c->trex_count; i++)
-        if (c->trex_data[i].track_id == frag->track_id) {
+        if (c->trex_data[i].track_id == track_id) {
             trex = &c->trex_data[i];
             break;
         }
     if (!trex) {
-        av_log(c->fc, AV_LOG_ERROR, "could not find corresponding trex\n");
-        return AVERROR_INVALIDDATA;
+        av_log(c->fc, AV_LOG_WARNING, "could not find corresponding trex (id %u)\n", track_id);
+        return 0;
     }
+    frag->track_id = track_id;
+    set_frag_stream(&c->frag_index, track_id);
 
     frag->base_data_offset = flags & MOV_TFHD_BASE_DATA_OFFSET ?
                              avio_rb64(pb) : flags & MOV_TFHD_DEFAULT_BASE_IS_MOOF ?
@@ -4639,8 +4639,8 @@  static int mov_read_tfdt(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         }
     }
     if (!st) {
-        av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %u\n", frag->track_id);
-        return AVERROR_INVALIDDATA;
+        av_log(c->fc, AV_LOG_WARNING, "could not find corresponding track id %u\n", frag->track_id);
+        return 0;
     }
     sc = st->priv_data;
     if (sc->pseudo_stream_id + 1 != frag->stsd_id && sc->pseudo_stream_id != -1)
@@ -4686,8 +4686,8 @@  static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom)
         }
     }
     if (!st) {
-        av_log(c->fc, AV_LOG_ERROR, "could not find corresponding track id %u\n", frag->track_id);
-        return AVERROR_INVALIDDATA;
+        av_log(c->fc, AV_LOG_WARNING, "could not find corresponding track id %u\n", frag->track_id);
+        return 0;
     }
     sc = st->priv_data;
     if (sc->pseudo_stream_id+1 != frag->stsd_id && sc->pseudo_stream_id != -1)
-- 
1.7.10.4