swscale: call handle_format() from the functions that need it

This should fix some hypothetical issues with alloc/init_context() usage

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-07-14 03:35:34 +02:00
parent 0fc11e7bad
commit c75dde6074

View File

@ -939,11 +939,15 @@ int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],
int srcRange, const int table[4], int dstRange, int srcRange, const int table[4], int dstRange,
int brightness, int contrast, int saturation) int brightness, int contrast, int saturation)
{ {
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(c->dstFormat); const AVPixFmtDescriptor *desc_dst;
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(c->srcFormat); const AVPixFmtDescriptor *desc_src;
memcpy(c->srcColorspaceTable, inv_table, sizeof(int) * 4); memcpy(c->srcColorspaceTable, inv_table, sizeof(int) * 4);
memcpy(c->dstColorspaceTable, table, sizeof(int) * 4); memcpy(c->dstColorspaceTable, table, sizeof(int) * 4);
handle_formats(c);
desc_dst = av_pix_fmt_desc_get(c->dstFormat);
desc_src = av_pix_fmt_desc_get(c->srcFormat);
if(!isYUV(c->dstFormat) && !isGray(c->dstFormat)) if(!isYUV(c->dstFormat) && !isGray(c->dstFormat))
dstRange = 0; dstRange = 0;
if(!isYUV(c->srcFormat) && !isGray(c->srcFormat)) if(!isYUV(c->srcFormat) && !isGray(c->srcFormat))
@ -1076,8 +1080,8 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
int flags, cpu_flags; int flags, cpu_flags;
enum AVPixelFormat srcFormat = c->srcFormat; enum AVPixelFormat srcFormat = c->srcFormat;
enum AVPixelFormat dstFormat = c->dstFormat; enum AVPixelFormat dstFormat = c->dstFormat;
const AVPixFmtDescriptor *desc_src = av_pix_fmt_desc_get(srcFormat); const AVPixFmtDescriptor *desc_src;
const AVPixFmtDescriptor *desc_dst = av_pix_fmt_desc_get(dstFormat); const AVPixFmtDescriptor *desc_dst;
cpu_flags = av_get_cpu_flags(); cpu_flags = av_get_cpu_flags();
flags = c->flags; flags = c->flags;
@ -1087,19 +1091,15 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
unscaled = (srcW == dstW && srcH == dstH); unscaled = (srcW == dstW && srcH == dstH);
handle_jpeg(&srcFormat); handle_jpeg(&c->srcFormat);
handle_jpeg(&dstFormat); handle_jpeg(&c->dstFormat);
if(srcFormat!=c->srcFormat || dstFormat!=c->dstFormat) if(srcFormat!=c->srcFormat || dstFormat!=c->dstFormat)
av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make sure you did set range correctly\n"); av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make sure you did set range correctly\n");
handle_0alpha(&srcFormat); handle_formats(c);
handle_0alpha(&dstFormat); srcFormat = c->srcFormat;
handle_xyz(&srcFormat); dstFormat = c->dstFormat;
handle_xyz(&dstFormat); desc_src = av_pix_fmt_desc_get(srcFormat);
desc_dst = av_pix_fmt_desc_get(dstFormat);
if(srcFormat!=c->srcFormat || dstFormat!=c->dstFormat){
c->srcFormat= srcFormat;
c->dstFormat= dstFormat;
}
if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) && if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) &&
av_pix_fmt_swap_endianness(srcFormat) == dstFormat)) { av_pix_fmt_swap_endianness(srcFormat) == dstFormat)) {
@ -1590,7 +1590,6 @@ SwsContext *sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat,
c->dstRange = handle_jpeg(&dstFormat); c->dstRange = handle_jpeg(&dstFormat);
c->srcFormat = srcFormat; c->srcFormat = srcFormat;
c->dstFormat = dstFormat; c->dstFormat = dstFormat;
handle_formats(c);
if (param) { if (param) {
c->param[0] = param[0]; c->param[0] = param[0];
@ -2034,7 +2033,6 @@ struct SwsContext *sws_getCachedContext(struct SwsContext *context, int srcW,
context->dstH = dstH; context->dstH = dstH;
context->dstRange = handle_jpeg(&dstFormat); context->dstRange = handle_jpeg(&dstFormat);
context->dstFormat = dstFormat; context->dstFormat = dstFormat;
handle_formats(context);
context->flags = flags; context->flags = flags;
context->param[0] = param[0]; context->param[0] = param[0];
context->param[1] = param[1]; context->param[1] = param[1];