summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-06-20 17:03:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-06-20 17:03:58 +0200
commitafa7ab557a801d54a4c3dbab38350f858efbbd5f (patch)
treed9bb2f47c96a4caecd7beb862c7eac92a2ccfff5
parent4a993335812f7e9b2088145c7d043c01019c5d04 (diff)
parent452860d7e056f9a894cac2fe52cdedeae4c38251 (diff)
downloadffmpeg-streaming-afa7ab557a801d54a4c3dbab38350f858efbbd5f.zip
ffmpeg-streaming-afa7ab557a801d54a4c3dbab38350f858efbbd5f.tar.gz
Merge commit '452860d7e056f9a894cac2fe52cdedeae4c38251'
* commit '452860d7e056f9a894cac2fe52cdedeae4c38251': Use av_packet_rescale_ts() to simplify code. Conflicts: doc/examples/muxing.c ffmpeg.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--doc/examples/muxing.c4
-rw-r--r--ffmpeg.c19
2 files changed, 4 insertions, 19 deletions
diff --git a/doc/examples/muxing.c b/doc/examples/muxing.c
index ad8e027..19f4ba3 100644
--- a/doc/examples/muxing.c
+++ b/doc/examples/muxing.c
@@ -63,9 +63,7 @@ static void log_packet(const AVFormatContext *fmt_ctx, const AVPacket *pkt)
static int write_frame(AVFormatContext *fmt_ctx, const AVRational *time_base, AVStream *st, AVPacket *pkt)
{
/* rescale output packet timestamp values from codec to stream timebase */
- pkt->pts = av_rescale_q_rnd(pkt->pts, *time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
- pkt->dts = av_rescale_q_rnd(pkt->dts, *time_base, st->time_base, AV_ROUND_NEAR_INF|AV_ROUND_PASS_MINMAX);
- pkt->duration = av_rescale_q(pkt->duration, *time_base, st->time_base);
+ av_packet_rescale_ts(pkt, *time_base, st->time_base);
pkt->stream_index = st->index;
/* Write the compressed frame to the media file. */
diff --git a/ffmpeg.c b/ffmpeg.c
index 099620b..1af3e0e 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -755,12 +755,7 @@ static void do_audio_out(AVFormatContext *s, OutputStream *ost,
update_benchmark("encode_audio %d.%d", ost->file_index, ost->index);
if (got_packet) {
- if (pkt.pts != AV_NOPTS_VALUE)
- pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
- if (pkt.dts != AV_NOPTS_VALUE)
- pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
- if (pkt.duration > 0)
- pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base);
+ av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:audio "
@@ -1052,10 +1047,7 @@ static void do_video_out(AVFormatContext *s,
if (pkt.pts == AV_NOPTS_VALUE && !(enc->codec->capabilities & CODEC_CAP_DELAY))
pkt.pts = ost->sync_opts;
- if (pkt.pts != AV_NOPTS_VALUE)
- pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
- if (pkt.dts != AV_NOPTS_VALUE)
- pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
+ av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
if (debug_ts) {
av_log(NULL, AV_LOG_INFO, "encoder -> type:video "
@@ -1564,12 +1556,7 @@ static void flush_encoders(void)
av_free_packet(&pkt);
continue;
}
- if (pkt.pts != AV_NOPTS_VALUE)
- pkt.pts = av_rescale_q(pkt.pts, enc->time_base, ost->st->time_base);
- if (pkt.dts != AV_NOPTS_VALUE)
- pkt.dts = av_rescale_q(pkt.dts, enc->time_base, ost->st->time_base);
- if (pkt.duration > 0)
- pkt.duration = av_rescale_q(pkt.duration, enc->time_base, ost->st->time_base);
+ av_packet_rescale_ts(&pkt, enc->time_base, ost->st->time_base);
pkt_size = pkt.size;
write_frame(os, &pkt, ost);
if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO && vstats_filename) {
OpenPOWER on IntegriCloud