Fallback to vaCreateImage + vaPutImage when vaDeriveImage fails#21538
Fallback to vaCreateImage + vaPutImage when vaDeriveImage fails#21538opencv-pushbot merged 1 commit intoopencv:4.xfrom
Conversation
4b99d7f to
038afdf
Compare
|
Fixed looping through the array of formats to use the num_formats returned by libva, and I have tested this on mine, works just fine |
alalek
left a comment
There was a problem hiding this comment.
Thank you for contribution!
convertToVASurface() workaround doesn't look valid.
We need to update data of the surface. Updating image is not enough as it doesn't update content of the original surface.
modules/core/src/va_intel.cpp
Outdated
| //try vaCreateImage + vaPutImage | ||
| //pick a format | ||
| int num_formats = vaMaxNumImageFormats(display); | ||
| VAImageFormat fmt_list[num_formats]; |
There was a problem hiding this comment.
Could you please to use std::vector<VAImageFormat> or cv::AutoBuffer<VAImageFormat> instead of dynamic allocated arrays?
modules/core/src/va_intel.cpp
Outdated
| VAImageFormat *selected_format = &fmt_list[0]; | ||
| for (int i = 0; i < num_formats; i++){ | ||
| if (fmt_list[i].fourcc == VA_FOURCC_NV12 || fmt_list[i].fourcc == VA_FOURCC_YV12){ | ||
| selected_format = &fmt_list[i]; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| status = vaCreateImage(display, selected_format, size.width, size.height, &image); |
There was a problem hiding this comment.
What if selected_format is not "found"? Why do we fallback to the first one?
I believe we should emit error message as fast as possible.
…fails Per intel docs for libva, when vaDeriveImage fails vaCreateImage + vaPutImage should be tried. This is important as mesa with AMD HW will always fail because the image is interlaced so a indirect method must be used to get the surface to/from and image Fixes opencv#21536
|
@alalek Updated it with the changes you suggested
That should be fixed now! It now uses vaPutImage or vaGetImage, and vaPutImage is after we write the data to the image. I have no idea why vaPutImage worked for me in my testing when it should have been vaGetImage, but I tested it in both directions and verified that I can modify it as a UMat and write it back and encode it with VA-API/FFmpeg |
Per intel docs for libva, when vaDeriveImage fails vaCreateImage +
vaPutImage should be tried. This is important as mesa with AMD HW
will always fail because the image is interlaced, but the HW
capability still exists
Fixes #21536
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.