* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <string.h>
-#include <stdio.h>
-
#include "common.h"
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
#include <stdarg.h>
#ifdef HAVE_MALLOC_H
#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"
#include <sys/sysctl.h>
#endif
-#include <string.h>
-
#include "common.h"
#ifdef HAVE_MMX
* 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,
* 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
* 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 )
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-
#include "common.h"
#include "clip1.h"
* 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
#endif
#include <time.h>
+#include "osdep.h"
+
int64_t x264_mdate( void )
{
#if !(defined(_MSC_VER) || defined(__MINGW32__))
--- /dev/null
+/*****************************************************************************
+ * 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <string.h>
-
#include "common.h"
#include "clip1.h"
*****************************************************************************/
#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))
* 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"
* 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
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-
#include "common/common.h"
#include "macroblock.h"
* 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"
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
#include <math.h>
#include "common/common.h"
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-
#include "common/common.h"
#include "macroblock.h"
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
-
#include "common/common.h"
#include "me.h"
#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;
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <stdio.h>
-#include <string.h>
#include <math.h>
#include "common/common.h"
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
-#include <string.h>
#include <math.h>
#include <limits.h>
* 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
* 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"
{
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 ) )
{
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 );
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 );
-#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <math.h>
#include "common/common.h"
* 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;