This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM5718: ducati encoding causing artifacts on CSI2 mipi capture data

Part Number: AM5718

Hi,

We have a custom AM5718 board capturing a 1080p30 parallel signal on vin1a interface and a 4k10 signal on the mipi/CSI2 interface.  It seems that encoding the 1080p30 input via the ducati gst plugin causes capture artifacts/tearing on the 4k10 capture.  All software is based on latest PSDK v06_03_00_106.

1080p30 capture/encode uses the following pipeline based on multimedia examples from the PSDK:

Fullscreen
1
2
3
gst-launch-1.0 -e v4l2src device=/dev/video2 io-mode=4 ! 'video/x-raw,format=(string)YUY2,width=1920,height=1080,framerate=(fraction)30/1' ! \
vpe num-input-buffers=8 device=/dev/video1 ! video/x-raw, framerate=30/1 ! queue ! ducatih264enc inter-interval=1 intra-interval=30 max-bitrate=20000 profile=main bitrate=2048 ! \
h264parse ! video/x-h264, alignment=au, framerate=30/1, parsed=true, stream-format=avc ! fakesink sync=true
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Then, capturing the 4k image using yavta:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
~# yavta -c20 -fUYVY -F/tmp/vout_3840x2160_uyvy.yuv -s3840x2160 /dev/video0
Device /dev/video0 opened.
Device `cal' on `platform:cal-000' is a video output (without mplanes) device.
Video format set: UYVY (59565955) 3840x2160 (stride 7680) field none buffer size 16588800
Video format: UYVY (59565955) 3840x2160 (stride 7680) field none buffer size 16588800
8 buffers requested.
length: 16588800 offset: 0 timestamp type/source: mono/EoF
Buffer 0/0 mapped at address 0x75e66000.
length: 16588800 offset: 16588800 timestamp type/source: mono/EoF
Buffer 1/0 mapped at address 0x74e94000.
length: 16588800 offset: 33177600 timestamp type/source: mono/EoF
Buffer 2/0 mapped at address 0x73ec2000.
length: 16588800 offset: 49766400 timestamp type/source: mono/EoF
Buffer 3/0 mapped at address 0x72ef0000.
length: 16588800 offset: 66355200 timestamp type/source: mono/EoF
Buffer 4/0 mapped at address 0x71f1e000.
length: 16588800 offset: 82944000 timestamp type/source: mono/EoF
Buffer 5/0 mapped at address 0x70f4c000.
length: 16588800 offset: 99532800 timestamp type/source: mono/EoF
Buffer 6/0 mapped at address 0x6ff7a000.
length: 16588800 offset: 116121600 timestamp type/source: mono/EoF
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Most frames have either green lines or tearing in captured image:

Capturing with v4l2-ctl or gstreamer produces the same result.  When the gst pipeline is off or when it is replaced with a fakesink, 4k capture looks perfect.  Gst pipeline with fakesink instead of ducati encoder:

Fullscreen
1
2
gst-launch-1.0 -e v4l2src device=/dev/video2 io-mode=4 ! 'video/x-raw,format=(string)YUY2,width=1920,height=1080,framerate=(fraction)30/1' ! \
vpe num-input-buffers=8 device=/dev/video1 ! video/x-raw, framerate=30/1 ! queue ! fakesink sync=true
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

We also have hdmi output in our pipeline that tends to make the issue worse:

Fullscreen
1
2
3
4
gst-launch-1.0 -e v4l2src device=/dev/video2 io-mode=4 ! 'video/x-raw,format=(string)YUY2,width=1920,height=1080,framerate=(fraction)30/1' ! \
tee name=src ! queue ! kmssink plane-id=38 async=false sync=false src. ! vpe num-input-buffers=8 device=/dev/video1 ! video/x-raw, framerate=30/1 ! \
queue ! ducatih264enc inter-interval=1 intra-interval=30 max-bitrate=20000 profile=main bitrate=2048 ! h264parse ! \
video/x-h264, alignment=au, framerate=30/1, parsed=true, stream-format=avc ! fakesink sync=true
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Both the ducati encoder plugin and kmssink allocate dma-buf memory from the DRM driver, while all other buffers are allocated from v4l2.  Is there some contention between the DRM and v4l2 buffers?  What would cause the artifacts we are seeing?

Thanks,

Steve