codec: rate browser support in my biased opinion
[sheet.git] / codec.inc.pl
index 6b6b4e09d0e582e8370dd303b87ddc8183efeb73..992c48869c83f7ae4d301daf090251835a345eef 100644 (file)
@@ -36,7 +36,7 @@ codec => {
 },
 feature => {
        default => {
-               children => [qw( quality_photo quality_art speed limits features royalties )],
+               children => [qw( quality_photo quality_art speed limits features royalties support )],
        },
        quality_photo => {
                name => 'compression (photo)',
@@ -233,62 +233,42 @@ feature => {
                parent => 'limits',
                name => 'maximum image dimensions',
                score => {
-                       jpeg => 3,
-                       gif  => 3,
-                       png  => 4,
-                       jp2k => 5,
-                       webp => 1,
-                       heic => 2,
-                       avif => 3,
-                       jxl  => 4,
-               },
-               data => {
-                       jpeg => '65k²',  # 2**16
-                       gif  => '65k²',  # 2**16
-                       png  => '2G²',   # 2**31
-                       jp2k => '4G²',   # 2**32
-                       webp => '16k²',  # 2**14
-                       heic => '8k×4k+', # 8193x4320
-                       avif => '65k²+',  # 2**16, 8193x4320 with profile
-                       jxl  => '1G²',   # 2**30
+                       jpeg => [3, '65k²'],   # 2**16
+                       gif  => [3, '65k²'],   # 2**16
+                       png  => [4,  '2G²'],   # 2**31
+                       jp2k => [5,  '4G²'],   # 2**32
+                       webp => [1, '16k²'],   # 2**14
+                       heic => [2,'8k×4k+', 'tilable, only 512×512 on Apple'], # 8193x4320
+                       avif => [3, '65k²+', 'tilable, 7680×4320 with Advanced profile'], # 2**16
+                       jxl  => [4,  '1G²'],   # 2**30
                },
        },
        max_bitdepth => {
                parent => 'limits',
                name => 'precision (max. bit depth)',
                score => {
-                       jpeg => 2,
-                       gif  => 2,
-                       png  => 4,
-                       jp2k => 5,
-                       webp => 2,
-                       heic => 3,
-                       avif => 3,
-                       jxl  => 5,
-               },
-               data => {
-                       jpeg => 8,
-                       gif  => 8,
-                       png  => 16,
-                       jp2k => 38,
-                       webp => 8,
-                       heic => 10,
-                       avif => 10,
-                       jxl  => 32,
+                       jpeg => [2,  8],
+                       gif  => [1,  8, '256 colour palette per frame'],
+                       png  => [4, 16],
+                       jp2k => [5, 38],
+                       webp => [2,  8],
+                       heic => [3, 10], #TODO 16?
+                       avif => [3, 12, '8, 10, 12 bit'],
+                       jxl  => [5, 32, '24-bit integer or 32-bit float'],
                },
        },
        color_444 => {
                parent => 'limits',
-               name => 'can do (lossy) 4:4:4',
+               name => 'chroma subsampling',
                score => {
-                       jpeg => 'y',
-                       gif  => 'y',
-                       png  => 'y',
+                       jpeg => ['y', undef, '4:2:0, 4:2:2, 4:4:4'],
+                       gif  => [4, '✘'],
+                       png  => [4, '✘'],
                        jp2k => 'y',
-                       webp => 'n',
-                       heic => 'n',
-                       avif => 'y',
-                       jxl  => 'y',
+                       webp => [1, '4:2:0'],
+                       heic => [1, '4:2:0'],
+                       avif => ['y', undef, '4:2:0, 4:2:2, 4:4:4'],
+                       jxl  => ['y', undef, 'for JPEG compatibility'],
                },
        },
        hdr => {
@@ -309,24 +289,14 @@ feature => {
                parent => 'limits',
                name => 'maximum number of channels',
                score => {
-                       jpeg => 2,
-                       gif  => 1,
-                       png  => 2,
-                       jp2k => 5,
-                       webp => 2,
-                       heic => 3,
-                       avif => 3,
-                       jxl  => 4,
-               },
-               data => {
-                       jpeg => 4, # cmyk
-                       gif  => 3,
-                       png  => 4, # cmyk
-                       jp2k => 2**15,
-                       webp => 4,
-                       heic => 5,
-                       avif => 5,
-                       jxl  => 4099,
+                       jpeg => [3, 4, 'RGB or CMYK'],
+                       gif  => [3, 3, 'RGB palette'],
+                       png  => [3, 4, 'RGBA'],
+                       jp2k => [5, 2**15],
+                       webp => [3, 4, 'RGBA'],
+                       heic => [3, 3, 'RGB, separate alpha and depth'],
+                       avif => [3, 3, 'RGB, separate alpha and depth'],
+                       jxl  => [4, 4099, 'native XYB'],
                },
        },
        features => {
@@ -346,20 +316,15 @@ feature => {
                parent => 'features',
                name => 'supports animation',
                score => {
-                       jpeg => 2,
+                       jpeg => [2, 'MJPEG'],
                        gif  => 'y',
-                       png  => 4,
-                       jp2k => 2,
+                       png  => [4, 'APNG', 'later backwards-compatible extension'],
+                       jp2k => [2, 'MJP2'],
                        webp => 'y',
                        heic => 'y',
                        avif => 'y',
                        jxl  => 'y',
                },
-               data => {
-                       jpeg => 'MJPEG',
-                       png  => 'APNG',
-                       jp2k => 'MJP2',
-               },
        },
        progressive => {
                parent => 'features',
@@ -380,7 +345,7 @@ feature => {
                name => 'alpha transparency',
                score => {
                        jpeg => 'n',
-                       gif  => 3,
+                       gif  => [3, '1 bit'],
                        png  => 'y',
                        jp2k => 'y',
                        webp => 'y',
@@ -388,9 +353,6 @@ feature => {
                        avif => 'y',
                        jxl  => 'y',
                },
-               data => {
-                       gif => '1 bit',
-               },
        },
        depthmap => {
                parent => 'features',
@@ -447,10 +409,6 @@ feature => {
                        avif => 3,
                        jxl  => 4,
                },
-               data => {
-                       gif  => 'n/a',
-                       png  => 'n/a',
-               },
        },
        compat_jpeg => {
                parent => 'features',
@@ -465,23 +423,32 @@ feature => {
                        avif => 'n',
                        jxl  => 'y',
                },
-               data => {
-                       jpeg => 'n/a',
-               },
        },
        royalties => {
                name => 'royalty-free',
                score => {
                        jpeg => 5,
-                       gif  => 5, # patents expired
+                       gif  => [5, undef, 'patented before 2003'],
                        png  => 5,
-                       jp2k => 3, # specs not freely available
-                       webp => 4, # submarine risk
-                       heic => 'n', # patents enforced
-                       avif => 4,
-                       jxl  => 4,
+                       jp2k => [3, undef, 'ISO specification not freely available'],
+                       webp => [4, undef, 'free format, low remaining risk of patent trolls'],
+                       heic => ['n', undef, 'heavily patented'],
+                       avif => [4, undef, 'free format, risk of patent trolls'],
+                       jxl  => [4, undef, 'free format, risk of patent trolls'],
                },
                children => [],
        },
+       support => {
+               score => {
+                       jpeg => 5,
+                       gif  => 5,
+                       png  => 5,
+                       jp2k => [2, undef, 'Apple only'],
+                       webp => [4, undef, 'modern browsers'],
+                       heic => [1, undef, 'stored by latest cameras, no browser support'],
+                       avif => [3, undef, 'all modern browsers except Safari and Edge'],
+                       jxl  => [2, undef, 'upcoming in most browsers'],
+               },
+       },
 },
 }