diff options
author | 2022-12-17 05:38:56 +0100 | |
---|---|---|
committer | 2022-12-17 04:38:56 +0000 | |
commit | 2bbc64be4317166d3abb7aa177d4913f166a53e8 (patch) | |
tree | 88c3d613eb986b18894f311afa4291987a0e26c4 /vendor/github.com/abema/go-mp4/util/string.go | |
parent | [chore] fix some little config whoopsies (#1272) (diff) | |
download | gotosocial-2bbc64be4317166d3abb7aa177d4913f166a53e8.tar.xz |
[feature] Enable basic video support (mp4 only) (#1274)
* [feature] basic video support
* fix missing semicolon
* replace text shadow with stacked icons
Co-authored-by: f0x <f0x@cthu.lu>
Diffstat (limited to 'vendor/github.com/abema/go-mp4/util/string.go')
-rw-r--r-- | vendor/github.com/abema/go-mp4/util/string.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/vendor/github.com/abema/go-mp4/util/string.go b/vendor/github.com/abema/go-mp4/util/string.go new file mode 100644 index 000000000..b38251bb3 --- /dev/null +++ b/vendor/github.com/abema/go-mp4/util/string.go @@ -0,0 +1,42 @@ +package util + +import ( + "strconv" + "strings" + "unicode" +) + +func FormatSignedFixedFloat1616(val int32) string { + if val&0xffff == 0 { + return strconv.Itoa(int(val >> 16)) + } else { + return strconv.FormatFloat(float64(val)/(1<<16), 'f', 5, 64) + } +} + +func FormatUnsignedFixedFloat1616(val uint32) string { + if val&0xffff == 0 { + return strconv.Itoa(int(val >> 16)) + } else { + return strconv.FormatFloat(float64(val)/(1<<16), 'f', 5, 64) + } +} + +func FormatSignedFixedFloat88(val int16) string { + if val&0xff == 0 { + return strconv.Itoa(int(val >> 8)) + } else { + return strconv.FormatFloat(float64(val)/(1<<8), 'f', 3, 32) + } +} + +func EscapeUnprintable(r rune) rune { + if unicode.IsGraphic(r) { + return r + } + return rune('.') +} + +func EscapeUnprintables(src string) string { + return strings.Map(EscapeUnprintable, src) +} |