mov: Trim dref absolute path
authorVittorio Giovara <vittorio.giovara@gmail.com>
Tue, 16 Feb 2016 02:44:07 +0000 (21:44 -0500)
committerVittorio Giovara <vittorio.giovara@gmail.com>
Sat, 5 Mar 2016 13:23:18 +0000 (08:23 -0500)
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.giovara@gmail.com>
libavformat/mov.c

index 0dee5ec..a556aa7 100644 (file)
@@ -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;
                     }
                         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] = '/';
                     for (j = 0; j < len; j++)
                         if (dref->path[j] == ':' || dref->path[j] == 0)
                             dref->path[j] = '/';