Re: [FFmpeg-devel] [PATCH 1/2] avformat/tee: Factor parse_slave_options() out

2016-08-02 Thread Michael Niedermayer
On Tue, Aug 02, 2016 at 04:42:56PM +0200, Nicolas George wrote:
> Le quintidi 15 thermidor, an CCXXIV, Michael Niedermayer a écrit :
> > Signed-off-by: Michael Niedermayer 
[...]
> > +int ff_tee_parse_slave_options(void *log, char *slave,
> > +   AVDictionary **options, char **filename)
> > +{
> > +const char *p;
> > +char *key, *val;
> > +int ret;
> > +
> > +if (!strspn(slave, slave_opt_open)) {
> > +*filename = slave;
> > +return 0;
> > +}
> > +p = slave + 1;
> > +if (strspn(p, slave_opt_close)) {
> > +*filename = (char *)p + 1;
> > +return 0;
> > +}
> > +while (1) {
> > +ret = av_opt_get_key_value(, "=", slave_opt_delim, 0, , 
> > );
> > +if (ret < 0) {
> > +av_log(log, AV_LOG_ERROR, "No option found near \"%s\"\n", p);
> > +goto fail;
> > +}
> > +ret = av_dict_set(options, key, val,
> > +  AV_DICT_DONT_STRDUP_KEY | 
> > AV_DICT_DONT_STRDUP_VAL);
> > +if (ret < 0)
> > +goto fail;
> > +if (strspn(p, slave_opt_close))
> > +break;
> > +p++;
> > +}
> > +*filename = (char *)p + 1;
> > +return 0;
> > +
> > +fail:
> > +av_dict_free(options);
> > +return ret;
> > +}
> 
> > \ No newline at end of file
> 
> Better fix that. It happened several times recently, maybe check the config
> of your editor?

i dont think my editor supports that, but it really shouldnt matter,
theres a git hook that prevents this from being checked in, so it
will get fixed before i push it


> 
> > diff --git a/libavformat/tee_common.h b/libavformat/tee_common.h
> > new file mode 100644
> > index 000..78ef1b8
> > --- /dev/null
> > +++ b/libavformat/tee_common.h
> > @@ -0,0 +1,31 @@
> > +/*
> > + * Tee common code
> 
> > + * Copyright (c) 2012 Nicolas George
> 
> I do not think this specific file warrants any copyright from me. Either
> yourself or "the FFmpeg developers" would be better I think.

fixed


> 
> > + *
> > + * 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_TEE_COMMON_H
> > +#define AVFORMAT_TEE_COMMON_H
> > +
> > +#include "libavutil/dict.h"
> > +
> > +int ff_tee_parse_slave_options(void *log, char *slave,
> > +   AVDictionary **options, char **filename);
> > +
> > +#endif
> 
> > +
> 
> Stray empty line.

fixed


> 
> LGTM apart from that, but maybe ask Jan if it will not interfere with his
> work.

applied as jan is ok with it too

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Old school: Use the lowest level language in which you can solve the problem
conveniently.
New school: Use the highest level language in which the latest supercomputer
can solve the problem without the user falling asleep waiting.


signature.asc
Description: Digital signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avformat/tee: Factor parse_slave_options() out

2016-08-02 Thread Jan Sebechlebsky

On 08/02/2016 04:42 PM, Nicolas George wrote:


LGTM apart from that, but maybe ask Jan if it will not interfere with his
work.
It will interfere with patch "avformat/tee: Use BSF list API" I've send 
to ML, but it's not a problem at all, I'll just regenerate and resend 
the patch after this is applied.

I am ok with the patch.

Regards,
Jan

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


Re: [FFmpeg-devel] [PATCH 1/2] avformat/tee: Factor parse_slave_options() out

2016-08-02 Thread Nicolas George
Le quintidi 15 thermidor, an CCXXIV, Michael Niedermayer a écrit :
> Signed-off-by: Michael Niedermayer 
> ---
>  libavformat/Makefile |2 +-
>  libavformat/tee.c|   44 ++
>  libavformat/tee_common.c |   68 
> ++
>  libavformat/tee_common.h |   31 +
>  4 files changed, 102 insertions(+), 43 deletions(-)
>  create mode 100644 libavformat/tee_common.c
>  create mode 100644 libavformat/tee_common.h
> 
> diff --git a/libavformat/Makefile b/libavformat/Makefile
> index 4966347..783b96a 100644
> --- a/libavformat/Makefile
> +++ b/libavformat/Makefile
> @@ -463,7 +463,7 @@ OBJS-$(CONFIG_SWF_DEMUXER)   += swfdec.o swf.o
>  OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o
>  OBJS-$(CONFIG_TAK_DEMUXER)   += takdec.o apetag.o img2.o rawdec.o
>  OBJS-$(CONFIG_TEDCAPTIONS_DEMUXER)   += tedcaptionsdec.o subtitles.o
> -OBJS-$(CONFIG_TEE_MUXER) += tee.o
> +OBJS-$(CONFIG_TEE_MUXER) += tee.o tee_common.o
>  OBJS-$(CONFIG_THP_DEMUXER)   += thp.o
>  OBJS-$(CONFIG_THREEDOSTR_DEMUXER)+= 3dostr.o
>  OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER)+= tiertexseq.o
> diff --git a/libavformat/tee.c b/libavformat/tee.c
> index b4158e1..5689ca3 100644
> --- a/libavformat/tee.c
> +++ b/libavformat/tee.c
> @@ -26,6 +26,7 @@
>  #include "internal.h"
>  #include "avformat.h"
>  #include "avio_internal.h"
> +#include "tee_common.h"
>  
>  typedef enum {
>  ON_SLAVE_FAILURE_ABORT  = 1,
> @@ -54,9 +55,6 @@ typedef struct TeeContext {
>  } TeeContext;
>  
>  static const char *const slave_delim = "|";
> -static const char *const slave_opt_open  = "[";
> -static const char *const slave_opt_close = "]";
> -static const char *const slave_opt_delim = ":]"; /* must have the close too 
> */
>  static const char *const slave_bsfs_spec_sep = "/";
>  static const char *const slave_select_sep = ",";
>  
> @@ -66,44 +64,6 @@ static const AVClass tee_muxer_class = {
>  .version= LIBAVUTIL_VERSION_INT,
>  };
>  
> -static int parse_slave_options(void *log, char *slave,
> -   AVDictionary **options, char **filename)
> -{
> -const char *p;
> -char *key, *val;
> -int ret;
> -
> -if (!strspn(slave, slave_opt_open)) {
> -*filename = slave;
> -return 0;
> -}
> -p = slave + 1;
> -if (strspn(p, slave_opt_close)) {
> -*filename = (char *)p + 1;
> -return 0;
> -}
> -while (1) {
> -ret = av_opt_get_key_value(, "=", slave_opt_delim, 0, , );
> -if (ret < 0) {
> -av_log(log, AV_LOG_ERROR, "No option found near \"%s\"\n", p);
> -goto fail;
> -}
> -ret = av_dict_set(options, key, val,
> -  AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
> -if (ret < 0)
> -goto fail;
> -if (strspn(p, slave_opt_close))
> -break;
> -p++;
> -}
> -*filename = (char *)p + 1;
> -return 0;
> -
> -fail:
> -av_dict_free(options);
> -return ret;
> -}
> -
>  /**
>   * Parse list of bitstream filters and add them to the list of filters
>   * pointed to by bsfs.
> @@ -217,7 +177,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
> TeeSlave *tee_slave)
>  int fullret;
>  char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, 
> *tmp_select = NULL;
>  
> -if ((ret = parse_slave_options(avf, slave, , )) < 0)
> +if ((ret = ff_tee_parse_slave_options(avf, slave, , )) 
> < 0)
>  return ret;
>  
>  #define STEAL_OPTION(option, field) do {\
> diff --git a/libavformat/tee_common.c b/libavformat/tee_common.c
> new file mode 100644
> index 000..70c06d2
> --- /dev/null
> +++ b/libavformat/tee_common.c
> @@ -0,0 +1,68 @@
> +/*
> + * Tee common code
> + * Copyright (c) 2012 Nicolas George
> + *
> + * 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 "libavutil/avutil.h"
> +#include "libavutil/avstring.h"
> +#include "libavutil/opt.h"
> +
> +#include "tee_common.h"
> +
> +static const char *const 

[FFmpeg-devel] [PATCH 1/2] avformat/tee: Factor parse_slave_options() out

2016-07-31 Thread Michael Niedermayer
Signed-off-by: Michael Niedermayer 
---
 libavformat/Makefile |2 +-
 libavformat/tee.c|   44 ++
 libavformat/tee_common.c |   68 ++
 libavformat/tee_common.h |   31 +
 4 files changed, 102 insertions(+), 43 deletions(-)
 create mode 100644 libavformat/tee_common.c
 create mode 100644 libavformat/tee_common.h

diff --git a/libavformat/Makefile b/libavformat/Makefile
index 4966347..783b96a 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -463,7 +463,7 @@ OBJS-$(CONFIG_SWF_DEMUXER)   += swfdec.o swf.o
 OBJS-$(CONFIG_SWF_MUXER) += swfenc.o swf.o
 OBJS-$(CONFIG_TAK_DEMUXER)   += takdec.o apetag.o img2.o rawdec.o
 OBJS-$(CONFIG_TEDCAPTIONS_DEMUXER)   += tedcaptionsdec.o subtitles.o
-OBJS-$(CONFIG_TEE_MUXER) += tee.o
+OBJS-$(CONFIG_TEE_MUXER) += tee.o tee_common.o
 OBJS-$(CONFIG_THP_DEMUXER)   += thp.o
 OBJS-$(CONFIG_THREEDOSTR_DEMUXER)+= 3dostr.o
 OBJS-$(CONFIG_TIERTEXSEQ_DEMUXER)+= tiertexseq.o
diff --git a/libavformat/tee.c b/libavformat/tee.c
index b4158e1..5689ca3 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -26,6 +26,7 @@
 #include "internal.h"
 #include "avformat.h"
 #include "avio_internal.h"
+#include "tee_common.h"
 
 typedef enum {
 ON_SLAVE_FAILURE_ABORT  = 1,
@@ -54,9 +55,6 @@ typedef struct TeeContext {
 } TeeContext;
 
 static const char *const slave_delim = "|";
-static const char *const slave_opt_open  = "[";
-static const char *const slave_opt_close = "]";
-static const char *const slave_opt_delim = ":]"; /* must have the close too */
 static const char *const slave_bsfs_spec_sep = "/";
 static const char *const slave_select_sep = ",";
 
@@ -66,44 +64,6 @@ static const AVClass tee_muxer_class = {
 .version= LIBAVUTIL_VERSION_INT,
 };
 
-static int parse_slave_options(void *log, char *slave,
-   AVDictionary **options, char **filename)
-{
-const char *p;
-char *key, *val;
-int ret;
-
-if (!strspn(slave, slave_opt_open)) {
-*filename = slave;
-return 0;
-}
-p = slave + 1;
-if (strspn(p, slave_opt_close)) {
-*filename = (char *)p + 1;
-return 0;
-}
-while (1) {
-ret = av_opt_get_key_value(, "=", slave_opt_delim, 0, , );
-if (ret < 0) {
-av_log(log, AV_LOG_ERROR, "No option found near \"%s\"\n", p);
-goto fail;
-}
-ret = av_dict_set(options, key, val,
-  AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL);
-if (ret < 0)
-goto fail;
-if (strspn(p, slave_opt_close))
-break;
-p++;
-}
-*filename = (char *)p + 1;
-return 0;
-
-fail:
-av_dict_free(options);
-return ret;
-}
-
 /**
  * Parse list of bitstream filters and add them to the list of filters
  * pointed to by bsfs.
@@ -217,7 +177,7 @@ static int open_slave(AVFormatContext *avf, char *slave, 
TeeSlave *tee_slave)
 int fullret;
 char *subselect = NULL, *next_subselect = NULL, *first_subselect = NULL, 
*tmp_select = NULL;
 
-if ((ret = parse_slave_options(avf, slave, , )) < 0)
+if ((ret = ff_tee_parse_slave_options(avf, slave, , )) < 
0)
 return ret;
 
 #define STEAL_OPTION(option, field) do {\
diff --git a/libavformat/tee_common.c b/libavformat/tee_common.c
new file mode 100644
index 000..70c06d2
--- /dev/null
+++ b/libavformat/tee_common.c
@@ -0,0 +1,68 @@
+/*
+ * Tee common code
+ * Copyright (c) 2012 Nicolas George
+ *
+ * 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 "libavutil/avutil.h"
+#include "libavutil/avstring.h"
+#include "libavutil/opt.h"
+
+#include "tee_common.h"
+
+static const char *const slave_opt_open  = "[";
+static const char *const slave_opt_close = "]";
+static const char *const slave_opt_delim = ":]"; /* must have the close too */
+
+int ff_tee_parse_slave_options(void *log, char *slave,
+   AVDictionary **options, char **filename)
+{
+const char *p;
+char *key, *val;
+int ret;
+
+if