[nut]: r558 - in src/trunk: config.mak libnut/demuxer.c libnut/muxer.c libnut/priv.h

Author: ods15 Date: Sat Feb 2 14:04:36 2008 New Revision: 558 Log: fprintf(stderr -> debug_msg(, with a #define DEBUG Modified: src/trunk/config.mak src/trunk/libnut/demuxer.c src/trunk/libnut/muxer.c src/trunk/libnut/priv.h Modified: src/trunk/config.mak ============================================================================== --- src/trunk/config.mak (original) +++ src/trunk/config.mak Sat Feb 2 14:04:36 2008 @@ -1,8 +1,8 @@ PREFIX = /usr/local prefix = $(DESTDIR)$(PREFIX) -CFLAGS = -Os -Wall -g -#CFLAGS = -fomit-frame-pointer -g -Wall +CFLAGS = -Os -fomit-frame-pointer -Wall +#CFLAGS = -g -DDEBUG -Wall #CFLAGS += -DWORDS_BIGENDIAN CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 Modified: src/trunk/libnut/demuxer.c ============================================================================== --- src/trunk/libnut/demuxer.c (original) +++ src/trunk/libnut/demuxer.c Sat Feb 2 14:04:36 2008 @@ -54,11 +54,11 @@ static void seek_buf(input_buffer_t * bc } } if (whence == SEEK_CUR) pos -= bc->read_len - (bc->buf_ptr - bc->buf); - fprintf(stderr, "seeking %d ", (int)pos); + debug_msg("seeking %d ", (int)pos); switch (whence) { - case SEEK_SET: fprintf(stderr, "SEEK_SET "); break; - case SEEK_CUR: fprintf(stderr, "SEEK_CUR "); break; - case SEEK_END: fprintf(stderr, "SEEK_END "); break; + case SEEK_SET: debug_msg("SEEK_SET "); break; + case SEEK_CUR: debug_msg("SEEK_CUR "); break; + case SEEK_END: debug_msg("SEEK_END "); break; } bc->file_pos = bc->isc.seek(bc->isc.priv, pos, whence); bc->buf_ptr = bc->buf; @@ -650,7 +650,7 @@ static int get_index(nut_context_t * nut } } - fprintf(stderr, "NUT index read successfully, %d syncpoints\n", sl->len); + debug_msg("NUT index read successfully, %d syncpoints\n", sl->len); err_out: return err; @@ -757,7 +757,7 @@ static int get_packet(nut_context_t * nu for (i = 0; i < nut->stream_count; i++) { if (nut->sc[i].last_dts == -1) continue; if (compare_ts(pd->pts, TO_TB(pd->stream), nut->sc[i].last_dts, TO_TB(i)) < 0) - fprintf(stderr, "%lld %d (%f) %lld %d (%f) \n", + debug_msg("%lld %d (%f) %lld %d (%f) \n", pd->pts, pd->stream, TO_DOUBLE(pd->stream, pd->pts), nut->sc[i].last_dts, i, TO_DOUBLE(i, nut->sc[i].last_dts)); ERROR(compare_ts(pd->pts, TO_TB(pd->stream), nut->sc[i].last_dts, TO_TB(i)) < 0, NUT_ERR_OUT_OF_ORDER); @@ -1003,7 +1003,7 @@ int nut_read_next_packet(nut_context_t * while ((err = get_packet(nut, pd, NULL)) == -1) flush_buf(nut->i); if (err > NUT_ERR_OUT_OF_MEM) { // some error occured! - fprintf(stderr, "NUT: %s\n", nut_error(err)); + debug_msg("NUT: %s\n", nut_error(err)); // rewind as much as possible if (nut->i->isc.seek) seek_buf(nut->i, nut->last_syncpoint + 16, SEEK_SET); else nut->i->buf_ptr = nut->i->buf + MIN(16, nut->i->read_len); @@ -1206,7 +1206,7 @@ static int binary_search_syncpoint(nut_c // start binary search between LO (sl->s[i].pos) to HI (sl->s[i+1].pos) ... if (!*guess) *guess = seek_interpolate(nut->max_distance*2, time_pos, LO.pos, HI.pos, TO_DOUBLE_PTS(LO.pts), TO_DOUBLE_PTS(HI.pts), fake_hi); - fprintf(stderr, "\n%d [ (%d,%.3f) .. (%d,%.3f) .. (%d(%d),%.3f) ] ", i, (int)LO.pos, TO_DOUBLE_PTS(LO.pts), (int)*guess, time_pos, + debug_msg("\n%d [ (%d,%.3f) .. (%d,%.3f) .. (%d(%d),%.3f) ] ", i, (int)LO.pos, TO_DOUBLE_PTS(LO.pts), (int)*guess, time_pos, (int)HI.pos, (int)fake_hi, TO_DOUBLE_PTS(HI.pts)); a++; @@ -1245,7 +1245,7 @@ scan_backwards: } *guess = 0; - fprintf(stderr, "\n[ (%d,%d) .. %d .. (%d,%d) ] => %d (%d seeks) %d\n", + debug_msg("\n[ (%d,%d) .. %d .. (%d,%d) ] => %d (%d seeks) %d\n", (int)LO.pos, (int)LO.pts, (int)timebases[0], (int)HI.pos, (int)HI.pts, (int)(LO.pos - LO.back_ptr), a, LO.back_ptr); // at this point, s[i].pts < P < s[i+1].pts, and s[i].seen_next is set *start = LO.pos - LO.back_ptr; @@ -1360,8 +1360,8 @@ static int linear_search_seek(nut_contex if (nut->sc[i].state.good_key && (!min_pos || nut->sc[i].state.good_key < min_pos)) min_pos = nut->sc[i].state.good_key; } if (!min_pos) { - fprintf(stderr, "BIG FAT WARNING (Possibly caused by `%s')", nut_error(err)); - for (i = 0; i < nut->stream_count; i++) fprintf(stderr, "%d: %d\n", i, (int)nut->sc[i].state.good_key); + debug_msg("BIG FAT WARNING (Possibly caused by `%s')", nut_error(err)); + for (i = 0; i < nut->stream_count; i++) debug_msg("%d: %d\n", i, (int)nut->sc[i].state.good_key); min_pos = nut->seek_status >> 1; } @@ -1490,7 +1490,7 @@ int nut_seek(nut_context_t * nut, double } if (start == 0) CHECK(binary_search_syncpoint(nut, time_pos, &start, &end, &stopper)); - else fprintf(stderr, "============= NO BINARY SEARCH \n"); + else debug_msg("============= NO BINARY SEARCH \n"); if (start) { // "unsuccessful" seek needs no linear search if (!(flags & 2)) { // regular seek @@ -1499,7 +1499,7 @@ int nut_seek(nut_context_t * nut, double CHECK(linear_search_seek(nut, backwards, end, 0, NULL)); } } - fprintf(stderr, "DONE SEEK\n"); + debug_msg("DONE SEEK\n"); err_out: if (err != NUT_ERR_EAGAIN) { // unless EAGAIN syncpoint_list_t * sl = &nut->syncpoints; Modified: src/trunk/libnut/muxer.c ============================================================================== --- src/trunk/libnut/muxer.c (original) +++ src/trunk/libnut/muxer.c Sat Feb 2 14:04:36 2008 @@ -134,7 +134,7 @@ static void put_header(output_buffer_t * put_bytes(in, 4, crc32(in->buf, bctello(in))); put_data(bc, bctello(in), in->buf); - if (startcode != SYNCPOINT_STARTCODE) fprintf(stderr, "header/index size: %d\n", (int)(bctello(tmp) + bctello(in))); + if (startcode != SYNCPOINT_STARTCODE) debug_msg("header/index size: %d\n", (int)(bctello(tmp) + bctello(in))); } static void put_main_header(nut_context_t * nut) { @@ -411,7 +411,7 @@ static int frame_header(nut_context_t * if (fd->len > 2*nut->max_distance) checksum = 1; if (ABS(pts_delta) > sc->max_pts_distance) { - fprintf(stderr, "%d > %d || %d - %d > %d \n", fd->len, 2*nut->max_distance, (int)fd->pts, (int)sc->last_pts, sc->max_pts_distance); + debug_msg("%d > %d || %d - %d > %d \n", fd->len, 2*nut->max_distance, (int)fd->pts, (int)sc->last_pts, sc->max_pts_distance); checksum = 1; } @@ -496,7 +496,7 @@ void nut_write_frame(nut_context_t * nut for (i = 0; i < nut->stream_count; i++) { if (nut->sc[i].last_dts == -1) continue; if (compare_ts(fd->pts, TO_TB(fd->stream), nut->sc[i].last_dts, TO_TB(i)) < 0) - fprintf(stderr, "%lld %d (%f) %lld %d (%f) \n", + debug_msg("%lld %d (%f) %lld %d (%f) \n", fd->pts, fd->stream, TO_DOUBLE(fd->stream, fd->pts), nut->sc[i].last_dts, i, TO_DOUBLE(i, nut->sc[i].last_dts)); assert(compare_ts(fd->pts, TO_TB(fd->stream), nut->sc[i].last_dts, TO_TB(i)) >= 0); @@ -554,12 +554,12 @@ nut_context_t * nut_muxer_init(const nut nut_framecode_generate(s, mfti); fti = mfti; } - fprintf(stderr, "/""/ { %4s, %3s, %6s, %3s, %4s, %5s },\n", "flag", "pts", "stream", "mul", "size", "count"); + debug_msg("/""/ { %4s, %3s, %6s, %3s, %4s, %5s },\n", "flag", "pts", "stream", "mul", "size", "count"); for (n=i=0; i < 256; n++) { int j; assert(fti[n].flag != -1); - fprintf(stderr, " { %4d, %3d, %6d, %3d, %4d, %5d },\n", fti[n].flag, fti[n].pts, fti[n].stream, fti[n].mul, fti[n].size, fti[n].count); + debug_msg(" { %4d, %3d, %6d, %3d, %4d, %5d },\n", fti[n].flag, fti[n].pts, fti[n].stream, fti[n].mul, fti[n].size, fti[n].count); for(j = 0; j < fti[n].count && i < 256; j++, i++) { if (i == 'N') { nut->ft[i].flags = FLAG_INVALID; @@ -573,7 +573,7 @@ nut_context_t * nut_muxer_init(const nut nut->ft[i].lsb = fti[n].size + j; } } - fprintf(stderr, " { %4d, %3d, %6d, %3d, %4d, %5d },\n", fti[n].flag, fti[n].pts, fti[n].stream, fti[n].mul, fti[n].size, fti[n].count); + debug_msg(" { %4d, %3d, %6d, %3d, %4d, %5d },\n", fti[n].flag, fti[n].pts, fti[n].stream, fti[n].mul, fti[n].size, fti[n].count); assert(fti[n].flag == -1); nut->sync_overhead = 0; @@ -678,15 +678,15 @@ void nut_muxer_uninit(nut_context_t * nu for (i = 0; i < nut->stream_count; i++) { total += nut->sc[i].tot_size; - fprintf(stderr, "Stream %d:\n", i); - fprintf(stderr, " frames: %d\n", nut->sc[i].total_frames); - fprintf(stderr, " TOT: "); - fprintf(stderr, "packet size: %d ", nut->sc[i].tot_size); - fprintf(stderr, "packet overhead: %d ", nut->sc[i].overhead); - fprintf(stderr, "(%.2lf%%)\n", (double)nut->sc[i].overhead / nut->sc[i].tot_size * 100); - fprintf(stderr, " AVG: "); - fprintf(stderr, "packet size: %.2lf ", (double)nut->sc[i].tot_size / nut->sc[i].total_frames); - fprintf(stderr, "packet overhead: %.2lf\n", (double)nut->sc[i].overhead / nut->sc[i].total_frames); + debug_msg("Stream %d:\n", i); + debug_msg(" frames: %d\n", nut->sc[i].total_frames); + debug_msg(" TOT: "); + debug_msg("packet size: %d ", nut->sc[i].tot_size); + debug_msg("packet overhead: %d ", nut->sc[i].overhead); + debug_msg("(%.2lf%%)\n", (double)nut->sc[i].overhead / nut->sc[i].tot_size * 100); + debug_msg(" AVG: "); + debug_msg("packet size: %.2lf ", (double)nut->sc[i].tot_size / nut->sc[i].total_frames); + debug_msg("packet overhead: %.2lf\n", (double)nut->sc[i].overhead / nut->sc[i].total_frames); nut->alloc->free(nut->sc[i].sh.fourcc); nut->alloc->free(nut->sc[i].sh.codec_specific); @@ -703,7 +703,7 @@ void nut_muxer_uninit(nut_context_t * nu } nut->alloc->free(nut->info); - fprintf(stderr, "Syncpoints: %d size: %d\n", nut->syncpoints.len, nut->sync_overhead); + debug_msg("Syncpoints: %d size: %d\n", nut->syncpoints.len, nut->sync_overhead); nut->alloc->free(nut->syncpoints.s); nut->alloc->free(nut->syncpoints.pts); @@ -711,7 +711,7 @@ void nut_muxer_uninit(nut_context_t * nu free_buffer(nut->tmp_buffer); free_buffer(nut->tmp_buffer2); - fprintf(stderr, "TOTAL: %d bytes data, %d bytes overhead, %.2lf%% overhead\n", total, + debug_msg("TOTAL: %d bytes data, %d bytes overhead, %.2lf%% overhead\n", total, (int)bctello(nut->o) - total, (double)(bctello(nut->o) - total) / total*100); free_buffer(nut->o); // flushes file nut->alloc->free(nut); Modified: src/trunk/libnut/priv.h ============================================================================== --- src/trunk/libnut/priv.h (original) +++ src/trunk/libnut/priv.h Sat Feb 2 14:04:36 2008 @@ -4,8 +4,16 @@ #ifndef LIBNUT_PRIV_H #define LIBNUT_PRIV_H -//#define NDEBUG +//#define NDEBUG // disables asserts +//#define DEBUG //#define TRACE + +#ifdef DEBUG +#define debug_msg(...) fprintf(stderr, __VA_ARGS__) +#else +#define debug_msg(...) +#endif + #include <assert.h> #include <inttypes.h> #include <stdlib.h>
participants (1)
-
ods15