Work on magic numbers for aarch64

This commit is contained in:
Justine Tunney 2023-05-10 01:10:28 -07:00
parent 59766efd3e
commit 5a455eaa0b
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2070 changed files with 4567 additions and 4200 deletions

View file

@ -1,21 +1,25 @@
#ifndef COSMOPOLITAN_TOOL_VIZ_LIB_CONVOLVE_H_
#define COSMOPOLITAN_TOOL_VIZ_LIB_CONVOLVE_H_
#include "dsp/tty/quant.h"
#include "libc/str/str.h"
#include "tool/viz/lib/graphic.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
forceinline void convolve(unsigned yn, unsigned xn, __m128 img[yn][xn], int KW,
const float kernel[KW][KW], float C1, float C2) {
typedef float convolve_t __attribute__((__vector_size__(16)));
forceinline void convolve(unsigned yn, unsigned xn, ttyrgb_m128 img[yn][xn],
int KW, const float kernel[KW][KW], float C1,
float C2) {
/* TODO(jart): nontemporal herringbone strategy */
float f;
struct Graphic g;
unsigned y, x, i, j;
__v4sf p, kflip[KW][KW], (*tmp)[yn][xn];
convolve_t p, kflip[KW][KW], (*tmp)[yn][xn];
for (i = 0; i < KW; ++i) {
for (j = 0; j < KW; ++j) {
f = kernel[i][j] / C1;
kflip[KW - i - 1][KW - j - 1] = (__v4sf){f, f, f, f};
kflip[KW - i - 1][KW - j - 1] = (convolve_t){f, f, f, f};
}
}
bzero(&g, sizeof(g));

View file

@ -2,7 +2,6 @@
#define COSMOPOLITAN_TOOL_VIZ_LIB_GRAPHIC_H_
#include "dsp/tty/quant.h"
#include "libc/runtime/buffer.internal.h"
#include "libc/mem/gc.internal.h"
#if !(__ASSEMBLER__ + __LINKER__ + 0)
COSMOPOLITAN_C_START_
@ -35,15 +34,8 @@ void emboss(struct Graphic *);
void boxblur(struct Graphic *);
double perlin3(double, double, double);
void stdgamma(unsigned n, __m128 rgba[n]);
void lingamma(unsigned n, __m128 rgba[n]);
void OldBilinearScale(size_t dyw, size_t dxw, __v4sf dst[dyw][dxw], size_t syw,
size_t sxw, __v4sf src[syw][sxw], size_t dyn, size_t dxn,
size_t syn, size_t sxn);
int MagicScale(unsigned dyn, unsigned dxn, __v4sf dst[dyn][dxn], unsigned syn,
unsigned sxn, __v4sf src[syn][sxn]);
void stdgamma(unsigned n, ttyrgb_m128 rgba[n]);
void lingamma(unsigned n, ttyrgb_m128 rgba[n]);
void interlace(size_t dyn, size_t dxn, float dst[dyn][dxn][4], size_t syn,
size_t sxn, size_t ssw, unsigned char reds[syn][ssw],

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "dsp/tty/quant.h"
#include "libc/assert.h"
#include "libc/runtime/buffer.internal.h"
#include "tool/viz/lib/graphic.h"
@ -29,7 +30,7 @@
struct Graphic *resizegraphic(struct Graphic *g, size_t yn, size_t xn) {
/* assert(xn % 2 == 0); */ /* todo: ughhh this whole thing is wrong */
yn &= ~1;
balloc(&g->b, 64, yn * xn * sizeof(__m128) + /* wut */ PAGESIZE);
balloc(&g->b, 64, yn * xn * sizeof(ttyrgb_m128) + /* wut */ PAGESIZE);
g->yn = yn;
g->xn = xn;
return g;

View file

@ -61,7 +61,6 @@ o/$(MODE)/tool/viz/lib/doublechrominance.o \
o/$(MODE)/tool/viz/lib/doublechrominance.o \
o/$(MODE)/tool/viz/lib/interlace.o \
o/$(MODE)/tool/viz/lib/bilinearscale.o \
o/$(MODE)/tool/viz/lib/oldbilinearscale.o \
o/$(MODE)/tool/viz/lib/boxblur.o \
o/$(MODE)/tool/viz/lib/dither.o \
o/$(MODE)/tool/viz/lib/emboss.o \