rockchip-linux / mpp

Media Process Platform (MPP) module
591 stars 171 forks source link

RK3588 采集BGR3、NV16 编码h264缺色 #470

Closed jukeboge closed 12 months ago

jukeboge commented 12 months ago

使用RK3588 android 12 采集hdmirx图像 测试BGR3、NV16,分别尝试使用ffplay和PotPlayer播放test-nv16.h264都会出现缺色问题,以下以NV16为例跑mpp测试
adb shell 运行

./data/test/mpi_enc_test -i /dev/video20 -o /data/test-nv16.h264 -w 1920 -h 1080 -f 2 -t 7

代码使用develop

commit 3b2784384468f13fb7659a47058024d990048cfa

logcat mpp 相关日志

11-14 06:09:33.637  3848  3848 I mpp_opt : setup:real node 67:71 info 22:22
11-14 06:09:33.637  3848  3848 I mpi_enc_utils: cmd parse result:
11-14 06:09:33.637  3848  3848 I mpi_enc_utils: input  file name: /dev/video20
11-14 06:09:33.637  3848  3848 I mpi_enc_utils: output file name: /data/test-nv16.h264
11-14 06:09:33.637  3848  3848 I mpi_enc_utils: width      : 1920
11-14 06:09:33.637  3848  3848 I mpi_enc_utils: height     : 1080
11-14 06:09:33.637  3848  3848 I mpi_enc_utils: format     : 2
11-14 06:09:33.637  3848  3848 I mpi_enc_utils: type       : 7
11-14 06:09:33.638  3848  3849 I mpi_enc_test: ./data/test/mpi_enc_test start
11-14 06:09:33.638  3848  3849 I mpi_enc_test: open camera device
11-14 06:09:33.638  3848  3849 I camera_source: input devices:hdmirx
11-14 06:09:33.638  3848  3849 I camera_source: fmt name: [24-bit BGR 8-8-8]
11-14 06:09:33.638  3848  3849 I camera_source: fmt pixelformat: 'BGR3', description = '24-bit BGR 8-8-8'
11-14 06:09:33.638  3848  3849 I camera_source: fmt name: [Y/CbCr 4:4:4]
11-14 06:09:33.638  3848  3849 I camera_source: fmt pixelformat: 'NV24', description = 'Y/CbCr 4:4:4'
11-14 06:09:33.638  3848  3849 I camera_source: fmt name: [Y/CbCr 4:2:2]
11-14 06:09:33.638  3848  3849 I camera_source: fmt pixelformat: 'NV16', description = 'Y/CbCr 4:2:2'
11-14 06:09:33.638  3848  3849 I camera_source: fmt name: [Y/CbCr 4:2:0]
11-14 06:09:33.638  3848  3849 I camera_source: fmt pixelformat: 'NV12', description = 'Y/CbCr 4:2:0'
11-14 06:09:33.638  3848  3849 I camera_source: get width 1920 height 1080
11-14 06:09:33.642  3848  3849 I camera_source: get dma buf(0)-fd: 6
11-14 06:09:33.643  3848  3849 I camera_source: get dma buf(1)-fd: 8
11-14 06:09:33.643  3848  3849 I camera_source: get dma buf(2)-fd: 9
11-14 06:09:33.643  3848  3849 I camera_source: get dma buf(3)-fd: 10
11-14 06:09:33.811  3848  3849 I mpi_enc_test: new framecap ok
11-14 06:09:33.819  3848  3849 I mpp_info: mpp version: db560c14 author: Yandong Lin   2022-07-06 [jpege]: add new client type for vepu2 jpeg only
11-14 06:09:33.819  3848  3849 I mpi_enc_test: 0xb400007a72a324c0 encoder test start w 1920 h 1080 type 7
11-14 06:09:33.820  3848  3849 E mpp_cfg : mpp_enc_cfg_set_s32: cfg rc:fqp_min_i is invalid
11-14 06:09:33.820  3848  3849 E mpp_cfg : mpp_enc_cfg_set_s32: cfg rc:fqp_max_i is invalid
11-14 06:09:33.820  3848  3849 E mpp_cfg : mpp_enc_cfg_set_s32: cfg rc:fqp_min_p is invalid
11-14 06:09:33.820  3848  3849 E mpp_cfg : mpp_enc_cfg_set_s32: cfg rc:fqp_max_p is invalid
11-14 06:09:33.820  3848  3849 E mpp_cfg : mpp_enc_cfg_set_s32: cfg prep:flip is invalid
11-14 06:09:33.820  3848  3850 I mpp_enc : MPP_ENC_SET_RC_CFG bps 7776000 [486000 : 8262000] fps [30:30] gop 60
11-14 06:09:33.820  3848  3850 I h264e_api_v2: MPP_ENC_SET_PREP_CFG w:h [1920:1080] stride [1920:1080]
11-14 06:09:33.820  3848  3850 I mpp_enc : send header for set cfg change input/format/color
11-14 06:09:33.822  3848  3850 I mpp_enc : mode vbr bps [486000:7776000:8262000] fps fix [30/1] -> fix [30/1] gop i [60] v [0]
11-14 06:09:36.672   199   199 I fdee0000.hdmirx-controller: rcv frames
11-14 06:09:34.666  3848  3849 I mpi_enc_test: chn 0 encoded frame 0    size 442678  qp 11
11-14 06:09:34.682  3848  3849 I mpi_enc_test: chn 0 encoded frame 1    size 30836   qp 15
11-14 06:09:34.698  3848  3849 I mpi_enc_test: chn 0 encoded frame 2    size 30212   qp 15

图像格式

Format Video Capture Multiplanar:
        Width/Height      : 1920/1080
        Pixel Format      : 'NV16'
        Field             : None
        Number of planes  : 1
        Flags             : premultiplied-alpha, 000000fe
        Colorspace        : Unknown (1025fca0)
        Transfer Function : Unknown (00000020)
        YCbCr Encoding    : Unknown (000000ff)
        Quantization      : Default
        Plane 0           :
           Bytes per Line : 1920
           Size Image     : 4147200

登录按钮中“录”缺了一半红色
缺色

HermanChen commented 12 months ago

编码器只能编码出 YUV420 的码流来,RGB 或者 422 转 420 过程中会直接丢失部分色度分量,会导致丢线或者颜色异常 这种是正常现象,可以用 RGA 做格式转换,它的效果会好一些