diff options
author | Haihao Xiang <haihao.xiang@intel.com> | 2022-10-06 15:35:34 +0800 |
---|---|---|
committer | Haihao Xiang <haihao.xiang@intel.com> | 2022-10-10 09:31:34 +0800 |
commit | 3f28116ea26a87fbe1c807248effaf449008d979 (patch) | |
tree | 7f6804ae26e2aa980b6c49cc5c916faf5c6466cf | |
parent | 1496e7c1732f6f2e2e8d9c6a1866c13756e54ac4 (diff) | |
download | ffmpeg-3f28116ea26a87fbe1c807248effaf449008d979.tar.gz |
lavc/qsv: specify Shift for each format too
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
-rw-r--r-- | libavcodec/qsv.c | 9 | ||||
-rw-r--r-- | libavcodec/qsv_internal.h | 2 | ||||
-rw-r--r-- | libavcodec/qsvenc.c | 6 |
3 files changed, 11 insertions, 6 deletions
diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c index 51aac16695..4e11b33a7d 100644 --- a/libavcodec/qsv.c +++ b/libavcodec/qsv.c @@ -217,35 +217,42 @@ enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc) return AV_PIX_FMT_NONE; } -int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc) +int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc, uint16_t *shift) { switch (format) { case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUVJ420P: case AV_PIX_FMT_NV12: *fourcc = MFX_FOURCC_NV12; + *shift = 0; return AV_PIX_FMT_NV12; case AV_PIX_FMT_YUV420P10: case AV_PIX_FMT_P010: *fourcc = MFX_FOURCC_P010; + *shift = 1; return AV_PIX_FMT_P010; case AV_PIX_FMT_X2RGB10: *fourcc = MFX_FOURCC_A2RGB10; + *shift = 1; return AV_PIX_FMT_X2RGB10; case AV_PIX_FMT_BGRA: *fourcc = MFX_FOURCC_RGB4; + *shift = 0; return AV_PIX_FMT_BGRA; #if CONFIG_VAAPI case AV_PIX_FMT_YUV422P: case AV_PIX_FMT_YUYV422: *fourcc = MFX_FOURCC_YUY2; + *shift = 0; return AV_PIX_FMT_YUYV422; case AV_PIX_FMT_YUV422P10: case AV_PIX_FMT_Y210: *fourcc = MFX_FOURCC_Y210; + *shift = 1; return AV_PIX_FMT_Y210; case AV_PIX_FMT_VUYX: *fourcc = MFX_FOURCC_AYUV; + *shift = 0; return AV_PIX_FMT_VUYX; #endif default: diff --git a/libavcodec/qsv_internal.h b/libavcodec/qsv_internal.h index f914956596..f95e23c5e8 100644 --- a/libavcodec/qsv_internal.h +++ b/libavcodec/qsv_internal.h @@ -132,7 +132,7 @@ int ff_qsv_codec_id_to_mfx(enum AVCodecID codec_id); enum AVPixelFormat ff_qsv_map_fourcc(uint32_t fourcc); -int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc); +int ff_qsv_map_pixfmt(enum AVPixelFormat format, uint32_t *fourcc, uint16_t *shift); enum AVPictureType ff_qsv_map_pictype(int mfx_pic_type); enum AVFieldOrder ff_qsv_map_picstruct(int mfx_pic_struct); diff --git a/libavcodec/qsvenc.c b/libavcodec/qsvenc.c index 398fa6ff22..dc5479d0f3 100644 --- a/libavcodec/qsvenc.c +++ b/libavcodec/qsvenc.c @@ -553,7 +553,7 @@ static int init_video_param_jpeg(AVCodecContext *avctx, QSVEncContext *q) if (!desc) return AVERROR_BUG; - ret = ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC); + ret = ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC, &q->param.mfx.FrameInfo.Shift); if (ret < 0) return AVERROR_BUG; @@ -567,7 +567,6 @@ static int init_video_param_jpeg(AVCodecContext *avctx, QSVEncContext *q) !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; q->param.mfx.FrameInfo.Width = FFALIGN(avctx->width, 16); q->param.mfx.FrameInfo.Height = FFALIGN(avctx->height, 16); @@ -653,7 +652,7 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) if (!desc) return AVERROR_BUG; - ret = ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC); + ret = ff_qsv_map_pixfmt(sw_format, &q->param.mfx.FrameInfo.FourCC, &q->param.mfx.FrameInfo.Shift); if (ret < 0) return AVERROR_BUG; @@ -667,7 +666,6 @@ static int init_video_param(AVCodecContext *avctx, QSVEncContext *q) !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; // If the minor version is greater than or equal to 19, // then can use the same alignment settings as H.264 for HEVC |