[SCM] libav/experimental: oggdec: Parse skeleton to determine the start time of each stream

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 17:04:08 UTC 2013


The following commit has been merged in the experimental branch:
commit 32ad8692846ab5cdc8f9d5126f6ac2cf437ee4e9
Author: David Conrad <lessen42 at gmail.com>
Date:   Thu Mar 11 07:17:40 2010 +0000

    oggdec: Parse skeleton to determine the start time of each stream
    
    Originally committed as revision 22457 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 67a19e4..3587467 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -144,6 +144,7 @@ OBJS-$(CONFIG_OGG_DEMUXER)               += oggdec.o         \
                                             oggparsedirac.o  \
                                             oggparseflac.o   \
                                             oggparseogm.o    \
+                                            oggparseskeleton.o \
                                             oggparsespeex.o  \
                                             oggparsetheora.o \
                                             oggparsevorbis.o \
diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c
index f079946..58b8f96 100644
--- a/libavformat/oggdec.c
+++ b/libavformat/oggdec.c
@@ -38,6 +38,7 @@
 #define DECODER_BUFFER_SIZE MAX_PAGE_SIZE
 
 static const struct ogg_codec * const ogg_codecs[] = {
+    &ff_skeleton_codec,
     &ff_dirac_codec,
     &ff_speex_codec,
     &ff_vorbis_codec,
diff --git a/libavformat/oggdec.h b/libavformat/oggdec.h
index 170455a..6a0ec59 100644
--- a/libavformat/oggdec.h
+++ b/libavformat/oggdec.h
@@ -107,6 +107,7 @@ extern const struct ogg_codec ff_ogm_text_codec;
 extern const struct ogg_codec ff_ogm_video_codec;
 extern const struct ogg_codec ff_old_dirac_codec;
 extern const struct ogg_codec ff_old_flac_codec;
+extern const struct ogg_codec ff_skeleton_codec;
 extern const struct ogg_codec ff_speex_codec;
 extern const struct ogg_codec ff_theora_codec;
 extern const struct ogg_codec ff_vorbis_codec;
diff --git a/libavformat/oggparseskeleton.c b/libavformat/oggparseskeleton.c
new file mode 100644
index 0000000..a3a5f75
--- /dev/null
+++ b/libavformat/oggparseskeleton.c
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2010 David Conrad
+ *
+ * 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 "libavcodec/bytestream.h"
+#include "avformat.h"
+#include "oggdec.h"
+
+static int skeleton_header(AVFormatContext *s, int idx)
+{
+    struct ogg *ogg = s->priv_data;
+    struct ogg_stream *os = ogg->streams + idx;
+    AVStream *st = s->streams[idx];
+    uint8_t *buf = os->buf + os->pstart;
+    int version_major, version_minor;
+    int64_t start_num, start_den, start_granule;
+    int target_idx, start_time;
+
+    strcpy(st->codec->codec_name, "skeleton");
+    st->codec->codec_type = CODEC_TYPE_DATA;
+
+    if (os->psize < 8)
+        return -1;
+
+    if (!strncmp(buf, "fishead", 8)) {
+        if (os->psize < 64)
+            return -1;
+
+        version_major = AV_RL16(buf+8);
+        version_minor = AV_RL16(buf+10);
+
+        if (version_major != 3) {
+            av_log(s, AV_LOG_WARNING, "Unknown skeleton version %d.%d\n",
+                   version_major, version_minor);
+            return -1;
+        }
+
+        // This is the overall start time. We use it for the start time of
+        // of the skeleton stream since if left unset lavf assumes 0,
+        // which we don't want since skeleton is timeless
+        // FIXME: the real meaning of this field is "start playback at
+        // this time which can be in the middle of a packet
+        start_num = AV_RL64(buf+12);
+        start_den = AV_RL64(buf+20);
+
+        if (start_den) {
+            av_reduce(&start_time, &st->time_base.den, start_num, start_den, INT_MAX);
+            st->time_base.num = 1;
+            st->start_time = start_time;
+        }
+    } else if (!strncmp(buf, "fisbone", 8)) {
+        if (os->psize < 52)
+            return -1;
+
+        target_idx = ogg_find_stream(ogg, AV_RL32(buf+12));
+        start_granule = AV_RL64(buf+36);
+        if (target_idx >= 0 && start_granule != -1) {
+            s->streams[target_idx]->start_time = ogg_gptopts(s, target_idx, start_granule, NULL);
+        }
+    }
+
+    return 1;
+}
+
+const struct ogg_codec ff_skeleton_codec = {
+    .magic = "fishead",
+    .magicsize = 8,
+    .header = skeleton_header,
+};

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list