frontends/va: reallocate surface for yuv400/yuv444 picture
reallocate the surface appropriately based on the mjpeg sampling factor v2: use macros for mjpeg sampling factors (Ruijing Dong) indentation fix (Thong Thai) v3: add comments to mention workaround of reallocation (Boyuan Zhang) Signed-off-by: Sathishkumar S <sathishkumar.sundararaju@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:
@@ -859,14 +859,36 @@ vlVaEndPicture(VADriverContextP ctx, VAContextID context_id)
|
||||
realloc = true;
|
||||
}
|
||||
|
||||
if (u_reduce_video_profile(context->templat.profile) == PIPE_VIDEO_FORMAT_JPEG &&
|
||||
surf->buffer->buffer_format == PIPE_FORMAT_NV12) {
|
||||
if (context->mjpeg.sampling_factor == 0x211111 ||
|
||||
context->mjpeg.sampling_factor == 0x221212) {
|
||||
surf->templat.buffer_format = PIPE_FORMAT_YUYV;
|
||||
if (u_reduce_video_profile(context->templat.profile) == PIPE_VIDEO_FORMAT_JPEG) {
|
||||
if (surf->buffer->buffer_format == PIPE_FORMAT_NV12 &&
|
||||
context->mjpeg.sampling_factor != MJPEG_SAMPLING_FACTOR_NV12) {
|
||||
/* workaround to reallocate surface buffer with right format
|
||||
* if it doesnt match with sampling_factor. ffmpeg doesnt
|
||||
* use VASurfaceAttribPixelFormat and defaults to NV12.
|
||||
*/
|
||||
switch (context->mjpeg.sampling_factor) {
|
||||
case MJPEG_SAMPLING_FACTOR_YUV422:
|
||||
case MJPEG_SAMPLING_FACTOR_YUY2:
|
||||
surf->templat.buffer_format = PIPE_FORMAT_YUYV;
|
||||
break;
|
||||
case MJPEG_SAMPLING_FACTOR_YUV444:
|
||||
surf->templat.buffer_format = PIPE_FORMAT_Y8_U8_V8_444_UNORM;
|
||||
break;
|
||||
case MJPEG_SAMPLING_FACTOR_YUV400:
|
||||
surf->templat.buffer_format = PIPE_FORMAT_Y8_400_UNORM;
|
||||
break;
|
||||
default:
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||
}
|
||||
realloc = true;
|
||||
} else if (context->mjpeg.sampling_factor != 0x221111) {
|
||||
/* Not NV12 either */
|
||||
}
|
||||
/* check if format is supported before proceeding with realloc,
|
||||
* also avoid submission if hardware doesnt support the format and
|
||||
* applcation failed to check the supported rt_formats.
|
||||
*/
|
||||
if (!screen->is_video_format_supported(screen, surf->templat.buffer_format,
|
||||
PIPE_VIDEO_PROFILE_JPEG_BASELINE, PIPE_VIDEO_ENTRYPOINT_BITSTREAM)) {
|
||||
mtx_unlock(&drv->mutex);
|
||||
return VA_STATUS_ERROR_INVALID_SURFACE;
|
||||
}
|
||||
|
@@ -330,6 +330,11 @@ typedef struct {
|
||||
|
||||
struct {
|
||||
unsigned sampling_factor;
|
||||
#define MJPEG_SAMPLING_FACTOR_NV12 (0x221111)
|
||||
#define MJPEG_SAMPLING_FACTOR_YUY2 (0x221212)
|
||||
#define MJPEG_SAMPLING_FACTOR_YUV422 (0x211111)
|
||||
#define MJPEG_SAMPLING_FACTOR_YUV444 (0x111111)
|
||||
#define MJPEG_SAMPLING_FACTOR_YUV400 (0x11)
|
||||
uint8_t slice_header[MAX_MJPEG_SLICE_HEADER_SIZE];
|
||||
unsigned int slice_header_size;
|
||||
} mjpeg;
|
||||
|
Reference in New Issue
Block a user