Skip to content

Commit 2d077f9

Browse files
committed
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 <[email protected]>
1 parent 10d1be2 commit 2d077f9

36 files changed

+692
-680
lines changed

libswscale/aarch64/swscale.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@ static void ff_hscale16to15_4_neon(SwsInternal *c, int16_t *_dst, int dstW,
4545
const uint8_t *_src, const int16_t *filter,
4646
const int32_t *filterPos, int filterSize)
4747
{
48-
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
48+
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.src_format);
4949
int sh = desc->comp[0].depth - 1;
5050

5151
if (sh<15) {
52-
sh = isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : (desc->comp[0].depth - 1);
52+
sh = isAnyRGB(c->opts.src_format) || c->opts.src_format==AV_PIX_FMT_PAL8 ? 13 : (desc->comp[0].depth - 1);
5353
} else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
5454
sh = 16 - 1;
5555
}
@@ -61,11 +61,11 @@ static void ff_hscale16to15_X8_neon(SwsInternal *c, int16_t *_dst, int dstW,
6161
const uint8_t *_src, const int16_t *filter,
6262
const int32_t *filterPos, int filterSize)
6363
{
64-
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
64+
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.src_format);
6565
int sh = desc->comp[0].depth - 1;
6666

6767
if (sh<15) {
68-
sh = isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : (desc->comp[0].depth - 1);
68+
sh = isAnyRGB(c->opts.src_format) || c->opts.src_format==AV_PIX_FMT_PAL8 ? 13 : (desc->comp[0].depth - 1);
6969
} else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
7070
sh = 16 - 1;
7171
}
@@ -77,11 +77,11 @@ static void ff_hscale16to15_X4_neon(SwsInternal *c, int16_t *_dst, int dstW,
7777
const uint8_t *_src, const int16_t *filter,
7878
const int32_t *filterPos, int filterSize)
7979
{
80-
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
80+
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.src_format);
8181
int sh = desc->comp[0].depth - 1;
8282

8383
if (sh<15) {
84-
sh = isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8 ? 13 : (desc->comp[0].depth - 1);
84+
sh = isAnyRGB(c->opts.src_format) || c->opts.src_format==AV_PIX_FMT_PAL8 ? 13 : (desc->comp[0].depth - 1);
8585
} else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
8686
sh = 16 - 1;
8787
}
@@ -92,11 +92,11 @@ static void ff_hscale16to19_4_neon(SwsInternal *c, int16_t *_dst, int dstW,
9292
const uint8_t *_src, const int16_t *filter,
9393
const int32_t *filterPos, int filterSize)
9494
{
95-
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
95+
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.src_format);
9696
int bits = desc->comp[0].depth - 1;
9797
int sh = bits - 4;
9898

99-
if ((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
99+
if ((isAnyRGB(c->opts.src_format) || c->opts.src_format==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
100100
sh = 9;
101101
} else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
102102
sh = 16 - 1 - 4;
@@ -110,11 +110,11 @@ static void ff_hscale16to19_X8_neon(SwsInternal *c, int16_t *_dst, int dstW,
110110
const uint8_t *_src, const int16_t *filter,
111111
const int32_t *filterPos, int filterSize)
112112
{
113-
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
113+
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.src_format);
114114
int bits = desc->comp[0].depth - 1;
115115
int sh = bits - 4;
116116

117-
if ((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
117+
if ((isAnyRGB(c->opts.src_format) || c->opts.src_format==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
118118
sh = 9;
119119
} else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
120120
sh = 16 - 1 - 4;
@@ -128,11 +128,11 @@ static void ff_hscale16to19_X4_neon(SwsInternal *c, int16_t *_dst, int dstW,
128128
const uint8_t *_src, const int16_t *filter,
129129
const int32_t *filterPos, int filterSize)
130130
{
131-
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
131+
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.src_format);
132132
int bits = desc->comp[0].depth - 1;
133133
int sh = bits - 4;
134134

135-
if ((isAnyRGB(c->srcFormat) || c->srcFormat==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
135+
if ((isAnyRGB(c->opts.src_format) || c->opts.src_format==AV_PIX_FMT_PAL8) && desc->comp[0].depth<16) {
136136
sh = 9;
137137
} else if (desc->flags & AV_PIX_FMT_FLAG_FLOAT) { /* float input are process like uint 16bpc */
138138
sh = 16 - 1 - 4;
@@ -229,7 +229,7 @@ av_cold void ff_sws_init_range_convert_aarch64(SwsInternal *c)
229229

230230
if (have_neon(cpu_flags)) {
231231
if (c->dstBpc <= 14) {
232-
if (c->srcRange) {
232+
if (c->opts.src_range) {
233233
c->lumConvertRange = ff_lumRangeFromJpeg_neon;
234234
c->chrConvertRange = ff_chrRangeFromJpeg_neon;
235235
} else {
@@ -251,7 +251,7 @@ av_cold void ff_sws_init_swscale_aarch64(SwsInternal *c)
251251
if (c->dstBpc == 8) {
252252
c->yuv2planeX = ff_yuv2planeX_8_neon;
253253
}
254-
switch (c->srcFormat) {
254+
switch (c->opts.src_format) {
255255
case AV_PIX_FMT_ABGR:
256256
c->lumToYV12 = ff_abgr32ToY_neon;
257257
if (c->chrSrcHSubSample)

libswscale/aarch64/swscale_unscaled.c

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const
4343
const int dstStride[]) { \
4444
const int16_t yuv2rgb_table[] = { YUV_TO_RGB_TABLE }; \
4545
\
46-
return ff_##ifmt##_to_##ofmt##_neon(c->srcW, srcSliceH, \
46+
return ff_##ifmt##_to_##ofmt##_neon(c->opts.src_w, srcSliceH, \
4747
dst[0] + srcSliceY * dstStride[0], dstStride[0], \
4848
src[0], srcStride[0], \
4949
src[1], srcStride[1], \
@@ -71,7 +71,7 @@ static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const
7171
const int dstStride[]) { \
7272
const int16_t yuv2rgb_table[] = { YUV_TO_RGB_TABLE }; \
7373
\
74-
return ff_##ifmt##_to_##ofmt##_neon(c->srcW, srcSliceH, \
74+
return ff_##ifmt##_to_##ofmt##_neon(c->opts.src_w, srcSliceH, \
7575
dst[0] + srcSliceY * dstStride[0], dstStride[0], \
7676
src[0], srcStride[0], \
7777
src[1], srcStride[1], \
@@ -108,7 +108,7 @@ static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const
108108
const int dstStride[]) { \
109109
const int16_t yuv2rgb_table[] = { YUV_TO_RGB_TABLE }; \
110110
\
111-
return ff_##ifmt##_to_##ofmt##_neon(c->srcW, srcSliceH, \
111+
return ff_##ifmt##_to_##ofmt##_neon(c->opts.src_w, srcSliceH, \
112112
dst[0] + srcSliceY * dstStride[0], dstStride[0], \
113113
src[0], srcStride[0], src[1], srcStride[1], \
114114
yuv2rgb_table, \
@@ -133,7 +133,7 @@ static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const
133133
const int dstStride[]) { \
134134
const int16_t yuv2rgb_table[] = { YUV_TO_RGB_TABLE }; \
135135
\
136-
return ff_##ifmt##_to_##ofmt##_neon(c->srcW, srcSliceH, \
136+
return ff_##ifmt##_to_##ofmt##_neon(c->opts.src_w, srcSliceH, \
137137
dst[0] + srcSliceY * dstStride[0], dstStride[0], \
138138
src[0], srcStride[0], src[1], srcStride[1], \
139139
yuv2rgb_table, \
@@ -155,15 +155,17 @@ static int nv24_to_yuv420p_neon_wrapper(SwsInternal *c, const uint8_t *const src
155155
uint8_t *dst1 = dst[1] + dstStride[1] * srcSliceY / 2;
156156
uint8_t *dst2 = dst[2] + dstStride[2] * srcSliceY / 2;
157157

158-
ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->srcW,
158+
ff_copyPlane(src[0], srcStride[0], srcSliceY, srcSliceH, c->opts.src_w,
159159
dst[0], dstStride[0]);
160160

161-
if (c->srcFormat == AV_PIX_FMT_NV24)
161+
if (c->opts.src_format == AV_PIX_FMT_NV24)
162162
ff_nv24_to_yuv420p_chroma_neon(dst1, dstStride[1], dst2, dstStride[2],
163-
src[1], srcStride[1], c->srcW / 2, srcSliceH);
163+
src[1], srcStride[1], c->opts.src_w / 2,
164+
srcSliceH);
164165
else
165166
ff_nv24_to_yuv420p_chroma_neon(dst2, dstStride[2], dst1, dstStride[1],
166-
src[1], srcStride[1], c->srcW / 2, srcSliceH);
167+
src[1], srcStride[1], c->opts.src_w / 2,
168+
srcSliceH);
167169

168170
return srcSliceH;
169171
}
@@ -183,10 +185,10 @@ DECLARE_FF_NVX_TO_ALL_RGBX_FUNCS(nv21)
183185
* assembly might be writing as much as 4*15=60 extra bytes at the end of the
184186
* line, which won't fit the 32-bytes buffer alignment. */
185187
#define SET_FF_NVX_TO_RGBX_FUNC(ifmt, IFMT, ofmt, OFMT, accurate_rnd) do { \
186-
if (c->srcFormat == AV_PIX_FMT_##IFMT \
187-
&& c->dstFormat == AV_PIX_FMT_##OFMT \
188-
&& !(c->srcH & 1) \
189-
&& !(c->srcW & 15) \
188+
if (c->opts.src_format == AV_PIX_FMT_##IFMT \
189+
&& c->opts.dst_format == AV_PIX_FMT_##OFMT \
190+
&& !(c->opts.src_h & 1) \
191+
&& !(c->opts.src_w & 15) \
190192
&& !accurate_rnd) \
191193
c->convert_unscaled = ifmt##_to_##ofmt##_neon_wrapper; \
192194
} while (0)
@@ -200,16 +202,16 @@ DECLARE_FF_NVX_TO_ALL_RGBX_FUNCS(nv21)
200202
} while (0)
201203

202204
static void get_unscaled_swscale_neon(SwsInternal *c) {
203-
int accurate_rnd = c->flags & SWS_ACCURATE_RND;
205+
int accurate_rnd = c->opts.flags & SWS_ACCURATE_RND;
204206

205207
SET_FF_NVX_TO_ALL_RGBX_FUNC(nv12, NV12, accurate_rnd);
206208
SET_FF_NVX_TO_ALL_RGBX_FUNC(nv21, NV21, accurate_rnd);
207209
SET_FF_NVX_TO_ALL_RGBX_FUNC(yuv420p, YUV420P, accurate_rnd);
208210
SET_FF_NVX_TO_ALL_RGBX_FUNC(yuv422p, YUV422P, accurate_rnd);
209211

210-
if (c->dstFormat == AV_PIX_FMT_YUV420P &&
211-
(c->srcFormat == AV_PIX_FMT_NV24 || c->srcFormat == AV_PIX_FMT_NV42) &&
212-
!(c->srcH & 1) && !(c->srcW & 15) && !accurate_rnd)
212+
if (c->opts.dst_format == AV_PIX_FMT_YUV420P &&
213+
(c->opts.src_format == AV_PIX_FMT_NV24 || c->opts.src_format == AV_PIX_FMT_NV42) &&
214+
!(c->opts.src_h & 1) && !(c->opts.src_w & 15) && !accurate_rnd)
213215
c->convert_unscaled = nv24_to_yuv420p_neon_wrapper;
214216
}
215217

libswscale/alphablend.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ int ff_sws_alphablendaway(SwsInternal *c, const uint8_t *const src[],
2424
const int srcStride[], int srcSliceY, int srcSliceH,
2525
uint8_t *const dst[], const int dstStride[])
2626
{
27-
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->srcFormat);
27+
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(c->opts.src_format);
2828
int nb_components = desc->nb_components;
2929
int plane, x, ysrc;
30-
int plane_count = isGray(c->srcFormat) ? 1 : 3;
30+
int plane_count = isGray(c->opts.src_format) ? 1 : 3;
3131
int sixteen_bits = desc->comp[0].depth >= 9;
3232
unsigned off = 1<<(desc->comp[0].depth - 1);
3333
unsigned shift = desc->comp[0].depth;
@@ -36,7 +36,7 @@ int ff_sws_alphablendaway(SwsInternal *c, const uint8_t *const src[],
3636

3737
for (plane = 0; plane < plane_count; plane++) {
3838
int a = 0, b = 0;
39-
if (c->alphablend == SWS_ALPHA_BLEND_CHECKERBOARD) {
39+
if (c->opts.alpha_blend == SWS_ALPHA_BLEND_CHECKERBOARD) {
4040
a = (1<<(desc->comp[0].depth - 1))/2;
4141
b = 3*(1<<(desc->comp[0].depth-1))/2;
4242
}
@@ -47,7 +47,7 @@ int ff_sws_alphablendaway(SwsInternal *c, const uint8_t *const src[],
4747
av_assert0(plane_count == nb_components - 1);
4848
if (desc->flags & AV_PIX_FMT_FLAG_PLANAR) {
4949
for (plane = 0; plane < plane_count; plane++) {
50-
int w = plane ? c->chrSrcW : c->srcW;
50+
int w = plane ? c->chrSrcW : c->opts.src_w;
5151
int x_subsample = plane ? desc->log2_chroma_w: 0;
5252
int y_subsample = plane ? desc->log2_chroma_h: 0;
5353
for (ysrc = 0; ysrc < AV_CEIL_RSHIFT(srcSliceH, y_subsample); ysrc++) {
@@ -60,7 +60,7 @@ int ff_sws_alphablendaway(SwsInternal *c, const uint8_t *const src[],
6060
const uint16_t *s = (const uint16_t *)(src[plane ] + srcStride[plane ] * ysrc);
6161
const uint16_t *a = (const uint16_t *)(src[plane_count] + (srcStride[plane_count] * ysrc << y_subsample));
6262
uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
63-
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
63+
if ((!isBE(c->opts.src_format)) == !HAVE_BIGENDIAN) {
6464
for (x = 0; x < w; x++) {
6565
if (y_subsample) {
6666
alpha = (a[2*x] + a[2*x + 1] + 2 +
@@ -101,7 +101,7 @@ int ff_sws_alphablendaway(SwsInternal *c, const uint8_t *const src[],
101101
const uint16_t *s = (const uint16_t *)(src[plane ] + srcStride[plane ] * ysrc);
102102
const uint16_t *a = (const uint16_t *)(src[plane_count] + srcStride[plane_count] * ysrc);
103103
uint16_t *d = ( uint16_t *)(dst[plane ] + dstStride[plane ] * y);
104-
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
104+
if ((!isBE(c->opts.src_format)) == !HAVE_BIGENDIAN) {
105105
for (x = 0; x < w; x++) {
106106
unsigned u = s[x]*a[x] + target_table[((x^y)>>5)&1][plane]*(max-a[x]) + off;
107107
d[x] = av_clip((u + (u >> shift)) >> shift, 0, max);
@@ -127,14 +127,14 @@ int ff_sws_alphablendaway(SwsInternal *c, const uint8_t *const src[],
127127
}
128128
} else {
129129
int alpha_pos = desc->comp[plane_count].offset;
130-
int w = c->srcW;
130+
int w = c->opts.src_w;
131131
for (ysrc = 0; ysrc < srcSliceH; ysrc++) {
132132
int y = ysrc + srcSliceY;
133133
if (sixteen_bits) {
134134
const uint16_t *s = (const uint16_t *)(src[0] + srcStride[0] * ysrc + 2*!alpha_pos);
135135
const uint16_t *a = (const uint16_t *)(src[0] + srcStride[0] * ysrc + alpha_pos);
136136
uint16_t *d = ( uint16_t *)(dst[0] + dstStride[0] * y);
137-
if ((!isBE(c->srcFormat)) == !HAVE_BIGENDIAN) {
137+
if ((!isBE(c->opts.src_format)) == !HAVE_BIGENDIAN) {
138138
for (x = 0; x < w; x++) {
139139
for (plane = 0; plane < plane_count; plane++) {
140140
int x_index = (plane_count + 1) * x;

0 commit comments

Comments
 (0)