#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <stdarg.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#include "common.h"
#include "cpu.h"
+static void x264_log_default( void *, int, const char *, va_list );
+
/****************************************************************************
* x264_param_default:
****************************************************************************/
/* CPU autodetect */
param->cpu = x264_cpu_detect();
- fprintf( stderr, "x264: cpu capabilities: %s%s%s%s%s%s\n",
- param->cpu&X264_CPU_MMX ? "MMX " : "",
- param->cpu&X264_CPU_MMXEXT ? "MMXEXT " : "",
- param->cpu&X264_CPU_SSE ? "SSE " : "",
- param->cpu&X264_CPU_SSE2 ? "SSE2 " : "",
- param->cpu&X264_CPU_3DNOW ? "3DNow! " : "",
- param->cpu&X264_CPU_ALTIVEC ? "Altivec " : "" );
-
/* Video properties */
param->i_csp = X264_CSP_I420;
param->f_ip_factor = 2.0;
param->f_pb_factor = 2.0;
+ /* Log */
+ param->pf_log = x264_log_default;
+ param->p_log_private = NULL;
+ param->i_log_level = X264_LOG_INFO;
+
+ /* */
param->analyse.intra = X264_ANALYSE_I4x4;
param->analyse.inter = X264_ANALYSE_I4x4 | X264_ANALYSE_PSUB16x16;
}
+/****************************************************************************
+ * x264_log:
+ ****************************************************************************/
+void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... )
+{
+ if( i_level <= h->param.i_log_level )
+ {
+ va_list arg;
+ va_start( arg, psz_fmt );
+ h->param.pf_log( h->param.p_log_private, i_level, psz_fmt, arg );
+ va_end( arg );
+ }
+}
+
+static void x264_log_default( void *p_unused, int i_level, const char *psz_fmt, va_list arg )
+{
+ char *psz_prefix;
+ switch( i_level )
+ {
+ case X264_LOG_ERROR:
+ psz_prefix = "error";
+ break;
+ case X264_LOG_WARNING:
+ psz_prefix = "warning";
+ break;
+ case X264_LOG_INFO:
+ psz_prefix = "info";
+ break;
+ case X264_LOG_DEBUG:
+ psz_prefix = "debug";
+ break;
+ default:
+ psz_prefix = "unknown";
+ break;
+ }
+ fprintf( stderr, "x264 [%s]: ", psz_prefix );
+ vfprintf( stderr, psz_fmt, arg );
+}
+
/****************************************************************************
* x264_picture_alloc:
****************************************************************************/
#else
#include <inttypes.h>
#endif
+#include <stdarg.h>
#include "../x264.h"
#include "bs.h"
#include "cabac.h"
#include "csp.h"
+/****************************************************************************
+ * Macros
+ ****************************************************************************/
#define X264_MIN(a,b) ( (a)<(b) ? (a) : (b) )
#define X264_MAX(a,b) ( (a)>(b) ? (a) : (b) )
#define X264_ABS(a) ( (a)< 0 ? -(a) : (a) )
+/****************************************************************************
+ * Generals functions
+ ****************************************************************************/
/* x264_malloc : will do or emulate a memalign
* XXX you HAVE TO use x264_free for buffer allocated
* with x264_malloc
/* mdate: return the current date in microsecond */
int64_t x264_mdate( void );
+/* log */
+void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... );
+
static inline int x264_clip3( int v, int i_min, int i_max )
{
if( v < i_min )
}
}
+
+/****************************************************************************
+ *
+ ****************************************************************************/
enum slice_type_e
{
SLICE_TYPE_P = 0,
h->stat.i_mb_count[SLICE_TYPE_P][i] = 0;
h->stat.i_mb_count[SLICE_TYPE_B][i] = 0;
}
+
+ x264_log( h, X264_LOG_INFO, "using cpu capabilities %s%s%s%s%s%s\n",
+ param->cpu&X264_CPU_MMX ? "MMX " : "",
+ param->cpu&X264_CPU_MMXEXT ? "MMXEXT " : "",
+ param->cpu&X264_CPU_SSE ? "SSE " : "",
+ param->cpu&X264_CPU_SSE2 ? "SSE2 " : "",
+ param->cpu&X264_CPU_3DNOW ? "3DNow! " : "",
+ param->cpu&X264_CPU_ALTIVEC ? "Altivec " : "" );
+
return h;
}
#define X264_TYPE_P 0x0003
#define X264_TYPE_B 0x0004
+/* Log level
+ */
+#define X264_LOG_NONE (-1)
+#define X264_LOG_ERROR 0
+#define X264_LOG_WARNING 1
+#define X264_LOG_INFO 2
+#define X264_LOG_DEBUG 3
+
typedef struct
{
/* CPU flags */
float f_ip_factor;
float f_pb_factor;
+ /* Log */
+ void (*pf_log)( void *, int i_level, const char *psz, va_list );
+ void *p_log_private;
+ int i_log_level;
+
/* Encoder analyser parameters */
struct
{