mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2026-03-13 09:00:40 +08:00
swscale: don't hard code number of scaler params
In case we ever need to increase this number in the future. I won't bother bumping the ABI version for this new #define, since it doesn't affect ABI, and I'm about to bump the ABI version in a following commit. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
@@ -524,8 +524,8 @@ static int add_legacy_sws_pass(SwsGraph *graph, const SwsFormat *src,
|
||||
legacy_chr_pos(graph, &sws->dst_h_chr_pos, ctx->dst_h_chr_pos, &warned);
|
||||
legacy_chr_pos(graph, &sws->dst_v_chr_pos, ctx->dst_v_chr_pos, &warned);
|
||||
|
||||
sws->scaler_params[0] = ctx->scaler_params[0];
|
||||
sws->scaler_params[1] = ctx->scaler_params[1];
|
||||
for (int i = 0; i < SWS_NUM_SCALER_PARAMS; i++)
|
||||
sws->scaler_params[i] = ctx->scaler_params[i];
|
||||
|
||||
ret = sws_init_context(sws, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
|
||||
@@ -204,7 +204,8 @@ typedef struct SwsContext {
|
||||
/**
|
||||
* Extra parameters for fine-tuning certain scalers.
|
||||
*/
|
||||
double scaler_params[2];
|
||||
#define SWS_NUM_SCALER_PARAMS 2
|
||||
double scaler_params[SWS_NUM_SCALER_PARAMS];
|
||||
|
||||
/**
|
||||
* How many threads to use for processing, or 0 for automatic selection.
|
||||
|
||||
@@ -87,10 +87,8 @@ static SwsContext *alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcForm
|
||||
sws->src_format = srcFormat;
|
||||
sws->dst_format = dstFormat;
|
||||
|
||||
if (param) {
|
||||
sws->scaler_params[0] = param[0];
|
||||
sws->scaler_params[1] = param[1];
|
||||
}
|
||||
for (int i = 0; param && i < SWS_NUM_SCALER_PARAMS; i++)
|
||||
sws->scaler_params[i] = param[i];
|
||||
|
||||
return sws;
|
||||
}
|
||||
@@ -200,7 +198,7 @@ static av_cold int initFilter(int16_t **outFilter, int32_t **filterPos,
|
||||
int dstW, int filterAlign, int one,
|
||||
int flags, int cpu_flags,
|
||||
SwsVector *srcFilter, SwsVector *dstFilter,
|
||||
double param[2], int srcPos, int dstPos)
|
||||
double param[SWS_NUM_SCALER_PARAMS], int srcPos, int dstPos)
|
||||
{
|
||||
int i;
|
||||
int filterSize;
|
||||
@@ -2375,8 +2373,8 @@ SwsContext *sws_getCachedContext(SwsContext *prev, int srcW,
|
||||
prev->dst_h == dstH &&
|
||||
prev->dst_format == dstFormat &&
|
||||
prev->flags == flags &&
|
||||
prev->scaler_params[0] == param[0] &&
|
||||
prev->scaler_params[1] == param[1])) {
|
||||
!memcmp(prev->scaler_params, param,
|
||||
sizeof(prev->scaler_params)))) {
|
||||
return prev;
|
||||
}
|
||||
|
||||
@@ -2397,8 +2395,8 @@ SwsContext *sws_getCachedContext(SwsContext *prev, int srcW,
|
||||
sws->dst_h = dstH;
|
||||
sws->dst_format = dstFormat;
|
||||
sws->flags = flags;
|
||||
sws->scaler_params[0] = param[0];
|
||||
sws->scaler_params[1] = param[1];
|
||||
for (int i = 0; i < SWS_NUM_SCALER_PARAMS; i++)
|
||||
sws->scaler_params[i] = param[i];
|
||||
|
||||
if (sws_init_context(sws, srcFilter, dstFilter) < 0)
|
||||
sws_free_context(&sws);
|
||||
|
||||
Reference in New Issue
Block a user