comparison utils.c @ 3494:05bb54c1d979 libavcodec

Move av_log() & friends to libavutil
author lucabe
date Tue, 18 Jul 2006 11:00:55 +0000
parents 7581658de3d1
children faa8dc533ad3
comparison
equal deleted inserted replaced
3493:7dc6dcbc6960 3494:05bb54c1d979
1 /* 1 /*
2 * utils for libavcodec 2 * utils for libavcodec
3 * Copyright (c) 2001 Fabrice Bellard. 3 * Copyright (c) 2001 Fabrice Bellard.
4 * Copyright (c) 2003 Michel Bardiaux for the av_log API
5 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at> 4 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
6 * 5 *
7 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public 7 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
1337 default: 1336 default:
1338 return 0; 1337 return 0;
1339 } 1338 }
1340 } 1339 }
1341 1340
1342 /* av_log API */
1343
1344 static int av_log_level = AV_LOG_INFO;
1345
1346 static void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
1347 {
1348 static int print_prefix=1;
1349 AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
1350 if(level>av_log_level)
1351 return;
1352 #undef fprintf
1353 if(print_prefix && avc) {
1354 fprintf(stderr, "[%s @ %p]", avc->item_name(ptr), avc);
1355 }
1356 #define fprintf please_use_av_log
1357
1358 print_prefix= strstr(fmt, "\n") != NULL;
1359
1360 vfprintf(stderr, fmt, vl);
1361 }
1362
1363 static void (*av_log_callback)(void*, int, const char*, va_list) = av_log_default_callback;
1364
1365 void av_log(void* avcl, int level, const char *fmt, ...)
1366 {
1367 va_list vl;
1368 va_start(vl, fmt);
1369 av_vlog(avcl, level, fmt, vl);
1370 va_end(vl);
1371 }
1372
1373 void av_vlog(void* avcl, int level, const char *fmt, va_list vl)
1374 {
1375 av_log_callback(avcl, level, fmt, vl);
1376 }
1377
1378 int av_log_get_level(void)
1379 {
1380 return av_log_level;
1381 }
1382
1383 void av_log_set_level(int level)
1384 {
1385 av_log_level = level;
1386 }
1387
1388 void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
1389 {
1390 av_log_callback = callback;
1391 }
1392
1393 #if !defined(HAVE_THREADS) 1341 #if !defined(HAVE_THREADS)
1394 int avcodec_thread_init(AVCodecContext *s, int thread_count){ 1342 int avcodec_thread_init(AVCodecContext *s, int thread_count){
1395 return -1; 1343 return -1;
1396 } 1344 }
1397 #endif 1345 #endif