[FFmpeg-devel] [PATCH V3 2/3] doc/filters: update how to generate native model for sr filter

2019-06-12 Thread Guo, Yejun
Signed-off-by: Guo, Yejun 
---
 doc/filters.texi | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ec1c7c7..fe6725a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -16588,10 +16588,13 @@ Efficient Sub-Pixel Convolutional Neural Network 
model (ESPCN).
 See @url{https://arxiv.org/abs/1609.05158}.
 @end itemize
 
-Training scripts as well as scripts for model generation can be found at
+Training scripts as well as scripts for model file (.pb) saving can be found at
 @url{https://github.com/XueweiMeng/sr/tree/sr_dnn_native}. Original repository
 is at @url{https://github.com/HighVoltageRocknRoll/sr.git}.
 
+Native model files (.model) can be generated from TensorFlow model
+files (.pb) by using tools/python/convert.py
+
 The filter accepts the following options:
 
 @table @option
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH V3 3/3] tools/python: move .py scripts from tools to tools/python

2019-06-12 Thread Guo, Yejun
so, all the .py scripts will be under tools/python/

Signed-off-by: Guo, Yejun 
---
 tools/normalize.py| 33 -
 tools/python/normalize.py | 33 +
 tools/python/zmqshell.py  | 26 ++
 tools/zmqshell.py | 26 --
 4 files changed, 59 insertions(+), 59 deletions(-)
 delete mode 100755 tools/normalize.py
 create mode 100755 tools/python/normalize.py
 create mode 100755 tools/python/zmqshell.py
 delete mode 100755 tools/zmqshell.py

diff --git a/tools/normalize.py b/tools/normalize.py
deleted file mode 100755
index 7d87c5e..000
--- a/tools/normalize.py
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/usr/bin/env python2
-
-import sys, subprocess
-
-if len(sys.argv) > 2:
-ifile  = sys.argv[1]
-encopt = sys.argv[2:-1]
-ofile  = sys.argv[-1]
-else:
-print 'usage: %s  [encode_options] ' % sys.argv[0]
-sys.exit(1)
-
-analysis_cmd  = 'ffprobe -v error -of compact=p=0:nk=1 '
-analysis_cmd += '-show_entries frame_tags=lavfi.r128.I -f lavfi '
-analysis_cmd += "amovie='%s',ebur128=metadata=1" % ifile
-try:
-probe_out = subprocess.check_output(analysis_cmd, shell=True)
-except subprocess.CalledProcessError, e:
-sys.exit(e.returncode)
-loudness = ref = -23
-for line in probe_out.splitlines():
-sline = line.rstrip()
-if sline:
-loudness = sline
-adjust = ref - float(loudness)
-if abs(adjust) < 0.0001:
-print 'No normalization needed for ' + ifile
-else:
-print "Adjust %s by %.1fdB" % (ifile, adjust)
-norm_cmd  = ['ffmpeg', '-i', ifile, '-af', 'volume=%fdB' % adjust]
-norm_cmd += encopt + [ofile]
-print ' => %s' % ' '.join(norm_cmd)
-subprocess.call(norm_cmd)
diff --git a/tools/python/normalize.py b/tools/python/normalize.py
new file mode 100755
index 000..7d87c5e
--- /dev/null
+++ b/tools/python/normalize.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python2
+
+import sys, subprocess
+
+if len(sys.argv) > 2:
+ifile  = sys.argv[1]
+encopt = sys.argv[2:-1]
+ofile  = sys.argv[-1]
+else:
+print 'usage: %s  [encode_options] ' % sys.argv[0]
+sys.exit(1)
+
+analysis_cmd  = 'ffprobe -v error -of compact=p=0:nk=1 '
+analysis_cmd += '-show_entries frame_tags=lavfi.r128.I -f lavfi '
+analysis_cmd += "amovie='%s',ebur128=metadata=1" % ifile
+try:
+probe_out = subprocess.check_output(analysis_cmd, shell=True)
+except subprocess.CalledProcessError, e:
+sys.exit(e.returncode)
+loudness = ref = -23
+for line in probe_out.splitlines():
+sline = line.rstrip()
+if sline:
+loudness = sline
+adjust = ref - float(loudness)
+if abs(adjust) < 0.0001:
+print 'No normalization needed for ' + ifile
+else:
+print "Adjust %s by %.1fdB" % (ifile, adjust)
+norm_cmd  = ['ffmpeg', '-i', ifile, '-af', 'volume=%fdB' % adjust]
+norm_cmd += encopt + [ofile]
+print ' => %s' % ' '.join(norm_cmd)
+subprocess.call(norm_cmd)
diff --git a/tools/python/zmqshell.py b/tools/python/zmqshell.py
new file mode 100755
index 000..a7d1126
--- /dev/null
+++ b/tools/python/zmqshell.py
@@ -0,0 +1,26 @@
+#!/usr/bin/env python2
+
+import sys, zmq, cmd
+
+class LavfiCmd(cmd.Cmd):
+prompt = 'lavfi> '
+
+def __init__(self, bind_address):
+context = zmq.Context()
+self.requester = context.socket(zmq.REQ)
+self.requester.connect(bind_address)
+cmd.Cmd.__init__(self)
+
+def onecmd(self, cmd):
+if cmd == 'EOF':
+sys.exit(0)
+print 'Sending command:[%s]' % cmd
+self.requester.send(cmd)
+message = self.requester.recv()
+print 'Received reply:[%s]' % message
+
+try:
+bind_address = sys.argv[1] if len(sys.argv) > 1 else "tcp://localhost:"
+LavfiCmd(bind_address).cmdloop('FFmpeg libavfilter interactive shell')
+except KeyboardInterrupt:
+pass
diff --git a/tools/zmqshell.py b/tools/zmqshell.py
deleted file mode 100755
index a7d1126..000
--- a/tools/zmqshell.py
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env python2
-
-import sys, zmq, cmd
-
-class LavfiCmd(cmd.Cmd):
-prompt = 'lavfi> '
-
-def __init__(self, bind_address):
-context = zmq.Context()
-self.requester = context.socket(zmq.REQ)
-self.requester.connect(bind_address)
-cmd.Cmd.__init__(self)
-
-def onecmd(self, cmd):
-if cmd == 'EOF':
-sys.exit(0)
-print 'Sending command:[%s]' % cmd
-self.requester.send(cmd)
-message = self.requester.recv()
-print 'Received reply:[%s]' % message
-
-try:
-bind_address = sys.argv[1] if len(sys.argv) > 1 else "tcp://localhost:"
-LavfiCmd(bind_address).cmdloop('FFmpeg libavfilter interactive shell')
-except KeyboardInterrupt:
-pass
-- 
2.7.4

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

To unsubscribe, visit link above, or email
ffmpeg-devel

[FFmpeg-devel] [PATCH V3 1/3] tools/python: add script to convert TensorFlow model (.pb) to native model (.model)

2019-06-12 Thread Guo, Yejun
For example, given TensorFlow model file espcn.pb,
to generate native model file espcn.model, just run:
python convert.py espcn.pb

In current implementation, the native model file is generated for
specific dnn network with hard-code python scripts maintained out of ffmpeg.
For example, srcnn network used by vf_sr is generated with
https://github.com/HighVoltageRocknRoll/sr/blob/master/generate_header_and_model.py#L85

In this patch, the script is designed as a general solution which
converts general TensorFlow model .pb file into .model file. The script
now has some tricky to be compatible with current implemention, will
be refined step by step.

The script is also added into ffmpeg source tree. It is expected there
will be many more patches and community needs the ownership of it.

Another technical direction is to do the conversion in c/c++ code within
ffmpeg source tree. While .pb file is organized with protocol buffers,
it is not easy to do such work with tiny c/c++ code, see more discussion
at http://ffmpeg.org/pipermail/ffmpeg-devel/2019-May/244496.html. So,
choose the python script.

Signed-off-by: Guo, Yejun 
---
 .gitignore  |   1 +
 tools/python/convert.py |  52 +
 tools/python/convert_from_tensorflow.py | 201 
 3 files changed, 254 insertions(+)
 create mode 100644 tools/python/convert.py
 create mode 100644 tools/python/convert_from_tensorflow.py

diff --git a/.gitignore b/.gitignore
index 0e57cb0..2450ee8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -36,3 +36,4 @@
 /lcov/
 /src
 /mapfile
+/tools/python/__pycache__/
diff --git a/tools/python/convert.py b/tools/python/convert.py
new file mode 100644
index 000..662b429
--- /dev/null
+++ b/tools/python/convert.py
@@ -0,0 +1,52 @@
+# Copyright (c) 2019 Guo Yejun
+#
+# 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
+# 
==
+
+# verified with Python 3.5.2 on Ubuntu 16.04
+import argparse
+import os
+from convert_from_tensorflow import *
+
+def get_arguments():
+parser = argparse.ArgumentParser(description='generate native mode model 
with weights from deep learning model')
+parser.add_argument('--outdir', type=str, default='./', help='where to put 
generated files')
+parser.add_argument('--infmt', type=str, default='tensorflow', 
help='format of the deep learning model')
+parser.add_argument('infile', help='path to the deep learning model with 
weights')
+
+return parser.parse_args()
+
+def main():
+args = get_arguments()
+
+if not os.path.isfile(args.infile):
+print('the specified input file %s does not exist' % args.infile)
+exit(1)
+
+if not os.path.exists(args.outdir):
+print('create output directory %s' % args.outdir)
+os.mkdir(args.outdir)
+
+basefile = os.path.split(args.infile)[1]
+basefile = os.path.splitext(basefile)[0]
+outfile = os.path.join(args.outdir, basefile) + '.model'
+
+if args.infmt == 'tensorflow':
+convert_from_tensorflow(args.infile, outfile)
+
+if __name__ == '__main__':
+main()
diff --git a/tools/python/convert_from_tensorflow.py 
b/tools/python/convert_from_tensorflow.py
new file mode 100644
index 000..37049e5
--- /dev/null
+++ b/tools/python/convert_from_tensorflow.py
@@ -0,0 +1,201 @@
+# Copyright (c) 2019 Guo Yejun
+#
+# 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
+# 
==
+
+import tensorflow as tf
+import

Re: [FFmpeg-devel] [PATCH v2] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables

2019-06-12 Thread greg Luce
> This doesn't look correct. It's supposed to contain
> Subject: vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> and the Signed-off-by line is to be somewhere in the remaining commit
> message. How did you create the patch?

I just cloned the main, made the change, and then did
"git format-patch -1 HEAD"
I'm afraid I don't know git very well. I'll just strip the head out of
the patch files so I can't get them wrong!

> Strictly speaking, you're fixing and amending existing documentation,
> not related to your modifications. I personally don't mind, but others
> will request you to do this is a separate patch.

Split into two separate patch files (attached) in case that helps

> A non-related question: Do you understand when this is -1? (I myself
> am looking for some filter or log info which can give me the pkt_pos
> related to a certain time offset from the beginning of a file, as when
> seeked using "-ss".)

I'm afraid I have no help for you there. I'm going on Gyan's advice from
https://lists.ffmpeg.org/pipermail/ffmpeg-devel/2019-June/245249.html

> > +The current packet's input duration.
>
> "input duration" sounds confusing. You can likely drop the "input".
>
> > +The current packet's input size (in bytes).
>
> Ditto.

I'd included "input" since the frame rate and size might be changed
later, but you're right people can probably figure that out. I'll take
them out

> You may need to bump libavfilter's MICRO version, as you are adding
> features.

I can't speak to that and I wouldn't know how to do it, but good point!


[PATCH] filters doc typo fix.patch
Description: Binary data


[PATCH] REVISED vf_drawtext - Add pkt_pos, pkt_duration, pkt_size as variables.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: add support for AVC Trellis

2019-06-12 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Thursday, June 13, 2019 06:37
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: add support for
> AVC Trellis
> 
> On 12/06/2019 16:28, Linjie Fu wrote:
> > Add support for VAAPI AVC Trellis Quantization with limitation:
> > - VA-API version >= (1, 0, 0)
> >
> > Use option "-trellis off/I/P/B" to disable or enable Trellis
> > quantization for I/P/B frames.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> > [v2]: Since nonstandard struct for VAEncMiscParameterQuantization is
> > fixed: https://github.com/intel/libva/issues/265
> 
> Should the version check be for the first release this fix is in rather than 
> for
> libva 2.0, then?

I've been thinking about the concerns before, too.
Since the nonstandard structure is supported more robustly, uint32_t data[]
in misc now can be point to the uint64_t quantization and make this feature
valid.
The remaining concern is that using  a uint32_t pointer to point a uint64_t one 
(should be uint32_t) which
is not functional. 
So I choose to check the version libva 2.0  which supported Trellis for the 
first time to support
more libva version.

Will update the version check to libva 2.5 to eliminate all concerns if it's 
more acceptable.

> 
> > update patch based on:
> >
> http://git.ffmpeg.org/gitweb/ffmpeg.git/commit/2880a32c668023bfee47450
> 95c885450d547ae45
> >  libavcodec/vaapi_encode.c  | 48
> ++
> >  libavcodec/vaapi_encode.h  |  9 +--
> >  libavcodec/vaapi_encode_h264.c |  9 +++
> >  3 files changed, 64 insertions(+), 2 deletions(-)
> >
> > diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> > index dd2a24de04..fbfbe78c6b 100644
> > --- a/libavcodec/vaapi_encode.c
> > +++ b/libavcodec/vaapi_encode.c
> > @@ -1671,6 +1671,48 @@ rc_mode_found:
> >  return 0;
> >  }
> >
> > +static av_cold int vaapi_encode_init_quantization(AVCodecContext
> *avctx)
> > +{
> > +#if VA_CHECK_VERSION(1, 0, 0)
> > +VAAPIEncodeContext *ctx = avctx->priv_data;
> > +VAStatus vas;
> > +VAConfigAttrib attr = { VAConfigAttribEncQuantization };
> > +int trellis = ctx->trellis;
> 
> This variable isn't really doing anything.
Yep, trying to match the behavior with quality but since this variable is not 
frequently
used, ctx->trellis seems to be enough.

> 
> > +
> > +vas = vaGetConfigAttributes(ctx->hwctx->display,
> > +ctx->va_profile,
> > +ctx->va_entrypoint,
> > +&attr, 1);
> > +if (vas != VA_STATUS_SUCCESS) {
> > +av_log(avctx, AV_LOG_ERROR, "Failed to query quantization "
> > +   "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
> > +return AVERROR_EXTERNAL;
> > +}
> > +
> > +if (attr.value == VA_ATTRIB_NOT_SUPPORTED ||
> > +attr.value == VA_ENC_QUANTIZATION_NONE) {
> > +av_log(avctx, AV_LOG_WARNING, "Special Quantization attribute is
> not "
> > +"supported: will use default quantization.\n");
> > +} else if (attr.value == VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED){
> > +av_log(avctx, AV_LOG_VERBOSE, "Quantization Trellis supported.\n");
> > +
> > +ctx->quantization_params = (VAEncMiscParameterQuantization) {
> > +.quantization_flags.value = trellis,
> > +};
> > +
> > +vaapi_encode_add_global_param(avctx,
> > +  VAEncMiscParameterTypeQuantization,
> > +  &ctx->quantization_params,
> > +  sizeof(ctx->quantization_params));
> > +}
> > +#else
> > +av_log(avctx, AV_LOG_WARNING, "The encode quantization option
> (Trellis) is "
> > +   "not supported with this VAAPI version.\n");
> > +#endif
> > +
> > +return 0;
> > +}
> > +
> >  static av_cold int vaapi_encode_init_gop_structure(AVCodecContext
> *avctx)
> >  {
> >  VAAPIEncodeContext *ctx = avctx->priv_data;
> > @@ -2132,6 +2174,12 @@ av_cold int
> ff_vaapi_encode_init(AVCodecContext *avctx)
> >  if (err < 0)
> >  goto fail;
> >
> > +if (ctx->trellis) {
> > +err = vaapi_encode_init_quantization(avctx);
> > +if (err < 0)
> > +goto fail;
> > +}
> > +
> >  if (avctx->compression_level >= 0) {
> >  err = vaapi_encode_init_quality(avctx);
> >  if (err < 0)
> > diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
> > index eeec06036b..b24735da59 100644
> > --- a/libavcodec/vaapi_encode.h
> > +++ b/libavcodec/vaapi_encode.h
> > @@ -37,7 +37,7 @@ struct VAAPIEncodePicture;
> >
> >  enum {
> >  MAX_CONFIG_ATTRIBUTES  = 4,
> > -MAX_GLOBAL_PARAMS  = 4,
> > +MAX_GLOBAL_PARAMS  = 5,
> >  MAX_DPB_SIZE   = 16,
> >  MAX_PICTURE_REFERENCES = 2,
> >

Re: [FFmpeg-devel] [PATCH V3 1/2] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-12 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Adam Sampson
> Sent: Wednesday, June 12, 2019 8:21 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH V3 1/2] avfilter/vf_gblur: add x86 SIMD
> optimizations
> 
> Hi Ruiling,
> 
> Ruiling Song  writes:
> 
> This breaks the build for me on x86-32 -- the asm helpers in
> vf_gblur.asm are only defined on x86-64, but vf_gblur_init.c expects
> them to exist on both architectures.
> 
> ld: libavfilter/libavfilter.so: undefined reference to `ff_horiz_slice_avx2'
> ld: libavfilter/libavfilter.so: undefined reference to `ff_horiz_slice_sse4'
> collect2: error: ld returned 1 exit status
> 
> Adding "#if ARCH_X86_64" conditionals to vf_gblur_init.c fixes it.
Thank you for reporting this. Sorry for that. Thank you James for fixing it.

> 
> Thanks,
> 
> --
> Adam Sampson  
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 2/4] avformat/img2dec: Fix probe_buffer leak in ff_img_read_header()

2019-06-12 Thread Michael Niedermayer
Fixes: memleak
Fixes: 
15171/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5683881644130304

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

diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
index fe45c5e5ec..f8b4a655a5 100644
--- a/libavformat/img2dec.c
+++ b/libavformat/img2dec.c
@@ -356,6 +356,7 @@ int ff_img_read_header(AVFormatContext *s1)
 }
 if (s1->flags & AVFMT_FLAG_CUSTOM_IO) {
 avio_seek(s1->pb, 0, SEEK_SET);
+av_freep(&probe_buffer);
 } else
 ffio_rewind_with_probe_data(s1->pb, &probe_buffer, 
probe_buffer_size);
 }
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 1/4] avcodec/xpmdec: Do not use context dimensions as temporary variables

2019-06-12 Thread Michael Niedermayer
Fixes: Integer overflow
Fixes: 
15134/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_XPM_fuzzer-5722635939348480

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

diff --git a/libavcodec/xpmdec.c b/libavcodec/xpmdec.c
index 43dd9bc7e7..922dfc0f67 100644
--- a/libavcodec/xpmdec.c
+++ b/libavcodec/xpmdec.c
@@ -311,6 +311,7 @@ static int xpm_decode_frame(AVCodecContext *avctx, void 
*data,
 int ncolors, cpp, ret, i, j;
 int64_t size;
 uint32_t *dst;
+int width, height;
 
 avctx->pix_fmt = AV_PIX_FMT_BGRA;
 
@@ -332,12 +333,12 @@ static int xpm_decode_frame(AVCodecContext *avctx, void 
*data,
 
 ptr += mod_strcspn(ptr, "\"");
 if (sscanf(ptr, "\"%u %u %u %u\",",
-   &avctx->width, &avctx->height, &ncolors, &cpp) != 4) {
+   &width, &height, &ncolors, &cpp) != 4) {
 av_log(avctx, AV_LOG_ERROR, "missing image parameters\n");
 return AVERROR_INVALIDDATA;
 }
 
-if ((ret = ff_set_dimensions(avctx, avctx->width, avctx->height)) < 0)
+if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
 return ret;
 
 if ((ret = ff_get_buffer(avctx, p, 0)) < 0)
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 3/4] avformat/wtvdec: Avoid (32bit signed) sectors

2019-06-12 Thread Michael Niedermayer
Fixes: left shift of negative value -14614752
Fixes: 
15174/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5670543606415360

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/wtvdec.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libavformat/wtvdec.c b/libavformat/wtvdec.c
index 890db2e705..706e8ca38d 100644
--- a/libavformat/wtvdec.c
+++ b/libavformat/wtvdec.c
@@ -149,7 +149,7 @@ static int read_ints(AVIOContext *pb, uint32_t *data, int 
count)
  * @param depth File allocation table depth
  * @return NULL on error
  */
-static AVIOContext * wtvfile_open_sector(int first_sector, uint64_t length, 
int depth, AVFormatContext *s)
+static AVIOContext * wtvfile_open_sector(unsigned first_sector, uint64_t 
length, int depth, AVFormatContext *s)
 {
 AVIOContext *pb;
 WtvFile *wf;
@@ -957,7 +957,8 @@ static int parse_chunks(AVFormatContext *s, int mode, 
int64_t seekts, int *len_p
 static int read_header(AVFormatContext *s)
 {
 WtvContext *wtv = s->priv_data;
-int root_sector, root_size;
+unsigned root_sector;
+int root_size;
 uint8_t root[WTV_SECTOR_SIZE];
 AVIOContext *pb;
 int64_t timeline_pos;
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH 4/4] avcodec/fitsdec: Check data_min/max

2019-06-12 Thread Michael Niedermayer
Fixes: division by 0
Fixes: 
15206/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FITS_fuzzer-5657260212092928

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

diff --git a/libavcodec/fitsdec.c b/libavcodec/fitsdec.c
index b0753813c9..2da79e1ef9 100644
--- a/libavcodec/fitsdec.c
+++ b/libavcodec/fitsdec.c
@@ -168,6 +168,16 @@ static int fits_read_header(AVCodecContext *avctx, const 
uint8_t **ptr, FITSHead
 header->data_min = (header->data_min - header->bzero) / header->bscale;
 header->data_max = (header->data_max - header->bzero) / header->bscale;
 }
+if (!header->rgb) {
+if (header->data_min > header->data_max) {
+av_log(avctx, AV_LOG_ERROR, "data min/max (%g %g) is invalid\n", 
header->data_min, header->data_max);
+return AVERROR_INVALIDDATA;
+}
+if (header->data_min == header->data_max) {
+av_log(avctx, AV_LOG_WARNING, "data min/max indicates a blank 
image\n");
+header->data_max ++;
+}
+}
 
 return 0;
 }
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: add support for AVC Trellis

2019-06-12 Thread Mark Thompson
On 12/06/2019 16:28, Linjie Fu wrote:
> Add support for VAAPI AVC Trellis Quantization with limitation:
> - VA-API version >= (1, 0, 0)
> 
> Use option "-trellis off/I/P/B" to disable or enable Trellis
> quantization for I/P/B frames.
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: Since nonstandard struct for VAEncMiscParameterQuantization is
> fixed: https://github.com/intel/libva/issues/265

Should the version check be for the first release this fix is in rather than 
for libva 2.0, then?

> update patch based on:
> http://git.ffmpeg.org/gitweb/ffmpeg.git/commit/2880a32c668023bfee4745095c885450d547ae45
>  libavcodec/vaapi_encode.c  | 48 ++
>  libavcodec/vaapi_encode.h  |  9 +--
>  libavcodec/vaapi_encode_h264.c |  9 +++
>  3 files changed, 64 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index dd2a24de04..fbfbe78c6b 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1671,6 +1671,48 @@ rc_mode_found:
>  return 0;
>  }
>  
> +static av_cold int vaapi_encode_init_quantization(AVCodecContext *avctx)
> +{
> +#if VA_CHECK_VERSION(1, 0, 0)
> +VAAPIEncodeContext *ctx = avctx->priv_data;
> +VAStatus vas;
> +VAConfigAttrib attr = { VAConfigAttribEncQuantization };
> +int trellis = ctx->trellis;

This variable isn't really doing anything.

> +
> +vas = vaGetConfigAttributes(ctx->hwctx->display,
> +ctx->va_profile,
> +ctx->va_entrypoint,
> +&attr, 1);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to query quantization "
> +   "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR_EXTERNAL;
> +}
> +
> +if (attr.value == VA_ATTRIB_NOT_SUPPORTED ||
> +attr.value == VA_ENC_QUANTIZATION_NONE) {
> +av_log(avctx, AV_LOG_WARNING, "Special Quantization attribute is not 
> "
> +"supported: will use default quantization.\n");
> +} else if (attr.value == VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED){
> +av_log(avctx, AV_LOG_VERBOSE, "Quantization Trellis supported.\n");
> +
> +ctx->quantization_params = (VAEncMiscParameterQuantization) {
> +.quantization_flags.value = trellis,
> +};
> +
> +vaapi_encode_add_global_param(avctx,
> +  VAEncMiscParameterTypeQuantization,
> +  &ctx->quantization_params,
> +  sizeof(ctx->quantization_params));
> +}
> +#else
> +av_log(avctx, AV_LOG_WARNING, "The encode quantization option (Trellis) 
> is "
> +   "not supported with this VAAPI version.\n");
> +#endif
> +
> +return 0;
> +}
> +
>  static av_cold int vaapi_encode_init_gop_structure(AVCodecContext *avctx)
>  {
>  VAAPIEncodeContext *ctx = avctx->priv_data;
> @@ -2132,6 +2174,12 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
>  if (err < 0)
>  goto fail;
>  
> +if (ctx->trellis) {
> +err = vaapi_encode_init_quantization(avctx);
> +if (err < 0)
> +goto fail;
> +}
> +
>  if (avctx->compression_level >= 0) {
>  err = vaapi_encode_init_quality(avctx);
>  if (err < 0)
> diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
> index eeec06036b..b24735da59 100644
> --- a/libavcodec/vaapi_encode.h
> +++ b/libavcodec/vaapi_encode.h
> @@ -37,7 +37,7 @@ struct VAAPIEncodePicture;
>  
>  enum {
>  MAX_CONFIG_ATTRIBUTES  = 4,
> -MAX_GLOBAL_PARAMS  = 4,
> +MAX_GLOBAL_PARAMS  = 5,
>  MAX_DPB_SIZE   = 16,
>  MAX_PICTURE_REFERENCES = 2,
>  MAX_REORDER_DELAY  = 16,
> @@ -220,6 +220,9 @@ typedef struct VAAPIEncodeContext {
>  // Packed headers which will actually be sent.
>  unsigned intva_packed_headers;
>  
> +// Quantization mode
> +int trellis;

Put this field further up, above the "set before calling 
ff_vaapi_encode_init()" line.

> +
>  // Configuration attributes to use when creating va_config.
>  VAConfigAttrib  config_attributes[MAX_CONFIG_ATTRIBUTES];
>  int  nb_config_attributes;
> @@ -256,7 +259,9 @@ typedef struct VAAPIEncodeContext {
>  #if VA_CHECK_VERSION(0, 36, 0)
>  VAEncMiscParameterBufferQualityLevel quality_params;
>  #endif
> -
> +#if VA_CHECK_VERSION(1, 0, 0)
> +VAEncMiscParameterQuantization quantization_params;
> +#endif
>  // Per-sequence parameter structure (VAEncSequenceParameterBuffer*).
>  void   *codec_sequence_params;
>  
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index d1427112ea..427fb6320e 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -72,6 +72,7 @@ typedef struct VAAPIEncodeH264Context {
>  int sei;
>

Re: [FFmpeg-devel] [PATCH] set AVFrame decode_error_flags in case of decoding error by h264dec

2019-06-12 Thread Amir Z
thanks, I will submit a new patch with the requested changes

On Wed, Jun 12, 2019 at 3:00 PM Marton Balint  wrote:

>
>
> On Wed, 12 Jun 2019, Michael Niedermayer wrote:
>
> > On Wed, Jun 12, 2019 at 10:09:08AM +0200, Marton Balint wrote:
> >>
> >>
> >> On Wed, 12 Jun 2019, Michael Niedermayer wrote:
> >>
> >>> On Tue, Jun 11, 2019 at 03:21:41PM -0500, Amir Z wrote:
>  Thanks Michael Niedermayer for looking into this
> 
>  What I am trying to solve is having a way to detect concealed decoding
>  errors by the caller to avcodec_receive_frame.
> 
>  Should I add a general value e.g. #define
>  FF_DECODE_ERROR_DECODE_ERROR_OCCURRED 4 ?
> >>>
> >>> I suggest
> >>> FF_DECODE_ERROR_CONCEALMENT_ACTIVE or something similar and then always
> >>> set this for all cases of error concealment
> >>> Its more informative than just knowing there was an error
> >>
> >> Concealment is a consequence. Error_flags should refer to the cause. A
> >> generic UNKNOWN error seems much better to me if it is not feasible to
> >> determine the cause.
> >
> > Concealment is the consequence generally, still the error in the frames
> > differs between concealment or no concealment. A user application may
> > want to treat these differently.
> > concealemnt is not supported by all codecs currently and also not by
> > all variants, for example interlaced material tends to be less supported
> > in concealment. A user app might choose to discard a frame that
> > contains errors but no concealemnt if the following frame is fine.
> >
> > Also in a very pedantic view, concealemnt itself is an error too.
> > Its rarly known exactly where the damage starts so concealment often
> needs
> > to cover more and by doing so adds errors in a minority of locations
> > that is if you just want a formal argument why this would fit in here.
> > Not an argument against the principle that concealemnt differs here in
> what
> > it is, you are certainly correct about that.
>
> OK, FF_DECODE_ERROR_CONCEALMENT_ACTIVE is fine then.
>
> Thanks,
> Marton
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4] vaapi_encode_mjpeg: fix bad component id bug

2019-06-12 Thread Mark Thompson
On 07/06/2019 22:45, U. Artie Eoff wrote:
> The compound literals assigned to "components"
> only exist within the scope of the if/else
> block (thanks Mark Thompson for the better
> explanation).
> 
> Thus, after this if/else block, "components"
> ends up pointing to an arbitrary/undefined
> array.  With some compilers and depending on
> optimization settings, these arbitrary values
> may end up being the same value (i.e. 0 with
> GNU GCC 9.x).  Unfortunately, the GNU GCC
> compiler, at least, never prints any warnings
> about this.
> 
> This patch fixes this issue by assigning the
> constant arrays to local variables at function
> scope and then pointing "components" to those
> as necessary.
> 
> Fixes #7915
> 
> Signed-off-by: U. Artie Eoff 
> ---
>  libavcodec/vaapi_encode_mjpeg.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_mjpeg.c b/libavcodec/vaapi_encode_mjpeg.c
> index 4dcdc3d16bb0..bd029cc90315 100644
> --- a/libavcodec/vaapi_encode_mjpeg.c
> +++ b/libavcodec/vaapi_encode_mjpeg.c
> @@ -227,6 +227,8 @@ static int 
> vaapi_encode_mjpeg_init_picture_params(AVCodecContext *avctx,
>  JPEGRawScanHeader *sh = &priv->scan.header;
>  VAEncPictureParameterBufferJPEG *vpic = pic->codec_picture_params;
>  const AVPixFmtDescriptor *desc;
> +const uint8_t components_rgb[3] = { 'R', 'G', 'B' };
> +const uint8_t components_yuv[3] = {  1,   2,   3  };
>  const uint8_t *components;
>  int t, i, quant_scale, len;
>  
> @@ -235,9 +237,9 @@ static int 
> vaapi_encode_mjpeg_init_picture_params(AVCodecContext *avctx,
>  desc = av_pix_fmt_desc_get(priv->common.input_frames->sw_format);
>  av_assert0(desc);
>  if (desc->flags & AV_PIX_FMT_FLAG_RGB)
> -components = (uint8_t[3]) { 'R', 'G', 'B' };
> +components = components_rgb;
>  else
> -components = (uint8_t[3]) {  1,   2,   3  };
> +components = components_yuv;
>  
>  // Frame header.
>  
> 

LGTM; applied.

Thanks!

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/omx: Correct av_log() log message

2019-06-12 Thread Mark Thompson
On 12/06/2019 13:16, Alejandro Solozabal wrote:
> Print the right library name, which is trying to open, on the log message.
> 
> Signed-off-by: Alejandro Solozabal 
> ---
>  libavcodec/omx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/omx.c b/libavcodec/omx.c
> index 466e0be9fe..a1e5a46a54 100644
> --- a/libavcodec/omx.c
> +++ b/libavcodec/omx.c
> @@ -100,7 +100,7 @@ static av_cold int omx_try_load(OMXContext *s, void 
> *logctx,
>  if (libname2) {
>  s->lib2 = dlopen(libname2, RTLD_NOW | RTLD_GLOBAL);
>  if (!s->lib2) {
> -av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname);
> +av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname2);
>  return AVERROR_ENCODER_NOT_FOUND;
>  }
>  s->host_init = dlsym(s->lib2, "bcm_host_init");
> 

Yep, applied.

Thanks!

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-12 Thread Jean-Baptiste Kempf
On Wed, Jun 12, 2019, at 20:59, Reimar Döffinger wrote:
> Ok, but practically, if we mix all kinds of licenses that require 
> explicit mention of the license text, how is someone supposed to be 
> able to ship a FFmpeg binary?

List all the copyrights, in theory.

> Are they supposed to go through all files one by one and check the 
> license and copy the license text?
> Should we not at very least provide and maintain a correct "list of 
> licenses" file?

Well, yes/no. In practice many overlap.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables

2019-06-12 Thread Moritz Barsnick
On Wed, Jun 12, 2019 at 12:11:16 -0400, greg Luce wrote:
> Ooops apologies, .patch file attached and with hopefully better line breaks

Yes, but something went wrong with its contents:

> Subject: [PATCH] Signed-off-by: greg Luce 

This doesn't look correct. It's supposed to contain
Subject: vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
and the Signed-off-by line is to be somewhere in the remaining commit
message. How did you create the patch?

>  These parameters allow the @var{x} and @var{y} expressions to refer
> -each other, so you can for example specify @code{y=x/dar}.
> +to each other, so you can for example specify @code{y=x/dar}.
> +
> +@item pict_type
> +A 1 character description of the current packet's input picture type.
> +

Strictly speaking, you're fixing and amending existing documentation,
not related to your modifications. I personally don't mind, but others
will request you to do this is a separate patch.

> +@item pkt_pos
> +The current packet's position in the input datastream
> +(in bytes from the head of the source file).
> +
> +A value of -1 indicates this info is not available.

A non-related question: Do you understand when this is -1? (I myself
am looking for some filter or log info which can give me the pkt_pos
related to a certain time offset from the beginning of a file, as when
seeked using "-ss".)

> +The current packet's input duration.

"input duration" sounds confusing. You can likely drop the "input".

> +The current packet's input size (in bytes).

Ditto.

I can't comment on the rest, but like the feature.

You may need to bump libavfilter's MICRO version, as you are adding
features.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] set AVFrame decode_error_flags in case of decoding error by h264dec

2019-06-12 Thread Marton Balint



On Wed, 12 Jun 2019, Michael Niedermayer wrote:


On Wed, Jun 12, 2019 at 10:09:08AM +0200, Marton Balint wrote:



On Wed, 12 Jun 2019, Michael Niedermayer wrote:


On Tue, Jun 11, 2019 at 03:21:41PM -0500, Amir Z wrote:

Thanks Michael Niedermayer for looking into this

What I am trying to solve is having a way to detect concealed decoding
errors by the caller to avcodec_receive_frame.

Should I add a general value e.g. #define
FF_DECODE_ERROR_DECODE_ERROR_OCCURRED 4 ?


I suggest
FF_DECODE_ERROR_CONCEALMENT_ACTIVE or something similar and then always
set this for all cases of error concealment
Its more informative than just knowing there was an error


Concealment is a consequence. Error_flags should refer to the cause. A
generic UNKNOWN error seems much better to me if it is not feasible to
determine the cause.


Concealment is the consequence generally, still the error in the frames
differs between concealment or no concealment. A user application may
want to treat these differently.
concealemnt is not supported by all codecs currently and also not by
all variants, for example interlaced material tends to be less supported
in concealment. A user app might choose to discard a frame that
contains errors but no concealemnt if the following frame is fine.

Also in a very pedantic view, concealemnt itself is an error too.
Its rarly known exactly where the damage starts so concealment often needs
to cover more and by doing so adds errors in a minority of locations
that is if you just want a formal argument why this would fit in here.
Not an argument against the principle that concealemnt differs here in what
it is, you are certainly correct about that.


OK, FF_DECODE_ERROR_CONCEALMENT_ACTIVE is fine then.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-12 Thread Reimar Döffinger
On 12.06.2019, at 11:44, "Jean-Baptiste Kempf"  wrote:

> On Wed, Jun 12, 2019, at 07:51, Reimar Döffinger wrote:
>> Where does this license come from?
> 
> Original file.
> Very classical BSD-3
> 
>> Is that even GPL-compatible?
> 
> Yes, of course.

Ok, but practically, if we mix all kinds of licenses that require explicit 
mention of the license text, how is someone supposed to be able to ship a 
FFmpeg binary?
Are they supposed to go through all files one by one and check the license and 
copy the license text?
Should we not at very least provide and maintain a correct "list of licenses" 
file?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables

2019-06-12 Thread greg Luce
Ooops apologies, .patch file attached and with hopefully better line breaks

On Wed, 12 Jun 2019 at 03:43, Michael Niedermayer
 wrote:
>
> On Tue, Jun 11, 2019 at 06:02:10PM -0400, greg Luce wrote:
> > This is on the bug tracker at https://trac.ffmpeg.org/ticket/7947
> > Created with the help of the excellent Calvin Walton 
> > 
> > and rewritten with the advice of the excellent Gyan 
> >
> > ---
> >  doc/filters.texi  | 24 +++-
> >  libavfilter/vf_drawtext.c |  9 +
> >  2 files changed, 32 insertions(+), 1 deletion(-)
>
> git doesnt like this patch, probably messed up newlines
>
> Applying: vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
> error: corrupt patch at line 23
> error: could not build fake ancestor
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Dictatorship: All citizens are under surveillance, all their steps and
> actions recorded, for the politicians to enforce control.
> Democracy: All politicians are under surveillance, all their steps and
> actions recorded, for the citizens to enforce control.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".


[PATCH v2] vf_drawtext_ Add pkt_pos, pkt_duration, pkt_size as variables.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] set AVFrame decode_error_flags in case of decoding error by h264dec

2019-06-12 Thread Amir Z
FF_DECODE_ERROR_CONCEALMENT_ACTIVE sounds right for the case that the
ret variable is set to zero (i.e. indicate the fact that there was an
error and it is concealed)

ret = ff_h264_execute_decode_slices(h);
if (ret < 0 && (h->avctx->err_recognition & AV_EF_EXPLODE))
goto end;

// set h->cur_pic_ptr->f->decode_error_flags here

ret = 0;
end:

Thank


On Wed, Jun 12, 2019 at 4:35 AM Michael Niedermayer 
wrote:

> On Wed, Jun 12, 2019 at 10:09:08AM +0200, Marton Balint wrote:
> >
> >
> > On Wed, 12 Jun 2019, Michael Niedermayer wrote:
> >
> > >On Tue, Jun 11, 2019 at 03:21:41PM -0500, Amir Z wrote:
> > >>Thanks Michael Niedermayer for looking into this
> > >>
> > >>What I am trying to solve is having a way to detect concealed decoding
> > >>errors by the caller to avcodec_receive_frame.
> > >>
> > >>Should I add a general value e.g. #define
> > >>FF_DECODE_ERROR_DECODE_ERROR_OCCURRED 4 ?
> > >
> > >I suggest
> > >FF_DECODE_ERROR_CONCEALMENT_ACTIVE or something similar and then always
> > >set this for all cases of error concealment
> > >Its more informative than just knowing there was an error
> >
> > Concealment is a consequence. Error_flags should refer to the cause. A
> > generic UNKNOWN error seems much better to me if it is not feasible to
> > determine the cause.
>
> Concealment is the consequence generally, still the error in the frames
> differs between concealment or no concealment. A user application may
> want to treat these differently.
> concealemnt is not supported by all codecs currently and also not by
> all variants, for example interlaced material tends to be less supported
> in concealment. A user app might choose to discard a frame that
> contains errors but no concealemnt if the following frame is fine.
>
> Also in a very pedantic view, concealemnt itself is an error too.
> Its rarly known exactly where the damage starts so concealment often needs
> to cover more and by doing so adds errors in a minority of locations
> that is if you just want a formal argument why this would fit in here.
> Not an argument against the principle that concealemnt differs here in what
> it is, you are certainly correct about that.
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Modern terrorism, a quick summary: Need oil, start war with country that
> has oil, kill hundread thousand in war. Let country fall into chaos,
> be surprised about raise of fundamantalists. Drop more bombs, kill more
> people, be surprised about them taking revenge and drop even more bombs
> and strip your own citizens of their rights and freedoms. to be continued
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avformat/vividas: check length in read_vblock()

2019-06-12 Thread Michael Niedermayer
Fixes: out of array access
Fixes: 
15166/clusterfuzz-testcase-minimized-ffmpeg_DEMUXER_fuzzer-5731062396747776

Found-by: continuous fuzzing process 
https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer 
---
 libavformat/vividas.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavformat/vividas.c b/libavformat/vividas.c
index c99cbd1f6e..ec20aabbae 100644
--- a/libavformat/vividas.c
+++ b/libavformat/vividas.c
@@ -205,7 +205,7 @@ static uint8_t *read_vblock(AVIOContext *src, uint32_t 
*size,
 decode_block(tmp, tmp, 4, key, k2, align);
 
 n = get_v(tmp);
-if (!n)
+if (n < 4)
 return NULL;
 
 buf = av_malloc(n);
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V3 1/2] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-12 Thread Adam Sampson
Hi Ruiling,

Ruiling Song  writes:

> The horizontal pass get ~2x performance with the patch
> under single thread.
[...]
> +++ b/libavfilter/x86/vf_gblur.asm
[...]
> +%if ARCH_X86_64
> +INIT_XMM sse4
> +HORIZ_SLICE
> +
> +INIT_XMM avx2
> +HORIZ_SLICE
> +%endif
[...]
> +++ b/libavfilter/x86/vf_gblur_init.c
[...]
> +void ff_horiz_slice_sse4(float *ptr, int width, int height, int steps, float 
> nu, float bscale);
> +void ff_horiz_slice_avx2(float *ptr, int width, int height, int
> steps, float nu, float bscale);

This breaks the build for me on x86-32 -- the asm helpers in
vf_gblur.asm are only defined on x86-64, but vf_gblur_init.c expects
them to exist on both architectures.

ld: libavfilter/libavfilter.so: undefined reference to `ff_horiz_slice_avx2'
ld: libavfilter/libavfilter.so: undefined reference to `ff_horiz_slice_sse4'
collect2: error: ld returned 1 exit status

Adding "#if ARCH_X86_64" conditionals to vf_gblur_init.c fixes it.

Thanks,

-- 
Adam Sampson  
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec/omx: Correct av_log() log message

2019-06-12 Thread Alejandro Solozabal
Print the right library name, which is trying to open, on the log message.

Signed-off-by: Alejandro Solozabal 
---
 libavcodec/omx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/omx.c b/libavcodec/omx.c
index 466e0be9fe..a1e5a46a54 100644
--- a/libavcodec/omx.c
+++ b/libavcodec/omx.c
@@ -100,7 +100,7 @@ static av_cold int omx_try_load(OMXContext *s, void *logctx,
 if (libname2) {
 s->lib2 = dlopen(libname2, RTLD_NOW | RTLD_GLOBAL);
 if (!s->lib2) {
-av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname);
+av_log(logctx, AV_LOG_WARNING, "%s not found\n", libname2);
 return AVERROR_ENCODER_NOT_FOUND;
 }
 s->host_init = dlsym(s->lib2, "bcm_host_init");
-- 
2.11.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v4 2/2] doc/filters.texi: don't need to be in gray8 for find image

2019-06-12 Thread Lance Wang
On Wed, Jun 12, 2019 at 5:23 AM Michael Niedermayer 
wrote:

> On Tue, Jun 11, 2019 at 02:07:30PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  doc/filters.texi | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/doc/filters.texi b/doc/filters.texi
> > index ec1c7c7591..90c57430a6 100644
> > --- a/doc/filters.texi
> > +++ b/doc/filters.texi
> > @@ -10150,7 +10150,7 @@ It accepts the following options:
> >
> >  @table @option
> >  @item object
> > -Filepath of the object image, needs to be in gray8.
> > +Filepath of the object image.
>
> this belongs in the same patch which changes the code accordingly
>
> Have update the patch below:
https://patchwork.ffmpeg.org/patch/13513/

Also I have add more patch to improve the performance, please help to
review and give comments:
https://patchwork.ffmpeg.org/patch/13511/
https://patchwork.ffmpeg.org/patch/13512/

Thx.

thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> No snowflake in an avalanche ever feels responsible. -- Voltaire
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 1/3] libavfilter/vf_find_rect: convert the object image to gray8 format instead of failed directly

2019-06-12 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/filters.texi   |  2 +-
 libavfilter/vf_find_rect.c | 39 +++---
 2 files changed, 29 insertions(+), 12 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ec1c7c7591..90c57430a6 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10150,7 +10150,7 @@ It accepts the following options:
 
 @table @option
 @item object
-Filepath of the object image, needs to be in gray8.
+Filepath of the object image.
 
 @item threshold
 Detection threshold, default is 0.5.
diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index d7e6579af7..ee6c3f4b45 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -28,6 +28,7 @@
 #include "internal.h"
 
 #include "lavfutils.h"
+#include "lswsutils.h"
 
 #define MAX_MIPMAPS 5
 
@@ -244,6 +245,9 @@ static av_cold int init(AVFilterContext *ctx)
 {
 FOCContext *foc = ctx->priv;
 int ret, i;
+uint8_t *tmp_data[4] = { NULL };
+int tmp_linesize[4], width, height;
+enum AVPixelFormat pix_fmt;
 
 if (!foc->obj_filename) {
 av_log(ctx, AV_LOG_ERROR, "object filename not set\n");
@@ -254,24 +258,37 @@ static av_cold int init(AVFilterContext *ctx)
 if (!foc->obj_frame)
 return AVERROR(ENOMEM);
 
-if ((ret = ff_load_image(foc->obj_frame->data, foc->obj_frame->linesize,
- &foc->obj_frame->width, &foc->obj_frame->height,
- &foc->obj_frame->format, foc->obj_filename, ctx)) 
< 0)
-return ret;
-
-if (foc->obj_frame->format != AV_PIX_FMT_GRAY8) {
-av_log(ctx, AV_LOG_ERROR, "object image is not a grayscale image\n");
-return AVERROR(EINVAL);
-}
+if ((ret = ff_load_image(tmp_data, tmp_linesize,
+ &width, &height,
+ &pix_fmt, foc->obj_filename, ctx)) < 0)
+goto error;
+
+/* convert object image to gray8 format with same width and height */
+foc->obj_frame->format = AV_PIX_FMT_GRAY8;
+foc->obj_frame->width  = width;
+foc->obj_frame->height = height;
+if ((ret = ff_scale_image(foc->obj_frame->data, foc->obj_frame->linesize,
+foc->obj_frame->width, foc->obj_frame->height, 
foc->obj_frame->format,
+tmp_data, tmp_linesize, width, height, pix_fmt, ctx)) < 0)
+goto error;
+av_freep(&tmp_data[0]);
 
 foc->needle_frame[0] = av_frame_clone(foc->obj_frame);
 for (i = 1; i < foc->mipmaps; i++) {
 foc->needle_frame[i] = downscale(foc->needle_frame[i-1]);
-if (!foc->needle_frame[i])
-return AVERROR(ENOMEM);
+if (!foc->needle_frame[i]) {
+ret = AVERROR(ENOMEM);
+goto error;
+}
 }
 
 return 0;
+error:
+av_freep(&tmp_data[0]);
+if (foc->obj_frame)
+av_freep(&foc->obj_frame->data[0]);
+av_frame_free(&foc->obj_frame);
+return ret;
 }
 
 static const AVFilterPad foc_inputs[] = {
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 2/3] libavfilter/vf_cover_rect: support for cover image with more pixel format and different width and height

2019-06-12 Thread Lance Wang
On Wed, Jun 12, 2019 at 5:43 PM Moritz Barsnick  wrote:

> On Tue, Jun 11, 2019 at 13:38:43 +0800, lance.lmw...@gmail.com wrote:
> > @@ -220,11 +248,6 @@ static av_cold int init(AVFilterContext *ctx)
> >  &cover->cover_frame->width,
> &cover->cover_frame->height,
> >  &cover->cover_frame->format,
> cover->cover_filename, ctx)) < 0)
> >  return ret;
> > -
> > -if (cover->cover_frame->format != AV_PIX_FMT_YUV420P &&
> cover->cover_frame->format != AV_PIX_FMT_YUVJ420P) {
> > -av_log(ctx, AV_LOG_ERROR, "cover image is not a YUV420
> image\n");
> > -return AVERROR(EINVAL);
> > -}
> >  }
>
> Don't you also need to update query_formats()? Just wondering,
> untested.
>
> It's image format only, the patch will convert it to same format as input
frame.  I have tested with the new patch and haven't see any issue.




> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 3/3] vf_find_rect.c: improve the find object detect performance

2019-06-12 Thread lance . lmwang
From: Limin Wang 

Test with my samples with same test command, the detect function is OK, however 
the benchmark result is from 16fps to 400fps

Signed-off-by: Limin Wang 
---
 libavfilter/vf_find_rect.c | 15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index ed15885bc2..d7da224c10 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -32,6 +32,7 @@
 #include "lswsutils.h"
 
 #define MAX_MIPMAPS 5
+#define MIN_THRESHOLD (0.05)
 
 typedef struct FOCContext {
 AVClass *class;
@@ -42,6 +43,7 @@ typedef struct FOCContext {
 int xmin, ymin, xmax, ymax;
 char *obj_filename;
 int last_x, last_y;
+float last_best_score;
 AVFrame *obj_frame;
 AVFrame *needle_frame[MAX_MIPMAPS];
 AVFrame *haystack_frame[MAX_MIPMAPS];
@@ -190,8 +192,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 FFMIN(foc->ymax, foc->last_y + 8),
 &best_x, &best_y, 1.0);
 
-best_score = search(foc, 0, foc->mipmaps - 1, foc->xmin, foc->xmax, 
foc->ymin, foc->ymax,
+if (FFABS(best_score - foc->last_best_score) > MIN_THRESHOLD && best_score 
> MIN_THRESHOLD) {
+best_score = search(foc, 0, foc->mipmaps - 1, foc->xmin, foc->xmax, 
foc->ymin, foc->ymax,
 &best_x, &best_y, best_score);
+} else {
+/* prefer to use last x and y for best xy to avoid small shift of 
object */
+best_x = foc->last_x;
+best_y = foc->last_y;
+}
 
 for (i=0; ihaystack_frame[i]);
@@ -204,6 +212,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 av_log(ctx, AV_LOG_DEBUG, "Found at %d %d score %f\n", best_x, best_y, 
best_score);
 foc->last_x = best_x;
 foc->last_y = best_y;
+foc->last_best_score = best_score;
 
 av_frame_make_writable(in);
 
@@ -271,6 +280,10 @@ static av_cold int init(AVFilterContext *ctx)
 }
 }
 
+foc->last_x = 0;
+foc->last_y = 0;
+foc->last_best_score = 1;
+
 return 0;
 error:
 av_freep(&tmp_data[0]);
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v5 2/3] vf_find_rect.c: use the optimized sad function to improve the find performance

2019-06-12 Thread lance . lmwang
From: Limin Wang 

benchmark on x86_64: 6.4 -> 16 with below command:
./ffmpeg  -i 1920x1080.mp4 -vf 
find_rect=./find.tif,cover_rect=./cover.jpg:mode=cover -f null -
6.4 fps -> 16fps

Signed-off-by: Limin Wang 
---
 libavfilter/vf_find_rect.c | 53 +++---
 1 file changed, 21 insertions(+), 32 deletions(-)

diff --git a/libavfilter/vf_find_rect.c b/libavfilter/vf_find_rect.c
index ee6c3f4b45..ed15885bc2 100644
--- a/libavfilter/vf_find_rect.c
+++ b/libavfilter/vf_find_rect.c
@@ -26,6 +26,7 @@
 #include "libavutil/imgutils.h"
 #include "libavutil/opt.h"
 #include "internal.h"
+#include "scene_sad.h"
 
 #include "lavfutils.h"
 #include "lswsutils.h"
@@ -36,6 +37,8 @@ typedef struct FOCContext {
 AVClass *class;
 float threshold;
 int mipmaps;
+ff_scene_sad_fn sad;
+int bitdepth;
 int xmin, ymin, xmax, ymax;
 char *obj_filename;
 int last_x, last_y;
@@ -103,54 +106,40 @@ static AVFrame *downscale(AVFrame *in)
 return frame;
 }
 
-static float compare(const AVFrame *haystack, const AVFrame *obj, int offx, 
int offy)
+static float compare_sad(FOCContext *foc, AVFrame *haystack, AVFrame *obj, int 
offx, int offy)
 {
-int x,y;
-int o_sum_v = 0;
-int h_sum_v = 0;
-int64_t oo_sum_v = 0;
-int64_t hh_sum_v = 0;
-int64_t oh_sum_v = 0;
-float c;
+uint64_t sad = 0;
 int n = obj->height * obj->width;
-const uint8_t *odat = obj ->data[0];
+double mafd;
+const uint8_t *odat = obj->data[0];
 const uint8_t *hdat = haystack->data[0] + offx + offy * 
haystack->linesize[0];
-int64_t o_sigma, h_sigma;
-
-for(y = 0; y < obj->height; y++) {
-for(x = 0; x < obj->width; x++) {
-int o_v = odat[x];
-int h_v = hdat[x];
-o_sum_v += o_v;
-h_sum_v += h_v;
-oo_sum_v += o_v * o_v;
-hh_sum_v += h_v * h_v;
-oh_sum_v += o_v * h_v;
-}
-odat += obj->linesize[0];
-hdat += haystack->linesize[0];
-}
-o_sigma = n*oo_sum_v - o_sum_v*(int64_t)o_sum_v;
-h_sigma = n*hh_sum_v - h_sum_v*(int64_t)h_sum_v;
 
-if (o_sigma == 0 || h_sigma == 0)
-return 1.0;
+foc->sad(hdat, haystack->linesize[0], odat, obj->linesize[0],
+obj->width, obj->height, &sad);
+emms_c();
+mafd = (double)sad / n / (1ULL << foc->bitdepth);
 
-c = (n*oh_sum_v - o_sum_v*(int64_t)h_sum_v) / 
(sqrt(o_sigma)*sqrt(h_sigma));
-
-return 1 - fabs(c);
+return mafd;
 }
 
 static int config_input(AVFilterLink *inlink)
 {
 AVFilterContext *ctx = inlink->dst;
 FOCContext *foc = ctx->priv;
+const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
 
 if (foc->xmax <= 0)
 foc->xmax = inlink->w - foc->obj_frame->width;
 if (foc->ymax <= 0)
 foc->ymax = inlink->h - foc->obj_frame->height;
 
+foc->bitdepth = pix_desc->comp[0].depth;
+
+foc->sad = ff_scene_sad_get_fn(foc->bitdepth == 8 ? 8 : 16);
+if (!foc->sad)
+return AVERROR(EINVAL);
+
+
 return 0;
 }
 
@@ -169,7 +158,7 @@ static float search(FOCContext *foc, int pass, int maxpass, 
int xmin, int xmax,
 
 for (y = ymin; y <= ymax; y++) {
 for (x = xmin; x <= xmax; x++) {
-float score = compare(foc->haystack_frame[pass], 
foc->needle_frame[pass], x, y);
+float score = compare_sad(foc, foc->haystack_frame[pass], 
foc->needle_frame[pass], x, y);
 av_assert0(score != 0);
 if (score < best_score) {
 best_score = score;
-- 
2.21.0

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 2/3] libavfilter/vf_cover_rect: support for cover image with more pixel format and different width and height

2019-06-12 Thread Lance Wang
On Wed, Jun 12, 2019 at 4:51 AM Michael Niedermayer 
wrote:

> On Tue, Jun 11, 2019 at 01:38:43PM +0800, lance.lmw...@gmail.com wrote:
> > From: Limin Wang 
> >
> > Signed-off-by: Limin Wang 
> > ---
> >  libavfilter/vf_cover_rect.c | 49 +++--
> >  1 file changed, 36 insertions(+), 13 deletions(-)
> >
> > diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c
> > index 898debf09d..22389b79d2 100644
> > --- a/libavfilter/vf_cover_rect.c
> > +++ b/libavfilter/vf_cover_rect.c
> > @@ -28,6 +28,7 @@
> >  #include "internal.h"
> >
> >  #include "lavfutils.h"
> > +#include "lswsutils.h"
> >
> >  enum mode {
> >  MODE_COVER,
> > @@ -40,6 +41,7 @@ typedef struct CoverContext {
> >  int mode;
> >  char *cover_filename;
> >  AVFrame *cover_frame;
> > +AVFrame *match_frame;
> >  int width, height;
> >  } CoverContext;
> >
> > @@ -71,21 +73,21 @@ static int config_input(AVFilterLink *inlink)
> >  return 0;
> >  }
> >
> > -static void cover_rect(CoverContext *cover, AVFrame *in, int offx, int
> offy)
> > +static void cover_rect(AVFrame *cover_frame, AVFrame *in, int offx, int
> offy)
> >  {
> >  int x, y, p;
> >
> >  for (p = 0; p < 3; p++) {
> >  uint8_t *data = in->data[p] + (offx>>!!p) + (offy>>!!p) *
> in->linesize[p];
> > -const uint8_t *src = cover->cover_frame->data[p];
> > -int w = AV_CEIL_RSHIFT(cover->cover_frame->width , !!p);
> > -int h = AV_CEIL_RSHIFT(cover->cover_frame->height, !!p);
> > +const uint8_t *src = cover_frame->data[p];
> > +int w = AV_CEIL_RSHIFT(cover_frame->width , !!p);
> > +int h = AV_CEIL_RSHIFT(cover_frame->height, !!p);
> >  for (y = 0; y < h; y++) {
> >  for (x = 0; x < w; x++) {
> >  data[x] = src[x];
> >  }
> >  data += in->linesize[p];
> > -src += cover->cover_frame->linesize[p];
> > +src += cover_frame->linesize[p];
> >  }
> >  }
> >  }
> > @@ -138,7 +140,10 @@ static int filter_frame(AVFilterLink *inlink,
> AVFrame *in)
> >  CoverContext *cover = ctx->priv;
> >  AVDictionaryEntry *ex, *ey, *ew, *eh;
> >  int x = -1, y = -1, w = -1, h = -1;
> > +enum AVPixelFormat in_format;
> >  char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr =
> NULL;
> > +AVFrame *cover_frame = NULL;
> > +int ret;
> >
> >  ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL,
> AV_DICT_MATCH_CASE);
> >  ey = av_dict_get(in->metadata, "lavfi.rect.y", NULL,
> AV_DICT_MATCH_CASE);
> > @@ -167,13 +172,30 @@ static int filter_frame(AVFilterLink *inlink,
> AVFrame *in)
> >  }
> >  w = FFMIN(w, in->width  - x);
> >  h = FFMIN(h, in->height - y);
> > +in_format = in->format;
> >
> >  if (w > in->width || h > in->height || w <= 0 || h <= 0)
> >  return AVERROR(EINVAL);
> >
> >  if (cover->cover_frame) {
> > -if (w != cover->cover_frame->width || h !=
> cover->cover_frame->height)
> > -return AVERROR(EINVAL);
> > +if (w != cover->cover_frame->width || h !=
> cover->cover_frame->height ||
> > +in_format != cover->cover_frame->format) {
> > +if (!cover->match_frame && !(cover->match_frame =
> av_frame_alloc()))
> > +return AVERROR(EINVAL);
> > +
> > +if ((ret = ff_scale_image(cover->match_frame->data,
> cover->match_frame->linesize,
> > +w, h, in_format, cover->cover_frame->data,
> cover->cover_frame->linesize,
> > +cover->cover_frame->width,
> cover->cover_frame->height,
> > +cover->cover_frame->format, ctx)) < 0)
> > +return AVERROR(EINVAL);
>
> This looks like the same static cover image would be converted again for
> each input frame
> which if iam not misreading this would be doing the exact same operation
> over and over
> again, thats same wastefull
>
>
I have fixed the issue in the updated patch, please help to review again.
https://patchwork.ffmpeg.org/patch/13510/


> []
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Why not whip the teacher when the pupil misbehaves? -- Diogenes of Sinope
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 3/3] doc/filters.texi: Don't need to be yuv420 format for cover image

2019-06-12 Thread Lance Wang
On Wed, Jun 12, 2019 at 5:46 PM Moritz Barsnick  wrote:

> On Tue, Jun 11, 2019 at 13:38:44 +0800, lance.lmw...@gmail.com wrote:
> >  doc/filters.texi | 2 +-
>
> While you're at it, could you kindly add another patch to fix the
> descriptions of the examples for find_rect and cover_rect? They are
> copy pasted from pallettegen, and are totally misleading:
>
> > Generate a representative palette of a given video using
> @command{ffmpeg}:
>
>
OK, I'll update the patch with the description also. Please help to review
it.



> Thanks,
> Moritz
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH v4] libavfilter/vf_cover_rect: support for cover image with more pixel format and different width and height

2019-06-12 Thread lance . lmwang
From: Limin Wang 

Signed-off-by: Limin Wang 
---
 doc/filters.texi|  6 ++--
 libavfilter/vf_cover_rect.c | 56 +++--
 2 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/doc/filters.texi b/doc/filters.texi
index ec1c7c7591..4594a61c13 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -10166,7 +10166,7 @@ Specifies the rectangle in which to search.
 
 @itemize
 @item
-Generate a representative palette of a given video using @command{ffmpeg}:
+Cover a rectangular object by the supplied image of a given video using 
@command{ffmpeg}:
 @example
 ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover 
new.mkv
 @end example
@@ -10180,7 +10180,7 @@ It accepts the following options:
 
 @table @option
 @item cover
-Filepath of the optional cover image, needs to be in yuv420.
+Filepath of the optional cover image.
 
 @item mode
 Set covering mode.
@@ -10200,7 +10200,7 @@ Default value is @var{blur}.
 
 @itemize
 @item
-Generate a representative palette of a given video using @command{ffmpeg}:
+Cover a rectangular object by the supplied image of a given video using 
@command{ffmpeg}:
 @example
 ffmpeg -i file.ts -vf find_rect=newref.pgm,cover_rect=cover.jpg:mode=cover 
new.mkv
 @end example
diff --git a/libavfilter/vf_cover_rect.c b/libavfilter/vf_cover_rect.c
index 898debf09d..36c650dd21 100644
--- a/libavfilter/vf_cover_rect.c
+++ b/libavfilter/vf_cover_rect.c
@@ -28,6 +28,7 @@
 #include "internal.h"
 
 #include "lavfutils.h"
+#include "lswsutils.h"
 
 enum mode {
 MODE_COVER,
@@ -40,6 +41,7 @@ typedef struct CoverContext {
 int mode;
 char *cover_filename;
 AVFrame *cover_frame;
+AVFrame *match_frame;
 int width, height;
 } CoverContext;
 
@@ -71,21 +73,21 @@ static int config_input(AVFilterLink *inlink)
 return 0;
 }
 
-static void cover_rect(CoverContext *cover, AVFrame *in, int offx, int offy)
+static void cover_rect(AVFrame *cover_frame, AVFrame *in, int offx, int offy)
 {
 int x, y, p;
 
 for (p = 0; p < 3; p++) {
 uint8_t *data = in->data[p] + (offx>>!!p) + (offy>>!!p) * 
in->linesize[p];
-const uint8_t *src = cover->cover_frame->data[p];
-int w = AV_CEIL_RSHIFT(cover->cover_frame->width , !!p);
-int h = AV_CEIL_RSHIFT(cover->cover_frame->height, !!p);
+const uint8_t *src = cover_frame->data[p];
+int w = AV_CEIL_RSHIFT(cover_frame->width , !!p);
+int h = AV_CEIL_RSHIFT(cover_frame->height, !!p);
 for (y = 0; y < h; y++) {
 for (x = 0; x < w; x++) {
 data[x] = src[x];
 }
 data += in->linesize[p];
-src += cover->cover_frame->linesize[p];
+src += cover_frame->linesize[p];
 }
 }
 }
@@ -138,7 +140,10 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 CoverContext *cover = ctx->priv;
 AVDictionaryEntry *ex, *ey, *ew, *eh;
 int x = -1, y = -1, w = -1, h = -1;
+enum AVPixelFormat in_format;
 char *xendptr = NULL, *yendptr = NULL, *wendptr = NULL, *hendptr = NULL;
+AVFrame *cover_frame = NULL;
+int ret;
 
 ex = av_dict_get(in->metadata, "lavfi.rect.x", NULL, AV_DICT_MATCH_CASE);
 ey = av_dict_get(in->metadata, "lavfi.rect.y", NULL, AV_DICT_MATCH_CASE);
@@ -167,14 +172,34 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 }
 w = FFMIN(w, in->width  - x);
 h = FFMIN(h, in->height - y);
+in_format = in->format;
 
 if (w > in->width || h > in->height || w <= 0 || h <= 0)
 return AVERROR(EINVAL);
 
-if (cover->cover_frame) {
-if (w != cover->cover_frame->width || h != cover->cover_frame->height)
-return AVERROR(EINVAL);
-}
+if (w != cover->cover_frame->width || h != cover->cover_frame->height ||
+in_format != cover->cover_frame->format) {
+if (!cover->match_frame || (w != cover->match_frame->width || h != 
cover->match_frame->height
+|| in_format != cover->match_frame->format)) {
+if (cover->match_frame)
+av_freep(&cover->match_frame->data[0]);
+else if (!(cover->match_frame = av_frame_alloc()))
+return AVERROR(ENOMEM);
+
+if ((ret = ff_scale_image(cover->match_frame->data, 
cover->match_frame->linesize,
+w, h, in_format, cover->cover_frame->data, 
cover->cover_frame->linesize,
+cover->cover_frame->width, 
cover->cover_frame->height,
+cover->cover_frame->format, ctx)) < 0)
+return AVERROR(ENOMEM);
+
+cover->match_frame->width  = w;
+cover->match_frame->height = h;
+cover->match_frame->format = in_format;
+}
+
+cover_frame = cover->match_frame;
+} else
+cover_frame = cover->cover_frame;
 
 cover->width  = w;
 cover->height = h;
@@ -187,8 +212,10 @@ static int filte

Re: [FFmpeg-devel] [PATCH v3 3/3] doc/filters.texi: Don't need to be yuv420 format for cover image

2019-06-12 Thread Moritz Barsnick
On Tue, Jun 11, 2019 at 13:38:44 +0800, lance.lmw...@gmail.com wrote:
>  doc/filters.texi | 2 +-

While you're at it, could you kindly add another patch to fix the
descriptions of the examples for find_rect and cover_rect? They are
copy pasted from pallettegen, and are totally misleading:

> Generate a representative palette of a given video using @command{ffmpeg}:

Thanks,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-12 Thread Jean-Baptiste Kempf
On Wed, Jun 12, 2019, at 07:51, Reimar Döffinger wrote:
> Where does this license come from?

Original file.
Very classical BSD-3

> Is that even GPL-compatible?

Yes, of course.

-- 
Jean-Baptiste Kempf -  President
+33 672 704 734
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v3 2/3] libavfilter/vf_cover_rect: support for cover image with more pixel format and different width and height

2019-06-12 Thread Moritz Barsnick
On Tue, Jun 11, 2019 at 13:38:43 +0800, lance.lmw...@gmail.com wrote:
> @@ -220,11 +248,6 @@ static av_cold int init(AVFilterContext *ctx)
>  &cover->cover_frame->width, 
> &cover->cover_frame->height,
>  &cover->cover_frame->format, 
> cover->cover_filename, ctx)) < 0)
>  return ret;
> -
> -if (cover->cover_frame->format != AV_PIX_FMT_YUV420P && 
> cover->cover_frame->format != AV_PIX_FMT_YUVJ420P) {
> -av_log(ctx, AV_LOG_ERROR, "cover image is not a YUV420 image\n");
> -return AVERROR(EINVAL);
> -}
>  }

Don't you also need to update query_formats()? Just wondering,
untested.

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] set AVFrame decode_error_flags in case of decoding error by h264dec

2019-06-12 Thread Michael Niedermayer
On Wed, Jun 12, 2019 at 10:09:08AM +0200, Marton Balint wrote:
> 
> 
> On Wed, 12 Jun 2019, Michael Niedermayer wrote:
> 
> >On Tue, Jun 11, 2019 at 03:21:41PM -0500, Amir Z wrote:
> >>Thanks Michael Niedermayer for looking into this
> >>
> >>What I am trying to solve is having a way to detect concealed decoding
> >>errors by the caller to avcodec_receive_frame.
> >>
> >>Should I add a general value e.g. #define
> >>FF_DECODE_ERROR_DECODE_ERROR_OCCURRED 4 ?
> >
> >I suggest
> >FF_DECODE_ERROR_CONCEALMENT_ACTIVE or something similar and then always
> >set this for all cases of error concealment
> >Its more informative than just knowing there was an error
> 
> Concealment is a consequence. Error_flags should refer to the cause. A
> generic UNKNOWN error seems much better to me if it is not feasible to
> determine the cause.

Concealment is the consequence generally, still the error in the frames
differs between concealment or no concealment. A user application may
want to treat these differently.
concealemnt is not supported by all codecs currently and also not by
all variants, for example interlaced material tends to be less supported
in concealment. A user app might choose to discard a frame that
contains errors but no concealemnt if the following frame is fine.

Also in a very pedantic view, concealemnt itself is an error too.
Its rarly known exactly where the damage starts so concealment often needs
to cover more and by doing so adds errors in a minority of locations
that is if you just want a formal argument why this would fit in here.
Not an argument against the principle that concealemnt differs here in what
it is, you are certainly correct about that.

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

Modern terrorism, a quick summary: Need oil, start war with country that
has oil, kill hundread thousand in war. Let country fall into chaos,
be surprised about raise of fundamantalists. Drop more bombs, kill more
people, be surprised about them taking revenge and drop even more bombs
and strip your own citizens of their rights and freedoms. to be continued


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-12 Thread Moritz Barsnick
On Wed, Jun 12, 2019 at 08:23:29 +, Song, Ruiling wrote:
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Reimar D?ffinger

> > Where does this license come from?
> The license is from vf_gblur.c, because the code was copied from there.
> If I read correctly, this is "Simplified BSD License".

To me, it looks like the BSD 3-clause, a.k.a. "Modified BSD" license.
Several files in ffmpeg's source tree seem to carry this license.

> > Is that even GPL-compatible?

According to gnu.org: Yes.

> > I mean how is someone compiling ffmpeg even supposed to know
> > they have to put this license text in their documentation?

Good question. ffmpeg's LICENSE.md provides some license references,
but is probably not meant as a template for distribution with a binary,
and doesn't explicitly quote the BSD-licensed components. It does
mention all GPL-licensed components, bit I assume to raise awareness
for when ffmpeg is GPL and when it it LGPL - and what non-free means.

IANAL,
Moritz
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec: Add smpte2084 transfer function to videotoolboxenc

2019-06-12 Thread Nomis101 🐝
Am 12.06.19 um 10:01 schrieb Michael Niedermayer:
> On Wed, Jun 12, 2019 at 09:44:26AM +0200, Nomis101 🐝 wrote:
>> This patch will add support of the smpte2084 transfer function to 
>> videotoolboxenc. kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ is 
>> available on macOS 10.13 and up.
>> This is on the bug tracker at https://trac.ffmpeg.org/ticket/7953
>>
>> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
>> index 3665581283..e786ebe3a7 100644
>> --- a/libavcodec/videotoolboxenc.c
>> +++ b/libavcodec/videotoolboxenc.c
>> @@ -909,6 +909,12 @@ static int get_cv_transfer_function(AVCodecContext 
>> *avctx,
>>  case AVCOL_TRC_SMPTE240M:
>>  *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
>>  break;
>> +
>> +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
>> +case AVCOL_TRC_SMPTE2084:
>> +*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
>> +break;
>> +#endif
>>
>>  case AVCOL_TRC_GAMMA22:
>>  gamma = 2.2;
>
> git does not like this patch
>
> Applying: avcodec: Add smpte2084 transfer function to videotoolboxenc
> Using index info to reconstruct a base tree...
> error: patch failed: libavcodec/videotoolboxenc.c:909
> error: libavcodec/videotoolboxenc.c: patch does not apply
> error: Did you hand edit your patch?
> It does not apply to blobs recorded in its index.
>
>
> [..]
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
>

Sorry, I removed some whitespace afterwards. My bad. I attached a new untouched 
patch created only by git format-patch. Hope this applies.
From a973fa96e4f8f54351e14019acf6b1f7b5b3ff00 Mon Sep 17 00:00:00 2001
From: Nomis101 
Date: Wed, 12 Jun 2019 10:32:47 +0200
Subject: [PATCH] [PATCH] avcodec: Add smpte2084 transfer function to
 videotoolboxenc

---
 libavcodec/videotoolboxenc.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 3665581283..f2cb24a012 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -910,6 +910,12 @@ static int get_cv_transfer_function(AVCodecContext *avctx,
 *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
 break;
 
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+case AVCOL_TRC_SMPTE2084:
+*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
+break;
+#endif
+
 case AVCOL_TRC_GAMMA22:
 gamma = 2.2;
 *transfer_fnc = kCVImageBufferTransferFunction_UseGamma;
-- 
2.20.1 (Apple Git-117)

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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_gblur: add x86 SIMD optimizations

2019-06-12 Thread Song, Ruiling
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Reimar D?ffinger
> Sent: Wednesday, June 12, 2019 1:51 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [FFmpeg-cvslog] avfilter/vf_gblur: add x86
> SIMD optimizations
> 
> 
> 
> On 12.06.2019, at 03:00, Ruiling Song  wrote:
> 
> > ffmpeg | branch: master | Ruiling Song  | Wed
> May 15 17:54:10 2019 +0800| [83f9da77684e7ea0d8e9f9712ec716424140043a]
> | committer: Ruiling Song
> >
> > avfilter/vf_gblur: add x86 SIMD optimizations
> >
> > The horizontal pass get ~2x performance with the patch
> > under single thread.
> >
> > Tested overall performance using the command(avx2 enabled):
> > ./ffmpeg -i 1080p.mp4 -vf gblur -f null /dev/null
> > ./ffmpeg -i 1080p.mp4 -vf gblur=threads=1 -f null /dev/null
> > For single thread, the fps improves from 43 to 60, about 40%.
> > For multi-thread, the fps improves from 110 to 130, about 20%.
> >
> > Signed-off-by: Ruiling Song 
> >
> >>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=83f9da77684e7e
> a0d8e9f9712ec716424140043a
> > ---
> >
> > libavfilter/gblur.h |  55 
> > libavfilter/vf_gblur.c  |  71 +++
> > libavfilter/x86/Makefile|   2 +
> > libavfilter/x86/vf_gblur.asm| 185
> 
> > libavfilter/x86/vf_gblur_init.c |  36 
> > 5 files changed, 310 insertions(+), 39 deletions(-)
> >
> > diff --git a/libavfilter/gblur.h b/libavfilter/gblur.h
> > new file mode 100644
> > index 00..87129801de
> > --- /dev/null
> > +++ b/libavfilter/gblur.h
> > @@ -0,0 +1,55 @@
> > +/*
> > + * Copyright (c) 2011 Pascal Getreuer
> > + * Copyright (c) 2016 Paul B Mahol
> > + *
> > + * Redistribution and use in source and binary forms, with or without
> modification,
> > + * are permitted provided that the following conditions are met:
> > + *
> > + *  * Redistributions of source code must retain the above copyright
> > + *notice, this list of conditions and the following disclaimer.
> > + *  * Redistributions in binary form must reproduce the above
> > + *copyright notice, this list of conditions and the following
> > + *disclaimer in the documentation and/or other materials provided
> > + *with the distribution.
> 
> Where does this license come from?
The license is from vf_gblur.c, because the code was copied from there.
If I read correctly, this is "Simplified BSD License".

> Is that even GPL-compatible?
> I mean how is someone compiling ffmpeg even supposed to know
> they have to put this license text in their documentation?


> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: add support for AVC Trellis

2019-06-12 Thread myp...@gmail.com
On Wed, Jun 12, 2019 at 3:28 PM Linjie Fu  wrote:
>
> Add support for VAAPI AVC Trellis Quantization with limitation:
> - VA-API version >= (1, 0, 0)
>
> Use option "-trellis off/I/P/B" to disable or enable Trellis
> quantization for I/P/B frames.
>
> Signed-off-by: Linjie Fu 
> ---
> [v2]: Since nonstandard struct for VAEncMiscParameterQuantization is
> fixed: https://github.com/intel/libva/issues/265
> update patch based on:
> http://git.ffmpeg.org/gitweb/ffmpeg.git/commit/2880a32c668023bfee4745095c885450d547ae45
>  libavcodec/vaapi_encode.c  | 48 ++
>  libavcodec/vaapi_encode.h  |  9 +--
>  libavcodec/vaapi_encode_h264.c |  9 +++
>  3 files changed, 64 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
> index dd2a24de04..fbfbe78c6b 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1671,6 +1671,48 @@ rc_mode_found:
>  return 0;
>  }
>
> +static av_cold int vaapi_encode_init_quantization(AVCodecContext *avctx)
> +{
> +#if VA_CHECK_VERSION(1, 0, 0)
> +VAAPIEncodeContext *ctx = avctx->priv_data;
> +VAStatus vas;
> +VAConfigAttrib attr = { VAConfigAttribEncQuantization };
> +int trellis = ctx->trellis;
> +
> +vas = vaGetConfigAttributes(ctx->hwctx->display,
> +ctx->va_profile,
> +ctx->va_entrypoint,
> +&attr, 1);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(avctx, AV_LOG_ERROR, "Failed to query quantization "
> +   "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
> +return AVERROR_EXTERNAL;
> +}
> +
> +if (attr.value == VA_ATTRIB_NOT_SUPPORTED ||
> +attr.value == VA_ENC_QUANTIZATION_NONE) {
> +av_log(avctx, AV_LOG_WARNING, "Special Quantization attribute is not 
> "
> +"supported: will use default quantization.\n");
> +} else if (attr.value == VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED){
> +av_log(avctx, AV_LOG_VERBOSE, "Quantization Trellis supported.\n");
> +
> +ctx->quantization_params = (VAEncMiscParameterQuantization) {
> +.quantization_flags.value = trellis,
> +};
> +
> +vaapi_encode_add_global_param(avctx,
> +  VAEncMiscParameterTypeQuantization,
> +  &ctx->quantization_params,
> +  sizeof(ctx->quantization_params));
> +}
> +#else
> +av_log(avctx, AV_LOG_WARNING, "The encode quantization option (Trellis) 
> is "
> +   "not supported with this VAAPI version.\n");
> +#endif
> +
> +return 0;
> +}
> +
>  static av_cold int vaapi_encode_init_gop_structure(AVCodecContext *avctx)
>  {
>  VAAPIEncodeContext *ctx = avctx->priv_data;
> @@ -2132,6 +2174,12 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
>  if (err < 0)
>  goto fail;
>
> +if (ctx->trellis) {
> +err = vaapi_encode_init_quantization(avctx);
> +if (err < 0)
> +goto fail;
> +}
> +
>  if (avctx->compression_level >= 0) {
>  err = vaapi_encode_init_quality(avctx);
>  if (err < 0)
> diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
> index eeec06036b..b24735da59 100644
> --- a/libavcodec/vaapi_encode.h
> +++ b/libavcodec/vaapi_encode.h
> @@ -37,7 +37,7 @@ struct VAAPIEncodePicture;
>
>  enum {
>  MAX_CONFIG_ATTRIBUTES  = 4,
> -MAX_GLOBAL_PARAMS  = 4,
> +MAX_GLOBAL_PARAMS  = 5,
>  MAX_DPB_SIZE   = 16,
>  MAX_PICTURE_REFERENCES = 2,
>  MAX_REORDER_DELAY  = 16,
> @@ -220,6 +220,9 @@ typedef struct VAAPIEncodeContext {
>  // Packed headers which will actually be sent.
>  unsigned intva_packed_headers;
>
> +// Quantization mode
> +int trellis;
> +
>  // Configuration attributes to use when creating va_config.
>  VAConfigAttrib  config_attributes[MAX_CONFIG_ATTRIBUTES];
>  int  nb_config_attributes;
> @@ -256,7 +259,9 @@ typedef struct VAAPIEncodeContext {
>  #if VA_CHECK_VERSION(0, 36, 0)
>  VAEncMiscParameterBufferQualityLevel quality_params;
>  #endif
> -
> +#if VA_CHECK_VERSION(1, 0, 0)
> +VAEncMiscParameterQuantization quantization_params;
> +#endif
>  // Per-sequence parameter structure (VAEncSequenceParameterBuffer*).
>  void   *codec_sequence_params;
>
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index d1427112ea..427fb6320e 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -72,6 +72,7 @@ typedef struct VAAPIEncodeH264Context {
>  int sei;
>  int profile;
>  int level;
> +int trellis;
>
>  // Derived settings.
>  int mb_width;
> @@ -1233,6 +1234,8 @@ static av_cold int 
> vaapi_encode_h264_init(AVCodecContext *avctx)
>  if (priv->qp > 0)
>  ctx

Re: [FFmpeg-devel] [PATCH] set AVFrame decode_error_flags in case of decoding error by h264dec

2019-06-12 Thread Marton Balint



On Wed, 12 Jun 2019, Michael Niedermayer wrote:


On Tue, Jun 11, 2019 at 03:21:41PM -0500, Amir Z wrote:

Thanks Michael Niedermayer for looking into this

What I am trying to solve is having a way to detect concealed decoding
errors by the caller to avcodec_receive_frame.

Should I add a general value e.g. #define
FF_DECODE_ERROR_DECODE_ERROR_OCCURRED 4 ?


I suggest
FF_DECODE_ERROR_CONCEALMENT_ACTIVE or something similar and then always
set this for all cases of error concealment
Its more informative than just knowing there was an error


Concealment is a consequence. Error_flags should refer to the cause. A 
generic UNKNOWN error seems much better to me if it is not feasible to 
determine the cause.


Regards,
Marton
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec: Add smpte2084 transfer function to videotoolboxenc

2019-06-12 Thread Michael Niedermayer
On Wed, Jun 12, 2019 at 09:44:26AM +0200, Nomis101 🐝 wrote:
> This patch will add support of the smpte2084 transfer function to 
> videotoolboxenc. kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ is available 
> on macOS 10.13 and up.
> This is on the bug tracker at https://trac.ffmpeg.org/ticket/7953
> 
> diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
> index 3665581283..e786ebe3a7 100644
> --- a/libavcodec/videotoolboxenc.c
> +++ b/libavcodec/videotoolboxenc.c
> @@ -909,6 +909,12 @@ static int get_cv_transfer_function(AVCodecContext 
> *avctx,
>  case AVCOL_TRC_SMPTE240M:
>  *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
>  break;
> +
> +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
> +case AVCOL_TRC_SMPTE2084:
> +*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
> +break;
> +#endif
> 
>  case AVCOL_TRC_GAMMA22:
>  gamma = 2.2;

git does not like this patch

Applying: avcodec: Add smpte2084 transfer function to videotoolboxenc
Using index info to reconstruct a base tree...
error: patch failed: libavcodec/videotoolboxenc.c:909
error: libavcodec/videotoolboxenc.c: patch does not apply
error: Did you hand edit your patch?
It does not apply to blobs recorded in its index.


[..]


-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH V2 1/2] libavfilter/dnn: add script to convert TensorFlow model (.pb) to native model (.model)

2019-06-12 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of
> Pedro Arthur
> Sent: Wednesday, June 12, 2019 3:43 AM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH V2 1/2] libavfilter/dnn: add script to
> convert TensorFlow model (.pb) to native model (.model)
> 
> Hi,
> 
> Em ter, 11 de jun de 2019 às 05:00, Guo, Yejun 
> escreveu:
> >
> >
> > there are three options for the place to put these .py scripts.
> > 1) at libavfilter/dnn/python/
> >   the point is to put all the dnn stuffs together
> > 2) at tools/python/
> >   the point is that there is already a .py script under tools/
> > 3) create a new project controlled by ffmpeg
> >   the point is that the python scripts should not be part of ffmpeg source
> tree.
> >   (btw, how to apply such sub project?)
> >
> I think option (2) is better as it is already there, even if (1) is
> more convenient.

thanks, there are two comments suggest to put under tools/, I'll put all the 
python scripts under tools/python if no more other comments.

> 
> 
> > My idea is that the script generates dnn native model file which is loaded 
> > by
> ffmpeg c code,
> > it is better to put the script within the ffmpeg source tree, and all the 
> > dnn
> stuffs would be better to put together, thanks.
> >
> > anyway, I'm open to any option, just to make the progress continue ...
> >
> > >
> > > ping for review, thanks.
> > >
> > > Here is my rough plan after this patch.
> > > - move dnn relative .h/.c from libavfilter to libavfilter/dnn, it is 
> > > expected
> there
> > > will be more files for dnn module (code for both model loading and
> execution).
> > > - add a layer for padding (tf.pad) for native mode and its fate test.
> > > - change the script to add tf.pad support, and so the native model and 
> > > the tf
> > > model of vf_sr will be the same.
> > >  in current implementation, the two models have a little difference, it
> makes
> > > the script not a general solution to convert tf model to native model.
> > > - add layer maximum and fate test. This layer appears in tf model, but 
> > > not in
> > > native model, of vf_sr.
> > > - introduce operand concept in native mode (both execution and model), to
> > > support data split and merge/concat in the network, such split/concat is
> very
> > > common.
> > >  it also makes possible to reuse memory for the intermediate data as the
> > > output of the hidden layers.
> > > - tune conv2d layer performance (it is very slow now) or add more layers 
> > > for
> > > native mode.
> > >
> > > ___
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel@ffmpeg.org
> > > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> > > To unsubscribe, visit link above, or email
> > > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> > ___
> > ffmpeg-devel mailing list
> > ffmpeg-devel@ffmpeg.org
> > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> >
> > To unsubscribe, visit link above, or email
> > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 2/2] fftools/ffmpeg: log skipped initial non-keyframes

2019-06-12 Thread Michael Niedermayer
On Sun, Jun 09, 2019 at 11:26:14AM +0200, Stephan Hilb wrote:
> > Repeated messages only get supressed if there is no interspaced
> > message if 2 things generate a message per frame, neither will be
> > supressed
> 
> So should I leave it at DEBUG level or implement a custom log_once?

i agree that the message might be usefull to be seen by the end user.
maybe as this is already discussed, the first could be a more vissible
level and the following then debug or lower level


> The "cur_dts invalid" debug message is currently being printed at least
> as often.

yes, this should be investigated and fixed by someone ...


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you fake or manipulate statistics in a paper in physics you will never
get a job again.
If you fake or manipulate statistics in a paper in medicin you will get
a job for life at the pharma industry.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] set AVFrame decode_error_flags in case of decoding error by h264dec

2019-06-12 Thread Michael Niedermayer
On Tue, Jun 11, 2019 at 03:21:41PM -0500, Amir Z wrote:
> Thanks Michael Niedermayer for looking into this
> 
> What I am trying to solve is having a way to detect concealed decoding
> errors by the caller to avcodec_receive_frame.
> 
> Should I add a general value e.g. #define
> FF_DECODE_ERROR_DECODE_ERROR_OCCURRED 4 ?

I suggest 
FF_DECODE_ERROR_CONCEALMENT_ACTIVE or something similar and then always
set this for all cases of error concealment
Its more informative than just knowing there was an error

also dont forget to increase minor version and add a entry to APICHanges

thx

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

Avoid a single point of failure, be that a person or equipment.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH] avcodec: Add smpte2084 transfer function to videotoolboxenc

2019-06-12 Thread Nomis101 🐝
This patch will add support of the smpte2084 transfer function to 
videotoolboxenc. kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ is available 
on macOS 10.13 and up.
This is on the bug tracker at https://trac.ffmpeg.org/ticket/7953

diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c
index 3665581283..e786ebe3a7 100644
--- a/libavcodec/videotoolboxenc.c
+++ b/libavcodec/videotoolboxenc.c
@@ -909,6 +909,12 @@ static int get_cv_transfer_function(AVCodecContext *avctx,
 case AVCOL_TRC_SMPTE240M:
 *transfer_fnc = kCVImageBufferTransferFunction_SMPTE_240M_1995;
 break;
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300
+case AVCOL_TRC_SMPTE2084:
+*transfer_fnc = kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ;
+break;
+#endif

 case AVCOL_TRC_GAMMA22:
 gamma = 2.2;


patch.bin
Description: application/macbinary
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH v2] vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables

2019-06-12 Thread Michael Niedermayer
On Tue, Jun 11, 2019 at 06:02:10PM -0400, greg Luce wrote:
> This is on the bug tracker at https://trac.ffmpeg.org/ticket/7947
> Created with the help of the excellent Calvin Walton 
> 
> and rewritten with the advice of the excellent Gyan 
> 
> ---
>  doc/filters.texi  | 24 +++-
>  libavfilter/vf_drawtext.c |  9 +
>  2 files changed, 32 insertions(+), 1 deletion(-)

git doesnt like this patch, probably messed up newlines

Applying: vf_drawtext: Add pkt_pos, pkt_duration, pkt_size as variables
error: corrupt patch at line 23
error: could not build fake ancestor


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

Dictatorship: All citizens are under surveillance, all their steps and
actions recorded, for the politicians to enforce control.
Democracy: All politicians are under surveillance, all their steps and
actions recorded, for the citizens to enforce control.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/mjpegdec: Check for non ls PAL8

2019-06-12 Thread Michael Niedermayer
On Sat, Jun 01, 2019 at 09:31:32PM +0200, Michael Niedermayer wrote:
> Fixes: Null-dereference READ in av_malloc
> Fixes: 
> 15002/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_THP_fuzzer-5643474625363968
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/mjpegdec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

will apply

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

What does censorship reveal? It reveals fear. -- Julian Assange


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/v4l2_m2m_dec: Fix memleak on ff_v4l2_m2m_codec_init() failure

2019-06-12 Thread Michael Niedermayer
On Sat, Jun 01, 2019 at 05:16:56PM +0200, Michael Niedermayer wrote:
> Fixes: 
> 13579/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_MPEG1_V4L2M2M_fuzzer-5753560726241280
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/v4l2_m2m_dec.c | 4 
>  1 file changed, 4 insertions(+)

will apply

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

Avoid a single point of failure, be that a person or equipment.


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH 3/4] tests/ref/fate/nuv-rtjpeg: Preserve the original timestamps

2019-06-12 Thread Michael Niedermayer
On Thu, May 30, 2019 at 04:03:59PM +0200, Michael Niedermayer wrote:
> The tests previously rounded the timestamps. Its better in a fate test to 
> preserve
> the data from the demuxer and decoder.
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  tests/fate/video.mak  |  2 +-
>  tests/ref/fate/nuv-rtjpeg | 18 +-
>  2 files changed, 10 insertions(+), 10 deletions(-)

will apply

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

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/interplayvideo: check decoding_map_size with video_data_size

2019-06-12 Thread Michael Niedermayer
On Sun, May 26, 2019 at 11:39:13PM +0200, Michael Niedermayer wrote:
> Fixes: Timeout (90543 ms -> 59 ms)
> Fixes: 
> 14721/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_INTERPLAY_VIDEO_fuzzer-5697492148027392
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/interplayvideo.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

will apply

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

Complexity theory is the science of finding the exact solution to an
approximation. Benchmarking OTOH is finding an approximation of the exact


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/pngdec: Check input space

2019-06-12 Thread Michael Niedermayer
On Wed, May 15, 2019 at 05:53:49PM +0200, Michael Niedermayer wrote:
> On Tue, May 14, 2019 at 08:52:27PM +0100, Kieran Kunhya wrote:
> > On Tue, 14 May 2019 at 20:42, Michael Niedermayer 
> > wrote:
> > 
> > > Fixes: Timeout (33sec -> 78ms)
> > > Fixes:
> > > 14668/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_LSCR_fuzzer-5767073352908800
> > >
> > > Found-by: continuous fuzzing process
> > > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by
> > > :
> > > Michael Niedermayer 
> > > ---
> > >  libavcodec/pngdec.c | 3 +++
> > >  1 file changed, 3 insertions(+)
> > >
> > > diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
> > > index 6a681be29d..78988d9e75 100644
> > > --- a/libavcodec/pngdec.c
> > > +++ b/libavcodec/pngdec.c
> > > @@ -1535,6 +1535,9 @@ static int decode_frame_lscr(AVCodecContext *avctx,
> > >  AVFrame *frame = data;
> > >  int ret, nb_blocks, offset = 0;
> > >
> > > +if (avpkt->size < 2)
> > > +return AVERROR_INVALIDDATA;
> > > +
> > >
> > 
> > Why not 1?
> 
> because the code reads 2 bytes next:
> 
> nb_blocks = bytestream2_get_le16(gb);
> 
> 
> > Or maybe 3?
> > Or maybe 42?
> 
> Its not checking for 3 or 42 or another number because the smallest
> valid frame that our decoder accepts is 2 bytes.
> In case you have a specification for LSCR, that would be interresting
> to read to see if it contains more constraints which would lead to a
> larger minimum size

will apply the patch in  the next days unless there are objections


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Re: [FFmpeg-devel] [PATCH] avcodec/h264_parse: Use 64bit for expectedpoc

2019-06-12 Thread Michael Niedermayer
On Mon, May 27, 2019 at 01:10:00AM -0300, James Almer wrote:
> On 5/23/2019 8:25 PM, Michael Niedermayer wrote:
> > Fixes: signed integer overflow: -2142516591 + -267814575 cannot be 
> > represented in type 'int'
> > Fixes: 
> > 14450/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_H264_fuzzer-5716105319940096
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/h264_parse.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/h264_parse.c b/libavcodec/h264_parse.c
> > index a075443d17..cc72a1b263 100644
> > --- a/libavcodec/h264_parse.c
> > +++ b/libavcodec/h264_parse.c
> > @@ -301,7 +301,8 @@ int ff_h264_init_poc(int pic_field_poc[2], int *pic_poc,
> >  if (picture_structure == PICT_FRAME)
> >  field_poc[1] += pc->delta_poc_bottom;
> >  } else if (sps->poc_type == 1) {
> > -int abs_frame_num, expected_delta_per_poc_cycle, expectedpoc;
> > +int abs_frame_num, expected_delta_per_poc_cycle;
> 
> expected_delta_per_poc_cycle should also be int64_t. If you look at the
> code below this chunk, it's set with the sum of all
> sps->offset_for_ref_frame[] values (up to 255 of them), each of which
> can be as high as INT32_MAX, so might as well change it now instead of
> waiting for the fuzzer to trip on it.

sure, will push with this change

Thanks

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

When the tyrant has disposed of foreign enemies by conquest or treaty, and
there is nothing more to fear from them, then he is always stirring up
some war or other, in order that the people may require a leader. -- Plato


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

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: add support for AVC Trellis

2019-06-12 Thread Linjie Fu
Add support for VAAPI AVC Trellis Quantization with limitation:
- VA-API version >= (1, 0, 0)

Use option "-trellis off/I/P/B" to disable or enable Trellis
quantization for I/P/B frames.

Signed-off-by: Linjie Fu 
---
[v2]: Since nonstandard struct for VAEncMiscParameterQuantization is
fixed: https://github.com/intel/libva/issues/265
update patch based on:
http://git.ffmpeg.org/gitweb/ffmpeg.git/commit/2880a32c668023bfee4745095c885450d547ae45
 libavcodec/vaapi_encode.c  | 48 ++
 libavcodec/vaapi_encode.h  |  9 +--
 libavcodec/vaapi_encode_h264.c |  9 +++
 3 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index dd2a24de04..fbfbe78c6b 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1671,6 +1671,48 @@ rc_mode_found:
 return 0;
 }
 
+static av_cold int vaapi_encode_init_quantization(AVCodecContext *avctx)
+{
+#if VA_CHECK_VERSION(1, 0, 0)
+VAAPIEncodeContext *ctx = avctx->priv_data;
+VAStatus vas;
+VAConfigAttrib attr = { VAConfigAttribEncQuantization };
+int trellis = ctx->trellis;
+
+vas = vaGetConfigAttributes(ctx->hwctx->display,
+ctx->va_profile,
+ctx->va_entrypoint,
+&attr, 1);
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to query quantization "
+   "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR_EXTERNAL;
+}
+
+if (attr.value == VA_ATTRIB_NOT_SUPPORTED ||
+attr.value == VA_ENC_QUANTIZATION_NONE) {
+av_log(avctx, AV_LOG_WARNING, "Special Quantization attribute is not "
+"supported: will use default quantization.\n");
+} else if (attr.value == VA_ENC_QUANTIZATION_TRELLIS_SUPPORTED){
+av_log(avctx, AV_LOG_VERBOSE, "Quantization Trellis supported.\n");
+
+ctx->quantization_params = (VAEncMiscParameterQuantization) {
+.quantization_flags.value = trellis,
+};
+
+vaapi_encode_add_global_param(avctx,
+  VAEncMiscParameterTypeQuantization,
+  &ctx->quantization_params,
+  sizeof(ctx->quantization_params));
+}
+#else
+av_log(avctx, AV_LOG_WARNING, "The encode quantization option (Trellis) is 
"
+   "not supported with this VAAPI version.\n");
+#endif
+
+return 0;
+}
+
 static av_cold int vaapi_encode_init_gop_structure(AVCodecContext *avctx)
 {
 VAAPIEncodeContext *ctx = avctx->priv_data;
@@ -2132,6 +2174,12 @@ av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
 if (err < 0)
 goto fail;
 
+if (ctx->trellis) {
+err = vaapi_encode_init_quantization(avctx);
+if (err < 0)
+goto fail;
+}
+
 if (avctx->compression_level >= 0) {
 err = vaapi_encode_init_quality(avctx);
 if (err < 0)
diff --git a/libavcodec/vaapi_encode.h b/libavcodec/vaapi_encode.h
index eeec06036b..b24735da59 100644
--- a/libavcodec/vaapi_encode.h
+++ b/libavcodec/vaapi_encode.h
@@ -37,7 +37,7 @@ struct VAAPIEncodePicture;
 
 enum {
 MAX_CONFIG_ATTRIBUTES  = 4,
-MAX_GLOBAL_PARAMS  = 4,
+MAX_GLOBAL_PARAMS  = 5,
 MAX_DPB_SIZE   = 16,
 MAX_PICTURE_REFERENCES = 2,
 MAX_REORDER_DELAY  = 16,
@@ -220,6 +220,9 @@ typedef struct VAAPIEncodeContext {
 // Packed headers which will actually be sent.
 unsigned intva_packed_headers;
 
+// Quantization mode
+int trellis;
+
 // Configuration attributes to use when creating va_config.
 VAConfigAttrib  config_attributes[MAX_CONFIG_ATTRIBUTES];
 int  nb_config_attributes;
@@ -256,7 +259,9 @@ typedef struct VAAPIEncodeContext {
 #if VA_CHECK_VERSION(0, 36, 0)
 VAEncMiscParameterBufferQualityLevel quality_params;
 #endif
-
+#if VA_CHECK_VERSION(1, 0, 0)
+VAEncMiscParameterQuantization quantization_params;
+#endif
 // Per-sequence parameter structure (VAEncSequenceParameterBuffer*).
 void   *codec_sequence_params;
 
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index d1427112ea..427fb6320e 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -72,6 +72,7 @@ typedef struct VAAPIEncodeH264Context {
 int sei;
 int profile;
 int level;
+int trellis;
 
 // Derived settings.
 int mb_width;
@@ -1233,6 +1234,8 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext 
*avctx)
 if (priv->qp > 0)
 ctx->explicit_qp = priv->qp;
 
+ctx->trellis = priv->trellis;
+
 return ff_vaapi_encode_init(avctx);
 }
 
@@ -1263,6 +1266,12 @@ static const AVOption vaapi_encode_h264_options[] = {
 { "cabac", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, INT_MIN, INT_MAX, 
FLAGS, "coder" },
 { "vlc",   N