[FFmpeg-devel] [PATCH] libavutil/hwcontext_opencl.c: fix bug in `opencl_get_plane_format`

Mark Thompson sw at jkqxz.net
Mon Apr 8 02:26:51 EEST 2019


On 07/04/2019 23:40, Cld fire wrote:
>>
>> Does anything go wrong if you unconditionally add comp->offset / (depth /
>> 8)?
> 
> 
> Yes. Occasionally there is a depth value less than 8:
> 
> [opencl_get_plane_format] depth is 2 < 8 for format: rgb8 on plane: 0
> [AVHWDeviceContext @ _] Format yuva420p supported.
> [opencl_get_plane_format] depth is 5 < 8 for format: rgb565be on plane: 0
> [opencl_get_plane_format] depth is 5 < 8 for format: rgb565le on plane: 0
> 
> Which causes an FPE (divide-by-zero). If I throw in an if statement to weed
> out those cases, that method of calculating the number results in the
> following output:
> 
> [AVHWDeviceContext @ _] Maximum supported image size 16384x16384.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p, plane: 2
> [AVHWDeviceContext @ _] Format yuv420p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p, plane: 2
> [AVHWDeviceContext @ _] Format yuv422p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p, plane: 2
> [AVHWDeviceContext @ _] Format yuv444p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv410p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv410p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv410p, plane: 2
> [AVHWDeviceContext @ _] Format yuv410p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv411p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv411p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv411p, plane: 2
> [AVHWDeviceContext @ _] Format yuv411p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: gray, plane: 0
> [AVHWDeviceContext @ _] Format gray supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj420p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj420p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj420p, plane: 2
> [AVHWDeviceContext @ _] Format yuvj420p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj422p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj422p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj422p, plane: 2
> [AVHWDeviceContext @ _] Format yuvj422p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj444p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj444p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj444p, plane: 2
> [AVHWDeviceContext @ _] Format yuvj444p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: nv12, plane: 0
> [opencl_get_plane_format] order_num: 12, pixel_format: nv12, plane: 1
> [AVHWDeviceContext @ _] Format nv12 supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: nv21, plane: 0
> [opencl_get_plane_format] order_num: 21, pixel_format: nv21, plane: 1
> [opencl_get_plane_format] order_num: 2341, pixel_format: argb, plane: 0
> [opencl_get_plane_format] order_num: 1234, pixel_format: rgba, plane: 0
> [AVHWDeviceContext @ _] Format rgba supported.
> [opencl_get_plane_format] order_num: 4321, pixel_format: abgr, plane: 0
> [opencl_get_plane_format] order_num: 3214, pixel_format: bgra, plane: 0
> [AVHWDeviceContext @ _] Format bgra supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: gray16le, plane: 0
> [AVHWDeviceContext @ _] Format gray16le supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv440p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv440p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv440p, plane: 2
> [AVHWDeviceContext @ _] Format yuv440p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj440p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj440p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj440p, plane: 2
> [AVHWDeviceContext @ _] Format yuvj440p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p, plane: 2
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p, plane: 3
> [AVHWDeviceContext @ _] Format yuva420p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p16le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p16le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv420p16le, plane: 2
> [AVHWDeviceContext @ _] Format yuv420p16le supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p16le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p16le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv422p16le, plane: 2
> [AVHWDeviceContext @ _] Format yuv422p16le supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p16le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p16le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuv444p16le, plane: 2
> [AVHWDeviceContext @ _] Format yuv444p16le supported.
> [opencl_get_plane_format] order_num: 12, pixel_format: ya8, plane: 0
> [AVHWDeviceContext @ _] Format ya8 supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrp, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrp, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrp, plane: 2
> [AVHWDeviceContext @ _] Format gbrp supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrp16le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrp16le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrp16le, plane: 2
> [AVHWDeviceContext @ _] Format gbrp16le supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p, plane: 2
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p, plane: 3
> [AVHWDeviceContext @ _] Format yuva422p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p, plane: 2
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p, plane: 3
> [AVHWDeviceContext @ _] Format yuva444p supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p16le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p16le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p16le, plane: 2
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva420p16le, plane: 3
> [AVHWDeviceContext @ _] Format yuva420p16le supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p16le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p16le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p16le, plane: 2
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva422p16le, plane: 3
> [AVHWDeviceContext @ _] Format yuva422p16le supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p16le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p16le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p16le, plane: 2
> [opencl_get_plane_format] order_num: 1, pixel_format: yuva444p16le, plane: 3
> [AVHWDeviceContext @ _] Format yuva444p16le supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: nv16, plane: 0
> [opencl_get_plane_format] order_num: 12, pixel_format: nv16, plane: 1
> [AVHWDeviceContext @ _] Format nv16 supported.
> [opencl_get_plane_format] order_num: 1234, pixel_format: rgba64le, plane: 0
> [AVHWDeviceContext @ _] Format rgba64le supported.
> [opencl_get_plane_format] order_num: 3214, pixel_format: bgra64le, plane: 0
> [opencl_get_plane_format] order_num: 12, pixel_format: ya16le, plane: 0
> [AVHWDeviceContext @ _] Format ya16le supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 2
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrap, plane: 3
> [AVHWDeviceContext @ _] Format gbrap supported.
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 2
> [opencl_get_plane_format] order_num: 1, pixel_format: gbrap16le, plane: 3
> [AVHWDeviceContext @ _] Format gbrap16le supported.
> [opencl_get_plane_format] order_num: 234, pixel_format: 0rgb, plane: 0
> [opencl_get_plane_format] order_num: 123, pixel_format: rgb0, plane: 0
> [opencl_get_plane_format] order_num: 432, pixel_format: 0bgr, plane: 0
> [opencl_get_plane_format] order_num: 321, pixel_format: bgr0, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj411p, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj411p, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: yuvj411p, plane: 2
> [AVHWDeviceContext @ _] Format yuvj411p supported.
> [opencl_get_plane_format] order_num: 2341, pixel_format: ayuv64le, plane: 0
> [opencl_get_plane_format] order_num: 1, pixel_format: p010le, plane: 0
> [opencl_get_plane_format] order_num: 13, pixel_format: p010le, plane: 1
> [opencl_get_plane_format] order_num: 1, pixel_format: p016le, plane: 0
> [opencl_get_plane_format] order_num: 12, pixel_format: p016le, plane: 1
> [AVHWDeviceContext @ _] Format p016le supported.
> 
> This is mostly fine, but it looks like nv21, ayuv64le, and p010le are all
> having their order numbers changed to broken values.

The changes to AYUV and NV21 both make sense - they can be supported because the layout works, but they require special treatment to use beyond just taking the given planes in the order common to other formats.  It doesn't seem unreasonable to drop them because of that?  I don't think any existing code actually supports them (e.g. trying to overlay AYUV on anything is going to mess up totally).

For P010, I guess that division needs to round up?  element_size = (comp->depth + 7) / 8.

Thanks,

- Mark


More information about the ffmpeg-devel mailing list