mirror of
https://github.com/Harshit-Dhanwalkar/AsciiCam.git
synced 2026-06-15 10:45:13 +02:00
Add FPS rendering on top
This commit is contained in:
parent
9eaf33ea36
commit
8a79d2fece
6 changed files with 146 additions and 70 deletions
|
|
@ -7,13 +7,13 @@
|
|||
#define ASCII_CHARS_DEFAULT " .:-=+*#%@"
|
||||
|
||||
typedef struct {
|
||||
int brightness;
|
||||
int contrast;
|
||||
int invert;
|
||||
int color;
|
||||
int edges;
|
||||
int dither;
|
||||
const char *charset;
|
||||
int brightness; /* additive offset: -128..128 */
|
||||
int contrast; /* percent, 100 = no change */
|
||||
int invert; /* flip brightness->charset mapping */
|
||||
int color; /* ANSI truecolor output */
|
||||
int edges; /* Sobel edge detection */
|
||||
int dither; /* Floyd-Steinberg dithering */
|
||||
const char *charset; /* NULL = ASCII_CHARS_DEFAULT */
|
||||
} ascii_opts_t;
|
||||
|
||||
// Convert YUYV raw data to grayscale
|
||||
|
|
@ -28,4 +28,7 @@ int grayscale_to_ascii(const uint8_t *gray, const uint8_t *rgb, int src_w,
|
|||
int src_h, int dst_w, int dst_h, char *out,
|
||||
size_t out_size, const ascii_opts_t *opts);
|
||||
|
||||
// Overlay FPS box
|
||||
void overlay_fps_box(int dst_w, double fps, int color_enabled);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,17 +1,22 @@
|
|||
#ifndef THREAD_SHARING_H
|
||||
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include "ascii.h"
|
||||
|
||||
typedef struct {
|
||||
uint8_t *buf[2]; // Duble buffer
|
||||
int width, height;
|
||||
int ascii_w, ascii_h;
|
||||
int ready_idx;
|
||||
int has_frame;
|
||||
uint8_t *buf[2]; // Double buffer
|
||||
int width, height;
|
||||
int ascii_w, ascii_h;
|
||||
int ready_idx;
|
||||
int has_frame;
|
||||
pthread_mutex_t lock;
|
||||
pthread_cond_t cond;
|
||||
volatile int stop;
|
||||
|
||||
ascii_opts_t opts;
|
||||
pthread_cond_t cond;
|
||||
volatile int stop;
|
||||
ascii_opts_t opts;
|
||||
} shared_frame_t;
|
||||
|
||||
void *capture_thread(void *arg);
|
||||
void *render_thread (void *arg);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -3,9 +3,19 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
typedef struct {
|
||||
long samples[16]; // frame duration (ns) ring buffer
|
||||
int head;
|
||||
int count;
|
||||
} fps_counter_t;
|
||||
|
||||
// Initialize framerate control
|
||||
void timing_init(int fps);
|
||||
|
||||
void timing_sleep(struct timespec *start_time);
|
||||
|
||||
void fps_push(fps_counter_t *fc, long elapsed_ns);
|
||||
|
||||
double fps_get(const fps_counter_t *fc);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue