JeffyCN / libv4l-rkmpp

A rockchip-mpp V4L2 wrapper plugin for chromium V4L2 VDA/VEA
GNU Lesser General Public License v2.1
79 stars 26 forks source link

use LibYUVImageProcessorBackend in case NV12 rendering is not supported #22

Closed amazingfate closed 3 months ago

amazingfate commented 3 months ago

Continue with discussion from https://github.com/JeffyCN/libv4l-rkmpp/issues/18.

Current patches for chromium only work with mali blob driver. And mesa patch to make gbm support NV12 rendering seems to have a long way to get merged.

So there is another way: use LibYUVImageProcessorBackend in chromium, which has been tested with mainline stateful/stateless v4l2 api.

When I try to use it with rkmpp in chromium v122, I get following logs:

[6737:6797:0517/114722.596787:VERBOSE2:video_decoder_pipeline.cc(487)] Initialize(): config: codec: av1, profile: av1 profile main, level: not available, alpha_mode: is_opaque, coded size: [1920,1080], visible rect: [0,0,1920,1080], natural size: [1920,1080], has extra data: true, encryption scheme: Unencrypted, rotation: 0°, flipped: 0, color space: {primaries:INVALID, transfer:INVALID, matrix:INVALID, range:INVALID}
[6737:6804:0517/114722.624417:VERBOSE2:v4l2_video_decoder.cc(182)] V4L2VideoDecoder():
[6737:6804:0517/114722.639858:VERBOSE1:v4l2_video_decoder.cc(470)] InitializeBackend(): Using a stateful API for profile: av1 profile main and fourcc: AV01
[6737:6804:0517/114722.645693:VERBOSE1:v4l2_framerate_control.cc(60)] Failed to issue VIDIOC_S_PARM command
[6737:6804:0517/114722.646433:VERBOSE1:v4l2_video_decoder.cc(600)] SetupInputFormat(): Input (OUTPUT queue) Fourcc: AV01
[6737:6804:0517/114722.646822:VERBOSE1:v4l2_video_decoder.cc(638)] AllocateInputBuffers(): Requesting: 8 OUTPUT buffers of type V4L2_MEMORY_MMAP
[6737:6804:0517/114722.688887:VERBOSE2:v4l2_video_decoder_backend_stateful.cc(636)] ChangeResolution(): V4L2_CID_MIN_BUFFERS_FOR_CAPTURE  = 10
[6737:6804:0517/114722.689374:VERBOSE1:v4l2_video_decoder.cc(664)] SetupOutputFormat(): Output (CAPTURE queue) candidate: NV12
[6737:6804:0517/114722.689533:VERBOSE2:video_decoder_pipeline.cc(1133)] PickDecoderOutputFormat(): Initializing ImageProcessor; max buffers: 16
[6737:6804:0517/114722.689641:VERBOSE2:libyuv_image_processor_backend.cc(125)] CreateWithTaskRunner():
[6737:6804:0517/114722.689753:VERBOSE2:libyuv_image_processor_backend.cc(263)] CreateWithTaskRunner(): LibYUVImageProcessorBackend created for converting from PortConfig(format:NV12, size:1920x1080, planes: [], visible_rect:0,0 1920x1080, storage_types:[5]) to PortConfig(format:AR24, size:1920x1080, planes: [], visible_rect:0,0 1920x1080, storage_types:[6])
[6737:6804:0517/114722.689975:VERBOSE2:video_decoder_pipeline.cc(1214)] PickDecoderOutputFormat(): Initializing Image Processor frame pool with up to 16 VideoFrames
[6737:6804:0517/114722.704904:VERBOSE2:video_decoder_pipeline.cc(1225)] PickDecoderOutputFormat(): ImageProcessor is created: LibYUVImageProcessor
[6737:6804:0517/114722.705213:VERBOSE1:v4l2_video_decoder.cc(1111)] ContinueChangeResolution(): Requesting: 12 CAPTURE buffers of type V4L2_MEMORY_MMAP
[6737:6804:0517/114722.758485:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.759472:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.759677:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.760081:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.760253:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.760396:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.760589:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.760777:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.760979:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.761144:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.761352:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.761559:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.802919:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.807141:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6769:0517/114722.807374:ERROR:client_native_pixmap_dmabuf.cc(45)] Failed to mmap dmabuf: Permission denied (13)
[6737:6769:0517/114722.807674:VERBOSE1:gpu_memory_buffer_video_frame_mapper.cc(63)] Map(): Failed to map GpuMemoryBuffer
[6737:6804:0517/114722.807805:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6769:0517/114722.807801:VERBOSE1:libyuv_image_processor_backend.cc(326)] Process(): Failed to map output VideoFrame
[6737:6804:0517/114722.808051:VERBOSE1:video_decoder_pipeline.cc(892)] OnError(): ImageProcessor error
[6737:6804:0517/114722.808518:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6804:0517/114722.808815:VERBOSE4:v4l2_device.cc(750)] DequeueEvent(): Failed to dequeue event: No such file or directory (2)
[6737:6769:0517/114722.809072:ERROR:client_native_pixmap_dmabuf.cc(45)] Failed to mmap dmabuf: Permission denied (13)
[6737:6769:0517/114722.809184:VERBOSE1:gpu_memory_buffer_video_frame_mapper.cc(63)] Map(): Failed to map GpuMemoryBuffer
[6737:6769:0517/114722.809257:VERBOSE1:libyuv_image_processor_backend.cc(326)] Process(): Failed to map output VideoFrame
[6737:6804:0517/114722.809336:VERBOSE1:video_decoder_pipeline.cc(892)] OnError(): ImageProcessor error

Root cause should be ERROR:client_native_pixmap_dmabuf.cc(45)] Failed to mmap dmabuf: Permission denied (13). And I notice libv4l-rkmpp is using v4l2_mmap instead of mmap. So is it possible to let client_native_pixmap_dmabuf.cc use v4l2_mmap when v4l_plugin is enabled?

JeffyCN commented 3 months ago

don't know much about that, but usually it should mmap the dmabuf's fd(exported from expbuf), not the device fd(which should use hacked v4l2_mmap).

amazingfate commented 3 months ago

I find the root cause, which is a mesa issue. Similar fix to i965 is merged: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10850. I will try do push a fix to mesa.