[FFmpeg-soc] [soc]: r4601 - in concat/libavformat: concatgen.c m3u.c playlist.c playlist.h

gkovacs subversion at mplayerhq.hu
Sat Jul 4 23:19:37 CEST 2009


Author: gkovacs
Date: Sat Jul  4 23:19:36 2009
New Revision: 4601

Log:
renamed PlaylistC to PlaylistContext

Modified:
   concat/libavformat/concatgen.c
   concat/libavformat/m3u.c
   concat/libavformat/playlist.c
   concat/libavformat/playlist.h

Modified: concat/libavformat/concatgen.c
==============================================================================
--- concat/libavformat/concatgen.c	Sat Jul  4 22:49:33 2009	(r4600)
+++ concat/libavformat/concatgen.c	Sat Jul  4 23:19:36 2009	(r4601)
@@ -22,25 +22,25 @@
 #include "concatgen.h"
 
 int concatgen_read_packet(AVFormatContext *s,
-                       AVPacket *pkt)
+                          AVPacket *pkt)
 {
     int i;
     int ret;
     int stream_index;
-    PlaylistC *playld;
+    PlaylistContext *ctx;
     AVFormatContext *ic;
-    playld = s->priv_data;
+    ctx = s->priv_data;
     stream_index = 0;
     retr:
-    ic = playld->pelist[playld->pe_curidxs[0]]->ic;
+    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
     ret = ic->iformat->read_packet(ic, pkt);
     if (pkt) {
         stream_index = pkt->stream_index;
-        ic = playld->pelist[playld->pe_curidxs[stream_index]]->ic;
+        ic = ctx->pelist[ctx->pe_curidxs[stream_index]]->ic;
     }
     if (ret >= 0) {
         if (pkt) {
-            int64_t time_offset = ff_conv_stream_time(ic, pkt->stream_index, playld->time_offsets[pkt->stream_index]);
+            int64_t time_offset = ff_conv_stream_time(ic, pkt->stream_index, ctx->time_offsets[pkt->stream_index]);
             pkt->dts += time_offset;
             if (!ic->streams[pkt->stream_index]->codec->has_b_frames)
                 pkt->pts = pkt->dts + 1;
@@ -48,7 +48,7 @@ int concatgen_read_packet(AVFormatContex
     }
     // TODO switch from AVERROR_EOF to AVERROR_EOS
     // -32 AVERROR_EOF for avi, -51 for ogg
-    else if (ret < 0 && playld->pe_curidxs[stream_index] < playld->pelist_size - 1) {
+    else if (ret < 0 && ctx->pe_curidxs[stream_index] < ctx->pelist_size - 1) {
         // TODO account for out-of-sync audio/video by using per-stream offsets
         // using streams[]->duration slightly overestimates offset
 //        playld->dts_offset += ic->streams[0]->duration;
@@ -56,14 +56,14 @@ int concatgen_read_packet(AVFormatContex
 //        playld->dts_offset += ic->streams[0]->cur_dts;
 //        playld->dts_offset += playld->dts_prevpacket;
         printf("switching streams\n");
-        for (i = 0; i < ic->nb_streams && i < playld->time_offsets_size; ++i) {
-            playld->time_offsets[i] += ff_get_duration(ic, i);
+        for (i = 0; i < ic->nb_streams && i < ctx->time_offsets_size; ++i) {
+            ctx->time_offsets[i] += ff_get_duration(ic, i);
         }
-        ++playld->pe_curidxs[stream_index];
+        ++ctx->pe_curidxs[stream_index];
 //        pkt->destruct(pkt);
         pkt = av_malloc(sizeof(AVPacket));
 //        for (i = 0; i < playld->pe_curidxs_size; ++i) {
-            ff_playlist_populate_context(playld, s, stream_index);
+            ff_playlist_populate_context(ctx, s, stream_index);
 //        }
         goto retr;
     }
@@ -78,10 +78,10 @@ int concatgen_read_seek(AVFormatContext 
                      int64_t pts,
                      int flags)
 {
-    PlaylistC *playld;
+    PlaylistContext *ctx;
     AVFormatContext *ic;
-    playld = s->priv_data;
-    ic = playld->pelist[playld->pe_curidxs[0]]->ic;
+    ctx = s->priv_data;
+    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
     ic->iformat->read_seek(ic, stream_index, pts, flags);
 }
 
@@ -91,10 +91,10 @@ int concatgen_read_timestamp(AVFormatCon
                              int64_t pos_limit)
 {
     printf("m3u_read_timestamp called\n");
-    PlaylistC *playld;
+    PlaylistContext *ctx;
     AVFormatContext *ic;
-    playld = s->priv_data;
-    ic = playld->pelist[playld->pe_curidxs[0]]->ic;
+    ctx = s->priv_data;
+    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
     if (ic->iformat->read_timestamp)
         return ic->iformat->read_timestamp(ic, stream_index, pos, pos_limit);
     return 0;
@@ -103,10 +103,10 @@ int concatgen_read_timestamp(AVFormatCon
 int concatgen_read_close(AVFormatContext *s)
 {
     printf("m3u_read_close called\n");
-    PlaylistC *playld;
+    PlaylistContext *ctx;
     AVFormatContext *ic;
-    playld = s->priv_data;
-    ic = playld->pelist[playld->pe_curidxs[0]]->ic;
+    ctx = s->priv_data;
+    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
     if (ic->iformat->read_close)
         return ic->iformat->read_close(ic);
     return 0;
@@ -115,19 +115,19 @@ int concatgen_read_close(AVFormatContext
 int concatgen_read_play(AVFormatContext *s)
 {
     printf("m3u_read_play called\n");
-    PlaylistC *playld;
+    PlaylistContext *ctx;
     AVFormatContext *ic;
-    playld = s->priv_data;
-    ic = playld->pelist[playld->pe_curidxs[0]]->ic;
+    ctx = s->priv_data;
+    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
     return av_read_play(ic);
 }
 
 int concatgen_read_pause(AVFormatContext *s)
 {
     printf("m3u_read_pause called\n");
-    PlaylistC *playld;
+    PlaylistContext *ctx;
     AVFormatContext *ic;
-    playld = s->priv_data;
-    ic = playld->pelist[playld->pe_curidxs[0]]->ic;
+    ctx = s->priv_data;
+    ic = ctx->pelist[ctx->pe_curidxs[0]]->ic;
     return av_read_pause(ic);
 }

Modified: concat/libavformat/m3u.c
==============================================================================
--- concat/libavformat/m3u.c	Sat Jul  4 22:49:33 2009	(r4600)
+++ concat/libavformat/m3u.c	Sat Jul  4 23:19:36 2009	(r4601)
@@ -82,16 +82,16 @@ static int m3u_read_header(AVFormatConte
                            AVFormatParameters *ap)
 {
     int i;
-    PlaylistC *playlc = ff_make_playlistc(s->filename);
+    PlaylistContext *ctx = ff_make_playlistc(s->filename);
     m3u_list_files(s->pb,
-                   &(playlc->flist),
-                   &(playlc->pelist_size),
-                   playlc->workingdir);
-    playlc->pelist = av_malloc(playlc->pelist_size * sizeof(PlayElem*));
-    memset(playlc->pelist, 0, playlc->pelist_size * sizeof(PlayElem*));
-    s->priv_data = playlc;
-    for (i = 0; i < playlc->pe_curidxs_size; ++i) {
-        ff_playlist_populate_context(playlc, s, i);
+                   &(ctx->flist),
+                   &(ctx->pelist_size),
+                   ctx->workingdir);
+    ctx->pelist = av_malloc(ctx->pelist_size * sizeof(PlayElem*));
+    memset(ctx->pelist, 0, ctx->pelist_size * sizeof(PlayElem*));
+    s->priv_data = ctx;
+    for (i = 0; i < ctx->pe_curidxs_size; ++i) {
+        ff_playlist_populate_context(ctx, s, i);
     }
     return 0;
 }

Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c	Sat Jul  4 22:49:33 2009	(r4600)
+++ concat/libavformat/playlist.c	Sat Jul  4 23:19:36 2009	(r4601)
@@ -30,9 +30,9 @@ int ff_alloc_playelem(unsigned char *fil
 {
     AVFormatContext *ic;
     AVFormatParameters *ap;
-    ic = av_malloc(sizeof(AVFormatContext));
-    ap = av_malloc(sizeof(AVFormatParameters));
-    memset(ap, 0, sizeof(AVFormatParameters));
+    ic = av_malloc(sizeof(*ic));
+    ap = av_malloc(sizeof(*ap));
+    memset(ap, 0, sizeof(*ap));
     ap->width = 0;
     ap->height = 0;
     ap->time_base = (AVRational){1, 25};
@@ -48,7 +48,7 @@ int ff_alloc_playelem(unsigned char *fil
 PlayElem* ff_make_playelem(char *filename)
 {
     int err;
-    PlayElem *pe = av_malloc(sizeof(PlayElem));
+    PlayElem *pe = av_malloc(sizeof(*pe));
     err = ff_alloc_playelem(filename, pe);
     if (err < 0)
         print_error("during-av_alloc_playelem", err);
@@ -77,22 +77,22 @@ PlayElem* ff_make_playelem(char *filenam
     return pe;
 }
 
-PlaylistC* ff_make_playlistc(char *filename)
+PlaylistContext* ff_make_playlistc(char *filename)
 {
     int i;
-    PlaylistC *playlc = av_malloc(sizeof(PlaylistC));
-    playlc->time_offsets_size = 2; // TODO don't assume we have just 2 streams
-    playlc->time_offsets = av_malloc(sizeof(playlc->time_offsets) * playlc->time_offsets_size);
-    for (i = 0; i < playlc->time_offsets_size; ++i)
-        playlc->time_offsets[i] = 0;
-    playlc->pe_curidxs_size = 2; // TODO don't assume we have just 2 streams
-    playlc->pe_curidxs = av_malloc(sizeof(playlc->pe_curidxs) * playlc->pe_curidxs_size);
-    for (i = 0; i < playlc->pe_curidxs_size; ++i)
-        playlc->pe_curidxs[i] = 0;
+    PlaylistContext *ctx = av_malloc(sizeof(*ctx));
+    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;
+    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;
     ff_split_wd_fn(filename,
-                   &playlc->workingdir,
-                   &playlc->filename);
-    return playlc;
+                   &ctx->workingdir,
+                   &ctx->filename);
+    return ctx;
 }
 
 char* ff_conc_strings(char *string1,
@@ -172,7 +172,7 @@ void ff_split_wd_fn(char *filepath,
     (*filename)[cofp-lslash] = 0;
 }
 
-int ff_playlist_populate_context(PlaylistC *playlc,
+int ff_playlist_populate_context(PlaylistContext *ctx,
                                  AVFormatContext *s,
                                  int stream_index)
 {
@@ -180,9 +180,9 @@ int ff_playlist_populate_context(Playlis
     AVFormatContext *ic;
     AVFormatParameters *nap;
     printf("playlist_populate_context called\n");
-    playlc->pelist[playlc->pe_curidxs[stream_index]] = ff_make_playelem(playlc->flist[playlc->pe_curidxs[stream_index]]);
-    ic = playlc->pelist[playlc->pe_curidxs[stream_index]]->ic;
-    nap = playlc->pelist[playlc->pe_curidxs[stream_index]]->ap;
+    ctx->pelist[ctx->pe_curidxs[stream_index]] = ff_make_playelem(ctx->flist[ctx->pe_curidxs[stream_index]]);
+    ic = ctx->pelist[ctx->pe_curidxs[stream_index]]->ic;
+    nap = ctx->pelist[ctx->pe_curidxs[stream_index]]->ap;
     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	Sat Jul  4 22:49:33 2009	(r4600)
+++ concat/libavformat/playlist.h	Sat Jul  4 23:19:36 2009	(r4601)
@@ -35,7 +35,7 @@ typedef struct PlayElem {
     int64_t indv_time;
 } PlayElem;
 
-typedef struct PlaylistC {
+typedef struct PlaylistContext {
     char **flist;
 //    int flist_len;
     PlayElem **pelist;
@@ -50,13 +50,13 @@ typedef struct PlaylistC {
     char *filename;
     int64_t *time_offsets;
     int time_offsets_size;
-} PlaylistC;
+} PlaylistContext;
 
 PlayElem* ff_make_playelem(char *filename);
 
-PlaylistC* ff_make_playlistc(char *filename);
+PlaylistContext* ff_make_playlistc(char *filename);
 
-int ff_playlist_populate_context(PlaylistC *playlc, AVFormatContext *s, int stream_index);
+int ff_playlist_populate_context(PlaylistContext *playlc, AVFormatContext *s, int stream_index);
 
 char* ff_conc_strings(char *string1, char *string2);
 


More information about the FFmpeg-soc mailing list