ref: fc858fbb5ec7268a7f70a00de36eef4ed2f5fad5
parent: d2c3a6aeaa6d1a46090834e15a90b768918b18ac
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Wed Oct 16 13:00:09 EDT 2024
cmprocess: remove one useless parameter
--- a/cmprocess.c
+++ b/cmprocess.c
@@ -4,22 +4,17 @@
extern int cmflags;
void
-cmprocess(s16int cm[4*4], void *in_, void *out_, int n)
+cmprocess(s16int cm[4*4], pixel_t *p, int n)
{
- pixel_t *in, *out;
-
if(cmkind == CmIdent)
return;
- in = in_;
- out = out_;
-
if(cmkind == CmBright){
- for(; n > 0; in++, n--){
+ for(; n > 0; n--){
s32int x[4] = {
- (*in>>0)&0xff,
- (*in>>8)&0xff,
- (*in>>16)&0xff,
+ (*p>>0)&0xff,
+ (*p>>8)&0xff,
+ (*p>>16)&0xff,
0xff,
};
s32int y[4] = {
@@ -34,16 +29,16 @@
min(y[2], 255),
0xff,
};
- *out++ = z[0]<<0 | z[1]<<8 | z[2]<<16 | (pixel_t)0xff<<24;
+ *p++ = z[0]<<0 | z[1]<<8 | z[2]<<16 | (pixel_t)0xff<<24;
}
return;
}
- for(; n > 0; in++, n--){
+ for(; n > 0; n--){
s32int x[4] = {
- (*in>>0)&0xff,
- (*in>>8)&0xff,
- (*in>>16)&0xff,
+ (*p>>0)&0xff,
+ (*p>>8)&0xff,
+ (*p>>16)&0xff,
0xff,
};
s32int y[4] = {
@@ -58,6 +53,6 @@
clamp(y[2], 0, 255),
0xff,
};
- *out++ = z[0]<<0 | z[1]<<8 | z[2]<<16 | z[3]<<24;
+ *p++ = z[0]<<0 | z[1]<<8 | z[2]<<16 | z[3]<<24;
}
}
--- a/cmprocess_arm64.s
+++ b/cmprocess_arm64.s
@@ -1,27 +1,30 @@
#include "colormatrix.h"
TEXT cmprocess(SB), $0
- MOV in+8(FP), R1
- MOV out+16(FP), R2
- MOVW cnt+24(FP), R3
+ MOV p+8(FP), R1
+ MOVW n+16(FP), R2
MOVW cmkind(SB), R4
CMPW $CmIdent, R4
BEQ _done
+ BIC $7, R2
+ LSL $2, R2
+ ADD R1, R2, R3
+
CMPW $CmBright, R4
BNE _full
/* just the brightness */
+ WORD $0x4d40c400 // ld1r {v0.8h}, [x0]
WORD $0x4f0797fc // orr v28.8h, 0xff, lsl 0
WORD $0x4f0777fd // orr v29.4s, 0xff, lsl 24
- WORD $0x4d40c400 // ld1r {v0.8h}, [x0]
- ORRW $3, R3
- ADDW $1, R3
_brightconv:
- WORD $0x0cdfa821 // ld1 {v1.2s, v2.2s}, [x1], 16
+ WORD $0x3dc00021 // ldr q1, [x1]
+ CMP R1, R3
+ BEQ _done
+ WORD $0x6f08a422 // uxtl2 v2.8h, v1.16b
WORD $0x2f08a421 // uxtl v1.8h, v1.8b
- WORD $0x2f08a442 // uxtl v2.8h, v2.8b
WORD $0x2f40a023 // umull v3.4s, v1.4h, v0.h[0]
WORD $0x6f40a024 // umull2 v4.4s, v1.8h, v0.h[0]
WORD $0x2f40a045 // umull v5.4s, v2.4h, v0.h[0]
@@ -32,21 +35,21 @@
WORD $0x4f1484c4 // shrn2 v4.8h, v6.4s, 12
WORD $0x4e7c6c63 // smin.8h v3, v3, v28
WORD $0x4e7c6c84 // smin.8h v4, v4, v28
- WORD $0x0e212862 // xtn v2.8b, v3.8h
- WORD $0x4e212882 // xtn2 v2.16b, v4.8h
- WORD $0x4ebd1c42 // orr.16b v2, v2, v29
- WORD $0x4c9f7042 // st1.16b {v2}, [x2], 16
- SUBW $4, R3, R3
- CBNZW R3, _brightconv
- B _done
+ WORD $0x0e212863 // xtn v3.8b, v3.8h
+ WORD $0x4e212883 // xtn2 v3.16b, v4.8h
+ WORD $0x4ebd1c63 // orr.16b v3, v3, v29
+ WORD $0x3c810423 // str q3, [x1], 16
+ B _brightconv
/* full-on multiplication */
_full:
- WORD $0x4f0707fe // movi v30.4s, 0xff, lsl 0
WORD $0x4c40a000 // ld1.16b {v0, v1}, [x0]
+ WORD $0x4f0707fe // movi v30.4s, 0xff, lsl 0
WORD $0x6e3d1fbd // eor.16b v29, v29, v29
_fullconv:
- WORD $0x0ddf803f // ld1 {v31.s}[0], [x1], 4
+ WORD $0x0d40803f // ld1 {v31.s}[0], [x1]
+ CMP R1, R3
+ BEQ _done
WORD $0x0f0777ff // orr v31.2s, 0xff, lsl 24
WORD $0x2f08a7ff // uxtl.8h v31, v31
WORD $0x4e0807ff // dup v31.2d, v31.d[0]
@@ -66,9 +69,8 @@
WORD $0x4ebe6c42 // smin.4s v2, v2, v30
WORD $0x0e612842 // xtn v2.4h, v2.4s
WORD $0x0e212842 // xtn v2.8b, v2.8h
- WORD $0x0d9f8042 // st1.s {v2}[0], [x2], 4
- SUBW $1, R3, R3
- CBNZW R3, _fullconv
+ WORD $0x0d9f8022 // str1.s {v2}[0], [x1], 4
+ B _fullconv
_done:
RETURN
--- a/colormatrix.h
+++ b/colormatrix.h
@@ -12,6 +12,6 @@
extern int cmkind;
void cmsetvblend(float blend[4]);
-void cmprocess(s16int cm[4*4], void *in, void *out, int n);
+void cmprocess(s16int cm[4*4], pixel_t *p, int n);
void cminit(void);
#endif
--- a/vid_plan9.c
+++ b/vid_plan9.c
@@ -8,7 +8,7 @@
Rectangle grabr;
static Image *fbi;
-static s32int *scibuf;
+static pixel_t *scibuf;
static int scifactor;
static Rectangle fbr;
static pixel_t *vidbuffers[2];
@@ -82,7 +82,7 @@
static void
loader(void *)
{
- s32int *in, *out;
+ pixel_t *in, *out;
int n, x, y, j;
Point center;
Rectangle r;
@@ -98,10 +98,9 @@
for(;;){
if((f = recvp(frame)) == nil)
break;
- cmprocess(cm, f, f, vid.width*vid.height);
+ in = (pixel_t*)f;
+ cmprocess(cm, in, vid.width*vid.height);
if(scibuf != nil){
- in = (s32int*)f;
-
r = rectsubpt(
rectaddpt(Rect(0, 0, scifactor*vid.width, scifactor), center),
Pt(scifactor*vid.width/2, scifactor*vid.height/2)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -104,7 +104,7 @@
return;
}
- cmprocess(cm, vidbuffer, vidbuffer, vid.width*vid.height);
+ cmprocess(cm, vidbuffer, vid.width*vid.height);
SDL_UpdateTexture(fbi, nil, vidbuffer, vid.width*4);
SDL_RenderCopy(rend, fbi, nil, nil);