1 |
{ RCSid $Id: pq.cal,v 1.1 2021/03/17 23:49:20 greg Exp $ } |
2 |
{ |
3 |
Convert absolute luminance in cd/m^2 to/from Dolby's |
4 |
Perceptual Quantization |
5 |
} |
6 |
peak`PQ : 10000; |
7 |
n`PQ : 2610.0/(4096.0*4.0); |
8 |
m`PQ : 2523.0/4096.0*128.0; |
9 |
c1`PQ : 3424.0/4096.0; |
10 |
c2`PQ : 2413.0/4096.0*32.0; |
11 |
c3`PQ : 2392.0/4096.0*32.0; |
12 |
|
13 |
bound(a,x,b) : if(a-x, a, if(x-b, b, x)); |
14 |
|
15 |
toPQ1(Yn) : ((c1`PQ + c2`PQ*Yn)/(1 + c3`PQ*Yn))^m`PQ; |
16 |
toPQ(Y) : toPQ1(bound(0,Y/peak`PQ,1)^n`PQ); |
17 |
|
18 |
fromPQ1(PQm) : (max(PQm-c1`PQ,0)/(c2`PQ - c3`PQ*PQm))^(1/n`PQ) * peak`PQ; |
19 |
fromPQ(q) : fromPQ1(bound(0,q,1)^(1/m`PQ)); |