Author: gkovacs
Date: Mon Aug 24 04:39:15 2009
New Revision: 5227
Log:
use static variable to cache result of av_playlist_time_offset to reduce
computations in read_packet
Modified:
concat/libavformat/concatgen.c
Modified: concat/libavformat/concatgen.c
==============================================================================
--- concat/libavformat/concatgen.c Mon Aug 24 04:20:33 2009 (r5226)
+++ concat/libavformat/concatgen.c Mon Aug 24 04:39:15 2009 (r5227)
@@ -52,14 +52,21 @@ int ff_concatgen_read_packet(AVFormatCon
}
if (ret >= 0) {
if (pkt) {
+ int streams_offset =
av_playlist_streams_offset_from_playidx(ctx, ctx->pe_curidx);
stream_index = av_playlist_localstidx_from_streamidx(ctx,
pkt->stream_index);
- pkt->stream_index = stream_index +
av_playlist_streams_offset_from_playidx(ctx, ctx->pe_curidx);
+ pkt->stream_index = stream_index + streams_offset;
if (!ic->streams[stream_index]->codec->has_b_frames ||
ic->streams[stream_index]->codec->codec->id ==
CODEC_ID_MPEG1VIDEO) {
- int time_offset_avbase =
av_playlist_time_offset(ctx->durations, ctx->pe_curidx);
- int time_offset_localbase =
av_rescale_q(time_offset_avbase,
- AV_TIME_BASE_Q,
-
ic->streams[stream_index]->time_base);
+ static int cached_streams_offset = -1;
+ static int64_t time_offset_avbase = 0;
+ int time_offset_localbase;
+ if (cached_streams_offset != streams_offset) { // must
recompute timestamp offset
+ cached_streams_offset = streams_offset;
+ time_offset_avbase =
av_playlist_time_offset(ctx->durations, streams_offset);
+ }
+ time_offset_localbase = av_rescale_q(time_offset_avbase,
+ AV_TIME_BASE_Q,
+
ic->streams[stream_index]->time_base);
pkt->dts += time_offset_localbase;
if (pkt->pts != AV_NOPTS_VALUE)
pkt->pts += time_offset_localbase;
_______________________________________________
FFmpeg-soc mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc