2012-08-06 15:46:42 +00:00
|
|
|
/*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
2012-08-06 15:46:42 +00:00
|
|
|
*
|
2017-06-18 13:45:24 +00:00
|
|
|
* mpv is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
2012-08-06 15:46:42 +00:00
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2012-08-06 15:46:42 +00:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2017-06-18 13:45:24 +00:00
|
|
|
* GNU Lesser General Public License for more details.
|
2012-08-06 15:46:42 +00:00
|
|
|
*
|
2017-06-18 13:45:24 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2012-08-06 15:46:42 +00:00
|
|
|
*/
|
|
|
|
|
2016-09-05 19:04:55 +00:00
|
|
|
#include "options/m_option.h"
|
|
|
|
|
2012-08-06 15:46:42 +00:00
|
|
|
struct mp_image;
|
2013-12-21 16:59:38 +00:00
|
|
|
struct mp_log;
|
2012-08-06 15:46:42 +00:00
|
|
|
|
|
|
|
struct image_writer_opts {
|
2017-03-18 14:03:05 +00:00
|
|
|
int format;
|
2023-02-20 03:32:50 +00:00
|
|
|
bool high_bit_depth;
|
2012-08-06 15:46:42 +00:00
|
|
|
int png_compression;
|
2013-06-15 13:14:06 +00:00
|
|
|
int png_filter;
|
2012-08-06 15:46:42 +00:00
|
|
|
int jpeg_quality;
|
2023-02-20 03:32:50 +00:00
|
|
|
bool jpeg_source_chroma;
|
|
|
|
bool webp_lossless;
|
2019-09-14 20:18:02 +00:00
|
|
|
int webp_quality;
|
2019-08-02 14:04:54 +00:00
|
|
|
int webp_compression;
|
2022-04-23 18:24:09 +00:00
|
|
|
double jxl_distance;
|
|
|
|
int jxl_effort;
|
2023-03-24 23:30:57 +00:00
|
|
|
char *avif_encoder;
|
|
|
|
char *avif_pixfmt;
|
|
|
|
char **avif_opts;
|
2023-02-20 03:32:50 +00:00
|
|
|
bool tag_csp;
|
2012-08-06 15:46:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern const struct image_writer_opts image_writer_opts_defaults;
|
|
|
|
|
2016-09-05 19:04:55 +00:00
|
|
|
extern const struct m_option image_writer_opts[];
|
2012-08-06 15:46:42 +00:00
|
|
|
|
|
|
|
// Return the file extension that will be used, e.g. "png".
|
|
|
|
const char *image_writer_file_ext(const struct image_writer_opts *opts);
|
|
|
|
|
2018-02-07 19:18:36 +00:00
|
|
|
// Return whether the selected format likely supports >8 bit per component.
|
|
|
|
bool image_writer_high_depth(const struct image_writer_opts *opts);
|
|
|
|
|
2023-02-13 19:59:46 +00:00
|
|
|
// Return whether the selected format likely supports non-sRGB colorspaces
|
|
|
|
bool image_writer_flexible_csp(const struct image_writer_opts *opts);
|
|
|
|
|
2017-03-18 14:03:05 +00:00
|
|
|
// Map file extension to format ID - return 0 (which is invalid) if unknown.
|
|
|
|
int image_writer_format_from_ext(const char *ext);
|
|
|
|
|
2012-08-06 15:46:42 +00:00
|
|
|
/*
|
|
|
|
* Save the given image under the given filename. The parameters csp and opts
|
|
|
|
* are optional. All pixel formats supported by swscale are supported.
|
|
|
|
*
|
|
|
|
* File format and compression settings are controlled via the opts parameter.
|
|
|
|
*
|
2019-10-31 14:44:09 +00:00
|
|
|
* If global!=NULL, use command line scaler options etc.
|
|
|
|
*
|
2012-08-06 15:46:42 +00:00
|
|
|
* NOTE: The fields w/h/width/height of the passed mp_image must be all set
|
|
|
|
* accordingly. Setting w and width or h and height to different values
|
|
|
|
* can be used to store snapshots of anamorphic video.
|
|
|
|
*/
|
2015-04-20 21:02:20 +00:00
|
|
|
bool write_image(struct mp_image *image, const struct image_writer_opts *opts,
|
2019-10-31 14:44:09 +00:00
|
|
|
const char *filename, struct mpv_global *global,
|
2024-03-19 04:38:58 +00:00
|
|
|
struct mp_log *log, bool overwrite);
|
2012-10-27 15:30:26 +00:00
|
|
|
|
|
|
|
// Debugging helper.
|
2013-12-21 16:59:38 +00:00
|
|
|
void dump_png(struct mp_image *image, const char *filename, struct mp_log *log);
|