diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 94a7ce2..4f44d52 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ jobs: strategy: matrix: compiler: [gcc, clang] - os: [ubuntu-18.04, ubuntu-20.04, macos-latest] + os: [ubuntu-20.04, macos-latest] exclude: - os: macos-latest compiler: gcc @@ -42,5 +42,5 @@ jobs: run: | cd .. make -C re libre.a - make -C rem EXTRA_CFLAGS=-Werror CCACHE= librem.a - cd retest && make STATIC=1 LIBRE_SO=../re && ./retest -r + cmake -S rem -B rem/build && cmake --build rem/build + cd retest && cmake . && make && ./retest -r diff --git a/CHANGELOG.md b/CHANGELOG.md index aafe157..33bbf60 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,23 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [v2.8.0] - 2022-10-01 + +* cmake: bump min. version 3.10 by @sreimers in https://github.com/baresip/rem/pull/79 +* auframe: auframe\_bytes\_to\_timestamp use uint64\_t by @cspiel1 in https://github.com/baresip/rem/pull/80 +* ci: migrate from make to CMake by @alfredh in https://github.com/baresip/rem/pull/81 +* cmake: install improvements by @sreimers in https://github.com/baresip/rem/pull/83 +* cmake: add static and shared targets by @sreimers in https://github.com/baresip/rem/pull/84 +* cmake: add win32 linklibs by @sreimers in https://github.com/baresip/rem/pull/85 +* debian: use dh-cmake by @sreimers in https://github.com/baresip/rem/pull/86 +* vid/frame: fix possbile overflow multiplication by @sreimers in https://github.com/baresip/rem/pull/87 +* cmake: add pkgconfig (fixes #90) by @robert-scheck in https://github.com/baresip/rem/pull/91 +* cmake: fix shared API soversion (aligned with make) by @robert-scheck in https://github.com/baresip/rem/pull/89 + +**Full Changelog**: https://github.com/baresip/rem/compare/v2.7.0...v2.8.0 + +--- + ## [v2.7.0] - 2022-09-01 * cmake: add FindRE and use re-config.cmake for definitions by @sreimers in https://github.com/baresip/rem/pull/76 diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bfd613..a92deff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,9 +9,14 @@ # Versioning # -cmake_minimum_required(VERSION 3.7) +cmake_minimum_required(VERSION 3.10) -project(rem VERSION 2.7.0 LANGUAGES C) +project(rem + VERSION 2.8.0 + LANGUAGES C + HOMEPAGE_URL https://github.com/baresip/rem + DESCRIPTION "Audio and video processing media library" +) set(PROJECT_SOVERSION 3) # bump if ABI breaks @@ -21,6 +26,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake) # # Module Includes # +include(GNUInstallDirs) include(CheckIncludeFile) find_package(RE REQUIRED) @@ -113,22 +119,104 @@ set(HEADERS include/rem_vidmix.h ) -add_library(${PROJECT_NAME} - ${SRCS} - ${HEADERS} -) +############################################################################## +# +# Linking LIBS +# + +set(LINKLIBS ${RE_LIBRARIES} Threads::Threads) + +if(WIN32) + list(APPEND LINKLIBS qwave iphlpapi wsock32 ws2_32) +else() + list(APPEND LINKLIBS -lm) +endif() + ############################################################################## # # Main target object # -target_link_libraries(${PROJECT_NAME} ${RE_LIBRARIES} -lpthread -lm) -target_compile_definitions(${PROJECT_NAME} PRIVATE ${RE_DEFINITIONS}) -target_include_directories(${PROJECT_NAME} PRIVATE - include ${RE_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR}) -set_target_properties(${PROJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE ON) -set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${PROJECT_SOVERSION}) +add_library(rem-objs OBJECT ${SRCS} ${HEADERS}) + +set_target_properties(rem-objs PROPERTIES POSITION_INDEPENDENT_CODE ON) + +target_compile_definitions(rem-objs PRIVATE ${RE_DEFINITIONS}) + +target_link_libraries(rem-objs ${LINKLIBS}) +target_include_directories(rem-objs + PUBLIC include + PRIVATE ${RE_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} +) + + +############################################################################## +# +# Shared target librem.[so|dll|dylib] +# + +add_library(rem-shared SHARED $) +target_link_libraries(rem-shared PRIVATE ${LINKLIBS}) +set_target_properties(rem-shared PROPERTIES VERSION + ${PROJECT_SOVERSION}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}) +set_target_properties(rem-shared PROPERTIES SOVERSION ${PROJECT_SOVERSION}) +set_target_properties(rem-shared PROPERTIES OUTPUT_NAME "rem") + +############################################################################## +# +# Static target librem.a +# + +add_library(rem STATIC $) +target_link_libraries(rem PUBLIC ${LINKLIBS}) +target_include_directories(rem PUBLIC include) set_target_properties(rem PROPERTIES PUBLIC_HEADER "${HEADERS}") -install(TARGETS rem LIBRARY) + +if(MSVC) +set_target_properties(rem PROPERTIES OUTPUT_NAME "rem-static") +endif() + + +############################################################################## +# +# Packaging section +# + +if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) + add_subdirectory(packaging) +endif() + +configure_file(packaging/librem.pc.in librem.pc @ONLY) + + +############################################################################## +# +# Install section +# + +install(TARGETS rem-shared rem + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT Libraries + NAMELINK_SKIP + ARCHIVE + DESTINATION ${CMAKE_INSTALL_LIBDIR} + COMPONENT Development + PUBLIC_HEADER + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/rem + COMPONENT Development +) + +install(TARGETS rem-shared + LIBRARY + DESTINATION ${CMAKE_INSTALL_LIBDIR} + NAMELINK_ONLY + COMPONENT Development +) + +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/librem.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig + COMPONENT Development +) diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..52faab9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,32 @@ +Copyright (C) 2020 - 2022, Baresip Foundation (https://github.com/baresip) +Copyright (c) 2010 - 2022, Alfred E. Heggestad +Copyright (c) 2010 - 2020, Richard Aas +Copyright (c) 2010 - 2020, Creytiv.com +All rights reserved. + + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile index bbc77eb..4b4c175 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ # Main version number VER_MAJOR := 2 -VER_MINOR := 7 +VER_MINOR := 8 VER_PATCH := 0 # Development version, comment out on a release @@ -26,7 +26,7 @@ else VERSION := $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)-$(VER_PRE) endif OPT_SPEED := 1 -LIBRE_MIN := 2.7.0 +LIBRE_MIN := 2.8.0 ifndef LIBRE_MK LIBRE_MK := $(shell [ -f ../re/mk/re.mk ] && \ diff --git a/README.md b/README.md index 5f4f426..29dd897 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ librem README librem is a Audio and video processing media library - Copyright (C) 2010 - 2019 Creytiv.com -- Copyright (C) 2020 - 2021 Baresip Foundation (https://github.com/baresip) +- Copyright (C) 2020 - 2022 Baresip Foundation (https://github.com/baresip) [![Build](https://github.com/baresip/rem/actions/workflows/build.yml/badge.svg)](https://github.com/baresip/rem/actions/workflows/build.yml) diff --git a/debian/changelog b/debian/changelog index 4ce3f15..c269c7b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +librem (2.8.0) unstable; urgency=medium + + * version 2.8.0 + + -- Christian Spielberger Sat, 1 Oct 2022 08:00:00 +0200 + librem (2.7.0) unstable; urgency=medium * version 2.7.0 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index f599e28..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/debian/control b/debian/control index 5fd5943..7b7fe38 100644 --- a/debian/control +++ b/debian/control @@ -2,14 +2,14 @@ Source: librem Section: comm Priority: optional Maintainer: Alfred E. Heggestad -Standards-Version: 3.9.5 -Build-Depends: debhelper (>= 9.20120311), libre-dev (>= 1.1.0) -Homepage: http://www.creytiv.com/ +Standards-Version: 4.1.5 +Build-Depends: cmake, dh-cmake, dh-cmake-compat (= 1), dh-sequence-cmake, debhelper-compat (= 12) +Homepage: https://github.com/baresip/rem Package: librem Architecture: any Section: libs -Depends: libre (>= 1.1.0), ${shlibs:Depends}, ${misc:Depends} +Depends: libre (>= 2.7.0), ${shlibs:Depends}, ${misc:Depends} Description: Audio and video processing media library Audio mixer, resampler, tone generator, G.711 codec Video mixer, pixel converter diff --git a/debian/copyright b/debian/copyright index cd4354b..52faab9 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,11 +1,7 @@ -This package was debianized by Alfred E. Heggestad - -It was downloaded from http://www.creytiv.com/ - - -Copyright (c) 2010 - 2014, Alfred E. Heggestad -Copyright (c) 2010 - 2014, Richard Aas -Copyright (c) 2010 - 2014, Creytiv.com +Copyright (C) 2020 - 2022, Baresip Foundation (https://github.com/baresip) +Copyright (c) 2010 - 2022, Alfred E. Heggestad +Copyright (c) 2010 - 2020, Richard Aas +Copyright (c) 2010 - 2020, Creytiv.com All rights reserved. @@ -20,18 +16,17 @@ are met: notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. -3. Neither the name of the Creytiv.com nor the names of its contributors +3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/debian/librem-dev.cmake-components b/debian/librem-dev.cmake-components new file mode 100644 index 0000000..e0eb968 --- /dev/null +++ b/debian/librem-dev.cmake-components @@ -0,0 +1 @@ +Development diff --git a/debian/librem-dev.dirs b/debian/librem-dev.dirs deleted file mode 100644 index da07fdd..0000000 --- a/debian/librem-dev.dirs +++ /dev/null @@ -1,2 +0,0 @@ -usr/include -usr/lib diff --git a/debian/librem-dev.files b/debian/librem-dev.files deleted file mode 100644 index 8d7ce12..0000000 --- a/debian/librem-dev.files +++ /dev/null @@ -1,3 +0,0 @@ -usr/include -usr/lib/librem.a -usr/lib/pkgconfig/librem.pc diff --git a/debian/librem.cmake-components b/debian/librem.cmake-components new file mode 100644 index 0000000..4e9af8a --- /dev/null +++ b/debian/librem.cmake-components @@ -0,0 +1 @@ +Libraries diff --git a/debian/librem.dirs b/debian/librem.dirs deleted file mode 100644 index 6845771..0000000 --- a/debian/librem.dirs +++ /dev/null @@ -1 +0,0 @@ -usr/lib diff --git a/debian/librem.files b/debian/librem.files deleted file mode 100644 index 4251858..0000000 --- a/debian/librem.files +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/librem.so* diff --git a/debian/rules b/debian/rules index ae7b2f4..09879ce 100755 --- a/debian/rules +++ b/debian/rules @@ -1,98 +1,7 @@ #!/usr/bin/make -f -# -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 +%: + dh $@ --buildsystem=cmake - -EXTRA_CFLAGS:="$(shell dpkg-buildflags --get CFLAGS | sed -e 's/-O2//')" -EXTRA_LFLAGS:="$(shell dpkg-buildflags --get LDFLAGS)" - - -configure: configure-stamp -configure-stamp: - dh_testdir - # Add here commands to configure the package. - - touch configure-stamp - - -build: build-stamp -build-stamp: configure-stamp - dh_testdir - - # Add here commands to compile the package. - $(MAKE) RELEASE=1 PREFIX=/usr \ - EXTRA_CFLAGS=$(EXTRA_CFLAGS) \ - EXTRA_LFLAGS=$(EXTRA_LFLAGS) - - touch $@ - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - - # Add here commands to clean up after the build process. - $(MAKE) clean - - dh_clean - -install: build - dh_testdir - dh_testroot - dh_prep - dh_installdirs - - # Add here commands to install the package into debian/tmp - mkdir $(CURDIR)/debian/tmp - $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp - - dh_movefiles - -# Build architecture-independent files here. -binary-indep: build install -# We have nothing to do by default. - -# Build architecture-dependent files here. -binary-arch: build install - dh_testdir - dh_testroot - dh_installchangelogs - dh_installdocs - dh_installexamples -# dh_install -# dh_installmenu -# dh_installdebconf -# dh_installlogrotate -# dh_installemacsen -# dh_installpam -# dh_installmime -# dh_installinit -# dh_installcron -# dh_installinfo - dh_installman - dh_link - dh_strip - dh_compress - dh_fixperms -# dh_perl -# dh_python - dh_makeshlibs - dh_installdeb - dh_shlibdeps - dh_gencontrol - dh_md5sums - dh_builddeb - -build-arch: build - -build-indep: build - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure +override_dh_auto_configure: + dh_auto_configure -- -DCMAKE_BUILD_TYPE=Release diff --git a/debian/source/format b/debian/source/format index d3827e7..89ae9db 100644 --- a/debian/source/format +++ b/debian/source/format @@ -1 +1 @@ -1.0 +3.0 (native) diff --git a/docs/COPYING b/docs/COPYING deleted file mode 100644 index 1b8c3af..0000000 --- a/docs/COPYING +++ /dev/null @@ -1,32 +0,0 @@ -Copyright (c) 2010 - 2019, Alfred E. Heggestad -Copyright (c) 2010 - 2019, Richard Aas -Copyright (c) 2010 - 2019, Creytiv.com -All rights reserved. - - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -3. Neither the name of the Creytiv.com nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, -INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT -NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/include/rem_auframe.h b/include/rem_auframe.h index cf8a063..c0295a2 100644 --- a/include/rem_auframe.h +++ b/include/rem_auframe.h @@ -44,4 +44,4 @@ static inline void auframe_update(struct auframe *af, void *sampv, size_t auframe_size(const struct auframe *af); void auframe_mute(struct auframe *af); double auframe_level(struct auframe *af); -size_t auframe_bytes_to_timestamp(const struct auframe *af, size_t n); +uint64_t auframe_bytes_to_timestamp(const struct auframe *af, size_t n); diff --git a/packaging/CMakeLists.txt b/packaging/CMakeLists.txt new file mode 100644 index 0000000..b08f3e1 --- /dev/null +++ b/packaging/CMakeLists.txt @@ -0,0 +1,12 @@ +set(CPACK_PACKAGE_NAME librem) +set(CPACK_PACKAGE_VENDOR baresip) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Audio and video processing media library") +set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME}) +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_VERBATIM_VARIABLES YES) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md") + +include(CPack) diff --git a/packaging/librem.pc.in b/packaging/librem.pc.in new file mode 100644 index 0000000..68284a7 --- /dev/null +++ b/packaging/librem.pc.in @@ -0,0 +1,11 @@ +prefix="@CMAKE_INSTALL_PREFIX@" +exec_prefix=${prefix} +libdir={$prefix}/lib +includedir=${prefix}/include/rem + +Name: librem +Description: @CMAKE_PROJECT_DESCRIPTION@ +Version: @PROJECT_VERSION@ +URL: @CMAKE_PROJECT_HOMEPAGE_URL@ +Libs: -L${libdir} -lrem -lre +Cflags: -I${includedir} diff --git a/src/auframe/auframe.c b/src/auframe/auframe.c index 3b6ae85..5373f44 100644 --- a/src/auframe/auframe.c +++ b/src/auframe/auframe.c @@ -103,9 +103,10 @@ double auframe_level(struct auframe *af) } -size_t auframe_bytes_to_timestamp(const struct auframe *af, size_t n) +uint64_t auframe_bytes_to_timestamp(const struct auframe *af, size_t n) { size_t sample_size = aufmt_sample_size(af->fmt); - return n * AUDIO_TIMEBASE / (af->srate * af->ch * sample_size); + return ((uint64_t) n) * AUDIO_TIMEBASE / + (af->srate * af->ch * sample_size); } diff --git a/src/vid/frame.c b/src/vid/frame.c index 65e6980..1dbd99c 100644 --- a/src/vid/frame.c +++ b/src/vid/frame.c @@ -24,15 +24,15 @@ size_t vidframe_size(enum vidfmt fmt, const struct vidsz *sz) switch (fmt) { - case VID_FMT_YUV420P: return sz->w * sz->h * 3 / 2; - case VID_FMT_YUYV422: return sz->w * sz->h * 2; - case VID_FMT_UYVY422: return sz->w * sz->h * 2; - case VID_FMT_RGB32: return sz->w * sz->h * 4; - case VID_FMT_ARGB: return sz->w * sz->h * 4; - case VID_FMT_RGB565: return sz->w * sz->h * 2; - case VID_FMT_NV12: return sz->w * sz->h * 3 / 2; - case VID_FMT_NV21: return sz->w * sz->h * 3 / 2; - case VID_FMT_YUV444P: return sz->w * sz->h * 3; + case VID_FMT_YUV420P: return (size_t)sz->w * sz->h * 3 / 2; + case VID_FMT_YUYV422: return (size_t)sz->w * sz->h * 2; + case VID_FMT_UYVY422: return (size_t)sz->w * sz->h * 2; + case VID_FMT_RGB32: return (size_t)sz->w * sz->h * 4; + case VID_FMT_ARGB: return (size_t)sz->w * sz->h * 4; + case VID_FMT_RGB565: return (size_t)sz->w * sz->h * 2; + case VID_FMT_NV12: return (size_t)sz->w * sz->h * 3 / 2; + case VID_FMT_NV21: return (size_t)sz->w * sz->h * 3 / 2; + case VID_FMT_YUV444P: return (size_t)sz->w * sz->h * 3; default: return 0; } @@ -186,7 +186,8 @@ int vidframe_alloc(struct vidframe **vfp, enum vidfmt fmt, void vidframe_fill(struct vidframe *vf, uint32_t r, uint32_t g, uint32_t b) { uint8_t *p; - unsigned h, i, x; + size_t h; + unsigned i, x; int u, v; if (!vf)