From 1dd3ef24b1e8e73c54e57b3f6385f08a0536a630 Mon Sep 17 00:00:00 2001 From: Haihao Xiang Date: Fri, 11 Oct 2019 14:48:11 +0800 Subject: [PATCH] msdkmjpegenc: convert UYVY to YUY2 instead of NV12 Before this fix, the chroma subsampling of the output is 4:2:0. It is 4:2:2 with this fix, which is better for UYVY input --- sys/msdk/gstmsdkenc.c | 21 +++++++++++++++------ sys/msdk/gstmsdkmjpegenc.c | 4 ++++ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/sys/msdk/gstmsdkenc.c b/sys/msdk/gstmsdkenc.c index 8a40d3773a..64dea75134 100644 --- a/sys/msdk/gstmsdkenc.c +++ b/sys/msdk/gstmsdkenc.c @@ -322,12 +322,21 @@ gst_msdkenc_init_encoder (GstMsdkEnc * thiz) thiz->vpp_param.vpp.Out = thiz->vpp_param.vpp.In; - if (encoder_input_fmt == GST_VIDEO_FORMAT_P010_10LE) { - thiz->vpp_param.vpp.Out.FourCC = MFX_FOURCC_P010; - thiz->vpp_param.vpp.Out.ChromaFormat = MFX_CHROMAFORMAT_YUV420; - } else { - thiz->vpp_param.vpp.Out.FourCC = MFX_FOURCC_NV12; - thiz->vpp_param.vpp.Out.ChromaFormat = MFX_CHROMAFORMAT_YUV420; + switch (encoder_input_fmt) { + case GST_VIDEO_FORMAT_P010_10LE: + thiz->vpp_param.vpp.Out.FourCC = MFX_FOURCC_P010; + thiz->vpp_param.vpp.Out.ChromaFormat = MFX_CHROMAFORMAT_YUV420; + break; + + case GST_VIDEO_FORMAT_YUY2: + thiz->vpp_param.vpp.Out.FourCC = MFX_FOURCC_YUY2; + thiz->vpp_param.vpp.Out.ChromaFormat = MFX_CHROMAFORMAT_YUV422; + break; + + default: + thiz->vpp_param.vpp.Out.FourCC = MFX_FOURCC_NV12; + thiz->vpp_param.vpp.Out.ChromaFormat = MFX_CHROMAFORMAT_YUV420; + break; } /* validate parameters and allow the Media SDK to make adjustments */ diff --git a/sys/msdk/gstmsdkmjpegenc.c b/sys/msdk/gstmsdkmjpegenc.c index d2c8053e14..573950fc1a 100644 --- a/sys/msdk/gstmsdkmjpegenc.c +++ b/sys/msdk/gstmsdkmjpegenc.c @@ -141,6 +141,10 @@ gst_msdkmjpegenc_need_conversion (GstMsdkEnc * encoder, GstVideoInfo * info, case GST_VIDEO_FORMAT_BGRA: return FALSE; + case GST_VIDEO_FORMAT_UYVY: + *out_format = GST_VIDEO_FORMAT_YUY2; + return TRUE; + default: *out_format = GST_VIDEO_FORMAT_NV12; return TRUE;