[Ffmpeg-cvslog] CVS: ffmpeg qt-faststart.c,1.4,1.5

Baptiste Coudurier CVS bcoudurier
Thu Mar 16 17:37:07 CET 2006


Update of /cvsroot/ffmpeg/ffmpeg
In directory mail:/var2/tmp/cvs-serv26496

Modified Files:
	qt-faststart.c 
Log Message:
keep ftyp first

Index: qt-faststart.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/qt-faststart.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- qt-faststart.c	16 Mar 2006 00:20:58 -0000	1.4
+++ qt-faststart.c	16 Mar 2006 16:37:05 -0000	1.5
@@ -72,10 +72,13 @@
     uint64_t atom_size = 0;
     uint64_t last_offset;
     unsigned char *moov_atom;
+    unsigned char *ftyp_atom = 0;
     uint64_t moov_atom_size;
+    uint64_t ftyp_atom_size = 0;
     uint64_t i, j;
     uint32_t offset_count;
     uint64_t current_offset;
+    uint64_t start_offset = 0;
     unsigned char copy_buffer[COPY_BUFFER_SIZE];
     int bytes_to_copy;
 
@@ -112,6 +115,27 @@
             break;
         }
 
+        /* keep ftyp atom */
+        if (atom_type == FTYP_ATOM) {
+            ftyp_atom_size = atom_size;
+            ftyp_atom = malloc(ftyp_atom_size);
+            if (!ftyp_atom) {
+                printf ("could not allocate 0x%llX byte for ftyp atom\n",
+                        atom_size);
+                fclose(infile);
+                return 1;
+            }
+            fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
+            if (fread(ftyp_atom, atom_size, 1, infile) != 1) {
+                perror(argv[1]);
+                free(ftyp_atom);
+                fclose(infile);
+                return 1;
+            }
+            start_offset = ftello(infile);
+            continue;
+        }
+
         /* 64-bit special case */
         if (atom_size == 1) {
             if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
@@ -214,6 +238,9 @@
         free(moov_atom);
         return 1;
     }
+    /* seek after ftyp atom if needed */
+    fseeko(infile, start_offset, SEEK_SET);
+
     outfile = fopen(argv[2], "wb");
     if (!outfile) {
         perror(argv[2]);
@@ -222,6 +249,15 @@
         return 1;
     }
 
+    /* dump the same ftyp atom */
+    if (ftyp_atom_size > 0) {
+        printf (" writing ftyp atom...\n");
+        if (fwrite(ftyp_atom, ftyp_atom_size, 1, outfile) != 1) {
+            perror(argv[2]);
+            goto error_out;
+        }
+    }
+
     /* dump the new moov atom */
     printf (" writing moov atom...\n");
     if (fwrite(moov_atom, moov_atom_size, 1, outfile) != 1) {





More information about the ffmpeg-cvslog mailing list