Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 32 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ cmake_minimum_required (VERSION 3.12)
########################################

# Set project version from git tag or version.txt file
function(get_versions versionstring VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
string(REGEX REPLACE "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$" "\\2" numbers ${versionstring})
set(VERSION_MAJOR ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV][0-9]*[.])([0-9]*)([.][0-9]*-?.*)$" "\\2" numbers ${versionstring})
set(VERSION_MINOR ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV][0-9]*[.][0-9]*[.])([0-9]*)(-?.*)$" "\\2" numbers ${versionstring})
set(VERSION_PATCH ${numbers} PARENT_SCOPE)
function(get_versions versionstring VERSION_APISET VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
string(REGEX REPLACE "^([vV])([0-9]+)([.])([0-9]+)([.])([0-9]+)([.])([0-9]+)$" "\\2" numbers ${versionstring})
set(${VERSION_APISET} ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV])([0-9]+)([.])([0-9]+)([.])([0-9]+)([.])([0-9]+)$" "\\4" numbers ${versionstring})
set(${VERSION_MAJOR} ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV])([0-9]+)([.])([0-9]+)([.])([0-9]+)([.])([0-9]+)$" "\\6" numbers ${versionstring})
set(${VERSION_MINOR} ${numbers} PARENT_SCOPE)
string(REGEX REPLACE "^([vV])([0-9]+)([.])([0-9]+)([.])([0-9]+)([.])([0-9]+)$" "\\8" numbers ${versionstring})
set(${VERSION_PATCH} ${numbers} PARENT_SCOPE)
endfunction()

execute_process(
COMMAND git describe --match "v[0-9]*.[0-9]*.[0-9]*" --abbrev=0 --tags
COMMAND git describe --match "v[0-9]*.[0-9]*.[0-9]*.[0-9]*" --abbrev=0 --tags
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE OUTPUT)
Expand All @@ -32,7 +34,7 @@ if(NOT RESULT EQUAL 0)
message(FATAL_ERROR
"version.txt file doesn't exist!\n"
"Since your working directory doesn't contain a git repository you must provide \"${CMAKE_SOURCE_DIR}/version.txt\" file containing a valid version string.\n"
"The version string provided to version.txt must match the following format:\n\tv[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]\n"
"The version string provided to version.txt must match the following format:\n\tv[VERSION_APISET].[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]\n"
"To get the information on version of the downloaded library please follow the link below:\n\t https://github.com/AcademySoftwareFoundation/openapv"
)
endif()
Expand All @@ -46,17 +48,29 @@ else()
string(REGEX REPLACE "\n$" "" VERSION_STRING "${VERSION_STRING}")
endif()

if(NOT ${VERSION_STRING} MATCHES "^([vV])([0-9]*)([.][0-9]*[.][0-9]*-?.*)$")
message(FATAL_ERROR "Version string ${VERSION_STRING} doesn't match required format v[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]")
if(NOT ${VERSION_STRING} MATCHES "^([vV])([0-9]+)([.])([0-9]+)([.])([0-9]+)([.])([0-9]+)$")
message(FATAL_ERROR "Version string ${VERSION_STRING} doesn't match required format v[VERSION_APISET].[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]")
endif()

get_versions(${VERSION_STRING} VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
get_versions(${VERSION_STRING} VERSION_APISET VERSION_MAJOR VERSION_MINOR VERSION_PATCH)
if(VERSION_MAJOR STREQUAL ${VERSION_STRING})
message(FATAL_ERROR "Version string parsing error")
endif()
message("OAPV VERSION=${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
message("OAPV project version: ${VERSION_APISET}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")

project(OAPV VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES C)
# if(NOT EXISTS "${CMAKE_SOURCE_DIR}/library_version.txt")
# message(FATAL_ERROR
# "library_version.txt file doesn't exist!\n"
# "You must provide \"${CMAKE_SOURCE_DIR}/library_version.txt\" file containing a valid library version string.\n"
# "The library version string provided to library_version.txt must match the following format:\n\tv[VERSION_APISET].[VERSION_MAJOR].[VERSION_MINOR].[VERSION_PATCH]\n"
# "To get the information on version of the downloaded library please follow the link below:\n\t https://github.com/AcademySoftwareFoundation/openapv"
# )
# endif()

# message("Library version string has been taken from library_version.txt file.")
# file(STRINGS "library_version.txt" LIB_VERSION_STRING)

project(OAPV VERSION ${VERSION_APISET}.${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} LANGUAGES C)

########################################
# Input arguments.
Expand Down Expand Up @@ -219,10 +233,10 @@ set(CPACK_PACKAGE_CONTACT "https://github.com/AcademySoftwareFoundation")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/openapv/releases")
set(CMAKE_PROJECT_HOMEPAGE_URL "https://github.com/AcademySoftwareFoundation/openapv")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Advanced Professional Video Codec")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION "${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION_MAJOR "${LIB_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${LIB_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${LIB_VERSION_PATCH}")
set(CPACK_PACKAGE_CHECKSUM MD5)

set(CPACK_DEBIAN_PACKAGE_MAINTAINER "AcademySoftwareFoundation")
Expand Down
2 changes: 1 addition & 1 deletion app/oapv_app_dec.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int main(int argc, const char **argv)

// print logo
logv2(" ____ ___ ___ _ __\n");
logv2(" / __ \\___ ___ ___ / _ | / _ \\ | / / Decoder (v%s)\n", oapv_version());
logv2(" / __ \\___ ___ ___ / _ | / _ \\ | / / Decoder (v%s)\n", OAPV_VERSION_2_STRING(oapv_version()));
logv2("/ /_/ / _ \\/ -_) _ \\/ __ |/ ___/ |/ / \n");
logv2("\\____/ .__/\\__/_//_/_/ |_/_/ |___/ \n");
logv2(" /_/ \n");
Expand Down
2 changes: 1 addition & 1 deletion app/oapv_app_enc.c
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ int main(int argc, const char **argv)

// print logo
logv2(" ____ ___ ___ _ __\n");
logv2(" / __ \\___ ___ ___ / _ | / _ \\ | / / Encoder (v%s)\n", oapv_version());
logv2(" / __ \\___ ___ ___ / _ | / _ \\ | / / Encoder (v%s)\n", OAPV_VERSION_2_STRING(oapv_version()));
logv2("/ /_/ / _ \\/ -_) _ \\/ __ |/ ___/ |/ / \n");
logv2("\\____/ .__/\\__/_//_/_/ |_/_/ |___/ \n");
logv2(" /_/ \n");
Expand Down
45 changes: 34 additions & 11 deletions inc/oapv.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,34 @@
extern "C" {
#endif

#include <oapv_config.h>

#if defined(OAPV_LIBVERSION_HEADER)
#include <oapv/oapv_libversion.h>
#endif

#if defined(OAPV_EXPORT_HEADER) && !defined(OAPV_STATIC_DEFINE)
#include <oapv/oapv_exports.h>
#if defined(ANDROID) || defined(OAPV_STATIC_DEFINE)
#define OAPV_EXPORT
#else
#define OAPV_EXPORT
#include <oapv/oapv_exports.h>
#endif

#if !defined(ANDROID)
#include <oapv/oapv_version.h>
#endif

/* macro for version */
#define OAPV_GET_VERSION(apiset, major, minor, patch) ((apiset << 24) | (major << 16) | (minor << 8) | patch)

#define OAPV_GET_APISET(v) (((v) >> 24) & 0xFF)
#define OAPV_GET_MAJOR(v) (((v) >> 16) & 0xFF)
#define OAPV_GET_MINOR(v) (((v) >> 8) & 0xFF)
#define OAPV_GET_PATCH(v) ( (v) & 0xFF)

#define OAPV_VERSION_2_STRING(version) \
({ \
static char buffer[16]; \
snprintf(buffer, sizeof(buffer), "%d.%d.%d.%d", \
(version >> 24) & 0xFF, \
(version >> 16) & 0xFF, \
(version >> 8) & 0xFF, \
version & 0xFF); \
buffer; \
})

/* size of macroblock */
#define OAPV_LOG2_MB (4)
Expand Down Expand Up @@ -662,9 +679,15 @@ OAPV_EXPORT int oapvd_decode(oapvd_t did, oapv_bitb_t *bitb, oapv_frms_t *ofrms,
OAPV_EXPORT int oapvd_info(void *au, int au_size, oapv_au_info_t *aui);

/*****************************************************************************
* openapv version
* openapv project version
*****************************************************************************/
OAPV_EXPORT char *oapv_version();
OAPV_EXPORT unsigned oapv_version();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to use unsigned int instead of just unsigned here


/*****************************************************************************
* openapv library version
*****************************************************************************/
OAPV_EXPORT unsigned oapv_libversion();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest to use unsigned int instead of just unsigned here



#ifdef __cplusplus
} /* extern "C" */
Expand Down
38 changes: 0 additions & 38 deletions inc/oapv_config.h

This file was deleted.

38 changes: 0 additions & 38 deletions inc/oapv_config.h.in

This file was deleted.

23 changes: 13 additions & 10 deletions inc/oapv_libversion.h.in → inc/oapv_version.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,25 @@
* POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __OAPV_LIBVERSION_H__8465216516551324987461894651851187416502317561968__
#define __OAPV_LIBVERSION_H__8465216516551324987461894651851187416502317561968__
#ifndef __OAPV_VERSION_H__8465216516551324987461894651851187416502317561968__
#define __OAPV_VERSION_H__8465216516551324987461894651851187416502317561968__

#cmakedefine01 OAPV_BUILD_SHARED_LIB
#if !OAPV_BUILD_SHARED_LIB && !defined(OAPV_STATIC_DEFINE)
#define OAPV_STATIC_DEFINE
#endif
#undef OAPV_BUILD_SHARED_LIB

#define OAPV_LIB_VERSION_MAJOR @LIB_VERSION_MAJOR@
#define OAPV_LIB_VERSION_MINOR @LIB_VERSION_MINOR@
#define OAPV_LIB_VERSION_PATCH @LIB_VERSION_PATCH@
// Project version
#define OAPV_VERSION_APISET 0
#define OAPV_VERSION_MAJOR @VERSION_MAJOR@
#define OAPV_VERSION_MINOR @VERSION_MINOR@
#define OAPV_VERSION_PATCH @VERSION_PATCH@

#define OAPV_CHECK_LIB_VERSION(major, minor, patch) \
((major) < OAPV_LIB_VERSION_MAJOR || \
((major) == OAPV_LIB_VERSION_MAJOR && (minor) < OAPV_LIB_VERSION_MINOR) || \
((major) == OAPV_LIB_VERSION_MAJOR && (minor) == OAPV_LIB_VERSION_MINOR && (patch) <= OAPV_LIB_VERSION_PATCH))
#define OAPV_CHECK_VERSION(apiset, major, minor, patch) \
((apiset) < OAPV_VERSION_APISET || \
((apiset) == OAPV_VERSION_APISET && (major) < OAPV_VERSION_MAJOR) || \
((apiset) == OAPV_VERSION_APISET && (major) == OAPV_VERSION_MAJOR && (minor) < OAPV_VERSION_MINOR) || \
((apiset) == OAPV_VERSION_APISET && (major) == OAPV_VERSION_MAJOR && (minor) == OAPV_VERSION_MINOR && (patch) <= OAPV_VERSION_PATCH))

#endif /* __OAPV_LIBVERSION_H__8465216516551324987461894651851187416502317561968__ */
#endif /* __OAPV_VERSION_H__8465216516551324987461894651851187416502317561968__ */
2 changes: 1 addition & 1 deletion pkgconfig/oapv.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ includedir=@CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_INCLUDEDIR@/@LIB_NAME_BASE@
Name: oapv
Description: Advanced Professional Video Codec

Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
Version: @LIB_VERSION_MAJOR@.@LIB_VERSION_MINOR@.@LIB_VERSION_PATCH@
Copy link
Contributor

@jamrial jamrial May 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, this one is fine staying as project version. Pkg-config is usually about a package, and not necessarily a specific library within it.

Copy link
Collaborator Author

@dkozinski dkozinski May 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not always. In the FFmpeg project, the version in the .pc files of individual libraries specifies the versions of the libraries, for example:

libavfilter.pc

...
Name: libavfilter
Description: FFmpeg audio/video filtering library
Version: 11.0.100
...

libavcodec.pc


...
Name: libavcodec
Description: FFmpeg codec library
Version: 62.3.101
...
libavcodec.so -> libavcodec.so.62.3.101
libavcodec.so.62 -> libavcodec.so.62.3.101
libavcodec.so.62.3.101
libavfilter.so -> libavfilter.so.11.0.100
libavfilter.so.11 -> libavfilter.so.11.0.100
libavfilter.so.11.0.100

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.


Requires:
Libs: -L${libdir} -l@LIB_NAME_BASE@
Expand Down
16 changes: 4 additions & 12 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
set(LIB_NAME_BASE oapv)

set(LIB_VERSION_MAJOR 1)
set(LIB_VERSION_MINOR 0)
set(LIB_VERSION_PATCH 0)

file(GLOB LIB_INC "../inc/*.h")
file(GLOB LIB_API_SRC "oapv.c")
file(GLOB LIB_BASE_SRC "oapv_*.c")
Expand All @@ -15,17 +11,13 @@ file(GLOB LIB_NEON_INC "../src/neon/oapv_*.h" )
file(GLOB LIB_AVX_SRC "../src/avx/oapv_*.c")
file(GLOB LIB_AVX_INC "../src/avx/oapv_*.h" )

set(LIB_LIBVERSION_HEADER "${CMAKE_BINARY_DIR}/include/${LIB_NAME_BASE}/${LIB_NAME_BASE}_libversion.h")
configure_file("${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_libversion.h.in" "${LIB_LIBVERSION_HEADER}" @ONLY)
list(APPEND LIB_INC "${LIB_LIBVERSION_HEADER}")
set(LIB_VERSION_HEADER "${CMAKE_BINARY_DIR}/include/${LIB_NAME_BASE}/${LIB_NAME_BASE}_version.h")
configure_file("${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_version.h.in" "${LIB_VERSION_HEADER}" @ONLY)
list(APPEND LIB_INC "${LIB_VERSION_HEADER}")

include(GenerateExportHeader)
include_directories("${CMAKE_BINARY_DIR}/include")

set(LIB_CONFIG_HEADER "${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_config.h")
configure_file("${CMAKE_SOURCE_DIR}/inc/${LIB_NAME_BASE}_config.h.in" "${LIB_CONFIG_HEADER}" @ONLY)
list(APPEND LIB_INC "${LIB_CONFIG_HEADER}")


message("SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}")

Expand Down Expand Up @@ -67,7 +59,7 @@ endif()

if(OAPV_BUILD_SHARED_LIB)
add_library(${LIB_NAME_BASE}_dynamic SHARED ${SOURCE_FILES})
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES VERSION ${LIB_VERSION_MAJOR}.${LIB_VERSION_MINOR}.${LIB_VERSION_PATCH} SOVERSION ${LIB_VERSION_MAJOR})
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} SOVERSION ${VERSION_MAJOR})
set_target_properties(${LIB_NAME_BASE}_dynamic PROPERTIES OUTPUT_NAME ${LIB_NAME_BASE})

# @todo Consider using WINDOWS_EXPORT_ALL_SYMBOLS instead of generate_export_header
Expand Down
15 changes: 13 additions & 2 deletions src/oapv.c
Original file line number Diff line number Diff line change
Expand Up @@ -2153,5 +2153,16 @@ int oapvd_info(void *au, int au_size, oapv_au_info_t *aui)
#endif // ENABLE_DECODER
///////////////////////////////////////////////////////////////////////////////

static char *oapv_ver = "0.1.13.1";
char * oapv_version() { return oapv_ver; }
#if defined(ANDROID)

unsigned int oapv_version() {
return OAPV_GET_VERSION(0, 1, 13, 1);
}

#else

unsigned int oapv_version(void) {
return OAPV_GET_VERSION(OAPV_VERSION_APISET, OAPV_VERSION_MAJOR, OAPV_VERSION_MINOR, OAPV_VERSION_PATCH);
}

#endif
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.1.13
v0.1.13.1