Commit 507aa4c9 authored by Niklas Haas's avatar Niklas Haas

tests: test av1 film grain synthesis

Turns out, doing this improves coverage massively. :-)
parent 762de151
Pipeline #3890 passed with stages
in 2 minutes and 3 seconds
......@@ -276,42 +276,11 @@ static void bench_hdr_desat(struct pl_shader *sh, struct pl_shader_obj **state,
NULL, false);
}
static const struct pl_grain_params grain_params = {
.width = TEX_SIZE,
.height = TEX_SIZE,
.repr = {
.sys = PL_COLOR_SYSTEM_BT_709,
.levels = PL_COLOR_LEVELS_TV,
.bits = { .color_depth = 10, .sample_depth = 10 },
},
.grain_seed = 48476,
.num_points_y = 6,
.points_y = {{0, 4}, {27, 33}, {54, 55}, {67, 61}, {108, 71}, {255, 72}},
.chroma_scaling_from_luma = false,
.num_points_uv = {2, 2},
.points_uv = {{{0, 64}, {255, 64}}, {{0, 64}, {255, 64}}},
.scaling_shift = 11,
.ar_coeff_lag = 3,
.ar_coeffs_y = {4, 1, 3, 0, 1, -3, 8, -3, 7, -23, 1, -25,
0, -10, 6, -17, -4, 53, 36, 5, -5, -17, 8, 66},
.ar_coeffs_uv = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127},
},
.ar_coeff_shift = 7,
.grain_scale_shift = 0,
.uv_mult = {0, 0},
.uv_mult_luma = {64, 64},
.uv_offset = {0, 0},
};
static void bench_av1_grain(struct pl_shader *sh, struct pl_shader_obj **state,
const struct pl_tex *src)
{
struct pl_grain_params params = grain_params;
struct pl_grain_params params = av1_grain_params;
params.width = params.height = TEX_SIZE;
params.grain_seed = rand();
pl_shader_sample_direct(sh, &(struct pl_sample_src) { .tex = src });
......@@ -321,7 +290,8 @@ static void bench_av1_grain(struct pl_shader *sh, struct pl_shader_obj **state,
static void bench_av1_grain_lap(struct pl_shader *sh, struct pl_shader_obj **state,
const struct pl_tex *src)
{
struct pl_grain_params params = grain_params;
struct pl_grain_params params = av1_grain_params;
params.width = params.height = TEX_SIZE;
params.grain_seed = rand();
params.overlap = true;
......
......@@ -250,6 +250,22 @@ static void pl_shader_tests(const struct pl_gpu *gpu)
pl_shader_obj_destroy(&lut3d);
#endif
// Test AV1 grain synthesis
struct pl_shader_obj *grain = NULL;
for (int i = 0; i < 2; i++) {
struct pl_grain_params grain_params = av1_grain_params;
grain_params.width = FBO_W;
grain_params.height = FBO_H;
grain_params.grain_seed = rand();
grain_params.overlap = !!i;
sh = pl_dispatch_begin(dp);
pl_shader_sample_direct(sh, &(struct pl_sample_src) { .tex = src });
pl_shader_av1_grain(sh, &grain, (enum pl_channel[]){0, 1, 2}, NULL,
&grain_params);
REQUIRE(pl_dispatch_finish(dp, &sh, fbo, NULL, NULL));
}
pl_shader_obj_destroy(&grain);
pl_dispatch_destroy(&dp);
pl_tex_destroy(gpu, &src);
pl_tex_destroy(gpu, &fbo);
......
......@@ -51,3 +51,33 @@ static inline bool feq(float a, float b)
#define REQUIRE(cond) require((cond), #cond)
#define RANDOM (rand() / (float) RAND_MAX)
#define SKIP 77
static const struct pl_grain_params av1_grain_params = {
.repr = {
.sys = PL_COLOR_SYSTEM_BT_709,
.levels = PL_COLOR_LEVELS_TV,
.bits = { .color_depth = 10, .sample_depth = 10 },
},
.grain_seed = 48476,
.num_points_y = 6,
.points_y = {{0, 4}, {27, 33}, {54, 55}, {67, 61}, {108, 71}, {255, 72}},
.chroma_scaling_from_luma = false,
.num_points_uv = {2, 2},
.points_uv = {{{0, 64}, {255, 64}}, {{0, 64}, {255, 64}}},
.scaling_shift = 11,
.ar_coeff_lag = 3,
.ar_coeffs_y = {4, 1, 3, 0, 1, -3, 8, -3, 7, -23, 1, -25,
0, -10, 6, -17, -4, 53, 36, 5, -5, -17, 8, 66},
.ar_coeffs_uv = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127},
},
.ar_coeff_shift = 7,
.grain_scale_shift = 0,
.uv_mult = {0, 0},
.uv_mult_luma = {64, 64},
.uv_offset = {0, 0},
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment