Re: [FFmpeg-devel] [PATCH, v4] lavc/qsvdec: Add GPU-accelerated memory copy support

2019-10-08 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Linjie Fu
> Sent: Tuesday, October 8, 2019 9:41 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: ChaoX A Liu ; Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v4] lavc/qsvdec: Add GPU-accelerated memory
> copy support
> 
> GPU copy enables or disables GPU accelerated copying between video and
> system memory. This may lead to a notable performance improvement.
> Memory must be sequent and aligned with 128x64.
> 
> CMD:
> ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv
> -gpu_copy on -i input.h264 -f null -
> or:
> ffmpeg -c:v h264_qsv -gpu_copy on -i input.h264 -f null -
> 
> Signed-off-by: Linjie Fu 
> Signed-off-by: ChaoX A Liu 
> ---
> [v4]: add an assert check.

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

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

Re: [FFmpeg-devel] [PATCH] lavc/qsv: remove vaapi device free function

2019-10-08 Thread Li, Zhong
> From: Fu, Linjie 
> Sent: Wednesday, October 9, 2019 10:49 AM
> To: FFmpeg development discussions and patches 
> Cc: Li, Zhong 
> Subject: RE: [FFmpeg-devel] [PATCH] lavc/qsv: remove vaapi device free 
> function
> 
> > -Original Message-
> > From: ffmpeg-devel  On Behalf Of
> > Zhong Li
> > Sent: Tuesday, October 8, 2019 12:55
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Li, Zhong 
> > Subject: [FFmpeg-devel] [PATCH] lavc/qsv: remove vaapi device free
> > function
> >
> > It is not needed since av_buffer_unref() will call it internally
> >
> > Signed-off-by: Zhong Li 
> > ---
> >  libavcodec/qsv.c | 4 
> >  1 file changed, 4 deletions(-)
> >
> > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index
> > a43f0d5..81fa4a8 100644
> > --- a/libavcodec/qsv.c
> > +++ b/libavcodec/qsv.c
> > @@ -835,10 +835,6 @@ int ff_qsv_close_internal_session(QSVSession *qs)
> >  qs->session = NULL;
> >  }
> >  #ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
> > -if (qs->va_device_ctx) {
> > -qs->va_device_ctx->free(qs->va_device_ctx);
> > -}
> > -
> >  av_buffer_unref(>va_device_ref);
> >  #endif
> >  return 0;
> > --
> > 2.7.4
> 
> LGTM.
> Also addressed some unexpected crashes when "vframes" is set.

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

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

Re: [FFmpeg-devel] [PATCH v2 12/14] avfilter/vf_scale_qsv: add logging context to log

2019-10-08 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Steven
> Liu
> Sent: Wednesday, October 2, 2019 2:58 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Steven Liu 
> Subject: [FFmpeg-devel] [PATCH v2 12/14] avfilter/vf_scale_qsv: add logging
> context to log
> 
> Signed-off-by: Steven Liu 
> ---
>  libavfilter/vf_scale_qsv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index
> 3cc05b64f3..1cf5367969 100644
> --- a/libavfilter/vf_scale_qsv.c
> +++ b/libavfilter/vf_scale_qsv.c
> @@ -541,7 +541,7 @@ static int qsvscale_config_props(AVFilterLink *outlink)
>  return 0;
> 
>  fail:
> -av_log(NULL, AV_LOG_ERROR,
> +av_log(ctx, AV_LOG_ERROR,
> "Error when evaluating the expression '%s'\n", expr);
>  return ret;
>  }
> --
> 2.15.1

LGTM

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

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

Re: [FFmpeg-devel] [PATCH, v3] lavc/qsvdec: Add GPU-accelerated memory copy support

2019-09-29 Thread Li, Zhong
> +static int ff_qsv_get_continuous_buffer(AVCodecContext *avctx, AVFrame
> +*frame, AVBufferPool *pool) {
> +int ret = 0;
> +
> +ff_decode_frame_props(avctx, frame);
> +
> +frame->width   = avctx->width;
> +frame->height  = avctx->height;
> +frame->linesize[0] = FFALIGN(avctx->width, 128);
> +frame->linesize[1] = frame->linesize[0];
> +frame->buf[0]  = av_buffer_pool_get(pool);
> +if (!frame->buf[0])
> +return AVERROR(ENOMEM);
> +
> +frame->data[0] = frame->buf[0]->data;
> +frame->data[1] = frame->data[0] +
> +frame->linesize[0] * FFALIGN(avctx->height,
> + 64);

It is assumed there are only two planes , but this is not correct for some 
formats, such as RGB32.
Probably ok since currently all decoder output is NV12/P010, but would be 
better add an assert check,
since it is possible for decoder to output some other formats (e.g:  it is plan 
to add RGB format for JPEG decoding output).

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

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

Re: [FFmpeg-devel] [PATCH, v2] lavc/qsvdec: Add GPU-accelerated memory copy support

2019-09-29 Thread Li, Zhong
> > > +static int ff_qsv_get_continuous_buffer(AVCodecContext *avctx,
> > AVFrame
> > > +*frame, AVBufferPool *pool) {
> > > +int ret = 0;
> > > +
> > > +ff_decode_frame_props(avctx, frame);
> > > +
> > > +frame->width   = avctx->width;
> > > +frame->height  = avctx->height;
> > > +frame->linesize[0] = FFALIGN(avctx->width, 128);
> > > +frame->linesize[1] = frame->linesize[0];
> > > +frame->buf[0]  = av_buffer_pool_get(pool);
> > > +if (!frame->buf[0])
> > > +return AVERROR(ENOMEM);
> > > +
> > > +frame->data[0] = frame->buf[0]->data;
> > > +frame->data[1] = frame->data[0] +
> > > +frame->linesize[0] *
> > > + FFALIGN(avctx->height, 64);
> > > +
> > > +ret = ff_attach_decode_data(frame);
> >
> > Could you please explain why need this function? I don't see
> > private_ref is needed from qsv decoding.
> 
> private_ref is required if a decoder declares the capability of
> AV_CODEC_CAP_DR1.
> https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/decode.c#L654
> 
> - Linjie

Ok, to keep consistency it is ok though get_buffer() is not called in the path 
of ff_qsv_get_continuous_buffer ().
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v2] lavc/qsvdec: Add GPU-accelerated memory copy support

2019-09-28 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Linjie Fu
> Sent: Friday, September 27, 2019 1:47 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: ChaoX A Liu ; Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v2] lavc/qsvdec: Add GPU-accelerated memory
> copy support
> 
> GPU copy enables or disables GPU accelerated copying between video and
> system memory. This may lead to a notable performance improvement.
> Memory must be sequent and aligned with 128x64.
> (first introduced in FFmpeg 3.3.1)

This line should be removed. FFmpeg 3.3.1 mainline never support GPU copy.

> 
> CMD:
> ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv
> -gpu_copy on -i input.h264 -f null -
> or:
> ffmpeg -c:v h264_qsv -gpu_copy on -i input.h264 -f null -
> 
> Signed-off-by: Linjie Fu 
> Signed-off-by: ChaoX A Liu 
> ---
> Rebased and send again.
> 
>  libavcodec/qsv.c  | 31 +---
>  libavcodec/qsv_internal.h |  7 +++---
>  libavcodec/qsvdec.c   | 50 ++-
>  libavcodec/qsvdec.h   |  2 ++
>  libavcodec/qsvdec_h2645.c | 10   libavcodec/qsvdec_other.c |  5 
>  libavcodec/qsvenc.c   |  8 ---
>  7 files changed, 92 insertions(+), 21 deletions(-)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 994c9ebcb0..9e66fbc9da
> 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -412,15 +412,19 @@ static int ff_qsv_set_display_handle(AVCodecContext
> *avctx, QSVSession *qs)  #endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
> 
>  int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
> - const char *load_plugins)
> + const char *load_plugins, int
> + gpu_copy)
>  {
> -mfxIMPL impl   = MFX_IMPL_AUTO_ANY;
> -mfxVersion ver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } };
> +mfxIMPL  impl = MFX_IMPL_AUTO_ANY;
> +mfxVersionver = { { QSV_VERSION_MINOR, QSV_VERSION_MAJOR } };
> +mfxInitParam init_par = { MFX_IMPL_AUTO_ANY };
> 
>  const char *desc;
>  int ret;
> 
> -ret = MFXInit(impl, , >session);
> +init_par.GPUCopy= gpu_copy;

GPUCopy field is introduced from API 1.16, would better to check it to avoid 
compile issue with old API.  

> +init_par.Implementation = impl;
> +init_par.Version= ver;
> +ret = MFXInitEx(init_par, >session);
>  if (ret < 0)
>  return ff_qsv_print_error(avctx, ret,
>"Error initializing an internal MFX 
> session"); @@ -712,7
> +716,8 @@ static mfxStatus qsv_frame_get_hdl(mfxHDL pthis, mfxMemId mid,
> mfxHDL *hdl)  }
> 
>  int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession *psession,
> -   AVBufferRef *device_ref, const char 
> *load_plugins)
> +   AVBufferRef *device_ref, const char 
> *load_plugins,
> +   int gpu_copy)
>  {
>  static const mfxHandleType handle_types[] = {
>  MFX_HANDLE_VA_DISPLAY,
> @@ -722,11 +727,12 @@ int ff_qsv_init_session_device(AVCodecContext
> *avctx, mfxSession *psession,
>  AVHWDeviceContext*device_ctx = (AVHWDeviceContext*)device_ref-
> >data;
>  AVQSVDeviceContext *device_hwctx = device_ctx->hwctx;
>  mfxSessionparent_session = device_hwctx->session;
> +mfxInitParaminit_par = { MFX_IMPL_AUTO_ANY };
> +mfxHDLhandle = NULL;
> 
>  mfxSessionsession;
>  mfxVersionver;
>  mfxIMPL   impl;
> -mfxHDLhandle = NULL;
>  mfxHandleType handle_type;
>  mfxStatus err;
> 
> @@ -752,7 +758,10 @@ int ff_qsv_init_session_device(AVCodecContext *avctx,
> mfxSession *psession,
> "from the session\n");
>  }
> 
> -err = MFXInit(impl, , );
> +init_par.GPUCopy= gpu_copy;
> +init_par.Implementation = impl;
> +init_par.Version= ver;
> +err = MFXInitEx(init_par, );
>  if (err != MFX_ERR_NONE)
>  return ff_qsv_print_error(avctx, err,
>"Error initializing a child MFX session"); 
> @@ -783,7 +792,7
> @@ int ff_qsv_init_session_device(AVCodecContext *avctx, mfxSession
> *psession,
> 
>  int ff_qsv_init_session_frames(AVCodecContext *avctx, mfxSession *psession,
> QSVFramesContext *qsv_frames_ctx,
> -   const char *load_plugins, int opaque)
> +   const char *load_plugins, int opaque,
> + int gpu_copy)
>  {
>  mfxFrameAllocator frame_allocator = {
>  .pthis  = qsv_frames_ctx,
> @@ -802,8 +811,12 @@ int ff_qsv_init_session_frames(AVCodecContext *avctx,
> mfxSession *psession,
> 
>  int ret;
> 
> +if (gpu_copy == MFX_GPUCOPY_ON)
> +av_log(avctx, AV_LOG_WARNING, "GPU-accelerated memory copy "
> +"only works in
> + 

Re: [FFmpeg-devel] [PATCH V2 1/3] checkasm/vf_eq: add test for vf_eq

2019-09-24 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Ting Fu
> Sent: Wednesday, September 18, 2019 3:06 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH V2 1/3] checkasm/vf_eq: add test for vf_eq
> 
> Signed-off-by: Ting Fu 
> ---
>  libavfilter/vf_eq.c   | 13 ---
>  libavfilter/vf_eq.h   |  1 +
>  tests/checkasm/Makefile   |  1 +
>  tests/checkasm/checkasm.c |  3 ++
>  tests/checkasm/checkasm.h |  1 +
>  tests/checkasm/vf_eq.c| 79 +++
>  tests/fate/checkasm.mak   |  1 +
>  7 files changed, 94 insertions(+), 5 deletions(-)  create mode 100644
> tests/checkasm/vf_eq.c
> 
> diff --git a/libavfilter/vf_eq.c b/libavfilter/vf_eq.c index 
> 2c4c7e4d54..0f9d129255
> 100644
> --- a/libavfilter/vf_eq.c
> +++ b/libavfilter/vf_eq.c
> @@ -174,12 +174,18 @@ static int set_expr(AVExpr **pexpr, const char *expr,
> const char *option, void *
>  return 0;
>  }
> 
> +void ff_eq_init(EQContext *eq)
> +{
> +eq->process = process_c;
> +if (ARCH_X86)
> +ff_eq_init_x86(eq);
> +}
> +
>  static int initialize(AVFilterContext *ctx)  {
>  EQContext *eq = ctx->priv;
>  int ret;
> -
> -eq->process = process_c;
> +ff_eq_init(eq);
> 
>  if ((ret = set_expr(>contrast_pexpr, eq->contrast_expr, 
> "contrast",
> ctx)) < 0 ||
>  (ret = set_expr(>brightness_pexpr,   eq->brightness_expr,   
> "brightness",
> ctx)) < 0 ||
> @@ -191,9 +197,6 @@ static int initialize(AVFilterContext *ctx)
>  (ret = set_expr(>gamma_weight_pexpr, eq->gamma_weight_expr,
> "gamma_weight", ctx)) < 0 )
>  return ret;
> 
> -if (ARCH_X86)
> -ff_eq_init_x86(eq);
> -
>  if (eq->eval_mode == EVAL_MODE_INIT) {
>  set_gamma(eq);
>  set_contrast(eq);
> diff --git a/libavfilter/vf_eq.h b/libavfilter/vf_eq.h index 
> fa49d46e5c..cd0cd75f08
> 100644
> --- a/libavfilter/vf_eq.h
> +++ b/libavfilter/vf_eq.h
> @@ -100,6 +100,7 @@ typedef struct EQContext {
>  enum EvalMode { EVAL_MODE_INIT, EVAL_MODE_FRAME, EVAL_MODE_NB }
> eval_mode;  } EQContext;
> 
> +void ff_eq_init(EQContext *eq);
>  void ff_eq_init_x86(EQContext *eq);
> 
>  #endif /* AVFILTER_EQ_H */
> diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index
> 0112ff603e..de850c016e 100644
> --- a/tests/checkasm/Makefile
> +++ b/tests/checkasm/Makefile
> @@ -36,6 +36,7 @@ CHECKASMOBJS-$(CONFIG_AVCODEC)  +=
> $(AVCODECOBJS-yes)
>  AVFILTEROBJS-$(CONFIG_AFIR_FILTER) += af_afir.o
>  AVFILTEROBJS-$(CONFIG_BLEND_FILTER) += vf_blend.o
>  AVFILTEROBJS-$(CONFIG_COLORSPACE_FILTER) += vf_colorspace.o
> +AVFILTEROBJS-$(CONFIG_EQ_FILTER) += vf_eq.o
>  AVFILTEROBJS-$(CONFIG_GBLUR_FILTER)  += vf_gblur.o
>  AVFILTEROBJS-$(CONFIG_HFLIP_FILTER)  += vf_hflip.o
>  AVFILTEROBJS-$(CONFIG_THRESHOLD_FILTER)  += vf_threshold.o diff --git
> a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index
> d9a5c7f401..bcbe775510 100644
> --- a/tests/checkasm/checkasm.c
> +++ b/tests/checkasm/checkasm.c
> @@ -165,6 +165,9 @@ static const struct {
>  #if CONFIG_COLORSPACE_FILTER
>  { "vf_colorspace", checkasm_check_colorspace },
>  #endif
> +#if CONFIG_EQ_FILTER
> +{ "vf_eq", checkasm_check_vf_eq },
> +#endif
>  #if CONFIG_GBLUR_FILTER
>  { "vf_gblur", checkasm_check_vf_gblur },
>  #endif
> diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index
> fdf9eeb75d..0a7f9f25c4 100644
> --- a/tests/checkasm/checkasm.h
> +++ b/tests/checkasm/checkasm.h
> @@ -72,6 +72,7 @@ void checkasm_check_sw_rgb(void);  void
> checkasm_check_utvideodsp(void);  void checkasm_check_v210dec(void);  void
> checkasm_check_v210enc(void);
> +void checkasm_check_vf_eq(void);
>  void checkasm_check_vf_gblur(void);
>  void checkasm_check_vf_hflip(void);
>  void checkasm_check_vf_threshold(void);
> diff --git a/tests/checkasm/vf_eq.c b/tests/checkasm/vf_eq.c new file mode
> 100644 index 00..684718f2cd
> --- /dev/null
> +++ b/tests/checkasm/vf_eq.c
> @@ -0,0 +1,79 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 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 General Public License for more details.
> + *
> + * You should have received a copy of the GNU 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 "checkasm.h"
> +#include "libavfilter/avfilter.h"
> +#include "libavfilter/vf_eq.h"
> +#include "libavutil/intreadwrite.h"
> +
> +#define WIDTH 256
> 

Re: [FFmpeg-devel] avcodec/qsv: polling free synchronization

2019-09-23 Thread Li, Zhong
> -Original Message-
> From: ffmpeg-devel  On Behalf Of Orlov,
> Andrey
> Sent: Monday, September 23, 2019 11:20 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] avcodec/qsv: polling free synchronization
> 
> Hi all,
> 
> Please review the change, that fixes high CPU usage on AVC decode (18% -> 9%):
> https://github.com/andreyor/FFmpeg/commit/21014bcfa3cfa56b993d56c56971
> 67b889228f08
> 
> Thanks,
> Orlov, Andrey

Need to add detail explain why it work. 
It is only benefit to AVC decoder? I see you also changed AVC encoder code.
And how about other codec? Such as HEVC. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 2/3] lavc/qsv: Fix MSDK initialization failure in system memory mode

2019-09-22 Thread Li, Zhong
> From: Li, Zhong 
> Sent: Friday, September 20, 2019 4:45 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Li, Zhong 
> Subject: [PATCH 2/3] lavc/qsv: Fix MSDK initialization failure in system 
> memory
> mode
> 
> MSDK does not create internal acceleration device on Linux, So
> MFXVideoCORE_SetHandle() is necessary.
> It has been added for ff_qsv_init_session_device().
> But missed for ff_qsv_init_internal_session() due to commit
> 1f26a23 overwrited commit db89f45
> 
> Fix #7030
> 
> Signed-off-by: Zhong Li 
> ---
>  libavcodec/qsv.c  | 62 ---
>  libavcodec/qsv_internal.h | 28 +-
>  libavcodec/qsvdec.c   | 29 +-
>  libavcodec/qsvdec.h   |  2 +-
>  libavcodec/qsvenc.c   | 17 +--
>  libavcodec/qsvenc.h   |  2 +-
>  6 files changed, 109 insertions(+), 31 deletions(-)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 65ad070e1f..87ff694030
> 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -348,7 +348,41 @@ load_plugin_fail:
> 
>  }
> 
> -int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
> +//This code is only required for Linux since a display handle is required.
> +//For Windows the session is complete and ready to use.
> +
> +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE static int
> +ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) {
> +AVDictionary *child_device_opts = NULL;
> +AVVAAPIDeviceContext *hwctx;
> +int ret;
> +
> +av_dict_set(_device_opts, "kernel_driver", "i915", 0);
> +av_dict_set(_device_opts, "driver","iHD",  0);
> +
> +ret = av_hwdevice_ctx_create(>va_device_ref,
> AV_HWDEVICE_TYPE_VAAPI, NULL, child_device_opts, 0);
> +if (ret < 0) {
> + av_log(avctx, AV_LOG_ERROR, "Failed to create a VAAPI device.\n");
> +return ret;
> +} else {
> +qs->va_device_ctx = (AVHWDeviceContext*)qs->va_device_ref->data;
> +hwctx = qs->va_device_ctx->hwctx;
> +
> + ret = MFXVideoCORE_SetHandle(qs->session,
> + (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)hwctx-
> >display);
> + if (ret < 0) {
> + return ff_qsv_print_error(avctx, ret, "Error during set display
> handle\n");
> + }
> +}
> +
> +av_dict_free(_device_opts);
> +
> +return 0;
> +}
> +#endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
> +
> +int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
>   const char *load_plugins)  {
>  mfxIMPL impl   = MFX_IMPL_AUTO_ANY;
> @@ -357,18 +391,24 @@ int ff_qsv_init_internal_session(AVCodecContext
> *avctx, mfxSession *session,
>  const char *desc;
>  int ret;
> 
> -ret = MFXInit(impl, , session);
> +ret = MFXInit(impl, , >session);
>  if (ret < 0)
>  return ff_qsv_print_error(avctx, ret,
>"Error initializing an internal MFX 
> session");
> 
> -ret = qsv_load_plugins(*session, load_plugins, avctx);
> +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
> +ret = ff_qsv_set_display_handle(avctx, qs);
> +if (ret < 0)
> +return ret;
> +#endif
> +
> +ret = qsv_load_plugins(qs->session, load_plugins, avctx);
>  if (ret < 0) {
>  av_log(avctx, AV_LOG_ERROR, "Error loading plugins\n");
>  return ret;
>  }
> 
> -MFXQueryIMPL(*session, );
> +MFXQueryIMPL(qs->session, );
> 
>  switch (MFX_IMPL_BASETYPE(impl)) {
>  case MFX_IMPL_SOFTWARE:
> @@ -758,3 +798,17 @@ int ff_qsv_init_session_frames(AVCodecContext *avctx,
> mfxSession *psession,
>  *psession = session;
>  return 0;
>  }
> +
> +int ff_qsv_close_internal_session(QSVSession *qs) {
> +if (qs->session) {
> +MFXClose(qs->session);
> +qs->session = NULL;
> +}
> +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
> +if (qs->va_device_ctx) {
> +qs->va_device_ctx->free(qs->va_device_ctx);
> +}
> +#endif
> +return 0;
> +}
> diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index
> c50e9c792c..62885134b1 100644
> --- a/libavcodec/qsv_internal.h
> +++ b/libavcodec/qsv_internal.h
> @@ -21,6 +21,22 @@
>  #ifndef AVCODEC_QSV_INTERNAL_H
>  #define AVCODEC_QSV_INTERNAL_H
> 
> +#if CONFIG_VAAPI
> +#define AVCODEC_QSV_LINUX_SESSION_HANDLE #endif //CONFIG_VAAPI
> +
> +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE #include  #include
> + #if HAVE_UNISTD_H #include  #endif #incl

Re: [FFmpeg-devel] [PATCH V2] lavu/qsv: remove the redundant libmfx init code

2019-09-13 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Mark
> Thompson
> Sent: Wednesday, September 11, 2019 6:34 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH V2] lavu/qsv: remove the redundant libmfx
> init code
> 
> On 05/09/2019 06:24, Zhong Li wrote:
> > Signed-off-by: Zhong Li 
> > ---
> >  libavutil/hwcontext_qsv.c | 24 ++--
> >  1 file changed, 2 insertions(+), 22 deletions(-)
> >
> > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> > index 0329a81..1c0e4ff 100644
> > --- a/libavutil/hwcontext_qsv.c
> > +++ b/libavutil/hwcontext_qsv.c
> > @@ -1145,27 +1145,6 @@ static int
> > qsv_device_derive_from_child(AVHWDeviceContext *ctx,
> >
> >  err = MFXInit(implementation, , >session);
> >  if (err != MFX_ERR_NONE) {
> > -av_log(ctx, AV_LOG_ERROR, "Error initializing an MFX session: "
> > -   "%d.\n", err);
> > -ret = AVERROR_UNKNOWN;
> > -goto fail;
> > -}
> > -
> > -err = MFXQueryVersion(hwctx->session, );
> > -if (err != MFX_ERR_NONE) {
> > -av_log(ctx, AV_LOG_ERROR, "Error querying an MFX session: %d.\n", 
> > err);
> > -ret = AVERROR_UNKNOWN;
> > -goto fail;
> > -}
> > -
> > -av_log(ctx, AV_LOG_VERBOSE,
> > -   "Initialize MFX session: API version is %d.%d, implementation 
> > version
> is %d.%d\n",
> > -   MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor);
> > -
> > -MFXClose(hwctx->session);
> > -
> > -err = MFXInit(implementation, , >session);
> > -if (err != MFX_ERR_NONE) {
> >  av_log(ctx, AV_LOG_ERROR,
> > "Error initializing an MFX session: %d.\n", err);
> >  ret = AVERROR_UNKNOWN;
> > @@ -1182,7 +1161,8 @@ static int
> > qsv_device_derive_from_child(AVHWDeviceContext *ctx,
> >
> >  ret = MFXQueryVersion(hwctx->session,);
> >  if (ret == MFX_ERR_NONE) {
> > -av_log(ctx, AV_LOG_VERBOSE, "MFX compile/runtime
> API: %d.%d/%d.%d\n",
> > +av_log(ctx, AV_LOG_VERBOSE,
> > +   "Initialize MFX session: API version is %d.%d,
> > + implementation version is %d.%d\n",
> > MFX_VERSION_MAJOR, MFX_VERSION_MINOR, ver.Major, ver.Minor);
> >  }
> >  return 0;
> >
> 
> Can you add some more explanation?  The extra session checking the version is
> not obviously redundant, and the commit log does indicate that the setup was
> deliberate:
> 
> commit ccbb31c14b766ef666ef2daa8c467e478183a957
> Author: Luca Barbato 
> Date:   Mon Sep 25 09:57:30 2017 +
> 
> qsv: Make sure the session is set with the latest version
> 
> It is needed to have the calls to MFXJoinSession succeed.
> 
> 
> - Mark

Thanks to point out this. 
So probably just need to remove the redundant MFXQueryVersion()? 
Will update the patch.

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

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

Re: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if vaMapBuffer returns multiple buffers

2019-09-12 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Linjie Fu
> Sent: Friday, May 31, 2019 8:35 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v2] lavc/vaapi_encode: grow packet if
> vaMapBuffer returns multiple buffers
> 
> It seems that VA_CODED_BUF_STATUS_SINGLE_NALU allows driver to map
> buffer for each slice.
> 
> Currently, assigning new buffer for pkt when multiple buffer returns from
> vaMapBuffer will cover the previous encoded pkt data and lead to encode 
> issues.
> 
> Iterate through the buf_list first to find out the total buffer size needed 
> for the
> pkt, allocate the whole pkt to avoid repeated reallocation and memcpy, then 
> copy
> data from each buf to pkt.
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: allocate the whole pkt to avoid repeated reallocation and memcpy
> 
>  libavcodec/vaapi_encode.c | 18 +-
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index
> 2dda451..9c9e5dd 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -489,6 +489,8 @@ static int vaapi_encode_output(AVCodecContext *avctx,
>  VAAPIEncodeContext *ctx = avctx->priv_data;
>  VACodedBufferSegment *buf_list, *buf;
>  VAStatus vas;
> +int total_size = 0;
> +uint8_t *ptr;
>  int err;
> 
>  err = vaapi_encode_wait(avctx, pic); @@ -505,15 +507,21 @@ static int
> vaapi_encode_output(AVCodecContext *avctx,
>  goto fail;
>  }
> 
> +for (buf = buf_list; buf; buf = buf->next)
> +total_size += buf->size;
> +
> +err = av_new_packet(pkt, total_size);
> +ptr = pkt->data;
> +
> +if (err < 0)
> +goto fail_mapped;
> +
>  for (buf = buf_list; buf; buf = buf->next) {
>  av_log(avctx, AV_LOG_DEBUG, "Output buffer: %u bytes "
> "(status %08x).\n", buf->size, buf->status);
> 
> -err = av_new_packet(pkt, buf->size);
> -if (err < 0)
> -goto fail_mapped;
> -
> -memcpy(pkt->data, buf->buf, buf->size);
> +memcpy(ptr, buf->buf, buf->size);
> +ptr += buf->size;
>  }
> 
>  if (pic->type == PICTURE_TYPE_IDR)
> --
> 2.7.4

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

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

Re: [FFmpeg-devel] [PATCH] qsv: get FrameInfo.Shift by desc->comp[0].shift

2019-09-12 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Linjie Fu
> Sent: Wednesday, September 11, 2019 12:09 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] qsv: get FrameInfo.Shift by 
> desc->comp[0].shift
> 
> Since Y410 is a pixel format with depth > 8 but shift = 0, get Shift info by 
> depth is
> not quite accurate.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/qsvenc.c   | 4 ++--
>  libavutil/hwcontext_qsv.c | 2 +-
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 9bf8574..912f2a8
> 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -437,7 +437,7 @@ static int init_video_param_jpeg(AVCodecContext
> *avctx, QSVEncContext *q)
>  q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
>  q->param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
>  q->param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
> -q->param.mfx.FrameInfo.Shift  = desc->comp[0].depth > 8;
> +q->param.mfx.FrameInfo.Shift  = desc->comp[0].shift > 0;

Is it safe enough? 
As MSDK docs: "Not all codecs and SDK implementations support this value. Use 
Query function to check if this feature is supported."
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: update crop width/height when mapping frames

2019-09-12 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Rodger
> Combs
> Sent: Thursday, September 12, 2019 11:59 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: update crop width/height
> when mapping frames
> 
> This fixes an issue where the context could be configured with one 
> resolution, but
> incoming frames could have another, and our output AVFrames wouldn't match
> the underlying surfaces' resolution, which is usually the value that MFX code 
> uses.
> 
> In particular, this would happen when mapping from DXVA2 decoders, since
> DXVA2 aligns the width/height fields in its context to the required alignment 
> for
> the particular codec being used, and those values are then propagated into the
> QSV context, rather than the crop dimensions.
> ---
>  libavutil/hwcontext_qsv.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> 8f9838d7d8..fe5a705c19 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -1031,8 +1031,8 @@ static int qsv_map_to(AVHWFramesContext *dst_ctx,
>  if (err)
>  return err;
> 
> -dst->width   = src->width;
> -dst->height  = src->height;
> +hwctx->surfaces[i].Info.CropW = dst->width  = src->width;
> +hwctx->surfaces[i].Info.CropH = dst->height = src->height;
>  dst->data[3] = (uint8_t*)>surfaces[i];
> 
>  return 0;
> --
> 2.21.0

Patch looks good. 
Could you please share detailed command line and clip to reproduce the issue?

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

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

Re: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK initialization failure in system memory mode

2019-09-10 Thread Li, Zhong
> From: Li, Zhong
> Sent: Wednesday, September 4, 2019 11:41 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Li, Zhong 
> Subject: [PATCH 1/2] lavc/qsv: Fix MSDK initialization failure in system 
> memory
> mode
> 
> MSDK does not create internal acceleration device on Linux, So
> MFXVideoCORE_SetHandle() is necessary.
> It has been added for ff_qsv_init_session_device().
> But missed for ff_qsv_init_internal_session() due to commit
> 1f26a23 overwrited commit db89f45
> 
> Fix #7030
> 
> Signed-off-by: Zhong Li 
> ---
>  libavcodec/qsv.c  | 105
> --
>  libavcodec/qsv_internal.h |  27 +++-
>  libavcodec/qsvdec.c   |  29 +++--
>  libavcodec/qsvdec.h   |   2 +-
>  libavcodec/qsvenc.c   |  17 
>  libavcodec/qsvenc.h   |   2 +-
>  6 files changed, 151 insertions(+), 31 deletions(-)
> 
> diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 65ad070..126182b 100644
> --- a/libavcodec/qsv.c
> +++ b/libavcodec/qsv.c
> @@ -348,7 +348,79 @@ load_plugin_fail:
> 
>  }
> 
> -int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
> +//This code is only required for Linux since a display handle is required.
> +//For Windows the session is complete and ready to use.
> +//For releases of Media Server Studio >= 2015 R4 the //render nodes
> +interface is preferred (/dev/dri/renderD).
> +//Using Media Server Studio 2015 R4 or newer is recommended //but the
> +older /dev/dri/card interface is also searched for broader compatibility.
> +
> +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE static int
> +ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession *qs) {
> +// VAAPI display handle
> +int ret = 0;
> +VADisplay va_dpy = NULL;
> +VAStatus va_res = VA_STATUS_SUCCESS;
> +int major_version = 0, minor_version = 0;
> +int fd = -1;
> +char adapterpath[256];
> +int adapter_num;
> +
> +qs->fd_display = -1;
> +qs->va_display = NULL;
> +
> +//search for valid graphics device
> +for (adapter_num = 0;adapter_num < 6;adapter_num++) {
> +
> +if (adapter_num<3) {
> +snprintf(adapterpath,sizeof(adapterpath),
> +"/dev/dri/renderD%d", adapter_num+128);
> +} else {
> +snprintf(adapterpath,sizeof(adapterpath),
> +"/dev/dri/card%d", adapter_num-3);
> +}
> +
> +fd = open(adapterpath, O_RDWR);
> +if (fd < 0) {
> +av_log(avctx, AV_LOG_ERROR,
> +"mfx init: %s fd open failed\n", adapterpath);
> +continue;
> +}
> +
> +va_dpy = vaGetDisplayDRM(fd);
> +if (!va_dpy) {
> +av_log(avctx, AV_LOG_ERROR,
> +"mfx init: %s vaGetDisplayDRM failed\n", adapterpath);
> +close(fd);
> +continue;
> +}
> +
> +va_res = vaInitialize(va_dpy, _version, _version);
> +if (VA_STATUS_SUCCESS != va_res) {
> +av_log(avctx, AV_LOG_ERROR,
> +"mfx init: %s vaInitialize failed\n", adapterpath);
> +close(fd);
> +fd = -1;
> +continue;
> +} else {
> +av_log(avctx, AV_LOG_VERBOSE,
> +"mfx initialization: %s vaInitialize successful\n",adapterpath);
> +qs->fd_display = fd;
> +qs->va_display = va_dpy;
> +ret = MFXVideoCORE_SetHandle(qs->session,
> +  (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)va_dpy);
> +if (ret < 0) {
> +return ff_qsv_print_error(avctx, ret, "Error %d during set 
> display
> handle\n");
> +}
> +break;
> +}
> +}
> +return 0;
> +}
> +#endif //AVCODEC_QSV_LINUX_SESSION_HANDLE
> +
> +int ff_qsv_init_internal_session(AVCodecContext *avctx, QSVSession *qs,
>   const char *load_plugins)  {
>  mfxIMPL impl   = MFX_IMPL_AUTO_ANY;
> @@ -357,18 +429,24 @@ int ff_qsv_init_internal_session(AVCodecContext
> *avctx, mfxSession *session,
>  const char *desc;
>  int ret;
> 
> -ret = MFXInit(impl, , session);
> +ret = MFXInit(impl, , >session);
>  if (ret < 0)
>  return ff_qsv_print_error(avctx, ret,
>"Error initializing an internal MFX 
> session");
> 
> -ret = qsv_load_plugins(*session, load_plugins, avctx);
> +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE
> +ret = ff_qsv_set_display_handle(avctx, q

Re: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK initialization failure in system memory mode

2019-09-04 Thread Li, Zhong
> From: Fu, Linjie
> Sent: Thursday, September 5, 2019 12:07 PM
> To: Li, Zhong ; FFmpeg development discussions and patches
> 
> Subject: RE: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK initialization 
> failure
> in system memory mode
> 
> > -Original Message-
> > From: Li, Zhong
> > Sent: Thursday, September 5, 2019 11:14
> > To: Fu, Linjie ; FFmpeg development discussions
> > and patches 
> > Subject: RE: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK
> > initialization failure in system memory mode
> >
> > > From: Fu, Linjie
> > > Sent: Thursday, September 5, 2019 10:54 AM
> > > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > > Cc: Li, Zhong 
> > > Subject: RE: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK
> > > initialization
> > failure
> > > in system memory mode
> > >
> > > > -Original Message-
> > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > > > Of Zhong Li
> > > > Sent: Wednesday, September 4, 2019 23:41
> > > > To: ffmpeg-devel@ffmpeg.org
> > > > Cc: Li, Zhong 
> > > > Subject: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK
> > > > initialization failure in system memory mode
> > > >
> > > > MSDK does not create internal acceleration device on Linux, So
> > > > MFXVideoCORE_SetHandle() is necessary.
> > > > It has been added for ff_qsv_init_session_device().
> > > > But missed for ff_qsv_init_internal_session() due to commit
> > > > 1f26a23 overwrited commit db89f45
> > > >
> > > > Fix #7030
> > > >
> > > > Signed-off-by: Zhong Li 
> > > > ---
> > > >  libavcodec/qsv.c  | 105
> > > > --
> > > >  libavcodec/qsv_internal.h |  27 +++-
> > > >  libavcodec/qsvdec.c   |  29 +++--
> > > >  libavcodec/qsvdec.h   |   2 +-
> > > >  libavcodec/qsvenc.c   |  17 
> > > >  libavcodec/qsvenc.h   |   2 +-
> > > >  6 files changed, 151 insertions(+), 31 deletions(-)
> > > >
> > > > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index
> > > > 65ad070..126182b 100644
> > > > --- a/libavcodec/qsv.c
> > > > +++ b/libavcodec/qsv.c
> > > > @@ -348,7 +348,79 @@ load_plugin_fail:
> > > >
> > > >  }
> > > >
> > > > -int ff_qsv_init_internal_session(AVCodecContext *avctx,
> > > > mfxSession *session,
> > > > +//This code is only required for Linux since a display handle is 
> > > > required.
> > > > +//For Windows the session is complete and ready to use.
> > > > +//For releases of Media Server Studio >= 2015 R4 the //render
> > > > +nodes interface is preferred (/dev/dri/renderD).
> > > > +//Using Media Server Studio 2015 R4 or newer is recommended //but
> > the
> > > > +older /dev/dri/card interface is also searched for broader
> > > > compatibility.
> > > > +
> > > > +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE static int
> > > > +ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession
> > > > *qs)
> > > > +{
> > > > +// VAAPI display handle
> > > > +int ret = 0;
> > > > +VADisplay va_dpy = NULL;
> > > > +VAStatus va_res = VA_STATUS_SUCCESS;
> > > > +int major_version = 0, minor_version = 0;
> > > > +int fd = -1;
> > > > +char adapterpath[256];
> > > > +int adapter_num;
> > > > +
> > > > +qs->fd_display = -1;
> > > > +qs->va_display = NULL;
> > > > +
> > > > +//search for valid graphics device
> > > > +for (adapter_num = 0;adapter_num < 6;adapter_num++) {
> > > > +
> > > > +if (adapter_num<3) {
> > > > +snprintf(adapterpath,sizeof(adapterpath),
> > > > +"/dev/dri/renderD%d", adapter_num+128);
> > > > +} else {
> > > > +snprintf(adapterpath,sizeof(adapterpath),
> > > > +"/dev/dri/card%d", adapter_num-3);
> > > > +}
> > > > +
> > > > +fd = open(adapterpath, O_RDWR);
> > > > +if (fd < 0) {
> > > > +  

Re: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK initialization failure in system memory mode

2019-09-04 Thread Li, Zhong
> From: Fu, Linjie
> Sent: Thursday, September 5, 2019 10:54 AM
> To: FFmpeg development discussions and patches 
> Cc: Li, Zhong 
> Subject: RE: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK initialization 
> failure
> in system memory mode
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> > Of Zhong Li
> > Sent: Wednesday, September 4, 2019 23:41
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Li, Zhong 
> > Subject: [FFmpeg-devel] [PATCH 1/2] lavc/qsv: Fix MSDK initialization
> > failure in system memory mode
> >
> > MSDK does not create internal acceleration device on Linux, So
> > MFXVideoCORE_SetHandle() is necessary.
> > It has been added for ff_qsv_init_session_device().
> > But missed for ff_qsv_init_internal_session() due to commit
> > 1f26a23 overwrited commit db89f45
> >
> > Fix #7030
> >
> > Signed-off-by: Zhong Li 
> > ---
> >  libavcodec/qsv.c  | 105
> > --
> >  libavcodec/qsv_internal.h |  27 +++-
> >  libavcodec/qsvdec.c   |  29 +++--
> >  libavcodec/qsvdec.h   |   2 +-
> >  libavcodec/qsvenc.c   |  17 
> >  libavcodec/qsvenc.h   |   2 +-
> >  6 files changed, 151 insertions(+), 31 deletions(-)
> >
> > diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index
> > 65ad070..126182b 100644
> > --- a/libavcodec/qsv.c
> > +++ b/libavcodec/qsv.c
> > @@ -348,7 +348,79 @@ load_plugin_fail:
> >
> >  }
> >
> > -int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession
> > *session,
> > +//This code is only required for Linux since a display handle is required.
> > +//For Windows the session is complete and ready to use.
> > +//For releases of Media Server Studio >= 2015 R4 the //render nodes
> > +interface is preferred (/dev/dri/renderD).
> > +//Using Media Server Studio 2015 R4 or newer is recommended //but the
> > +older /dev/dri/card interface is also searched for broader
> > compatibility.
> > +
> > +#ifdef AVCODEC_QSV_LINUX_SESSION_HANDLE static int
> > +ff_qsv_set_display_handle(AVCodecContext *avctx, QSVSession
> > *qs)
> > +{
> > +// VAAPI display handle
> > +int ret = 0;
> > +VADisplay va_dpy = NULL;
> > +VAStatus va_res = VA_STATUS_SUCCESS;
> > +int major_version = 0, minor_version = 0;
> > +int fd = -1;
> > +char adapterpath[256];
> > +int adapter_num;
> > +
> > +qs->fd_display = -1;
> > +qs->va_display = NULL;
> > +
> > +//search for valid graphics device
> > +for (adapter_num = 0;adapter_num < 6;adapter_num++) {
> > +
> > +if (adapter_num<3) {
> > +snprintf(adapterpath,sizeof(adapterpath),
> > +"/dev/dri/renderD%d", adapter_num+128);
> > +} else {
> > +snprintf(adapterpath,sizeof(adapterpath),
> > +"/dev/dri/card%d", adapter_num-3);
> > +}
> > +
> > +fd = open(adapterpath, O_RDWR);
> > +if (fd < 0) {
> > +av_log(avctx, AV_LOG_ERROR,
> > +"mfx init: %s fd open failed\n", adapterpath);
> > +continue;
> > +}
> > +
> > +va_dpy = vaGetDisplayDRM(fd);
> > +if (!va_dpy) {
> > +av_log(avctx, AV_LOG_ERROR,
> > +"mfx init: %s vaGetDisplayDRM failed\n", adapterpath);
> > +close(fd);
> > +continue;
> > +}
> > +
> > +va_res = vaInitialize(va_dpy, _version, _version);
> > +if (VA_STATUS_SUCCESS != va_res) {
> > +av_log(avctx, AV_LOG_ERROR,
> > +"mfx init: %s vaInitialize failed\n", adapterpath);
> > +close(fd);
> > +fd = -1;
> > +continue;
> > +} else {
> > +av_log(avctx, AV_LOG_VERBOSE,
> > +"mfx initialization: %s vaInitialize 
> > successful\n",adapterpath);
> > +qs->fd_display = fd;
> > +qs->va_display = va_dpy;
> > +ret = MFXVideoCORE_SetHandle(qs->session,
> > +  (mfxHandleType)MFX_HANDLE_VA_DISPLAY, (mfxHDL)va_dpy);
> > +if (ret < 0) {
> > +return ff_qsv_print_error(avctx, ret, "Error %d
> > + during set display
> > handle\n");
> > +  

Re: [FFmpeg-devel] [PATCH] lavc/qsvdec: fix the regression on linux for init_hw_device

2019-09-03 Thread Li, Zhong
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index eef4fe7..319b549
> 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -46,6 +46,7 @@ const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
>  .public = {
>  .pix_fmt = AV_PIX_FMT_QSV,
>  .methods = AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX |
> +   AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX |

AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX means we can support AV_PIX_FMT_QSV by 
AVCodecContext.hw_device_ctx
This is not supported for qsv now. 
And even if it is supported, there is no business of system memory frame, just 
means output AV_PIX_FMT_QSV format frame created by hw_device_ctx.

> AV_CODEC_HW_CONFIG_METHOD_AD_HOC,
>  .device_type = AV_HWDEVICE_TYPE_QSV,
>  },
> --
> 2.7.4

Probably we need to add MFXVideoCORE_SetHandle() function for system memory 
output path, which is removed by 1f26a231bb065276cd80ce02957c759f3197edfa.
I will try to give a patch to fix it ASAP. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/5] avcodec/vaapi_encode: Simplify code with av_clip_int8()

2019-08-28 Thread Li, Zhong
> From: ffmpeg-devel  On Behalf Of Michael
> Niedermayer
> Sent: Thursday, August 29, 2019 1:27 AM
> To: FFmpeg development discussions and patches 
> Subject: [FFmpeg-devel] [PATCH 1/5] avcodec/vaapi_encode: Simplify code with
> av_clip_int8()
> 
> Only build tested
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  libavcodec/vaapi_encode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index
> 2fb43cf1a4..3be9159d37 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -480,7 +480,7 @@ static int vaapi_encode_issue(AVCodecContext *avctx,
>  .width  = roi->right  - roi->left,
>  .height = roi->bottom - roi->top,
>  },
> -.roi_value = av_clip_c(v, INT8_MIN, INT8_MAX),
> +.roi_value = av_clip_int8(v),
>  };
>  }
> 
> --
> 2.23.0

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

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

Re: [FFmpeg-devel] [PATCH v4] avfilter/vaapi: add overlay_vaapi filter

2019-08-28 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Zachary Zhou
> Sent: Thursday, July 11, 2019 5:30 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Zhou, Zachary 
> Subject: [FFmpeg-devel] [PATCH v4] avfilter/vaapi: add overlay_vaapi filter
> 
> ---
>  configure  |   1 +
>  libavfilter/Makefile   |   1 +
>  libavfilter/allfilters.c   |   1 +
>  libavfilter/vf_overlay_vaapi.c | 424

Would be good to update the filter doc when you add a new one.

> +
>  4 files changed, 427 insertions(+)
>  create mode 100644 libavfilter/vf_overlay_vaapi.c
> 
> diff --git a/configure b/configure
> index 32fc26356c..f469e6a3b1 100755
> --- a/configure
> +++ b/configure
> @@ -3478,6 +3478,7 @@ openclsrc_filter_deps="opencl"
>  overlay_opencl_filter_deps="opencl"
>  overlay_qsv_filter_deps="libmfx"
>  overlay_qsv_filter_select="qsvvpp"
> +overlay_vaapi_filter_deps="vaapi"
>  owdenoise_filter_deps="gpl"
>  pan_filter_deps="swresample"
>  perspective_filter_deps="gpl"
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile index
> 07ea8d7edc..ccaad0d6a4 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -311,6 +311,7 @@ OBJS-$(CONFIG_OVERLAY_FILTER)
> += vf_overlay.o framesync.o
>  OBJS-$(CONFIG_OVERLAY_OPENCL_FILTER) +=
> vf_overlay_opencl.o opencl.o \
> 
> opencl/overlay.o framesync.o
>  OBJS-$(CONFIG_OVERLAY_QSV_FILTER)+= vf_overlay_qsv.o
> framesync.o
> +OBJS-$(CONFIG_OVERLAY_VAAPI_FILTER)  +=
> vf_overlay_vaapi.o framesync.o vaapi_vpp.o
>  OBJS-$(CONFIG_OWDENOISE_FILTER)  += vf_owdenoise.o
>  OBJS-$(CONFIG_PAD_FILTER)+= vf_pad.o
>  OBJS-$(CONFIG_PALETTEGEN_FILTER) += vf_palettegen.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c index
> 9c846b1ddd..27ee1df78b 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -295,6 +295,7 @@ extern AVFilter ff_vf_oscilloscope;  extern AVFilter
> ff_vf_overlay;  extern AVFilter ff_vf_overlay_opencl;  extern AVFilter
> ff_vf_overlay_qsv;
> +extern AVFilter ff_vf_overlay_vaapi;
>  extern AVFilter ff_vf_owdenoise;
>  extern AVFilter ff_vf_pad;
>  extern AVFilter ff_vf_palettegen;
> diff --git a/libavfilter/vf_overlay_vaapi.c b/libavfilter/vf_overlay_vaapi.c
> new file mode 100644 index 00..9fffa0fcb9
> --- /dev/null
> +++ b/libavfilter/vf_overlay_vaapi.c
> @@ -0,0 +1,424 @@
> +/*
> + * 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 "framesync.h"
> +#include "formats.h"
> +#include "internal.h"
> +#include "vaapi_vpp.h"
> +
> +typedef struct OverlayVAAPIContext {
> +VAAPIVPPContext  vpp_ctx; // must be the first field
> +FFFrameSync  fs;
> +int  overlay_x;
> +int  overlay_y;
> +int  overlay_w;
> +int  overlay_h;
> +floatoverlay_alpha;

Personally I would like to remove the redundant "overlay_" prefix since they 
are belong to Overlay context.

> +} OverlayVAAPIContext;
> +
> +static int overlay_vaapi_query_formats(AVFilterContext *ctx) {
> +int i;
> +int ret;
> +
> +static const enum AVPixelFormat main_in_fmts[] = {
> +AV_PIX_FMT_VAAPI,
> +AV_PIX_FMT_NONE
> +};
> +static const enum AVPixelFormat out_pix_fmts[] = {
> +AV_PIX_FMT_VAAPI,
> +AV_PIX_FMT_NONE
> +};

What are the software pixel formats can be supported for input and output? 

> +for (i = 0; i < ctx->nb_inputs; i++) {

What is the maximum input can be support? 
If only two, probably using ctx->inputs[MAIN]/ ctx->inputs[OVERLAY] is clearer. 

> +ret = ff_formats_ref(ff_make_format_list(main_in_fmts),
> >inputs[i]->out_formats);
> +if (ret < 0)
> +return ret;
> +}
>
> +ret = ff_formats_ref(ff_make_format_list(out_pix_fmts),
> >outputs[0]->in_formats);
> +if (ret < 0)
> +return ret;
> +
> +return 0;
> +}
> +
> +static int overlay_vaapi_render(AVFilterContext *avctx,
> + 

Re: [FFmpeg-devel] [CALL] New FFmpeg developers meeting

2019-08-19 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Jean-Baptiste Kempf
> Sent: Monday, August 19, 2019 2:18 PM
> To: ffmpeg-devel 
> Subject: Re: [FFmpeg-devel] [CALL] New FFmpeg developers meeting
> 
> On Sat, Aug 17, 2019, at 11:48, Paul B Mahol wrote:
> > When and how to organize this?
> 
> You have the choice:
> - IBC
> - GSoC summit
> - VDD

Have the conference time and place been decided for this year's VDD?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/6] lavc/qsvdec: Replace current parser with MFXVideoDECODE_DecodeHeader()

2019-08-19 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Thursday, August 15, 2019 3:43 PM
> To: FFmpeg development discussions and patches
> 
> Cc: Rogozhkin, Dmitry V 
> Subject: Re: [FFmpeg-devel] [PATCH 3/6] lavc/qsvdec: Replace current parser
> with MFXVideoDECODE_DecodeHeader()
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Zhong Li
> > Sent: Tuesday, August 13, 2019 2:11 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Li, Zhong ; Rogozhkin, Dmitry V
> > 
> > Subject: [FFmpeg-devel] [PATCH 3/6] lavc/qsvdec: Replace current
> > parser with MFXVideoDECODE_DecodeHeader()
> >
> > Using MSDK parser can improve qsv decoder pass rate in some cases (E.g:
> > sps declares a wrong level_idc, smaller than it should be).
> > And it is necessary for adding new qsv decoders such as MJPEG and VP9
> > since current parser can't provide enough information.
> > Actually using MFXVideoDECODE_DecodeHeader() was disscussed at
> > https://ffmpeg.org/pipermail/ffmpeg-devel/2015-July/175734.html and
> > merged as commit 1acb19d, but was overwritten when merged libav
> > patches
> > (commit: 1f26a23) without any explain.
> >
> > Split decode header from decode_init, and call it for everyframe to
> > detect format/resoultion change. It can fix some regression issues
> > such as hevc 10bits decoding.
> >
> > Signed-off-by: Zhong Li 
> > Signed-off-by: Dmitry Rogozhkin 
> > ---
> >  libavcodec/qsvdec.c   | 184
> > --
> >  libavcodec/qsvdec.h   |   2 +
> >  libavcodec/qsvdec_h2645.c |   1 +
> >  libavcodec/qsvdec_other.c |   1 +
> >  4 files changed, 100 insertions(+), 88 deletions(-)
> >
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> > 46aa2d6..7e48c83 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -147,19 +147,21 @@ static int check_dec_param(AVCodecContext
> > *avctx, QSVContext *q, mfxVideoParam *
> >  return 1;
> >  }
> >
> > -static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
> > +static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q,
> > +enum AVPixelFormat pix_fmt, mfxVideoParam *param)
> >  {
> > -const AVPixFmtDescriptor *desc;
> >  mfxSession session = NULL;
> >  int iopattern = 0;
> > -mfxVideoParam param = { 0 };
> > -int frame_width  = avctx->coded_width;
> > -int frame_height = avctx->coded_height;
> >  int ret;
> > +enum AVPixelFormat pix_fmts[3] = {
> > +AV_PIX_FMT_QSV, /* opaque format in case of video memory
> > output */
> > +pix_fmt,/* system memory format obtained from
> > bitstream parser */
> > +AV_PIX_FMT_NONE };
> >
> > -desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
> > -if (!desc)
> > -return AVERROR_BUG;
> > +ret = ff_get_format(avctx, pix_fmts);
> > +if (ret < 0) {
> > +q->orig_pix_fmt = avctx->pix_fmt = AV_PIX_FMT_NONE;
> > +return ret;
> > +}
> >
> >  if (!q->async_fifo) {
> >  q->async_fifo = av_fifo_alloc(q->async_depth *
> > qsv_fifo_item_size()); @@ -197,54 +199,72 @@ static int
> > qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
> >  return ret;
> >  }
> >
> > -ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
> > -if (ret < 0)
> > -return ret;
> > +param->IOPattern   = q->iopattern;
> > +param->AsyncDepth  = q->async_depth;
> > +param->ExtParam= q->ext_buffers;
> > +param->NumExtParam = q->nb_ext_buffers;
> >
> > -param.mfx.CodecId  = ret;
> > -param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id,
> > avctx->profile);
> > -param.mfx.CodecLevel   = ff_qsv_level_to_mfx(avctx->codec_id,
> > avctx->level);
> > -
> > -param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
> > -param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
> > -param.mfx.FrameInfo.Shift  = desc->comp[0].depth > 8;
> > -param.mfx.FrameInfo.FourCC = q->fourcc;
> > -param.mfx.FrameInfo.Width  = frame_width;
> > -param.mfx.FrameInfo.Height = frame_height;
> > -param.mfx.FrameInfo.ChromaFormat   =
> > MFX_CHROMAFORMAT_YUV420;
> > -
> > -switch (avctx->field_or

Re: [FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter

2019-08-19 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Paul B Mahol
> Sent: Wednesday, August 14, 2019 5:38 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter
> 
> On Wed, Aug 14, 2019 at 9:01 AM Li, Zhong  wrote:
> 
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > > Of Eugene Lyapustin
> > > Sent: Wednesday, August 14, 2019 9:14 AM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Subject: [FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter
> > >
> > > Signed-off-by: Eugene Lyapustin 
> > > ---
> > >  doc/filters.texi |  137 +++
> > >  libavfilter/Makefile |1 +
> > >  libavfilter/allfilters.c |1 +
> > >  libavfilter/vf_v360.c| 1847
> > > ++
> >
> > Probably you also want to update the Changelog?
> >
> 
> That is job for comitter.

Patch set merged but without changelog update. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V2] FATE/dnn: let fate/dnn tests depend on ffmpeg static libraries

2019-08-16 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Guo, Yejun
> Sent: Wednesday, August 7, 2019 10:44 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Guo, Yejun 
> Subject: [FFmpeg-devel] [PATCH V2] FATE/dnn: let fate/dnn tests depend on
> ffmpeg static libraries
> 
> background:
> DNN (deep neural network) is a sub module of libavfilter, and FATE/dnn is
> unit test for the DNN module, one unit test for one dnn layer.
> The unit tests are not based on the APIs exported by libavfilter, they just
> directly call into the functions within DNN submodule.
> 
> There is an issue when run the following command:
> build$ ../ffmpeg/configure --disable-static --enable-shared make make
> fate-dnn-layer-pad
> 
> And part of error message:
> tests/dnn/dnn-layer-pad-test.o: In function `test_with_mode_symmetric':
> /work/media/ffmpeg/build/src/tests/dnn/dnn-layer-pad-test.c:73:
> undefined reference to `dnn_execute_layer_pad'
> 
> The root cause is that function dnn_execute_layer_pad is a LOCAL symbol in
> libavfilter.so, and so the linker could not find it when build
> dnn-layer-pad-test.
> To check it, just run: readelf -s libavfilter/libavfilter.so | grep dnn
> 
> So, add dependency in fate/dnn Makefile with ffmpeg static libraries.
> This is the same method used in fate/checkasm
> 
> Signed-off-by: Guo, Yejun 
> ---
>  tests/dnn/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/dnn/Makefile b/tests/dnn/Makefile index b2e6680..0e050ea
> 100644
> --- a/tests/dnn/Makefile
> +++ b/tests/dnn/Makefile
> @@ -4,8 +4,8 @@ DNNTESTOBJS  :=
> $(DNNTESTOBJS:%=$(DNNTESTSDIR)%)
> $(DNNTESTPROGS:%=$(DNNTESTSDIR)  DNNTESTPROGS :=
> $(DNNTESTPROGS:%=$(DNNTESTSDIR)/%-test$(EXESUF))
>  -include $(wildcard $(DNNTESTOBJS:.o=.d))
> 
> -$(DNNTESTPROGS): %$(EXESUF): %.o $(FF_DEP_LIBS)
> - $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^)
> $(FF_EXTRALIBS) $(ELIBS)
> +$(DNNTESTPROGS): %$(EXESUF): %.o $(FF_STATIC_DEP_LIBS)
> + $(LD) $(LDFLAGS) $(LDEXEFLAGS) $(LD_O) $(filter %.o,$^)
> +$(FF_STATIC_DEP_LIBS) $(ELIBS)
> 
>  testclean::
>   $(RM) $(addprefix $(DNNTESTSDIR)/,$(CLEANSUFFIXES)
> *-test$(EXESUF))
> --
> 2.7.4

LGTM && Verified

IMHO this is a high priority patch since currently FATE is broken now if build 
with dynamic link
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/6] lavc/qsvdec: Replace current parser with MFXVideoDECODE_DecodeHeader()

2019-08-15 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Zhong Li
> Sent: Tuesday, August 13, 2019 2:11 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Li, Zhong ; Rogozhkin, Dmitry V
> 
> Subject: [FFmpeg-devel] [PATCH 3/6] lavc/qsvdec: Replace current parser
> with MFXVideoDECODE_DecodeHeader()
> 
> Using MSDK parser can improve qsv decoder pass rate in some cases (E.g:
> sps declares a wrong level_idc, smaller than it should be).
> And it is necessary for adding new qsv decoders such as MJPEG and VP9 since
> current parser can't provide enough information.
> Actually using MFXVideoDECODE_DecodeHeader() was disscussed at
> https://ffmpeg.org/pipermail/ffmpeg-devel/2015-July/175734.html and
> merged as commit 1acb19d, but was overwritten when merged libav patches
> (commit: 1f26a23) without any explain.
> 
> Split decode header from decode_init, and call it for everyframe to detect
> format/resoultion change. It can fix some regression issues such as hevc
> 10bits decoding.
> 
> Signed-off-by: Zhong Li 
> Signed-off-by: Dmitry Rogozhkin 
> ---
>  libavcodec/qsvdec.c   | 184
> --
>  libavcodec/qsvdec.h   |   2 +
>  libavcodec/qsvdec_h2645.c |   1 +
>  libavcodec/qsvdec_other.c |   1 +
>  4 files changed, 100 insertions(+), 88 deletions(-)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> 46aa2d6..7e48c83 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -147,19 +147,21 @@ static int check_dec_param(AVCodecContext
> *avctx, QSVContext *q, mfxVideoParam *
>  return 1;
>  }
> 
> -static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
> +static int qsv_decode_preinit(AVCodecContext *avctx, QSVContext *q,
> +enum AVPixelFormat pix_fmt, mfxVideoParam *param)
>  {
> -const AVPixFmtDescriptor *desc;
>  mfxSession session = NULL;
>  int iopattern = 0;
> -mfxVideoParam param = { 0 };
> -int frame_width  = avctx->coded_width;
> -int frame_height = avctx->coded_height;
>  int ret;
> +enum AVPixelFormat pix_fmts[3] = {
> +AV_PIX_FMT_QSV, /* opaque format in case of video memory
> output */
> +pix_fmt,/* system memory format obtained from
> bitstream parser */
> +AV_PIX_FMT_NONE };
> 
> -desc = av_pix_fmt_desc_get(avctx->sw_pix_fmt);
> -if (!desc)
> -return AVERROR_BUG;
> +ret = ff_get_format(avctx, pix_fmts);
> +if (ret < 0) {
> +q->orig_pix_fmt = avctx->pix_fmt = AV_PIX_FMT_NONE;
> +return ret;
> +}
> 
>  if (!q->async_fifo) {
>  q->async_fifo = av_fifo_alloc(q->async_depth *
> qsv_fifo_item_size()); @@ -197,54 +199,72 @@ static int
> qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
>  return ret;
>  }
> 
> -ret = ff_qsv_codec_id_to_mfx(avctx->codec_id);
> -if (ret < 0)
> -return ret;
> +param->IOPattern   = q->iopattern;
> +param->AsyncDepth  = q->async_depth;
> +param->ExtParam= q->ext_buffers;
> +param->NumExtParam = q->nb_ext_buffers;
> 
> -param.mfx.CodecId  = ret;
> -param.mfx.CodecProfile = ff_qsv_profile_to_mfx(avctx->codec_id,
> avctx->profile);
> -param.mfx.CodecLevel   = ff_qsv_level_to_mfx(avctx->codec_id,
> avctx->level);
> -
> -param.mfx.FrameInfo.BitDepthLuma   = desc->comp[0].depth;
> -param.mfx.FrameInfo.BitDepthChroma = desc->comp[0].depth;
> -param.mfx.FrameInfo.Shift  = desc->comp[0].depth > 8;
> -param.mfx.FrameInfo.FourCC = q->fourcc;
> -param.mfx.FrameInfo.Width  = frame_width;
> -param.mfx.FrameInfo.Height = frame_height;
> -param.mfx.FrameInfo.ChromaFormat   =
> MFX_CHROMAFORMAT_YUV420;
> -
> -switch (avctx->field_order) {
> -case AV_FIELD_PROGRESSIVE:
> -param.mfx.FrameInfo.PicStruct =
> MFX_PICSTRUCT_PROGRESSIVE;
> -break;
> -case AV_FIELD_TT:
> -param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_TFF;
> -break;
> -case AV_FIELD_BB:
> -param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_FIELD_BFF;
> -break;
> -default:
> -param.mfx.FrameInfo.PicStruct = MFX_PICSTRUCT_UNKNOWN;
> -break;
> -}
> +return 0;
> + }
> 
> -param.IOPattern   = q->iopattern;
> -param.AsyncDepth  = q->async_depth;
> -param.ExtParam= q->ext_buffers;
> -param.NumExtParam = q->nb_ext_buffers;
> +static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q,
> +mfxVideoParam *param) {
> +int ret;
&

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: provide detailed warning if directly mapping fails

2019-08-14 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Wednesday, August 14, 2019 5:25 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: provide detailed
> warning if directly mapping fails
> 
> Detailed message could be helpful when using
> hwmap=mode=direct,format=xxx for both qsv and vaapi.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/hwcontext_vaapi.c | 9 ++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index
> cf117640f2..30c42e4385 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -747,19 +747,22 @@ static int vaapi_map_frame(AVHWFramesContext
> *hwfc,
>  av_log(hwfc, AV_LOG_DEBUG, "Map surface %#x.\n", surface_id);
> 
>  if (!ctx->derive_works && (flags & AV_HWFRAME_MAP_DIRECT)) {
> -// Requested direct mapping but it is not possible.
> +av_log(hwfc, AV_LOG_WARNING, "Requested direct mapping but
> "
> +"it is not
> possible.\n");
>  return AVERROR(EINVAL);
>  }
>  if (dst->format == AV_PIX_FMT_NONE)
>  dst->format = hwfc->sw_format;
>  if (dst->format != hwfc->sw_format && (flags &
> AV_HWFRAME_MAP_DIRECT)) {
> -// Requested direct mapping but the formats do not match.
> +av_log(hwfc, AV_LOG_WARNING, "Requested direct mapping but
> "
> +"the formats do not
> match.\n");
>  return AVERROR(EINVAL);
>  }
> 
>  err = vaapi_get_image_format(hwfc->device_ctx, dst->format,
> _format);
>  if (err < 0) {
> -// Requested format is not a valid output format.
> +av_log(hwfc, AV_LOG_WARNING, "Requested format is "
> +"not a valid output
> + format.\n");
>  return AVERROR(EINVAL);
>  }
> 
> --
> 2.17.1

Why just give a warning message when you need to return an error? 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter

2019-08-14 Thread Li, Zhong
gt;> +    hf = inlink->h * 2.f;
> >>>>>> +    break;
> >>>>>> +    case EQUIANGULAR:
> >>>>>> +    in_transform = xyz_to_eac;
> >>>>>> +    err = prepare_eac_in(ctx);
> >>>>>> +    wf = inlink->w;
> >>>>>> +    hf = inlink->h / 9.f * 8.f;
> >>>>>> +    break;
> >>>>>> +    case FLAT:
> >>>>>> +    av_log(ctx, AV_LOG_ERROR, "Flat format is not
> accepted
> >>>>>> +as
> >>>>>> input.\n");
> >>>>>> +    return AVERROR(EINVAL);
> >>>>>> +    }
> >>>>>> +
> >>>>>> +    if (err != 0) {
> >>>>>> +    return err;
> >>>>>> +    }
> >>>>>> +
> >>>>>> +    switch (s->out) {
> >>>>>> +    case EQUIRECTANGULAR:
> >>>>>> +    out_transform = equirect_to_xyz;
> >>>>>> +    err = 0;
> >>>>>> +    w = roundf(wf);
> >>>>>> +    h = roundf(hf);
> >>>>>> +    break;
> >>>>>> +    case CUBEMAP_3_2:
> >>>>>> +    out_transform = cube3x2_to_xyz;
> >>>>>> +    err = prepare_cube_out(ctx);
> >>>>>> +    w = roundf(wf / 4.f * 3.f);
> >>>>>> +    h = roundf(hf);
> >>>>>> +    break;
> >>>>>> +    case CUBEMAP_6_1:
> >>>>>> +    out_transform = cube6x1_to_xyz;
> >>>>>> +    err = prepare_cube_out(ctx);
> >>>>>> +    w = roundf(wf / 2.f * 3.f);
> >>>>>> +    h = roundf(hf / 2.f);
> >>>>>> +    break;
> >>>>>> +    case EQUIANGULAR:
> >>>>>> +    out_transform = eac_to_xyz;
> >>>>>> +    err = prepare_eac_out(ctx);
> >>>>>> +    w = roundf(wf);
> >>>>>> +    h = roundf(hf / 8.f * 9.f);
> >>>>>> +    break;
> >>>>>> +    case FLAT:
> >>>>>> +    out_transform = flat_to_xyz;
> >>>>>> +    err = prepare_flat_out(ctx);
> >>>>>> +    w = roundf(wf * s->flat_range[0] / s->flat_range[1] /
> >>>>>> +2.f);
> >>>>>> +    h = roundf(hf);
> >>>>>> +    break;
> >>>>>> +    }
> >>>>>> +
> >>>>>> +    if (err != 0) {
> >>>>>> +    return err;
> >>>>>> +    }
> >>>>>> +
> >>>>>> +    if (s->width > 0 && s->height > 0) {
> >>>>>> +    w = s->width;
> >>>>>> +    h = s->height;
> >>>>>> +    }
> >>>>> If s->width/height are checked, should handle the case of no ture,
> >>>>> Else w/h may be used but not initialized.
> >>>>>
> >>>> Please try more hard to write english. I do not understand what is
> >>>> typed above.
> >>> If w and h don't have initial values at declaration. So they might
> >>> never get set if that last if statement evaluates to false.
> >>>
> >>> So he suggests to add an else case like
> >>>
> >>> if (s->width > 0 && s->height > 0) {
> >>>   w = s->width;
> >>>   h = s->height;
> >>> } else {
> >>>   w = 0;
> >>>   h = 0;
> >>> }
> >>>
> >>> or whatever values might make sense.
> >>>
> >> else case should have assert or return AVERROR_BUG.
> >
> > This "if" branch overrides default values with user values. Default values
> are calculated just above this code based on input/output formats.
> > So w and h do get initialized in any case.
> 
> Hmm... what happens if (s->out != any case you have in the switch) and
> (s->width < 1 || s->height < 1)
> 
> Maybe I misread, actually I just clarified what Li Zhong said.
> 
> -Thilo

Yes, this is exactly what I mean.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: cope with race map for YUV420P

2019-08-14 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Fu, Linjie
> Sent: Wednesday, August 14, 2019 9:59 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_vaapi: cope with race
> map for YUV420P
> 
> > -Original Message-
> > From: Fu, Linjie
> > Sent: Thursday, August 1, 2019 12:45
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Fu, Linjie 
> > Subject: [PATCH] lavu/hwcontext_vaapi: cope with race map for YUV420P
> >
> > There is a race condition for AV_PIX_FMT_YUV420P when mapping from
> > pix_fmt to fourcc, both VA_FOURCC_I420 and VA_FOURCC_YV12 could be
> > find by pix_fmt.

find -> found

> > Currently, vaapi_get_image_format will go through the query results of
> > pix_fmt and returned the first matched result according to the
> > declared order in driver.This may leads to a wrong image_format.
> >
> > Modify to find image_format via fourcc.
> >
> > Fix vaapi CSC to I420:
> > ffmpeg -hwaccel vaapi -vaapi_device /dev/dri/renderD128 -f rawvideo
> > -pix_fmt nv12 -s:v 1280x720 -i NV12.yuv -vf
> >
> 'format=nv12,hwupload,scale_vaapi=format=yuv420p,hwdownload,format=
> > yuv420p'
> > -f rawvideo -vsync passthrough -vframes 10 -y aa.yuv
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavutil/hwcontext_vaapi.c | 14 +++---
> >  1 file changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c
> > index cf11764..64f14de 100644
> > --- a/libavutil/hwcontext_vaapi.c
> > +++ b/libavutil/hwcontext_vaapi.c
> > @@ -63,6 +63,7 @@ typedef struct VAAPIDevicePriv {  typedef struct
> > VAAPISurfaceFormat {
> >  enum AVPixelFormat pix_fmt;
> >  VAImageFormat image_format;
> > +unsigned int fourcc;
> >  } VAAPISurfaceFormat;
> >
> >  typedef struct VAAPIDeviceContext {
> > @@ -171,15 +172,21 @@ static int
> > vaapi_get_image_format(AVHWDeviceContext *hwdev,
> >VAImageFormat
> **image_format)  {
> >  VAAPIDeviceContext *ctx = hwdev->internal->priv;
> > +VAAPIFormatDescriptor *desc;
> >  int i;
> >
> > +desc = vaapi_format_from_pix_fmt(pix_fmt);
> > +if (!desc || !image_format)
> > +goto fail;
> > +
> >  for (i = 0; i < ctx->nb_formats; i++) {
> > -if (ctx->formats[i].pix_fmt == pix_fmt) {
> > -if (image_format)
> > -*image_format = >formats[i].image_format;
> > +if (ctx->formats[i].fourcc == desc->fourcc) {
> > +*image_format = >formats[i].image_format;
> >  return 0;
> >  }
> >  }
> > +
> > +fail:
> >  return AVERROR(EINVAL);
> >  }
> >
> > @@ -368,6 +375,7 @@ static int vaapi_device_init(AVHWDeviceContext
> > *hwdev)
> >  av_log(hwdev, AV_LOG_DEBUG, "Format %#x -> %s.\n",
> > fourcc, av_get_pix_fmt_name(pix_fmt));
> >  ctx->formats[ctx->nb_formats].pix_fmt  = pix_fmt;
> > +ctx->formats[ctx->nb_formats].fourcc   = fourcc;
> >  ctx->formats[ctx->nb_formats].image_format =
> image_list[i];
> >  ++ctx->nb_formats;
> >  }
> > --
> > 2.7.4
> A gentle ping.

Patch LGTM

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

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

Re: [FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter

2019-08-14 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Eugene Lyapustin
> Sent: Wednesday, August 14, 2019 9:14 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v2 1/3] avfilter: add v360 filter
> 
> Signed-off-by: Eugene Lyapustin 
> ---
>  doc/filters.texi |  137 +++
>  libavfilter/Makefile |1 +
>  libavfilter/allfilters.c |1 +
>  libavfilter/vf_v360.c| 1847
> ++

Probably you also want to update the Changelog?

>  4 files changed, 1986 insertions(+)
>  create mode 100644 libavfilter/vf_v360.c
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index e081cdc7bc..6168a3502a 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -17879,6 +17879,143 @@ Force a constant quantization parameter. If
> not set, the filter will use the QP
>  from the video stream (if available).
>  @end table
> 
> +@section v360
> +
> +Convert 360 videos between various formats.
> +
> +The filter accepts the following options:
> +
> +@table @option
> +
> +@item input
> +@item output
> +Set format of the input/output video.
> +
> +Available formats:
> +
> +@table @samp
> +
> +@item e
> +Equirectangular projection.
> +
> +@item c3x2
> +@item c6x1
> +Cubemap with 3x2/6x1 layout.
> +
> +Format specific options:
> +
> +@table @option
> +@item in_forder
> +@item out_forder
> +Set order of faces for the input/output cubemap. Choose one direction for
> each position.
> +
> +Designation of directions:
> +@table @samp
> +@item r
> +right
> +@item l
> +left
> +@item u
> +up
> +@item d
> +down
> +@item f
> +forward
> +@item b
> +back
> +@end table
> +
> +Default value is @b{@samp{rludfb}}.
> +
> +@item in_frot
> +@item out_frot
> +Set rotation of faces for the input/output cubemap. Choose one angle for
> each position.
> +
> +Designation of angles:
> +@table @samp
> +@item 0
> +0 degrees clockwise
> +@item 1
> +90 degrees clockwise
> +@item 2
> +180 degrees clockwise
> +@item 4
> +270 degrees clockwise
> +@end table
> +
> +Default value is @b{@samp{00}}.
> +@end table
> +
> +@item eac
> +Equi-Angular Cubemap.
> +
> +@item flat
> +Regular video. @i{(output only)}
> +
> +Format specific options:
> +@table @option
> +@item h_fov
> +@item v_fov
> +Set horizontal/vertical field of view. Values in degrees.
> +@end table
> +@end table
> +
> +@item interp
> +Set interpolation method.@*
> +@i{Note: more complex interpolation methods require much more memory
> to run.}
> +
> +Available methods:
> +
> +@table @samp
> +@item near
> +@item nearest
> +Nearest neighbour.
> +@item line
> +@item linear
> +Bilinear interpolation.
> +@item cube
> +@item cubic
> +Bicubic interpolation.
> +@item lanc
> +@item lanczos
> +Lanczos interpolation.
> +@end table
> +
> +Default value is @b{@samp{line}}.
> +
> +@item w
> +@item h
> +Set the output video resolution.
> +
> +Default resolution depends on formats.
> +
> +@item yaw
> +@item pitch
> +@item roll
> +Set rotation for the output video. Values in degrees.
> +
> +@item hflip
> +@item vflip
> +@item dflip
> +Flip the output video horizontally/vertically/in-depth. Boolean values.
> +
> +@end table
> +
> +@subsection Examples
> +
> +@itemize
> +@item
> +Convert equirectangular video to cubemap with 3x2 layout using bicubic
> interpolation:
> +@example
> +ffmpeg -i input.mkv -vf v360=e:c3x2:cubic output.mkv
> +@end example
> +@item
> +Extract back view of Equi-Angular Cubemap:
> +@example
> +ffmpeg -i input.mkv -vf v360=eac:flat:yaw=180 output.mkv
> +@end example
> +@end itemize
> +
>  @section vaguedenoiser
> 
>  Apply a wavelet based denoiser.
> diff --git a/libavfilter/Makefile b/libavfilter/Makefile
> index efc7bbb153..345f7c95cd 100644
> --- a/libavfilter/Makefile
> +++ b/libavfilter/Makefile
> @@ -410,6 +410,7 @@ OBJS-$(CONFIG_UNSHARP_FILTER)
> += vf_unsharp.o
>  OBJS-$(CONFIG_UNSHARP_OPENCL_FILTER) +=
> vf_unsharp_opencl.o opencl.o \
> 
> opencl/unsharp.o
>  OBJS-$(CONFIG_USPP_FILTER)   += vf_uspp.o
> +OBJS-$(CONFIG_V360_FILTER)   += vf_v360.o
>  OBJS-$(CONFIG_VAGUEDENOISER_FILTER)  +=
> vf_vaguedenoiser.o
>  OBJS-$(CONFIG_VECTORSCOPE_FILTER)+= vf_vectorscope.o
>  OBJS-$(CONFIG_VFLIP_FILTER)  += vf_vflip.o
> diff --git a/libavfilter/allfilters.c b/libavfilter/allfilters.c
> index abd726d616..5799fb4b3c 100644
> --- a/libavfilter/allfilters.c
> +++ b/libavfilter/allfilters.c
> @@ -390,6 +390,7 @@ extern AVFilter ff_vf_unpremultiply;
>  extern AVFilter ff_vf_unsharp;
>  extern AVFilter ff_vf_unsharp_opencl;
>  extern AVFilter ff_vf_uspp;
> +extern AVFilter ff_vf_v360;
>  extern AVFilter ff_vf_vaguedenoiser;
>  extern AVFilter ff_vf_vectorscope;
>  extern AVFilter ff_vf_vflip;
> diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
> new file mode 100644
> index 00..5c377827b0
> --- /dev/null
> +++ b/libavfilter/vf_v360.c
> @@ -0,0 +1,1847 @@
> +/*
> + * Copyright (c) 2019 Eugene Lyapustin
> + *
> + * This file is 

Re: [FFmpeg-devel] [PATCH V3] fate: add a case for ticket #3229

2019-08-12 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Thilo Borgmann
> Sent: Monday, August 12, 2019 3:55 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH V3] fate: add a case for ticket #3229
> 
> Am 12.08.19 um 08:13 schrieb Zhong Li:
> > Signed-off-by: Zhong Li 
> > ---
> > https://patchwork.ffmpeg.org/patch/13725/ introduces a regression but
> not found by fate, so add it.
> > Test clip produced by:
> > ffmpeg -i tickets/3229/bad.avi -vframes 3 -c:v copy
> > /fate-suite/mjpeg/mjpeg_field_order.avi
> >
> >  tests/fate/video.mak| 3 +++
> >  tests/ref/fate/mjpeg-ticket3229 | 8 
> >  2 files changed, 11 insertions(+)
> >  create mode 100644 tests/ref/fate/mjpeg-ticket3229 [...]
> 
> LGTM & sample uploaded.
> 
> -Thilo

Thanks!
Patch applied.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] doc/fate: Document how to request samples upload access

2019-08-07 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Tuesday, August 6, 2019 1:07 AM
> To: FFmpeg development discussions and patches
> 
> Subject: [FFmpeg-devel] [PATCH] doc/fate: Document how to request
> samples upload access
> 
> Signed-off-by: Michael Niedermayer 
> ---
>  doc/fate.texi | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/doc/fate.texi b/doc/fate.texi index 2be61d639c..e04fbfbe43
> 100644
> --- a/doc/fate.texi
> +++ b/doc/fate.texi
> @@ -157,6 +157,9 @@ practice generally do not replace, remove or
> overwrite files as it likely would  break older checkouts or releases.
>  Also all needed samples for a commit should be uploaded, ideally 24
> hours, before the push.
> +If you need an account for frequently uploading samples or you wish to
> +help others do so send mail to ffmpeg-devel. Also please state if you
> +are available to help others upload samples if you request access.

Probably I miss something.

It is still not clear for someone need to help to upload a sample: who is the 
contact person?
Should we update a new section with the name who can help others to upload, or 
set-up/public a new mail list channel?

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

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

Re: [FFmpeg-devel] [PATCH 1/2] Revert "lavf/vf_vpp_qsv: add support for QSV transpose filter"

2019-08-07 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Paul B Mahol
> Sent: Wednesday, August 7, 2019 10:36 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] Revert "lavf/vf_vpp_qsv: add
> support for QSV transpose filter"
> 
> On Wed, Aug 7, 2019 at 4:34 PM Li, Zhong  wrote:
> 
> > > From: Nicolas George [mailto:geo...@nsup.org]
> > > Sent: Wednesday, August 7, 2019 10:31 PM
> > > To: FFmpeg development discussions and patches
> > > 
> > > Cc: Li, Zhong 
> > > Subject: Re: [FFmpeg-devel] [PATCH 1/2] Revert "lavf/vf_vpp_qsv: add
> > > support for QSV transpose filter"
> > >
> > > Zhong Li (12019-08-07):
> > > > This reverts commit af3ddd581faf2c3c4748ae589947c662b1a2271e.
> > > >
> > > > Revert it due to the uncorrect subject, should be: "lavf" -> "lavfi"
> > >
> > > The damage to the git log is done, this will just make it worse, IMHO.
> > >
> > > Regards,
> > >
> > > --
> > >   Nicolas George
> >
> > So your suggestion should be: just keep it and do nothing now?
> 
> 
> Please do nothing now, please do not forget it for next time, what is lavf and
> what is lavfi.

Thanks for remind. Will take care of it next time.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/2] Revert "lavf/vf_vpp_qsv: add support for QSV transpose filter"

2019-08-07 Thread Li, Zhong
> From: Nicolas George [mailto:geo...@nsup.org]
> Sent: Wednesday, August 7, 2019 10:31 PM
> To: FFmpeg development discussions and patches
> 
> Cc: Li, Zhong 
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] Revert "lavf/vf_vpp_qsv: add
> support for QSV transpose filter"
> 
> Zhong Li (12019-08-07):
> > This reverts commit af3ddd581faf2c3c4748ae589947c662b1a2271e.
> >
> > Revert it due to the uncorrect subject, should be: "lavf" -> "lavfi"
> 
> The damage to the git log is done, this will just make it worse, IMHO.
> 
> Regards,
> 
> --
>   Nicolas George

So your suggestion should be: just keep it and do nothing now? 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for QSV transpose filter

2019-08-07 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Paul B Mahol
> Sent: Wednesday, August 7, 2019 10:08 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for
> QSV transpose filter
> > Applied with updated commit message to remove the limitation
> > description, since
> > https://github.com/Intel-Media-SDK/MediaSDK/pull/1491 has been
> merged.
> 
> 
> Please revert, lavf stand for libavformat.
> You need lavfi, as that stand for libavfilter.

Sorry for the incaution. Revert patch has been sent and will merge soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for QSV transpose filter

2019-08-07 Thread Li, Zhong
> From: Fu, Linjie
> Sent: Monday, July 15, 2019 12:30 PM
> To: Li, Zhong ; FFmpeg development discussions and
> patches 
> Subject: RE: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for
> QSV transpose filter
> 
> > -Original Message-
> > From: Li, Zhong
> > Sent: Sunday, July 14, 2019 19:33
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Cc: Fu, Linjie 
> > Subject: RE: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support
> > for QSV transpose filter
> >
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > > Of Linjie Fu
> > > Sent: Thursday, July 11, 2019 1:58 AM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Fu, Linjie 
> > > Subject: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for
> > QSV
> > > transpose filter
> > >
> > > Add transpose support for qsv_vpp with rotate and hflip:
> > > - rotate: [0, 3] support clockwise rotation of 0, 90, 180, 270;
> > > - hflip:  [0, 1] support horizontal flip;
> > >
> > > Configure with:
> > > {"cclock_hflip","clock","cclock","clock_hflip","reversal","hflip","v
> > > flip"}
> > >
> > > Limitation:
> > > If pipeline contains resize, mirroring and other, VPP skips
> > > other filters in MSDK when IOPattern equals d3d->d3d. So "cclock_hflip,
> clock_hflip, vflip"
> > > will not work in d3d->d3d condition.
> > >
> > > This pr is fixing this:
> > > https://github.com/Intel-Media-SDK/MediaSDK/pull/1491
> > >
> > > CMD:
> > > ffmpeg -hwaccel qsv -c:v h264_qsv -i input.h264
> > > -vf 'format=qsv,vpp_qsv=transpose=clock' -c:v h264_qsv
> > > output.h264
> >
> > Tested:
> > ffmpeg -hwaccel qsv -c:v h264_qsv -i
> > ~/bbb_sunflower_1080p_30fps_normal.mp4 -vframes 100 -vf
> > 'format=qsv,vpp_qsv=transpose=cclock_hflip' -c:v h264_qsv ch.mp4 Both
> > Skylake and KBL failed:
> >
> > [Parsed_vpp_qsv_1 @ 0x5581aaf16080] Failed to create a qsvvpp, ret =
> -15.
> > [Parsed_vpp_qsv_1 @ 0x5581aaf16080] Failed to configure output pad on
> > Parsed_vpp_qsv_1
> > Error reinitializing filters!
> > Failed to inject frame into filter network: Block device required
> > Error while processing the decoded data for stream #0:0
> 
> It is due to the limitation in MSDK mentioned in commit message:
> If pipeline contains resize, mirroring and other, VPP skips other filters in
> MSDK.
> 
> And specially for resize (also width/height swap caused  by rotate),
> MFXVideoVPP_Init would fail directly, not simply skip the resize/rotate:
> https://github.com/Intel-Media-SDK/MediaSDK/blob/master/_studio/mfx_li
> b/vpp/src/mfx_vpp_hw.cpp#L5546
> 
> This PR could handle this properly as suggested:
> https://github.com/Intel-Media-SDK/MediaSDK/pull/1491
> 
> - Linjie

Applied with updated commit message to remove the limitation description,
since https://github.com/Intel-Media-SDK/MediaSDK/pull/1491 has been merged. 

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

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

Re: [FFmpeg-devel] [RFC] samples.ffmpeg.org

2019-08-04 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Monday, August 5, 2019 3:45 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [RFC] samples.ffmpeg.org
> 
> On Sun, Aug 04, 2019 at 05:42:14PM +0100, Kieran Kunhya wrote:
> > On Sat, 3 Aug 2019 at 18:35, Michael Niedermayer
> > 
> > wrote:
> >
> > > Hi all
> > >
> > > It seems we do not have a list of people volunteering to do uploads
> > > to samples. And no place to send such requests to except here, where
> > > they sometimes get ignored.
> > >
> >
> > Just give everyone with push access right to upload.
> 
> Upload currently requires an account on the server, giving everyone an
> account is a security risk.
> It also doesnt really make sense to give someone access who doesnt need
> access.
> If someone wants to take care of uploads (s)he can have access.
> 
> Of course if theres a majority wanting everyone with push access to have an
> account on the server, sure we will do that but i dont think its a good idea.
> IMHO its always better (aka more secure) if access is kept at a minimum.
> 
> besides, it would be a bit of work to keep the list of who has push access and
> who has sampeles access synchronized. Its different servers and different
> types of "accounts"
> and the whole point from my point of view is that id like to spend my time on
> other areas on FFmpeg While keeping accounts synchronized would be
> probably more work than doing the uploads myself
> 
> Thanks

My suggestions would be:
1. If there is any volunteer to be fate-samples MAINTAINERS, tell him how to 
apply and update the FATE MAINTAINERS list.
2. If there is anyone with push access has a requirement to upload a fate 
sample, reply him to please apply fate access and update the FATE MAINTAINERS 
list.

Then there will be several or a dozen of people with fate access in the future, 
they can help to take the requirements from someone who have no both push 
access and FATE account, this will be not a big burden for everyone.

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

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

Re: [FFmpeg-devel] [PATCH V2] fate: add a case for ticket #3229

2019-08-02 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Tuesday, July 30, 2019 9:53 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH V2] fate: add a case for ticket #3229
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Michael Niedermayer
> > Sent: Tuesday, July 30, 2019 4:28 AM
> > To: FFmpeg development discussions and patches
> > 
> > Subject: Re: [FFmpeg-devel] [PATCH V2] fate: add a case for ticket
> > #3229
> >
> > On Mon, Jul 29, 2019 at 06:20:39PM +0800, Zhong Li wrote:
> > > Signed-off-by: Zhong Li 
> > > ---
> > > https://patchwork.ffmpeg.org/patch/13725/ introduces a regression
> > > but
> > not found by fate, so add it.
> > > Test clip produced by:
> > > ffmpeg -i tickets/3229/bad.avi -vframes 6 -c:v copy
> > > /fate-suite/mjpeg/mjpeg_field_order.avi
> > >
> > >  tests/fate/video.mak|  3 +++
> > >  tests/ref/fate/mjpeg-ticket3229 | 11 +++
> > >  2 files changed, 14 insertions(+)
> > >  create mode 100644 tests/ref/fate/mjpeg-ticket3229
> >
> > LGTM & passed on mingw32/64 arm/mips qemu and linux32
> >
> > thx
> 
> Thanks for review and testing.
> May I search your help to produce/upload the clip to fate server and then
> apply this patch?

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

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

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Sun, Jing A
> Sent: Wednesday, July 31, 2019 10:16 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Tuesday, July 30, 2019 3:49 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> > > +AVCodec ff_libsvt_hevc_encoder = {
> > > +.name   = "libsvt_hevc",
> > > +.long_name  =
> NULL_IF_CONFIG_SMALL("SVT-HEVC(Scalable
> > Video Technology for HEVC) encoder"),
> > > +.priv_data_size = sizeof(SvtContext),
> > > +.type   = AVMEDIA_TYPE_VIDEO,
> > > +.id = AV_CODEC_ID_HEVC,
> > > +.init   = eb_enc_init,
> > > +.encode2= eb_encode_frame,
> > > +.close  = eb_enc_close,
> > > +.capabilities   = AV_CODEC_CAP_DELAY |
> > AV_CODEC_CAP_AUTO_THREADS,
> >
> > The code don't support to configure thread_count, so I think you'll
> > get the same result without AV_CODEC_CAP_AUTO_THREADS.
> 
> > This was pointed out by Mark Thompson on patch V4.
> > It is a problem how comment can be well addressed and avoid to be
> pointed out again and again.
> 
> I got started based on V5 and V6 is my first submission. Thanks for showing
> me the information. I am looking into it.

It was also mentioned in svt-av1 patch 
https://patchwork.ffmpeg.org/patch/13912/:
* Expose threads setting since AV_CODEC_CAP_AUTO_THREADS declared
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v15 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-07-30 Thread Li, Zhong
> > +AVCodec ff_libsvt_hevc_encoder = {
> > +.name   = "libsvt_hevc",
> > +.long_name  = NULL_IF_CONFIG_SMALL("SVT-HEVC(Scalable
> Video Technology for HEVC) encoder"),
> > +.priv_data_size = sizeof(SvtContext),
> > +.type   = AVMEDIA_TYPE_VIDEO,
> > +.id = AV_CODEC_ID_HEVC,
> > +.init   = eb_enc_init,
> > +.encode2= eb_encode_frame,
> > +.close  = eb_enc_close,
> > +.capabilities   = AV_CODEC_CAP_DELAY |
> AV_CODEC_CAP_AUTO_THREADS,
> 
> The code don't support to configure thread_count, so I think you'll get the
> same result without AV_CODEC_CAP_AUTO_THREADS.

This was pointed out by Mark Thompson on patch V4. 
It is a problem how comment can be well addressed and avoid to be pointed out 
again and again. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: fix the memory leak

2019-07-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Friday, July 26, 2019 4:00 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] lavu/hwcontext_qsv: fix the memory leak
> 
> av_dict_free child_device_opts to fix the memory leak.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/hwcontext_qsv.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> 59e4ed9157..0329a81ec3 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -1240,6 +1240,8 @@ static int qsv_device_create(AVHWDeviceContext
> *ctx, const char *device,
> 
>  ret = av_hwdevice_ctx_create(>child_device_ctx,
> child_device_type,
>   e ? e->value : NULL,
> child_device_opts, 0);
> +
> +av_dict_free(_device_opts);
>  if (ret < 0)
>  return ret;
> 
> --
> 2.17.1

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

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

Re: [FFmpeg-devel] [PATCH V2] fate: add a case for ticket #3229

2019-07-29 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Tuesday, July 30, 2019 4:28 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH V2] fate: add a case for ticket #3229
> 
> On Mon, Jul 29, 2019 at 06:20:39PM +0800, Zhong Li wrote:
> > Signed-off-by: Zhong Li 
> > ---
> > https://patchwork.ffmpeg.org/patch/13725/ introduces a regression but
> not found by fate, so add it.
> > Test clip produced by:
> > ffmpeg -i tickets/3229/bad.avi -vframes 6 -c:v copy
> > /fate-suite/mjpeg/mjpeg_field_order.avi
> >
> >  tests/fate/video.mak|  3 +++
> >  tests/ref/fate/mjpeg-ticket3229 | 11 +++
> >  2 files changed, 14 insertions(+)
> >  create mode 100644 tests/ref/fate/mjpeg-ticket3229
> 
> LGTM & passed on mingw32/64 arm/mips qemu and linux32
> 
> thx

Thanks for review and testing. 
May I search your help to produce/upload the clip to fate server and then apply 
this patch? 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] fate: add a case for ticket #3229

2019-07-29 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Monday, July 15, 2019 2:56 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH] fate: add a case for ticket #3229
> 
> On Sun, Jul 14, 2019 at 06:16:19PM +0800, Zhong Li wrote:
> > Signed-off-by: Zhong Li 
> > ---
> > https://patchwork.ffmpeg.org/patch/13725/ introduces a regression but
> not found by fate, so add it.
> > Test clip produced by:
> > ffmpeg -i tickets/3229/bad.avi -vframes 20 -c:v copy
> > /fate-suite/mjpeg/mjpeg_field_order.avi
> 
> do we need 20 frames for this ?
> the file is over 4mb large, which is why i ask
> 
> thx

Good point, Michael.
A new version cut to 6 frames has been sent.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for QSV transpose filter

2019-07-14 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Thursday, July 11, 2019 1:58 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for QSV
> transpose filter
> 
> Add transpose support for qsv_vpp with rotate and hflip:
> - rotate: [0, 3] support clockwise rotation of 0, 90, 180, 270;
> - hflip:  [0, 1] support horizontal flip;
> 
> Configure with:
> {"cclock_hflip","clock","cclock","clock_hflip","reversal","hflip","vflip"}
> 
> Limitation:
> If pipeline contains resize, mirroring and other, VPP skips other filters 
> in
> MSDK when IOPattern equals d3d->d3d. So "cclock_hflip, clock_hflip, vflip"
> will not work in d3d->d3d condition.
> 
> This pr is fixing this:
> https://github.com/Intel-Media-SDK/MediaSDK/pull/1491
> 
> CMD:
> ffmpeg -hwaccel qsv -c:v h264_qsv -i input.h264
> -vf 'format=qsv,vpp_qsv=transpose=clock' -c:v h264_qsv output.h264

Tested:
ffmpeg -hwaccel qsv -c:v h264_qsv -i ~/bbb_sunflower_1080p_30fps_normal.mp4 
-vframes 100 -vf 'format=qsv,vpp_qsv=transpose=cclock_hflip' -c:v h264_qsv 
ch.mp4
Both Skylake and KBL failed:

[Parsed_vpp_qsv_1 @ 0x5581aaf16080] Failed to create a qsvvpp, ret = -15.
[Parsed_vpp_qsv_1 @ 0x5581aaf16080] Failed to configure output pad on 
Parsed_vpp_qsv_1
Error reinitializing filters!
Failed to inject frame into filter network: Block device required
Error while processing the decoded data for stream #0:0

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

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

Re: [FFmpeg-devel] [PATCH v3 2/3] lavc/libdavs2.c: change decoder info level

2019-07-13 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of hwrenx
> Sent: Friday, July 12, 2019 11:22 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v3 2/3] lavc/libdavs2.c: change decoder info
> level
> 
> Signed-off-by: hwrenx 
> ---
>  libavcodec/libdavs2.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/libdavs2.c b/libavcodec/libdavs2.c index
> 218f3ec..1b274a3 100644
> --- a/libavcodec/libdavs2.c
> +++ b/libavcodec/libdavs2.c
> @@ -44,7 +44,9 @@ static av_cold int davs2_init(AVCodecContext *avctx)
> 
>  /* init the decoder */
>  cad->param.threads  = avctx->thread_count;
> -cad->param.info_level   = 0;
> +cad->param.info_level   = av_log_get_level() > AV_LOG_INFO
> + ?
> DAVS2_LOG_DEBUG
> + :
> DAVS2_LOG_WARNING;

How about exactly map AV_LOG_XXX to DAVS2_LOG_XXX?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] lavc: Add libsvt-av1 encoder wrapper

2019-07-12 Thread Li, Zhong
> You (or anyone) are welcome to contribute to the SVT-AV1 project, and
> submit the FFmpeg plugin changes you'd like to make here:
> https://github.com/OpenVisualCloud/SVT-AV1/tree/master/ffmpeg_plugin,
> and we will take your commits seriously. But I have not got any code
> changes made by you in our project GitHub and it seems you haven't made
> any contribution to the project yet.

I prefer to contribute on FFmpeg mainline instead of a forked branch. However, 
once get aligned in the community, of course I can contribute to the branch as 
well.
(Many SVT core library and API patches hold on my hand will also be sent out 
after my leave of next 2~3 weeks)

And let me provide more detail about the purposes:
1. SVT encoders (01.org/svt ) show very impressive performance benefit and get 
much attention . 
  Let's collect some feedback as early as possible, this patch is not call for 
merge bug call for feedback, comments. Not only collect feedback of SVT FFmpeg 
wrapper, but also feedback of SVT core libraries and APIs.

  e.g : SVT-AV1 reused libaom. If you enable both libsvt-av1 and libaom as 
static link, then will have name conflict. 
  Such issue is not easily found if you keep wrapper patch on 
https://github.com/OpenVisualCloud/SVT-AV1/tree/master/ffmpeg_plugin ,
  But will easily found if works on FFmpeg mainline. 

2. Many review comments from community (including mine) haven't been well 
addressed in SVT-HEVC wrapper patch. 
  This patch is just to address them, probably it can be a reference of 
SVT-HEVC wrapper too. 

3. As mentioned in the patch annotation, this wrapper patch is a response of 
ticket #7914, though it is not quite mature.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter to disable/enable auto scale

2019-07-12 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Friday, July 12, 2019 9:19 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter to
> disable/enable auto scale
> 
> Currently, ffmpeg inserts scale filter in the filter graph to force the whole
> decoded stream to scale into the same size with the first frame. It's not 
> quite
> make sense in resolution changing cases if user wants the rawvideo without
> any scale.
> 
> Option -reinit_filter 0 could be used to realize similar function, but it 
> fails
> when ifilter has hw_frame_ctx.
> 
> Add auto_scale flag set by -reinit_filter to indicate whether auto inserting
> the scale filter in the filter graph.
> 
> Signed-off-by: Linjie Fu 
> ---
> Request for comments.
> As we have discussed in the rawdump filter patch, here is a simpler solution
> based on -reinit_filter, and reuse this option.(maybe it's not easy to be
> accepted to add a separate option)
> 
>  fftools/ffmpeg.c| 2 +-
>  fftools/ffmpeg.h| 1 +
>  fftools/ffmpeg_filter.c | 2 +-
>  3 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index
> 01f04103cf..5305b87bd4 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -2133,6 +2133,7 @@ static int ifilter_send_frame(InputFilter *ifilter,
> AVFrame *frame)
> 
>  /* determine if the parameters for this input changed */
>  need_reinit = ifilter->format != frame->format;
> +fg->auto_scale = ifilter->ist->reinit_filters;
> 
>  switch (ifilter->ist->st->codecpar->codec_type) {
>  case AVMEDIA_TYPE_AUDIO:
> @@ -2145,7 +2146,6 @@ static int ifilter_send_frame(InputFilter *ifilter,
> AVFrame *frame)
> ifilter->height != frame->height;
>  break;
>  }
> -
>  if (!ifilter->ist->reinit_filters && fg->graph)
>  need_reinit = 0;
> 
> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index
> 7b6f802082..0c289b439f 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -285,6 +285,7 @@ typedef struct FilterGraph {
> 
>  AVFilterGraph *graph;
>  int reconfiguration;
> +int auto_scale;
> 
>  InputFilter   **inputs;
>  int  nb_inputs;
> diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index
> 72838de1e2..856ba48de7 100644
> --- a/fftools/ffmpeg_filter.c
> +++ b/fftools/ffmpeg_filter.c
> @@ -469,7 +469,7 @@ static int configure_output_video_filter(FilterGraph
> *fg, OutputFilter *ofilter,
>  if (ret < 0)
>  return ret;
> 
> -if (ofilter->width || ofilter->height) {
> +if ((ofilter->width || ofilter->height) && fg->auto_scale) {
>  char args[255];
>  AVFilterContext *filter;
>  AVDictionaryEntry *e = NULL;
> --
> 2.17.1

Is there any big difference with https://patchwork.ffmpeg.org/patch/8173/, 
especially for the purpose of disabling scaling for HWACCEL? 

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

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

Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter to disable/enable auto scale

2019-07-11 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Fu, Linjie
> Sent: Friday, July 12, 2019 1:36 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use -reinit_filter
> to disable/enable auto scale
> 
> > -Original Message-
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of myp...@gmail.com
> > Sent: Friday, July 12, 2019 13:28
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Cc: Fu, Linjie 
> > Subject: Re: [FFmpeg-devel] [PATCH] fftools/ffmpeg_filter: use
> > -reinit_filter to disable/enable auto scale
> >
> > On Fri, Jul 12, 2019 at 1:19 PM Linjie Fu  wrote:
> > >
> > > Currently, ffmpeg inserts scale filter in the filter graph to force
> > > the whole decoded stream to scale into the same size with the first
> > > frame. It's not quite make sense in resolution changing cases if
> > > user wants the rawvideo without any scale.
> > >
> > > Option -reinit_filter 0 could be used to realize similar function,
> > > but it fails when ifilter has hw_frame_ctx.
> > >
> > > Add auto_scale flag set by -reinit_filter to indicate whether auto
> > > inserting the scale filter in the filter graph.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > > Request for comments.
> > > As we have discussed in the rawdump filter patch, here is a simpler
> > > solution based on -reinit_filter, and reuse this option.(maybe it's
> > > not easy to be accepted to add a separate option)
> > >
> > >  fftools/ffmpeg.c| 2 +-
> > >  fftools/ffmpeg.h| 1 +
> > >  fftools/ffmpeg_filter.c | 2 +-
> > >  3 files changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index
> > > 01f04103cf..5305b87bd4 100644
> > > --- a/fftools/ffmpeg.c
> > > +++ b/fftools/ffmpeg.c
> > > @@ -2133,6 +2133,7 @@ static int ifilter_send_frame(InputFilter
> > > *ifilter,
> > AVFrame *frame)
> > >
> > >  /* determine if the parameters for this input changed */
> > >  need_reinit = ifilter->format != frame->format;
> > > +fg->auto_scale = ifilter->ist->reinit_filters;
> > >
> > >  switch (ifilter->ist->st->codecpar->codec_type) {
> > >  case AVMEDIA_TYPE_AUDIO:
> > > @@ -2145,7 +2146,6 @@ static int ifilter_send_frame(InputFilter
> > > *ifilter,
> > AVFrame *frame)
> > > ifilter->height != frame->height;
> > >  break;
> > >  }
> > > -
> > Unrelated change
> 
> Yep, this should be recalled.
> 
> > >
> > Add an option to disable/enable "auto insert" is Ok for me, but I
> > think if you reuse the -reinit_filter option, you need to update doc
> > part at the same time.
> 
> I prefer to add a separate option, too.
> Depending on the comments, I'll either update doc for reinit_filter, or add a
> new option and related doc.

Since there is an existed option named "autorotate", add an new option 
"autoscale" looks can keep tune. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for QSV transpose filter

2019-07-11 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Thursday, July 11, 2019 1:58 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v3] lavf/vf_vpp_qsv: add support for QSV
> transpose filter
> 
> Add transpose support for qsv_vpp with rotate and hflip:
> - rotate: [0, 3] support clockwise rotation of 0, 90, 180, 270;
> - hflip:  [0, 1] support horizontal flip;
> 
> Configure with:
> {"cclock_hflip","clock","cclock","clock_hflip","reversal","hflip","vflip"}
> 
> Limitation:
> If pipeline contains resize, mirroring and other, VPP skips other filters 
> in
> MSDK when IOPattern equals d3d->d3d. So "cclock_hflip, clock_hflip, vflip"
> will not work in d3d->d3d condition.
> 
> This pr is fixing this:
> https://github.com/Intel-Media-SDK/MediaSDK/pull/1491
> 
> CMD:
> ffmpeg -hwaccel qsv -c:v h264_qsv -i input.h264
> -vf 'format=qsv,vpp_qsv=transpose=clock' -c:v h264_qsv output.h264
> 
> ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv -i
> input.h264
> -vf
> 'hwupload=extra_hw_frames=64,format=qsv,vpp_qsv=transpose=cclock_hfli
> p'
> -f rawvideo -pix_fmt nv12 ./transpose.yuv
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavfilter/vf_vpp_qsv.c | 101
> ++-
>  1 file changed, 99 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index
> dd05e8baff..01ff42a677 100644
> --- a/libavfilter/vf_vpp_qsv.c
> +++ b/libavfilter/vf_vpp_qsv.c
> @@ -36,12 +36,15 @@
>  #include "libavformat/avformat.h"
> 
>  #include "qsvvpp.h"
> +#include "transpose.h"
> 
>  #define OFFSET(x) offsetof(VPPContext, x)  #define FLAGS
> (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
> 
>  /* number of video enhancement filters */ -#define ENH_FILTERS_COUNT
> (5)
> +#define ENH_FILTERS_COUNT (7)
> +#define QSV_HAVE_ROTATION  QSV_VERSION_ATLEAST(1, 17) #define
> +QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19)
> 
>  typedef struct VPPContext{
>  const AVClass *class;
> @@ -54,6 +57,8 @@ typedef struct VPPContext{
>  mfxExtVPPDenoise denoise_conf;
>  mfxExtVPPDetail detail_conf;
>  mfxExtVPPProcAmp procamp_conf;
> +mfxExtVPPRotation rotation_conf;
> +mfxExtVPPMirroring mirroring_conf;
> 
>  int out_width;
>  int out_height;
> @@ -70,6 +75,10 @@ typedef struct VPPContext{
>  int crop_x;
>  int crop_y;
> 
> +int transpose;
> +int rotate; /* rotate angle : [0, 90, 180, 270] */
> +int hflip;  /* flip mode : 0 = off, 1 = HORIZONTAL
> flip */
> +
>  /* param for the procamp */
>  intprocamp;/* enable procamp */
>  float  hue;
> @@ -95,6 +104,15 @@ static const AVOption options[] = {
>  { "contrast","ProcAmp contrast",
> OFFSET(contrast),AV_OPT_TYPE_FLOAT,{ .dbl = 1.0 }, 0.0,
> 10.0, .flags = FLAGS},
>  { "brightness",  "ProcAmp brightness",
> OFFSET(brightness),  AV_OPT_TYPE_FLOAT,{ .dbl = 0.0 }, -100.0,
> 100.0, .flags = FLAGS},
> 
> +{ "transpose",  "set transpose direction",   OFFSET(transpose),
> AV_OPT_TYPE_INT,  { .i64 = -1 }, -1, 6, FLAGS, "transpose"},
> +{ "cclock_hflip",  "rotate counter-clockwise with horizontal flip",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = "transpose" },
> +{ "clock", "rotate clockwise",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_CLOCK   }, .flags=FLAGS, .unit = "transpose" },
> +{ "cclock","rotate counter-clockwise",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_CCLOCK  }, .flags=FLAGS, .unit = "transpose" },
> +{ "clock_hflip",   "rotate clockwise with horizontal flip",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_CLOCK_FLIP  }, .flags=FLAGS, .unit = "transpose" },
> +{ "reversal",  "rotate by half-turn",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_REVERSAL}, .flags=FLAGS, .unit = "transpose" },
> +{ "hflip", "flip horizontally",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_HFLIP   }, .flags=FLAGS, .unit = "transpose" },
> +{ "vflip", "flip vertically",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_VFLIP   }, .flags=FLAGS, .unit = "transpose" },
> +
>  { "cw",   "set the width crop area expression",   OFFSET(cw),
> AV_OPT_TYPE_STRING, { .str = "iw" }, CHAR_MIN, CHAR_MAX, FLAGS },
>  { "ch",   "set the height crop area expression",  OFFSET(ch),
> AV_OPT_TYPE_STRING, { .str = "ih" }, CHAR_MIN, CHAR_MAX, FLAGS },
>  { "cx",   "set the x crop area expression",   OFFSET(cx),
> AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, CHAR_MIN, CHAR_MAX,
> FLAGS },
> @@ -322,8 +340,87 @@ static int config_output(AVFilterLink *outlink)
>  param.ext_buf[param.num_ext_buf++] =
> (mfxExtBuffer*)>procamp_conf;
>  }
> 
> +if (vpp->transpose >= 0) {
> +#ifdef QSV_HAVE_ROTATION
> +

Re: [FFmpeg-devel] [PATCH 2/2] lavf/vf_vpp_qsv: add support for QSV transpose filter

2019-07-07 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Tuesday, June 18, 2019 10:53 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH 2/2] lavf/vf_vpp_qsv: add support for QSV
> transpose filter
> 
> Add transpose support for qsv_vpp with rotate and hflip:
> - rotate: [0, 3] support clockwise rotation of 0, 90, 180, 270;
> - hflip:  [0, 1] support horizontal flip;
> 
> Configure with:
> {"cclock_hflip","clock","cclock","clock_hflip","reversal","hflip","vflip"}
> 
> Limitation:
> If pipeline contains resize, mirroring and other, VPP skips other filters 
> in
> MSDK when IOPattern equals d3d->d3d. So "cclock_hflip, clock_hflip, vflip"
> will not work in d3d->d3d condition.

How user can aware this if not check the log message? And any MSDK github issue 
created?

> CMD:
> ffmpeg -hwaccel qsv -c:v h264_qsv -i input.h264
> -vf 'format=qsv,vpp_qsv=transpose=clock' -c:v h264_qsv output.h264
> 
> ffmpeg -init_hw_device qsv=foo -filter_hw_device foo -f rawvideo
> -pix_fmt nv12 -s:v 1920x1080 -i input.nv12 -vf
> 
> 'hwupload=extra_hw_frames=64,format=qsv,vpp_qsv=transpose=cclock_hfli
> p'
> -f rawvideo -pix_fmt nv12 -y ./transpose.yuv

What is the platform tested? Probably adding MFXVideoVPP_Query() to runtime 
capability checking is a good idea. 

> Signed-off-by: Linjie Fu 
> ---
>  libavfilter/vf_vpp_qsv.c | 95
> +++-
>  1 file changed, 93 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c index
> dd05e8baff..974fc7a255 100644
> --- a/libavfilter/vf_vpp_qsv.c
> +++ b/libavfilter/vf_vpp_qsv.c
> @@ -36,12 +36,15 @@
>  #include "libavformat/avformat.h"
> 
>  #include "qsvvpp.h"
> +#include "transpose.h"
> 
>  #define OFFSET(x) offsetof(VPPContext, x)  #define FLAGS
> (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
> 
>  /* number of video enhancement filters */ -#define ENH_FILTERS_COUNT
> (5)
> +#define ENH_FILTERS_COUNT (7)
> +#define QSV_HAVE_ROTATION  QSV_VERSION_ATLEAST(1, 17) #define
> +QSV_HAVE_MIRRORING QSV_VERSION_ATLEAST(1, 19)
> 
>  typedef struct VPPContext{
>  const AVClass *class;
> @@ -54,6 +57,8 @@ typedef struct VPPContext{
>  mfxExtVPPDenoise denoise_conf;
>  mfxExtVPPDetail detail_conf;
>  mfxExtVPPProcAmp procamp_conf;
> +mfxExtVPPRotation rotation_conf;
> +mfxExtVPPMirroring mirroring_conf;
> 
>  int out_width;
>  int out_height;
> @@ -70,6 +75,10 @@ typedef struct VPPContext{
>  int crop_x;
>  int crop_y;
> 
> +int transpose;
> +int rotate; /* rotate angle : [0, 90, 180, 270] */
> +int hflip;  /* flip mode : 0 = off, 1 = HORIZONTAL
> flip */
> +
>  /* param for the procamp */
>  intprocamp;/* enable procamp */
>  float  hue;
> @@ -95,6 +104,15 @@ static const AVOption options[] = {
>  { "contrast","ProcAmp contrast",
> OFFSET(contrast),AV_OPT_TYPE_FLOAT,{ .dbl = 1.0 }, 0.0,
> 10.0, .flags = FLAGS},
>  { "brightness",  "ProcAmp brightness",
> OFFSET(brightness),  AV_OPT_TYPE_FLOAT,{ .dbl = 0.0 }, -100.0,
> 100.0, .flags = FLAGS},
> 
> +{ "transpose",  "set transpose direction",   OFFSET(transpose),
> AV_OPT_TYPE_INT,  { .i64 = -1 }, -1, 6, FLAGS, "transpose"},
> +{ "cclock_hflip",  "rotate counter-clockwise with horizontal flip",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = "transpose" },
> +{ "clock", "rotate clockwise",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_CLOCK   }, .flags=FLAGS, .unit = "transpose" },
> +{ "cclock","rotate counter-clockwise",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_CCLOCK  }, .flags=FLAGS, .unit = "transpose" },
> +{ "clock_hflip",   "rotate clockwise with horizontal flip",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_CLOCK_FLIP  }, .flags=FLAGS, .unit = "transpose" },
> +{ "reversal",  "rotate by half-turn",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_REVERSAL}, .flags=FLAGS, .unit = "transpose" },
> +{ "hflip", "flip horizontally",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_HFLIP   }, .flags=FLAGS, .unit = "transpose" },
> +{ "vflip", "flip vertically",
> 0, AV_OPT_TYPE_CONST, { .i64 =
> TRANSPOSE_VFLIP   }, .flags=FLAGS, .unit = "transpose" },
> +
>  { "cw",   "set the width crop area expression",   OFFSET(cw),
> AV_OPT_TYPE_STRING, { .str = "iw" }, CHAR_MIN, CHAR_MAX, FLAGS },
>  { "ch",   "set the height crop area expression",  OFFSET(ch),
> AV_OPT_TYPE_STRING, { .str = "ih" }, CHAR_MIN, CHAR_MAX, FLAGS },
>  { "cx",   "set the x crop area expression",   OFFSET(cx),
> AV_OPT_TYPE_STRING, { .str = "(in_w-out_w)/2" }, CHAR_MIN, CHAR_MAX,
> FLAGS },
> @@ -322,8 +340,81 @@ static int config_output(AVFilterLink *outlink)
>  

Re: [FFmpeg-devel] [PATCH 2/2] lavc/mjpegdec: make code aligned

2019-06-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Friday, June 28, 2019 8:55 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 2/2] lavc/mjpegdec: make code aligned
> 
> On Thu, Jun 27, 2019 at 04:58:24PM +0800, Zhong Li wrote:
> > Signed-off-by: Zhong Li 
> > ---
> >  libavcodec/mjpegdec.c | 450
> +-
> >  1 file changed, 225 insertions(+), 225 deletions(-)
> 
> LGTM
> 
> thx

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

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

Re: [FFmpeg-devel] [PATCH 1/3] lavc/mjpegdec: add function ff_mjpeg_decode_header

2019-06-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Friday, June 28, 2019 8:52 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavc/mjpegdec: add function
> ff_mjpeg_decode_header
> 
> On Thu, Jun 27, 2019 at 08:59:12PM +0800, Zhong Li wrote:
> > It will be reused in the following mjpeg_parser patch
> >
> > Signed-off-by: Zhong Li 
> > ---
> > Mark Thompson: This seems suspicious - MJPEG is generally 4:2:2 (e.g.
> > UVC requires it), so I would expect a 4:2:2 format to be the default
> > here?  (Or maybe a longer list - VAAPI certainly supports 4:2:2, 4:2:0
> > and 4:4:4 on the same hardware.)
> > Zhong: libmfx can support jpeg baseline profile with more output formats,
> but current ffmpeg-qsv decoder/vpp can't. Will extend supported format list
> as separated patch.
> >
> >  libavcodec/mjpegdec.c | 37 -
> >  libavcodec/mjpegdec.h |  4 
> >  2 files changed, 32 insertions(+), 9 deletions(-)
> >
> > diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c index
> > a65bc8d..5da66bb 100644
> > --- a/libavcodec/mjpegdec.c
> > +++ b/libavcodec/mjpegdec.c
> > @@ -157,6 +157,8 @@ av_cold int
> ff_mjpeg_decode_init(AVCodecContext *avctx)
> >  s->start_code= -1;
> >  s->first_picture = 1;
> >  s->got_picture   = 0;
> > +s->reinit_idct   = 0;
> > +s->size_change   = 0;
> >  s->org_height= avctx->coded_height;
> >  avctx->chroma_sample_location = AVCHROMA_LOC_CENTER;
> >  avctx->colorspace = AVCOL_SPC_BT470BG; @@ -302,9 +304,9 @@
> int
> > ff_mjpeg_decode_dht(MJpegDecodeContext *s)
> >  return 0;
> >  }
> >
> > -int ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> > +int ff_mjpeg_decode_header(MJpegDecodeContext *s)
> >  {
> > -int len, nb_components, i, width, height, bits, ret, size_change;
> > +int len, nb_components, i, width, height, bits, ret;
> >  unsigned pix_fmt_id;
> >  int h_count[MAX_COMPONENTS] = { 0 };
> >  int v_count[MAX_COMPONENTS] = { 0 }; @@ -324,7 +326,7 @@ int
> > ff_mjpeg_decode_sof(MJpegDecodeContext *s)
> >  if (s->avctx->bits_per_raw_sample != bits) {
> >  av_log(s->avctx, s->avctx->bits_per_raw_sample > 0 ?
> AV_LOG_INFO : AV_LOG_DEBUG, "Changing bps from %d to %d\n",
> s->avctx->bits_per_raw_sample, bits);
> >  s->avctx->bits_per_raw_sample = bits;
> > -init_idct(s->avctx);
> > +s->reinit_idct = 1;
> >  }
> 
> I think the avctx->bits_per_raw_sample value should stay in sync with the
> initialized idct
> 
> This patch would allow the bits_per_raw_sample to change and then a
> subsequent error to skip init_idct() maybe this is ok as it would be probably
> called later in a subsequent frame but i think its better if they stay closer
> together or there is nothing between them that can cause ine to exeucute
> without the other

Thanks for detail comment, actually this is an intended way to resolve a 
dependency:
Calling init_idct requires the decoder has been initialized. 

static void init_idct(AVCodecContext *avctx)
{
MJpegDecodeContext *s = avctx->priv_data; 
...
}

But I hope ff_mjpeg_decode_header can be used for mjpeg_parser, if don't use 
current way, will cause segment fault when call init_idct() due to 
avctx->priv_data is NULL.

Probably we can change the definition of init_idct(AVCodecContext *avctx) to be 
init_idct(MJpegDecodeContext *s) ? (But init_idct is useless for parser). 


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

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

Re: [FFmpeg-devel] [PATCH 2/3] lavc/mjpeg_parser: use ff_mjpeg_decode_header to parse frame info

2019-06-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of James Almer
> Sent: Saturday, June 29, 2019 12:56 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 2/3] lavc/mjpeg_parser: use
> ff_mjpeg_decode_header to parse frame info
> 
> On 6/27/2019 9:59 AM, Zhong Li wrote:
> > Signed-off-by: Zhong Li 
> > ---
> >  libavcodec/mjpeg_parser.c | 158
> > +-
> >  1 file changed, 157 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/mjpeg_parser.c b/libavcodec/mjpeg_parser.c
> > index 07a6b2b..f59aa3e 100644
> > --- a/libavcodec/mjpeg_parser.c
> > +++ b/libavcodec/mjpeg_parser.c
> > @@ -27,12 +27,131 @@
> >   */
> >
> >  #include "parser.h"
> > +#include "mjpeg.h"
> > +#include "mjpegdec.h"
> > +#include "get_bits.h"
> >
> >  typedef struct MJPEGParserContext{
> >  ParseContext pc;
> > +MJpegDecodeContext dec_ctx;
> 
> This is not acceptable. The parser shouldn't use decoder structs, as it makes
> the former depend on the latter.
> 
> A reusable header parsing function should be standalone, so it may be called
> from decoders, parsers, bitstream filters, and anything that may require it.

Thanks for your comment, James.
This is not the first time to introduce decoder dependency, please see 
mpeg4video_parser.c
And IMHO no matter what is the form you parse a header, actually it is a part 
of decoding process. 
Refusing to reuse decoder context or function will introduce huge code 
duplication and bring trouble to maintain later.

Probably set up a middle layer just like h264_ps.c for both decoder and parser 
to use is a better idea?
(But a tricky thing is that mjpeg header parser is a litter more complex h264, 
pix_fmt and color_range is not just desided by frame header makers, but also 
comment makers:
See:
case 0x1100:
if (s->rgb)
s->avctx->pix_fmt = s->bits <= 9 ? AV_PIX_FMT_BGR24 : 
AV_PIX_FMT_BGR48;
else {
if (   s->adobe_transform == 0
|| s->component_id[0] == 'R' - 1 && s->component_id[1] == 
'G' - 1 && s->component_id[2] == 'B' - 1) {
s->avctx->pix_fmt = s->bits <= 8 ? AV_PIX_FMT_GBRP : 
AV_PIX_FMT_GBRP16;
} else {
if (s->bits <= 8) s->avctx->pix_fmt = s->cs_itu601 ? 
AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P;
else  s->avctx->pix_fmt = AV_PIX_FMT_YUV444P16;
s->avctx->color_range = s->cs_itu601 ? AVCOL_RANGE_MPEG : 
AVCOL_RANGE_JPEG;
}
}

Here cs_itu601 is parsed from comment makers. 
)

Any suggestion/comment is welcome. 



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

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

Re: [FFmpeg-devel] [PATCH 1/3] lavc/mjpegdec: add function ff_mjpeg_decode_header

2019-06-30 Thread Li, Zhong
>Sorry for not realizing this earlier (I searched for "SOF0"):
>Why is this function duplicated?
>
>Carl Eugen

Hi Carl:
  You can find the difference: here I just find frame header markers (SOF0 ~ 
SOF 3), mjpeg decoder try to find all markers.
Thanks
Zhong

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

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

Re: [FFmpeg-devel] [PATCH 2/3] lavc/mjpeg_parser: use ff_mjpeg_decode_header to parse frame info

2019-06-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Michael Niedermayer
> Sent: Friday, June 28, 2019 4:12 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 2/3] lavc/mjpeg_parser: use
> ff_mjpeg_decode_header to parse frame info
> 
> On Thu, Jun 27, 2019 at 08:59:13PM +0800, Zhong Li wrote:
> > Signed-off-by: Zhong Li 
> > ---
> >  libavcodec/mjpeg_parser.c | 158
> > +-
> >  1 file changed, 157 insertions(+), 1 deletion(-)
> 
> this breaks mjpeg decoding
> 
> for example tickets/3229/bad.avi
> https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket3229/

Ok, will fix and update.
(Probably adding this case to fate is a good idea?)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 4/5] lavc/qsvdec: add ChromaFormat support for YUV422/YUV444

2019-06-27 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Hendrik Leppkes
> Sent: Friday, June 28, 2019 9:09 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 4/5] lavc/qsvdec: add ChromaFormat
> support for YUV422/YUV444
> 
> On Thu, Jun 27, 2019 at 4:31 PM Linjie Fu  wrote:
> >
> > Currently, ChromaFormat passed to libmfx is set to YUV42O by default.
> >
> > Modify to choose ChromaFormat according to fourCC.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/qsvdec.c | 20 +++-
> >  1 file changed, 19 insertions(+), 1 deletion(-)
> >
> > diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> > 46aa2d6..7650325 100644
> > --- a/libavcodec/qsvdec.c
> > +++ b/libavcodec/qsvdec.c
> > @@ -40,6 +40,7 @@
> >  #include "qsv.h"
> >  #include "qsv_internal.h"
> >  #include "qsvdec.h"
> > +#include 
> >
> >  const AVCodecHWConfigInternal *ff_qsv_hw_configs[] = {
> >  &(const AVCodecHWConfigInternal) { @@ -211,7 +212,24 @@
> static
> > int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)
> >  param.mfx.FrameInfo.FourCC = q->fourcc;
> >  param.mfx.FrameInfo.Width  = frame_width;
> >  param.mfx.FrameInfo.Height = frame_height;
> > -param.mfx.FrameInfo.ChromaFormat   =
> MFX_CHROMAFORMAT_YUV420;
> > +
> > +switch (q->fourcc) {
> > +case VA_FOURCC_YUY2:
> > +#ifdef VA_FOURCC_Y210
> > +case VA_FOURCC_Y210:
> > +#endif
> > +param.mfx.FrameInfo.ChromaFormat   =
> MFX_CHROMAFORMAT_YUV422;
> > +break;
> > +case VA_FOURCC_AYUV:
> > +#ifdef VA_FOURCC_Y410
> > +case VA_FOURCC_Y410:
> > +#endif
> > +param.mfx.FrameInfo.ChromaFormat   =
> MFX_CHROMAFORMAT_YUV444;
> > +break;
> > +default:
> > +param.mfx.FrameInfo.ChromaFormat   =
> MFX_CHROMAFORMAT_YUV420;
> > +break;
> > +}
> >
> >  switch (avctx->field_order) {
> >  case AV_FIELD_PROGRESSIVE:
> 
> VA_FOURCC_ sounds like VAAPI, that doesn't seem like it belongs in qsv code
> which is supposed to work on multiple platforms.
> 
> - Hendrik

Good point, shouldn't use any VAAPI definition if without checking Linux 
platform or CONFIG_VAAPI.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/3] lavc/mjpegdec: add function ff_mjpeg_decode_header

2019-06-27 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Carl Eugen Hoyos
> Sent: Friday, June 28, 2019 2:56 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavc/mjpegdec: add function
> ff_mjpeg_decode_header
> 
> Am Do., 27. Juni 2019 um 14:59 Uhr schrieb Zhong Li :
> 
> > -if (s->avctx->pix_fmt == s->hwaccel_sw_pix_fmt
> && !size_change) {
> > +if (!(s->got_picture && s->interlaced && (s->bottom_field
> == !s->interlace_polarity))) {
> > +if (s->avctx->pix_fmt == s->hwaccel_sw_pix_fmt &&
> > + !s->size_change) {
> 
> Is this an (unrelated) bug fix or only vaapi-related?
> I wonder if it should be in this patch for both cases.

Hi Carl:
  This is not to fix any issue, just a tailing after refact with 
ff_mjpeg_decode_header():

Original code: 
if (s->got_picture && s->interlaced && (s->bottom_field == 
!s->interlace_polarity)) {
if (s->progressive) {
avpriv_request_sample(s->avctx, "progressively coded interlaced 
picture");
return AVERROR_INVALIDDATA;
}
} else {
  ... 

if (s->avctx->pix_fmt == s->hwaccel_sw_pix_fmt && !size_change) {
s->avctx->pix_fmt = s->hwaccel_pix_fmt;
} else {
enum AVPixelFormat pix_fmts[] = {
#if CONFIG_MJPEG_NVDEC_HWACCEL
AV_PIX_FMT_CUDA,
#endif
#if CONFIG_MJPEG_VAAPI_HWACCEL
AV_PIX_FMT_VAAPI,
#endif
s->avctx->pix_fmt,
AV_PIX_FMT_NONE,
};
s->hwaccel_pix_fmt = ff_get_format(s->avctx, pix_fmts);

 ...
   }

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

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

Re: [FFmpeg-devel] [PATCH 2/5] lavu/hwcontext_vaapi: add vaapi_format_map for Y210/AYUV/Y410

2019-06-27 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Friday, June 28, 2019 10:27 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH 2/5] lavu/hwcontext_vaapi: add
> vaapi_format_map for Y210/AYUV/Y410
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/hwcontext_vaapi.c | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index
> 4227c3c..6378d0e 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -116,6 +116,14 @@ static const VAAPIFormatDescriptor
> vaapi_format_map[] = {  #endif
>  MAP(UYVY, YUV422,  UYVY422, 0),
>  MAP(YUY2, YUV422,  YUYV422, 0),
> +#ifdef VA_FOURCC_Y210
> +MAP(Y210, YUV422_10,Y210LE, 0),
> +#endif
> +#define VA_RT_FORMAT_AYUV VA_FOURCC_AYUV

Probably you want to add "#ifdef VA_FOURCC_AYUV" too.
And would better to #undef VA_RT_FORMAT_AYUV here once map is done.
(If you want to get a longer life cycle, would better define it outside)

> +MAP(AYUV,   AYUV, AYUV, 0),
> +#ifdef VA_FOURCC_Y410
> +MAP(Y410, YUV444_10,Y410LE, 0),
> +#endif
>  MAP(411P, YUV411,  YUV411P, 0),
>  MAP(422V, YUV422,  YUV440P, 0),
>  MAP(444P, YUV444,  YUV444P, 0),
> --
> 2.7.4

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

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

Re: [FFmpeg-devel] [PATCH 3/3] avutil/hwcontext_vaapi: move kernel_driver into CONFIG_LIBDRM

2019-06-27 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Steven Liu
> Sent: Thursday, June 27, 2019 3:38 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Steven Liu 
> Subject: [FFmpeg-devel] [PATCH 3/3] avutil/hwcontext_vaapi: move
> kernel_driver into CONFIG_LIBDRM
> 
> Signed-off-by: Steven Liu 
> ---
>  libavutil/hwcontext_vaapi.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index
> 4227c3c090..cf117640f2 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -1514,10 +1514,12 @@ static int
> vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
>  break;
>  }
>  } else {
> -const AVDictionaryEntry *kernel_driver;
>  char path[64];
>  int n, max_devices = 8;
> +#if CONFIG_LIBDRM
> +const AVDictionaryEntry *kernel_driver;
>  kernel_driver = av_dict_get(opts, "kernel_driver", NULL, 0);
> +#endif
>  for (n = 0; n < max_devices; n++) {
>  snprintf(path, sizeof(path),
>   "/dev/dri/renderD%d", 128 + n);
> --
> 2.17.2 (Apple Git-113)

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

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

Re: [FFmpeg-devel] [PATCH 1/3] lavc/mjpegdec: add function ff_mjpeg_decode_header

2019-06-27 Thread Li, Zhong
> From: Li, Zhong
> Sent: Thursday, June 27, 2019 8:59 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Li, Zhong 
> Subject: [PATCH 1/3] lavc/mjpegdec: add function ff_mjpeg_decode_header
> 
> It will be reused in the following mjpeg_parser patch
> 
> Signed-off-by: Zhong Li 
> ---
> Mark Thompson: This seems suspicious - MJPEG is generally 4:2:2 (e.g. UVC
> requires it), so I would expect a 4:2:2 format to be the default here?  (Or
> maybe a longer list - VAAPI certainly supports 4:2:2, 4:2:0 and 4:4:4 on the
> same hardware.)
> Zhong: libmfx can support jpeg baseline profile with more output formats,
> but current ffmpeg-qsv decoder/vpp can't. Will extend supported format list
> as separated patch.

Sorry, this annotation should be part of patch 3/3. Please ignore here.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder support

2019-06-26 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of James Almer
> Sent: Wednesday, June 26, 2019 10:19 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder
> support
> 
> On 6/26/2019 3:00 AM, Li, Zhong wrote:
> >
> >
> >> -Original Message-
> >> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> >> Of Li, Zhong
> >> Sent: Tuesday, April 16, 2019 10:32 AM
> >> To: FFmpeg development discussions and patches
> >> 
> >> Subject: Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9
> >> decoder support
> >>
> >>> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> >> Behalf
> >>> Of Mark Thompson
> >>> Sent: Tuesday, April 2, 2019 7:40 AM
> >>> To: ffmpeg-devel@ffmpeg.org
> >>> Subject: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder
> >>> support
> >>>
> >>> From: Zhong Li 
> >>>
> >>> VP9 decoder is supported on Intel kabyLake+ platforms with MSDK
> >>> Version 1.19+
> >>>
> >>> Signed-off-by: Zhong Li 
> >>> ---
> >>> On 20/03/2019 14:41, Li, Zhong wrote:
> >>>> Yes, QSV is a marketing name which is no equal to libmfx/MSDK.
> >>>> But would be better to keep consistent with others, such as "Intel
> >>> QSV-accelerated VP8 video decoding" in pervious changelog?
> >>>
> >>> I don't think so?  VP9 decoding with the QSV hardware is already
> >>> supported, this only adds the additional option of using libmfx to
> >>> access the same thing as well.
> >>
> >> Ok, here are just some words description of changelog. I will be
> >> happy to see this patch can be applied.
> >> (As previous comment, the updated version of vp9 parser with pic_type
> >> of key frame issue fixing LGTM.)
> >
> > Ping?
> >
> > If nobody against, I will merge it with cbs vp9 parser patch during one
> week.
> 
> Please, don't push a patchset written by Mark without his approval. I
> reviewed a few other patches from this set and he will most likely submit a
> new version for all of them.

Thanks for your remind, James. Yes I saw your comment for av1, I thought the 
others should be ok but pending for a while. 
Anyway, will hold on and waiting for Mark's response.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder support

2019-06-26 Thread Li, Zhong


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Tuesday, April 16, 2019 10:32 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder
> support
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Mark Thompson
> > Sent: Tuesday, April 2, 2019 7:40 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder
> > support
> >
> > From: Zhong Li 
> >
> > VP9 decoder is supported on Intel kabyLake+ platforms with MSDK
> > Version 1.19+
> >
> > Signed-off-by: Zhong Li 
> > ---
> > On 20/03/2019 14:41, Li, Zhong wrote:
> > > Yes, QSV is a marketing name which is no equal to libmfx/MSDK.
> > > But would be better to keep consistent with others, such as "Intel
> > QSV-accelerated VP8 video decoding" in pervious changelog?
> >
> > I don't think so?  VP9 decoding with the QSV hardware is already
> > supported, this only adds the additional option of using libmfx to
> > access the same thing as well.
> 
> Ok, here are just some words description of changelog. I will be happy to see
> this patch can be applied.
> (As previous comment, the updated version of vp9 parser with pic_type of
> key frame issue fixing LGTM.)

Ping?

If nobody against, I will merge it with cbs vp9 parser patch during one week.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream properties

2019-06-25 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Friday, May 31, 2019 3:23 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream
> properties
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Li, Zhong
> > Sent: Sunday, April 28, 2019 6:24 PM
> > To: FFmpeg development discussions and patches
> > 
> > Subject: Re: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream
> > properties
> >
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > > Of Mark Thompson
> > > Sent: Tuesday, April 2, 2019 7:40 AM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Subject: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream
> > > properties
> > >
> > > Rewrites the parser entirely, using CBS for header parsing.
> > > ---
> > >  libavcodec/vp9_parser.c | 112
> > > +---
> > >  1 file changed, 82 insertions(+), 30 deletions(-)
> > >
> > > diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c index
> > > c957a75667..6bf4f30e80 100644
> > > --- a/libavcodec/vp9_parser.c
> > > +++ b/libavcodec/vp9_parser.c
> > > @@ -1,8 +1,5 @@
> > >  /*
> > > - * VP9 compatible video decoder
> > > - *
> > > - * Copyright (C) 2013 Ronald S. Bultje 
> > > - * Copyright (C) 2013 Clément Bœsch 
> > > + * VP9 parser
> > >   *
> > >   * This file is part of FFmpeg.
> > >   *
> > > @@ -21,50 +18,105 @@
> > >   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> > > 02110-1301 USA
> > >   */
> > >
> > > -#include "libavutil/intreadwrite.h"
> > > -#include "libavcodec/get_bits.h"
> > > +#include "libavutil/avassert.h"
> > > +#include "cbs.h"
> > > +#include "cbs_vp9.h"
> > >  #include "parser.h"
> > >
> > > -static int parse(AVCodecParserContext *ctx,
> > > - AVCodecContext *avctx,
> > > - const uint8_t **out_data, int *out_size,
> > > - const uint8_t *data, int size)
> > > +typedef struct VP9ParserContext {
> > > +CodedBitstreamContext *cbc;
> > > +VP9RawFrameHeader frame_header; } VP9ParserContext;
> > > +
> > > +static const enum AVPixelFormat vp9_pix_fmts[3][2][2] = {
> > > +{ // 8-bit.
> > > +{ AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P },
> > > +{ AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P },
> > > +},
> > > +{ // 10-bit.
> > > +{ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV440P10 },
> > > +{ AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10 },
> > > +},
> > > +{ // 12-bit.
> > > +{ AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV440P12 },
> > > +{ AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12 },
> > > +},
> > > +};
> > > +
> > > +static int vp9_parser_parse(AVCodecParserContext *ctx,
> > > +AVCodecContext *avctx,
> > > +const uint8_t **out_data, int
> > *out_size,
> > > +const uint8_t *data, int size)
> > >  {
> > > -GetBitContext gb;
> > > -int res, profile, keyframe;
> > > +VP9ParserContext *s = ctx->priv_data;
> > > +const CodedBitstreamVP9Context *vp9 = s->cbc->priv_data;
> > > +const VP9RawFrameHeader *fh;
> > > +int err;
> > >
> > >  *out_data = data;
> > >  *out_size = size;
> > >
> > > -if (!size || (res = init_get_bits8(, data, size)) < 0)
> > > -return size; // parsers can't return errors
> > > -get_bits(, 2); // frame marker
> > > -profile  = get_bits1();
> > > -profile |= get_bits1() << 1;
> > > -if (profile == 3) profile += get_bits1();
> > > -if (profile > 3)
> > > -return size;
> > > +ctx->key_frame = -1;
> > > +ctx->pict_type = AV_PICTURE_TYPE_NONE;
> > > +ctx->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
> > >
> > > -avctx->profile = profile;
> > > +if (!size)
> > > +return 0;
> > >
&

Re: [FFmpeg-devel] [Patch V2] lavf/qsv_scale: add scaling modes support

2019-06-24 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Friday, June 21, 2019 5:33 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [Patch V2] lavf/qsv_scale: add scaling modes
> support
> 
> > Subject: [Patch V2] lavf/qsv_scale: add scaling modes support
> >
> > low_power mode will use a fixed HW engine (SFC), thus can offload EU
> > usage.
> > high quality mode will take EU usage (AVS sampler).
> >
> > Performance and EU usage (Render usage) comparsion on Intel(R) Xeon(R)
> > CPU E3-1225 v5 @ 3.30GHz:
> >
> > High quality mode : ffmpeg -hwaccel qsv -c:v h264_qsv -i
> > bbb_sunflower_1080p_30fps_normal_2000frames.h264 \ -vf
> > scale_qsv=w=1280:h=736:mode=hq -f null -
> > fps=389
> > RENDER usage: 28.10 (provided by MSDK metrics_monitor)
> >
> > Low Power mode: ffmpeg -hwaccel qsv -c:v h264_qsv -i
> > ~/bbb_sunflower_1080p_30fps_normal_2000frames.h264 \ -vf
> > scale_qsv=w=1280:h=736:mode=low_power -f null -
> > fps=343
> > RENDER usage: 0.00
> >
> > Low power mode (SFC) may be disabled if not supported by
> > MSDK/Driver/HW, and replaced by AVS mode interanlly.
> >
> > Signed-off-by: Zhong Li 
> > ---
> >  libavfilter/vf_scale_qsv.c | 40
> > +++-
> >  1 file changed, 35 insertions(+), 5 deletions(-)
> >
> > diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
> > index db7715f..499534e 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, );
> >  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*)>opaque_alloc;
> > -
> > -par.ExtParam= s->ext_buffers;
> > -par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers);
> > +s->ext_buffers[s->num_ext_buf++] =
> > + (mfxExtBuffer*)>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(>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*)>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,16 @@ static const AVOption options[] = {
> >  { "h",  "Output video height", OFFSET(h_expr),
> > AV_OPT_TYPE_STRING, { .str = "ih"   }, .flags

Re: [FFmpeg-devel] [Patch V2] lavf/qsv_scale: add scaling modes support

2019-06-21 Thread Li, Zhong
> Subject: [Patch V2] lavf/qsv_scale: add scaling modes support
> 
> low_power mode will use a fixed HW engine (SFC), thus can offload EU
> usage.
> high quality mode will take EU usage (AVS sampler).
> 
> Performance and EU usage (Render usage) comparsion on Intel(R) Xeon(R)
> CPU E3-1225 v5 @ 3.30GHz:
> 
> High quality mode : ffmpeg -hwaccel qsv -c:v h264_qsv -i
> bbb_sunflower_1080p_30fps_normal_2000frames.h264 \ -vf
> scale_qsv=w=1280:h=736:mode=hq -f null -
> fps=389
> RENDER usage: 28.10 (provided by MSDK metrics_monitor)
> 
> Low Power mode: ffmpeg -hwaccel qsv -c:v h264_qsv -i
> ~/bbb_sunflower_1080p_30fps_normal_2000frames.h264 \ -vf
> scale_qsv=w=1280:h=736:mode=low_power -f null -
> fps=343
> RENDER usage: 0.00
> 
> Low power mode (SFC) may be disabled if not supported by MSDK/Driver/HW,
> and replaced by AVS mode interanlly.
> 
> Signed-off-by: Zhong Li 
> ---
>  libavfilter/vf_scale_qsv.c | 40
> +++-
>  1 file changed, 35 insertions(+), 5 deletions(-)
> 
> diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c index
> db7715f..499534e 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, );
>  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*)>opaque_alloc;
> -
> -par.ExtParam= s->ext_buffers;
> -par.NumExtParam = FF_ARRAY_ELEMS(s->ext_buffers);
> +s->ext_buffers[s->num_ext_buf++] =
> + (mfxExtBuffer*)>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(>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*)>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,16 @@ 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"},
> +#else
> +{ "mode",  "(not supported)", OFFSET(mode),
> AV_OPT_TYPE_INT,{ .i64 = 0}, 0, INT_MAX, FLAGS, "mode"},
> +{ "low_power", "",  0,
> AV_OPT_TYPE_CONST,  { .i64 = 1}, 0,   0, FLAGS, "mode"},
> +{ "hq","",  0,
> AV_OPT_TYPE_CONST,  { .i64 = 2}, 0,   0, FLAGS, "mode"},
> +#endif
> +
>  { NULL },
>  };
> 
> --
> 2.7.4

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

To unsubscribe, visit link above, or email

Re: [FFmpeg-devel] [PATCH, v3] lavf/qsvvpp:allocate continuous memory

2019-06-14 Thread Li, Zhong
> From: Fu, Linjie
> Sent: Friday, June 14, 2019 1:39 PM
> To: Li, Zhong ; FFmpeg development discussions and
> patches 
> Subject: RE: [FFmpeg-devel] [PATCH,v3] lavf/qsvvpp:allocate continuous
> memory
> 
> > -Original Message-
> > From: Li, Zhong
> > Sent: Friday, June 14, 2019 11:34
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Cc: Fu, Linjie 
> > Subject: RE: [FFmpeg-devel] [PATCH,v3] lavf/qsvvpp:allocate continuous
> > memory
> >
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > > Of Linjie Fu
> > > Sent: Tuesday, June 4, 2019 11:59 PM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Fu, Linjie 
> > > Subject: [FFmpeg-devel] [PATCH,v3] lavf/qsvvpp:allocate continuous
> > > memory
> > >
> > > Mediasdk calls CMRT to copy from video to system memory and requires
> > > memory to be continuously allocated across Y and UV.
> > >
> > > Add a new path to allocate continuous memory when using system out.
> > > Use av_frame_get_buffer to arrange data according to pixfmt, and
> > > remove the introduced plane_padding.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > >  libavfilter/qsvvpp.c | 26 --
> > >  1 file changed, 20 insertions(+), 6 deletions(-)
> > >
> > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> > > 5cd1d5d345..c06171444f 100644
> > > --- a/libavfilter/qsvvpp.c
> > > +++ b/libavfilter/qsvvpp.c
> > > @@ -350,7 +350,7 @@ static QSVFrame *query_frame(QSVVPPContext
> *s,
> > > AVFilterLink *outlink)  {
> > >  AVFilterContext *ctx = outlink->src;
> > >  QSVFrame*out_frame;
> > > -int  ret;
> > > +int  i, ret;
> > >
> > >  clear_unused_frames(s->out_frame_list);
> > >
> > > @@ -374,12 +374,26 @@ static QSVFrame
> *query_frame(QSVVPPContext *s,
> > > AVFilterLink *outlink)
> > >  out_frame->surface = (mfxFrameSurface1
> > > *)out_frame->frame->data[3];
> > >  } else {
> > >  /* Get a frame with aligned dimensions.
> > > - * Libmfx need system memory being 128x64 aligned */
> > > -out_frame->frame = ff_get_video_buffer(outlink,
> > > -
> > > FFALIGN(outlink->w, 128),
> > > -
> > > FFALIGN(outlink->h, 64));
> > > -if (!out_frame->frame)
> > > + * Libmfx need system memory being 128x64 aligned
> > > + * and continuously allocated across Y and UV */
> > > +out_frame->frame = av_frame_alloc();
> > > +if (!out_frame->frame) {
> > >  return NULL;
> > > +}
> > > +
> > > +out_frame->frame->width  = FFALIGN(outlink->w, 128);
> > > +out_frame->frame->height = FFALIGN(outlink->h, 64);
> > > +out_frame->frame->format = outlink->format;
> > > +
> > > +ret = av_frame_get_buffer(out_frame->frame, 128);
> > > +if (ret < 0)
> > > +return NULL;
> > > +
> > > +/* remove plane_padding introduced by av_frame_get_buffer
> > > + */
> > Should be well explained in the comments why need to reomove.
> 
> Tried to explain that continuous memory is need for  libmfx in commit
> message and before av_frame_get_buffer was called.
> 
> If that's not enough, would you please offer some advices on how to explain
> better?
> 
> >
> > > +for (i = 1; i < 4; i++) {
> > > +if (out_frame->frame->data[i])
> > > +out_frame->frame->data[i] -= i * 128;
> > > +}
> >
> > Looks like tricky workaround. If padding bytes size changed in
> > av_frame_get_buffer, will break qsv vpp.
> 
> Calls av_frame_get_buffer-> get_video_buffer could allocate memory at
> one time and make the code clearer, but will introduce plane_padding:
> 
> plane_padding = FFMAX(16 + 16/*STRIDE_ALIGN*/, align);
> 
> The padding bytes was initialized by variable "align", and "align" was set to
> 128 as a requirement.
> So the padding bytes will always be set to align and I think it won't break 
> vpp
> pipeline.

This is just current status, if you check git log of frame.c, plane_padding 
size was changed serval times. 
If it is continuous to change, then will break qsv vpp. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v3] lavf/qsvvpp:allocate continuous memory

2019-06-13 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Tuesday, June 4, 2019 11:59 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH,v3] lavf/qsvvpp:allocate continuous
> memory
> 
> Mediasdk calls CMRT to copy from video to system memory and requires
> memory to be continuously allocated across Y and UV.
> 
> Add a new path to allocate continuous memory when using system out.
> Use av_frame_get_buffer to arrange data according to pixfmt, and remove
> the introduced plane_padding.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavfilter/qsvvpp.c | 26 --
>  1 file changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> 5cd1d5d345..c06171444f 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -350,7 +350,7 @@ static QSVFrame *query_frame(QSVVPPContext *s,
> AVFilterLink *outlink)  {
>  AVFilterContext *ctx = outlink->src;
>  QSVFrame*out_frame;
> -int  ret;
> +int  i, ret;
> 
>  clear_unused_frames(s->out_frame_list);
> 
> @@ -374,12 +374,26 @@ static QSVFrame *query_frame(QSVVPPContext
> *s, AVFilterLink *outlink)
>  out_frame->surface = (mfxFrameSurface1
> *)out_frame->frame->data[3];
>  } else {
>  /* Get a frame with aligned dimensions.
> - * Libmfx need system memory being 128x64 aligned */
> -out_frame->frame = ff_get_video_buffer(outlink,
> -
> FFALIGN(outlink->w, 128),
> -
> FFALIGN(outlink->h, 64));
> -if (!out_frame->frame)
> + * Libmfx need system memory being 128x64 aligned
> + * and continuously allocated across Y and UV */
> +out_frame->frame = av_frame_alloc();
> +if (!out_frame->frame) {
>  return NULL;
> +}
> +
> +out_frame->frame->width  = FFALIGN(outlink->w, 128);
> +out_frame->frame->height = FFALIGN(outlink->h, 64);
> +out_frame->frame->format = outlink->format;
> +
> +ret = av_frame_get_buffer(out_frame->frame, 128);
> +if (ret < 0)
> +return NULL;
> +
> +/* remove plane_padding introduced by av_frame_get_buffer */
Should be well explained in the comments why need to reomove.

> +for (i = 1; i < 4; i++) {
> +if (out_frame->frame->data[i])
> +out_frame->frame->data[i] -= i * 128;
> +}

Looks like tricky workaround. If padding bytes size changed in 
av_frame_get_buffer, will break qsv vpp. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/3] lavf/qsv_vpp: add frame format option

2019-06-10 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Monday, June 3, 2019 10:59 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavf/qsv_vpp: add frame format
> option
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Carl Eugen Hoyos
> > Sent: Saturday, June 1, 2019 4:43 AM
> > To: FFmpeg development discussions and patches
> > 
> > Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavf/qsv_vpp: add frame format
> > option
> >
> > Am Fr., 31. Mai 2019 um 10:01 Uhr schrieb Zhong Li :
> >
> > > @@ -104,6 +109,8 @@ static const AVOption options[] = {
> > >  { "width",  "Output video width",  OFFSET(ow),
> > AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS },
> > >  { "h",  "Output video height", OFFSET(oh),
> > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
> > >  { "height", "Output video height", OFFSET(oh),
> > > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
> > > +{ "format", "Output pixel format", OFFSET(output_format_str),
> > > + AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
> >
> > AV_OPT_TYPE_PIXEL_FMT?
> > Or do I miss something?
> >
> > Carl Eugen
> 
> It is a string and converted to AVPixelFormat using av_get_pix_fmt() 
>Keep alignment with vf_scaling_qsv/npp/vaapi.c

Does this answer make sense? If so will push it soon.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate continuous memory

2019-06-03 Thread Li, Zhong


> -Original Message-
> From: Fu, Linjie
> Sent: Monday, June 3, 2019 3:10 PM
> To: Li, Zhong ; FFmpeg development discussions and
> patches 
> Subject: RE: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate
> continuous memory
> 
> 
> 
> > -----Original Message-
> > From: Li, Zhong
> > Sent: Monday, June 3, 2019 13:28
> > To: Fu, Linjie ; FFmpeg development discussions
> > and patches 
> > Subject: RE: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate
> > continuous memory
> >
> >
> >
> > > -----Original Message-
> > > From: Fu, Linjie
> > > Sent: Monday, June 3, 2019 1:17 PM
> > > To: Li, Zhong ; FFmpeg development discussions
> > > and patches 
> > > Subject: RE: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate
> > > continuous memory
> > >
> > > > -Original Message-
> > > > From: Li, Zhong
> > > > Sent: Friday, May 31, 2019 17:20
> > > > To: FFmpeg development discussions and patches  > > > de...@ffmpeg.org>
> > > > Cc: Fu, Linjie 
> > > > Subject: RE: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate
> > > > continuous memory
> > > >
> > > > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > > > Behalf
> > > > > Of Linjie Fu
> > > > > Sent: Thursday, May 30, 2019 1:01 AM
> > > > > To: ffmpeg-devel@ffmpeg.org
> > > > > Cc: Fu, Linjie 
> > > > > Subject: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate
> > > > > continuous memory
> > > > >
> > > > > Mediasdk calls CMRT to copy from video to system memory and
> > requires
> > > > > memory to be continuously allocated across Y and UV.
> > > > >
> > > > > Add a new path to allocate continuous memory when using system
> out.
> > > > > Use av_image_fill_pointers to arrange data according to pixfmt.
> > > > >
> > > > > Signed-off-by: Linjie Fu 
> > > > > ---
> > > > > [v2]: use av_image_fill_pointers
> > > > >
> > > > >  libavfilter/qsvvpp.c | 32 +++-
> > > > >  1 file changed, 27 insertions(+), 5 deletions(-)
> > > > >
> > > > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> > > > > 06efdf5089..6eeed7e632 100644
> > > > > --- a/libavfilter/qsvvpp.c
> > > > > +++ b/libavfilter/qsvvpp.c
> > > > > @@ -27,6 +27,7 @@
> > > > >  #include "libavutil/hwcontext_qsv.h"
> > > > >  #include "libavutil/time.h"
> > > > >  #include "libavutil/pixdesc.h"
> > > > > +#include "libavutil/imgutils.h"
> > > > >
> > > > >  #include "internal.h"
> > > > >  #include "qsvvpp.h"
> > > > > @@ -51,6 +52,7 @@ struct QSVVPPContext {
> > > > >  enum AVPixelFormat  out_sw_format;   /* Real output
> format
> > > */
> > > > >  mfxVideoParam   vpp_param;
> > > > >  mfxFrameInfo   *frame_infos; /* frame info for
> each
> > > > > input */
> > > > > +AVBufferPool   *pool;
> > > > >
> > > > >  /* members related to the input/output surface */
> > > > >  int in_mem_mode;
> > > > > @@ -375,10 +377,24 @@ static QSVFrame
> > > *query_frame(QSVVPPContext *s,
> > > > > AVFilterLink *outlink)
> > > > >  out_frame->surface = (mfxFrameSurface1
> > > > > *)out_frame->frame->data[3];
> > > > >  } else {
> > > > >  /* Get a frame with aligned dimensions.
> > > > > - * Libmfx need system memory being 128x64 aligned */
> > > > > -out_frame->frame = ff_get_video_buffer(outlink,
> > > > > -
> > > > > FFALIGN(outlink->w, 128),
> > > > > -
> > > > > FFALIGN(outlink->h, 64));
> > > > > + * Libmfx need system memory being 128x64 aligned
> > > > > + * and continuously allocated across Y and UV */
> > > > > +out_frame->frame = av_frame_alloc();
> > > > > +if (!out_frame->frame) {
> > > > > +return NULL;
> > >

Re: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate continuous memory

2019-06-02 Thread Li, Zhong


> -Original Message-
> From: Fu, Linjie
> Sent: Monday, June 3, 2019 1:17 PM
> To: Li, Zhong ; FFmpeg development discussions and
> patches 
> Subject: RE: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate
> continuous memory
> 
> > -Original Message-
> > From: Li, Zhong
> > Sent: Friday, May 31, 2019 17:20
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Cc: Fu, Linjie 
> > Subject: RE: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate
> > continuous memory
> >
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > > Of Linjie Fu
> > > Sent: Thursday, May 30, 2019 1:01 AM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Fu, Linjie 
> > > Subject: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate
> > > continuous memory
> > >
> > > Mediasdk calls CMRT to copy from video to system memory and requires
> > > memory to be continuously allocated across Y and UV.
> > >
> > > Add a new path to allocate continuous memory when using system out.
> > > Use av_image_fill_pointers to arrange data according to pixfmt.
> > >
> > > Signed-off-by: Linjie Fu 
> > > ---
> > > [v2]: use av_image_fill_pointers
> > >
> > >  libavfilter/qsvvpp.c | 32 +++-
> > >  1 file changed, 27 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> > > 06efdf5089..6eeed7e632 100644
> > > --- a/libavfilter/qsvvpp.c
> > > +++ b/libavfilter/qsvvpp.c
> > > @@ -27,6 +27,7 @@
> > >  #include "libavutil/hwcontext_qsv.h"
> > >  #include "libavutil/time.h"
> > >  #include "libavutil/pixdesc.h"
> > > +#include "libavutil/imgutils.h"
> > >
> > >  #include "internal.h"
> > >  #include "qsvvpp.h"
> > > @@ -51,6 +52,7 @@ struct QSVVPPContext {
> > >  enum AVPixelFormat  out_sw_format;   /* Real output format
> */
> > >  mfxVideoParam   vpp_param;
> > >  mfxFrameInfo   *frame_infos; /* frame info for each
> > > input */
> > > +AVBufferPool   *pool;
> > >
> > >  /* members related to the input/output surface */
> > >  int in_mem_mode;
> > > @@ -375,10 +377,24 @@ static QSVFrame
> *query_frame(QSVVPPContext *s,
> > > AVFilterLink *outlink)
> > >  out_frame->surface = (mfxFrameSurface1
> > > *)out_frame->frame->data[3];
> > >  } else {
> > >  /* Get a frame with aligned dimensions.
> > > - * Libmfx need system memory being 128x64 aligned */
> > > -out_frame->frame = ff_get_video_buffer(outlink,
> > > -
> > > FFALIGN(outlink->w, 128),
> > > -
> > > FFALIGN(outlink->h, 64));
> > > + * Libmfx need system memory being 128x64 aligned
> > > + * and continuously allocated across Y and UV */
> > > +out_frame->frame = av_frame_alloc();
> > > +if (!out_frame->frame) {
> > > +return NULL;
> >
> > Should be better to return AVERROR(ENOMEM)?
> 
> Will refine.
> 
> >
> > > +}
> > > +
> > > +out_frame->frame->linesize[0] = FFALIGN(outlink->w, 128);
> > > +out_frame->frame->linesize[1] =
> out_frame->frame->linesize[0];
> > > +out_frame->frame->buf[0]  =
> av_buffer_pool_get(s->pool);
> > > +out_frame->frame->format  = outlink->format;
> > > +
> > > +if (!out_frame->frame->buf[0])
> > > +return NULL;
> >
> > Same as frame alloc.
> 
> Will refine.
> > 1. What is the benefit to use a pool? Comparing with directly alloc a
> > buffer use ()?
> Directly allocate seems to be better.

I am thinking using av_frame_get_buffer() will make life easier or not. 
It can make sure memory continuous and call av_buffer_alloc() and 
av_image_fill_pointers() internally.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 3/3] lavf/qsv: use av_cold for init/uninit

2019-06-02 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Carl Eugen Hoyos
> Sent: Saturday, June 1, 2019 4:41 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 3/3] lavf/qsv: use av_cold for init/uninit
> 
> Am Fr., 31. Mai 2019 um 10:01 Uhr schrieb Zhong Li :
> >
> > Signed-off-by: Zhong Li 
> > ---
> >  libavfilter/vf_deinterlace_qsv.c | 2 +-
> >  libavfilter/vf_overlay_qsv.c | 2 +-
> >  libavfilter/vf_scale_qsv.c   | 4 ++--
> >  3 files changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/libavfilter/vf_deinterlace_qsv.c
> > b/libavfilter/vf_deinterlace_qsv.c
> > index bee10c220f..80217c8419 100644
> > --- a/libavfilter/vf_deinterlace_qsv.c
> > +++ b/libavfilter/vf_deinterlace_qsv.c
> > @@ -83,7 +83,7 @@ typedef struct QSVDeintContext {
> >  int mode;
> >  } QSVDeintContext;
> >
> > -static void qsvdeint_uninit(AVFilterContext *ctx)
> > +static av_cold void qsvdeint_uninit(AVFilterContext *ctx)
> >  {
> >  QSVDeintContext *s = ctx->priv;
> >  QSVFrame *cur;
> > diff --git a/libavfilter/vf_overlay_qsv.c
> > b/libavfilter/vf_overlay_qsv.c index 9aabb594ba..2a4dc5cb58 100644
> > --- a/libavfilter/vf_overlay_qsv.c
> > +++ b/libavfilter/vf_overlay_qsv.c
> > @@ -345,7 +345,7 @@ static int overlay_qsv_init(AVFilterContext *ctx)
> >  return 0;
> >  }
> >
> > -static void overlay_qsv_uninit(AVFilterContext *ctx)
> > +static av_cold void overlay_qsv_uninit(AVFilterContext *ctx)
> >  {
> >  QSVOverlayContext *vpp = ctx->priv;
> >
> > diff --git a/libavfilter/vf_scale_qsv.c b/libavfilter/vf_scale_qsv.c
> > index 7d593b2b21..db7715fc1b 100644
> > --- a/libavfilter/vf_scale_qsv.c
> > +++ b/libavfilter/vf_scale_qsv.c
> > @@ -109,7 +109,7 @@ typedef struct QSVScaleContext {
> >  char *format_str;
> >  } QSVScaleContext;
> >
> > -static int qsvscale_init(AVFilterContext *ctx)
> > +static av_cold int qsvscale_init(AVFilterContext *ctx)
> >  {
> >  QSVScaleContext *s = ctx->priv;
> >
> > @@ -126,7 +126,7 @@ static int qsvscale_init(AVFilterContext *ctx)
> >  return 0;
> >  }
> >
> > -static void qsvscale_uninit(AVFilterContext *ctx)
> > +static av_cold void qsvscale_uninit(AVFilterContext *ctx)
> 
> Patch looks fine to me.
> 
> Carl Eugen

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

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

Re: [FFmpeg-devel] [PATCH 1/3] lavf/qsv_vpp: add frame format option

2019-06-02 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Carl Eugen Hoyos
> Sent: Saturday, June 1, 2019 4:43 AM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH 1/3] lavf/qsv_vpp: add frame format
> option
> 
> Am Fr., 31. Mai 2019 um 10:01 Uhr schrieb Zhong Li :
> 
> > @@ -104,6 +109,8 @@ static const AVOption options[] = {
> >  { "width",  "Output video width",  OFFSET(ow),
> AV_OPT_TYPE_STRING, { .str="cw" }, 0, 255, .flags = FLAGS },
> >  { "h",  "Output video height", OFFSET(oh),
> AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
> >  { "height", "Output video height", OFFSET(oh),
> > AV_OPT_TYPE_STRING, { .str="w*ch/cw" }, 0, 255, .flags = FLAGS },
> > +{ "format", "Output pixel format", OFFSET(output_format_str),
> > + AV_OPT_TYPE_STRING, { .str = "same" }, .flags = FLAGS },
> 
> AV_OPT_TYPE_PIXEL_FMT?
> Or do I miss something?
> 
> Carl Eugen

It is a string and converted to AVPixelFormat using av_get_pix_fmt()
Keep alignment with vf_scaling_qsv/npp/vaapi.c
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate continuous memory

2019-05-31 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Thursday, May 30, 2019 1:01 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v2 1/2] lavf/qsvvpp: allocate continuous
> memory
> 
> Mediasdk calls CMRT to copy from video to system memory and requires
> memory to be continuously allocated across Y and UV.
> 
> Add a new path to allocate continuous memory when using system out.
> Use av_image_fill_pointers to arrange data according to pixfmt.
> 
> Signed-off-by: Linjie Fu 
> ---
> [v2]: use av_image_fill_pointers
> 
>  libavfilter/qsvvpp.c | 32 +++-
>  1 file changed, 27 insertions(+), 5 deletions(-)
> 
> diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> 06efdf5089..6eeed7e632 100644
> --- a/libavfilter/qsvvpp.c
> +++ b/libavfilter/qsvvpp.c
> @@ -27,6 +27,7 @@
>  #include "libavutil/hwcontext_qsv.h"
>  #include "libavutil/time.h"
>  #include "libavutil/pixdesc.h"
> +#include "libavutil/imgutils.h"
> 
>  #include "internal.h"
>  #include "qsvvpp.h"
> @@ -51,6 +52,7 @@ struct QSVVPPContext {
>  enum AVPixelFormat  out_sw_format;   /* Real output format */
>  mfxVideoParam   vpp_param;
>  mfxFrameInfo   *frame_infos; /* frame info for each
> input */
> +AVBufferPool   *pool;
> 
>  /* members related to the input/output surface */
>  int in_mem_mode;
> @@ -375,10 +377,24 @@ static QSVFrame *query_frame(QSVVPPContext
> *s, AVFilterLink *outlink)
>  out_frame->surface = (mfxFrameSurface1
> *)out_frame->frame->data[3];
>  } else {
>  /* Get a frame with aligned dimensions.
> - * Libmfx need system memory being 128x64 aligned */
> -out_frame->frame = ff_get_video_buffer(outlink,
> -
> FFALIGN(outlink->w, 128),
> -
> FFALIGN(outlink->h, 64));
> + * Libmfx need system memory being 128x64 aligned
> + * and continuously allocated across Y and UV */
> +out_frame->frame = av_frame_alloc();
> +if (!out_frame->frame) {
> +return NULL;

Should be better to return AVERROR(ENOMEM)? 

> +}
> +
> +out_frame->frame->linesize[0] = FFALIGN(outlink->w, 128);
> +out_frame->frame->linesize[1] = out_frame->frame->linesize[0];
> +out_frame->frame->buf[0]  = av_buffer_pool_get(s->pool);
> +out_frame->frame->format  = outlink->format;
> +
> +if (!out_frame->frame->buf[0])
> +return NULL;

Same as frame alloc.

> +
> +av_image_fill_pointers(out_frame->frame->data,
> out_frame->frame->format,
> +FFALIGN(outlink->h, 64),
> out_frame->frame->buf[0]->data,
> +
> + out_frame->frame->linesize);
>  if (!out_frame->frame)
>  return NULL;
> 
> @@ -483,8 +499,13 @@ static int init_vpp_session(AVFilterContext *avctx,
> QSVVPPContext *s)
> 
>  av_buffer_unref(>hw_frames_ctx);
>  outlink->hw_frames_ctx = out_frames_ref;
> -} else
> +} else {
>  s->out_mem_mode = MFX_MEMTYPE_SYSTEM_MEMORY;
> +s->pool =
> av_buffer_pool_init(av_image_get_buffer_size(outlink->format,
> +
> FFALIGN(outlink->w, 128),
> +
> FFALIGN(outlink->h, 64), 1),
> +av_buffer_allocz);

1. What is the benefit to use a pool? Comparing with directly alloc a buffer 
use av_buffer_allocz()? 
2. av_buffer_allocz() will memset the whole buffer and make performance drop. 
Is it really necessary here? 
  If no (I believe so), just use av_buffer_alloc()
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream properties

2019-05-31 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Sunday, April 28, 2019 6:24 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream
> properties
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Mark Thompson
> > Sent: Tuesday, April 2, 2019 7:40 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream
> > properties
> >
> > Rewrites the parser entirely, using CBS for header parsing.
> > ---
> >  libavcodec/vp9_parser.c | 112
> > +---
> >  1 file changed, 82 insertions(+), 30 deletions(-)
> >
> > diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c index
> > c957a75667..6bf4f30e80 100644
> > --- a/libavcodec/vp9_parser.c
> > +++ b/libavcodec/vp9_parser.c
> > @@ -1,8 +1,5 @@
> >  /*
> > - * VP9 compatible video decoder
> > - *
> > - * Copyright (C) 2013 Ronald S. Bultje 
> > - * Copyright (C) 2013 Clément Bœsch 
> > + * VP9 parser
> >   *
> >   * This file is part of FFmpeg.
> >   *
> > @@ -21,50 +18,105 @@
> >   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> > 02110-1301 USA
> >   */
> >
> > -#include "libavutil/intreadwrite.h"
> > -#include "libavcodec/get_bits.h"
> > +#include "libavutil/avassert.h"
> > +#include "cbs.h"
> > +#include "cbs_vp9.h"
> >  #include "parser.h"
> >
> > -static int parse(AVCodecParserContext *ctx,
> > - AVCodecContext *avctx,
> > - const uint8_t **out_data, int *out_size,
> > - const uint8_t *data, int size)
> > +typedef struct VP9ParserContext {
> > +CodedBitstreamContext *cbc;
> > +VP9RawFrameHeader frame_header;
> > +} VP9ParserContext;
> > +
> > +static const enum AVPixelFormat vp9_pix_fmts[3][2][2] = {
> > +{ // 8-bit.
> > +{ AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P },
> > +{ AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P },
> > +},
> > +{ // 10-bit.
> > +{ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV440P10 },
> > +{ AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10 },
> > +},
> > +{ // 12-bit.
> > +{ AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV440P12 },
> > +{ AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12 },
> > +},
> > +};
> > +
> > +static int vp9_parser_parse(AVCodecParserContext *ctx,
> > +AVCodecContext *avctx,
> > +const uint8_t **out_data, int
> *out_size,
> > +const uint8_t *data, int size)
> >  {
> > -GetBitContext gb;
> > -int res, profile, keyframe;
> > +VP9ParserContext *s = ctx->priv_data;
> > +const CodedBitstreamVP9Context *vp9 = s->cbc->priv_data;
> > +const VP9RawFrameHeader *fh;
> > +int err;
> >
> >  *out_data = data;
> >  *out_size = size;
> >
> > -if (!size || (res = init_get_bits8(, data, size)) < 0)
> > -return size; // parsers can't return errors
> > -get_bits(, 2); // frame marker
> > -profile  = get_bits1();
> > -profile |= get_bits1() << 1;
> > -if (profile == 3) profile += get_bits1();
> > -if (profile > 3)
> > -return size;
> > +ctx->key_frame = -1;
> > +ctx->pict_type = AV_PICTURE_TYPE_NONE;
> > +ctx->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
> >
> > -avctx->profile = profile;
> > +if (!size)
> > +return 0;
> >
> > -if (get_bits1()) {
> > -keyframe = 0;
> > -} else {
> > -keyframe  = !get_bits1();
> > +s->cbc->log_ctx = avctx;
> > +
> > +err = ff_cbs_parse_headers(s->cbc, >frame_header, data, size);
> > +if (err < 0) {
> > +av_log(avctx, AV_LOG_WARNING, "Failed to parse VP9 frame
> > headers.\n");
> > +goto end;
> >  }
> > +fh = >frame_header;
> >
> > -if (!keyframe) {
> > -ctx->pict_type = AV_PICTURE_TYPE_P;
> > -ctx->key_frame = 0;
> > -} else {
> > +avctx->profile = vp9->profile;
> > +avctx->level   = FF_LEVEL_UNKNOWN;
> > +
> > +ctx->width  =

Re: [FFmpeg-devel] [PATCH] lavf/qsvvpp: avoid the double-free when working in sys memory mode

2019-05-30 Thread Li, Zhong
> vpp_qsv with system software path could reproduce this with mainline
> version:
> 
> ffmpeg -init_hw_device qsv=foo -filter_hw_device foo -v debug -f rawvideo
> -pix_fmt nv12 -s:v 852x480 -i 852x480.nv12 -vf 'vpp_qsv=w=500:h=400' -f
> rawvideo -pix_fmt nv12 qsv.nv12
> 
> This happens when the size of the input stream is not 32 aligned and has
> more than 1 frames.

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

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

Re: [FFmpeg-devel] [PATCH] libavformat/qsvenc: repeat mpeg2 missing headers [v2]

2019-05-30 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Andreas Håkon
> Sent: Tuesday, May 28, 2019 6:48 PM
> To: FFmpeg development discussions and patches
> 
> Subject: [FFmpeg-devel] [PATCH] libavformat/qsvenc: repeat mpeg2 missing
> headers [v2]
> 
> Hi,
> 
> This patch supersedes #13105 (https://patchwork.ffmpeg.org/patch/13105/)
> 
> A new (simpler and more robust) implementationof of the reinsertion of the
> missing headers in the MPEG-2 bitstream from the HW QSV encoder.
> 
> The problem is quite simple: The bitstream generated by the MPEG-2 QSV
> encoder only incorporates the SEQ_START_CODE and EXT_START_CODE
> headers in the first GOP. This generates a result that is not suitable for
> streaming or broadcasting.
> With this patch the "mpeg2_qsv" encoder is at the same level as the
> "mpeg2video", as the software implementation repeats these headers by
> default in each GOP.
> 
> Regards.
> A.H.

1. Doesn't dump_extra filter to add extradata to all key packets work well?
2. You always insert such a repeat header without any option to turn it off, 
thus should not be default behavior IMHO. 

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

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

Re: [FFmpeg-devel] [PATCH] lavf/qsvvpp: avoid the double-free when working in sys memory mode

2019-05-29 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Fu, Linjie
> Sent: Wednesday, May 29, 2019 5:08 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH] lavf/qsvvpp: avoid the double-free
> when working in sys memory mode
> 
> > -Original Message-
> > From: Fu, Linjie
> > Sent: Monday, April 15, 2019 21:24
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Fu, Linjie 
> > Subject: [PATCH] lavf/qsvvpp: avoid the double-free when working in
> > sys memory mode
> >
> > Currently, picref will be freed by calling av_frame_free() in
> > submit_frame() in qsvvpp.c when working in system memory mode,and
> > normally it is freed in filter_frame() in vf_vpp_qsv.c when working in
> > other modes.
> >
> > Double free happens when working in system memory mode, remove to fix
> > the memory issue.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> > Can be reproduced by applying the system memory patch and qsvdec+vpp:
> > ffmpeg -init_hw_device qsv=hw -filter_hw_device hw -c:v h264_qsv
> > -i
> > input.mp4 \
> > -vf
> "vpp_qsv=w=960:h=540,format=rgb32"

Is it possible to reproduce with another command line? It can work with 
mainline on Linux.

> > -f null -  libavfilter/qsvvpp.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c index
> > 06efdf5089..5cd1d5d345 100644
> > --- a/libavfilter/qsvvpp.c
> > +++ b/libavfilter/qsvvpp.c
> > @@ -316,7 +316,6 @@ static QSVFrame *submit_frame(QSVVPPContext
> *s,
> > AVFilterLink *inlink, AVFrame *p
> >  }
> >
> >  av_frame_copy_props(qsv_frame->frame, picref);
> > -av_frame_free();
> >  } else
> >  qsv_frame->frame = av_frame_clone(picref);
> >
> > --
> > 2.17.1
> Ping?

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

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

Re: [FFmpeg-devel] [PATCH V1 2/2] lavfi/sr: Remove slice thread flag

2019-05-25 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Jun Zhao
> Sent: Saturday, May 25, 2019 8:17 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Jun Zhao 
> Subject: [FFmpeg-devel] [PATCH V1 2/2] lavfi/sr: Remove slice thread flag
> 
> From: Jun Zhao 
> 
> sr didn't enable the slice threading, so remove the flag
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/vf_sr.c |3 +--
>  1 files changed, 1 insertions(+), 2 deletions(-)
> 
> diff --git a/libavfilter/vf_sr.c b/libavfilter/vf_sr.c index 95bd3b7..86dc551
> 100644
> --- a/libavfilter/vf_sr.c
> +++ b/libavfilter/vf_sr.c
> @@ -317,6 +317,5 @@ AVFilter ff_vf_sr = {
>  .inputs= sr_inputs,
>  .outputs   = sr_outputs,
>  .priv_class= _class,
> -.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC |
> AVFILTER_FLAG_SLICE_THREADS,
> +.flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC,
>  };
> -
> --
> 1.7.1

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

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

Re: [FFmpeg-devel] [PATCH, v2] lavc/qsvenc: Fix the memory leak for enc_ctrl.Payload

2019-05-22 Thread Li, Zhong
> From: Fu, Linjie
> Sent: Wednesday, May 22, 2019 1:50 PM
> To: Li, Zhong ; FFmpeg development discussions and
> patches 
> Subject: RE: [FFmpeg-devel] [PATCH, v2] lavc/qsvenc: Fix the memory leak
> for enc_ctrl.Payload
> 
> > -Original Message-
> > From: Li, Zhong
> > Sent: Monday, April 29, 2019 17:00
> > To: FFmpeg development discussions and patches  > de...@ffmpeg.org>
> > Cc: Fu, Linjie 
> > Subject: RE: [FFmpeg-devel] [PATCH, v2] lavc/qsvenc: Fix the memory
> > leak for enc_ctrl.Payload
> >
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > Behalf
> > > Of Linjie Fu
> > > Sent: Monday, April 15, 2019 9:23 PM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Fu, Linjie 
> > > Subject: [FFmpeg-devel] [PATCH, v2] lavc/qsvenc: Fix the memory leak
> > > for enc_ctrl.Payload
> > >
> > > frame->enc_ctrl.Payload is malloced in get_free_frame, directly
> > > frame->memset
> > > the whole structure of enc_ctrl to zero will cause the memory leak
> > > for enc_ctrl.Payload.
> > >
> > > frame->enc_ctrl as a structure will be malloc and init to zero by
> > > frame->calling
> > > frame = av_mallocz(sizeof(*frame)), so the memset is redundant and
> > > can
> > be
> > > removed.
> > >
> > > Can be reproduced by #7830.
> >
> > Patch LGTM now, but I can't see strong relationship between this patch
> > and tikect #7830.
> > IMHO this is a quite common issue even if you use qsv transcoding
> pipeline?
> 
> Yes, it's not strongly related with the issue. Remove this would be fine.
> Thanks.

Applied with commit message modified. 
Thanks.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH V2] lavfi/colorlevels: Add slice threading support

2019-05-21 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Jun Zhao
> Sent: Tuesday, May 21, 2019 7:21 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Jun Zhao 
> Subject: [FFmpeg-devel] [PATCH V2] lavfi/colorlevels: Add slice threading
> support
> 
> From: Jun Zhao 
> 
> Add slice threading support, use the command like:
> 
> ./ffmpeg -i input -vf colorlevel with 1080p h264 clip, the fps from 39 fps to
> 79 fps in the local
> 
> Signed-off-by: Jun Zhao 
> ---
>  libavfilter/vf_colorlevels.c |  125
> +++--
>  1 files changed, 106 insertions(+), 19 deletions(-)
> 
> diff --git a/libavfilter/vf_colorlevels.c b/libavfilter/vf_colorlevels.c index
> 5385a5e..68668e7 100644
> --- a/libavfilter/vf_colorlevels.c
> +++ b/libavfilter/vf_colorlevels.c
> @@ -105,6 +105,83 @@ static int config_input(AVFilterLink *inlink)
>  return 0;
>  }
> 
> +struct thread_data {
> +const uint8_t *srcrow;
> +uint8_t *dstrow;
> +int dst_linesize;
> +int src_linesize;
> +
> +double coeff;
> +uint8_t offset;
> +
> +int h;
> +
> +int imin;
> +int omin;
> +};
> +
> +static int colorlevel_slice_8(AVFilterContext *ctx, void *arg, int
> +jobnr, int nb_jobs) {
> +ColorLevelsContext *s = ctx->priv;
> +const struct thread_data *td = arg;
> +
> +int process_h = td->h;
> +const int slice_start = (process_h *  jobnr   ) / nb_jobs;
> +const int slice_end   = (process_h * (jobnr+1)) / nb_jobs;
> +int x, y;
> +const uint8_t *srcrow = td->srcrow;
> +uint8_t *dstrow = td->dstrow;
> +const int step = s->step;
> +const uint8_t offset = td->offset;
> +
> +int imin = td->imin;
> +int omin = td->omin;
> +double coeff = td->coeff;
> +
> +for (y = slice_start; y < slice_end; y++) {
> +const uint8_t *src = srcrow;
> +uint8_t *dst = dstrow;
> +
> +for (x = 0; x < s->linesize; x += step)
> +dst[x + offset] = av_clip_uint8((src[x + offset] - imin) * coeff
> + omin);
> +dstrow += td->dst_linesize;
> +srcrow += td->src_linesize;
> +}
> +
> +return 0;
> +}
> +
> +static int colorlevel_slice_16(AVFilterContext *ctx, void *arg, int
> +jobnr, int nb_jobs) {
> +ColorLevelsContext *s = ctx->priv;
> +const struct thread_data *td = arg;
> +
> +int process_h = td->h;
> +const int slice_start = (process_h *  jobnr   ) / nb_jobs;
> +const int slice_end   = (process_h * (jobnr+1)) / nb_jobs;
> +int x, y;
> +const uint8_t *srcrow = td->srcrow;
> +uint8_t *dstrow = td->dstrow;
> +const int step = s->step;
> +const uint8_t offset = td->offset;
> +
> +int imin = td->imin;
> +int omin = td->omin;
> +double coeff = td->coeff;
> +
> +for (y = slice_start; y < slice_end; y++) {
> +const uint16_t *src = (const uint16_t *)srcrow;
> +uint16_t *dst = (uint16_t *)dstrow;

Function colorlevel_slice_16() is same as colorlevel_slice_8 expect here to 
replace unit8_t to be unit16t.
Would better to define a template function to be reused.

> +for (x = 0; x < s->linesize; x += step)
> +dst[x + offset] = av_clip_uint8((src[x + offset] - imin) * coeff
> + omin);
> +dstrow += td->dst_linesize;
> +srcrow += td->src_linesize;
> +}
> +
> +return 0;
> +}
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: disable ICQ mode when enabling low power

2019-05-21 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Wednesday, May 22, 2019 4:31 AM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH] lavc/vaapi_encode: disable ICQ mode
> when enabling low power
> 
> ICQ mode is not supported in low power mode and should be disabled.
> 
> For H264, Driver supports RC modes CQP, CBR, VBR, QVBR.
> For HEVC, Driver supports RC modes CQP, CBR, VBR, ICQ, QVBR.
> 
> ICQ is not exposed while working on low power mode for h264_vaapi, but
> will trigger issues for hevc_vaapi.
> 
> Signed-off-by: Linjie Fu 
> ---
> See https://github.com/intel/media-driver/issues/618 for details.
> And patch for HEVC low power(ICL+):
> https://github.com/intel-media-ci/ffmpeg/pull/42
> 
>  libavcodec/vaapi_encode.c | 7 +--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode.c b/libavcodec/vaapi_encode.c index
> 2dda451..55ab919 100644
> --- a/libavcodec/vaapi_encode.c
> +++ b/libavcodec/vaapi_encode.c
> @@ -1371,6 +1371,7 @@ static av_cold int
> vaapi_encode_init_rate_control(AVCodecContext *avctx)
>  // * If bitrate and maxrate are set and have the same value, try CBR.
>  // * If a bitrate is set, try AVBR, then VBR, then CBR.
>  // * If no bitrate is set, try ICQ, then CQP.
> +// * If low power is set, ICQ is not supported.
> 
>  #define TRY_RC_MODE(mode, fail) do { \
>  rc_mode = _encode_rc_modes[mode]; \ @@ -1405,7
> +1406,8 @@ static av_cold int
> vaapi_encode_init_rate_control(AVCodecContext *avctx)
>  TRY_RC_MODE(RC_MODE_QVBR, 0);
> 
>  if (avctx->global_quality > 0) {
> -TRY_RC_MODE(RC_MODE_ICQ, 0);
> +if (!ctx->low_power)
> +TRY_RC_MODE(RC_MODE_ICQ, 0);
>  TRY_RC_MODE(RC_MODE_CQP, 0);
>  }
> 
> @@ -1417,7 +1419,8 @@ static av_cold int
> vaapi_encode_init_rate_control(AVCodecContext *avctx)
>  TRY_RC_MODE(RC_MODE_VBR, 0);
>  TRY_RC_MODE(RC_MODE_CBR, 0);
>  } else {
> -TRY_RC_MODE(RC_MODE_ICQ, 0);
> +if (!ctx->low_power)
> +TRY_RC_MODE(RC_MODE_ICQ, 0);

Is it possible ICQ mode can be supported in future (new driver/HW version)? 
I would like to see avoid hard-coded workaround. 
If there is any driver limitation, would better to query driver capability 
firstly and then disable a feature if it is not supported.

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

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

Re: [FFmpeg-devel] [PATCH 7/7] hwcontext_qsv: Try to select a matching VAAPI device by default

2019-05-20 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Monday, May 6, 2019 10:49 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 7/7] hwcontext_qsv: Try to select a
> matching VAAPI device by default
> 
> Tries to find a device backed by the i915 kernel driver and loads the iHD
> VAAPI driver to use with it.  This reduces confusion on machines with
> multiple DRM devices and removes the surprising requirement to set the
> LIBVA_DRIVER_NAME environment variable to use libmfx at all.
> ---
>  libavutil/hwcontext_qsv.c | 15 ---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> 49b5952cef..59e4ed9157 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -1206,6 +1206,7 @@ static int qsv_device_create(AVHWDeviceContext
> *ctx, const char *device,
>  QSVDevicePriv *priv;
>  enum AVHWDeviceType child_device_type;
>  AVHWDeviceContext *child_device;
> +AVDictionary *child_device_opts;
>  AVDictionaryEntry *e;
> 
>  mfxIMPL impl;
> @@ -1220,9 +1221,17 @@ static int
> qsv_device_create(AVHWDeviceContext *ctx, const char *device,
> 
>  e = av_dict_get(opts, "child_device", NULL, 0);
> 
> -if (CONFIG_VAAPI)
> +child_device_opts = NULL;
> +if (CONFIG_VAAPI) {
>  child_device_type = AV_HWDEVICE_TYPE_VAAPI;
> -else if (CONFIG_DXVA2)
> +// libmfx does not actually implement VAAPI properly, rather it
> +// depends on the specific behaviour of a matching iHD driver
> when
> +// used on recent Intel hardware.  Set options to the VAAPI
> device
> +// creation so that we should pick a usable setup by default if
> +// possible, even when multiple devices and drivers are available.
> +av_dict_set(_device_opts, "kernel_driver", "i915", 0);
> +av_dict_set(_device_opts, "driver","iHD",  0);
> +} else if (CONFIG_DXVA2)
>  child_device_type = AV_HWDEVICE_TYPE_DXVA2;
>  else {
>  av_log(ctx, AV_LOG_ERROR, "No supported child device type is
> enabled\n"); @@ -1230,7 +1239,7 @@ static int
> qsv_device_create(AVHWDeviceContext *ctx, const char *device,
>  }
> 
>  ret = av_hwdevice_ctx_create(>child_device_ctx,
> child_device_type,
> - e ? e->value : NULL, NULL, 0);
> + e ? e->value : NULL,
> + child_device_opts, 0);
>  if (ret < 0)
>  return ret;
> 
> --
> 2.20.1

LGTM and tested. Thanks!
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 5/7] hwcontext_vaapi: Add option to set driver name

2019-05-20 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Monday, May 6, 2019 10:49 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH 5/7] hwcontext_vaapi: Add option to set
> driver name
> 
> For example: -init_hw_device vaapi:/dev/dri/renderD128,driver=foo
> 
> This may be more convenient that using the environment variable, and
> allows loading different drivers for different devices in the same process.
> ---
>  libavutil/hwcontext_vaapi.c | 19 +++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/libavutil/hwcontext_vaapi.c b/libavutil/hwcontext_vaapi.c index
> c151f8da93..35883d7855 100644
> --- a/libavutil/hwcontext_vaapi.c
> +++ b/libavutil/hwcontext_vaapi.c
> @@ -1598,6 +1598,25 @@ static int
> vaapi_device_create(AVHWDeviceContext *ctx, const char *device,
>  return AVERROR(EINVAL);
>  }
> 
> +ent = av_dict_get(opts, "driver", NULL, 0);
> +if (ent) {
> +#if VA_CHECK_VERSION(0, 38, 0)
> +VAStatus vas;
> +vas = vaSetDriverName(display, ent->value);
> +if (vas != VA_STATUS_SUCCESS) {
> +av_log(ctx, AV_LOG_ERROR, "Failed to set driver name to "
> +   "%s: %d (%s).\n", ent->value, vas, vaErrorStr(vas));
> +vaTerminate(display);
> +return AVERROR_EXTERNAL;
> +}
> +#else
> +av_log(ctx, AV_LOG_WARNING, "Driver name setting is not "
> +   "supported with this VAAPI version.\n");
> +vaTerminate(display);
> +return AVERROR(ENOSYS);

Giving a warning message should be enough?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: fix mpeg2 encoding

2019-05-15 Thread Li, Zhong
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Andreas Håkon
> Sent: Wednesday, May 15, 2019 8:55 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: fix mpeg2 encoding
> 
> Hi,
> 
> 
> > > The difference?
> > > In addition to a few extra little checks, It seems that the
> > > QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11) check fails every time in
> > > Windows (almost in my environment).
> >
> > If QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11) always equal to zero,
> > then co3 won't be set, If codec is MPEG2, co3 won't be set too.
> > I can't see any difference for MPEG2 case.
> 
> Your assumption about QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11) is
> not real.
> This depends on the run-time driver used.
> 
> 
> > > Futhermore, it has more sense to apply the check inside the
> > > conditional preprocessing of #if QSV_HAVE_CO3 and not outside.
> >
> > Make sense, but no difference for run-time result?
> 
> I prefer to make the code as more legible as possible.
> That's the reason for the other additions of #if QSV_HAVE_CO3.
> 
> 
> > > As a summary: I confirm that my patch works. And it's based on your
> > > proposal. So please comment positively to merge it.
> >
> > It is closer to be merged, but need to confirm which exact line of code
> make difference.
> > (Your verification on Windows was appreciated.)
> 
> As I pointed, the QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11) check fails
> in Windows.
> This version runs without problems and resolves the bug (in Windows).

Well, let me to explain with more detail:

V1: 
if (avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO &&
> QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11)) 

For mpeg2 case, it is always equal to "if (0)" , right? 

V2:
if (avctx->codec_id != AV_CODEC_ID_MPEG2VIDEO)

For mpeg2 case, it is equal to "if (0)" too, right?

Thus why I asked what the difference between V1 and V2 was. 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: fix mpeg2 encoding

2019-05-15 Thread Li, Zhong
> > > Subject: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: fix mpeg2
> > > encoding Fixes bug #7839
> > > https://trac.ffmpeg.org/ticket/7839
> > > Supersedes:
> > > #12935 - https://patchwork.ffmpeg.org/patch/12935/
> > > #12872 - https://patchwork.ffmpeg.org/patch/12872/
> > > Regards.
> > > A.H.
> >
> > It was saidhttps://patchwork.ffmpeg.org/patch/12935/ could not fix
> #7839, how this one can work?
> 
> 
> I compiled your patch and doesn't work.
> My path works.

Glad to know it.

> The difference?
> In addition to a few extra little checks, It seems that the
> QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11) check fails every time in
> Windows (almost in my environment).

If QSV_RUNTIME_VERSION_ATLEAST(q->ver, 1, 11) always equal to zero, then co3 
won't be set, 
If codec is MPEG2, co3 won't be set too.
I can't see any difference for MPEG2 case.

> Futhermore, it has more sense to apply the check inside the conditional
> preprocessing of #if QSV_HAVE_CO3 and not outside.

Make sense, but no difference for run-time result? 

> As a summary: I confirm that my patch works. And it's based on your
> proposal. So please comment positively to merge it.

It is closer to be merged, but need to confirm which exact line of code make 
difference.
(Your verification on Windows was appreciated.)

> Thank you!
> A.H.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: fix mpeg2 encoding

2019-05-15 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Andreas Håkon
> Sent: Wednesday, May 15, 2019 12:00 AM
> To: FFmpeg development discussions and patches
> 
> Subject: [FFmpeg-devel] [PATCH] libavcodec/qsvenc: fix mpeg2 encoding
> 
> Fixes bug #7839
> https://trac.ffmpeg.org/ticket/7839
> 
> Supersedes:
> #12935 - https://patchwork.ffmpeg.org/patch/12935/
> #12872 - https://patchwork.ffmpeg.org/patch/12872/
> 
> Regards.
> A.H.

It was said https://patchwork.ffmpeg.org/patch/12935/ could not fix #7839, how 
this one can work?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v12 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-09 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Sun, Jing A
> Sent: Friday, May 10, 2019 1:30 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v12 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Li, Zhong
> Sent: Friday, May 10, 2019 1:23 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH v12 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> >The better solution should be: use av_malloc and just memset the padding
> bytes.
> 
> The memset inside av_mallocv sets the whole buffer of the size
> "avctx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE" to zero.

That is low efficiency and slow as James mentioned. You don't need to set the 
whole buffer to be zero, only padding bytes needed.

> 
> avctx->extradata_size = header_ptr->nFilledLen;
> avctx->extradata = av_mallocz(avctx->extradata_size +
> AV_INPUT_BUFFER_PADDING_SIZE);
> 
> -Jing
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v12 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-05-09 Thread Li, Zhong
> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of James Almer
> Sent: Friday, May 10, 2019 12:05 PM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH v12 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> >You used av_mallocz() to allocate the buffer, so it's already fully zeroed.
> >In any case, it would be faster to instead use av_malloc() above, then only
> zero the padding bytes here. Since you're copying the actual data in the line
> below, nothing will remain uninitialized.
> 
> Hi Almer,
> 
> Thanks for the review! Indeed the explicit memset() is redundant and I have
> removed that.
> 
> void *av_mallocz(size_t size)
> {
> void *ptr = av_malloc(size);
> if (ptr)
> memset(ptr, 0, size);
> return ptr;
> }
> 
> -Jing
The better solution should be: use av_malloc and just memset the padding bytes.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH 1/3] lavc/qsvdec: add query function and provide error message

2019-05-05 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Zhong Li
> Sent: Tuesday, April 30, 2019 5:04 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Li, Zhong 
> Subject: [FFmpeg-devel] [PATCH 1/3] lavc/qsvdec: add query function and
> provide error message
> 
> It is helpful to know why some clips decoding failed.
> Ticket#7330 is a good example, with this patch it is easily to know bitstream
> codec level is out of support range.
> 
> Signed-off-by: Zhong Li 
> ---
>  libavcodec/qsvdec.c | 33 +
>  1 file changed, 33 insertions(+)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> 4a0be811fb..2a8a032111 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -120,6 +120,33 @@ static inline unsigned int qsv_fifo_size(const
> AVFifoBuffer* fifo)
>  return av_fifo_size(fifo) / qsv_fifo_item_size();  }
> 
> +static int check_dec_param(AVCodecContext *avctx, QSVContext *q,
> +mfxVideoParam *param_in) {
> +mfxVideoParam param_out = { .mfx.CodecId =
> param_in->mfx.CodecId };
> +mfxStatus ret;
> +
> +#define CHECK_MATCH(x) \
> +do { \
> +  if (param_out.mfx.x != param_in->mfx.x) {   \
> +  av_log(avctx, AV_LOG_WARNING, "Required "#x" %d is
> unsupported\n", \
> +  param_in->mfx.x); \
> +  } \
> +} while (0)
> +
> +ret = MFXVideoDECODE_Query(q->session, param_in, _out);
> +
> +if (ret < 0) {
> +CHECK_MATCH(CodecId);
> +CHECK_MATCH(CodecProfile);
> +CHECK_MATCH(CodecLevel);
> +CHECK_MATCH(FrameInfo.Width);
> +CHECK_MATCH(FrameInfo.Height);
> +#undef CHECK_MATCH
> +return 0;
> +}
> +return 1;
> +}
> +
>  static int qsv_decode_init(AVCodecContext *avctx, QSVContext *q)  {
>  const AVPixFmtDescriptor *desc;
> @@ -206,6 +233,12 @@ static int qsv_decode_init(AVCodecContext *avctx,
> QSVContext *q)
>  param.ExtParam= q->ext_buffers;
>  param.NumExtParam = q->nb_ext_buffers;
> 
> +if (!check_dec_param(avctx, q, )) {
> +//Just give a warning instead of an error since it is still decodable
> possibly.
> +av_log(avctx, AV_LOG_WARNING,
> +   "Current input bitstream is not supported by QSV
> decoder.\n");
> +}
> +
>  ret = MFXVideoDECODE_Init(q->session, );
>  if (ret < 0)
>  return ff_qsv_print_error(avctx, ret,
> --
> 2.17.1

Ping for comment of this patch set.  
Thanks
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [DECISION] Project policy on closed source components

2019-05-05 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Marton Balint
> Sent: Monday, April 29, 2019 4:02 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [DECISION] Project policy on closed source
> components
> 
> Hi All,
> 
> There has been discussion on the mailing list several times about the
> inclusion of support for closed source components (codecs, formats, filters,
> etc) in the main ffmpeg codebase.
> 
> Also the removal of libNDI happened without general consensus, so a vote is
> necessary to justify the removal.
> 
> So here is a call to the voting committee [1] to decide on the following two
> questions:
> 
> 1) Should libNDI support be removed from the ffmpeg codebase?

Yes

> 2) Should patches using closed source libraries which are not considered
> "System Libraries" according to the GPL be rejected?
> 
> Deadline for voting is 7 days from now.

Yes.

(Looks it is a good chance to have a good summary (or guide) about the whole 
vote process, including which case can trigger a vote, how to define a vote 
period,
how to remove vote committee who are not active and add new committee, and so 
on )
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH] libavcodec/vp9: fix ref-frame size judging method

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

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

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

Patch makes sense, but I wonder is there any clip to reproduce the issue you 
want to fix?
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v2] lavc/qsvenc: Fix the memory leak for enc_ctrl.Payload

2019-04-29 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Monday, April 15, 2019 9:23 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v2] lavc/qsvenc: Fix the memory leak for
> enc_ctrl.Payload
> 
> frame->enc_ctrl.Payload is malloced in get_free_frame, directly memset
> the whole structure of enc_ctrl to zero will cause the memory leak for
> enc_ctrl.Payload.
> 
> frame->enc_ctrl as a structure will be malloc and init to zero by
> frame->calling
> frame = av_mallocz(sizeof(*frame)), so the memset is redundant and can be
> removed.
> 
> Can be reproduced by #7830.

Patch LGTM now, but I can't see strong relationship between this patch and 
tikect #7830.
IMHO this is a quite common issue even if you use qsv transcoding pipeline? 

> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/qsvenc.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index
> 5aa020d47b..19953bd4ea 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -1254,7 +1254,6 @@ static int encode_frame(AVCodecContext *avctx,
> QSVEncContext *q,
>  if (qsv_frame) {
>  surf = _frame->surface;
>  enc_ctrl = _frame->enc_ctrl;
> -memset(enc_ctrl, 0, sizeof(mfxEncodeCtrl));
> 
>  if (frame->pict_type == AV_PICTURE_TYPE_I) {
>  enc_ctrl->FrameType = MFX_FRAMETYPE_I |
> MFX_FRAMETYPE_REF;
> --
> 2.17.1

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

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

Re: [FFmpeg-devel] [PATCH] libavcodec: QSV protect GPB code with CO3 define

2019-04-29 Thread Li, Zhong
> > But the CODE doesn't say that!
> >
> > The code uses:
> > "#if QSV_HAVE_CO3"
> >
> > And then every use of the "co3" member needs to be protected by this
> clausule.
> > Futhermore, this is true in every part of the source code in
> > "qsvenc.c"... except at two points (I need to review my patch, as I noticed
> another block not protected).
> >
> > This is a must, even if "QSV_VERSION_ATLEAST(1, 18)" >
> "QSV_VERSION_ATLEAST(1, 11)"
> >
> > Why?
> > Because the option "QSV_HAVE_CO3" can be rewriten (for example,
> disabled).

I don't think so.
It is pre-compile checking and should not be decided in FFmpeg level, indstead 
depended on MSDK API has defined it or not.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH, v3] lavu/hwcontext_qsv: Fix the realign check for hwupload

2019-04-28 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Monday, April 15, 2019 9:24 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v3] lavu/hwcontext_qsv: Fix the realign
> check for hwupload
> 
> Fix the aligned check in hwupload, input surface should be 16 aligned too.
> 
> Fix #7830.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavutil/hwcontext_qsv.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> b6d8bfe2bf..197dd8002a 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -891,8 +891,7 @@ static int
> qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
>  if (ret < 0)
>  return ret;
> 
> -
> -if (src->height & 16 || src->linesize[0] & 16) {
> +if (src->height & 15 || src->linesize[0] & 15) {
>  realigned = 1;
>  memset(_frame, 0, sizeof(tmp_frame));
>  tmp_frame.format = src->format;
> --
> 2.17.1

LGTM, will apply.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream properties

2019-04-28 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Tuesday, April 2, 2019 7:40 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v2 4/9] vp9_parser: Return stream
> properties
> 
> Rewrites the parser entirely, using CBS for header parsing.
> ---
>  libavcodec/vp9_parser.c | 112 +---
>  1 file changed, 82 insertions(+), 30 deletions(-)
> 
> diff --git a/libavcodec/vp9_parser.c b/libavcodec/vp9_parser.c index
> c957a75667..6bf4f30e80 100644
> --- a/libavcodec/vp9_parser.c
> +++ b/libavcodec/vp9_parser.c
> @@ -1,8 +1,5 @@
>  /*
> - * VP9 compatible video decoder
> - *
> - * Copyright (C) 2013 Ronald S. Bultje 
> - * Copyright (C) 2013 Clément Bœsch 
> + * VP9 parser
>   *
>   * This file is part of FFmpeg.
>   *
> @@ -21,50 +18,105 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
> USA
>   */
> 
> -#include "libavutil/intreadwrite.h"
> -#include "libavcodec/get_bits.h"
> +#include "libavutil/avassert.h"
> +#include "cbs.h"
> +#include "cbs_vp9.h"
>  #include "parser.h"
> 
> -static int parse(AVCodecParserContext *ctx,
> - AVCodecContext *avctx,
> - const uint8_t **out_data, int *out_size,
> - const uint8_t *data, int size)
> +typedef struct VP9ParserContext {
> +CodedBitstreamContext *cbc;
> +VP9RawFrameHeader frame_header;
> +} VP9ParserContext;
> +
> +static const enum AVPixelFormat vp9_pix_fmts[3][2][2] = {
> +{ // 8-bit.
> +{ AV_PIX_FMT_YUV444P, AV_PIX_FMT_YUV440P },
> +{ AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P },
> +},
> +{ // 10-bit.
> +{ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_YUV440P10 },
> +{ AV_PIX_FMT_YUV422P10, AV_PIX_FMT_YUV420P10 },
> +},
> +{ // 12-bit.
> +{ AV_PIX_FMT_YUV444P12, AV_PIX_FMT_YUV440P12 },
> +{ AV_PIX_FMT_YUV422P12, AV_PIX_FMT_YUV420P12 },
> +},
> +};
> +
> +static int vp9_parser_parse(AVCodecParserContext *ctx,
> +AVCodecContext *avctx,
> +const uint8_t **out_data, int *out_size,
> +const uint8_t *data, int size)
>  {
> -GetBitContext gb;
> -int res, profile, keyframe;
> +VP9ParserContext *s = ctx->priv_data;
> +const CodedBitstreamVP9Context *vp9 = s->cbc->priv_data;
> +const VP9RawFrameHeader *fh;
> +int err;
> 
>  *out_data = data;
>  *out_size = size;
> 
> -if (!size || (res = init_get_bits8(, data, size)) < 0)
> -return size; // parsers can't return errors
> -get_bits(, 2); // frame marker
> -profile  = get_bits1();
> -profile |= get_bits1() << 1;
> -if (profile == 3) profile += get_bits1();
> -if (profile > 3)
> -return size;
> +ctx->key_frame = -1;
> +ctx->pict_type = AV_PICTURE_TYPE_NONE;
> +ctx->picture_structure = AV_PICTURE_STRUCTURE_UNKNOWN;
> 
> -avctx->profile = profile;
> +if (!size)
> +return 0;
> 
> -if (get_bits1()) {
> -keyframe = 0;
> -} else {
> -keyframe  = !get_bits1();
> +s->cbc->log_ctx = avctx;
> +
> +err = ff_cbs_parse_headers(s->cbc, >frame_header, data, size);
> +if (err < 0) {
> +av_log(avctx, AV_LOG_WARNING, "Failed to parse VP9 frame
> headers.\n");
> +goto end;
>  }
> +fh = >frame_header;
> 
> -if (!keyframe) {
> -ctx->pict_type = AV_PICTURE_TYPE_P;
> -ctx->key_frame = 0;
> -} else {
> +avctx->profile = vp9->profile;
> +avctx->level   = FF_LEVEL_UNKNOWN;
> +
> +ctx->width  = ctx->coded_width  = vp9->frame_width;
> +ctx->height = ctx->coded_height = vp9->frame_height;
> +
> +if (fh->frame_type == VP9_KEY_FRAME) {
>  ctx->pict_type = AV_PICTURE_TYPE_I;
>  ctx->key_frame = 1;
> +} else {
> +ctx->pict_type = fh->intra_only ? AV_PICTURE_TYPE_I :
> AV_PICTURE_TYPE_P;
> +ctx->key_frame = 0;
>  }
> 
> +ctx->picture_structure = AV_PICTURE_STRUCTURE_FRAME;
> +
> +av_assert0(vp9->bit_depth == 8  ||
> +   vp9->bit_depth == 10 ||
> +   vp9->bit_depth == 12);
> +
> +ctx->format = vp9_pix_fmts[(vp9->bit_depth - 8) / 2]
> +
> [vp9->subsampling_x][vp9->subsampling_y];
> +
> +end:
> +s->cbc->log_ctx = NULL;
> +
>  return size;
>  }
> 
> +static av_cold int vp9_parser_init(AVCodecParserContext *ctx) {
> +VP9ParserContext *s = ctx->priv_data;
> +return ff_cbs_init(>cbc, AV_CODEC_ID_VP9, NULL); }
> +
> +static av_cold void vp9_parser_close(AVCodecParserContext *ctx) {
> +VP9ParserContext *s = ctx->priv_data;
> +ff_cbs_close(>cbc);
> +}
> +
>  AVCodecParser ff_vp9_parser = {
>  .codec_ids  = { AV_CODEC_ID_VP9 },
> -.parser_parse   = parse,
> +.priv_data_size = sizeof(VP9ParserContext),
> +.parser_init= _parser_init,
> +.parser_close   = _parser_close,
> +.parser_parse   = _parser_parse,
>  

Re: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-04-26 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Jing Sun
> Sent: Tuesday, April 2, 2019 3:02 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Sun, Jing A ; Huang, Zhengxu
> ; Jun Zhao ; Tmar,
> Hassene 
> Subject: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc

Is it V11 now? (Just saw several V10 and I am a litter confused.)

> encoder wrapper

Since there is some existed software HEVC encoder, how about add a link to the 
SVT-HEVC writepaper in the commit message
to make other easily to understand what is the advantage of SVT-HEVC and the 
benefit to plugin to FFmpeg?

> Signed-off-by: Zhengxu Huang 
> Signed-off-by: Hassene Tmar 
> Signed-off-by: Jun Zhao 
> Signed-off-by: Jing Sun 
> ---
>  configure|   4 +
>  libavcodec/Makefile  |   1 +
>  libavcodec/allcodecs.c   |   1 +
>  libavcodec/libsvt_hevc.c | 482
> +++
>  4 files changed, 488 insertions(+)
>  create mode 100644 libavcodec/libsvt_hevc.c
> 
> diff --git a/configure b/configure
> index 938ff10..2aabac4 100755
> --- a/configure
> +++ b/configure
> @@ -264,6 +264,7 @@ External library support:
>--enable-libspeexenable Speex de/encoding via libspeex [no]
>--enable-libsrt  enable Haivision SRT protocol via libsrt [no]
>--enable-libssh  enable SFTP protocol via libssh [no]
> +  --enable-libsvthevc  enable HEVC encoding via svt [no]
>--enable-libtensorflow   enable TensorFlow as a DNN module backend
> for DNN based filters like sr [no]
>--enable-libtesseractenable Tesseract, needed for ocr filter [no]
> @@ -1784,6 +1785,7 @@ EXTERNAL_LIBRARY_LIST="
>  libspeex
>  libsrt
>  libssh
> +libsvthevc
>  libtensorflow
>  libtesseract
>  libtheora
> @@ -3173,6 +3175,7 @@ libshine_encoder_select="audio_frame_queue"
>  libspeex_decoder_deps="libspeex"
>  libspeex_encoder_deps="libspeex"
>  libspeex_encoder_select="audio_frame_queue"
> +libsvt_hevc_encoder_deps="libsvthevc"
>  libtheora_encoder_deps="libtheora"
>  libtwolame_encoder_deps="libtwolame"
>  libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
> @@ -6209,6 +6212,7 @@ enabled libsoxr   && require libsoxr
> soxr.h soxr_create -lsoxr
>  enabled libssh&& require_pkg_config libssh libssh
> libssh/sftp.h sftp_init
>  enabled libspeex  && require_pkg_config libspeex speex
> speex/speex.h speex_decoder_init
>  enabled libsrt&& require_pkg_config libsrt "srt >= 1.3.0"
> srt/srt.h srt_socket
> +enabled libsvthevc&& require_pkg_config libsvthevc SvtHevcEnc
> EbApi.h EbInitHandle
>  enabled libtensorflow && require libtensorflow tensorflow/c/c_api.h
> TF_Version -ltensorflow
>  enabled libtesseract  && require_pkg_config libtesseract tesseract
> tesseract/capi.h TessBaseAPICreate
>  enabled libtheora && require libtheora theora/theoraenc.h
> th_info_init -ltheoraenc -ltheoradec -logg
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile index
> 15c43a8..c93e545 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -987,6 +987,7 @@ OBJS-$(CONFIG_LIBOPUS_ENCODER)
> += libopusenc.o libopus.o \
>  OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
>  OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
>  OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
> +OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER)+= libsvt_hevc.o
>  OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
>  OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
>  OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) +=
> libvo-amrwbenc.o
> diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index
> b26aeca..e93f66f 100644
> --- a/libavcodec/allcodecs.c
> +++ b/libavcodec/allcodecs.c
> @@ -703,6 +703,7 @@ extern AVCodec ff_librsvg_decoder;  extern
> AVCodec ff_libshine_encoder;  extern AVCodec ff_libspeex_encoder;
> extern AVCodec ff_libspeex_decoder;
> +extern AVCodec ff_libsvt_hevc_encoder;
>  extern AVCodec ff_libtheora_encoder;
>  extern AVCodec ff_libtwolame_encoder;
>  extern AVCodec ff_libvo_amrwbenc_encoder; diff --git
> a/libavcodec/libsvt_hevc.c b/libavcodec/libsvt_hevc.c new file mode 100644
> index 000..5534389
> --- /dev/null
> +++ b/libavcodec/libsvt_hevc.c
> @@ -0,0 +1,482 @@
> +/*
> +* Scalable Video Technology for HEVC encoder library plugin
> +*
> +* Copyright (c) 2019 Intel Corporation
> +*
> +* 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 

Re: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc encoder wrapper

2019-04-26 Thread Li, Zhong
> From: Sun, Jing A
> Sent: Tuesday, April 2, 2019 2:02 PM
> To: Li, Zhong ; FFmpeg development discussions and
> patches 
> Cc: Huang, Zhengxu ; Jun Zhao
> ; Tmar, Hassene 
> Subject: RE: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> -Original Message-
> From: Li, Zhong
> Sent: Friday, March 29, 2019 6:59 PM
> To: FFmpeg development discussions and patches
> 
> Cc: Sun, Jing A ; Huang, Zhengxu
> ; Jun Zhao ; Tmar,
> Hassene 
> Subject: RE: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc
> encoder wrapper
> 
> > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> Behalf
> > Of Jing Sun
> > Sent: Friday, March 29, 2019 4:22 PM
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Sun, Jing A ; Huang, Zhengxu
> > ; Jun Zhao ; Tmar,
> > Hassene 
> > Subject: [FFmpeg-devel] [PATCH v10 1/2] lavc/svt_hevc: add libsvt hevc
> > encoder wrapper
> >
> > Signed-off-by: Zhengxu Huang 
> > Signed-off-by: Hassene Tmar 
> > Signed-off-by: Jun Zhao 
> > Signed-off-by: Jing Sun 
> > ---
> >  configure|   4 +
> >  libavcodec/Makefile  |   1 +
> >  libavcodec/allcodecs.c   |   1 +
> >  libavcodec/libsvt_hevc.c | 500
> > +++
> >  4 files changed, 506 insertions(+)
> >  create mode 100644 libavcodec/libsvt_hevc.c
> >
> > diff --git a/configure b/configure
> > index 938ff10..2aabac4 100755
> > --- a/configure
> > +++ b/configure
> > @@ -264,6 +264,7 @@ External library support:
> >--enable-libspeexenable Speex de/encoding via libspeex [no]
> >--enable-libsrt  enable Haivision SRT protocol via libsrt [no]
> >--enable-libssh  enable SFTP protocol via libssh [no]
> > +  --enable-libsvthevc  enable HEVC encoding via svt [no]
> >--enable-libtensorflow   enable TensorFlow as a DNN module
> backend
> > for DNN based filters like sr [no]
> >--enable-libtesseractenable Tesseract, needed for ocr filter [no]
> > @@ -1784,6 +1785,7 @@ EXTERNAL_LIBRARY_LIST="
> >  libspeex
> >  libsrt
> >  libssh
> > +libsvthevc
> >  libtensorflow
> >  libtesseract
> >  libtheora
> > @@ -3173,6 +3175,7 @@ libshine_encoder_select="audio_frame_queue"
> >  libspeex_decoder_deps="libspeex"
> >  libspeex_encoder_deps="libspeex"
> >  libspeex_encoder_select="audio_frame_queue"
> > +libsvt_hevc_encoder_deps="libsvthevc"
> >  libtheora_encoder_deps="libtheora"
> >  libtwolame_encoder_deps="libtwolame"
> >  libvo_amrwbenc_encoder_deps="libvo_amrwbenc"
> > @@ -6209,6 +6212,7 @@ enabled libsoxr   && require libsoxr
> > soxr.h soxr_create -lsoxr
> >  enabled libssh&& require_pkg_config libssh libssh
> > libssh/sftp.h sftp_init
> >  enabled libspeex  && require_pkg_config libspeex speex
> > speex/speex.h speex_decoder_init
> >  enabled libsrt&& require_pkg_config libsrt "srt >= 1.3.0"
> > srt/srt.h srt_socket
> > +enabled libsvthevc&& require_pkg_config libsvthevc
> SvtHevcEnc
> > EbApi.h EbInitHandle
> >  enabled libtensorflow && require libtensorflow
> tensorflow/c/c_api.h
> > TF_Version -ltensorflow
> >  enabled libtesseract  && require_pkg_config libtesseract tesseract
> > tesseract/capi.h TessBaseAPICreate
> >  enabled libtheora && require libtheora theora/theoraenc.h
> > th_info_init -ltheoraenc -ltheoradec -logg diff --git
> > a/libavcodec/Makefile b/libavcodec/Makefile index
> > 15c43a8..c93e545 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -987,6 +987,7 @@ OBJS-$(CONFIG_LIBOPUS_ENCODER)
> > += libopusenc.o libopus.o \
> >  OBJS-$(CONFIG_LIBSHINE_ENCODER)   += libshine.o
> >  OBJS-$(CONFIG_LIBSPEEX_DECODER)   += libspeexdec.o
> >  OBJS-$(CONFIG_LIBSPEEX_ENCODER)   += libspeexenc.o
> > +OBJS-$(CONFIG_LIBSVT_HEVC_ENCODER)+= libsvt_hevc.o
> >  OBJS-$(CONFIG_LIBTHEORA_ENCODER)  += libtheoraenc.o
> >  OBJS-$(CONFIG_LIBTWOLAME_ENCODER) += libtwolame.o
> >  OBJS-$(CONFIG_LIBVO_AMRWBENC_ENCODER) +=
> > libvo-amrwbenc.o
> > diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index
> > b26aeca..e93f66f 100644
> > --- a/libavcodec/allcodecs.c
> >

Re: [FFmpeg-devel] [PATCH] libavcodec: QSV protect GPB code with CO3 define

2019-04-23 Thread Li, Zhong


> -Original Message-
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Andreas Håkon
> Sent: Monday, April 22, 2019 8:21 PM
> To: FFmpeg development discussions and patches
> 
> Subject: Re: [FFmpeg-devel] [PATCH] libavcodec: QSV protect GPB code with
> CO3 define
> 
> 
> ‐‐‐ Original Message ‐‐‐
> On Monday, 22 de April de 2019 13:33, Li, Zhong 
> wrote:
> 
> > > From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On
> > > Behalf Of Andreas Håkon via ffmpeg-devel
> > > Sent: Thursday, April 18, 2019 6:11 PM
> > > To: FFmpeg development discussions and patches
> > > ffmpeg-devel@ffmpeg.org
> > > Cc: Andreas Håkon andreas.ha...@protonmail.com
> > > Subject: [FFmpeg-devel] [PATCH] libavcodec: QSV protect GPB code
> > > with
> > > CO3 define
> > > Hi,
> > > In response to this ticket I provide the first part of the patch:
> > > https://trac.ffmpeg.org/ticket/7839
> > > This QSV_HAVE_GPB code needs to be protected by QSV_HAVE_CO3.
> > > Regards.
> > > A.H.
> >
> > Why it is must? It is impossible that QSV_HAVE_GPB is enabled but
> QSV_HAVE_CO3 is not enabled.
> > QSV_HAVE_GPB is enabled by MSDK API v1.18, but QSV_HAVE_CO3 is API
> V1.11.
> >
> 
> Hi Li,
> 
> > Why it is must?
> 
> Let me to explain why:
> 
> - The "#if QSV_HAVE_GPB" only appears two times inside
> "/libavcodec/qsvenc.c":
>   1.
> https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvenc.c#L75
> 6
>   2.
> https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/qsvenc.c#L27
> 0
> 
> In the first occurrence (line #756) the code is protected by one "#if
> QSV_HAVE_CO3". This is necessary because if QSV_HAVE_CO3 is not enabled
> then the code fails when using "extco3.GPB". The original author (which I
> think was you) included the test with sound common sense.

I belive they are different. If you extend the MARCIO, they are actually:

Case 1:
#if QSV_VERSION_ATLEAST(1, 11)
q->extco3.Header.BufferId  = MFX_EXTBUFF_CODING_OPTION3;
q->extco3.Header.BufferSz  = sizeof(q->extco3);
#if QSV_VERSION_ATLEAST(1, 18)
if (avctx->codec_id == AV_CODEC_ID_HEVC)
q->extco3.GPB  = q->gpb ? MFX_CODINGOPTION_ON : 
MFX_CODINGOPTION_OFF;
#endif
q->extparam_internal[q->nb_extparam_internal++] = (mfxExtBuffer 
*)>extco3;
#endif

And Case2:

#if QSV_VERSION_ATLEAST(1, 18)
if (avctx->codec_id == AV_CODEC_ID_HEVC)
av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB));
#endif

You must add "#if QSV_VERSION_ATLEAST(1, 11)"  for case 1, else " 
q->extco3.Header.BufferId = MFX_EXTBUFF_CODING_OPTION3;" is broken.
But you don't need change Case 2 to be:
#if QSV_VERSION_ATLEAST(1, 11)
#if QSV_VERSION_ATLEAST(1, 18)
if (avctx->codec_id == AV_CODEC_ID_HEVC)
av_log(avctx, AV_LOG_VERBOSE,"GPB: %s\n", print_threestate(co3->GPB));
#endif
#endif

> In the second occurrence (line #270) where my patch is applied, the code
> isn't protected. The reason is because this code is changed **after**. And
> the developer forgot to protect it.
> 
> So my patch is a simple fixing.
> 
> > It is impossible that QSV_HAVE_GPB is enabled but QSV_HAVE_CO3 is not
> enabled.
> > QSV_HAVE_GPB is enabled by MSDK API v1.18, but QSV_HAVE_CO3 is API
> V1.11.
> 
> This isn't true in all cases. As described in
> "https://trac.ffmpeg.org/ticket/7839;
> one current bug breaks the "mpeg2_qsv" encoder. One solution is to
> MANUALLY disable the QVBR. This can be done with a simple "#define
> QSV_HAVE_QVBR 0". Even if you compile with a recent version of the SDK >
> v1.11.
> 
> But the problem is then that this implies too to disable "QSV_HAVE_CO3".
> And doing this the code doesn't compile as this patch isn't applied.
> 
> So, the best solution is to merge this patch. It enables then the option to
> disable manually what you like, and the code compiles clean.
> 
> Please, accept the patch.

IMHO, your patch is only needed when disable "QSV_HAVE_CO3", but tiket#7839 is 
not root caused now.
I will consider to accept it when tiket#7839 is root caused.

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

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

Re: [FFmpeg-devel] [PATCH] libavcodec: QSV protect GPB code with CO3 define

2019-04-22 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Andreas Håkon via ffmpeg-devel
> Sent: Thursday, April 18, 2019 6:11 PM
> To: FFmpeg development discussions and patches
> 
> Cc: Andreas Håkon 
> Subject: [FFmpeg-devel] [PATCH] libavcodec: QSV protect GPB code with
> CO3 define
> 
> Hi,
> 
> In response to this ticket I provide the first part of the patch:
> https://trac.ffmpeg.org/ticket/7839
> 
> This QSV_HAVE_GPB code needs to be protected by QSV_HAVE_CO3.
> 
> Regards.
> A.H.

Why it is must? It is impossible that QSV_HAVE_GPB is enabled but QSV_HAVE_CO3 
is not enabled.
QSV_HAVE_GPB is enabled by MSDK API v1.18, but QSV_HAVE_CO3 is API V1.11.
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

Re: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder support

2019-04-15 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Mark Thompson
> Sent: Tuesday, April 2, 2019 7:40 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: [FFmpeg-devel] [PATCH v2 5/9] lavc/qsvdec: Add VP9 decoder
> support
> 
> From: Zhong Li 
> 
> VP9 decoder is supported on Intel kabyLake+ platforms with MSDK Version
> 1.19+
> 
> Signed-off-by: Zhong Li 
> ---
> On 20/03/2019 14:41, Li, Zhong wrote:
> > Yes, QSV is a marketing name which is no equal to libmfx/MSDK.
> > But would be better to keep consistent with others, such as "Intel
> QSV-accelerated VP8 video decoding" in pervious changelog?
> 
> I don't think so?  VP9 decoding with the QSV hardware is already supported,
> this only adds the additional option of using libmfx to access the same thing
> as well.

Ok, here are just some words description of changelog. I will be happy to see 
this patch can be applied.
(As previous comment, the updated version of vp9 parser with pic_type of key 
frame issue fixing LGTM.)

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

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

Re: [FFmpeg-devel] [PATCH 1/2] lavc/qsvenc: Fix the memory leak for enc_ctrl.Payload

2019-04-10 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Wednesday, April 10, 2019 7:27 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH 1/2] lavc/qsvenc: Fix the memory leak for
> enc_ctrl.Payload
> 
> frame->enc_ctrl.Payload is malloced in get_free_frame, directly memset
> the whole structure of enc_ctrl to zero will cause the memory leak for
> enc_ctrl.Payload.
> 
> Fix the memory leak issue and reset other members in mfxEncodeCtrl.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/qsvenc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index
> 5aa020d47b..029bb562d6 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -1254,7 +1254,7 @@ static int encode_frame(AVCodecContext *avctx,
> QSVEncContext *q,
>  if (qsv_frame) {
>  surf = _frame->surface;
>  enc_ctrl = _frame->enc_ctrl;
> -memset(enc_ctrl, 0, sizeof(mfxEncodeCtrl));
> +memset(enc_ctrl, 0, sizeof(mfxEncodeCtrl) - sizeof(mfxPayload
> + **));

Looks a little tricky, if someone didn't read carefully the sequence of 
mfxPayload usages, they can't know why this change happening. 
And potential risk for other elements such as "mfxExtBuffer** ExtParam" is 
still existed. 

IMHO, one good habit is that is you want to memset a buffer, would better 
memset it when you allocate it. 
So I believe the correct fix should be: memset mfxEncodeCtrl at the start of 
qsv frame allocated: the place should be in the function get_free_frame()



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

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

Re: [FFmpeg-devel] [PATCH, v2] lavu/hwcontext_qsv: Fix the realign check for hwupload

2019-04-10 Thread Li, Zhong
> From: ffmpeg-devel [mailto:ffmpeg-devel-boun...@ffmpeg.org] On Behalf
> Of Linjie Fu
> Sent: Wednesday, April 10, 2019 7:56 PM
> To: ffmpeg-devel@ffmpeg.org
> Cc: Fu, Linjie 
> Subject: [FFmpeg-devel] [PATCH, v2] lavu/hwcontext_qsv: Fix the realign
> check for hwupload
> 
> Fix the aligned check in hwupload, input surface should be 16 aligned too.
> 
> Fix #7830.
> 
> Signed-off-by: Linjie Fu 
> ---
> 
>  libavutil/hwcontext_qsv.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> b6d8bfe2bf..8b000fe636 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -892,7 +892,8 @@ static int
> qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
>  return ret;
> 
> 
> -if (src->height & 16 || src->linesize[0] & 16) {
> +if (src->height & 15 || src->width & 15 ||
> +src->linesize[0] & 15) {

Should be better to use FFALIGN()

Another question is it really necessary to check width alignment if we already 
checked linesize to fix this issue?
(I guess it it not necessary, and if it is needed, many other places probably 
needed to be changed too.)
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

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

  1   2   3   >