]> granicus.if.org Git - libx264/commitdiff
* all: introduced a x264_log function. It's not yet used everywhere
authorLaurent Aimar <fenrir@videolan.org>
Tue, 17 Aug 2004 19:56:36 +0000 (19:56 +0000)
committerLaurent Aimar <fenrir@videolan.org>
Tue, 17 Aug 2004 19:56:36 +0000 (19:56 +0000)
 but we should start using it :)

git-svn-id: svn://svn.videolan.org/x264/trunk@32 df754926-b1dd-0310-bc7b-ec298dee348c

13 files changed:
core/common.c
core/common.h
core/cpu.c
core/dct.c
core/i386/dct-c.c
core/i386/mc-c.c
core/i386/predict.c
core/mc.c
core/pixel.c
core/predict.c
encoder/encoder.c
encoder/set.c
x264.h

index 61a78306e4360ee6ecc014b52713dc14b5564394..b69db9b9a9db3c7eba270837f02f4df4f76e0fce 100644 (file)
@@ -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:
  ****************************************************************************/
index 65ae4b458dcb1c504d176e3fc92fd762c4da7476..ec9ab22784157765407b5036f970b84388a7a978 100644 (file)
@@ -29,6 +29,7 @@
 #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
@@ -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,
index 5cce5db0f5b6bdd2f86d50951a0162f36805bd14..a39c42712ad771ab8c16626c24ad3c5b6864e9ce 100644 (file)
@@ -28,6 +28,7 @@
 #endif
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include "../x264.h"
 #include "cpu.h"
index da018287a113b20d11a3e47d3fa03814639d8f26..c8a0c8fae3ddc6a9e35e49111cbdff34a23e4fbd 100644 (file)
@@ -27,6 +27,7 @@
 #include <inttypes.h>
 #endif
 #include <stdlib.h>
+#include <stdarg.h>
 
 #include "x264.h"
 
index 368603e0d04b29a36b90564b24ec0c8c44933724..adba948021bfa2d15f312a7f57dedfa80f392ea6 100644 (file)
@@ -27,6 +27,7 @@
 #include <inttypes.h>
 #endif
 #include <stdlib.h>
+#include <stdarg.h>
 
 #include "x264.h"
 
index 08207c177b8c1ca64fd95fdf5148cc2e8ef28088..e2e9251b5f56ab54cf0612f2c405ded6b6e5a503 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include "x264.h"   /* DECLARE_ALIGNED */
 #include "../mc.h"
index ef1a027d8b46ce8a1dc49f33e7eadf889fcff9fb..febb4a2e2769812b751a5a38e0fa173f29a486f8 100644 (file)
@@ -30,6 +30,7 @@
 #include <inttypes.h>
 #endif
 #include <stdlib.h>
+#include <stdarg.h>
 
 #include "x264.h"   /* for keyword inline */
 #include "../predict.h"
index ae9c668521d76198c50a95fe6ea4d883f8ce45f4..5eb94c4f19e22dfaf54c50b541aa795ecfb5e7c3 100644 (file)
--- a/core/mc.c
+++ b/core/mc.c
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include "../x264.h"
 
index 056491caa33e330c2e302115f21caf6e227aa013..d0001b1b4072ca023da764b706eccdc7aba8f360 100644 (file)
@@ -28,6 +28,7 @@
 #endif
 #include <stdlib.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include "../x264.h"
 #include "pixel.h"
index 2df2739456767e48195cd149c1d662382dc369c7..13c986036896ab36b4b68790803946157b9f249c 100644 (file)
@@ -30,6 +30,7 @@
 #include <inttypes.h>
 #endif
 #include <stdlib.h>
+#include <stdarg.h>
 
 #include "x264.h"
 #include "predict.h"
index 9b7d4dfa4815f319627a86b6412507dd307db778..dc0250abc0bc4d4354ab57e7ea9eada4994c75fb 100644 (file)
@@ -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;
 }
 
index 64f32462c06bf6bb780b7daff6dd5b53fd32d520..94b1343ff45be28fa8ab9492a9db3873efed5910 100644 (file)
@@ -29,6 +29,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include "../x264.h"
 #include "../core/bs.h"
diff --git a/x264.h b/x264.h
index 2cfbbd65dbed50d745a9d9eae916191c469543b9..16a969f7969671cc9d0965d29c8c6619d5919e15 100644 (file)
--- a/x264.h
+++ b/x264.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
     {