From 919d7a345a7e9044c3cdc89cf06dc521a1b01c6c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 7 Jun 2011 13:18:12 +0200 Subject: [PATCH] Replace DEBUG_SEEK/DEBUG_SI + av_log combinations by av_dlog. --- libavformat/avidec.c | 43 +++++++++++++++---------------------------- libavformat/ffmdec.c | 14 +++----------- libavformat/mpeg.c | 12 +++--------- libavformat/mpegenc.c | 1 - libavformat/mpegts.c | 2 -- libavformat/nsvdec.c | 2 -- libavformat/utils.c | 47 +++++++++++++++-------------------------------- 7 files changed, 36 insertions(+), 85 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index a915cc658..dacd23061 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -19,9 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -//#define DEBUG -//#define DEBUG_SEEK - #include #include "libavutil/intreadwrite.h" #include "libavutil/bswap.h" @@ -141,10 +138,8 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ int64_t last_pos= -1; int64_t filesize= avio_size(s->pb); -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_ERROR, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16"PRIX64"\n", - longs_pre_entry,index_type, entries_in_use, chunk_id, base); -#endif + av_dlog(s, "longs_pre_entry:%d index_type:%d entries_in_use:%d chunk_id:%X base:%16"PRIX64"\n", + longs_pre_entry,index_type, entries_in_use, chunk_id, base); if(stream_id >= s->nb_streams || stream_id < 0) return -1; @@ -176,9 +171,8 @@ static int read_braindead_odml_indx(AVFormatContext *s, int frame_num){ int key= len >= 0; len &= 0x7FFFFFFF; -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_ERROR, "pos:%"PRId64", len:%X\n", pos, len); -#endif + av_dlog(s, "pos:%"PRId64", len:%X\n", pos, len); + if(pb->eof_reached) return -1; @@ -1134,10 +1128,8 @@ static int avi_read_idx1(AVFormatContext *s, int size) flags = avio_rl32(pb); pos = avio_rl32(pb); len = avio_rl32(pb); -#if defined(DEBUG_SEEK) - av_log(s, AV_LOG_DEBUG, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/", - i, tag, flags, pos, len); -#endif + av_dlog(s, "%d: tag=0x%x flags=0x%x pos=0x%x len=%d/", + i, tag, flags, pos, len); if(i==0 && pos > avi->movi_list) avi->movi_list= 0; //FIXME better check pos += avi->movi_list; @@ -1149,9 +1141,8 @@ static int avi_read_idx1(AVFormatContext *s, int size) st = s->streams[index]; ast = st->priv_data; -#if defined(DEBUG_SEEK) - av_log(s, AV_LOG_DEBUG, "%d cum_len=%"PRId64"\n", len, ast->cum_len); -#endif + av_dlog(s, "%d cum_len=%"PRId64"\n", len, ast->cum_len); + if(pb->eof_reached) return -1; @@ -1206,22 +1197,18 @@ static int avi_load_index(AVFormatContext *s) if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0) goto the_end; // maybe truncated file -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "movi_end=0x%"PRIx64"\n", avi->movi_end); -#endif + av_dlog(s, "movi_end=0x%"PRIx64"\n", avi->movi_end); for(;;) { if (pb->eof_reached) break; tag = avio_rl32(pb); size = avio_rl32(pb); -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "tag=%c%c%c%c size=0x%x\n", - tag & 0xff, - (tag >> 8) & 0xff, - (tag >> 16) & 0xff, - (tag >> 24) & 0xff, - size); -#endif + av_dlog(s, "tag=%c%c%c%c size=0x%x\n", + tag & 0xff, + (tag >> 8) & 0xff, + (tag >> 16) & 0xff, + (tag >> 24) & 0xff, + size); switch(tag) { case MKTAG('i', 'd', 'x', '1'): if (avi_read_idx1(s, size) < 0) diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c index 8a6226a10..dfd86cb28 100644 --- a/libavformat/ffmdec.c +++ b/libavformat/ffmdec.c @@ -163,8 +163,6 @@ static int ffm_read_data(AVFormatContext *s, return size1 - size; } -//#define DEBUG_SEEK - /* ensure that acutal seeking happens between FFM_PACKET_SIZE and file_size - FFM_PACKET_SIZE */ static void ffm_seek1(AVFormatContext *s, int64_t pos1) @@ -175,9 +173,7 @@ static void ffm_seek1(AVFormatContext *s, int64_t pos1) pos = FFMIN(pos1, ffm->file_size - FFM_PACKET_SIZE); pos = FFMAX(pos, FFM_PACKET_SIZE); -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos); -#endif + av_dlog(s, "seek to %"PRIx64" -> %"PRIx64"\n", pos1, pos); avio_seek(pb, pos, SEEK_SET); } @@ -189,9 +185,7 @@ static int64_t get_dts(AVFormatContext *s, int64_t pos) ffm_seek1(s, pos); avio_skip(pb, 4); dts = avio_rb64(pb); -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "dts=%0.6f\n", dts / 1000000.0); -#endif + av_dlog(s, "dts=%0.6f\n", dts / 1000000.0); return dts; } @@ -465,9 +459,7 @@ static int ffm_seek(AVFormatContext *s, int stream_index, int64_t wanted_pts, in int64_t pts_min, pts_max, pts; double pos1; -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0); -#endif + av_dlog(s, "wanted_pts=%0.6f\n", wanted_pts / 1000000.0); /* find the position using linear interpolation (better than dichotomy in typical cases) */ pos_min = FFM_PACKET_SIZE; diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 5b4996e82..496b9d45f 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -23,8 +23,6 @@ #include "internal.h" #include "mpeg.h" -//#define DEBUG_SEEK - #undef NDEBUG #include @@ -589,9 +587,7 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, for(;;) { len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts); if (len < 0) { -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "none (ret=%d)\n", len); -#endif + av_dlog(s, "none (ret=%d)\n", len); return AV_NOPTS_VALUE; } if (startcode == s->streams[stream_index]->id && @@ -600,10 +596,8 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, } avio_skip(s->pb, len); } -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", - pos, dts, dts / 90000.0); -#endif + av_dlog(s, "pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", + pos, dts, dts / 90000.0); *ppos = pos; return dts; } diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c index 98169abcf..820c5bd5e 100644 --- a/libavformat/mpegenc.c +++ b/libavformat/mpegenc.c @@ -25,7 +25,6 @@ #include "mpeg.h" #define MAX_PAYLOAD_SIZE 4096 -//#define DEBUG_SEEK #undef NDEBUG #include diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index bf81b20b5..e9b8b3513 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -19,8 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -//#define DEBUG -//#define DEBUG_SEEK //#define USE_SYNCPOINT_SEARCH #include "libavutil/crc.h" diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index 08338c460..9adb2f472 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -22,9 +22,7 @@ #include "riff.h" #include "libavutil/dict.h" -//#define DEBUG //#define DEBUG_DUMP_INDEX // XXX dumbdriving-271.nsv breaks with it commented!! -//#define DEBUG_SEEK #define CHECK_SUBSEQUENT_NSVS //#define DISABLE_AUDIO diff --git a/libavformat/utils.c b/libavformat/utils.c index b189bfb62..dc3b9d8fb 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1421,8 +1421,6 @@ int av_index_search_timestamp(AVStream *st, int64_t wanted_timestamp, wanted_timestamp, flags); } -#define DEBUG_SEEK - int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts, int flags){ AVInputFormat *avif= s->iformat; int64_t av_uninit(pos_min), av_uninit(pos_max), pos, pos_limit; @@ -1434,9 +1432,7 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts if (stream_index < 0) return -1; -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "read_seek: %d %"PRId64"\n", stream_index, target_ts); -#endif + av_dlog(s, "read_seek: %d %"PRId64"\n", stream_index, target_ts); ts_max= ts_min= AV_NOPTS_VALUE; @@ -1453,10 +1449,8 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts if(e->timestamp <= target_ts || e->pos == e->min_distance){ pos_min= e->pos; ts_min= e->timestamp; -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n", - pos_min,ts_min); -#endif + av_dlog(s, "using cached pos_min=0x%"PRIx64" dts_min=%"PRId64"\n", + pos_min,ts_min); }else{ assert(index==0); } @@ -1469,10 +1463,8 @@ int av_seek_frame_binary(AVFormatContext *s, int stream_index, int64_t target_ts pos_max= e->pos; ts_max= e->timestamp; pos_limit= pos_max - e->min_distance; -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n", - pos_max,pos_limit, ts_max); -#endif + av_dlog(s, "using cached pos_max=0x%"PRIx64" pos_limit=0x%"PRIx64" dts_max=%"PRId64"\n", + pos_max,pos_limit, ts_max); } } @@ -1494,9 +1486,7 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i int64_t start_pos, filesize; int no_change; -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "gen_seek: %d %"PRId64"\n", stream_index, target_ts); -#endif + av_dlog(s, "gen_seek: %d %"PRId64"\n", stream_index, target_ts); if(ts_min == AV_NOPTS_VALUE){ pos_min = s->data_offset; @@ -1538,11 +1528,8 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i no_change=0; while (pos_min < pos_limit) { -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "pos_min=0x%"PRIx64" pos_max=0x%"PRIx64" dts_min=%"PRId64" dts_max=%"PRId64"\n", - pos_min, pos_max, - ts_min, ts_max); -#endif + av_dlog(s, "pos_min=0x%"PRIx64" pos_max=0x%"PRIx64" dts_min=%"PRId64" dts_max=%"PRId64"\n", + pos_min, pos_max, ts_min, ts_max); assert(pos_limit <= pos_max); if(no_change==0){ @@ -1569,11 +1556,9 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i no_change++; else no_change=0; -#ifdef DEBUG_SEEK - av_log(s, AV_LOG_DEBUG, "%"PRId64" %"PRId64" %"PRId64" / %"PRId64" %"PRId64" %"PRId64" target:%"PRId64" limit:%"PRId64" start:%"PRId64" noc:%d\n", - pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts, pos_limit, - start_pos, no_change); -#endif + av_dlog(s, "%"PRId64" %"PRId64" %"PRId64" / %"PRId64" %"PRId64" %"PRId64" target:%"PRId64" limit:%"PRId64" start:%"PRId64" noc:%d\n", + pos_min, pos, pos_max, ts_min, ts, ts_max, target_ts, + pos_limit, start_pos, no_change); if(ts == AV_NOPTS_VALUE){ av_log(s, AV_LOG_ERROR, "read_timestamp() failed in the middle\n"); return -1; @@ -1592,13 +1577,13 @@ int64_t av_gen_search(AVFormatContext *s, int stream_index, int64_t target_ts, i pos = (flags & AVSEEK_FLAG_BACKWARD) ? pos_min : pos_max; ts = (flags & AVSEEK_FLAG_BACKWARD) ? ts_min : ts_max; -#ifdef DEBUG_SEEK +#if 1 pos_min = pos; ts_min = read_timestamp(s, stream_index, &pos_min, INT64_MAX); pos_min++; ts_max = read_timestamp(s, stream_index, &pos_min, INT64_MAX); - av_log(s, AV_LOG_DEBUG, "pos=0x%"PRIx64" %"PRId64"<=%"PRId64"<=%"PRId64"\n", - pos, ts_min, target_ts, ts_max); + av_dlog(s, "pos=0x%"PRIx64" %"PRId64"<=%"PRId64"<=%"PRId64"\n", + pos, ts_min, target_ts, ts_max); #endif *ts_ret= ts; return pos; @@ -2651,9 +2636,7 @@ AVProgram *av_new_program(AVFormatContext *ac, int id) AVProgram *program=NULL; int i; -#ifdef DEBUG_SI - av_log(ac, AV_LOG_DEBUG, "new_program: id=0x%04x\n", id); -#endif + av_dlog(ac, "new_program: id=0x%04x\n", id); for(i=0; inb_programs; i++) if(ac->programs[i]->id == id) -- 2.11.0