From 055aa53e403bbdfb4b3454f6c34bb92b4eb80b20 Mon Sep 17 00:00:00 2001 From: MrDave Date: Fri, 4 Oct 2019 19:45:29 -0600 Subject: [PATCH] Elminate picture_type as separate variable --- src/event.c | 8 ++------ src/motion.h | 7 +------ src/motion_loop.c | 16 ---------------- src/picture.c | 10 +++++----- 4 files changed, 8 insertions(+), 33 deletions(-) diff --git a/src/event.c b/src/event.c index 98adcffb..d3b51f97 100644 --- a/src/event.c +++ b/src/event.c @@ -304,12 +304,8 @@ static void event_vlp_putpipe(struct ctx_cam *cam, motion_event evnt const char *imageext(struct ctx_cam *cam) { - if (cam->imgs.picture_type == IMAGE_TYPE_PPM) - return "ppm"; - - if (cam->imgs.picture_type == IMAGE_TYPE_WEBP) - return "webp"; - + if (mystreq(cam->conf.picture_type, "ppm")) return "ppm"; + if (mystreq(cam->conf.picture_type, "webp")) return "webp"; return "jpg"; } diff --git a/src/motion.h b/src/motion.h index d942e413..64e0eee9 100644 --- a/src/motion.h +++ b/src/motion.h @@ -101,11 +101,6 @@ int nls_enabled; #define DEF_TIMELAPSE_MODE "daily" -/* OUTPUT Image types */ -#define IMAGE_TYPE_JPEG 0 -#define IMAGE_TYPE_PPM 1 -#define IMAGE_TYPE_WEBP 2 - /* Filetype defines */ #define FTYPE_IMAGE 1 #define FTYPE_IMAGE_SNAPSHOT 2 @@ -262,7 +257,7 @@ struct ctx_images { int labels_above; int labelsize_max; int largest_label; - int picture_type; + }; struct ctx_stream_data { diff --git a/src/motion_loop.c b/src/motion_loop.c index 85b5d8f3..544bcaeb 100644 --- a/src/motion_loop.c +++ b/src/motion_loop.c @@ -573,22 +573,6 @@ static int mlp_init(struct ctx_cam *cam) { webu_stream_init(cam); - /* Set output picture type */ - if (mystreq(cam->conf.picture_type, "ppm")) - cam->imgs.picture_type = IMAGE_TYPE_PPM; - else if (mystreq(cam->conf.picture_type, "webp")) { - #ifdef HAVE_WEBP - cam->imgs.picture_type = IMAGE_TYPE_WEBP; - #else - /* Fallback to jpeg if webp was selected in the config file, but the support for it was not compiled in */ - MOTION_LOG(ERR, TYPE_ALL, NO_ERRNO - ,_("webp image format is not available, failing back to jpeg")); - cam->imgs.picture_type = IMAGE_TYPE_JPEG; - #endif /* HAVE_WEBP */ - } - else - cam->imgs.picture_type = IMAGE_TYPE_JPEG; - rotate_init(cam); draw_init_scale(cam); diff --git a/src/picture.c b/src/picture.c index 257f36bf..6a423957 100644 --- a/src/picture.c +++ b/src/picture.c @@ -266,14 +266,14 @@ static void pic_write(struct ctx_cam *cam, FILE *picture, unsigned char *image, height = cam->imgs.height; } - if (cam->imgs.picture_type == IMAGE_TYPE_PPM) { + if (mystreq(cam->conf.picture_type, "ppm")) { pic_save_ppm(picture, image, width, height); - } else if (cam->imgs.picture_type == IMAGE_TYPE_WEBP) { + } else if (mystreq(cam->conf.picture_type, "webp")) { pic_save_webp(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); - } else if (cam->imgs.picture_type == IMAGE_TYPE_JPEG) { - pic_save_yuv420p(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); - } else { + } else if (mystreq(cam->conf.picture_type, "grey")) { pic_save_grey(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); + } else { + pic_save_yuv420p(picture, image, width, height, quality, cam, &(cam->current_image->imgts), &(cam->current_image->location)); } }