Add benchmark for zrle
parent
712215cc73
commit
f31b5a6915
|
@ -1,5 +1,8 @@
|
|||
.clang_complete
|
||||
src/*.o
|
||||
src/*.o.deps
|
||||
*/*.o
|
||||
*/*.o.deps
|
||||
neatvnc
|
||||
vgcore.*
|
||||
perf.data
|
||||
perf.data.old
|
||||
zrle-bench
|
||||
|
|
11
Makefile
11
Makefile
|
@ -2,7 +2,7 @@ all: neatvnc
|
|||
|
||||
DEPENDENCIES := pixman-1 libpng libuv
|
||||
|
||||
CFLAGS := -g -O0 -std=gnu11 -D_GNU_SOURCE -Iinc \
|
||||
CFLAGS := -g -O3 -DNDEBUG -std=gnu11 -D_GNU_SOURCE -Iinc \
|
||||
$(foreach dep,$(DEPENDENCIES),$(shell pkg-config --cflags $(dep)))
|
||||
|
||||
LDFLAGS := $(foreach dep,$(DEPENDENCIES),$(shell pkg-config --libs $(dep)))
|
||||
|
@ -10,13 +10,20 @@ LDFLAGS := $(foreach dep,$(DEPENDENCIES),$(shell pkg-config --libs $(dep)))
|
|||
neatvnc: src/server.o src/util.o src/vec.o src/zrle.o src/pngfb.o
|
||||
$(CC) $^ $(LDFLAGS) -o $@
|
||||
|
||||
zrle-bench: bench/zrle-bench.o src/server.o src/util.o src/vec.o src/zrle.o \
|
||||
src/pngfb.o
|
||||
$(CC) $^ $(LDFLAGS) -o $@
|
||||
|
||||
src/%.o: src/%.c
|
||||
$(CC) -c $(CFLAGS) $< -o $@ -MMD -MP -MF $@.deps
|
||||
|
||||
bench/%.o: bench/%.c
|
||||
$(CC) -c $(CFLAGS) $< -o $@ -MMD -MP -MF $@.deps
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -f neatvnc
|
||||
rm -f src/*.o src/*.deps
|
||||
rm -f src/*.o src/*.deps bench/*.o bench/*.deps
|
||||
|
||||
-include src/*.deps
|
||||
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
#include "zrle.h"
|
||||
#include "rfb-proto.h"
|
||||
#include "util.h"
|
||||
#include "vec.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <libdrm/drm_fourcc.h>
|
||||
#include <pixman.h>
|
||||
|
||||
int read_png_file(struct vnc_framebuffer* fb, const char *filename);
|
||||
|
||||
int run_benchmark(const char *image)
|
||||
{
|
||||
int rc = -1;
|
||||
|
||||
struct vnc_framebuffer fb;
|
||||
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;
|
||||
}
|
|
@ -19,4 +19,6 @@ struct vnc_write_request {
|
|||
int vnc__write(uv_stream_t *stream, const void *payload, size_t size,
|
||||
uv_write_cb on_done);
|
||||
|
||||
int rfb_pixfmt_from_fourcc(struct rfb_pixel_format *dst, uint32_t src);
|
||||
|
||||
#endif /* _VNC_UTIL_H_ */
|
||||
|
|
|
@ -685,6 +685,7 @@ failure:
|
|||
|
||||
int read_png_file(struct vnc_framebuffer* fb, const char *filename);
|
||||
|
||||
/*
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (!argv[1]) {
|
||||
|
@ -709,3 +710,4 @@ int main(int argc, char *argv[])
|
|||
|
||||
uv_run(uv_default_loop(), UV_RUN_DEFAULT);
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -235,9 +235,6 @@ int zrle_encode_box(struct vec* out, const struct rfb_pixel_format *dst_fmt,
|
|||
int tile_width = width - tile_x >= 64 ? 64 : width - tile_x;
|
||||
int tile_height = height - tile_y >= 64 ? 64 : height - tile_y;
|
||||
|
||||
printf("Encoding tile @ %dx%d. width: %d, height: %d\n", tile_x,
|
||||
tile_y, tile_width, tile_height);
|
||||
|
||||
zrle_encode_tile(&in, dst_fmt,
|
||||
((uint32_t*)src) + tile_x + tile_y * width,
|
||||
src_fmt, stride, tile_width, tile_height);
|
||||
|
@ -251,7 +248,6 @@ int zrle_encode_box(struct vec* out, const struct rfb_pixel_format *dst_fmt,
|
|||
|
||||
/* There seems to be something extra at the end */
|
||||
out->len -= 4;
|
||||
printf("Encoded with size: %lu\n", out->len - size_index);
|
||||
|
||||
uint32_t out_size = htonl(out->len - size_index - 4);
|
||||
memcpy(((uint8_t*)out->data) + size_index, &out_size, sizeof(out_size));
|
||||
|
|
Loading…
Reference in New Issue