frontends/va: add support for yuv400 and yuv444

v2: indentation fixes (Saleem)

Signed-off-by: James Zhu <James.Zhu@amd.com>
Signed-off-by: Sathishkumar S <sathishkumar.sundararaju@amd.com>
Reviewed-by: Ruijing Dong <ruijing.dong@amd.com>
Reviewed-by: Boyuan Zhang <Boyuan.Zhang@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18914>
This commit is contained in:
James Zhu
2022-09-26 09:51:29 +05:30
committed by Leo Liu
parent 9055ab9de3
commit d2c0ff1caf
3 changed files with 56 additions and 1 deletions

View File

@@ -49,6 +49,8 @@ static const VAImageFormat formats[] =
{VA_FOURCC('Y','U','Y','V')},
{VA_FOURCC('Y','U','Y','2')},
{VA_FOURCC('U','Y','V','Y')},
{VA_FOURCC('Y','8','0','0')},
{VA_FOURCC('4','4','4','P')},
{.fourcc = VA_FOURCC('B','G','R','A'), .byte_order = VA_LSB_FIRST, 32, 32,
0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000},
{.fourcc = VA_FOURCC('R','G','B','A'), .byte_order = VA_LSB_FIRST, 32, 32,
@@ -179,6 +181,24 @@ vlVaCreateImage(VADriverContextP ctx, VAImageFormat *format, int width, int heig
img->data_size = w * h * 4;
break;
case VA_FOURCC('Y','8','0','0'):
img->num_planes = 1;
img->pitches[0] = w;
img->offsets[0] = 0;
img->data_size = w * h;
break;
case VA_FOURCC('4','4','4', 'P'):
img->num_planes = 3;
img->offsets[0] = 0;
img->offsets[1] = w * h;
img->offsets[2] = w * h * 2;
img->pitches[0] = w;
img->pitches[1] = w;
img->pitches[2] = w;
img->data_size = w * h * 3;
break;
default:
return VA_STATUS_ERROR_INVALID_IMAGE_FORMAT;
}

View File

@@ -506,6 +506,30 @@ vlVaQuerySurfaceAttributes(VADriverContextP ctx, VAConfigID config_id,
i++;
}
if (config->rt_format & VA_RT_FORMAT_YUV400) {
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_Y800;
i++;
}
if (config->rt_format & VA_RT_FORMAT_YUV422) {
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_YUY2;
i++;
}
if (config->rt_format & VA_RT_FORMAT_YUV444) {
attribs[i].type = VASurfaceAttribPixelFormat;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
attribs[i].value.value.i = VA_FOURCC_444P;
i++;
}
attribs[i].type = VASurfaceAttribMemoryType;
attribs[i].value.type = VAGenericValueTypeInteger;
attribs[i].flags = VA_SURFACE_ATTRIB_GETTABLE | VA_SURFACE_ATTRIB_SETTABLE;
@@ -935,6 +959,7 @@ vlVaCreateSurfaces2(VADriverContextP ctx, unsigned int format,
if (VA_RT_FORMAT_YUV420 != format &&
VA_RT_FORMAT_YUV422 != format &&
VA_RT_FORMAT_YUV444 != format &&
VA_RT_FORMAT_YUV400 != format &&
VA_RT_FORMAT_YUV420_10BPP != format &&
VA_RT_FORMAT_RGB32 != format) {
return VA_STATUS_ERROR_UNSUPPORTED_RT_FORMAT;

View File

@@ -53,7 +53,7 @@
#define VL_VA_DRIVER(ctx) ((vlVaDriver *)ctx->pDriverData)
#define VL_VA_PSCREEN(ctx) (VL_VA_DRIVER(ctx)->vscreen->pscreen)
#define VL_VA_MAX_IMAGE_FORMATS 12
#define VL_VA_MAX_IMAGE_FORMATS 14
#define VL_VA_ENC_GOP_COEFF 16
#define UINT_TO_PTR(x) ((void*)(uintptr_t)(x))
@@ -88,6 +88,8 @@ ChromaToPipe(int format)
return PIPE_VIDEO_CHROMA_FORMAT_422;
case VA_RT_FORMAT_YUV444:
return PIPE_VIDEO_CHROMA_FORMAT_444;
case VA_RT_FORMAT_YUV400:
return PIPE_VIDEO_CHROMA_FORMAT_400;
default:
return PIPE_VIDEO_CHROMA_FORMAT_NONE;
}
@@ -120,6 +122,10 @@ VaFourccToPipeFormat(unsigned format)
return PIPE_FORMAT_B8G8R8X8_UNORM;
case VA_FOURCC('R','G','B','X'):
return PIPE_FORMAT_R8G8B8X8_UNORM;
case VA_FOURCC('Y','8','0','0'):
return PIPE_FORMAT_Y8_400_UNORM;
case VA_FOURCC('4','4','4','P'):
return PIPE_FORMAT_Y8_U8_V8_444_UNORM;
default:
assert(0);
return PIPE_FORMAT_NONE;
@@ -152,6 +158,10 @@ PipeFormatToVaFourcc(enum pipe_format p_format)
return VA_FOURCC('B','G','R','X');
case PIPE_FORMAT_R8G8B8X8_UNORM:
return VA_FOURCC('R','G','B','X');
case PIPE_FORMAT_Y8_400_UNORM:
return VA_FOURCC('Y','8','0','0');
case PIPE_FORMAT_Y8_U8_V8_444_UNORM:
return VA_FOURCC('4','4','4','P');
default:
assert(0);
return -1;