2019-08-27 22:29:46 +00:00
|
|
|
#include "zrle.h"
|
|
|
|
#include "rfb-proto.h"
|
|
|
|
#include "util.h"
|
|
|
|
#include "vec.h"
|
2019-08-29 21:47:02 +00:00
|
|
|
#include "neatvnc.h"
|
2019-08-27 22:29:46 +00:00
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <libdrm/drm_fourcc.h>
|
|
|
|
#include <pixman.h>
|
|
|
|
|
2019-08-29 21:47:02 +00:00
|
|
|
int read_png_file(struct nvnc_fb* fb, const char *filename);
|
2019-08-27 22:29:46 +00:00
|
|
|
|
|
|
|
int run_benchmark(const char *image)
|
|
|
|
{
|
|
|
|
int rc = -1;
|
|
|
|
|
2019-08-29 21:47:02 +00:00
|
|
|
struct nvnc_fb fb;
|
2019-08-27 22:29:46 +00:00
|
|
|
rc = read_png_file(&fb, image);
|
|
|
|
if (rc < 0)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
struct rfb_pixel_format pixfmt;
|
|
|
|
rfb_pixfmt_from_fourcc(&pixfmt, DRM_FORMAT_ARGB8888);
|
|
|
|
|
|
|
|
struct pixman_region16 region;
|
|
|
|
pixman_region_init(®ion);
|
|
|
|
|
|
|
|
pixman_region_union_rect(®ion, ®ion, 0, 0, fb.width, fb.height);
|
|
|
|
|
|
|
|
struct vec frame;
|
|
|
|
vec_init(&frame, fb.width * fb.height * 3 / 2);
|
|
|
|
|
|
|
|
rc = zrle_encode_frame(&frame, &pixfmt, fb.addr, &pixfmt,
|
|
|
|
fb.width, fb.height, ®ion);
|
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
goto failure;
|
|
|
|
|
|
|
|
rc = 0;
|
|
|
|
failure:
|
|
|
|
pixman_region_fini(®ion);
|
|
|
|
vec_destroy(&frame);
|
|
|
|
free(fb.addr);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int rc = 0;
|
|
|
|
|
|
|
|
char *image = argv[1];
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
return run_benchmark(image) < 0 ? 1 :0;
|
|
|
|
|
|
|
|
rc |= run_benchmark("test-images/tv-test-card.png") < 0 ? 1 : 0;
|
|
|
|
rc |= run_benchmark("test-images/lena-soderberg.png") < 0 ? 1 : 0;
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|