Skip to content

Commit dc4a20e

Browse files
authored
Merge pull request #443 from agruzdev/api-version
API functions for accessing version in runtime
2 parents 6040962 + c17b595 commit dc4a20e

File tree

6 files changed

+115
-11
lines changed

6 files changed

+115
-11
lines changed

CMakeLists.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
cmake_minimum_required(VERSION 3.25)
22

3+
set(KVAZAAR_VERSION_MAJOR 2)
4+
set(KVAZAAR_VERSION_MINOR 3)
5+
set(KVAZAAR_VERSION_REVISION 2)
6+
37
project(kvazaar
48
LANGUAGES C CXX
59
HOMEPAGE_URL https://github.com/ultravideo/kvazaar
610
DESCRIPTION "An open-source HEVC encoder licensed under 3-clause BSD"
7-
VERSION 2.3.2 )
11+
VERSION ${KVAZAAR_VERSION_MAJOR}.${KVAZAAR_VERSION_MINOR}.${KVAZAAR_VERSION_REVISION})
812

913
option(BUILD_SHARED_LIBS "Build using shared kvazaar library" ON)
1014

@@ -91,8 +95,10 @@ if(MSVC)
9195
set(KVZ_COMPILER_VERSION "VS2017")
9296
elseif(MSVC_VERSION LESS 1930)
9397
set(KVZ_COMPILER_VERSION "VS2019")
94-
else()
98+
elseif(MSVC_VERSION LESS 1950)
9599
set(KVZ_COMPILER_VERSION "VS2022")
100+
else()
101+
set(KVZ_COMPILER_VERSION "VS2026")
96102
endif()
97103
endif()
98104

@@ -201,6 +207,10 @@ else()
201207

202208
endif()
203209

210+
target_compile_definitions(kvazaar PUBLIC KVZ_VERSION_MAJOR=${KVAZAAR_VERSION_MAJOR})
211+
target_compile_definitions(kvazaar PUBLIC KVZ_VERSION_MINOR=${KVAZAAR_VERSION_MINOR})
212+
target_compile_definitions(kvazaar PUBLIC KVZ_VERSION_REVISION=${KVAZAAR_VERSION_REVISION})
213+
204214
target_include_directories(kvazaar PUBLIC src)
205215
target_include_directories(kvazaar PUBLIC src/extras)
206216
target_include_directories(kvazaar PUBLIC src/strategies)
@@ -249,7 +259,7 @@ else()
249259
if(BUILD_KVAZAAR_BINARY)
250260
set_target_properties(kvazaar-bin PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src)
251261
endif()
252-
set_target_properties(kvazaar PROPERTIES SOVERSION "7" VERSION "7.4.0")
262+
set_target_properties(kvazaar PROPERTIES SOVERSION "7" VERSION "7.6.0")
253263
if(${CMAKE_SYSTEM_PROCESSOR} IN_LIST ALLOW_AVX2)
254264
set_property( SOURCE ${LIB_SOURCES_STRATEGIES_AVX2} APPEND PROPERTY COMPILE_FLAGS "-mavx2 -mbmi -mpopcnt -mlzcnt -mbmi2" )
255265
set_property( SOURCE ${LIB_SOURCES_STRATEGIES_SSE41} APPEND PROPERTY COMPILE_FLAGS "-msse4.1" )

build/kvazaar_lib/kvazaar_lib.vcxproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,9 @@
8080
<AdditionalDependencies>
8181
</AdditionalDependencies>
8282
</Lib>
83+
<ClCompile>
84+
<PreprocessorDefinitions>KVZ_VERSION_MAJOR=2;KVZ_VERSION_MINOR=3;KVZ_VERSION_REVISION=2;KVZ_COMPILER_STRING="VS2015";KVZ_COMPILE_DATE="2026-01-20";%(PreprocessorDefinitions)</PreprocessorDefinitions>
85+
</ClCompile>
8386
</ItemDefinitionGroup>
8487
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
8588
<Lib>
@@ -91,6 +94,7 @@
9194
<ClCompile>
9295
<UndefinePreprocessorDefinitions>
9396
</UndefinePreprocessorDefinitions>
97+
<PreprocessorDefinitions>KVZ_VERSION_MAJOR=2;KVZ_VERSION_MINOR=3;KVZ_VERSION_REVISION=2;KVZ_COMPILER_STRING="VS2015";KVZ_COMPILE_DATE="2026-01-20";%(PreprocessorDefinitions)</PreprocessorDefinitions>
9498
</ClCompile>
9599
</ItemDefinitionGroup>
96100
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
@@ -103,6 +107,7 @@
103107
<ClCompile>
104108
<UndefinePreprocessorDefinitions>
105109
</UndefinePreprocessorDefinitions>
110+
<PreprocessorDefinitions>KVZ_VERSION_MAJOR=2;KVZ_VERSION_MINOR=3;KVZ_VERSION_REVISION=2;KVZ_COMPILER_STRING="VS2015";KVZ_COMPILE_DATE="2026-01-20";%(PreprocessorDefinitions)</PreprocessorDefinitions>
106111
</ClCompile>
107112
</ItemDefinitionGroup>
108113
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@@ -115,6 +120,7 @@
115120
<ClCompile>
116121
<UndefinePreprocessorDefinitions>
117122
</UndefinePreprocessorDefinitions>
123+
<PreprocessorDefinitions>KVZ_VERSION_MAJOR=2;KVZ_VERSION_MINOR=3;KVZ_VERSION_REVISION=2;KVZ_COMPILER_STRING="VS2015";KVZ_COMPILE_DATE="2026-01-20";%(PreprocessorDefinitions)</PreprocessorDefinitions>
118124
</ClCompile>
119125
</ItemDefinitionGroup>
120126
<ItemGroup>

configure.ac

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,13 @@ AC_CONFIG_SRCDIR([src/encmain.c])
2323
#
2424
# Here is a somewhat sane guide to lib versioning: http://apr.apache.org/versioning.html
2525
ver_major=7
26-
ver_minor=5
26+
ver_minor=6
2727
ver_release=0
2828

29+
kvz_pjt_ver_major=2
30+
kvz_pjt_ver_minor=3
31+
kvz_pjt_ver_revision=2
32+
2933
# Prevents configure from adding a lot of defines to the CFLAGS
3034
AC_CONFIG_HEADERS([config.h])
3135

@@ -75,6 +79,8 @@ AM_CONDITIONAL([HAVE_SSE2], [test x"$flag_sse2" = x"true"])
7579

7680
KVZ_CFLAGS="-Wall -Wextra -Wvla -Wno-sign-compare -Wno-unused-parameter -I$srcdir/src -I$srcdir/src/extras -ftree-vectorize -fvisibility=hidden"
7781
CFLAGS="$KVZ_CFLAGS $CFLAGS"
82+
CFLAGS="-DKVZ_VERSION_MAJOR=$kvz_pjt_ver_major -DKVZ_VERSION_MINOR=$kvz_pjt_ver_minor -DKVZ_VERSION_REVISION=$kvz_pjt_ver_revision $CFLAGS"
83+
7884

7985
AC_SEARCH_LIBS([log], [m c], [], [exit 1])
8086
AC_SEARCH_LIBS([pow], [m c], [], [exit 1])
@@ -103,7 +109,6 @@ LIBS="$LIBS $cryptopp_LIBS"
103109

104110
CPPFLAGS="-DKVZ_DLL_EXPORTS $CPPFLAGS"
105111

106-
107112
# We need to force AX_PTHREAD to check -pthread -lpthread since otherwise
108113
# it only outputs -pthread for GCC. Without -lpthread GCC does not link the
109114
# shared library against the pthread library (even though it does link the
@@ -118,6 +123,14 @@ CFLAGS="$PTHREAD_CFLAGS $CFLAGS"
118123
LIBS="$PTHREAD_LIBS $LIBS"
119124
CC="$PTHREAD_CC"
120125

126+
compiler_name=`basename $CC`
127+
escaped_compiler_name='\"'$compiler_name'\"'
128+
CFLAGS="-DKVZ_COMPILER_STRING=$escaped_compiler_name $CFLAGS"
129+
130+
compile_date=`date -u +"%Y-%m-%d"`
131+
escaped_compile_date='\"'$compile_date'\"'
132+
CFLAGS="-DKVZ_COMPILE_DATE=$escaped_compile_date $CFLAGS"
133+
121134
# --enable-werror
122135
AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [treat warnings as errors [no]])],
123136
[CFLAGS="-Werror $CFLAGS"], []

src/cli.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,9 @@ void print_usage(void)
394394
void print_version(void)
395395
{
396396
fprintf(stdout,
397-
#ifdef CMAKE_BUILD
398-
"kvazaar " VERSION_STRING " [" KVZ_COMPILER_STRING "] " KVZ_COMPILE_DATE "\n");
399-
#else
400-
"Kvazaar " VERSION_STRING "\n"
401-
"Kvazaar license: 3-clause BSD\n");
402-
#endif
397+
"Kvazaar %s [%s] %s\n"
398+
"Kvazaar license: 3-clause BSD\n",
399+
kvz_get_version_string(), kvz_get_compiler_string(), kvz_get_compile_date_string());
403400
}
404401

405402

src/kvazaar.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,3 +416,39 @@ const kvz_api * kvz_api_get(int bit_depth)
416416
{
417417
return &kvz_8bit_api;
418418
}
419+
420+
421+
const char * kvz_get_version_string()
422+
{
423+
return VERSION_STRING;
424+
}
425+
426+
427+
int kvz_get_version_major()
428+
{
429+
return KVZ_VERSION_MAJOR;
430+
}
431+
432+
433+
int kvz_get_version_minor()
434+
{
435+
return KVZ_VERSION_MINOR;
436+
}
437+
438+
439+
int kvz_get_version_revision()
440+
{
441+
return KVZ_VERSION_REVISION;
442+
}
443+
444+
445+
const char * kvz_get_compiler_string()
446+
{
447+
return KVZ_COMPILER_STRING;
448+
}
449+
450+
451+
const char * kvz_get_compile_date_string()
452+
{
453+
return KVZ_COMPILE_DATE;
454+
}

src/kvazaar.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,48 @@ typedef struct kvz_api {
828828

829829
KVZ_PUBLIC const kvz_api * kvz_api_get(int bit_depth);
830830

831+
832+
/**
833+
* \brief Return version string
834+
*
835+
* Returns version string in format MAJOR.MINOR.REVISION
836+
*
837+
*/
838+
KVZ_PUBLIC const char * kvz_get_version_string();
839+
840+
841+
/**
842+
* \brief Return major version number
843+
*/
844+
KVZ_PUBLIC int kvz_get_version_major();
845+
846+
847+
/**
848+
* \brief Return minor version number
849+
*/
850+
KVZ_PUBLIC int kvz_get_version_minor();
851+
852+
853+
/**
854+
* \brief Return revision version number
855+
*/
856+
KVZ_PUBLIC int kvz_get_version_revision();
857+
858+
859+
/**
860+
* \brief Return compiler name string
861+
*
862+
*/
863+
KVZ_PUBLIC const char * kvz_get_compiler_string();
864+
865+
866+
/**
867+
* \brief Return compile date string
868+
*
869+
*/
870+
KVZ_PUBLIC const char * kvz_get_compile_date_string();
871+
872+
831873
#ifdef __cplusplus
832874
}
833875
#endif

0 commit comments

Comments
 (0)