Repository navigation
Conversation
…16-aligned handling Summary of changes: - Broaden RKMPP device detection in linux_support_rkmpp() to include legacy BSP nodes (/dev/vpu_service, /dev/rkvenc, /dev/vepu, /dev/rga) alongside /dev/mpp_service. - Add non-fatal MPP buffer group fallback (DRM|CACHABLE -> DRM -> ION -> NORMAL) and timeout controls in rkmpp_dmabuf.cpp, plus DMA_BUF_SYNC_RW/END flush for non-JPEG DMABUF frames. - Enforce 16-aligned ver_stride and buffer size validation on RK33xx in rkmpp_dmabuf.cpp so undersized V4L2 buffers (e.g., 1080p YUYV 0x3f4800 < 0x3fc000) fail fast at init instead of faulting/stalling. - Add NativeMppMjpegH264 (ping-pong overlapped MJPEG->NV12->H.264) and NativeMppEncoder (16-aligned raw->H.264 with mpp_buffer_sync_end cache flush) in rkmpp_native.cpp as runtime/init fallback when FFmpeg h264_rkmpp fails. - Auto-detect RK33xx (/proc/device-tree/compatible) in encoder_state.rs to default MJPEG to parallel TurboJPEG decode + aligned NativeMppEncoder (overridable via ONE_KVM_RKMPP_MODE=native|ffmpeg|turbojpeg) without altering RK35xx behavior. - Drop initial UVC warmup frames after STREAMON (configurable via ONE_KVM_UVC_WARMUP_FRAMES, default 3).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景与问题
在 RK3399(Linux 4.19 BSP)等 RK33xx 平台上测试 RKMPP 硬件编码时,遇到了以下兼容与性能问题:
/dev/vpu_service、/dev/vepu、/dev/rkvenc等设备节点,导致linux_support_rkmpp()漏检。h264_rkmpp/ MJPEG 解码管线兼容与性能问题:FFmpeg硬件 MJPEG->H.264 管线在 RK3399 上运行时会报错(avcodec_send_packet/avcodec_send_frame失败),需要自动回退路径;turbojpeg解码 + 硬件 H.264 编码(~29.5ms)可稳定达到 28 FPS。hal_h264e_vepu_v2要求ver_stride16 字节对齐(1088行,需要0x3fc000字节),而 USB UVC 采集卡分配的 V4L2 DMABUF 只有1920*1080*2 = 0x3f4800字节,导致开局数秒持续报错并花屏后才回退,回退后的 FFmpegh264_rkmpp同样存在未对齐问题(仅 ~20 FPS)。修改内容
libs/hwcodec/cpp/common/platform/linux/linux.cpp):补充/dev/vpu_service、/dev/rkvenc、/dev/vepu、/dev/rga。libs/hwcodec/cpp/ffmpeg_hw/rkmpp_dmabuf.cpp):DRM|CACHABLE -> DRM -> ION -> NORMAL缓冲组回退及非致命超时控制;DMA_BUF_SYNC_RW/END同步;ver_stride校验 DMABUF 容量,容量不足时在初始化阶段立即快速回退,消除开局卡顿与越界警告。libs/hwcodec/cpp/ffmpeg_hw/rkmpp_native.cpp、libs/hwcodec/src/rkmpp_native.rs):NativeMppMjpegH264与 16 对齐的NativeMppEncoder(含mpp_buffer_sync_end缓存刷写)。src/video/pipeline/encoder_state.rs):/proc/device-tree/compatible识别rk33xx后,MJPEG 默认启用turbojpeg并行解码 + 原生 MPP 编码(支持ONE_KVM_RKMPP_MODE=native|ffmpeg|turbojpeg覆盖);YUYV/原始帧优先使用 16 对齐的NativeMppEncoder。src/video/capture/linux.rs):STREAMON后默认丢弃前 3 帧(可通过ONE_KVM_UVC_WARMUP_FRAMES配置)。实测结果(NanoPC-T4 / RK3399 + USB3 HDMI 采集卡 1920x1080)
vepu_v2300MHz 硬件编码吞吐上限)。但是根据我的实测硬编码没有直接使用CPU帧率高。