Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
F
ffmpeg.wasm-core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ffmpeg.wasm-core
Commits
cd8d8457
Commit
cd8d8457
authored
Dec 30, 2011
by
Diego Biurrun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
qt-faststart: K&R reformatting; fix comment typos
parent
ae51b1a9
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
45 deletions
+45
-45
qt-faststart.c
tools/qt-faststart.c
+45
-45
No files found.
tools/qt-faststart.c
View file @
cd8d8457
...
...
@@ -30,15 +30,17 @@
#include <string.h>
#ifdef __MINGW32__
#define fseeko(x,
y,z) fseeko64(x,y,
z)
#define fseeko(x,
y, z) fseeko64(x, y,
z)
#define ftello(x) ftello64(x)
#endif
#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
(((uint8_t*)(x))[1] << 16) | \
(((uint8_t*)(x))[2] << 8) | \
((uint8_t*)(x))[3])
#define BE_64(x) (((uint64_t)(((uint8_t*)(x))[0]) << 56) | \
((uint64_t)(((uint8_t*)(x))[1]) << 48) | \
((uint64_t)(((uint8_t*)(x))[2]) << 40) | \
...
...
@@ -46,13 +48,13 @@
((uint64_t)(((uint8_t*)(x))[4]) << 24) | \
((uint64_t)(((uint8_t*)(x))[5]) << 16) | \
((uint64_t)(((uint8_t*)(x))[6]) << 8) | \
((uint64_t)((uint8_t*)(x))[7]))
((uint64_t)(
(uint8_t*)(x))[7]))
#define BE_FOURCC(
ch0, ch1, ch2, ch3 )
\
#define BE_FOURCC(
ch0, ch1, ch2, ch3)
\
( (uint32_t)(unsigned char)(ch3) | \
( (uint32_t)(unsigned char)(ch2) << 8
) | \
( (uint32_t)(unsigned char)(ch1) << 16 ) |
\
( (uint32_t)(unsigned char)(ch0) << 24
) )
((uint32_t)(unsigned char)(ch2) << 8
) | \
((uint32_t)(unsigned char)(ch1) << 16) |
\
((uint32_t)(unsigned char)(ch0) << 24
) )
#define QT_ATOM BE_FOURCC
/* top level atoms */
...
...
@@ -95,7 +97,7 @@ int main(int argc, char *argv[])
int
bytes_to_copy
;
if
(
argc
!=
3
)
{
printf
(
"Usage: qt-faststart <infile.mov> <outfile.mov>
\n
"
);
printf
(
"Usage: qt-faststart <infile.mov> <outfile.mov>
\n
"
);
return
0
;
}
...
...
@@ -116,7 +118,7 @@ int main(int argc, char *argv[])
if
(
fread
(
atom_bytes
,
ATOM_PREAMBLE_SIZE
,
1
,
infile
)
!=
1
)
{
break
;
}
atom_size
=
(
uint32_t
)
BE_32
(
&
atom_bytes
[
0
]);
atom_size
=
(
uint32_t
)
BE_32
(
&
atom_bytes
[
0
]);
atom_type
=
BE_32
(
&
atom_bytes
[
4
]);
/* keep ftyp atom */
...
...
@@ -125,7 +127,7 @@ int main(int argc, char *argv[])
free
(
ftyp_atom
);
ftyp_atom
=
malloc
(
ftyp_atom_size
);
if
(
!
ftyp_atom
)
{
printf
(
"could not allocate %"
PRIu64
" byte
for ftyp atom
\n
"
,
printf
(
"could not allocate %"
PRIu64
" bytes
for ftyp atom
\n
"
,
atom_size
);
goto
error_out
;
}
...
...
@@ -165,7 +167,7 @@ int main(int argc, char *argv[])
(
atom_type
!=
PICT_ATOM
)
&&
(
atom_type
!=
UUID_ATOM
)
&&
(
atom_type
!=
FTYP_ATOM
))
{
printf
(
"encountered non-QT top-level atom (is this a Quickt
ime file?)
\n
"
);
printf
(
"encountered non-QT top-level atom (is this a QuickT
ime file?)
\n
"
);
break
;
}
atom_offset
+=
atom_size
;
...
...
@@ -178,7 +180,7 @@ int main(int argc, char *argv[])
}
if
(
atom_type
!=
MOOV_ATOM
)
{
printf
(
"last atom in file was not a moov atom
\n
"
);
printf
(
"last atom in file was not a moov atom
\n
"
);
free
(
ftyp_atom
);
fclose
(
infile
);
return
0
;
...
...
@@ -191,8 +193,7 @@ int main(int argc, char *argv[])
moov_atom_size
=
atom_size
;
moov_atom
=
malloc
(
moov_atom_size
);
if
(
!
moov_atom
)
{
printf
(
"could not allocate %"
PRIu64
" byte for moov atom
\n
"
,
atom_size
);
printf
(
"could not allocate %"
PRIu64
" bytes for moov atom
\n
"
,
atom_size
);
goto
error_out
;
}
if
(
fread
(
moov_atom
,
atom_size
,
1
,
infile
)
!=
1
)
{
...
...
@@ -203,7 +204,7 @@ int main(int argc, char *argv[])
/* this utility does not support compressed atoms yet, so disqualify
* files with compressed QT atoms */
if
(
BE_32
(
&
moov_atom
[
12
])
==
CMOV_ATOM
)
{
printf
(
"this utility does not support compressed moov atoms yet
\n
"
);
printf
(
"this utility does not support compressed moov atoms yet
\n
"
);
goto
error_out
;
}
...
...
@@ -215,10 +216,10 @@ int main(int argc, char *argv[])
for
(
i
=
4
;
i
<
moov_atom_size
-
4
;
i
++
)
{
atom_type
=
BE_32
(
&
moov_atom
[
i
]);
if
(
atom_type
==
STCO_ATOM
)
{
printf
(
" patching stco atom...
\n
"
);
printf
(
" patching stco atom...
\n
"
);
atom_size
=
BE_32
(
&
moov_atom
[
i
-
4
]);
if
(
i
+
atom_size
-
4
>
moov_atom_size
)
{
printf
(
" bad atom size
\n
"
);
printf
(
" bad atom size
\n
"
);
goto
error_out
;
}
offset_count
=
BE_32
(
&
moov_atom
[
i
+
8
]);
...
...
@@ -232,10 +233,10 @@ int main(int argc, char *argv[])
}
i
+=
atom_size
-
4
;
}
else
if
(
atom_type
==
CO64_ATOM
)
{
printf
(
" patching co64 atom...
\n
"
);
printf
(
" patching co64 atom...
\n
"
);
atom_size
=
BE_32
(
&
moov_atom
[
i
-
4
]);
if
(
i
+
atom_size
-
4
>
moov_atom_size
)
{
printf
(
" bad atom size
\n
"
);
printf
(
" bad atom size
\n
"
);
goto
error_out
;
}
offset_count
=
BE_32
(
&
moov_atom
[
i
+
8
]);
...
...
@@ -275,7 +276,7 @@ int main(int argc, char *argv[])
/* dump the same ftyp atom */
if
(
ftyp_atom_size
>
0
)
{
printf
(
" writing ftyp atom...
\n
"
);
printf
(
" writing ftyp atom...
\n
"
);
if
(
fwrite
(
ftyp_atom
,
ftyp_atom_size
,
1
,
outfile
)
!=
1
)
{
perror
(
argv
[
2
]);
goto
error_out
;
...
...
@@ -283,14 +284,14 @@ int main(int argc, char *argv[])
}
/* dump the new moov atom */
printf
(
" writing moov atom...
\n
"
);
printf
(
" writing moov atom...
\n
"
);
if
(
fwrite
(
moov_atom
,
moov_atom_size
,
1
,
outfile
)
!=
1
)
{
perror
(
argv
[
2
]);
goto
error_out
;
}
/* copy the remainder of the infile, from offset 0 -> last_offset - 1 */
printf
(
" copying rest of file...
\n
"
);
printf
(
" copying rest of file...
\n
"
);
while
(
last_offset
)
{
if
(
last_offset
>
COPY_BUFFER_SIZE
)
bytes_to_copy
=
COPY_BUFFER_SIZE
;
...
...
@@ -305,7 +306,6 @@ int main(int argc, char *argv[])
perror
(
argv
[
2
]);
goto
error_out
;
}
last_offset
-=
bytes_to_copy
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment