Re: [FFmpeg-devel] [PATCH] img2enc: mention -frames:v in error message

2019-01-16 Thread Kieran O Leary
On Tue, 15 Jan 2019, 00:25 Lou Logan  Signed-off-by: Lou Logan 
> ---
>  libavformat/img2enc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/libavformat/img2enc.c b/libavformat/img2enc.c
> index a09cc8ec50..bec4bf81dd 100644
> --- a/libavformat/img2enc.c
> +++ b/libavformat/img2enc.c
> @@ -110,7 +110,8 @@ static int write_packet(AVFormatContext *s, AVPacket
> *pkt)
>
>  AV_FRAME_FILENAME_FLAGS_MULTIPLE) < 0 &&
> img->img_number > 1) {
>  av_log(s, AV_LOG_ERROR,
> -   "Could not get frame filename number %d from pattern
> '%s' (either set update or use a pattern like %%03d within the filename
> pattern)\n",
> +   "Could not get frame filename number %d from pattern
> '%s'. "
> +   "Use '-frames:v 1' for a single image, or '-update'
> option, or use a pattern such as %%03d within the filename.\n",
>

Looks good to me. The adding of a dash is useful as my colleagues and I
have seen that error many times and I never really new what 'set update'
meant. I only now looked up -update in the documentation.

-Kieran

img->img_number, img->path);
>  return AVERROR(EINVAL);
>  }
> --
> 2.20.1
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH v3] Improved the performance of 1 decode + N filter graphs and adaptive bitrate.

2019-01-16 Thread Shaofei Wang
With new option "-abr_pipeline"
It enabled multiple filter graph concurrency, which bring obove about
4%~20% improvement in some 1:N scenarios by CPU or GPU acceleration

Below are some test cases and comparison as reference.
(Hardware platform: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz)
(Software: Intel iHD driver - 16.9.00100, CentOS 7)

For 1:N transcode by GPU acceleration with vaapi:
./ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi \
-hwaccel_output_format vaapi \
-i ~/Videos/1920x1080p_30.00_x264_qp28.h264 \
-vf "scale_vaapi=1280:720" -c:v h264_vaapi -f null /dev/null \
-vf "scale_vaapi=720:480" -c:v h264_vaapi -f null /dev/null \
-abr_pipeline

test results:
2 encoders 5 encoders 10 encoders
Improved   6.1%6.9%   5.5%

For 1:N transcode by GPU acceleration with QSV:
./ffmpeg -hwaccel qsv -c:v h264_qsv \
-i ~/Videos/1920x1080p_30.00_x264_qp28.h264 \
-vf "scale_qsv=1280:720:format=nv12" -c:v h264_qsv -f null /dev/null \
-vf "scale_qsv=720:480:format=nv12" -c:v h264_qsv -f null /dev/null

test results:
2 encoders  5 encoders 10 encoders
Improved   6%   4% 15%

For Intel GPU acceleration case, 1 decode to N scaling, by QSV:
./ffmpeg -hwaccel qsv -c:v h264_qsv \
-i ~/Videos/1920x1080p_30.00_x264_qp28.h264 \
-vf "scale_qsv=1280:720:format=nv12,hwdownload" -pix_fmt nv12 -f null 
/dev/null \
-vf "scale_qsv=720:480:format=nv12,hwdownload" -pix_fmt nv12 -f null 
/dev/null

test results:
2 scale  5 scale   10 scale
Improved   12% 21%21%

For CPU only 1 decode to N scaling:
./ffmpeg -i ~/Videos/1920x1080p_30.00_x264_qp28.h264 \
-vf "scale=1280:720" -pix_fmt nv12 -f null /dev/null \
-vf "scale=720:480" -pix_fmt nv12 -f null /dev/null \
-abr_pipeline

test results:
2 scale  5 scale   10 scale
Improved   25%107%   148%

Signed-off-by: Wang, Shaofei 
Reviewed-by: Zhao, Jun 
---
 fftools/ffmpeg.c| 228 
 fftools/ffmpeg.h|  15 
 fftools/ffmpeg_filter.c |   4 +
 fftools/ffmpeg_opt.c|   6 +-
 4 files changed, 237 insertions(+), 16 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 544f1a1..7dbff15 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1523,6 +1523,109 @@ static int reap_filters(int flush)
 return 0;
 }
 
+static int pipeline_reap_filters(int flush, InputFilter * ifilter)
+{
+AVFrame *filtered_frame = NULL;
+int i;
+
+for (i = 0; i < nb_output_streams; i++) {
+if (ifilter == output_streams[i]->filter->graph->inputs[0]) break;
+}
+OutputStream *ost = output_streams[i];
+OutputFile*of = output_files[ost->file_index];
+AVFilterContext *filter;
+AVCodecContext *enc = ost->enc_ctx;
+int ret = 0;
+
+if (!ost->filter || !ost->filter->graph->graph)
+return 0;
+filter = ost->filter->filter;
+
+if (!ost->initialized) {
+char error[1024] = "";
+ret = init_output_stream(ost, error, sizeof(error));
+if (ret < 0) {
+av_log(NULL, AV_LOG_ERROR, "Error initializing output stream %d:%d 
-- %s\n",
+   ost->file_index, ost->index, error);
+exit_program(1);
+}
+}
+
+if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc()))
+return AVERROR(ENOMEM);
+filtered_frame = ost->filtered_frame;
+
+while (1) {
+double float_pts = AV_NOPTS_VALUE; // this is identical to 
filtered_frame.pts but with higher precision
+ret = av_buffersink_get_frame_flags(filter, filtered_frame,
+   AV_BUFFERSINK_FLAG_NO_REQUEST);
+if (ret < 0) {
+if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
+av_log(NULL, AV_LOG_WARNING,
+   "Error in av_buffersink_get_frame_flags(): %s\n", 
av_err2str(ret));
+} else if (flush && ret == AVERROR_EOF) {
+if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO)
+do_video_out(of, ost, NULL, AV_NOPTS_VALUE);
+}
+break;
+}
+if (ost->finished) {
+av_frame_unref(filtered_frame);
+continue;
+}
+if (filtered_frame->pts != AV_NOPTS_VALUE) {
+int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : 
of->start_time;
+AVRational filter_tb = av_buffersink_get_time_base(filter);
+AVRational tb = enc->time_base;
+int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
+
+tb.den <<= extra_bits;
+float_pts =
+av_rescale_q(filtered_frame->pts, filter_tb, tb) -
+av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
+float_pts /= 1 << extra_bits;
+// avoid exact midoints to reduce the chance of roundi

[FFmpeg-devel] [PATCH] lavf/qsv_scale: add scaling mode option

2019-01-16 Thread Zhong Li
Signed-off-by: Zhong Li 
---
 libavfilter/vf_scale_qsv.c | 36 +++-
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
index 7d593b2..f9f708e 100644
--- a/libavfilter/vf_scale_qsv.c
+++ b/libavfilter/vf_scale_qsv.c
@@ -69,6 +69,8 @@ enum var_name {
 VARS_NB
 };
 
+#define QSV_HAVE_SCALING_CONFIG  QSV_VERSION_ATLEAST(1, 19)
+
 typedef struct QSVScaleContext {
 const AVClass *class;
 
@@ -88,7 +90,14 @@ typedef struct QSVScaleContext {
 int nb_surface_ptrs_out;
 
 mfxExtOpaqueSurfaceAlloc opaque_alloc;
-mfxExtBuffer*ext_buffers[1];
+
+#if QSV_HAVE_SCALING_CONFIG
+mfxExtVPPScaling scale_conf;
+#endif
+int  mode;
+
+mfxExtBuffer *ext_buffers[1 + QSV_HAVE_SCALING_CONFIG];
+int  num_ext_buf;
 
 int shift_width, shift_height;
 
@@ -285,6 +294,8 @@ static int init_out_session(AVFilterContext *ctx)
 mfxStatus err;
 int i;
 
+s->num_ext_buf = 0;
+
 /* extract the properties of the "master" session given to us */
 err = MFXQueryIMPL(device_hwctx->session, &impl);
 if (err == MFX_ERR_NONE)
@@ -357,10 +368,7 @@ static int init_out_session(AVFilterContext *ctx)
 s->opaque_alloc.Header.BufferId = 
MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
 s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
 
-s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc;
-
-par.ExtParam= s->ext_buffers;
-par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers);
+s->ext_buffers[s->num_ext_buf++] = (mfxExtBuffer*)&s->opaque_alloc;
 
 par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY | 
MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
 } else {
@@ -396,6 +404,18 @@ static int init_out_session(AVFilterContext *ctx)
 par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY | 
MFX_IOPATTERN_OUT_VIDEO_MEMORY;
 }
 
+#if QSV_HAVE_SCALING_CONFIG
+memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling));
+s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
+s->scale_conf.Header.BufferSz = sizeof(mfxExtVPPScaling);
+s->scale_conf.ScalingMode = s->mode;
+s->ext_buffers[s->num_ext_buf++]  = (mfxExtBuffer*)&s->scale_conf;
+av_log(ctx, AV_LOG_VERBOSE, "Scaling mode: %"PRIu16"\n", s->mode);
+#endif
+
+par.ExtParam= s->ext_buffers;
+par.NumExtParam = s->num_ext_buf;
+
 par.AsyncDepth = 1;// TODO async
 
 par.vpp.In  = in_frames_hwctx->surfaces[0].Info;
@@ -595,6 +615,12 @@ static const AVOption options[] = {
 { "h",  "Output video height", OFFSET(h_expr), AV_OPT_TYPE_STRING, 
{ .str = "ih"   }, .flags = FLAGS },
 { "format", "Output pixel format", OFFSET(format_str), AV_OPT_TYPE_STRING, 
{ .str = "same" }, .flags = FLAGS },
 
+#if QSV_HAVE_SCALING_CONFIG
+{ "mode",  "set scaling mode",OFFSET(mode),AV_OPT_TYPE_INT,
{ .i64 = MFX_SCALING_MODE_DEFAULT}, MFX_SCALING_MODE_DEFAULT, 
MFX_SCALING_MODE_QUALITY, FLAGS, "mode"},
+{ "low_power", "low power mode",0, AV_OPT_TYPE_CONST,  
{ .i64 = MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX, FLAGS, "mode"},
+{ "hq","high quality mode", 0, AV_OPT_TYPE_CONST,  
{ .i64 = MFX_SCALING_MODE_QUALITY},  INT_MIN, INT_MAX, FLAGS, "mode"},
+#endif
+
 { NULL },
 };
 
-- 
2.7.4

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


Re: [FFmpeg-devel] [PATCH] lavf/qsv_scale: add scaling mode option

2019-01-16 Thread Maxym Dmytrychenko
On Wed, Jan 16, 2019 at 9:55 AM Zhong Li  wrote:

> Signed-off-by: Zhong Li 
> ---
>  libavfilter/vf_scale_qsv.c | 36 +++-
>  1 file changed, 31 insertions(+), 5 deletions(-)
>
> diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
> index 7d593b2..f9f708e 100644
> --- a/libavfilter/vf_scale_qsv.c
> +++ b/libavfilter/vf_scale_qsv.c
> @@ -69,6 +69,8 @@ enum var_name {
>  VARS_NB
>  };
>
> +#define QSV_HAVE_SCALING_CONFIG  QSV_VERSION_ATLEAST(1, 19)
> +
>  typedef struct QSVScaleContext {
>  const AVClass *class;
>
> @@ -88,7 +90,14 @@ typedef struct QSVScaleContext {
>  int nb_surface_ptrs_out;
>
>  mfxExtOpaqueSurfaceAlloc opaque_alloc;
> -mfxExtBuffer*ext_buffers[1];
> +
> +#if QSV_HAVE_SCALING_CONFIG
> +mfxExtVPPScaling scale_conf;
> +#endif
> +int  mode;
> +
> +mfxExtBuffer *ext_buffers[1 + QSV_HAVE_SCALING_CONFIG];
> +int  num_ext_buf;
>
>  int shift_width, shift_height;
>
> @@ -285,6 +294,8 @@ static int init_out_session(AVFilterContext *ctx)
>  mfxStatus err;
>  int i;
>
> +s->num_ext_buf = 0;
> +
>  /* extract the properties of the "master" session given to us */
>  err = MFXQueryIMPL(device_hwctx->session, &impl);
>  if (err == MFX_ERR_NONE)
> @@ -357,10 +368,7 @@ static int init_out_session(AVFilterContext *ctx)
>  s->opaque_alloc.Header.BufferId =
> MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION;
>  s->opaque_alloc.Header.BufferSz = sizeof(s->opaque_alloc);
>
> -s->ext_buffers[0] = (mfxExtBuffer*)&s->opaque_alloc;
> -
> -par.ExtParam= s->ext_buffers;
> -par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers);
> +s->ext_buffers[s->num_ext_buf++] =
> (mfxExtBuffer*)&s->opaque_alloc;
>
>  par.IOPattern = MFX_IOPATTERN_IN_OPAQUE_MEMORY |
> MFX_IOPATTERN_OUT_OPAQUE_MEMORY;
>  } else {
> @@ -396,6 +404,18 @@ static int init_out_session(AVFilterContext *ctx)
>  par.IOPattern = MFX_IOPATTERN_IN_VIDEO_MEMORY |
> MFX_IOPATTERN_OUT_VIDEO_MEMORY;
>  }
>
> +#if QSV_HAVE_SCALING_CONFIG
> +memset(&s->scale_conf, 0, sizeof(mfxExtVPPScaling));
> +s->scale_conf.Header.BufferId = MFX_EXTBUFF_VPP_SCALING;
> +s->scale_conf.Header.BufferSz = sizeof(mfxExtVPPScaling);
> +s->scale_conf.ScalingMode = s->mode;
> +s->ext_buffers[s->num_ext_buf++]  = (mfxExtBuffer*)&s->scale_conf;
> +av_log(ctx, AV_LOG_VERBOSE, "Scaling mode: %"PRIu16"\n", s->mode);
> +#endif
> +
> +par.ExtParam= s->ext_buffers;
> +par.NumExtParam = s->num_ext_buf;
> +
>  par.AsyncDepth = 1;// TODO async
>
>  par.vpp.In  = in_frames_hwctx->surfaces[0].Info;
> @@ -595,6 +615,12 @@ static const AVOption options[] = {
>  { "h",  "Output video height", OFFSET(h_expr),
>  AV_OPT_TYPE_STRING, { .str = "ih"   }, .flags = FLAGS },
>  { "format", "Output pixel format", OFFSET(format_str),
> AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
>
> +#if QSV_HAVE_SCALING_CONFIG
> +{ "mode",  "set scaling mode",OFFSET(mode),
> AV_OPT_TYPE_INT,{ .i64 = MFX_SCALING_MODE_DEFAULT},
> MFX_SCALING_MODE_DEFAULT, MFX_SCALING_MODE_QUALITY, FLAGS, "mode"},
> +{ "low_power", "low power mode",0,
>  AV_OPT_TYPE_CONST,  { .i64 = MFX_SCALING_MODE_LOWPOWER}, INT_MIN, INT_MAX,
> FLAGS, "mode"},
> +{ "hq","high quality mode", 0,
>  AV_OPT_TYPE_CONST,  { .i64 = MFX_SCALING_MODE_QUALITY},  INT_MIN, INT_MAX,
> FLAGS, "mode"},
> +#endif
> +
>  { NULL },
>  };
>
> --
> 2.7.4
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


seems to be quiet straight forward and simple.

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


[FFmpeg-devel] [PATCH] palettegen: Fill with last color, not black

2019-01-16 Thread Tomas Härdin
Hi

I was helping the fine folks at peppercarrot.com with web video
nonsense, and I notice palettegen outputs more colors than it should
due to padding the generated palette with pure black.

Compare this (ffmpeg version 3.2.12-1~deb9u1):
http://www.härdin.se/files/peppercarrot_gif/output-blackspecks-64.gif
with this (282a471 with this patch applied):
http://www.härdin.se/files/peppercarrot_gif/output-fixed-64.gif

The attached patch fixes this by padding with the last color instead of
black.

/TomasFrom 3a01f62fdcc95cc7afaf5aa6e439b8742cce43bc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= 
Date: Wed, 16 Jan 2019 13:07:48 +0100
Subject: [PATCH] palettegen: Fill with last color, not black

If we fill with black then the generated palette will have one color more
than what the user requested. This also resulted in unwanted black specks in
the output of paletteuse, especially when generating small palettes.
---
 libavfilter/vf_palettegen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/vf_palettegen.c b/libavfilter/vf_palettegen.c
index 5ff73e6b2b..44323782d2 100644
--- a/libavfilter/vf_palettegen.c
+++ b/libavfilter/vf_palettegen.c
@@ -245,7 +245,7 @@ static void write_palette(AVFilterContext *ctx, AVFrame *out)
 av_log(ctx, AV_LOG_WARNING, "Dupped color: %08"PRIX32"\n", pal[x]);
 last_color = pal[x];
 } else {
-pal[x] = 0xff00; // pad with black
+pal[x] = last_color; // pad with last color
 }
 }
 pal += pal_linesize;
-- 
2.11.0

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


Re: [FFmpeg-devel] [PATCH V8 2/2] avcodec/libx264: add support for ROI-based encoding

2019-01-16 Thread Derek Buitenhuis
On 16/01/2019 00:41, Guo, Yejun wrote:
> this patch set asks for pushing if no more concerns, thanks.

I support this.

If nobody raises any concerns in the next 24-48 hrs, I'll go ahead.

Thank you for sticking with it through the bikeshedding.

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


[FFmpeg-devel] [PATCH 1/2] lavc/vaapi_encode_mpeg2: add support for CBR/VBR

2019-01-16 Thread Linjie Fu
Add support for VBR/CBR mode in mpeg2_vaapi encode.

Fix #7650.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_encode_mpeg2.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/vaapi_encode_mpeg2.c b/libavcodec/vaapi_encode_mpeg2.c
index 22d7e306bb..a625b15461 100644
--- a/libavcodec/vaapi_encode_mpeg2.c
+++ b/libavcodec/vaapi_encode_mpeg2.c
@@ -541,6 +541,13 @@ static av_cold int 
vaapi_encode_mpeg2_configure(AVCodecContext *avctx)
"%d / %d / %d for I- / P- / B-frames.\n",
priv->quant_i, priv->quant_p, priv->quant_b);
 
+} else if (ctx->va_rc_mode == VA_RC_CBR ||
+   ctx->va_rc_mode == VA_RC_VBR) {
+// These still need to be set for quantiser_scale_code.
+priv->quant_i = 10;
+priv->quant_p = 10;
+priv->quant_b = 10;
+
 } else {
 av_assert0(0 && "Invalid RC mode.");
 }
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 2/2] lavc/vaapi_encode: fix the mismatched vbvBuf size unit for mpeg2

2019-01-16 Thread Linjie Fu
hrd_buffer_size and hrd_initial_buffer_fullness are set in bits, while
driver takes the vbvBuf size in 16 kbits. The mismatch will cause
quality issue.

One way to solve this issue in FFmpeg level is set the bufsize
specially for mpeg2 as the unit of 16 kbits, and discard the default
CBR mode in driver.

Fix the quality issue in #7650.

Signed-off-by: Linjie Fu 
---
 libavcodec/vaapi_encode.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c
index eda8a36299..c932d9d7fb 100644
--- a/libavcodec/vaapi_encode.c
+++ b/libavcodec/vaapi_encode.c
@@ -1305,9 +1305,11 @@ static av_cold int 
vaapi_encode_init_rate_control(AVCodecContext *avctx)
 if (avctx->rc_buffer_size)
 hrd_buffer_size = avctx->rc_buffer_size;
 else if (avctx->rc_max_rate > 0)
-hrd_buffer_size = avctx->rc_max_rate;
+hrd_buffer_size = ctx->codec->profiles->va_profile > 1 ?
+avctx->rc_max_rate : avctx->rc_max_rate >> 14;
 else
-hrd_buffer_size = avctx->bit_rate;
+hrd_buffer_size = ctx->codec->profiles->va_profile > 1 ?
+avctx->bit_rate : avctx->bit_rate >> 14;
 if (avctx->rc_initial_buffer_occupancy) {
 if (avctx->rc_initial_buffer_occupancy > hrd_buffer_size) {
 av_log(avctx, AV_LOG_ERROR, "Invalid RC buffer settings: "
@@ -1318,7 +1320,7 @@ static av_cold int 
vaapi_encode_init_rate_control(AVCodecContext *avctx)
 }
 hrd_initial_buffer_fullness = avctx->rc_initial_buffer_occupancy;
 } else {
-hrd_initial_buffer_fullness = hrd_buffer_size * 3 / 4;
+hrd_initial_buffer_fullness = FFMAX(avctx->bit_rate, 
avctx->rc_max_rate) * 3 / 4;
 }
 
 if (avctx->rc_max_rate && avctx->rc_max_rate < avctx->bit_rate) {
-- 
2.17.1

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


[FFmpeg-devel] [PATCH 0/1] flush after writing hls segments to fix single file hls

2019-01-16 Thread Daniel Oberhoff
Hello,

This patch makes the hls muxer use avio_flush after writing a segment to disk.
This is needed so that in single file hls segments actually become visile to 
readers in time.

Daniel Oberhoff (1):
  flush segments to guarantuee atomic single file hls

 libavformat/hlsenc.c | 1 +
 1 file changed, 1 insertion(+)

-- 
2.16.2

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


[FFmpeg-devel] [PATCH 1/1] flush segments to guarantuee atomic single file hls

2019-01-16 Thread Daniel Oberhoff
---
 libavformat/hlsenc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index ca57694e9e..2cd651d7e8 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -406,6 +406,7 @@ static int flush_dynbuf(VariantStream *vs, int 
*range_length)
 *range_length = avio_close_dyn_buf(ctx->pb, &buffer);
 ctx->pb = NULL;
 avio_write(vs->out, buffer, *range_length);
+avio_flush(vs->out);
 av_free(buffer);
 
 // re-open buffer
-- 
2.16.2

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


Re: [FFmpeg-devel] [PATCH 1/3] avutil/imgutils: Optimize writing 4 bytes in memset_bytes()

2019-01-16 Thread Marton Balint



On Tue, 15 Jan 2019, Michael Niedermayer wrote:


On Sun, Dec 30, 2018 at 07:15:49PM +0100, Marton Balint wrote:



On Fri, 28 Dec 2018, Michael Niedermayer wrote:


On Wed, Dec 26, 2018 at 10:16:47PM +0100, Marton Balint wrote:



On Wed, 26 Dec 2018, Paul B Mahol wrote:


On 12/26/18, Michael Niedermayer  wrote:

On Wed, Dec 26, 2018 at 04:32:17PM +0100, Paul B Mahol wrote:

On 12/25/18, Michael Niedermayer  wrote:

Fixes: Timeout
Fixes:
11502/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920
Before: Executed
clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920
in 11294 ms
After : Executed
clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_WCMV_fuzzer-5664893810769920
in 4249 ms

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

diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 4938a7ef67..cc38f1e878 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -529,6 +529,12 @@ static void memset_bytes(uint8_t *dst, size_t
dst_size,
uint8_t *clear,
}
} else if (clear_size == 4) {
uint32_t val = AV_RN32(clear);
+uint64_t val8 = val * 0x10001ULL;
+for (; dst_size >= 32; dst_size -= 32) {
+AV_WN64(dst   , val8); AV_WN64(dst+ 8, val8);
+AV_WN64(dst+16, val8); AV_WN64(dst+24, val8);
+dst += 32;
+}
for (; dst_size >= 4; dst_size -= 4) {
AV_WN32(dst, val);
dst += 4;
--
2.20.1



NAK, implement special memset function instead.


I can move the added loop into a seperate function, if thats what you
suggest ?


No, don't do that.


All the code is already in a "special" memset though, this is
memset_bytes()



I guess function is less useful if its static. So any duplicate should
be avoided in codebase.


Isn't av_memcpy_backptr does almost exactly what is needed here? That can
also be optimized further if needed.


av_memcpy_backptr() copies data with overlap, its more like a recursive
memmove().


So? As far as I see the memset_bytes function in imgutils.c can be replaced
with this:

if (clear_size > dst_size)
clear_size = dst_size;
memcpy(dst, clear, clear_size);
av_memcpy_backptr(dst + clear_size, clear_size, dst_size - clear_size);

I am not against an av_memset_bytes API addition, but I believe it should
share code with av_memcpy_backptr to avoid duplication.


ive implemented this, it does not seem to be really faster in the testcase


I guess it is not faster because you have not applied your 
original optimalization to fill32 in libavutil/mem.c. Could you compare 
speed after optimizing that the same way your original patch did it with 
imgutils memset_bytes?


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


[FFmpeg-devel] [PATCH] Support HDR dynamic metdata (HDR10+) in HEVC decoder.

2019-01-16 Thread Mohammad Izadi
---
 libavcodec/hevc_sei.c | 211 --
 libavcodec/hevc_sei.h |   6 ++
 libavcodec/hevcdec.c  |  22 +
 3 files changed, 233 insertions(+), 6 deletions(-)

diff --git a/libavcodec/hevc_sei.c b/libavcodec/hevc_sei.c
index c59bd4321e..265e3f4dd1 100644
--- a/libavcodec/hevc_sei.c
+++ b/libavcodec/hevc_sei.c
@@ -25,6 +25,7 @@
 #include "golomb.h"
 #include "hevc_ps.h"
 #include "hevc_sei.h"
+#include "libavutil/hdr_dynamic_metadata.h"
 
 static int decode_nal_sei_decoded_picture_hash(HEVCSEIPictureHash *s, 
GetBitContext *gb)
 {
@@ -206,10 +207,179 @@ static int 
decode_registered_user_data_closed_caption(HEVCSEIA53Caption *s, GetB
 return 0;
 }
 
-static int decode_nal_sei_user_data_registered_itu_t_t35(HEVCSEI *s, 
GetBitContext *gb,
+static int decode_registered_user_data_dynamic_hdr_plus(AVDynamicHDRPlus *s, 
GetBitContext *gb,
+void *logctx, int size)
+{
+const int luminance_den = 1;
+const int peak_luminance_den = 15;
+const int rgb_den = 10;
+const int fraction_pixel_den = 1000;
+const int knee_point_den = 4095;
+const int bezier_anchor_den = 1023;
+const int saturation_weight_den = 8;
+
+int w, i, j;
+
+if (get_bits_left(gb) < size * 8)
+return AVERROR_INVALIDDATA;
+
+if (get_bits_left(gb) < 2)
+return AVERROR_INVALIDDATA;
+s->num_windows = get_bits(gb, 2);
+if (s->num_windows < 1 || s->num_windows > 3) {
+av_log(logctx, AV_LOG_ERROR, "num_windows=%d, must be in [1, 3]\n",
+   s->num_windows);
+return AVERROR_INVALIDDATA;
+}
+
+if (get_bits_left(gb) < ((19 * 8 + 1) * (s->num_windows - 1)))
+return AVERROR_INVALIDDATA;
+for (w = 1; w < s->num_windows; w++) {
+s->params[w].window_upper_left_corner_x.num = get_bits(gb, 16);
+s->params[w].window_upper_left_corner_y.num = get_bits(gb, 16);
+s->params[w].window_lower_right_corner_x.num = get_bits(gb, 16);
+s->params[w].window_lower_right_corner_y.num = get_bits(gb, 16);
+// The corners are set to absolute coordinates here. They should be
+// converted to the relative coordinates (in [0, 1]) in the decoder.
+s->params[w].window_upper_left_corner_x.den = 1;
+s->params[w].window_upper_left_corner_y.den = 1;
+s->params[w].window_lower_right_corner_x.den = 1;
+s->params[w].window_lower_right_corner_y.den = 1;
+
+s->params[w].center_of_ellipse_x = get_bits(gb, 16);
+s->params[w].center_of_ellipse_y = get_bits(gb, 16);
+s->params[w].rotation_angle = get_bits(gb, 8);
+s->params[w].semimajor_axis_internal_ellipse = get_bits(gb, 16);
+s->params[w].semimajor_axis_external_ellipse = get_bits(gb, 16);
+s->params[w].semiminor_axis_external_ellipse = get_bits(gb, 16);
+s->params[w].overlap_process_option = get_bits(gb, 1);
+}
+
+if (get_bits_left(gb) < 28)
+return AVERROR(EINVAL);
+s->targeted_system_display_maximum_luminance.num = get_bits(gb, 27);
+s->targeted_system_display_maximum_luminance.den = luminance_den;
+s->targeted_system_display_actual_peak_luminance_flag = get_bits(gb, 1);
+
+if (s->targeted_system_display_actual_peak_luminance_flag) {
+int rows, cols;
+if (get_bits_left(gb) < 10)
+return AVERROR(EINVAL);
+rows = get_bits(gb, 5);
+cols = get_bits(gb, 5);
+if (((rows < 2) && (rows > 25)) || ((cols < 2) && (cols > 25))) {
+av_log(logctx, AV_LOG_ERROR, "num_rows=%d, num_cols=%d, they must 
[2, 25] for targeted_system_display_actual_peak_luminance\n", rows, cols);
+return AVERROR_INVALIDDATA;
+}
+s->num_rows_targeted_system_display_actual_peak_luminance = rows;
+s->num_cols_targeted_system_display_actual_peak_luminance = cols;
+
+if (get_bits_left(gb) < (rows * cols * 4))
+return AVERROR(EINVAL);
+
+for (i = 0; i < rows; i++) {
+for (j = 0; j < cols; j++) {
+s->targeted_system_display_actual_peak_luminance[i][j].num = 
get_bits(gb, 4);
+s->targeted_system_display_actual_peak_luminance[i][j].den = 
peak_luminance_den;
+}
+}
+}
+for (w = 0; w < s->num_windows; w++) {
+if (get_bits_left(gb) < (3 * 17 + 17 + 4))
+return AVERROR(EINVAL);
+for (i = 0; i < 3; i++) {
+s->params[w].maxscl[i].num = get_bits(gb, 17);
+s->params[w].maxscl[i].den = rgb_den;
+}
+s->params[w].average_maxrgb.num = get_bits(gb, 17);
+s->params[w].average_maxrgb.den = rgb_den;
+s->params[w].num_distribution_maxrgb_percentiles = get_bits(gb, 4);
+
+if (get_bits_left(gb) <
+(s->params[w].num_distribution_maxrgb_percentiles * 24))
+return AVERROR(EINVAL);
+for (i = 0; i < s->params[w].num_distributio

Re: [FFmpeg-devel] [PATCH] palettegen: Fill with last color, not black

2019-01-16 Thread Carl Eugen Hoyos
2019-01-16 13:40 GMT+01:00, Tomas Härdin :
> Hi
>
> I was helping the fine folks at peppercarrot.com with web video
> nonsense, and I notice palettegen outputs more colors than it should
> due to padding the generated palette with pure black.
>
> Compare this (ffmpeg version 3.2.12-1~deb9u1):
> http://www.härdin.se/files/peppercarrot_gif/output-blackspecks-64.gif
> with this (282a471 with this patch applied):
> http://www.härdin.se/files/peppercarrot_gif/output-fixed-64.gif
>
> The attached patch fixes this by padding with the last color instead of
> black.

lgtm, but I believe there is a maintainer so please wait a few days.

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


Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc/qsvenc: add VDENC support for H264

2019-01-16 Thread Carl Eugen Hoyos
2019-01-16 7:44 GMT+01:00, Li, Zhong :
>> > Is it a possible way to show "not supported" info and set the option
>> > to default off instead of  just hiding the option?
>> >
>> > Like:
>> > #if QSV_HAVE_VDENC
>> > { "low_power", "enable low power mode (experimental, many
>> > limitations by mfx version, HW platform, BRC modes, etc.)",
>> > OFFSET(qsv.low_power), AV_OPT_TYPE_BOOL, { .i64 =  0 }, 0, 1, VE}, #
>> > else
>> > { "low_power", "not supported", OFFSET(qsv.low_power),
>> > AV_OPT_TYPE_BOOL, { .i64 =  0 }, 0, 0, VE}, #endif
>>
>> This is also an option but I wonder if a failure message wouldn't help
>> users
>> even more.
>
> It give a remind to user to prevent to set an useless option, instead of
> setting it and expect it will take effect.

This is what I suggest with the error message.

I found your new patch after having this discussion a little disturbing.

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


[FFmpeg-devel] [PATCH] avcodec/rscc: Avoid returning frames that have nearly no undamaged pixels in them

2019-01-16 Thread Michael Niedermayer
Fixes: Timeout
Fixes: 
12192/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264

Before: 
clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264 
in 15423 ms
After:  
clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264 
in 190 ms

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

diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
index 7921f149ed..fa066afd7f 100644
--- a/libavcodec/rscc.c
+++ b/libavcodec/rscc.c
@@ -64,6 +64,7 @@ typedef struct RsccContext {
 /* zlib interaction */
 uint8_t *inflated_buf;
 uLongf inflated_size;
+int valid_pixels
 } RsccContext;
 
 static av_cold int rscc_init(AVCodecContext *avctx)
@@ -348,7 +349,11 @@ static int rscc_decode_frame(AVCodecContext *avctx, void 
*data,
 memcpy (frame->data[1], ctx->palette, AVPALETTE_SIZE);
 }
 
-*got_frame = 1;
+// We only return a picture when more than 5% is undameged, this avoids 
copying nearly broken frames around
+if (ctx->valid_pixels < ctx->inflated_size)
+ctx->valid_pixels += pixel_size;
+if (ctx->valid_pixels >= ctx->inflated_size/20)
+*got_frame = 1;
 
 ret = avpkt->size;
 end:
-- 
2.20.1

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


Re: [FFmpeg-devel] [PATCH v3] Improved the performance of 1 decode + N filter graphs and adaptive bitrate.

2019-01-16 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Shaofei Wang
> Sent: Thursday, January 17, 2019 5:17 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: mich...@niedermayer.cc; atomnu...@gmail.com; c...@passwd.hu;
> Wang, Shaofei ; ceffm...@gmail.com
> Subject: [FFmpeg-devel] [PATCH v3] Improved the performance of 1 decode
> + N filter graphs and adaptive bitrate.
> 
> With new option "-abr_pipeline"
> It enabled multiple filter graph concurrency, which bring obove about
> 4%~20% improvement in some 1:N scenarios by CPU or GPU acceleration
> 
> Below are some test cases and comparison as reference.
> (Hardware platform: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz)
> (Software: Intel iHD driver - 16.9.00100, CentOS 7)
> 
> For 1:N transcode by GPU acceleration with vaapi:
> ./ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi \
> -hwaccel_output_format vaapi \
> -i ~/Videos/1920x1080p_30.00_x264_qp28.h264 \
> -vf "scale_vaapi=1280:720" -c:v h264_vaapi -f null /dev/null \
> -vf "scale_vaapi=720:480" -c:v h264_vaapi -f null /dev/null \
> -abr_pipeline
> 
> test results:
> 2 encoders 5 encoders 10 encoders
> Improved   6.1%6.9%   5.5%
> 
> For 1:N transcode by GPU acceleration with QSV:
> ./ffmpeg -hwaccel qsv -c:v h264_qsv \
> -i ~/Videos/1920x1080p_30.00_x264_qp28.h264 \
> -vf "scale_qsv=1280:720:format=nv12" -c:v h264_qsv -f null /dev/null \
> -vf "scale_qsv=720:480:format=nv12" -c:v h264_qsv -f null /dev/null
> 
> test results:
> 2 encoders  5 encoders 10 encoders
> Improved   6%   4% 15%
> 
> For Intel GPU acceleration case, 1 decode to N scaling, by QSV:
> ./ffmpeg -hwaccel qsv -c:v h264_qsv \
> -i ~/Videos/1920x1080p_30.00_x264_qp28.h264 \
> -vf "scale_qsv=1280:720:format=nv12,hwdownload" -pix_fmt nv12 -f null
> /dev/null \
> -vf "scale_qsv=720:480:format=nv12,hwdownload" -pix_fmt nv12 -f null
> /dev/null
> 
> test results:
> 2 scale  5 scale   10 scale
> Improved   12% 21%21%
> 
> For CPU only 1 decode to N scaling:
> ./ffmpeg -i ~/Videos/1920x1080p_30.00_x264_qp28.h264 \
> -vf "scale=1280:720" -pix_fmt nv12 -f null /dev/null \
> -vf "scale=720:480" -pix_fmt nv12 -f null /dev/null \
> -abr_pipeline
> 
> test results:
> 2 scale  5 scale   10 scale
> Improved   25%107%   148%
> 
> Signed-off-by: Wang, Shaofei 
> Reviewed-by: Zhao, Jun 
> ---
>  fftools/ffmpeg.c| 228
> 
>  fftools/ffmpeg.h|  15 
>  fftools/ffmpeg_filter.c |   4 +
>  fftools/ffmpeg_opt.c|   6 +-
>  4 files changed, 237 insertions(+), 16 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 544f1a1..7dbff15 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -1523,6 +1523,109 @@ static int reap_filters(int flush)
>  return 0;
>  }
> 
> +static int pipeline_reap_filters(int flush, InputFilter * ifilter)
> +{
> +AVFrame *filtered_frame = NULL;
> +int i;
> +
> +for (i = 0; i < nb_output_streams; i++) {
> +if (ifilter == output_streams[i]->filter->graph->inputs[0]) break;
> +}
> +OutputStream *ost = output_streams[i];
> +OutputFile*of = output_files[ost->file_index];
> +AVFilterContext *filter;
> +AVCodecContext *enc = ost->enc_ctx;
> +int ret = 0;
> +
> +if (!ost->filter || !ost->filter->graph->graph)
> +return 0;
> +filter = ost->filter->filter;
> +
> +if (!ost->initialized) {
> +char error[1024] = "";
> +ret = init_output_stream(ost, error, sizeof(error));
> +if (ret < 0) {
> +av_log(NULL, AV_LOG_ERROR, "Error initializing output stream 
> %d:%d
> -- %s\n",
> +   ost->file_index, ost->index, error);
> +exit_program(1);

imo, it's not good to exit the program.

> +}
> +}
> +
> +if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc()))
> +return AVERROR(ENOMEM);
> +filtered_frame = ost->filtered_frame;
> +
> +while (1) {
> +double float_pts = AV_NOPTS_VALUE; // this is identical to
> filtered_frame.pts but with higher precision
> +ret = av_buffersink_get_frame_flags(filter, filtered_frame,
> +   AV_BUFFERSINK_FLAG_NO_REQUEST);
> +if (ret < 0) {
> +if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
> +av_log(NULL, AV_LOG_WARNING,
> +   "Error in av_buffersink_get_frame_flags(): %s\n",
> av_err2str(ret));
> +} else if (flush && ret == AVERROR_EOF) {
> +if (av_buffersink_get_type(filter) == AVMEDIA_TYPE_VIDEO)
> +do_video_out(of, ost, NULL, AV_NOPTS_VALUE);
> +}
> +break;
> +}
> +if (ost->finished) {
> +av_f

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

2019-01-16 Thread Guo, Yejun


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Zachary Zhou
> Sent: Wednesday, January 16, 2019 3:05 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Zhou, Zachary 
> Subject: [FFmpeg-devel] [PATCH V9] libavfilter: add transpose_vaapi filter
> 
> Swap width and height when do clock/cclock rotation
> Add reversal/hflip/vflip options
> 
> ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
> -hwaccel_output_format vaapi -i input.264 -vf "transpose_vaapi=clock_flip"
> -c:v h264_vaapi output.h264
> 
> Signed-off-by: Zachary Zhou 
> ---
>  configure|   2 +
>  libavfilter/Makefile |   1 +
>  libavfilter/allfilters.c |   1 +
>  libavfilter/transpose.h  |   3 +
>  libavfilter/vf_transpose_vaapi.c | 334
> +++
>  5 files changed, 341 insertions(+)
>  create mode 100644 libavfilter/vf_transpose_vaapi.c
> 
> diff --git a/configure b/configure
> index 2205751402..bf0e435b53 100755
> --- a/configure
> +++ b/configure
> @@ -3482,6 +3482,7 @@ tinterlace_pad_test_deps="tinterlace_filter"
>  tonemap_filter_deps="const_nan"
>  tonemap_opencl_filter_deps="opencl const_nan"
>  transpose_opencl_filter_deps="opencl"
> +transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
>  unsharp_opencl_filter_deps="opencl"
>  uspp_filter_deps="gpl avcodec"
>  vaguedenoiser_filter_deps="gpl"
> @@ -5985,6 +5986,7 @@ check_type "d3d9.h dxva2api.h"
> DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
> 
>  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
>  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
> +check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
>  check_type "va/va.h va/va_enc_hevc.h"
> "VAEncPictureParameterBufferHEVC"
>  check_type "va/va.h va/va_enc_jpeg.h"
> "VAEncPictureParameterBufferJPEG"
>  check_type "va/va.h va/va_enc_vp8.h"
> "VAEncPictureParameterBufferVP8"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index 6e2658186d..4246d3480f 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -394,6 +394,7 @@ OBJS-$(CONFIG_TPAD_FILTER)   += vf_tpad.o
>  OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
>  OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o
> cuda_check.o
>  OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER)   +=
> vf_transpose_opencl.o opencl.o opencl/transpose.o
> +OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+= vf_transpose_vaapi.o
> vaapi_vpp.o
>  OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
>  OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o
> framesync.o
>  OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index a600069500..0b82ff7ced 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -373,6 +373,7 @@ extern AVFilter ff_vf_tpad;
>  extern AVFilter ff_vf_transpose;
>  extern AVFilter ff_vf_transpose_npp;
>  extern AVFilter ff_vf_transpose_opencl;
> +extern AVFilter ff_vf_transpose_vaapi;
>  extern AVFilter ff_vf_trim;
>  extern AVFilter ff_vf_unpremultiply;
>  extern AVFilter ff_vf_unsharp;
> diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h
> index d4bb4da1ae..aa262b9487 100644
> --- a/libavfilter/transpose.h
> +++ b/libavfilter/transpose.h
> @@ -29,6 +29,9 @@ enum TransposeDir {
>  TRANSPOSE_CLOCK,
>  TRANSPOSE_CCLOCK,
>  TRANSPOSE_CLOCK_FLIP,
> +TRANSPOSE_REVERSAL,// rotate by half-turn
> +TRANSPOSE_HFLIP,
> +TRANSPOSE_VFLIP,
>  };
> 
>  #endif
> diff --git a/libavfilter/vf_transpose_vaapi.c 
> b/libavfilter/vf_transpose_vaapi.c
> new file mode 100644
> index 00..25641b626d
> --- /dev/null
> +++ b/libavfilter/vf_transpose_vaapi.c
> @@ -0,0 +1,334 @@
> +/*
> + * 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 "transpose.h"
> +#include "vaapi_vpp.h"
> +
> +typedef struct TransposeVAAPICo

Re: [FFmpeg-devel] [PATCH] avcodec/rscc: Avoid returning frames that have nearly no undamaged pixels in them

2019-01-16 Thread Kieran Kunhya
On Thu, 17 Jan 2019 at 00:44 Michael Niedermayer 
wrote:

> Fixes: Timeout
> Fixes:
> 12192/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
>
> Before:
> clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
> in 15423 ms
> After:
> clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
> in 190 ms
>

Oh come on, this is getting a bit ridiculous now.

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


Re: [FFmpeg-devel] [PATCH] avcodec/rscc: Avoid returning frames that have nearly no undamaged pixels in them

2019-01-16 Thread Vittorio Giovara
On Wed, Jan 16, 2019 at 7:44 PM Michael Niedermayer 
wrote:

> Fixes: Timeout
> Fixes:
> 12192/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
>
> Before:
> clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
> in 15423 ms
> After:
> clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
> in 190 ms
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by
> :
> Michael Niedermayer 
> ---
>  libavcodec/rscc.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
> index 7921f149ed..fa066afd7f 100644
> --- a/libavcodec/rscc.c
> +++ b/libavcodec/rscc.c
> @@ -64,6 +64,7 @@ typedef struct RsccContext {
>  /* zlib interaction */
>  uint8_t *inflated_buf;
>  uLongf inflated_size;
> +int valid_pixels
>  } RsccContext;
>
>  static av_cold int rscc_init(AVCodecContext *avctx)
> @@ -348,7 +349,11 @@ static int rscc_decode_frame(AVCodecContext *avctx,
> void *data,
>  memcpy (frame->data[1], ctx->palette, AVPALETTE_SIZE);
>  }
>
> -*got_frame = 1;
> +// We only return a picture when more than 5% is undameged, this
> avoids copying nearly broken frames around
> +if (ctx->valid_pixels < ctx->inflated_size)
> +ctx->valid_pixels += pixel_size;
> +if (ctx->valid_pixels >= ctx->inflated_size/20)
>

this feels arbitrary and hackish, for very little gain, IMO
-- 
Vittorio
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2019-01-16 Thread Zhou, Zachary


> -Original Message-
> From: Guo, Yejun
> Sent: Thursday, January 17, 2019 9:29 AM
> To: FFmpeg development discussions and patches 
> Cc: Zhou, Zachary 
> Subject: RE: [FFmpeg-devel] [PATCH V9] libavfilter: add transpose_vaapi filter
> 
> 
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Zachary Zhou
> > Sent: Wednesday, January 16, 2019 3:05 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Zhou, Zachary 
> > Subject: [FFmpeg-devel] [PATCH V9] libavfilter: add transpose_vaapi
> > filter
> >
> > Swap width and height when do clock/cclock rotation Add
> > reversal/hflip/vflip options
> >
> > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
> > -hwaccel_output_format vaapi -i input.264 -vf "transpose_vaapi=clock_flip"
> > -c:v h264_vaapi output.h264
> >
> > Signed-off-by: Zachary Zhou 
> > ---
> >  configure|   2 +
> >  libavfilter/Makefile |   1 +
> >  libavfilter/allfilters.c |   1 +
> >  libavfilter/transpose.h  |   3 +
> >  libavfilter/vf_transpose_vaapi.c | 334
> > +++
> >  5 files changed, 341 insertions(+)
> >  create mode 100644 libavfilter/vf_transpose_vaapi.c
> >
> > diff --git a/configure b/configure
> > index 2205751402..bf0e435b53 100755
> > --- a/configure
> > +++ b/configure
> > @@ -3482,6 +3482,7 @@ tinterlace_pad_test_deps="tinterlace_filter"
> >  tonemap_filter_deps="const_nan"
> >  tonemap_opencl_filter_deps="opencl const_nan"
> >  transpose_opencl_filter_deps="opencl"
> > +transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
> >  unsharp_opencl_filter_deps="opencl"
> >  uspp_filter_deps="gpl avcodec"
> >  vaguedenoiser_filter_deps="gpl"
> > @@ -5985,6 +5986,7 @@ check_type "d3d9.h dxva2api.h"
> > DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
> >
> >  check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
> >  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
> > +check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps"
> > +rotation_flags
> >  check_type "va/va.h va/va_enc_hevc.h"
> > "VAEncPictureParameterBufferHEVC"
> >  check_type "va/va.h va/va_enc_jpeg.h"
> > "VAEncPictureParameterBufferJPEG"
> >  check_type "va/va.h va/va_enc_vp8.h"
> > "VAEncPictureParameterBufferVP8"
> > diff --git a/libavfilter/Makefile b/libavfilter/Makefile index
> > 6e2658186d..4246d3480f 100644
> > --- a/libavfilter/Makefile
> > +++ b/libavfilter/Makefile
> > @@ -394,6 +394,7 @@ OBJS-$(CONFIG_TPAD_FILTER)   +=
> vf_tpad.o
> >  OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
> >  OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o
> > cuda_check.o
> >  OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER)   +=
> > vf_transpose_opencl.o opencl.o opencl/transpose.o
> > +OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+= vf_transpose_vaapi.o
> > vaapi_vpp.o
> >  OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
> >  OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o
> > framesync.o
> >  OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o
> > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index
> > a600069500..0b82ff7ced 100644
> > --- a/libavfilter/allfilters.c
> > +++ b/libavfilter/allfilters.c
> > @@ -373,6 +373,7 @@ extern AVFilter ff_vf_tpad;  extern AVFilter
> > ff_vf_transpose;  extern AVFilter ff_vf_transpose_npp;  extern
> > AVFilter ff_vf_transpose_opencl;
> > +extern AVFilter ff_vf_transpose_vaapi;
> >  extern AVFilter ff_vf_trim;
> >  extern AVFilter ff_vf_unpremultiply;
> >  extern AVFilter ff_vf_unsharp;
> > diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h index
> > d4bb4da1ae..aa262b9487 100644
> > --- a/libavfilter/transpose.h
> > +++ b/libavfilter/transpose.h
> > @@ -29,6 +29,9 @@ enum TransposeDir {
> >  TRANSPOSE_CLOCK,
> >  TRANSPOSE_CCLOCK,
> >  TRANSPOSE_CLOCK_FLIP,
> > +TRANSPOSE_REVERSAL,// rotate by half-turn
> > +TRANSPOSE_HFLIP,
> > +TRANSPOSE_VFLIP,
> >  };
> >
> >  #endif
> > diff --git a/libavfilter/vf_transpose_vaapi.c
> > b/libavfilter/vf_transpose_vaapi.c
> > new file mode 100644
> > index 00..25641b626d
> > --- /dev/null
> > +++ b/libavfilter/vf_transpose_vaapi.c
> > @@ -0,0 +1,334 @@
> > +/*
> > + * 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 P

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

2019-01-16 Thread Guo, Yejun


> -Original Message-
> From: Zhou, Zachary
> Sent: Thursday, January 17, 2019 10:35 AM
> To: Guo, Yejun ; FFmpeg development discussions
> and patches 
> Subject: RE: [FFmpeg-devel] [PATCH V9] libavfilter: add transpose_vaapi
> filter
> 
> 
> 
> > -Original Message-
> > From: Guo, Yejun
> > Sent: Thursday, January 17, 2019 9:29 AM
> > To: FFmpeg development discussions and patches  de...@ffmpeg.org>
> > Cc: Zhou, Zachary 
> > Subject: RE: [FFmpeg-devel] [PATCH V9] libavfilter: add transpose_vaapi
> filter
> >
> >
> >
> > > -Original Message-
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > > Of Zachary Zhou
> > > Sent: Wednesday, January 16, 2019 3:05 PM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Zhou, Zachary 
> > > Subject: [FFmpeg-devel] [PATCH V9] libavfilter: add transpose_vaapi
> > > filter
> > >
> > > Swap width and height when do clock/cclock rotation Add
> > > reversal/hflip/vflip options
> > >
> > > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128
> > > -hwaccel_output_format vaapi -i input.264 -vf
> "transpose_vaapi=clock_flip"
> > > -c:v h264_vaapi output.h264
> > >
> > > Signed-off-by: Zachary Zhou 
> > > ---
> > >  configure|   2 +
> > >  libavfilter/Makefile |   1 +
> > >  libavfilter/allfilters.c |   1 +
> > >  libavfilter/transpose.h  |   3 +
> > >  libavfilter/vf_transpose_vaapi.c | 334
> > > +++
> > >  5 files changed, 341 insertions(+)
> > >  create mode 100644 libavfilter/vf_transpose_vaapi.c
> > >
> > > diff --git a/configure b/configure
> > > index 2205751402..bf0e435b53 100755
> > > --- a/configure
> > > +++ b/configure
> > > @@ -3482,6 +3482,7 @@ tinterlace_pad_test_deps="tinterlace_filter"
> > >  tonemap_filter_deps="const_nan"
> > >  tonemap_opencl_filter_deps="opencl const_nan"
> > >  transpose_opencl_filter_deps="opencl"
> > > +transpose_vaapi_filter_deps="vaapi
> VAProcPipelineCaps_rotation_flags"
> > >  unsharp_opencl_filter_deps="opencl"
> > >  uspp_filter_deps="gpl avcodec"
> > >  vaguedenoiser_filter_deps="gpl"
> > > @@ -5985,6 +5986,7 @@ check_type "d3d9.h dxva2api.h"
> > > DXVA2_ConfigPictureDecode -D_WIN32_WINNT=0x0602
> > >
> > >  check_type "va/va.h va/va_dec_hevc.h"
> "VAPictureParameterBufferHEVC"
> > >  check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
> > > +check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps"
> > > +rotation_flags
> > >  check_type "va/va.h va/va_enc_hevc.h"
> > > "VAEncPictureParameterBufferHEVC"
> > >  check_type "va/va.h va/va_enc_jpeg.h"
> > > "VAEncPictureParameterBufferJPEG"
> > >  check_type "va/va.h va/va_enc_vp8.h"
> > > "VAEncPictureParameterBufferVP8"
> > > diff --git a/libavfilter/Makefile b/libavfilter/Makefile index
> > > 6e2658186d..4246d3480f 100644
> > > --- a/libavfilter/Makefile
> > > +++ b/libavfilter/Makefile
> > > @@ -394,6 +394,7 @@ OBJS-$(CONFIG_TPAD_FILTER)   +=
> > vf_tpad.o
> > >  OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
> > >  OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o
> > > cuda_check.o
> > >  OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER)   +=
> > > vf_transpose_opencl.o opencl.o opencl/transpose.o
> > > +OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+=
> vf_transpose_vaapi.o
> > > vaapi_vpp.o
> > >  OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
> > >  OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o
> > > framesync.o
> > >  OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o
> > > diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index
> > > a600069500..0b82ff7ced 100644
> > > --- a/libavfilter/allfilters.c
> > > +++ b/libavfilter/allfilters.c
> > > @@ -373,6 +373,7 @@ extern AVFilter ff_vf_tpad;  extern AVFilter
> > > ff_vf_transpose;  extern AVFilter ff_vf_transpose_npp;  extern
> > > AVFilter ff_vf_transpose_opencl;
> > > +extern AVFilter ff_vf_transpose_vaapi;
> > >  extern AVFilter ff_vf_trim;
> > >  extern AVFilter ff_vf_unpremultiply;
> > >  extern AVFilter ff_vf_unsharp;
> > > diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h index
> > > d4bb4da1ae..aa262b9487 100644
> > > --- a/libavfilter/transpose.h
> > > +++ b/libavfilter/transpose.h
> > > @@ -29,6 +29,9 @@ enum TransposeDir {
> > >  TRANSPOSE_CLOCK,
> > >  TRANSPOSE_CCLOCK,
> > >  TRANSPOSE_CLOCK_FLIP,
> > > +TRANSPOSE_REVERSAL,// rotate by half-turn
> > > +TRANSPOSE_HFLIP,
> > > +TRANSPOSE_VFLIP,
> > >  };
> > >
> > >  #endif
> > > diff --git a/libavfilter/vf_transpose_vaapi.c
> > > b/libavfilter/vf_transpose_vaapi.c
> > > new file mode 100644
> > > index 00..25641b626d
> > > --- /dev/null
> > > +++ b/libavfilter/vf_transpose_vaapi.c
> > > @@ -0,0 +1,334 @@
> > > +/*
> > > + * 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 Gene

Re: [FFmpeg-devel] [PATCH] avcodec/rscc: Avoid returning frames that have nearly no undamaged pixels in them

2019-01-16 Thread Carl Eugen Hoyos


> Am 17.01.2019 um 03:05 schrieb Vittorio Giovara :
> 
> On Wed, Jan 16, 2019 at 7:44 PM Michael Niedermayer 
> wrote:
> 
>> Fixes: Timeout
>> Fixes:
>> 12192/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
>> 
>> Before:
>> clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
>> in 15423 ms
>> After:
>> clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_RSCC_fuzzer-6279038004363264
>> in 190 ms
>> 
>> Found-by: continuous fuzzing process
>> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
>> Signed-off-by
>> :
>> Michael Niedermayer 
>> ---
>> libavcodec/rscc.c | 7 ++-
>> 1 file changed, 6 insertions(+), 1 deletion(-)
>> 
>> diff --git a/libavcodec/rscc.c b/libavcodec/rscc.c
>> index 7921f149ed..fa066afd7f 100644
>> --- a/libavcodec/rscc.c
>> +++ b/libavcodec/rscc.c
>> @@ -64,6 +64,7 @@ typedef struct RsccContext {
>> /* zlib interaction */
>> uint8_t *inflated_buf;
>> uLongf inflated_size;
>> +int valid_pixels
>> } RsccContext;
>> 
>> static av_cold int rscc_init(AVCodecContext *avctx)
>> @@ -348,7 +349,11 @@ static int rscc_decode_frame(AVCodecContext *avctx,
>> void *data,
>> memcpy (frame->data[1], ctx->palette, AVPALETTE_SIZE);
>> }
>> 
>> -*got_frame = 1;
>> +// We only return a picture when more than 5% is undameged, this
>> avoids copying nearly broken frames around
>> +if (ctx->valid_pixels < ctx->inflated_size)
>> +ctx->valid_pixels += pixel_size;
>> +if (ctx->valid_pixels >= ctx->inflated_size/20)
>> 
> 
> this feels arbitrary and hackish, for very little gain, IMO

You mean searching for security issues makes no sense?

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


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

2019-01-16 Thread Zachary Zhou
Swap width and height when do clock/cclock rotation
Add reversal/hflip/vflip options

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

Signed-off-by: Zachary Zhou 
---
 configure|   2 +
 libavfilter/Makefile |   1 +
 libavfilter/allfilters.c |   1 +
 libavfilter/transpose.h  |   3 +
 libavfilter/vf_transpose_vaapi.c | 316 +++
 5 files changed, 323 insertions(+)
 create mode 100644 libavfilter/vf_transpose_vaapi.c

diff --git a/configure b/configure
index 2205751402..bf0e435b53 100755
--- a/configure
+++ b/configure
@@ -3482,6 +3482,7 @@ tinterlace_pad_test_deps="tinterlace_filter"
 tonemap_filter_deps="const_nan"
 tonemap_opencl_filter_deps="opencl const_nan"
 transpose_opencl_filter_deps="opencl"
+transpose_vaapi_filter_deps="vaapi VAProcPipelineCaps_rotation_flags"
 unsharp_opencl_filter_deps="opencl"
 uspp_filter_deps="gpl avcodec"
 vaguedenoiser_filter_deps="gpl"
@@ -5985,6 +5986,7 @@ check_type "d3d9.h dxva2api.h" DXVA2_ConfigPictureDecode 
-D_WIN32_WINNT=0x0602
 
 check_type "va/va.h va/va_dec_hevc.h" "VAPictureParameterBufferHEVC"
 check_struct "va/va.h" "VADecPictureParameterBufferVP9" bit_depth
+check_struct "va/va.h va/va_vpp.h" "VAProcPipelineCaps" rotation_flags
 check_type "va/va.h va/va_enc_hevc.h" "VAEncPictureParameterBufferHEVC"
 check_type "va/va.h va/va_enc_jpeg.h" "VAEncPictureParameterBufferJPEG"
 check_type "va/va.h va/va_enc_vp8.h"  "VAEncPictureParameterBufferVP8"
diff --git a/libavfilter/Makefile b/libavfilter/Makefile
index 6e2658186d..4246d3480f 100644
--- a/libavfilter/Makefile
+++ b/libavfilter/Makefile
@@ -394,6 +394,7 @@ OBJS-$(CONFIG_TPAD_FILTER)   += vf_tpad.o
 OBJS-$(CONFIG_TRANSPOSE_FILTER)  += vf_transpose.o
 OBJS-$(CONFIG_TRANSPOSE_NPP_FILTER)  += vf_transpose_npp.o cuda_check.o
 OBJS-$(CONFIG_TRANSPOSE_OPENCL_FILTER)   += vf_transpose_opencl.o opencl.o 
opencl/transpose.o
+OBJS-$(CONFIG_TRANSPOSE_VAAPI_FILTER)+= vf_transpose_vaapi.o 
vaapi_vpp.o
 OBJS-$(CONFIG_TRIM_FILTER)   += trim.o
 OBJS-$(CONFIG_UNPREMULTIPLY_FILTER)  += vf_premultiply.o framesync.o
 OBJS-$(CONFIG_UNSHARP_FILTER)+= vf_unsharp.o
diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
index a600069500..0b82ff7ced 100644
--- a/libavfilter/allfilters.c
+++ b/libavfilter/allfilters.c
@@ -373,6 +373,7 @@ extern AVFilter ff_vf_tpad;
 extern AVFilter ff_vf_transpose;
 extern AVFilter ff_vf_transpose_npp;
 extern AVFilter ff_vf_transpose_opencl;
+extern AVFilter ff_vf_transpose_vaapi;
 extern AVFilter ff_vf_trim;
 extern AVFilter ff_vf_unpremultiply;
 extern AVFilter ff_vf_unsharp;
diff --git a/libavfilter/transpose.h b/libavfilter/transpose.h
index d4bb4da1ae..aa262b9487 100644
--- a/libavfilter/transpose.h
+++ b/libavfilter/transpose.h
@@ -29,6 +29,9 @@ enum TransposeDir {
 TRANSPOSE_CLOCK,
 TRANSPOSE_CCLOCK,
 TRANSPOSE_CLOCK_FLIP,
+TRANSPOSE_REVERSAL,// rotate by half-turn
+TRANSPOSE_HFLIP,
+TRANSPOSE_VFLIP,
 };
 
 #endif
diff --git a/libavfilter/vf_transpose_vaapi.c b/libavfilter/vf_transpose_vaapi.c
new file mode 100644
index 00..8c691cfab5
--- /dev/null
+++ b/libavfilter/vf_transpose_vaapi.c
@@ -0,0 +1,316 @@
+/*
+ * 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 "transpose.h"
+#include "vaapi_vpp.h"
+
+typedef struct TransposeVAAPIContext {
+VAAPIVPPContext vpp_ctx; // must be the first field
+int passthrough; // PassthroughType, landscape passthrough mode 
enabled
+int dir; // TransposeDir
+
+int rotation_state;
+int mirror_state;
+} TransposeVAAPIContext;
+
+static int transpose_vaapi_build_filter_params(AVFilterContext *avctx)
+{
+VAAPIVPPContext *vpp_ctx   = avctx->priv;
+TransposeVAAPIContext *ctx = avctx->priv;
+VAStatus vas;
+int support_flag;
+VAProcPipelineCaps pipeline_caps;
+
+memset(

Re: [FFmpeg-devel] [FFmpeg-cvslog] lavc/qsvenc: add VDENC support for H264

2019-01-16 Thread Li, Zhong
> I found your new patch after having this discussion a little disturbing.
> 
> Carl Eugen
I believe it is a little different as this patch.
MFX_SCALING_MODE_DEFAULT/ MFX_SCALING_MODE_QUALITY are only buildable with 
QSV_HAVE_SCALING_CONFIG.
It is same as the libx264 case we discussed.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH v3] Improved the performance of 1 decode + N filter graphs and adaptive bitrate.

2019-01-16 Thread Wang, Shaofei
> From: Guo, Yejun
> Sent: Thursday, January 17, 2019 9:25 AM
> To: FFmpeg development discussions and patches 
> Cc: mich...@niedermayer.cc; atomnu...@gmail.com; c...@passwd.hu;
> Wang, Shaofei ; ceffm...@gmail.com
> Subject: RE: [FFmpeg-devel] [PATCH v3] Improved the performance of 1
> decode + N filter graphs and adaptive bitrate.
> 
> 
> > +static int pipeline_reap_filters(int flush, InputFilter * ifilter) {
> > +AVFrame *filtered_frame = NULL;
> > +int i;
> > +
> > +for (i = 0; i < nb_output_streams; i++) {
> > +if (ifilter == output_streams[i]->filter->graph->inputs[0]) break;
> > +}
> > +OutputStream *ost = output_streams[i];
> > +OutputFile*of = output_files[ost->file_index];
> > +AVFilterContext *filter;
> > +AVCodecContext *enc = ost->enc_ctx;
> > +int ret = 0;
> > +
> > +if (!ost->filter || !ost->filter->graph->graph)
> > +return 0;
> > +filter = ost->filter->filter;
> > +
> > +if (!ost->initialized) {
> > +char error[1024] = "";
> > +ret = init_output_stream(ost, error, sizeof(error));
> > +if (ret < 0) {
> > +av_log(NULL, AV_LOG_ERROR, "Error initializing output
> > + stream %d:%d
> > -- %s\n",
> > +   ost->file_index, ost->index, error);
> > +exit_program(1);
> 
> imo, it's not good to exit the program.
Any reason? These lines are similar as them in reap_filters(). Line 1445.

> > +}
> > +}
> > +
> > +if (!ost->filtered_frame && !(ost->filtered_frame = av_frame_alloc()))
> > +return AVERROR(ENOMEM);
> > +filtered_frame = ost->filtered_frame;
> > +
> > +while (1) {
> > +double float_pts = AV_NOPTS_VALUE; // this is identical to
> > filtered_frame.pts but with higher precision
> > +ret = av_buffersink_get_frame_flags(filter, filtered_frame,
> > +
> AV_BUFFERSINK_FLAG_NO_REQUEST);
> > +if (ret < 0) {
> > +if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
> > +av_log(NULL, AV_LOG_WARNING,
> > +   "Error in av_buffersink_get_frame_flags():
> > + %s\n",
> > av_err2str(ret));
> > +} else if (flush && ret == AVERROR_EOF) {
> > +if (av_buffersink_get_type(filter) ==
> AVMEDIA_TYPE_VIDEO)
> > +do_video_out(of, ost, NULL, AV_NOPTS_VALUE);
> > +}
> > +break;
> > +}
> > +if (ost->finished) {
> > +av_frame_unref(filtered_frame);
> > +continue;
> > +}
> > +if (filtered_frame->pts != AV_NOPTS_VALUE) {
> > +int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ?
> > + 0 : of-
> > >start_time;
> > +AVRational filter_tb = av_buffersink_get_time_base(filter);
> > +AVRational tb = enc->time_base;
> > +int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
> > +
> > +tb.den <<= extra_bits;
> > +float_pts =
> > +av_rescale_q(filtered_frame->pts, filter_tb, tb) -
> > +av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
> > +float_pts /= 1 << extra_bits;
> > +// avoid exact midoints to reduce the chance of rounding
> > + differences,
> > this can be removed in case the fps code is changed to work with
> > integers
> > +float_pts += FFSIGN(float_pts) * 1.0 / (1<<17);
> > +
> > +filtered_frame->pts =
> > +av_rescale_q(filtered_frame->pts, filter_tb,
> enc->time_base) -
> > +av_rescale_q(start_time, AV_TIME_BASE_Q,
> enc->time_base);
> > +}
> > +
> > +switch (av_buffersink_get_type(filter)) {
> > +case AVMEDIA_TYPE_VIDEO:
> > +if (!ost->frame_aspect_ratio.num)
> > +enc->sample_aspect_ratio =
> > + filtered_frame->sample_aspect_ratio;
> > +
> > +if (debug_ts) {
> > +av_log(NULL, AV_LOG_INFO, "filter -> pts:%s
> > + pts_time:%s exact:%f
> > time_base:%d/%d\n",
> > +av_ts2str(filtered_frame->pts),
> > + av_ts2timestr(filtered_frame-
> > >pts, &enc->time_base),
> > +float_pts,
> > +enc->time_base.num, enc->time_base.den);
> > +}
> > +
> > +do_video_out(of, ost, filtered_frame, float_pts);
> > +break;
> > +case AVMEDIA_TYPE_AUDIO:
> > +if (!(enc->codec->capabilities &
> > + AV_CODEC_CAP_PARAM_CHANGE)
> > &&
> > +enc->channels != filtered_frame->channels) {
> > +av_log(NULL, AV_LOG_ERROR,
> > +   "Audio filter graph output is not normalized
> > + and encoder does
> > not support parameter changes\n");
> > +break;
> > +}
> > +do_audio_out(of, ost, filtered_frame);
> > +break;
> > +default:
> > +// TODO support subtitle filters
> > +av_assert0(0);
> 
> ma

Re: [FFmpeg-devel] [PATCH] avutil/ppc/cpu: Fix power8 linux detection

2019-01-16 Thread Lauri Kasanen
On Tue, 8 Jan 2019 11:08:04 +0200
Lauri Kasanen  wrote:

> The existing code was in no released kernel that I can see. The corrected code
> was added in 3.9.
> 
> Signed-off-by: Lauri Kasanen 
> ---
>  libavutil/ppc/cpu.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)

Ping.

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


Re: [FFmpeg-devel] [PATCH v3] Improved the performance of 1 decode + N filter graphs and adaptive bitrate.

2019-01-16 Thread Guo, Yejun


> -Original Message-
> From: Wang, Shaofei
> Sent: Thursday, January 17, 2019 3:36 PM
> To: Guo, Yejun ; FFmpeg development discussions
> and patches 
> Cc: mich...@niedermayer.cc; atomnu...@gmail.com; c...@passwd.hu;
> ceffm...@gmail.com
> Subject: RE: [FFmpeg-devel] [PATCH v3] Improved the performance of 1
> decode + N filter graphs and adaptive bitrate.
> 
> > From: Guo, Yejun
> > Sent: Thursday, January 17, 2019 9:25 AM
> > To: FFmpeg development discussions and patches
> > 
> > Cc: mich...@niedermayer.cc; atomnu...@gmail.com; c...@passwd.hu;
> Wang,
> > Shaofei ; ceffm...@gmail.com
> > Subject: RE: [FFmpeg-devel] [PATCH v3] Improved the performance of 1
> > decode + N filter graphs and adaptive bitrate.
> >
> >
> > > +static int pipeline_reap_filters(int flush, InputFilter * ifilter) {
> > > +AVFrame *filtered_frame = NULL;
> > > +int i;
> > > +
> > > +for (i = 0; i < nb_output_streams; i++) {
> > > +if (ifilter == output_streams[i]->filter->graph->inputs[0]) 
> > > break;
> > > +}
> > > +OutputStream *ost = output_streams[i];
> > > +OutputFile*of = output_files[ost->file_index];
> > > +AVFilterContext *filter;
> > > +AVCodecContext *enc = ost->enc_ctx;
> > > +int ret = 0;
> > > +
> > > +if (!ost->filter || !ost->filter->graph->graph)
> > > +return 0;
> > > +filter = ost->filter->filter;
> > > +
> > > +if (!ost->initialized) {
> > > +char error[1024] = "";
> > > +ret = init_output_stream(ost, error, sizeof(error));
> > > +if (ret < 0) {
> > > +av_log(NULL, AV_LOG_ERROR, "Error initializing output
> > > + stream %d:%d
> > > -- %s\n",
> > > +   ost->file_index, ost->index, error);
> > > +exit_program(1);
> >
> > imo, it's not good to exit the program.
> Any reason? These lines are similar as them in reap_filters(). Line 1445.

I'm just wondering, in general, how the program could exit in the middle. And 
the function does have a return value for error code. 

> 
> > > +}
> > > +}
> > > +
> > > +if (!ost->filtered_frame && !(ost->filtered_frame = 
> > > av_frame_alloc()))
> > > +return AVERROR(ENOMEM);
> > > +filtered_frame = ost->filtered_frame;
> > > +
> > > +while (1) {
> > > +double float_pts = AV_NOPTS_VALUE; // this is identical to
> > > filtered_frame.pts but with higher precision
> > > +ret = av_buffersink_get_frame_flags(filter, filtered_frame,
> > > +
> > AV_BUFFERSINK_FLAG_NO_REQUEST);
> > > +if (ret < 0) {
> > > +if (ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
> > > +av_log(NULL, AV_LOG_WARNING,
> > > +   "Error in av_buffersink_get_frame_flags():
> > > + %s\n",
> > > av_err2str(ret));
> > > +} else if (flush && ret == AVERROR_EOF) {
> > > +if (av_buffersink_get_type(filter) ==
> > AVMEDIA_TYPE_VIDEO)
> > > +do_video_out(of, ost, NULL, AV_NOPTS_VALUE);
> > > +}
> > > +break;
> > > +}
> > > +if (ost->finished) {
> > > +av_frame_unref(filtered_frame);
> > > +continue;
> > > +}
> > > +if (filtered_frame->pts != AV_NOPTS_VALUE) {
> > > +int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ?
> > > + 0 : of-
> > > >start_time;
> > > +AVRational filter_tb = av_buffersink_get_time_base(filter);
> > > +AVRational tb = enc->time_base;
> > > +int extra_bits = av_clip(29 - av_log2(tb.den), 0, 16);
> > > +
> > > +tb.den <<= extra_bits;
> > > +float_pts =
> > > +av_rescale_q(filtered_frame->pts, filter_tb, tb) -
> > > +av_rescale_q(start_time, AV_TIME_BASE_Q, tb);
> > > +float_pts /= 1 << extra_bits;
> > > +// avoid exact midoints to reduce the chance of
> > > + rounding differences,
> > > this can be removed in case the fps code is changed to work with
> > > integers
> > > +float_pts += FFSIGN(float_pts) * 1.0 / (1<<17);
> > > +
> > > +filtered_frame->pts =
> > > +av_rescale_q(filtered_frame->pts, filter_tb,
> > enc->time_base) -
> > > +av_rescale_q(start_time, AV_TIME_BASE_Q,
> > enc->time_base);
> > > +}
> > > +
> > > +switch (av_buffersink_get_type(filter)) {
> > > +case AVMEDIA_TYPE_VIDEO:
> > > +if (!ost->frame_aspect_ratio.num)
> > > +enc->sample_aspect_ratio =
> > > + filtered_frame->sample_aspect_ratio;
> > > +
> > > +if (debug_ts) {
> > > +av_log(NULL, AV_LOG_INFO, "filter -> pts:%s
> > > + pts_time:%s exact:%f
> > > time_base:%d/%d\n",
> > > +av_ts2str(filtered_frame->pts),
> > > + av_ts2timestr(filtered_frame-
> > > >pts, &enc->time_base),
> > > +float_pts,
> > > +enc->time_base.num, enc->ti