diff options
author | Martin Storsjö <martin@martin.st> | 2011-02-24 10:08:06 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-03-03 14:15:10 +0100 |
commit | 08ad81cbffd6c2a433fae891d42d6cf332faa7e3 (patch) | |
tree | 91d266671497ca4c51365789d6b438badc45e041 /libavformat | |
parent | 62d0a7453af12e9e7880dd08d4dafe20374625c1 (diff) | |
download | ffmpeg-08ad81cbffd6c2a433fae891d42d6cf332faa7e3.tar.gz |
libavformat: Add av_pkt_dump{, _log}2, taking an AVStream parameter
This removes a fixme issue, by allowing the av_pkt_dump functions
to use the correct time base.
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit 863c471638fa667e6e5c5df059b67af263e1cd40)
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avformat.h | 16 | ||||
-rw-r--r-- | libavformat/utils.c | 26 |
2 files changed, 31 insertions, 11 deletions
diff --git a/libavformat/avformat.h b/libavformat/avformat.h index 0c28007f7c..46fb57596a 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -951,7 +951,7 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name, * @param buf buffer * @param size buffer size * - * @see av_hex_dump_log, av_pkt_dump, av_pkt_dump_log + * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2 */ void av_hex_dump(FILE *f, uint8_t *buf, int size); @@ -965,7 +965,7 @@ void av_hex_dump(FILE *f, uint8_t *buf, int size); * @param buf buffer * @param size buffer size * - * @see av_hex_dump, av_pkt_dump, av_pkt_dump_log + * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2 */ void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size); @@ -975,8 +975,11 @@ void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size); * @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. + * @param st AVStream that the packet belongs to */ -void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); +void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st); + +attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); /** * Send a nice dump of a packet to the log. @@ -987,8 +990,13 @@ void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload); * higher importance. * @param pkt packet to dump * @param dump_payload True if the payload must be displayed, too. + * @param st AVStream that the packet belongs to */ -void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload); +void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, + AVStream *st); + +attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, + int dump_payload); /** * Initialize libavformat and register all the muxers, demuxers and diff --git a/libavformat/utils.c b/libavformat/utils.c index 87185d115f..82552abf49 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3494,26 +3494,25 @@ 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 -static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int dump_payload) +static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int dump_payload, AVRational time_base) { #undef fprintf #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", (double)pkt->duration / AV_TIME_BASE); + PRINT(" duration=%0.3f\n", pkt->duration * av_q2d(time_base)); /* DTS is _always_ valid after av_read_frame() */ PRINT(" dts="); if (pkt->dts == AV_NOPTS_VALUE) PRINT("N/A"); else - PRINT("%0.3f", (double)pkt->dts / AV_TIME_BASE); + PRINT("%0.3f", pkt->dts * av_q2d(time_base)); /* PTS may not be known if B-frames are present. */ PRINT(" pts="); if (pkt->pts == AV_NOPTS_VALUE) PRINT("N/A"); else - PRINT("%0.3f", (double)pkt->pts / AV_TIME_BASE); + PRINT("%0.3f", pkt->pts * av_q2d(time_base)); PRINT("\n"); PRINT(" size=%d\n", pkt->size); #undef PRINT @@ -3523,12 +3522,25 @@ static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload) { - pkt_dump_internal(NULL, f, 0, pkt, dump_payload); + AVRational tb = { 1, AV_TIME_BASE }; + pkt_dump_internal(NULL, f, 0, pkt, dump_payload, tb); +} + +void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st) +{ + pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base); } void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload) { - pkt_dump_internal(avcl, NULL, level, pkt, dump_payload); + AVRational tb = { 1, AV_TIME_BASE }; + pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, tb); +} + +void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload, + AVStream *st) +{ + pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, st->time_base); } #if FF_API_URL_SPLIT |