nice refactors, now way cleaner to work with!

This commit is contained in:
2026-04-07 17:20:42 +02:00
parent 966c15cffb
commit bdc58f5b48
17 changed files with 61 additions and 31 deletions

69
src/main.c Normal file
View File

@@ -0,0 +1,69 @@
#include "encoder/modes/martin.h"
#include "encoder/modes/scottie.h"
#include "encoder/sstv.h"
#include <stdio.h>
#include <string.h>
#include <time.h>
static void usage(const char *prog) {
fprintf(stderr,
"Usage: %s <mode> <input_image> <output_wav>\n"
"\n"
"Modes:\n"
" robot36 Robot 36 (320x240)\n"
" martin1 Martin M1 (320x256)\n"
" martin2 Martin M2 (320x256)\n"
" scottie1 Scottie S1 (320x256)\n"
" scottie2 Scottie S2 (320x256)\n"
" scottiedx Scottie DX (320x256)\n"
"\n"
"Example:\n"
" %s mode photo.jpg output.wav\n",
prog, prog);
}
int main(int argc, char *argv[]) {
if (argc != 4) {
usage(argv[0]);
return 1;
}
const char *mode = argv[1];
const char *input_img = argv[2];
const char *output_wav = argv[3];
clock_t start = clock();
int ok = 0;
if (strcmp(mode, "robot36") == 0) {
ok = sstv_encode_robot36(input_img, output_wav);
} else if (strcmp(mode, "martin1") == 0) {
ok = sstv_encode_martin(input_img, output_wav, &MARTIN_M1);
} else if (strcmp(mode, "martin2") == 0) {
ok = sstv_encode_martin(input_img, output_wav, &MARTIN_M2);
} else if (strcmp(mode, "scottie1") == 0) {
ok = sstv_encode_scottie(input_img, output_wav, &SCOTTIE_S1);
} else if (strcmp(mode, "scottie2") == 0) {
ok = sstv_encode_scottie(input_img, output_wav, &SCOTTIE_S2);
} else if (strcmp(mode, "scottiedx") == 0) {
ok = sstv_encode_scottie(input_img, output_wav, &SCOTTIE_DX);
} else {
fprintf(stderr, "unknown mode: %s\n\n", mode);
usage(argv[0]);
return 1;
}
if (!ok) {
fprintf(stderr, "make sure the file exsists");
return 1;
}
clock_t end = clock();
double elapsed = (double)(end - start) / CLOCKS_PER_SEC;
printf("encoded '%s' -> '%s' using '%s'\n", input_img, output_wav, mode);
printf("took %.3f seconds\n", elapsed);
return 0;
}