[vlc-devel] [PATCH 11/25] bench_asm: add startcode
Victorien Le Couviour--Tuffet
victorien.lecouviour.tuffet at gmail.com
Tue Apr 14 12:40:22 CEST 2020
---
test/Makefile.am | 4 +-
test/bench_asm/bench_asm.h | 2 +
test/bench_asm/main.c | 1 +
test/bench_asm/startcode_annexb.c | 67 +++++++++++++++++++++++++++++++
4 files changed, 73 insertions(+), 1 deletion(-)
create mode 100644 test/bench_asm/startcode_annexb.c
diff --git a/test/Makefile.am b/test/Makefile.am
index b21995d867..57cc271f6f 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -167,7 +167,9 @@ test_modules_demux_ts_pes_SOURCES = modules/demux/ts_pes.c \
../modules/demux/mpeg/ts_pes.c \
../modules/demux/mpeg/ts_pes.h
-test_bench_asm_SOURCES = bench_asm/main.c
+test_bench_asm_SOURCES = bench_asm/main.c \
+ bench_asm/startcode_annexb.c \
+ $(top_srcdir)/modules/packetizer/startcode.asm
test_bench_asm_LDADD = $(LIBVLCCORE)
checkall:
diff --git a/test/bench_asm/bench_asm.h b/test/bench_asm/bench_asm.h
index c75d4994fa..f915f72dab 100644
--- a/test/bench_asm/bench_asm.h
+++ b/test/bench_asm/bench_asm.h
@@ -8,6 +8,8 @@ void bench_asm_subscribe(int id, char const *name,
int (*check_feature)(int),
uint64_t (*bench)(void), bool need_warm_up);
+void subscribe_startcode_annexb(int id);
+
static inline uint64_t
read_cycle_counter(void)
{
diff --git a/test/bench_asm/main.c b/test/bench_asm/main.c
index a2a8885514..10b66fd1e2 100644
--- a/test/bench_asm/main.c
+++ b/test/bench_asm/main.c
@@ -24,6 +24,7 @@ static struct bench
bool need_warm_up;
} benchmarks[] =
{
+ { .subscribe = subscribe_startcode_annexb },
{ 0 }
};
diff --git a/test/bench_asm/startcode_annexb.c b/test/bench_asm/startcode_annexb.c
new file mode 100644
index 0000000000..7e63031bfe
--- /dev/null
+++ b/test/bench_asm/startcode_annexb.c
@@ -0,0 +1,67 @@
+#if HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <assert.h>
+#include <vlc_common.h>
+#include <vlc_cpu.h>
+#include "bench_asm.h"
+#include "../../modules/packetizer/startcode_helper.h"
+
+static uint8_t *buffer;
+
+static int
+init_startcode_FindAnnexB(void)
+{
+ buffer = calloc(4096, 1);
+ if (!buffer) return VLC_ENOMEM;
+ return VLC_SUCCESS;
+}
+
+static void
+destroy_startcode_FindAnnexB(void)
+{
+ free(buffer);
+}
+
+static uint8_t const *(*startcode_FindAnnexB)(uint8_t const *, uint8_t const *);
+
+static int
+check_feature_startcode_FindAnnexB(int flag)
+{
+ startcode_FindAnnexB = startcode_FindAnnexB_helper();
+ assert(startcode_FindAnnexB);
+ if (flag == 0)
+ return VLC_SUCCESS;
+ vlc_CPU_mask(flag);
+ int has_impl = startcode_FindAnnexB != startcode_FindAnnexB_helper();
+ vlc_CPU_unmask(flag);
+ return has_impl ? VLC_SUCCESS : VLC_EGENERIC;
+}
+
+static uint64_t
+bench_startcode_FindAnnexB(void)
+{
+ assert(startcode_FindAnnexB);
+ uint64_t cycles = 0;
+ for (int i = 0; i < 4096; ++i)
+ {
+ buffer[i] = 1;
+ uint64_t const cycles_start = read_cycle_counter();
+ startcode_FindAnnexB(buffer, buffer + 4096);
+ uint64_t const cycles_end = read_cycle_counter();
+ cycles += cycles_end - cycles_start;
+ buffer[i] = 0;
+ }
+ return (cycles + (1UL << 11)) >> 12;
+}
+
+void
+subscribe_startcode_annexb(int id)
+{
+ bench_asm_subscribe(id, "startcode_FindAnnexB",
+ init_startcode_FindAnnexB,
+ destroy_startcode_FindAnnexB,
+ check_feature_startcode_FindAnnexB,
+ bench_startcode_FindAnnexB, true);
+}
--
2.24.1
More information about the vlc-devel
mailing list