Skip to content

Commit 67adb30

Browse files
committed
swscale: rename SwsContext to SwsInternal
And preserve the public SwsContext as separate name. The motivation here is that I want to turn SwsContext into a public struct, while keeping the internal implementation hidden. Additionally, I also want to be able to use multiple internal implementations, e.g. for GPU devices. This commit does not include any functional changes. For the most part, it is a simple rename. The only complications arise from the public facing API functions, which preserve their current type (and hence require an additional unwrapping step internally), and the checkasm test framework, which directly accesses SwsInternal. For consistency, the affected functions that need to maintain a distionction have generally been changed to refer to the SwsContext as *sws, and the SwsInternal as *c. In an upcoming commit, I will provide a backing definition for the public SwsContext, and update `sws_internal()` to dereference the internal struct instead of merely casting it. Sponsored-by: Sovereign Tech Fund Signed-off-by: Niklas Haas <[email protected]>
1 parent 153a6dc commit 67adb30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+630
-578
lines changed

libswscale/aarch64/hscale.S

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
; horizontal line scaling
2828
;
2929
; void hscale<source_width>to<intermediate_nbits>_<filterSize>_<opt>
30-
; (SwsContext *c, int{16,32}_t *dst,
30+
; (SwsInternal *c, int{16,32}_t *dst,
3131
; int dstW, const uint{8,16}_t *src,
3232
; const int16_t *filter,
3333
; const int32_t *filterPos, int filterSize);
@@ -92,7 +92,7 @@ function ff_hscale8to15_X8_neon, export=1
9292
endfunc
9393

9494
function ff_hscale8to15_X4_neon, export=1
95-
// x0 SwsContext *c (not used)
95+
// x0 SwsInternal *c (not used)
9696
// x1 int16_t *dst
9797
// w2 int dstW
9898
// x3 const uint8_t *src
@@ -199,7 +199,7 @@ function ff_hscale8to15_X4_neon, export=1
199199
endfunc
200200

201201
function ff_hscale8to15_4_neon, export=1
202-
// x0 SwsContext *c (not used)
202+
// x0 SwsInternal *c (not used)
203203
// x1 int16_t *dst
204204
// x2 int dstW
205205
// x3 const uint8_t *src
@@ -349,7 +349,7 @@ function ff_hscale8to15_4_neon, export=1
349349
endfunc
350350

351351
function ff_hscale8to19_4_neon, export=1
352-
// x0 SwsContext *c (unused)
352+
// x0 SwsInternal *c (unused)
353353
// x1 int32_t *dst
354354
// w2 int dstW
355355
// x3 const uint8_t *src // treat it as uint16_t *src
@@ -542,7 +542,7 @@ function ff_hscale8to19_X8_neon, export=1
542542
endfunc
543543

544544
function ff_hscale8to19_X4_neon, export=1
545-
// x0 SwsContext *c (not used)
545+
// x0 SwsInternal *c (not used)
546546
// x1 int16_t *dst
547547
// w2 int dstW
548548
// x3 const uint8_t *src

libswscale/aarch64/swscale.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void ff_hscale16to19_X4_neon_asm(int shift, int16_t *_dst, int dstW,
4141
const uint8_t *_src, const int16_t *filter,
4242
const int32_t *filterPos, int filterSize);
4343

44-
static void ff_hscale16to15_4_neon(SwsContext *c, int16_t *_dst, int dstW,
44+
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
{
@@ -57,7 +57,7 @@ static void ff_hscale16to15_4_neon(SwsContext *c, int16_t *_dst, int dstW,
5757

5858
}
5959

60-
static void ff_hscale16to15_X8_neon(SwsContext *c, int16_t *_dst, int dstW,
60+
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
{
@@ -73,7 +73,7 @@ static void ff_hscale16to15_X8_neon(SwsContext *c, int16_t *_dst, int dstW,
7373

7474
}
7575

76-
static void ff_hscale16to15_X4_neon(SwsContext *c, int16_t *_dst, int dstW,
76+
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
{
@@ -88,7 +88,7 @@ static void ff_hscale16to15_X4_neon(SwsContext *c, int16_t *_dst, int dstW,
8888
ff_hscale16to15_X4_neon_asm(sh, _dst, dstW, _src, filter, filterPos, filterSize);
8989
}
9090

91-
static void ff_hscale16to19_4_neon(SwsContext *c, int16_t *_dst, int dstW,
91+
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
{
@@ -106,7 +106,7 @@ static void ff_hscale16to19_4_neon(SwsContext *c, int16_t *_dst, int dstW,
106106

107107
}
108108

109-
static void ff_hscale16to19_X8_neon(SwsContext *c, int16_t *_dst, int dstW,
109+
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
{
@@ -124,7 +124,7 @@ static void ff_hscale16to19_X8_neon(SwsContext *c, int16_t *_dst, int dstW,
124124

125125
}
126126

127-
static void ff_hscale16to19_X4_neon(SwsContext *c, int16_t *_dst, int dstW,
127+
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
{
@@ -144,7 +144,7 @@ static void ff_hscale16to19_X4_neon(SwsContext *c, int16_t *_dst, int dstW,
144144

145145
#define SCALE_FUNC(filter_n, from_bpc, to_bpc, opt) \
146146
void ff_hscale ## from_bpc ## to ## to_bpc ## _ ## filter_n ## _ ## opt( \
147-
SwsContext *c, int16_t *data, \
147+
SwsInternal *c, int16_t *data, \
148148
int dstW, const uint8_t *src, \
149149
const int16_t *filter, \
150150
const int32_t *filterPos, int filterSize)
@@ -223,7 +223,7 @@ void ff_chrRangeFromJpeg_neon(int16_t *dstU, int16_t *dstV, int width);
223223
void ff_lumRangeToJpeg_neon(int16_t *dst, int width);
224224
void ff_chrRangeToJpeg_neon(int16_t *dstU, int16_t *dstV, int width);
225225

226-
av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c)
226+
av_cold void ff_sws_init_range_convert_aarch64(SwsInternal *c)
227227
{
228228
if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) {
229229
if (c->dstBpc <= 14) {
@@ -238,7 +238,7 @@ av_cold void ff_sws_init_range_convert_aarch64(SwsContext *c)
238238
}
239239
}
240240

241-
av_cold void ff_sws_init_swscale_aarch64(SwsContext *c)
241+
av_cold void ff_sws_init_swscale_aarch64(SwsInternal *c)
242242
{
243243
int cpu_flags = av_get_cpu_flags();
244244

libswscale/aarch64/swscale_unscaled.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ int ff_##ifmt##_to_##ofmt##_neon(int w, int h,
3737
int y_offset, \
3838
int y_coeff); \
3939
\
40-
static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *const src[], \
40+
static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const src[], \
4141
const int srcStride[], int srcSliceY, \
4242
int srcSliceH, uint8_t *const dst[], \
4343
const int dstStride[]) { \
@@ -65,7 +65,7 @@ int ff_##ifmt##_to_##ofmt##_neon(int w, int h,
6565
uint8_t *dst1, int linesize1, \
6666
uint8_t *dst2, int linesize2); \
6767
\
68-
static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *const src[], \
68+
static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const src[], \
6969
const int srcStride[], int srcSliceY, \
7070
int srcSliceH, uint8_t *const dst[], \
7171
const int dstStride[]) { \
@@ -102,7 +102,7 @@ int ff_##ifmt##_to_##ofmt##_neon(int w, int h,
102102
int y_offset, \
103103
int y_coeff); \
104104
\
105-
static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *const src[], \
105+
static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const src[], \
106106
const int srcStride[], int srcSliceY, \
107107
int srcSliceH, uint8_t *const dst[], \
108108
const int dstStride[]) { \
@@ -127,7 +127,7 @@ int ff_##ifmt##_to_##ofmt##_neon(int w, int h,
127127
uint8_t *dst1, int linesize1, \
128128
uint8_t *dst2, int linesize2); \
129129
\
130-
static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *const src[], \
130+
static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const src[], \
131131
const int srcStride[], int srcSliceY, \
132132
int srcSliceH, uint8_t *const dst[], \
133133
const int dstStride[]) { \
@@ -148,7 +148,7 @@ void ff_nv24_to_yuv420p_chroma_neon(uint8_t *dst1, int dstStride1,
148148
const uint8_t *src, int srcStride,
149149
int w, int h);
150150

151-
static int nv24_to_yuv420p_neon_wrapper(SwsContext *c, const uint8_t *const src[],
151+
static int nv24_to_yuv420p_neon_wrapper(SwsInternal *c, const uint8_t *const src[],
152152
const int srcStride[], int srcSliceY, int srcSliceH,
153153
uint8_t *const dst[], const int dstStride[])
154154
{
@@ -199,7 +199,7 @@ DECLARE_FF_NVX_TO_ALL_RGBX_FUNCS(nv21)
199199
SET_FF_NVX_TO_RGBX_FUNC(nvx, NVX, gbrp, GBRP, accurate_rnd); \
200200
} while (0)
201201

202-
static void get_unscaled_swscale_neon(SwsContext *c) {
202+
static void get_unscaled_swscale_neon(SwsInternal *c) {
203203
int accurate_rnd = c->flags & SWS_ACCURATE_RND;
204204

205205
SET_FF_NVX_TO_ALL_RGBX_FUNC(nv12, NV12, accurate_rnd);
@@ -213,7 +213,7 @@ static void get_unscaled_swscale_neon(SwsContext *c) {
213213
c->convert_unscaled = nv24_to_yuv420p_neon_wrapper;
214214
}
215215

216-
void ff_get_unscaled_swscale_aarch64(SwsContext *c)
216+
void ff_get_unscaled_swscale_aarch64(SwsInternal *c)
217217
{
218218
int cpu_flags = av_get_cpu_flags();
219219
if (have_neon(cpu_flags))

libswscale/alphablend.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "swscale_internal.h"
2222

23-
int ff_sws_alphablendaway(SwsContext *c, const uint8_t *const src[],
23+
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
{

libswscale/arm/swscale.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@
2222
#include "libswscale/swscale_internal.h"
2323
#include "libavutil/arm/cpu.h"
2424

25-
void ff_hscale_8_to_15_neon(SwsContext *c, int16_t *dst, int dstW,
25+
void ff_hscale_8_to_15_neon(SwsInternal *c, int16_t *dst, int dstW,
2626
const uint8_t *src, const int16_t *filter,
2727
const int32_t *filterPos, int filterSize);
2828

2929
void ff_yuv2planeX_8_neon(const int16_t *filter, int filterSize,
3030
const int16_t **src, uint8_t *dest, int dstW,
3131
const uint8_t *dither, int offset);
3232

33-
av_cold void ff_sws_init_swscale_arm(SwsContext *c)
33+
av_cold void ff_sws_init_swscale_arm(SwsInternal *c)
3434
{
3535
int cpu_flags = av_get_cpu_flags();
3636

libswscale/arm/swscale_unscaled.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern void rgbx_to_nv12_neon_16(const uint8_t *src, uint8_t *y, uint8_t *chroma
3434
int y_stride, int c_stride, int src_stride,
3535
int32_t coeff_tbl[9]);
3636

37-
static int rgbx_to_nv12_neon_32_wrapper(SwsContext *context, const uint8_t *const src[],
37+
static int rgbx_to_nv12_neon_32_wrapper(SwsInternal *context, const uint8_t *const src[],
3838
const int srcStride[], int srcSliceY, int srcSliceH,
3939
uint8_t *const dst[], const int dstStride[]) {
4040

@@ -48,7 +48,7 @@ static int rgbx_to_nv12_neon_32_wrapper(SwsContext *context, const uint8_t *cons
4848
return 0;
4949
}
5050

51-
static int rgbx_to_nv12_neon_16_wrapper(SwsContext *context, const uint8_t *const src[],
51+
static int rgbx_to_nv12_neon_16_wrapper(SwsInternal *context, const uint8_t *const src[],
5252
const int srcStride[], int srcSliceY, int srcSliceH,
5353
uint8_t *const dst[], int dstStride[]) {
5454

@@ -78,7 +78,7 @@ int ff_##ifmt##_to_##ofmt##_neon(int w, int h,
7878
int y_offset, \
7979
int y_coeff); \
8080
\
81-
static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *const src[], \
81+
static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const src[], \
8282
const int srcStride[], int srcSliceY, \
8383
int srcSliceH, uint8_t *const dst[], \
8484
const int dstStride[]) { \
@@ -114,7 +114,7 @@ int ff_##ifmt##_to_##ofmt##_neon(int w, int h,
114114
int y_offset, \
115115
int y_coeff); \
116116
\
117-
static int ifmt##_to_##ofmt##_neon_wrapper(SwsContext *c, const uint8_t *const src[], \
117+
static int ifmt##_to_##ofmt##_neon_wrapper(SwsInternal *c, const uint8_t *const src[], \
118118
const int srcStride[], int srcSliceY, \
119119
int srcSliceH, uint8_t *const dst[], \
120120
const int dstStride[]) { \
@@ -160,7 +160,7 @@ DECLARE_FF_NVX_TO_ALL_RGBX_FUNCS(nv21)
160160
SET_FF_NVX_TO_RGBX_FUNC(nvx, NVX, bgra, BGRA, accurate_rnd); \
161161
} while (0)
162162

163-
static void get_unscaled_swscale_neon(SwsContext *c) {
163+
static void get_unscaled_swscale_neon(SwsInternal *c) {
164164
int accurate_rnd = c->flags & SWS_ACCURATE_RND;
165165
if (c->srcFormat == AV_PIX_FMT_RGBA
166166
&& c->dstFormat == AV_PIX_FMT_NV12
@@ -175,14 +175,14 @@ static void get_unscaled_swscale_neon(SwsContext *c) {
175175
SET_FF_NVX_TO_ALL_RGBX_FUNC(yuv422p, YUV422P, accurate_rnd);
176176
}
177177

178-
void ff_get_unscaled_swscale_arm(SwsContext *c)
178+
void ff_get_unscaled_swscale_arm(SwsInternal *c)
179179
{
180180
int cpu_flags = av_get_cpu_flags();
181181
if (have_neon(cpu_flags))
182182
get_unscaled_swscale_neon(c);
183183
}
184184
#else
185-
void ff_get_unscaled_swscale_arm(SwsContext *c)
185+
void ff_get_unscaled_swscale_arm(SwsInternal *c)
186186
{
187187
}
188188
#endif

libswscale/gamma.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct GammaContext
2828

2929
// gamma_convert expects 16 bit rgb format
3030
// it writes directly in src slice thus it must be modifiable (done through cascade context)
31-
static int gamma_convert(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
31+
static int gamma_convert(SwsInternal *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
3232
{
3333
GammaContext *instance = desc->instance;
3434
uint16_t *table = instance->table;
@@ -70,4 +70,3 @@ int ff_init_gamma_convert(SwsFilterDescriptor *desc, SwsSlice * src, uint16_t *t
7070

7171
return 0;
7272
}
73-

libswscale/hscale.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ typedef struct ColorContext
3636
uint32_t *pal;
3737
} ColorContext;
3838

39-
static int lum_h_scale(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
39+
static int lum_h_scale(SwsInternal *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
4040
{
4141
FilterContext *instance = desc->instance;
4242
int srcW = desc->src->width;
@@ -84,7 +84,7 @@ static int lum_h_scale(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, int
8484
return sliceH;
8585
}
8686

87-
static int lum_convert(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
87+
static int lum_convert(SwsInternal *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
8888
{
8989
int srcW = desc->src->width;
9090
ColorContext * instance = desc->instance;
@@ -164,7 +164,7 @@ int ff_init_desc_hscale(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst,
164164
return 0;
165165
}
166166

167-
static int chr_h_scale(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
167+
static int chr_h_scale(SwsInternal *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
168168
{
169169
FilterContext *instance = desc->instance;
170170
int srcW = AV_CEIL_RSHIFT(desc->src->width, desc->src->h_chr_sub_sample);
@@ -200,7 +200,7 @@ static int chr_h_scale(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, int
200200
return sliceH;
201201
}
202202

203-
static int chr_convert(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
203+
static int chr_convert(SwsInternal *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
204204
{
205205
int srcW = AV_CEIL_RSHIFT(desc->src->width, desc->src->h_chr_sub_sample);
206206
ColorContext * instance = desc->instance;
@@ -270,7 +270,7 @@ int ff_init_desc_chscale(SwsFilterDescriptor *desc, SwsSlice *src, SwsSlice *dst
270270
return 0;
271271
}
272272

273-
static int no_chr_scale(SwsContext *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
273+
static int no_chr_scale(SwsInternal *c, SwsFilterDescriptor *desc, int sliceY, int sliceH)
274274
{
275275
desc->dst->plane[1].sliceY = sliceY + sliceH - desc->dst->plane[1].available_lines;
276276
desc->dst->plane[1].sliceH = desc->dst->plane[1].available_lines;

libswscale/hscale_fast_bilinear.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
#include "swscale_internal.h"
2222

23-
void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
23+
void ff_hyscale_fast_c(SwsInternal *c, int16_t *dst, int dstWidth,
2424
const uint8_t *src, int srcW, int xInc)
2525
{
2626
int i;
@@ -35,7 +35,7 @@ void ff_hyscale_fast_c(SwsContext *c, int16_t *dst, int dstWidth,
3535
dst[i] = src[srcW-1]*128;
3636
}
3737

38-
void ff_hcscale_fast_c(SwsContext *c, int16_t *dst1, int16_t *dst2,
38+
void ff_hcscale_fast_c(SwsInternal *c, int16_t *dst1, int16_t *dst2,
3939
int dstWidth, const uint8_t *src1,
4040
const uint8_t *src2, int srcW, int xInc)
4141
{

libswscale/input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1539,7 +1539,7 @@ static void rgbf16##endian_name##ToY_c(uint8_t *_dst, const uint8_t *_src, const
15391539
rgbaf16_funcs_endian(le, 0)
15401540
rgbaf16_funcs_endian(be, 1)
15411541

1542-
av_cold void ff_sws_init_input_funcs(SwsContext *c,
1542+
av_cold void ff_sws_init_input_funcs(SwsInternal *c,
15431543
planar1_YV12_fn *lumToYV12,
15441544
planar1_YV12_fn *alpToYV12,
15451545
planar2_YV12_fn *chrToYV12,

0 commit comments

Comments
 (0)