]> git.sesse.net Git - ffmpeg/blobdiff - tools/qt-faststart.c
mpeg4videoenc: Remove disabled variant of mpeg4_encode_block().
[ffmpeg] / tools / qt-faststart.c
index e1bcebca93819d7035922137b54adfbc90b6e24d..eefeafdfac39229947f3d556772e80edfcb249af 100644 (file)
@@ -8,7 +8,7 @@
  * is in front of the data, thus facilitating network streaming.
  *
  * To compile this program, start from the base directory from which you
- * are building FFmpeg and type:
+ * are building Libav and type:
  *  make tools/qt-faststart
  * The qt-faststart program will be built in the tools/ directory. If you
  * do not build the program in this manner, correct results are not
@@ -27,6 +27,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h>
+#include <string.h>
 
 #ifdef __MINGW32__
 #define fseeko(x,y,z)  fseeko64(x,y,z)
@@ -83,7 +84,7 @@ int main(int argc, char *argv[])
     uint64_t atom_offset = 0;
     uint64_t last_offset;
     unsigned char *moov_atom = NULL;
-    unsigned char *ftyp_atom = 0;
+    unsigned char *ftyp_atom = NULL;
     uint64_t moov_atom_size;
     uint64_t ftyp_atom_size = 0;
     uint64_t i, j;
@@ -98,6 +99,11 @@ int main(int argc, char *argv[])
         return 0;
     }
 
+    if (!strcmp(argv[1], argv[2])) {
+        fprintf(stderr, "input and output files need to be different\n");
+        return 1;
+    }
+
     infile = fopen(argv[1], "rb");
     if (!infile) {
         perror(argv[1]);
@@ -163,6 +169,12 @@ int main(int argc, char *argv[])
             break;
         }
         atom_offset += atom_size;
+
+        /* The atom header is 8 (or 16 bytes), if the atom size (which
+         * includes these 8 or 16 bytes) is less than that, we won't be
+         * able to continue scanning sensibly after this atom, so break. */
+        if (atom_size < 8)
+            break;
     }
 
     if (atom_type != MOOV_ATOM) {