1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

lavc/qsv: specify Shift for each format too

Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
This commit is contained in:
Haihao Xiang 2022-10-06 15:35:34 +08:00
parent 1496e7c173
commit 3f28116ea2
3 changed files with 11 additions and 6 deletions

View File

@ -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:

View File

@ -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);

View File

@ -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