diff options
author | Niklas Haas <git@haasn.dev> | 2024-10-24 12:12:08 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2024-11-25 10:59:52 +0100 |
commit | 6a91a165fdae1cb19e48b9a403d94a930ffc54bb (patch) | |
tree | c86468c95696b19a9dd1ea046021fc21e27098a1 /tests/checkasm | |
parent | ed5dd675624c83d9c69b406ce30e4e09f29970e3 (diff) | |
download | ffmpeg-6a91a165fdae1cb19e48b9a403d94a930ffc54bb.tar.gz |
swscale: eliminate redundant SwsInternal accesses
This is a purely cosmetic commit aimed at replacing accesses to
SwsInternal.opts by direct access to SwsContext wherever convenient.
Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
Diffstat (limited to 'tests/checkasm')
-rw-r--r-- | tests/checkasm/sw_gbrp.c | 16 | ||||
-rw-r--r-- | tests/checkasm/sw_range_convert.c | 16 | ||||
-rw-r--r-- | tests/checkasm/sw_rgb.c | 29 | ||||
-rw-r--r-- | tests/checkasm/sw_scale.c | 22 |
4 files changed, 43 insertions, 40 deletions
diff --git a/tests/checkasm/sw_gbrp.c b/tests/checkasm/sw_gbrp.c index b8ac7fdd1c..4fcb87cd5f 100644 --- a/tests/checkasm/sw_gbrp.c +++ b/tests/checkasm/sw_gbrp.c @@ -135,13 +135,13 @@ static void check_output_yuv2gbrp(void) fail(); c = sws_internal(sws); - c->opts.flags |= SWS_FULL_CHR_H_INT; + sws->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 < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); - c->opts.dst_format = planar_fmts[fmi]; + sws->dst_format = planar_fmts[fmi]; dstW = input_sizes[isi]; luma_filter_size = filter_sizes[fsi]; @@ -229,8 +229,8 @@ static void check_input_planar_rgb_to_y(void) for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); - c->opts.src_format = planar_fmts[fmi]; - c->opts.dst_format = AV_PIX_FMT_YUVA444P16; + sws->src_format = planar_fmts[fmi]; + sws->dst_format = AV_PIX_FMT_YUVA444P16; byte_size = 2; dstW = input_sizes[isi]; @@ -300,8 +300,8 @@ static void check_input_planar_rgb_to_uv(void) for (fmi = 0; fmi < FF_ARRAY_ELEMS(planar_fmts); fmi++) { for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++ ) { desc = av_pix_fmt_desc_get(planar_fmts[fmi]); - c->opts.src_format = planar_fmts[fmi]; - c->opts.dst_format = AV_PIX_FMT_YUVA444P16; + sws->src_format = planar_fmts[fmi]; + sws->dst_format = AV_PIX_FMT_YUVA444P16; byte_size = 2; dstW = input_sizes[isi]; @@ -373,8 +373,8 @@ static void check_input_planar_rgb_to_a(void) if (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA)) continue; - c->opts.src_format = planar_fmts[fmi]; - c->opts.dst_format = AV_PIX_FMT_YUVA444P16; + sws->src_format = planar_fmts[fmi]; + sws->dst_format = AV_PIX_FMT_YUVA444P16; byte_size = 2; dstW = input_sizes[isi]; diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c index f17050f524..bf14209987 100644 --- a/tests/checkasm/sw_range_convert.c +++ b/tests/checkasm/sw_range_convert.c @@ -73,16 +73,16 @@ static void check_lumConvertRange(int from) fail(); c = sws_internal(sws); - c->opts.src_range = from; - c->opts.dst_range = !from; + sws->src_range = from; + sws->dst_range = !from; for (int pfi = 0; pfi < FF_ARRAY_ELEMS(pixel_formats); pfi++) { enum AVPixelFormat pix_fmt = pixel_formats[pfi]; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int bit_depth = desc->comp[0].depth; int sample_size = bit_depth == 16 ? sizeof(int32_t) : sizeof(int16_t); - c->opts.src_format = pix_fmt; - c->opts.dst_format = pix_fmt; + sws->src_format = pix_fmt; + sws->dst_format = pix_fmt; c->dstBpc = bit_depth; ff_sws_init_scale(c); for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { @@ -123,16 +123,16 @@ static void check_chrConvertRange(int from) fail(); c = sws_internal(sws); - c->opts.src_range = from; - c->opts.dst_range = !from; + sws->src_range = from; + sws->dst_range = !from; for (int pfi = 0; pfi < FF_ARRAY_ELEMS(pixel_formats); pfi++) { enum AVPixelFormat pix_fmt = pixel_formats[pfi]; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int bit_depth = desc->comp[0].depth; int sample_size = bit_depth == 16 ? sizeof(int32_t) : sizeof(int16_t); - c->opts.src_format = pix_fmt; - c->opts.dst_format = pix_fmt; + sws->src_format = pix_fmt; + sws->dst_format = pix_fmt; c->dstBpc = bit_depth; ff_sws_init_scale(c); for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) { diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c index 65f8404d3f..05370c1e41 100644 --- a/tests/checkasm/sw_rgb.c +++ b/tests/checkasm/sw_rgb.c @@ -127,9 +127,10 @@ static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int a return 0; } -static void check_rgb24toyv12(SwsInternal *ctx) +static void check_rgb24toyv12(SwsContext *sws) { static const int input_sizes[] = {16, 128, 512, MAX_LINE_SIZE, -MAX_LINE_SIZE}; + SwsInternal *ctx = sws_internal(sws); LOCAL_ALIGNED_32(uint8_t, src, [BUFSIZE * 3]); LOCAL_ALIGNED_32(uint8_t, buf_y_0, [BUFSIZE]); @@ -353,8 +354,10 @@ static const enum AVPixelFormat rgb_formats[] = { AV_PIX_FMT_ARGB, }; -static void check_rgb_to_y(SwsInternal *ctx) +static void check_rgb_to_y(SwsContext *sws) { + SwsInternal *ctx = sws_internal(sws); + LOCAL_ALIGNED_16(uint8_t, src24, [MAX_LINE_SIZE * 3]); LOCAL_ALIGNED_16(uint8_t, src32, [MAX_LINE_SIZE * 4]); LOCAL_ALIGNED_32(uint8_t, dst0_y, [MAX_LINE_SIZE * 2]); @@ -370,7 +373,7 @@ static void check_rgb_to_y(SwsInternal *ctx) for (int i = 0; i < FF_ARRAY_ELEMS(rgb_formats); i++) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(rgb_formats[i]); - ctx->opts.src_format = rgb_formats[i]; + sws->src_format = rgb_formats[i]; ff_sws_init_scale(ctx); for (int j = 0; j < FF_ARRAY_ELEMS(input_sizes); j++) { @@ -389,15 +392,17 @@ static void check_rgb_to_y(SwsInternal *ctx) if (desc->nb_components == 3 || // only bench native endian formats - (ctx->opts.src_format == AV_PIX_FMT_RGB32 || ctx->opts.src_format == AV_PIX_FMT_RGB32_1)) + (sws->src_format == AV_PIX_FMT_RGB32 || sws->src_format == AV_PIX_FMT_RGB32_1)) bench_new(dst1_y, src, NULL, NULL, w, ctx->input_rgb2yuv_table, NULL); } } } } -static void check_rgb_to_uv(SwsInternal *ctx) +static void check_rgb_to_uv(SwsContext *sws) { + SwsInternal *ctx = sws_internal(sws); + LOCAL_ALIGNED_16(uint8_t, src24, [MAX_LINE_SIZE * 3]); LOCAL_ALIGNED_16(uint8_t, src32, [MAX_LINE_SIZE * 4]); LOCAL_ALIGNED_16(uint8_t, dst0_u, [MAX_LINE_SIZE * 2]); @@ -417,8 +422,8 @@ static void check_rgb_to_uv(SwsInternal *ctx) const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src_fmt); ctx->chrSrcHSubSample = (i % 2) ? 0 : 1; - ctx->opts.src_format = src_fmt; - ctx->opts.dst_format = ctx->chrSrcHSubSample ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV444P; + sws->src_format = src_fmt; + sws->dst_format = ctx->chrSrcHSubSample ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV444P; ff_sws_init_scale(ctx); for (int j = 0; j < FF_ARRAY_ELEMS(input_sizes); j++) { @@ -441,7 +446,7 @@ static void check_rgb_to_uv(SwsInternal *ctx) if (desc->nb_components == 3 || // only bench native endian formats - (ctx->opts.src_format == AV_PIX_FMT_RGB32 || ctx->opts.src_format == AV_PIX_FMT_RGB32_1)) + (sws->src_format == AV_PIX_FMT_RGB32 || sws->src_format == AV_PIX_FMT_RGB32_1)) bench_new(dst1_u, dst1_v, NULL, src, src, w, ctx->input_rgb2yuv_table, NULL); } } @@ -451,7 +456,6 @@ static void check_rgb_to_uv(SwsInternal *ctx) void checkasm_check_sw_rgb(void) { SwsContext *sws; - SwsInternal *c; ff_sws_rgb2rgb_init(); @@ -485,14 +489,13 @@ void checkasm_check_sw_rgb(void) if (!sws) fail(); - c = sws_internal(sws); - check_rgb_to_y(c); + check_rgb_to_y(sws); report("rgb_to_y"); - check_rgb_to_uv(c); + check_rgb_to_uv(sws); report("rgb_to_uv"); - check_rgb24toyv12(c); + check_rgb24toyv12(sws); report("rgb24toyv12"); sws_freeContext(sws); diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c index 82e2b1d5ce..350f2b73d4 100644 --- a/tests/checkasm/sw_scale.c +++ b/tests/checkasm/sw_scale.c @@ -123,12 +123,12 @@ static void check_yuv2yuv1(int accurate) randomize_buffers((uint8_t*)dither, 8); randomize_buffers((uint8_t*)src_pixels, LARGEST_INPUT_SIZE * sizeof(int16_t)); sws = sws_alloc_context(); - c = sws_internal(sws); if (accurate) - c->opts.flags |= SWS_ACCURATE_RND; + sws->flags |= SWS_ACCURATE_RND; if (sws_init_context(sws, NULL, NULL) < 0) fail(); + c = sws_internal(sws); ff_sws_init_scale(c); for (isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi) { dstW = input_sizes[isi]; @@ -190,12 +190,12 @@ static void check_yuv2yuvX(int accurate) memset(dither, d_val, LARGEST_INPUT_SIZE); randomize_buffers((uint8_t*)src_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int16_t)); sws = sws_alloc_context(); - c = sws_internal(sws); if (accurate) - c->opts.flags |= SWS_ACCURATE_RND; + sws->flags |= SWS_ACCURATE_RND; if (sws_init_context(sws, NULL, NULL) < 0) fail(); + c = sws_internal(sws); ff_sws_init_scale(c); for(isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); ++isi){ dstW = input_sizes[isi]; @@ -341,20 +341,20 @@ static void check_hscale(void) filter[SRC_PIXELS * width + i] = rnd(); } - c->opts.dst_w = c->chrDstW = input_sizes[dstWi]; + sws->dst_w = c->chrDstW = input_sizes[dstWi]; ff_sws_init_scale(c); memcpy(filterAvx2, filter, sizeof(uint16_t) * (SRC_PIXELS * MAX_FILTER_WIDTH + MAX_FILTER_WIDTH)); - ff_shuffle_filter_coefficients(c, filterPosAvx, width, filterAvx2, c->opts.dst_w); + ff_shuffle_filter_coefficients(c, filterPosAvx, width, filterAvx2, sws->dst_w); - if (check_func(c->hcScale, "hscale_%d_to_%d__fs_%d_dstW_%d", c->srcBpc, c->dstBpc + 1, width, c->opts.dst_w)) { + if (check_func(c->hcScale, "hscale_%d_to_%d__fs_%d_dstW_%d", c->srcBpc, c->dstBpc + 1, width, sws->dst_w)) { memset(dst0, 0, SRC_PIXELS * sizeof(dst0[0])); memset(dst1, 0, SRC_PIXELS * sizeof(dst1[0])); - call_ref(NULL, dst0, c->opts.dst_w, src, filter, filterPos, width); - call_new(NULL, dst1, c->opts.dst_w, src, filterAvx2, filterPosAvx, width); - if (memcmp(dst0, dst1, c->opts.dst_w * sizeof(dst0[0]))) + call_ref(NULL, dst0, sws->dst_w, src, filter, filterPos, width); + call_new(NULL, dst1, sws->dst_w, src, filterAvx2, filterPosAvx, width); + if (memcmp(dst0, dst1, sws->dst_w * sizeof(dst0[0]))) fail(); - bench_new(NULL, dst0, c->opts.dst_w, src, filter, filterPosAvx, width); + bench_new(NULL, dst0, sws->dst_w, src, filter, filterPosAvx, width); } } } |