Re: [FFmpeg-devel] [PATCH v2 1/7] lavc/qsvenc: enable ICQ and ICQ_LA on Linux

2018-11-28 Thread Li, Zhong
> > On 05/11/18 12:15, Zhong Li wrote:
> > > ICQ/ICQ_LA are enabled with MSDK V1.28
> > >
> > > One example of ICQ_LA:
> > > ffmpeg -hwaccel qsv -c:v h264_qsv -i in.mp4 -c:v h264_qsv
> > > -global_quality 25 -look_ahead 1 out.mp4
> > >
> > > Signed-off-by: Zhong Li 
> > > ---
> > > ICQ mode will fail with some cases:
> > https://github.com/Intel-Media-SDK/MediaSDK/issues/863. Don't merge
> > this patch before it resolved.
> > >
> > >  libavcodec/qsvenc.h | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index
> > > 50cc426..055b4a6 100644
> > > --- a/libavcodec/qsvenc.h
> > > +++ b/libavcodec/qsvenc.h
> > > @@ -53,7 +53,7 @@
> > >  #define QSV_HAVE_MF 0
> > >  #else
> > >  #define QSV_HAVE_AVBR   0
> > > -#define QSV_HAVE_ICQ0
> > > +#define QSV_HAVE_ICQQSV_VERSION_ATLEAST(1, 28)
> > >  #define QSV_HAVE_VCM0
> > >  #define QSV_HAVE_QVBR   0
> > >  #define QSV_HAVE_MF QSV_VERSION_ATLEAST(1, 25)
> > >
> >
> > LGTM once the issues with the driver are resolved.
> >
> > (I guess this is another case in favour of querying the actual
> > capabilities at runtime, though.)
> 
> Yup, API version is not library version, and ideally checking runtime version 
> or
> check capabilities at runtime should be better than check API version.
> FFmpeg define a micro to check runtime version and here is an example:
> https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvenc.c#L68
> 4
> 
> However, if one feature is implemented on different MSDK version on
> Windows and Linux, it is ugly to check different
> QSV_RUNTIME_VERSION_ATLEAST on different OS at runtime.
> Currently I am mainly checking API version at precompile stage.
> It is not perfect but higher efficient since currently MSDK API is a part of
> MSDK library and always keep some version release as I see.
> 
> And as you know, MSDK has no a powerful query interface like vaapi (Based
> on this, ffmpeg-vaapi can keep a better compatibility than ffmpeg-qsv as I
> see). MSDK query interface just tells you yes or not, and mixed with other
> parameters that cause even the answer (yes or no) is not precise. As the
> complaint on https://trac.ffmpeg.org/wiki/Hardware/QuickSync : “Using an
> invalid combination is likely to provoke the message: ‘Selected ratecontrol
> mode is not supported by the QSV runtime. Choose a different mode.’
> Usually this message is accurate, but it can also refer to other issues like 
> the
> lack of a usable device.”
> I gave a patch https://patchwork.ffmpeg.org/patch/7785/ )to make things
> better but still not perfect without a more powerful MSDK query interface.
> 
> A better way should be: define a better query interface which can expose a
> list of MSDK’s capacity just like vaapi, instead of just tell you yes or not.
> Then application can know the limitation accurately without mixed with
> other input parameters, and can switch to some supported path with a
> warning message instead of crashed.
> 
> Please be free to give comments.

Ping?

Currently the run-time checking is 
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvenc.c#L365 , 
I verified this can tell you ICQ mode is not supported if libmfx library 
version is less than 1.28.
(I would like to have a discussion about the possibility to provide a more 
powerful query interface of libmfx just like vaapi's vaGetConfigAttributes or 
nvenc's vaGetConfigAttributes
But I guess we can't see that in short-time.)
And https://github.com/Intel-Media-SDK/MediaSDK/issues/863 has been fixed, so I 
prefer to merge this patch if nobody against.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavf/dashenc: Write media trailers when DASH trailer is written.

2018-11-28 Thread Jeyapal, Karthick

On 11/28/18 5:13 PM, Andrey Semashev wrote:
> This commit ensures that all (potentially, long) filesystem activity is
> performed when the user calls av_write_trailer on the DASH libavformat
> context, not when freeing the context. Also, this defers media segment
> deletion until after the media trailers are written.
> ---
>  libavformat/dashenc.c | 19 ++-
>  1 file changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 6ce70e0076..e1c959dc89 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -424,8 +424,6 @@ static void dash_free(AVFormatContext *s)
>  return;
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
> -if (os->ctx && os->ctx_inited)
> -av_write_trailer(os->ctx);
>  if (os->ctx && os->ctx->pb)
>  ffio_free_dyn_buf(>ctx->pb);
>  ff_format_io_close(s, >out);
> @@ -1420,13 +1418,11 @@ static int dash_flush(AVFormatContext *s, int final, 
> int stream)
>  os->pos += range_length;
>  }
>  
> -if (c->window_size || (final && c->remove_at_exit)) {
> +if (c->window_size) {
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
>  int j;
>  int remove = os->nb_segments - c->window_size - 
> c->extra_window_size;
> -if (final && c->remove_at_exit)
> -remove = os->nb_segments;
Is there any reason for deferring the delete after write_trailer.
Because if the file is getting deleted immediately, why should we bother about 
write_trailer? Is it causing any issues?
I am asking this, because the segment deletion code is getting duplicated due 
to this change. I am trying to avoid code duplication as much as possible.
>  if (remove > 0) {
>  for (j = 0; j < remove; j++) {
>  char filename[1024];
> @@ -1599,11 +1595,24 @@ static int dash_write_trailer(AVFormatContext *s)
>  }
>  dash_flush(s, 1, -1);
>  
> +for (int i = 0; i < s->nb_streams; ++i) {
Can we merge this loop with the below loop for deleting init segments. The "if" 
condition for remove_at_exit, could be moved inside the merged loop. 
> +OutputStream *os = >streams[i];
> +if (os->ctx && os->ctx_inited) {
> +av_write_trailer(os->ctx);
> +}
> +}
> +
>  if (c->remove_at_exit) {
>  char filename[1024];
>  int i;
>  for (i = 0; i < s->nb_streams; i++) {
>  OutputStream *os = >streams[i];
> +for (int j = 0; j < os->nb_segments; ++j) {
> +snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
> os->segments[j]->file);
> +dashenc_delete_file(s, filename);
> +av_free(os->segments[j]);
> +}
> +os->nb_segments = 0;
>  snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
> os->initfile);
>  dashenc_delete_file(s, filename);
>  }

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


Re: [FFmpeg-devel] [PATCH v3] libavfilter: add transpose_vaapi filter

2018-11-28 Thread Zhou, Zachary
Thanks for the comments, reply inline, and sent out new version of the patch.

> -Original Message-
> From: Guo, Yejun
> Sent: Wednesday, November 28, 2018 4:12 PM
> To: FFmpeg development discussions and patches 
> Cc: Zhou, Zachary 
> Subject: RE: [FFmpeg-devel] [PATCH v3] libavfilter: add transpose_vaapi filter
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Zachary Zhou
> > Sent: Wednesday, November 28, 2018 2:54 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Zhou, Zachary 
> > Subject: [FFmpeg-devel] [PATCH v3] libavfilter: add transpose_vaapi
> > filter
> >
> > Swap width and height when do clock/cclock rotation Add 180/180_flip
> > options
> >
> > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
> > -hwaccel_output_format vaapi -i input.264 -vf "transpose_vaapi=clock_flip"
> > -c:v h264_vaapi output.h264
> >
> > Signed-off-by: Zachary Zhou 
> > ---
> >  configure|   2 +
> >  libavfilter/Makefile |   1 +
> >  libavfilter/allfilters.c |   1 +
> >  libavfilter/vf_transpose_vaapi.c | 356
> > +++
> >  4 files changed, 360 insertions(+)
> >  create mode 100644 libavfilter/vf_transpose_vaapi.c
> >
> > diff --git a/configure b/configure
> > index ab3144e459..6e711bd9c6 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3451,6 +3451,7 @@ scale_filter_deps="swscale"
> >  scale_qsv_filter_deps="libmfx"
> >  select_filter_select="scene_sad"
> >  sharpness_vaapi_filter_deps="vaapi"
> > +transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
> 
> it is better to be in alphabetical order. Just a few exceptions here and I 
> think
> original idea is in alphabetical order.

changed it.

> 
> >  showcqt_filter_deps="avcodec avformat swscale"
> >  showcqt_filter_suggest="libfontconfig libfreetype"
> >  showcqt_filter_select="fft"
> > @@ -5975,6 +5976,7 @@ check_type "d3d9.h dxva2api.h"
> > DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
> >
> >  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
> >  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
> > +check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps"
> > +rotation_flags
> >  check_type "va/va.h va/va_enc_hevc.h"
> > "VAEncPictureParameterBufferHEVC"
> >  check_type "va/va.h va/va_enc_jpeg.h"
> > "VAEncPictureParameterBufferJPEG"
> >  check_type "va/va.h va/va_enc_vp8.h"
> > "VAEncPictureParameterBufferVP8"
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile index
> > 1895fa2b0d..97e1786071 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -356,6 +356,7 @@ OBJS-$(CONFIG_SETRANGE_FILTER)   +=
> > vf_setparams.o
> >  OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o
> >  OBJS-$(CONFIG_SETTB_FILTER)  += settb.o
> >  OBJS-$(CONFIG_SHARPNESS_VAAPI_FILTER)+= vf_misc_vaapi.o
> > vaapi_vpp.o
> > +OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+= vf_transpose_vaapi.o
> > vaapi_vpp.o
> >  OBJS-$(CONFIG_SHOWINFO_FILTER)   += vf_showinfo.o
> >  OBJS-$(CONFIG_SHOWPALETTE_FILTER)+= vf_showpalette.o
> >  OBJS-$(CONFIG_SHUFFLEFRAMES_FILTER)  += vf_shuffleframes.o
> > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index
> > 837c99eb75..f0c69e9c67 100644
> > --- a/libavfilter/allfilters.c
> > +++ b/libavfilter/allfilters.c
> > @@ -338,6 +338,7 @@ extern AVFilter ff_vf_setrange;  extern AVFilter
> > ff_vf_setsar;  extern AVFilter ff_vf_settb;  extern AVFilter
> > ff_vf_sharpness_vaapi;
> > +extern AVFilter ff_vf_transpose_vaapi;
> 
> need to be in alphabetical order.

Changed it.

> 
> >  extern AVFilter ff_vf_showinfo;
> >  extern AVFilter ff_vf_showpalette;
> >  extern AVFilter ff_vf_shuffleframes;
> > diff --git a/libavfilter/vf_transpose_vaapi.c
> > b/libavfilter/vf_transpose_vaapi.c
> > new file mode 100644
> > index 00..ca7203e880
> > --- /dev/null
> > +++ b/libavfilter/vf_transpose_vaapi.c
> > @@ -0,0 +1,356 @@
> > +/*
> > + * 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 
> > +
> > +#include "libavutil/avassert.h"
> > +#include 

Re: [FFmpeg-devel] [PATCH, v4] lavc/qsvenc: add VDENC support for H264

2018-11-28 Thread Fu, Linjie
> -Original Message-
> From: Li, Zhong
> Sent: Thursday, November 29, 2018 12:36
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Cc: Fu, Linjie 
> Subject: RE: [FFmpeg-devel] [PATCH,v4] lavc/qsvenc: add VDENC support for
> H264
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Linjie Fu
> > Sent: Wednesday, November 28, 2018 12:45 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Fu, Linjie 
> > Subject: [FFmpeg-devel] [PATCH,v4] lavc/qsvenc: add VDENC support for
> > H264
> >
> > Add VDENC(lowpower mode) support for QSV H264
> >
> > It's an experimental function(like lowpower in vaapi) with some limitations:
> > - CBR/VBR require HuC which should be explicitly loaded via i915 module
> > parameter(i915.enable_guc=2 for linux kernel version >= 4.16)
> >
> > Use option "-low_power 1" to enable VDENC.
> > Add in dump_video_param() to show the status of VDENC in runtime log.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> > [v2]: modified the commit message and option comments, use
> > AV_OPT_TYPE_BOOL to replace AV_OPT_TYPE_INT.
> > [v3]: enable H264 VDENC separately.
> > [v4]: Add in dump_video_param to show the status of VDENC in runtime
> log.
> >
> >  libavcodec/qsvenc.c  | 11 +++
> >  libavcodec/qsvenc.h  |  2 ++
> >  libavcodec/qsvenc_h264.c |  3 +++
> >  3 files changed, 16 insertions(+)
> >
> > diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index
> > 948751daf4..42804e68af 100644
> > --- a/libavcodec/qsvenc.c
> > +++ b/libavcodec/qsvenc.c
> > @@ -226,6 +226,14 @@ static void dump_video_param(AVCodecContext
> > *avctx, QSVEncContext *q,
> >  av_log(avctx, AV_LOG_VERBOSE, "\n");  #endif
> >
> > +#if QSV_HAVE_VDENC
> > +av_log(avctx, AV_LOG_VERBOSE, "VDENC: ");
> > +if (info->LowPower == MFX_CODINGOPTION_ON)
> > +av_log(avctx, AV_LOG_VERBOSE, "ON\n");
> > +else
> > +av_log(avctx, AV_LOG_VERBOSE, "OFF\n"); #endif
> 
> print_threestate() can be used to print libmfx option strings.
> print_threestate(co->RateDistortionOpt) is an example.
> 

Modified and sent a new patch.

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


[FFmpeg-devel] [PATCH v4] libavfilter: add transpose_vaapi filter

2018-11-28 Thread Zachary Zhou
Swap width and height when do clock/cclock rotation
Add 180/180_flip options

ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
-hwaccel_output_format vaapi -i input.264 -vf "transpose_vaapi=clock_flip"
-c:v h264_vaapi output.h264

Signed-off-by: Zachary Zhou 
---
 configure|   2 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/vf_transpose_vaapi.c | 356 +++
 4 files changed, 360 insertions(+)
 create mode 100644 libavfilter/vf_transpose_vaapi.c

diff --git a/configure b/configure
index 3e9222ed1b..9e3908ef61 100755
--- a/configure
+++ b/configure
@@ -3480,6 +3480,7 @@ tinterlace_merge_test_deps="tinterlace_filter"
 tinterlace_pad_test_deps="tinterlace_filter"
 tonemap_filter_deps="const_nan"
 tonemap_opencl_filter_deps="opencl const_nan"
+transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
 unsharp_opencl_filter_deps="opencl"
 uspp_filter_deps="gpl avcodec"
 vaguedenoiser_filter_deps="gpl"
@@ -5979,6 +5980,7 @@ check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode 
-D_WIN32_WINNT=0x0602
 
 check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
 check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
+check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
 check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
 check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
 check_type "va/va.h va/va_enc_vp8.h"  "VAEncPictureParameterBufferVP8"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 1895fa2b0d..ccce4bbb2f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -393,6 +393,7 @@ OBJS-$(CONFIG_TONEMAP_OPENCL_FILTER) += 
vf_tonemap_opencl.o colorspace.o
 OBJS-$(CONFIG_TPAD_FILTER)   += vf_tpad.o
 OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
 OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o cuda_check.o
+OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+= vf_transpose_vaapi.o 
vaapi_vpp.o
 OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
 OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o framesync.o
 OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 837c99eb75..40e5d82b62 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -372,6 +372,7 @@ extern AVFilter ff_vf_tonemap_opencl;
 extern AVFilter ff_vf_tpad;
 extern AVFilter ff_vf_transpose;
 extern AVFilter ff_vf_transpose_npp;
+extern AVFilter ff_vf_transpose_vaapi;
 extern AVFilter ff_vf_trim;
 extern AVFilter ff_vf_unpremultiply;
 extern AVFilter ff_vf_unsharp;
diff --git a/libavfilter/vf_transpose_vaapi.c b/libavfilter/vf_transpose_vaapi.c
new file mode 100644
index 00..d0502b7944
--- /dev/null
+++ b/libavfilter/vf_transpose_vaapi.c
@@ -0,0 +1,356 @@
+/*
+ * 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 
+
+#include "libavutil/avassert.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "vaapi_vpp.h"
+
+typedef enum {
+TRANSPOSE_PT_TYPE_NONE,
+TRANSPOSE_PT_TYPE_LANDSCAPE,
+TRANSPOSE_PT_TYPE_PORTRAIT,
+} PassthroughType;
+
+enum TransposeDir {
+TRANSPOSE_CCLOCK_FLIP,
+TRANSPOSE_CLOCK,
+TRANSPOSE_CCLOCK,
+TRANSPOSE_CLOCK_FLIP,
+TRANSPOSE_180,
+TRANSPOSE_180_FLIP,
+};
+
+typedef struct TransposeVAAPIContext {
+VAAPIVPPContext vpp_ctx; // must be the first field
+int passthrough; // PassthroughType, landscape passthrough mode 
enabled
+int dir; // TransposeDir
+
+int rotation_state;
+int mirror_state;
+} TransposeVAAPIContext;
+
+static int transpose_vaapi_build_filter_params(AVFilterContext *avctx)
+{
+VAAPIVPPContext *vpp_ctx   = avctx->priv;
+TransposeVAAPIContext *ctx = avctx->priv;
+VAStatus vas;
+int support_flag;
+VAProcPipelineCaps pipeline_caps;
+
+memset(_caps, 0, sizeof(pipeline_caps));
+vas = vaQueryVideoProcPipelineCaps(vpp_ctx->hwctx->display,
+   

[FFmpeg-devel] [PATCH,v5] lavc/qsvenc: add VDENC support for H264

2018-11-28 Thread Linjie Fu
Add VDENC(lowpower mode) support for QSV H264

It's an experimental function(like lowpower in vaapi) with
some limitations:
- CBR/VBR require HuC which should be explicitly loaded via i915
module parameter(i915.enable_guc=2 for linux kernel version >= 4.16)

Use option "-low_power 1" to enable VDENC.
Add in dump_video_param() to show the status of VDENC in runtime log.

Signed-off-by: Linjie Fu 
---
[v2]: Modify the commit message and option comments, use AV_OPT_TYPE_BOOL
to replace AV_OPT_TYPE_INT.
[v3]: Enable H264 VDENC separately.
[v4]: Add in dump_video_param to show the status of VDENC in runtime
log.
[v5]: Use print_threestate.

 libavcodec/qsvenc.c  | 7 +++
 libavcodec/qsvenc.h  | 2 ++
 libavcodec/qsvenc_h264.c | 3 +++
 3 files changed, 12 insertions(+)

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 948751daf4..b1ec90c6c6 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -226,6 +226,10 @@ static void dump_video_param(AVCodecContext *avctx, 
QSVEncContext *q,
 av_log(avctx, AV_LOG_VERBOSE, "\n");
 #endif
 
+#if QSV_HAVE_VDENC
+av_log(avctx, AV_LOG_VERBOSE, "VDENC: %s\n", 
print_threestate(info->LowPower));
+#endif
+
 #if QSV_VERSION_ATLEAST(1, 8)
 av_log(avctx, AV_LOG_VERBOSE,
"RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ",
@@ -464,6 +468,9 @@ static int init_video_param(AVCodecContext *avctx, 
QSVEncContext *q)
 }
 }
 
+#if QSV_HAVE_VDENC
+q->param.mfx.LowPower   = q->low_power ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
+#endif
 q->param.mfx.CodecProfile   = q->profile;
 q->param.mfx.TargetUsage= avctx->compression_level;
 q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size);
diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h
index 50cc4267e7..a396aa7d3f 100644
--- a/libavcodec/qsvenc.h
+++ b/libavcodec/qsvenc.h
@@ -44,6 +44,7 @@
 #define QSV_HAVE_LA QSV_VERSION_ATLEAST(1, 7)
 #define QSV_HAVE_LA_DS  QSV_VERSION_ATLEAST(1, 8)
 #define QSV_HAVE_LA_HRD QSV_VERSION_ATLEAST(1, 11)
+#define QSV_HAVE_VDENC  QSV_VERSION_ATLEAST(1, 15)
 
 #if defined(_WIN32) || defined(__CYGWIN__)
 #define QSV_HAVE_AVBR   QSV_VERSION_ATLEAST(1, 3)
@@ -162,6 +163,7 @@ typedef struct QSVEncContext {
 int recovery_point_sei;
 
 int a53_cc;
+int low_power;
 
 #if QSV_HAVE_MF
 int mfmode;
diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index 07c9d64e6b..40071d805a 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -153,6 +153,9 @@ static const AVOption options[] = {
 { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_DISABLED }, 
INT_MIN, INT_MAX, VE, "mfmode" },
 { "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_AUTO }, 
INT_MIN, INT_MAX, VE, "mfmode" },
 #endif
+#if QSV_HAVE_VDENC
+{ "low_power", "enable low power mode(experimental: many limitations by 
mfx version, BRC modes, etc.)", OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 
=  0 }, 0, 1, VE},
+#endif
 
 { NULL },
 };
-- 
2.17.1

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


[FFmpeg-devel] [PATCH] refine filters to be in alphabetical order in configure

2018-11-28 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 configure | 24 
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/configure b/configure
index 3e9222e..37a39e3 100755
--- a/configure
+++ b/configure
@@ -3395,10 +3395,10 @@ drawtext_filter_suggest="libfontconfig libfribidi"
 elbg_filter_deps="avcodec"
 eq_filter_deps="gpl"
 erosion_opencl_filter_deps="opencl"
-fftfilt_filter_deps="avcodec"
-fftfilt_filter_select="rdft"
 fftdnoiz_filter_deps="avcodec"
 fftdnoiz_filter_select="fft"
+fftfilt_filter_deps="avcodec"
+fftfilt_filter_select="rdft"
 find_rect_filter_deps="avcodec avformat gpl"
 firequalizer_filter_deps="avcodec"
 firequalizer_filter_select="rdft"
@@ -3415,12 +3415,13 @@ interlace_filter_deps="gpl"
 kerndeint_filter_deps="gpl"
 ladspa_filter_deps="ladspa libdl"
 lensfun_filter_deps="liblensfun version3"
+libvmaf_filter_deps="libvmaf pthreads"
 lv2_filter_deps="lv2"
 mcdeint_filter_deps="avcodec gpl"
+minterpolate_filter_select="scene_sad"
 movie_filter_deps="avcodec avformat"
 mpdecimate_filter_deps="gpl"
 mpdecimate_filter_select="pixelutils"
-minterpolate_filter_select="scene_sad"
 mptestsrc_filter_deps="gpl"
 negate_filter_deps="lut_filter"
 nnedi_filter_deps="gpl"
@@ -3434,8 +3435,9 @@ owdenoise_filter_deps="gpl"
 pan_filter_deps="swresample"
 perspective_filter_deps="gpl"
 phase_filter_deps="gpl"
-pp7_filter_deps="gpl"
+pixfmts_super2xsai_test_deps="super2xsai_filter"
 pp_filter_deps="gpl postproc"
+pp7_filter_deps="gpl"
 prewitt_opencl_filter_deps="opencl"
 procamp_vaapi_filter_deps="vaapi"
 program_opencl_filter_deps="opencl"
@@ -3446,14 +3448,15 @@ resample_filter_deps="avresample"
 roberts_opencl_filter_deps="opencl"
 rubberband_filter_deps="librubberband"
 sab_filter_deps="gpl swscale"
-scale2ref_filter_deps="swscale"
 scale_filter_deps="swscale"
 scale_qsv_filter_deps="libmfx"
+scale_vaapi_filter_deps="vaapi"
+scale2ref_filter_deps="swscale"
 select_filter_select="scene_sad"
 sharpness_vaapi_filter_deps="vaapi"
 showcqt_filter_deps="avcodec avformat swscale"
-showcqt_filter_suggest="libfontconfig libfreetype"
 showcqt_filter_select="fft"
+showcqt_filter_suggest="libfontconfig libfreetype"
 showfreqs_filter_deps="avcodec"
 showfreqs_filter_select="fft"
 showspectrum_filter_deps="avcodec"
@@ -3474,7 +3477,6 @@ sr_filter_select="dnn"
 stereo3d_filter_deps="gpl"
 subtitles_filter_deps="avformat avcodec libass"
 super2xsai_filter_deps="gpl"
-pixfmts_super2xsai_test_deps="super2xsai_filter"
 tinterlace_filter_deps="gpl"
 tinterlace_merge_test_deps="tinterlace_filter"
 tinterlace_pad_test_deps="tinterlace_filter"
@@ -3485,14 +3487,12 @@ uspp_filter_deps="gpl avcodec"
 vaguedenoiser_filter_deps="gpl"
 vidstabdetect_filter_deps="libvidstab"
 vidstabtransform_filter_deps="libvidstab"
-libvmaf_filter_deps="libvmaf pthreads"
-zmq_filter_deps="libzmq"
-zoompan_filter_deps="swscale"
-zscale_filter_deps="libzimg const_nan"
-scale_vaapi_filter_deps="vaapi"
 vpp_qsv_filter_deps="libmfx"
 vpp_qsv_filter_select="qsvvpp"
 yadif_cuda_filter_deps="cuda_sdk"
+zmq_filter_deps="libzmq"
+zoompan_filter_deps="swscale"
+zscale_filter_deps="libzimg const_nan"
 
 # examples
 avio_dir_cmd_deps="avformat avutil"
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH, v4] lavc/qsvenc: add VDENC support for H264

2018-11-28 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Wednesday, November 28, 2018 12:45 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH,v4] lavc/qsvenc: add VDENC support for
> H264
> 
> Add VDENC(lowpower mode) support for QSV H264
> 
> It's an experimental function(like lowpower in vaapi) with some limitations:
> - CBR/VBR require HuC which should be explicitly loaded via i915 module
> parameter(i915.enable_guc=2 for linux kernel version >= 4.16)
> 
> Use option "-low_power 1" to enable VDENC.
> Add in dump_video_param() to show the status of VDENC in runtime log.
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: modified the commit message and option comments, use
> AV_OPT_TYPE_BOOL to replace AV_OPT_TYPE_INT.
> [v3]: enable H264 VDENC separately.
> [v4]: Add in dump_video_param to show the status of VDENC in runtime log.
> 
>  libavcodec/qsvenc.c  | 11 +++
>  libavcodec/qsvenc.h  |  2 ++
>  libavcodec/qsvenc_h264.c |  3 +++
>  3 files changed, 16 insertions(+)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index
> 948751daf4..42804e68af 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -226,6 +226,14 @@ static void dump_video_param(AVCodecContext
> *avctx, QSVEncContext *q,
>  av_log(avctx, AV_LOG_VERBOSE, "\n");  #endif
> 
> +#if QSV_HAVE_VDENC
> +av_log(avctx, AV_LOG_VERBOSE, "VDENC: ");
> +if (info->LowPower == MFX_CODINGOPTION_ON)
> +av_log(avctx, AV_LOG_VERBOSE, "ON\n");
> +else
> +av_log(avctx, AV_LOG_VERBOSE, "OFF\n"); #endif

print_threestate() can be used to print libmfx option strings.
print_threestate(co->RateDistortionOpt) is an example.

> +
>  #if QSV_VERSION_ATLEAST(1, 8)
>  av_log(avctx, AV_LOG_VERBOSE,
> "RepeatPPS: %s; NumMbPerSlice: %"PRIu16"; LookAheadDS: ",
> @@ -464,6 +472,9 @@ static int init_video_param(AVCodecContext *avctx,
> QSVEncContext *q)
>  }
>  }
> 
> +#if QSV_HAVE_VDENC
> +q->param.mfx.LowPower   = q->low_power ?
> MFX_CODINGOPTION_ON:MFX_CODINGOPTION_OFF;
> +#endif
>  q->param.mfx.CodecProfile   = q->profile;
>  q->param.mfx.TargetUsage= avctx->compression_level;
>  q->param.mfx.GopPicSize = FFMAX(0, avctx->gop_size);
> diff --git a/libavcodec/qsvenc.h b/libavcodec/qsvenc.h index
> 50cc4267e7..a396aa7d3f 100644
> --- a/libavcodec/qsvenc.h
> +++ b/libavcodec/qsvenc.h
> @@ -44,6 +44,7 @@
>  #define QSV_HAVE_LA QSV_VERSION_ATLEAST(1, 7)
>  #define QSV_HAVE_LA_DS  QSV_VERSION_ATLEAST(1, 8)  #define
> QSV_HAVE_LA_HRD QSV_VERSION_ATLEAST(1, 11)
> +#define QSV_HAVE_VDENC  QSV_VERSION_ATLEAST(1, 15)
> 
>  #if defined(_WIN32) || defined(__CYGWIN__)
>  #define QSV_HAVE_AVBR   QSV_VERSION_ATLEAST(1, 3)
> @@ -162,6 +163,7 @@ typedef struct QSVEncContext {
>  int recovery_point_sei;
> 
>  int a53_cc;
> +int low_power;
> 
>  #if QSV_HAVE_MF
>  int mfmode;
> diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c index
> 07c9d64e6b..40071d805a 100644
> --- a/libavcodec/qsvenc_h264.c
> +++ b/libavcodec/qsvenc_h264.c
> @@ -153,6 +153,9 @@ static const AVOption options[] = {
>  { "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_MF_DISABLED }, INT_MIN, INT_MAX, VE, "mfmode" },
>  { "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 =
> MFX_MF_AUTO }, INT_MIN, INT_MAX, VE, "mfmode" },
>  #endif
> +#if QSV_HAVE_VDENC
> +{ "low_power", "enable low power mode(experimental: many
> +limitations by mfx version, BRC modes, etc.)", OFFSET(qsv.low_power),
> +AV_OPT_TYPE_BOOL, { .i64 =  0 }, 0, 1, VE}, #endif
> 
>  { NULL },
>  };
> --
> 2.17.1

The reset LGTM

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


Re: [FFmpeg-devel] [PATCH] libavfilter/idet: fix double count and offset accuracy on progressive frame

2018-11-28 Thread pon pon
>Please avoid top-posting here,
Thannk you for your advice. I'll take care.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] lavc/hevc_parser: add 4 bytes startcode condition in hevc_find_frame_end

2018-11-28 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Thursday, November 29, 2018 02:14
> To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH] lavc/hevc_parser: add 4 bytes
> startcode condition in hevc_find_frame_end
> 
> On Tue, Nov 27, 2018 at 08:16:55PM +0800, Linjie Fu wrote:
> > The startcode before VPS,SPS,PPS and the first NALU in an AU is 4 bytes.
> > Blindly taking the startcode as 3 bytes will leave 0x00 in last packet
> > and may lead to some warnings in parse_nal_units when s->flags is set to
> > PARSER_FLAG_COMPLETE_FRAMES.
> >
> > Add 4 bytes startcode condition in hevc_find_frame_end.
> > Modify the code to print the buf_size like in H264 and reduce the
> duplication.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/hevc_parser.c | 15 ++-
> >  1 file changed, 10 insertions(+), 5 deletions(-)
> 
> breaks
>  make fate-hevc-bsf-mp4toannexb
> TESThevc-bsf-mp4toannexb
> --- - 2018-11-28 19:12:47.869732022 +0100
> +++ tests/data/fate/hevc-bsf-mp4toannexb  2018-11-28
> 19:12:47.864276885 +0100
> @@ -1 +1 @@
> -1873662a3af1848c37e4eb25722c8df9
> +73019329ed7f81c24f9af67c34c640c0
> Test hevc-bsf-mp4toannexb failed. Look at tests/data/fate/hevc-bsf-
> mp4toannexb.err for details.
> make: *** [fate-hevc-bsf-mp4toannexb] Error 1
> 

Investigate the root cause:

In fate test:
Step 1. ffmpeg -i hevc-conformance/WPP_A_ericsson_MAIN10_2.bit -c copy -flags 
+bitexact hevc-mp4.mov
Step 2. ffmpeg -i hevc-mp4_after.mov -c:v copy -fflags +bitexact -f hevc 
hevc.out
Step3. md5sum and compared with the reference

Compare the output file in Step 1 before and after the patch, and found it 
changed:
-rw-r--r-- 1 root root 68460 11月 29 11:23 hevc-mp4_after.mov
-rw-r--r-- 1 root root 68507 11月 29 11:31 hevc-mp4_before.mov

Compare the original file with two output files:
SUFFIX_SEI bit information in  the first frame for example :

WPP_A_ericsson_MAIN10_2.bit: { 50 01 84 31 00 19 39 77 d0 7b 3f bd 1e 09 38 9a 
79 41 c0 16 11 da 18 aa 0a db 2b 19 fa 47 3f 0f 67 4a 91 9c a1 12 72 67 d6 f0 
8f 66 ee 95 f9 e2 b9 ba 23 9a e8 80 }

hevc-mp4_before.mov: { 50 01 84 31 00 19 39 77 d0 7b 3f bd 1e 09 38 9a 79 41 c0 
16 11 da 18 aa 0a db 2b 19 fa 47 3f 0f 67 4a 91 9c a1 12 72 67 d6 f0 8f 66 ee 
95 f9 e2 b9 ba 23 9a e8 80 00 }

hevc-mp4_after.mov: { 50 01 84 31 00 19 39 77 d0 7b 3f bd 1e 09 38 9a 79 41 c0 
16 11 da 18 aa 0a db 2b 19 fa 47 3f 0f 67 4a 91 9c a1 12 72 67 d6 f0 8f 66 ee 
95 f9 e2 b9 ba 23 9a e8 80 }

Before applying the patch, the output file has an extra 0x00 at the end of 
SUFFIX_SEI (because of blindly taking startcode as 3 bytes and left one byte).
After applying the patch, the output file has the same bit info like the 
original file.
So, I think this patch works.

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


[FFmpeg-devel] [PATCH] [RFC] channel_layout: add support for ambisonics

2018-11-28 Thread Rostislav Pehlivanov
This is an RFC to add support for tagging channel layouts as ambisonics
in a backward-compatible way.
For now ambisonics up to third order are supported.
The functions have been updated to support and propagate the
AV_CH_LAYOUT_AMBISONICS flag.
This is messy but does not require a new API for layouts. Perhaps the
new proposed API might be a better solution, comments are welcome.
---
 doc/APIchanges |  4 ++
 libavutil/channel_layout.c | 85 +-
 libavutil/channel_layout.h | 19 -
 libavutil/version.h|  4 +-
 4 files changed, 72 insertions(+), 40 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index db1879e6e2..88e2d0764b 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,10 @@ libavutil: 2017-10-21
 
 API changes, most recent first:
 
+2018-xx-xx - xx - lavu 56.25.100 - channel_layout.h
+  Add AV_CH_LAYOUT_AMBISONICS, AV_CH_LAYOUT_AMBISONICS_1ST,
+  AV_CH_LAYOUT_AMBISONICS_2ND and AV_CH_LAYOUT_AMBISONICS_3RD.
+
  8< - FFmpeg 4.1 was cut here  8< -
 
 2018-10-27 - 718044dc19 - lavu 56.21.100 - pixdesc.h
diff --git a/libavutil/channel_layout.c b/libavutil/channel_layout.c
index 3bd5ee29b7..30297138fe 100644
--- a/libavutil/channel_layout.c
+++ b/libavutil/channel_layout.c
@@ -33,42 +33,45 @@
 
 struct channel_name {
 const char *name;
+const char *ambisonics_name;
 const char *description;
+const char *ambisonics_description;
 };
 
 static const struct channel_name channel_names[] = {
- [0] = { "FL","front left"},
- [1] = { "FR","front right"   },
- [2] = { "FC","front center"  },
- [3] = { "LFE",   "low frequency" },
- [4] = { "BL","back left" },
- [5] = { "BR","back right"},
- [6] = { "FLC",   "front left-of-center"  },
- [7] = { "FRC",   "front right-of-center" },
- [8] = { "BC","back center"   },
- [9] = { "SL","side left" },
-[10] = { "SR","side right"},
-[11] = { "TC","top center"},
-[12] = { "TFL",   "top front left"},
-[13] = { "TFC",   "top front center"  },
-[14] = { "TFR",   "top front right"   },
-[15] = { "TBL",   "top back left" },
-[16] = { "TBC",   "top back center"   },
-[17] = { "TBR",   "top back right"},
-[29] = { "DL","downmix left"  },
-[30] = { "DR","downmix right" },
-[31] = { "WL","wide left" },
-[32] = { "WR","wide right"},
-[33] = { "SDL",   "surround direct left"  },
-[34] = { "SDR",   "surround direct right" },
-[35] = { "LFE2",  "low frequency 2"   },
+ [0] = { "FL",   "1",  "front left","ambisonics component 1"  
},
+ [1] = { "FR",   "2",  "front right",   "ambisonics component 2"  
},
+ [2] = { "FC",   "0",  "front center",  "ambisonics component 0"  
},
+ [3] = { "LFE",  "3",  "low frequency", "ambisonics component 3"  
},
+ [4] = { "BL",   "4",  "back left", "ambisonics component 4"  
},
+ [5] = { "BR",   "5",  "back right","ambisonics component 5"  
},
+ [6] = { "FLC",  "6",  "front left-of-center",  "ambisonics component 6"  
},
+ [7] = { "FRC",  "7",  "front right-of-center", "ambisonics component 7"  
},
+ [8] = { "BC",   "8",  "back center",   "ambisonics component 8"  
},
+ [9] = { "SL",   "9",  "side left", "ambisonics component 9"  
},
+[10] = { "SR",   "10", "side right","ambisonics component 10" 
},
+[11] = { "TC",   "11", "top center","ambisonics component 11" 
},
+[12] = { "TFL",  "12", "top front left","ambisonics component 12" 
},
+[13] = { "TFC",  "13", "top front center",  "ambisonics component 13" 
},
+[14] = { "TFR",  "14", "top front right",   "ambisonics component 14" 
},
+[15] = { "TBL",  "15", "top back left", "ambisonics component 15" 
},
+[16] = { "TBC",  NULL, "top back center",   NULL  
},
+[17] = { "TBR",  NULL, "top back right",NULL  
},
+[29] = { "DL",   NULL, "downmix left",  NULL  
},
+[30] = { "DR",   NULL, "downmix right", NULL  
},
+[31] = { "WL",   NULL, "wide left", NULL  
},
+[32] = { "WR",   NULL, "wide right",NULL  
},
+[33] = { "SDL",  NULL, "surround direct left",  NULL  
},
+[34] = { "SDR",  NULL, "surround direct right", NULL  
},
+[35] = { "LFE2", NULL, "low frequency 2",   NULL  
},
 };
 
-static const char 

[FFmpeg-devel] [PATCH] avcodec/msmpeg4dec: Skip frame if its smaller than 1/8 of the minimal size

2018-11-28 Thread Michael Niedermayer
Frames that small are not valid and of limited use for error concealment, while
being very computationally intensive to process.

Fixes: Timeout
Fixes: 
11318/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSMPEG4V1_fuzzer-5710884555456512

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavcodec/msmpeg4dec.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
index 457a37e745..16b67192b5 100644
--- a/libavcodec/msmpeg4dec.c
+++ b/libavcodec/msmpeg4dec.c
@@ -412,6 +412,14 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
 {
 int code;
 
+// at minimum one bit per macroblock is required at least in a valid frame,
+// we discard frames much smaller than this. Frames smaller than 1/8 of the
+// smallest "black/skip" frame generally contain not much recoverable 
content
+// while at the same time they have the highest computational requirements
+// per byte
+if (get_bits_left(>gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
+return AVERROR_INVALIDDATA;
+
 if(s->msmpeg4_version==1){
 int start_code = get_bits_long(>gb, 32);
 if(start_code!=0x0100){
-- 
2.19.2

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


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/msmpeg4dec: Skip frame if its smaller than 1/8 of the minimal size

2018-11-28 Thread Michael Niedermayer
On Wed, Nov 28, 2018 at 10:06:12AM +0100, Hendrik Leppkes wrote:
> On Wed, Nov 28, 2018 at 1:54 AM Michael Niedermayer
>  wrote:
> >
> > Fixes: Timeout
> > Fixes: 
> > 11318/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSMPEG4V1_fuzzer-5710884555456512
> >
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/msmpeg4dec.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
> > index 457a37e745..d278540ec2 100644
> > --- a/libavcodec/msmpeg4dec.c
> > +++ b/libavcodec/msmpeg4dec.c
> > @@ -412,6 +412,9 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
> >  {
> >  int code;
> >
> > +if (get_bits_left(>gb) * 8LL < (s->width+15)/16 * 
> > ((s->height+15)/16))
> > +return AVERROR_INVALIDDATA;
> > +
> 
> Please add a comment so such lines why these magic values where
> choosen, and an explanation in the commit message that explains the
> proof that these are an absolute limit and no valid frame could ever
> be smaller would be appreciated.

ill post one with a more verbose description, ill update the 2nd
in line with what we agree on for the first

thx

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

"Nothing to hide" only works if the folks in power share the values of
you and everyone you know entirely and always will -- Tom Scott



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


Re: [FFmpeg-devel] [PATCH] avcodec/libopusenc: allow encoding channel mapping 2

2018-11-28 Thread Rostislav Pehlivanov
On Wed, 28 Nov 2018 at 20:35, Michael Niedermayer 
wrote:

> On Tue, Nov 27, 2018 at 06:13:54PM +0800, Felicia Lim wrote:
> > Friendly ping. Please let me know if there are any changes I should make
> to
> > this patch?
>
> will apply, seems noone else cares about it ...
>
> thanks
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Rewriting code that is poorly written but fully understood is good.
> Rewriting code that one doesnt understand is a sign that one is less smart
> then the original author, trying to rewrite it will not make it better.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>

Reverted.
I did describe what has to be done to properly support ambisonics as to
make this patch work properly. I know it works for Google's usecase but I'm
against "by-chance" ambisonics where you rely on a specific channel layout
and a specific encoder encoding them with a specific setting.
We still have bits leftover for channel layout and I'd agree to add an
extra bit to indicate the particular layout carries ambisonics, with the
number of channels indicating the order. This wouldn't need extensive
channel layout API replacements and would still be sufficient to implement
both encoding and decoding of such audio.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avcodec/libopusenc: allow encoding channel mapping 2

2018-11-28 Thread Rostislav Pehlivanov
On Fri, 27 Jul 2018 at 20:44, Felicia Lim 
wrote:

> ---
>  libavcodec/libopusenc.c | 22 ++
>  1 file changed, 22 insertions(+)
>
> diff --git a/libavcodec/libopusenc.c b/libavcodec/libopusenc.c
> index 4ae81b0bb2..6b450ec317 100644
> --- a/libavcodec/libopusenc.c
> +++ b/libavcodec/libopusenc.c
> @@ -27,6 +27,7 @@
>  #include "bytestream.h"
>  #include "internal.h"
>  #include "libopus.h"
> +#include "mathops.h"
>  #include "vorbis.h"
>  #include "audio_frame_queue.h"
>
> @@ -200,6 +201,21 @@ static int libopus_check_vorbis_layout(AVCodecContext
> *avctx, int mapping_family
>  return 0;
>  }
>
> +static int libopus_check_ambisonics_channels(AVCodecContext *avctx) {
> +int channels = avctx->channels;
> +int ambisonic_order = ff_sqrt(channels) - 1;
> +if (channels != ((ambisonic_order + 1) * (ambisonic_order + 1)) &&
> +channels != ((ambisonic_order + 1) * (ambisonic_order + 1) + 2)) {
> +av_log(avctx, AV_LOG_ERROR,
> +   "Ambisonics coding is only specified for channel counts"
> +   " which can be written as (n + 1)^2 or (n + 1)^2 + 2"
> +   " for nonnegative integer n\n");
> +return AVERROR_INVALIDDATA;
> +}
> +
> +return 0;
> +}
> +
>  static int libopus_validate_layout_and_get_channel_map(
>  AVCodecContext *avctx,
>  int mapping_family,
> @@ -231,6 +247,12 @@ static int
> libopus_validate_layout_and_get_channel_map(
>  channel_map =
> ff_vorbis_channel_layout_offsets[avctx->channels - 1];
>  }
>  break;
> +case 2:
> +ret = libopus_check_max_channels(avctx, 227);
> +if (ret == 0) {
> +ret = libopus_check_ambisonics_channels(avctx);
> +}
> +break;
>  case 255:
>  ret = libopus_check_max_channels(avctx, 254);
>  break;
> --
> 2.18.0.345.g5c9ce644c3-goog
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel



I did not OK the patch at all and none of the requests I made were met.
This has to be reverted.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH]lavf/rawdec: Do not mark raw subtitle streams as data streams

2018-11-28 Thread Carl Eugen Hoyos
2018-11-28 21:21 GMT+01:00, Michael Niedermayer :
> On Tue, Nov 27, 2018 at 06:24:15PM +0100, Carl Eugen Hoyos wrote:
>> Hi!
>>
>> Attached patch improves the "ffmpeg -i" output for raw dvbsub files.
>>
>> Please comment, Carl Eugen
>
>>  rawdec.c |   11 +++
>>  rawdec.h |4 +++-
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>> 72597d4a785a23105a2eba5f57b5cc3bc1f95f93
>> 0001-lavf-rawdec-Do-not-mark-streams-from-raw-subtitle-de.patch
>> From 6cddd293354c75a20ae54e0ea62898c128826601 Mon Sep 17 00:00:00 2001
>> From: Carl Eugen Hoyos 
>> Date: Tue, 27 Nov 2018 18:22:02 +0100
>> Subject: [PATCH] lavf/rawdec: Do not mark streams from raw subtitle
>> demuxers
>>  as data streams.
>>
>> Improves "ffmpeg -i" output for raw dvbsub files.
>> ---
>>  libavformat/rawdec.c |   11 +++
>>  libavformat/rawdec.h |4 +++-
>>  2 files changed, 14 insertions(+), 1 deletion(-)
>
> should be ok

Patch applied.

Thank you, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH]lavc/mpeg12dec: Read Closed Captions from second field

2018-11-28 Thread Carl Eugen Hoyos
Hi!

Attached patch fixes reading Closed Captions from a field-encoded
mpeg2video sample from the libav-user mailing list.

Please review, Carl Eugen
From 045a485ffedb3344560070a58a2def659be81700 Mon Sep 17 00:00:00 2001
From: Carl Eugen Hoyos 
Date: Wed, 28 Nov 2018 22:45:00 +0100
Subject: [PATCH] lavc/mpeg12dec: Read Closed Captions from second field.

---
 libavcodec/mpeg12dec.c |   11 +++
 1 file changed, 11 insertions(+)

diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 83e5378..c0a54a8 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -1664,6 +1664,17 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
 return AVERROR_INVALIDDATA;
 }
 
+if (s1->a53_caption) {
+AVFrameSideData *sd;
+av_frame_remove_side_data(s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC);
+sd = av_frame_new_side_data(
+s->current_picture_ptr->f, AV_FRAME_DATA_A53_CC,
+s1->a53_caption_size);
+if (sd)
+memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
+av_freep(>a53_caption);
+}
+
 if (s->avctx->hwaccel &&
 (s->avctx->slice_flags & SLICE_FLAG_ALLOW_FIELD)) {
 if ((ret = s->avctx->hwaccel->end_frame(s->avctx)) < 0) {
-- 
1.7.10.4

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


Re: [FFmpeg-devel] [PATCH v2] lavfi/vf_colorconstancy: add weighted_greyedge

2018-11-28 Thread Moritz Barsnick
On Mon, Oct 01, 2018 at 18:09:46 +0200, Mina wrote:

Nit:

> +be chosen in the range [1,20] and default value is 1.
[...]
> +chosen in the range [0.2,1024.0] and default value = 1.

A bit inconsistent here, with "is" vs. "=".

> +The max number of iterations for performing the algorithm. Must be chosen in 
> the
   ^ maximum

I can't comment on the rest.

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


Re: [FFmpeg-devel] [PATCH] avcodec/libopusenc: allow encoding channel mapping 2

2018-11-28 Thread Michael Niedermayer
On Tue, Nov 27, 2018 at 06:13:54PM +0800, Felicia Lim wrote:
> Friendly ping. Please let me know if there are any changes I should make to
> this patch?

will apply, seems noone else cares about it ...

thanks

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

Rewriting code that is poorly written but fully understood is good.
Rewriting code that one doesnt understand is a sign that one is less smart
then the original author, trying to rewrite it will not make it better.


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


Re: [FFmpeg-devel] [PATCH]lavf/rawdec: Do not mark raw subtitle streams as data streams

2018-11-28 Thread Michael Niedermayer
On Tue, Nov 27, 2018 at 06:24:15PM +0100, Carl Eugen Hoyos wrote:
> Hi!
> 
> Attached patch improves the "ffmpeg -i" output for raw dvbsub files.
> 
> Please comment, Carl Eugen

>  rawdec.c |   11 +++
>  rawdec.h |4 +++-
>  2 files changed, 14 insertions(+), 1 deletion(-)
> 72597d4a785a23105a2eba5f57b5cc3bc1f95f93  
> 0001-lavf-rawdec-Do-not-mark-streams-from-raw-subtitle-de.patch
> From 6cddd293354c75a20ae54e0ea62898c128826601 Mon Sep 17 00:00:00 2001
> From: Carl Eugen Hoyos 
> Date: Tue, 27 Nov 2018 18:22:02 +0100
> Subject: [PATCH] lavf/rawdec: Do not mark streams from raw subtitle demuxers
>  as data streams.
> 
> Improves "ffmpeg -i" output for raw dvbsub files.
> ---
>  libavformat/rawdec.c |   11 +++
>  libavformat/rawdec.h |4 +++-
>  2 files changed, 14 insertions(+), 1 deletion(-)

should be ok

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

During times of universal deceit, telling the truth becomes a
revolutionary act. -- George Orwell


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


Re: [FFmpeg-devel] [PATCH 1/3] lavf/matroskadec: don't treat I/O errors as EOF

2018-11-28 Thread Rodger Combs


> On Nov 28, 2018, at 13:19, Marton Balint  wrote:
> 
> 
> 
> On Wed, 28 Nov 2018, Rodger Combs wrote:
> 
>> pb->eof_reached is set on error, so we need to check pb->error,
>> even after checking pb->eof_reached or avio_feof(pb), or else we
>> can end up returning AVERROR_EOF instead of the actual error code.
> 
> Why eof_reached is set in the first place on error? Why does avio_feof() 
> return nonzero if we are not at the end of file? That is strictly against its 
> documentation.

Looks like it's been like that since at least 2002. It's probably because a lot 
of code that loops on e.g. avio_r8 checks for EOF, but doesn't explicitly check 
for error, so if errors didn't set the EOF flag, they'd just loop forever. 
Either way, that code needs to be updated to return errors properly, so I don't 
think removing the EOF-on-error behavior is helpful (it'd just make existing 
problem cases worse).

> 
> Seems like a fine mess, let's think about how we will resolve this in a 
> generic way.

I don't think this can really be resolved generically, since all the places 
that currently just return AVERROR_EOF in this case will need updating to read 
the error from AVIOContext regardless.

> 
> Thanks,
> Marton
> ___
> 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


Re: [FFmpeg-devel] avcodec/proresdec : add 12b decoding support

2018-11-28 Thread Michael Niedermayer
On Tue, Nov 27, 2018 at 11:03:50PM +0100, Martin Vignali wrote:
>  utils.c |4 
>  1 file changed, 4 insertions(+)
> 16e7e76e9bde70f7604c3df1a5ec42828e38555b  
> 0001-avcodec-utils-add-YUVA444P12-and-YUVA422P12-to-pixfm.patch
> From db7fb1bd052ff3dba0fe3510912214aa6e66d56b Mon Sep 17 00:00:00 2001
> From: Martin Vignali 
> Date: Tue, 27 Nov 2018 22:21:47 +0100
> Subject: [PATCH 01/10] avcodec/utils : add YUVA444P12 and YUVA422P12 to pixfmt
>  who need height padding in avcodec_align_dimensions2
> 
> ---
>  libavcodec/utils.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 1661d48b90..c4c64a6ca4 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -214,6 +214,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int 
> *width, int *height,
>  case AV_PIX_FMT_YUVA422P9BE:
>  case AV_PIX_FMT_YUVA422P10LE:
>  case AV_PIX_FMT_YUVA422P10BE:
> +case AV_PIX_FMT_YUVA422P12LE:
> +case AV_PIX_FMT_YUVA422P12BE:
>  case AV_PIX_FMT_YUVA422P16LE:
>  case AV_PIX_FMT_YUVA422P16BE:
>  case AV_PIX_FMT_YUV440P10LE:
> @@ -234,6 +236,8 @@ void avcodec_align_dimensions2(AVCodecContext *s, int 
> *width, int *height,
>  case AV_PIX_FMT_YUVA444P9BE:
>  case AV_PIX_FMT_YUVA444P10LE:
>  case AV_PIX_FMT_YUVA444P10BE:
> +case AV_PIX_FMT_YUVA444P12LE:
> +case AV_PIX_FMT_YUVA444P12BE:
>  case AV_PIX_FMT_YUVA444P16LE:
>  case AV_PIX_FMT_YUVA444P16BE:
>  case AV_PIX_FMT_GBRP9LE:

LGTM

thx

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The real ebay dictionary, page 1
"Used only once"- "Some unspecified defect prevented a second use"
"In good condition" - "Can be repaird by experienced expert"
"As is" - "You wouldnt want it even if you were payed for it, if you knew ..."


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


Re: [FFmpeg-devel] [PATCH 1/3] lavf/matroskadec: don't treat I/O errors as EOF

2018-11-28 Thread Marton Balint



On Wed, 28 Nov 2018, Rodger Combs wrote:


pb->eof_reached is set on error, so we need to check pb->error,
even after checking pb->eof_reached or avio_feof(pb), or else we
can end up returning AVERROR_EOF instead of the actual error code.


Why eof_reached is set in the first place on error? Why does avio_feof() 
return nonzero if we are not at the end of file? That is strictly against 
its documentation.


Seems like a fine mess, let's think about how we will resolve this in a 
generic way.


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


Re: [FFmpeg-devel] [PATCH v2] lavfi/vf_colorconstancy: add weighted_greyedge

2018-11-28 Thread Thilo Borgmann

>> V2 changes:
>> - fixed some spelling mistakes in filters.texi
>> - fixed some text format error in filters.texi

Will apply soon if there are no further comments.

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


Re: [FFmpeg-devel] [PATCH] lavc/hevc_parser: add 4 bytes startcode condition in hevc_find_frame_end

2018-11-28 Thread Michael Niedermayer
On Tue, Nov 27, 2018 at 08:16:55PM +0800, Linjie Fu wrote:
> The startcode before VPS,SPS,PPS and the first NALU in an AU is 4 bytes.
> Blindly taking the startcode as 3 bytes will leave 0x00 in last packet
> and may lead to some warnings in parse_nal_units when s->flags is set to
> PARSER_FLAG_COMPLETE_FRAMES.
> 
> Add 4 bytes startcode condition in hevc_find_frame_end.
> Modify the code to print the buf_size like in H264 and reduce the duplication.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/hevc_parser.c | 15 ++-
>  1 file changed, 10 insertions(+), 5 deletions(-)

breaks
 make fate-hevc-bsf-mp4toannexb
TESThevc-bsf-mp4toannexb
--- -   2018-11-28 19:12:47.869732022 +0100
+++ tests/data/fate/hevc-bsf-mp4toannexb2018-11-28 19:12:47.864276885 
+0100
@@ -1 +1 @@
-1873662a3af1848c37e4eb25722c8df9
+73019329ed7f81c24f9af67c34c640c0
Test hevc-bsf-mp4toannexb failed. Look at 
tests/data/fate/hevc-bsf-mp4toannexb.err for details.
make: *** [fate-hevc-bsf-mp4toannexb] Error 1

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

Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.


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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/mpegenc: extend muxing PCM-DVD to other depths

2018-11-28 Thread Michael Niedermayer
On Tue, Nov 27, 2018 at 12:29:26PM +0100, Paul B Mahol wrote:
> Fixes #6783.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavformat/mpegenc.c | 15 +--
>  1 file changed, 9 insertions(+), 6 deletions(-)

breaks:
make fate-mpegps-remuxed-pcm-demux
TESTmpegps-remuxed-pcm-demux
--- ./tests/ref/fate/mpegps-remuxed-pcm-demux   2018-11-25 15:28:06.126532228 
+0100
+++ tests/data/fate/mpegps-remuxed-pcm-demux2018-11-28 18:42:49.004238988 
+0100
@@ -1,50 +0,0 @@
-#tb 0: 1/9
-#media_type 0: audio
-#codec_id 0: pcm_dvd
-#sample_rate 0: 44100
-#channel_layout 0: 4
-#channel_layout_name 0: mono
-0,  0,  0, 2040, 2005, 0x8e98e563
-0,   2090,   2090, 2069, 2033, 0xd6f2f455
-0,   4180,   4180, 2057, 2021, 0x77a6e6c9
-0,   6269,   6269, 2057, 2021, 0x8dbcf6be
-0,   8359,   8359, 2057, 2021, 0xc629eaa0
-0,  10449,  10449, 2057, 2021, 0xa951ebe5
-0,  12539,  12539, 2057, 2021, 0x1324f29b
-0,  14629,  14629, 2057, 2021, 0x55f1e968
-0,  16718,  16718, 2057, 2021, 0x98a7f994
-0,  18808,  18808, 2057, 2021, 0xba42f42f
-0,  20898,  20898, 2057, 2021, 0xcf5cefe6
-0,  22988,  22988, 2057, 2021, 0xeef8f2b5
-0,  25078,  25078, 2057, 2021, 0x71faf42f
-0,  27167,  27167, 2057, 2021, 0x0346f019
-0,  29257,  29257, 2057, 2021, 0xbca0f4a3
-0,  31347,  31347, 2057, 2021, 0x3b6ced4f
-0,  33437,  33437, 2057, 2021, 0xc8b9ea0a
-0,  35527,  35527, 2057, 2021, 0x18e5f385
-0,  37616,  37616, 2057, 2021, 0x74f6e9d6
-0,  39706,  39706, 2057, 2021, 0x35d8f2b5
-0,  41796,  41796, 2057, 2021, 0x9d2aec53
-0,  43886,  43886, 2057, 2021, 0xf0acf1a0
-0,  45976,  45976, 2057, 2021, 0xa724ebe9
-0,  48065,  48065, 2057, 2021, 0xd4f8f534
-0,  50155,  50155, 2057, 2021, 0xdf62efc6
-0,  52245,  52245, 2057, 2021, 0x9865f504
-0,  54335,  54335, 2057, 2021, 0x8670efb7
-0,  56424,  56424, 2057, 2021, 0xe51af219
-0,  58514,  58514, 2057, 2021, 0x0210f27f
-0,  60604,  60604, 2057, 2021, 0x4b08f406
-0,  62694,  62694, 2057, 2021, 0x2b02eed4
-0,  64784,  64784, 2057, 2021, 0x0445ed00
-0,  66873,  66873, 2057, 2021, 0xfae9f21f
-0,  68963,  68963, 2057, 2021, 0x3d6beabc
-0,  71053,  71053, 2057, 2021, 0xc50af39c
-0,  73143,  73143, 2057, 2021, 0xf9eceb82
-0,  75233,  75233, 2057, 2021, 0x7b89eb9b
-0,  77322,  77322, 2057, 2021, 0x7c07ef4b
-0,  79412,  79412, 2057, 2021, 0xbfacf1eb
-0,  81502,  81502, 2057, 2021, 0xccb2f27b
-0,  83592,  83592, 2057, 2021, 0xc035f557
-0,  85682,  85682, 2057, 2021, 0xbdf1edea
-0,  87771,  87771, 2057, 2021, 0x3644f424
-0,  89861,  89861, 1457, 1433, 0xdd17d51f
Test mpegps-remuxed-pcm-demux failed. Look at 
tests/data/fate/mpegps-remuxed-pcm-demux.err for details.
make: *** [fate-mpegps-remuxed-pcm-demux] Error 1

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

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.


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


Re: [FFmpeg-devel] [PATCH] avcodec/opus: set skip_samples

2018-11-28 Thread Michael Niedermayer
On Tue, Nov 27, 2018 at 03:18:14PM +0100, Paul B Mahol wrote:
> Fixes #5258.
> 
> Signed-off-by: Paul B Mahol 
> ---
>  libavcodec/opus.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

breaks fate

make: *** [fate-seek-mkv-codec-delay] Error 139
make: *** [fate-opus-tron.6ch.tinypkts] Error 1
make: *** [fate-ts-opus-demux] Error 139


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

It is dangerous to be right in matters on which the established authorities
are wrong. -- Voltaire


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


Re: [FFmpeg-devel] [PATCH 2/2] avformat/dashenc: Added an option to ignore io errors

2018-11-28 Thread Jeyapal, Karthick

On 11/27/18 9:52 PM, Carl Eugen Hoyos wrote:
> 2018-11-26 11:25 GMT+01:00, Karthick J :
> > When dashenc has to run for long duration(say 24x7 live stream), one can
> > enable this option to ignore the io failure of few segment's upload due to
> > an intermittent network issues.
> > When the network connection recovers dashenc will continue with the upload
> > of the current segments, leading to the recovery of the stream.
>
> > -return ret;
> > +if (c->ignore_io_errors)
> > +return 0;
> > +else
> > +return ret;
>
> Maybe: return c->ignore_io_errors ? 0 : ret;
> but it's your code...
I appreciate your comment. Always happy to accept suggestions that will make 
this code better. Have sent PATCH v2 with these changes.
And it is everybody's code. I am just a maintainer (

Regards,
Karthick
>
> Carl Eugen
> ___
> 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 v2 2/2] avformat/dashenc: Added an option to ignore io errors

2018-11-28 Thread Karthick J
When dashenc has to run for long duration(say 24x7 live stream), one can enable 
this option to ignore the io failure of few segment's upload due to an 
intermittent network issues.
When the network connection recovers dashenc will continue with the upload of 
the current segments, leading to the recovery of the stream.
---
 doc/muxers.texi   |  3 +++
 libavformat/dashenc.c | 17 +++--
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index a02ac01b55..f1cc6f5fee 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -300,6 +300,9 @@ If this flag is set, the dash segment files will be in in 
ISOBMFF format.
 @item webm
 If this flag is set, the dash segment files will be in in WebM format.
 
+@item -ignore_io_errors @var{ignore_io_errors}
+Ignore IO errors during open and write. Useful for long-duration runs with 
network output.
+
 @end table
 
 @anchor{framecrc}
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 2f403257c0..04218af6a6 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -138,6 +138,7 @@ typedef struct DASHContext {
 int index_correction;
 char *format_options_str;
 SegmentType segment_type_option;  /* segment type as specified in options 
*/
+int ignore_io_errors;
 } DASHContext;
 
 static struct codec_string {
@@ -846,7 +847,7 @@ static int write_manifest(AVFormatContext *s, int final)
 av_dict_free();
 if (ret < 0) {
 av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", 
temp_filename);
-return ret;
+return c->ignore_io_errors ? 0 : ret;
 }
 out = c->mpd_out;
 avio_printf(out, "\n");
@@ -937,7 +938,7 @@ static int write_manifest(AVFormatContext *s, int final)
 av_dict_free();
 if (ret < 0) {
 av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", 
temp_filename);
-return ret;
+return c->ignore_io_errors ? 0 : ret;
 }
 
 ff_hls_write_playlist_version(c->m3u8_out, 7);
@@ -1565,8 +1566,9 @@ static int dash_write_packet(AVFormatContext *s, AVPacket 
*pkt)
 set_http_options(, c);
 ret = dashenc_io_open(s, >out, os->temp_path, );
 av_dict_free();
-if (ret < 0)
-return ret;
+if (ret < 0) {
+return c->ignore_io_errors ? 0 : ret;
+}
 }
 
 //write out the data immediately in streaming mode
@@ -1577,9 +1579,11 @@ static int dash_write_packet(AVFormatContext *s, 
AVPacket *pkt)
 write_styp(os->ctx->pb);
 avio_flush(os->ctx->pb);
 len = avio_get_dyn_buf (os->ctx->pb, );
-avio_write(os->out, buf + os->written_len, len - os->written_len);
+if (os->out) {
+avio_write(os->out, buf + os->written_len, len - os->written_len);
+avio_flush(os->out);
+}
 os->written_len = len;
-avio_flush(os->out);
 }
 
 return ret;
@@ -1670,6 +1674,7 @@ static const AVOption options[] = {
 { "auto", "select segment file format based on codec", 0, 
AV_OPT_TYPE_CONST, {.i64 = SEGMENT_TYPE_AUTO }, 0, UINT_MAX,   E, 
"segment_type"},
 { "mp4", "make segment file in ISOBMFF format", 0, AV_OPT_TYPE_CONST, 
{.i64 = SEGMENT_TYPE_MP4 }, 0, UINT_MAX,   E, "segment_type"},
 { "webm", "make segment file in WebM format", 0, AV_OPT_TYPE_CONST, {.i64 
= SEGMENT_TYPE_WEBM }, 0, UINT_MAX,   E, "segment_type"},
+{ "ignore_io_errors", "Ignore IO errors during open and write. Useful for 
long-duration runs with network output", OFFSET(ignore_io_errors), 
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
 { NULL },
 };
 
-- 
2.17.1 (Apple Git-112)

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


[FFmpeg-devel] [PATCH v2 1/2] avformat/dashenc: Handled the error from dashenc_io_open()

2018-11-28 Thread Karthick J
---
 libavformat/dashenc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6ce70e0076..2f403257c0 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -527,8 +527,12 @@ static void output_segment_list(OutputStream *os, 
AVIOContext *out, AVFormatCont
 snprintf(temp_filename_hls, sizeof(temp_filename_hls), use_rename ? 
"%s.tmp" : "%s", filename_hls);
 
 set_http_options(_opts, c);
-dashenc_io_open(s, >m3u8_out, temp_filename_hls, _opts);
+ret = dashenc_io_open(s, >m3u8_out, temp_filename_hls, _opts);
 av_dict_free(_opts);
+if (ret < 0) {
+av_log(s, AV_LOG_ERROR, "Unable to open %s for writing\n", 
temp_filename_hls);
+return;
+}
 for (i = start_index; i < os->nb_segments; i++) {
 Segment *seg = os->segments[i];
 double duration = (double) seg->duration / timescale;
-- 
2.17.1 (Apple Git-112)

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


Re: [FFmpeg-devel] [PATCH 2/2] lavf/dashenc: Delete HLS manifests on trailer writing if remove_at_exit is set.

2018-11-28 Thread Jeyapal, Karthick

On 11/28/18 5:06 PM, Andrey Semashev wrote:
> This fixes HLS manifests being left behind if remove_at_exit is set.
> ---
>  libavformat/dashenc.c | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index a7d8c4e237..af3f0ee167 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1619,6 +1619,18 @@ static int dash_write_trailer(AVFormatContext *s)
>  dashenc_delete_file(s, filename);
>  }
>  dashenc_delete_file(s, s->url);
> +
> +if (c->hls_playlist && c->master_playlist_created) {
> +for (i = 0; i < s->nb_streams; i++) {
> +OutputStream *os = >streams[i];
> +if (os->segment_type == SEGMENT_TYPE_MP4) {
> +get_hls_playlist_name(filename, sizeof(filename), 
> c->dirname, i);
> +dashenc_delete_file(s, filename);
> +}
> +}
> +snprintf(filename, sizeof(filename), "%smaster.m3u8", 
> c->dirname);
> +dashenc_delete_file(s, filename);
> +}
>  }
>  
>  return 0;
LGTM

Regards,
Karthick

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


Re: [FFmpeg-devel] [PATCH 1/2] lavf/dashenc: Don't put non-mp4 streams in HLS manifests.

2018-11-28 Thread Jeyapal, Karthick

On 11/28/18 5:06 PM, Andrey Semashev wrote:
> The only native HLS implementation in the wild (Safari browser) doesn't
> support WebM. And at least some MSE-based players (e.g. shaka-player)
> cannot handle WebM media segments when playing HLS. So just skip non-mp4
> streams from HLS manifests. Note that such streams will still be described
> by the DASH manifest and therefore consumed by players supporting DASH.
> ---
>  libavformat/dashenc.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 6ce70e0076..a7d8c4e237 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -225,6 +225,7 @@ static inline SegmentType select_segment_type(SegmentType 
> segment_type, enum AVC
>  static int init_segment_types(AVFormatContext *s)
>  {
>  DASHContext *c = s->priv_data;
> +int has_mp4_streams = 0;
>  for (int i = 0; i < s->nb_streams; ++i) {
>  OutputStream *os = >streams[i];
>  SegmentType segment_type = select_segment_type(
> @@ -235,6 +236,12 @@ static int init_segment_types(AVFormatContext *s)
>  av_log(s, AV_LOG_ERROR, "Could not select DASH segment type for 
> stream %d\n", i);
>  return AVERROR_MUXER_NOT_FOUND;
>  }
> +has_mp4_streams |= segment_type == SEGMENT_TYPE_MP4;
> +}
> +
> +if (c->hls_playlist && !has_mp4_streams) {
> + av_log(s, AV_LOG_WARNING, "No mp4 streams, disabling HLS manifest 
> generation\n");
> + c->hls_playlist = 0;
>  }
>  
>  return 0;
> @@ -510,7 +517,7 @@ static void output_segment_list(OutputStream *os, 
> AVIOContext *out, AVFormatCont
>  }
>  avio_printf(out, "\t\t\t\t\n");
>  }
> -if (c->hls_playlist && start_index < os->nb_segments)
> +if (c->hls_playlist && start_index < os->nb_segments && os->segment_type 
> == SEGMENT_TYPE_MP4)
>  {
>  int timescale = os->ctx->streams[0]->time_base.den;
>  char temp_filename_hls[1024];
> @@ -944,6 +951,8 @@ static int write_manifest(AVFormatContext *s, int final)
>  OutputStream *os = >streams[i];
>  if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
>  continue;
> +if (os->segment_type != SEGMENT_TYPE_MP4)
> +continue;
>  get_hls_playlist_name(playlist_file, sizeof(playlist_file), 
> NULL, i);
>  ff_hls_write_audio_rendition(c->m3u8_out, (char *)audio_group,
>   playlist_file, i, is_default);
> @@ -967,6 +976,8 @@ static int write_manifest(AVFormatContext *s, int final)
>  int stream_bitrate = st->codecpar->bit_rate + os->muxer_overhead;
>  if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
>  continue;
> +if (os->segment_type != SEGMENT_TYPE_MP4)
> +continue;
>  av_strlcpy(codec_str, os->codec_str, sizeof(codec_str));
>  if (max_audio_bitrate) {
>  agroup = (char *)audio_group;
LGTM

Regards,
Karthick

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


Re: [FFmpeg-devel] [PATCH] lavf/dashenc: Fix file URI handling when deleting files.

2018-11-28 Thread Jeyapal, Karthick

On 11/28/18 4:46 PM, Andrey Semashev wrote:
> The URI used to open the output streams may be an actual URI with "file" 
> scheme,
> according to https://tools.ietf.org/html/rfc8089. This commit makes file
> deletion routine recognize file URIs and extract the actual filesystem path
> from it.
There is already some code in ffmpeg to handle this. It is present in 
file_delete() function in file.c.
We will need to avoid code duplication for the same functionality. One option 
could be to call avpriv_io_delete() function instead of calling unlink, so that 
file_delete function gets called.
Calling avpriv_io_delete will also make the delete functionality easily 
extendable for other output protocols. 
>
> It also fixes strerror use, which may not be thread-safe.
> ---
>  libavformat/dashenc.c | 29 +++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 6ce70e0076..e59fa0944e 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -25,6 +25,7 @@
>  #include 
>  #endif
>  
> +#include "libavutil/error.h"
>  #include "libavutil/avassert.h"
>  #include "libavutil/avutil.h"
>  #include "libavutil/avstring.h"
> @@ -1326,8 +1327,32 @@ static void dashenc_delete_file(AVFormatContext *s, 
> char *filename) {
>  
>  av_dict_free(_opts);
>  ff_format_io_close(s, );
> -} else if (unlink(filename) < 0) {
> -av_log(s, AV_LOG_ERROR, "failed to delete %s: %s\n", filename, 
> strerror(errno));
> +} else {
> +const char* path = filename;
> +// Check if the filename is a file URI. 
> https://tools.ietf.org/html/rfc8089#section-2
> +if (av_strncasecmp(path, "file:", sizeof("file:") - 1) == 0) {
> +path += sizeof("file:") - 1;
> +if (path[0] == '/' && path[1] == '/') {
> +// The URI may have an authority part. Check that the 
> authority does not contain
> +// a host name. We cannot access filesystem on a different 
> host.
> +path += 2;
> +if (path[0] != '/') {
> +if (strncmp(path, "localhost", sizeof("localhost") - 1) 
> == 0) {
> +path += sizeof("localhost") - 1;
> +} else {
> +av_log(s, AV_LOG_ERROR, "cannot delete file on a 
> remote host: %s\n", filename);
> +return;
> +}
> +}
> +}
> +}
> +
> +if (unlink(path) < 0) {
> +int err = AVERROR(errno);
> +char errbuf[128];
> +av_strerror(err, errbuf, sizeof(errbuf));
> +av_log(s, (err == AVERROR(ENOENT) ? AV_LOG_WARNING : 
> AV_LOG_ERROR), "failed to delete %s: %s\n", path, errbuf);
> +}
>  }
>  }
>  

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


Re: [FFmpeg-devel] [PATCH] lavf/dashenc: Remove global_sidx from movenc params for live streaming.

2018-11-28 Thread Jeyapal, Karthick

On 11/28/18 4:41 PM, Andrey Semashev wrote:
> The global_sidx flag causes errors like the following in movenc when media
> segment removal is enabled via windos_size or remove_at_exit:
>
> Non-consecutive fragments, writing incorrect sidx
> Unable to re-open  output file for the second pass (faststart)
Removing global_sidx flag adds sidx atom to each moof fragment adding 
significant bitrate overhead. 
Instead I have submitted a patch to handle this case cleanly in movenc. 
http://ffmpeg.org/pipermail/ffmpeg-devel/2018-November/236873.html
Please try the above patch and let me know if that will work for you. 
> ---
>  libavformat/dashenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index 6ce70e0076..cb49641b4e 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -1141,7 +1141,7 @@ static int dash_init(AVFormatContext *s)
>  
>  if (os->segment_type == SEGMENT_TYPE_MP4) {
>  if (c->streaming)
> -av_dict_set(, "movflags", 
> "frag_every_frame+dash+delay_moov+global_sidx", 0);
> +av_dict_set(, "movflags", 
> "frag_every_frame+dash+delay_moov", 0);
>  else
>  av_dict_set(, "movflags", 
> "frag_custom+dash+delay_moov", 0);
>  } else {

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


Re: [FFmpeg-devel] [PATCH] avformat/movenc : Don't write sidx for empty urls

2018-11-28 Thread Jeyapal, Karthick
>On 11/28/18, 8:19 PM, "Moritz Barsnick"  wrote:
>
>On Wed, Nov 28, 2018 at 20:10:11 +0530, Karthick J wrote:
>> +// If url is an empty string("") don't write sidx atom.
>> +if (s->url[0] == '\0')
>> +return res;
>
>Probably clearer if you return 0, as res hasn't been assigned anything
>up to this point, except its initial 0.
Makes sense. Sent PATCH v2 with this change.

Regards,
Karthick
>
>Moritz

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


[FFmpeg-devel] [PATCH v2] avformat/movenc : Don't write sidx for empty urls

2018-11-28 Thread Karthick J
When movenc is used by other segmenting muxers such as dashenc, url field is 
always empty.
In such cases it is better to not write sidx, instead of throwing errors.
---
 libavformat/movenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..d47ecc65ca 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6706,6 +6706,9 @@ static int mov_write_trailer(AVFormatContext *s)
mov->tracks[i].data_offset = 0;
 if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX) {
 int64_t end;
+// If url is an empty string("") don't write sidx atom.
+if (s->url[0] == '\0')
+return 0;
 av_log(s, AV_LOG_INFO, "Starting second pass: inserting sidx 
atoms\n");
 res = shift_data(s);
 if (res < 0)
-- 
2.17.1 (Apple Git-112)

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


Re: [FFmpeg-devel] [PATCH] libavfilter/idet: fix double count and offset accuracy on progressive frame

2018-11-28 Thread Carl Eugen Hoyos
2018-11-28 7:52 GMT+01:00, pon pon :
> I have attached logs in tichet #7565.

No...

Please avoid top-posting here, Carl Eugen
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat/movenc : Don't write sidx for empty urls

2018-11-28 Thread Moritz Barsnick
On Wed, Nov 28, 2018 at 20:10:11 +0530, Karthick J wrote:
> +// If url is an empty string("") don't write sidx atom.
> +if (s->url[0] == '\0')
> +return res;

Probably clearer if you return 0, as res hasn't been assigned anything
up to this point, except its initial 0.

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


[FFmpeg-devel] [PATCH] avformat/movenc : Don't write sidx for empty urls

2018-11-28 Thread Karthick J
When movenc is used by other segmenting muxers such as dashenc, url field is 
always empty.
In such cases it is better to not write sidx, instead of throwing errors.
---
 libavformat/movenc.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 6dab5193b0..150a505a4a 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -6706,6 +6706,9 @@ static int mov_write_trailer(AVFormatContext *s)
mov->tracks[i].data_offset = 0;
 if (mov->flags & FF_MOV_FLAG_GLOBAL_SIDX) {
 int64_t end;
+// If url is an empty string("") don't write sidx atom.
+if (s->url[0] == '\0')
+return res;
 av_log(s, AV_LOG_INFO, "Starting second pass: inserting sidx 
atoms\n");
 res = shift_data(s);
 if (res < 0)
-- 
2.17.1 (Apple Git-112)

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


[FFmpeg-devel] [PATCH] lavf/dashenc: Write media trailers when DASH trailer is written.

2018-11-28 Thread Andrey Semashev
This commit ensures that all (potentially, long) filesystem activity is
performed when the user calls av_write_trailer on the DASH libavformat
context, not when freeing the context. Also, this defers media segment
deletion until after the media trailers are written.
---
 libavformat/dashenc.c | 19 ++-
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6ce70e0076..e1c959dc89 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -424,8 +424,6 @@ static void dash_free(AVFormatContext *s)
 return;
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = >streams[i];
-if (os->ctx && os->ctx_inited)
-av_write_trailer(os->ctx);
 if (os->ctx && os->ctx->pb)
 ffio_free_dyn_buf(>ctx->pb);
 ff_format_io_close(s, >out);
@@ -1420,13 +1418,11 @@ static int dash_flush(AVFormatContext *s, int final, 
int stream)
 os->pos += range_length;
 }
 
-if (c->window_size || (final && c->remove_at_exit)) {
+if (c->window_size) {
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = >streams[i];
 int j;
 int remove = os->nb_segments - c->window_size - 
c->extra_window_size;
-if (final && c->remove_at_exit)
-remove = os->nb_segments;
 if (remove > 0) {
 for (j = 0; j < remove; j++) {
 char filename[1024];
@@ -1599,11 +1595,24 @@ static int dash_write_trailer(AVFormatContext *s)
 }
 dash_flush(s, 1, -1);
 
+for (int i = 0; i < s->nb_streams; ++i) {
+OutputStream *os = >streams[i];
+if (os->ctx && os->ctx_inited) {
+av_write_trailer(os->ctx);
+}
+}
+
 if (c->remove_at_exit) {
 char filename[1024];
 int i;
 for (i = 0; i < s->nb_streams; i++) {
 OutputStream *os = >streams[i];
+for (int j = 0; j < os->nb_segments; ++j) {
+snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
os->segments[j]->file);
+dashenc_delete_file(s, filename);
+av_free(os->segments[j]);
+}
+os->nb_segments = 0;
 snprintf(filename, sizeof(filename), "%s%s", c->dirname, 
os->initfile);
 dashenc_delete_file(s, filename);
 }
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 2/2] lavf/dashenc: Delete HLS manifests on trailer writing if remove_at_exit is set.

2018-11-28 Thread Andrey Semashev
This fixes HLS manifests being left behind if remove_at_exit is set.
---
 libavformat/dashenc.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index a7d8c4e237..af3f0ee167 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1619,6 +1619,18 @@ static int dash_write_trailer(AVFormatContext *s)
 dashenc_delete_file(s, filename);
 }
 dashenc_delete_file(s, s->url);
+
+if (c->hls_playlist && c->master_playlist_created) {
+for (i = 0; i < s->nb_streams; i++) {
+OutputStream *os = >streams[i];
+if (os->segment_type == SEGMENT_TYPE_MP4) {
+get_hls_playlist_name(filename, sizeof(filename), 
c->dirname, i);
+dashenc_delete_file(s, filename);
+}
+}
+snprintf(filename, sizeof(filename), "%smaster.m3u8", c->dirname);
+dashenc_delete_file(s, filename);
+}
 }
 
 return 0;
-- 
2.19.1

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


[FFmpeg-devel] [PATCH 1/2] lavf/dashenc: Don't put non-mp4 streams in HLS manifests.

2018-11-28 Thread Andrey Semashev
The only native HLS implementation in the wild (Safari browser) doesn't
support WebM. And at least some MSE-based players (e.g. shaka-player)
cannot handle WebM media segments when playing HLS. So just skip non-mp4
streams from HLS manifests. Note that such streams will still be described
by the DASH manifest and therefore consumed by players supporting DASH.
---
 libavformat/dashenc.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6ce70e0076..a7d8c4e237 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -225,6 +225,7 @@ static inline SegmentType select_segment_type(SegmentType 
segment_type, enum AVC
 static int init_segment_types(AVFormatContext *s)
 {
 DASHContext *c = s->priv_data;
+int has_mp4_streams = 0;
 for (int i = 0; i < s->nb_streams; ++i) {
 OutputStream *os = >streams[i];
 SegmentType segment_type = select_segment_type(
@@ -235,6 +236,12 @@ static int init_segment_types(AVFormatContext *s)
 av_log(s, AV_LOG_ERROR, "Could not select DASH segment type for 
stream %d\n", i);
 return AVERROR_MUXER_NOT_FOUND;
 }
+has_mp4_streams |= segment_type == SEGMENT_TYPE_MP4;
+}
+
+if (c->hls_playlist && !has_mp4_streams) {
+ av_log(s, AV_LOG_WARNING, "No mp4 streams, disabling HLS manifest 
generation\n");
+ c->hls_playlist = 0;
 }
 
 return 0;
@@ -510,7 +517,7 @@ static void output_segment_list(OutputStream *os, 
AVIOContext *out, AVFormatCont
 }
 avio_printf(out, "\t\t\t\t\n");
 }
-if (c->hls_playlist && start_index < os->nb_segments)
+if (c->hls_playlist && start_index < os->nb_segments && os->segment_type 
== SEGMENT_TYPE_MP4)
 {
 int timescale = os->ctx->streams[0]->time_base.den;
 char temp_filename_hls[1024];
@@ -944,6 +951,8 @@ static int write_manifest(AVFormatContext *s, int final)
 OutputStream *os = >streams[i];
 if (st->codecpar->codec_type != AVMEDIA_TYPE_AUDIO)
 continue;
+if (os->segment_type != SEGMENT_TYPE_MP4)
+continue;
 get_hls_playlist_name(playlist_file, sizeof(playlist_file), NULL, 
i);
 ff_hls_write_audio_rendition(c->m3u8_out, (char *)audio_group,
  playlist_file, i, is_default);
@@ -967,6 +976,8 @@ static int write_manifest(AVFormatContext *s, int final)
 int stream_bitrate = st->codecpar->bit_rate + os->muxer_overhead;
 if (st->codecpar->codec_type != AVMEDIA_TYPE_VIDEO)
 continue;
+if (os->segment_type != SEGMENT_TYPE_MP4)
+continue;
 av_strlcpy(codec_str, os->codec_str, sizeof(codec_str));
 if (max_audio_bitrate) {
 agroup = (char *)audio_group;
-- 
2.19.1

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


[FFmpeg-devel] [PATCH] lavf/dashenc: Fix file URI handling when deleting files.

2018-11-28 Thread Andrey Semashev
The URI used to open the output streams may be an actual URI with "file" scheme,
according to https://tools.ietf.org/html/rfc8089. This commit makes file
deletion routine recognize file URIs and extract the actual filesystem path
from it.

It also fixes strerror use, which may not be thread-safe.
---
 libavformat/dashenc.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6ce70e0076..e59fa0944e 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -25,6 +25,7 @@
 #include 
 #endif
 
+#include "libavutil/error.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avutil.h"
 #include "libavutil/avstring.h"
@@ -1326,8 +1327,32 @@ static void dashenc_delete_file(AVFormatContext *s, char 
*filename) {
 
 av_dict_free(_opts);
 ff_format_io_close(s, );
-} else if (unlink(filename) < 0) {
-av_log(s, AV_LOG_ERROR, "failed to delete %s: %s\n", filename, 
strerror(errno));
+} else {
+const char* path = filename;
+// Check if the filename is a file URI. 
https://tools.ietf.org/html/rfc8089#section-2
+if (av_strncasecmp(path, "file:", sizeof("file:") - 1) == 0) {
+path += sizeof("file:") - 1;
+if (path[0] == '/' && path[1] == '/') {
+// The URI may have an authority part. Check that the 
authority does not contain
+// a host name. We cannot access filesystem on a different 
host.
+path += 2;
+if (path[0] != '/') {
+if (strncmp(path, "localhost", sizeof("localhost") - 1) == 
0) {
+path += sizeof("localhost") - 1;
+} else {
+av_log(s, AV_LOG_ERROR, "cannot delete file on a 
remote host: %s\n", filename);
+return;
+}
+}
+}
+}
+
+if (unlink(path) < 0) {
+int err = AVERROR(errno);
+char errbuf[128];
+av_strerror(err, errbuf, sizeof(errbuf));
+av_log(s, (err == AVERROR(ENOENT) ? AV_LOG_WARNING : 
AV_LOG_ERROR), "failed to delete %s: %s\n", path, errbuf);
+}
 }
 }
 
-- 
2.19.1

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


[FFmpeg-devel] [PATCH] lavf/dashenc: Remove global_sidx from movenc params for live streaming.

2018-11-28 Thread Andrey Semashev
The global_sidx flag causes errors like the following in movenc when media
segment removal is enabled via windos_size or remove_at_exit:

Non-consecutive fragments, writing incorrect sidx
Unable to re-open  output file for the second pass (faststart)
---
 libavformat/dashenc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 6ce70e0076..cb49641b4e 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -1141,7 +1141,7 @@ static int dash_init(AVFormatContext *s)
 
 if (os->segment_type == SEGMENT_TYPE_MP4) {
 if (c->streaming)
-av_dict_set(, "movflags", 
"frag_every_frame+dash+delay_moov+global_sidx", 0);
+av_dict_set(, "movflags", 
"frag_every_frame+dash+delay_moov", 0);
 else
 av_dict_set(, "movflags", "frag_custom+dash+delay_moov", 
0);
 } else {
-- 
2.19.1

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


Re: [FFmpeg-devel] [PATCH] os_support: define socket shutdown SHUT_xxx macros if they are not defined

2018-11-28 Thread Peter Ross
sys/socket.h (with WIN32 guard) is needed to check if the SHUT_xxx macro exists.
and because of this, SHUT_xxx defs have been moved into the CONFIG_NETWORK 
block,
since they only affect network capable platforms.
---

This is a minor reworking of Dave's suggestion to make it work on *nix and 
windows.


 libavformat/os_support.h | 23 +--
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 7a56dc9a7c..5e6b32d2dc 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -76,17 +76,7 @@ static inline int is_dos_path(const char *path)
 return 0;
 }
 
-#if defined(__OS2__)
-#define SHUT_RD 0
-#define SHUT_WR 1
-#define SHUT_RDWR 2
-#endif
-
 #if defined(_WIN32)
-#define SHUT_RD SD_RECEIVE
-#define SHUT_WR SD_SEND
-#define SHUT_RDWR SD_BOTH
-
 #ifndef S_IRUSR
 #define S_IRUSR S_IREAD
 #endif
@@ -96,6 +86,19 @@ static inline int is_dos_path(const char *path)
 #endif
 
 #if CONFIG_NETWORK
+#if defined(_WIN32)
+#define SHUT_RD SD_RECEIVE
+#define SHUT_WR SD_SEND
+#define SHUT_RDWR SD_BOTH
+#else
+#include 
+#if !defined(SHUT_RD) /* OS/2, DJGPP */
+#define SHUT_RD 0
+#define SHUT_WR 1
+#define SHUT_RDWR 2
+#endif
+#endif
+
 #if !HAVE_SOCKLEN_T
 typedef int socklen_t;
 #endif
-- 
2.17.1

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)


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


Re: [FFmpeg-devel] Add 16-bit Depth pixel format

2018-11-28 Thread Pablo Rubio Fernández
Yes, it is like gray16. But gray16le is already in use to Y16 pixel format.
For this reason, I think that best way to add Z16 pixel format is creating it.
I'm not an expert, any help will be appreciated.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH 1/2] avcodec/msmpeg4dec: Skip frame if its smaller than 1/8 of the minimal size

2018-11-28 Thread Hendrik Leppkes
On Wed, Nov 28, 2018 at 1:54 AM Michael Niedermayer
 wrote:
>
> Fixes: Timeout
> Fixes: 
> 11318/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MSMPEG4V1_fuzzer-5710884555456512
>
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/msmpeg4dec.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libavcodec/msmpeg4dec.c b/libavcodec/msmpeg4dec.c
> index 457a37e745..d278540ec2 100644
> --- a/libavcodec/msmpeg4dec.c
> +++ b/libavcodec/msmpeg4dec.c
> @@ -412,6 +412,9 @@ int ff_msmpeg4_decode_picture_header(MpegEncContext * s)
>  {
>  int code;
>
> +if (get_bits_left(>gb) * 8LL < (s->width+15)/16 * ((s->height+15)/16))
> +return AVERROR_INVALIDDATA;
> +

Please add a comment so such lines why these magic values where
choosen, and an explanation in the commit message that explains the
proof that these are an absolute limit and no valid frame could ever
be smaller would be appreciated.

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


Re: [FFmpeg-devel] [PATCH v3] libavfilter: add transpose_vaapi filter

2018-11-28 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Zachary Zhou
> Sent: Wednesday, November 28, 2018 2:54 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Zhou, Zachary 
> Subject: [FFmpeg-devel] [PATCH v3] libavfilter: add transpose_vaapi filter
> 
> Swap width and height when do clock/cclock rotation
> Add 180/180_flip options
> 
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
> -hwaccel_output_format vaapi -i input.264 -vf "transpose_vaapi=clock_flip"
> -c:v h264_vaapi output.h264
> 
> Signed-off-by: Zachary Zhou 
> ---
>  configure|   2 +
>  libavfilter/Makefile |   1 +
>  libavfilter/allfilters.c |   1 +
>  libavfilter/vf_transpose_vaapi.c | 356
> +++
>  4 files changed, 360 insertions(+)
>  create mode 100644 libavfilter/vf_transpose_vaapi.c
> 
> diff --git a/configure b/configure
> index ab3144e459..6e711bd9c6 100755
> --- a/configure
> +++ b/configure
> @@ -3451,6 +3451,7 @@ scale_filter_deps="swscale"
>  scale_qsv_filter_deps="libmfx"
>  select_filter_select="scene_sad"
>  sharpness_vaapi_filter_deps="vaapi"
> +transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"

it is better to be in alphabetical order. Just a few exceptions here and I 
think original idea is in alphabetical order.

>  showcqt_filter_deps="avcodec avformat swscale"
>  showcqt_filter_suggest="libfontconfig libfreetype"
>  showcqt_filter_select="fft"
> @@ -5975,6 +5976,7 @@ check_type "d3d9.h dxva2api.h"
> DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
> 
>  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
>  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
> +check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
>  check_type "va/va.h va/va_enc_hevc.h"
> "VAEncPictureParameterBufferHEVC"
>  check_type "va/va.h va/va_enc_jpeg.h"
> "VAEncPictureParameterBufferJPEG"
>  check_type "va/va.h va/va_enc_vp8.h"
> "VAEncPictureParameterBufferVP8"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 1895fa2b0d..97e1786071 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -356,6 +356,7 @@ OBJS-$(CONFIG_SETRANGE_FILTER)   +=
> vf_setparams.o
>  OBJS-$(CONFIG_SETSAR_FILTER) += vf_aspect.o
>  OBJS-$(CONFIG_SETTB_FILTER)  += settb.o
>  OBJS-$(CONFIG_SHARPNESS_VAAPI_FILTER)+= vf_misc_vaapi.o
> vaapi_vpp.o
> +OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+= vf_transpose_vaapi.o
> vaapi_vpp.o
>  OBJS-$(CONFIG_SHOWINFO_FILTER)   += vf_showinfo.o
>  OBJS-$(CONFIG_SHOWPALETTE_FILTER)+= vf_showpalette.o
>  OBJS-$(CONFIG_SHUFFLEFRAMES_FILTER)  += vf_shuffleframes.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index 837c99eb75..f0c69e9c67 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -338,6 +338,7 @@ extern AVFilter ff_vf_setrange;
>  extern AVFilter ff_vf_setsar;
>  extern AVFilter ff_vf_settb;
>  extern AVFilter ff_vf_sharpness_vaapi;
> +extern AVFilter ff_vf_transpose_vaapi;

need to be in alphabetical order.

>  extern AVFilter ff_vf_showinfo;
>  extern AVFilter ff_vf_showpalette;
>  extern AVFilter ff_vf_shuffleframes;
> diff --git a/libavfilter/vf_transpose_vaapi.c 
> b/libavfilter/vf_transpose_vaapi.c
> new file mode 100644
> index 00..ca7203e880
> --- /dev/null
> +++ b/libavfilter/vf_transpose_vaapi.c
> @@ -0,0 +1,356 @@
> +/*
> + * 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 
> +
> +#include "libavutil/avassert.h"
> +#include "libavutil/mem.h"
> +#include "libavutil/opt.h"
> +#include "libavutil/pixdesc.h"
> +
> +#include "avfilter.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "vaapi_vpp.h"
> +
> +typedef enum {
> +TRANSPOSE_PT_TYPE_NONE,
> +TRANSPOSE_PT_TYPE_LANDSCAPE,
> +TRANSPOSE_PT_TYPE_PORTRAIT,
> +} PassthroughType;
> +
> +enum TransposeDir {
> +TRANSPOSE_CCLOCK_FLIP,
> +TRANSPOSE_CLOCK,
> +TRANSPOSE_CCLOCK,
> +TRANSPOSE_CLOCK_FLIP,
> +TRANSPOSE_180,
> +TRANSPOSE_180_FLIP,
> +};
> +
> +typedef struct TransposeVAAPIContext {
> +VAAPIVPPContext