MICROCHIP H.264 4K I-Frame Encoder IP Cores User Guide

June 13, 2024
MICROCHIP

MICROCHIP H.264 4K I-Frame Encoder IP Cores

Introduction

H.264 is a popular video compression standard to compress a digital video. It is also known as MPEG-4 Part10 or Advanced Video Coding (MPEG-4 AVC). H.264 uses the block-wise approach for compressing a video where the block size is defined as 16 x 16 and such block is called a macro block. The compression standard supports various profiles that define the compression ratio and complexity of implementation. The video frames to be compressed are treated as I-Frame, P-Frame, and B-Frame. An I-Frame is an intra-coded frame where compression is done by using the information contained within the frame. No other frames are required to decode the I-Frame. A P-Frame is compressed by using the changes with respect to an earlier frame that can be an I-Frame or a P-Frame. The compression of B-Frame is done by using the motion changes with respect to both an earlier frame and an upcoming frame. The I-Frame compression process has four stages—Intra prediction, Integer transformation, Quantization, and Entropy encoding. H.264 supports two types of encoding—Context Adaptive Variable Length Coding (CAVLC) and Context Adaptive Binary Arithmetic Coding (CABAC). The current version of the IP implements Baseline profile and uses CAVLC for entropy encoding. Also, the IP supports encoding of only I-Frames upto 4K resolution.

Features

H.264 I-Frame Encoder supports the following key feature:

  • Implements Compression on YCbCr 420 Video Format
  • Expects the Input in YCbCr 422 Video Format
  • Supports 8 bits for Each Component (Y, Cb, and Cr)
  • Supports ITU-T H.264 Annex B Compliant NAL byte Stream Output
  • Standalone Operation, CPU, or Processor Assistance Not Required
  • User Configurable Quality Factor QP During Run Time
  • Computation at the Rate of 1 pixel Per Clock
  • Supports Compression up to Resolution of 4K (3840 × 2160) 60 fps
  • Minimal Latency (252 μs for full HD or 17 horizontal lines)
  • Supports 2 and 4 slices

Supported Families
The H.264 4K I-Frame Encoder supports the following families:

  • PolarFire® SoC FPGA
  • PolarFire FPGA

Hardware Implementation

The following figure shows the H.264 4K I-Frame Encoder IP block diagram.
Figure 1-1. H.264 4K I-Frame Encoder IP Block DiagramMICROCHIP-H-264-4K-I-Frame-Encoder-IP-Cores-FIG-1
\(1\)

Inputs and Outputs
The following table lists the input and output ports of H.264 4K I-Frame Encoder IP.
Table 1-1. Input and Output Ports of H.264 4K I-Frame Encoder IP

Signal Name Direction Width Description
RESET_N Input 1 Active-low Asynchronous reset signal to the design.
PIX_CLK_I Input 1 Input clock with which incoming pixels are sampled.
DDR_CLK_I Input 1 Clock from DDR memory controller.
HRES_I Input 16 Horizontal resolution of input image. It must be multiple

of 16.
VRES_I| Input| 16| Vertical resolution of input image. It must be multiple of 16.
QP_I| Input| 6| Quality factor for H.264 quantization. The value ranges from 0 to 51 where 0 represents the highest quality and the lowest compression and 51 represents the highest compression.
DATA0_O| Output| 16| H.264 Slice0 encoded data output that contains NAL unit, Slice header, SPS, PPS, and the encoded data of macro blocks.
DATA_VALID0_O| Output| 1| Signal denoting Slice0 encoded data is valid.
DATA1_O| Output| 16| H.264 Slice1 encoded data output that contains Slice header, and the encoded data of macro blocks.
DATA_VALID1_O| Output| 1| Signal denoting Slice1 encoded data is valid.
DATA2_O| Output| 16| H.264 Slice2 encoded data output that contains Slice header, and the encoded data of macro blocks.
DATA_VALID2_O| Output| 1| Signal denoting Slice2 encoded data is valid.
………..continued

Signal Name| Direction| Width| Description
DATA3_O| Output| 16| H.264 Slice3 encoded data output that contains Slice header, and the encoded data of macro blocks.
DATA_VALID3_O| Output| 1| Signal denoting Slice3 encoded data is valid.
DDR_LINE_GAP_I| Input| 16| Line gap between input image horizontal lines in the DDR memory.
FRAME_START_ADDR_I| Input| 7/8| DDR frame buffer address. 7 bits when the frame gap is configured for 32 MB. 8 bits when the frame gap is configured for 16 MB.
FRAME_END_O| Output| 1| End of H.264 bit stream for a frame.
Read Channel 0 Arbiter Interface Ports
RDATA0_I| Input| Input data width| Read data from arbiter
RVALID0_I| Input| 1| Read data valid from arbiter
ARREADY0_I| Input| 1| Arbiter acknowledgment
BUSER0_I| Input| 1| Read completion
ARADDR0_O| Output| 32| DDR address from where read must be started
ARVALID0_O| Output| 1| Read request to arbiter
ARSIZE0_O| Output| 8| Read burst size
Read Channel 1 Arbiter Interface Ports
RDATA1_I| Input| Input data width| Read data from arbiter
RVALID1_I| Input| 1| Read data valid from arbiter
ARREADY1_I| Input| 1| Arbiter acknowledgment
BUSER1_I| Input| 1| Read completion
ARADDR1_O| Output| 32| DDR address from where read must be started
ARVALID1_O| Output| 1| Read request to arbiter
ARSIZE1_O| Output| 8| Read burst size
Read Channel 2 Arbiter Interface Ports
RDATA2_I| Input| Input data width| Read data from arbiter
RVALID2_I| Input| 1| Read data valid from arbiter
ARREADY2_I| Input| 1| Arbiter acknowledgment
BUSER2_I| Input| 1| Read completion
ARADDR2_O| Output| 32| DDR address from where read must be started
ARVALID2_O| Output| 1| Read request to arbiter
ARSIZE2_O| Output| 8| Read burst size
Read Channel 3 Arbiter Interface Ports
RDATA3_I| Input| Input data width| Read data from arbiter
RVALID3_I| Input| 1| Read data valid from arbiter
………..continued

Signal Name| Direction| Width| Description
ARREADY3_I| Input| 1| Arbiter acknowledgment
BUSER3_I| Input| 1| Read completion
ARADDR3_O| Output| 32| DDR address from where read must be started
ARVALID3_O| Output| 1| Read request to arbiter
ARSIZE3_O| Output| 8| Read burst size

Configuration Parameters
The following table lists the description of the generic configuration parameters used in the hardware implementation of the H.264 4K I-Frame Encoder, which can vary based on the application requirements.
Table 1-2. H.264 4K I-Frame Encoder Configuration Parameters

Name Description
16x16_DC_INTRA_PREDICTION Option to Enable the 16 x 16 intra dc prediction

along with 4 x 4 intra dc prediction.
NUM_SLICES| Select 2 slices to support 4K at 30 fps. Select 4 slices to support 4K at 60 fps.
DDR_AXI_DATA_WIDTH| Select the DATA width of read channel, which must be connected to video arbiter IP.
FRAME_GAP| Select the frame buffer size. For 4K select 32 MB.

IP Configurator
The following figure shows the H.264 4K I-Frame Encoder IP configurator.

Figure 1-2. IP ConfigurationMICROCHIP-H-264-4K-I-Frame-Encoder-IP-
Cores-FIG-1 \(2\)

Hardware Implementation of H.264 4K I-Frame Encoder IP
The H.264 4K I-Frame Encoder IP divides each frame into 2/4 slices and encodes using the slice encoder. The DDR read logic expects the frame data in DDR memory as YCbCr 422 format. The line gap between every horizontal line of frame in DDR memory must be specified through DDR_LINE_GAP_I input. The IP uses 422 formats as input and implements compression in 420 formats. The Slice0 output also contains the SPS and PPS header. All slices bit stream is provided seperately. All slices bit stream combine together becomes the final H.264 bit stream. The following figure shows the H.264 4K I-Frame encoder IP block diagram.
Figure 1-3. H.264 4K I-Frame Encoder IP Block DiagramMICROCHIP-H-264-4K-I-Frame-Encoder-IP-Cores-FIG-1
\(3\)

The following figure shows the slice encoder block diagram.

Figure 1-4. Slice Encoder Block DiagramMICROCHIP-H-264-4K-I-Frame-
Encoder-IP-Cores-FIG-1 \(4\)

Design Description Slice Encoder
This section describes the different internal modules of the slice encoder.
16 x 16 Matrix Framer
This module frames the 16 x 16 macro blocks for Y component as per H.264 specification. Line buffers are used to store 16 horizontal lines of input image, and a 16 x 16 matrix is framed using shift registers.
8 x 8 Matrix Framer
This module frames the 8 x 8 macro blocks for the C component as per H.264 specification for 420 formats. Line buffers are used to store 8 horizontal lines of input image, and an 8 x 16 matrix is framed using shift registers. From the 8 x 16 matrix, the Cb and Cr components are separated to frame each 8 x 8 matrix.
4 x 4 Matrix Framer
The integer transform, quantization, and CAVLC encoding operate on a 4 x 4 sub-block within a macroblock. The 4 x 4 matrix framer generates a 4 x 4 sub- block from a 16 x 16 or 8 x 8 macroblock. This matrix generator spans through all the sub-blocks of a macroblock before going to the next macroblock.
Intra Prediction
H.264 uses various intra-prediction modes to reduce the information in a 4 x 4 block. The intra-prediction block in the IP uses only 4 x 4 or 16 x 16 DC prediction. 16 x 16 is used for QP values more than 35 if 16 x 16 intra-DC prediction is enabled in the IP configurator. The DC component is computed from the adjacent top and left 4 x 4 or 16 x 16 blocks.
Integer Transform
H.264 uses integer discrete cosine transform where the coefficients are distributed across the integer transform matrix and the quantization matrix such that there are no multiplications or divisions in the integer transform. The integer transform stage implements the transformation using shift and add operations.
Quantization
The quantization multiplies each output of the integer transform with a predetermined quantization value defined by the QP user input value. The range of QP value is from 0 to 51. Any value more than 51 is clamped to 51. A lower QP value denotes lower compression and higher quality and vice versa.
CAVLC
H.264 uses two types of entropy encoding—Context Adaptive Variable Length Coding (CAVLC) and Context Adaptive Binary Arithmetic Coding (CABAC). The IP uses CAVLC for encoding the quantized output.
Header Generator
The header generator block generates the block headers, slice headers, Sequence Parameter Set (SPS), Picture Parameter Set (PPS), and Network Abstraction Layer (NAL) unit depending on the instance of the video frame.
H.264 Stream Generator
The H.264 stream generator block combines the CAVLC output along with the headers to create the encoded output as per the H.264 standard format.

Testbench

Testbench is provided to check the functionality of H.264 4K I-Frame Encoder IP.
Simulation
The simulation uses a 432 x 240 image in YCbCr422 format represented by two files, each for Y and C as input and generates a H.264 with 4 slices file format that contains two frames.
The following steps describe how to simulate the core using the testbench:

  1. Go to Libero® SoC Catalog > View > Windows > Catalog, and then expand Solutions-Video. Double click H264_4K_Iframe_Encoder, and then click OK. H264_4K_Iframe-Encoder IP appears on the SmartDesign canvas.
    Figure 2-1. H.264 4K I-Frame Encoder IP Core in Libero® SoC Catalog

  2. Go to the Files tab and select simulation > Import Files.
    Figure 2-2. Import Files

  3. Import the H264_sim_data_in_y.txt, H264_sim_data_in_c.txt, and H264_refOut.txt files from the following path: ..\\component\Microsemi\SolutionCore\ H264_4K_Iframe_Encoder\ \Stimulus.

  4. To import a different file, browse the folder that contains the required file, and click Open. The imported file is listed under simulation, see the following figure.
    Figure 2-3. Imported Files

  5. Go to the Design Hierarchy tab and right click on H264_4K_Iframe_Enc_C0 and select Set As Root. Figure 2-4. Set As Root

  6. Go to the Stimulus Hierarchy tab and select H264_4K_Iframe_Encoder_tb (H264_4K_Iframe_Encoder_tb. v) > Simulate Pre-Synth Design > Open Interactively. The IP is simulated for two frames. Figure 2-5. Simulating Pre-Synthesis DesignMICROCHIP-H-264-4K-I-Frame-Encoder-IP-Cores-FIG-1 \(9\)

  7. ModelSim opens with the testbench file as shown in the following figure.

Figure 2-6. ModelSim Simulation WindowMICROCHIP-H-264-4K-I-Frame-
Encoder-IP-Cores-FIG-1 \(10\)

Important: If the simulation is interrupted due to the runtime limit specified in the .do file, use the run -all command to complete the simulation.

License

  • H.264 4K I-Frame Encoder IP is provided only in encrypted form under license.
  • Encrypted RTL source code is license locked, must be purchased separately. You can perform simulation, synthesis, layout, and program the Field Programmable Gate Array (FPGA) silicon using the Libero design suite.
  • Evaluation license is provided for free to check the H.264 Encoder features. The evaluation license expires after an hour’s use on the hardware.

Installation Instructions

  • The core must be installed into Libero SoC software. It is done automatically through the Catalog update function in
  • Libero SoC software, or the CPZ file can be manually added using the Add Core catalog feature. When the CPZ file is installed in Libero, the core can be configured, generated, and instantiated within SmartDesign for inclusion in the Libero project.
  • For more instructions on core installation, licensing, and general use, see Libero SoC Online Help.

The following table lists the resource utilization of a sample H.264 4K I-Frame Encoder IP design made for PolarFire FPGA (MPF300TS-1FCG1152I package) and generates compressed data by using 4:2:2 sampling of input data.
Table 5-1. Resource Utilization of the H.264 4K I-Frame Encoder IP

Element 4 Slices 2 Slices
4LUTs 73588 37017
DFFs 67543 33839
LSRAM 592 296
µSRAM 84 42
Math Blocks 89 45
Interface 4-input LUTs 25524 12780
Interface DFFs 25524 12780

Revision History

The revision history table describes the changes that were implemented in the document. The changes are listed by revision, starting with the most current publication.
Table 6-1. Revision History

Revision Date Description
A 01/2023 Initial Release.

Microchip FPGA Support

Microchip FPGA products group backs its products with various support services, including Customer Service, Customer Technical Support Center, a website, and worldwide sales offices. Customers are suggested to visit Microchip online resources prior to contacting support as it is very likely that their queries have been already answered. Contact the Technical Support Center through the website at www.microchip.com/support. Mention the FPGA Device Part number, select the appropriate case category, and upload desig  files while creating a technical support case. Contact Customer Service for non-technical product support, such as product pricing, product upgrades, update information, order status, and authorization.

  • From North America, call 800.262.1060
  • From the rest of the world, call 650.318.4460
  • Fax, from anywhere in the world, 650.318.8044

Microchip Information

The Microchip Website
Microchip provides online support via our website at www.microchip.com/. This website is used to make files and information easily available to customers. Some of the content available includes:

  • Product Support – Datasheets and errata, application notes and sample programs, design resources, user’s guides and hardware support documents, latest software releases and archived software
  • General Technical Support – Frequently Asked Questions (FAQs), technical support requests, online discussion groups, Microchip design partner program member listing
  • Business of Microchip – Product selector and ordering guides, latest Microchip press releases, the listing of seminars and events, listings of Microchip sales offices, distributors, and factory representatives

Product Change Notification Service
Microchip’s product change notification service helps keep customers current on Microchip products. Subscribers will receive email notification whenever there are changes, updates, revisions, or errata related to a specified product family or development tool of interest.
To register, go to www.microchip.com/pcn. and follow the registration instructions.

Customer Support

Users of Microchip products can receive assistance through several channels:

  • Distributor or Representative
  • Local Sales Office
  • Embedded Solutions Engineer (ESE)
  • Technical Support

Customers should contact their distributor, representative or ESE for support. Local sales offices are also available to help customers. A listing of sales offices and locations is included in this document.
Technical support is available through the website at: www.microchip.com/support.

Microchip Devices Code Protection Feature
Note the following details of the code protection feature on Microchip products:

  • Microchip products meet the specifications contained in their particular Microchip Data Sheet.
  • Microchip believes that its family of products is secure when used in the intended manner, within operating specifications, and under normal conditions.
  • Microchip values and aggressively protects its intellectual property rights. Attempts to breach the code protection features of Microchip product is strictly prohibited and may violate the Digital Millennium Copyright Act.
  • Neither Microchip nor any other semiconductor manufacturer can guarantee the security of its code. Code protection does not mean that we are guaranteeing the product is “unbreakable”.
  • Code protection is constantly evolving. Microchip is committed to continuously improving the code protection features of our products.

Legal Notice
This publication and the information herein may be used only with Microchip products, including to design, test, and integrate Microchip products with your application. Use of this information in any other manner violates these terms. Information regarding device applications is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. Contact your local Microchip sales office for additional support or, obtain additional support at www.microchip.com/en-us/support/design-help/client-support- services. THIS INFORMATION IS PROVIDED BY MICROCHIP “AS IS”. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE, OR WARRANTIES RELATED TO ITS CONDITION, QUALITY, OR PERFORMANCE. IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, INCIDENTAL, OR CONSEQUENTIAL LOSS, DAMAGE, COST, OR EXPENSE OF ANY KIND WHATSOEVER RELATED TO THE INFORMATION OR ITS USE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP’S TOTAL LIABILITY ON ALL CLAIMS IN ANY WAY RELATED TO THE INFORMATION OR ITS USE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THE INFORMATION. Use of Microchip devices in life support and/or safety applications is entirely at the buyer’s risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use.  No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights unless otherwise stated.

Trademarks
The Microchip name and logo, the Microchip logo, Adaptec, AVR, AVR logo, AVR Freaks, BesTime, BitCloud, CryptoMemory, CryptoRF, dsPIC, flexPWR, HELDO, IGLOO, JukeBlox, KeeLoq, Kleer, LANCheck, LinkMD, maXStylus, maXTouch, MediaLB, megaAVR, Microsemi, Microsemi logo, MOST, MOST logo, MPLAB, OptoLyzer, PIC, picoPower, PICSTART, PIC32 logo, PolarFire, Prochip Designer, QTouch, SAM-BA, SenGenuity, SpyNIC, SST, SST Logo, SuperFlash, Symmetricom, SyncServer, Tachyon, TimeSource, tinyAVR, UNI/O, Vectron, and XMEGA are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. AgileSwitch, APT, ClockWorks, The Embedded Control Solutions Company, EtherSynch, Flashtec, Hyper Speed Control, HyperLight Load, Libero, motorBench, mTouch, Powermite 3, Precision Edge, ProASIC, ProASIC Plus, ProASIC Plus logo, Quiet- Wire, SmartFusion, SyncWorld, Temux, TimeCesium, TimeHub, TimePictra, TimeProvider, TrueTime, and ZL are registered trademarks of Microchip Technology Incorporated in the U.S.A. Adjacent Key Suppression, AKS, Analog-for-the-Digital Age, Any Capacitor, AnyIn, AnyOut, Augmented Switching, BlueSky, BodyCom, Clockstudio, CodeGuard, CryptoAuthentication, CryptoAutomotive, CryptoCompanion, CryptoController, dsPICDEM, dsPICDEM.net, Dynamic Average Matching, DAM, ECAN, Espresso T1S, EtherGREEN, GridTime, IdealBridge, In-Circuit Serial Programming, ICSP, INICnet, Intelligent Paralleling, IntelliMOS, Inter-Chip Connectivity, JitterBlocker, Knob-on- Display, KoD, maxCrypto, maxView, membrane, Mindi, MiWi, MPASM, MPF, MPLAB Certified logo, MPLIB, MPLINK, MultiTRAK, NetDetach, Omniscient Code Generation, PICDEM, PICDEM.net, PICkit, PICtail, PowerSmart, PureSilicon, QMatrix, REAL ICE, Ripple Blocker, RTAX, RTG4, SAM ICE, Serial Quad I/O, simple map, SimpliPHY, SmartBuffer, SmartHLS, SMART-I.S., storClad, SQI, SuperSwitcher, SuperSwitcher II, Switchtec, SynchroPHY, Total Endurance, Trusted Time, TSHARC, USBCheck, VariSense, VectorBlox, VeriPHY, ViewSpan, WiperLock, XpressConnect, and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. The Adaptec logo, Frequency on Demand, Silicon Storage Technology, and Symmcom are registered trademarks of Microchip Technology Inc. in other countries. GestIC is a registered trademark of Microchip Technology Germany II GmbH & Co. KG, a subsidiary of Microchip Technology Inc., in other countries. All other trademarks mentioned herein are the property of their respective companies. © 2023, Microchip Technology Incorporated and its subsidiaries. All Rights Reserved. ISBN: 978-1-6683-1888-1

Quality Management System
For information regarding Microchip’s Quality Management Systems, please visit www.microchip.com/quality.

Worldwide Sales and Service

AMERICAS

Corporate Office

Atlanta

Austin, TX

Boston

Chicago

Dallas

Detroit

Houston, TX

Indianapolis

Los Angeles

Raleigh, NC

New York, NY

San Jose, CA

Canada – Toronto

ASIA/PACIFIC

  • Australia – Sydney
    • Tel: 61-2-9868-6733
  • China – Beijing
    • Tel: 86-10-8569-7000
  • China – Chengdu
    • Tel: 86-28-8665-5511
  • China – Chongqing
    • Tel: 86-23-8980-9588
  • China – Dongguan
    • Tel: 86-769-8702-9880
  • China – Guangzhou
    • Tel: 86-20-8755-8029
  • China – Hangzhou
    • Tel: 86-571-8792-8115
  • China – Hong Kong SAR
    • Tel: 852-2943-5100
  • China – Nanjing
    • Tel: 86-25-8473-2460
  • China – Qingdao
    • Tel: 86-532-8502-7355
  • China – Shanghai
    • Tel: 86-21-3326-8000
  • China – Shenyang
    • Tel: 86-24-2334-2829
  • China – Shenzhen
    • Tel: 86-755-8864-2200
  • China – Suzhou
    • Tel: 86-186-6233-1526
  • China – Wuhan
    • Tel: 86-27-5980-5300
  • China – Xian
    • Tel: 86-29-8833-7252
  • China – Xiamen
    • Tel: 86-592-2388138
  • China – Zhuhai
    • Tel: 86-756-3210040

© 2023 Microchip Technology Inc. and its subsidiaries DS50003486A-

References

Read User Manual Online (PDF format)

Read User Manual Online (PDF format)  >>

Download This Manual (PDF format)

Download this manual  >>

Related Manuals