diff --git a/atom.cpp b/atom.cpp index 0ca8b97e..275f2dac 100644 --- a/atom.cpp +++ b/atom.cpp @@ -1,13 +1,9 @@ #include "AP_AtomDefinitions.h" #include "atom.h" -#include "file.h" -#include #include #include - -#include -#include +#include using namespace std; diff --git a/atom.h b/atom.h index 0ea7bb5c..304d64c5 100644 --- a/atom.h +++ b/atom.h @@ -1,12 +1,12 @@ #ifndef ATOM_H #define ATOM_H -extern "C" { - #include -} + #include #include +#include #include "file.h" + class Atom { public: int64_t start; //including 8 header bytes diff --git a/file.cpp b/file.cpp index 3b4310ea..8fd4d36c 100644 --- a/file.cpp +++ b/file.cpp @@ -19,8 +19,7 @@ */ #include "file.h" -#include -#include +#include "endian.h" using namespace std; diff --git a/file.h b/file.h index edf1a3aa..087e65aa 100644 --- a/file.h +++ b/file.h @@ -21,12 +21,10 @@ #ifndef FILE_H #define FILE_H -extern "C" { - #include -} -#include #include #include +#include +#include uint16_t swap16(uint16_t us); uint32_t swap32(uint32_t ui); diff --git a/mp4.cpp b/mp4.cpp index 42b7af0e..3ec2ebff 100644 --- a/mp4.cpp +++ b/mp4.cpp @@ -18,14 +18,22 @@ */ -#include -#include #include +#include + +#ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS 1 +#endif +#ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS 1 +#endif +#include +#ifndef INT64_C +# define INT64_C(c) (c ## LL) +# define UINT64_C(c) (c ## ULL) +#endif -#define __STDC_LIMIT_MACROS 1 -#define __STDC_CONSTANT_MACROS 1 extern "C" { -#include #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" } diff --git a/mp4.h b/mp4.h index 0c9ee1a6..252f5a0f 100644 --- a/mp4.h +++ b/mp4.h @@ -23,9 +23,9 @@ #include #include -#include #include "track.h" + class Atom; class File; class AVFormatContext; diff --git a/track.cpp b/track.cpp index ebdba20e..3bf08e46 100644 --- a/track.cpp +++ b/track.cpp @@ -18,51 +18,48 @@ */ -#include "track.h" -#include "atom.h" - #include -#include -#include -#include -#include +#include -#define __STDC_LIMIT_MACROS 1 -#define __STDC_CONSTANT_MACROS 1 - -extern "C" { +#ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS 1 +#endif +#ifndef __STDC_CONSTANT_MACROS +# define __STDC_CONSTANT_MACROS 1 +#endif +#include #ifndef INT64_C -#define INT64_C(c) (c ## LL) -#define UINT64_C(c) (c ## ULL) +# define INT64_C(c) (c ## LL) +# define UINT64_C(c) (c ## ULL) #endif +#include // Define C11 bool used in internal header included below. -#include +extern "C" { #include #include -#include -//Horrible hack: there is a variabled named 'new' and 'class' inside! -#if LIBAVCODEC_VERSION_MAJOR != 56 //ubuntu 16.04 version -#include -#undef restrict -//#define restrict __restrict__ +// WARNING: Including internal header! +#if LIBAVCODEC_VERSION_MAJOR != 56 // Ubuntu 16.04 version. +# include +#endif +// XXX Horrible Hack: Suppress C99 keywords that are not in C++, like 'restrict' and '_Atomic'! XXX +#undef restrict // Harmless; don't restrict memory access. #define restrict -#define new extern_new -#define class extern_class +#undef _Atomic // Atomics are only included in headers, but never actually used in our code. +#define _Atomic +// XXX Horrible Hack: There are variables named 'new' and 'class' inside! XXX +#define new extern_new +#define class extern_class #include -#undef new #undef class +#undef new +#undef _Atomic #undef restrict +} -#else -define new extern_new -#define class extern_class -#include -#undef new -#undef class -#endif +#include "track.h" +#include "atom.h" -} using namespace std;