[FFmpeg-soc] [soc]: r4793 - in concat: ffmpeg.c.diff libavformat/concatgen.c libavformat/m3u.c libavformat/playlist.c libavformat/playlist.h libavformat/pls.c libavformat/xspf.c

gkovacs subversion at mplayerhq.hu
Fri Jul 24 01:08:32 CEST 2009


Author: gkovacs
Date: Fri Jul 24 01:08:31 2009
New Revision: 4793

Log:
use single time offset for all multimedia streams

Modified:
   concat/ffmpeg.c.diff
   concat/libavformat/concatgen.c
   concat/libavformat/m3u.c
   concat/libavformat/playlist.c
   concat/libavformat/playlist.h
   concat/libavformat/pls.c
   concat/libavformat/xspf.c

Modified: concat/ffmpeg.c.diff
==============================================================================
--- concat/ffmpeg.c.diff	Fri Jul 24 00:54:37 2009	(r4792)
+++ concat/ffmpeg.c.diff	Fri Jul 24 01:08:31 2009	(r4793)
@@ -1,5 +1,5 @@
 diff --git a/ffmpeg.c b/ffmpeg.c
-index 22bfed8..f5b9656 100644
+index 22bfed8..921943f 100644
 --- a/ffmpeg.c
 +++ b/ffmpeg.c
 @@ -70,6 +70,8 @@
@@ -101,7 +101,7 @@ index 22bfed8..f5b9656 100644
 +        if (!playlist_ctx) {
 +            ic = avformat_alloc_context();
 +            av_log(ic, AV_LOG_DEBUG, "Generating playlist ctx\n");
-+            playlist_ctx = ff_playlist_alloc_context();
++            playlist_ctx = av_mallocz(sizeof(*playlist_ctx));
 +            ff_playlist_add_path(playlist_ctx, filename);
 +            ic->nb_streams = 2;
 +            ic->iformat = ff_concat_alloc_demuxer();

Modified: concat/libavformat/concatgen.c
==============================================================================
--- concat/libavformat/concatgen.c	Fri Jul 24 00:54:37 2009	(r4792)
+++ concat/libavformat/concatgen.c	Fri Jul 24 01:08:31 2009	(r4793)
@@ -53,8 +53,8 @@ int ff_concatgen_read_packet(AVFormatCon
     if (ret >= 0) {
         if (pkt) {
             int64_t time_offset;
-            time_offset = av_rescale_q(ctx->time_offsets[pkt->stream_index], AV_TIME_BASE_Q, ic->streams[stream_index]->time_base);
-            av_log(ic, "%s conv stream time from %ld to %d/%d is %ld\n", ic->iformat->name, ctx->time_offsets[pkt->stream_index], ic->streams[stream_index]->time_base.num, ic->streams[stream_index]->time_base.den, time_offset);
+            time_offset = av_rescale_q(ctx->time_offset, AV_TIME_BASE_Q, ic->streams[stream_index]->time_base);
+            av_log(ic, AV_LOG_DEBUG, "%s conv stream time from %ld to %d/%d is %ld\n", ic->iformat->name, ctx->time_offset, ic->streams[stream_index]->time_base.num, ic->streams[stream_index]->time_base.den, time_offset);
             // TODO changing either dts or pts leads to timing issues on h264
             pkt->dts += time_offset;
             if (!ic->streams[pkt->stream_index]->codec->has_b_frames)
@@ -64,9 +64,7 @@ int ff_concatgen_read_packet(AVFormatCon
     // TODO switch from AVERROR_EOF to AVERROR_EOS
     // -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);
-        for (i = 0; i < ic->nb_streams && i < ctx->time_offsets_size; ++i) {
-            ctx->time_offsets[i] += av_rescale_q(ic->streams[i]->duration, ic->streams[i]->time_base, AV_TIME_BASE_Q);
-        }
+        ctx->time_offset += av_rescale_q(ic->streams[i]->duration, ic->streams[i]->time_base, AV_TIME_BASE_Q);
         ++ctx->pe_curidx;
         ff_playlist_populate_context(s);
         have_switched_streams = 1;

Modified: concat/libavformat/m3u.c
==============================================================================
--- concat/libavformat/m3u.c	Fri Jul 24 00:54:37 2009	(r4792)
+++ concat/libavformat/m3u.c	Fri Jul 24 01:08:31 2009	(r4793)
@@ -92,7 +92,7 @@ static int m3u_read_header(AVFormatConte
                            AVFormatParameters *ap)
 {
     int i;
-    PlaylistContext *ctx = ff_playlist_alloc_context();
+    PlaylistContext *ctx = av_mallocz(sizeof(*ctx));
     m3u_list_files(s->pb, ctx, s->filename);
     s->priv_data = ctx;
     ff_playlist_populate_context(s);

Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c	Fri Jul 24 00:54:37 2009	(r4792)
+++ concat/libavformat/playlist.c	Fri Jul 24 01:08:31 2009	(r4793)
@@ -56,15 +56,6 @@ void ff_playlist_init_playelem(PlayElem 
         av_log(pe->ic, AV_LOG_ERROR, "ByteIOContext not set\n");
 }
 
-PlaylistContext* ff_playlist_alloc_context(void)
-{
-    int i;
-    PlaylistContext *ctx = av_mallocz(sizeof(*ctx));
-    ctx->time_offsets_size = 2; // TODO don't assume we have just 2 streams
-    ctx->time_offsets = av_mallocz(sizeof(*(ctx->time_offsets)) * ctx->time_offsets_size);
-    return ctx;
-}
-
 void ff_playlist_populate_context(AVFormatContext *s)
 {
     int i;
@@ -146,7 +137,7 @@ PlaylistContext *ff_playlist_from_encode
         av_free(flist);
         return NULL;
     }
-    ctx = ff_playlist_alloc_context();
+    ctx = av_mallocz(sizeof(*ctx));
     ff_playlist_relative_paths(flist, len, workingdir);
     for (i = 0; i < len; ++i)
         ff_playlist_add_path(ctx, flist[i]);

Modified: concat/libavformat/playlist.h
==============================================================================
--- concat/libavformat/playlist.h	Fri Jul 24 00:54:37 2009	(r4792)
+++ concat/libavformat/playlist.h	Fri Jul 24 01:08:31 2009	(r4793)
@@ -54,8 +54,7 @@ typedef struct PlaylistContext {
     PlayElem **pelist; /**< List of PlayElem, with each representing a playlist item */
     int pelist_size; /**< Number of PlayElem stored in pelist */
     int pe_curidx; /**< Index of the PlayElem that packets are being read from */
-    int time_offsets_size; /**< Number of time offsets (number of multimedia streams), 2 with audio and video. */
-    int64_t *time_offsets; /**< Time offsets, in 10^-6 seconds, for each multimedia stream */
+    int64_t time_offset; /**< Time offset, in 10^-6 seconds, for all multimedia streams */
 } PlaylistContext;
 
 /** @fn int ff_playlist_init_playelem(PlayElem* pe)
@@ -64,12 +63,6 @@ typedef struct PlaylistContext {
  */
 void ff_playlist_init_playelem(PlayElem* pe);
 
-/** @fn PlaylistContext* ff_playlist_alloc_context(void)
- *  @brief Allocates and returns a PlaylistContext.
- *  @return Returns the allocated PlaylistContext.
- */
-PlaylistContext* ff_playlist_alloc_context(void);
-
 /** @fn void ff_playlist_populate_context(PlaylistContext *playlc, AVFormatContext *s, int stream_index)
  *  @brief Opens the current PlayElem from the PlaylistContext.
  *  @param s AVFormatContext of the concat-type demuxer, which contains the PlaylistContext.

Modified: concat/libavformat/pls.c
==============================================================================
--- concat/libavformat/pls.c	Fri Jul 24 00:54:37 2009	(r4792)
+++ concat/libavformat/pls.c	Fri Jul 24 01:08:31 2009	(r4793)
@@ -116,7 +116,7 @@ static int pls_read_header(AVFormatConte
                            AVFormatParameters *ap)
 {
     int i;
-    PlaylistContext *ctx = ff_playlist_alloc_context();
+    PlaylistContext *ctx = av_mallocz(sizeof(*ctx));
     if (pls_list_files(s->pb, ctx, s->filename)) {
         fprintf(stderr, "no playlist items found in %s\n", s->filename);
         return AVERROR_EOF;

Modified: concat/libavformat/xspf.c
==============================================================================
--- concat/libavformat/xspf.c	Fri Jul 24 00:54:37 2009	(r4792)
+++ concat/libavformat/xspf.c	Fri Jul 24 01:08:31 2009	(r4793)
@@ -120,7 +120,7 @@ static int xspf_read_header(AVFormatCont
                             AVFormatParameters *ap)
 {
     int i;
-    PlaylistContext *ctx = ff_playlist_alloc_context();
+    PlaylistContext *ctx = av_mallocz(sizeof(*ctx));
     if (xspf_list_files(s->pb, ctx, s->filename)) {
         fprintf(stderr, "no playlist items found in %s\n", s->filename);
         return AVERROR_EOF;


More information about the FFmpeg-soc mailing list