diff options
author | Niklas Haas <git@haasn.dev> | 2024-10-09 19:44:33 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2024-10-24 22:50:00 +0200 |
commit | 67adb303228a5d8e2abe860b7748004cc83ca65f (patch) | |
tree | 5b987107804eb246b68414da8e43789658594c7c /tests/checkasm/sw_gbrp.c | |
parent | 153a6dc8faafc4de263a493484ffc1dc2b5b26b2 (diff) | |
download | ffmpeg-67adb303228a5d8e2abe860b7748004cc83ca65f.tar.gz |
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 <git@haasn.dev>
Diffstat (limited to 'tests/checkasm/sw_gbrp.c')
-rw-r--r-- | tests/checkasm/sw_gbrp.c | 80 |
1 files changed, 44 insertions, 36 deletions
diff --git a/tests/checkasm/sw_gbrp.c b/tests/checkasm/sw_gbrp.c index d843730f3e..039be8006b 100644 --- a/tests/checkasm/sw_gbrp.c +++ b/tests/checkasm/sw_gbrp.c @@ -63,7 +63,8 @@ static const int planar_fmts[] = { static void check_output_yuv2gbrp(void) { - struct SwsContext *ctx; + SwsContext *sws; + SwsInternal *c; const AVPixFmtDescriptor *desc; int fmi, fsi, isi, i; int dstW, byte_size, luma_filter_size, chr_filter_size; @@ -76,7 +77,7 @@ static void check_output_yuv2gbrp(void) uint8_t *dst0[4]; uint8_t *dst1[4]; - declare_func(void, struct SwsContext *c, const int16_t *lumFilter, + declare_func(void, SwsInternal *c, const int16_t *lumFilter, const int16_t **lumSrcx, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrcx, const int16_t **chrVSrcx, int chrFilterSize, @@ -130,17 +131,18 @@ static void check_output_yuv2gbrp(void) alpha[i] = (int16_t *)(src_a + i*LARGEST_INPUT_SIZE); } - ctx = sws_alloc_context(); - if (sws_init_context(ctx, NULL, NULL) < 0) + sws = sws_alloc_context(); + if (sws_init_context(sws, NULL, NULL) < 0) fail(); - ctx->flags |= SWS_FULL_CHR_H_INT; + c = sws_internal(sws); + c->flags |= SWS_FULL_CHR_H_INT; for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { for (fsi = 0; fsi < FILTER_SIZES; fsi++) { for (isi = 0; isi < INPUT_SIZES; isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); - ctx->dstFormat = planar_fmts[fmi]; + c->dstFormat = planar_fmts[fmi]; dstW = input_sizes[isi]; luma_filter_size = filter_sizes[fsi]; @@ -154,17 +156,17 @@ static void check_output_yuv2gbrp(void) byte_size = 1; } - ff_sws_init_scale(ctx); - if (check_func(ctx->yuv2anyX, "yuv2%s_full_X_%d_%d", desc->name, luma_filter_size, dstW)) { + ff_sws_init_scale(c); + if (check_func(c->yuv2anyX, "yuv2%s_full_X_%d_%d", desc->name, luma_filter_size, dstW)) { for (i = 0; i < 4; i ++) { memset(dst0[i], 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t)); memset(dst1[i], 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t)); } - call_ref(ctx, luma_filter, luma, luma_filter_size, + call_ref(c, luma_filter, luma, luma_filter_size, chr_filter, chru, chrv, chr_filter_size, alpha, dst0, dstW, 0); - call_new(ctx, luma_filter, luma, luma_filter_size, + call_new(c, luma_filter, luma, luma_filter_size, chr_filter, chru, chrv, chr_filter_size, alpha, dst1, dstW, 0); @@ -174,14 +176,14 @@ static void check_output_yuv2gbrp(void) memcmp(dst0[3], dst1[3], dstW * byte_size) ) fail(); - bench_new(ctx, luma_filter, luma, luma_filter_size, + bench_new(c, luma_filter, luma, luma_filter_size, chr_filter, chru, chrv, chr_filter_size, alpha, dst1, dstW, 0); } } } } - sws_freeContext(ctx); + sws_freeContext(sws); } #undef LARGEST_INPUT_SIZE @@ -189,7 +191,8 @@ static void check_output_yuv2gbrp(void) static void check_input_planar_rgb_to_y(void) { - struct SwsContext *ctx; + SwsContext *sws; + SwsInternal *c; const AVPixFmtDescriptor *desc; int fmi, isi; int dstW, byte_size; @@ -221,20 +224,21 @@ static void check_input_planar_rgb_to_y(void) src[2] = (uint8_t*)src_r; src[3] = (uint8_t*)src_a; - ctx = sws_alloc_context(); - if (sws_init_context(ctx, NULL, NULL) < 0) + sws = sws_alloc_context(); + if (sws_init_context(sws, NULL, NULL) < 0) fail(); + c = sws_internal(sws); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { for (isi = 0; isi < INPUT_SIZES; isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); - ctx->srcFormat = planar_fmts[fmi]; - ctx->dstFormat = AV_PIX_FMT_YUVA444P16; + c->srcFormat = planar_fmts[fmi]; + c->dstFormat = AV_PIX_FMT_YUVA444P16; byte_size = 2; dstW = input_sizes[isi]; - ff_sws_init_scale(ctx); - if(check_func(ctx->readLumPlanar, "planar_%s_to_y_%d", desc->name, dstW)) { + ff_sws_init_scale(c); + if(check_func(c->readLumPlanar, "planar_%s_to_y_%d", desc->name, dstW)) { memset(dst0_y, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t)); memset(dst1_y, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t)); @@ -249,7 +253,7 @@ static void check_input_planar_rgb_to_y(void) } } } - sws_freeContext(ctx); + sws_freeContext(sws); } #undef LARGEST_INPUT_SIZE @@ -257,7 +261,8 @@ static void check_input_planar_rgb_to_y(void) static void check_input_planar_rgb_to_uv(void) { - struct SwsContext *ctx; + SwsContext *sws; + SwsInternal *c; const AVPixFmtDescriptor *desc; int fmi, isi; int dstW, byte_size; @@ -292,20 +297,21 @@ static void check_input_planar_rgb_to_uv(void) src[2] = (uint8_t*)src_r; src[3] = (uint8_t*)src_a; - ctx = sws_alloc_context(); - if (sws_init_context(ctx, NULL, NULL) < 0) + sws = sws_alloc_context(); + if (sws_init_context(sws, NULL, NULL) < 0) fail(); + c = sws_internal(sws); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { for (isi = 0; isi < INPUT_SIZES; isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); - ctx->srcFormat = planar_fmts[fmi]; - ctx->dstFormat = AV_PIX_FMT_YUVA444P16; + c->srcFormat = planar_fmts[fmi]; + c->dstFormat = AV_PIX_FMT_YUVA444P16; byte_size = 2; dstW = input_sizes[isi]; - ff_sws_init_scale(ctx); - if(check_func(ctx->readChrPlanar, "planar_%s_to_uv_%d", desc->name, dstW)) { + ff_sws_init_scale(c); + if(check_func(c->readChrPlanar, "planar_%s_to_uv_%d", desc->name, dstW)) { memset(dst0_u, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t)); memset(dst0_v, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t)); memset(dst1_u, 0xFF, LARGEST_INPUT_SIZE * sizeof(int32_t)); @@ -322,7 +328,7 @@ static void check_input_planar_rgb_to_uv(void) } } } - sws_freeContext(ctx); + sws_freeContext(sws); } #undef LARGEST_INPUT_SIZE @@ -330,7 +336,8 @@ static void check_input_planar_rgb_to_uv(void) static void check_input_planar_rgb_to_a(void) { - struct SwsContext *ctx; + SwsContext *sws; + SwsInternal *c; const AVPixFmtDescriptor *desc; int fmi, isi; int dstW, byte_size; @@ -362,23 +369,24 @@ static void check_input_planar_rgb_to_a(void) src[2] = (uint8_t*)src_r; src[3] = (uint8_t*)src_a; - ctx = sws_alloc_context(); - if (sws_init_context(ctx, NULL, NULL) < 0) + sws = sws_alloc_context(); + if (sws_init_context(sws, NULL, NULL) < 0) fail(); + c = sws_internal(sws); for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { for (isi = 0; isi < INPUT_SIZES; isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) continue; - ctx->srcFormat = planar_fmts[fmi]; - ctx->dstFormat = AV_PIX_FMT_YUVA444P16; + c->srcFormat = planar_fmts[fmi]; + c->dstFormat = AV_PIX_FMT_YUVA444P16; byte_size = 2; dstW = input_sizes[isi]; - ff_sws_init_scale(ctx); - if(check_func(ctx->readAlpPlanar, "planar_%s_to_a_%d", desc->name, dstW)) { + ff_sws_init_scale(c); + if(check_func(c->readAlpPlanar, "planar_%s_to_a_%d", desc->name, dstW)) { memset(dst0_a, 0x00, LARGEST_INPUT_SIZE * sizeof(int32_t)); memset(dst1_a, 0x00, LARGEST_INPUT_SIZE * sizeof(int32_t)); @@ -391,7 +399,7 @@ static void check_input_planar_rgb_to_a(void) } } } - sws_freeContext(ctx); + sws_freeContext(sws); } void checkasm_check_sw_gbrp(void) |