HDR to SDR Tone mapping,a practical analysis.

What is HDR?


High-dynamic-range imaging (HDRI) is a high dynamic range (HDR) technique used in imaging and photography to reproduce a greater dynamic range of luminosity than is possible with standard digital imaging or photographic techniques. The aim is to present a similar range of luminance to that experienced through the human visual system. The human eye, through adaptation of the iris and other methods, adjusts constantly to adapt to a broad range of luminance present in the environment. The brain continuously interprets this information so that a viewer can see in a wide range of light conditions.

or just watch this…


The current option’s to reproduce HDR colors in non-HDR env. are:

  • MadVR
  • Hable’s Tone Mapping (passed through pipe to mpv)
  • reinhard Tonemapping Technique (MPV’s Default)
  • Top sekret proprietary methods.(not a option :/)


I will show you example’s how above 3 methods try to produce HDR colors to SDR.(Aka. tonemapping)





madVR is a high quality DirectShow video renderer.

Designed as a no-compromise approach, madVR tries to achieve the best possible video playback quality.


View post on imgur.com

Hable’s Tone Mapping


Hable’s tone mapping simply put is a algorithm.while many people conside this as very premature.the results are good.


Environment : VS pipe to MPV.

View post on imgur.com


Reinhard Tonemapping


Environment :MPV.

View post on imgur.com




Generate x264 zones from ConditionalFilter Input

Recently i have been playing with x264 and with video encoding.Sometimes it is required to use zones to preserve bitrate/quality whenever it’s needed.Usually when Denoisers or Debanding plugins are used.Most common among debanding plugin is f3kdb(Avisynth) and commanly it is used on specific scenes/ranges where there is visable banding.These ranges can either be specified through Trim() function or using conditionalFilter Trigger.

An example of a generic Conditionalfilter Input:

type int
 default 0

R 24 336 1
R 25 676 2
R 555 6776 1
R 68854 68859 2
#R 4465<--

Start Range


End Range


Condition Trigger

And for these ranges,you have to specify zones to x264 to preserve debanding effect.I wrote a small <1 KB script to automate this task:

Github: https://github.com/jagadeesh-kotra/x264zones


Installing VapourSynth in Ubuntu/Mint


Tested with Ubuntu 17.04+ and Mint 18+

VapourSynth is an application for video manipulation. Or a plugin. Or a library. It’s hard to tell because it has a core library written in C++ and a Python module to allow video scripts to be created. It came to be when I started thinking about alternative designs for Avisynth and most of it was written over a 3 month period. The software has been heavily inspired by Avisynth and aims to be a 21st century rewrite, taking advantage of the advancements computers have made since the late 90s. The main features compared to Avisynth are:

  • Multithreaded – Frame level multithreading
  • Generalized Colorspaces – New Colorspaces can be specified at runtime
  • Per Frame Properties – Additional metadata can be attached to frames
  • Python Based – The scripting part is implemented as a Python module so you don’t have have to learn a special language
  • Support for video with format changes – Some video just can’t stick to one format or frame size VapourSynth can handle any kind of change


Installing VapourSynth in Ubuntu/Mint



Add repository for ubuntu :

sudo add-apt-repository ppa:djcj/vapoursynth
sudo apt-get update

Install dependencies:

sudo apt-get install build-essential yasm libass-dev python3-pip python3-dev cython3 autoconf libtool libmagick++-dev qt5-default libfftw3-dev

sudo apt-get install ffmpeg

sudo apt-get install fftw3

sudo apt-get install mpv

sudo apt-get installnnedi3-weights

sudo apt-get install vapoursynth-extra-plugins

sudo apt-get install vapoursynth-waifu2x-models


Now, Install Vspipe,VSEdit,x264:


sudo apt-get install vapoursynth

sudo apt-get install vapoursynth-editor

sudo apt-get install x264

Install l-smash:

sudo apt-get install git

git clone https://github.com/l-smash/l-smash.git

cd l-smash

./configure --enable-shared

make lib

sudo make install-lib


Install zimg:

git clone https://github.com/sekrit-twc/zimg.git

cd zimg




sudo make install


Install Vapoursynth:


git clone https://github.com/vapoursynth/vapoursynth.git

cd vapoursynth




sudo make install


Linking Vapoursynth to Lib:


mkdir $HOME/.config/vapoursynth

echo 'UserPluginDir=/usr/local/lib' | sudo tee --append $HOME/.config/vapoursynth/vapoursynth.conf

echo 'include /usr/local/lib' | sudo tee --append /etc/ld.so.conf

sudo ldconfig


And finally,Set up python path:




You can run Vapoursynth editor by running the following command:



Sample script: