codec: derive column groups from generation sequence
authorMischa POSLAWSKY <perl@shiar.org>
Tue, 2 Nov 2021 00:02:43 +0000 (01:02 +0100)
committerMischa POSLAWSKY <perl@shiar.org>
Tue, 9 Nov 2021 03:14:15 +0000 (04:14 +0100)
Not specific to hardcoded image formats.

codec-audio.inc.pl
codec-image.inc.pl
codec.plp

index 5bd336d76f1a254a8a2133eb844074b5a2cf0ba7..4d14f9b10e97d45116601985f8617b6935645459 100644 (file)
@@ -4,22 +4,27 @@ codec => {
        mp3 => {
                name => '<abbr title="MPEG-1 Audio Layer III">MP3</abbr>',
                available => 1991,
+               generation => 0,
        },
        vorbis => {
                name => 'Vorbis',
                available => 2000,
+               generation => 1,
        },
        opus => {
                name => 'Opus',
                available => 2012,
+               generation => 1,
        },
        aac => {
                name => '<abbr title="Advanced Audio Coding">AAC</abbr>',
                available => 1997,
+               generation => 1,
        },
        atrac => {
                name => '<abbr title="Adaptive Transform Acoustic Coding">ATRAC</abbr>',
                available => 1992,
+               generation => 0,
        },
 },
 feature => {
index 92e17d5911cf9890641b1e9a32883f3a7c72053f..f9a544c55ef9251b29f1981b9232887a3d6edc4f 100644 (file)
@@ -4,38 +4,47 @@ codec => {
        jpeg => {
                name => '<abbr title="Joint Photographic Experts Group">JPEG</abbr>',
                available => 1992,
+               generation => 0,
        },
        gif => {
                name => '<abbr title="Graphics Interchange Format">GIF</abbr>',
                available => 1987,
+               generation => 0,
        },
        png => {
                name => '<abbr title="Portable Network Graphics">PNG</abbr>',
                available => 1996,
+               generation => 1,
        },
        jp2k => {
                name => 'JPEG 2000',
                available => 2000,
+               generation => 1,
        },
        webp => {
                name => 'WebP',
                available => 2010,
+               generation => 1,
        },
        heic => {
                name => '<abbr title="High Efficiency Image Container (HEVC in HEIF)">HEIC</abbr>',
                available => 2015,
+               generation => 2,
        },
        avif => {
                name => '<abbr title="AV1 Image File Format">AVIF</abbr>',
                available => 2019,
+               generation => 2,
        },
        jxl => {
                name => 'JPEG XL',
                available => 2021,
+               generation => 2,
        },
        pnm => {
                name => '<abbr title="Portable aNyMap">PNM</abbr>',
                available => 1988,
+               generation => 0,
        },
 },
 feature => {
index b2c3407f930af9c9e18e8f8c767fe25633b55d32..4251df9239cf9b95e16d585a21df325ecad57f51 100644 (file)
--- a/codec.plp
+++ b/codec.plp
@@ -31,16 +31,22 @@ my %BOOLSCORE = (y => [5, '✔'], n => [1, '✘'], 0 => [0, 'n/a']);
 
 <div class="section">
 <table class="mapped">
-       <col><colgroup span=3><colgroup span=2><colgroup span=3>
-<thead><tr><th rowspan=2>feature
 <:
 my @codecs = sort {
        $info->{codec}->{$a}->{available} <=> $info->{codec}->{$b}->{available}
 } keys $info->{codec}->%*;
+my @codeccols = @{$info->{codec}}{@codecs};
 
-print '<th>', $_->{name} for @{$info->{codec}}{@codecs};
-print "\n<tr>";
-print '<td>', $_->{available} for @{$info->{codec}}{@codecs};
+{
+       print '<col>';
+       my @spans;
+       $spans[ $_->{generation} ]++ for @codeccols;
+       print "<colgroup span=$_>" for @spans;
+}
+say '<thead><tr><th rowspan=2>';
+say "\t", '<th>', $_->{name} for @codeccols;
+print '<tr>';
+print '<td>', $_->{available} for @codeccols;
 say '</thead>';
 
 while (defined (my $feat = shift @feat)) {