00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "libavutil/imgutils.h"
00020 #include "lswsutils.h"
00021
00022 int ff_scale_image(uint8_t *dst_data[4], int dst_linesize[4],
00023 int dst_w, int dst_h, enum PixelFormat dst_pix_fmt,
00024 uint8_t * const src_data[4], int src_linesize[4],
00025 int src_w, int src_h, enum PixelFormat src_pix_fmt,
00026 void *log_ctx)
00027 {
00028 int ret;
00029 struct SwsContext *sws_ctx = sws_getContext(src_w, src_h, src_pix_fmt,
00030 dst_w, dst_h, dst_pix_fmt,
00031 SWS_BILINEAR, NULL, NULL, NULL);
00032 if (!sws_ctx) {
00033 av_log(log_ctx, AV_LOG_ERROR,
00034 "Impossible to create scale context for the conversion "
00035 "fmt:%s s:%dx%d -> fmt:%s s:%dx%d\n",
00036 av_get_pix_fmt_name(src_pix_fmt), src_w, src_h,
00037 av_get_pix_fmt_name(dst_pix_fmt), dst_w, dst_h);
00038 ret = AVERROR(EINVAL);
00039 goto end;
00040 }
00041
00042 if ((ret = av_image_alloc(dst_data, dst_linesize, dst_w, dst_h, dst_pix_fmt, 16)) < 0)
00043 goto end;
00044 ret = 0;
00045 sws_scale(sws_ctx, src_data, src_linesize, 0, src_h, dst_data, dst_linesize);
00046
00047 end:
00048 sws_freeContext(sws_ctx);
00049 return ret;
00050 }