This is a quick reference on how to run the PetaLinux BSP design on the ZCU106 board to use the ZU7EV’s Video Codec Unit (VCU). There is a lot more details in H.264/H.265 Video Codec Unit v1.1 Product Guide (PG252) Chapter 11 on the Software applications. This boils it down to some simple steps to run examples on the ZCU106 to get acquainted with the VCU.
Download the ImageDownload the image from the wiki.
For the 2018.1 version.
https://www.xilinx.com/member/forms/download/xef.html?filename=2018.1-zcu106-release.tar.xz
For the 2018.2 version.
https://www.xilinx.com/member/forms/download/xef.html?filename=2018.2-zcu106-release.tar.xz
Get Video and Configuration FilesIf you would like use some video files without going to the network from the ZCU106 here are some files that you can use. The commands to get the files from the GitHub are from a linux machine are :
- Download the AVC sample file
wget petalinux.xilinx.com/sswreleases/video-files/bbb_sunflower_2160p_30fps_normal_avc.mp4
- Download the HEVC sample file
wget petalinux.xilinx.com/sswreleases/video-files/bbb_sunflower_2160p_30fps_normal_hevc.mkv
These files are used for the canned demos later and can be copied to the SD card. that you will boot from. If you have the ZCU106 connected to the network through a router you can download then directly with the commands from the Linux prompt once you boot the board. If you don’t have a router than use the following
export http_proxy=http://172.19.128.4:8080
So the commands need to be done from a device running linux, whether that is a separate machines or on the ZCU106 using the ZU7EV once it has booted. Setting up the board and getting the SD card prepared to boot is described below.
Set Up ZCU106 Board- Connect the Micro USB cable into the ZCU106 Board Micro USB port J83, and the other end into an open USB port on the host PC. This cable is used for UART over USB communication.
- Insert the SD card with the images copied into the SD card slot J100.
- Set the SW6 switches as shown in the below Figure. This configures the boot settings to boot from SD.
Set up a terminal session between a PC COM port and the serial port on the evaluation board. See below.
Determine which COM to use to access the USB serial port on the ZCU106 board.
Make sure that the ZCU106 board is powered on and a micro USB cable is connected between ZCU106 board and host PC. This ensures that the USB-to-serial bridge is enumerated by the PC host.
Open your computer's Control Panel by clicking on Start > Control Panel.
Note that the Start button is typically located in the lower left corner of the screen. Occasionally, it is in the upper left corner.
- Click Device Manager to open the Device Manager window. Note: You may be asked to confirm opening the Device Manager. If so, click YES.
- Expand Ports (COM & LPT).
- Locate the Silicon Labs Quad CP210x USB to UART Bridge: Interface 0 (COM#).
- Note down the COM Port number for further steps.
- Close the Device Manager by clicking the red X in the upper right corner of the window.
Launch any Terminal application like Tera term or Putty to view the serial messages
- Launch Tera Term and open the COM port that is associated to Silicon Labs Quad CP210x USB to UART Bridge: Interface 0 of the USB-to-serial bridge.
- Set the COM port to 115200 Baud rate, 8, none, 1 –Set COM port.
- Power ON the board which has SD card. It boots Linux on board.
You can also connect a display and mouse to the board. The display needs to connect to display port and be set to 4KP30. The mouse is connected to the USB connector next to the power supply. If this is done and when you boot here is the image that you see and the mouse will control the curser to run the icon on the screen.
In the UART terminal, then login into Linux using username: root and password: root.
Do the following commands. These are to setup the QoS, set the issuing or read and writes to the HP ports that the VCU uses.
devmem 0xFD3A0008 w 0x3
devmem 0xFD3A001C w 0x3
devmem 0xFD3B0008 w 0x3
devmem 0xFD3B001C w 0x3
devmem 0xFD3A0004 w 0xF
devmem 0xFD3A0018 w 0xF
devmem 0xFD3B0004 w 0xF
devmem 0xFD3B0018 w 0xF
The first four commands are to set the HP ports to low priority (not sure why at this point). And the second four commands are to allow for 16 outstanding commands. This is to help pass the video traffic to the PS memory controller.
Mount the SD card to get to the files if you have loaded them on the SD in previous step. If you don’t have any video files on the SD card then skip this step.
mkdir /mnt/vcu_example
mount /dev/mmcblk0p1 /mnt/vcu_example
cd /mnt/vcu_example
If the board is connected to the network you can get the files via the following commands.
- Download the AVC sample file
wget petalinux.xilinx.com/sswreleases/video-files/bbb_sunflower_2160p_30fps_normal_avc.mp4
- Download the HEVC sample file
wget petalinux.xilinx.com/sswreleases/video-files/bbb_sunflower_2160p_30fps_normal_hevc.mkv
Run the Display Demo on the BoardMake sure that you have a display and mouse connected to the board if you are running the demo and the files on SD card (downloaded or copied). Also ensure that the display is set to 4KP30 which matches the PS display ports capability.
The Display demo decodes AVC/HEVC encoded container stream and displays it on a DisplayPort monitor. The Display demo can be executed using command, use below command to run this example. Running the script with "-h" option shows all possible options.
Here is for a AVC or H.264 encoded video/,
vcu-demo-decode-display.sh -i /home/root/bbb_sunflower_2160p_30fps_normal_avc.mp4 -c avc -a aac
Here is for a HEVC or H.265 encoded vide0.
vcu-demo-decode-display.sh -i /home/root/bbb_sunflower_2160p_30fps_normal_hevc.mkv -c hevc -a vorbis
These two demos take the encoded file that have been downloaded and decodes it. The decoded video is displayed on the monitor via the display port in the PS.
Run Gstreamer on the boardgst-launch-1.0 filesrc location="input-file.mp4" ! qtdemux name=demux demux.video_0 ! h264parse ! omxh264dec ! queue max-size-bytes=0 ! kmssink bus-id=fd4a0000.zynqmp-display fullscreen-overlay=1
The input-file.mp4 file can be replaced with bbb_sunflower_2160p_30fps_normal_avc.mp4 if you have downloaded it. Or use another mp4 file that you have copied to the SD card. There are a lot more Gstreamer examples in PG252 that can be run. You will have to have more video files on the SD card and mount it to run all the examples.
Run Control Software on the boardAL_Encoder.exe and AL_Decoder.exe are complete sample applications that encode and
decode video respectively. These applications are intended as a learning aid for the VCU
Control Software API and for troubleshooting. The source code for the AL_Encoder and
AL_Decoder applications are at https://github.com/Xilinx/vcu-ctrl-sw.
H.264 Decoding File to File
AL_Decoder.exe -avc -in input-avc-file.h264 -out <output file name>.yuv
H.265 Decoding File to File
AL_Decoder.exe -hevc -in input-hevc-file.h265 -out <output file name>..yuv
Encoding File to File
AL_Encoder.exe –cfg <encode>.cfg
The output file name for encoding and whether the encoding is H.264 (AVC) or H.265 (HEVC) is dependent on the settings in the CFG file. The configuration file controls what is being done in the encoder or decoder of the VCU. All the parameters are explained in detail in PG252.
If the file to encode is larger than 2GB then it will not “fit” onto a FAT32 formatted SD card. The user will have to USB or SATA. Here is an example of using USB. Make sure the directory is created on the USB card.
mkdir /mnt/video_streams
mount /dev/sda1 /mnt/video_streams
cd /mnt/video_streams
One note is the
Here is a sample configuration file for BasketballDrive_1920x1080_50.yuv
#--------------------------------------------------------------------------
# Configuration file
#--------------------------------------------------------------------------
#--------------------------------------------------------------------------
[INPUT]
#--------------------------------------------------------------------------
# YUVFile : YUV or u4m input file
YUVFile = BasketballDrive_1920x1080_50.yuv
# Width, Height: frame width/height in pixels
# width and height shall be multiple of 8 pixels
Width = 1920
Height = 1080
# Format : FOURCC format of input file
# typical file formats : I420, I422, I0AL, I2AL...
# hardware supported formats : NV12, NV16, RX0A, RX2A
# default value : I420
Format = I420
#--------------------------------------------------------------------------
[OUTPUT]
#--------------------------------------------------------------------------
# BitstreamFile : elementary stream output file
BitstreamFile = BasketballDrive_1920x1080_50.hevc
# RecFile : optional output file for reconstructed pictures
#RecFile = rec.yuv
#--------------------------------------------------------------------------
[RATE_CONTROL]
#--------------------------------------------------------------------------
# RateCtrlMode : selects the bit rate control mode
# allowed values : CONST_QP, CBR, VBR, LOW_LATENCY
# default value : CONST_QP
RateCtrlMode = CBR
# FrameRate : number of frames per second
# default value : 30
FrameRate = 25
# BitRate: target bitrate in kbit/s (not used when RateCtrlMode = CONST_QP)
# default value : 4000
BitRate = 700
# MaxBitRate: maximum bitrate in kbit/s used when RateCtrlMode = VBR
# MaxBitRate shall be equal to BitRate when RateCtrlMode = CBR or LOW_LATENCY
# default value : 4000
MaxBitRate = 700
# SliceQP : Quantization Parameter
# when RateCtrlMode = CONST_QP, it defines the QP for all slices, otherwise it specifies the initial QP
# allowed values : from 0 to 51, AUTO
# default value : 30
SliceQP = 25
# CPBSize : specifies the size of the Coded Picture Buffer as specified in the HRD model, in seconds (not used when RateCtrlMode = CONST_QP)
# default value : 3.0
CPBSize = 1.0
# InitialDelay : specifies the initial removal delay as specified in the HRD model, in seconds (not used when RateCtrlMode = CONST_QP)
# default value : 1.5
InitialDelay = 1.0
#--------------------------------------------------------------------------
[GOP]
#--------------------------------------------------------------------------
# GopCtrlMode : specifies the Group Of Pictures configuration
# allowed values : DEFAULT_GOP, LOW_DELAY_P, LOW_DELAY_B, PYRAMIDAL_GOP
# default value : DEFAULT_GOP
GopCtrlMode = DEFAULT_GOP
# Gop.Length : GOP length in frames including the I picture. 0 = Intra only
# default value : 30
Gop.Length = 25
# Gop.NumB : maximum number of consecutive B frames in a GOP (used only when GopCtrlMode = DEFAULT_GOP or PYRAMIDAL_GOP)
# allowed values : 0 to 4 when GopCtrlMode = DEFAULT_GOP
# 3, 5 or 7 when GopCtrlMode = PYRAMIDAL_GOP
# default value : 0
Gop.NumB = 1
# Gop.FreqIDR : minimum number of frames between two IDR pictures (IDR insertion depends on the position of the GOP boundary)
# allowed values : positive value or -1 to disable IDR insertion
# default value : -1
#Gop.FreqIDR = 25
#--------------------------------------------------------------------------
[SETTINGS]
#--------------------------------------------------------------------------
# Profile : specifies the standard/profile to which the bitstream conforms
# allowed values : AVC_BASELINE, AVC_MAIN, AVC_HIGH, AVC_HIGH10, AVC_HIGH_422,
# HEVC_MAIN, HEVC_MAIN10, HEVC_MAIN_422_10...
Profile = HEVC_MAIN
# Level : specifies the level to which the bitstream conforms
# allowed values : 1.0 to 5.2 for AVC, 1.0 to 5.1 for HEVC
Level = 2
# Tier : specifies the tier to which the bitstream conforms (HEVC only)
# allowed values : MAIN_TIER, HIGH_TIER
#Tier = MAIN_TIER
# ChromaMode : selects the chroma subsampling mode used to encode the stream
# allowed values : CHROMA_MONO, CHROMA_4_2_0, CHROMA_4_2_2
# default value : CHROMA_4_2_0
ChromaMode = CHROMA_4_2_0
# BitDepth : specifies the bit depth of the luma and chroma samples in the encoded stream
# allowed values : 8, 10
# default value : 8
BitDepth = 8
# NumSlices : number of row-based slices used for each frame
# allowed values : from 1 up to the number of coding unit rows in the frame
# default value : 1
NumSlices = 2
# QPCtrlMode : specifies how to generate the QP per coding unit
# allowed values : UNIFORM_QP, AUTO_QP, LOAD_QP, LOAD_QP | RELATIVE_QP
# default value : UNIFORM_QP
QPCtrlMode = UNIFORM_QP
# ScalingList : specifies the scaling list mode
# allowed values : FLAT, DEFAULT, CUSTOM
# default value : DEFAULT
ScalingList = FLAT
# EntropyMode : selects the entropy coding mode (AVC only)
# allowed values : MODE_CAVLC, MODE_CABAC
# default value : MODE_CABAC
EntropyMode = MODE_CABAC
# LoopFilter : enables/disables the deblocking filter
# allowed values : ENABLE, DISABLE
# default value : ENABLE
LoopFilter = ENABLE
#--------------------------------------------------------------------------
[RUN]
#--------------------------------------------------------------------------
# Loop : specifies whether the encoder should loop back to the beginning of the YUV input stream when it reaches the end of the file
# Allowed values : TRUE, FALSE
# default value : FALSE
Loop = TRUE
# MaxPicture : number of frames to encode
# Allowed value : ALL, 1.. 2147483647
# default value : ALL
MaxPicture = 10
# FirstPicture : specifies the first frame to encode
# Allowed value : 0.. 2147483647
# default value : 0
FirstPicture = 0
All the parameters/settings in the configuration file are explained in PG252. Running this does not take an expert, how knowing what each setting is and changing those to get optimum compress and quality does.
Comments
Please log in or sign up to comment.