codec: categorise related features in groups
authorMischa POSLAWSKY <perl@shiar.org>
Fri, 29 Oct 2021 13:57:29 +0000 (15:57 +0200)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 9 Nov 2021 03:14:15 +0000 (04:14 +0100)
codec.inc.pl
codec.plp

index 2e157fcb88c468972fca9aefd99857e4803b4884..925c2fe54f5b0e6b286b263e095b67ca9a49ea4f 100644 (file)
@@ -31,6 +31,9 @@ codec => {
        },
 },
 feature => {
+       default => {
+               children => [qw( quality_photo quality_art speed limits features royalties )],
+       },
        quality_photo => {
                name => 'compression (photo)',
                score => {
@@ -42,8 +45,10 @@ feature => {
                        avif => 5,
                        jxl  => 5,
                },
+               children => [qw( quality_photo_1 quality_photo_2 quality_photo_3 quality_photo_ll )],
        },
        quality_photo_1 => {
+               parent => 'quality_photo',
                name => 'low fidelity',
                score => {
                        jpeg => 2,
@@ -56,6 +61,7 @@ feature => {
                },
        },
        quality_photo_2 => {
+               parent => 'quality_photo',
                name => 'medium fidelity',
                score => {
                        jpeg => 3,
@@ -68,6 +74,7 @@ feature => {
                },
        },
        quality_photo_3 => {
+               parent => 'quality_photo',
                name => 'high fidelity',
                score => {
                        jpeg => 3,
@@ -80,6 +87,7 @@ feature => {
                },
        },
        quality_photo_ll => {
+               parent => 'quality_photo',
                name => 'lossless',
                score => {
                        jpeg => 1,
@@ -102,6 +110,7 @@ feature => {
                        avif => 4.5,
                        jxl  => 5,
                },
+               children => [qw( quality_art_2 quality_art_ll quality_art_mixed )],
        },
        quality_art_2 => {
                name => 'lossy non-photographic',
@@ -149,8 +158,10 @@ feature => {
                        avif => 3,
                        jxl  => 5,
                },
+               children => [qw( speed_encode speed_decode speed_parallel )],
        },
        speed_encode => {
+               parent => 'speed',
                name => 'single-core encode',
                score => {
                        jpeg => 5,
@@ -163,6 +174,7 @@ feature => {
                },
        },
        speed_decode => {
+               parent => 'speed',
                name => 'single-core decode',
                score => {
                        jpeg => 5,
@@ -175,6 +187,7 @@ feature => {
                },
        },
        speed_parallel => {
+               parent => 'speed',
                name => 'pararellizable',
                score => {
                        jpeg => 2,
@@ -196,8 +209,10 @@ feature => {
                        avif => 4.5,
                        jxl  => 5,
                },
+               children => [qw( max_dimensions max_bitdepth color_444 hdr max_channels  )],
        },
        max_dimensions => {
+               parent => 'limits',
                name => 'maximum image dimensions',
                score => {
                        jpeg => 3,
@@ -219,6 +234,7 @@ feature => {
                },
        },
        max_bitdepth => {
+               parent => 'limits',
                name => 'precision (max. bit depth)',
                score => {
                        jpeg => 2,
@@ -240,6 +256,7 @@ feature => {
                },
        },
        color_444 => {
+               parent => 'limits',
                name => 'can do (lossy) 4:4:4',
                score => {
                        jpeg => 'y',
@@ -252,6 +269,7 @@ feature => {
                },
        },
        hdr => {
+               parent => 'limits',
                name => 'wide gamut/HDR',
                score => {
                        jpeg => 'n',
@@ -264,6 +282,7 @@ feature => {
                },
        },
        max_channels => {
+               parent => 'limits',
                name => 'maximum number of channels',
                score => {
                        jpeg => 2,
@@ -294,8 +313,10 @@ feature => {
                        avif => 4,
                        jxl  => 5,
                },
+               children => [qw( animation progressive alpha depthmap overlays authoring reencode compat_jpeg )],
        },
        animation => {
+               parent => 'features',
                name => 'supports animation',
                score => {
                        jpeg => 2,
@@ -313,6 +334,7 @@ feature => {
                },
        },
        progressive => {
+               parent => 'features',
                name => 'progressive decoding',
                score => {
                        jpeg => 4,
@@ -325,6 +347,7 @@ feature => {
                },
        },
        alpha => {
+               parent => 'features',
                name => 'alpha transparency',
                score => {
                        jpeg => 'n',
@@ -337,6 +360,7 @@ feature => {
                },
        },
        depthmap => {
+               parent => 'features',
                name => 'depth map',
                score => {
                        jpeg => 'n',
@@ -349,6 +373,7 @@ feature => {
                },
        },
        overlays => {
+               parent => 'features',
                name => 'overlays',
                score => {
                        jpeg => 'n',
@@ -361,6 +386,7 @@ feature => {
                },
        },
        authoring => {
+               parent => 'features',
                name => 'authoring workflow suitability',
                score => {
                        jpeg => 2,
@@ -373,6 +399,7 @@ feature => {
                },
        },
        reencode => {
+               parent => 'features',
                name => 'generation loss resilience',
                score => {
                        jpeg => 4,
@@ -388,6 +415,7 @@ feature => {
                },
        },
        compat_jpeg => {
+               parent => 'features',
                name => 'lossless JPEG recompression',
                score => {
                        jpeg => 0,
@@ -414,6 +442,7 @@ feature => {
                        avif => 4,
                        jxl  => 4,
                },
+               children => [],
        },
 },
 }
index 2cc454ad3f20bd3c830b4c14eceeec84ced0f1fc..27a6cb73960bd54f1d7f88f8177239d4aa41598f 100644 (file)
--- a/codec.plp
+++ b/codec.plp
@@ -1,5 +1,7 @@
 <(common.inc.plp)><:
 
+my @feat = split m{/+}, $Request || 'default';
+
 Html({
        title => 'Codecs',
        version => '1.0',
@@ -32,9 +34,11 @@ print "\n<tr>";
 print '<td>', $_->{available} for @{$info->{codec}}{@codecs};
 say '</thead>';
 
-print '<tbody>';
-for my $feat (sort keys %{$info->{feature}}) {
-       my $featinfo = $info->{feature}->{$feat};
+while (defined (my $feat = shift @feat)) {
+       my $featinfo = $info->{feature}->{$feat} or next;
+       unshift @feat, @{$_} for $featinfo->{children} // ();
+       $featinfo->{score} or $featinfo->{data} or next;
+       print '<tbody>' if $featinfo->{children};
        printf '<tr><th>%s', $featinfo->{name} // $feat;
        printf('<td class="l%d">%s',
                (map { $_ && $BOOLSCORE{$_} || $_ || 0 } $featinfo->{score}->{$_}),