Branch data Line data Source code
1 : : #include "utils.h" 2 : : 3 : : #include <libplacebo/dither.h> 4 : : #include <libplacebo/shaders/dithering.h> 5 : : 6 : : #define SHIFT 4 7 : : #define SIZE (1 << SHIFT) 8 : : float data[SIZE][SIZE]; 9 : : 10 : 1 : int main() 11 : : { 12 : : printf("Ordered dither matrix:\n"); 13 : 1 : pl_generate_bayer_matrix(&data[0][0], SIZE); 14 [ + + ]: 17 : for (int y = 0; y < SIZE; y++) { 15 [ + + ]: 272 : for (int x = 0; x < SIZE; x++) 16 : 256 : printf(" %3d", (int)(data[y][x] * SIZE * SIZE)); 17 : : printf("\n"); 18 : : } 19 : : 20 : : printf("Blue noise dither matrix:\n"); 21 : 1 : pl_generate_blue_noise(&data[0][0], SHIFT); 22 [ + + ]: 17 : for (int y = 0; y < SIZE; y++) { 23 [ + + ]: 272 : for (int x = 0; x < SIZE; x++) 24 : 256 : printf(" %3d", (int)(data[y][x] * SIZE * SIZE)); 25 : : printf("\n"); 26 : : } 27 : : 28 : : // Generate an example of a dither shader 29 : 1 : pl_log log = pl_test_logger(); 30 : 1 : pl_shader sh = pl_shader_alloc(log, NULL); 31 : 1 : pl_shader_obj obj = NULL; 32 : : 33 : 1 : pl_shader_dither(sh, 8, &obj, NULL); 34 : 1 : const struct pl_shader_res *res = pl_shader_finalize(sh); 35 [ - + ]: 1 : REQUIRE(res); 36 : 1 : printf("Generated dither shader:\n%s\n", res->glsl); 37 : : 38 : 1 : pl_shader_obj_destroy(&obj); 39 : 1 : pl_shader_free(&sh); 40 : 1 : pl_log_destroy(&log); 41 : : }