/*! convert/scale between an input and an output format. * Old version of ffmpeg only have img_convert, which does not rescale. * New versions use sws_scale which does both. */ static void my_scale(struct fbuf_t *in, AVPicture *p_in, struct fbuf_t *out, AVPicture *p_out) { AVPicture my_p_in, my_p_out; int eff_w=out->w, eff_h=out->h; if (p_in == NULL) p_in = fill_pict(in, &my_p_in); if (p_out == NULL) p_out = fill_pict(out, &my_p_out); /*if win_w is different from zero then we must change the size of the scaled buffer (the position is already encoded into the out parameter)*/ if (out->win_w) { /* picture in picture enabled */ eff_w=out->win_w; eff_h=out->win_h; } #ifdef OLD_FFMPEG /* XXX img_convert is deprecated, and does not do rescaling, PiP not supported */ img_convert(p_out, out->pix_fmt, p_in, in->pix_fmt, in->w, in->h); #else /* XXX replacement */ { struct SwsContext *convert_ctx; convert_ctx = sws_getContext(in->w, in->h, in->pix_fmt, eff_w, eff_h, out->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL); if (convert_ctx == NULL) { ast_log(LOG_ERROR, "FFMPEG::convert_cmodel : swscale context initialization failed"); return; } if (0) ast_log(LOG_WARNING, "in %d %dx%d out %d %dx%d\n", in->pix_fmt, in->w, in->h, out->pix_fmt, eff_w, eff_h); sws_scale(convert_ctx, p_in->data, p_in->linesize, in->w, in->h, /* src slice */ p_out->data, p_out->linesize); sws_freeContext(convert_ctx); } #endif /* XXX replacement */ }
/*! convert/scale between an input and an output format. * Old version of ffmpeg only have img_convert, which does not rescale. * New versions use sws_scale which does both. */ static void my_scale(struct fbuf_t *in, AVPicture *p_in, struct fbuf_t *out, AVPicture *p_out) { AVPicture my_p_in, my_p_out; if (p_in == NULL) p_in = fill_pict(in, &my_p_in); if (p_out == NULL) p_out = fill_pict(out, &my_p_out); #ifdef OLD_FFMPEG /* XXX img_convert is deprecated, and does not do rescaling */ img_convert(p_out, out->pix_fmt, p_in, in->pix_fmt, in->w, in->h); #else /* XXX replacement */ { struct SwsContext *convert_ctx; convert_ctx = sws_getContext(in->w, in->h, in->pix_fmt, out->w, out->h, out->pix_fmt, SWS_BICUBIC, NULL, NULL, NULL); if (convert_ctx == NULL) { ast_log(LOG_ERROR, "FFMPEG::convert_cmodel : swscale context initialization failed"); return; } if (0) ast_log(LOG_WARNING, "in %d %dx%d out %d %dx%d\n", in->pix_fmt, in->w, in->h, out->pix_fmt, out->w, out->h); sws_scale(convert_ctx, p_in->data, p_in->linesize, in->w, in->h, /* src slice */ p_out->data, p_out->linesize); sws_freeContext(convert_ctx); } #endif /* XXX replacement */ }