[FFmpeg-devel] [PATCH] Write correct creation time of new ASF

2015-12-27 Thread Vadim Belov
---
 libavformat/asfenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
index 32b726b..9bb439a 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -428,7 +428,7 @@ static int asf_write_header1(AVFormatContext *s, int64_t 
file_size,
 hpos  = put_header(pb, _asf_file_header);
 ff_put_guid(pb, _asf_my_guid);
 avio_wl64(pb, file_size);
-file_time = 0;
+file_time = time(NULL);
 avio_wl64(pb, unix_to_file_time(file_time));
 avio_wl64(pb, asf->nb_packets); /* number of packets */
 avio_wl64(pb, duration); /* end time stamp (in 100ns units) */
-- 
2.6.4.windows.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/1] Extended ASF functionality

2015-07-01 Thread Vadim Belov
Sorry, please don't post, I'll send a new one,
Thanks!
On Jul 1, 2015 7:12 PM, Michael Niedermayer michae...@gmx.at wrote:

 On Wed, Jul 01, 2015 at 06:33:52PM +0300, Vadim Belov wrote:
  ---
   libavformat/Makefile |   2 +-
   libavformat/asf.c|   4 +
   libavformat/asf.h|  12 ++-
   libavformat/asf_ex.h |  58 ++
   libavformat/asf_trim.c   | 228
 +++
   libavformat/asf_trim.h   |  95 
   libavformat/asfdec.c |  17 ++-
   libavformat/asfenc.c |  64 ++-
   8 files changed, 954 insertions(+), 485 deletions(-)
   create mode 100644 libavformat/asf_ex.h
   create mode 100644 libavformat/asf_trim.c
   create mode 100644 libavformat/asf_trim.h
 
   1.9.5.msysgit.1
 
  diff --git a/ffmpeg.c b/ffmpeg.c
  index a89ae39..a3cca09 100644
  --- a/ffmpeg.c
  +++ b/ffmpeg.c

 there is something wrong with the patch
 this hunk changes ffmpeg.c, yet that is not in the stats above
 the change to ffmpeg.c doesnt belong in the patch

 also the patch still contain sprintf(), tabs and other issues
 is this the patch you wanted to post or an old one ?

 [...]
 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 Dictatorship naturally arises out of democracy, and the most aggravated
 form of tyranny and slavery out of the most extreme liberty. -- Plato

 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2015-07-01 Thread Vadim Belov
From: Vadim Belov vad...@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 000..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 000..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 000..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

Re: [FFmpeg-devel] [PATCH 2/5] copy stream metadata when using concat

2015-07-01 Thread Vadim Belov
Thanks!

On Wed, Jul 1, 2015 at 3:56 PM, Michael Niedermayer michae...@gmx.at
wrote:

 On Wed, Jul 01, 2015 at 01:49:06PM +0300, Vadim Belov wrote:
  ---
   libavformat/concatdec.c | 2 ++
   1 file changed, 2 insertions(+)

 applied

 thanks

 [...]
 --
 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

 Into a blind darkness they enter who follow after the Ignorance,
 they as if into a greater darkness enter who devote themselves
 to the Knowledge alone. -- Isha Upanishad

 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/1] Extended ASF functionality

2015-07-01 Thread Vadim Belov
---
 libavformat/Makefile |   2 +-
 libavformat/asf.c|   4 +
 libavformat/asf.h|  12 ++-
 libavformat/asf_ex.h |  58 ++
 libavformat/asf_trim.c   | 228 +++
 libavformat/asf_trim.h   |  95 
 libavformat/asfdec.c |  17 ++-
 libavformat/asfenc.c |  64 ++-
 8 files changed, 954 insertions(+), 485 deletions(-)
 create mode 100644 libavformat/asf_ex.h
 create mode 100644 libavformat/asf_trim.c
 create mode 100644 libavformat/asf_trim.h

 1.9.5.msysgit.1

 Signed-off-by: Vadim Belov vadim.be...@gmail.com

diff --git a/libavformat/Makefile b/libavformat/Makefile
index bca9d5b..2743467 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -84,7 +84,7 @@ OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec.o asf.o asfcrypt.o \
 avlanguage.o
-OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o
+OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o asf_trim.o
 OBJS-$(CONFIG_ASS_DEMUXER)   += assdec.o subtitles.o
 OBJS-$(CONFIG_ASS_MUXER) += assenc.o
 OBJS-$(CONFIG_AST_DEMUXER)   += ast.o astdec.o
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 80d24db..d2a0a8f 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -143,6 +143,10 @@ const ff_asf_guid ff_asf_digital_signature = {
 0xfc, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 
0xc9, 0x55, 0xfc, 0x6e
 };
 
+const ff_asf_guid ff_asf_index_header = {
+0xd3, 0x29, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00, 0xa0, 
0xc9, 0x03, 0x49, 0xbe
+};
+
 /* List of official tags at 
http://msdn.microsoft.com/en-us/library/dd743066(VS.85).aspx */
 const AVMetadataConv ff_asf_metadata_conv[] = {
 { WM/AlbumArtist,  album_artist },
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 0c9598a..0ef4ea6 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
  *
@@ -28,6 +29,11 @@
 
 #define PACKET_SIZE 3200
 
+/** 
+ * asf_ex.h is IMPORTANT to be placed After PACKET_SIZE definition
+ */
+#include asf_ex.h
+
 typedef struct ASFPayload {
 uint8_t type;
 uint16_t size;
@@ -57,7 +63,9 @@ typedef struct ASFStream {
 uint32_t palette[256];
 
 int payload_ext_ct;
-ASFPayload payload[8];
+ASFPayload payload[8]; 
+
+ASFIndexData idx_data;
 } ASFStream;
 
 typedef struct ASFMainHeader {
@@ -123,7 +131,7 @@ extern const ff_asf_guid ff_asf_language_guid;
 extern const ff_asf_guid ff_asf_content_encryption;
 extern const ff_asf_guid ff_asf_ext_content_encryption;
 extern const ff_asf_guid ff_asf_digital_signature;
-
+extern const ff_asf_guid ff_asf_index_header;
 extern const AVMetadataConv ff_asf_metadata_conv[];
 
 #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 
diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
new file mode 100644
index 000..480105a
--- /dev/null
+++ b/libavformat/asf_ex.h
@@ -0,0 +1,58 @@
+/**
+ * @file asf_ex.h
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
+ * 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_EX_H
+#define AVFORMAT_ASF_EX_H
+
+#include stdint.h
+
+/**
+ * Packet size according to the size that Custom ASF File Creator writes 
+ * to its output packets:
+ * ASF_PACKET_SIZE is 8192, but is decremented later.
+ * Final result: in the ASF core file the value is 8032 
+ */
+#ifdef PACKET_SIZE
+#undef PACKET_SIZE
+#endif
+#define PACKET_SIZE 8032 
+
+#define STREAM_DIRECTION_STR streamDirection
+#define DIRECTION_DICT_KEY direction
+#define NO_STREAM_DIRECTION -1
+#define ASF_MAX_STREAMS_NUM 128
+
+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

[FFmpeg-devel] [PATCH 1/5] Metadata attribute passing in ASF

2015-07-01 Thread Vadim Belov
From: unknown vad...@vadimb-t440.nice.com

---
 ffmpeg.c |   7 ++-
 libavformat/asf.h|   9 ++-
 libavformat/asfdec.c |  32 +-
 libavformat/asfenc.c |  60 ---
 libavformat/cache.c  |   6 +-
 libavformat/dashenc.c|   6 +-
 libavformat/file.c   |   6 +-
 libavformat/hdsenc.c |   6 +-
 libavformat/hlsenc.c |   6 +-
 libavformat/smoothstreamingenc.c |   6 +-
 libavutil/file.c |   6 +-
 libavutil/file_open.c|   6 +-
 libavutil/log.c  |   6 +-
 libavutil/random_seed.c  |   6 +-
 libavutil/time.c |   6 +-
 tests/ref/fate/sub-aqtitle   |  90 ++--
 tests/ref/fate/sub-charenc   | 124 +++
 tests/ref/fate/sub-jacosub   |  46 +++
 tests/ref/fate/sub-microdvd  |  44 +++---
 tests/ref/fate/sub-movtext   |  30 +-
 tests/ref/fate/sub-mpl2  |  32 +-
 tests/ref/fate/sub-mpsub |  66 ++---
 tests/ref/fate/sub-mpsub-frames  |  28 -
 tests/ref/fate/sub-pjs   |  30 +-
 tests/ref/fate/sub-realtext  |  34 +--
 tests/ref/fate/sub-sami  |  42 ++---
 tests/ref/fate/sub-srt   |  98 +++
 tests/ref/fate/sub-stl   |  58 +-
 tests/ref/fate/sub-subripenc |   4 +-
 tests/ref/fate/sub-subviewer |  30 +-
 tests/ref/fate/sub-subviewer1|  44 +++---
 tests/ref/fate/sub-vplayer   |  30 +-
 tests/ref/fate/sub-webvtt|  54 -
 33 files changed, 569 insertions(+), 489 deletions(-)

diff --git a/ffmpeg.c b/ffmpeg.c
index a89ae39..a3cca09 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -36,9 +36,6 @@
 #if HAVE_IO_H
 #include io.h
 #endif
-#if HAVE_UNISTD_H
-#include unistd.h
-#endif
 #endif
 
 #include libavformat/avformat.h
@@ -75,6 +72,10 @@
 #elif HAVE_GETPROCESSTIMES
 #include windows.h
 #endif
+#if HAVE_UNISTD_H
+#include unistd.h
+#endif
+
 #if HAVE_GETPROCESSMEMORYINFO
 #include windows.h
 #include psapi.h
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 0c9598a..6dce410 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -26,7 +26,11 @@
 #include metadata.h
 #include riff.h
 
-#define PACKET_SIZE 3200
+// 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! 
Most possibly by 100
+// Bottom line: in the ASF core file the value is 8032 
+#define PACKET_SIZE 8032 
+//#define PACKET_SIZE 3200
 
 typedef struct ASFPayload {
 uint8_t type;
@@ -189,4 +193,7 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
 
 extern AVInputFormat ff_asf_demuxer;
 
+// TODO: move to .c ?
+#define DIRECTION_DICT_KEY direction
+
 #endif /* AVFORMAT_ASF_H */
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 359ee8b..bf4ef75 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -39,6 +39,8 @@
 #include asf.h
 #include asfcrypt.h
 
+#define NO_STREAM_DIRECTION -1
+
 typedef struct ASFContext {
 const AVClass *class;
 int asfid2avid[128]; /// conversion table from asf ID 2 
AVStream ID
@@ -81,6 +83,10 @@ typedef struct ASFContext {
 
 int no_resync_search;
 int export_xmp;
+   int direction[128];
+   //AVRational direction[128];/// pair: num={ 0 = 
doesn't have direction, 1 = has direction }
+   //  
///   den={ direction value }
+   
 } ASFContext;
 
 static const AVOption options[] = {
@@ -671,7 +677,9 @@ static int asf_read_metadata(AVFormatContext *s, int64_t 
size)
 avio_skip(pb, name_len - ret);
 av_log(s, AV_LOG_TRACE, %d stream %d name_len %2d type %d len %4d 
%s\n,
 i, stream_num, name_len, value_type, value_len, name);
-
+   
+   asf-direction[stream_num] = NO_STREAM_DIRECTION;
+   
 if (!strcmp(name, AspectRatioX)){
 int aspect_x = get_value(s-pb, value_type, 16);
 if(stream_num  128)
@@ -680,7 +688,16 @@ static int asf_read_metadata(AVFormatContext *s, int64_t 
size)
 int aspect_y = get_value(s-pb, value_type, 16);
 if(stream_num  128)
 asf-dar[stream_num].den = aspect_y;
-} else {
+} else if(!strcmp(name, streamDirection)   // V
+   0  stream_num){
// V
+   int direction = get_value(s-pb, value_type, value_len);
+   
+   av_log(s, AV_LOG_INFO, +++ stream %d 
Direction is %d\n, // V
+stream_num, direction);
+   
+  

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

2015-07-01 Thread Vadim Belov
From: Vadim Belov vad...@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 000..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 000..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 000..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

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

2015-07-01 Thread Vadim Belov
From: Vadim Belov vad...@vadimb-t440.nice.com

---
 libavformat/Makefile   |   2 +-
 libavformat/asf.c  |   4 +
 libavformat/asf.h  |  17 ++--
 libavformat/asf_ex.h   |  27 ++-
 libavformat/asf_trim.c | 206 -
 libavformat/asf_trim.h |  86 +++--
 libavformat/asfdec.c   |  29 ++-
 libavformat/asfenc.c   |  93 --
 8 files changed, 345 insertions(+), 119 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index bca9d5b..2743467 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -84,7 +84,7 @@ OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec.o asf.o asfcrypt.o \
 avlanguage.o
-OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o
+OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o asf_trim.o
 OBJS-$(CONFIG_ASS_DEMUXER)   += assdec.o subtitles.o
 OBJS-$(CONFIG_ASS_MUXER) += assenc.o
 OBJS-$(CONFIG_AST_DEMUXER)   += ast.o astdec.o
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 80d24db..d2a0a8f 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -143,6 +143,10 @@ const ff_asf_guid ff_asf_digital_signature = {
 0xfc, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 
0xc9, 0x55, 0xfc, 0x6e
 };
 
+const ff_asf_guid ff_asf_index_header = {
+0xd3, 0x29, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00, 0xa0, 
0xc9, 0x03, 0x49, 0xbe
+};
+
 /* List of official tags at 
http://msdn.microsoft.com/en-us/library/dd743066(VS.85).aspx */
 const AVMetadataConv ff_asf_metadata_conv[] = {
 { WM/AlbumArtist,  album_artist },
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 6dce410..7e8d8d3 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
  *
@@ -26,11 +27,10 @@
 #include metadata.h
 #include riff.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! 
Most possibly by 100
-// Bottom line: in the ASF core file the value is 8032 
-#define PACKET_SIZE 8032 
-//#define PACKET_SIZE 3200
+#define PACKET_SIZE 3200
+
+// asf_ex.h is IMPORTANT to be placed After PACKET_SIZE definition
+#include asf_ex.h
 
 typedef struct ASFPayload {
 uint8_t type;
@@ -62,6 +62,8 @@ typedef struct ASFStream {
 
 int payload_ext_ct;
 ASFPayload payload[8];
+
+   ASFIndexData idx_data;
 } ASFStream;
 
 typedef struct ASFMainHeader {
@@ -127,7 +129,7 @@ extern const ff_asf_guid ff_asf_language_guid;
 extern const ff_asf_guid ff_asf_content_encryption;
 extern const ff_asf_guid ff_asf_ext_content_encryption;
 extern const ff_asf_guid ff_asf_digital_signature;
-
+extern const ff_asf_guid ff_asf_index_header;
 extern const AVMetadataConv ff_asf_metadata_conv[];
 
 #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 
@@ -193,7 +195,4 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
 
 extern AVInputFormat ff_asf_demuxer;
 
-// TODO: move to .c ?
-#define DIRECTION_DICT_KEY direction
-
 #endif /* AVFORMAT_ASF_H */
diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
index 206bf62..6655424 100644
--- a/libavformat/asf_ex.h
+++ b/libavformat/asf_ex.h
@@ -18,12 +18,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVFORMAT_ASF_STREAM_IDX_H
-#define AVFORMAT_ASF_STREAM_IDX_H
+#ifndef AVFORMAT_ASF_EX_H
+#define AVFORMAT_ASF_EX_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.
@@ -33,8 +31,10 @@
 #endif
 #define PACKET_SIZE 8032 
 
+#define STREAM_DIRECTION_STR streamDirection
 #define DIRECTION_DICT_KEY direction
-
+#define NO_STREAM_DIRECTION -1
+#define ASF_MAX_STREAMS_NUM 128
 
 typedef struct ASFStreamIndex { // Index Entry value
uint64_t offset;
@@ -48,19 +48,4 @@ typedef struct ASFIndexData {
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 */
+#endif /* AVFORMAT_ASF_EX_H */
diff --git a/libavformat/asf_trim.c b/libavformat/asf_trim.c
index d4ef5a6..60017e4 100644
--- a/libavformat/asf_trim.c

[FFmpeg-devel] [PATCH 0/5] Extended ASF functionality

2015-07-01 Thread Vadim Belov
ASF streams metadata copy

Vadim Belov (3):
  ASF write indexing object with duration
  ASF write indexing object with duration
  tabs to spaces and comments

unknown (2):
  Metadata attribute passing in ASF
  copy stream metadata when using concat

 ffmpeg.c |   7 +-
 libavformat/Makefile |   2 +-
 libavformat/asf.c|   4 +
 libavformat/asf.h|  12 ++-
 libavformat/asf_ex.h |  58 ++
 libavformat/asf_trim.c   | 228 +++
 libavformat/asf_trim.h   |  95 
 libavformat/asfdec.c |  17 ++-
 libavformat/asfenc.c |  64 ++-
 libavformat/cache.c  |   6 +-
 libavformat/concatdec.c  |   2 +
 libavformat/dashenc.c|   6 +-
 libavformat/file.c   |   6 +-
 libavformat/hdsenc.c |   6 +-
 libavformat/hlsenc.c |   6 +-
 libavformat/smoothstreamingenc.c |   6 +-
 libavutil/file.c |   6 +-
 libavutil/file_open.c|   6 +-
 libavutil/log.c  |   6 +-
 libavutil/random_seed.c  |   6 +-
 libavutil/time.c |   6 +-
 tests/ref/fate/sub-aqtitle   |  90 
 tests/ref/fate/sub-charenc   | 124 ++---
 tests/ref/fate/sub-jacosub   |  46 
 tests/ref/fate/sub-microdvd  |  44 
 tests/ref/fate/sub-movtext   |  30 +++---
 tests/ref/fate/sub-mpl2  |  32 +++---
 tests/ref/fate/sub-mpsub |  66 ++--
 tests/ref/fate/sub-mpsub-frames  |  28 ++---
 tests/ref/fate/sub-pjs   |  30 +++---
 tests/ref/fate/sub-realtext  |  34 +++---
 tests/ref/fate/sub-sami  |  42 
 tests/ref/fate/sub-srt   |  98 -
 tests/ref/fate/sub-stl   |  58 +-
 tests/ref/fate/sub-subripenc |   4 +-
 tests/ref/fate/sub-subviewer |  30 +++---
 tests/ref/fate/sub-subviewer1|  44 
 tests/ref/fate/sub-vplayer   |  30 +++---
 tests/ref/fate/sub-webvtt|  54 +-
 39 files changed, 954 insertions(+), 485 deletions(-)
 create mode 100644 libavformat/asf_ex.h
 create mode 100644 libavformat/asf_trim.c
 create mode 100644 libavformat/asf_trim.h

-- 
1.9.5.msysgit.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 5/5] tabs to spaces and comments

2015-07-01 Thread Vadim Belov
From: Vadim Belov vad...@vadimb-t440.nice.com

---
 libavformat/asf.h   |   8 +-
 libavformat/asf_ex.h|  29 ++--
 libavformat/asf_trim.c  | 366 
 libavformat/asf_trim.h  |  42 +++---
 libavformat/asfdec.c|  24 ++--
 libavformat/asfenc.c| 105 +++---
 libavformat/concatdec.c |   2 +-
 7 files changed, 298 insertions(+), 278 deletions(-)

diff --git a/libavformat/asf.h b/libavformat/asf.h
index 7e8d8d3..0ef4ea6 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -29,7 +29,9 @@
 
 #define PACKET_SIZE 3200
 
-// asf_ex.h is IMPORTANT to be placed After PACKET_SIZE definition
+/** 
+ * asf_ex.h is IMPORTANT to be placed After PACKET_SIZE definition
+ */
 #include asf_ex.h
 
 typedef struct ASFPayload {
@@ -61,9 +63,9 @@ typedef struct ASFStream {
 uint32_t palette[256];
 
 int payload_ext_ct;
-ASFPayload payload[8];
+ASFPayload payload[8]; 
 
-   ASFIndexData idx_data;
+ASFIndexData idx_data;
 } ASFStream;
 
 typedef struct ASFMainHeader {
diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
index 6655424..480105a 100644
--- a/libavformat/asf_ex.h
+++ b/libavformat/asf_ex.h
@@ -1,4 +1,8 @@
-/*
+/**
+ * @file asf_ex.h
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
  * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
@@ -23,9 +27,12 @@
 
 #include stdint.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 
+/**
+ * Packet size according to the size that Custom ASF File Creator writes 
+ * to its output packets:
+ * ASF_PACKET_SIZE is 8192, but is decremented later.
+ * Final result: in the ASF core file the value is 8032 
+ */
 #ifdef PACKET_SIZE
 #undef PACKET_SIZE
 #endif
@@ -36,16 +43,16 @@
 #define NO_STREAM_DIRECTION -1
 #define ASF_MAX_STREAMS_NUM 128
 
-typedef struct ASFStreamIndex { // Index Entry value
-   uint64_t offset;
+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;
+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;
 
 #endif /* AVFORMAT_ASF_EX_H */
diff --git a/libavformat/asf_trim.c b/libavformat/asf_trim.c
index 60017e4..ce75170 100644
--- a/libavformat/asf_trim.c
+++ b/libavformat/asf_trim.c
@@ -1,21 +1,25 @@
 /*
-* 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
+ * @file asf_trim.c
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
+ * 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 asf_trim.h
@@ -23,202 +27,202 @@
 #define ASF_INDEX_ENTRY_TIME_INTERVAL 1
 #define SPECIFIER_INDEX_TYPE 3
 
-#define BLOCK_PART 0x
-#define OFFSET_PART0x
-#define INVALID_OFFSET 0x
+#define BLOCK_PART  0x
+#define OFFSET_PART 0x
+#define

[FFmpeg-devel] [PATCH 2/5] copy stream metadata when using concat

2015-07-01 Thread Vadim Belov
From: unknown vad...@vadimb-t440.nice.com

---
 libavformat/concatdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index f07cfd7..c61d5c2 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -172,6 +172,8 @@ static int copy_stream_props(AVStream *st, AVStream 
*source_st)
 st-avg_frame_rate  = source_st-avg_frame_rate;
 st-time_base   = source_st-time_base;
 st-sample_aspect_ratio = source_st-sample_aspect_ratio;
+   
+av_dict_copy(st-metadata, source_st-metadata, 0);
 return 0;
 }
 
-- 
1.9.5.msysgit.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 2/5] copy stream metadata when using concat

2015-07-01 Thread Vadim Belov
---
 libavformat/concatdec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index f07cfd7..c61d5c2 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -172,6 +172,8 @@ static int copy_stream_props(AVStream *st, AVStream 
*source_st)
 st-avg_frame_rate  = source_st-avg_frame_rate;
 st-time_base   = source_st-time_base;
 st-sample_aspect_ratio = source_st-sample_aspect_ratio;
+   
+av_dict_copy(st-metadata, source_st-metadata, 0);
 return 0;
 }
 
-- 
1.9.5.msysgit.1

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2015-07-01 Thread Vadim Belov
From: Vadim Belov vad...@vadimb-t440.nice.com

---
 libavformat/Makefile   |   2 +-
 libavformat/asf.c  |   4 +
 libavformat/asf.h  |  17 ++--
 libavformat/asf_ex.h   |  27 ++-
 libavformat/asf_trim.c | 206 -
 libavformat/asf_trim.h |  86 +++--
 libavformat/asfdec.c   |  29 ++-
 libavformat/asfenc.c   |  93 --
 8 files changed, 345 insertions(+), 119 deletions(-)

diff --git a/libavformat/Makefile b/libavformat/Makefile
index bca9d5b..2743467 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -84,7 +84,7 @@ OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec.o asf.o asfcrypt.o \
 avlanguage.o
-OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o
+OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o asf_trim.o
 OBJS-$(CONFIG_ASS_DEMUXER)   += assdec.o subtitles.o
 OBJS-$(CONFIG_ASS_MUXER) += assenc.o
 OBJS-$(CONFIG_AST_DEMUXER)   += ast.o astdec.o
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 80d24db..d2a0a8f 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -143,6 +143,10 @@ const ff_asf_guid ff_asf_digital_signature = {
 0xfc, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 
0xc9, 0x55, 0xfc, 0x6e
 };
 
+const ff_asf_guid ff_asf_index_header = {
+0xd3, 0x29, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00, 0xa0, 
0xc9, 0x03, 0x49, 0xbe
+};
+
 /* List of official tags at 
http://msdn.microsoft.com/en-us/library/dd743066(VS.85).aspx */
 const AVMetadataConv ff_asf_metadata_conv[] = {
 { WM/AlbumArtist,  album_artist },
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 6dce410..7e8d8d3 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
  *
@@ -26,11 +27,10 @@
 #include metadata.h
 #include riff.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! 
Most possibly by 100
-// Bottom line: in the ASF core file the value is 8032 
-#define PACKET_SIZE 8032 
-//#define PACKET_SIZE 3200
+#define PACKET_SIZE 3200
+
+// asf_ex.h is IMPORTANT to be placed After PACKET_SIZE definition
+#include asf_ex.h
 
 typedef struct ASFPayload {
 uint8_t type;
@@ -62,6 +62,8 @@ typedef struct ASFStream {
 
 int payload_ext_ct;
 ASFPayload payload[8];
+
+ASFIndexData idx_data;
 } ASFStream;
 
 typedef struct ASFMainHeader {
@@ -127,7 +129,7 @@ extern const ff_asf_guid ff_asf_language_guid;
 extern const ff_asf_guid ff_asf_content_encryption;
 extern const ff_asf_guid ff_asf_ext_content_encryption;
 extern const ff_asf_guid ff_asf_digital_signature;
-
+extern const ff_asf_guid ff_asf_index_header;
 extern const AVMetadataConv ff_asf_metadata_conv[];
 
 #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 
@@ -193,7 +195,4 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
 
 extern AVInputFormat ff_asf_demuxer;
 
-// TODO: move to .c ?
-#define DIRECTION_DICT_KEY direction
-
 #endif /* AVFORMAT_ASF_H */
diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
index 206bf62..6655424 100644
--- a/libavformat/asf_ex.h
+++ b/libavformat/asf_ex.h
@@ -18,12 +18,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVFORMAT_ASF_STREAM_IDX_H
-#define AVFORMAT_ASF_STREAM_IDX_H
+#ifndef AVFORMAT_ASF_EX_H
+#define AVFORMAT_ASF_EX_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.
@@ -33,8 +31,10 @@
 #endif
 #define PACKET_SIZE 8032 
 
+#define STREAM_DIRECTION_STR streamDirection
 #define DIRECTION_DICT_KEY direction
-
+#define NO_STREAM_DIRECTION -1
+#define ASF_MAX_STREAMS_NUM 128
 
 typedef struct ASFStreamIndex { // Index Entry value
uint64_t offset;
@@ -48,19 +48,4 @@ typedef struct ASFIndexData {
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 */
+#endif /* AVFORMAT_ASF_EX_H */
diff --git a/libavformat/asf_trim.c b/libavformat/asf_trim.c
index d4ef5a6..60017e4 100644
--- a/libavformat/asf_trim.c
+++ b/libavformat/asf_trim.c
@@ -18,9

[FFmpeg-devel] [PATCH 1/1] Extended ASF functionality

2015-07-01 Thread Vadim Belov
---
 libavformat/Makefile |   2 +-
 libavformat/asf.c|   4 +
 libavformat/asf.h|  12 ++-
 libavformat/asf_ex.h |  58 ++
 libavformat/asf_trim.c   | 228 +++
 libavformat/asf_trim.h   |  95 
 libavformat/asfdec.c |  17 ++-
 libavformat/asfenc.c |  64 ++-
 8 files changed, 954 insertions(+), 485 deletions(-)
 create mode 100644 libavformat/asf_ex.h
 create mode 100644 libavformat/asf_trim.c
 create mode 100644 libavformat/asf_trim.h

 1.9.5.msysgit.1

diff --git a/ffmpeg.c b/ffmpeg.c
index a89ae39..a3cca09 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -36,9 +36,6 @@
 #if HAVE_IO_H
 #include io.h
 #endif
-#if HAVE_UNISTD_H
-#include unistd.h
-#endif
 #endif
 
 #include libavformat/avformat.h
@@ -75,6 +72,10 @@
 #elif HAVE_GETPROCESSTIMES
 #include windows.h
 #endif
+#if HAVE_UNISTD_H
+#include unistd.h
+#endif
+
 #if HAVE_GETPROCESSMEMORYINFO
 #include windows.h
 #include psapi.h
diff --git a/libavformat/Makefile b/libavformat/Makefile
index bca9d5b..2743467 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -84,7 +84,7 @@ OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec.o asf.o asfcrypt.o \
 avlanguage.o
-OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o
+OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o asf_trim.o
 OBJS-$(CONFIG_ASS_DEMUXER)   += assdec.o subtitles.o
 OBJS-$(CONFIG_ASS_MUXER) += assenc.o
 OBJS-$(CONFIG_AST_DEMUXER)   += ast.o astdec.o
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 80d24db..d2a0a8f 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -143,6 +143,10 @@ const ff_asf_guid ff_asf_digital_signature = {
 0xfc, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 
0xc9, 0x55, 0xfc, 0x6e
 };
 
+const ff_asf_guid ff_asf_index_header = {
+0xd3, 0x29, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00, 0xa0, 
0xc9, 0x03, 0x49, 0xbe
+};
+
 /* List of official tags at 
http://msdn.microsoft.com/en-us/library/dd743066(VS.85).aspx */
 const AVMetadataConv ff_asf_metadata_conv[] = {
 { WM/AlbumArtist,  album_artist },
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 0c9598a..1ea848d 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
  *
@@ -25,6 +26,7 @@
 #include avformat.h
 #include metadata.h
 #include riff.h
+#include asf_ex.h
 
 #define PACKET_SIZE 3200
 
@@ -57,7 +59,9 @@ typedef struct ASFStream {
 uint32_t palette[256];
 
 int payload_ext_ct;
-ASFPayload payload[8];
+ASFPayload payload[8]; 
+
+ASFIndexData idx_data;
 } ASFStream;
 
 typedef struct ASFMainHeader {
@@ -123,7 +127,7 @@ extern const ff_asf_guid ff_asf_language_guid;
 extern const ff_asf_guid ff_asf_content_encryption;
 extern const ff_asf_guid ff_asf_ext_content_encryption;
 extern const ff_asf_guid ff_asf_digital_signature;
-
+extern const ff_asf_guid ff_asf_index_header;
 extern const AVMetadataConv ff_asf_metadata_conv[];
 
 #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 
diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
new file mode 100644
index 000..5e46a2b
--- /dev/null
+++ b/libavformat/asf_ex.h
@@ -0,0 +1,47 @@
+/**
+ * @file asf_ex.h
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
+ * 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_EX_H
+#define AVFORMAT_ASF_EX_H
+
+#include stdint.h
+
+#define STREAM_DIRECTION_STR streamDirection
+#define DIRECTION_DICT_KEY direction
+#define NO_STREAM_DIRECTION -1
+#define ASF_MAX_STREAMS_NUM 128
+
+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

Re: [FFmpeg-devel] [PATCH 1/1] Extended ASF functionality

2015-07-01 Thread Vadim Belov
Thanks Michael,
I've sent a fix of this patch,

Currently it doesn't change PACKET_SIZE, which was pretty specific for the
product I'm dealing with.


On Wed, Jul 1, 2015 at 4:21 PM, Michael Niedermayer michae...@gmx.at
wrote:

 On Wed, Jul 01, 2015 at 03:49:11PM +0300, Vadim Belov wrote:
  ---
   libavformat/Makefile |   2 +-
   libavformat/asf.c|   4 +
   libavformat/asf.h|  12 ++-
   libavformat/asf_ex.h |  58 ++
   libavformat/asf_trim.c   | 228
 +++
   libavformat/asf_trim.h   |  95 
   libavformat/asfdec.c |  17 ++-
   libavformat/asfenc.c |  64 ++-
   8 files changed, 954 insertions(+), 485 deletions(-)
   create mode 100644 libavformat/asf_ex.h
   create mode 100644 libavformat/asf_trim.c
   create mode 100644 libavformat/asf_trim.h
 
   1.9.5.msysgit.1
 
   Signed-off-by: Vadim Belov vadim.be...@gmail.com
 
  diff --git a/libavformat/Makefile b/libavformat/Makefile
  index bca9d5b..2743467 100644
  --- a/libavformat/Makefile
  +++ b/libavformat/Makefile
  @@ -84,7 +84,7 @@ OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
   OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
   OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec.o asf.o asfcrypt.o \
   avlanguage.o
  -OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o
  +OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o asf_trim.o
   OBJS-$(CONFIG_ASS_DEMUXER)   += assdec.o subtitles.o
   OBJS-$(CONFIG_ASS_MUXER) += assenc.o
   OBJS-$(CONFIG_AST_DEMUXER)   += ast.o astdec.o
  diff --git a/libavformat/asf.c b/libavformat/asf.c
  index 80d24db..d2a0a8f 100644
  --- a/libavformat/asf.c
  +++ b/libavformat/asf.c
  @@ -143,6 +143,10 @@ const ff_asf_guid ff_asf_digital_signature = {
   0xfc, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00,
 0xa0, 0xc9, 0x55, 0xfc, 0x6e
   };
 
  +const ff_asf_guid ff_asf_index_header = {
  +0xd3, 0x29, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00,
 0xa0, 0xc9, 0x03, 0x49, 0xbe
  +};
  +
   /* List of official tags at
 http://msdn.microsoft.com/en-us/library/dd743066(VS.85).aspx */
   const AVMetadataConv ff_asf_metadata_conv[] = {
   { WM/AlbumArtist,  album_artist },
  diff --git a/libavformat/asf.h b/libavformat/asf.h
  index 0c9598a..0ef4ea6 100644
  --- a/libavformat/asf.h
  +++ b/libavformat/asf.h
  @@ -1,5 +1,6 @@
   /*
* Copyright (c) 2000, 2001 Fabrice Bellard
  + * Copyright (c) 2015 Vadim Belov
*
* This file is part of FFmpeg.
*
  @@ -28,6 +29,11 @@
 
   #define PACKET_SIZE 3200
 
  +/**
  + * asf_ex.h is IMPORTANT to be placed After PACKET_SIZE definition
  + */
  +#include asf_ex.h
  +
   typedef struct ASFPayload {
   uint8_t type;
   uint16_t size;
  @@ -57,7 +63,9 @@ typedef struct ASFStream {
   uint32_t palette[256];
 
   int payload_ext_ct;
  -ASFPayload payload[8];
  +ASFPayload payload[8];
  +
  +ASFIndexData idx_data;
   } ASFStream;
 
   typedef struct ASFMainHeader {
  @@ -123,7 +131,7 @@ extern const ff_asf_guid ff_asf_language_guid;
   extern const ff_asf_guid ff_asf_content_encryption;
   extern const ff_asf_guid ff_asf_ext_content_encryption;
   extern const ff_asf_guid ff_asf_digital_signature;
  -
  +extern const ff_asf_guid ff_asf_index_header;
   extern const AVMetadataConv ff_asf_metadata_conv[];
 
   #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 
  diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
  new file mode 100644
  index 000..480105a
  --- /dev/null
  +++ b/libavformat/asf_ex.h
  @@ -0,0 +1,58 @@
  +/**
  + * @file asf_ex.h
  + * Extensions to ASF handling
  + * @author Vadim Belov
  + *
  + * 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_EX_H
  +#define AVFORMAT_ASF_EX_H
  +
  +#include stdint.h
  +

  +/**
  + * Packet size according to the size that Custom ASF File Creator writes
  + * to its output packets:
  + * ASF_PACKET_SIZE is 8192, but is decremented later

Re: [FFmpeg-devel] [PATCH 1/1] Extended ASF functionality

2015-07-01 Thread Vadim Belov
Hi,
Please see the last patch with more detailed explanation.
Thanks,
Vadim

On Wed, Jul 1, 2015 at 7:16 PM, Hendrik Leppkes h.lepp...@gmail.com wrote:

 On Wed, Jul 1, 2015 at 6:11 PM, Michael Niedermayer michae...@gmx.at
 wrote:
  On Wed, Jul 01, 2015 at 06:33:52PM +0300, Vadim Belov wrote:
  ---
   libavformat/Makefile |   2 +-
   libavformat/asf.c|   4 +
   libavformat/asf.h|  12 ++-
   libavformat/asf_ex.h |  58 ++
   libavformat/asf_trim.c   | 228
 +++
   libavformat/asf_trim.h   |  95 
   libavformat/asfdec.c |  17 ++-
   libavformat/asfenc.c |  64 ++-
   8 files changed, 954 insertions(+), 485 deletions(-)
   create mode 100644 libavformat/asf_ex.h
   create mode 100644 libavformat/asf_trim.c
   create mode 100644 libavformat/asf_trim.h
 
   1.9.5.msysgit.1
 
  diff --git a/ffmpeg.c b/ffmpeg.c
  index a89ae39..a3cca09 100644
  --- a/ffmpeg.c
  +++ b/ffmpeg.c
 
  there is something wrong with the patch
  this hunk changes ffmpeg.c, yet that is not in the stats above
  the change to ffmpeg.c doesnt belong in the patch
 
  also the patch still contain sprintf(), tabs and other issues
  is this the patch you wanted to post or an old one ?
 

 Maybe you could also explain what this thing does?
 The only comment I saw elsewhere was ASF streams metadata copy, but
 this patch is huge, hundreds of lines of new code. I cannot believe
 that copying metadata from one asf file into another would require
 these many changes.

 So please elaborate what this is doing and what the changes add to our
 code.

 - Hendrik
 ___
 ffmpeg-devel mailing list
 ffmpeg-devel@ffmpeg.org
 http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/1] Extended ASF functionality:

2015-07-01 Thread Vadim Belov
 1. Copy stream metadata specific attribute named streamDirection
 2. Create top-level Index Object for output file with intervals of 10sec
 3. Change of Preroll time to 0 for player to start playing the file immediately
 
---
 libavformat/Makefile |   2 +-
 libavformat/asf.c|   4 +
 libavformat/asf.h|  12 ++-
 libavformat/asf_ex.h |  58 ++
 libavformat/asf_trim.c   | 228 +++
 libavformat/asf_trim.h   |  95 
 libavformat/asfdec.c |  17 ++-
 libavformat/asfenc.c |  64 ++-
 8 files changed, 954 insertions(+), 485 deletions(-)
 create mode 100644 libavformat/asf_ex.h
 create mode 100644 libavformat/asf_trim.c
 create mode 100644 libavformat/asf_trim.h

 1.9.5.msysgit.1

 Signed-off-by: Vadim Belov vadim.be...@gmail.com

diff --git a/libavformat/Makefile b/libavformat/Makefile
index bca9d5b..2743467 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -84,7 +84,7 @@ OBJS-$(CONFIG_APNG_MUXER)+= apngenc.o
 OBJS-$(CONFIG_AQTITLE_DEMUXER)   += aqtitledec.o subtitles.o
 OBJS-$(CONFIG_ASF_DEMUXER)   += asfdec.o asf.o asfcrypt.o \
 avlanguage.o
-OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o
+OBJS-$(CONFIG_ASF_MUXER) += asfenc.o asf.o asf_trim.o
 OBJS-$(CONFIG_ASS_DEMUXER)   += assdec.o subtitles.o
 OBJS-$(CONFIG_ASS_MUXER) += assenc.o
 OBJS-$(CONFIG_AST_DEMUXER)   += ast.o astdec.o
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 80d24db..d2a0a8f 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -143,6 +143,10 @@ const ff_asf_guid ff_asf_digital_signature = {
 0xfc, 0xb3, 0x11, 0x22, 0x23, 0xbd, 0xd2, 0x11, 0xb4, 0xb7, 0x00, 0xa0, 
0xc9, 0x55, 0xfc, 0x6e
 };
 
+const ff_asf_guid ff_asf_index_header = {
+0xd3, 0x29, 0xe2, 0xd6, 0xda, 0x35, 0xd1, 0x11, 0x90, 0x34, 0x00, 0xa0, 
0xc9, 0x03, 0x49, 0xbe
+};
+
 /* List of official tags at 
http://msdn.microsoft.com/en-us/library/dd743066(VS.85).aspx */
 const AVMetadataConv ff_asf_metadata_conv[] = {
 { WM/AlbumArtist,  album_artist },
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 0c9598a..1ea848d 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2000, 2001 Fabrice Bellard
+ * Copyright (c) 2015 Vadim Belov
  *
  * This file is part of FFmpeg.
  *
@@ -25,6 +26,7 @@
 #include avformat.h
 #include metadata.h
 #include riff.h
+#include asf_ex.h
 
 #define PACKET_SIZE 3200
 
@@ -57,7 +59,9 @@ typedef struct ASFStream {
 uint32_t palette[256];
 
 int payload_ext_ct;
-ASFPayload payload[8];
+ASFPayload payload[8]; 
+
+ASFIndexData idx_data;
 } ASFStream;
 
 typedef struct ASFMainHeader {
@@ -123,7 +127,7 @@ extern const ff_asf_guid ff_asf_language_guid;
 extern const ff_asf_guid ff_asf_content_encryption;
 extern const ff_asf_guid ff_asf_ext_content_encryption;
 extern const ff_asf_guid ff_asf_digital_signature;
-
+extern const ff_asf_guid ff_asf_index_header;
 extern const AVMetadataConv ff_asf_metadata_conv[];
 
 #define ASF_PACKET_FLAG_ERROR_CORRECTION_PRESENT 0x80 //1000 
diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
new file mode 100644
index 000..5e46a2b
--- /dev/null
+++ b/libavformat/asf_ex.h
@@ -0,0 +1,47 @@
+/**
+ * @file asf_ex.h
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
+ * 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_EX_H
+#define AVFORMAT_ASF_EX_H
+
+#include stdint.h
+
+#define STREAM_DIRECTION_STR streamDirection
+#define DIRECTION_DICT_KEY direction
+#define NO_STREAM_DIRECTION -1
+#define ASF_MAX_STREAMS_NUM 128
+
+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;
+
+#endif