[FFmpeg-soc] [soc]: r4693 - in concat/libavformat: m3u.c playlist.c playlist.h pls.c xspf.c

gkovacs subversion at mplayerhq.hu
Mon Jul 13 02:10:14 CEST 2009


Author: gkovacs
Date: Mon Jul 13 02:10:14 2009
New Revision: 4693

Log:
removed ff_split_wd_fn

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

Modified: concat/libavformat/m3u.c
==============================================================================
--- concat/libavformat/m3u.c	Mon Jul 13 01:00:27 2009	(r4692)
+++ concat/libavformat/m3u.c	Mon Jul 13 02:10:14 2009	(r4693)
@@ -52,7 +52,7 @@ static int m3u_probe(AVProbeData *p)
         return 0;
 }
 
-static int m3u_list_files(ByteIOContext *s, PlaylistContext *ctx)
+static int m3u_list_files(ByteIOContext *s, PlaylistContext *ctx, const char *filename)
 {
     char **flist;
     int i, j;
@@ -77,7 +77,7 @@ static int m3u_list_files(ByteIOContext 
     }
     ctx->pelist_size = i;
     flist[i] = 0;
-    ff_playlist_relative_paths(flist, ctx->workingdir);
+    ff_playlist_relative_paths(flist, dirname(filename));
     ctx->pelist = av_malloc(ctx->pelist_size * sizeof(*(ctx->pelist)));
     memset(ctx->pelist, 0, ctx->pelist_size * sizeof(*(ctx->pelist)));
     for (i = 0; i < ctx->pelist_size; ++i) {
@@ -92,8 +92,8 @@ static int m3u_read_header(AVFormatConte
                            AVFormatParameters *ap)
 {
     int i;
-    PlaylistContext *ctx = ff_playlist_alloc_context(s->filename);
-    m3u_list_files(s->pb, ctx);
+    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(ctx, s, i);

Modified: concat/libavformat/playlist.c
==============================================================================
--- concat/libavformat/playlist.c	Mon Jul 13 01:00:27 2009	(r4692)
+++ concat/libavformat/playlist.c	Mon Jul 13 02:10:14 2009	(r4693)
@@ -68,7 +68,7 @@ void ff_playlist_init_playelem(PlayElem 
 
 }
 
-PlaylistContext* ff_playlist_alloc_context(const char *filename)
+PlaylistContext* ff_playlist_alloc_context()
 {
     int i;
     PlaylistContext *ctx = av_malloc(sizeof(*ctx));
@@ -79,36 +79,9 @@ PlaylistContext* ff_playlist_alloc_conte
     ctx->time_offsets = av_malloc(sizeof(*(ctx->time_offsets)) * ctx->pe_curidxs_size);
     for (i = 0; i < ctx->pe_curidxs_size; ++i)
         ctx->time_offsets[i] = 0;
-    ff_split_wd_fn(filename,
-                   &ctx->workingdir,
-                   &ctx->filename);
     return ctx;
 }
 
-void ff_split_wd_fn(const char *filepath,
-                    char **workingdir,
-                    char **filename)
-{
-    char *ofp;
-    char *cofp;
-    char *lslash = filepath;
-    ofp = filepath;
-    cofp = filepath;
-    while (*filepath != 0) {
-        if (*filepath == '/' || *filepath == '\\')
-            lslash = filepath+1;
-        ++filepath;
-    }
-    *workingdir = av_malloc((lslash-ofp)+1);
-    *filename = av_malloc((filepath-lslash)+1);
-    while (cofp < lslash)
-        (*workingdir)[cofp-ofp] = *(cofp++);
-    (*workingdir)[cofp-ofp] = 0;
-    while (cofp < filepath)
-        (*filename)[cofp-lslash] = *(cofp++);
-    (*filename)[cofp-lslash] = 0;
-}
-
 int ff_playlist_populate_context(PlaylistContext *ctx,
                                  AVFormatContext *s,
                                  int stream_index)
@@ -135,11 +108,11 @@ void ff_playlist_relative_paths(char **f
         char *fullfpath;
         int wdslen = strlen(workingdir);
         int flslen = strlen(*flist);
-        fullfpath = av_malloc(sizeof(char) * (wdslen+flslen+1));
-        av_strlcpy(fullfpath, workingdir, wdslen);
-        av_strlcpy(fullfpath+wdslen, *flist, flslen+1);
-        fullfpath[wdslen-1] = '/';
-        fullfpath[wdslen+flslen] = 0;
+        fullfpath = av_malloc(sizeof(char) * (wdslen+flslen+2));
+        av_strlcpy(fullfpath, workingdir, wdslen+1);
+        fullfpath[wdslen] = '/';
+        fullfpath[wdslen+1] = 0;
+        av_strlcat(fullfpath, *flist, wdslen+flslen+2);
         file = fopen(fullfpath, "r");
         if (file) {
             fclose(file);

Modified: concat/libavformat/playlist.h
==============================================================================
--- concat/libavformat/playlist.h	Mon Jul 13 01:00:27 2009	(r4692)
+++ concat/libavformat/playlist.h	Mon Jul 13 02:10:14 2009	(r4693)
@@ -24,6 +24,7 @@
 
 #include "avformat.h"
 #include "riff.h"
+#include <libgen.h>
 
 /** @struct PlayElem
  *  @brief Represents each input file on a playlist
@@ -53,12 +54,10 @@ typedef struct PlaylistContext {
 
 void ff_playlist_init_playelem(PlayElem* pe);
 
-PlaylistContext* ff_playlist_alloc_context(const char *filename);
+PlaylistContext* ff_playlist_alloc_context();
 
 int ff_playlist_populate_context(PlaylistContext *playlc, AVFormatContext *s, int stream_index);
 
-void ff_split_wd_fn(const char *filepath, char **workingdir, char **filename);
-
 void ff_playlist_relative_paths(char **flist, const char *workingdir);
 
 PlaylistContext* ff_playlist_get_context(AVFormatContext *ic);

Modified: concat/libavformat/pls.c
==============================================================================
--- concat/libavformat/pls.c	Mon Jul 13 01:00:27 2009	(r4692)
+++ concat/libavformat/pls.c	Mon Jul 13 02:10:14 2009	(r4693)
@@ -52,7 +52,7 @@ static int pls_probe(AVProbeData *p)
         return 0;
 }
 
-static int pls_list_files(ByteIOContext *b, PlaylistContext *ctx)
+static int pls_list_files(ByteIOContext *b, PlaylistContext *ctx, const char *filename)
 {
     int i, j, c;
     unsigned int buflen;
@@ -100,7 +100,7 @@ static int pls_list_files(ByteIOContext 
         return AVERROR_EOF;
     flist[j] = 0;
     ctx->pelist_size = j;
-    ff_playlist_relative_paths(flist, ctx->workingdir);
+    ff_playlist_relative_paths(flist, dirname(filename));
     ctx->pelist = av_malloc(ctx->pelist_size * sizeof(*(ctx->pelist)));
     memset(ctx->pelist, 0, ctx->pelist_size * sizeof(*(ctx->pelist)));
     for (i = 0; i < ctx->pelist_size; ++i) {
@@ -115,8 +115,8 @@ static int pls_read_header(AVFormatConte
                            AVFormatParameters *ap)
 {
     int i;
-    PlaylistContext *ctx = ff_playlist_alloc_context(s->filename);
-    if (pls_list_files(s->pb, ctx)) {
+    PlaylistContext *ctx = ff_playlist_alloc_context();
+    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	Mon Jul 13 01:00:27 2009	(r4692)
+++ concat/libavformat/xspf.c	Mon Jul 13 02:10:14 2009	(r4693)
@@ -19,6 +19,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "avformat.h"
+
+
 #include "playlist.h"
 
 static int ff_concatgen_read_packet(AVFormatContext *s, AVPacket *pkt);
@@ -52,7 +55,7 @@ static int xspf_probe(AVProbeData *p)
         return 0;
 }
 
-static int xspf_list_files(ByteIOContext *b, PlaylistContext *ctx)
+static int xspf_list_files(ByteIOContext *b, PlaylistContext *ctx, const char *filename)
 {
     int i, j, c;
     unsigned int buflen;
@@ -101,7 +104,7 @@ static int xspf_list_files(ByteIOContext
         return AVERROR_EOF;
     flist[j] = 0;
     ctx->pelist_size = j;
-    ff_playlist_relative_paths(flist, ctx->workingdir);
+    ff_playlist_relative_paths(flist, dirname(filename));
     ctx->pelist = av_malloc(ctx->pelist_size * sizeof(*(ctx->pelist)));
     memset(ctx->pelist, 0, ctx->pelist_size * sizeof(*(ctx->pelist)));
     for (i = 0; i < ctx->pelist_size; ++i) {
@@ -116,8 +119,8 @@ static int xspf_read_header(AVFormatCont
                             AVFormatParameters *ap)
 {
     int i;
-    PlaylistContext *ctx = ff_playlist_alloc_context(s->filename);
-    if (xspf_list_files(s->pb, ctx)) {
+    PlaylistContext *ctx = ff_playlist_alloc_context();
+    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