[FFmpeg-devel] [PATCH 3/5] ASF write indexing object with duration

Vadim Belov vadim.belov at gmail.com
Wed Jul 1 13:28:37 CEST 2015


From: Vadim Belov <vadimb at VADIMB-T440.nice.com>

---
 libavformat/asf_ex.h   | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
 libavformat/asf_trim.c | 26 ++++++++++++++++++++
 libavformat/asf_trim.h | 49 +++++++++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+)
 create mode 100644 libavformat/asf_ex.h
 create mode 100644 libavformat/asf_trim.c
 create mode 100644 libavformat/asf_trim.h

diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
new file mode 100644
index 0000000..206bf62
--- /dev/null
+++ b/libavformat/asf_ex.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015 Vadim Belov
+ *
+ * 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
+ */
+
+#ifndef AVFORMAT_ASF_STREAM_IDX_H
+#define AVFORMAT_ASF_STREAM_IDX_H
+
+#include <stdint.h>
+#include "avformat.h"
+
+
+// Packet size according to the size that ACX File Creator writes to its output packets:
+// ASF_PACKET_SIZE is 8192, but in CASFFile::InitAsfPckt it is decremented.
+// Bottom line: in the ASF core file the value is 8032 
+#ifdef PACKET_SIZE
+#undef PACKET_SIZE
+#endif
+#define PACKET_SIZE 8032 
+
+#define DIRECTION_DICT_KEY "direction"
+
+
+typedef struct ASFStreamIndex { // Index Entry value
+   uint64_t offset;
+} ASFStreamIndex;
+
+typedef struct ASFIndexData { 
+   ASFStreamIndex* indices;    // array of ASFStreamIndex
+   uint32_t indices_max_count; // allocated size
+   uint32_t next_duration_mark; // for next index
+   uint32_t indices_count;      // current index 
+   int64_t  duration_overall;
+} ASFIndexData;
+
+
+int upadte_indices(
+   ASFStream streams[MAX_STREAMS_NUM], //AVFormatContext *s,
+   uint64_t pkt_time,
+   uint32_t pkt_num,
+   uint64_t packet_offset,
+   int stream_index,
+   int64_t pkt_duration);
+
+int asf_write_indices(AVFormatContext *s);
+
+int should_iterate_block(int i, ASFIndexData *idx, uint64_t curr_offset);
+
+int get_num_entries(AVFormatContext *s);
+
+#endif /* AVFORMAT_ASF_STREAM_IDX_H */
diff --git a/libavformat/asf_trim.c b/libavformat/asf_trim.c
new file mode 100644
index 0000000..d4ef5a6
--- /dev/null
+++ b/libavformat/asf_trim.c
@@ -0,0 +1,26 @@
+/*
+* Copyright (c) 2015 Vadim Belov
+*
+* 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 "asfstreamindex.h"
+
+
+const ff_asf_guid ff_asf_index_header = {
+   0xd3, 0x29, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe
+};
diff --git a/libavformat/asf_trim.h b/libavformat/asf_trim.h
new file mode 100644
index 0000000..424bf6d
--- /dev/null
+++ b/libavformat/asf_trim.h
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2015 Vadim Belov
+ *
+ * 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
+ */
+
+#ifndef AVFORMAT_ASF_STREAM_IDX_H
+#define AVFORMAT_ASF_STREAM_IDX_H
+
+// Packet size according to the size that ACX File Creator writes to its output packets:
+// ASF_PACKET_SIZE is 8192, but in CASFFile::InitAsfPckt it is decremented.
+// Bottom line: in the ASF core file the value is 8032 
+#ifdef PACKET_SIZE
+#undef PACKET_SIZE
+#endif
+#define PACKET_SIZE 8032 
+
+typedef struct ASFStreamIndex { // Index Entry value
+   uint64_t offset;
+} ASFStreamIndex;
+
+typedef struct ASFIndexData { 
+   ASFStreamIndex* indices;    // array of ASFStreamIndex
+   uint32_t indices_max_count; // allocated size
+   uint32_t next_duration_mark; // TODO: check type
+   uint32_t indices_count;      // current index 
+   int64_t  duration_overall;
+} ASFIndexData;
+
+
+extern const ff_asf_guid ff_asf_index_header;
+
+#define DIRECTION_DICT_KEY "direction"
+
+#endif /* AVFORMAT_ASF_STREAM_IDX_H */
-- 
1.9.5.msysgit.1



More information about the ffmpeg-devel mailing list