[FFmpeg-soc] [soc]: r5255 - in concat/libavformat: avplaylist.c avplaylist.h concatgen.c
gkovacs
subversion at mplayerhq.hu
Tue Aug 25 01:29:06 CEST 2009
Author: gkovacs
Date: Tue Aug 25 01:29:06 2009
New Revision: 5255
Log:
switched durations to store sums of previous durations to eliminate the need for av_playlist_time_offset
Modified:
concat/libavformat/avplaylist.c
concat/libavformat/avplaylist.h
concat/libavformat/concatgen.c
Modified: concat/libavformat/avplaylist.c
==============================================================================
--- concat/libavformat/avplaylist.c Tue Aug 25 00:54:32 2009 (r5254)
+++ concat/libavformat/avplaylist.c Tue Aug 25 01:29:06 2009 (r5255)
@@ -35,6 +35,7 @@
#include "libavutil/avstring.h"
#include "internal.h"
#include "concat.h"
+#include "avplaylist.h"
AVFormatContext *av_playlist_alloc_formatcontext(char *filename)
{
@@ -68,6 +69,10 @@ int av_playlist_populate_context(AVPlayl
if (!(ctx->formatcontext_list[pe_curidx] = av_playlist_alloc_formatcontext(ctx->flist[pe_curidx])))
return AVERROR_NOFMT;
ctx->nb_streams_list[pe_curidx] = ctx->formatcontext_list[pe_curidx]->nb_streams;
+ if (pe_curidx > 0)
+ ctx->durations[pe_curidx] = ctx->durations[pe_curidx - 1] + ctx->formatcontext_list[pe_curidx]->duration;
+ else
+ ctx->durations[pe_curidx] = 0;
return 0;
}
@@ -225,16 +230,6 @@ void av_playlist_relative_paths(char **f
}
}
-int64_t av_playlist_time_offset(const int64_t *durations, int stream_index)
-{
- int i;
- int64_t total = 0;
- for (i = 0; i < stream_index; ++i) {
- total += durations[i];
- }
- return total;
-}
-
int av_playlist_stream_index_from_time(AVPlaylistContext *ctx,
int64_t pts,
int64_t *localpts)
@@ -245,7 +240,7 @@ int av_playlist_stream_index_from_time(A
while (pts >= total) {
if (i >= ctx->pelist_size)
break;
- total += ctx->durations[i++];
+ total = ctx->durations[i++];
}
if (localpts)
*localpts = pts-(total-ctx->durations[i-1]);
@@ -269,4 +264,3 @@ int av_playlist_streams_offset_from_play
total += ctx->nb_streams_list[i++];
return total;
}
-
Modified: concat/libavformat/avplaylist.h
==============================================================================
--- concat/libavformat/avplaylist.h Tue Aug 25 00:54:32 2009 (r5254)
+++ concat/libavformat/avplaylist.h Tue Aug 25 01:29:06 2009 (r5255)
@@ -44,7 +44,7 @@ typedef struct AVPlaylistContext {
AVFormatContext **formatcontext_list; /**< List of AVFormatContext for each playlist item */
int pelist_size; /**< Number of playlist elements stored in formatcontext_list */
int pe_curidx; /**< Index of the AVFormatContext in formatcontext_list that packets are being read from */
- int64_t *durations; /**< Durations, in AV_TIME_BASE units, for each playlist item */
+ int64_t *durations; /**< Sum of previous durations, in AV_TIME_BASE units, for each playlist item */
int *nb_streams_list; /**< List of the number of streams in each playlist item*/
} AVPlaylistContext;
@@ -113,13 +113,6 @@ AVPlaylistContext *av_playlist_from_file
*/
void av_playlist_add_path(AVPlaylistContext *ctx, const char *itempath);
-/** @brief Calculates the total time offset of an element in a AVPlaylistContext in AV_TIME_BASE units.
- * @param durations Durations of playlist items in AV_TIME_BASE units, array must be of size greater than or equal to pe_curidx.
- * @param pe_curidx Index of the playlist element for which to calculate the time offset.
- * @return Returns the time offset in AV_TIME_BASE units.
- */
-int64_t av_playlist_time_offset(const int64_t *durations, int stream_index);
-
/** @brief Calculates the index of the playlist item which would contain the timestamp specified in AV_TIME_BASE units.
* @param ctx AVPlaylistContext within which the list of playlist elements and durations are stored.
* @param pts Timestamp in AV_TIME_BASE.
Modified: concat/libavformat/concatgen.c
==============================================================================
--- concat/libavformat/concatgen.c Tue Aug 25 00:54:32 2009 (r5254)
+++ concat/libavformat/concatgen.c Tue Aug 25 01:29:06 2009 (r5255)
@@ -58,7 +58,7 @@ int ff_concatgen_read_packet(AVFormatCon
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) {
- int64_t time_offset_localbase = av_rescale_q(av_playlist_time_offset(ctx->durations, streams_offset),
+ int64_t time_offset_localbase = av_rescale_q(ctx->durations[ctx->pe_curidx],
AV_TIME_BASE_Q,
ic->streams[stream_index]->time_base);
pkt->dts += time_offset_localbase;
@@ -75,10 +75,10 @@ int ff_concatgen_read_packet(AVFormatCon
// -32 AVERROR_EOF for avi, -51 for ogg
av_log(ic, AV_LOG_DEBUG, "Switching stream %d to %d\n", stream_index, ctx->pe_curidx+1);
- ctx->durations[ctx->pe_curidx] = ic->duration;
- ctx->pe_curidx = av_playlist_stream_index_from_time(ctx,
- av_playlist_time_offset(ctx->durations, ctx->pe_curidx),
- NULL);
+ ctx->pe_curidx++;
+ //ctx->pe_curidx = av_playlist_stream_index_from_time(ctx,
+ //av_playlist_time_offset(ctx->durations, ctx->pe_curidx),
+ //NULL);
if (av_playlist_populate_context(ctx, ctx->pe_curidx) < 0) {
av_log(NULL, AV_LOG_ERROR, "Failed to switch to AVFormatContext %d\n", ctx->pe_curidx);
break;
@@ -112,7 +112,6 @@ int ff_concatgen_read_seek(AVFormatConte
int64_t localpts_avtimebase, localpts, pts_avtimebase;
AVPlaylistContext *ctx = s->priv_data;
AVFormatContext *ic = ctx->formatcontext_list[ctx->pe_curidx];
- ctx->durations[ctx->pe_curidx] = ic->duration;
pts_avtimebase = av_rescale_q(pts,
ic->streams[stream_index]->time_base,
AV_TIME_BASE_Q);
More information about the FFmpeg-soc
mailing list