[FFmpeg-soc] [soc]: r4620 - in concat/libavformat: Makefile.diff allformats.c.diff concat.c datanode.c datanode.h pls.c

gkovacs subversion at mplayerhq.hu
Sun Jul 5 21:52:51 CEST 2009


Author: gkovacs
Date: Sun Jul  5 21:52:51 2009
New Revision: 4620

Log:
added pls demuxer

Modified:
   concat/libavformat/Makefile.diff
   concat/libavformat/allformats.c.diff
   concat/libavformat/concat.c
   concat/libavformat/datanode.c
   concat/libavformat/datanode.h
   concat/libavformat/pls.c

Modified: concat/libavformat/Makefile.diff
==============================================================================
--- concat/libavformat/Makefile.diff	Sun Jul  5 21:48:52 2009	(r4619)
+++ concat/libavformat/Makefile.diff	Sun Jul  5 21:52:51 2009	(r4620)
@@ -1,12 +1,12 @@
 diff --git a/libavformat/Makefile b/libavformat/Makefile
-index 8e8a869..23074a7 100644
+index 8e8a869..1dee9be 100644
 --- a/libavformat/Makefile
 +++ b/libavformat/Makefile
 @@ -175,6 +175,7 @@ OBJS-$(CONFIG_PCM_U32LE_DEMUXER)         += raw.o
  OBJS-$(CONFIG_PCM_U32LE_MUXER)           += raw.o
  OBJS-$(CONFIG_PCM_U8_DEMUXER)            += raw.o
  OBJS-$(CONFIG_PCM_U8_MUXER)              += raw.o
-+OBJS-$(CONFIG_CONCAT_DEMUXER)            += m3u.o playlist.o concat.o concatgen.o datanode.o
++OBJS-$(CONFIG_CONCAT_DEMUXER)            += m3u.o pls.o playlist.o concat.o concatgen.o datanode.o
  OBJS-$(CONFIG_PSP_MUXER)                 += movenc.o riff.o isom.o avc.o
  OBJS-$(CONFIG_PVA_DEMUXER)               += pva.o
  OBJS-$(CONFIG_QCP_DEMUXER)               += qcp.o

Modified: concat/libavformat/allformats.c.diff
==============================================================================
--- concat/libavformat/allformats.c.diff	Sun Jul  5 21:48:52 2009	(r4619)
+++ concat/libavformat/allformats.c.diff	Sun Jul  5 21:52:51 2009	(r4620)
@@ -1,12 +1,14 @@
 diff --git a/libavformat/allformats.c b/libavformat/allformats.c
-index ad47631..08a460b 100644
+index ad47631..433be82 100644
 --- a/libavformat/allformats.c
 +++ b/libavformat/allformats.c
-@@ -66,6 +66,7 @@ void av_register_all(void)
+@@ -66,6 +66,9 @@ void av_register_all(void)
      REGISTER_DEMUXER  (BFI, bfi);
      REGISTER_DEMUXER  (C93, c93);
      REGISTER_DEMUXER  (CAVSVIDEO, cavsvideo);
++    REGISTER_DEMUXER  (CONCAT, concat);
 +    REGISTER_DEMUXER  (M3U, m3u);
++    REGISTER_DEMUXER  (PLS, pls);
      REGISTER_MUXER    (CRC, crc);
      REGISTER_MUXDEMUX (DAUD, daud);
      REGISTER_MUXDEMUX (DIRAC, dirac);

Modified: concat/libavformat/concat.c
==============================================================================
--- concat/libavformat/concat.c	Sun Jul  5 21:48:52 2009	(r4619)
+++ concat/libavformat/concat.c	Sun Jul  5 21:52:51 2009	(r4620)
@@ -63,7 +63,7 @@ AVInputFormat *concat_make_demuxer()
     return cdm;
 }
 
-#if 0
+#if CONFIG_CONCAT_DEMUXER
 AVInputFormat concat_demuxer = {
     "concat",
     NULL_IF_CONFIG_SMALL("CONCAT format"),

Modified: concat/libavformat/datanode.c
==============================================================================
--- concat/libavformat/datanode.c	Sun Jul  5 21:48:52 2009	(r4619)
+++ concat/libavformat/datanode.c	Sun Jul  5 21:52:51 2009	(r4620)
@@ -40,9 +40,9 @@ DataNode *ff_datanode_mknext(DataNode *o
     return d;
 }
 
-DataNode *ff_datanode_tree_from_ini(char *p)
+DataNode *ff_datanode_tree_from_ini(ByteIOContext *p)
 {
-    char c;
+    int c;
     char *s;
     char e;
     int i, b;
@@ -54,7 +54,10 @@ DataNode *ff_datanode_tree_from_ini(char
     s = d->name;
     e = 1;
     i = b = 0;
-    while ((c = *p++)) {
+    while (1) {
+        c = url_fgetc(p);
+        if (c == 0 || c == EOF)
+            break;
         if (c == '\n') {
             d = ff_datanode_mknext(d);
             i = b = 0;
@@ -106,7 +109,7 @@ DataNode *ff_datanode_tree_from_ini(char
     return o;
 }
 
-DataNode *ff_datanode_tree_from_xml(char *p)
+DataNode *ff_datanode_tree_from_xml(ByteIOContext *p)
 {
     // TODO
     return NULL;
@@ -143,9 +146,9 @@ void ff_datanode_filter_values_by_name(D
     ff_datanode_filter_values_by_name(ff_datanode_getlognext(d), l, n);
 }
 
-int ff_datanode_getdepth(DataNode *d)
+unsigned int ff_datanode_getdepth(DataNode *d)
 {
-    int i = 0;
+    unsigned int i = 0;
     while ((d = d->parent))
         ++i;
     return i;
@@ -190,6 +193,28 @@ void ff_stringlist_append(StringList *l,
         l->str = str;
 }
 
+void ff_stringlist_export(StringList *l, char ***flist_ptr, unsigned int *lfx_ptr)
+{
+    unsigned int i;
+    char **flist;
+    unsigned int strlen = ff_stringlist_len(l);
+    *lfx_ptr = strlen;
+    flist = av_malloc(sizeof(*flist)*(strlen+1));
+    memset(flist, 0, sizeof(*flist)*(strlen+1));
+    for (i = 0; l && (i < strlen); ++i) {
+        flist[i] = (l = l->next);
+    }
+    *flist_ptr = flist;
+}
+
+unsigned int ff_stringlist_len(StringList *l)
+{
+    unsigned int i = 0;
+    while ((l = l->next))
+        ++i;
+    return i;
+}
+
 void ff_stringlist_print(StringList *l)
 {
     if (!l)
@@ -200,3 +225,4 @@ void ff_stringlist_print(StringList *l)
     putchar('\n');
     ff_stringlist_print(l->next);
 }
+

Modified: concat/libavformat/datanode.h
==============================================================================
--- concat/libavformat/datanode.h	Sun Jul  5 21:48:52 2009	(r4619)
+++ concat/libavformat/datanode.h	Sun Jul  5 21:52:51 2009	(r4620)
@@ -44,15 +44,15 @@ DataNode *ff_datanode_mkchild(DataNode *
 
 DataNode *ff_datanode_mknext(DataNode *o);
 
-DataNode *ff_datanode_tree_from_ini(char *p);
+DataNode *ff_datanode_tree_from_ini(ByteIOContext *p);
 
-DataNode *ff_datanode_tree_from_xml(char *p);
+DataNode *ff_datanode_tree_from_xml(ByteIOContext *p);
 
 DataNode *ff_datanode_getlognext(DataNode *d);
 
 void ff_datanode_filter_values_by_name(DataNode *d, StringList *l, char *n);
 
-int ff_datanode_getdepth(DataNode *d);
+unsigned int ff_datanode_getdepth(DataNode *d);
 
 void ff_datanode_visualize(DataNode *d);
 
@@ -60,6 +60,10 @@ StringList *ff_stringlist_alloc();
 
 void ff_stringlist_append(StringList *l, char *str);
 
+void ff_stringlist_export(StringList *l, char ***flist_ptr, unsigned int *lfx_ptr);
+
 void ff_stringlist_print(StringList *l);
 
+unsigned int ff_stringlist_len(StringList *l);
+
 #endif /* AVFORMAT_DATANODE_H */

Modified: concat/libavformat/pls.c
==============================================================================
--- concat/libavformat/pls.c	Sun Jul  5 21:48:52 2009	(r4619)
+++ concat/libavformat/pls.c	Sun Jul  5 21:52:51 2009	(r4620)
@@ -1,2 +1,99 @@
+/*
+ * PLS muxer and demuxer
+ * Copyright (c) 2009 Geza Kovacs
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
 
+#include "concatgen.h"
+#include "datanode.h"
 
+/* The ffmpeg codecs we support, and the IDs they have in the file */
+static const AVCodecTag codec_pls_tags[] = {
+    { 0, 0 },
+};
+
+static int pls_probe(AVProbeData *p)
+{
+    if (p->buf != 0) {
+        if (!strncmp(p->buf, "[playli", 7))
+            return AVPROBE_SCORE_MAX;
+        else
+            return 0;
+    }
+    if (match_ext(p->filename, "pls"))
+        return AVPROBE_SCORE_MAX/2;
+    else
+        return 0;
+}
+
+static int pls_list_files(ByteIOContext *s,
+                          char ***flist_ptr,
+                          unsigned int *lfx_ptr,
+                          char *workingdir)
+{
+    StringList *l;
+    DataNode *d;
+    l = ff_stringlist_alloc();
+    d = ff_datanode_tree_from_ini(s);
+    ff_datanode_visualize(d);
+    ff_datanode_filter_values_by_name(d, l, "File");
+    ff_stringlist_print(l);
+    ff_stringlist_export(l, flist_ptr, lfx_ptr);
+    return 0;
+}
+
+static int pls_read_header(AVFormatContext *s,
+                           AVFormatParameters *ap)
+{
+    int i;
+    PlaylistContext *ctx = ff_playlist_make_context(s->filename);
+    pls_list_files(s->pb,
+                   &(ctx->flist),
+                   &(ctx->pelist_size),
+                   ctx->workingdir);
+    ctx->pelist = av_malloc(ctx->pelist_size * sizeof(*(ctx->pelist)));
+    memset(ctx->pelist, 0, ctx->pelist_size * sizeof(*(ctx->pelist)));
+    s->priv_data = ctx;
+    for (i = 0; i < ctx->pe_curidxs_size; ++i) {
+        ff_playlist_populate_context(ctx, s, i);
+    }
+    return 0;
+}
+
+#if CONFIG_PLS_DEMUXER
+AVInputFormat pls_demuxer = {
+    "pls",
+    NULL_IF_CONFIG_SMALL("PLS format"),
+    sizeof(PlaylistContext),
+    pls_probe,
+    pls_read_header,
+    ff_concatgen_read_packet,
+    ff_concatgen_read_close,
+    ff_concatgen_read_seek,
+    ff_concatgen_read_timestamp,
+    NULL, //flags
+    NULL, //extensions
+    NULL, //value
+    ff_concatgen_read_play,
+    ff_concatgen_read_pause,
+    (const AVCodecTag* const []){codec_pls_tags, 0},
+    ff_concatgen_read_seek, //m3u_read_seek2
+    NULL, //metadata_conv
+    NULL, //next
+};
+#endif


More information about the FFmpeg-soc mailing list