On Wed, Feb 17, 2016 at 2:41 AM, Luca Barbato <lu_z...@gentoo.org> wrote: > On 16/02/16 22:26, Vittorio Giovara wrote: >> On Tue, Feb 16, 2016 at 2:19 AM, Luca Barbato <lu_z...@gentoo.org> wrote: >>> On 16/02/16 03:44, Vittorio Giovara wrote: >>>> Samples produced by Omneon (Harmonic) store external references with >>>> paths ending with 0s. Such movs cannot be loaded properly since every >>>> 0 is converted to '/', to keep the same parsing code for dref type 2 >>>> and type 18: this makes the external reference point to a non-existing >>>> direactory, rather than to the actual referenced file. >>>> >>>> Add a brief trimming loop that drops all ending 0s before trying to >>>> parse the external reference path. >>>> >>>> Signed-off-by: Vittorio Giovara <vittorio.giov...@gmail.com> >>>> --- >>>> Note: all samples I was given only have one zero appended, so it might >>>> be enough to just do something like >>>> >>>> -if (dref->path[j] == ':' || dref->path[j] == 0) >>>> +if (dref->path[j] == ':' || (dref->path[j] == 0 && j < len -1)) >>>> >>>> the loop seems safer but potentially wasteful. >>>> Opinions? >>>> Vittorio >>>> >>>> libavformat/mov.c | 7 +++++++ >>>> 1 file changed, 7 insertions(+) >>>> >>>> diff --git a/libavformat/mov.c b/libavformat/mov.c >>>> index 1cb91b9..7081ead 100644 >>>> --- a/libavformat/mov.c >>>> +++ b/libavformat/mov.c >>>> @@ -554,6 +554,13 @@ static int mov_read_dref(MOVContext *c, AVIOContext >>>> *pb, MOVAtom atom) >>>> memmove(dref->path, dref->path+volume_len, len); >>>> dref->path[len] = 0; >>>> } >>>> + // trim string of any ending zeros >>>> + for (j = len - 1; j >= 0; j--) { >>>> + if (dref->path[j] == 0) >>>> + len--; >>>> + else >>>> + break; >>>> + } >>>> for (j = 0; j < len; j++) >>>> if (dref->path[j] == ':' || dref->path[j] == 0) >>>> dref->path[j] = '/'; >>>> >>> >>> breaking the other loop in the presence of 0 isn't an option? >> >> No because for dref type 18 uses 0 instead of / for setting absolute path >> I think this software is adding the null terminator even though it's >> not strictly required, so it might be enough to just opt for the other >> alternative I proposed. >> > > Then I guess is fine your way.
Which way? Patch as is or the other version that trims by 1 character only? -- Vittorio _______________________________________________ libav-devel mailing list libav-devel@libav.org https://lists.libav.org/mailman/listinfo/libav-devel