Working with HEVC Video Coding Standard

Introduction

High Efficiency Video Coding (HEVC) is the latest video coding standard developed by Joint Collaborative Team on Video Coding (JCT-VC). JCT-VC has been jointly established by ISO/IEC Moving Picture Experts Group (MPEG) and ITU-T Video Coding Experts Group (VCEG). The main goal of the HEVC standard is to significantly improve the compression ratio up to 50% compared to earlier technologies such as H.264/AVC. In other words, HEVC can support up to 50% bit-rate reduction for equal perceptual video quality. The scope of the standard only includes defining the semantic meaning of syntax elements and a decoding process. However, during the standardization process, the team also developed a reference software namely HEVC test Model (HM). The aim of the reference software is to provide a basis upon which to conduct experiments in order to determine coding performance. 

Getting Started with the Reference Software

The main repository URL for HM is https://hevc.hhi.fraunhofer.de/svn/svn_HEVCSoftware/. For Windows user, the svn client TortoiseSVN is needed to check out the source code of HM from the svn server.

step 1: Download TortoiseSVN from http://tortoisesvn.net/downloads.html (current latest version is 1.8.0).

step 2: Select "TortoiseSVN->Settings". and click "Subversioin configuration file: Edit" in "General" to open the configuration file. Add the following lines to configuration file:

[miscellany]

enable-auto-props = yes

[auto-props]

enable-auto-props = yes

*.c = svn:eol-style=native

*.cpp = svn:eol-style=native

*.h = svn:eol-style=native

*.sh = svn:eol-style=native

*.pl = svn:eol-style=native

*.txt = svn:eol-style=native

*.cfg = svn:eol-style=native

Makefile = svn:eol-style=native

makefile = svn:eol-style=native

step 3: Select "SVN Checkout" from right-click menu in Windows Explorer, copy and paste the above repository URL into the "URL of repository" field. In the "Export directory" box, please select a target directory.

Step 4: Click "OK" to start the check out process. This process may take several minutes. 

Microsoft Visual Studio is required to modify and/or compile the source code. There are three solutions in the build folder of the reference software. Open MS Visual Studio and in the file menu, select open-> project\solution. Then select "HM_vc10.sln" in the build folder for MS Visual Studio version 10.


The entire solution can built by either selecting "built solution " from "Built" menu or pressing F7. That operation will produce two .exe files namely "TAppEncoder.exe" and "TAppDecoder.exe". One can encode the raw video file in .yuv format by using "TAppEncoder.exe" file and some configuration files to get str.bin file (the output file in hevc format). The str.bin file is the input file for "TAppDecoder.exe" to get the output yuv file. Windows Command Prompt can be used for execution of these two files. The following command is a sample one for executing the encoder.

TAppEncoder -c encoder_lowdelay.cfg -c basketballpass.cfg

For modifying and debugging the source code, there is another way to set up the MS visual studio. Firstly, the setting for encoder will be presented.

Encoder

1. Select "Set as StartUP Project" in the right click menu of TAppEncoder as shown in figure.
2. Create two new folders (namely: origCFP and testsequences) in the same path with HM.
3. In the HM folder, create a new folder and rename it as working which will store the output files of the encoder.
4. In the right-click menu of TAppEncoder in MS Visual Studio, select properties. And then click Debugging. 
In the Command Arguments field, type -c ../cfg/encoder_lowdelay_main.cfg -c ../cfg/per-sequence/BasketballPass.cfg  (the configuration file name may be vary according to the experiments)
In the Working Directory field, type ../../working
5. Start debugging by using combination of function keys F5 (start debugging), F10 (Step Over) and F11 (Step Into). Breakpoints are very useful indeed!!

Decoder

The decoder has similar steps as follows:
1. Choose "Set as StartUP project" from the right-click menu of TAppDecoder in MS Visual Studio.
2. Then choose "Properties" form the same menu and in the "TAppDecoder Property Pages", go to "Debugging".
In the Command Arguments field, type  -b str.bin -o result.yuv
In the Working Directiory field, type  ../../working
3. Start debugging by using combination of function keys F5 (start debugging), F10 (Step Over) and F11 (Step Into).


To download YUV Test Sequences: 


For HEVC: 


Other standard test sequences:
http://trace.eas.asu.edu/yuv/index.html
http://media.xiph.org/


















22 comments:

  1. Do you know any good documentation for analysis of the codec except the software manual and JVT-VC meeting files. I need a good documentation for understanding the codec.

    ReplyDelete
    Replies
    1. For quick overview, HEVC tutorials by Prof. Iain Richardson (http://www.vcodex.com/h265.html) are good. More deep explanations about the codec can be downloaded from IEEE database (http://ieeexplore.ieee.org/xpl/tocresult.jsp?isnumber=6403920&punumber=76). Detail operations of the codec are explained in "High Efficiency Video Coding (HEVC) text specification draft 10 (JCTVC-L1003)".
      I am currently using all these documents. I am not sure whether my answer is useful for you. I wish you good luck.

      Delete
    2. Thanks for reply , I have gone through the drafts, it little hard to understand. I want a documentation for the functions and the class are used in the software. suppose the cTAppEncTop.encode() function used for compression it call various function from different files. I want to go through these functions detail. Is there documentation for that? Does any draft contain these flow together? Or how to go through the drafts for under standing that?

      Delete
    3. To understand how the codec work, you need to trace the reference software. Debugging mode in MS Visual Studio is very useful. I've already mentioned the steps for debugging in the above article. Once you complete tracing the entire process, you will know the specific portion that you need to focus for your research. For example, if your research is about the rate control, TEncRateCtrl.cpp becomes the file of interest. So, the first step is to trace the codec and the second step may be the recording of some parameters in a text file (e.g., parameter likes number of bits per frame). Then, the third step is modifying or implementing your research idea. That is what I am currently doing. So far, I cannot find any document that explain the detail implementation of the codec except the drafts.

      Delete
  2. Thanks for sharing such a valuable information. How to implement a Deblocking FIlter using HM Reference Software? I mean where and how to insert files related to Deblocking inside Reference Model?

    ReplyDelete
    Replies
    1. Please check TComLoopFilter.cpp under TLibCommon.

      Delete
    2. If I am replacing TComLoopFilter.cpp with my TComLoopFilter.cpp with header files ( TComLoopFilter.h) and building TLibCommon, its showing error. Is there any way to replace my TComLoopFilter.cpp with HM Source? I am using HM 3.0.

      Delete
    3. Girish may i know any specific reason for using HM 3.0 ? i think hm 14.x is new?

      Delete
  3. I am successful in building my own TComLoopFilter.cpp. How to Analyze and Compare the Performance between Default LoopFilter and Improved one?

    ReplyDelete
  4. This question may seem silly, but how to get the Summary of whole Encoding Process? Like, About the PSNR values of Y, U, V etc?

    ReplyDelete
    Replies
    1. Use hevc analyzer zond265 or codecvisa or elecard hevc analyze ...one interra vega which i didnt used

      Delete
  5. please write a note on how to use analyzer. And also give link of some free analyzer.

    ReplyDelete
  6. Thanks for sharing such a valuable information. How to implement a Motion Estimation using HM Reference Software?I am using HM-15.0-dev from https://hevc.hhi.fraunhofer.de/svn/svn_HEVCSoftware/branches/HM-15.0-dev/

    ReplyDelete
  7. Hello Htoo Maung Maung,
    This is a very informative blog. Could you please help me with :
    How and where to implement a radial basis function to select whether a coding unit (CU) has to split or not? I have to use classification (SVM) in order to classify whether a coding unit (CU) falls into homogeneous or non- homogeneous section in an image.
    I would be very thankful if you could provide me with this information at the earliest.

    ReplyDelete
  8. Hi,
    I am working on a verilog design of hevc dequantizer and inverse transform. Do you know if there is a way to use the HEVC Reference Software to verify these intermediate results? In other words, given a 4x4 array of quantized coefficents, use the Reference Software to get the dequantized outputs to compare with my simulation results. Same for the inverse transform. Thank You.

    ReplyDelete
  9. Hi is there a way to edit the code of TRDcost such as it only uses SAD in the code rather than choosing from sse sad and the default?? thank you

    ReplyDelete
  10. bonjour existe-t-il une documentation bien détaillé sur le codage vidéo en utilisant le Windows studio Visual

    ReplyDelete
  11. Hello,

    i have followed the exact same steps as above. but when i am trying to run a encoder , it runs fine.
    But in working folder there is only one folder occurred. named as
    str.bin size 0kb.

    Why it is not making exact str.bin file so i can test Decoder too..

    Waiting for your reply

    ReplyDelete
  12. 'TAppEncoder.exe': Loaded 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\ImportProjects\SHM-upgrade\bin\vc10\Win32\Debug\TAppEncoder.exe', Symbols loaded.
    'TAppEncoder.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Symbols loaded (source information stripped).
    'TAppEncoder.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Symbols loaded (source information stripped).
    'TAppEncoder.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Symbols loaded (source information stripped).
    The program '[13524] TAppEncoder.exe: Native' has exited with code 1 (0x1).

    ReplyDelete
  13. Greeting everyone,

    Thank you for sharing this tutorial with us, it is really useful, but i have some errors and I don't know how can I fix them:

    ../cfg/encoder_lowdelay_main.cfg error: Failed to open config file
    ../cfg/per-sequence/BasketballPass.cfg error: Failed to open config file

    I hope you help, thanks alot.

    Sincerely.

    ReplyDelete
  14. Here are several ways to convert HEVC to MP4 on Windows/Mac easily! Check them out if desired.

    ReplyDelete