]> git.sesse.net Git - x264/commitdiff
move os/compiler specific defines to their own header
authorLoren Merritt <pengvado@videolan.org>
Tue, 17 Jul 2007 11:11:19 +0000 (11:11 +0000)
committerLoren Merritt <pengvado@videolan.org>
Tue, 17 Jul 2007 11:11:19 +0000 (11:11 +0000)
git-svn-id: svn://svn.videolan.org/x264/trunk@666 df754926-b1dd-0310-bc7b-ec298dee348c

27 files changed:
common/cabac.c
common/common.c
common/common.h
common/cpu.c
common/csp.c
common/frame.c
common/macroblock.c
common/mc.c
common/mdate.c
common/osdep.h [new file with mode: 0644]
common/pixel.c
common/set.c
common/visualize.c
encoder/analyse.c
encoder/cabac.c
encoder/cavlc.c
encoder/encoder.c
encoder/macroblock.c
encoder/me.c
encoder/ratecontrol.c
encoder/set.c
encoder/slicetype.c
matroska.c
muxers.c
muxers.h
tools/checkasm.c
x264.c

index 2996d33c9057767cb4c6cd824c99185ed15d0f06..695b411de3862eef4e553c7dbc382d9b4fc2b3c3 100644 (file)
@@ -21,9 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <string.h>
-#include <stdio.h>
-
 #include "common.h"
 
 
index e771dc07fcf7b8aebba5837bb022a16abbe14b94..f699d1288ef36fa65101e6062bbcf99b7a526681 100644 (file)
@@ -21,8 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
 #include <stdarg.h>
 
 #ifdef HAVE_MALLOC_H
index 0b8f8f79e7f720ef4de2d811029ed60635f6b228..7e147ef5ecc4203534b453aa4111c2153e5b33ae 100644 (file)
 #ifndef _COMMON_H
 #define _COMMON_H 1
 
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#else
-#include <inttypes.h>
-#endif
-#include <stdarg.h>
-#include <stdlib.h>
-#include <assert.h>
-
-#ifdef _MSC_VER
-#define inline __inline
-#define strncasecmp(s1, s2, n) strnicmp(s1, s2, n)
-#define snprintf _snprintf
-#define X264_VERSION "" // no configure script for msvc
-#endif
-
-#ifdef _MSC_VER
-#define DECLARE_ALIGNED( type, var, n ) __declspec(align(n)) type var
-#else
-#define DECLARE_ALIGNED( type, var, n ) type var __attribute__((aligned(n)))
-#endif
-
-/* threads */
-#if defined(__WIN32__) && defined(HAVE_PTHREAD)
-#include <pthread.h>
-#define USE_CONDITION_VAR
-
-#elif defined(SYS_BEOS)
-#include <kernel/OS.h>
-#define pthread_t               thread_id
-#define pthread_create(t,u,f,d) { *(t)=spawn_thread(f,"",10,d); \
-                                  resume_thread(*(t)); }
-#define pthread_join(t,s)       { long tmp; \
-                                  wait_for_thread(t,(s)?(long*)(s):&tmp); }
-#ifndef usleep
-#define usleep(t)               snooze(t)
-#endif
-#define HAVE_PTHREAD 1
-
-#elif defined(HAVE_PTHREAD)
-#include <pthread.h>
-#define USE_CONDITION_VAR
-#else
-#define pthread_t               int
-#define pthread_create(t,u,f,d)
-#define pthread_join(t,s)
-#endif //SYS_*
-
-#ifndef USE_CONDITION_VAR
-#define pthread_mutex_t         int
-#define pthread_mutex_init(m,f)
-#define pthread_mutex_destroy(m)
-#define pthread_mutex_lock(m)
-#define pthread_mutex_unlock(m)
-#define pthread_cond_t          int
-#define pthread_cond_init(c,f)
-#define pthread_cond_destroy(c)
-#define pthread_cond_broadcast(c)
-#define pthread_cond_wait(c,m)  usleep(100)
-#endif
-
 /****************************************************************************
  * Macros
  ****************************************************************************/
 #define offsetof(T,F) ((unsigned int)((char *)&((T *)0)->F))
 #endif
 
-#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
-#define UNUSED __attribute__((unused))
-#else
-#define UNUSED
-#endif
-
 #define CHECKED_MALLOC( var, size )\
 {\
     var = x264_malloc( size );\
 /****************************************************************************
  * Includes
  ****************************************************************************/
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include "osdep.h"
 #include "x264.h"
 #include "bs.h"
 #include "set.h"
index 1668a6fae57fbf4e3e2ff2b36f98026a0f870b8e..45484b83526143ae7307e7e9cbe4a7c4918fe374 100644 (file)
@@ -33,8 +33,6 @@
 #include <sys/sysctl.h>
 #endif
 
-#include <string.h>
-
 #include "common.h"
 
 #ifdef HAVE_MMX
index baf6de001aa3f0121a479b392e96d45bf7740849..6813291142f16c4d4cc67e2e4fa1fc2a7a61d3fb 100644 (file)
@@ -21,9 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-
 #include "common.h"
 
 static inline void plane_copy_vflip( x264_mc_functions_t *mc,
index 99529d0ae2a20352556bf3060e897c59bf40f95f..f16fe17d988fb0f21920824447d6a438b8c0d28a 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif
-
 #include "common.h"
 
 #define PADH 32
index 3ecda66c05e25dd5b3b1007598441bd1d8067b4e..6bd2c83b0bff462f53eefc4502892dda56bad42c 100644 (file)
@@ -21,9 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-
 #include "common.h"
 
 int x264_mb_predict_intra4x4_mode( x264_t *h, int idx )
index 9a498caa838981544729b396a17282708831704c..6d3a226b62ce12a8d261fba89ccef29ef495958f 100644 (file)
@@ -21,9 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-
 #include "common.h"
 #include "clip1.h"
 
index c57becbd9ace027ca517dd7c1de6cb58ea0cd196..a856ac1028e5f02e151a5a8948161e308508559d 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#else
-#include <inttypes.h>
-#endif
-
 #if !(defined(_MSC_VER) || defined(__MINGW32__))
 #include <sys/time.h>
 #else
@@ -35,6 +29,8 @@
 #endif
 #include <time.h>
 
+#include "osdep.h"
+
 int64_t x264_mdate( void )
 {
 #if !(defined(_MSC_VER) || defined(__MINGW32__))
diff --git a/common/osdep.h b/common/osdep.h
new file mode 100644 (file)
index 0000000..7edfa5c
--- /dev/null
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * common.h: h264 encoder
+ *****************************************************************************
+ * Copyright (C) 2007 x264 project
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
+ *****************************************************************************/
+
+#ifndef _OSDEP_H
+#define _OSDEP_H
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#else
+#include <inttypes.h>
+#endif
+
+#define _LARGEFILE_SOURCE 1
+#define _FILE_OFFSET_BITS 64
+#include <stdio.h>
+
+#ifdef _MSC_VER
+#include <io.h>    // _setmode()
+#include <fcntl.h> // _O_BINARY
+#define inline __inline
+#define strncasecmp strnicmp
+#define snprintf _snprintf
+#define fseek _fseeki64
+#define ftell _ftelli64
+#define isfinite _finite
+#define _CRT_SECURE_NO_DEPRECATE
+#define X264_VERSION "" // no configure script for msvc
+#endif
+
+#ifdef SYS_OPENBSD
+#define isfinite finite
+#endif
+#if defined(_MSC_VER) || defined(SYS_SunOS) || defined(SYS_MACOSX)
+#define sqrtf sqrt
+#endif
+#ifdef __WIN32__ // POSIX says that rename() removes the destination, but win32 doesn't.
+#define rename(src,dst) (unlink(dst), rename(src,dst))
+#endif
+
+#ifdef _MSC_VER
+#define DECLARE_ALIGNED( type, var, n ) __declspec(align(n)) type var
+#else
+#define DECLARE_ALIGNED( type, var, n ) type var __attribute__((aligned(n)))
+#endif
+
+#if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0)
+#define UNUSED __attribute__((unused))
+#else
+#define UNUSED
+#endif
+
+/* threads */
+#if defined(__WIN32__) && defined(HAVE_PTHREAD)
+#include <pthread.h>
+#define USE_CONDITION_VAR
+
+#elif defined(SYS_BEOS)
+#include <kernel/OS.h>
+#define pthread_t               thread_id
+#define pthread_create(t,u,f,d) { *(t)=spawn_thread(f,"",10,d); \
+                                  resume_thread(*(t)); }
+#define pthread_join(t,s)       { long tmp; \
+                                  wait_for_thread(t,(s)?(long*)(s):&tmp); }
+#ifndef usleep
+#define usleep(t)               snooze(t)
+#endif
+#define HAVE_PTHREAD 1
+
+#elif defined(HAVE_PTHREAD)
+#include <pthread.h>
+#define USE_CONDITION_VAR
+#else
+#define pthread_t               int
+#define pthread_create(t,u,f,d)
+#define pthread_join(t,s)
+#endif //SYS_*
+
+#ifndef USE_CONDITION_VAR
+#define pthread_mutex_t         int
+#define pthread_mutex_init(m,f)
+#define pthread_mutex_destroy(m)
+#define pthread_mutex_lock(m)
+#define pthread_mutex_unlock(m)
+#define pthread_cond_t          int
+#define pthread_cond_init(c,f)
+#define pthread_cond_destroy(c)
+#define pthread_cond_broadcast(c)
+#define pthread_cond_wait(c,m)  usleep(100)
+#endif
+
+#endif //_OSDEP_H
index 1ccfb6e85f9e8bc37fcdfe2334e4858fe606d8a3..39fb210eef3ef73d2aec319ee308594ad9317c9d 100644 (file)
@@ -21,8 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <string.h>
-
 #include "common.h"
 #include "clip1.h"
 
index 8a6886f7926614a5de761dd51d620a025fb9d91d..e49de9b0d47b02d42b538c18010934d871a88eb3 100644 (file)
@@ -21,8 +21,6 @@
  *****************************************************************************/
 
 #include "common.h"
-#include <stdio.h>
-#include <string.h>
 
 #define SHIFT(x,s) ((s)<0 ? (x)<<-(s) : (s)==0 ? (x) : ((x)+(1<<((s)-1)))>>(s))
 #define DIV(n,d) (((n) + ((d)>>1)) / (d))
index 8bd02d865f45ec19427a2f3f69da9614a9579f44..a5f90290ef78db064d82699989f19d20b9abcb04 100644 (file)
  * pink blocks with a diagonal line are predicted using the planar function.
  */
 
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#else
-#include <inttypes.h>
-#endif
-#include <stddef.h>                 /* NULL */
-#include <stdio.h>                  /* getchar */
-
 #include "common.h"
 #include "visualize.h"
 #include "display.h"
index b4795638490f84df054020cb7de0f3db3d933204..1e1db9ea34c4a31671737a33d2d56c52947b6dda 100644 (file)
@@ -22,8 +22,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
 #include <math.h>
 #include <limits.h>
 #ifndef _MSC_VER
index dc7f6596f67d3d319d9c0440514e5b347e4401f2..f5ece2bc5e6bbcbec3f87e8502da3aadebc6d56c 100644 (file)
@@ -21,9 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-
 #include "common/common.h"
 #include "macroblock.h"
 
index 52aec2813574871dd9ad9d1585a0a379603e8e53..6ac15b191b401b6165f597905b9ae8533c67cce2 100644 (file)
@@ -21,9 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-
 #include "common/common.h"
 #include "common/vlc.h"
 #include "macroblock.h"
index 8917ae1ac6af79aae3696ccfaef718842b5e7dcb..a48ed1e7e70683f9249c13d5ac3f6f60cad77e7f 100644 (file)
@@ -21,8 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
 #include <math.h>
 
 #include "common/common.h"
index ec7e9b8018222cf995c1f6d80a388ab1069b91e6..c0967fe0d91b7c8bb660e59d2c28d8dcd5eb8c60 100644 (file)
@@ -21,9 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-
 #include "common/common.h"
 #include "macroblock.h"
 
index ffd18140398e7d55b393ecdd692bf9bd4236c0d9..eb9d124603ad50385fa3de14a87422d1b53f2a56 100644 (file)
@@ -22,9 +22,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
-
 #include "common/common.h"
 #include "me.h"
 
index 9b92dbeb55f41d5179254dd44126ded6025a8c90..20425a7725da0b12a895ca5a48f11ec182afeb8f 100644 (file)
@@ -25,8 +25,6 @@
 
 #define _ISOC99_SOURCE
 #undef NDEBUG // always check asserts, the speed effect is far too small to disable them
-#include <stdio.h>
-#include <string.h>
 #include <math.h>
 #include <limits.h>
 #include <assert.h>
 #include "common/cpu.h"
 #include "ratecontrol.h"
 
-#if defined(SYS_OPENBSD)
-#define isfinite finite
-#endif
-#if defined(_MSC_VER)
-#define isfinite _finite
-#endif
-#if defined(_MSC_VER) || defined(SYS_SunOS) || defined(SYS_MACOSX)
-#define sqrtf sqrt
-#endif
-#ifdef WIN32 // POSIX says that rename() removes the destination, but win32 doesn't.
-#define rename(src,dst) (unlink(dst), rename(src,dst))
-#endif
-
 typedef struct
 {
     int pict_type;
index 200840b5cda5eb2eb12d967d2aefed0ae5b99bbc..04fe82613b237120a3cbb6a102a6907e50179e5a 100644 (file)
@@ -21,8 +21,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <stdio.h>
-#include <string.h>
 #include <math.h>
 
 #include "common/common.h"
index d3e1194ee9190a4f8213e42754296b6ac4bdab6a..bfe44e579b678165204232a7251805c718d0e0ea 100644 (file)
@@ -20,7 +20,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#include <string.h>
 #include <math.h>
 #include <limits.h>
 
index fb7e4d0ca893e95f943e814639dc8127bcc01abf..917acebc1e85c2bdf4688b073aeecb7ce02dfeb9 100644 (file)
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define _LARGEFILE_SOURCE
-#define _FILE_OFFSET_BITS 64
-
-#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-
-#ifdef HAVE_STDINT_H
-#include <stdint.h>
-#else
-#include <inttypes.h>
-#endif
-
+#include "common/osdep.h"
 #include "matroska.h"
 
 #define        CLSIZE    1048576
index 6a7f76e220da4dfc30776d32fbfe1e692f4fde32..46315367a2c757ee6b3d65368bb66b1f1e25f186 100644 (file)
--- a/muxers.c
+++ b/muxers.c
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define _LARGEFILE_SOURCE
-#define _FILE_OFFSET_BITS 64
-
-#include <stdio.h>
-#include <string.h>
 #include <sys/types.h>
 
 #include "common/common.h"
@@ -257,7 +252,7 @@ int get_frame_total_y4m( hnd_t handle )
 {
     y4m_input_t *h             = handle;
     int          i_frame_total = 0;
-    off_t        init_pos      = ftell(h->fh);
+    uint64_t     init_pos      = ftell(h->fh);
 
     if( !fseek( h->fh, 0, SEEK_END ) )
     {
index 7ce84afb9181443e933b95abf00bf2219ea05266..eef40cd457be6a54f18e18417747bcaecd730e40 100644 (file)
--- a/muxers.h
+++ b/muxers.h
@@ -13,19 +13,15 @@ int get_frame_total_y4m( hnd_t handle );
 int read_frame_y4m( x264_picture_t *p_pic, hnd_t handle, int i_frame );
 int close_file_y4m( hnd_t handle );
 
-#ifdef AVIS_INPUT
 int open_file_avis( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param );
 int get_frame_total_avis( hnd_t handle );
 int read_frame_avis( x264_picture_t *p_pic, hnd_t handle, int i_frame );
 int close_file_avis( hnd_t handle );
-#endif
 
-#ifdef HAVE_PTHREAD
 int open_file_thread( char *psz_filename, hnd_t *p_handle, x264_param_t *p_param );
 int get_frame_total_thread( hnd_t handle );
 int read_frame_thread( x264_picture_t *p_pic, hnd_t handle, int i_frame );
 int close_file_thread( hnd_t handle );
-#endif
 
 int open_file_bsf( char *psz_filename, hnd_t *p_handle );
 int set_param_bsf( hnd_t handle, x264_param_t *p_param );
@@ -33,13 +29,11 @@ int write_nalu_bsf( hnd_t handle, uint8_t *p_nal, int i_size );
 int set_eop_bsf( hnd_t handle,  x264_picture_t *p_picture );
 int close_file_bsf( hnd_t handle );
 
-#ifdef MP4_OUTPUT
 int open_file_mp4( char *psz_filename, hnd_t *p_handle );
 int set_param_mp4( hnd_t handle, x264_param_t *p_param );
 int write_nalu_mp4( hnd_t handle, uint8_t *p_nal, int i_size );
 int set_eop_mp4( hnd_t handle, x264_picture_t *p_picture );
 int close_file_mp4( hnd_t handle );
-#endif
 
 int open_file_mkv( char *psz_filename, hnd_t *p_handle );
 int set_param_mkv( hnd_t handle, x264_param_t *p_param );
index 8e77fbb76ca40233d297fefc17ed3bf0746b4588..07c9210f39077ec2e9869a1303d09ac8d3826d3c 100644 (file)
@@ -1,6 +1,4 @@
-#include <stdio.h>
 #include <stdlib.h>
-#include <string.h>
 #include <math.h>
 
 #include "common/common.h"
diff --git a/x264.c b/x264.c
index d864b513d030e62ca32a15f684aad8c0747cf819..73877c9abf07a2219fca3f8dc16a1998dc33a938 100644 (file)
--- a/x264.c
+++ b/x264.c
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define _LARGEFILE_SOURCE
-#define _FILE_OFFSET_BITS 64
-
 #include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
 #include <math.h>
 
 #include <signal.h>
 #define _GNU_SOURCE
 #include <getopt.h>
 
-#ifdef _MSC_VER
-#include <io.h>     /* _setmode() */
-#include <fcntl.h>  /* _O_BINARY */
-#endif
+#include "common/common.h"
+#include "x264.h"
+#include "muxers.h"
 
 #ifndef _MSC_VER
 #include "config.h"
 #endif
 
-#include "common/common.h"
-#include "x264.h"
-#include "muxers.h"
-
 uint8_t *mux_buffer = NULL;
 int mux_buffer_size = 0;