summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-01-29 23:40:39 +0100
committerMichael Niedermayer <michaelni@gmx.at>2014-01-29 23:40:51 +0100
commit72afa381b3fa347f4149067845c6582469d8062e (patch)
treeeb366c532e925d9be305143330a75486424e49af
parentfbafd64acce4a2a0aa6a5b392524a99f397e96a8 (diff)
parentd67cfdeb530360748ada6ad0335af99507dd6308 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: avformat: utils: Refactor duplicated PRINT macro Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/utils.c54
1 files changed, 23 insertions, 31 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c
index ac9236b18f..743d6f4081 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3907,11 +3907,7 @@ fail:
return -1;
}
-static void hex_dump_internal(void *avcl, FILE *f, int level,
- const uint8_t *buf, int size)
-{
- int len, i, j, c;
-#define PRINT(...) \
+#define HEXDUMP_PRINT(...) \
do { \
if (!f) \
av_log(avcl, level, __VA_ARGS__); \
@@ -3919,27 +3915,31 @@ static void hex_dump_internal(void *avcl, FILE *f, int level,
fprintf(f, __VA_ARGS__); \
} while (0)
+static void hex_dump_internal(void *avcl, FILE *f, int level,
+ const uint8_t *buf, int size)
+{
+ int len, i, j, c;
+
for (i = 0; i < size; i += 16) {
len = size - i;
if (len > 16)
len = 16;
- PRINT("%08x ", i);
+ HEXDUMP_PRINT("%08x ", i);
for (j = 0; j < 16; j++) {
if (j < len)
- PRINT(" %02x", buf[i + j]);
+ HEXDUMP_PRINT(" %02x", buf[i + j]);
else
- PRINT(" ");
+ HEXDUMP_PRINT(" ");
}
- PRINT(" ");
+ HEXDUMP_PRINT(" ");
for (j = 0; j < len; j++) {
c = buf[i + j];
if (c < ' ' || c > '~')
c = '.';
- PRINT("%c", c);
+ HEXDUMP_PRINT("%c", c);
}
- PRINT("\n");
+ HEXDUMP_PRINT("\n");
}
-#undef PRINT
}
void av_hex_dump(FILE *f, const uint8_t *buf, int size)
@@ -3955,31 +3955,23 @@ void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size)
static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt,
int dump_payload, AVRational time_base)
{
-#define PRINT(...) \
- do { \
- if (!f) \
- av_log(avcl, level, __VA_ARGS__); \
- else \
- fprintf(f, __VA_ARGS__); \
- } while (0)
- PRINT("stream #%d:\n", pkt->stream_index);
- PRINT(" keyframe=%d\n", ((pkt->flags & AV_PKT_FLAG_KEY) != 0));
- PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base));
+ HEXDUMP_PRINT("stream #%d:\n", pkt->stream_index);
+ HEXDUMP_PRINT(" keyframe=%d\n", (pkt->flags & AV_PKT_FLAG_KEY) != 0);
+ HEXDUMP_PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base));
/* DTS is _always_ valid after av_read_frame() */
- PRINT(" dts=");
+ HEXDUMP_PRINT(" dts=");
if (pkt->dts == AV_NOPTS_VALUE)
- PRINT("N/A");
+ HEXDUMP_PRINT("N/A");
else
- PRINT("%0.3f", pkt->dts * av_q2d(time_base));
+ HEXDUMP_PRINT("%0.3f", pkt->dts * av_q2d(time_base));
/* PTS may not be known if B-frames are present. */
- PRINT(" pts=");
+ HEXDUMP_PRINT(" pts=");
if (pkt->pts == AV_NOPTS_VALUE)
- PRINT("N/A");
+ HEXDUMP_PRINT("N/A");
else
- PRINT("%0.3f", pkt->pts * av_q2d(time_base));
- PRINT("\n");
- PRINT(" size=%d\n", pkt->size);
-#undef PRINT
+ HEXDUMP_PRINT("%0.3f", pkt->pts * av_q2d(time_base));
+ HEXDUMP_PRINT("\n");
+ HEXDUMP_PRINT(" size=%d\n", pkt->size);
if (dump_payload)
av_hex_dump(f, pkt->data, pkt->size);
}