diff mbox series

[FFmpeg-devel] libavcodec/qsvenc: add more ChromaFormat support for mjpeg-qsv

Message ID 20210322063524.2270692-1-wenbin.chen@intel.com
State New
Headers show
Series [FFmpeg-devel] libavcodec/qsvenc: add more ChromaFormat support for mjpeg-qsv | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Wenbin Chen March 22, 2021, 6:35 a.m. UTC
From: "Chen,Wenbin" <wenbin.chen@intel.com>

ChromaForamt for mjpeg-qsv is always set to yuv420, and this will be
wrong when encode other pixel format (for example yuyv422). I change
this assignment to be adaptive to pix_fmt.

Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
---
 libavcodec/qsvenc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Xiang, Haihao March 23, 2021, 4:27 a.m. UTC | #1
On Mon, 2021-03-22 at 14:35 +0800, wenbin.chen@intel.com wrote:
> From: "Chen,Wenbin" <wenbin.chen@intel.com>
> 
> ChromaForamt for mjpeg-qsv is always set to yuv420, and this will be
> wrong when encode other pixel format (for example yuyv422). I change
> this assignment to be adaptive to pix_fmt.
> 
> Signed-off-by: Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavcodec/qsvenc.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
> index 566a5c8552..a0fc206364 100644
> --- a/libavcodec/qsvenc.c
> +++ b/libavcodec/qsvenc.c
> @@ -445,7 +445,8 @@ static int init_video_param_jpeg(AVCodecContext *avctx,
> QSVEncContext *q)
>      q->param.mfx.FrameInfo.CropH          = avctx->height;
>      q->param.mfx.FrameInfo.AspectRatioW   = avctx->sample_aspect_ratio.num;
>      q->param.mfx.FrameInfo.AspectRatioH   = avctx->sample_aspect_ratio.den;
> -    q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
> +    q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420 +
> +                                            !desc->log2_chroma_w + !desc-
> >log2_chroma_h;
>      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;

LGTM, thank!

-Haihao
diff mbox series

Patch

diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c
index 566a5c8552..a0fc206364 100644
--- a/libavcodec/qsvenc.c
+++ b/libavcodec/qsvenc.c
@@ -445,7 +445,8 @@  static int init_video_param_jpeg(AVCodecContext *avctx, QSVEncContext *q)
     q->param.mfx.FrameInfo.CropH          = avctx->height;
     q->param.mfx.FrameInfo.AspectRatioW   = avctx->sample_aspect_ratio.num;
     q->param.mfx.FrameInfo.AspectRatioH   = avctx->sample_aspect_ratio.den;
-    q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420;
+    q->param.mfx.FrameInfo.ChromaFormat   = MFX_CHROMAFORMAT_YUV420 +
+                                            !desc->log2_chroma_w + !desc->log2_chroma_h;
     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;