which use av_log() for logging instead of fprintf(). Originally committed as revision 8339 to svn://svn.ffmpeg.org/ffmpeg/trunktags/v0.5
@@ -1878,7 +1878,7 @@ static int av_encode(AVFormatContext **output_files, | |||
} | |||
if (do_pkt_dump) { | |||
av_pkt_dump(stdout, &pkt, do_hex_dump); | |||
av_pkt_dump_log(NULL, AV_LOG_DEBUG, &pkt, do_hex_dump); | |||
} | |||
/* the following test is needed in case new streams appear | |||
dynamically in stream : we ignore them */ | |||
@@ -3347,7 +3347,7 @@ static void extract_mpeg4_header(AVFormatContext *infile) | |||
if (p[0] == 0x00 && p[1] == 0x00 && | |||
p[2] == 0x01 && p[3] == 0xb6) { | |||
size = p - pkt.data; | |||
// av_hex_dump(pkt.data, size); | |||
// av_hex_dump_log(infile, AV_LOG_DEBUG, pkt.data, size); | |||
st->codec->extradata = av_malloc(size); | |||
st->codec->extradata_size = size; | |||
memcpy(st->codec->extradata, pkt.data, size); | |||
@@ -444,21 +444,51 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, | |||
const char *filename, const char *mime_type, enum CodecType type); | |||
/** | |||
* Print nice hexa dump of a buffer | |||
* @param f stream for output | |||
* Send a nice hexadecimal dump of a buffer to the specified file stream. | |||
* | |||
* @param f The file stream pointer where the dump should be sent to. | |||
* @param buf buffer | |||
* @param size buffer size | |||
* | |||
* @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log | |||
*/ | |||
void av_hex_dump(FILE *f, uint8_t *buf, int size); | |||
/** | |||
* Print on 'f' a nice dump of a packet | |||
* @param f stream for output | |||
* Send a nice hexadecimal dump of a buffer to the log. | |||
* | |||
* @param avcl A pointer to an arbitrary struct of which the first field is a | |||
* pointer to an AVClass struct. | |||
* @param level The importance level of the message, lower values signifying | |||
* higher importance. | |||
* @param buf buffer | |||
* @param size buffer size | |||
* | |||
* @see av_hex_dump, av_pkt_dump, av_pkt_dump_log | |||
*/ | |||
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size); | |||
/** | |||
* Send a nice dump of a packet to the specified file stream. | |||
* | |||
* @param f The file stream pointer where the dump should be sent to. | |||
* @param pkt packet to dump | |||
* @param dump_payload true if the payload must be displayed too | |||
*/ | |||
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); | |||
/** | |||
* Send a nice dump of a packet to the log. | |||
* | |||
* @param avcl A pointer to an arbitrary struct of which the first field is a | |||
* pointer to an AVClass struct. | |||
* @param level The importance level of the message, lower values signifying | |||
* higher importance. | |||
* @param pkt packet to dump | |||
* @param dump_payload true if the payload must be displayed too | |||
*/ | |||
void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload); | |||
void av_register_all(void); | |||
/** codec tag <-> codec id */ | |||
@@ -401,7 +401,7 @@ static void pmt_cb(void *opaque, const uint8_t *section, int section_len) | |||
#ifdef DEBUG_SI | |||
av_log(ts->stream, AV_LOG_DEBUG, "PMT: len %i\n", section_len); | |||
av_hex_dump(stdout, (uint8_t *)section, section_len); | |||
av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len); | |||
#endif | |||
p_end = section + section_len - 4; | |||
p = section; | |||
@@ -545,7 +545,7 @@ static void pat_cb(void *opaque, const uint8_t *section, int section_len) | |||
#ifdef DEBUG_SI | |||
av_log(ts->stream, AV_LOG_DEBUG, "PAT:\n"); | |||
av_hex_dump(stdout, (uint8_t *)section, section_len); | |||
av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len); | |||
#endif | |||
p_end = section + section_len - 4; | |||
p = section; | |||
@@ -594,7 +594,7 @@ static void pat_scan_cb(void *opaque, const uint8_t *section, int section_len) | |||
#ifdef DEBUG_SI | |||
av_log(ts->stream, AV_LOG_DEBUG, "PAT:\n"); | |||
av_hex_dump(stdout, (uint8_t *)section, section_len); | |||
av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len); | |||
#endif | |||
p_end = section + section_len - 4; | |||
p = section; | |||
@@ -655,7 +655,7 @@ static void sdt_cb(void *opaque, const uint8_t *section, int section_len) | |||
#ifdef DEBUG_SI | |||
av_log(ts->stream, AV_LOG_DEBUG, "SDT:\n"); | |||
av_hex_dump(stdout, (uint8_t *)section, section_len); | |||
av_hex_dump_log(ts->stream, AV_LOG_DEBUG, (uint8_t *)section, section_len); | |||
#endif | |||
p_end = section + section_len - 4; | |||
@@ -806,7 +806,7 @@ static void mpegts_push_data(void *opaque, | |||
/* we got all the PES or section header. We can now | |||
decide */ | |||
#if 0 | |||
av_hex_dump(pes->header, pes->data_index); | |||
av_hex_dump_log(pes->stream, AV_LOG_DEBUG, pes->header, pes->data_index); | |||
#endif | |||
if (pes->header[0] == 0x00 && pes->header[1] == 0x00 && | |||
pes->header[2] == 0x01) { | |||
@@ -2702,56 +2702,80 @@ int av_get_frame_filename(char *buf, int buf_size, | |||
return -1; | |||
} | |||
void av_hex_dump(FILE *f, uint8_t *buf, int size) | |||
static void hex_dump_internal(void *avcl, FILE *f, int level, uint8_t *buf, int size) | |||
{ | |||
int len, i, j, c; | |||
#define PRINT(...) do { if (!f) av_log(avcl, level, __VA_ARGS__); else fprintf(f, __VA_ARGS__); } while(0) | |||
for(i=0;i<size;i+=16) { | |||
len = size - i; | |||
if (len > 16) | |||
len = 16; | |||
fprintf(f, "%08x ", i); | |||
PRINT("%08x ", i); | |||
for(j=0;j<16;j++) { | |||
if (j < len) | |||
fprintf(f, " %02x", buf[i+j]); | |||
PRINT(" %02x", buf[i+j]); | |||
else | |||
fprintf(f, " "); | |||
PRINT(" "); | |||
} | |||
fprintf(f, " "); | |||
PRINT(" "); | |||
for(j=0;j<len;j++) { | |||
c = buf[i+j]; | |||
if (c < ' ' || c > '~') | |||
c = '.'; | |||
fprintf(f, "%c", c); | |||
PRINT("%c", c); | |||
} | |||
fprintf(f, "\n"); | |||
PRINT("\n"); | |||
} | |||
#undef PRINT | |||
} | |||
void av_hex_dump(FILE *f, uint8_t *buf, int size) | |||
{ | |||
hex_dump_internal(NULL, f, 0, buf, size); | |||
} | |||
void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size) | |||
{ | |||
hex_dump_internal(avcl, NULL, level, buf, size); | |||
} | |||
//FIXME needs to know the time_base | |||
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload) | |||
static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int dump_payload) | |||
{ | |||
fprintf(f, "stream #%d:\n", pkt->stream_index); | |||
fprintf(f, " keyframe=%d\n", ((pkt->flags & PKT_FLAG_KEY) != 0)); | |||
fprintf(f, " duration=%0.3f\n", (double)pkt->duration / AV_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 & PKT_FLAG_KEY) != 0)); | |||
PRINT(" duration=%0.3f\n", (double)pkt->duration / AV_TIME_BASE); | |||
/* DTS is _always_ valid after av_read_frame() */ | |||
fprintf(f, " dts="); | |||
PRINT(" dts="); | |||
if (pkt->dts == AV_NOPTS_VALUE) | |||
fprintf(f, "N/A"); | |||
PRINT("N/A"); | |||
else | |||
fprintf(f, "%0.3f", (double)pkt->dts / AV_TIME_BASE); | |||
PRINT("%0.3f", (double)pkt->dts / AV_TIME_BASE); | |||
/* PTS may be not known if B frames are present */ | |||
fprintf(f, " pts="); | |||
PRINT(" pts="); | |||
if (pkt->pts == AV_NOPTS_VALUE) | |||
fprintf(f, "N/A"); | |||
PRINT("N/A"); | |||
else | |||
fprintf(f, "%0.3f", (double)pkt->pts / AV_TIME_BASE); | |||
fprintf(f, "\n"); | |||
fprintf(f, " size=%d\n", pkt->size); | |||
PRINT("%0.3f", (double)pkt->pts / AV_TIME_BASE); | |||
PRINT("\n"); | |||
PRINT(" size=%d\n", pkt->size); | |||
#undef PRINT | |||
if (dump_payload) | |||
av_hex_dump(f, pkt->data, pkt->size); | |||
} | |||
void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload) | |||
{ | |||
pkt_dump_internal(NULL, f, 0, pkt, dump_payload); | |||
} | |||
void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload) | |||
{ | |||
pkt_dump_internal(avcl, NULL, level, pkt, dump_payload); | |||
} | |||
void url_split(char *proto, int proto_size, | |||
char *authorization, int authorization_size, | |||
char *hostname, int hostname_size, | |||