Re: [libav-devel] [PATCH V2 2/3] lavu/hwcontext_qsv: Add support for pix_fmt RGB32.

2018-03-29 Thread Mark Thompson
On 22/03/18 14:41, Zhong Li wrote:
> RGB32 format may be used as overlay with alpha blending.
> So add RGB32 format support.
> 
> Signed-off-by: ChaoX A Liu 
> Signed-off-by: Zhong Li 
> ---
>  libavutil/hwcontext_qsv.c | 43 +--
>  1 file changed, 33 insertions(+), 10 deletions(-)

Please write BGRA rather than RGB32.  I doubt this will ever run on a 
big-endian machine, but it would be clearer.

> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
> index 5018a05..0db446b 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -90,6 +90,7 @@ static const struct {
>  uint32_t   fourcc;
>  } supported_pixel_formats[] = {
>  { AV_PIX_FMT_NV12, MFX_FOURCC_NV12 },
> +{ AV_PIX_FMT_RGB32,MFX_FOURCC_RGB4 },
>  { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
>  { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
>  };
> @@ -730,6 +731,36 @@ static int qsv_transfer_data_child(AVHWFramesContext 
> *ctx, AVFrame *dst,
>  return ret;
>  }
>  
> +static int map_frame_to_surface(const AVFrame *frame, mfxFrameSurface1 
> *surface)
> +{
> +switch (frame->format) {
> +case AV_PIX_FMT_NV12:

Indentation - case labels should be at the same level as switch.

> +surface->Data.Y  = frame->data[0];
> +surface->Data.UV = frame->data[1];
> +break;
> +
> +case AV_PIX_FMT_YUV420P:
> +surface->Data.Y = frame->data[0];
> +surface->Data.U = frame->data[1];
> +surface->Data.V = frame->data[2];
> +break;
> +
> +case AV_PIX_FMT_RGB32:
> +surface->Data.B = frame->data[0];
> +surface->Data.G = frame->data[0] + 1;
> +surface->Data.R = frame->data[0] + 2;
> +surface->Data.A = frame->data[0] + 3;
> +break;
> +
> +default:
> +return MFX_ERR_UNSUPPORTED;
> +}
> +surface->Data.Pitch = frame->linesize[0];

What happens if linesize[0] != linesize[1]?  (You aren't introducing that 
problem, but I hadn't seen it before.)

> +surface->Data.TimeStamp = frame->pts;
> +
> +return 0;
> +}
> +
>  static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst,
>const AVFrame *src)
>  {
> @@ -749,11 +780,7 @@ static int qsv_transfer_data_from(AVHWFramesContext 
> *ctx, AVFrame *dst,
>  }
>  
>  out.Info = in->Info;
> -out.Data.PitchLow = dst->linesize[0];
> -out.Data.Y= dst->data[0];
> -out.Data.U= dst->data[1];
> -out.Data.V= dst->data[2];
> -out.Data.A= dst->data[3];
> +map_frame_to_surface(dst, );
>  
>  do {
>  err = MFXVideoVPP_RunFrameVPPAsync(s->session_download, in, , 
> NULL, );
> @@ -796,11 +823,7 @@ static int qsv_transfer_data_to(AVHWFramesContext *ctx, 
> AVFrame *dst,
>  }
>  
>  in.Info = out->Info;
> -in.Data.PitchLow = src->linesize[0];
> -in.Data.Y= src->data[0];
> -in.Data.U= src->data[1];
> -in.Data.V= src->data[2];
> -in.Data.A= src->data[3];
> +map_frame_to_surface(src, );
>  
>  do {
>  err = MFXVideoVPP_RunFrameVPPAsync(s->session_upload, , out, 
> NULL, );
> 

This has slightly changed what gets passed for YUV420P and NV12 - it no longer 
sets the unused pointers to NULL.  Presumably that's always ok, even with old 
versions?

Thanks,

- Mark
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH V2 2/3] lavu/hwcontext_qsv: Add support for pix_fmt RGB32.

2018-03-29 Thread Maxym Dmytrychenko
should be ok,

will take care of it shotly

On Thu, Mar 29, 2018 at 4:05 PM, Li, Zhong  wrote:

> Ping?
>
> > -Original Message-
> > From: Li, Zhong
> > Sent: Thursday, March 22, 2018 10:42 PM
> > To: libav-devel@libav.org
> > Cc: Li, Zhong ; Liu, ChaoX A 
> > Subject: [PATCH V2 2/3] lavu/hwcontext_qsv: Add support for pix_fmt
> > RGB32.
> >
> > RGB32 format may be used as overlay with alpha blending.
> > So add RGB32 format support.
> >
> > Signed-off-by: ChaoX A Liu 
> > Signed-off-by: Zhong Li 
> > ---
> >  libavutil/hwcontext_qsv.c | 43
> > +--
> >  1 file changed, 33 insertions(+), 10 deletions(-)
> >
> > diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> > 5018a05..0db446b 100644
> > --- a/libavutil/hwcontext_qsv.c
> > +++ b/libavutil/hwcontext_qsv.c
> > @@ -90,6 +90,7 @@ static const struct {
> >  uint32_t   fourcc;
> >  } supported_pixel_formats[] = {
> >  { AV_PIX_FMT_NV12, MFX_FOURCC_NV12 },
> > +{ AV_PIX_FMT_RGB32,MFX_FOURCC_RGB4 },
> >  { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
> >  { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
> >  };
> > @@ -730,6 +731,36 @@ static int
> > qsv_transfer_data_child(AVHWFramesContext *ctx, AVFrame *dst,
> >  return ret;
> >  }
> >
> > +static int map_frame_to_surface(const AVFrame *frame,
> > mfxFrameSurface1
> > +*surface) {
> > +switch (frame->format) {
> > +case AV_PIX_FMT_NV12:
> > +surface->Data.Y  = frame->data[0];
> > +surface->Data.UV = frame->data[1];
> > +break;
> > +
> > +case AV_PIX_FMT_YUV420P:
> > +surface->Data.Y = frame->data[0];
> > +surface->Data.U = frame->data[1];
> > +surface->Data.V = frame->data[2];
> > +break;
> > +
> > +case AV_PIX_FMT_RGB32:
> > +surface->Data.B = frame->data[0];
> > +surface->Data.G = frame->data[0] + 1;
> > +surface->Data.R = frame->data[0] + 2;
> > +surface->Data.A = frame->data[0] + 3;
> > +break;
> > +
> > +default:
> > +return MFX_ERR_UNSUPPORTED;
> > +}
> > +surface->Data.Pitch = frame->linesize[0];
> > +surface->Data.TimeStamp = frame->pts;
> > +
> > +return 0;
> > +}
> > +
> >  static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame
> > *dst,
> >const AVFrame *src)  { @@
> > -749,11 +780,7 @@ static int qsv_transfer_data_from(AVHWFramesContext
> > *ctx, AVFrame *dst,
> >  }
> >
> >  out.Info = in->Info;
> > -out.Data.PitchLow = dst->linesize[0];
> > -out.Data.Y= dst->data[0];
> > -out.Data.U= dst->data[1];
> > -out.Data.V= dst->data[2];
> > -out.Data.A= dst->data[3];
> > +map_frame_to_surface(dst, );
> >
> >  do {
> >  err = MFXVideoVPP_RunFrameVPPAsync(s->session_download, in,
> > , NULL, ); @@ -796,11 +823,7 @@ static int
> > qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
> >  }
> >
> >  in.Info = out->Info;
> > -in.Data.PitchLow = src->linesize[0];
> > -in.Data.Y= src->data[0];
> > -in.Data.U= src->data[1];
> > -in.Data.V= src->data[2];
> > -in.Data.A= src->data[3];
> > +map_frame_to_surface(src, );
> >
> >  do {
> >  err = MFXVideoVPP_RunFrameVPPAsync(s->session_upload, ,
> > out, NULL, );
> > --
> > 1.8.3.1
>
> ___
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

Re: [libav-devel] [PATCH 1/2] avcodec: rename the AV1 profiles

2018-03-29 Thread Janne Grunau
On 2018-03-29 13:10:49 -0300, James Almer wrote:
> Use the proper names instead of numbers
> 
> Signed-off-by: James Almer 
> ---
>  libavcodec/avcodec.h   | 6 +++---
>  libavcodec/libaomenc.c | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index ac0915328..eb234a40d 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -2551,9 +2551,9 @@ typedef struct AVCodecContext {
>  #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
>  #define FF_PROFILE_HEVC_REXT4
>  
> -#define FF_PROFILE_AV1_00
> -#define FF_PROFILE_AV1_11
> -#define FF_PROFILE_AV1_22
> +#define FF_PROFILE_AV1_MAIN 0
> +#define FF_PROFILE_AV1_HIGH 1
> +#define FF_PROFILE_AV1_PROFESSIONAL 2
>  
>  /**
>   * level
> diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
> index 94b3ddd32..a2a2c3994 100644
> --- a/libavcodec/libaomenc.c
> +++ b/libavcodec/libaomenc.c
> @@ -302,13 +302,13 @@ static av_cold int aom_init(AVCodecContext *avctx)
>  if (avctx->profile != FF_PROFILE_UNKNOWN)
>  enccfg.g_profile = avctx->profile;
>  else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P)
> -avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_0;
> +avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_MAIN;
>  else {
>  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
>  if (desc->comp[0].depth < 12)
> -avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_1;
> +avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_HIGH;
>  else
> -avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_2;
> +avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_PROFESSIONAL;
>  }

both patched look good to j-b in irc and I agree

Janne
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel

[libav-devel] [PATCH 2/2] libaomenc: fix profile setting

2018-03-29 Thread James Almer
Main Profile is yuv420p 8 and 10 bit
High Profile is yuv444p 8 and 10 bit
Professional Profile is yuv422p 8, 10, and 12 bit, plus every other pixfmt at 
12 bit

Signed-off-by: James Almer 
---
 libavcodec/libaomenc.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index a2a2c3994..9807bd5ad 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -301,14 +301,14 @@ static av_cold int aom_init(AVCodecContext *avctx)
  * quality. */
 if (avctx->profile != FF_PROFILE_UNKNOWN)
 enccfg.g_profile = avctx->profile;
-else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P)
+else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P ||
+ avctx->pix_fmt == AV_PIX_FMT_YUV420P10)
 avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_MAIN;
+else if (avctx->pix_fmt == AV_PIX_FMT_YUV444P ||
+ avctx->pix_fmt == AV_PIX_FMT_YUV444P10)
+avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_HIGH;
 else {
-const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
-if (desc->comp[0].depth < 12)
-avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_HIGH;
-else
-avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_PROFESSIONAL;
+avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_PROFESSIONAL;
 }
 
 
-- 
2.16.2

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

[libav-devel] [PATCH 1/2] avcodec: rename the AV1 profiles

2018-03-29 Thread James Almer
Use the proper names instead of numbers

Signed-off-by: James Almer 
---
 libavcodec/avcodec.h   | 6 +++---
 libavcodec/libaomenc.c | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index ac0915328..eb234a40d 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2551,9 +2551,9 @@ typedef struct AVCodecContext {
 #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE  3
 #define FF_PROFILE_HEVC_REXT4
 
-#define FF_PROFILE_AV1_00
-#define FF_PROFILE_AV1_11
-#define FF_PROFILE_AV1_22
+#define FF_PROFILE_AV1_MAIN 0
+#define FF_PROFILE_AV1_HIGH 1
+#define FF_PROFILE_AV1_PROFESSIONAL 2
 
 /**
  * level
diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c
index 94b3ddd32..a2a2c3994 100644
--- a/libavcodec/libaomenc.c
+++ b/libavcodec/libaomenc.c
@@ -302,13 +302,13 @@ static av_cold int aom_init(AVCodecContext *avctx)
 if (avctx->profile != FF_PROFILE_UNKNOWN)
 enccfg.g_profile = avctx->profile;
 else if (avctx->pix_fmt == AV_PIX_FMT_YUV420P)
-avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_0;
+avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_MAIN;
 else {
 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
 if (desc->comp[0].depth < 12)
-avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_1;
+avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_HIGH;
 else
-avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_2;
+avctx->profile = enccfg.g_profile = FF_PROFILE_AV1_PROFESSIONAL;
 }
 
 
-- 
2.16.2

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

Re: [libav-devel] [PATCH] configure: Revert some incorrect uses of check_cc()

2018-03-29 Thread James Almer
On 3/29/2018 4:28 AM, Diego Biurrun wrote:
> ---
> 
> Thanks to James for pointing this out.
> 
>  configure | 16 +++-
>  1 file changed, 11 insertions(+), 5 deletions(-)
> 
> diff --git a/configure b/configure
> index 90fb6f07ca..a64f241560 100755
> --- a/configure
> +++ b/configure
> @@ -4841,7 +4841,9 @@ check_disable_warning_headers -Wno-unused-variable
>  
>  check_objcflags -fobjc-arc && enable objc_arc
>  
> -check_cc blocks_extension "" "void (^block)(void)"
> +test_cc < +void (^block)(void);
> +EOF
>  
>  # add some linker flags
>  check_ldflags -Wl,--warn-common
> @@ -4895,10 +4897,14 @@ if enabled proper_dce; then
>  if test_ldflags -Wl,${version_script},$TMPV; then
>  append SHFLAGS '-Wl,${version_script},\$(SUBDIR)lib\$(NAME).ver'
>  quotes='""'
> -check_cc symver_asm_label "" "void ff_foo(void) __asm__ 
> ("av_foo@VERSION");
> -  void ff_foo(void) { 
> ${inline_asm+__asm__($quotes);} }"
> -check_cc symver_gnu_asm   "" "__asm__(".symver 
> ff_foo,av_foo@VERSION");
> -  void ff_foo(void) {}"
> +test_cc < +void ff_foo(void) __asm__ ("av_foo@VERSION");
> +void ff_foo(void) { ${inline_asm+__asm__($quotes);} }
> +EOF
> +test_cc < +__asm__(".symver ff_foo,av_foo@VERSION");
> +void ff_foo(void) {}
> +EOF
>  fi
>  fi

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

Re: [libav-devel] [PATCH] configure: Revert some incorrect uses of check_cc()

2018-03-29 Thread Luca Barbato

On 29/03/2018 09:28, Diego Biurrun wrote:

---

Thanks to James for pointing this out.

  configure | 16 +++-
  1 file changed, 11 insertions(+), 5 deletions(-)



Probably Ok.

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

Re: [libav-devel] [PATCH V2 2/3] lavu/hwcontext_qsv: Add support for pix_fmt RGB32.

2018-03-29 Thread Li, Zhong
Ping?

> -Original Message-
> From: Li, Zhong
> Sent: Thursday, March 22, 2018 10:42 PM
> To: libav-devel@libav.org
> Cc: Li, Zhong ; Liu, ChaoX A 
> Subject: [PATCH V2 2/3] lavu/hwcontext_qsv: Add support for pix_fmt
> RGB32.
> 
> RGB32 format may be used as overlay with alpha blending.
> So add RGB32 format support.
> 
> Signed-off-by: ChaoX A Liu 
> Signed-off-by: Zhong Li 
> ---
>  libavutil/hwcontext_qsv.c | 43
> +--
>  1 file changed, 33 insertions(+), 10 deletions(-)
> 
> diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c index
> 5018a05..0db446b 100644
> --- a/libavutil/hwcontext_qsv.c
> +++ b/libavutil/hwcontext_qsv.c
> @@ -90,6 +90,7 @@ static const struct {
>  uint32_t   fourcc;
>  } supported_pixel_formats[] = {
>  { AV_PIX_FMT_NV12, MFX_FOURCC_NV12 },
> +{ AV_PIX_FMT_RGB32,MFX_FOURCC_RGB4 },
>  { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
>  { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
>  };
> @@ -730,6 +731,36 @@ static int
> qsv_transfer_data_child(AVHWFramesContext *ctx, AVFrame *dst,
>  return ret;
>  }
> 
> +static int map_frame_to_surface(const AVFrame *frame,
> mfxFrameSurface1
> +*surface) {
> +switch (frame->format) {
> +case AV_PIX_FMT_NV12:
> +surface->Data.Y  = frame->data[0];
> +surface->Data.UV = frame->data[1];
> +break;
> +
> +case AV_PIX_FMT_YUV420P:
> +surface->Data.Y = frame->data[0];
> +surface->Data.U = frame->data[1];
> +surface->Data.V = frame->data[2];
> +break;
> +
> +case AV_PIX_FMT_RGB32:
> +surface->Data.B = frame->data[0];
> +surface->Data.G = frame->data[0] + 1;
> +surface->Data.R = frame->data[0] + 2;
> +surface->Data.A = frame->data[0] + 3;
> +break;
> +
> +default:
> +return MFX_ERR_UNSUPPORTED;
> +}
> +surface->Data.Pitch = frame->linesize[0];
> +surface->Data.TimeStamp = frame->pts;
> +
> +return 0;
> +}
> +
>  static int qsv_transfer_data_from(AVHWFramesContext *ctx, AVFrame
> *dst,
>const AVFrame *src)  { @@
> -749,11 +780,7 @@ static int qsv_transfer_data_from(AVHWFramesContext
> *ctx, AVFrame *dst,
>  }
> 
>  out.Info = in->Info;
> -out.Data.PitchLow = dst->linesize[0];
> -out.Data.Y= dst->data[0];
> -out.Data.U= dst->data[1];
> -out.Data.V= dst->data[2];
> -out.Data.A= dst->data[3];
> +map_frame_to_surface(dst, );
> 
>  do {
>  err = MFXVideoVPP_RunFrameVPPAsync(s->session_download, in,
> , NULL, ); @@ -796,11 +823,7 @@ static int
> qsv_transfer_data_to(AVHWFramesContext *ctx, AVFrame *dst,
>  }
> 
>  in.Info = out->Info;
> -in.Data.PitchLow = src->linesize[0];
> -in.Data.Y= src->data[0];
> -in.Data.U= src->data[1];
> -in.Data.V= src->data[2];
> -in.Data.A= src->data[3];
> +map_frame_to_surface(src, );
> 
>  do {
>  err = MFXVideoVPP_RunFrameVPPAsync(s->session_upload, ,
> out, NULL, );
> --
> 1.8.3.1

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

Re: [libav-devel] [PATCH V2 1/3] lavc/qsvdec: set complete_frame flags for progressive picture

2018-03-29 Thread Li, Zhong
Ping? 

> -Original Message-
> From: Li, Zhong
> Sent: Thursday, March 22, 2018 10:42 PM
> To: libav-devel@libav.org
> Cc: Li, Zhong 
> Subject: [PATCH V2 1/3] lavc/qsvdec: set complete_frame flags for
> progressive picture
> 
> Set the flag MFX_BITSTREAM_COMPLETE_FRAME when it is a progressive
> picture.
> This can fix vc1 decoding segment fault issues because can't set the start
> code correctly.
> See: ./avconv -hwaccel qsv -c:v vc1_qsv -i /fate-suite/vc1/SA00040.vc1 -vf
> "hwdownload, format=nv12" -f rawvideo /dev/null
> 
> v2: fix some h264 interlaced clips regression a. field_order of some h264
> interlaced video (e.g: cama3_vtc_b.avc) is marked as AV_FIELD_UNKNOWN
>in h264_parser.c. This is not a completed frames.
>So only set the MFX_BITSTREAM_COMPLETE_FRAME when it is
> progressive.
> b. some clips have both progressive and interlaced frames
> (e.g.CAPAMA3_Sand_F.264),
>the parsed field_order maybe changed druing the decoding progress.
> 
> This patch has been verified for other codecs(mpeg2/hevc/vp8).
> 
> Signed-off-by: Zhong Li 
> ---
>  libavcodec/qsvdec.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c index
> c74ec68..8148beb 100644
> --- a/libavcodec/qsvdec.c
> +++ b/libavcodec/qsvdec.c
> @@ -321,6 +321,8 @@ static int qsv_decode(AVCodecContext *avctx,
> QSVContext *q,
>  bs.DataLength = avpkt->size;
>  bs.MaxLength  = bs.DataLength;
>  bs.TimeStamp  = avpkt->pts;
> +if (avctx->field_order == AV_FIELD_PROGRESSIVE)
> +bs.DataFlag   |= MFX_BITSTREAM_COMPLETE_FRAME;
>  }
> 
>  sync = av_mallocz(sizeof(*sync));
> @@ -509,6 +511,7 @@ int ff_qsv_process_data(AVCodecContext *avctx,
> QSVContext *q,
>   pkt->data, pkt->size, pkt->pts, pkt->dts,
>   pkt->pos);
> 
> +avctx->field_order  = q->parser->field_order;
>  /* TODO: flush delayed frames on reinit */
>  if (q->parser->format   != q->orig_pix_fmt||
>  q->parser->coded_width  != avctx->coded_width || @@ -533,7
> +536,6 @@ int ff_qsv_process_data(AVCodecContext *avctx, QSVContext
> *q,
>  avctx->height   = q->parser->height;
>  avctx->coded_width  = q->parser->coded_width;
>  avctx->coded_height = q->parser->coded_height;
> -avctx->field_order  = q->parser->field_order;
>  avctx->level= q->avctx_internal->level;
>  avctx->profile  = q->avctx_internal->profile;
> 
> --
> 1.8.3.1

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

[libav-devel] [PATCH V4 1/2] lavc/qsvdec: expose frame pic_type and key_frame

2018-03-29 Thread Zhong Li
Currently pict_type and key_frame are unset.
Add an extra param to fetch the picture type from qsv decoder

The judgement “key frame is equal to IDR frame” only suitable for H264.
For HEVC, all IRAP frames are key frames, and other codecs have no IDR
frame.

Signed-off-by: ChaoX A Liu 
Signed-off-by: Zhong Li 
---
 libavcodec/qsv.c  | 24 
 libavcodec/qsv_internal.h |  3 +++
 libavcodec/qsvdec.c   |  9 +
 3 files changed, 36 insertions(+)

diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index e78633d..e578ab1 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext *ctx, 
QSVFrame *frame)
 return AVERROR_BUG;
 }
 
+enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type)
+{
+enum AVPictureType type;
+switch (mfx_pic_type & 0x7) {
+case MFX_FRAMETYPE_I:
+if (mfx_pic_type & MFX_FRAMETYPE_S)
+type = AV_PICTURE_TYPE_SI;
+else
+type = AV_PICTURE_TYPE_I;
+break;
+case MFX_FRAMETYPE_B:
+type = AV_PICTURE_TYPE_B;
+break;
+case MFX_FRAMETYPE_P:
+if (mfx_pic_type & MFX_FRAMETYPE_S)
+type = AV_PICTURE_TYPE_SP;
+else
+type = AV_PICTURE_TYPE_P;
+break;
+}
+
+return type;
+}
+
 static int qsv_load_plugins(mfxSession session, const char *load_plugins,
 void *logctx)
 {
diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h
index 975c8de..07ddc59 100644
--- a/libavcodec/qsv_internal.h
+++ b/libavcodec/qsv_internal.h
@@ -48,6 +48,8 @@ typedef struct QSVMid {
 typedef struct QSVFrame {
 AVFrame *frame;
 mfxFrameSurface1 surface;
+mfxExtDecodedFrameInfo dec_info;
+mfxExtBuffer *ext_param;
 
 int queued;
 int used;
@@ -83,6 +85,7 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id);
 int ff_qsv_profile_to_mfx(enum AVCodecID codec_id, int profile);
 
 int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc);
+enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type);
 
 int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
  const char *load_plugins);
diff --git a/libavcodec/qsvdec.c b/libavcodec/qsvdec.c
index d05d48f..3ec45f0 100644
--- a/libavcodec/qsvdec.c
+++ b/libavcodec/qsvdec.c
@@ -232,6 +232,11 @@ static int alloc_frame(AVCodecContext *avctx, QSVContext 
*q, QSVFrame *frame)
 
 frame->surface.Data.MemId = >frames_ctx.mids[ret];
 }
+frame->surface.Data.ExtParam = >ext_param;
+frame->surface.Data.NumExtParam = 1;
+frame->ext_param = (mfxExtBuffer*)>dec_info;
+frame->dec_info.Header.BufferId = MFX_EXTBUFF_DECODED_FRAME_INFO;
+frame->dec_info.Header.BufferSz = sizeof(frame->dec_info);
 
 frame->used = 1;
 
@@ -418,6 +423,10 @@ FF_ENABLE_DEPRECATION_WARNINGS
 outsurf->Info.PicStruct & MFX_PICSTRUCT_FIELD_TFF;
 frame->interlaced_frame =
 !(outsurf->Info.PicStruct & MFX_PICSTRUCT_PROGRESSIVE);
+frame->pict_type = ff_qsv_map_pictype(out_frame->dec_info.FrameType);
+//Key frame is IDR frame is only suitable for H264. For HEVC, IRAPs 
are key frames.
+if (avctx->codec_id == AV_CODEC_ID_H264)
+frame->key_frame = !!(out_frame->dec_info.FrameType & 
MFX_FRAMETYPE_IDR);
 
 /* update the surface properties */
 if (avctx->pix_fmt == AV_PIX_FMT_QSV)
-- 
1.8.3.1

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

[libav-devel] [PATCH 2/2] lavf/qsvvpp: bypass vpp if not needed.

2018-03-29 Thread Zhong Li
It is benefit to performance for specific case.

Signed-off-by: Zhong Li 
---
 libavfilter/vf_vpp_qsv.c | 28 +---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/libavfilter/vf_vpp_qsv.c b/libavfilter/vf_vpp_qsv.c
index 610e821..568dee5 100644
--- a/libavfilter/vf_vpp_qsv.c
+++ b/libavfilter/vf_vpp_qsv.c
@@ -27,6 +27,7 @@
 #include "libavutil/eval.h"
 #include "libavutil/avassert.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/mathematics.h"
 
 #include "formats.h"
 #include "internal.h"
@@ -249,6 +250,7 @@ static int config_output(AVFilterLink *outlink)
 QSVVPPParam param = { NULL };
 QSVVPPCrop  crop  = { 0 };
 mfxExtBuffer*ext_buf[ENH_FILTERS_COUNT];
+AVFilterLink*inlink = ctx->inputs[0];
 
 outlink->w  = vpp->out_width;
 outlink->h  = vpp->out_height;
@@ -320,14 +322,34 @@ static int config_output(AVFilterLink *outlink)
 param.ext_buf[param.num_ext_buf++] = (mfxExtBuffer*)>procamp_conf;
 }
 
-return ff_qsvvpp_create(ctx, >qsv, );
+if (vpp->use_frc || vpp->use_crop || vpp->deinterlace || vpp->denoise ||
+vpp->detail || vpp->procamp || inlink->w != outlink->w || inlink->h != 
outlink->h)
+return ff_qsvvpp_create(ctx, >qsv, );
+else {
+av_log(ctx, AV_LOG_VERBOSE, "qsv vpp pass through mode.\n");
+if (inlink->hw_frames_ctx)
+outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
+}
+
+return 0;
 }
 
 static int filter_frame(AVFilterLink *inlink, AVFrame *picref)
 {
-VPPContext *vpp = inlink->dst->priv;
+int  ret = 0;
+AVFilterContext  *ctx = inlink->dst;
+VPPContext   *vpp = inlink->dst->priv;
+AVFilterLink *outlink = ctx->outputs[0];
+
+if (vpp->qsv)
+ret = ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
+else {
+if (picref->pts != AV_NOPTS_VALUE)
+picref->pts = av_rescale_q(picref->pts, inlink->time_base, 
outlink->time_base);
+ret = ff_filter_frame(outlink, picref);
+}
 
-return ff_qsvvpp_filter_frame(vpp->qsv, inlink, picref);
+return ret;
 }
 
 static int query_formats(AVFilterContext *ctx)
-- 
1.8.3.1

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

Re: [libav-devel] [PATCH] lavf/qsvvpp: bypass vpp is not needed.

2018-03-29 Thread Li, Zhong
> From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of
> Diego Biurrun
> Sent: Thursday, March 29, 2018 12:56 AM
> To: libav development 
> Subject: Re: [libav-devel] [PATCH] lavf/qsvvpp: bypass vpp is not needed.
> 
> On Wed, Mar 28, 2018 at 05:40:07PM +0800, Zhong Li wrote:
> > It is benefit to performance for specific case.
> 
> "i_F_ not needed" is what you were trying to say I guess.
> 
> Diego
Exactly! Thanks for review. Will update it. 

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

Re: [libav-devel] [PATCH] lavc/qsvdec: expose frame pic_type

2018-03-29 Thread Li, Zhong
> From: libav-devel [mailto:libav-devel-boun...@libav.org] On Behalf Of
> Diego Biurrun
> Sent: Thursday, March 29, 2018 12:55 AM
> To: libav development 
> Subject: Re: [libav-devel] [PATCH] lavc/qsvdec: expose frame pic_type
> 
> On Wed, Mar 28, 2018 at 04:50:10PM +0800, Zhong Li wrote:
> > Currently pict_type are unset.
> > Add an extra param to fetch the picture type from qsv decoder
> >
> > v2: fix the compile error since AV_PICTURE_TYPE_NONE is not existed in
> libav.
> > v3: remove the key_frame setting because the judgement “key frame is
> > equal to IDR frame” only suitable for H264.
> 
> These look like sensible patch annotations that you can add with --annotate
> when using git-send-email, but they should not be part of the log message.
> How you fixed compilation failures needs not be preserved for posterity ;)

Agree, will remove it in the updated patch.

> 
> > --- a/libavcodec/qsv.c
> > +++ b/libavcodec/qsv.c
> > @@ -195,6 +195,30 @@ int ff_qsv_find_surface_idx(QSVFramesContext
> > *ctx, QSVFrame *frame)
> >
> > +enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type) {
> > +enum AVPictureType type;
> > +switch (mfx_pic_type & 0x7) {
> > +case MFX_FRAMETYPE_I:
> 
> Please indent switch and case at the same level.
> 
> Diego

Yup, will update it, thanks for pointing this. : )  

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

[libav-devel] [PATCH] configure: Revert some incorrect uses of check_cc()

2018-03-29 Thread Diego Biurrun
---

Thanks to James for pointing this out.

 configure | 16 +++-
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 90fb6f07ca..a64f241560 100755
--- a/configure
+++ b/configure
@@ -4841,7 +4841,9 @@ check_disable_warning_headers -Wno-unused-variable
 
 check_objcflags -fobjc-arc && enable objc_arc
 
-check_cc blocks_extension "" "void (^block)(void)"
+test_cc 

Re: [libav-devel] [PATCH] Add Haivision Open SRT protocol

2018-03-29 Thread Diego Biurrun
On Mon, Mar 26, 2018 at 11:37:49AM -0400, Sven Dueking wrote:
> protocol requires libsrt (https://github.com/Haivision/srt) to be
> installed

Luca and I pushed a cleaned-up version of this yesterday.

Diego
___
libav-devel mailing list
libav-devel@libav.org
https://lists.libav.org/mailman/listinfo/libav-devel