Skip to content

Commit

Permalink
Reinhard: actually use the exposure parameter
Browse files Browse the repository at this point in the history
The default exposure value is 1.5, which seems reasonable enough
after limited testing.
  • Loading branch information
ifb committed Aug 10, 2018
1 parent 508298c commit 5a037ae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ References:
Reinhard
===

tonemap.Reinhard(clip clip[, float exposure=2.0, contrast=0.5, float peak=1.0])
tonemap.Reinhard(clip clip[, float exposure=1.5, contrast=0.5, float peak=1.0])

* clip: Clip to process. Only planar 32-bit float is supported.

Expand Down
11 changes: 6 additions & 5 deletions tonemap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* VapourSynth plugin
* Copyright (C) 2017 Phillip Blucas
*
* Hable ported from vf_tonemap
* Hable and Reinhard ported from vf_tonemap
* Copyright (C) 2017 Vittorio Giovara
*
* Mobius ported from mpv and vf_tonemap
Expand Down Expand Up @@ -286,12 +286,13 @@ static const VSFrameRef *VS_CC reinhardGetFrame( int n, int activationReason, vo
int w = vsapi->getFrameWidth( src, plane );
intptr_t stride = vsapi->getStride( src, plane ) / sizeof(float);

const double offset = ( 1.0 - d->contrast ) / d->contrast;
const double peak = d->peak;
const float offset = ( 1.0 - d->contrast ) / d->contrast;
const float peak = d->peak;
const float gain = d->exposure;
for( int y = 0; y < h; y++ )
{
for( int x = 0; x < w; x++ )
dstp[x] = srcp[x] / ( srcp[x] + offset ) * ( peak + offset ) / peak;
dstp[x] = srcp[x] * gain / ( srcp[x] * gain + offset ) * ( peak + offset ) / peak;
dstp += stride;
srcp += stride;
}
Expand Down Expand Up @@ -320,7 +321,7 @@ static void VS_CC reinhardCreate( const VSMap *in, VSMap *out, void *userData, V

d.exposure = vsapi->propGetFloat( in, "exposure", 0, &err );
if( err )
d.exposure = 2.0;
d.exposure = 1.5;
d.contrast = vsapi->propGetFloat( in, "contrast", 0, &err );
if( err )
d.contrast = 0.5;
Expand Down

0 comments on commit 5a037ae

Please sign in to comment.