summaryrefslogtreecommitdiffstats
path: root/image_writer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2012-10-27 18:06:09 +0200
committerwm4 <wm4@nowhere>2012-11-01 02:07:45 +0100
commit9ba52ea6efd41db9dbd08311380f7fa633e22aa2 (patch)
tree698757630c88e96f323bc66461045234505ace91 /image_writer.c
parentd9839fe8623c855b6b335df3a5b9783e3ed22266 (diff)
downloadmpv-9ba52ea6efd41db9dbd08311380f7fa633e22aa2.tar.bz2
mpv-9ba52ea6efd41db9dbd08311380f7fa633e22aa2.tar.xz
screenshot, draw_bmp: use colorspace passed with mp_image
Remove the explicit struct mp_csp_details parameters from all related functions, and use mp_image.colorspace/levels instead.
Diffstat (limited to 'image_writer.c')
-rw-r--r--image_writer.c32
1 files changed, 12 insertions, 20 deletions
diff --git a/image_writer.c b/image_writer.c
index f4851a9176..82afeb0e48 100644
--- a/image_writer.c
+++ b/image_writer.c
@@ -39,8 +39,8 @@
#include "libmpcodecs/vf.h"
#include "fmt-conversion.h"
-//for sws_getContextFromCmdLine_hq and mp_sws_set_colorspace
#include "libmpcodecs/sws_utils.h"
+#include "libmpcodecs/vf.h"
#include "libvo/csputils.h"
#include "m_option.h"
@@ -284,28 +284,20 @@ int write_image(struct mp_image *image, const struct mp_csp_details *csp,
}
}
+ // Caveat: - no colorspace/levels conversion done if pixel formats equal
+ // - RGB->YUV assumes BT.601
if (image->imgfmt != destfmt || is_anamorphic) {
+ struct mp_image hack = *image;
+ hack.w = hack.width;
+ hack.h = hack.height;
+
struct mp_image *dst = alloc_mpi(image->w, image->h, destfmt);
+ vf_clone_mpi_attributes(dst, image);
+
+ int flags = SWS_LANCZOS | SWS_FULL_CHR_H_INT | SWS_FULL_CHR_H_INP |
+ SWS_ACCURATE_RND | SWS_BITEXACT;
- struct SwsContext *sws = sws_getContextFromCmdLine_hq(image->width,
- image->height,
- image->imgfmt,
- dst->width,
- dst->height,
- dst->imgfmt);
-
- struct mp_csp_details colorspace = MP_CSP_DETAILS_DEFAULTS;
- if (csp)
- colorspace = *csp;
- // This is a property of the output device; images always use
- // full-range RGB.
- colorspace.levels_out = MP_CSP_LEVELS_PC;
- mp_sws_set_colorspace(sws, &colorspace);
-
- sws_scale(sws, (const uint8_t **)image->planes, image->stride, 0,
- image->height, dst->planes, dst->stride);
-
- sws_freeContext(sws);
+ mp_image_swscale(dst, &hack, flags);
allocated_image = dst;
image = dst;