summaryrefslogtreecommitdiffstats
path: root/video
diff options
context:
space:
mode:
authorMartin Herkt <lachs0r@srsfckn.biz>2013-06-15 15:14:06 +0200
committerMartin Herkt <lachs0r@srsfckn.biz>2013-06-15 15:48:52 +0200
commit9b5a98676d18156d56fabae52dbc1d918e4401d4 (patch)
tree20ae40f29e87dd2238b9757b22c0d543fada22e1 /video
parent3c12148668ac70366ec48af2c61777db744eba66 (diff)
downloadmpv-9b5a98676d18156d56fabae52dbc1d918e4401d4.tar.bz2
mpv-9b5a98676d18156d56fabae52dbc1d918e4401d4.tar.xz
image_writer: Add PNG filter option (default "mixed")
The use of filters prior to PNG compression can greatly improve compression ratio, with "mixed" (ImageMagick calls it "adaptive") typically achieving the best results.
Diffstat (limited to 'video')
-rw-r--r--video/image_writer.c6
-rw-r--r--video/image_writer.h1
2 files changed, 6 insertions, 1 deletions
diff --git a/video/image_writer.c b/video/image_writer.c
index a65024124e..1791c01a38 100644
--- a/video/image_writer.c
+++ b/video/image_writer.c
@@ -46,6 +46,7 @@
const struct image_writer_opts image_writer_opts_defaults = {
.format = "jpg",
.png_compression = 7,
+ .png_filter = 5,
.jpeg_quality = 90,
.jpeg_optimize = 100,
.jpeg_smooth = 0,
@@ -65,6 +66,7 @@ const struct m_sub_options image_writer_conf = {
OPT_FLAG("jpeg-progressive", jpeg_progressive, 0),
OPT_FLAG("jpeg-baseline", jpeg_baseline, 0),
OPT_INTRANGE("png-compression", png_compression, 0, 0, 9),
+ OPT_INTRANGE("png-filter", png_filter, 0, 0, 5),
OPT_STRING("format", format, 0),
{0},
},
@@ -105,8 +107,10 @@ static int write_lavc(struct image_writer_ctx *ctx, mp_image_t *image, FILE *fp)
avctx->width = image->w;
avctx->height = image->h;
avctx->pix_fmt = imgfmt2pixfmt(image->imgfmt);
- if (ctx->writer->lavc_codec == AV_CODEC_ID_PNG)
+ if (ctx->writer->lavc_codec == AV_CODEC_ID_PNG) {
avctx->compression_level = ctx->opts->png_compression;
+ avctx->prediction_method = ctx->opts->png_filter;
+ }
if (avcodec_open2(avctx, codec, NULL) < 0) {
print_open_fail:
diff --git a/video/image_writer.h b/video/image_writer.h
index e73b526c7e..4f5942edb5 100644
--- a/video/image_writer.h
+++ b/video/image_writer.h
@@ -21,6 +21,7 @@ struct mp_csp_details;
struct image_writer_opts {
char *format;
int png_compression;
+ int png_filter;
int jpeg_quality;
int jpeg_optimize;
int jpeg_smooth;