[x265] [PATCH] Fix testbench crash with dhdr10 enabled
bhavna at multicorewareinc.com
bhavna at multicorewareinc.com
Wed Aug 2 18:17:31 CEST 2017
# HG changeset patch
# User Bhavna Hariharan <bhavna at multicorewareinc.com>
# Date 1501680985 -19800
# Wed Aug 02 19:06:25 2017 +0530
# Node ID 041fcaf820659d504d887cfaa239a02988812c14
# Parent d11482e5fedbcdaf62ee3c6872f43827d99ad181
Fix testbench crash with dhdr10 enabled
__rdtsc() was being defined multiple times causing failure in testbench.
This patch renames the function and duplicates the REPORT_SPEEDUP macro that
supports GNU compiler.
Display warning when dhdr10 is enabled with MSVC version that does not
support c++11.
diff -r d11482e5fedb -r 041fcaf82065 source/CMakeLists.txt
--- a/source/CMakeLists.txt Mon Jul 24 11:15:38 2017 +0530
+++ b/source/CMakeLists.txt Wed Aug 02 19:06:25 2017 +0530
@@ -184,6 +184,9 @@
endif()
# this option is to enable the inclusion of dynamic HDR10 library to the libx265 compilation
option(ENABLE_HDR10_PLUS "Enable dynamic HDR10 compilation" OFF)
+if(MSVC AND (MSVC_VERSION LESS 1800) AND ENABLE_HDR10_PLUS)
+ message(FATAL_ERROR "MSVC version 12.0 or above required to support hdr10plus")
+endif()
if(GCC)
add_definitions(-Wall -Wextra -Wshadow)
add_definitions(-D__STDC_LIMIT_MACROS=1)
diff -r d11482e5fedb -r 041fcaf82065 source/dynamicHDR10/metadataFromJson.cpp
--- a/source/dynamicHDR10/metadataFromJson.cpp Mon Jul 24 11:15:38 2017 +0530
+++ b/source/dynamicHDR10/metadataFromJson.cpp Wed Aug 02 19:06:25 2017 +0530
@@ -34,8 +34,6 @@
#include "BasicStructures.h"
#include "SeiMetadataDictionary.h"
-#define M_PI 3.14159265358979323846
-
using namespace SeiMetadataDictionary;
class metadataFromJson::DynamicMetaIO
diff -r d11482e5fedb -r 041fcaf82065 source/test/testharness.h
--- a/source/test/testharness.h Mon Jul 24 11:15:38 2017 +0530
+++ b/source/test/testharness.h Wed Aug 02 19:06:25 2017 +0530
@@ -70,7 +70,7 @@
#include <intrin.h>
#elif defined(__GNUC__)
/* fallback for older GCC/MinGW */
-static inline uint32_t __rdtsc(void)
+static inline uint32_t rdtsc(void)
{
uint32_t a = 0;
@@ -92,6 +92,41 @@
// Adapted from checkasm.c, runs each optimized primitive four times, measures rdtsc
// and discards invalid times. Repeats 1000 times to get a good average. Then measures
// the C reference with fewer runs and reports X factor and average cycles.
+
+// Duplicate macro to avoid conflict with in-built function __rdtsc()
+#if defined(__GNUC__)
+#define REPORT_SPEEDUP(RUNOPT, RUNREF, ...) \
+ { \
+ uint32_t cycles = 0; int runs = 0; \
+ RUNOPT(__VA_ARGS__); \
+ for (int ti = 0; ti < BENCH_RUNS; ti++) { \
+ uint32_t t0 = (uint32_t)rdtsc(); \
+ RUNOPT(__VA_ARGS__); \
+ RUNOPT(__VA_ARGS__); \
+ RUNOPT(__VA_ARGS__); \
+ RUNOPT(__VA_ARGS__); \
+ uint32_t t1 = (uint32_t)rdtsc() - t0; \
+ if (t1 * runs <= cycles * 4 && ti > 0) { cycles += t1; runs++; } \
+ } \
+ uint32_t refcycles = 0; int refruns = 0; \
+ RUNREF(__VA_ARGS__); \
+ for (int ti = 0; ti < BENCH_RUNS / 4; ti++) { \
+ uint32_t t0 = (uint32_t)rdtsc(); \
+ RUNREF(__VA_ARGS__); \
+ RUNREF(__VA_ARGS__); \
+ RUNREF(__VA_ARGS__); \
+ RUNREF(__VA_ARGS__); \
+ uint32_t t1 = (uint32_t)rdtsc() - t0; \
+ if (t1 * refruns <= refcycles * 4 && ti > 0) { refcycles += t1; refruns++; } \
+ } \
+ x265_emms(); \
+ float optperf = (10.0f * cycles / runs) / 4; \
+ float refperf = (10.0f * refcycles / refruns) / 4; \
+ printf("\t%3.2fx ", refperf / optperf); \
+ printf("\t %-8.2lf \t %-8.2lf\n", optperf, refperf); \
+ }
+
+#else
#define REPORT_SPEEDUP(RUNOPT, RUNREF, ...) \
{ \
uint32_t cycles = 0; int runs = 0; \
@@ -123,6 +158,7 @@
printf("\t %-8.2lf \t %-8.2lf\n", optperf, refperf); \
}
+#endif
extern "C" {
#if X265_ARCH_X86
int PFX(stack_pagealign)(int (*func)(), int align);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: x265-clone.patch
Type: text/x-patch
Size: 3954 bytes
Desc: not available
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20170802/e6e7031d/attachment.bin>
More information about the x265-devel
mailing list