Re: [FFmpeg-devel] [PATCH] cuvid : add support to force intra frames as in input source

2018-01-17 Thread Timo Rothenpieler

Am 17.01.2018 um 06:12 schrieb Yogender Gupta:

Please find attached a patch for setting key frames.

"-force_key_frames" can then use this option.

Thanks,
Yogender


> diff --git a/libavcodec/cuviddec.c b/libavcodec/cuviddec.c
> index c23033c..54f6cb7 100644
> --- a/libavcodec/cuviddec.c
> +++ b/libavcodec/cuviddec.c
> @@ -74,6 +74,8 @@ typedef struct CuvidContext
>  int internal_error;
>  int decoder_flushing;
>
> +int key_frame[32];

Isn't it a bit risky to hardcode this to 32?
CurrPicIdx can be as large as ctx->nb_surfaces, which is 25 by default 
but can be user-set to any value up to INT_MAX.

So this needs allocation after nb_surfaces is known.

> +
>  cudaVideoCodec codec_type;
>  cudaVideoChromaFormat chroma_format;
>
> @@ -340,6 +342,8 @@ static int CUDAAPI 
cuvid_handle_picture_decode(void *opaque, CUVIDPICPARAMS* pic

>
>  av_log(avctx, AV_LOG_TRACE, "pfnDecodePicture\n");
>
> +ctx->key_frame[picparams->CurrPicIdx] = picparams->intra_pic_flag;
> +
>  ctx->internal_error = 
CHECK_CU(ctx->cvdl->cuvidDecodePicture(ctx->cudecoder, picparams));

>  if (ctx->internal_error < 0)
>  return 0;
> @@ -590,6 +594,7 @@ static int cuvid_output_frame(AVCodecContext 
*avctx, AVFrame *frame)

>  goto error;
>  }
>
> +frame->key_frame = 
ctx->key_frame[parsed_frame.dispinfo.picture_index];

>  frame->width = avctx->width;
>  frame->height = avctx->height;
>  if (avctx->pkt_timebase.num && avctx->pkt_timebase.den)
> --
> 2.10.1.windows.1
>
>

Otherwise this looks sensible to me.


Thanks,
Timo



smime.p7s
Description: S/MIME Cryptographic Signature
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH V2 4/5] lavfi: add ProcAmp(color balance) vaapi video filter.

2018-01-17 Thread Moritz Barsnick
On Wed, Jan 17, 2018 at 10:49:21 +0800, Jun Zhao wrote:
>  configure  |   1 +
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_procamp_vaapi.c | 230 
> +
>  4 files changed, 233 insertions(+)

The newly added filters require a doc (texi) entry, a changelog entry,
and a minor version bump.

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


Re: [FFmpeg-devel] [PATCH] Adding mkdir option for img2enc (3rd attempt)

2018-01-17 Thread Dr. Alan Barclay

Hi,

Attached in a further patch - adding the error checks.

Derek - I don't think there is a functional downside to this 'mkdir' 
option being a default behaviour, but it would introduce a minor 
performance penalty (which users maybe don't want).


All comments and help appreciated.

Thanks and Regards,
Alan.


On 27/12/2017 16:01, Derek Buitenhuis wrote:

Hi,

On 12/27/2017 12:27 PM, Dr Alan Barclay wrote:

Resending the two (git format-patch) patches, without the top lines
removed (which I thought I needed to do as some patch emails didn't seem
to have them).

All comments and help appreciated.


[...]


Subject: [PATCH 1/2] Move mkdir_p (renamed ff_mkdir_p) from hlsenc.c to
  utils.c.

---
  libavformat/hlsenc.c   | 35 +--
  libavformat/internal.h |  7 +++
  libavformat/utils.c| 33 +
  3 files changed, 41 insertions(+), 34 deletions(-)


On a technical level, this patch looks OK.


Subject: [PATCH 2/2] Adding mkdir option for img2enc.

---
  libavformat/img2enc.c | 8 
  1 file changed, 8 insertions(+)


I'm not sure how others feel about the premise (mkdir in img2enc).
I personally don't mind - though, maybe it should be default instead
of an option? (Maybe a bad idea.)


+if (img->use_mkdir) {
+char *temp_filename = av_strdup(filename);
+const char *temp_path = av_dirname(temp_filename);
+ff_mkdir_p(temp_path);
+av_free(temp_filename);
+}


This lacks error checks for av_strdup and ff_mkdir_p.

- Derek

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




--
Dr. Alan Barclay
Electric Scribe Ltd.
118 Stanley Street
Aberdeen AB10 6UQ, U.K.
+44 1224 591779 office
+44 7803 606485 mobile
a...@escribe.co.uk
From a85be3fbf11f40567370c58f6c7e72d7edbd3109 Mon Sep 17 00:00:00 2001
From: "Dr. Alan Barclay" 
Date: Wed, 17 Jan 2018 10:44:17 +
Subject: [PATCH 2/2] Added error checking for mkdir option.

---
 libavformat/img2enc.c | 12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
index a8ee064396..9de2c8f356 100644
--- a/libavformat/img2enc.c
+++ b/libavformat/img2enc.c
@@ -116,9 +116,17 @@ static int write_packet(AVFormatContext *s, AVPacket *pkt)
 return AVERROR(EINVAL);
 }
 if (img->use_mkdir) {
+const char *temp_path;
 char *temp_filename = av_strdup(filename);
-const char *temp_path = av_dirname(temp_filename);
-ff_mkdir_p(temp_path);
+if (!temp_filename) {
+return AVERROR(ENOMEM);
+}
+temp_path = av_dirname(temp_filename);
+if (ff_mkdir_p(temp_path) == -1 && errno != EEXIST) {
+av_log(s, AV_LOG_ERROR, "Could not create directory %s\n", 
temp_path);
+av_free(temp_filename);
+return AVERROR(errno);
+}
 av_free(temp_filename);
 }
 for (i = 0; i < 4; i++) {
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH] Adding mkdir option for img2enc (3rd attempt)

2018-01-17 Thread Carl Eugen Hoyos
2018-01-17 11:56 GMT+01:00 Dr. Alan Barclay :

> Attached in a further patch - adding the error checks.

Please merge this patch into your previous patch.

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


Re: [FFmpeg-devel] avfilter/x86/vf_blend : add avx2 for 8b func (v2)

2018-01-17 Thread Henrik Gramner
On Tue, Jan 16, 2018 at 11:33 PM, Martin Vignali
 wrote:
> BLEND_INIT grainextract, 4

You could also try doing twice as much per iteration which might be
more efficient, especially in avx2 since it avoids cross-lane
shuffles. Applies to some other ones as well.

E.g. something like:

pxor   m4, m4
VBROADCASTI128 m5, [pw_128]

.loop:
movu   m1, [topq + xq]
movu   m3, [bottomq + xq]
punpcklbw  m0, m1, m4
punpckhbw  m1, m4
punpcklbw  m2, m3, m4
punpckhbw  m3, m4
paddw  m0, m5
paddw  m1, m5
psubw  m0, m2
psubw  m1, m3
packuswb   m0, m1
mova  [dstq + xq], m0
addxq, mmsize
jl .loop

> BLEND_INIT average, 3

pavgb should probably be more efficient than unpacking to words. It
does round up so some bitflipping shenanigans might be required if you
want to round down.

E.g. something like:

pcmpeqbm2, m2

.loop:
movu   m0, [topq + xq]
movu   m1, [bottomq + xq]
pxor   m0, m2
pxor   m1, m2
pavgb  m0, m1
pxor   m0, m2
mova  [dstq + xq], m0
addxq, mmsize
jl .loop

(optionally combining movu+pxor into a 3-arg pxor with avx since
memory operands can be unaligned in VEX-encoded instructions).
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-17 Thread Richard Shaffer
I just want to ping the list again to see if anyone would be willing to
have a look at this change set. I sent it off last time on a Friday
evening, so I'm not sure if maybe it was just forgotten or missed over the
weekend, or if it's just not interesting to anyone else.

If this isn't useful to anyone else, that would also be good to know. Any
feedback at all would be appreciated if anyone is willing.

Much thanks,

-Richard

On Fri, Jan 12, 2018 at 1:13 PM,  wrote:

> From: Richard Shaffer 
>
> Enables getting access to ID3 PRIV tags from the command-line or metadata
> API
> when demuxing. The PRIV owner is stored as the metadata key, and the data
> is
> stored as the metadata value. As PRIV tags may contain arbitrary data, non-
> printable characters, including NULL bytes, are escaped as \xXX.
>
> As this introduces a change in behavior, it must be enabled by setting the
> 'id3v2_parse_priv' option.
> ---
>
> I want to be able to expose PRIV tags using an existing API, but not sure
> if
> this is the best approach. In particular, PRIV data may be of any type,
> while
> metadata (and the AVDictionary type it uses) expresses values as strings.
> Any
> feedback on the approach or specifics would be much appreciated,
> especially if
> there is a suggestion for a better way to accomplish this.
>
> -Richard
>
>  libavformat/aacdec.c | 40 +++-
>  libavformat/id3v2.c  | 40 
>  libavformat/id3v2.h  | 13 +
>  libavformat/mp3dec.c |  2 ++
>  libavformat/utils.c  |  4 
>  5 files changed, 90 insertions(+), 9 deletions(-)
>
> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> index 36d558ff54..46e10f34af 100644
> --- a/libavformat/aacdec.c
> +++ b/libavformat/aacdec.c
> @@ -21,6 +21,7 @@
>   */
>
>  #include "libavutil/intreadwrite.h"
> +#include "libavutil/opt.h"
>  #include "avformat.h"
>  #include "internal.h"
>  #include "id3v1.h"
> @@ -28,6 +29,11 @@
>
>  #define ADTS_HEADER_SIZE 7
>
> +typedef struct AACDemuxContext {
> +AVClass *class;
> +int id3v2_parse_priv;
> +} AACDemuxContext;
> +
>  static int adts_aac_probe(AVProbeData *p)
>  {
>  int max_frames = 0, first_frames = 0;
> @@ -146,14 +152,30 @@ static int adts_aac_read_packet(AVFormatContext *s,
> AVPacket *pkt)
>  return ret;
>  }
>
> +static const AVOption aac_options[] = {
> +{ "id3v2_parse_priv",
> +"parse ID3v2 PRIV tags", offsetof(AACDemuxContext,
> id3v2_parse_priv),
> +AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM
> },
> +{ NULL },
> +};
> +
> +static const AVClass aac_class = {
> +.class_name = "aac",
> +.item_name  = av_default_item_name,
> +.option = aac_options,
> +.version= LIBAVUTIL_VERSION_INT,
> +};
> +
>  AVInputFormat ff_aac_demuxer = {
> -.name = "aac",
> -.long_name= NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced Audio
> Coding)"),
> -.read_probe   = adts_aac_probe,
> -.read_header  = adts_aac_read_header,
> -.read_packet  = adts_aac_read_packet,
> -.flags= AVFMT_GENERIC_INDEX,
> -.extensions   = "aac",
> -.mime_type= "audio/aac,audio/aacp,audio/x-aac",
> -.raw_codec_id = AV_CODEC_ID_AAC,
> +.name   = "aac",
> +.long_name  = NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced Audio
> Coding)"),
> +.read_probe = adts_aac_probe,
> +.read_header= adts_aac_read_header,
> +.read_packet= adts_aac_read_packet,
> +.flags  = AVFMT_GENERIC_INDEX,
> +.priv_class = &aac_class,
> +.priv_data_size = sizeof(AACDemuxContext),
> +.extensions = "aac",
> +.mime_type  = "audio/aac,audio/aacp,audio/x-aac",
> +.raw_codec_id   = AV_CODEC_ID_AAC,
>  };
> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 6c216ba7a2..dd151dd7f2 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -33,6 +33,7 @@
>  #endif
>
>  #include "libavutil/avstring.h"
> +#include "libavutil/bprint.h"
>  #include "libavutil/dict.h"
>  #include "libavutil/intreadwrite.h"
>  #include "avio_internal.h"
> @@ -1224,3 +1225,42 @@ end:
>  av_freep(&chapters);
>  return ret;
>  }
> +
> +int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta
> **extra_meta)
> +{
> +ID3v2ExtraMeta *cur;
> +int dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL;
> +
> +for (cur = *extra_meta; cur; cur = cur->next) {
> +if (!strcmp(cur->tag, "PRIV")) {
> +ID3v2ExtraMetaPRIV *priv = cur->data;
> +AVBPrint bprint;
> +char * escaped;
> +int i, ret;
> +
> +av_bprint_init(&bprint, priv->datasize + sizeof(char),
> AV_BPRINT_SIZE_UNLIMITED);
> +
> +for (i = 0; i < priv->datasize; i++) {
> +if (priv->data[i] < 32 || priv->data[i] > 126) {
> +av_bprintf(&bprint, "\\x%02x", priv->data[i]);
> +} else if (priv->d

Re: [FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-17 Thread wm4
On Fri, 12 Jan 2018 13:13:05 -0800
rshaf...@tunein.com wrote:

> From: Richard Shaffer 
> 
> Enables getting access to ID3 PRIV tags from the command-line or metadata API
> when demuxing. The PRIV owner is stored as the metadata key, and the data is
> stored as the metadata value. As PRIV tags may contain arbitrary data, non-
> printable characters, including NULL bytes, are escaped as \xXX.
> 
> As this introduces a change in behavior, it must be enabled by setting the
> 'id3v2_parse_priv' option.
> ---
> 
> I want to be able to expose PRIV tags using an existing API, but not sure if
> this is the best approach. In particular, PRIV data may be of any type, while
> metadata (and the AVDictionary type it uses) expresses values as strings. Any
> feedback on the approach or specifics would be much appreciated, especially if
> there is a suggestion for a better way to accomplish this.
> 
> -Richard
> 
>  libavformat/aacdec.c | 40 +++-
>  libavformat/id3v2.c  | 40 
>  libavformat/id3v2.h  | 13 +
>  libavformat/mp3dec.c |  2 ++
>  libavformat/utils.c  |  4 
>  5 files changed, 90 insertions(+), 9 deletions(-)
> 
> diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> index 36d558ff54..46e10f34af 100644
> --- a/libavformat/aacdec.c
> +++ b/libavformat/aacdec.c
> @@ -21,6 +21,7 @@
>   */
>  
>  #include "libavutil/intreadwrite.h"
> +#include "libavutil/opt.h"
>  #include "avformat.h"
>  #include "internal.h"
>  #include "id3v1.h"
> @@ -28,6 +29,11 @@
>  
>  #define ADTS_HEADER_SIZE 7
>  
> +typedef struct AACDemuxContext {
> +AVClass *class;
> +int id3v2_parse_priv;
> +} AACDemuxContext;
> +
>  static int adts_aac_probe(AVProbeData *p)
>  {
>  int max_frames = 0, first_frames = 0;
> @@ -146,14 +152,30 @@ static int adts_aac_read_packet(AVFormatContext *s, 
> AVPacket *pkt)
>  return ret;
>  }
>  
> +static const AVOption aac_options[] = {
> +{ "id3v2_parse_priv",
> +"parse ID3v2 PRIV tags", offsetof(AACDemuxContext, id3v2_parse_priv),
> +AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
> +{ NULL },
> +};
> +
> +static const AVClass aac_class = {
> +.class_name = "aac",
> +.item_name  = av_default_item_name,
> +.option = aac_options,
> +.version= LIBAVUTIL_VERSION_INT,
> +};
> +
>  AVInputFormat ff_aac_demuxer = {
> -.name = "aac",
> -.long_name= NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced Audio 
> Coding)"),
> -.read_probe   = adts_aac_probe,
> -.read_header  = adts_aac_read_header,
> -.read_packet  = adts_aac_read_packet,
> -.flags= AVFMT_GENERIC_INDEX,
> -.extensions   = "aac",
> -.mime_type= "audio/aac,audio/aacp,audio/x-aac",
> -.raw_codec_id = AV_CODEC_ID_AAC,
> +.name   = "aac",
> +.long_name  = NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced Audio 
> Coding)"),
> +.read_probe = adts_aac_probe,
> +.read_header= adts_aac_read_header,
> +.read_packet= adts_aac_read_packet,
> +.flags  = AVFMT_GENERIC_INDEX,
> +.priv_class = &aac_class,
> +.priv_data_size = sizeof(AACDemuxContext),
> +.extensions = "aac",
> +.mime_type  = "audio/aac,audio/aacp,audio/x-aac",
> +.raw_codec_id   = AV_CODEC_ID_AAC,
>  };

AAC and mp3 are by far not the only formats that can use ID3v2. FFmpeg
accepts ID3v2 tags on basically all file formats. So just adding a
private option to aac and mp3 doesn't make that much sense.

I'm also not sure if an option for compatibility is needed. It's
probably fine to prefix the name with something (maybe "id3v2_priv."?),
and always export it.

> diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> index 6c216ba7a2..dd151dd7f2 100644
> --- a/libavformat/id3v2.c
> +++ b/libavformat/id3v2.c
> @@ -33,6 +33,7 @@
>  #endif
>  
>  #include "libavutil/avstring.h"
> +#include "libavutil/bprint.h"
>  #include "libavutil/dict.h"
>  #include "libavutil/intreadwrite.h"
>  #include "avio_internal.h"
> @@ -1224,3 +1225,42 @@ end:
>  av_freep(&chapters);
>  return ret;
>  }
> +
> +int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta 
> **extra_meta)
> +{
> +ID3v2ExtraMeta *cur;
> +int dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_VAL;
> +
> +for (cur = *extra_meta; cur; cur = cur->next) {
> +if (!strcmp(cur->tag, "PRIV")) {
> +ID3v2ExtraMetaPRIV *priv = cur->data;
> +AVBPrint bprint;
> +char * escaped;
> +int i, ret;
> +
> +av_bprint_init(&bprint, priv->datasize + sizeof(char), 
> AV_BPRINT_SIZE_UNLIMITED);

sizeof(char) makes no sense - it's always 1, and it's better to use 1.

> +
> +for (i = 0; i < priv->datasize; i++) {
> +if (priv->data[i] < 32 || priv->data[i] > 126) {
> +av_bprintf(&bprint, "\\x%02x", priv->data[i]);
> +  

Re: [FFmpeg-devel] [PATCH] lavfi/deinterlace_vaapi: fix can't show full option information.

2018-01-17 Thread Michael Niedermayer
On Wed, Jan 17, 2018 at 08:19:38AM +0800, Jun Zhao wrote:
> 

>  vf_deinterlace_vaapi.c |   14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 4223a9ff8b91e93ca66ce0225762879cfb4e0247  
> 0001-lavfi-deinterlace_vaapi-fix-can-t-show-full-option-i.patch
> From af8982bddc1e5b430ba12fc155676ee71f598c0a Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Tue, 16 Jan 2018 22:44:02 +0800
> Subject: [PATCH] lavfi/deinterlace_vaapi: fix can't show full option
>  information.
> 
> use ffmpeg -h filter=deinterlace_vaapi can't get full help information,
> the root cause is not setting the flags fileld in options.
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/vf_deinterlace_vaapi.c | 14 +++---
>  1 file changed, 7 insertions(+), 7 deletions(-)

will apply

thanks

[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- 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] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-17 Thread Richard Shaffer
Thanks for reviewing; it's much appreciated. I responded to one of the
comments in-line. I'll work on updating the patch to address your comments.

On Wed, Jan 17, 2018 at 10:21 AM, wm4  wrote:

> On Fri, 12 Jan 2018 13:13:05 -0800
> rshaf...@tunein.com wrote:
>
> > From: Richard Shaffer 
> >
> > Enables getting access to ID3 PRIV tags from the command-line or
> metadata API
> > when demuxing. The PRIV owner is stored as the metadata key, and the
> data is
> > stored as the metadata value. As PRIV tags may contain arbitrary data,
> non-
> > printable characters, including NULL bytes, are escaped as \xXX.
> >
> > As this introduces a change in behavior, it must be enabled by setting
> the
> > 'id3v2_parse_priv' option.
> > ---
> >
> > I want to be able to expose PRIV tags using an existing API, but not
> sure if
> > this is the best approach. In particular, PRIV data may be of any type,
> while
> > metadata (and the AVDictionary type it uses) expresses values as
> strings. Any
> > feedback on the approach or specifics would be much appreciated,
> especially if
> > there is a suggestion for a better way to accomplish this.
> >
> > -Richard
> >
> >  libavformat/aacdec.c | 40 +++-
> >  libavformat/id3v2.c  | 40 
> >  libavformat/id3v2.h  | 13 +
> >  libavformat/mp3dec.c |  2 ++
> >  libavformat/utils.c  |  4 
> >  5 files changed, 90 insertions(+), 9 deletions(-)
> >
> > diff --git a/libavformat/aacdec.c b/libavformat/aacdec.c
> > index 36d558ff54..46e10f34af 100644
> > --- a/libavformat/aacdec.c
> > +++ b/libavformat/aacdec.c
> > @@ -21,6 +21,7 @@
> >   */
> >
> >  #include "libavutil/intreadwrite.h"
> > +#include "libavutil/opt.h"
> >  #include "avformat.h"
> >  #include "internal.h"
> >  #include "id3v1.h"
> > @@ -28,6 +29,11 @@
> >
> >  #define ADTS_HEADER_SIZE 7
> >
> > +typedef struct AACDemuxContext {
> > +AVClass *class;
> > +int id3v2_parse_priv;
> > +} AACDemuxContext;
> > +
> >  static int adts_aac_probe(AVProbeData *p)
> >  {
> >  int max_frames = 0, first_frames = 0;
> > @@ -146,14 +152,30 @@ static int adts_aac_read_packet(AVFormatContext
> *s, AVPacket *pkt)
> >  return ret;
> >  }
> >
> > +static const AVOption aac_options[] = {
> > +{ "id3v2_parse_priv",
> > +"parse ID3v2 PRIV tags", offsetof(AACDemuxContext,
> id3v2_parse_priv),
> > +AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
> AV_OPT_FLAG_DECODING_PARAM },
> > +{ NULL },
> > +};
> > +
> > +static const AVClass aac_class = {
> > +.class_name = "aac",
> > +.item_name  = av_default_item_name,
> > +.option = aac_options,
> > +.version= LIBAVUTIL_VERSION_INT,
> > +};
> > +
> >  AVInputFormat ff_aac_demuxer = {
> > -.name = "aac",
> > -.long_name= NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced Audio
> Coding)"),
> > -.read_probe   = adts_aac_probe,
> > -.read_header  = adts_aac_read_header,
> > -.read_packet  = adts_aac_read_packet,
> > -.flags= AVFMT_GENERIC_INDEX,
> > -.extensions   = "aac",
> > -.mime_type= "audio/aac,audio/aacp,audio/x-aac",
> > -.raw_codec_id = AV_CODEC_ID_AAC,
> > +.name   = "aac",
> > +.long_name  = NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced
> Audio Coding)"),
> > +.read_probe = adts_aac_probe,
> > +.read_header= adts_aac_read_header,
> > +.read_packet= adts_aac_read_packet,
> > +.flags  = AVFMT_GENERIC_INDEX,
> > +.priv_class = &aac_class,
> > +.priv_data_size = sizeof(AACDemuxContext),
> > +.extensions = "aac",
> > +.mime_type  = "audio/aac,audio/aacp,audio/x-aac",
> > +.raw_codec_id   = AV_CODEC_ID_AAC,
> >  };
>
> AAC and mp3 are by far not the only formats that can use ID3v2. FFmpeg
> accepts ID3v2 tags on basically all file formats. So just adding a
> private option to aac and mp3 doesn't make that much sense.


Fair point.

>
>
I'm also not sure if an option for compatibility is needed. It's
> probably fine to prefix the name with something (maybe "id3v2_priv."?),
> and always export it.
>

I guess my thought was that users of ffmpeg/ffprobe might have some
scripting or programming around the metadata API, such as dumping metadata
with -f ffmetadata and then mapping it to a stream later. In those cases,
this change might suddenly cause behavior that they weren't expecting.
Maybe that would be mitigated to some degree if we could also map
'id3v2_priv' back to PRIV tags on output. That would actually address a use
case that I have and would be super from my standpoint. I'll work on
implementing that. Please let me know if you have additional thoughts.

>
> > diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
> > index 6c216ba7a2..dd151dd7f2 100644
> > --- a/libavformat/id3v2.c
> > +++ b/libavformat/id3v2.c
> > @@ -33,6 +33,7 @@
> >  #endif
> >
> >  #include "libavutil/avstring.h"
> > +#include "libavutil/bprint.h"
> >  #i

Re: [FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-17 Thread wm4
On Wed, 17 Jan 2018 11:10:26 -0800
Richard Shaffer  wrote:

> [...]
> I'm also not sure if an option for compatibility is needed. It's
> > probably fine to prefix the name with something (maybe "id3v2_priv."?),
> > and always export it.
> >  
> 
> I guess my thought was that users of ffmpeg/ffprobe might have some
> scripting or programming around the metadata API, such as dumping metadata
> with -f ffmetadata and then mapping it to a stream later. In those cases,
> this change might suddenly cause behavior that they weren't expecting.

That's probably a lost cause. The "metadata" the FFmpeg API is full of
container specific things and rather arbitrary. I don't think it
matters to invent and export a few new keys.

What needs to be assured is that the entry names can't clash with
generic tag names (there's a list in avformat.h), which is why I
suggested adding a prefix to the name.

Although if metadata entries are very long (like big binary blobs)
there might be a problem. I don't know what's the use of those priv
tags though.

> Maybe that would be mitigated to some degree if we could also map
> 'id3v2_priv' back to PRIV tags on output. That would actually address a use
> case that I have and would be super from my standpoint. I'll work on
> implementing that. Please let me know if you have additional thoughts.

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


Re: [FFmpeg-devel] [PATCH] Adding mkdir option for img2enc (3rd attempt)

2018-01-17 Thread Marton Balint



On Wed, 17 Jan 2018, Dr. Alan Barclay wrote:


Hi,

Attached in a further patch - adding the error checks.

Derek - I don't think there is a functional downside to this 'mkdir' option 
being a default behaviour, but it would introduce a minor performance penalty 
(which users maybe don't want).


I'd rather keep the mkdir functionality disabled by default, from a 
security standpoint I don't really like the idea of an ordinary muxer 
creating dirs, replacing parts of the path as default behaviour...


Thanks,
Marton



All comments and help appreciated.

Thanks and Regards,
Alan.


On 27/12/2017 16:01, Derek Buitenhuis wrote:

Hi,

On 12/27/2017 12:27 PM, Dr Alan Barclay wrote:

Resending the two (git format-patch) patches, without the top lines
removed (which I thought I needed to do as some patch emails didn't seem
to have them).

All comments and help appreciated.


[...]


Subject: [PATCH 1/2] Move mkdir_p (renamed ff_mkdir_p) from hlsenc.c to
  utils.c.

---
  libavformat/hlsenc.c   | 35 +--
  libavformat/internal.h |  7 +++
  libavformat/utils.c| 33 +
  3 files changed, 41 insertions(+), 34 deletions(-)


On a technical level, this patch looks OK.


Subject: [PATCH 2/2] Adding mkdir option for img2enc.

---
  libavformat/img2enc.c | 8 
  1 file changed, 8 insertions(+)


I'm not sure how others feel about the premise (mkdir in img2enc).
I personally don't mind - though, maybe it should be default instead
of an option? (Maybe a bad idea.)


+if (img->use_mkdir) {
+char *temp_filename = av_strdup(filename);
+const char *temp_path = av_dirname(temp_filename);
+ff_mkdir_p(temp_path);
+av_free(temp_filename);
+}


This lacks error checks for av_strdup and ff_mkdir_p.

- Derek

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




--
Dr. Alan Barclay
Electric Scribe Ltd.
118 Stanley Street
Aberdeen AB10 6UQ, U.K.
+44 1224 591779 office
+44 7803 606485 mobile
a...@escribe.co.uk


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


Re: [FFmpeg-devel] avfilter/x86/vf_blend : add avx2 for 8b func (v2)

2018-01-17 Thread Martin Vignali
Hello,


New patch in attach

with modification in average, grain extract, multiply, screen, grain merge


-- blend Average --
Prev patch :
average_c: 15605.4
average_sse2: 1205.9
average_avx2: 772.4

New patch :
average_c: 15604.4
average_sse2: 490.9
average_avx2: 265.2

With 3 operand :
using
%if cpuflag(avx)
pxor m0, m2, [topq + xq]
pxor m1, m2, [bottomq + xq]
%else
movu   m0, [topq + xq]
movu   m1, [bottomq + xq]
pxor   m0, m2
pxor   m1, m2
%endif

average_c: 15615.5
average_sse2: 456.2
average_avx: 553.7
average_avx2: 387.0


And for grain extract, multiply, screen, grain merge
using mmsize process at each loop (instead of mmsize / 2)

-- Grain extract --
Prev :
grainextract_c: 22182.9
grainextract_sse2: 1158.9
grainextract_avx2: 777.6

New :
grainextract_c: 22206.5
grainextract_sse2: 964.8
grainextract_avx2: 485.3

-- Multiply --
Prev :
multiply_c: 41347.8
multiply_sse2: 1376.0
multiply_avx2: 840.0

New :
multiply_c: 40432.5
multiply_sse2: 1248.0
multiply_avx2: 635.0

-- Screen --
Prev :
screen_c: 21635.8
screen_sse2: 1801.5
screen_avx2: 1069.8

New :
screen_c: 21617.0
screen_sse2: 1625.7
screen_avx2: 840.2

-- Grain merge --
Prev :
grainmerge_c: 25233.5
grainmerge_sse2: 1158.0
grainmerge_avx2: 775.7

New :
grainmerge_c: 25246.7
grainmerge_sse2: 967.4
grainmerge_avx2: 487.7


Martin


0001-avfilter-x86-vf_blend-avfilter-x86-vf_blend-add-AVX2.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-17 Thread Richard Shaffer
On Wed, Jan 17, 2018 at 11:38 AM, wm4  wrote:

> On Wed, 17 Jan 2018 11:10:26 -0800
> Richard Shaffer  wrote:
>
> > [...]
> > I'm also not sure if an option for compatibility is needed. It's
> > > probably fine to prefix the name with something (maybe "id3v2_priv."?),
> > > and always export it.
> > >
> >
> > I guess my thought was that users of ffmpeg/ffprobe might have some
> > scripting or programming around the metadata API, such as dumping
> metadata
> > with -f ffmetadata and then mapping it to a stream later. In those cases,
> > this change might suddenly cause behavior that they weren't expecting.
>
> That's probably a lost cause. The "metadata" the FFmpeg API is full of
> container specific things and rather arbitrary. I don't think it
> matters to invent and export a few new keys.
>
> What needs to be assured is that the entry names can't clash with
> generic tag names (there's a list in avformat.h), which is why I
> suggested adding a prefix to the name.
>
> Although if metadata entries are very long (like big binary blobs)
> there might be a problem. I don't know what's the use of those priv
> tags though.
>

The tags that I have seen are short. However, most ID3v2 frames have a
maximum length of 256MB, even text information frames. If it is a concern,
we should probably implement a limit for ID3 tags generally.

>
> > Maybe that would be mitigated to some degree if we could also map
> > 'id3v2_priv' back to PRIV tags on output. That would actually address a
> use
> > case that I have and would be super from my standpoint. I'll work on
> > implementing that. Please let me know if you have additional thoughts.
>
> Probably makes sense.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] add dumpwave filter

2018-01-17 Thread Dmytro Humeniuk

> On 15 Jan 2018, at 13:48, Dmytro Humeniuk  wrote:
> 
>> 
>> On 15 Jan 2018, at 09:14, Tobias Rapp  wrote:
>> 
>> On 13.01.2018 23:52, Дмитрий Гуменюк wrote:
>>> Hi,
 On 13 Jan 2018, at 01:37, Дмитрий Гуменюк  
 wrote:
 
 Hi
 
> On 12 Jan 2018, at 13:32, Дмитрий Гуменюк  
> wrote:
> 
>> On 12 Jan 2018, at 13:17, Tobias Rapp  wrote:
>> 
>> On 12.01.2018 12:16, Дмитрий Гуменюк wrote:
>>> Hi
 On 11 Jan 2018, at 09:20, Tobias Rapp  wrote:
 
 On 10.01.2018 18:18, Kyle Swanson wrote:
> Hi,
> For this to be a part of libavfilter the output needs to be more 
> generic
> than the just the Soundcloud format. If we want this to be generally 
> useful
> it should probably just output an array of floats between 0.0 and 
> 1.0. The
> consumer of this data (JS library, or whatever) can use this in 
> whatever
> way it wants.
 
 I agree. If the BWF Peak Envelope output which was suggested in the 
 other thread does not match your demands and filter implementation is 
 actually necessary I would prefer if the filter would attach the RMS 
 value(s) as frame metadata instead of directly dumping to file. Frame 
 metadata can then be re-
>>> RMS values may be counted for several frames or only for a half of a 
>>> frame
 used by other filters or dumped into file by using the existing 
 "ametadata" filter.
 
 This would be similar to:
 
 ffmpeg -i input-file -f null -filter:a 
 "asetnsamples=22050,astats=metadata=on,ametadata=print:file=stats-file.dat"
  /dev/null
>>> I like this idea, but won’t asetnsamples affect performance by creating 
>>> fifo queue? And it may require some effort to parse long output
>> 
>> I added asetnsamples to define the audio frame size (interval of values 
>> from astats). You can reduce the number of lines printed by ametadata by 
>> using the "key=lavfi.astats.foo" option.
> I used asetnsamples as well, and I measured performance while transcoding 
> - it appears to be slight slower
 I think output is now more generic and I got rid of long switch/case, 
 thanks for support
>>> Here is most recent patch, seems like all comments are addressed, did I 
>>> miss something?
>> 
>> I still would prefer to have the value attached as frame metadata, then 
>> dumped into file via the existing "ametadata" filter. Even better would be 
>> to integrate the statistic value (if missing) into the "astats" filter.
>> 
>> If your concern is the output format of "ametadata" then some output format 
>> extension (CSV/JSON) needs to be discussed for ametadata/metadata.
>> 
>> If your concern is performance then please add some numbers. In my tests 
>> using an approx. 5 minutes input WAV file (48kHz, stereo) the run with 
>> "asetnsamples" was considerably faster than the run without (1.7s vs. 13.9s)
> Hi
> As I mentioned previously adding metadata to each frame is not possible
> as value may be counted for several frames or only for a half of a frame 
> 
> I used 2 hours long 48kHz mp3 
> https://s3-eu-west-1.amazonaws.com/balamii/SynthSystemSystersJAN2018.mp3
> For this purposes I set up CentOS AWS EC2 nano instance
> Then I transcoded it while filtering like following (just to recreate real 
> situation):
> 1. -filter:a 
> "asetnsamples=192197,astats=metadata=on,ametadata=print:file=stats-file.dat" 
> out.mp3
> 2. -filter:a "dumpwave=n=192197:f=-" out.mp3
> Results:
> 1. 244810550046 nanoseconds
> 2. 87494286740 nanoseconds
> 
> One of the possible use cases - to set up 2 chains of asetnsamples->metadata 
> - for example:
> "asetnsamples=192197,astats=metadata=on,ametadata=print:file=stats-file.dat,asetnsamples=22050,astats=metadata=on,ametadata=print:file=stats-file1.dat”
>  for sure it will affect performance
> Comparing with "dumpwave=n=192197:f=out1,dumpwave=n= 22050:f=out2”
> 
Ping
>> Regards,
>> Tobias
>> 
>> ___
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
—
Best regards,
Dmytro
From 64e953923a0c9f882afcced1d00ce572e0fafaeb Mon Sep 17 00:00:00 2001
From: Dmytro Humeniuk 
Date: Mon, 15 Jan 2018 00:01:25 +0100
Subject: [PATCH] avfilter: add dumpwave filter.

Signed-off-by: Dmytro Humeniuk 
---
 Changelog|1 +
 doc/filters.texi |   33 +-
 libavfilter/Makefile |1 +
 libavfilter/af_dumpwave.c|  234 +
 libavfilter/allfilters.c |1 +
 libavfilter/version.h|4 +-
 tests/fate-run.sh|9 +
 tests/fate/filter-audio.mak  |   12 +
 tests/ref/fate/filter-dumpwave   | 1800 ++
 tests/ref/fate/filter-dumpwave-24bit | 1800 +++

Re: [FFmpeg-devel] [PATCH 2/3] libavformat/dashdec: Fix for ticket 6658 (Dash demuxer segfault)

2018-01-17 Thread Colin NG
Believe the comment is related to the 3rd patch. The update version is attached.



From: 刘歧 
Sent: January 16, 2018 10:39 PM
To: FFmpeg development discussions and patches
Cc: 刘歧; Colin NG
Subject: Re: [FFmpeg-devel] [PATCH 2/3] libavformat/dashdec: Fix for ticket 
6658 (Dash demuxer segfault)


> On 17 Jan 2018, at 11:00, Colin NG  wrote:
>
> - Add function 'resolve_content_path' to propagate the baseURL from upper 
> level nodes.
> * if no baseURL is available, the path of mpd file will be set as the baseURL.
> - Remove checking for newly established connection.
> - Establish the communication protocol in each connection rather than 
> applying one protocol to all connection.
> ---
> libavformat/dashdec.c | 128 +-
> 1 file changed, 115 insertions(+), 13 deletions(-)
>
> diff --git a/libavformat/dashdec.c b/libavformat/dashdec.c
> index 67a92d6..1d520d4 100644
> --- a/libavformat/dashdec.c
> +++ b/libavformat/dashdec.c
> @@ -149,6 +149,11 @@ typedef struct DASHContext {
> AVDictionary *avio_opts;
> } DASHContext;
>
> +static int ishttp(char *url) {
> +const char *proto_name = avio_find_protocol_name(url);
> +return av_strstart(proto_name, "http", NULL);
> +}
> +
> static uint64_t get_current_time_in_sec(void)
> {
> return  av_gettime() / 100;
> @@ -420,7 +425,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, 
> const char *url,
> else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
> return AVERROR_INVALIDDATA;
>
> -ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);
> +av_freep(pb);
> +ret = avio_open2(pb, url, AVIO_FLAG_READ, c->interrupt_callback, &tmp);
> if (ret >= 0) {
> // update cookies on http response with setcookies.
> char *new_cookies = NULL;
> @@ -564,6 +570,7 @@ static struct fragment * get_Fragment(char *range)
> seg->url_offset = strtoll(str_offset, NULL, 10);
> seg->size = strtoll(str_end_offset, NULL, 10) - seg->url_offset;
> }
> +
> return seg;
> }
>
> @@ -591,6 +598,7 @@ static int parse_manifest_segmenturlnode(AVFormatContext 
> *s, struct representati
>  rep_id_val,
>  rep_bandwidth_val,
>  initialization_val);
> +
> if (!rep->init_section->url) {
> av_free(rep->init_section);
> xmlFree(initialization_val);
> @@ -665,6 +673,105 @@ static int 
> parse_manifest_segmenttimeline(AVFormatContext *s, struct representat
> return 0;
> }
>
> +static int resolve_content_path(AVFormatContext *s, const char *url, 
> xmlNodePtr *baseurl_nodes, int n_baseurl_nodes) {
> +
> +char *tmp_str = NULL;
> +char *path = NULL;
> +char *mpdName = NULL;
> +xmlNodePtr node = NULL;
> +char *baseurl = NULL;
> +char *root_url = NULL;
> +char *text = NULL;
> +
> +int isRootHttp = 0;
> +char token ='/';
> +int start =  0;
> +int rootId = 0;
> +int updated = 0;
> +int size = 0;
> +int i;
> +int max_url_size = strlen(url);
> +
> +for (i = n_baseurl_nodes-1; i >= 0 ; i--) {
> +text = xmlNodeGetContent(baseurl_nodes[i]);
> +if (!text)
> +continue;
> +max_url_size += strlen(text);
> +if (ishttp(text)) {
> +xmlFree(text);
> +break;
> +}
> +xmlFree(text);
> +}
> +
> +text = av_mallocz(max_url_size);
> +if (!text) {
> +updated = AVERROR(ENOMEM);
> +goto end;
> +}
> +av_strlcpy(text, url, strlen(url)+1);
> +while (mpdName = av_strtok(text, "/", &text))  {
> +size = strlen(mpdName);
> +}
> +
> +path = av_mallocz(max_url_size);
> +tmp_str = av_mallocz(max_url_size);
> +if (!tmp_str || !path) {
> +updated = AVERROR(ENOMEM);
> +goto end;
> +}
> +
> +av_strlcpy (path, url, strlen(url) - size + 1);
> +for (rootId = n_baseurl_nodes - 1; rootId > 0; rootId --) {
> +if (!(node = baseurl_nodes[rootId])) {
> +continue;
> +}
> +if (ishttp(xmlNodeGetContent(node))) {
> +break;
> +}
> +}
> +
> +node = baseurl_nodes[rootId];
> +baseurl = xmlNodeGetContent(node);
> +root_url = (av_strcasecmp(baseurl, "")) ? baseurl : path;
> +if (node) {
> +xmlNodeSetContent(node, root_url);
> +updated = 1;
> +}
> +
> +size = strlen(root_url);
> +isRootHttp = ishttp(root_url);
> +
> +if (root_url[size - 1] != token) {
> +av_strlcat(root_url, "/", size + 2);
> +size += 2;
> +}
> +
> +for (i = 0; i < n_baseurl_nodes; ++i) {
> +if (i == rootId) {
> +continue;
> +}
> +text = xmlNodeGetContent(baseurl_nodes[i]);
> +if (text) {
> +memset(tmp_str, 0, 

Re: [FFmpeg-devel] [PATCH] add dumpwave filter

2018-01-17 Thread Moritz Barsnick
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -680,13 +680,13 @@ select RIAA.
>  @item cd
>  select Compact Disc (CD).
>  @item 50fm
> -select 50??s (FM).
> +select 50??s (FM).
>  @item 75fm
> -select 75??s (FM).
> +select 75??s (FM).
>  @item 50kf
> -select 50??s (FM-KF).
> +select 50??s (FM-KF).
>  @item 75kf
> -select 75??s (FM-KF).
> +select 75??s (FM-KF).
>  @end table
>  @end table

Please review your own patches carefully. As you can see here, your
editor is changing other sections due to some charset options or so.
Please make sure that doesn't happen.

> +The default value is @var{1800}

You probably don't need to add markup to "1800" (and is it really a
@val? not @code?), especially:

> +Samples count per value per channel, default 128

as you didn't do that here either.

> +@item f, file
> +Path to a file ``-'' is a shorthand
> +for standard output.

There needs to be a comma or perios after "Path to a file".
Furthermore, you don't need to wrap your lines so short.


>  more details but also more artifacts, while higher values make the image 
> smoother
> -but also blurrier. Default value is @code{0} ??? PSNR optimal.
> +but also blurrier. Default value is @code{0} ??? PSNR optimal.

Your editor also changed this.

> +static const AVOption dumpwave_options[] = {
> +{ "w", "set number of data values",  OFFSET(width), AV_OPT_TYPE_INT,  
> {.i64 = 1800}, 1, INT_MAX, FLAGS },
> +{ "width", "set number of data values",  OFFSET(width), AV_OPT_TYPE_INT, 
>  {.i64 = 1800}, 1, INT_MAX, FLAGS },
> +{ "n", "set number of samples per value per channel",  
> OFFSET(nb_samples), AV_OPT_TYPE_INT64,  {.i64 = 128}, 1, INT64_MAX, FLAGS },
> +{ "nb_samples", "set number of samples per value per channel",  
> OFFSET(nb_samples), AV_OPT_TYPE_INT64,  {.i64 = 128}, 1, INT64_MAX, FLAGS },
> +{ "f", "set dump file", OFFSET(filename), AV_OPT_TYPE_STRING, { .str = 
> NULL }, 0, 0, FLAGS },
> +{ "file", "set dump file", OFFSET(filename), AV_OPT_TYPE_STRING, { .str 
> = NULL }, 0, 0, FLAGS },

Cosmetic: I suggest aligning these with some whitespace, which makes it
easier to recognize the duplicated options.

> +dumpwave->values = av_malloc(dumpwave->width * sizeof(float));
> +if (!dumpwave->values)
> +return AVERROR(ENOMEM);
> +memset(dumpwave->values, 0, dumpwave->width * sizeof(float));

av_mallocz()?

> +static inline void RMS(DumpWaveContext *dumpwave, const float sample)
  ^^^ I believe capitals are not desired here (but may be 
wrong)

> +if (sample != 0)

0.f

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


[FFmpeg-devel] [PATCH 1/4] avfilter/vf_framerate: unify luma and chroma blending

2018-01-17 Thread Marton Balint
The expressions were mathematically equvivalent...

Signed-off-by: Marton Balint 
---
 libavfilter/vf_framerate.c | 60 --
 1 file changed, 15 insertions(+), 45 deletions(-)

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index a5ae6ddb71..583c96e02c 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -196,32 +196,16 @@ static int filter_slice8(AVFilterContext *ctx, void *arg, 
int job, int nb_jobs)
 cpy_src2_data += start * cpy_src2_line_size;
 cpy_dst_data += start * cpy_dst_line_size;
 
-if (plane <1 || plane >2) {
-// luma or alpha
-for (line = start; line < end; line++) {
-for (pixel = 0; pixel < cpy_line_width; pixel++) {
-// integer version of (src1 * src1_factor) + (src2 + 
src2_factor) + 0.5
-// 0.5 is for rounding
-// 128 is the integer representation of 0.5 << 8
-cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * 
src1_factor) + (cpy_src2_data[pixel] * src2_factor) + 128) >> 8;
-}
-cpy_src1_data += cpy_src1_line_size;
-cpy_src2_data += cpy_src2_line_size;
-cpy_dst_data += cpy_dst_line_size;
-}
-} else {
-// chroma
-for (line = start; line < end; line++) {
-for (pixel = 0; pixel < cpy_line_width; pixel++) {
-// as above
-// because U and V are based around 128 we have to 
subtract 128 from the components.
-// 32896 is the integer representation of 128.5 << 8
-cpy_dst_data[pixel] = (((cpy_src1_data[pixel] - 128) * 
src1_factor) + ((cpy_src2_data[pixel] - 128) * src2_factor) + 32896) >> 8;
-}
-cpy_src1_data += cpy_src1_line_size;
-cpy_src2_data += cpy_src2_line_size;
-cpy_dst_data += cpy_dst_line_size;
+for (line = start; line < end; line++) {
+for (pixel = 0; pixel < cpy_line_width; pixel++) {
+// integer version of (src1 * src1_factor) + (src2 + 
src2_factor) + 0.5
+// 0.5 is for rounding
+// 128 is the integer representation of 0.5 << 8
+cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + 
(cpy_src2_data[pixel] * src2_factor) + 128) >> 8;
 }
+cpy_src1_data += cpy_src1_line_size;
+cpy_src2_data += cpy_src2_line_size;
+cpy_dst_data += cpy_dst_line_size;
 }
 }
 
@@ -235,7 +219,6 @@ static int filter_slice16(AVFilterContext *ctx, void *arg, 
int job, int nb_jobs)
 uint16_t src1_factor = td->src1_factor;
 uint16_t src2_factor = td->src2_factor;
 const int half = s->max / 2;
-const int uv = (s->max + 1) * half;
 const int shift = s->bitdepth;
 int plane, line, pixel;
 
@@ -254,25 +237,12 @@ static int filter_slice16(AVFilterContext *ctx, void 
*arg, int job, int nb_jobs)
 cpy_src2_data += start * cpy_src2_line_size;
 cpy_dst_data += start * cpy_dst_line_size;
 
-if (plane <1 || plane >2) {
-// luma or alpha
-for (line = start; line < end; line++) {
-for (pixel = 0; pixel < cpy_line_width; pixel++)
-cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * 
src1_factor) + (cpy_src2_data[pixel] * src2_factor) + half) >> shift;
-cpy_src1_data += cpy_src1_line_size;
-cpy_src2_data += cpy_src2_line_size;
-cpy_dst_data += cpy_dst_line_size;
-}
-} else {
-// chroma
-for (line = start; line < end; line++) {
-for (pixel = 0; pixel < cpy_line_width; pixel++) {
-cpy_dst_data[pixel] = (((cpy_src1_data[pixel] - half) * 
src1_factor) + ((cpy_src2_data[pixel] - half) * src2_factor) + uv) >> shift;
-}
-cpy_src1_data += cpy_src1_line_size;
-cpy_src2_data += cpy_src2_line_size;
-cpy_dst_data += cpy_dst_line_size;
-}
+for (line = start; line < end; line++) {
+for (pixel = 0; pixel < cpy_line_width; pixel++)
+cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + 
(cpy_src2_data[pixel] * src2_factor) + half) >> shift;
+cpy_src1_data += cpy_src1_line_size;
+cpy_src2_data += cpy_src2_line_size;
+cpy_dst_data += cpy_dst_line_size;
 }
 }
 
-- 
2.13.6

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


[FFmpeg-devel] [PATCH 2/4] avfilter/vf_framerate: factorize blend functions and unify filter_slice

2018-01-17 Thread Marton Balint
Signed-off-by: Marton Balint 
---
 libavfilter/vf_framerate.c | 108 -
 1 file changed, 57 insertions(+), 51 deletions(-)

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 583c96e02c..2a6d692eb0 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -39,6 +39,14 @@
 #include "internal.h"
 #include "video.h"
 
+#define BLEND_FUNC_PARAMS const uint8_t *src1, ptrdiff_t src1_linesize, \
+  const uint8_t *src2, ptrdiff_t src2_linesize, \
+  uint8_t *dst, ptrdiff_t dst_linesize, \
+  ptrdiff_t width, ptrdiff_t height, \
+  int factor1, int factor2, int half, int shift
+
+typedef void (*blend_func)(BLEND_FUNC_PARAMS);
+
 typedef struct FrameRateContext {
 const AVClass *class;
 // parameters
@@ -72,6 +80,8 @@ typedef struct FrameRateContext {
 int flush;  ///< 1 if the filter is being flushed
 int64_t start_pts;  ///< pts of the first output frame
 int64_t n;  ///< output frame counter
+
+blend_func blend;
 } FrameRateContext;
 
 #define OFFSET(x) offsetof(FrameRateContext, x)
@@ -173,13 +183,13 @@ typedef struct ThreadData {
 uint16_t src1_factor, src2_factor;
 } ThreadData;
 
-static int filter_slice8(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
+static int filter_slice(AVFilterContext *ctx, void *arg, int job, int nb_jobs)
 {
 FrameRateContext *s = ctx->priv;
 ThreadData *td = arg;
 uint16_t src1_factor = td->src1_factor;
 uint16_t src2_factor = td->src2_factor;
-int plane, line, pixel;
+int plane;
 
 for (plane = 0; plane < 4 && td->copy_src1->data[plane] && 
td->copy_src2->data[plane]; plane++) {
 int cpy_line_width = s->line_size[plane];
@@ -196,54 +206,11 @@ static int filter_slice8(AVFilterContext *ctx, void *arg, 
int job, int nb_jobs)
 cpy_src2_data += start * cpy_src2_line_size;
 cpy_dst_data += start * cpy_dst_line_size;
 
-for (line = start; line < end; line++) {
-for (pixel = 0; pixel < cpy_line_width; pixel++) {
-// integer version of (src1 * src1_factor) + (src2 + 
src2_factor) + 0.5
-// 0.5 is for rounding
-// 128 is the integer representation of 0.5 << 8
-cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + 
(cpy_src2_data[pixel] * src2_factor) + 128) >> 8;
-}
-cpy_src1_data += cpy_src1_line_size;
-cpy_src2_data += cpy_src2_line_size;
-cpy_dst_data += cpy_dst_line_size;
-}
-}
-
-return 0;
-}
-
-static int filter_slice16(AVFilterContext *ctx, void *arg, int job, int 
nb_jobs)
-{
-FrameRateContext *s = ctx->priv;
-ThreadData *td = arg;
-uint16_t src1_factor = td->src1_factor;
-uint16_t src2_factor = td->src2_factor;
-const int half = s->max / 2;
-const int shift = s->bitdepth;
-int plane, line, pixel;
-
-for (plane = 0; plane < 4 && td->copy_src1->data[plane] && 
td->copy_src2->data[plane]; plane++) {
-int cpy_line_width = s->line_size[plane];
-const uint16_t *cpy_src1_data = (const uint16_t 
*)td->copy_src1->data[plane];
-int cpy_src1_line_size = td->copy_src1->linesize[plane] / 2;
-const uint16_t *cpy_src2_data = (const uint16_t 
*)td->copy_src2->data[plane];
-int cpy_src2_line_size = td->copy_src2->linesize[plane] / 2;
-int cpy_src_h = (plane > 0 && plane < 3) ? (td->copy_src1->height >> 
s->vsub) : (td->copy_src1->height);
-uint16_t *cpy_dst_data = (uint16_t *)s->work->data[plane];
-int cpy_dst_line_size = s->work->linesize[plane] / 2;
-const int start = (cpy_src_h *  job   ) / nb_jobs;
-const int end   = (cpy_src_h * (job+1)) / nb_jobs;
-cpy_src1_data += start * cpy_src1_line_size;
-cpy_src2_data += start * cpy_src2_line_size;
-cpy_dst_data += start * cpy_dst_line_size;
-
-for (line = start; line < end; line++) {
-for (pixel = 0; pixel < cpy_line_width; pixel++)
-cpy_dst_data[pixel] = ((cpy_src1_data[pixel] * src1_factor) + 
(cpy_src2_data[pixel] * src2_factor) + half) >> shift;
-cpy_src1_data += cpy_src1_line_size;
-cpy_src2_data += cpy_src2_line_size;
-cpy_dst_data += cpy_dst_line_size;
-}
+s->blend(cpy_src1_data, cpy_src1_line_size,
+ cpy_src2_data, cpy_src2_line_size,
+ cpy_dst_data,  cpy_dst_line_size,
+ cpy_line_width, end - start,
+ src1_factor, src2_factor, s->max / 2, s->bitdepth);
 }
 
 return 0;
@@ -278,7 +245,7 @@ static int blend_frames(AVFilterContext *ctx, int 
interpolate)
 av_frame_copy_props(s->work, s->f0);
 
 ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
-   

[FFmpeg-devel] [PATCH 4/4] avfilter/vf_framerate: add SIMD functions for frame blending

2018-01-17 Thread Marton Balint
Blend function speedups on x86_64 Core i5 4460:

ffmpeg -f lavfi -i allyuv -vf framerate=60:threads=1 -f null none

C: 447548411 decicycles in Blend,2048 runs,  0 skips
SSSE3: 130020087 decicycles in Blend,2048 runs,  0 skips
AVX2:  128508221 decicycles in Blend,2048 runs,  0 skips

ffmpeg -f lavfi -i allyuv -vf format=yuv420p12,framerate=60:threads=1 -f null 
none

C: 228932745 decicycles in Blend,2048 runs,  0 skips
SSE4:  123357781 decicycles in Blend,2048 runs,  0 skips
AVX2:  121215353 decicycles in Blend,2048 runs,  0 skips

Signed-off-by: Marton Balint 
---
 libavfilter/vf_framerate.c   |  24 ++-
 libavfilter/x86/Makefile |   1 +
 libavfilter/x86/vf_framerate.asm | 131 +++
 3 files changed, 153 insertions(+), 3 deletions(-)
 create mode 100644 libavfilter/x86/vf_framerate.asm

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index d315ef5d09..1c10699c3a 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -29,11 +29,13 @@
 #define DEBUG
 
 #include "libavutil/avassert.h"
+#include "libavutil/cpu.h"
 #include "libavutil/imgutils.h"
 #include "libavutil/internal.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "libavutil/pixelutils.h"
+#include "libavutil/x86/cpu.h"
 
 #include "avfilter.h"
 #include "internal.h"
@@ -246,7 +248,7 @@ static int blend_frames(AVFilterContext *ctx, int 
interpolate)
 av_frame_copy_props(s->work, s->f0);
 
 ff_dlog(ctx, "blend_frames() INTERPOLATE to create work frame\n");
-ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, 
ff_filter_get_nb_threads(ctx)));
+ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(FFMAX(1, 
outlink->h >> 2), ff_filter_get_nb_threads(ctx)));
 return 1;
 }
 return 0;
@@ -347,6 +349,11 @@ static void blend_frames_c(BLEND_FUNC_PARAMS)
 }
 }
 
+void ff_blend_frames_ssse3(BLEND_FUNC_PARAMS);
+void ff_blend_frames_avx2(BLEND_FUNC_PARAMS);
+void ff_blend_frames16_sse4(BLEND_FUNC_PARAMS);
+void ff_blend_frames16_avx2(BLEND_FUNC_PARAMS);
+
 static void blend_frames16_c(BLEND_FUNC_PARAMS)
 {
 int line, pixel;
@@ -371,6 +378,7 @@ static int config_input(AVFilterLink *inlink)
 AVFilterContext *ctx = inlink->dst;
 FrameRateContext *s = ctx->priv;
 const AVPixFmtDescriptor *pix_desc = av_pix_fmt_desc_get(inlink->format);
+int cpu_flags = av_get_cpu_flags();
 int plane;
 
 for (plane = 0; plane < 4; plane++) {
@@ -389,10 +397,20 @@ static int config_input(AVFilterLink *inlink)
 
 if (s->bitdepth == 8) {
 s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH8;
-s->blend = blend_frames_c;
+if (ARCH_X86 && EXTERNAL_AVX2(cpu_flags))
+s->blend = ff_blend_frames_avx2;
+else if (ARCH_X86 && EXTERNAL_SSSE3(cpu_flags))
+s->blend = ff_blend_frames_ssse3;
+else
+s->blend = blend_frames_c;
 } else {
 s->blend_factor_max = 1 << BLEND_FACTOR_DEPTH16;
-s->blend = blend_frames16_c;
+if (ARCH_X86 && EXTERNAL_AVX2(cpu_flags))
+s->blend = ff_blend_frames16_avx2;
+else if (ARCH_X86 && EXTERNAL_SSE4(cpu_flags))
+s->blend = ff_blend_frames16_sse4;
+else
+s->blend = blend_frames16_c;
 }
 
 return 0;
diff --git a/libavfilter/x86/Makefile b/libavfilter/x86/Makefile
index 2fc5c62644..07fc0f9486 100644
--- a/libavfilter/x86/Makefile
+++ b/libavfilter/x86/Makefile
@@ -31,6 +31,7 @@ X86ASM-OBJS-$(CONFIG_AFIR_FILTER)+= x86/af_afir.o
 X86ASM-OBJS-$(CONFIG_BLEND_FILTER)   += x86/vf_blend.o
 X86ASM-OBJS-$(CONFIG_BWDIF_FILTER)   += x86/vf_bwdif.o
 X86ASM-OBJS-$(CONFIG_COLORSPACE_FILTER)  += x86/colorspacedsp.o
+X86ASM-OBJS-$(CONFIG_FRAMERATE_FILTER)   += x86/vf_framerate.o
 X86ASM-OBJS-$(CONFIG_FSPP_FILTER)+= x86/vf_fspp.o
 X86ASM-OBJS-$(CONFIG_GRADFUN_FILTER) += x86/vf_gradfun.o
 X86ASM-OBJS-$(CONFIG_HFLIP_FILTER)   += x86/vf_hflip.o
diff --git a/libavfilter/x86/vf_framerate.asm b/libavfilter/x86/vf_framerate.asm
new file mode 100644
index 00..0b1bed821f
--- /dev/null
+++ b/libavfilter/x86/vf_framerate.asm
@@ -0,0 +1,131 @@
+;*
+;* x86-optimized functions for framerate filter
+;*
+;* Copyright (C) 2018 Marton Balint
+;*
+;* Based on vf_blend.asm, Copyright (C) 2015 Paul B Mahol
+;*
+;* 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
+;* MERCHAN

[FFmpeg-devel] [PATCH 3/4] avfilter/vf_framerate: change blend factor precision

2018-01-17 Thread Marton Balint
This is done mainly in preparation for the SIMD patches.

- for the 8-bit input, decrease the blend factor precision to 7-bit.
- for the 16-bit input, increase the blend factor precision to 15-bit.
- make sure the blend functions are not called with 0 or maximum blending
  factors, because we don't want the signed factor integers to overflow.

Fate test changes are due to different rounding.

Signed-off-by: Marton Balint 
---
 libavfilter/vf_framerate.c | 54 ++--
 tests/ref/fate/filter-framerate-12bit-down | 80 +++---
 tests/ref/fate/filter-framerate-12bit-up   | 78 ++---
 tests/ref/fate/filter-framerate-up |  8 +--
 4 files changed, 109 insertions(+), 111 deletions(-)

diff --git a/libavfilter/vf_framerate.c b/libavfilter/vf_framerate.c
index 2a6d692eb0..d315ef5d09 100644
--- a/libavfilter/vf_framerate.c
+++ b/libavfilter/vf_framerate.c
@@ -43,7 +43,10 @@
   const uint8_t *src2, ptrdiff_t src2_linesize, \
   uint8_t *dst, ptrdiff_t dst_linesize, \
   ptrdiff_t width, ptrdiff_t height, \
-  int factor1, int factor2, int half, int shift
+  int factor1, int factor2, int half
+
+#define BLEND_FACTOR_DEPTH8   7
+#define BLEND_FACTOR_DEPTH16 15
 
 typedef void (*blend_func)(BLEND_FUNC_PARAMS);
 
@@ -53,10 +56,8 @@ typedef struct FrameRateContext {
 AVRational dest_frame_rate; ///< output frames per second
 int flags;  ///< flags affecting frame rate 
conversion algorithm
 double scene_score; ///< score that denotes a scene change 
has happened
-int interp_start;   ///< start of range to apply linear 
interpolation (same bitdepth as input)
-int interp_end; ///< end of range to apply linear 
interpolation (same bitdepth as input)
-int interp_start_param; ///< start of range to apply linear 
interpolation
-int interp_end_param;   ///< end of range to apply linear 
interpolation
+int interp_start;   ///< start of range to apply linear 
interpolation
+int interp_end; ///< end of range to apply linear 
interpolation
 
 int line_size[4];   ///< bytes of pixel data per line for 
each plane
 int vsub;
@@ -67,7 +68,7 @@ typedef struct FrameRateContext {
 av_pixelutils_sad_fn sad;   ///< Sum of the absolute difference 
function (scene detect only)
 double prev_mafd;   ///< previous MAFD 
  (scene detect only)
 
-int max;
+int blend_factor_max;
 int bitdepth;
 AVFrame *work;
 
@@ -92,8 +93,8 @@ typedef struct FrameRateContext {
 static const AVOption framerate_options[] = {
 {"fps", "required output frames per second rate", 
OFFSET(dest_frame_rate), AV_OPT_TYPE_VIDEO_RATE, {.str="50"}, 0,
   INT_MAX, V|F },
 
-{"interp_start","point to start linear interpolation",
OFFSET(interp_start_param),AV_OPT_TYPE_INT,{.i64=15}, 0,
   255, V|F },
-{"interp_end",  "point to end linear interpolation",  
OFFSET(interp_end_param),  AV_OPT_TYPE_INT,{.i64=240},0,
   255, V|F },
+{"interp_start","point to start linear interpolation",
OFFSET(interp_start),AV_OPT_TYPE_INT,  {.i64=15}, 0,
   256, V|F },
+{"interp_end",  "point to end linear interpolation",  
OFFSET(interp_end),  AV_OPT_TYPE_INT,  {.i64=240},0,
   256, V|F },
 {"scene",   "scene change level", 
OFFSET(scene_score), AV_OPT_TYPE_DOUBLE,   {.dbl=8.2},0,
   INT_MAX, V|F },
 
 {"flags",   "set flags",  
OFFSET(flags),   AV_OPT_TYPE_FLAGS,{.i64=1},  0,
   INT_MAX, V|F, "flags" },
@@ -210,7 +211,7 @@ static int filter_slice(AVFilterContext *ctx, void *arg, 
int job, int nb_jobs)
  cpy_src2_data, cpy_src2_line_size,
  cpy_dst_data,  cpy_dst_line_size,
  cpy_line_width, end - start,
- src1_factor, src2_factor, s->max / 2, s->bitdepth);
+ src1_factor, src2_factor, s->blend_factor_max >> 1);
 }
 
 return 0;
@@ -235,7 +236,7 @@ static int blend_frames(AVFilterContext *ctx, int 
interpolate)
 td.copy_src1 = s->f0;
 td.copy_src2 = s->f1;
 td.src2_factor = interpolate;
-td.src1_factor = s->max - td.src2_factor;
+td.src1_factor = s->blend_factor_max - td.src2_factor;
 
 // get work-space for output frame
 s->work = ff_get_video_buffer(outlink, outlink->w, outlink->h);
@@ -255,7 +256,7 @@ static int process_work_frame(AVFilterCont

[FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-17 Thread rshaffer
From: Richard Shaffer 

Enables getting access to ID3 PRIV tags from the command-line or metadata API
when demuxing. The PRIV owner is stored as the metadata key prepended with
"id3v2_priv.", and the data is stored as the metadata value. As PRIV tags may
contain arbitrary data, non-printable characters, including NULL bytes, are
escaped as \xXX.

Similarly, any metadata tags that begin with "id3v2_priv." are inserted as ID3
PRIV tags into the output (assuming the format supports ID3). \xXX sequences in
the value are un-escaped to their byte value.
---

I've taken a second try at this given wm4's comments. If you don't mind having 
a second look, I'd really appreciate it.

Thanks,

-Richard

 libavformat/id3v2.c| 48 
 libavformat/id3v2.h| 15 +
 libavformat/id3v2enc.c | 59 ++
 libavformat/utils.c|  2 ++
 4 files changed, 124 insertions(+)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 6c216ba7a2..e46174d7c7 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -33,6 +33,7 @@
 #endif
 
 #include "libavutil/avstring.h"
+#include "libavutil/bprint.h"
 #include "libavutil/dict.h"
 #include "libavutil/intreadwrite.h"
 #include "avio_internal.h"
@@ -1224,3 +1225,50 @@ end:
 av_freep(&chapters);
 return ret;
 }
+
+int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta 
**extra_meta)
+{
+ID3v2ExtraMeta *cur;
+int dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_KEY | 
AV_DICT_DONT_STRDUP_VAL;
+
+for (cur = *extra_meta; cur; cur = cur->next) {
+if (!strcmp(cur->tag, "PRIV")) {
+ID3v2ExtraMetaPRIV *priv = cur->data;
+AVBPrint bprint;
+char * escaped, * key;
+int i, ret;
+
+if ((key = av_asprintf(ID3v2_PRIV_METADATA_PREFIX "%s", 
priv->owner)) == NULL) {
+return AVERROR(ENOMEM);
+}
+
+av_bprint_init(&bprint, priv->datasize + 1, 
AV_BPRINT_SIZE_UNLIMITED);
+
+for (i = 0; i < priv->datasize; i++) {
+if (priv->data[i] < 32 || priv->data[i] > 126 || priv->data[i] 
== '\\') {
+av_bprintf(&bprint, "\\x%02x", priv->data[i]);
+} else {
+av_bprint_chars(&bprint, priv->data[i], 1);
+}
+}
+
+if ((ret = av_bprint_finalize(&bprint, &escaped)) < 0) {
+av_free(key);
+return ret;
+}
+
+if ((ret = av_dict_set(metadata, key, escaped, dict_flags)) < 0) {
+av_free(key);
+av_free(escaped);
+return ret;
+}
+}
+}
+
+return 0;
+}
+
+int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
+{
+return ff_id3v2_parse_priv_dict(&s->metadata, extra_meta);
+}
\ No newline at end of file
diff --git a/libavformat/id3v2.h b/libavformat/id3v2.h
index 5e64ead096..9de0bee374 100644
--- a/libavformat/id3v2.h
+++ b/libavformat/id3v2.h
@@ -39,6 +39,8 @@
 #define ID3v2_FLAG_ENCRYPTION  0x0004
 #define ID3v2_FLAG_COMPRESSION 0x0008
 
+#define ID3v2_PRIV_METADATA_PREFIX "id3v2_priv."
+
 enum ID3v2Encoding {
 ID3v2_ENCODING_ISO8859  = 0,
 ID3v2_ENCODING_UTF16BOM = 1,
@@ -167,6 +169,19 @@ int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta 
**extra_meta);
  */
 int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
 
+/**
+ * Parse PRIV tags into a dictionary. The PRIV owner is the metadata key. The
+ * PRIV data is the value, with non-printable characters escaped.
+ */
+int ff_id3v2_parse_priv_dict(AVDictionary **d, ID3v2ExtraMeta **extra_meta);
+
+/**
+ * Add metadata for all PRIV tags in the ID3v2 header. The PRIV owner is the
+ * metadata key. The PRIV data is the value, with non-printable characters
+ * escaped.
+ */
+int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
+
 extern const AVMetadataConv ff_id3v2_34_metadata_conv[];
 extern const AVMetadataConv ff_id3v2_4_metadata_conv[];
 
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 14de76ac06..2a8cc35cdc 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -96,6 +96,58 @@ static int id3v2_put_ttag(ID3v2EncContext *id3, AVIOContext 
*avioc, const char *
 return len + ID3v2_HEADER_SIZE;
 }
 
+/**
+ * Write a priv frame with owner and data. 'key' is the owner prepended with
+ * ID3v2_PRIV_METADATA_PREFIX. 'data' is provided as a string. Any \xXX
+ * (where 'X' is a valid hex digit) will be unescaped to the byte value.
+ */
+static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const char 
*key, const char *data)
+{
+int len;
+uint8_t *pb;
+AVIOContext *dyn_buf;
+
+if (!av_strstart(key, ID3v2_PRIV_METADATA_PREFIX, &key)) {
+return 0;
+}
+
+if (avio_open_dyn_buf(&dyn_buf) < 0)
+return AVERROR(ENOMEM);
+
+//

Re: [FFmpeg-devel] [PATCH V2 4/5] lavfi: add ProcAmp(color balance) vaapi video filter.

2018-01-17 Thread Jun Zhao


On 2018/1/17 19:00, Moritz Barsnick wrote:
> On Wed, Jan 17, 2018 at 10:49:21 +0800, Jun Zhao wrote:
>>  configure  |   1 +
>>  libavfilter/Makefile   |   1 +
>>  libavfilter/allfilters.c   |   1 +
>>  libavfilter/vf_procamp_vaapi.c | 230 
>> +
>>  4 files changed, 233 insertions(+)
> The newly added filters require a doc (texi) entry, a changelog entry,
> and a minor version bump.
>
> Cheers,
> Moritz
Thanks, will submit a other patch to add a new doc enrty/changelog entry
and bump the minor version.
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


Re: [FFmpeg-devel] [PATCH V2 2/5] lavfi: use common VPP infrastructure for vf_scale_vaapi.

2018-01-17 Thread Michael Niedermayer
On Wed, Jan 17, 2018 at 10:49:01AM +0800, Jun Zhao wrote:
> 

>  Makefile |2 
>  vf_scale_vaapi.c |  350 
> ++-
>  2 files changed, 41 insertions(+), 311 deletions(-)
> 1817904aa549f9226b7628eb3201dd8b88b6233d  
> 0002-lavfi-use-common-VPP-infrastructure-for-vf_scale_vaa.patch
> From 415c5da45adfb09b7f083e0d912be7033bd44876 Mon Sep 17 00:00:00 2001
> From: Jun Zhao 
> Date: Mon, 8 Jan 2018 16:02:35 +0800
> Subject: [PATCH V2 2/5] lavfi: use common VPP infrastructure for
>  vf_scale_vaapi.
> 
> Use the common VPP infrastructure re-work vf_scale_vaapi.
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/Makefile |   2 +-
>  libavfilter/vf_scale_vaapi.c | 350 
> +--
>  2 files changed, 41 insertions(+), 311 deletions(-)

this togethger with patch one of the patchset fails to build

AR  libavdevice/libavdevice.a
CC  libavfilter/vaapi_vpp.o
In file included from libavfilter/vaapi_vpp.c:25:0:
libavfilter/vaapi_vpp.h:47:31: error: ‘VAProcFilterCount’ undeclared here (not 
in a function)
 VABufferID filter_buffers[VAProcFilterCount];
   ^
libavfilter/vaapi_vpp.h:82:30: error: unknown type name 
‘VAProcPipelineParameterBuffer’


[...]

-- 
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf


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


[FFmpeg-devel] [PATCH] avformat: add option to parse/store ID3 PRIV tags in metadata.

2018-01-17 Thread rshaffer
From: Richard Shaffer 

Enables getting access to ID3 PRIV tags from the command-line or metadata API
when demuxing. The PRIV owner is stored as the metadata key prepended with
"id3v2_priv.", and the data is stored as the metadata value. As PRIV tags may
contain arbitrary data, non-printable characters, including NULL bytes, are
escaped as \xXX.

Similarly, any metadata tags that begin with "id3v2_priv." are inserted as ID3
PRIV tags into the output (assuming the format supports ID3). \xXX sequences in
the value are un-escaped to their byte value.
---

Sorry. One more update. I realized there was a possibility of reading past the
end of input in id3v2_put_priv, so I added a fix.

-Richard

 libavformat/id3v2.c| 48 +
 libavformat/id3v2.h| 15 
 libavformat/id3v2enc.c | 64 ++
 libavformat/utils.c|  2 ++
 4 files changed, 129 insertions(+)

diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index 6c216ba7a2..e46174d7c7 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -33,6 +33,7 @@
 #endif
 
 #include "libavutil/avstring.h"
+#include "libavutil/bprint.h"
 #include "libavutil/dict.h"
 #include "libavutil/intreadwrite.h"
 #include "avio_internal.h"
@@ -1224,3 +1225,50 @@ end:
 av_freep(&chapters);
 return ret;
 }
+
+int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta 
**extra_meta)
+{
+ID3v2ExtraMeta *cur;
+int dict_flags = AV_DICT_DONT_OVERWRITE | AV_DICT_DONT_STRDUP_KEY | 
AV_DICT_DONT_STRDUP_VAL;
+
+for (cur = *extra_meta; cur; cur = cur->next) {
+if (!strcmp(cur->tag, "PRIV")) {
+ID3v2ExtraMetaPRIV *priv = cur->data;
+AVBPrint bprint;
+char * escaped, * key;
+int i, ret;
+
+if ((key = av_asprintf(ID3v2_PRIV_METADATA_PREFIX "%s", 
priv->owner)) == NULL) {
+return AVERROR(ENOMEM);
+}
+
+av_bprint_init(&bprint, priv->datasize + 1, 
AV_BPRINT_SIZE_UNLIMITED);
+
+for (i = 0; i < priv->datasize; i++) {
+if (priv->data[i] < 32 || priv->data[i] > 126 || priv->data[i] 
== '\\') {
+av_bprintf(&bprint, "\\x%02x", priv->data[i]);
+} else {
+av_bprint_chars(&bprint, priv->data[i], 1);
+}
+}
+
+if ((ret = av_bprint_finalize(&bprint, &escaped)) < 0) {
+av_free(key);
+return ret;
+}
+
+if ((ret = av_dict_set(metadata, key, escaped, dict_flags)) < 0) {
+av_free(key);
+av_free(escaped);
+return ret;
+}
+}
+}
+
+return 0;
+}
+
+int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta **extra_meta)
+{
+return ff_id3v2_parse_priv_dict(&s->metadata, extra_meta);
+}
\ No newline at end of file
diff --git a/libavformat/id3v2.h b/libavformat/id3v2.h
index 5e64ead096..9de0bee374 100644
--- a/libavformat/id3v2.h
+++ b/libavformat/id3v2.h
@@ -39,6 +39,8 @@
 #define ID3v2_FLAG_ENCRYPTION  0x0004
 #define ID3v2_FLAG_COMPRESSION 0x0008
 
+#define ID3v2_PRIV_METADATA_PREFIX "id3v2_priv."
+
 enum ID3v2Encoding {
 ID3v2_ENCODING_ISO8859  = 0,
 ID3v2_ENCODING_UTF16BOM = 1,
@@ -167,6 +169,19 @@ int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta 
**extra_meta);
  */
 int ff_id3v2_parse_chapters(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
 
+/**
+ * Parse PRIV tags into a dictionary. The PRIV owner is the metadata key. The
+ * PRIV data is the value, with non-printable characters escaped.
+ */
+int ff_id3v2_parse_priv_dict(AVDictionary **d, ID3v2ExtraMeta **extra_meta);
+
+/**
+ * Add metadata for all PRIV tags in the ID3v2 header. The PRIV owner is the
+ * metadata key. The PRIV data is the value, with non-printable characters
+ * escaped.
+ */
+int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta **extra_meta);
+
 extern const AVMetadataConv ff_id3v2_34_metadata_conv[];
 extern const AVMetadataConv ff_id3v2_4_metadata_conv[];
 
diff --git a/libavformat/id3v2enc.c b/libavformat/id3v2enc.c
index 14de76ac06..d5e358c8b6 100644
--- a/libavformat/id3v2enc.c
+++ b/libavformat/id3v2enc.c
@@ -96,6 +96,63 @@ static int id3v2_put_ttag(ID3v2EncContext *id3, AVIOContext 
*avioc, const char *
 return len + ID3v2_HEADER_SIZE;
 }
 
+/**
+ * Write a priv frame with owner and data. 'key' is the owner prepended with
+ * ID3v2_PRIV_METADATA_PREFIX. 'data' is provided as a string. Any \xXX
+ * (where 'X' is a valid hex digit) will be unescaped to the byte value.
+ */
+static int id3v2_put_priv(ID3v2EncContext *id3, AVIOContext *avioc, const char 
*key, const char *data)
+{
+int len;
+uint8_t *pb;
+AVIOContext *dyn_buf;
+
+if (!av_strstart(key, ID3v2_PRIV_METADATA_PREFIX, &key)) {
+return 0;
+}
+
+if (avio_open_dyn_buf(&dyn_buf) < 0)
+return AVERROR(ENOMEM);
+
+// owne

Re: [FFmpeg-devel] [PATCH V2 2/5] lavfi: use common VPP infrastructure for vf_scale_vaapi.

2018-01-17 Thread Jun Zhao


On 2018/1/18 8:29, Michael Niedermayer wrote:
> On Wed, Jan 17, 2018 at 10:49:01AM +0800, Jun Zhao wrote:
>>  Makefile |2 
>>  vf_scale_vaapi.c |  350 
>> ++-
>>  2 files changed, 41 insertions(+), 311 deletions(-)
>> 1817904aa549f9226b7628eb3201dd8b88b6233d  
>> 0002-lavfi-use-common-VPP-infrastructure-for-vf_scale_vaa.patch
>> From 415c5da45adfb09b7f083e0d912be7033bd44876 Mon Sep 17 00:00:00 2001
>> From: Jun Zhao 
>> Date: Mon, 8 Jan 2018 16:02:35 +0800
>> Subject: [PATCH V2 2/5] lavfi: use common VPP infrastructure for
>>  vf_scale_vaapi.
>>
>> Use the common VPP infrastructure re-work vf_scale_vaapi.
>>
>> Signed-off-by: Jun Zhao 
>> ---
>>  libavfilter/Makefile |   2 +-
>>  libavfilter/vf_scale_vaapi.c | 350 
>> +--
>>  2 files changed, 41 insertions(+), 311 deletions(-)
> this togethger with patch one of the patchset fails to build
>
> ARlibavdevice/libavdevice.a
> CClibavfilter/vaapi_vpp.o
> In file included from libavfilter/vaapi_vpp.c:25:0:
> libavfilter/vaapi_vpp.h:47:31: error: ‘VAProcFilterCount’ undeclared here 
> (not in a function)
>  VABufferID filter_buffers[VAProcFilterCount];
>^
> libavfilter/vaapi_vpp.h:82:30: error: unknown type name 
> ‘VAProcPipelineParameterBuffer’
Will double-check and fix the build fail, Thanks.
>
> [...]
>
>
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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


[FFmpeg-devel] RTMPS to FFM

2018-01-17 Thread Gonzalo Martinez
Hi I have a client written in C++ that use a Hardware Encoder called Cedar
and Stream the Video and Audio to my RTMPS server but now I need to change
that to Stream locally to a ffserver.

The problem that I have when modify the URL from rtmps to
http://localhost:8090/feed1.ffm is an error in DTS. Specially this.

I/HipcamCameraJNI(  786): sending video pts=880919, dts=9223372036854775808
I/ffmpeg  (  786): Application provided invalid, non monotonically
increasing dts to muxer in stream 0: 800821 >= 800821
E/HipcamCameraJNI(  786): Error while writing video frame: Invalid argument

I need to contract someone to help with this bug, I have an environment
with the build and the code and you can test with me in the camera that is
android based.

Please let me know if someone can take this job or if you need more details
about the error.

Thanks


-- 
Gonzalo Martinez
*blog.deploshark.com *
www.deploshark.com
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH 1/2] lavc: Add coded_w/h to AVCodecParameters

2018-01-17 Thread Zhong Li
coded_width/height may be different from width/height sometimes
(e.g, crop or lowres cases).
ffprobe always show coded_width/height same as width/height since they
are overwritten.
This fixes tiket #6958.

Signed-off-by: Zhong Li 
---
 libavcodec/avcodec.h | 7 +++
 libavcodec/utils.c   | 4 
 libavcodec/version.h | 2 +-
 3 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 8fbbc79..710e90c 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3905,6 +3905,13 @@ typedef struct AVCodecParameters {
 int height;
 
 /**
+ * Video only. The dimensions of the coded video frame in pixels.
+ *
+ */
+int coded_width;
+int coded_height;
+
+/**
  * Video only. The aspect ratio (width / height) which a single pixel
  * should have when displayed.
  *
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 4c71843..427f612 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -2147,6 +2147,8 @@ int avcodec_parameters_from_context(AVCodecParameters 
*par,
 par->format  = codec->pix_fmt;
 par->width   = codec->width;
 par->height  = codec->height;
+par->coded_width = codec->coded_width;
+par->coded_height= codec->coded_height;
 par->field_order = codec->field_order;
 par->color_range = codec->color_range;
 par->color_primaries = codec->color_primaries;
@@ -2202,6 +2204,8 @@ int avcodec_parameters_to_context(AVCodecContext *codec,
 codec->pix_fmt= par->format;
 codec->width  = par->width;
 codec->height = par->height;
+codec->coded_width= par->coded_width;
+codec->coded_height   = par->coded_height;
 codec->field_order= par->field_order;
 codec->color_range= par->color_range;
 codec->color_primaries= par->color_primaries;
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 47a15d5..ec536bf 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR  58
 #define LIBAVCODEC_VERSION_MINOR   9
-#define LIBAVCODEC_VERSION_MICRO 100
+#define LIBAVCODEC_VERSION_MICRO 101
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
LIBAVCODEC_VERSION_MINOR, \
-- 
1.8.3.1

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


[FFmpeg-devel] [PATCH V2 2/2] Don't overwrite previously setup dimensions for all codecs

2018-01-17 Thread Zhong Li
Currently a hacky way is used for some specific codecs such as
H264/VP6F/DXV (and "lowres" case is broken now).
Replace with a more generic way(an evolution based on a libav commit
9de9b828 but hasn't been merged since it breaks lowres).

V1->V2: add "lowres" handle code

Signed-off-by: Zhong Li 
---
 libavcodec/utils.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 427f612..fdd1b46 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -684,16 +684,12 @@ int attribute_align_arg avcodec_open2(AVCodecContext 
*avctx, const AVCodec *code
 goto free_and_end;
 }
 
-// only call ff_set_dimensions() for non H.264/VP6F/DXV codecs so as not 
to overwrite previously setup dimensions
-if (!(avctx->coded_width && avctx->coded_height && avctx->width && 
avctx->height &&
-  (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == 
AV_CODEC_ID_VP6F || avctx->codec_id == AV_CODEC_ID_DXV))) {
-if (avctx->coded_width && avctx->coded_height)
+if (avctx->coded_width && avctx->coded_height && (!avctx->width && 
!avctx->height || avctx->lowles))
 ret = ff_set_dimensions(avctx, avctx->coded_width, 
avctx->coded_height);
-else if (avctx->width && avctx->height)
+else if (avctx->width && avctx->height && (!avctx->coded_width && 
!avctx->coded_height || avctx->lowles))
 ret = ff_set_dimensions(avctx, avctx->width, avctx->height);
 if (ret < 0)
 goto free_and_end;
-}
 
 if ((avctx->coded_width || avctx->coded_height || avctx->width || 
avctx->height)
 && (  av_image_check_size2(avctx->coded_width, avctx->coded_height, 
avctx->max_pixels, AV_PIX_FMT_NONE, 0, avctx) < 0
-- 
1.8.3.1

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


[FFmpeg-devel] [PATCH V3 1/6] lavfi: VAAPI VPP common infrastructure.

2018-01-17 Thread Jun Zhao

V3: - Fix the error handle in vaapi_vpp.
    - Fix the build issue and remove the duplicated header file
- Add a entry to Changelog for procamp_vaapi filter.
 
V2: - Fix the resource leak in procamp/misc VPP filter.
    - Re-work the common VAAPIVPPContext and specific VPP context part
like VAAPIVPPContext+ScaleVAAPIContext, borrowing the idea from
vaapi_encode.
    - misc vpp part need to refactoring, and I don't have good idea
about the file name for vf_misc_vaapi.c, sadly.


From 826e2c10bbe107fd494912ce72aa166db49ac9db Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Mon, 8 Jan 2018 15:56:43 +0800
Subject: [PATCH V3 1/6] lavfi: VAAPI VPP common infrastructure.

Re-work the VA-API common infrastructure.

Signed-off-by: Jun Zhao 
---
 libavfilter/vaapi_vpp.c | 377 
 libavfilter/vaapi_vpp.h |  88 +++
 2 files changed, 465 insertions(+)
 create mode 100644 libavfilter/vaapi_vpp.c
 create mode 100644 libavfilter/vaapi_vpp.h

diff --git a/libavfilter/vaapi_vpp.c b/libavfilter/vaapi_vpp.c
new file mode 100644
index 00..95ee38ca10
--- /dev/null
+++ b/libavfilter/vaapi_vpp.c
@@ -0,0 +1,377 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include 
+
+#include "libavutil/avassert.h"
+#include "libavutil/pixdesc.h"
+#include "formats.h"
+
+#include "vaapi_vpp.h"
+
+int vaapi_vpp_query_formats(AVFilterContext *avctx)
+{
+enum AVPixelFormat pix_fmts[] = {
+AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE,
+};
+int err;
+
+if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
+  &avctx->inputs[0]->out_formats)) < 0)
+return err;
+if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
+  &avctx->outputs[0]->in_formats)) < 0)
+return err;
+
+return 0;
+}
+
+void vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
+{
+VAAPIVPPContext *ctx   = avctx->priv;
+int i;
+for (i = 0; i < ctx->nb_filter_buffers; i++) {
+if (ctx->filter_buffers[i] != VA_INVALID_ID) {
+vaDestroyBuffer(ctx->hwctx->display, ctx->filter_buffers[i]);
+ctx->filter_buffers[i] = VA_INVALID_ID;
+}
+}
+ctx->nb_filter_buffers = 0;
+
+if (ctx->va_context != VA_INVALID_ID) {
+vaDestroyContext(ctx->hwctx->display, ctx->va_context);
+ctx->va_context = VA_INVALID_ID;
+}
+
+if (ctx->va_config != VA_INVALID_ID) {
+vaDestroyConfig(ctx->hwctx->display, ctx->va_config);
+ctx->va_config = VA_INVALID_ID;
+}
+
+av_buffer_unref(&ctx->output_frames_ref);
+av_buffer_unref(&ctx->device_ref);
+ctx->hwctx = NULL;
+}
+
+int vaapi_vpp_config_input(AVFilterLink *inlink)
+{
+AVFilterContext *avctx = inlink->dst;
+VAAPIVPPContext *ctx   = avctx->priv;
+
+if (ctx->pipeline_uninit)
+ctx->pipeline_uninit(avctx);
+
+if (!inlink->hw_frames_ctx) {
+av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is "
+   "required to associate the processing device.\n");
+return AVERROR(EINVAL);
+}
+
+ctx->input_frames_ref = av_buffer_ref(inlink->hw_frames_ctx);
+if (!ctx->input_frames_ref) {
+av_log(avctx, AV_LOG_ERROR, "A input frames reference create "
+   "failed.\n");
+return AVERROR(ENOMEM);
+}
+ctx->input_frames = (AVHWFramesContext*)ctx->input_frames_ref->data;
+
+return 0;
+}
+
+int vaapi_vpp_config_output(AVFilterLink *outlink)
+{
+AVFilterContext *avctx = outlink->src;
+VAAPIVPPContext *ctx   = avctx->priv;
+AVVAAPIHWConfig *hwconfig = NULL;
+AVHWFramesConstraints *constraints = NULL;
+AVVAAPIFramesContext *va_frames;
+VAStatus vas;
+int err, i;
+
+if (ctx->pipeline_uninit)
+ctx->pipeline_uninit(avctx);
+
+if (!ctx->output_width)
+ctx->output_width  = avctx->inputs[0]->w;
+if (!ctx->output_height)
+ctx->output_height = avctx->inputs[0]->h;
+
+av_assert0(ctx->input_frames);
+ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);
+if (!ctx->device_ref) {
+av_log(avctx, AV_LOG_ERROR, "A device reference create "
+   "failed.\n");
+return AVERROR(ENOMEM);
+}
+ctx->hwctx

[FFmpeg-devel] [PATCH V3 2/6] lavfi: use common VPP infrastructure for vf_scale_vaapi.

2018-01-17 Thread Jun Zhao

From d157fdbffebd07066b1a857398e1067615f908b3 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Mon, 8 Jan 2018 16:02:35 +0800
Subject: [PATCH V3 2/6] lavfi: use common VPP infrastructure for
 vf_scale_vaapi.

Use the common VPP infrastructure re-work vf_scale_vaapi.

Signed-off-by: Jun Zhao 
---
 libavfilter/Makefile |   2 +-
 libavfilter/vf_scale_vaapi.c | 353 +--
 2 files changed, 41 insertions(+), 314 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index ef4729dd3f..3d8dd2c890 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -296,7 +296,7 @@ OBJS-$(CONFIG_SCALE_FILTER)  += vf_scale.o 
scale.o
 OBJS-$(CONFIG_SCALE_CUDA_FILTER) += vf_scale_cuda.o 
vf_scale_cuda.ptx.o
 OBJS-$(CONFIG_SCALE_NPP_FILTER)  += vf_scale_npp.o scale.o
 OBJS-$(CONFIG_SCALE_QSV_FILTER)  += vf_scale_qsv.o
-OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale.o
+OBJS-$(CONFIG_SCALE_VAAPI_FILTER)+= vf_scale_vaapi.o scale.o 
vaapi_vpp.o
 OBJS-$(CONFIG_SCALE2REF_FILTER)  += vf_scale.o scale.o
 OBJS-$(CONFIG_SELECT_FILTER) += f_select.o
 OBJS-$(CONFIG_SELECTIVECOLOR_FILTER) += vf_selectivecolor.o
diff --git a/libavfilter/vf_scale_vaapi.c b/libavfilter/vf_scale_vaapi.c
index 22e928c098..6c641baff8 100644
--- a/libavfilter/vf_scale_vaapi.c
+++ b/libavfilter/vf_scale_vaapi.c
@@ -18,12 +18,7 @@
 
 #include 
 
-#include 
-#include 
-
 #include "libavutil/avassert.h"
-#include "libavutil/hwcontext.h"
-#include "libavutil/hwcontext_vaapi.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -33,264 +28,61 @@
 #include "internal.h"
 #include "scale.h"
 #include "video.h"
+#include "vaapi_vpp.h"
 
 typedef struct ScaleVAAPIContext {
-const AVClass *class;
-
-AVVAAPIDeviceContext *hwctx;
-AVBufferRef *device_ref;
-
-int valid_ids;
-VAConfigID  va_config;
-VAContextID va_context;
-
-AVBufferRef   *input_frames_ref;
-AVHWFramesContext *input_frames;
-
-AVBufferRef   *output_frames_ref;
-AVHWFramesContext *output_frames;
-
 char *output_format_string;
-enum AVPixelFormat output_format;
 
 char *w_expr;  // width expression string
 char *h_expr;  // height expression string
-
-int output_width;  // computed width
-int output_height; // computed height
 } ScaleVAAPIContext;
 
-
-static int scale_vaapi_query_formats(AVFilterContext *avctx)
-{
-enum AVPixelFormat pix_fmts[] = {
-AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE,
-};
-int err;
-
-if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
-  &avctx->inputs[0]->out_formats)) < 0)
-return err;
-if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
-  &avctx->outputs[0]->in_formats)) < 0)
-return err;
-
-return 0;
-}
-
-static int scale_vaapi_pipeline_uninit(ScaleVAAPIContext *ctx)
-{
-if (ctx->va_context != VA_INVALID_ID) {
-vaDestroyContext(ctx->hwctx->display, ctx->va_context);
-ctx->va_context = VA_INVALID_ID;
-}
-
-if (ctx->va_config != VA_INVALID_ID) {
-vaDestroyConfig(ctx->hwctx->display, ctx->va_config);
-ctx->va_config = VA_INVALID_ID;
-}
-
-av_buffer_unref(&ctx->output_frames_ref);
-av_buffer_unref(&ctx->device_ref);
-ctx->hwctx = 0;
-
-return 0;
-}
-
-static int scale_vaapi_config_input(AVFilterLink *inlink)
-{
-AVFilterContext *avctx = inlink->dst;
-ScaleVAAPIContext *ctx = avctx->priv;
-
-scale_vaapi_pipeline_uninit(ctx);
-
-if (!inlink->hw_frames_ctx) {
-av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is "
-   "required to associate the processing device.\n");
-return AVERROR(EINVAL);
-}
-
-ctx->input_frames_ref = av_buffer_ref(inlink->hw_frames_ctx);
-ctx->input_frames = (AVHWFramesContext*)ctx->input_frames_ref->data;
-
-return 0;
-}
-
 static int scale_vaapi_config_output(AVFilterLink *outlink)
 {
-AVFilterLink *inlink = outlink->src->inputs[0];
-AVFilterContext *avctx = outlink->src;
-ScaleVAAPIContext *ctx = avctx->priv;
-AVVAAPIHWConfig *hwconfig = NULL;
-AVHWFramesConstraints *constraints = NULL;
-AVVAAPIFramesContext *va_frames;
-VAStatus vas;
-int err, i;
-
-scale_vaapi_pipeline_uninit(ctx);
-
-ctx->device_ref = av_buffer_ref(ctx->input_frames->device_ref);
-ctx->hwctx = ((AVHWDeviceContext*)ctx->device_ref->data)->hwctx;
-
-av_assert0(ctx->va_config == VA_INVALID_ID);
-vas = vaCreateConfig(ctx->hwctx->display, VAProfileNone,
- VAEntrypointVideoProc, 0, 0, &ctx->va_config);
-if (vas != VA_STATUS_SUCCESS) {
-av_log(ctx, AV_LOG_ERROR, "Failed to create processing pipeline "
-   "config: %d (%s).\n", vas, vaErrorStr(vas));
-err = AVE

[FFmpeg-devel] [PATCH V3 3/6] lavfi: use common VPP infrastructure for vf_deinterlace_vaapi.

2018-01-17 Thread Jun Zhao

From f59ba36864423a2cdcdd16b136b38d511efb8952 Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Mon, 8 Jan 2018 16:07:38 +0800
Subject: [PATCH V3 3/6] lavfi: use common VPP infrastructure for
 vf_deinterlace_vaapi.

Use the common VPP infrastructure re-work vf_deinterlace_vaapi.

Signed-off-by: Jun Zhao 
---
 libavfilter/Makefile   |   2 +-
 libavfilter/vf_deinterlace_vaapi.c | 355 +
 2 files changed, 48 insertions(+), 309 deletions(-)

diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 3d8dd2c890..bbc97a0831 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -171,7 +171,7 @@ OBJS-$(CONFIG_DECONVOLVE_FILTER) += 
vf_convolve.o framesync.o
 OBJS-$(CONFIG_DEFLATE_FILTER)+= vf_neighbor.o
 OBJS-$(CONFIG_DEFLICKER_FILTER)  += vf_deflicker.o
 OBJS-$(CONFIG_DEINTERLACE_QSV_FILTER)+= vf_deinterlace_qsv.o
-OBJS-$(CONFIG_DEINTERLACE_VAAPI_FILTER)  += vf_deinterlace_vaapi.o
+OBJS-$(CONFIG_DEINTERLACE_VAAPI_FILTER)  += vf_deinterlace_vaapi.o 
vaapi_vpp.o
 OBJS-$(CONFIG_DEJUDDER_FILTER)   += vf_dejudder.o
 OBJS-$(CONFIG_DELOGO_FILTER) += vf_delogo.o
 OBJS-$(CONFIG_DESHAKE_FILTER)+= vf_deshake.o
diff --git a/libavfilter/vf_deinterlace_vaapi.c 
b/libavfilter/vf_deinterlace_vaapi.c
index a38da5d57b..9bf32fd423 100644
--- a/libavfilter/vf_deinterlace_vaapi.c
+++ b/libavfilter/vf_deinterlace_vaapi.c
@@ -18,13 +18,8 @@
 
 #include 
 
-#include 
-#include 
-
 #include "libavutil/avassert.h"
 #include "libavutil/common.h"
-#include "libavutil/hwcontext.h"
-#include "libavutil/hwcontext_vaapi.h"
 #include "libavutil/mem.h"
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
@@ -33,31 +28,15 @@
 #include "formats.h"
 #include "internal.h"
 #include "video.h"
+#include "vaapi_vpp.h"
 
 #define MAX_REFERENCES 8
 
 typedef struct DeintVAAPIContext {
-const AVClass *class;
-
-AVVAAPIDeviceContext *hwctx;
-AVBufferRef   *device_ref;
-
 intmode;
 intfield_rate;
 intauto_enable;
 
-intvalid_ids;
-VAConfigID va_config;
-VAContextIDva_context;
-
-AVBufferRef   *input_frames_ref;
-AVHWFramesContext *input_frames;
-
-AVBufferRef   *output_frames_ref;
-AVHWFramesContext *output_frames;
-intoutput_height;
-intoutput_width;
-
 VAProcFilterCapDeinterlacing
deint_caps[VAProcDeinterlacingCount];
 int nb_deint_caps;
@@ -67,8 +46,6 @@ typedef struct DeintVAAPIContext {
 intqueue_count;
 AVFrame   *frame_queue[MAX_REFERENCES];
 intextra_delay_for_timestamps;
-
-VABufferID filter_buffer;
 } DeintVAAPIContext;
 
 static const char *deint_vaapi_mode_name(int mode)
@@ -85,82 +62,30 @@ static const char *deint_vaapi_mode_name(int mode)
 }
 }
 
-static int deint_vaapi_query_formats(AVFilterContext *avctx)
+static void deint_vaapi_pipeline_uninit(AVFilterContext *avctx)
 {
-enum AVPixelFormat pix_fmts[] = {
-AV_PIX_FMT_VAAPI, AV_PIX_FMT_NONE,
-};
-int err;
-
-if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
-  &avctx->inputs[0]->out_formats)) < 0)
-return err;
-if ((err = ff_formats_ref(ff_make_format_list(pix_fmts),
-  &avctx->outputs[0]->in_formats)) < 0)
-return err;
-
-return 0;
-}
-
-static int deint_vaapi_pipeline_uninit(AVFilterContext *avctx)
-{
-DeintVAAPIContext *ctx = avctx->priv;
+VAAPIVPPContext *vpp_ctx = avctx->priv;
+DeintVAAPIContext *ctx   = vpp_ctx->priv;
 int i;
 
 for (i = 0; i < ctx->queue_count; i++)
 av_frame_free(&ctx->frame_queue[i]);
 ctx->queue_count = 0;
 
-if (ctx->filter_buffer != VA_INVALID_ID) {
-vaDestroyBuffer(ctx->hwctx->display, ctx->filter_buffer);
-ctx->filter_buffer = VA_INVALID_ID;
-}
-
-if (ctx->va_context != VA_INVALID_ID) {
-vaDestroyContext(ctx->hwctx->display, ctx->va_context);
-ctx->va_context = VA_INVALID_ID;
-}
-
-if (ctx->va_config != VA_INVALID_ID) {
-vaDestroyConfig(ctx->hwctx->display, ctx->va_config);
-ctx->va_config = VA_INVALID_ID;
-}
-
-av_buffer_unref(&ctx->device_ref);
-ctx->hwctx = NULL;
-
-return 0;
-}
-
-static int deint_vaapi_config_input(AVFilterLink *inlink)
-{
-AVFilterContext   *avctx = inlink->dst;
-DeintVAAPIContext *ctx = avctx->priv;
-
-deint_vaapi_pipeline_uninit(avctx);
-
-if (!inlink->hw_frames_ctx) {
-av_log(avctx, AV_LOG_ERROR, "A hardware frames reference is "
-   "required to associate the processing device.\n");
-return AVERROR(EINVAL);
-}
-
-ctx->input_frames_ref = av_buffer_ref(inlink->hw_frames_ctx);
-ctx->input_frames = (AVHWF

[FFmpeg-devel] [PATCH V3 4/6] lavfi: add ProcAmp(color balance) vaapi video filter.

2018-01-17 Thread Jun Zhao

From 795fc41a83c23ff461fef1870a003d77b070084f Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Mon, 8 Jan 2018 16:12:41 +0800
Subject: [PATCH V3 4/6] lavfi: add ProcAmp(color balance) vaapi video filter.

add ProcAmp(color balance) vaapi video filter, use the option
like -vf "procamp_vaapi=b=10:h=120:c=2.8:s=3.7" to set
brightness/hue/contrast/saturation.

Signed-off-by: Yun Zhou 
Signed-off-by: Jun Zhao 
---
 configure  |   1 +
 libavfilter/Makefile   |   1 +
 libavfilter/allfilters.c   |   1 +
 libavfilter/vf_procamp_vaapi.c | 227 +
 4 files changed, 230 insertions(+)
 create mode 100644 libavfilter/vf_procamp_vaapi.c

diff --git a/configure b/configure
index 5d533621ae..12fb34a202 100755
--- a/configure
+++ b/configure
@@ -3245,6 +3245,7 @@ perspective_filter_deps="gpl"
 phase_filter_deps="gpl"
 pp7_filter_deps="gpl"
 pp_filter_deps="gpl postproc"
+procamp_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
 program_opencl_filter_deps="opencl"
 pullup_filter_deps="gpl"
 removelogo_filter_deps="avcodec avformat swscale"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index bbc97a0831..43d0dd36e6 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -275,6 +275,7 @@ 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_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
 OBJS-$(CONFIG_PSNR_FILTER)   += vf_psnr.o framesync.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 42516bbdf9..63550628e5 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -284,6 +284,7 @@ static void register_all(void)
 REGISTER_FILTER(PP7,pp7,vf);
 REGISTER_FILTER(PREMULTIPLY,premultiply,vf);
 REGISTER_FILTER(PREWITT,prewitt,vf);
+REGISTER_FILTER(PROCAMP_VAAPI,  procamp_vaapi,  vf);
 REGISTER_FILTER(PROGRAM_OPENCL, program_opencl, vf);
 REGISTER_FILTER(PSEUDOCOLOR,pseudocolor,vf);
 REGISTER_FILTER(PSNR,   psnr,   vf);
diff --git a/libavfilter/vf_procamp_vaapi.c b/libavfilter/vf_procamp_vaapi.c
new file mode 100644
index 00..2d6c45366f
--- /dev/null
+++ b/libavfilter/vf_procamp_vaapi.c
@@ -0,0 +1,227 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include 
+
+#include "libavutil/avassert.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "vaapi_vpp.h"
+
+typedef struct ProcampVAAPIContext {
+float bright;
+float hue;
+float saturation;
+float contrast;
+} ProcampVAAPIContext;
+
+static int procamp_vaapi_build_filter_params(AVFilterContext *avctx)
+{
+VAAPIVPPContext *vpp_ctx = avctx->priv;
+ProcampVAAPIContext *ctx = vpp_ctx->priv;
+VAStatus vas;
+VAProcFilterParameterBufferColorBalance procamp_params[4];
+VAProcFilterCapColorBalance procamp_caps[VAProcColorBalanceCount];
+int num_caps;
+
+memset(&procamp_params, 0, sizeof(procamp_params));
+memset(&procamp_caps, 0, sizeof(procamp_caps));
+
+num_caps = VAProcColorBalanceCount;
+vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display, 
vpp_ctx->va_context,
+ VAProcFilterColorBalance, &procamp_caps, 
&num_caps);
+
+if (vas != VA_STATUS_SUCCESS) {
+av_log(avctx, AV_LOG_ERROR, "Failed to query procamp "
+   "filter caps: %d (%s).\n", vas, vaErrorStr(vas));
+return AVERROR(EIO);
+}
+
+procamp_params[0].type   = VAProcFilterColorBalance;
+procamp_params[0].attrib = VAProcColorBalanceBrightness;
+procamp_params[0].value  = ctx->bright;
+
+procamp_params[1].type   = VAProcFilterColorBalance;
+procamp_params[1].attrib = VAProcColorBalanceContrast;
+procamp_params[

[FFmpeg-devel] [PATCH V3 6/6] Changelog: add ProcAmp(color balance) filter.

2018-01-17 Thread Jun Zhao

From b091ecba062ee0221074287c72fa804f0382925b Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Thu, 18 Jan 2018 12:51:20 +0800
Subject: [PATCH V3 6/6] Changelog: add ProcAmp(color balance) filter.

Signed-off-by: Jun Zhao 
---
 Changelog | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 61075b3392..b5ea252de4 100644
--- a/Changelog
+++ b/Changelog
@@ -38,7 +38,7 @@ version :
 - Removed the ffserver program
 - Removed the ffmenc and ffmdec muxer and demuxer
 - VideoToolbox HEVC encoder and hwaccel
-
+- VAAPI-accelerated ProcAmp(color balance) video filter
 
 version 3.4:
 - deflicker video filter
-- 
2.14.1

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


[FFmpeg-devel] [PATCH V3 5/6] lavfi: add misc(denoise/sharpness) VPP video filter.

2018-01-17 Thread Jun Zhao

From 12f307d7537487013a4968b7e810f6f6c0f2229a Mon Sep 17 00:00:00 2001
From: Jun Zhao 
Date: Mon, 8 Jan 2018 16:19:17 +0800
Subject: [PATCH V3 5/6] lavfi: add misc(denoise/sharpness) VPP video filter.

add misc(denoise/sharpness) VPP video filter.

 Signed-off-by: Yun Zhou 
 Signed-off-by: Jun Zhao 
---
 configure   |   1 +
 libavfilter/Makefile|   1 +
 libavfilter/allfilters.c|   1 +
 libavfilter/vf_misc_vaapi.c | 275 
 4 files changed, 278 insertions(+)
 create mode 100644 libavfilter/vf_misc_vaapi.c

diff --git a/configure b/configure
index 12fb34a202..218d9ccecf 100755
--- a/configure
+++ b/configure
@@ -3227,6 +3227,7 @@ kerndeint_filter_deps="gpl"
 ladspa_filter_deps="ladspa libdl"
 lv2_filter_deps="lv2"
 mcdeint_filter_deps="avcodec gpl"
+misc_vaapi_filter_deps="vaapi VAProcPipelineParameterBuffer"
 movie_filter_deps="avcodec avformat"
 mpdecimate_filter_deps="gpl"
 mpdecimate_filter_select="pixelutils"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 43d0dd36e6..db9049614b 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -246,6 +246,7 @@ OBJS-$(CONFIG_MESTIMATE_FILTER)  += 
vf_mestimate.o motion_estimation
 OBJS-$(CONFIG_METADATA_FILTER)   += f_metadata.o
 OBJS-$(CONFIG_MIDEQUALIZER_FILTER)   += vf_midequalizer.o framesync.o
 OBJS-$(CONFIG_MINTERPOLATE_FILTER)   += vf_minterpolate.o 
motion_estimation.o
+OBJS-$(CONFIG_MISC_VAAPI_FILTER) += vf_misc_vaapi.o vaapi_vpp.o
 OBJS-$(CONFIG_MIX_FILTER)+= vf_mix.o
 OBJS-$(CONFIG_MPDECIMATE_FILTER) += vf_mpdecimate.o
 OBJS-$(CONFIG_NEGATE_FILTER) += vf_lut.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index 63550628e5..6183be9a73 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -256,6 +256,7 @@ static void register_all(void)
 REGISTER_FILTER(METADATA,   metadata,   vf);
 REGISTER_FILTER(MIDEQUALIZER,   midequalizer,   vf);
 REGISTER_FILTER(MINTERPOLATE,   minterpolate,   vf);
+REGISTER_FILTER(MISC_VAAPI, misc_vaapi, vf);
 REGISTER_FILTER(MIX,mix,vf);
 REGISTER_FILTER(MPDECIMATE, mpdecimate, vf);
 REGISTER_FILTER(NEGATE, negate, vf);
diff --git a/libavfilter/vf_misc_vaapi.c b/libavfilter/vf_misc_vaapi.c
new file mode 100644
index 00..2b50911bfe
--- /dev/null
+++ b/libavfilter/vf_misc_vaapi.c
@@ -0,0 +1,275 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+#include 
+
+#include "libavutil/avassert.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+#include "vaapi_vpp.h"
+
+typedef struct MiscVAAPIContext {
+VAProcFilterCap denoise_caps;
+int denoise; // enable denoise algo. level is the optional
+ // value from the interval [-1, 100], -1 means 
disabled
+
+VAProcFilterCap sharpness_caps;
+int sharpness;   // enable sharpness. level is the optional value
+ // from the interval [-1, 100], -1 means disabled
+int num_filter_bufs;
+VABufferID filter_bufs[VAProcFilterCount];
+} MiscVAAPIContext;
+
+static float map_to_range(
+int input, int in_min, int in_max,
+float out_min, float out_max)
+{
+return (input - in_min) * (out_max - out_min) / (in_max - in_min) + 
out_min;
+}
+
+static int misc_vaapi_build_filter_params(AVFilterContext *avctx)
+{
+VAAPIVPPContext *vpp_ctx = avctx->priv;
+MiscVAAPIContext *ctx= vpp_ctx->priv;
+
+VAStatus vas;
+VAProcFilterParameterBufferColorBalance misc_params[4];
+VAProcFilterCapColorBalance misc_caps[VAProcColorBalanceCount];
+uint32_t num_denoise_caps = 1;
+uint32_t num_sharpness_caps = 1;
+
+VAProcFilterParameterBuffer denoise;
+VAProcFilterParameterBuffer sharpness;
+
+memset(&misc_params, 0, sizeof(misc_params));
+memset(&misc_caps, 0, sizeof(misc_caps));
+
+if (ctx->denoise != -1) {
+vas = vaQueryVideoProcFilterCaps(vpp_ctx->hwctx->display, 
vpp_ctx->va_context,
+ VAPr

Re: [FFmpeg-devel] [PATCH 1/2] lavc: Add coded_w/h to AVCodecParameters

2018-01-17 Thread James Almer
On 1/18/2018 2:03 AM, Zhong Li wrote:
> coded_width/height may be different from width/height sometimes

> (e.g, crop or lowres cases).

Which is why it's not a field that belongs to AVCodecParameters.

Codec level cropping has nothing to do with containers. Same with
lowres, which is an internal feature, and scheduled for removal.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] cuvid : add support to force intra frames as in input source

2018-01-17 Thread Yogender Gupta
Improved the patch by dynamic allocation.

Thanks,
Yogender


---
This email message is for the sole use of the intended recipient(s) and may 
contain
confidential information.  Any unauthorized review, use, disclosure or 
distribution
is prohibited.  If you are not the intended recipient, please contact the 
sender by
reply email and destroy all copies of the original message.
---


0001-cuviddec-Set-key-frame-for-decoded-frames.patch
Description: 0001-cuviddec-Set-key-frame-for-decoded-frames.patch
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] add dumpwave filter

2018-01-17 Thread Tobias Rapp

On 15.01.2018 13:48, Dmytro Humeniuk wrote:



On 15 Jan 2018, at 09:14, Tobias Rapp  wrote:

On 13.01.2018 23:52, Дмитрий Гуменюк wrote:

Hi,

On 13 Jan 2018, at 01:37, Дмитрий Гуменюк  wrote:

Hi


On 12 Jan 2018, at 13:32, Дмитрий Гуменюк  wrote:


On 12 Jan 2018, at 13:17, Tobias Rapp  wrote:

On 12.01.2018 12:16, Дмитрий Гуменюк wrote:

Hi

On 11 Jan 2018, at 09:20, Tobias Rapp  wrote:

On 10.01.2018 18:18, Kyle Swanson wrote:

Hi,
For this to be a part of libavfilter the output needs to be more generic
than the just the Soundcloud format. If we want this to be generally useful
it should probably just output an array of floats between 0.0 and 1.0. The
consumer of this data (JS library, or whatever) can use this in whatever
way it wants.


I agree. If the BWF Peak Envelope output which was suggested in the other 
thread does not match your demands and filter implementation is actually 
necessary I would prefer if the filter would attach the RMS value(s) as frame 
metadata instead of directly dumping to file. Frame metadata can then be re-

RMS values may be counted for several frames or only for a half of a frame

used by other filters or dumped into file by using the existing "ametadata" 
filter.

This would be similar to:

ffmpeg -i input-file -f null -filter:a 
"asetnsamples=22050,astats=metadata=on,ametadata=print:file=stats-file.dat" 
/dev/null

I like this idea, but won’t asetnsamples affect performance by creating fifo 
queue? And it may require some effort to parse long output


I added asetnsamples to define the audio frame size (interval of values from astats). You 
can reduce the number of lines printed by ametadata by using the 
"key=lavfi.astats.foo" option.

I used asetnsamples as well, and I measured performance while transcoding - it 
appears to be slight slower

I think output is now more generic and I got rid of long switch/case, thanks 
for support

Here is most recent patch, seems like all comments are addressed, did I miss 
something?


I still would prefer to have the value attached as frame metadata, then dumped into file via the 
existing "ametadata" filter. Even better would be to integrate the statistic value (if 
missing) into the "astats" filter.

If your concern is the output format of "ametadata" then some output format 
extension (CSV/JSON) needs to be discussed for ametadata/metadata.

If your concern is performance then please add some numbers. In my tests using an approx. 
5 minutes input WAV file (48kHz, stereo) the run with "asetnsamples" was 
considerably faster than the run without (1.7s vs. 13.9s)

Hi
As I mentioned previously adding metadata to each frame is not possible
as value may be counted for several frames or only for a half of a frame

I used 2 hours long 48kHz mp3 
https://s3-eu-west-1.amazonaws.com/balamii/SynthSystemSystersJAN2018.mp3
For this purposes I set up CentOS AWS EC2 nano instance
Then I transcoded it while filtering like following (just to recreate real 
situation):
1. -filter:a 
"asetnsamples=192197,astats=metadata=on,ametadata=print:file=stats-file.dat" 
out.mp3
2. -filter:a "dumpwave=n=192197:f=-" out.mp3
Results:
1. 244810550046 nanoseconds
2. 87494286740 nanoseconds

One of the possible use cases - to set up 2 chains of asetnsamples->metadata - 
for example:
"asetnsamples=192197,astats=metadata=on,ametadata=print:file=stats-file.dat,asetnsamples=22050,astats=metadata=on,ametadata=print:file=stats-file1.dat”
 for sure it will affect performance
Comparing with "dumpwave=n=192197:f=out1,dumpwave=n= 22050:f=out2"


Sorry, I misunderstood your concerns regarding asetnsamples filter 
performance. The numbers I provided have been for


"asetnsamples=22050,astats=metadata=on,ametadata=print:file=stats-file.dat"

versus

"astats=metadata=on,ametadata=print:file=stats-file.dat"

When comparing astats+ametadata versus dumpwave it is obvious that a 
specialized filter which only calculates one statistic value is faster 
than a filter that calculates multiple statistics. But still my opinion 
is that if the dumpwave filter is to be added to the codebase it should 
be more generic (i.e. output frame metadata similar to the psnr/ssim 
filters for video).


Regards,
Tobias

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