[FFmpeg-soc] [soc]: r4698 - 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
Mon Jul 13 04:28:40 CEST 2009


Author: gkovacs
Date: Mon Jul 13 04:28:39 2009
New Revision: 4698

Log:
made playelem counter global rather than per multimedia stream

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	Mon Jul 13 04:16:17 2009	(r4697)
+++ concat/ffmpeg.c.diff	Mon Jul 13 04:28:39 2009	(r4698)
@@ -1,5 +1,5 @@
 diff --git a/ffmpeg.c b/ffmpeg.c
-index 22bfed8..097f12b 100644
+index 22bfed8..b34db3a 100644
 --- a/ffmpeg.c
 +++ b/ffmpeg.c
 @@ -70,6 +70,8 @@
@@ -76,7 +76,7 @@ index 22bfed8..097f12b 100644
      AVFormatContext *ic;
      AVFormatParameters params, *ap = &params;
      int err, i, ret, rfps, rfps_base;
-@@ -2859,6 +2869,45 @@ static void opt_input_file(const char *filename)
+@@ -2859,6 +2869,43 @@ static void opt_input_file(const char *filename)
      using_stdin |= !strncmp(filename, "pipe:", 5) ||
                      !strcmp(filename, "/dev/stdin");
  
@@ -99,9 +99,7 @@ index 22bfed8..097f12b 100644
 +            ic->nb_streams = 2;
 +            ic->iformat = ff_concat_alloc_demuxer();
 +            ic->priv_data = playlist_ctx;
-+            for (i = 0; i < playlist_ctx->pe_curidxs_size; ++i) {
-+                ff_playlist_populate_context(ic, i);
-+            }
++            ff_playlist_populate_context(ic);
 +            nb_input_files = 1;
 +            input_files[0] = ic;
 +            goto configcodecs;
@@ -122,7 +120,7 @@ index 22bfed8..097f12b 100644
      /* get default parameters from command line */
      ic = avformat_alloc_context();
  
-@@ -2925,6 +2974,8 @@ static void opt_input_file(const char *filename)
+@@ -2925,6 +2972,8 @@ static void opt_input_file(const char *filename)
          start_time = 0;
      }
  
@@ -131,7 +129,7 @@ index 22bfed8..097f12b 100644
      /* update the current parameters so that they match the one of the input stream */
      for(i=0;i<ic->nb_streams;i++) {
          AVCodecContext *enc = ic->streams[i]->codec;
-@@ -3000,6 +3051,8 @@ static void opt_input_file(const char *filename)
+@@ -3000,6 +3049,8 @@ static void opt_input_file(const char *filename)
          dump_format(ic, nb_input_files, filename, 0);
  
      nb_input_files++;
@@ -140,7 +138,7 @@ index 22bfed8..097f12b 100644
      file_iformat = NULL;
      file_oformat = NULL;
  
-@@ -3874,6 +3927,7 @@ static const OptionDef options[] = {
+@@ -3874,6 +3925,7 @@ static const OptionDef options[] = {
      { "programid", HAS_ARG | OPT_INT | OPT_EXPERT, {(void*)&opt_programid}, "desired program number", "" },
      { "xerror", OPT_BOOL, {(void*)&exit_on_error}, "exit on error", "error" },
      { "copyinkf", OPT_BOOL | OPT_EXPERT, {(void*)&copy_initial_nonkeyframes}, "copy initial non-keyframes" },

Modified: concat/libavformat/concatgen.c
==============================================================================
--- concat/libavformat/concatgen.c	Mon Jul 13 04:16:17 2009	(r4697)
+++ concat/libavformat/concatgen.c	Mon Jul 13 04:28:39 2009	(r4698)
@@ -33,11 +33,11 @@ int ff_concatgen_read_packet(AVFormatCon
     ctx = s->priv_data;
     stream_index = 0;
     retr:
-    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
+    ic = ctx->pelist[ctx->pe_curidx]->ic;
     ret = ic->iformat->read_packet(ic, pkt);
     if (pkt) {
         stream_index = pkt->stream_index;
-        ic = ctx->pelist[ctx->pe_curidxs[stream_index]]->ic;
+        ic = ctx->pelist[ctx->pe_curidx]->ic;
         pkt->stream = ic->streams[pkt->stream_index];
     }
     if (ret >= 0) {
@@ -50,15 +50,15 @@ int ff_concatgen_read_packet(AVFormatCon
             if (!ic->streams[pkt->stream_index]->codec->has_b_frames)
                 pkt->pts = pkt->dts + 1;
         }
-    } else if (ret < 0 && !have_switched_streams && ctx->pe_curidxs[stream_index] < ctx->pelist_size - 1) {
+    } else if (ret < 0 && !have_switched_streams && ctx->pe_curidx < ctx->pelist_size - 1) {
     // 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_curidxs[stream_index]+1);
-        for (i = 0; i < ic->nb_streams && i < ctx->pe_curidxs_size; ++i) {
+        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->pe_curidxs[stream_index];
-        ff_playlist_populate_context(s, stream_index);
+        ++ctx->pe_curidx;
+        ff_playlist_populate_context(s);
         have_switched_streams = 1;
         goto retr;
     } else {
@@ -75,7 +75,7 @@ int ff_concatgen_read_seek(AVFormatConte
     PlaylistContext *ctx;
     AVFormatContext *ic;
     ctx = s->priv_data;
-    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
+    ic = ctx->pelist[ctx->pe_curidx]->ic;
     return ic->iformat->read_seek(ic, stream_index, pts, flags);
 }
 
@@ -87,7 +87,7 @@ int ff_concatgen_read_timestamp(AVFormat
     PlaylistContext *ctx;
     AVFormatContext *ic;
     ctx = s->priv_data;
-    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
+    ic = ctx->pelist[ctx->pe_curidx]->ic;
     if (ic->iformat->read_timestamp)
         return ic->iformat->read_timestamp(ic, stream_index, pos, pos_limit);
     return 0;
@@ -98,7 +98,7 @@ int ff_concatgen_read_close(AVFormatCont
     PlaylistContext *ctx;
     AVFormatContext *ic;
     ctx = s->priv_data;
-    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
+    ic = ctx->pelist[ctx->pe_curidx]->ic;
     if (ic->iformat->read_close)
         return ic->iformat->read_close(ic);
     return 0;
@@ -109,7 +109,7 @@ int ff_concatgen_read_play(AVFormatConte
     PlaylistContext *ctx;
     AVFormatContext *ic;
     ctx = s->priv_data;
-    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
+    ic = ctx->pelist[ctx->pe_curidx]->ic;
     return av_read_play(ic);
 }
 
@@ -118,6 +118,6 @@ int ff_concatgen_read_pause(AVFormatCont
     PlaylistContext *ctx;
     AVFormatContext *ic;
     ctx = s->priv_data;
-    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
+    ic = ctx->pelist[ctx->pe_curidx]->ic;
     return av_read_pause(ic);
 }

Modified: concat/libavformat/m3u.c
==============================================================================
--- concat/libavformat/m3u.c	Mon Jul 13 04:16:17 2009	(r4697)
+++ concat/libavformat/m3u.c	Mon Jul 13 04:28:39 2009	(r4698)
@@ -97,9 +97,7 @@ static int m3u_read_header(AVFormatConte
     PlaylistContext *ctx = ff_playlist_alloc_context();
     m3u_list_files(s->pb, ctx, s->filename);
     s->priv_data = ctx;
-    for (i = 0; i < ctx->pe_curidxs_size; ++i) {
-        ff_playlist_populate_context(s, i);
-    }
+    ff_playlist_populate_context(s);
     return 0;
 }
 

Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c	Mon Jul 13 04:16:17 2009	(r4697)
+++ concat/libavformat/playlist.c	Mon Jul 13 04:28:39 2009	(r4698)
@@ -23,7 +23,7 @@
 #include "playlist.h"
 #include "internal.h"
 
-void ff_playlist_init_playelem(PlayElem *pe)
+int ff_playlist_init_playelem(PlayElem *pe)
 {
     int i;
     int err;
@@ -65,6 +65,7 @@ void ff_playlist_init_playelem(PlayElem 
             return AVERROR(EINVAL);
         }
     }
+    return 0;
 
 }
 
@@ -72,24 +73,21 @@ PlaylistContext* ff_playlist_alloc_conte
 {
     int i;
     PlaylistContext *ctx = av_malloc(sizeof(*ctx));
-    ctx->pe_curidxs_size = 2; // TODO don't assume we have just 2 streams
-    ctx->pe_curidxs = av_malloc(sizeof(*(ctx->pe_curidxs)) * ctx->pe_curidxs_size);
-    for (i = 0; i < ctx->pe_curidxs_size; ++i)
-        ctx->pe_curidxs[i] = 0;
-    ctx->time_offsets = av_malloc(sizeof(*(ctx->time_offsets)) * ctx->pe_curidxs_size);
-    for (i = 0; i < ctx->pe_curidxs_size; ++i)
+    ctx->pe_curidx = 0;
+    ctx->time_offsets_size = 2; // TODO don't assume we have just 2 streams
+    ctx->time_offsets = av_malloc(sizeof(*(ctx->time_offsets)) * ctx->time_offsets_size);
+    for (i = 0; i < ctx->time_offsets_size; ++i)
         ctx->time_offsets[i] = 0;
     return ctx;
 }
 
-void ff_playlist_populate_context(AVFormatContext *s,
-                                 int stream_index)
+void ff_playlist_populate_context(AVFormatContext *s)
 {
     int i;
     AVFormatContext *ic;
     PlaylistContext *ctx = s->priv_data;
-    ff_playlist_init_playelem(ctx->pelist[ctx->pe_curidxs[stream_index]]);
-    ic = ctx->pelist[ctx->pe_curidxs[stream_index]]->ic;
+    ff_playlist_init_playelem(ctx->pelist[ctx->pe_curidx]);
+    ic = ctx->pelist[ctx->pe_curidx]->ic;
     ic->iformat->read_header(ic, 0);
     s->nb_streams = ic->nb_streams;
     for (i = 0; i < ic->nb_streams; ++i) {

Modified: concat/libavformat/playlist.h
==============================================================================
--- concat/libavformat/playlist.h	Mon Jul 13 04:16:17 2009	(r4697)
+++ concat/libavformat/playlist.h	Mon Jul 13 04:28:39 2009	(r4698)
@@ -44,20 +44,21 @@ typedef struct PlayElem {
 typedef struct PlaylistContext {
     PlayElem **pelist; /**< List of PlayElem, with each representing a playlist item */
     int pelist_size; /**< Length of the pelist array (number of playlist items) */
-    int *pe_curidxs; /**< Index of the PlayElem that each multimedia stream (video and audio) is currently on */
-    int pe_curidxs_size; /**< Length of pe_curidxs array (number of multimedia streams) currently set to 2 (video and audio) */
+    int pe_curidx; /**< Index of the PlayElem that packets are being read from */
     AVChapter **chlist; /**< List of chapters, with each playlist element representing a chapter */
     char *workingdir; /**< Directory in which the playlist file is stored in */
     char *filename; /**< Filename (not path) of the playlist file */
+    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 */
 } PlaylistContext;
 
-/** @fn void ff_playlist_init_playelem(PlayElem* pe)
+/** @fn int ff_playlist_init_playelem(PlayElem* pe)
  *  @brief Opens file, codecs, and streams associated with PlayElem.
  *  @param pe PlayElem to open. It should already be allocated.
+ *  @return 0 if successful.
  */
 
-void ff_playlist_init_playelem(PlayElem* pe);
+int ff_playlist_init_playelem(PlayElem* pe);
 
 
 /** @fn PlaylistContext* ff_playlist_alloc_context(void)
@@ -73,7 +74,7 @@ PlaylistContext* ff_playlist_alloc_conte
  *  @param stream_index Index of multimedia stream (video, audio, or subtitle).
  */
 
-void ff_playlist_populate_context(AVFormatContext *s, int stream_index);
+void ff_playlist_populate_context(AVFormatContext *s);
 
 PlaylistContext* ff_playlist_get_context(AVFormatContext *ic);
 

Modified: concat/libavformat/pls.c
==============================================================================
--- concat/libavformat/pls.c	Mon Jul 13 04:16:17 2009	(r4697)
+++ concat/libavformat/pls.c	Mon Jul 13 04:28:39 2009	(r4698)
@@ -123,9 +123,7 @@ static int pls_read_header(AVFormatConte
         return AVERROR_EOF;
     }
     s->priv_data = ctx;
-    for (i = 0; i < ctx->pe_curidxs_size; ++i) {
-        ff_playlist_populate_context(s, i);
-    }
+    ff_playlist_populate_context(s);
     return 0;
 }
 

Modified: concat/libavformat/xspf.c
==============================================================================
--- concat/libavformat/xspf.c	Mon Jul 13 04:16:17 2009	(r4697)
+++ concat/libavformat/xspf.c	Mon Jul 13 04:28:39 2009	(r4698)
@@ -127,9 +127,7 @@ static int xspf_read_header(AVFormatCont
         return AVERROR_EOF;
     }
     s->priv_data = ctx;
-    for (i = 0; i < ctx->pe_curidxs_size; ++i) {
-        ff_playlist_populate_context(s, i);
-    }
+    ff_playlist_populate_context(s);
     return 0;
 }
 


More information about the FFmpeg-soc mailing list