Commit 863c4716 authored by Martin Storsjö's avatar Martin Storsjö Committed by Luca Barbato
Browse files

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: default avatarLuca Barbato <lu_zero@gentoo.org>
parent e360ada2
......@@ -949,7 +949,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);
......@@ -963,7 +963,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);
......@@ -973,8 +973,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.
......@@ -985,8 +988,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
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment