mirror of https://git.ffmpeg.org/ffmpeg.git
checkasm/sw_range_convert: test all supported bit depths
This commit also reduces the number of times ff_sws_init_scale() gets called (only once per bit depth), and the number of times randomize_buffers() gets called (only if the function must be checked). Benchmarks are only performed on bit depths 8 and 16 (since they are different functions, and not only different constants).
This commit is contained in:
parent
2c44393c01
commit
031d98790e
|
@ -28,6 +28,33 @@
|
||||||
|
|
||||||
#include "checkasm.h"
|
#include "checkasm.h"
|
||||||
|
|
||||||
|
static const enum AVPixelFormat pixel_formats[] = {
|
||||||
|
AV_PIX_FMT_YUV444P,
|
||||||
|
AV_PIX_FMT_YUV444P9,
|
||||||
|
AV_PIX_FMT_YUV444P10,
|
||||||
|
AV_PIX_FMT_YUV444P12,
|
||||||
|
AV_PIX_FMT_YUV444P14,
|
||||||
|
AV_PIX_FMT_YUV444P16,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void randomize_buffers(int16_t *buf0, int16_t *buf1, int bit_depth, int width)
|
||||||
|
{
|
||||||
|
int32_t *buf0_32 = (int32_t *) buf0;
|
||||||
|
int32_t *buf1_32 = (int32_t *) buf1;
|
||||||
|
int mask = (1 << bit_depth) - 1;
|
||||||
|
int src_shift = bit_depth <= 14 ? 15 - bit_depth : 19 - bit_depth;
|
||||||
|
for (int i = 0; i < width; i++) {
|
||||||
|
int32_t r = rnd() & mask;
|
||||||
|
if (bit_depth == 16) {
|
||||||
|
buf0_32[i] = r << src_shift;
|
||||||
|
buf1_32[i] = r << src_shift;
|
||||||
|
} else {
|
||||||
|
buf0[i] = r << src_shift;
|
||||||
|
buf1[i] = r << src_shift;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void check_lumConvertRange(int from)
|
static void check_lumConvertRange(int from)
|
||||||
{
|
{
|
||||||
const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg";
|
const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg";
|
||||||
|
@ -36,8 +63,8 @@ static void check_lumConvertRange(int from)
|
||||||
SwsContext *sws;
|
SwsContext *sws;
|
||||||
SwsInternal *c;
|
SwsInternal *c;
|
||||||
|
|
||||||
LOCAL_ALIGNED_32(int16_t, dst0, [LARGEST_INPUT_SIZE]);
|
LOCAL_ALIGNED_32(int16_t, dst0, [LARGEST_INPUT_SIZE * 2]);
|
||||||
LOCAL_ALIGNED_32(int16_t, dst1, [LARGEST_INPUT_SIZE]);
|
LOCAL_ALIGNED_32(int16_t, dst1, [LARGEST_INPUT_SIZE * 2]);
|
||||||
|
|
||||||
declare_func(void, int16_t *dst, int width);
|
declare_func(void, int16_t *dst, int width);
|
||||||
|
|
||||||
|
@ -46,28 +73,31 @@ static void check_lumConvertRange(int from)
|
||||||
fail();
|
fail();
|
||||||
|
|
||||||
c = sws_internal(sws);
|
c = sws_internal(sws);
|
||||||
c->srcFormat = AV_PIX_FMT_YUV444P;
|
|
||||||
c->dstFormat = AV_PIX_FMT_YUV444P;
|
|
||||||
c->srcRange = from;
|
c->srcRange = from;
|
||||||
c->dstRange = !from;
|
c->dstRange = !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->srcFormat = pix_fmt;
|
||||||
|
c->dstFormat = pix_fmt;
|
||||||
|
c->dstBpc = bit_depth;
|
||||||
|
ff_sws_init_scale(c);
|
||||||
for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
|
for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
|
||||||
int width = input_sizes[dstWi];
|
int width = input_sizes[dstWi];
|
||||||
for (int i = 0; i < width; i++) {
|
if (check_func(c->lumConvertRange, "%s%d_%d", func_str, bit_depth, width)) {
|
||||||
uint8_t r = rnd();
|
randomize_buffers(dst0, dst1, bit_depth, width);
|
||||||
dst0[i] = (int16_t) r << 7;
|
|
||||||
dst1[i] = (int16_t) r << 7;
|
|
||||||
}
|
|
||||||
ff_sws_init_scale(c);
|
|
||||||
if (check_func(c->lumConvertRange, "%s_%d", func_str, width)) {
|
|
||||||
call_ref(dst0, width);
|
call_ref(dst0, width);
|
||||||
call_new(dst1, width);
|
call_new(dst1, width);
|
||||||
if (memcmp(dst0, dst1, width * sizeof(int16_t)))
|
if (memcmp(dst0, dst1, width * sample_size))
|
||||||
fail();
|
fail();
|
||||||
if (width == LARGEST_INPUT_SIZE)
|
if (width == LARGEST_INPUT_SIZE && (bit_depth == 8 || bit_depth == 16))
|
||||||
bench_new(dst1, width);
|
bench_new(dst1, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sws_freeContext(sws);
|
sws_freeContext(sws);
|
||||||
}
|
}
|
||||||
|
@ -81,10 +111,10 @@ static void check_chrConvertRange(int from)
|
||||||
SwsContext *sws;
|
SwsContext *sws;
|
||||||
SwsInternal *c;
|
SwsInternal *c;
|
||||||
|
|
||||||
LOCAL_ALIGNED_32(int16_t, dstU0, [LARGEST_INPUT_SIZE]);
|
LOCAL_ALIGNED_32(int16_t, dstU0, [LARGEST_INPUT_SIZE * 2]);
|
||||||
LOCAL_ALIGNED_32(int16_t, dstV0, [LARGEST_INPUT_SIZE]);
|
LOCAL_ALIGNED_32(int16_t, dstV0, [LARGEST_INPUT_SIZE * 2]);
|
||||||
LOCAL_ALIGNED_32(int16_t, dstU1, [LARGEST_INPUT_SIZE]);
|
LOCAL_ALIGNED_32(int16_t, dstU1, [LARGEST_INPUT_SIZE * 2]);
|
||||||
LOCAL_ALIGNED_32(int16_t, dstV1, [LARGEST_INPUT_SIZE]);
|
LOCAL_ALIGNED_32(int16_t, dstV1, [LARGEST_INPUT_SIZE * 2]);
|
||||||
|
|
||||||
declare_func(void, int16_t *dstU, int16_t *dstV, int width);
|
declare_func(void, int16_t *dstU, int16_t *dstV, int width);
|
||||||
|
|
||||||
|
@ -93,31 +123,33 @@ static void check_chrConvertRange(int from)
|
||||||
fail();
|
fail();
|
||||||
|
|
||||||
c = sws_internal(sws);
|
c = sws_internal(sws);
|
||||||
c->srcFormat = AV_PIX_FMT_YUV444P;
|
|
||||||
c->dstFormat = AV_PIX_FMT_YUV444P;
|
|
||||||
c->srcRange = from;
|
c->srcRange = from;
|
||||||
c->dstRange = !from;
|
c->dstRange = !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->srcFormat = pix_fmt;
|
||||||
|
c->dstFormat = pix_fmt;
|
||||||
|
c->dstBpc = bit_depth;
|
||||||
|
ff_sws_init_scale(c);
|
||||||
for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
|
for (int dstWi = 0; dstWi < FF_ARRAY_ELEMS(input_sizes); dstWi++) {
|
||||||
int width = input_sizes[dstWi];
|
int width = input_sizes[dstWi];
|
||||||
for (int i = 0; i < width; i++) {
|
if (check_func(c->chrConvertRange, "%s%d_%d", func_str, bit_depth, width)) {
|
||||||
uint8_t r = rnd();
|
randomize_buffers(dstU0, dstU1, bit_depth, width);
|
||||||
dstU0[i] = (int16_t) r << 7;
|
randomize_buffers(dstV0, dstV1, bit_depth, width);
|
||||||
dstV0[i] = (int16_t) r << 7;
|
|
||||||
dstU1[i] = (int16_t) r << 7;
|
|
||||||
dstV1[i] = (int16_t) r << 7;
|
|
||||||
}
|
|
||||||
ff_sws_init_scale(c);
|
|
||||||
if (check_func(c->chrConvertRange, "%s_%d", func_str, width)) {
|
|
||||||
call_ref(dstU0, dstV0, width);
|
call_ref(dstU0, dstV0, width);
|
||||||
call_new(dstU1, dstV1, width);
|
call_new(dstU1, dstV1, width);
|
||||||
if (memcmp(dstU0, dstU1, width * sizeof(int16_t)) ||
|
if (memcmp(dstU0, dstU1, width * sample_size) ||
|
||||||
memcmp(dstV0, dstV1, width * sizeof(int16_t)))
|
memcmp(dstV0, dstV1, width * sample_size))
|
||||||
fail();
|
fail();
|
||||||
if (width == LARGEST_INPUT_SIZE)
|
if (width == LARGEST_INPUT_SIZE && (bit_depth == 8 || bit_depth == 16))
|
||||||
bench_new(dstU1, dstV1, width);
|
bench_new(dstU1, dstV1, width);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sws_freeContext(sws);
|
sws_freeContext(sws);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue