[MPlayer-cvslog] r32464 - in trunk: libmpcodecs/vd_ffmpeg.c mp_msg.c mp_msg.h
reimar
subversion at mplayerhq.hu
Sat Oct 9 14:12:14 CEST 2010
Author: reimar
Date: Sat Oct 9 14:12:14 2010
New Revision: 32464
Log:
Add a va_list version of mp_msg and use it to avoid yet another intermediate
buffer when printing FFmpeg messages in vd_ffmpeg.c
Modified:
trunk/libmpcodecs/vd_ffmpeg.c
trunk/mp_msg.c
trunk/mp_msg.h
Modified: trunk/libmpcodecs/vd_ffmpeg.c
==============================================================================
--- trunk/libmpcodecs/vd_ffmpeg.c Sat Oct 9 14:08:50 2010 (r32463)
+++ trunk/libmpcodecs/vd_ffmpeg.c Sat Oct 9 14:12:14 2010 (r32464)
@@ -185,7 +185,6 @@ static void mp_msp_av_log_callback(void
AVClass *avc= ptr ? *(AVClass **)ptr : NULL;
int type= MSGT_FIXME;
int mp_level;
- char buf[256];
switch(level){
case AV_LOG_VERBOSE: mp_level = MSGL_V ; break;
@@ -226,8 +225,7 @@ static void mp_msp_av_log_callback(void
}
print_prefix= strchr(fmt, '\n') != NULL;
- vsnprintf(buf, sizeof(buf), fmt, vl);
- mp_msg(type, mp_level, buf);
+ mp_msg_va(type, mp_level, fmt, vl);
}
static void set_format_params(struct AVCodecContext *avctx, enum PixelFormat fmt){
Modified: trunk/mp_msg.c
==============================================================================
--- trunk/mp_msg.c Sat Oct 9 14:08:50 2010 (r32463)
+++ trunk/mp_msg.c Sat Oct 9 14:12:14 2010 (r32464)
@@ -178,6 +178,12 @@ static void print_msg_module(FILE* strea
void mp_msg(int mod, int lev, const char *format, ... ){
va_list va;
+ va_start(va, format);
+ mp_msg_va(mod, lev, format, va);
+ va_end(va);
+}
+
+void mp_msg_va(int mod, int lev, const char *format, va_list va){
char tmp[MSGSIZE_MAX];
FILE *stream = lev <= MSGL_WARN ? stderr : stdout;
static int header = 1;
@@ -186,9 +192,7 @@ void mp_msg(int mod, int lev, const char
size_t len;
if (!mp_msg_test(mod, lev)) return; // do not display
- va_start(va, format);
vsnprintf(tmp, MSGSIZE_MAX, format, va);
- va_end(va);
tmp[MSGSIZE_MAX-2] = '\n';
tmp[MSGSIZE_MAX-1] = 0;
Modified: trunk/mp_msg.h
==============================================================================
--- trunk/mp_msg.h Sat Oct 9 14:08:50 2010 (r32463)
+++ trunk/mp_msg.h Sat Oct 9 14:12:14 2010 (r32464)
@@ -19,6 +19,8 @@
#ifndef MPLAYER_MP_MSG_H
#define MPLAYER_MP_MSG_H
+#include <stdarg.h>
+
// defined in mplayer.c and mencoder.c
extern int verbose;
@@ -140,6 +142,7 @@ int mp_msg_test(int mod, int lev);
#include "config.h"
+void mp_msg_va(int mod, int lev, const char *format, va_list va);
#ifdef __GNUC__
void mp_msg(int mod, int lev, const char *format, ... ) __attribute__ ((format (printf, 3, 4)));
# ifdef MP_DEBUG
More information about the MPlayer-cvslog
mailing list