[FFmpeg-devel] [PATCH] Add memory dumper function av_log_dump().
Clément Bœsch
ubitux at gmail.com
Sat Sep 24 23:28:48 CEST 2011
From: joolzg <joolzg at btinternet.com>
---
Here is a patch from Julian Gardner, with a small cleanup (style mainly). I
didn't test it nor I did a proper review. Another more interesting patch is
incoming.
---
libavutil/avutil.h | 2 +-
libavutil/log.c | 27 +++++++++++++++++++++++++++
libavutil/log.h | 3 +++
3 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 3d46365..dde9d43 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -40,7 +40,7 @@
#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
#define LIBAVUTIL_VERSION_MAJOR 51
-#define LIBAVUTIL_VERSION_MINOR 17
+#define LIBAVUTIL_VERSION_MINOR 18
#define LIBAVUTIL_VERSION_MICRO 0
#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
diff --git a/libavutil/log.c b/libavutil/log.c
index fd5e2cb..7c59c12 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -169,3 +169,30 @@ void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
{
av_log_callback = callback;
}
+
+void av_log_dump(void *avcl, int level, const unsigned char *data, int size)
+{
+ long address = 0;
+
+ av_log(avcl, level, "HexDump (%p %d)\n", data, size);
+ if (data) {
+ while (size) {
+ int size2 = FFMIN(size, 16);
+ int l;
+
+ av_log(avcl, level, "%08lx:", address);
+ for (l = 0; l < size2; l++)
+ av_log(avcl, level, "%02x ", data[l]);
+ while (l < 16) {
+ av_log(avcl, level, " ");
+ l++;
+ }
+ for (l = 0; l < size2; l++)
+ av_log(avcl, level, "%c", data[l] < 32 ? '.' : data[l]);
+ av_log(avcl, level, "\n");
+ data += size2;
+ address += size2;
+ size -= size2;
+ }
+ }
+}
diff --git a/libavutil/log.h b/libavutil/log.h
index 046d199..4946498 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -138,6 +138,7 @@ void av_log_set_level(int);
void av_log_set_callback(void (*)(void*, int, const char*, va_list));
void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
const char* av_default_item_name(void* ctx);
+void av_log_dump(void *avcl, int level, const unsigned char *data, int length);
/**
* av_dlog macros
@@ -146,8 +147,10 @@ const char* av_default_item_name(void* ctx);
#ifdef DEBUG
# define av_dlog(pctx, ...) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__)
+# define av_dlog_dump(pctx, ...) av_log_dump(pctx, AV_LOG_DEBUG, __VA_ARGS__)
#else
# define av_dlog(pctx, ...) do { if (0) av_log(pctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
+# define av_dlog_dump(pctx, ...) do { if (0) av_log_dump(pctx, AV_LOG_DEBUG, __VA_ARGS__); } while (0)
#endif
/**
--
1.7.6.3
More information about the ffmpeg-devel
mailing list