Commit a01315f4 authored by Laurent Aimar's avatar Laurent Aimar

* all: introduced a x264_log function. It's not yet used everywhere

 but we should start using it :)


git-svn-id: svn://svn.videolan.org/x264/trunk@32 df754926-b1dd-0310-bc7b-ec298dee348c
parent 5ffe5a90
......@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#ifdef HAVE_MALLOC_H
#include <malloc.h>
......@@ -32,6 +33,8 @@
#include "common.h"
#include "cpu.h"
static void x264_log_default( void *, int, const char *, va_list );
/****************************************************************************
* x264_param_default:
****************************************************************************/
......@@ -42,14 +45,6 @@ void x264_param_default( x264_param_t *param )
/* 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;
......@@ -85,10 +80,55 @@ void x264_param_default( x264_param_t *param )
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:
****************************************************************************/
......
......@@ -29,6 +29,7 @@
#else
#include <inttypes.h>
#endif
#include <stdarg.h>
#include "../x264.h"
#include "bs.h"
......@@ -41,10 +42,16 @@
#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
......@@ -56,6 +63,9 @@ void x264_free( void * );
/* 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 )
......@@ -72,6 +82,10 @@ static inline int x264_clip3( int v, int i_min, int i_max )
}
}
/****************************************************************************
*
****************************************************************************/
enum slice_type_e
{
SLICE_TYPE_P = 0,
......
......@@ -28,6 +28,7 @@
#endif
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "../x264.h"
#include "cpu.h"
......
......@@ -27,6 +27,7 @@
#include <inttypes.h>
#endif
#include <stdlib.h>
#include <stdarg.h>
#include "x264.h"
......
......@@ -27,6 +27,7 @@
#include <inttypes.h>
#endif
#include <stdlib.h>
#include <stdarg.h>
#include "x264.h"
......
......@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "x264.h" /* DECLARE_ALIGNED */
#include "../mc.h"
......
......@@ -30,6 +30,7 @@
#include <inttypes.h>
#endif
#include <stdlib.h>
#include <stdarg.h>
#include "x264.h" /* for keyword inline */
#include "../predict.h"
......
......@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "../x264.h"
......
......@@ -28,6 +28,7 @@
#endif
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "../x264.h"
#include "pixel.h"
......
......@@ -30,6 +30,7 @@
#include <inttypes.h>
#endif
#include <stdlib.h>
#include <stdarg.h>
#include "x264.h"
#include "predict.h"
......
......@@ -437,6 +437,15 @@ x264_t *x264_encoder_open ( x264_param_t *param )
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;
}
......
......@@ -29,6 +29,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include "../x264.h"
#include "../core/bs.h"
......
......@@ -71,6 +71,14 @@ typedef struct x264_t x264_t;
#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 */
......@@ -117,6 +125,11 @@ typedef struct
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
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment