| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
# YUV color space specific code as in BT.601 |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Graphics::Toolkit::Color::Space::Instance::YUV; |
|
5
|
15
|
|
|
15
|
|
222007
|
use v5.12; |
|
|
15
|
|
|
|
|
236
|
|
|
6
|
15
|
|
|
15
|
|
85
|
use warnings; |
|
|
15
|
|
|
|
|
59
|
|
|
|
15
|
|
|
|
|
1040
|
|
|
7
|
15
|
|
|
15
|
|
609
|
use Graphics::Toolkit::Color::Space qw/mult_matrix_vector_3/; |
|
|
15
|
|
|
|
|
41
|
|
|
|
15
|
|
|
|
|
5388
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub from_rgb { |
|
10
|
5
|
|
|
5
|
0
|
18
|
my ($rgb) = shift; |
|
11
|
5
|
|
|
|
|
45
|
my (@yuv) = mult_matrix_vector_3([[ 0.299 , 0.587, 0.114 ], |
|
12
|
|
|
|
|
|
|
[-0.168736, -0.331264, 0.5 ], |
|
13
|
|
|
|
|
|
|
[ 0.5 , -0.418688, -0.081312 ]], @$rgb); |
|
14
|
5
|
|
|
|
|
21
|
$yuv[1] += 0.5; |
|
15
|
5
|
|
|
|
|
12
|
$yuv[2] += 0.5; |
|
16
|
5
|
|
|
|
|
26
|
return \@yuv; |
|
17
|
|
|
|
|
|
|
} |
|
18
|
|
|
|
|
|
|
sub to_rgb { |
|
19
|
9
|
|
|
9
|
0
|
28
|
my ($yuv) = shift; |
|
20
|
9
|
|
|
|
|
27
|
$yuv->[1] -= 0.5; |
|
21
|
9
|
|
|
|
|
20
|
$yuv->[2] -= 0.5; |
|
22
|
9
|
|
|
|
|
85
|
my (@rgb) = mult_matrix_vector_3([[ 1, 0 , 1.402 ], |
|
23
|
|
|
|
|
|
|
[ 1, -0.344136, -0.714136], |
|
24
|
|
|
|
|
|
|
[ 1, 1.772 , 0 ]], @$yuv); |
|
25
|
9
|
|
|
|
|
55
|
return \@rgb; |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Graphics::Toolkit::Color::Space->new( |
|
29
|
|
|
|
|
|
|
alias => 'YPbPr', |
|
30
|
|
|
|
|
|
|
axis => [qw/luma Pb Pr/], # luma, cyan-orange balance, magenta-green balance |
|
31
|
|
|
|
|
|
|
short => [qw/Y U V/], |
|
32
|
|
|
|
|
|
|
range => [1, [-.5, .5], [-.5, .5],], |
|
33
|
|
|
|
|
|
|
convert => {RGB => [\&to_rgb, \&from_rgb]}, |
|
34
|
|
|
|
|
|
|
); |
|
35
|
|
|
|
|
|
|
|