[FFmpeg-devel] [PATCH] avcodec/wmv2dec: Check input bits vs. coded MBs

2019-04-30 Thread Michael Niedermayer
Fixes: Timeout (94sec ->8sec)
Fixes: 
14387/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WMV2_fuzzer-5723546887651328

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

diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index 124dfdb7e0..afa65478e3 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -33,6 +33,7 @@
 static int parse_mb_skip(Wmv2Context *w)
 {
 int mb_x, mb_y;
+int coded_mb_count = 0;
 MpegEncContext *const s = >s;
 uint32_t *const mb_type = s->current_picture_ptr->mb_type;
 
@@ -83,6 +84,14 @@ static int parse_mb_skip(Wmv2Context *w)
 }
 break;
 }
+
+for (mb_y = 0; mb_y < s->mb_height; mb_y++)
+for (mb_x = 0; mb_x < s->mb_width; mb_x++)
+coded_mb_count += !IS_SKIP(mb_type[mb_y * s->mb_stride + mb_x]);
+
+if (coded_mb_count > get_bits_left(>gb))
+return AVERROR_INVALIDDATA;
+
 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] libavcodec/vp9: fix ref-frame size judging method

2019-04-30 Thread Ronald S. Bultje
Hi,

On Mon, Apr 29, 2019 at 10:03 PM Yan Cen  wrote:

> From: Yan Cen 
>
> There is no need all reference frame demension is valid in libvpx.


I think you're touching on a bigger issue here: libvpx allows having
invalid (or even missing) references, and we don't. Note that this means we
lack per-block reference validity checks in the block reconstruction code,
and your patch is not adding them, thus exposing us to potential security
issues there.

Ronald
___
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] avformat/mov: Populate packet duration using `stts` atom instead of guessing.

2019-04-30 Thread fumoboy007
Oops. Will fix.

> On Apr 30, 2019, at 10:58 AM, Michael Niedermayer  
> wrote:
> breaks "make fate"
> 
> make: *** [fate-filter-fps-cfr] Error 1
> make: *** [fate-filter-fps-r] Error 1
> make: *** [fate-filter-fps] Error 1
> make: *** [fate-copy-trac236] Error 1
> make: *** [fate-gaplessenc-itunes-to-ipod-aac] Error 1
> make: *** [fate-mov-zombie] Error 1
> make: *** [fate-mov-aac-2048-priming] Error 1
___
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/h263dec: Fixed VA API, VDPAU, and VideoToolbox hardware acceleration due to missing `hw_configs` property.

2019-04-30 Thread fumoboy007
Ah, I see.

> On Apr 29, 2019, at 4:52 PM, Michael Niedermayer  
> wrote:
> 
> On Mon, Apr 29, 2019 at 02:16:53PM -0700, fumoboy...@me.com wrote:
>> Btw, what’s the difference between `h263` and `h263p`?
> 
> Its described probably best with the encoders:
>.name   = "h263p",
>.long_name  = NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 
> version 2"),
> vs.
>.name   = "h263",
>.long_name  = NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
> 
> 
> [...]
> -- 
> 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.
> ___
> 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] avfilter/vf_tonemap: add slice threading

2019-04-30 Thread Paul B Mahol
On 4/30/19, Vittorio Giovara  wrote:
> On Tue, Apr 30, 2019 at 6:07 AM Paul B Mahol  wrote:
>
>> Signed-off-by: Paul B Mahol 
>> ---
>>  libavfilter/vf_tonemap.c | 39 ++-
>>  1 file changed, 34 insertions(+), 5 deletions(-)
>>
>> diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
>> index efd4af5466..d1728c8513 100644
>> --- a/libavfilter/vf_tonemap.c
>> +++ b/libavfilter/vf_tonemap.c
>> @@ -191,10 +191,36 @@ static void tonemap(TonemapContext *s, AVFrame *out,
>> const AVFrame *in,
>>  *b_out *= sig / sig_orig;
>>  }
>>
>> +typedef struct ThreadData {
>> +AVFrame *in, *out;
>> +const AVPixFmtDescriptor *desc;
>> +double peak;
>> +} ThreadData;
>> +
>> +static int tonemap_slice(AVFilterContext *ctx, void *arg, int jobnr, int
>> nb_jobs)
>> +{
>> +TonemapContext *s = ctx->priv;
>> +ThreadData *td = arg;
>> +AVFrame *in = td->in;
>> +AVFrame *out = td->out;
>> +const AVPixFmtDescriptor *desc = td->desc;
>> +const int slice_start = (in->height * jobnr) / nb_jobs;
>> +const int slice_end = (in->height * (jobnr+1)) / nb_jobs;
>> +double peak = td->peak;
>> +
>> +for (int y = slice_start; y < slice_end; y++)
>> +for (int x = 0; x < out->width; x++)
>> +tonemap(s, out, in, desc, x, y, peak);
>> +
>> +return 0;
>> +}
>> +
>>  static int filter_frame(AVFilterLink *link, AVFrame *in)
>>  {
>> -TonemapContext *s = link->dst->priv;
>> -AVFilterLink *outlink = link->dst->outputs[0];
>> +AVFilterContext *ctx = link->dst;
>> +TonemapContext *s = ctx->priv;
>> +AVFilterLink *outlink = ctx->outputs[0];
>> +ThreadData td;
>>  AVFrame *out;
>>  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
>>  const AVPixFmtDescriptor *odesc =
>> av_pix_fmt_desc_get(outlink->format);
>> @@ -245,9 +271,11 @@ static int filter_frame(AVFilterLink *link, AVFrame
>> *in)
>>  }
>>
>>  /* do the tone map */
>> -for (y = 0; y < out->height; y++)
>> -for (x = 0; x < out->width; x++)
>> -tonemap(s, out, in, desc, x, y, peak);
>> +td.out = out;
>> +td.in = in;
>> +td.desc = desc;
>> +td.peak = peak;
>> +ctx->internal->execute(ctx, tonemap_slice, , NULL,
>> FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
>>
>
> why this FFMIN()?

So that it does not break up if user set number of threads more than height.

>
>  /* copy/generate alpha if needed */
>>  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags &
>> AV_PIX_FMT_FLAG_ALPHA) {
>> @@ -315,4 +343,5 @@ AVFilter ff_vf_tonemap = {
>>  .priv_class  = _class,
>>  .inputs  = tonemap_inputs,
>>  .outputs = tonemap_outputs,
>> +.flags   = AVFILTER_FLAG_SLICE_THREADS,
>>  };
>> --
>>
>
> lgtm
> --
> Vittorio
> ___
> 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] avfilter/f_realtime: add option to scale speed

2019-04-30 Thread Paul B Mahol
On 12/25/18, Moritz Barsnick  wrote:
> Signed-off-by: Moritz Barsnick 
> ---
> This adds two double precision divisions per frame, which seems acceptable.
>
> I'm not sure scaling the limit by the factor is the correct idea.  It feels
> right regarding the discontinuities, but not according to the limit option's
> description.
>

What is status of this patch?
___
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] avfilter/vf_tonemap: add slice threading

2019-04-30 Thread Vittorio Giovara
On Tue, Apr 30, 2019 at 6:07 AM Paul B Mahol  wrote:

> Signed-off-by: Paul B Mahol 
> ---
>  libavfilter/vf_tonemap.c | 39 ++-
>  1 file changed, 34 insertions(+), 5 deletions(-)
>
> diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
> index efd4af5466..d1728c8513 100644
> --- a/libavfilter/vf_tonemap.c
> +++ b/libavfilter/vf_tonemap.c
> @@ -191,10 +191,36 @@ static void tonemap(TonemapContext *s, AVFrame *out,
> const AVFrame *in,
>  *b_out *= sig / sig_orig;
>  }
>
> +typedef struct ThreadData {
> +AVFrame *in, *out;
> +const AVPixFmtDescriptor *desc;
> +double peak;
> +} ThreadData;
> +
> +static int tonemap_slice(AVFilterContext *ctx, void *arg, int jobnr, int
> nb_jobs)
> +{
> +TonemapContext *s = ctx->priv;
> +ThreadData *td = arg;
> +AVFrame *in = td->in;
> +AVFrame *out = td->out;
> +const AVPixFmtDescriptor *desc = td->desc;
> +const int slice_start = (in->height * jobnr) / nb_jobs;
> +const int slice_end = (in->height * (jobnr+1)) / nb_jobs;
> +double peak = td->peak;
> +
> +for (int y = slice_start; y < slice_end; y++)
> +for (int x = 0; x < out->width; x++)
> +tonemap(s, out, in, desc, x, y, peak);
> +
> +return 0;
> +}
> +
>  static int filter_frame(AVFilterLink *link, AVFrame *in)
>  {
> -TonemapContext *s = link->dst->priv;
> -AVFilterLink *outlink = link->dst->outputs[0];
> +AVFilterContext *ctx = link->dst;
> +TonemapContext *s = ctx->priv;
> +AVFilterLink *outlink = ctx->outputs[0];
> +ThreadData td;
>  AVFrame *out;
>  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
>  const AVPixFmtDescriptor *odesc =
> av_pix_fmt_desc_get(outlink->format);
> @@ -245,9 +271,11 @@ static int filter_frame(AVFilterLink *link, AVFrame
> *in)
>  }
>
>  /* do the tone map */
> -for (y = 0; y < out->height; y++)
> -for (x = 0; x < out->width; x++)
> -tonemap(s, out, in, desc, x, y, peak);
> +td.out = out;
> +td.in = in;
> +td.desc = desc;
> +td.peak = peak;
> +ctx->internal->execute(ctx, tonemap_slice, , NULL,
> FFMIN(in->height, ff_filter_get_nb_threads(ctx)));
>

why this FFMIN()?

 /* copy/generate alpha if needed */
>  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags &
> AV_PIX_FMT_FLAG_ALPHA) {
> @@ -315,4 +343,5 @@ AVFilter ff_vf_tonemap = {
>  .priv_class  = _class,
>  .inputs  = tonemap_inputs,
>  .outputs = tonemap_outputs,
> +.flags   = AVFILTER_FLAG_SLICE_THREADS,
>  };
> --
>

lgtm
-- 
Vittorio
___
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/truemotion2: Fix 2 integer overflows in tm2_update_block()

2019-04-30 Thread Michael Niedermayer
On Sat, Apr 20, 2019 at 02:22:05AM +0200, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483648 + -1 cannot be represented in 
> type 'int'
> Fixes: 
> 14107/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEMOTION2_fuzzer-5694078680825856
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/truemotion2.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

will apply

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

He who knows, does not speak. He who speaks, does not know. -- Lao Tsu


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 1/2] avcodec/agm: Check output size before allocation

2019-04-30 Thread Michael Niedermayer
On Wed, Apr 24, 2019 at 10:35:09PM +0200, Michael Niedermayer wrote:
> Fixes: OOM
> Fixes: 
> 14198/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5723579234123776
> 
> Found-by: continuous fuzzing process 
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/agm.c | 3 +++
>  1 file changed, 3 insertions(+)

will apply

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

Asymptotically faster algorithms should always be preferred if you have
asymptotical amounts of data


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 1/2] avcodec/cinepak: Check slice_size before allocating image

2019-04-30 Thread Michael Niedermayer
On Sun, Apr 28, 2019 at 04:53:53PM +0200, Tomas Härdin wrote:
> sön 2019-04-28 klockan 11:42 +0200 skrev Michael Niedermayer:
> > Fixes: Timeout (16sec -> 125msec)
> > Fixes: 
> > 14283/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CINEPAK_fuzzer-5742851457024000
> > 
> > Found-by: continuous fuzzing process 
> > https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> > > Signed-off-by: Michael Niedermayer 
> > ---
> >  libavcodec/cinepak.c | 7 +++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c
> > index 9b0077402f..d26c505222 100644
> > --- a/libavcodec/cinepak.c
> > +++ b/libavcodec/cinepak.c
> > @@ -353,6 +353,13 @@ static int cinepak_predecode_check (CinepakContext *s)
> >  if (s->size < 10 + s->sega_film_skip_bytes + num_strips * 12)
> >  return AVERROR_INVALIDDATA;
> >  
> > +if (num_strips) {
> > +uint8_t *data = s->data + 10 + s->sega_film_skip_bytes;
> > +int strip_size = AV_RB24 (data + 1);
> 
> Should be OK since the check just before this ensures data[0..11] are
> valid

will apply patch

thx

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

Never trust a computer, one day, it may think you are the virus. -- Compn


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] avformat/mov: Populate packet duration using `stts` atom instead of guessing.

2019-04-30 Thread Michael Niedermayer
On Mon, Apr 29, 2019 at 03:50:27PM -0700, fumoboy007 wrote:
> Fixes #7855 (“Last subtitle in MP4 is displayed forever”).
> ---
>  libavformat/isom.h |   3 +
>  libavformat/mov.c  | 158 +
>  2 files changed, 135 insertions(+), 26 deletions(-)

breaks "make fate"

make: *** [fate-filter-fps-cfr] Error 1
make: *** [fate-filter-fps-r] Error 1
make: *** [fate-filter-fps] Error 1
make: *** [fate-copy-trac236] Error 1
make: *** [fate-gaplessenc-itunes-to-ipod-aac] Error 1
make: *** [fate-mov-zombie] Error 1
make: *** [fate-mov-aac-2048-priming] Error 1

[...]
-- 
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
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] ffmpeg: Add option to force a specific decode format

2019-04-30 Thread Eoff, Ullysses A
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf Of Carl 
> Eugen Hoyos
> Sent: Tuesday, April 23, 2019 12:48 PM
> To: FFmpeg development discussions and patches 
> Subject: Re: [FFmpeg-devel] [PATCH] ffmpeg: Add option to force a specific 
> decode format
> 
> 2018-11-11 15:54 GMT+01:00, Mark Thompson :
> > Fixes #7519.
> 
> > +{ "decode_format",  OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
> > +OPT_SPEC | OPT_INPUT,
> >  { .off = OFFSET(decode_formats) },
> > +"set output format used by decoder, fail if this format is not
> > available", "format" },
> 
> Sorry if this was already asked:
> Why can't you use the input option "pix_fmt"?
> 

Are you saying that pix_fmt is already supported as in input option
for decode or, instead, that this patch should enable pix_fmt to be
used as such instead of adding a new option name?

> Carl Eugen
> ___
> 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] avfilter/avf_showwaves: Add draw mode also to showwavespic filter

2019-04-30 Thread Paul B Mahol
On 4/30/19, Martin Vobruba  wrote:
>> See commit a8c2d375ca68b7f001564ced14d8ac0757f53a29
>> ---
>>  doc/filters.texi| 14 ++
>>  libavfilter/avf_showwaves.c |  3 +++
>>  2 files changed, 17 insertions(+)
>>
>> diff --git a/doc/filters.texi b/doc/filters.texi
>> index e9cbccc..2aabe8a 100644
>> --- a/doc/filters.texi
>> +++ b/doc/filters.texi
>> @@ -22645,6 +22645,20 @@ Cubic root.
>>  @end table
>> Default is linear.
>> +
>> +@item draw
>> +Set the draw mode.
>> +
>> +Available values are:
>> +@table @samp
>> +@item scale
>> +Scale pixel values for each drawn sample.
>> +
>> +@item full
>> +Draw every sample directly.
>> +@end table
>> +
>> +Default value is @code{scale}.
>>  @end table
>> @subsection Examples
>> diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c
>> index 0e683cf..a0d2b25 100644
>> --- a/libavfilter/avf_showwaves.c
>> +++ b/libavfilter/avf_showwaves.c
>> @@ -765,6 +765,9 @@ static const AVOption showwavespic_options[] = {
>>  { "log", "logarithmic",0, AV_OPT_TYPE_CONST,
>> {.i64=SCALE_LOG}, .flags=FLAGS, .unit="scale"},
>>  { "sqrt", "square root",   0, AV_OPT_TYPE_CONST,
>> {.i64=SCALE_SQRT}, .flags=FLAGS, .unit="scale"},
>>  { "cbrt", "cubic root",0, AV_OPT_TYPE_CONST,
>> {.i64=SCALE_CBRT}, .flags=FLAGS, .unit="scale"},
>> +{ "draw", "set draw mode", OFFSET(draw_mode), AV_OPT_TYPE_INT,
>> {.i64 = DRAW_SCALE}, 0, DRAW_NB-1, FLAGS, .unit="draw" },
>> +{ "scale", "scale pixel values for each drawn sample", 0,
>> AV_OPT_TYPE_CONST, {.i64=DRAW_SCALE}, .flags=FLAGS, .unit="draw"},
>> +{ "full",  "draw every pixel for sample directly", 0,
>> AV_OPT_TYPE_CONST, {.i64=DRAW_FULL},  .flags=FLAGS, .unit="draw"},
>>  { NULL }
>>  };
>>
>
> Any feedback please?

Was applied.
___
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] avfilter/avf_showwaves: Add draw mode also to showwavespic filter

2019-04-30 Thread Martin Vobruba

See commit a8c2d375ca68b7f001564ced14d8ac0757f53a29
---
 doc/filters.texi| 14 ++
 libavfilter/avf_showwaves.c |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/doc/filters.texi b/doc/filters.texi
index e9cbccc..2aabe8a 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -22645,6 +22645,20 @@ Cubic root.
 @end table
Default is linear.
+
+@item draw
+Set the draw mode.
+
+Available values are:
+@table @samp
+@item scale
+Scale pixel values for each drawn sample.
+
+@item full
+Draw every sample directly.
+@end table
+
+Default value is @code{scale}.
 @end table
@subsection Examples
diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c
index 0e683cf..a0d2b25 100644
--- a/libavfilter/avf_showwaves.c
+++ b/libavfilter/avf_showwaves.c
@@ -765,6 +765,9 @@ static const AVOption showwavespic_options[] = {
 { "log", "logarithmic",0, AV_OPT_TYPE_CONST,  
{.i64=SCALE_LOG}, .flags=FLAGS, .unit="scale"},
 { "sqrt", "square root",   0, AV_OPT_TYPE_CONST,  
{.i64=SCALE_SQRT}, .flags=FLAGS, .unit="scale"},
 { "cbrt", "cubic root",0, AV_OPT_TYPE_CONST,  
{.i64=SCALE_CBRT}, .flags=FLAGS, .unit="scale"},
+{ "draw", "set draw mode", OFFSET(draw_mode), AV_OPT_TYPE_INT,  
{.i64 = DRAW_SCALE}, 0, DRAW_NB-1, FLAGS, .unit="draw" },
+{ "scale", "scale pixel values for each drawn sample", 0,  
AV_OPT_TYPE_CONST, {.i64=DRAW_SCALE}, .flags=FLAGS, .unit="draw"},
+{ "full",  "draw every pixel for sample directly", 0,  
AV_OPT_TYPE_CONST, {.i64=DRAW_FULL},  .flags=FLAGS, .unit="draw"},

 { NULL }
 };



Any feedback please?
___
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] lavfi: add gblur_opencl filter

2019-04-30 Thread Paul B Mahol
On 4/30/19, Dylan Fernando  wrote:
>
> Anyone have any feedback?

If I'm not mistaken there is already one available.
___
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] lavfi: add gblur_opencl filter

2019-04-30 Thread Dylan Fernando
On Thu, 25 Apr 2019 at 10:42 pm, Dylan Fernando  wrote:

> ---
>  configure |   1 +
>  libavfilter/Makefile  |   2 +
>  libavfilter/allfilters.c  |   1 +
>  libavfilter/opencl/gblur.cl   |  62 +++
>  libavfilter/opencl_source.h   |   1 +
>  libavfilter/vf_gblur_opencl.c | 370
> ++
>  6 files changed, 437 insertions(+)
>  create mode 100644 libavfilter/opencl/gblur.cl
>  create mode 100644 libavfilter/vf_gblur_opencl.c
>
> diff --git a/configure b/configure
> index bbeaf2fadc..8c1d3cdf92 100755
> --- a/configure
> +++ b/configure
> @@ -3451,6 +3451,7 @@ freezedetect_filter_select="scene_sad"
>  frei0r_filter_deps="frei0r libdl"
>  frei0r_src_filter_deps="frei0r libdl"
>  fspp_filter_deps="gpl"
> +gblur_opencl_filter_deps="opencl"
>  geq_filter_deps="gpl"
>  histeq_filter_deps="gpl"
>  hqdn3d_filter_deps="gpl"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index fef6ec5c55..230315ef39 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -243,6 +243,8 @@ OBJS-$(CONFIG_FREEZEDETECT_FILTER)   +=
> vf_freezedetect.o
>  OBJS-$(CONFIG_FREI0R_FILTER) += vf_frei0r.o
>  OBJS-$(CONFIG_FSPP_FILTER)   += vf_fspp.o
>  OBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
> +OBJS-$(CONFIG_GBLUR_OPENCL_FILTER)   += vf_gblur_opencl.o
> opencl.o \
> +opencl/gblur.o
>  OBJS-$(CONFIG_GEQ_FILTER)+= vf_geq.o
>  OBJS-$(CONFIG_GRADFUN_FILTER)+= vf_gradfun.o
>  OBJS-$(CONFIG_GRAPHMONITOR_FILTER)   += f_graphmonitor.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index c51ae0f3c7..cb0fc051cc 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -229,6 +229,7 @@ extern AVFilter ff_vf_freezedetect;
>  extern AVFilter ff_vf_frei0r;
>  extern AVFilter ff_vf_fspp;
>  extern AVFilter ff_vf_gblur;
> +extern AVFilter ff_vf_gblur_opencl;
>  extern AVFilter ff_vf_geq;
>  extern AVFilter ff_vf_gradfun;
>  extern AVFilter ff_vf_graphmonitor;
> diff --git a/libavfilter/opencl/gblur.cl b/libavfilter/opencl/gblur.cl
> new file mode 100644
> index 00..4fece30d4a
> --- /dev/null
> +++ b/libavfilter/opencl/gblur.cl
> @@ -0,0 +1,62 @@
> +/*
> + * Copyright (c) 2018 Dylan Fernando
> + *
> + * 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
> + */
> +
> +
> +__kernel void gblur_conv_horz(__write_only image2d_t dst,
> +  __read_only  image2d_t src,
> +  int coef_matrix_dim,
> +  __constant float *coef_matrix)
> +{
> +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
> +   CLK_ADDRESS_CLAMP_TO_EDGE   |
> +   CLK_FILTER_NEAREST);
> +
> +const int half_matrix_dim = (coef_matrix_dim / 2);
> +int2 loc = (int2)(get_global_id(0), get_global_id(1));
> +float4 convPix = (float4)(0.0f, 0.0f, 0.0f, 0.0f);
> +
> +for (int conv_j = -half_matrix_dim; conv_j <= half_matrix_dim;
> conv_j++) {
> +float4 px = read_imagef(src, sampler, loc + (int2)(conv_j, 0));
> +convPix += px * coef_matrix[(conv_j + half_matrix_dim)];
> +}
> +
> +write_imagef(dst, loc, convPix);
> +}
> +
> +__kernel void gblur_conv_vert(__write_only image2d_t dst,
> +  __read_only  image2d_t src,
> +  int coef_matrix_dim,
> +  __constant float *coef_matrix)
> +{
> +const sampler_t sampler = (CLK_NORMALIZED_COORDS_FALSE |
> +   CLK_ADDRESS_CLAMP_TO_EDGE   |
> +   CLK_FILTER_NEAREST);
> +
> +const int half_matrix_dim = (coef_matrix_dim / 2);
> +int2 loc = (int2)(get_global_id(0), get_global_id(1));
> +float4 convPix = (float4)(0.0f, 0.0f, 0.0f, 0.0f);
> +
> +for (int conv_j = -half_matrix_dim; conv_j <= half_matrix_dim;
> conv_j++) {
> +float4 px = read_imagef(src, sampler, loc + (int2)(0, conv_j));
> +convPix += px * coef_matrix[(conv_j + half_matrix_dim)];
> +}
> +
> +write_imagef(dst, loc, convPix);

Re: [FFmpeg-devel] [PATCH 3/4] swscale/ppc: VSX-optimize hScale16To*

2019-04-30 Thread Lauri Kasanen
./ffmpeg -loop 1 -s 1200x1440 -i tux16.png \
-s 2400x720 -f rawvideo -y -vframes 5 -pix_fmt yuv420p16le -nostats test.raw

./ffmpeg -loop 1 -s 1200x1440 -i tux16.png \
-s 2400x720 -f rawvideo -y -vframes 5 -pix_fmt yuv420p -nostats test.raw

32-bit mul, power8 only

2x speedup for hScale8To19_vsx (x86 SSE2 is 2.37):
  30896 UNITS in hscale,8192 runs,  0 skips
  63956 UNITS in hscale,8192 runs,  0 skips

2.06 for hScale16To15_vsx:
  30531 UNITS in hscale,8192 runs,  0 skips
  63161 UNITS in hscale,8192 runs,  0 skips

Signed-off-by: Lauri Kasanen 
---
 libswscale/ppc/swscale_vsx.c | 159 +++
 1 file changed, 159 insertions(+)

Resending due to mail client.

diff --git a/libswscale/ppc/swscale_vsx.c b/libswscale/ppc/swscale_vsx.c
index 17c15a2..31d3ba2 100644
--- a/libswscale/ppc/swscale_vsx.c
+++ b/libswscale/ppc/swscale_vsx.c
@@ -1911,6 +1911,160 @@ static void hScale8To19_vsx(SwsContext *c, int16_t 
*_dst, int dstW,
 }
 }

+static void hScale16To19_vsx(SwsContext *c, int16_t *_dst, int dstW,
+ const uint8_t *_src, const int16_t *filter,
+ const int32_t *filterPos, int filterSize)
+{
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
+int i, j;
+int32_t *dst= (int32_t *) _dst;
+const uint16_t *src = (const uint16_t *) _src;
+int bits= desc->comp[0].depth - 1;
+int sh  = bits - 4;
+vector int16_t vfilter, vin;
+vector int32_t vout, vtmp, vtmp2, vfilter32_l, vfilter32_r;
+const vector uint8_t vzero = vec_splat_u8(0);
+const vector uint8_t vunusedtab[8] = {
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf},
+(vector uint8_t) {0x0, 0x1, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x10, 0x10, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0x10, 0x10},
+};
+const vector uint8_t vunused = vunusedtab[filterSize % 8];
+
+if ((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && 
desc->comp[0].depth<16) {
+sh = 9;
+} else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are 
process like uint 16bpc */
+sh = 16 - 1 - 4;
+}
+
+if (filterSize == 1) {
+for (i = 0; i < dstW; i++) {
+int srcPos = filterPos[i];
+int val= 0;
+
+for (j = 0; j < filterSize; j++) {
+val += src[srcPos + j] * filter[filterSize * i + j];
+}
+// filter=14 bit, input=16 bit, output=30 bit, >> 11 makes 19 bit
+dst[i] = FFMIN(val >> sh, (1 << 19) - 1);
+}
+} else {
+for (i = 0; i < dstW; i++) {
+const int srcPos = filterPos[i];
+vout = vec_splat_s32(0);
+for (j = 0; j < filterSize; j += 8) {
+vin = (vector int16_t) vec_vsx_ld(0, [srcPos + j]);
+if (j + 8 > filterSize) // Remove the unused elements on the 
last round
+vin = vec_perm(vin, (vector int16_t) vzero, vunused);
+
+vfilter = vec_vsx_ld(0, [filterSize * i + j]);
+vfilter32_l = vec_unpackh(vfilter);
+vfilter32_r = vec_unpackl(vfilter);
+
+vtmp = (vector int32_t) vec_mergeh(vin, (vector int16_t) 
vzero);
+vtmp2 = (vector int32_t) vec_mergel(vin, (vector int16_t) 
vzero);
+
+vtmp = vec_mul(vtmp, vfilter32_l);
+vtmp2 = vec_mul(vtmp2, vfilter32_r);
+
+vout = vec_adds(vout, vtmp);
+vout = vec_adds(vout, vtmp2);
+}
+vout = vec_sums(vout, (vector int32_t) vzero);
+dst[i] = FFMIN(vout[3] >> sh, (1 << 19) - 1);
+}
+}
+}
+
+static void hScale16To15_vsx(SwsContext *c, int16_t *dst, int dstW,
+ const uint8_t *_src, const int16_t *filter,
+ const int32_t *filterPos, int filterSize)
+{
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
+ 

[FFmpeg-devel] [PATCH 3/4] swscale/ppc: VSX-optimize hScale16To*

2019-04-30 Thread Lauri Kasanen
./ffmpeg -loop 1 -s 1200x1440 -i tux16.png \
-s 2400x720 -f rawvideo -y -vframes 5 -pix_fmt yuv420p16le -nostats
test.raw

./ffmpeg -loop 1 -s 1200x1440 -i tux16.png \
-s 2400x720 -f rawvideo -y -vframes 5 -pix_fmt yuv420p -nostats
test.raw

32-bit mul, power8 only

2x speedup for hScale8To19_vsx (x86 SSE2 is 2.37):
  30896 UNITS in hscale,8192 runs,  0 skips
  63956 UNITS in hscale,8192 runs,  0 skips

2.06 for hScale16To15_vsx:
  30531 UNITS in hscale,8192 runs,  0 skips
  63161 UNITS in hscale,8192 runs,  0 skips

Signed-off-by: Lauri Kasanen 
---
 libswscale/ppc/swscale_vsx.c | 159 
+++ 1 file changed, 159 insertions(+)

diff --git a/libswscale/ppc/swscale_vsx.c b/libswscale/ppc/swscale_vsx.c
index 17c15a2..31d3ba2 100644
--- a/libswscale/ppc/swscale_vsx.c
+++ b/libswscale/ppc/swscale_vsx.c
@@ -1911,6 +1911,160 @@ static void hScale8To19_vsx(SwsContext *c,
int16_t *_dst, int dstW, }
 }

+static void hScale16To19_vsx(SwsContext *c, int16_t *_dst, int dstW,
+ const uint8_t *_src, const int16_t
*filter,
+ const int32_t *filterPos, int filterSize)
+{
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
+int i, j;
+int32_t *dst= (int32_t *) _dst;
+const uint16_t *src = (const uint16_t *) _src;
+int bits= desc->comp[0].depth - 1;
+int sh  = bits - 4;
+vector int16_t vfilter, vin;
+vector int32_t vout, vtmp, vtmp2, vfilter32_l, vfilter32_r;
+const vector uint8_t vzero = vec_splat_u8(0);
+const vector uint8_t vunusedtab[8] = {
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf},
+(vector uint8_t) {0x0, 0x1, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x10, 0x10, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0x10, 0x10, 0x10, 0x10, 0x10,
0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0x10, 0x10},
+};
+const vector uint8_t vunused = vunusedtab[filterSize % 8];
+
+if ((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) &&
desc->comp[0].depth<16) {
+sh = 9;
+} else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input
are process like uint 16bpc */
+sh = 16 - 1 - 4;
+}
+
+if (filterSize == 1) {
+for (i = 0; i < dstW; i++) {
+int srcPos = filterPos[i];
+int val= 0;
+
+for (j = 0; j < filterSize; j++) {
+val += src[srcPos + j] * filter[filterSize * i + j];
+}
+// filter=14 bit, input=16 bit, output=30 bit, >> 11 makes
19 bit
+dst[i] = FFMIN(val >> sh, (1 << 19) - 1);
+}
+} else {
+for (i = 0; i < dstW; i++) {
+const int srcPos = filterPos[i];
+vout = vec_splat_s32(0);
+for (j = 0; j < filterSize; j += 8) {
+vin = (vector int16_t) vec_vsx_ld(0, [srcPos + j]);
+if (j + 8 > filterSize) // Remove the unused elements
on the last round
+vin = vec_perm(vin, (vector int16_t) vzero,
vunused); +
+vfilter = vec_vsx_ld(0, [filterSize * i + j]);
+vfilter32_l = vec_unpackh(vfilter);
+vfilter32_r = vec_unpackl(vfilter);
+
+vtmp = (vector int32_t) vec_mergeh(vin, (vector
int16_t) vzero);
+vtmp2 = (vector int32_t) vec_mergel(vin, (vector
int16_t) vzero); +
+vtmp = vec_mul(vtmp, vfilter32_l);
+vtmp2 = vec_mul(vtmp2, vfilter32_r);
+
+vout = vec_adds(vout, vtmp);
+vout = vec_adds(vout, vtmp2);
+}
+vout = vec_sums(vout, (vector int32_t) vzero);
+dst[i] = FFMIN(vout[3] >> sh, (1 << 19) - 1);
+}
+}
+}
+
+static void hScale16To15_vsx(SwsContext *c, int16_t *dst, int dstW,
+ const uint8_t *_src, const int16_t
*filter,
+ const int32_t *filterPos, int filterSize)
+{
+const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
+int i, j;
+const uint16_t *src = 

[FFmpeg-devel] [PATCH 4/4] swscale/ppc: Shorten power8 tests via a var

2019-04-30 Thread Lauri Kasanen
Signed-off-by: Lauri Kasanen 
---
 libswscale/ppc/swscale_vsx.c | 27 ++-
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/libswscale/ppc/swscale_vsx.c b/libswscale/ppc/swscale_vsx.c
index 31d3ba2..a617f76 100644
--- a/libswscale/ppc/swscale_vsx.c
+++ b/libswscale/ppc/swscale_vsx.c
@@ -2074,6 +2074,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 #if HAVE_VSX
 enum AVPixelFormat dstFormat = c->dstFormat;
 const int cpu_flags = av_get_cpu_flags();
+const unsigned char power8 = HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8;

 if (!(cpu_flags & AV_CPU_FLAG_VSX))
 return;
@@ -2090,7 +2091,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 c->hyScale = c->hcScale = hScale8To19_vsx;
 }
 } else {
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 c->hyScale = c->hcScale = c->dstBpc > 14 ? hScale16To19_vsx
  : hScale16To15_vsx;
 }
@@ -2144,21 +2145,21 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 if (c->flags & SWS_FULL_CHR_H_INT) {
 switch (dstFormat) {
 case AV_PIX_FMT_RGB24:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 c->yuv2packed1 = yuv2rgb24_full_1_vsx;
 c->yuv2packed2 = yuv2rgb24_full_2_vsx;
 c->yuv2packedX = yuv2rgb24_full_X_vsx;
 }
 break;
 case AV_PIX_FMT_BGR24:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 c->yuv2packed1 = yuv2bgr24_full_1_vsx;
 c->yuv2packed2 = yuv2bgr24_full_2_vsx;
 c->yuv2packedX = yuv2bgr24_full_X_vsx;
 }
 break;
 case AV_PIX_FMT_BGRA:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 if (!c->needAlpha) {
 c->yuv2packed1 = yuv2bgrx32_full_1_vsx;
 c->yuv2packed2 = yuv2bgrx32_full_2_vsx;
@@ -2167,7 +2168,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 }
 break;
 case AV_PIX_FMT_RGBA:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 if (!c->needAlpha) {
 c->yuv2packed1 = yuv2rgbx32_full_1_vsx;
 c->yuv2packed2 = yuv2rgbx32_full_2_vsx;
@@ -2176,7 +2177,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 }
 break;
 case AV_PIX_FMT_ARGB:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 if (!c->needAlpha) {
 c->yuv2packed1 = yuv2xrgb32_full_1_vsx;
 c->yuv2packed2 = yuv2xrgb32_full_2_vsx;
@@ -2185,7 +2186,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 }
 break;
 case AV_PIX_FMT_ABGR:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 if (!c->needAlpha) {
 c->yuv2packed1 = yuv2xbgr32_full_1_vsx;
 c->yuv2packed2 = yuv2xbgr32_full_2_vsx;
@@ -2212,7 +2213,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 c->yuv2packedX = yuv2uyvy422_X_vsx;
 break;
 case AV_PIX_FMT_BGRA:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 if (!c->needAlpha) {
 c->yuv2packed1 = yuv2bgrx32_1_vsx;
 c->yuv2packed2 = yuv2bgrx32_2_vsx;
@@ -2220,7 +2221,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 }
 break;
 case AV_PIX_FMT_RGBA:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 if (!c->needAlpha) {
 c->yuv2packed1 = yuv2rgbx32_1_vsx;
 c->yuv2packed2 = yuv2rgbx32_2_vsx;
@@ -2228,7 +2229,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 }
 break;
 case AV_PIX_FMT_ARGB:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
 if (!c->needAlpha) {
 c->yuv2packed1 = yuv2xrgb32_1_vsx;
 c->yuv2packed2 = yuv2xrgb32_2_vsx;
@@ -2236,7 +2237,7 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 }
 break;
 case AV_PIX_FMT_ABGR:
-if (HAVE_POWER8 && cpu_flags & AV_CPU_FLAG_POWER8) {
+if (power8) {
   

[FFmpeg-devel] [PATCH 2/4] swscale/ppc: Indent

2019-04-30 Thread Lauri Kasanen
Signed-off-by: Lauri Kasanen 
---
 libswscale/ppc/swscale_vsx.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libswscale/ppc/swscale_vsx.c b/libswscale/ppc/swscale_vsx.c
index a82cf95..17c15a2 100644
--- a/libswscale/ppc/swscale_vsx.c
+++ b/libswscale/ppc/swscale_vsx.c
@@ -1927,13 +1927,13 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 #if !HAVE_BIGENDIAN
 if (c->srcBpc == 8) {
 if (c->dstBpc <= 14) {
-c->hyScale = c->hcScale = hScale_real_vsx;
-if (c->flags & SWS_FAST_BILINEAR && c->dstW >= c->srcW && c->chrDstW 
>= c->chrSrcW) {
-c->hyscale_fast = hyscale_fast_vsx;
-c->hcscale_fast = hcscale_fast_vsx;
-}
+c->hyScale = c->hcScale = hScale_real_vsx;
+if (c->flags & SWS_FAST_BILINEAR && c->dstW >= c->srcW && 
c->chrDstW >= c->chrSrcW) {
+c->hyscale_fast = hyscale_fast_vsx;
+c->hcscale_fast = hcscale_fast_vsx;
+}
 } else {
-c->hyScale = c->hcScale = hScale8To19_vsx;
+c->hyScale = c->hcScale = hScale8To19_vsx;
 }
 }
 if (!is16BPS(dstFormat) && !isNBPS(dstFormat) &&
--
2.6.2

___
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] swscale/ppc: VSX-optimize hScale8To19_vsx

2019-04-30 Thread Lauri Kasanen
./ffmpeg -f lavfi -i yuvtestsrc=duration=1:size=1200x1440 \
-s 2400x720 -f rawvideo -y -vframes 5 -pix_fmt yuv420p16le -nostats test.raw

2.26 speedup (x86 SSE2 is 2.32):
  23772 UNITS in hscale,4096 runs,  0 skips
  53862 UNITS in hscale,4096 runs,  0 skips

Signed-off-by: Lauri Kasanen 
---
 libswscale/ppc/swscale_vsx.c | 64 +++-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/libswscale/ppc/swscale_vsx.c b/libswscale/ppc/swscale_vsx.c
index 2e20ab3..a82cf95 100644
--- a/libswscale/ppc/swscale_vsx.c
+++ b/libswscale/ppc/swscale_vsx.c
@@ -1853,6 +1853,64 @@ static void hcscale_fast_vsx(SwsContext *c, int16_t 
*dst1, int16_t *dst2,

 #undef HCSCALE

+static void hScale8To19_vsx(SwsContext *c, int16_t *_dst, int dstW,
+const uint8_t *src, const int16_t *filter,
+const int32_t *filterPos, int filterSize)
+{
+int i, j;
+int32_t *dst = (int32_t *) _dst;
+vector int16_t vfilter, vin;
+vector uint8_t vin8;
+vector int32_t vout;
+const vector uint8_t vzero = vec_splat_u8(0);
+const vector uint8_t vunusedtab[8] = {
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf},
+(vector uint8_t) {0x0, 0x1, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x10, 0x10, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x10, 0x10,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0x10, 0x10, 0x10, 0x10},
+(vector uint8_t) {0x0, 0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7,
+  0x8, 0x9, 0xa, 0xb, 0xc, 0xd, 0x10, 0x10},
+};
+const vector uint8_t vunused = vunusedtab[filterSize % 8];
+
+if (filterSize == 1) {
+for (i = 0; i < dstW; i++) {
+int srcPos = filterPos[i];
+int val= 0;
+for (j = 0; j < filterSize; j++) {
+val += ((int)src[srcPos + j]) * filter[filterSize * i + j];
+}
+dst[i] = FFMIN(val >> 3, (1 << 19) - 1); // the cubic equation 
does overflow ...
+}
+} else {
+for (i = 0; i < dstW; i++) {
+const int srcPos = filterPos[i];
+vout = vec_splat_s32(0);
+for (j = 0; j < filterSize; j += 8) {
+vin8 = vec_vsx_ld(0, [srcPos + j]);
+vin = (vector int16_t) vec_mergeh(vin8, vzero);
+if (j + 8 > filterSize) // Remove the unused elements on the 
last round
+vin = vec_perm(vin, (vector int16_t) vzero, vunused);
+
+vfilter = vec_vsx_ld(0, [filterSize * i + j]);
+vout = vec_msums(vin, vfilter, vout);
+}
+vout = vec_sums(vout, (vector int32_t) vzero);
+dst[i] = FFMIN(vout[3] >> 3, (1 << 19) - 1);
+}
+}
+}
+
 #endif /* !HAVE_BIGENDIAN */

 #endif /* HAVE_VSX */
@@ -1867,12 +1925,16 @@ av_cold void ff_sws_init_swscale_vsx(SwsContext *c)
 return;

 #if !HAVE_BIGENDIAN
-if (c->srcBpc == 8 && c->dstBpc <= 14) {
+if (c->srcBpc == 8) {
+if (c->dstBpc <= 14) {
 c->hyScale = c->hcScale = hScale_real_vsx;
 if (c->flags & SWS_FAST_BILINEAR && c->dstW >= c->srcW && c->chrDstW 
>= c->chrSrcW) {
 c->hyscale_fast = hyscale_fast_vsx;
 c->hcscale_fast = hcscale_fast_vsx;
 }
+} else {
+c->hyScale = c->hcScale = hScale8To19_vsx;
+}
 }
 if (!is16BPS(dstFormat) && !isNBPS(dstFormat) &&
 dstFormat != AV_PIX_FMT_NV12 && dstFormat != AV_PIX_FMT_NV21 &&
--
2.6.2

___
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] swscale/ppc: VSX-optimize hscale_fast

2019-04-30 Thread Lauri Kasanen
On Wed, 24 Apr 2019 14:02:16 +0300
Lauri Kasanen  wrote:

> ./ffmpeg -f lavfi -i yuvtestsrc=duration=1:size=1200x1440 -sws_flags 
> fast_bilinear \
> -s 2400x720 -f rawvideo -vframes 5 -pix_fmt abgr -nostats test.raw
>
> 4.27 speedup for hyscale_fast:
>   24796 UNITS in hyscale_fast,4096 runs,  0 skips
>5797 UNITS in hyscale_fast,4096 runs,  0 skips
>
> 4.48 speedup for hcscale_fast:
>   19911 UNITS in hcscale_fast,4095 runs,  1 skips
>4437 UNITS in hcscale_fast,4096 runs,  0 skips
>
> Signed-off-by: Lauri Kasanen 
> ---
>  libswscale/ppc/swscale_vsx.c | 196 
> +++
>  1 file changed, 196 insertions(+)
>
> This has the same limit as the x86 version, same width or larger only.
> Shrinking would require a gather load, which doesn't exist on PPC and is slow
> even on x86 AVX. I tried a manual gather load, and the vector function was 20%
> slower than C.

Applying.

- Lauri
___
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] avfilter/vf_tonemap: add slice threading

2019-04-30 Thread Paul B Mahol
Signed-off-by: Paul B Mahol 
---
 libavfilter/vf_tonemap.c | 39 ++-
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_tonemap.c b/libavfilter/vf_tonemap.c
index efd4af5466..d1728c8513 100644
--- a/libavfilter/vf_tonemap.c
+++ b/libavfilter/vf_tonemap.c
@@ -191,10 +191,36 @@ static void tonemap(TonemapContext *s, AVFrame *out, 
const AVFrame *in,
 *b_out *= sig / sig_orig;
 }
 
+typedef struct ThreadData {
+AVFrame *in, *out;
+const AVPixFmtDescriptor *desc;
+double peak;
+} ThreadData;
+
+static int tonemap_slice(AVFilterContext *ctx, void *arg, int jobnr, int 
nb_jobs)
+{
+TonemapContext *s = ctx->priv;
+ThreadData *td = arg;
+AVFrame *in = td->in;
+AVFrame *out = td->out;
+const AVPixFmtDescriptor *desc = td->desc;
+const int slice_start = (in->height * jobnr) / nb_jobs;
+const int slice_end = (in->height * (jobnr+1)) / nb_jobs;
+double peak = td->peak;
+
+for (int y = slice_start; y < slice_end; y++)
+for (int x = 0; x < out->width; x++)
+tonemap(s, out, in, desc, x, y, peak);
+
+return 0;
+}
+
 static int filter_frame(AVFilterLink *link, AVFrame *in)
 {
-TonemapContext *s = link->dst->priv;
-AVFilterLink *outlink = link->dst->outputs[0];
+AVFilterContext *ctx = link->dst;
+TonemapContext *s = ctx->priv;
+AVFilterLink *outlink = ctx->outputs[0];
+ThreadData td;
 AVFrame *out;
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(link->format);
 const AVPixFmtDescriptor *odesc = av_pix_fmt_desc_get(outlink->format);
@@ -245,9 +271,11 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
 }
 
 /* do the tone map */
-for (y = 0; y < out->height; y++)
-for (x = 0; x < out->width; x++)
-tonemap(s, out, in, desc, x, y, peak);
+td.out = out;
+td.in = in;
+td.desc = desc;
+td.peak = peak;
+ctx->internal->execute(ctx, tonemap_slice, , NULL, FFMIN(in->height, 
ff_filter_get_nb_threads(ctx)));
 
 /* copy/generate alpha if needed */
 if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags & 
AV_PIX_FMT_FLAG_ALPHA) {
@@ -315,4 +343,5 @@ AVFilter ff_vf_tonemap = {
 .priv_class  = _class,
 .inputs  = tonemap_inputs,
 .outputs = tonemap_outputs,
+.flags   = AVFILTER_FLAG_SLICE_THREADS,
 };
-- 
2.17.1

___
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] libavfilter/af_astats: fix msvc compile error

2019-04-30 Thread Matthias Troffaes
On Mon, Apr 29, 2019 at 7:32 PM Paul B Mahol  wrote:
> On 4/29/19, Matthias Troffaes  wrote:
> > MSVC requires an explicit cast from void * to void when applying the
> > ternary conditional operator to switch between methods that return
> > void. The attached patch fixes the problem.
> >
> > For information, log of failed build:
> >
> > https://ci.appveyor.com/project/mcmtroffaes/ffmpeg-msvc-build/builds/2414/job/bbeyhavgy4kmqu7k
> >
> > Kind regards,
> > Matthias
> >
>
> Applied.

Thanks very much, Paul!

Kind regards,
Matthias
___
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/3] lavc/qsvdec: fix hevc level incorrectly map

2019-04-30 Thread Zhong Li
libmfx hevc level defination is same as h264, not level_idc of SPEC.

Signed-off-by: Zhong Li 
---
 libavcodec/qsv.c  | 13 +
 libavcodec/qsv_internal.h |  1 +
 libavcodec/qsvdec.c   |  2 +-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index bb0d79588c..4d3fbafe04 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -83,6 +83,19 @@ int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int 
profile)
 return MFX_PROFILE_UNKNOWN;
 }
 
+int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level)
+{
+if (level == FF_LEVEL_UNKNOWN)
+return MFX_LEVEL_UNKNOWN;
+
+switch (codec_id) {
+case AV_CODEC_ID_HEVC:
+return level / 3;
+default:
+return level;
+}
+}
+
 static const struct {
 mfxStatus   mfxerr;
 int averr;
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 57d861d2be..b63a7d6a31 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -90,6 +90,7 @@ int ff_qsv_print_warning(void *log_ctx, mfxStatus err,
 
 int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
+int ff_qsv_level_to_mfx(enum AVCodecID codec_id, int level);
 
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
 enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 2a8a032111..46aa2d6814 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -203,7 +203,7 @@ static int qsv_decode_init(AVCodecContext *avctx, 
QSVContext *q)
 
 param.mfx.CodecId  = ret;
 param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id, 
avctx->profile);
-param.mfx.CodecLevel   = avctx->level == FF_LEVEL_UNKNOWN ? 
MFX_LEVEL_UNKNOWN : avctx->level;
+param.mfx.CodecLevel   = ff_qsv_level_to_mfx(avctx->codec_id, 
avctx->level);
 
 param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
 param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
-- 
2.17.1

___
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/3] lavc/qsv: extactly map profile

2019-04-30 Thread Zhong Li
Currently profile mapping is hard-coded, and not flexible to do extactly
map (E.g: libmfx treats H264 constrained baseline to be baseline profile).

vaapi profile mapping funtion provides a better soultion than current
qsv mapping.

Signed-off-by: Zhong Li 
---
 libavcodec/qsv.c | 52 
 1 file changed, 44 insertions(+), 8 deletions(-)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 4d3fbafe04..986d4f6022 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -67,19 +67,55 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id)
 return AVERROR(ENOSYS);
 }
 
+
+static const struct {
+enum AVCodecID codec_id;
+int codec_profile;
+int mfx_profile;
+} qsv_profile_map[] = {
+#define MAP(c, p, v) { AV_CODEC_ID_ ## c, FF_PROFILE_ ## p, MFX_PROFILE_ ## v }
+MAP(MPEG2VIDEO,  MPEG2_SIMPLE,MPEG2_SIMPLE ),
+MAP(MPEG2VIDEO,  MPEG2_MAIN,  MPEG2_MAIN   ),
+MAP(MPEG2VIDEO,  MPEG2_HIGH,  MPEG2_HIGH   ),
+
+MAP(H264,H264_BASELINE,   AVC_BASELINE ),
+MAP(H264,H264_CONSTRAINED_BASELINE, AVC_BASELINE),
+#if QSV_VERSION_ATLEAST(1, 3)
+MAP(H264,H264_EXTENDED,   AVC_EXTENDED ),
+#endif
+MAP(H264,H264_MAIN,   AVC_MAIN ),
+MAP(H264,H264_HIGH,   AVC_HIGH ),
+MAP(H264,H264_HIGH_422,   AVC_HIGH_422 ),
+
+#if QSV_VERSION_ATLEAST(1, 8)
+MAP(HEVC,HEVC_MAIN,   HEVC_MAIN),
+MAP(HEVC,HEVC_MAIN_10,HEVC_MAIN10  ),
+MAP(HEVC,HEVC_MAIN_STILL_PICTURE,HEVC_MAINSP ),
+#endif
+#if QSV_VERSION_ATLEAST(1, 16)
+MAP(HEVC,HEVC_REXT,   HEVC_REXT),
+#endif
+
+MAP(VC1, VC1_SIMPLE,  VC1_SIMPLE   ),
+MAP(VC1, VC1_MAIN,VC1_MAIN ),
+MAP(VC1, VC1_COMPLEX, VC1_ADVANCED ),
+MAP(VC1, VC1_ADVANCED,VC1_ADVANCED ),
+#undef MAP
+};
+
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile)
 {
+int i;
 if (profile == FF_PROFILE_UNKNOWN)
 return MFX_PROFILE_UNKNOWN;
-switch (codec_id) {
-case AV_CODEC_ID_H264:
-case AV_CODEC_ID_HEVC:
-return profile;
-case AV_CODEC_ID_VC1:
-return 4 * profile + 1;
-case AV_CODEC_ID_MPEG2VIDEO:
-return 0x10 * profile;
+
+for (i = 0; i < FF_ARRAY_ELEMS(qsv_profile_map); i++) {
+if (qsv_profile_map[i].codec_id != codec_id)
+continue;
+if (qsv_profile_map[i].codec_profile == profile)
+return qsv_profile_map[i].mfx_profile;
 }
+
 return MFX_PROFILE_UNKNOWN;
 }
 
-- 
2.17.1

___
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/3] lavc/qsvdec: add query function and provide error message

2019-04-30 Thread Zhong Li
It is helpful to know why some clips decoding failed.
Ticket#7330 is a good example, with this patch it is easily to
know bitstream codec level is out of support range.

Signed-off-by: Zhong Li 
---
 libavcodec/qsvdec.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index 4a0be811fb..2a8a032111 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -120,6 +120,33 @@ static inline unsigned int qsv_fifo_size(const 
AVFifoBuffer* fifo)
 return av_fifo_size(fifo) / qsv_fifo_item_size();
 }
 
+static int check_dec_param(AVCodecContext *avctx, QSVContext *q, mfxVideoParam 
*param_in)
+{
+mfxVideoParam param_out = { .mfx.CodecId = param_in->mfx.CodecId };
+mfxStatus ret;
+
+#define CHECK_MATCH(x) \
+do { \
+  if (param_out.mfx.x != param_in->mfx.x) {   \
+  av_log(avctx, AV_LOG_WARNING, "Required "#x" %d is unsupported\n", \
+  param_in->mfx.x); \
+  } \
+} while (0)
+
+ret = MFXVideoDECODE_Query(q->session, param_in, _out);
+
+if (ret < 0) {
+CHECK_MATCH(CodecId);
+CHECK_MATCH(CodecProfile);
+CHECK_MATCH(CodecLevel);
+CHECK_MATCH(FrameInfo.Width);
+CHECK_MATCH(FrameInfo.Height);
+#undef CHECK_MATCH
+return 0;
+}
+return 1;
+}
+
 static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
 {
 const AVPixFmtDescriptor *desc;
@@ -206,6 +233,12 @@ static int qsv_decode_init(AVCodecContext *avctx, 
QSVContext *q)
 param.ExtParam= q->ext_buffers;
 param.NumExtParam = q->nb_ext_buffers;
 
+if (!check_dec_param(avctx, q, )) {
+//Just give a warning instead of an error since it is still decodable 
possibly.
+av_log(avctx, AV_LOG_WARNING,
+   "Current input bitstream is not supported by QSV decoder.\n");
+}
+
 ret = MFXVideoDECODE_Init(q->session, );
 if (ret < 0)
 return ff_qsv_print_error(avctx, ret,
-- 
2.17.1

___
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] libavcodec/vp9: fix ref-frame size judging method

2019-04-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Yan Cen
> Sent: Tuesday, April 30, 2019 9:46 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Yan, CenX 
> Subject: [FFmpeg-devel] [PATCH] libavcodec/vp9: fix ref-frame size judging
> method
> 
> From: Yan Cen 
> 
> There is no need all reference frame demension is valid in libvpx.
> 
> So this change contains three part:
> 1. Change each judgement's loglevel from "ERROR" to "WARNING"
> 2. Make sure at least one of frames that this frame references has valid
> dimension.
> 3. All judgements fail would report "ERROR".
> 
> Signed-off-by: Yan Cen
> ---
>  libavcodec/vp9.c | 14 +++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index acf3ffc..8dd14e0
> 100644
> --- a/libavcodec/vp9.c
> +++ b/libavcodec/vp9.c
> @@ -790,6 +790,7 @@ static int decode_frame_header(AVCodecContext
> *avctx,
> 
>  /* check reference frames */
>  if (!s->s.h.keyframe && !s->s.h.intraonly) {
> +int has_valid_ref_frame = 0;
>  for (i = 0; i < 3; i++) {
>  AVFrame *ref = s->s.refs[s->s.h.refidx[i]].f;
>  int refw = ref->width, refh = ref->height; @@ -802,12
> +803,14 @@ static int decode_frame_header(AVCodecContext *avctx,
>  return AVERROR_INVALIDDATA;
>  } else if (refw == w && refh == h) {
>  s->mvscale[i][0] = s->mvscale[i][1] = 0;
> +has_valid_ref_frame = 1;
>  } else {
> -if (w * 2 < refw || h * 2 < refh || w > 16 * refw || h > 16
> * refh) {
> -av_log(avctx, AV_LOG_ERROR,
> +int is_ref_frame_invalid = (w * 2 < refw || h * 2 < refh
> || w > 16 * refw || h > 16 * refh);
> +has_valid_ref_frame |= !is_ref_frame_invalid;
> +if (is_ref_frame_invalid) {
> +av_log(avctx, AV_LOG_WARNING,
> "Invalid ref frame dimensions %dx%d for
> frame size %dx%d\n",
> refw, refh, w, h);
> -return AVERROR_INVALIDDATA;
>  }

Would be higher efficient and easier to read if change as blew? 
if (is_ref_frame_invalid) 
   warning_log;
else
  has_valid_ref_frame = 1;

>  s->mvscale[i][0] = (refw << 14) / w;
>  s->mvscale[i][1] = (refh << 14) / h; @@ -815,6 +818,11
> @@ static int decode_frame_header(AVCodecContext *avctx,
>  s->mvstep[i][1] = 16 * s->mvscale[i][1] >> 14;
>  }
>  }
> +if (!has_valid_ref_frame) {
> +av_log(avctx, AV_LOG_ERROR,
> +   "Referenced frame has invalid size\n");
> +return AVERROR_INVALIDDATA;
> +}
>  }
> 
>  if (s->s.h.keyframe || s->s.h.errorres || (s->s.h.intraonly &&
> s->s.h.resetctx == 3)) {
> --
> 2.7.4

Patch makes sense, but I wonder is there any clip to reproduce the issue you 
want to fix?
___
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".