ascii-chat
Binary v0.15.83-53-gb711d8720
Library lib/v0.3.2-701-gb711d8720
Video chat in your terminal
Loading...
Searching...
No Matches
neon/halfblock.c
Go to the documentation of this file.
1#if SIMD_SUPPORT_NEON
2#define SIMD_CELL_NEON 1
3#define SIMD_CELL_ISA neon
4#include "../simd/pack.c"
6#include <libplatform/compiler.h>
7#include <libplatform/system.h>
8#include <libplatform/terminal.h>
11char *render_halfblocks_neon(const uint8_t *rgb, int width, int height, int stride, ascii_color_t mode) {
12 if (width <= 0 || height <= 0)
13 return platform_strdup("");
14 ascii_frame_t frame;
15 if (ascii_half_frame_init(&frame, rgb, width, height, &stride, mode) != ASCIICHAT_OK)
16 return NULL;
17 for (size_t y = 0; y < (size_t)height; y += 2) {
18 const uint8_t *top = rgb + y * (size_t)stride;
19 const uint8_t *bottom = y + 1 < (size_t)height ? top + stride : top;
20 simd_pack_neon(top, frame.packed, frame.width);
21 simd_pack_neon(bottom, frame.index, frame.width);
22 if (mode == ASCII_COLOR_TRUE) {
23 memcpy(frame.fg, frame.packed, frame.width * sizeof(uint32_t));
24 memcpy(frame.bg, frame.index, frame.width * sizeof(uint32_t));
25 } else if (mode != ASCII_COLOR_NONE) {
26 simd_quantize_neon(frame.packed, frame.fg, frame.width, mode == ASCII_COLOR_16 ? 16 : 256);
27 simd_quantize_neon(frame.index, frame.bg, frame.width, mode == ASCII_COLOR_16 ? 16 : 256);
28 }
29 simd_halfblock_neon(frame.packed, frame.index, frame.glyph, frame.fg, frame.bg, frame.width, (unsigned)mode,
30 frame.table);
31 ascii_frame_emit_halfrow(&frame, mode, y + 2 < (size_t)height, &simd_cells_neon);
32 }
33 return ascii_frame_finish(&frame);
34}
35char *rgb_to_truecolor_halfblocks_neon(const uint8_t *rgb, int width, int height, int stride) {
37}
38char *rgb_to_256color_halfblocks_neon(const uint8_t *rgb, int width, int height, int stride, const char *palette) {
39 (void)palette;
41}
42char *rgb_to_16color_halfblocks_neon(const uint8_t *rgb, int width, int height, int stride, const char *palette) {
43 (void)palette;
45}
46char *rgb_to_halfblocks_neon(const uint8_t *rgb, int width, int height, int stride, const char *palette) {
47 (void)palette;
49}
50#endif
void simd_quantize_neon(const uint32_t *, uint32_t *, size_t, unsigned)
void simd_pack_neon(const uint8_t *, uint32_t *, size_t)
void simd_halfblock_neon(const uint32_t *, const uint32_t *, uint32_t *, uint32_t *, uint32_t *, size_t, unsigned, const uint32_t[5])
const simd_cells_t simd_cells_neon
unsigned int height
Definition fft.c:23
unsigned int width
Definition fft.c:23
unsigned int uint32_t
Definition common.h:62
unsigned char uint8_t
Definition common.h:60
@ ASCIICHAT_OK
Definition error_codes.h:46
char * render_halfblocks_neon(const uint8_t *, int, int, int, ascii_color_t)
char * ascii_frame_finish(ascii_frame_t *frame)
asciichat_error_t ascii_half_frame_init(ascii_frame_t *frame, const uint8_t *rgb, int width, int height, int *stride, ascii_color_t mode)
void ascii_frame_emit_halfrow(ascii_frame_t *frame, ascii_color_t mode, bool more_rows, const simd_cells_t *ops)
NEON-optimized ASCII rendering functions.
🔤 String Manipulation and Shell Escaping Utilities
When code needs to work with ascii frame, it keeps output, output_target, width, source_height here i...