diff --git a/doc/formats.md b/doc/formats.md
index 3c5804c1..1226a338 100644
--- a/doc/formats.md
+++ b/doc/formats.md
@@ -1,4 +1,109 @@
-## Format specific functions
+## Supported formats
+
+[./formats_table.sh]: sh-start
+
+|Name |Description |Dependencies|
+|- |- |-|
+|`aac_frame` |Advanced Audio Coding frame ||
+|`adts` |Audio Data Transport Stream |`adts_frame`|
+|`adts_frame` |Audio Data Transport Stream frame |`aac_frame`|
+|`apev2` |APEv2 metadata tag |`image`|
+|`ar` |Unix archive |`probe`|
+|`av1_ccr` |AV1 Codec Configuration Record ||
+|`av1_frame` |AV1 frame |`av1_obu`|
+|`av1_obu` |AV1 Open Bitstream Unit ||
+|`avc_annexb` |H.264/AVC Annex B |`avc_nalu`|
+|`avc_au` |H.264/AVC Access Unit |`avc_nalu`|
+|`avc_dcr` |H.264/AVC Decoder Configuration Record |`avc_nalu`|
+|`avc_nalu` |H.264/AVC Network Access Layer Unit |`avc_sps` `avc_pps` `avc_sei`|
+|`avc_pps` |H.264/AVC Picture Parameter Set ||
+|`avc_sei` |H.264/AVC Supplemental Enhancement Information ||
+|`avc_sps` |H.264/AVC Sequence Parameter Set ||
+|[`bencode`](#bencode) |BitTorrent bencoding ||
+|`bsd_loopback_frame` |BSD loopback frame |`ipv4_packet`|
+|[`bson`](#bson) |Binary JSON ||
+|`bzip2` |bzip2 compression |`probe`|
+|[`cbor`](#cbor) |Concise Binary Object Representation ||
+|`dns` |DNS packet ||
+|`dns_tcp` |DNS packet (TCP) ||
+|`elf` |Executable and Linkable Format ||
+|`ether8023_frame` |Ethernet 802.3 frame |`ipv4_packet`|
+|`exif` |Exchangeable Image File Format ||
+|`flac` |Free Lossless Audio Codec file |`flac_metadatablocks` `flac_frame`|
+|`flac_frame` |FLAC frame ||
+|`flac_metadatablock` |FLAC metadatablock |`flac_streaminfo` `flac_picture` `vorbis_comment`|
+|`flac_metadatablocks` |FLAC metadatablocks |`flac_metadatablock`|
+|`flac_picture` |FLAC metadatablock picture |`image`|
+|`flac_streaminfo` |FLAC streaminfo ||
+|`gif` |Graphics Interchange Format ||
+|`gzip` |gzip compression |`probe`|
+|`hevc_annexb` |H.265/HEVC Annex B |`hevc_nalu`|
+|`hevc_au` |H.265/HEVC Access Unit |`hevc_nalu`|
+|`hevc_dcr` |H.265/HEVC Decoder Configuration Record |`hevc_nalu`|
+|`hevc_nalu` |H.265/HEVC Network Access Layer Unit ||
+|`icc_profile` |International Color Consortium profile ||
+|`icmp` |Internet Control Message Protocol ||
+|`id3v1` |ID3v1 metadata ||
+|`id3v11` |ID3v1.1 metadata ||
+|`id3v2` |ID3v2 metadata |`image`|
+|`ipv4_packet` |Internet protocol v4 packet |`udp_datagram` `tcp_segment` `icmp`|
+|`jpeg` |Joint Photographic Experts Group file |`exif` `icc_profile`|
+|`json` |JSON ||
+|[`matroska`](#matroska) |Matroska file |`aac_frame` `av1_ccr` `av1_frame` `avc_au` `avc_dcr` `flac_frame` `flac_metadatablocks` `hevc_au` `hevc_dcr` `image` `mp3_frame` `mpeg_asc` `mpeg_pes_packet` `mpeg_spu` `opus_packet` `vorbis_packet` `vp8_frame` `vp9_cfm` `vp9_frame`|
+|`mp3` |MP3 file |`id3v2` `id3v1` `id3v11` `apev2` `mp3_frame`|
+|`mp3_frame` |MPEG audio layer 3 frame |`xing`|
+|[`mp4`](#mp4) |MPEG-4 file and similar |`aac_frame` `av1_ccr` `av1_frame` `flac_frame` `flac_metadatablocks` `id3v2` `image` `jpeg` `mp3_frame` `avc_au` `avc_dcr` `mpeg_es` `hevc_au` `hevc_dcr` `mpeg_pes_packet` `opus_packet` `protobuf_widevine` `pssh_playready` `vorbis_packet` `vp9_frame` `vpx_ccr`|
+|`mpeg_asc` |MPEG-4 Audio Specific Config ||
+|`mpeg_es` |MPEG Elementary Stream |`mpeg_asc` `vorbis_packet`|
+|`mpeg_pes` |MPEG Packetized elementary stream |`mpeg_pes_packet` `mpeg_spu`|
+|`mpeg_pes_packet` |MPEG Packetized elementary stream packet ||
+|`mpeg_spu` |Sub Picture Unit (DVD subtitle) ||
+|`mpeg_ts` |MPEG Transport Stream ||
+|[`msgpack`](#msgpack) |MessagePack ||
+|`ogg` |OGG file |`ogg_page` `vorbis_packet` `opus_packet` `flac_metadatablock` `flac_frame`|
+|`ogg_page` |OGG page ||
+|`opus_packet` |Opus packet |`vorbis_comment`|
+|`pcap` |PCAP packet capture |`link_frame` `tcp_stream` `ipv4_packet`|
+|`pcapng` |PCAPNG packet capture |`link_frame` `tcp_stream` `ipv4_packet`|
+|`png` |Portable Network Graphics file |`icc_profile` `exif`|
+|[`protobuf`](#protobuf) |Protobuf ||
+|`protobuf_widevine` |Widevine protobuf |`protobuf`|
+|`pssh_playready` |PlayReady PSSH ||
+|`raw` |Raw bits ||
+|`sll2_packet` |Linux cooked capture encapsulation v2 |`ether8023_frame`|
+|`sll_packet` |Linux cooked capture encapsulation |`ether8023_frame`|
+|`tar` |Tar archive |`probe`|
+|`tcp_segment` |Transmission control protocol segment ||
+|`tiff` |Tag Image File Format |`icc_profile`|
+|`udp_datagram` |User datagram protocol |`udp_payload`|
+|`vorbis_comment` |Vorbis comment |`flac_picture`|
+|`vorbis_packet` |Vorbis packet |`vorbis_comment`|
+|`vp8_frame` |VP8 frame ||
+|`vp9_cfm` |VP9 Codec Feature Metadata ||
+|`vp9_frame` |VP9 frame ||
+|`vpx_ccr` |VPX Codec Configuration Record ||
+|`wav` |WAV file |`id3v2` `id3v1` `id3v11`|
+|`webp` |WebP image |`vp8_frame`|
+|`xing` |Xing header ||
+|`zip` |ZIP archive |`probe`|
+|`image` |Group |`gif` `jpeg` `mp4` `png` `tiff` `webp`|
+|`link_frame` |Group |`bsd_loopback_frame` `ether8023_frame` `sll2_packet` `sll_packet`|
+|`probe` |Group |`adts` `ar` `bzip2` `elf` `flac` `gif` `gzip` `jpeg` `json` `matroska` `mp3` `mp4` `mpeg_ts` `ogg` `pcap` `pcapng` `png` `tar` `tiff` `wav` `webp` `zip`|
+|`tcp_stream` |Group |`dns`|
+|`udp_payload` |Group |`dns`|
+
+[#]: sh-end
+
+## Format options
+
+Currently the only option is `force` and is used to ignore some format assertion errors. It can be used as a decode option or as a CLI `-o` option:
+
+```
+fq -d mp4 -o force=true file.mp4
+fq -d raw 'mp4({force: true})' file.mp4
+```
+
+## Format functions
[./formats_collect.sh]: sh-start
@@ -83,100 +188,7 @@ fq -d protobuf '.fields[6].wire_value | protobuf | d'
[#]: sh-end
-## Supported formats
-[./formats_table.jq]: sh-start
-
-|Name |Description |Dependencies|
-|- |- |-|
-|`aac_frame` |Advanced Audio Coding frame ||
-|`adts` |Audio Data Transport Stream |`adts_frame`|
-|`adts_frame` |Audio Data Transport Stream frame |`aac_frame`|
-|`apev2` |APEv2 metadata tag |`image`|
-|`ar` |Unix archive |`probe`|
-|`av1_ccr` |AV1 Codec Configuration Record ||
-|`av1_frame` |AV1 frame |`av1_obu`|
-|`av1_obu` |AV1 Open Bitstream Unit ||
-|`avc_annexb` |H.264/AVC Annex B |`avc_nalu`|
-|`avc_au` |H.264/AVC Access Unit |`avc_nalu`|
-|`avc_dcr` |H.264/AVC Decoder Configuration Record |`avc_nalu`|
-|`avc_nalu` |H.264/AVC Network Access Layer Unit |`avc_sps` `avc_pps` `avc_sei`|
-|`avc_pps` |H.264/AVC Picture Parameter Set ||
-|`avc_sei` |H.264/AVC Supplemental Enhancement Information ||
-|`avc_sps` |H.264/AVC Sequence Parameter Set ||
-|`bencode` |BitTorrent bencoding ||
-|`bsd_loopback_frame` |BSD loopback frame |`ipv4_packet`|
-|`bson` |Binary JSON ||
-|`bzip2` |bzip2 compression |`probe`|
-|`cbor` |Concise Binary Object Representation ||
-|`dns` |DNS packet ||
-|`dns_tcp` |DNS packet (TCP) ||
-|`elf` |Executable and Linkable Format ||
-|`ether8023_frame` |Ethernet 802.3 frame |`ipv4_packet`|
-|`exif` |Exchangeable Image File Format ||
-|`flac` |Free Lossless Audio Codec file |`flac_metadatablocks` `flac_frame`|
-|`flac_frame` |FLAC frame ||
-|`flac_metadatablock` |FLAC metadatablock |`flac_streaminfo` `flac_picture` `vorbis_comment`|
-|`flac_metadatablocks` |FLAC metadatablocks |`flac_metadatablock`|
-|`flac_picture` |FLAC metadatablock picture |`image`|
-|`flac_streaminfo` |FLAC streaminfo ||
-|`gif` |Graphics Interchange Format ||
-|`gzip` |gzip compression |`probe`|
-|`hevc_annexb` |H.265/HEVC Annex B |`hevc_nalu`|
-|`hevc_au` |H.265/HEVC Access Unit |`hevc_nalu`|
-|`hevc_dcr` |H.265/HEVC Decoder Configuration Record |`hevc_nalu`|
-|`hevc_nalu` |H.265/HEVC Network Access Layer Unit ||
-|`icc_profile` |International Color Consortium profile ||
-|`icmp` |Internet Control Message Protocol ||
-|`id3v1` |ID3v1 metadata ||
-|`id3v11` |ID3v1.1 metadata ||
-|`id3v2` |ID3v2 metadata |`image`|
-|`ipv4_packet` |Internet protocol v4 packet |`udp_datagram` `tcp_segment` `icmp`|
-|`jpeg` |Joint Photographic Experts Group file |`exif` `icc_profile`|
-|`json` |JSON ||
-|`matroska` |Matroska file |`aac_frame` `av1_ccr` `av1_frame` `avc_au` `avc_dcr` `flac_frame` `flac_metadatablocks` `hevc_au` `hevc_dcr` `image` `mp3_frame` `mpeg_asc` `mpeg_pes_packet` `mpeg_spu` `opus_packet` `vorbis_packet` `vp8_frame` `vp9_cfm` `vp9_frame`|
-|`mp3` |MP3 file |`id3v2` `id3v1` `id3v11` `apev2` `mp3_frame`|
-|`mp3_frame` |MPEG audio layer 3 frame |`xing`|
-|`mp4` |MPEG-4 file and similar |`aac_frame` `av1_ccr` `av1_frame` `flac_frame` `flac_metadatablocks` `id3v2` `image` `jpeg` `mp3_frame` `avc_au` `avc_dcr` `mpeg_es` `hevc_au` `hevc_dcr` `mpeg_pes_packet` `opus_packet` `protobuf_widevine` `pssh_playready` `vorbis_packet` `vp9_frame` `vpx_ccr`|
-|`mpeg_asc` |MPEG-4 Audio Specific Config ||
-|`mpeg_es` |MPEG Elementary Stream |`mpeg_asc` `vorbis_packet`|
-|`mpeg_pes` |MPEG Packetized elementary stream |`mpeg_pes_packet` `mpeg_spu`|
-|`mpeg_pes_packet` |MPEG Packetized elementary stream packet ||
-|`mpeg_spu` |Sub Picture Unit (DVD subtitle) ||
-|`mpeg_ts` |MPEG Transport Stream ||
-|`msgpack` |MessagePack ||
-|`ogg` |OGG file |`ogg_page` `vorbis_packet` `opus_packet` `flac_metadatablock` `flac_frame`|
-|`ogg_page` |OGG page ||
-|`opus_packet` |Opus packet |`vorbis_comment`|
-|`pcap` |PCAP packet capture |`link_frame` `tcp_stream` `ipv4_packet`|
-|`pcapng` |PCAPNG packet capture |`link_frame` `tcp_stream` `ipv4_packet`|
-|`png` |Portable Network Graphics file |`icc_profile` `exif`|
-|`protobuf` |Protobuf ||
-|`protobuf_widevine` |Widevine protobuf |`protobuf`|
-|`pssh_playready` |PlayReady PSSH ||
-|`raw` |Raw bits ||
-|`sll2_packet` |Linux cooked capture encapsulation v2 |`ether8023_frame`|
-|`sll_packet` |Linux cooked capture encapsulation |`ether8023_frame`|
-|`tar` |Tar archive |`probe`|
-|`tcp_segment` |Transmission control protocol segment ||
-|`tiff` |Tag Image File Format |`icc_profile`|
-|`udp_datagram` |User datagram protocol |`udp_payload`|
-|`vorbis_comment` |Vorbis comment |`flac_picture`|
-|`vorbis_packet` |Vorbis packet |`vorbis_comment`|
-|`vp8_frame` |VP8 frame ||
-|`vp9_cfm` |VP9 Codec Feature Metadata ||
-|`vp9_frame` |VP9 frame ||
-|`vpx_ccr` |VPX Codec Configuration Record ||
-|`wav` |WAV file |`id3v2` `id3v1` `id3v11`|
-|`webp` |WebP image |`vp8_frame`|
-|`xing` |Xing header ||
-|`zip` |ZIP archive |`probe`|
-|`image` |Group |`gif` `jpeg` `mp4` `png` `tiff` `webp`|
-|`link_frame` |Group |`bsd_loopback_frame` `ether8023_frame` `sll2_packet` `sll_packet`|
-|`probe` |Group |`adts` `ar` `bzip2` `elf` `flac` `gif` `gzip` `jpeg` `json` `matroska` `mp3` `mp4` `mpeg_ts` `ogg` `pcap` `pcapng` `png` `tar` `tiff` `wav` `webp` `zip`|
-|`tcp_stream` |Group |`dns`|
-|`udp_payload` |Group |`dns`|
-
-[#]: sh-end
+## Dependency graph
![alt text](formats.svg "Format diagram")
diff --git a/doc/formats_table.jq b/doc/formats_table.jq
index fe416755..33806574 100755
--- a/doc/formats_table.jq
+++ b/doc/formats_table.jq
@@ -3,47 +3,57 @@
def code: "`\(.)`";
def nbsp: gsub(" "; " ");
-[ {
- name: "Name",
- desc: "Description",
- uses: "Dependencies"
- },
- {
- name: "-",
- desc: "-",
- uses: "-"
- },
- ( formats
- | to_entries[]
- | {
- name: ((.key | code) + " "),
- desc: ((.value.description | nbsp) + " "),
- uses: "\((((.value.dependencies | flatten | map(code)) | join(" "))? // ""))"
- }
- ),
- ( [ formats
- | to_entries[]
- | . as $e
- | select(.value.groups)
- | .value.groups[] | {key: ., value: $e.key}
+def format_table:
+ ( ($doc_formats | split(" ")) as $doc_formats
+ | [ {
+ name: "Name",
+ desc: "Description",
+ uses: "Dependencies"
+ },
+ {
+ name: "-",
+ desc: "-",
+ uses: "-"
+ },
+ ( formats
+ | to_entries[]
+ | {
+ name:
+ ( ( .key as $format
+ | if ($doc_formats | indices($format)) != [] then "[\($format | code)](#\($format))"
+ else $format | code
+ end
+ )
+ + " "
+ ),
+ desc: ((.value.description | nbsp) + " "),
+ uses: "\((((.value.dependencies | flatten | map(code)) | join(" "))? // ""))"
+ }
+ ),
+ ( [ formats
+ | to_entries[]
+ | . as $e
+ | select(.value.groups)
+ | .value.groups[] | {key: ., value: $e.key}
+ ]
+ | reduce .[] as $e ({}; .[$e.key] += [$e.value])
+ | to_entries[]
+ | {
+ name: ((.key | code) + " "),
+ desc: "Group",
+ uses: "\(((.value | map(code)) | join(" ")))"
+ }
+ )
]
- | reduce .[] as $e ({}; .[$e.key] += [$e.value])
- | to_entries[]
- | {
- name: ((.key | code) + " "),
- desc: "Group",
- uses: "\(((.value | map(code)) | join(" ")))"
- }
- )
-]
-| table(
- [.name, .desc, .uses];
- [ ""
- , (.[0] | . as $rc | $rc.string | rpad(" "; $rc.maxwidth))
- , (.[1] | . as $rc | $rc.string | rpad(" "; $rc.maxwidth))
- , .[2].string
- , ""
- ] | join("|")
- )
-
+ | table(
+ [.name, .desc, .uses];
+ [ ""
+ , (.[0] | . as $rc | $rc.string | rpad(" "; $rc.maxwidth))
+ , (.[1] | . as $rc | $rc.string | rpad(" "; $rc.maxwidth))
+ , .[2].string
+ , ""
+ ] | join("|")
+ )
+ );
+format_table
diff --git a/doc/formats_table.sh b/doc/formats_table.sh
new file mode 100755
index 00000000..5a36d8be
--- /dev/null
+++ b/doc/formats_table.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+# what formats has a doc.md file
+DOC_FORMATS=$(echo $(ls -1 $REPODIR/format/*/doc.md | sed "s#$REPODIR/format/\(.*\)\/doc.md#\1#"))
+./formats_table.jq --arg doc_formats "$DOC_FORMATS"