Re: [libav-devel] [PATCH V2] lavc/qsvenc: add an option to disable MFE mode

2018-05-21 Thread Diego Biurrun
On Mon, May 21, 2018 at 02:33:28PM +0800, Zhong Li wrote:
> 
> V2: remove the manual option since it is not supported now.

This looks like a patch annotation that should not be part of the log
message.

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

[libav-devel] [PATCH] lavu/hwcontext_qsv: Add support for AV_PIX_FMT_BGRA.

2018-05-21 Thread Zhong Li
RGB32(AV_PIX_FMT_BGRA on intel platforms) format may be used as overlay with 
alpha blending.
So add AV_PIX_FMT_BGRA format support.

Rename RGB32 to be BGRA to make it clearer as Mark Thompson's suggestion.

Signed-off-by: Zhong Li 
---
 libavfilter/qsvvpp.c  |  2 +-
 libavutil/hwcontext_qsv.c | 43 +--
 2 files changed, 34 insertions(+), 11 deletions(-)

diff --git a/libavfilter/qsvvpp.c b/libavfilter/qsvvpp.c
index f704517..63b1c1e 100644
--- a/libavfilter/qsvvpp.c
+++ b/libavfilter/qsvvpp.c
@@ -142,7 +142,7 @@ static int pix_fmt_to_mfx_fourcc(int format)
 return MFX_FOURCC_NV12;
 case AV_PIX_FMT_YUYV422:
 return MFX_FOURCC_YUY2;
-case AV_PIX_FMT_RGB32:
+case AV_PIX_FMT_BGRA:
 return MFX_FOURCC_RGB4;
 }
 
diff --git a/libavutil/hwcontext_qsv.c b/libavutil/hwcontext_qsv.c
index b3eb4a3..c67d41b 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_BGRA, MFX_FOURCC_RGB4 },
 { AV_PIX_FMT_P010, MFX_FOURCC_P010 },
 { AV_PIX_FMT_PAL8, MFX_FOURCC_P8   },
 };
@@ -731,6 +732,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_BGRA:
+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)
 {
@@ -750,11 +781,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, );
@@ -797,11 +824,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] lavc/qsvenc: add an option to disable MFE mode

2018-05-21 Thread Luca Barbato
On 21/05/2018 08:33, Zhong Li wrote:
> Not convenient if using numerals to set MFE mode. It is ambiguous
> and misleading (e.g: user may misunderstand setting mfmode to 1 is to
> enable MFE but actually it is to disable MFE, and set it to be 5 or above is 
> meaningless).
> 
> V2: remove the manual option since it is not supported now.
> 
> Signed-off-by: Zhong Li 
> ---
>  libavcodec/qsvenc_h264.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
> index ae00ff8..2ecdb10 100644
> --- a/libavcodec/qsvenc_h264.c
> +++ b/libavcodec/qsvenc_h264.c
> @@ -94,7 +94,9 @@ static const AVOption options[] = {
>  { "aud", "Insert the Access Unit Delimiter NAL", OFFSET(qsv.aud), 
> AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE},
>  
>  #if QSV_HAVE_MF
> -{ "mfmode", "Multi-Frame Mode", OFFSET(qsv.mfmode), AV_OPT_TYPE_INT, { 
> .i64 = MFX_MF_AUTO }, 0, INT_MAX, VE },
> +{ "mfmode", "Multi-Frame Mode", OFFSET(qsv.mfmode), AV_OPT_TYPE_INT, { 
> .i64 = MFX_MF_AUTO }, MFX_MF_DEFAULT, MFX_MF_AUTO, VE, "mfmode"},
> +{ "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_DISABLED }, 
> INT_MIN, INT_MAX, VE, "mfmode" },
> +{ "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_AUTO }, 
> INT_MIN, INT_MAX, VE, "mfmode" },
>  #endif
>  
>  { NULL },
> 

Sounds fine to me, the previous iteration was on hold since Maxym wanted
to test it.

I guess this time it should work as intended on every current mfx release :)

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

[libav-devel] [PATCH V2] lavc/qsvenc: add an option to disable MFE mode

2018-05-21 Thread Zhong Li
Not convenient if using numerals to set MFE mode. It is ambiguous
and misleading (e.g: user may misunderstand setting mfmode to 1 is to
enable MFE but actually it is to disable MFE, and set it to be 5 or above is 
meaningless).

V2: remove the manual option since it is not supported now.

Signed-off-by: Zhong Li 
---
 libavcodec/qsvenc_h264.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/qsvenc_h264.c b/libavcodec/qsvenc_h264.c
index ae00ff8..2ecdb10 100644
--- a/libavcodec/qsvenc_h264.c
+++ b/libavcodec/qsvenc_h264.c
@@ -94,7 +94,9 @@ static const AVOption options[] = {
 { "aud", "Insert the Access Unit Delimiter NAL", OFFSET(qsv.aud), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE},
 
 #if QSV_HAVE_MF
-{ "mfmode", "Multi-Frame Mode", OFFSET(qsv.mfmode), AV_OPT_TYPE_INT, { 
.i64 = MFX_MF_AUTO }, 0, INT_MAX, VE },
+{ "mfmode", "Multi-Frame Mode", OFFSET(qsv.mfmode), AV_OPT_TYPE_INT, { 
.i64 = MFX_MF_AUTO }, MFX_MF_DEFAULT, MFX_MF_AUTO, VE, "mfmode"},
+{ "off", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_DISABLED }, 
INT_MIN, INT_MAX, VE, "mfmode" },
+{ "auto"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MFX_MF_AUTO }, 
INT_MIN, INT_MAX, VE, "mfmode" },
 #endif
 
 { NULL },
-- 
2.7.4

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