Explorar el Código

Implement strip effect

v2
Xerbo hace 1 año
padre
commit
e1c1173959
No se encontró ninguna clave conocida en la base de datos para esta firma ID de clave GPG: 34103F6D8F11CEB0
Se han modificado 3 ficheros con 54 adiciones y 8 borrados
  1. +1
    -1
      CMakeLists.txt
  2. +52
    -6
      aptdec-cli/main.c
  3. +1
    -1
      build_arm.sh

+ 1
- 1
CMakeLists.txt Ver fichero

@@ -76,7 +76,7 @@ else()
target_compile_options(aptdec PRIVATE -Wall -Wextra -pedantic -Wno-missing-field-initializers)
endif()

install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/aptdec LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS aptdec PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

# Packaging
string(REPLACE v "" CPACK_PACKAGE_VERSION ${VERSION})


+ 52
- 6
aptdec-cli/main.c Ver fichero

@@ -67,6 +67,8 @@ static int freq_from_filename(const char *filename);
static int satid_from_freq(int freq);
static size_t callback(float *samples, size_t count, void *context);
static void write_line(writer_t *png, float *row);
apt_image_t strip(apt_image_t img);
int array_contains(char **array, char *value, size_t n);

static volatile int sigint_stop = 0;
void sigint_handler(int signum) {
@@ -361,8 +363,16 @@ static int process_file(const char *path, options_t *opts) {
channel_desc[img.ch[1]]
);

writer_t *writer = writer_init(filename, APT_REGION_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description);
writer_write_image(writer, &img);
writer_t *writer;
if (array_contains(effects, "strip", effects_len)) {
writer = writer_init(filename, (apt_region_t){0, APT_CH_WIDTH*2}, img.rows, PNG_COLOR_TYPE_GRAY, description);
apt_image_t _img = strip(img);
writer_write_image(writer, &_img);
free(_img.data);
} else {
writer = writer_init(filename, APT_REGION_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description);
writer_write_image(writer, &img);
}
writer_free(writer);
} else if (strcmp(images[i], "lut") == 0) {
if (opts->lut != NULL && opts->lut[0] != '\0') {
@@ -393,8 +403,16 @@ static int process_file(const char *path, options_t *opts) {
char description[128];
sprintf(description, "Channel A: %s - %s", channel_name[img.ch[0]], channel_desc[img.ch[0]]);

writer_t *writer = writer_init(filename, APT_REGION_CHA_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description);
writer_write_image(writer, &img);
writer_t *writer;
if (array_contains(effects, "strip", effects_len)) {
writer = writer_init(filename, (apt_region_t){0, APT_CH_WIDTH}, img.rows, PNG_COLOR_TYPE_GRAY, description);
apt_image_t _img = strip(img);
writer_write_image(writer, &_img);
free(_img.data);
} else {
writer = writer_init(filename, APT_REGION_CHA_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description);
writer_write_image(writer, &img);
}
writer_free(writer);
} else if (strcmp(images[i], "b") == 0) {
char filename[269];
@@ -402,8 +420,16 @@ static int process_file(const char *path, options_t *opts) {
char description[128];
sprintf(description, "Channel B: %s - %s", channel_name[img.ch[1]], channel_desc[img.ch[1]]);

writer_t *writer = writer_init(filename, APT_REGION_CHB_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description);
writer_write_image(writer, &img);
writer_t *writer;
if (array_contains(effects, "strip", effects_len)) {
writer = writer_init(filename, (apt_region_t){APT_CH_WIDTH, APT_CH_WIDTH}, img.rows, PNG_COLOR_TYPE_GRAY, description);
apt_image_t _img = strip(img);
writer_write_image(writer, &_img);
free(_img.data);
} else {
writer = writer_init(filename, APT_REGION_CHB_FULL, img.rows, PNG_COLOR_TYPE_GRAY, description);
writer_write_image(writer, &img);
}
writer_free(writer);
}
}
@@ -489,3 +515,23 @@ static void write_line(writer_t *png, float *row) {
png_write_row(png->png, pixels);
#pragma GCC diagnostic pop
}

apt_image_t strip(apt_image_t img) {
uint8_t *data = (uint8_t *)malloc(img.rows * APT_IMG_WIDTH);
for (size_t y = 0; y < img.rows; y++) {
memcpy(&data[y*APT_IMG_WIDTH], &img.data[y*APT_IMG_WIDTH + APT_CHA_OFFSET], APT_CH_WIDTH);
memcpy(&data[y*APT_IMG_WIDTH + APT_CH_WIDTH], &img.data[y*APT_IMG_WIDTH + APT_CHB_OFFSET], APT_CH_WIDTH);
}

img.data = data;
return img;
}

int array_contains(char **array, char *value, size_t n) {
for (size_t i = 0; i < n; i++) {
if (strcmp(array[i], value) == 0) {
return 1;
}
}
return 0;
}

+ 1
- 1
build_arm.sh Ver fichero

@@ -4,7 +4,7 @@
# docker run -v $(pwd):/aptdec:z -w /aptdec debian:11 ./build_arm.sh

apt-get update
apt-get install -y debootstrap cmake gcc-arm-linux-gnueabihf
apt-get install -y debootstrap cmake gcc-arm-linux-gnueabihf git

# Prepare armhf root environment
if [ ! -d root ]; then


Cargando…
Cancelar
Guardar