[FFmpeg-devel] [PATCH] lavfi: add sobel, prewitt, roberts filters

2018-06-29 Thread Danil Iashchenko
Add opencl version of sobel, prewitt, roberts filters.
---
Fixed, Thanks!
Docs to all opencl-based filters will be added in another patch.

 configure   |   3 +
 libavfilter/Makefile|   8 +-
 libavfilter/allfilters.c|   3 +
 libavfilter/opencl/convolution.cl   |  82 +
 libavfilter/vf_convolution_opencl.c | 237 +---
 5 files changed, 285 insertions(+), 48 deletions(-)

diff --git a/configure b/configure
index 6ad5ce8..2c6360d 100755
--- a/configure
+++ b/configure
@@ -3372,12 +3372,14 @@ perspective_filter_deps="gpl"
 phase_filter_deps="gpl"
 pp7_filter_deps="gpl"
 pp_filter_deps="gpl postproc"
+prewitt_opencl_filter_deps="opencl"
 procamp_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
 program_opencl_filter_deps="opencl"
 pullup_filter_deps="gpl"
 removelogo_filter_deps="avcodec avformat swscale"
 repeatfields_filter_deps="gpl"
 resample_filter_deps="avresample"
+roberts_opencl_filter_deps="opencl"
 rubberband_filter_deps="librubberband"
 sab_filter_deps="gpl swscale"
 scale2ref_filter_deps="swscale"
@@ -3396,6 +3398,7 @@ showspectrumpic_filter_deps="avcodec"
 showspectrumpic_filter_select="fft"
 signature_filter_deps="gpl avcodec avformat"
 smartblur_filter_deps="gpl swscale"
+sobel_opencl_filter_deps="opencl"
 sofalizer_filter_deps="libmysofa avcodec"
 sofalizer_filter_select="fft"
 spectrumsynth_filter_deps="avcodec"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 34333aa..aa94a6d 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -171,7 +171,7 @@ OBJS-$(CONFIG_COLORMATRIX_FILTER)+= 
vf_colormatrix.o
 OBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o colorspace.o 
colorspacedsp.o
 OBJS-$(CONFIG_CONVOLUTION_FILTER)+= vf_convolution.o
 OBJS-$(CONFIG_CONVOLUTION_OPENCL_FILTER) += vf_convolution_opencl.o 
opencl.o \
-   opencl/convolution.o
+opencl/convolution.o
 OBJS-$(CONFIG_CONVOLVE_FILTER)   += vf_convolve.o framesync.o
 OBJS-$(CONFIG_COPY_FILTER)   += vf_copy.o
 OBJS-$(CONFIG_COREIMAGE_FILTER)  += vf_coreimage.o
@@ -294,6 +294,8 @@ OBJS-$(CONFIG_PP_FILTER) += vf_pp.o
 OBJS-$(CONFIG_PP7_FILTER)+= vf_pp7.o
 OBJS-$(CONFIG_PREMULTIPLY_FILTER)+= vf_premultiply.o framesync.o
 OBJS-$(CONFIG_PREWITT_FILTER)+= vf_convolution.o
+OBJS-$(CONFIG_PREWITT_OPENCL_FILTER) += vf_convolution_opencl.o 
opencl.o \
+opencl/convolution.o
 OBJS-$(CONFIG_PROCAMP_VAAPI_FILTER)  += vf_procamp_vaapi.o vaapi_vpp.o
 OBJS-$(CONFIG_PROGRAM_OPENCL_FILTER) += vf_program_opencl.o opencl.o 
framesync.o
 OBJS-$(CONFIG_PSEUDOCOLOR_FILTER)+= vf_pseudocolor.o
@@ -310,6 +312,8 @@ OBJS-$(CONFIG_REMOVELOGO_FILTER) += bbox.o 
lswsutils.o lavfutils.o v
 OBJS-$(CONFIG_REPEATFIELDS_FILTER)   += vf_repeatfields.o
 OBJS-$(CONFIG_REVERSE_FILTER)+= f_reverse.o
 OBJS-$(CONFIG_ROBERTS_FILTER)+= vf_convolution.o
+OBJS-$(CONFIG_ROBERTS_OPENCL_FILTER) += vf_convolution_opencl.o 
opencl.o \
+opencl/convolution.o
 OBJS-$(CONFIG_ROTATE_FILTER) += vf_rotate.o
 OBJS-$(CONFIG_SAB_FILTER)+= vf_sab.o
 OBJS-$(CONFIG_SCALE_FILTER)  += vf_scale.o scale.o
@@ -338,6 +342,8 @@ OBJS-$(CONFIG_SIGNALSTATS_FILTER)+= 
vf_signalstats.o
 OBJS-$(CONFIG_SIGNATURE_FILTER)  += vf_signature.o
 OBJS-$(CONFIG_SMARTBLUR_FILTER)  += vf_smartblur.o
 OBJS-$(CONFIG_SOBEL_FILTER)  += vf_convolution.o
+OBJS-$(CONFIG_SOBEL_OPENCL_FILTER)   += vf_convolution_opencl.o 
opencl.o \
+opencl/convolution.o
 OBJS-$(CONFIG_SPLIT_FILTER)  += split.o
 OBJS-$(CONFIG_SPP_FILTER)+= vf_spp.o
 OBJS-$(CONFIG_SRCNN_FILTER)  += vf_srcnn.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index e07fe67..f8bf177 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -282,6 +282,7 @@ extern AVFilter ff_vf_pp;
 extern AVFilter ff_vf_pp7;
 extern AVFilter ff_vf_premultiply;
 extern AVFilter ff_vf_prewitt;
+extern AVFilter ff_vf_prewitt_opencl;
 extern AVFilter ff_vf_procamp_vaapi;
 extern AVFilter ff_vf_program_opencl;
 extern AVFilter ff_vf_pseudocolor;
@@ -298,6 +299,7 @@ extern AVFilter ff_vf_removelogo;
 extern AVFilter ff_vf_repeatfields;
 extern AVFilter ff_vf_reverse;
 extern AVFilter ff_vf_roberts;
+extern AVFilter ff_vf_roberts_opencl;
 extern AVFilter ff_vf_rotate;
 extern AVFilter ff_vf_sab;
 extern AVFilter ff_vf_scale;
@@ -326,6 +328,7 @@ extern AVFilter ff_vf_signalstats;
 extern AVFilter ff_vf_signature;
 

Re: [FFmpeg-devel] [PATCH] avcodec/vc1_block: Fix mqaunt check for negative values

2018-06-29 Thread Michael Niedermayer
On Fri, Jun 29, 2018 at 12:01:42PM +0200, Jerome Borsboom wrote:
> > Fixes: out of array access
> > Fixes: ffmpeg_bof_4.avi
> > Fixes: ffmpeg_bof_5.avi
> > Fixes: ffmpeg_bof_6.avi
> > 
> > Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan 
> > Caciulescu with AFLSmart
> > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/vc1_block.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
> > index 5427de4ec6..74d5e27803 100644
> > --- a/libavcodec/vc1_block.c
> > +++ b/libavcodec/vc1_block.c
> > @@ -204,7 +204,7 @@ static void vc1_put_blocks_clamped(VC1Context *v, int 
> > put_signed)
> >  if ((edges&8) &&   \
> >  s->mb_y == ((s->mb_height >> v->field_mode) - 1))  \
> >  mquant = -v->altpq;\
> > -if (!mquant || mquant > 31) {  \
> > +if (!mquant || mquant > 31 || mquant < -31) {  
> > \
> >  av_log(v->s.avctx, AV_LOG_ERROR,   \
> > "Overriding invalid mquant %d\n", mquant);  \
> >  mquant = 1;\
> > -- 
> > 2.18.0
> 
> LGTM

will apply


> 
> However, we could consider to use saturation for invalid mquant values.
> 
> Something like:
> 
> mquant = mquant ? av_clip(mquant, -31, 31) : 1;

yes, it probably could be slightly better in some rare cases where
the decoder isnt totally confused and only produces random giberish anymore


> 
> 
> I would prefer to catch illegal values at the earliest occasion. Illegal
> v->pq or v->altpq should be catched earlier, in my view. A the current
> implementation is technically correct, this can wait for another time.

yes, i agree

thx

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

No snowflake in an avalanche ever feels responsible. -- Voltaire


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


Re: [FFmpeg-devel] [PATCH] libavformat/yuv4mpeg: Add color range support for Y4M Add color_range support in Y4M.

2018-06-29 Thread Michael Niedermayer
On Thu, Jun 28, 2018 at 04:32:01PM +0800, Wang Cao wrote:
> Set pixel format and color_range for YUVJ pixel formats. Also set
> color_range based on AVFormatContext.
> 
> Signed-off-by: Wang Cao 
> ---
>  libavformat/yuv4mpegdec.c |  8 
>  libavformat/yuv4mpegenc.c | 37 +++--
>  2 files changed, 43 insertions(+), 2 deletions(-)

will apply

maybe you want to also add a field that stores the "encoder" metadata
or all metadata ?

thanks

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

The educated differ from the uneducated as much as the living from the
dead. -- Aristotle 


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


Re: [FFmpeg-devel] [PATCH] ffmpeg.c: allow ffmpeg to output stats for each video stream

2018-06-29 Thread Michael Niedermayer
On Fri, Jun 22, 2018 at 04:03:38PM +0800, Wang Cao wrote:
> Make ffmpeg to output stats for each video/audio streams and each ouptut file 
> ffmpeg output log in print_report. The report of video/audio sizes is clear 
> now as previously all output video/audio sizes were combined to report and it 
> is unclear such stats is for one output files or aggregates for all output 
> files.
> 
> Signed-off-by: Wang Cao 
> ---
>  fftools/ffmpeg.c | 52 +---
>  1 file changed, 36 insertions(+), 16 deletions(-)

This changes the printed values
./ffmpeg -i ~/videos/matrixbench_mpeg2.mpg -qscale 2  -vframes 3 -an  test2.avi

frame=3 fps=0.0 q=2.0 Lsize=  51kB time=00:00:00.12 
bitrate=3495.7kbits/s speed=  12x
video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: 11.128063%

vs.

frame=3 fps=0.0 q=2.0 Lsize=  57kB time=00:00:00.12 
bitrate=3884.7kbits/s speed=11.2x
video:51kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing 
overhead: 11.128063%

the file is the same 

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

If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.


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


[FFmpeg-devel] [PATCH] fftools/ffmpeg_opt: Add -toeof option to stop reading at position relative to EOF

2018-06-29 Thread morten . with
From: withmorten 

Fixes ticket #7155: Add option to stop writing at position relative to EOF

Signed-off-by: Morten With 
---
 doc/ffmpeg.texi  |  6 ++
 fftools/ffmpeg.h |  1 +
 fftools/ffmpeg_opt.c | 31 +++
 3 files changed, 38 insertions(+)

diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 3717f22d42..f627f0e8a5 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -488,6 +488,12 @@ see @ref{time duration syntax,,the Time duration section 
in the ffmpeg-utils(1)
 
 -to and -t are mutually exclusive and -t has priority.
 
+@item -toeof @var{position} (@emph{input})
+Stop reading the input at @var{position} relative to the "end of file". That 
is,
+larger negative values are later in the file, 0 is at EOF.
+
+-toeof and -to, as well as -toeof and -t, are mutually exclusive, and -to, or 
respectively -t, has priority.
+
 @item -fs @var{limit_size} (@emph{output})
 Set the file size limit, expressed in bytes. No further chunk of bytes is 
written
 after the limit is exceeded. The size of the output file is slightly more than 
the
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index eb1eaf6363..70026b376e 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -149,6 +149,7 @@ typedef struct OptionsContext {
 
 int64_t recording_time;
 int64_t stop_time;
+int64_t stop_time_eof;
 uint64_t limit_filesize;
 float mux_preload;
 float mux_max_delay;
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 58ec13e5a8..30fd28ec3a 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -159,6 +159,7 @@ static void init_options(OptionsContext *o)
 memset(o, 0, sizeof(*o));
 
 o->stop_time = INT64_MAX;
+o->stop_time_eof  = AV_NOPTS_VALUE;
 o->mux_max_delay  = 0.7;
 o->start_time = AV_NOPTS_VALUE;
 o->start_time_eof = AV_NOPTS_VALUE;
@@ -979,6 +980,16 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 av_log(NULL, AV_LOG_WARNING, "-t and -to cannot be used together; 
using -t.\n");
 }
 
+if (o->stop_time_eof != AV_NOPTS_VALUE && o->recording_time != INT64_MAX) {
+o->stop_time_eof = AV_NOPTS_VALUE;
+av_log(NULL, AV_LOG_WARNING, "-t and -toeof cannot be used together; 
using -t for %s.\n", filename);
+}
+
+if (o->stop_time != INT64_MAX && o->stop_time_eof != AV_NOPTS_VALUE) {
+o->stop_time_eof = AV_NOPTS_VALUE;
+av_log(NULL, AV_LOG_WARNING, "-to and -toeof cannot be used together; 
using -to for %s.\n", filename);
+}
+
 if (o->stop_time != INT64_MAX && o->recording_time == INT64_MAX) {
 int64_t start_time = o->start_time == AV_NOPTS_VALUE ? 0 : 
o->start_time;
 if (o->stop_time <= start_time) {
@@ -1122,6 +1133,24 @@ static int open_input_file(OptionsContext *o, const char 
*filename)
 } else
 av_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s 
not known\n", filename);
 }
+
+if (o->stop_time_eof != AV_NOPTS_VALUE) {
+if (o->stop_time_eof >= 0) {
+av_log(NULL, AV_LOG_ERROR, "-toeof value must be negative; 
aborting\n");
+exit_program(1);
+}
+if (ic->duration > 0) {
+o->recording_time = ic->duration + o->stop_time_eof;
+if (o->start_time != AV_NOPTS_VALUE) {
+o->recording_time -= o->start_time;
+if (o->recording_time <= 0) {
+av_log(NULL, AV_LOG_WARNING, "-toeof value seeks to before 
start of file %s; ignored\n", filename);
+o->recording_time += o->start_time;
+}
+}
+} else
+av_log(NULL, AV_LOG_WARNING, "Cannot use -toeof, duration of %s 
not known\n", filename);
+}
 timestamp = (o->start_time == AV_NOPTS_VALUE) ? 0 : o->start_time;
 /* add the stream start time */
 if (!o->seek_timestamp && ic->start_time != AV_NOPTS_VALUE)
@@ -3347,6 +3376,8 @@ const OptionDef options[] = {
 "duration" },
 { "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT | 
OPT_OUTPUT,  { .off = OFFSET(stop_time) },
 "record or transcode stop time", "time_stop" },
+{ "toeof",  HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT, { .off = 
OFFSET(stop_time_eof) },
+"input stop time relative to EOF", "time_stop" },
 { "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET | OPT_OUTPUT, { .off 
= OFFSET(limit_filesize) },
 "set the limit file size in bytes", "limit_size" },
 { "ss", HAS_ARG | OPT_TIME | OPT_OFFSET |
-- 
2.17.1

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


Re: [FFmpeg-devel] [PATCH] avcodec/vc1_block: Fix mqaunt check for negative values

2018-06-29 Thread Jerome Borsboom
> Fixes: out of array access
> Fixes: ffmpeg_bof_4.avi
> Fixes: ffmpeg_bof_5.avi
> Fixes: ffmpeg_bof_6.avi
> 
> Found-by: Thuan Pham, Marcel Böhme, Andrew Santosa and Alexandru Razvan 
> Caciulescu with AFLSmart
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vc1_block.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vc1_block.c b/libavcodec/vc1_block.c
> index 5427de4ec6..74d5e27803 100644
> --- a/libavcodec/vc1_block.c
> +++ b/libavcodec/vc1_block.c
> @@ -204,7 +204,7 @@ static void vc1_put_blocks_clamped(VC1Context *v, int 
> put_signed)
>  if ((edges&8) &&   \
>  s->mb_y == ((s->mb_height >> v->field_mode) - 1))  \
>  mquant = -v->altpq;\
> -if (!mquant || mquant > 31) {  \
> +if (!mquant || mquant > 31 || mquant < -31) {
>   \
>  av_log(v->s.avctx, AV_LOG_ERROR,   \
> "Overriding invalid mquant %d\n", mquant);  \
>  mquant = 1;\
> -- 
> 2.18.0

LGTM

However, we could consider to use saturation for invalid mquant values.

Something like:

mquant = mquant ? av_clip(mquant, -31, 31) : 1;


I would prefer to catch illegal values at the earliest occasion. Illegal
v->pq or v->altpq should be catched earlier, in my view. A the current
implementation is technically correct, this can wait for another time.


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