2012-10-24 17:00:49 +00:00
|
|
|
/*
|
|
|
|
* This file is part of MPlayer.
|
|
|
|
*
|
|
|
|
* MPlayer is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* MPlayer is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
2013-07-18 11:46:05 +00:00
|
|
|
#include <libswscale/swscale.h>
|
2013-07-25 21:02:23 +00:00
|
|
|
#include <libavcodec/avcodec.h>
|
2012-10-27 16:06:09 +00:00
|
|
|
#include <libavutil/opt.h>
|
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "sws_utils.h"
|
2012-10-24 17:00:49 +00:00
|
|
|
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "video/mp_image.h"
|
|
|
|
#include "video/img_format.h"
|
2012-10-24 17:00:49 +00:00
|
|
|
#include "fmt-conversion.h"
|
2012-11-09 00:06:43 +00:00
|
|
|
#include "csputils.h"
|
2013-08-06 20:41:30 +00:00
|
|
|
#include "mpvcore/mp_msg.h"
|
2012-10-24 17:00:49 +00:00
|
|
|
|
|
|
|
//global sws_flags from the command line
|
|
|
|
int sws_flags = 2;
|
|
|
|
|
|
|
|
float sws_lum_gblur = 0.0;
|
|
|
|
float sws_chr_gblur = 0.0;
|
|
|
|
int sws_chr_vshift = 0;
|
|
|
|
int sws_chr_hshift = 0;
|
|
|
|
float sws_chr_sharpen = 0.0;
|
|
|
|
float sws_lum_sharpen = 0.0;
|
|
|
|
|
2013-07-18 11:48:57 +00:00
|
|
|
// Highest quality, but also slowest.
|
|
|
|
const int mp_sws_hq_flags = SWS_LANCZOS | SWS_FULL_CHR_H_INT |
|
|
|
|
SWS_FULL_CHR_H_INP | SWS_ACCURATE_RND |
|
|
|
|
SWS_BITEXACT;
|
2012-10-24 17:00:49 +00:00
|
|
|
|
2013-08-09 22:27:41 +00:00
|
|
|
// Fast, lossy.
|
|
|
|
const int mp_sws_fast_flags = SWS_BILINEAR;
|
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
// Set ctx parameters to global command line flags.
|
|
|
|
void mp_sws_set_from_cmdline(struct mp_sws_context *ctx)
|
|
|
|
{
|
|
|
|
sws_freeFilter(ctx->src_filter);
|
|
|
|
ctx->src_filter = sws_getDefaultFilter(sws_lum_gblur, sws_chr_gblur,
|
|
|
|
sws_lum_sharpen, sws_chr_sharpen,
|
|
|
|
sws_chr_hshift, sws_chr_vshift, 0);
|
|
|
|
ctx->force_reload = true;
|
|
|
|
|
|
|
|
ctx->flags = SWS_PRINT_INFO;
|
|
|
|
|
|
|
|
switch (sws_flags) {
|
|
|
|
case 0: ctx->flags |= SWS_FAST_BILINEAR; break;
|
|
|
|
case 1: ctx->flags |= SWS_BILINEAR; break;
|
|
|
|
case 2: ctx->flags |= SWS_BICUBIC; break;
|
|
|
|
case 3: ctx->flags |= SWS_X; break;
|
|
|
|
case 4: ctx->flags |= SWS_POINT; break;
|
|
|
|
case 5: ctx->flags |= SWS_AREA; break;
|
|
|
|
case 6: ctx->flags |= SWS_BICUBLIN; break;
|
|
|
|
case 7: ctx->flags |= SWS_GAUSS; break;
|
|
|
|
case 8: ctx->flags |= SWS_SINC; break;
|
|
|
|
case 9: ctx->flags |= SWS_LANCZOS; break;
|
|
|
|
case 10: ctx->flags |= SWS_SPLINE; break;
|
|
|
|
default: ctx->flags |= SWS_BILINEAR; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-10-19 17:11:58 +00:00
|
|
|
bool mp_sws_supported_format(int imgfmt)
|
|
|
|
{
|
|
|
|
enum PixelFormat av_format = imgfmt2pixfmt(imgfmt);
|
|
|
|
|
|
|
|
return av_format != PIX_FMT_NONE && sws_isSupportedInput(av_format)
|
|
|
|
&& sws_isSupportedOutput(av_format);
|
|
|
|
}
|
|
|
|
|
2012-10-27 16:06:09 +00:00
|
|
|
static int mp_csp_to_sws_colorspace(enum mp_csp csp)
|
|
|
|
{
|
|
|
|
switch (csp) {
|
|
|
|
case MP_CSP_BT_601: return SWS_CS_ITU601;
|
|
|
|
case MP_CSP_BT_709: return SWS_CS_ITU709;
|
|
|
|
case MP_CSP_SMPTE_240M: return SWS_CS_SMPTE240M;
|
|
|
|
default: return SWS_CS_DEFAULT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
draw_bmp: add RGB rendering to fix image quality issues
As pointed out in commit ed01df, the quality loss due to frequent
conversion between RGB and YUV is too much when drawing OSD and
subtitles.
Fix this by staying in the same colorspace when drawing subtitles.
Render directly to RGB, without converting to YUV first.
The bad thing about packed RGB is that there are many pixel formats,
which would all require special code for blending. It's also completely
incompatible to planar YUV. Use planar RGB instead, which allows us to
reuse all code originally written for planar YUV. The only thing that
needs to be changed is the color conversion in the libass case. (In
exchange for simpler code, the image has to be copied, but this is
still much better than converting to YUV.)
Unfortunately, libswscale doesn't support planar RGB output. Add a hack
to sws_utils.c to handle conversion to planar RGB. In the common case,
when converting 32 bit per pixel RGB, calling swscale can be avoided
entirely.
The change in mp_image.c is needed to allocate GBRP images correctly.
(The issue with vo_x11 could be easily solved by always backing up the
same bounding box as the bitmap drawing RGB<->YUV conversion does, but
this commit is probably the better fix.)
2012-11-22 12:30:16 +00:00
|
|
|
// component_offset[]: byte index of each r (0), g (1), b (2), a (3) component
|
|
|
|
static void planarize32(struct mp_image *dst, struct mp_image *src,
|
|
|
|
int component_offset[4])
|
|
|
|
{
|
|
|
|
for (int y = 0; y < dst->h; y++) {
|
|
|
|
for (int p = 0; p < 3; p++) {
|
|
|
|
uint8_t *d_line = dst->planes[p] + y * dst->stride[p];
|
|
|
|
uint8_t *s_line = src->planes[0] + y * src->stride[0];
|
|
|
|
s_line += component_offset[(p + 1) % 3]; // GBR => RGB
|
|
|
|
for (int x = 0; x < dst->w; x++) {
|
|
|
|
d_line[x] = s_line[x * 4];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#define SET_COMPS(comp, r, g, b, a) \
|
|
|
|
{ (comp)[0] = (r); (comp)[1] = (g); (comp)[2] = (b); (comp)[3] = (a); }
|
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
static int to_gbrp(struct mp_image *dst, struct mp_image *src,
|
|
|
|
int my_sws_flags)
|
draw_bmp: add RGB rendering to fix image quality issues
As pointed out in commit ed01df, the quality loss due to frequent
conversion between RGB and YUV is too much when drawing OSD and
subtitles.
Fix this by staying in the same colorspace when drawing subtitles.
Render directly to RGB, without converting to YUV first.
The bad thing about packed RGB is that there are many pixel formats,
which would all require special code for blending. It's also completely
incompatible to planar YUV. Use planar RGB instead, which allows us to
reuse all code originally written for planar YUV. The only thing that
needs to be changed is the color conversion in the libass case. (In
exchange for simpler code, the image has to be copied, but this is
still much better than converting to YUV.)
Unfortunately, libswscale doesn't support planar RGB output. Add a hack
to sws_utils.c to handle conversion to planar RGB. In the common case,
when converting 32 bit per pixel RGB, calling swscale can be avoided
entirely.
The change in mp_image.c is needed to allocate GBRP images correctly.
(The issue with vo_x11 could be easily solved by always backing up the
same bounding box as the bitmap drawing RGB<->YUV conversion does, but
this commit is probably the better fix.)
2012-11-22 12:30:16 +00:00
|
|
|
{
|
|
|
|
struct mp_image *temp = NULL;
|
|
|
|
int comp[4];
|
|
|
|
|
|
|
|
switch (src->imgfmt) {
|
|
|
|
case IMGFMT_ABGR: SET_COMPS(comp, 3, 2, 1, 0); break;
|
|
|
|
case IMGFMT_BGRA: SET_COMPS(comp, 2, 1, 0, 3); break;
|
|
|
|
case IMGFMT_ARGB: SET_COMPS(comp, 1, 2, 3, 0); break;
|
|
|
|
case IMGFMT_RGBA: SET_COMPS(comp, 0, 1, 2, 3); break;
|
|
|
|
default:
|
2012-12-22 20:46:22 +00:00
|
|
|
temp = mp_image_alloc(IMGFMT_RGBA, dst->w, dst->h);
|
draw_bmp: add RGB rendering to fix image quality issues
As pointed out in commit ed01df, the quality loss due to frequent
conversion between RGB and YUV is too much when drawing OSD and
subtitles.
Fix this by staying in the same colorspace when drawing subtitles.
Render directly to RGB, without converting to YUV first.
The bad thing about packed RGB is that there are many pixel formats,
which would all require special code for blending. It's also completely
incompatible to planar YUV. Use planar RGB instead, which allows us to
reuse all code originally written for planar YUV. The only thing that
needs to be changed is the color conversion in the libass case. (In
exchange for simpler code, the image has to be copied, but this is
still much better than converting to YUV.)
Unfortunately, libswscale doesn't support planar RGB output. Add a hack
to sws_utils.c to handle conversion to planar RGB. In the common case,
when converting 32 bit per pixel RGB, calling swscale can be avoided
entirely.
The change in mp_image.c is needed to allocate GBRP images correctly.
(The issue with vo_x11 could be easily solved by always backing up the
same bounding box as the bitmap drawing RGB<->YUV conversion does, but
this commit is probably the better fix.)
2012-11-22 12:30:16 +00:00
|
|
|
mp_image_swscale(temp, src, my_sws_flags);
|
|
|
|
src = temp;
|
|
|
|
SET_COMPS(comp, 0, 1, 2, 3);
|
|
|
|
}
|
|
|
|
|
|
|
|
planarize32(dst, src, comp);
|
|
|
|
|
|
|
|
talloc_free(temp);
|
2013-07-18 11:17:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool cache_valid(struct mp_sws_context *ctx)
|
|
|
|
{
|
|
|
|
struct mp_sws_context *old = ctx->cached;
|
|
|
|
if (ctx->force_reload)
|
|
|
|
return false;
|
|
|
|
return mp_image_params_equals(&ctx->src, &old->src) &&
|
|
|
|
mp_image_params_equals(&ctx->dst, &old->dst) &&
|
|
|
|
ctx->flags == old->flags &&
|
|
|
|
ctx->brightness == old->brightness &&
|
|
|
|
ctx->contrast == old->contrast &&
|
|
|
|
ctx->saturation == old->saturation;
|
draw_bmp: add RGB rendering to fix image quality issues
As pointed out in commit ed01df, the quality loss due to frequent
conversion between RGB and YUV is too much when drawing OSD and
subtitles.
Fix this by staying in the same colorspace when drawing subtitles.
Render directly to RGB, without converting to YUV first.
The bad thing about packed RGB is that there are many pixel formats,
which would all require special code for blending. It's also completely
incompatible to planar YUV. Use planar RGB instead, which allows us to
reuse all code originally written for planar YUV. The only thing that
needs to be changed is the color conversion in the libass case. (In
exchange for simpler code, the image has to be copied, but this is
still much better than converting to YUV.)
Unfortunately, libswscale doesn't support planar RGB output. Add a hack
to sws_utils.c to handle conversion to planar RGB. In the common case,
when converting 32 bit per pixel RGB, calling swscale can be avoided
entirely.
The change in mp_image.c is needed to allocate GBRP images correctly.
(The issue with vo_x11 could be easily solved by always backing up the
same bounding box as the bitmap drawing RGB<->YUV conversion does, but
this commit is probably the better fix.)
2012-11-22 12:30:16 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
static int free_mp_sws(void *p)
|
|
|
|
{
|
|
|
|
struct mp_sws_context *ctx = p;
|
|
|
|
sws_freeContext(ctx->sws);
|
|
|
|
sws_freeFilter(ctx->src_filter);
|
|
|
|
sws_freeFilter(ctx->dst_filter);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// You're supposed to set your scaling parameters on the returned context.
|
|
|
|
// Free the context with talloc_free().
|
|
|
|
struct mp_sws_context *mp_sws_alloc(void *talloc_parent)
|
|
|
|
{
|
|
|
|
struct mp_sws_context *ctx = talloc_ptrtype(talloc_parent, ctx);
|
|
|
|
*ctx = (struct mp_sws_context) {
|
|
|
|
.flags = SWS_BILINEAR,
|
|
|
|
.contrast = 1 << 16, // 1.0 in 16.16 fixed point
|
|
|
|
.saturation = 1 << 16,
|
|
|
|
.force_reload = true,
|
2013-07-22 12:41:33 +00:00
|
|
|
.params = {SWS_PARAM_DEFAULT, SWS_PARAM_DEFAULT},
|
2013-07-18 11:17:56 +00:00
|
|
|
.cached = talloc_zero(ctx, struct mp_sws_context),
|
|
|
|
};
|
|
|
|
talloc_set_destructor(ctx, free_mp_sws);
|
|
|
|
return ctx;
|
|
|
|
}
|
draw_bmp: add RGB rendering to fix image quality issues
As pointed out in commit ed01df, the quality loss due to frequent
conversion between RGB and YUV is too much when drawing OSD and
subtitles.
Fix this by staying in the same colorspace when drawing subtitles.
Render directly to RGB, without converting to YUV first.
The bad thing about packed RGB is that there are many pixel formats,
which would all require special code for blending. It's also completely
incompatible to planar YUV. Use planar RGB instead, which allows us to
reuse all code originally written for planar YUV. The only thing that
needs to be changed is the color conversion in the libass case. (In
exchange for simpler code, the image has to be copied, but this is
still much better than converting to YUV.)
Unfortunately, libswscale doesn't support planar RGB output. Add a hack
to sws_utils.c to handle conversion to planar RGB. In the common case,
when converting 32 bit per pixel RGB, calling swscale can be avoided
entirely.
The change in mp_image.c is needed to allocate GBRP images correctly.
(The issue with vo_x11 could be easily solved by always backing up the
same bounding box as the bitmap drawing RGB<->YUV conversion does, but
this commit is probably the better fix.)
2012-11-22 12:30:16 +00:00
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
// Reinitialize (if needed) - return error code.
|
|
|
|
// Optional, but possibly useful to avoid having to handle mp_sws_scale errors.
|
|
|
|
int mp_sws_reinit(struct mp_sws_context *ctx)
|
2012-11-24 23:06:16 +00:00
|
|
|
{
|
2013-07-18 11:17:56 +00:00
|
|
|
if (cache_valid(ctx))
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
sws_freeContext(ctx->sws);
|
|
|
|
ctx->sws = sws_alloc_context();
|
|
|
|
if (!ctx->sws)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
struct mp_image_params *src = &ctx->src;
|
|
|
|
struct mp_image_params *dst = &ctx->dst;
|
|
|
|
|
|
|
|
mp_image_params_guess_csp(src); // sanitize colorspace/colorlevels
|
|
|
|
mp_image_params_guess_csp(dst);
|
|
|
|
|
|
|
|
struct mp_imgfmt_desc src_fmt = mp_imgfmt_get_desc(src->imgfmt);
|
|
|
|
struct mp_imgfmt_desc dst_fmt = mp_imgfmt_get_desc(dst->imgfmt);
|
|
|
|
if (!src_fmt.id || !dst_fmt.id)
|
|
|
|
return -1;
|
|
|
|
|
2012-10-27 16:06:09 +00:00
|
|
|
enum PixelFormat s_fmt = imgfmt2pixfmt(src->imgfmt);
|
2013-07-18 11:17:56 +00:00
|
|
|
if (s_fmt == PIX_FMT_NONE || sws_isSupportedInput(s_fmt) < 1)
|
|
|
|
return -1;
|
2012-10-27 16:06:09 +00:00
|
|
|
|
|
|
|
enum PixelFormat d_fmt = imgfmt2pixfmt(dst->imgfmt);
|
2013-07-18 11:17:56 +00:00
|
|
|
if (d_fmt == PIX_FMT_NONE || sws_isSupportedOutput(d_fmt) < 1)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
int s_csp = mp_csp_to_sws_colorspace(src->colorspace);
|
|
|
|
int s_range = src->colorlevels == MP_CSP_LEVELS_PC;
|
|
|
|
|
|
|
|
int d_csp = mp_csp_to_sws_colorspace(dst->colorspace);
|
|
|
|
int d_range = dst->colorlevels == MP_CSP_LEVELS_PC;
|
2012-10-27 16:06:09 +00:00
|
|
|
|
|
|
|
// Work around libswscale bug #1852 (fixed in ffmpeg commit 8edf9b1fa):
|
|
|
|
// setting range flags for RGB gives random bogus results.
|
|
|
|
// Newer libswscale always ignores range flags for RGB.
|
2013-07-18 11:17:56 +00:00
|
|
|
s_range = s_range && (src_fmt.flags & MP_IMGFLAG_YUV);
|
|
|
|
d_range = d_range && (dst_fmt.flags & MP_IMGFLAG_YUV);
|
2012-10-27 16:06:09 +00:00
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
av_opt_set_int(ctx->sws, "sws_flags", ctx->flags, 0);
|
2012-10-27 16:06:09 +00:00
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
av_opt_set_int(ctx->sws, "srcw", src->w, 0);
|
|
|
|
av_opt_set_int(ctx->sws, "srch", src->h, 0);
|
|
|
|
av_opt_set_int(ctx->sws, "src_format", s_fmt, 0);
|
2012-10-27 16:06:09 +00:00
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
av_opt_set_int(ctx->sws, "dstw", dst->w, 0);
|
|
|
|
av_opt_set_int(ctx->sws, "dsth", dst->h, 0);
|
|
|
|
av_opt_set_int(ctx->sws, "dst_format", d_fmt, 0);
|
2012-10-27 16:06:09 +00:00
|
|
|
|
2013-07-22 12:41:33 +00:00
|
|
|
av_opt_set_double(ctx->sws, "param0", ctx->params[0], 0);
|
|
|
|
av_opt_set_double(ctx->sws, "param1", ctx->params[1], 0);
|
|
|
|
|
2013-07-25 21:02:23 +00:00
|
|
|
#if HAVE_AVCODEC_CHROMA_POS_API
|
|
|
|
int cr_src = mp_chroma_location_to_av(src->chroma_location);
|
|
|
|
int cr_dst = mp_chroma_location_to_av(dst->chroma_location);
|
|
|
|
int cr_xpos, cr_ypos;
|
|
|
|
if (avcodec_enum_to_chroma_pos(&cr_xpos, &cr_ypos, cr_src) >= 0) {
|
|
|
|
av_opt_set_int(ctx->sws, "src_h_chr_pos", cr_xpos, 0);
|
|
|
|
av_opt_set_int(ctx->sws, "src_v_chr_pos", cr_ypos, 0);
|
|
|
|
}
|
|
|
|
if (avcodec_enum_to_chroma_pos(&cr_xpos, &cr_ypos, cr_dst) >= 0) {
|
|
|
|
av_opt_set_int(ctx->sws, "dst_h_chr_pos", cr_xpos, 0);
|
|
|
|
av_opt_set_int(ctx->sws, "dst_v_chr_pos", cr_ypos, 0);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
// This can fail even with normal operation, e.g. if a conversion path
|
|
|
|
// simply does not support these settings.
|
|
|
|
sws_setColorspaceDetails(ctx->sws, sws_getCoefficients(s_csp), s_range,
|
2012-10-27 16:06:09 +00:00
|
|
|
sws_getCoefficients(d_csp), d_range,
|
2013-07-18 11:17:56 +00:00
|
|
|
ctx->brightness, ctx->contrast, ctx->saturation);
|
|
|
|
|
|
|
|
if (sws_init_context(ctx->sws, ctx->src_filter, ctx->dst_filter) < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
ctx->force_reload = false;
|
|
|
|
*ctx->cached = *ctx;
|
|
|
|
return 1;
|
2012-11-24 23:06:16 +00:00
|
|
|
}
|
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
// Scale from src to dst - if src/dst have different parameters from previous
|
|
|
|
// calls, the context is reinitialized. Return error code. (It can fail if
|
|
|
|
// reinitialization was necessary, and swscale returned an error.)
|
|
|
|
int mp_sws_scale(struct mp_sws_context *ctx, struct mp_image *dst,
|
|
|
|
struct mp_image *src)
|
2012-11-24 23:06:16 +00:00
|
|
|
{
|
2013-07-18 11:17:56 +00:00
|
|
|
// Hack for older swscale versions which don't support this.
|
|
|
|
// We absolutely need this in the OSD rendering path.
|
2013-01-26 20:04:35 +00:00
|
|
|
if (dst->imgfmt == IMGFMT_GBRP && !sws_isSupportedOutput(PIX_FMT_GBRP))
|
2013-07-18 11:17:56 +00:00
|
|
|
return to_gbrp(dst, src, ctx->flags);
|
2012-11-24 23:06:16 +00:00
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
mp_image_params_from_image(&ctx->src, src);
|
|
|
|
mp_image_params_from_image(&ctx->dst, dst);
|
2012-10-27 16:06:09 +00:00
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
int r = mp_sws_reinit(ctx);
|
|
|
|
if (r < 0) {
|
|
|
|
mp_msg(MSGT_VFILTER, MSGL_ERR, "libswscale initialization failed.\n");
|
|
|
|
return r;
|
|
|
|
}
|
2012-10-24 17:11:42 +00:00
|
|
|
|
2013-07-18 11:17:56 +00:00
|
|
|
sws_scale(ctx->sws, (const uint8_t *const *) src->planes, src->stride,
|
2012-10-27 16:06:09 +00:00
|
|
|
0, src->h, dst->planes, dst->stride);
|
2013-07-18 11:17:56 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void mp_image_swscale(struct mp_image *dst, struct mp_image *src,
|
|
|
|
int my_sws_flags)
|
|
|
|
{
|
|
|
|
struct mp_sws_context *ctx = mp_sws_alloc(NULL);
|
|
|
|
ctx->flags = my_sws_flags;
|
|
|
|
mp_sws_scale(ctx, dst, src);
|
|
|
|
talloc_free(ctx);
|
2012-10-24 17:11:42 +00:00
|
|
|
}
|
|
|
|
|
2012-11-24 23:06:16 +00:00
|
|
|
void mp_image_sw_blur_scale(struct mp_image *dst, struct mp_image *src,
|
|
|
|
float gblur)
|
|
|
|
{
|
2013-07-18 11:17:56 +00:00
|
|
|
struct mp_sws_context *ctx = mp_sws_alloc(NULL);
|
2013-07-18 11:48:57 +00:00
|
|
|
ctx->flags = mp_sws_hq_flags;
|
2013-07-18 11:17:56 +00:00
|
|
|
ctx->src_filter = sws_getDefaultFilter(gblur, gblur, 0, 0, 0, 0, 0);
|
|
|
|
ctx->force_reload = true;
|
|
|
|
mp_sws_scale(ctx, dst, src);
|
|
|
|
talloc_free(ctx);
|
2012-11-24 23:06:16 +00:00
|
|
|
}
|
|
|
|
|
2012-10-24 17:00:49 +00:00
|
|
|
// vim: ts=4 sw=4 et tw=80
|