1
1
mirror of https://github.com/wader/fq.git synced 2024-12-24 22:05:31 +03:00

Merge pull request #425 from wader/wasm-doc

wasm: Add some documentation
This commit is contained in:
Mattias Wadman 2022-09-13 09:59:17 +02:00 committed by GitHub
commit 88009ee9a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 284 additions and 228 deletions

View File

@ -128,7 +128,7 @@ vp8_frame,
vp9_cfm,
vp9_frame,
vpx_ccr,
wasm,
[wasm](doc/formats.md#wasm),
wav,
webp,
xing,

View File

@ -104,7 +104,7 @@
|`vp9_cfm` |VP9&nbsp;Codec&nbsp;Feature&nbsp;Metadata |<sub></sub>|
|`vp9_frame` |VP9&nbsp;frame |<sub></sub>|
|`vpx_ccr` |VPX&nbsp;Codec&nbsp;Configuration&nbsp;Record |<sub></sub>|
|`wasm` |WebAssembly&nbsp;Binary&nbsp;Format |<sub></sub>|
|[`wasm`](#wasm) |WebAssembly&nbsp;Binary&nbsp;Format |<sub></sub>|
|`wav` |WAV&nbsp;file |<sub>`id3v2` `id3v1` `id3v11`</sub>|
|`webp` |WebP&nbsp;image |<sub>`vp8_frame`</sub>|
|`xing` |Xing&nbsp;header |<sub></sub>|
@ -506,6 +506,26 @@ Current only supports plain RTMP (not RTMPT or encrypted variants etc) with AMF0
- https://rtmp.veriskope.com/docs/spec/
- https://rtmp.veriskope.com/pdf/video_file_format_spec_v10.pdf
## wasm
### Count opcode usage
```sh
$ fq '.sections[] | select(.id == "code_section") | [.. | .opcode? // empty] | count | map({key: .[0], value: .[1]}) | from_entries' file.wasm
```
### List exports and imports
```sh
$ fq '.sections | {import: map(select(.id == "import_section").content.im.x[].nm.b), export: map(select(.id == "export_section").content.ex.x[].nm.b)}' file.wasm
```
### Authors
- Takashi Oguma
[@bitbears-dev](https://github.com/bitbears-dev)
[@0xb17bea125](https://twitter.com/0xb17bea125)
### References
- https://webassembly.github.io/spec/core/
## xml
### Options

File diff suppressed because it is too large Load Diff

Before

Width:  |  Height:  |  Size: 135 KiB

After

Width:  |  Height:  |  Size: 133 KiB

View File

@ -1209,6 +1209,20 @@ out $ fq -d wasm . file
out # Decode value as wasm
out ... | wasm
out
out # Count opcode usage
out
out $ fq '.sections[] | select(.id == "code_section") | [.. | .opcode? // empty] | count | map({key: .[0], value: .[1]}) | from_entries' file.wasm
out
out # List exports and imports
out
out $ fq '.sections | {import: map(select(.id == "import_section").content.im.x[].nm.b), export: map(select(.id == "export_section").content.ex.x[].nm.b)}' file.wasm
out
out # Authors
out - Takashi Oguma @bitbears-dev (https://github.com/bitbears-dev) @0xb17bea125 (https://twitter.com/0xb17bea125)
out
out # References
out - https://webassembly.github.io/spec/core/
out
"help(wav)"
out wav: WAV file decoder
out

View File

@ -3,6 +3,7 @@ package wasm
// https://webassembly.github.io/spec/core/
import (
"embed"
"math"
"sync"
@ -12,6 +13,9 @@ import (
"github.com/wader/fq/pkg/scalar"
)
//go:embed wasm.md
var wasmFS embed.FS
func init() {
interp.RegisterFormat(decode.Format{
Name: format.WASM,
@ -19,6 +23,7 @@ func init() {
DecodeFn: decodeWASM,
Groups: []string{format.PROBE},
})
interp.RegisterFS(wasmFS)
}
const (

17
format/wasm/wasm.md Normal file
View File

@ -0,0 +1,17 @@
### Count opcode usage
```sh
$ fq '.sections[] | select(.id == "code_section") | [.. | .opcode? // empty] | count | map({key: .[0], value: .[1]}) | from_entries' file.wasm
```
### List exports and imports
```sh
$ fq '.sections | {import: map(select(.id == "import_section").content.im.x[].nm.b), export: map(select(.id == "export_section").content.ex.x[].nm.b)}' file.wasm
```
### Authors
- Takashi Oguma
[@bitbears-dev](https://github.com/bitbears-dev)
[@0xb17bea125](https://twitter.com/0xb17bea125)
### References
- https://webassembly.github.io/spec/core/