summaryrefslogtreecommitdiff
path: root/internal/media/imaging.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/media/imaging.go')
-rw-r--r--internal/media/imaging.go40
1 files changed, 20 insertions, 20 deletions
diff --git a/internal/media/imaging.go b/internal/media/imaging.go
index a9f73a066..6a0fa694c 100644
--- a/internal/media/imaging.go
+++ b/internal/media/imaging.go
@@ -399,9 +399,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
g16 := uint16(s[1])
b16 := uint16(s[2])
a16 := uint16(a)
- d[0] = uint8(r16 * 0xff / a16)
- d[1] = uint8(g16 * 0xff / a16)
- d[2] = uint8(b16 * 0xff / a16)
+ d[0] = uint8(r16 * 0xff / a16) // #nosec G115 -- Overflow desired.
+ d[1] = uint8(g16 * 0xff / a16) // #nosec G115 -- Overflow desired.
+ d[2] = uint8(b16 * 0xff / a16) // #nosec G115 -- Overflow desired.
d[3] = a
}
j += 4
@@ -431,9 +431,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
g32 := uint32(s[2])<<8 | uint32(s[3])
b32 := uint32(s[4])<<8 | uint32(s[5])
a32 := uint32(s[6])<<8 | uint32(s[7])
- d[0] = uint8((r32 * 0xffff / a32) >> 8)
- d[1] = uint8((g32 * 0xffff / a32) >> 8)
- d[2] = uint8((b32 * 0xffff / a32) >> 8)
+ d[0] = uint8((r32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
+ d[1] = uint8((g32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
+ d[2] = uint8((b32 * 0xffff / a32) >> 8) // #nosec G115 -- Overflow desired.
}
d[3] = a
j += 4
@@ -509,30 +509,30 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
cr1 := int32(img.Cr[ic]) - 128
r := yy1 + 91881*cr1
- if uint32(r)&0xff000000 == 0 {
+ if uint32(r)&0xff000000 == 0 { //nolint:gosec
r >>= 16
} else {
r = ^(r >> 31)
}
g := yy1 - 22554*cb1 - 46802*cr1
- if uint32(g)&0xff000000 == 0 {
+ if uint32(g)&0xff000000 == 0 { //nolint:gosec
g >>= 16
} else {
g = ^(g >> 31)
}
b := yy1 + 116130*cb1
- if uint32(b)&0xff000000 == 0 {
+ if uint32(b)&0xff000000 == 0 { //nolint:gosec
b >>= 16
} else {
b = ^(b >> 31)
}
d := dst[j : j+4 : j+4]
- d[0] = uint8(r)
- d[1] = uint8(g)
- d[2] = uint8(b)
+ d[0] = uint8(r) // #nosec G115 -- Overflow desired.
+ d[1] = uint8(g) // #nosec G115 -- Overflow desired.
+ d[2] = uint8(b) // #nosec G115 -- Overflow desired.
d[3] = 0xff
iy++
@@ -569,9 +569,9 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
d := dst[j : j+4 : j+4]
switch a16 {
case 0xffff:
- d[0] = uint8(r16 >> 8)
- d[1] = uint8(g16 >> 8)
- d[2] = uint8(b16 >> 8)
+ d[0] = uint8(r16 >> 8) // #nosec G115 -- Overflow desired.
+ d[1] = uint8(g16 >> 8) // #nosec G115 -- Overflow desired.
+ d[2] = uint8(b16 >> 8) // #nosec G115 -- Overflow desired.
d[3] = 0xff
case 0:
d[0] = 0
@@ -579,10 +579,10 @@ func (s *scanner) scan(x1, y1, x2, y2 int, dst []uint8) {
d[2] = 0
d[3] = 0
default:
- d[0] = uint8(((r16 * 0xffff) / a16) >> 8)
- d[1] = uint8(((g16 * 0xffff) / a16) >> 8)
- d[2] = uint8(((b16 * 0xffff) / a16) >> 8)
- d[3] = uint8(a16 >> 8)
+ d[0] = uint8(((r16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
+ d[1] = uint8(((g16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
+ d[2] = uint8(((b16 * 0xffff) / a16) >> 8) // #nosec G115 -- Overflow desired.
+ d[3] = uint8(a16 >> 8) // #nosec G115 -- Overflow desired.
}
j += 4
}
@@ -617,7 +617,7 @@ func clampFloat(x float64) uint8 {
return 255
}
if v > 0 {
- return uint8(v)
+ return uint8(v) // #nosec G115 -- Just checked.
}
return 0
}