diff options
author | Rudolf Polzer <divverent@xonotic.org> | 2012-10-24 19:11:42 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-10-24 21:56:29 +0200 |
commit | aa1047a35a98606c972cc35e566178703b1f2bff (patch) | |
tree | e757c045aee158cbe4bf56f3d142f80e0ef62cb0 /libmpcodecs/sws_utils.c | |
parent | 1282f9d79e09160af67ec13c05c0eed1ae02bd46 (diff) | |
download | mpv-aa1047a35a98606c972cc35e566178703b1f2bff.tar.bz2 mpv-aa1047a35a98606c972cc35e566178703b1f2bff.tar.xz |
sub: add helper to draw sub-bitmaps into an image
Merged by wm4 from commits 93978f17b76d..13211ef5fc20. Changed copyright
header in draw_bmp.c to "mpv", and removed the one in draw_bmp.h.
Diffstat (limited to 'libmpcodecs/sws_utils.c')
-rw-r--r-- | libmpcodecs/sws_utils.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libmpcodecs/sws_utils.c b/libmpcodecs/sws_utils.c index 438db4a13a..65b079dd84 100644 --- a/libmpcodecs/sws_utils.c +++ b/libmpcodecs/sws_utils.c @@ -131,4 +131,28 @@ struct SwsContext *sws_getContextFromCmdLine_hq(int srcW, int srcH, SWS_ACCURATE_RND | SWS_BITEXACT); } +void mp_image_swscale(struct mp_image *dst, + const struct mp_image *src, + struct mp_csp_details *csp, + int my_sws_flags) +{ + enum PixelFormat dfmt, sfmt; + dfmt = imgfmt2pixfmt(dst->imgfmt); + sfmt = imgfmt2pixfmt(src->imgfmt); + if (src->imgfmt == IMGFMT_RGB8 || src->imgfmt == IMGFMT_BGR8) + sfmt = PIX_FMT_PAL8; + + struct SwsContext *sws = + sws_getContext(src->w, src->h, sfmt, dst->w, dst->h, dfmt, + my_sws_flags, NULL, NULL, NULL); + struct mp_csp_details mycsp = MP_CSP_DETAILS_DEFAULTS; + if (csp) + mycsp = *csp; + mp_sws_set_colorspace(sws, &mycsp); + sws_scale(sws, (const unsigned char *const *) src->planes, src->stride, + 0, src->h, + dst->planes, dst->stride); + sws_freeContext(sws); +} + // vim: ts=4 sw=4 et tw=80 |