
H.264 Motion Estimation Engine v1.0
User Guide [optional]
User Guide
UG453 (v1.1) April 23, 2008 [optional]

Xilinx is disclosing this user guide, manual, release note, and/or specification (the “Documentation”) to you solely for use in the development of designs to operate with Xilinx hardware devices. You may not reproduce, distribute, republish, download, display, post, or transmit the Documentation in any form or by any means including, but not limited to, electronic, mechanical, photocopying, recording, or otherwise, without the prior written consent of Xilinx. Xilinx expressly disclaims any liability arising out of your use of the Documentation. Xilinx reserves the right, at its sole discretion, to change the Documentation without notice at any time. Xilinx assumes no obligation to correct any errors contained in the Documentation, or to advise you of any corrections or updates. Xilinx expressly disclaims any liability in connection with technical support or assistance that may be provided to you in connection with the Information.
THE DOCUMENTATION IS DISCLOSED TO YOU “AS-IS” WITH NO WARRANTY OF ANY KIND. XILINX MAKES NO OTHER WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, REGARDING THE DOCUMENTATION, INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NONINFRINGEMENT OF THIRD-PARTY RIGHTS. IN NO EVENT WILL XILINX BE LIABLE FOR ANY CONSEQUENTIAL, INDIRECT, EXEMPLARY, SPECIAL, OR INCIDENTAL DAMAGES, INCLUDING ANY LOSS OF DATA OR LOST PROFITS, ARISING FROM YOUR USE OF THE DOCUMENTATION.
© 2007-2008 Xilinx, Inc. All rights reserved.
XILINX, the Xilinx logo, the Brand Window, and other designated brands included herein are trademarks of Xilinx, Inc. All other trademarks are the property of their respective owners.
The following table shows the revision history for this document.


Chapter 2: Installing the H.264 Motion Estimation Engine Core
Chapter 3: Designing with the H.264 Motion Estimation Engine Core
Figure 3-1: H.264 Encoder 17
Figure 3-2: Motion Estimation Engine Block Diagram 19
Chapter 5: Verifying the System
Figure 5-1: Verification Process (Level 1) 24
Figure A-1: Directory Tree Structure 28
UG453 (v1.1) April 23, 2008 www.xilinx.com H.264 Motion Estimation Engine



Chapter 2: Installing the H.264 Motion Estimation Engine Core
Chapter 3: Designing with the H.264 Motion Estimation Engine Core
Chapter 4: Simulating the H. 264 Motion Estimation Engine Core
Chapter 5: Verifying the System
Table 5-1: Verifcation Level Summary 24
Table A-1: Regression Test Summary 27
UG453 (v1.1) April 23, 2008 www.xilinx.com H.264 Motion Estimation Engine



About This Guide
This document is intended to guide the user through all aspects of installation, demonstration, simulation, verification, and general usage of the Motion Estimation Engine core. It should be read in conjunction with the Xilinx Motion Estimation Engine Product Specification (DS648).
This manual contains the following chapters:
To find additional documentation, see the Xilinx website at:
http://www.xilinx.com/literature
To search the Answer Database of silicon, software, and IP questions and answers, or to create a technical support WebCase, see the Xilinx website at:
This document uses the following conventions. An example illustrates each convention.

The following typographical conventions are used in this document:
The following conventions are used in this document:

Conventions


Introduction
This user guide is required reading for the engineer using or considering using the Xilinx® Motion Estimation Engine core. The release of this product is given in ZIP file form.
The Xilinx Motion Estimation Engine core accepts input parameters on a frame and macroblock basis and a stream of pixels in macroblock format and generates output motion vectors, Sum-of-Absolute Difference (SAD) values, and coded block pattern with best motion vector for each block.
Although the Motion Estimation Engine core is a fully-verified solution, the challenge associated with implementing a complete design varies depending on the configuration and functionality of the application. For best results, previous experience building high- performance pipelined FPGA designs using Xilinx implementation software and user constraints files (UCF) is recommended.
Contact your local Xilinx representative for a closer review and estimation for your specific site requirements.
For detailed information and updates about the Motion Estimation Engine core, see the documents located on the Motion Estimation Engine product page. In general, this document should always be used in conjunction with the following:
For technical support, go to www.xilinx.com/support Questions are routed to a team of engineers with expertise using the Motion Estimation Engine core.
Xilinx provides technical support for use of this product as described in this guide.
Xilinx cannot guarantee timing, functionality, or support of this product for designs that do not follow these guidelines.

Xilinx welcomes comments and suggestions about the Motion Estimation Engine core and the accompanying documentation. For comments or suggestions about the Motion Estimation Engine core, submit a WebCase from www.xilinx.com/support Be sure to include the following information:
For comments or suggestions about this document, submit a WebCase from www.xilinx.com/support Be sure to include the following information:

Installing the H.264 Motion Estimation Engine Core
This chapter provides instructions for installing the H. 264 Motion Estimation Engine core.
The Motion Estimation Engine fixed netlist is provided under the Xilinx LogiCORE™ Site License Agreement, which conforms to the terms of the SignOnce IP Site License standard defined by the Common License Consortium.
Install the core by performing a manual installation after downloading the core from the web.
https://secure.xilinx.com/webreg/register.do?group=h264_me
Prompted to enter a login name and password, enter your Xilinx login name and password.
a. H264_MotionEstimation_verx_y_utils.zip – unzip this first.
b. H.264_MotionEstimation_verx_y_ReleaseNetlists.zip
c. H264_MotionEstimation_verx_y_InputSequences.zip
Windows · Software

The netlists given in this release of the H. 264 Motion Estimation Engine are all in the \ReleasedNetlists directory. They have been synthesized using Synplify_Pro 8.8.0.4 for Spartan™-3A (S3A), Virtex™-4 (V4), and Virtex-5 (V5) FPGAs:
To learn how to instantiate the cores in your system, refer to Chapter 3, “Designing with the H.264 Motion Estimation Engine Core.”

Designing with the H.264 Motion Estimation Engine Core
This chapter describes how to include a Motion Estimation Engine core into the next hierarchy of system architecture.
To help the user design the core into his system, the release provides the following template files. Neither the core source code nor the HDL libraries have been provided in source form but in object code format for simulation purposes.
/HDL/LowCost_MotionEstimation/MotionEstimation/src/MotionEstimation.vho
/HDL/LowCost_MotionEstimation/MotionEstimation/Testbench/MotionEstimation_TB.vho
Figure 3-1 shows the Motion Estimator in a typical implementation of an encoder. For more information on the system-level integration, refer to the H.264 specification [Ref 1].
X-Ref Target - Figure 3-1


Motion estimation requires a definition of a search region and a search scheme to find the best match (motion vector) within a search region. Rate-Distortion theory also takes into consideration vectors that may be close together, but not necessarily the best SAD value in finding the optimal motion vector to choose for entropy coding. Searching within the search region can be done exhaustively, but the computational overhead is prohibitive. Thus, a search scheme with seed motion vectors and regions to search are desired. In this implementation of the motion estimation, 10 seed vectors are provided for each 8x4 block with eight 8x4 blocks in a 16x16 macroblock. A 4x3 region is searched to the right and down from the seed vector.
Another difficult part of motion estimation is the localization of memory to allow for easy access to the search region. In this implementation, a sliding window of eight macroblocks high and seven macroblocks wide is utilized to keep the external memory transfers efficient and the bandwidth manageable.
Processing begins with frame parameters being updated each frame and the first macroblock being sent to the core. Macroblock parameters in the form of seed vectors (80) are send to the core and the H.264 Motion Estimation Engine processes and produces SADs and the list of Motion Vectors searched corresponding to the SADs produced. See Figure 3-2.
H.264 allows for variable block sizes within a macroblock. If through the search process the best motion vector (minimum SAD) for two blocks is identical, then the block can be merged to be a larger block, that is, two 8x4 blocks to an 8x8 block. The Variable Block Size Decision block performs this processing and provides as an output the coded block pattern for a macroblock and corresponding best motion vectors and SADs.

Motion Estimation in the H.264 Encoder
X-Ref Target - Figure 3-2
FULL PEL Motion Estimation


Simulating the H. 264 Motion Estimation Engine Core
This chapter describes a test bench architecture that was created in the ModelSim environment for simulation of the Motion Estimation Engine core. It does not describe the verification platform. The simulation described may be used for visualization of the I/O signals at the periphery of the cores. Although the same precompiled libraries are used in the verification of the Motion Estimation Engine core, this process is described in detail in Chapter 5, “Verifying the System.”
For the purposes of running, viewing, and understanding the test bench and the architectures used, the release provides the following files under \HDL\LowCost_MotionEstimation\MotionEstimation:
/HDL/LowCost_MotionEstimation/MotionEstimation/Testbench/ stimuli/ (input stimulus files)
/HDL/LowCost_MotionEstimation/MotionEstimation/Testbench/ MotionEstimation_prim.do
/HDL/LowCost_MotionEstimation/MotionEstimation/Testbench/ MotionEstimation_core.do
/HDL/LowCost_MotionEstimation/MotionEstimation/Testbench/ MotionEstimation_user.do
/HDL/LowCost_MotionEstimation/MotionEstimation/Testbench/ vsim_gui.bat

/HDL/LowCost_MotionEstimation/MotionEstimation/Testbench/ MotionEstimation_TB.vhd
To run the test bench:
If the the following error is received, the user needs to run the refresh command, vcom -refresh:
#**Error: (vsim-13) Recompile work.vfbc_infrastructure because C:\opt\Modeltech_6.1f\xilinx_libs_9_2_03i_ip2\.\unisims.vcomponents has changed.
The stimulus data for this simulation is held in the \HDL\LowCost_MotionEstimation\MotionEstimation\Testbench\stimul i directory, consisting of several input text files and some expected output text files. The stimulus data files and expected output files provided contain data extracted from the reference C model (see [Ref 1]).
The simulation generates these output files:
\HDL\LowCost_MotionEstimation\MotionEstimation\Testbench\ MotionEstimation_MVs.out.txt
\HDL\LowCost_MotionEstimation\MotionEstimation\Testbench\ MotionEstimation_ParamsMB.out.txt
\HDL\LowCost_MotionEstimation\MotionEstimation\Testbench\ MotionEstimation_SADs.out.txt
that are directly comparable to the reference expected output.
\HDL\LowCost_MotionEstimation\MotionEstimation\Testbench\ stimuli\MotionEstimation_MVs.out.txt
\HDL\LowCost_MotionEstimation\MotionEstimation\Testbench\ stimuli\MotionEstimation_ParamsMB.out.txt
\HDL\LowCost_MotionEstimation\MotionEstimation\Testbench\ stimuli\MotionEstimation_SADs.out.txt
In Chapter 5, “Verifying the System,” of this document, the process by which stimulus and expected results are generated from the reference code is described. The generated files may be used in place of the default simulation files provided with the release, but must reside in the locations mentioned above during simulation.

Verifying the System
This chapter describes the verification environment delivered with the Motion Estimation Engine core. Ultimately, the system is verified by using long regression tests with several different resolution input sequences. The output of the hardware from these tests must exactly match the output given by the reference software that runs with the same stimulus.
For the purposes of running, viewing, and understanding the verification process, the release provides the following files:
See the “Appendix, “Supporting Information” for the full file list.
\Verification\MotionEstimation\MotionEstimation_Verification.pl
\Verification\MotionEstimation\MotionEstimation_Verification_Le vel1.bat
\TestBenchSupport\TestBenchSupport.pm
\Software\ArchC_Rev3\bin\lencod.exe

There are five tests that can be run by the user. Each test has varying characteristics, including varying video formats, parameter settings, etc. A description of the tests is given in the Appendix, “Supporting Information” and is also summarized in the batch scripts listed under item 3 (Verification scripts) above.
Verification is automated down to running the simple editable Level1 batch script. It contains the command line:
perl -I"..\..\TestBenchSupport" MotionEstimation_Verification.pl [TestLevel][No. Frames][Test#]
Test#: between 0 and 5 inclusive (0 runs all tests in order from 1 to 5)
Edit the file as desired. Double clicking on the batch file invokes the appropriate test to be executed. Level 1 simulation is summarized in Table 5-1.
Level Reference Executable HW Representation Notes
Level 1 ArchC_rev3\bin\len cod.exe
MTI Simulation (precompiled libraries)
Table 5-1 shows the verification process (Level 1).
X-Ref Target - Figure 5-1
Modified JM10.2 Reference Software \ArchC_Rev3\bin\lencod.exe
START.yuv Video Source file .cfg encoder

The command line in the batch script invokes the following processes in this order:
This Perl script calls functions in the general-purpose test bench support module that runs the reference code:
\Software\ArchC_Rev3\bin\lencod.exe
\Verification\MotionEstimation\Level1\Testxx\stimuli\MotionEstimation in.txt
…and the expected output reference file:
\Verification\MotionEstimation\Level1\Testxx\ MotionEstimation out.x
\Verification\MotionEstimation\Level1\Testxx\ MotionEstimation out.txt
\Verification\MotionEstimation\ EncoderVerification_Summary_Level1.txt
When test number is set to 0 in the batch script file, all tests are run in sequence from 1 to 10. When doing this, by default, all tests are run regardless of whether they have been run in the past. If some tests have already been run, but some others have not been run or their results deleted, then the user may wish to run only the remaining tests. The user can do this by editing the MotionEstimation_Verification.pl script, commenting out the line:
Use ‘#’ to comment).
Also, if you want to take this approach, but rerun one or some tests selectively, delete the test directory of the test(s) you want to rerun:
and rerun the script.
Verification Notes · $ForceRegenerateAll = "1"; · MotionEstimation\Level1\testxx


Supporting Information
Input Sequences
The files provided as video input source files are:
\InputSequences\city_4cif_30\city_4cif_30.hdr
\InputSequences\city_4cif_30\city_4cif_30.yuv
\InputSequences\football_cif_30\football_cif_30.hdr
\InputSequences\football_cif_30\football_cif_30.yuv
\InputSequences\foreman_qcif_30\foreman_qcif_30.hdr
\InputSequences\foreman_qcif_30\foreman_qcif_30.yuv
\InputSequences\shields_720p_60\shields_720p_60.hdr
\InputSequences\shields_720p_60\shields_720p_60.yuv
\InputSequences\tractor_1088p_30\tractor_1088p_30.hdr
\InputSequences\tractor_1088p_30\tractor_1088p_30.yuv
All sequences are 10 frames long.
Figure A-1 shows the structure of the Motion Estimation directories after unzipping the three ZIP files.
Table A-1 describes the regression tests used by showing the main digressions from the default settings. See the generated JM code configuration file for more information.
Test Number Stream Image size Test Specifics Details
1 foreman_qcif_30 176x144 Baseline 1 Reference Frame
2 football_cif_30 352x288 Baseline 1 Reference Frame
3 city_4cif_30 704x576 Baseline 1 Reference Frame
4 shields_720p_60 1280x720 Baseline 1 Reference Frame
5 tractor_1088p_30 1920x1080 Baseline 1 Reference Frame

X-Ref Target - Figure A-1

Pages referenced in this manual — manufacturer, support and downloads.
Owners and our team usually reply within a day — and your question helps the next person too.
Be the first to ask — other owners or our team will answer.