diff --git a/video/image_writer.c b/video/image_writer.c index 491828aa22..88ffb7964c 100644 --- a/video/image_writer.c +++ b/video/image_writer.c @@ -78,14 +78,14 @@ struct image_writer_ctx { struct img_writer { const char *file_ext; - int (*write)(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp); + bool (*write)(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp); const int *pixfmts; int lavc_codec; }; -static int write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp) +static bool write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp) { - int success = 0; + bool success = 0; AVFrame *pic = NULL; AVPacket pkt = {0}; int got_output = 0; @@ -161,7 +161,7 @@ static void write_jpeg_error_exit(j_common_ptr cinfo) longjmp(*(jmp_buf*)cinfo->client_data, 1); } -static int write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp) +static bool write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp) { struct jpeg_compress_struct cinfo; struct jpeg_error_mgr jerr; @@ -173,7 +173,7 @@ static int write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp) cinfo.client_data = &error_return_jmpbuf; if (setjmp(cinfo.client_data)) { jpeg_destroy_compress(&cinfo); - return 0; + return false; } jpeg_create_compress(&cinfo); @@ -209,7 +209,7 @@ static int write_jpeg(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp) jpeg_destroy_compress(&cinfo); - return 1; + return true; } #endif @@ -279,8 +279,8 @@ const char *image_writer_file_ext(const struct image_writer_opts *opts) return get_writer(opts)->file_ext; } -int write_image(struct mp_image *image, const struct image_writer_opts *opts, - const char *filename, struct mp_log *log) +bool write_image(struct mp_image *image, const struct image_writer_opts *opts, + const char *filename, struct mp_log *log) { struct mp_image *allocated_image = NULL; struct image_writer_opts defs = image_writer_opts_defaults; @@ -316,7 +316,7 @@ int write_image(struct mp_image *image, const struct image_writer_opts *opts, } FILE *fp = fopen(filename, "wb"); - int success = 0; + bool success = false; if (fp == NULL) { mp_err(log, "Error opening '%s' for writing!\n", filename); } else { diff --git a/video/image_writer.h b/video/image_writer.h index 7db4293712..d7cdd99125 100644 --- a/video/image_writer.h +++ b/video/image_writer.h @@ -48,8 +48,8 @@ const char *image_writer_file_ext(const struct image_writer_opts *opts); * accordingly. Setting w and width or h and height to different values * can be used to store snapshots of anamorphic video. */ -int write_image(struct mp_image *image, const struct image_writer_opts *opts, - const char *filename, struct mp_log *log); +bool write_image(struct mp_image *image, const struct image_writer_opts *opts, + const char *filename, struct mp_log *log); // Debugging helper. void dump_png(struct mp_image *image, const char *filename, struct mp_log *log);