aboutsummaryrefslogtreecommitdiffstats
path: root/libswscale/utils.c
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-10-10 12:16:44 +0200
committerNiklas Haas <git@haasn.dev>2024-11-21 12:49:56 +0100
commit2d077f9acda4946b3455ded5778fb3fc7e85bba2 (patch)
tree44ab5d5889e65b4067fbe54f4e7966a31f4c9f13 /libswscale/utils.c
parent10d1be262126f1699a89b54cf5f23a5370c57cb5 (diff)
downloadffmpeg-2d077f9acda4946b3455ded5778fb3fc7e85bba2.tar.gz
swscale/internal: group user-facing options together
This is a preliminary step to separating these into a new struct. This commit contains no functional changes, it is a pure search-and-replace. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
Diffstat (limited to 'libswscale/utils.c')
-rw-r--r--libswscale/utils.c275
1 files changed, 142 insertions, 133 deletions
diff --git a/libswscale/utils.c b/libswscale/utils.c
index f71c63c17f..465302a9fa 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -298,17 +298,17 @@ static SwsContext *alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcForm
if (!c)
return NULL;
- c->flags = flags;
- c->srcW = srcW;
- c->srcH = srcH;
- c->dstW = dstW;
- c->dstH = dstH;
- c->srcFormat = srcFormat;
- c->dstFormat = dstFormat;
+ c->opts.flags = flags;
+ c->opts.src_w = srcW;
+ c->opts.src_h = srcH;
+ c->opts.dst_w = dstW;
+ c->opts.dst_h = dstH;
+ c->opts.src_format = srcFormat;
+ c->opts.dst_format = dstFormat;
if (param) {
- c->param[0] = param[0];
- c->param[1] = param[1];
+ c->opts.scaler_params[0] = param[0];
+ c->opts.scaler_params[1] = param[1];
}
return sws;
@@ -1030,10 +1030,10 @@ static int handle_xyz(enum AVPixelFormat *format)
static void handle_formats(SwsInternal *c)
{
- c->src0Alpha |= handle_0alpha(&c->srcFormat);
- c->dst0Alpha |= handle_0alpha(&c->dstFormat);
- c->srcXYZ |= handle_xyz(&c->srcFormat);
- c->dstXYZ |= handle_xyz(&c->dstFormat);
+ c->src0Alpha |= handle_0alpha(&c->opts.src_format);
+ c->dst0Alpha |= handle_0alpha(&c->opts.dst_format);
+ c->srcXYZ |= handle_xyz(&c->opts.src_format);
+ c->dstXYZ |= handle_xyz(&c->opts.dst_format);
if (c->srcXYZ || c->dstXYZ)
fill_xyztables(c);
}
@@ -1066,16 +1066,16 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4],
}
handle_formats(c);
- desc_dst = av_pix_fmt_desc_get(c->dstFormat);
- desc_src = av_pix_fmt_desc_get(c->srcFormat);
+ desc_dst = av_pix_fmt_desc_get(c->opts.dst_format);
+ desc_src = av_pix_fmt_desc_get(c->opts.src_format);
- if(range_override_needed(c->dstFormat))
+ if(range_override_needed(c->opts.dst_format))
dstRange = 0;
- if(range_override_needed(c->srcFormat))
+ if(range_override_needed(c->opts.src_format))
srcRange = 0;
- if (c->srcRange != srcRange ||
- c->dstRange != dstRange ||
+ if (c->opts.src_range != srcRange ||
+ c->opts.dst_range != dstRange ||
c->brightness != brightness ||
c->contrast != contrast ||
c->saturation != saturation ||
@@ -1092,8 +1092,8 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4],
c->brightness = brightness;
c->contrast = contrast;
c->saturation = saturation;
- c->srcRange = srcRange;
- c->dstRange = dstRange;
+ c->opts.src_range = srcRange;
+ c->opts.dst_range = dstRange;
if (need_reinit)
ff_sws_init_range_convert(c);
@@ -1107,27 +1107,27 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4],
if (!need_reinit)
return 0;
- if ((isYUV(c->dstFormat) || isGray(c->dstFormat)) && (isYUV(c->srcFormat) || isGray(c->srcFormat))) {
+ if ((isYUV(c->opts.dst_format) || isGray(c->opts.dst_format)) && (isYUV(c->opts.src_format) || isGray(c->opts.src_format))) {
if (!c->cascaded_context[0] &&
memcmp(c->dstColorspaceTable, c->srcColorspaceTable, sizeof(int) * 4) &&
- c->srcW && c->srcH && c->dstW && c->dstH) {
+ c->opts.src_w && c->opts.src_h && c->opts.dst_w && c->opts.dst_h) {
enum AVPixelFormat tmp_format;
int tmp_width, tmp_height;
- int srcW = c->srcW;
- int srcH = c->srcH;
- int dstW = c->dstW;
- int dstH = c->dstH;
+ int srcW = c->opts.src_w;
+ int srcH = c->opts.src_h;
+ int dstW = c->opts.dst_w;
+ int dstH = c->opts.dst_h;
int ret;
av_log(c, AV_LOG_VERBOSE, "YUV color matrix differs for YUV->YUV, using intermediate RGB to convert\n");
- if (isNBPS(c->dstFormat) || is16BPS(c->dstFormat)) {
- if (isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) {
+ if (isNBPS(c->opts.dst_format) || is16BPS(c->opts.dst_format)) {
+ if (isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) {
tmp_format = AV_PIX_FMT_BGRA64;
} else {
tmp_format = AV_PIX_FMT_BGR48;
}
} else {
- if (isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) {
+ if (isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) {
tmp_format = AV_PIX_FMT_BGRA;
} else {
tmp_format = AV_PIX_FMT_BGR24;
@@ -1147,13 +1147,14 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4],
if (ret < 0)
return ret;
- c->cascaded_context[0] = alloc_set_opts(srcW, srcH, c->srcFormat,
+ c->cascaded_context[0] = alloc_set_opts(srcW, srcH, c->opts.src_format,
tmp_width, tmp_height, tmp_format,
- c->flags, c->param);
+ c->opts.flags,
+ c->opts.scaler_params);
if (!c->cascaded_context[0])
return -1;
- sws_internal(c->cascaded_context[0])->alphablend = c->alphablend;
+ sws_internal(c->cascaded_context[0])->opts.alpha_blend = c->opts.alpha_blend;
ret = sws_init_context(c->cascaded_context[0], NULL , NULL);
if (ret < 0)
return ret;
@@ -1163,12 +1164,13 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4],
brightness, contrast, saturation);
c->cascaded_context[1] = alloc_set_opts(tmp_width, tmp_height, tmp_format,
- dstW, dstH, c->dstFormat,
- c->flags, c->param);
+ dstW, dstH, c->opts.dst_format,
+ c->opts.flags,
+ c->opts.scaler_params);
if (!c->cascaded_context[1])
return -1;
- sws_internal(c->cascaded_context[1])->srcRange = srcRange;
- sws_internal(c->cascaded_context[1])->dstRange = dstRange;
+ sws_internal(c->cascaded_context[1])->opts.src_range = srcRange;
+ sws_internal(c->cascaded_context[1])->opts.dst_range = dstRange;
ret = sws_init_context(c->cascaded_context[1], NULL , NULL);
if (ret < 0)
return ret;
@@ -1183,7 +1185,7 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4],
return 0;
}
- if (!isYUV(c->dstFormat) && !isGray(c->dstFormat)) {
+ if (!isYUV(c->opts.dst_format) && !isGray(c->opts.dst_format)) {
ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness,
contrast, saturation);
// FIXME factorize
@@ -1215,8 +1217,8 @@ int sws_getColorspaceDetails(SwsContext *sws, int **inv_table,
*inv_table = c->srcColorspaceTable;
*table = c->dstColorspaceTable;
- *srcRange = range_override_needed(c->srcFormat) ? 1 : c->srcRange;
- *dstRange = range_override_needed(c->dstFormat) ? 1 : c->dstRange;
+ *srcRange = range_override_needed(c->opts.src_format) ? 1 : c->opts.src_range;
+ *dstRange = range_override_needed(c->opts.dst_format) ? 1 : c->opts.dst_range;
*brightness = c->brightness;
*contrast = c->contrast;
*saturation = c->saturation;
@@ -1229,7 +1231,7 @@ SwsContext *sws_alloc_context(void)
SwsInternal *c = av_mallocz(sizeof(SwsInternal));
if (c) {
- c->av_class = &ff_sws_context_class;
+ c->opts.av_class = &ff_sws_context_class;
av_opt_set_defaults(c);
atomic_init(&c->stride_unaligned_warned, 0);
atomic_init(&c->data_unaligned_warned, 0);
@@ -1321,10 +1323,10 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
int unscaled;
SwsInternal *c = sws_internal(sws);
SwsFilter dummyFilter = { NULL, NULL, NULL, NULL };
- int srcW = c->srcW;
- int srcH = c->srcH;
- int dstW = c->dstW;
- int dstH = c->dstH;
+ int srcW = c->opts.src_w;
+ int srcH = c->opts.src_h;
+ int dstW = c->opts.dst_w;
+ int dstH = c->opts.dst_h;
int dst_stride = FFALIGN(dstW * sizeof(int16_t) + 66, 16);
int flags, cpu_flags;
enum AVPixelFormat srcFormat, dstFormat;
@@ -1335,25 +1337,25 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
static const float float_mult = 1.0f / 255.0f;
cpu_flags = av_get_cpu_flags();
- flags = c->flags;
+ flags = c->opts.flags;
emms_c();
unscaled = (srcW == dstW && srcH == dstH);
if (!c->contrast && !c->saturation && !c->dstFormatBpp)
- sws_setColorspaceDetails(sws, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->srcRange,
+ sws_setColorspaceDetails(sws, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->opts.src_range,
ff_yuv2rgb_coeffs[SWS_CS_DEFAULT],
- c->dstRange, 0, 1 << 16, 1 << 16);
+ c->opts.dst_range, 0, 1 << 16, 1 << 16);
handle_formats(c);
- srcFormat = c->srcFormat;
- dstFormat = c->dstFormat;
+ srcFormat = c->opts.src_format;
+ dstFormat = c->opts.dst_format;
desc_src = av_pix_fmt_desc_get(srcFormat);
desc_dst = av_pix_fmt_desc_get(dstFormat);
// If the source has no alpha then disable alpha blendaway
if (c->src0Alpha)
- c->alphablend = SWS_ALPHA_BLEND_NONE;
+ c->opts.alpha_blend = SWS_ALPHA_BLEND_NONE;
if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) &&
av_pix_fmt_swap_endianness(srcFormat) == dstFormat)) {
@@ -1390,7 +1392,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
flags |= SWS_BICUBIC;
else
flags |= SWS_BICUBIC;
- c->flags = flags;
+ c->opts.flags = flags;
} else if (i & (i - 1)) {
av_log(c, AV_LOG_ERROR,
"Exactly one scaler algorithm must be chosen, got %X\n", i);
@@ -1407,7 +1409,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
if (flags & SWS_FAST_BILINEAR) {
if (srcW < 8 || dstW < 8) {
flags ^= SWS_FAST_BILINEAR | SWS_BILINEAR;
- c->flags = flags;
+ c->opts.flags = flags;
}
}
@@ -1440,46 +1442,46 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
if (dstW&1) {
av_log(c, AV_LOG_DEBUG, "Forcing full internal H chroma due to odd output size\n");
flags |= SWS_FULL_CHR_H_INT;
- c->flags = flags;
+ c->opts.flags = flags;
}
if ( c->chrSrcHSubSample == 0
&& c->chrSrcVSubSample == 0
- && c->dither != SWS_DITHER_BAYER //SWS_FULL_CHR_H_INT is currently not supported with SWS_DITHER_BAYER
- && !(c->flags & SWS_FAST_BILINEAR)
+ && c->opts.dither != SWS_DITHER_BAYER //SWS_FULL_CHR_H_INT is currently not supported with SWS_DITHER_BAYER
+ && !(c->opts.flags & SWS_FAST_BILINEAR)
) {
av_log(c, AV_LOG_DEBUG, "Forcing full internal H chroma due to input having non subsampled chroma\n");
flags |= SWS_FULL_CHR_H_INT;
- c->flags = flags;
+ c->opts.flags = flags;
}
}
- if (c->dither == SWS_DITHER_AUTO) {
+ if (c->opts.dither == SWS_DITHER_AUTO) {
if (flags & SWS_ERROR_DIFFUSION)
- c->dither = SWS_DITHER_ED;
+ c->opts.dither = SWS_DITHER_ED;
}
if(dstFormat == AV_PIX_FMT_BGR4_BYTE ||
dstFormat == AV_PIX_FMT_RGB4_BYTE ||
dstFormat == AV_PIX_FMT_BGR8 ||
dstFormat == AV_PIX_FMT_RGB8) {
- if (c->dither == SWS_DITHER_AUTO)
- c->dither = (flags & SWS_FULL_CHR_H_INT) ? SWS_DITHER_ED : SWS_DITHER_BAYER;
+ if (c->opts.dither == SWS_DITHER_AUTO)
+ c->opts.dither = (flags & SWS_FULL_CHR_H_INT) ? SWS_DITHER_ED : SWS_DITHER_BAYER;
if (!(flags & SWS_FULL_CHR_H_INT)) {
- if (c->dither == SWS_DITHER_ED || c->dither == SWS_DITHER_A_DITHER || c->dither == SWS_DITHER_X_DITHER || c->dither == SWS_DITHER_NONE) {
+ if (c->opts.dither == SWS_DITHER_ED || c->opts.dither == SWS_DITHER_A_DITHER || c->opts.dither == SWS_DITHER_X_DITHER || c->opts.dither == SWS_DITHER_NONE) {
av_log(c, AV_LOG_DEBUG,
"Desired dithering only supported in full chroma interpolation for destination format '%s'\n",
av_get_pix_fmt_name(dstFormat));
flags |= SWS_FULL_CHR_H_INT;
- c->flags = flags;
+ c->opts.flags = flags;
}
}
if (flags & SWS_FULL_CHR_H_INT) {
- if (c->dither == SWS_DITHER_BAYER) {
+ if (c->opts.dither == SWS_DITHER_BAYER) {
av_log(c, AV_LOG_DEBUG,
"Ordered dither is not supported in full chroma interpolation for destination format '%s'\n",
av_get_pix_fmt_name(dstFormat));
- c->dither = SWS_DITHER_ED;
+ c->opts.dither = SWS_DITHER_ED;
}
}
}
@@ -1489,7 +1491,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
"%s output is not supported with half chroma resolution, switching to full\n",
av_get_pix_fmt_name(dstFormat));
flags |= SWS_FULL_CHR_H_INT;
- c->flags = flags;
+ c->opts.flags = flags;
}
}
@@ -1523,7 +1525,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
"full chroma interpolation for destination format '%s' not yet implemented\n",
av_get_pix_fmt_name(dstFormat));
flags &= ~SWS_FULL_CHR_H_INT;
- c->flags = flags;
+ c->opts.flags = flags;
}
if (isAnyRGB(dstFormat) && !(flags & SWS_FULL_CHR_H_INT))
c->chrDstHSubSample = 1;
@@ -1585,7 +1587,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
av_log(c, AV_LOG_INFO,
"output width is not a multiple of 32 -> no MMXEXT scaler\n");
}
- if (usesHFilter || isNBPS(c->srcFormat) || is16BPS(c->srcFormat) || isAnyRGB(c->srcFormat))
+ if (usesHFilter || isNBPS(c->opts.src_format) || is16BPS(c->opts.src_format) || isAnyRGB(c->opts.src_format))
c->canMMXEXTBeUsed = 0;
} else
c->canMMXEXTBeUsed = 0;
@@ -1617,7 +1619,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
tmpFmt = AV_PIX_FMT_RGBA64LE;
- if (!unscaled && c->gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) {
+ if (!unscaled && c->opts.gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) {
SwsInternal *c2;
c->cascaded_context[0] = NULL;
@@ -1628,14 +1630,16 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat,
srcW, srcH, tmpFmt,
- flags, NULL, NULL, c->param);
+ flags, NULL, NULL,
+ c->opts.scaler_params);
if (!c->cascaded_context[0]) {
return AVERROR(ENOMEM);
}
c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFmt,
dstW, dstH, tmpFmt,
- flags, srcFilter, dstFilter, c->param);
+ flags, srcFilter, dstFilter,
+ c->opts.scaler_params);
if (!c->cascaded_context[1])
return AVERROR(ENOMEM);
@@ -1665,8 +1669,9 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
return ret;
c->cascaded_context[2] = sws_getContext(dstW, dstH, tmpFmt,
- dstW, dstH, dstFormat,
- flags, NULL, NULL, c->param);
+ dstW, dstH, dstFormat,
+ flags, NULL, NULL,
+ c->opts.scaler_params);
if (!c->cascaded_context[2])
return AVERROR(ENOMEM);
}
@@ -1686,13 +1691,15 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat,
srcW, srcH, tmpFormat,
- flags, srcFilter, NULL, c->param);
+ flags, srcFilter, NULL,
+ c->opts.scaler_params);
if (!c->cascaded_context[0])
return AVERROR(ENOMEM);
c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFormat,
dstW, dstH, dstFormat,
- flags, NULL, dstFilter, c->param);
+ flags, NULL, dstFilter,
+ c->opts.scaler_params);
if (!c->cascaded_context[1])
return AVERROR(ENOMEM);
return 0;
@@ -1715,11 +1722,11 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
if (CONFIG_SWSCALE_ALPHA && isALPHA(srcFormat) && !isALPHA(dstFormat)) {
enum AVPixelFormat tmpFormat = alphaless_fmt(srcFormat);
- if (tmpFormat != AV_PIX_FMT_NONE && c->alphablend != SWS_ALPHA_BLEND_NONE) {
+ if (tmpFormat != AV_PIX_FMT_NONE && c->opts.alpha_blend != SWS_ALPHA_BLEND_NONE) {
if (!unscaled ||
dstFormat != tmpFormat ||
usesHFilter || usesVFilter ||
- c->srcRange != c->dstRange
+ c->opts.src_range != c->opts.dst_range
) {
c->cascaded_mainindex = 1;
ret = av_image_alloc(c->cascaded_tmp[0], c->cascaded_tmpStride[0],
@@ -1729,22 +1736,22 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
c->cascaded_context[0] = alloc_set_opts(srcW, srcH, srcFormat,
srcW, srcH, tmpFormat,
- flags, c->param);
+ flags, c->opts.scaler_params);
if (!c->cascaded_context[0])
return AVERROR(EINVAL);
- sws_internal(c->cascaded_context[0])->alphablend = c->alphablend;
+ sws_internal(c->cascaded_context[0])->opts.alpha_blend = c->opts.alpha_blend;
ret = sws_init_context(c->cascaded_context[0], NULL , NULL);
if (ret < 0)
return ret;
c->cascaded_context[1] = alloc_set_opts(srcW, srcH, tmpFormat,
dstW, dstH, dstFormat,
- flags, c->param);
+ flags, c->opts.scaler_params);
if (!c->cascaded_context[1])
return AVERROR(EINVAL);
- sws_internal(c->cascaded_context[1])->srcRange = c->srcRange;
- sws_internal(c->cascaded_context[1])->dstRange = c->dstRange;
+ sws_internal(c->cascaded_context[1])->opts.src_range = c->opts.src_range;
+ sws_internal(c->cascaded_context[1])->opts.dst_range = c->opts.dst_range;
ret = sws_init_context(c->cascaded_context[1], srcFilter , dstFilter);
if (ret < 0)
return ret;
@@ -1756,9 +1763,9 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
/* alpha blend special case, note this has been split via cascaded contexts if its scaled */
if (unscaled && !usesHFilter && !usesVFilter &&
- c->alphablend != SWS_ALPHA_BLEND_NONE &&
+ c->opts.alpha_blend != SWS_ALPHA_BLEND_NONE &&
isALPHA(srcFormat) &&
- (c->srcRange == c->dstRange || isAnyRGB(dstFormat)) &&
+ (c->opts.src_range == c->opts.dst_range || isAnyRGB(dstFormat)) &&
alphaless_fmt(srcFormat) == dstFormat
) {
c->convert_unscaled = ff_sws_alphablendaway;
@@ -1772,7 +1779,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
/* unscaled special cases */
if (unscaled && !usesHFilter && !usesVFilter &&
- (c->srcRange == c->dstRange || isAnyRGB(dstFormat) ||
+ (c->opts.src_range == c->opts.dst_range || isAnyRGB(dstFormat) ||
isFloat(srcFormat) || isFloat(dstFormat) || isBayer(srcFormat))){
ff_get_unscaled_swscale(c);
@@ -1868,7 +1875,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
srcW, dstW, filterAlign, 1 << 14,
(flags & SWS_BICUBLIN) ? (flags | SWS_BICUBIC) : flags,
cpu_flags, srcFilter->lumH, dstFilter->lumH,
- c->param,
+ c->opts.scaler_params,
get_local_pos(c, 0, 0, 0),
get_local_pos(c, 0, 0, 0))) < 0)
goto fail;
@@ -1879,9 +1886,9 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
c->chrSrcW, c->chrDstW, filterAlign, 1 << 14,
(flags & SWS_BICUBLIN) ? (flags | SWS_BILINEAR) : flags,
cpu_flags, srcFilter->chrH, dstFilter->chrH,
- c->param,
- get_local_pos(c, c->chrSrcHSubSample, c->src_h_chr_pos, 0),
- get_local_pos(c, c->chrDstHSubSample, c->dst_h_chr_pos, 0))) < 0)
+ c->opts.scaler_params,
+ get_local_pos(c, c->chrSrcHSubSample, c->opts.src_h_chr_pos, 0),
+ get_local_pos(c, c->chrDstHSubSample, c->opts.dst_h_chr_pos, 0))) < 0)
goto fail;
if (ff_shuffle_filter_coefficients(c, c->hChrFilterPos, c->hChrFilterSize, c->hChrFilter, c->chrDstW) < 0)
goto nomem;
@@ -1898,7 +1905,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
c->lumYInc, srcH, dstH, filterAlign, (1 << 12),
(flags & SWS_BICUBLIN) ? (flags | SWS_BICUBIC) : flags,
cpu_flags, srcFilter->lumV, dstFilter->lumV,
- c->param,
+ c->opts.scaler_params,
get_local_pos(c, 0, 0, 1),
get_local_pos(c, 0, 0, 1))) < 0)
goto fail;
@@ -1907,18 +1914,18 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
filterAlign, (1 << 12),
(flags & SWS_BICUBLIN) ? (flags | SWS_BILINEAR) : flags,
cpu_flags, srcFilter->chrV, dstFilter->chrV,
- c->param,
- get_local_pos(c, c->chrSrcVSubSample, c->src_v_chr_pos, 1),
- get_local_pos(c, c->chrDstVSubSample, c->dst_v_chr_pos, 1))) < 0)
+ c->opts.scaler_params,
+ get_local_pos(c, c->chrSrcVSubSample, c->opts.src_v_chr_pos, 1),
+ get_local_pos(c, c->chrDstVSubSample, c->opts.dst_v_chr_pos, 1))) < 0)
goto fail;
#if HAVE_ALTIVEC
- if (!FF_ALLOC_TYPED_ARRAY(c->vYCoeffsBank, c->vLumFilterSize * c->dstH) ||
+ if (!FF_ALLOC_TYPED_ARRAY(c->vYCoeffsBank, c->vLumFilterSize * c->opts.dst_h) ||
!FF_ALLOC_TYPED_ARRAY(c->vCCoeffsBank, c->vChrFilterSize * c->chrDstH))
goto nomem;
- for (i = 0; i < c->vLumFilterSize * c->dstH; i++) {
+ for (i = 0; i < c->vLumFilterSize * c->opts.dst_h; i++) {
int j;
short *p = (short *)&c->vYCoeffsBank[i];
for (j = 0; j < 8; j++)
@@ -1935,10 +1942,10 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
}
for (i = 0; i < 4; i++)
- if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], c->dstW + 3))
+ if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], c->opts.dst_w + 3))
goto nomem;
- c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(c->srcFormat) && isALPHA(c->dstFormat)) ? 1 : 0;
+ c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) ? 1 : 0;
// 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate)
c->uv_off = (dst_stride>>1) + 64 / (c->dstBpc &~ 7);
@@ -1980,7 +1987,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter
av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
av_log(c, AV_LOG_DEBUG,
"lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
- c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
+ c->opts.src_w, c->opts.src_h, c->opts.dst_w, c->opts.dst_h, c->lumXInc, c->lumYInc);
av_log(c, AV_LOG_DEBUG,
"chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH,
@@ -2011,13 +2018,15 @@ fail: // FIXME replace things by appropriate error codes
c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat,
tmpW, tmpH, tmpFormat,
- flags, srcFilter, NULL, c->param);
+ flags, srcFilter, NULL,
+ c->opts.scaler_params);
if (!c->cascaded_context[0])
return AVERROR(ENOMEM);
c->cascaded_context[1] = sws_getContext(tmpW, tmpH, tmpFormat,
dstW, dstH, dstFormat,
- flags, NULL, dstFilter, c->param);
+ flags, NULL, dstFilter,
+ c->opts.scaler_params);
if (!c->cascaded_context[1])
return AVERROR(ENOMEM);
return 0;
@@ -2032,21 +2041,21 @@ static int context_init_threaded(SwsContext *sws,
int ret;
ret = avpriv_slicethread_create(&c->slicethread, (void*) sws,
- ff_sws_slice_worker, NULL, c->nb_threads);
+ ff_sws_slice_worker, NULL, c->opts.threads);
if (ret == AVERROR(ENOSYS)) {
- c->nb_threads = 1;
+ c->opts.threads = 1;
return 0;
} else if (ret < 0)
return ret;
- c->nb_threads = ret;
+ c->opts.threads = ret;
- c->slice_ctx = av_calloc(c->nb_threads, sizeof(*c->slice_ctx));
- c->slice_err = av_calloc(c->nb_threads, sizeof(*c->slice_err));
+ c->slice_ctx = av_calloc(c->opts.threads, sizeof(*c->slice_ctx));
+ c->slice_err = av_calloc(c->opts.threads, sizeof(*c->slice_err));
if (!c->slice_ctx || !c->slice_err)
return AVERROR(ENOMEM);
- for (int i = 0; i < c->nb_threads; i++) {
+ for (int i = 0; i < c->opts.threads; i++) {
SwsInternal *c2;
c->slice_ctx[i] = sws_alloc_context();
if (!c->slice_ctx[i])
@@ -2060,13 +2069,13 @@ static int context_init_threaded(SwsContext *sws,
if (ret < 0)
return ret;
- c2->nb_threads = 1;
+ c2->opts.threads = 1;
ret = sws_init_single_context(c->slice_ctx[i], src_filter, dst_filter);
if (ret < 0)
return ret;
- if (c2->dither == SWS_DITHER_ED) {
+ if (c2->opts.dither == SWS_DITHER_ED) {
av_log(c, AV_LOG_VERBOSE,
"Error-diffusion dither is in use, scaling will be single-threaded.");
break;
@@ -2092,17 +2101,17 @@ av_cold int sws_init_context(SwsContext *sws, SwsFilter *srcFilter,
if (ff_thread_once(&rgb2rgb_once, ff_sws_rgb2rgb_init) != 0)
return AVERROR_UNKNOWN;
- src_format = c->srcFormat;
- dst_format = c->dstFormat;
- c->srcRange |= handle_jpeg(&c->srcFormat);
- c->dstRange |= handle_jpeg(&c->dstFormat);
+ src_format = c->opts.src_format;
+ dst_format = c->opts.dst_format;
+ c->opts.src_range |= handle_jpeg(&c->opts.src_format);
+ c->opts.dst_range |= handle_jpeg(&c->opts.dst_format);
- if (src_format != c->srcFormat || dst_format != c->dstFormat)
+ if (src_format != c->opts.src_format || dst_format != c->opts.dst_format)
av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make sure you did set range correctly\n");
- if (c->nb_threads != 1) {
+ if (c->opts.threads != 1) {
ret = context_init_threaded(sws, srcFilter, dstFilter);
- if (ret < 0 || c->nb_threads > 1)
+ if (ret < 0 || c->opts.threads > 1)
return ret;
// threading disabled in this build, init as single-threaded
}
@@ -2546,15 +2555,15 @@ SwsContext *sws_getCachedContext(SwsContext *sws, int srcW,
param = default_param;
if ((context = sws_internal(sws)) &&
- (context->srcW != srcW ||
- context->srcH != srcH ||
- context->srcFormat != srcFormat ||
- context->dstW != dstW ||
- context->dstH != dstH ||
- context->dstFormat != dstFormat ||
- context->flags != flags ||
- context->param[0] != param[0] ||
- context->param[1] != param[1])) {
+ (context->opts.src_w != srcW ||
+ context->opts.src_h != srcH ||
+ context->opts.src_format != srcFormat ||
+ context->opts.dst_w != dstW ||
+ context->opts.dst_h != dstH ||
+ context->opts.dst_format != dstFormat ||
+ context->opts.flags != flags ||
+ context->opts.scaler_params[0] != param[0] ||
+ context->opts.scaler_params[1] != param[1])) {
av_opt_get_int(context, "src_h_chr_pos", 0, &src_h_chr_pos);
av_opt_get_int(context, "src_v_chr_pos", 0, &src_v_chr_pos);
@@ -2568,15 +2577,15 @@ SwsContext *sws_getCachedContext(SwsContext *sws, int srcW,
if (!(sws = sws_alloc_context()))
return NULL;
context = sws_internal(sws);
- context->srcW = srcW;
- context->srcH = srcH;
- context->srcFormat = srcFormat;
- context->dstW = dstW;
- context->dstH = dstH;
- context->dstFormat = dstFormat;
- context->flags = flags;
- context->param[0] = param[0];
- context->param[1] = param[1];
+ context->opts.src_w = srcW;
+ context->opts.src_h = srcH;
+ context->opts.src_format = srcFormat;
+ context->opts.dst_w = dstW;
+ context->opts.dst_h = dstH;
+ context->opts.dst_format = dstFormat;
+ context->opts.flags = flags;
+ context->opts.scaler_params[0] = param[0];
+ context->opts.scaler_params[1] = param[1];
av_opt_set_int(context, "src_h_chr_pos", src_h_chr_pos, 0);
av_opt_set_int(context, "src_v_chr_pos", src_v_chr_pos, 0);