summaryrefslogtreecommitdiff
path: root/internal/media/probe.go
diff options
context:
space:
mode:
authorLibravatar kim <grufwub@gmail.com>2025-11-05 17:53:47 +0100
committerLibravatar tobi <tobi.smethurst@protonmail.com>2025-11-17 14:12:29 +0100
commitddf887d95c1cef95746f9881dc4180d983e7a351 (patch)
tree085dd1942c87ca1ff7da32dcdc5b3a9c0b6e5f28 /internal/media/probe.go
parent[bugfix] more RSS validation issues (#4517) (diff)
downloadgotosocial-ddf887d95c1cef95746f9881dc4180d983e7a351.tar.xz
[performance] when transforming media, perform read operations of large files using mmap (#4541)
the performance gains aren't as substantial as i was hoping, but benchmarks did show it averaged out faster using this method. unfortunately i managed to lose the benchmarks i wrote with a poorly timed `git checkout -- .` 😭 Reviewed-on: https://codeberg.org/superseriousbusiness/gotosocial/pulls/4541 Co-authored-by: kim <grufwub@gmail.com> Co-committed-by: kim <grufwub@gmail.com>
Diffstat (limited to 'internal/media/probe.go')
-rw-r--r--internal/media/probe.go5
1 files changed, 2 insertions, 3 deletions
diff --git a/internal/media/probe.go b/internal/media/probe.go
index 5c07b04fb..47990eea3 100644
--- a/internal/media/probe.go
+++ b/internal/media/probe.go
@@ -22,7 +22,6 @@ import (
"encoding/binary"
"image/jpeg"
"io"
- "os"
"strings"
"code.superseriousbusiness.org/gotosocial/internal/gtserror"
@@ -80,7 +79,7 @@ func probe(ctx context.Context, filepath string) (*result, error) {
// probeJPEG decodes the given file as JPEG and determines
// image details from the decoded JPEG using native Go code.
-func probeJPEG(file *os.File) (*result, error) {
+func probeJPEG(file fileReader) (*result, error) {
// Attempt to decode JPEG, adding back hdr magic.
cfg, err := jpeg.DecodeConfig(io.MultiReader(
@@ -129,7 +128,7 @@ func probeJPEG(file *os.File) (*result, error) {
//
// copied from github.com/disintegration/imaging
// but modified to optimize discard operations.
-func readOrientation(r *os.File) int {
+func readOrientation(r fileReader) int {
const (
markerAPP1 = 0xffe1
exifHeader = 0x45786966