diff --git a/.cirrus.yml b/.cirrus.yml index 5382e2d..ad7c656 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -13,7 +13,7 @@ task: freetype2 jackit jansson luajit mbedtls pulseaudio speexdsp libsysinfo libudev-devd libv4l libx264 cmake ninja mesa-libs lua52 pkgconf - qt5-svg qt5-qmake qt5-buildtools qt5-x11extras + qt5-svg qt5-qmake qt5-buildtools qt5-x11extras qt5-xml script: - mkdir build - cd build diff --git a/.github/workflows/clang-format.yml b/.github/workflows/clang-format.yml new file mode 100644 index 0000000..beffb79 --- /dev/null +++ b/.github/workflows/clang-format.yml @@ -0,0 +1,48 @@ +name: Clang Format Check + +on: [push, pull_request] +jobs: + ubuntu64: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Install clang format + run: | + # gets us newer clang + sudo bash -c "cat >> /etc/apt/sources.list" << LLVMAPT + # 3.8 + deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main + deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main + LLVMAPT + + wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - + + sudo apt-get -qq update + + sudo apt-get install -y clang-format-8 + + - name: Check the Formatting + run: | + ./formatcode.sh + ./CI/check-format.sh + + macos64: + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + + - name: Install clang-format + run: | + brew install clang-format + + - name: Check the Formatting + run: | + ./formatcode.sh + ./CI/check-format.sh diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..47c4710 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,348 @@ +name: 'CI Multiplatform Build' + +on: + push: + branches: + - master + pull_request: + paths-ignore: + - '**.md' + branches: + - master + +env: + CEF_BUILD_VERSION: '3770' + CEF_VERSION: '75.1.16+g16a67c4+chromium-75.0.3770.100' + +jobs: + macos64: + name: 'macOS 64-bit' + runs-on: [macos-latest] + env: + MACOS_DEPS_VERSION: '2020-04-24' + VLC_VERSION: '3.0.8' + SPARKLE_VERSION: '1.23.0' + QT_VERSION: '5.14.1' + steps: + - name: 'Checkout' + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: 'Fetch Git Tags' + run: | + git fetch --prune --unshallow + echo ::set-env name=OBS_GIT_BRANCH::$(git rev-parse --abbrev-ref HEAD) + echo ::set-env name=OBS_GIT_HASH::$(git rev-parse --short HEAD) + echo ::set-env name=OBS_GIT_TAG::$(git describe --tags --abbrev=0) + - name: 'Install prerequisites (Homebrew)' + shell: bash + run: | + brew bundle --file ./CI/scripts/macos/Brewfile + - name: 'Install prerequisite: Pre-built dependencies' + shell: bash + run: | + curl -L -O https://github.com/obsproject/obs-deps/releases/download/${{ env.MACOS_DEPS_VERSION }}/osx-deps-${{ env.MACOS_DEPS_VERSION }}.tar.gz + tar -xf ./osx-deps-${{ env.MACOS_DEPS_VERSION }}.tar.gz -C "/tmp" + - name: 'Install prerequisite: VLC' + shell: bash + run: | + curl -L -O https://downloads.videolan.org/vlc/${{ env.VLC_VERSION }}/vlc-${{ env.VLC_VERSION }}.tar.xz + if [ ! -d "${{ github.workspace }}/cmbuild" ]; then mkdir "${{ github.workspace }}/cmbuild"; fi + tar -xf ./vlc-${{ env.VLC_VERSION }}.tar.xz -C "${{ github.workspace }}/cmbuild" + - name: 'Install prerequisite: Sparkle' + shell: bash + run: | + curl -L -o sparkle.tar.bz2 https://github.com/sparkle-project/Sparkle/releases/download/${{ env.SPARKLE_VERSION }}/Sparkle-${{ env.SPARKLE_VERSION }}.tar.bz2 + mkdir ${{ github.workspace }}/cmbuild/sparkle + tar -xf ./sparkle.tar.bz2 -C ${{ github.workspace }}/cmbuild/sparkle + sudo cp -R ${{ github.workspace }}/cmbuild/sparkle/Sparkle.framework /Library/Frameworks/Sparkle.framework + - name: 'Restore Chromium Embedded Framework from cache' + id: cef-cache + uses: actions/cache@v1 + env: + CACHE_NAME: 'cef-cache' + with: + path: ${{ github.workspace }}/cmbuild/cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64 + key: ${{ runner.os }}-pr-${{ env.CACHE_NAME }}-${{ env.CEF_BUILD_VERSION }} + restore-keys: | + ${{ runner.os }}-pr-${{ env.CACHE_NAME }}- + - name: 'Install prerequisite: Chromium Embedded Framework' + if: steps.cef-cache.outputs.cache-hit != 'true' + shell: bash + run: | + curl -L -O https://obs-nightly.s3-us-west-2.amazonaws.com/cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64.tar.bz2 + tar -xf ./cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64.tar.bz2 -C ${{ github.workspace }}/cmbuild/ + cd ${{ github.workspace }}/cmbuild/cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64 + sed -i '.orig' '/add_subdirectory(tests\/ceftests)/d' ./CMakeLists.txt + # target 10.11 + sed -i '.orig' s/\"10.9\"/\"10.11\"/ ./cmake/cef_variables.cmake + mkdir build && cd build + cmake -DCMAKE_CXX_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_EXE_LINKER_FLAGS="-std=c++11 -stdlib=libc++" -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 .. + make -j4 + mkdir libcef_dll + cd ../../ + - name: 'Configure' + shell: bash + run: | + mkdir ./build + cd ./build + cmake -DENABLE_SPARKLE_UPDATER=ON -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 -DQTDIR="/usr/local/Cellar/qt/${{ env.QT_VERSION }}" -DDepsPath="/tmp/obsdeps" -DVLCPath="${{ github.workspace }}/cmbuild/vlc-${{ env.VLC_VERSION }}" -DBUILD_BROWSER=ON -DBROWSER_DEPLOY=ON -DBUILD_CAPTIONS=ON -DWITH_RTMPS=ON -DCEF_ROOT_DIR="${{ github.workspace }}/cmbuild/cef_binary_${{ env.CEF_BUILD_VERSION }}_macosx64" .. + - name: 'Build' + shell: bash + working-directory: ${{ github.workspace }}/build + run: make -j4 + - name: 'Install prerequisite: Packages app' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + shell: bash + run: | + curl -L -O https://s3-us-west-2.amazonaws.com/obs-nightly/Packages.pkg + sudo installer -pkg ./Packages.pkg -target / + - name: 'Install prerequisite: DMGbuild' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + shell: bash + run: | + pip3 install dmgbuild + - name: 'Package' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + shell: bash + run: | + FILE_DATE=$(date +%Y-%m-%d) + FILE_NAME=$FILE_DATE-${{ env.OBS_GIT_HASH }}-${{ env.OBS_GIT_TAG }}-osx.dmg + echo "::set-env name=FILE_NAME::${FILE_NAME}" + ./CI/scripts/macos/prepareApp.sh + dmgbuild -s ./CI/scripts/macos/package/settings.json "OBS" OBS.dmg + mkdir ./nightly + sudo mv ./OBS.dmg ./nightly/${FILE_NAME} + - name: 'Publish' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + uses: actions/upload-artifact@v2-preview + with: + name: '${{ env.FILE_NAME }}' + path: ./nightly/*.dmg + ubuntu64: + name: 'Linux/Ubuntu 64-bit' + runs-on: [ubuntu-latest] + steps: + - name: 'Checkout' + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: 'Fetch Git Tags' + run: | + git fetch --prune --unshallow + echo ::set-env name=OBS_GIT_BRANCH::$(git rev-parse --abbrev-ref HEAD) + echo ::set-env name=OBS_GIT_HASH::$(git rev-parse --short HEAD) + echo ::set-env name=OBS_GIT_TAG::$(git describe --tags --abbrev=0) + - name: Install prerequisites (Apt) + shell: bash + run: | + sudo dpkg --add-architecture amd64 + sudo apt-get -qq update + sudo apt-get install -y \ + build-essential \ + checkinstall \ + cmake \ + libasound2-dev \ + libavcodec-dev \ + libavdevice-dev \ + libavfilter-dev \ + libavformat-dev \ + libavutil-dev \ + libcurl4-openssl-dev \ + libfdk-aac-dev \ + libfontconfig-dev \ + libfreetype6-dev \ + libgl1-mesa-dev \ + libjack-jackd2-dev \ + libjansson-dev \ + libluajit-5.1-dev \ + libpulse-dev \ + libqt5x11extras5-dev \ + libspeexdsp-dev \ + libswresample-dev \ + libswscale-dev \ + libudev-dev \ + libv4l-dev \ + libva-dev \ + libvlc-dev \ + libx11-dev \ + libx264-dev \ + libxcb-randr0-dev \ + libxcb-shm0-dev \ + libxcb-xinerama0-dev \ + libxcomposite-dev \ + libxinerama-dev \ + libmbedtls-dev \ + pkg-config \ + python3-dev \ + qtbase5-dev \ + libqt5svg5-dev \ + swig + - name: 'Install prerequisite: Chromium Embedded Framework' + shell: bash + run: | + curl -kL https://cdn-fastly.obsproject.com/downloads/cef_binary_${{ env.CEF_BUILD_VERSION }}_linux64.tar.bz2 -f --retry 5 -o cef.tar.bz2 + if [ ! -d "${{ github.workspace }}/cmbuild" ]; then mkdir "${{ github.workspace }}/cmbuild"; fi + tar -C"${{ github.workspace }}/cmbuild" -xjf cef.tar.bz2 + - name: 'Configure' + shell: bash + run: | + mkdir ./build + cd ./build + cmake -DUNIX_STRUCTURE=0 -DCMAKE_INSTALL_PREFIX="${{ github.workspace }}/obs-studio-portable" -DBUILD_CAPTIONS=ON -DWITH_RTMPS=ON -DBUILD_BROWSER=ON -DCEF_ROOT_DIR="${{ github.workspace }}/cmbuild/cef_binary_${{ env.CEF_BUILD_VERSION }}_linux64" .. + - name: 'Build' + shell: bash + working-directory: ${{ github.workspace }}/build + run: make -j4 + - name: 'Package' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + shell: bash + run: | + FILE_DATE=$(date +%Y-%m-%d) + FILE_NAME=$FILE_DATE-${{ env.OBS_GIT_HASH }}-${{ env.OBS_GIT_TAG }}-linux64.tar.gz + echo "::set-env name=FILE_NAME::${FILE_NAME}" + cd ./build + sudo checkinstall --default --install=no --pkgname=obs-studio --fstrans=yes --backup=no --pkgversion="$(date +%Y%m%d)-git" --deldoc=yes + mkdir ../nightly + tar -cvzf "${FILE_NAME}" *.deb + mv "${FILE_NAME}" ../nightly/ + cd - + - name: 'Publish' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + uses: actions/upload-artifact@v2-preview + with: + name: '${{ env.FILE_NAME }}' + path: './nightly/*.tar.gz' + win64: + name: 'Windows 64-bit' + runs-on: [windows-latest] + env: + QT_VERSION: '5.10.1' + CMAKE_GENERATOR: "Visual Studio 16 2019" + CMAKE_SYSTEM_VERSION: "10.0.18363.657" + WINDOWS_DEPS_VERSION: '2017' + TWITCH-CLIENTID: ${{ secrets.TWITCH_CLIENTID }} + TWITCH-HASH: ${{ secrets.TWITCH_HASH }} + MIXER-CLIENTID: ${{ secrets.MIXER_CLIENTID }} + MIXER-HASH: ${{ secrets.MIXER_HASH }} + RESTREAM-CLIENTID: ${{ secrets.RESTREAM-CLIENTID }} + RESTREAM-HASH: ${{ secrets.RESTREAM-HASH }} + steps: + - name: 'Add msbuild to PATH' + uses: microsoft/setup-msbuild@v1.0.0 + - name: 'Checkout' + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: 'Fetch Git Tags' + shell: bash + run: | + git fetch --prune --unshallow + echo ::set-env name=OBS_GIT_BRANCH::$(git rev-parse --abbrev-ref HEAD) + echo ::set-env name=OBS_GIT_HASH::$(git rev-parse --short HEAD) + echo ::set-env name=OBS_GIT_TAG::$(git describe --tags --abbrev=0) + - name: 'Install prerequisite: QT' + run: | + curl -kLO https://cdn-fastly.obsproject.com/downloads/Qt_${{ env.QT_VERSION }}.7z -f --retry 5 -C - + 7z x Qt_${{ env.QT_VERSION }}.7z -o"${{ github.workspace }}/cmbuild/QT" + - name: 'Install prerequisite: Pre-built dependencies' + run: | + curl -kLO https://cdn-fastly.obsproject.com/downloads/dependencies${{ env.WINDOWS_DEPS_VERSION }}.zip -f --retry 5 -C - + 7z x dependencies${{ env.WINDOWS_DEPS_VERSION }}.zip -o"${{ github.workspace }}/cmbuild/deps" + - name: 'Install prerequisite: VLC' + run: | + curl -kL https://cdn-fastly.obsproject.com/downloads/vlc.zip -f --retry 5 -o vlc.zip + 7z x vlc.zip -o"${{ github.workspace }}/cmbuild/vlc" + - name: 'Install prerequisite: Chromium Embedded Framework' + run: | + curl -kL https://cdn-fastly.obsproject.com/downloads/cef_binary_${{ env.CEF_VERSION }}_windows64_minimal.zip -f --retry 5 -o cef.zip + 7z x cef.zip -o"${{ github.workspace }}/cmbuild" + - name: 'Configure' + run: | + mkdir ./build + mkdir ./build64 + cd ./build64 + cmake -G"${{ env.CMAKE_GENERATOR }}" -A"x64" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=true -DBUILD_CAPTIONS=true -DCOMPILE_D3D12_HOOK=true -DDepsPath="${{ github.workspace }}/cmbuild/deps/win64" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2017_64" -DCEF_ROOT_DIR="${{ github.workspace }}/cmdbuild/cef_binary_${{ env.CEF_VERSION }}_windows64_minimal" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE .. + - name: 'Build' + run: msbuild /m /p:Configuration=RelWithDebInfo .\build64\obs-studio.sln + - name: 'Package' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + run: | + $env:FILE_DATE=(Get-Date -UFormat "%F") + $env:FILE_NAME="${env:FILE_DATE}-${{ env.OBS_GIT_HASH }}-${{ env.OBS_GIT_TAG }}-win64.zip" + echo "::set-env name=FILE_NAME::${env:FILE_NAME}" + robocopy .\build64\rundir\RelWithDebInfo .\build\ /E /XF .gitignore + 7z a ${env:FILE_NAME} .\build\* + - name: 'Publish' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + uses: actions/upload-artifact@v2-preview + with: + name: '${{ env.FILE_NAME }}' + path: '*-win64.zip' + + win32: + name: 'Windows 32-bit' + runs-on: [windows-latest] + env: + QT_VERSION: '5.10.1' + CMAKE_GENERATOR: "Visual Studio 16 2019" + CMAKE_SYSTEM_VERSION: "10.0.18363.657" + WINDOWS_DEPS_VERSION: '2017' + TWITCH-CLIENTID: ${{ secrets.TWITCH_CLIENTID }} + TWITCH-HASH: ${{ secrets.TWITCH_HASH }} + MIXER-CLIENTID: ${{ secrets.MIXER_CLIENTID }} + MIXER-HASH: ${{ secrets.MIXER_HASH }} + RESTREAM-CLIENTID: ${{ secrets.RESTREAM-CLIENTID }} + RESTREAM-HASH: ${{ secrets.RESTREAM-HASH }} + steps: + - name: 'Add msbuild to PATH' + uses: microsoft/setup-msbuild@v1.0.0 + - name: 'Checkout' + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: 'Fetch Git Tags' + shell: bash + run: | + git fetch --prune --unshallow + echo ::set-env name=OBS_GIT_BRANCH::$(git rev-parse --abbrev-ref HEAD) + echo ::set-env name=OBS_GIT_HASH::$(git rev-parse --short HEAD) + echo ::set-env name=OBS_GIT_TAG::$(git describe --tags --abbrev=0) + - name: 'Install prerequisite: QT' + run: | + curl -kLO https://cdn-fastly.obsproject.com/downloads/Qt_${{ env.QT_VERSION }}.7z -f --retry 5 -C - + 7z x Qt_${{ env.QT_VERSION }}.7z -o"${{ github.workspace }}/cmbuild/QT" + - name: 'Install prerequisite: Pre-built dependencies' + run: | + curl -kLO https://cdn-fastly.obsproject.com/downloads/dependencies${{ env.WINDOWS_DEPS_VERSION }}.zip -f --retry 5 -C - + 7z x dependencies${{ env.WINDOWS_DEPS_VERSION }}.zip -o"${{ github.workspace }}/cmbuild/deps" + - name: 'Install prerequisite: VLC' + run: | + curl -kL https://cdn-fastly.obsproject.com/downloads/vlc.zip -f --retry 5 -o vlc.zip + 7z x vlc.zip -o"${{ github.workspace }}/cmbuild/vlc" + - name: 'Install prerequisite: Chromium Embedded Framework' + run: | + curl -kL https://cdn-fastly.obsproject.com/downloads/cef_binary_${{ env.CEF_VERSION }}_windows32_minimal.zip -f --retry 5 -o cef.zip + 7z x cef.zip -o"${{ github.workspace }}/cmbuild" + - name: 'Configure' + run: | + mkdir ./build + mkdir ./build32 + cd ./build32 + cmake -G"${{ env.CMAKE_GENERATOR }}" -A"Win32" -DCMAKE_SYSTEM_VERSION="${{ env.CMAKE_SYSTEM_VERSION }}" -DBUILD_BROWSER=true -DBUILD_CAPTIONS=true -DCOMPILE_D3D12_HOOK=true -DDepsPath="${{ github.workspace }}/cmbuild/deps/win32" -DQTDIR="${{ github.workspace }}/cmbuild/QT/${{ env.QT_VERSION }}/msvc2017" -DCEF_ROOT_DIR="${{ github.workspace }}/cmdbuild/cef_binary_${{ env.CEF_VERSION }}_windows32_minimal" -DCOPIED_DEPENDENCIES=FALSE -DCOPY_DEPENDENCIES=TRUE .. + - name: 'Build' + run: msbuild /m /p:Configuration=RelWithDebInfo .\build32\obs-studio.sln + - name: 'Package' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + run: | + $env:FILE_DATE=(Get-Date -UFormat "%F") + $env:FILE_NAME="${env:FILE_DATE}-${{ env.OBS_GIT_HASH }}-${{ env.OBS_GIT_TAG }}-win32.zip" + echo "::set-env name=FILE_NAME::${env:FILE_NAME}" + robocopy .\build32\rundir\RelWithDebInfo .\build\ /E /XF .gitignore + 7z a ${env:FILE_NAME} .\build\* + - name: 'Publish' + if: success() && (github.event_name != 'pull_request' || contains( github.event.pull_request.labels.*.name, 'Seeking Testers')) + uses: actions/upload-artifact@v2-preview + with: + name: '${{ env.FILE_NAME }}' + path: '*-win32.zip' diff --git a/CI/before-deploy-osx.sh b/CI/before-deploy-osx.sh index 236c0d0..b284615 100755 --- a/CI/before-deploy-osx.sh +++ b/CI/before-deploy-osx.sh @@ -37,7 +37,7 @@ fi ../CI/install/osx/packageApp.sh -# fix obs outputs +# fix obs outputs plugin it doesn't play nicely with dylibBundler at the moment cp /usr/local/opt/mbedtls/lib/libmbedtls.12.dylib ./OBS.app/Contents/Frameworks/ cp /usr/local/opt/mbedtls/lib/libmbedcrypto.3.dylib ./OBS.app/Contents/Frameworks/ cp /usr/local/opt/mbedtls/lib/libmbedx509.0.dylib ./OBS.app/Contents/Frameworks/ @@ -45,11 +45,12 @@ chmod +w ./OBS.app/Contents/Frameworks/*.dylib install_name_tool -id @executable_path/../Frameworks/libmbedtls.12.dylib ./OBS.app/Contents/Frameworks/libmbedtls.12.dylib install_name_tool -id @executable_path/../Frameworks/libmbedcrypto.3.dylib ./OBS.app/Contents/Frameworks/libmbedcrypto.3.dylib install_name_tool -id @executable_path/../Frameworks/libmbedx509.0.dylib ./OBS.app/Contents/Frameworks/libmbedx509.0.dylib -install_name_tool -change /usr/local/opt/mbedtls/lib/libmbedtls.12.dylib @executable_path/../Frameworks/libmbedtls.12.dylib ./OBS.app/Contents/Plugins/obs-outputs.so -install_name_tool -change /usr/local/opt/mbedtls/lib/libmbedcrypto.3.dylib @executable_path/../Frameworks/libmbedcrypto.3.dylib ./OBS.app/Contents/Plugins/obs-outputs.so -install_name_tool -change /usr/local/opt/mbedtls/lib/libmbedx509.0.dylib @executable_path/../Frameworks/libmbedx509.0.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change libmbedtls.12.dylib @executable_path/../Frameworks/libmbedtls.12.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change libmbedcrypto.3.dylib @executable_path/../Frameworks/libmbedcrypto.3.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change libmbedx509.0.dylib @executable_path/../Frameworks/libmbedx509.0.dylib ./OBS.app/Contents/Plugins/obs-outputs.so install_name_tool -change /usr/local/opt/curl/lib/libcurl.4.dylib @executable_path/../Frameworks/libcurl.4.dylib ./OBS.app/Contents/Plugins/obs-outputs.so install_name_tool -change @rpath/libobs.0.dylib @executable_path/../Frameworks/libobs.0.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change /tmp/obsdeps/bin/libjansson.4.dylib @executable_path/../Frameworks/libjansson.4.dylib ./OBS.app/Contents/Plugins/obs-outputs.so # copy sparkle into the app hr "Copying Sparkle.framework" diff --git a/CI/before-script-linux.sh b/CI/before-script-linux.sh index 31e1544..2118a27 100755 --- a/CI/before-script-linux.sh +++ b/CI/before-script-linux.sh @@ -1,10 +1,5 @@ #!/bin/bash -./formatcode.sh -if ! ./CI/check-format.sh; then - exit 1 -fi - set -ex ccache -s || echo "CCache is not available." mkdir build && cd build diff --git a/CI/before-script-osx.sh b/CI/before-script-osx.sh index 902bc3b..80403bf 100755 --- a/CI/before-script-osx.sh +++ b/CI/before-script-osx.sh @@ -3,19 +3,15 @@ export PATH=/usr/local/opt/ccache/libexec:$PATH git fetch --tags -./formatcode.sh -if ! ./CI/check-format.sh; then - exit 1 -fi - mkdir build cd build cmake -DENABLE_SPARKLE_UPDATER=ON \ -DCMAKE_OSX_DEPLOYMENT_TARGET=10.11 \ -DQTDIR=/usr/local/Cellar/qt/5.14.1 \ -DDepsPath=/tmp/obsdeps \ --DVLCPath=$PWD/../../vlc-3.0.4 \ +-DVLCPath=$PWD/../../vlc-3.0.8 \ -DBUILD_BROWSER=ON \ -DBROWSER_DEPLOY=ON \ -DBUILD_CAPTIONS=ON \ +-DWITH_RTMPS=ON \ -DCEF_ROOT_DIR=$PWD/../../cef_binary_${CEF_BUILD_VERSION}_macosx64 .. diff --git a/CI/install-dependencies-linux.sh b/CI/install-dependencies-linux.sh index a84c191..0d92fbf 100755 --- a/CI/install-dependencies-linux.sh +++ b/CI/install-dependencies-linux.sh @@ -3,15 +3,6 @@ set -ex curl -L https://packagecloud.io/github/git-lfs/gpgkey | sudo apt-key add - -# gets us newer clang -sudo bash -c "cat >> /etc/apt/sources.list" << LLVMAPT -# 3.8 -deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main -deb-src http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main -LLVMAPT - -wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add - - sudo apt-get -qq update sudo apt-get install -y \ build-essential \ @@ -52,8 +43,7 @@ sudo apt-get install -y \ python3-dev \ qtbase5-dev \ libqt5svg5-dev \ - swig \ - clang-format-8 + swig # build cef wget --quiet --retry-connrefused --waitretry=1 https://cdn-fastly.obsproject.com/downloads/cef_binary_${CEF_BUILD_VERSION}_linux64.tar.bz2 diff --git a/CI/install-dependencies-osx.sh b/CI/install-dependencies-osx.sh index 4fd5735..1e8f53e 100755 --- a/CI/install-dependencies-osx.sh +++ b/CI/install-dependencies-osx.sh @@ -28,9 +28,11 @@ sudo installer -pkg ./Packages.pkg -target / brew update #Base OBS Deps and ccache -brew install jack speexdsp ccache mbedtls clang-format freetype fdk-aac +brew install jack speexdsp ccache mbedtls freetype fdk-aac brew install https://gist.githubusercontent.com/DDRBoxman/9c7a2b08933166f4b61ed9a44b242609/raw/ef4de6c587c6bd7f50210eccd5bd51ff08e6de13/qt.rb -brew unlink swig +if [ -d "$(brew --cellar)/swig" ]; then + brew unlink swig +fi brew install https://gist.githubusercontent.com/DDRBoxman/4cada55c51803a2f963fa40ce55c9d3e/raw/572c67e908bfbc1bcb8c476ea77ea3935133f5b5/swig.rb pip install dmgbuild @@ -40,17 +42,17 @@ ccache -s || echo "CCache is not available." # Fetch and untar prebuilt OBS deps that are compatible with older versions of OSX hr "Downloading OBS deps" -wget --quiet --retry-connrefused --waitretry=1 https://obs-nightly.s3.amazonaws.com/osx-deps-2018-08-09.tar.gz -tar -xf ./osx-deps-2018-08-09.tar.gz -C /tmp +wget --quiet --retry-connrefused --waitretry=1 https://github.com/obsproject/obs-deps/releases/download/2020-04-24/osx-deps-2020-04-24.tar.gz +tar -xf ./osx-deps-2020-04-24.tar.gz -C /tmp # Fetch vlc codebase hr "Downloading VLC repo" -wget --quiet --retry-connrefused --waitretry=1 https://downloads.videolan.org/vlc/3.0.4/vlc-3.0.4.tar.xz -tar -xf vlc-3.0.4.tar.xz +wget --quiet --retry-connrefused --waitretry=1 https://downloads.videolan.org/vlc/3.0.8/vlc-3.0.8.tar.xz +tar -xf vlc-3.0.8.tar.xz # Get sparkle hr "Downloading Sparkle framework" -wget --quiet --retry-connrefused --waitretry=1 -O sparkle.tar.bz2 https://github.com/sparkle-project/Sparkle/releases/download/1.20.0/Sparkle-1.20.0.tar.bz2 +wget --quiet --retry-connrefused --waitretry=1 -O sparkle.tar.bz2 https://github.com/sparkle-project/Sparkle/releases/download/1.23.0/Sparkle-1.23.0.tar.bz2 mkdir ./sparkle tar -xf ./sparkle.tar.bz2 -C ./sparkle sudo cp -R ./sparkle/Sparkle.framework /Library/Frameworks/Sparkle.framework diff --git a/CI/scripts/macos/Brewfile b/CI/scripts/macos/Brewfile new file mode 100644 index 0000000..5d1d863 --- /dev/null +++ b/CI/scripts/macos/Brewfile @@ -0,0 +1,8 @@ +brew "jack" +brew "speexdsp" +brew "cmake" +brew "freetype" +brew "fdk-aac" +brew "https://gist.githubusercontent.com/DDRBoxman/9c7a2b08933166f4b61ed9a44b242609/raw/ef4de6c587c6bd7f50210eccd5bd51ff08e6de13/qt.rb" +brew "swig", link: false +brew "https://gist.githubusercontent.com/DDRBoxman/4cada55c51803a2f963fa40ce55c9d3e/raw/572c67e908bfbc1bcb8c476ea77ea3935133f5b5/swig.rb" diff --git a/CI/scripts/macos/app/Info.plist b/CI/scripts/macos/app/Info.plist new file mode 100644 index 0000000..074e14a --- /dev/null +++ b/CI/scripts/macos/app/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleIconFile + obs.icns + CFBundleName + OBS + CFBundleGetInfoString + OBS - Free and Open Source Streaming/Recording Software + CFBundleExecutable + obs + CFBundleIdentifier + com.obsproject.obs-studio + CFBundlePackageType + APPL + LSMinimumSystemVersion + 10.8.5 + NSHighResolutionCapable + + LSAppNapIsDisabled + + NSCameraUsageDescription + OBS needs to access the camera to enable camera sources to work. + NSMicrophoneUsageDescription + OBS needs to access the microphone to enable audio input. + + diff --git a/CI/scripts/macos/app/OBSPublicDSAKey.pem b/CI/scripts/macos/app/OBSPublicDSAKey.pem new file mode 100644 index 0000000..91adb40 --- /dev/null +++ b/CI/scripts/macos/app/OBSPublicDSAKey.pem @@ -0,0 +1,36 @@ +-----BEGIN PUBLIC KEY----- +MIIGPDCCBC4GByqGSM44BAEwggQhAoICAQCZZZ2y7H2GJmMfP4KQihJTJOoiGNUw +mue6sqMbH+utRykRnSKBZux6R665eRFMpNgrgFO1TLLGbdD2U31KiGtCvFJOmOl3 ++QP055BuXjEG36NU7AWEFLAlbDlr/2D3oumq3Ib3iMnnr9RrVztJ2VFOvVio1eWr +ZxboVwKPK8D6BqsWiv15vbYlJnTC4Fls6ySmdjVBxwoPlTaMu1ysi5DfbIZ93s5u +aQt1FvXuWtPBWjyVUORcNbcWf49E5R2pV0OSBK95Hw2/wXz4vmj+w92dTePGnVaW +Me4CoF5PIeZILwp6DCLStX4eW2WG1NChJTC8zeQ/3bMMoGyKM/MadyvrDqMywsKY +caxkIwHrDKOEdXXGo80dIwZMMLipPA8DKhx5ojphfkeXjIhKSx+49knXT3ED5okE +Wai7tGUXj/8D8sGh+7b+AVsdujvr4v8WQaZiKUOZ2IIHOg3VLz9T9v0zet1Yt987 +KNymFcp2CHeJ6KnDP/ZGQ6Nl0HsPxUgscsXV+R2FEc8Q1j0Ukkuxnopa0E4/huUu +gjyRzpXD734qFMDf7LcXca6qNjBor6gVj5sRyRKCpZ+KQfMUlr8jp506ztYSyeJu +dxJV30tQgztwkbrs02CqOt4Z3Peo6sdht7hWKSPVwmja3tq8/TfUSSoo6wKYN9/w +Mf3dVeRF8hCzJQIVAJnzuzmzQhCKPiQnl3jh5qGII2XfAoICAQCCVATAff89ceHj +ROHEbHTQFpVxJ/kRZPfxnU46DSw79Tih7tthV68oakPSOTP3cx/Tga0GwogarZ9N +F2VVan5w9OQSSewXsr5UDT5bnmJF+h+JB7TMy+sXZBYobUqjlUd5VtKc8RsN86P4 +s7xbK0mA+hfe+27r18JT81/eH3xUfh7UOUGSdMN2Ch9f7RFSMZIgUAZUzu2K3ODp +hPgtc2QJ8QVAp7GLvQgw8ZUME/ChZslyBIyJvYgUIxfxlgRWYro5pQT7/ngkgdXo +wlghHKkldwMuY3zaFdhPnFNuEUEtc18ILsbz0+AnagCUd6n+3safskCRqLIHMOY6 +iLBSZPX9hJQhVCqSqz1VNDDww8FNa/fojJ1Lr/TI0I+0Ib2pCiY2LChXUqGY5SLZ +2KNs5qFsyZP+I0L8YsGwqvUYyFwk7Ok224n0NtaOwqpLCrtXd/i6DaDNiaoJuwJC +1ELCfaZivorgkC5rhBt2H7qWUAR+EtrFE/gb0k/G5EIhjYql7onGbX+G2re38vQA +fg1pzguhig2dafP/BxMLZrn1Gg61xzmEYPuS9gclktaf675srv8GVb46VkOxXL+D +YvTmpJPP7UUOVlmAMCo4j4y09MW3jq9TDp42VTLeZVubyjslGnavlnq1O+ZyXUye +1FMeby65sIbSHHHwoFnRv3hLSEXI5gOCAgYAAoICAQCUkYnZkPfHfOJZI403xUYP +CE/bLpkza074Xo6EXElsWRnpQgNTx+JFOvItgj3v0OkIqDin9UredKOwfkiftslV +jxUVKA6I5kwnGvCpvTpQMLyLjq+VQr+J2D6eId6tV/iajhdu5r4JThU8KllT7Ywb +NAur34ftLNCVAMRUaDNeEoHfePgderW384e+lbvpmtifmBluammGSxxRtUsdjvJZ +BFkhaJu86CKxcU7D1lbPVOtV/jaxz6d16VdGcfBdi2LzXZzZtYpT9XGPX3NF+xii +spAURWsoe11LTRXF+eJhgCm5iIDN3kh1HEQKYKAVpmrcM0aFzk/NpS+tFyU72vaq +IRSSJw/aa1oELOAakG5oPldc4RcYWl32sbnVwXHO7TZvgTrBSC10o65MAC5CHP/s +b07heDYAIt7re7szvOYq+c/9zAMAlu3pcO8MqaXYMmybdHBXHQ2b+DdJWHmIUWcX +CbUzr09vzGkJAvqsXqbmJPr8aixrO75DhT0iDTILLWe/GWK51nf+Tg0pNxVgGyAl +BqvRqqo7SSDu9FMkwQesFFHhuoHLyEHwVPJ+sMQTNwQcm9c6YuW8EYDRSkeKLWYk +3fkjG+Pe9uVE8a1taDg3FjSY0UqjUT6XMw+i0Lajyus2L6wFBwrrGM6E4xa6x1CC +MGjmuSOlPA1umQsToIcO4g== +-----END PUBLIC KEY----- diff --git a/CI/scripts/macos/app/obs.icns b/CI/scripts/macos/app/obs.icns new file mode 100644 index 0000000..6f878d6 Binary files /dev/null and b/CI/scripts/macos/app/obs.icns differ diff --git a/CI/scripts/macos/package/background.tiff b/CI/scripts/macos/package/background.tiff new file mode 100644 index 0000000..4548740 Binary files /dev/null and b/CI/scripts/macos/package/background.tiff differ diff --git a/CI/scripts/macos/package/dylibBundler b/CI/scripts/macos/package/dylibBundler new file mode 100755 index 0000000..a28f209 Binary files /dev/null and b/CI/scripts/macos/package/dylibBundler differ diff --git a/CI/scripts/macos/package/settings.json b/CI/scripts/macos/package/settings.json new file mode 100644 index 0000000..e809366 --- /dev/null +++ b/CI/scripts/macos/package/settings.json @@ -0,0 +1,14 @@ +{ + "title": "OBS", + "background": "./CI/scripts/macos/package/background.tiff", + "icon": "./CI/scripts/macos/app/obs.icns", + "format": "UDZO", + "compression-level": 9, + "window": { "position": { "x": 100, "y": 100 }, + "size": { "width": 540, "height": 380 } }, + "contents": [ + { "x": 120, "y": 180, "type": "file", + "path": "./OBS.app" }, + { "x": 420, "y": 180, "type": "link", "path": "/Applications" } + ] +} diff --git a/CI/scripts/macos/package/src/background.png b/CI/scripts/macos/package/src/background.png new file mode 100644 index 0000000..02c4d55 Binary files /dev/null and b/CI/scripts/macos/package/src/background.png differ diff --git a/CI/scripts/macos/package/src/background@2x.png b/CI/scripts/macos/package/src/background@2x.png new file mode 100644 index 0000000..a001edf Binary files /dev/null and b/CI/scripts/macos/package/src/background@2x.png differ diff --git a/CI/scripts/macos/package/src/makeRetinaBG b/CI/scripts/macos/package/src/makeRetinaBG new file mode 100755 index 0000000..5d7f309 --- /dev/null +++ b/CI/scripts/macos/package/src/makeRetinaBG @@ -0,0 +1 @@ +tiffutil -cathidpicheck background.png background@2x.png -out background.tiff diff --git a/CI/scripts/macos/packageApp.sh b/CI/scripts/macos/packageApp.sh new file mode 100755 index 0000000..6d6cdd4 --- /dev/null +++ b/CI/scripts/macos/packageApp.sh @@ -0,0 +1,78 @@ +#!/usr/bin/env bash + +# Exit if something fails +set -e + +rm -rf ./OBS.app + +mkdir OBS.app +mkdir OBS.app/Contents +mkdir OBS.app/Contents/MacOS +mkdir OBS.app/Contents/PlugIns +mkdir OBS.app/Contents/Resources + +cp -R rundir/RelWithDebInfo/bin/ ./OBS.app/Contents/MacOS +cp -R rundir/RelWithDebInfo/data ./OBS.app/Contents/Resources +cp ../CI/scripts/macos/app/obs.icns ./OBS.app/Contents/Resources +cp -R rundir/RelWithDebInfo/obs-plugins/ ./OBS.app/Contents/PlugIns +cp ../CI/scripts/macos/app/Info.plist ./OBS.app/Contents + +../CI/scripts/macos/package/dylibBundler -b -cd -d ./OBS.app/Contents/Frameworks -p @executable_path/../Frameworks/ \ +-s ./OBS.app/Contents/MacOS \ +-x ./OBS.app/Contents/PlugIns/coreaudio-encoder.so \ +-x ./OBS.app/Contents/PlugIns/decklink-ouput-ui.so \ +-x ./OBS.app/Contents/PlugIns/frontend-tools.so \ +-x ./OBS.app/Contents/PlugIns/image-source.so \ +-x ./OBS.app/Contents/PlugIns/linux-jack.so \ +-x ./OBS.app/Contents/PlugIns/mac-avcapture.so \ +-x ./OBS.app/Contents/PlugIns/mac-capture.so \ +-x ./OBS.app/Contents/PlugIns/mac-decklink.so \ +-x ./OBS.app/Contents/PlugIns/mac-syphon.so \ +-x ./OBS.app/Contents/PlugIns/mac-vth264.so \ +-x ./OBS.app/Contents/PlugIns/obs-browser.so \ +-x ./OBS.app/Contents/PlugIns/obs-browser-page \ +-x ./OBS.app/Contents/PlugIns/obs-ffmpeg.so \ +-x ./OBS.app/Contents/PlugIns/obs-filters.so \ +-x ./OBS.app/Contents/PlugIns/obs-transitions.so \ +-x ./OBS.app/Contents/PlugIns/obs-vst.so \ +-x ./OBS.app/Contents/PlugIns/rtmp-services.so \ +-x ./OBS.app/Contents/MacOS/obs \ +-x ./OBS.app/Contents/MacOS/obs-ffmpeg-mux \ +-x ./OBS.app/Contents/MacOS/obslua.so \ +-x ./OBS.app/Contents/MacOS/_obspython.so \ +-x ./OBS.app/Contents/PlugIns/obs-x264.so \ +-x ./OBS.app/Contents/PlugIns/text-freetype2.so \ +-x ./OBS.app/Contents/PlugIns/obs-libfdk.so +# -x ./OBS.app/Contents/PlugIns/obs-outputs.so \ + +/usr/local/Cellar/qt/${QT_VERSION}/bin/macdeployqt ./OBS.app + +mv ./OBS.app/Contents/MacOS/libobs-opengl.so ./OBS.app/Contents/Frameworks + +rm -f -r ./OBS.app/Contents/Frameworks/QtNetwork.framework + +# put qt network in here becasuse streamdeck uses it +cp -R /usr/local/opt/qt/lib/QtNetwork.framework ./OBS.app/Contents/Frameworks +chmod -R +w ./OBS.app/Contents/Frameworks/QtNetwork.framework +rm -r ./OBS.app/Contents/Frameworks/QtNetwork.framework/Headers +rm -r ./OBS.app/Contents/Frameworks/QtNetwork.framework/Versions/5/Headers/ +chmod 644 ./OBS.app/Contents/Frameworks/QtNetwork.framework/Versions/5/Resources/Info.plist +install_name_tool -id @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork ./OBS.app/Contents/Frameworks/QtNetwork.framework/Versions/5/QtNetwork +install_name_tool -change /usr/local/Cellar/qt/${QT_VERSION}/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore ./OBS.app/Contents/Frameworks/QtNetwork.framework/Versions/5/QtNetwork + + +# decklink ui qt +install_name_tool -change /usr/local/opt/qt/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui ./OBS.app/Contents/PlugIns/decklink-ouput-ui.so +install_name_tool -change /usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore ./OBS.app/Contents/PlugIns/decklink-ouput-ui.so +install_name_tool -change /usr/local/opt/qt/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets ./OBS.app/Contents/PlugIns/decklink-ouput-ui.so + +# frontend tools qt +install_name_tool -change /usr/local/opt/qt/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui ./OBS.app/Contents/PlugIns/frontend-tools.so +install_name_tool -change /usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore ./OBS.app/Contents/PlugIns/frontend-tools.so +install_name_tool -change /usr/local/opt/qt/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets ./OBS.app/Contents/PlugIns/frontend-tools.so + +# vst qt +install_name_tool -change /usr/local/opt/qt/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui ./OBS.app/Contents/PlugIns/obs-vst.so +install_name_tool -change /usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore ./OBS.app/Contents/PlugIns/obs-vst.so +install_name_tool -change /usr/local/opt/qt/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets ./OBS.app/Contents/PlugIns/obs-vst.so +install_name_tool -change /usr/local/opt/qt/lib/QtMacExtras.framework/Versions/5/QtMacExtras @executable_path/../Frameworks/QtMacExtras.framework/Versions/5/QtMacExtras ./OBS.app/Contents/PlugIns/obs-vst.so diff --git a/CI/scripts/macos/prepareApp.sh b/CI/scripts/macos/prepareApp.sh new file mode 100755 index 0000000..1a6de88 --- /dev/null +++ b/CI/scripts/macos/prepareApp.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +# Exit if something fails +set -e + +cd ./build + +mv ./rundir/RelWithDebInfo/data/obs-scripting/obslua.so ./rundir/RelWithDebInfo/bin/ +mv ./rundir/RelWithDebInfo/data/obs-scripting/_obspython.so ./rundir/RelWithDebInfo/bin/ +mv ./rundir/RelWithDebInfo/data/obs-scripting/obspython.py ./rundir/RelWithDebInfo/bin/ + +../CI/scripts/macos/packageApp.sh + +# fix obs outputs plugin it doesn't play nicely with dylibBundler at the moment +chmod +w ./OBS.app/Contents/Frameworks/*.dylib +install_name_tool -change libmbedtls.12.dylib @executable_path/../Frameworks/libmbedtls.12.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change libmbedcrypto.3.dylib @executable_path/../Frameworks/libmbedcrypto.3.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change libmbedx509.0.dylib @executable_path/../Frameworks/libmbedx509.0.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change /usr/local/opt/curl/lib/libcurl.4.dylib @executable_path/../Frameworks/libcurl.4.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change @rpath/libobs.0.dylib @executable_path/../Frameworks/libobs.0.dylib ./OBS.app/Contents/Plugins/obs-outputs.so +install_name_tool -change /tmp/obsdeps/bin/libjansson.4.dylib @executable_path/../Frameworks/libjansson.4.dylib ./OBS.app/Contents/Plugins/obs-outputs.so + +cp -R ${GITHUB_WORKSPACE}/cmbuild/sparkle/Sparkle.framework ./OBS.app/Contents/Frameworks/ +install_name_tool -change @rpath/Sparkle.framework/Versions/A/Sparkle @executable_path/../Frameworks/Sparkle.framework/Versions/A/Sparkle ./OBS.app/Contents/MacOS/obs + +sudo mkdir -p ./OBS.app/Contents/Frameworks +sudo cp -R ${GITHUB_WORKSPACE}/cmbuild/cef_binary_${CEF_BUILD_VERSION}_macosx64/Release/Chromium\ Embedded\ Framework.framework ./OBS.app/Contents/Frameworks/ +install_name_tool -change /usr/local/opt/qt/lib/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui ./OBS.app/Contents/Plugins/obs-browser.so +install_name_tool -change /usr/local/opt/qt/lib/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore ./OBS.app/Contents/Plugins/obs-browser.so +install_name_tool -change /usr/local/opt/qt/lib/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets ./OBS.app/Contents/Plugins/obs-browser.so + +cp ../CI/scripts/macos/app/OBSPublicDSAKey.pem ./OBS.app/Contents/Resources + +plutil -insert CFBundleVersion -string $(basename ${GITHUB_REF}) ./OBS.app/Contents/Info.plist +plutil -insert CFBundleShortVersionString -string $(basename ${GITHUB_REF}) ./OBS.app/Contents/Info.plist +plutil -insert OBSFeedsURL -string https://obsproject.com/osx_update/feeds.xml ./OBS.app/Contents/Info.plist +plutil -insert SUFeedURL -string https://obsproject.com/osx_update/stable/updates.xml ./OBS.app/Contents/Info.plist +plutil -insert SUPublicDSAKeyFile -string OBSPublicDSAKey.pem ./OBS.app/Contents/Info.plist + +mv ./OBS.app ../OBS.app +cd - diff --git a/CMakeLists.txt b/CMakeLists.txt index 5ea2c5f..b56c2bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,6 +86,11 @@ if(WIN32) list(GET UI_VERSION_SEMANTIC 0 UI_VERSION_MAJOR) list(GET UI_VERSION_SEMANTIC 1 UI_VERSION_MINOR) list(GET UI_VERSION_SEMANTIC 2 UI_VERSION_PATCH) + set(OBS_COMPANY_NAME "OBS") + set(OBS_PRODUCT_NAME "OBS Studio") + set(OBS_COMMENTS "Free and open source software for video recording and live streaming") + set(OBS_LEGAL_COPYRIGHT "(C) Hugh Bailey") + set(MODULE_DESCRIPTION "OBS Studio") configure_file(UI/obs.rc.in ${PROJECT_BINARY_DIR}/obs.rc) endif() diff --git a/UI/data/locale/en-US.ini b/UI/data/locale/en-US.ini index eef5ba4..017987c 100644 --- a/UI/data/locale/en-US.ini +++ b/UI/data/locale/en-US.ini @@ -52,8 +52,8 @@ Untitled="Untitled" New="New" Duplicate="Duplicate" Enable="Enable" -DisableOSXVSync="Disable OSX V-Sync" -ResetOSXVSyncOnExit="Reset OSX V-Sync on Exit" +DisableOSXVSync="Disable macOS V-Sync" +ResetOSXVSyncOnExit="Reset macOS V-Sync on Exit" HighResourceUsage="Encoding overloaded! Consider turning down video settings or using a faster encoding preset." Transition="Transition" QuickTransitions="Quick Transitions" @@ -324,8 +324,6 @@ Output.RecordNoSpace.Msg="There is not sufficient disk space to continue recordi Output.RecordError.Title="Recording error" Output.RecordError.Msg="An unspecified error occurred while recording." Output.RecordError.EncodeErrorMsg="An encoder error occurred while recording." -Output.ReplayBuffer.NoHotkey.Title="No hotkey set!" -Output.ReplayBuffer.NoHotkey.Msg="No save hotkey set for replay buffer. Please set the \"Save\" hotkey to use for saving replay recordings." # output recording messages Output.BadPath.Title="Bad File Path" @@ -715,7 +713,6 @@ Basic.Settings.Output.ReplayBuffer.SecondsMax="Maximum Replay Time" Basic.Settings.Output.ReplayBuffer.MegabytesMax="Maximum Memory (Megabytes)" Basic.Settings.Output.ReplayBuffer.Estimate="Estimated memory usage: %1 MB" Basic.Settings.Output.ReplayBuffer.EstimateUnknown="Cannot estimate memory usage. Please set maximum memory limit." -Basic.Settings.Output.ReplayBuffer.HotkeyMessage="(Note: Make sure to set a hotkey for the replay buffer in the hotkeys section)" Basic.Settings.Output.ReplayBuffer.Prefix="Replay Buffer Filename Prefix" Basic.Settings.Output.ReplayBuffer.Suffix="Suffix" Basic.Settings.Output.Simple.SavePath="Recording Path" diff --git a/UI/data/themes/Acri.qss b/UI/data/themes/Acri.qss index 7982c67..3d636f2 100644 --- a/UI/data/themes/Acri.qss +++ b/UI/data/themes/Acri.qss @@ -154,6 +154,11 @@ QListWidget QLineEdit { } /* Dock stuff */ +QDockWidget { + titlebar-close-icon: url('./Dark/Close.svg'); + titlebar-normal-icon: url('./Dark/Popout.svg'); +} + QDockWidget { background: #181819; border: none; @@ -182,6 +187,7 @@ QDockWidget::float-button { subcontrol-position: top right; subcontrol-origin: padding; right: 0px; + margin: 0px; } QDockWidget::float-button { diff --git a/UI/data/themes/Dark.qss b/UI/data/themes/Dark.qss index 6420926..7feb6a0 100644 --- a/UI/data/themes/Dark.qss +++ b/UI/data/themes/Dark.qss @@ -119,6 +119,11 @@ SourceTree QLineEdit { /* Dock Widget */ +QDockWidget { + titlebar-close-icon: url('./Dark/Close.svg'); + titlebar-normal-icon: url('./Dark/Popout.svg'); +} + QDockWidget::title { text-align: center; background-color: rgb(70,69,70); diff --git a/UI/data/themes/Dark/close.svg b/UI/data/themes/Dark/close.svg new file mode 100644 index 0000000..9b44a5c --- /dev/null +++ b/UI/data/themes/Dark/close.svg @@ -0,0 +1 @@ + diff --git a/UI/data/themes/Dark/popout.svg b/UI/data/themes/Dark/popout.svg new file mode 100644 index 0000000..afba03a --- /dev/null +++ b/UI/data/themes/Dark/popout.svg @@ -0,0 +1 @@ + diff --git a/UI/data/themes/Rachni.qss b/UI/data/themes/Rachni.qss index f77f011..253061b 100644 --- a/UI/data/themes/Rachni.qss +++ b/UI/data/themes/Rachni.qss @@ -188,6 +188,11 @@ QListWidget::item:hover:!active { /* --- Dock widget --- */ /***********************/ +QDockWidget { + titlebar-close-icon: url('./Dark/Close.svg'); + titlebar-normal-icon: url('./Dark/Popout.svg'); +} + QDockWidget { background: rgb(49, 54, 59); /* Blue-gray */ border: 1px solid rgb(58, 64, 69); /* Light Blue-gray */ diff --git a/UI/forms/OBSBasic.ui b/UI/forms/OBSBasic.ui index 810bf7e..d1dd308 100644 --- a/UI/forms/OBSBasic.ui +++ b/UI/forms/OBSBasic.ui @@ -38,6 +38,21 @@ + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + @@ -853,19 +868,19 @@ - 4 + 2 - 1 + 0 - 1 + 0 - 1 + 0 - 2 + 0 diff --git a/UI/forms/OBSBasicSettings.ui b/UI/forms/OBSBasicSettings.ui index 0009163..6fc4f71 100644 --- a/UI/forms/OBSBasicSettings.ui +++ b/UI/forms/OBSBasicSettings.ui @@ -958,6 +958,12 @@ + + + 0 + 0 + + 1 @@ -1760,13 +1766,6 @@ - - - Basic.Settings.Output.ReplayBuffer.HotkeyMessage - - - - @@ -3670,13 +3669,6 @@ - - - Basic.Settings.Output.ReplayBuffer.HotkeyMessage - - - - diff --git a/UI/forms/images/recording-active.svg b/UI/forms/images/recording-active.svg new file mode 100644 index 0000000..d039ecb --- /dev/null +++ b/UI/forms/images/recording-active.svg @@ -0,0 +1,37 @@ + + + + + + + image/svg+xml + + + + + + + + + diff --git a/UI/forms/images/recording-inactive.svg b/UI/forms/images/recording-inactive.svg new file mode 100644 index 0000000..3d833d8 --- /dev/null +++ b/UI/forms/images/recording-inactive.svg @@ -0,0 +1,37 @@ + + + + + + + image/svg+xml + + + + + + + + + diff --git a/UI/forms/images/recording-pause-inactive.svg b/UI/forms/images/recording-pause-inactive.svg new file mode 100644 index 0000000..6ee3dc7 --- /dev/null +++ b/UI/forms/images/recording-pause-inactive.svg @@ -0,0 +1,45 @@ + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/UI/forms/images/recording-pause.svg b/UI/forms/images/recording-pause.svg new file mode 100644 index 0000000..884b226 --- /dev/null +++ b/UI/forms/images/recording-pause.svg @@ -0,0 +1,45 @@ + + + + + + + image/svg+xml + + + + + + + + + + diff --git a/UI/forms/images/streaming-active.svg b/UI/forms/images/streaming-active.svg new file mode 100644 index 0000000..b7c87bc --- /dev/null +++ b/UI/forms/images/streaming-active.svg @@ -0,0 +1,55 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/UI/forms/images/streaming-inactive.svg b/UI/forms/images/streaming-inactive.svg new file mode 100644 index 0000000..5c2e271 --- /dev/null +++ b/UI/forms/images/streaming-inactive.svg @@ -0,0 +1,55 @@ + + + + + + + image/svg+xml + + + + + + + + + + + + + diff --git a/UI/forms/obs.qrc b/UI/forms/obs.qrc index 1e61844..040e9af 100644 --- a/UI/forms/obs.qrc +++ b/UI/forms/obs.qrc @@ -34,6 +34,12 @@ images/sources/text.svg images/sources/window.svg images/sources/default.svg + images/recording-active.svg + images/recording-inactive.svg + images/recording-pause.svg + images/recording-pause-inactive.svg + images/streaming-active.svg + images/streaming-inactive.svg images/settings/output.svg diff --git a/UI/frontend-plugins/decklink-output-ui/CMakeLists.txt b/UI/frontend-plugins/decklink-output-ui/CMakeLists.txt index da82a6b..44039d2 100644 --- a/UI/frontend-plugins/decklink-output-ui/CMakeLists.txt +++ b/UI/frontend-plugins/decklink-output-ui/CMakeLists.txt @@ -39,6 +39,13 @@ set(decklink-ouput-ui_UI forms/output.ui ) +if(WIN32) + set(MODULE_DESCRIPTION "OBS DeckLink Output UI") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in decklink-ouput-ui.rc) + list(APPEND decklink-ouput-ui_SOURCES + decklink-ouput-ui.rc) +endif() + if(APPLE) set(decklink-ouput-ui_PLATFORM_LIBS ${COCOA}) diff --git a/UI/frontend-plugins/frontend-tools/CMakeLists.txt b/UI/frontend-plugins/frontend-tools/CMakeLists.txt index d595485..f9e8782 100644 --- a/UI/frontend-plugins/frontend-tools/CMakeLists.txt +++ b/UI/frontend-plugins/frontend-tools/CMakeLists.txt @@ -71,8 +71,11 @@ if(SCRIPTING_ENABLED) endif() if(WIN32) + set(MODULE_DESCRIPTION "OBS Frontend Tools") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in frontend-tools.rc) set(frontend-tools_PLATFORM_SOURCES - auto-scene-switcher-win.cpp) + auto-scene-switcher-win.cpp + frontend-tools.rc) if(BUILD_CAPTIONS) set(frontend-tools_PLATFORM_SOURCES diff --git a/UI/importers/sl.cpp b/UI/importers/sl.cpp index c1b98b2..11e55a4 100644 --- a/UI/importers/sl.cpp +++ b/UI/importers/sl.cpp @@ -298,15 +298,8 @@ static int attempt_import(const Json &root, const string &name, Json &res) Json::array filter_items = in_filters["items"].array_items(); Json in_settings = scene["settings"]; - Json in_sync = scene["syncOffset"]; - int sync = (int)(in_sync["sec"].number_value() * 1000000000 + - in_sync["nsec"].number_value()); - - double vol = scene["volume"].number_value(); - bool muted = scene["muted"].bool_value(); string name = scene["name"].string_value(); - int monitoring = scene["monitoringType"].int_value(); Json::object out_hotkeys = Json::object{}; get_hotkey_bindings(out_hotkeys, hotkey_items, ""); @@ -336,11 +329,8 @@ static int attempt_import(const Json &root, const string &name, Json &res) {"id", "scene"}, {"sl_id", sl_id}, {"settings", in_settings}, - {"sync", sync}, - {"volume", vol}, - {"muted", muted}, + {"volume", 1.0}, {"name", out_name}, - {"monitoring_type", monitoring}, {"private_settings", Json::object{}}}; Json in_items = scene["sceneItems"]; diff --git a/UI/obs-frontend-api/CMakeLists.txt b/UI/obs-frontend-api/CMakeLists.txt index 1d5ca9a..445cfef 100644 --- a/UI/obs-frontend-api/CMakeLists.txt +++ b/UI/obs-frontend-api/CMakeLists.txt @@ -7,6 +7,12 @@ add_definitions(-DLIBOBS_EXPORTS) set(obs-frontend-api_SOURCES obs-frontend-api.cpp) +if(WIN32) + set(MODULE_DESCRIPTION "OBS Frontend API") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in ./obs-frontend-api.rc) + list(APPEND obs-frontend-api_SOURCES + obs-frontend-api.rc) +endif() set(obs-frontend-api_HEADERS obs-frontend-internal.hpp obs-frontend-api.h) diff --git a/UI/properties-view.cpp b/UI/properties-view.cpp index 4431366..350cf47 100644 --- a/UI/properties-view.cpp +++ b/UI/properties-view.cpp @@ -1694,7 +1694,7 @@ bool WidgetInfo::ColorChanged(const char *setting) * other open QDialogs on exit, and * https://bugreports.qt-project.org/browse/QTBUG-34532 */ -#ifdef __APPLE__ +#ifndef _WIN32 options |= QColorDialog::DontUseNativeDialog; #endif @@ -1728,7 +1728,7 @@ bool WidgetInfo::FontChanged(const char *setting) QFontDialog::FontDialogOptions options; -#ifdef __APPLE__ +#ifndef _WIN32 options = QFontDialog::DontUseNativeDialog; #endif diff --git a/UI/properties-view.moc.hpp b/UI/properties-view.moc.hpp index a5cf36d..39f32a7 100644 --- a/UI/properties-view.moc.hpp +++ b/UI/properties-view.moc.hpp @@ -6,6 +6,7 @@ #include #include +#include #include #include diff --git a/UI/source-tree.hpp b/UI/source-tree.hpp index bf5569c..32a4c59 100644 --- a/UI/source-tree.hpp +++ b/UI/source-tree.hpp @@ -8,6 +8,8 @@ #include #include #include +#include +#include class QLabel; class QCheckBox; diff --git a/UI/window-basic-main-dropfiles.cpp b/UI/window-basic-main-dropfiles.cpp index 375eb66..462161b 100644 --- a/UI/window-basic-main-dropfiles.cpp +++ b/UI/window-basic-main-dropfiles.cpp @@ -169,6 +169,12 @@ void OBSBasic::AddDropSource(const char *data, DropType image) void OBSBasic::dragEnterEvent(QDragEnterEvent *event) { + // refuse drops of our own widgets + if (event->source() != nullptr) { + event->setDropAction(Qt::IgnoreAction); + return; + } + event->acceptProposedAction(); } diff --git a/UI/window-basic-main-transitions.cpp b/UI/window-basic-main-transitions.cpp index 552dc0f..ea2d9a8 100644 --- a/UI/window-basic-main-transitions.cpp +++ b/UI/window-basic-main-transitions.cpp @@ -1346,7 +1346,7 @@ void OBSBasic::SetPreviewProgramMode(bool enabled) RefreshQuickTransitions(); - programLabel = new QLabel(QTStr("StudioMode.Program")); + programLabel = new QLabel(QTStr("StudioMode.Program"), this); programLabel->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); programLabel->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index a830ce5..09304eb 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -385,6 +385,7 @@ OBSBasic::OBSBasic(QWidget *parent) statsDock->move(newPos); ui->previewLabel->setProperty("themeID", "previewProgramLabels"); + ui->previewLabel->style()->polish(ui->previewLabel); bool labels = config_get_bool(GetGlobalConfig(), "BasicWindow", "StudioModeLabels"); @@ -670,6 +671,8 @@ void OBSBasic::DeferSaveEnd() } } +static void LogFilter(obs_source_t *, obs_source_t *filter, void *v_val); + static void LoadAudioDevice(const char *name, int channel, obs_data_t *parent) { obs_data_t *data = obs_data_get_obj(parent, name); @@ -679,6 +682,10 @@ static void LoadAudioDevice(const char *name, int channel, obs_data_t *parent) obs_source_t *source = obs_load_source(data); if (source) { obs_set_output_source(channel, source); + + const char *name = obs_source_get_name(source); + blog(LOG_INFO, "[Loaded global audio device]: '%s'", name); + obs_source_enum_filters(source, LogFilter, (void *)(intptr_t)1); obs_source_release(source); } @@ -3915,6 +3922,7 @@ void OBSBasic::ClearSceneData() return true; }; + obs_enum_scenes(cb, nullptr); obs_enum_sources(cb, nullptr); if (api) @@ -5719,9 +5727,6 @@ void OBSBasic::RecordingStop(int code, QString last_error) UpdatePause(false); } -#define RP_NO_HOTKEY_TITLE QTStr("Output.ReplayBuffer.NoHotkey.Title") -#define RP_NO_HOTKEY_TEXT QTStr("Output.ReplayBuffer.NoHotkey.Msg") - void OBSBasic::ShowReplayBufferPauseWarning() { auto msgBox = []() { @@ -5773,21 +5778,6 @@ void OBSBasic::StartReplayBuffer() return; } - obs_output_t *output = outputHandler->replayBuffer; - obs_data_t *hotkeys = obs_hotkeys_save_output(output); - obs_data_array_t *bindings = - obs_data_get_array(hotkeys, "ReplayBuffer.Save"); - size_t count = obs_data_array_count(bindings); - obs_data_array_release(bindings); - obs_data_release(hotkeys); - - if (!count) { - OBSMessageBox::information(this, RP_NO_HOTKEY_TITLE, - RP_NO_HOTKEY_TEXT); - replayBufferButton->setChecked(false); - return; - } - if (api) api->on_event(OBS_FRONTEND_EVENT_REPLAY_BUFFER_STARTING); @@ -6225,6 +6215,9 @@ void OBSBasic::on_actionEditTransform_triggered() if (transformWindow) transformWindow->close(); + if (!GetCurrentSceneItem()) + return; + transformWindow = new OBSBasicTransform(this); transformWindow->show(); transformWindow->setAttribute(Qt::WA_DeleteOnClose, true); @@ -7264,7 +7257,7 @@ void OBSBasic::on_actionCopySource_triggered() copyVisible = obs_sceneitem_visible(item); uint32_t output_flags = obs_source_get_output_flags(source); - if (!(output_flags & OBS_SOURCE_DO_NOT_DUPLICATE) == 0) + if (output_flags & OBS_SOURCE_DO_NOT_DUPLICATE) allowPastingDuplicate = false; } @@ -7482,7 +7475,7 @@ void OBSBasic::ColorChange() obs_data_get_string(curPrivData, "color"); const char *customColor = *oldColor != 0 ? oldColor : "#55FF0000"; -#ifdef __APPLE__ +#ifndef _WIN32 options |= QColorDialog::DontUseNativeDialog; #endif @@ -7703,6 +7696,8 @@ void OBSBasic::PauseRecording() pause->setChecked(true); pause->blockSignals(false); + ui->statusbar->RecordingPaused(); + if (trayIcon) trayIcon->setIcon(QIcon(":/res/images/obs_paused.png")); @@ -7730,6 +7725,8 @@ void OBSBasic::UnpauseRecording() pause->setChecked(false); pause->blockSignals(false); + ui->statusbar->RecordingUnpaused(); + if (trayIcon) trayIcon->setIcon( QIcon(":/res/images/tray_active.png")); diff --git a/UI/window-basic-stats.hpp b/UI/window-basic-stats.hpp index 81f993d..d760f64 100644 --- a/UI/window-basic-stats.hpp +++ b/UI/window-basic-stats.hpp @@ -2,6 +2,7 @@ #include #include +#include #include #include #include diff --git a/UI/window-basic-status-bar.cpp b/UI/window-basic-status-bar.cpp index a4ef72f..93cc4af 100644 --- a/UI/window-basic-status-bar.cpp +++ b/UI/window-basic-status-bar.cpp @@ -11,18 +11,36 @@ OBSBasicStatusBar::OBSBasicStatusBar(QWidget *parent) : QStatusBar(parent), delayInfo(new QLabel), droppedFrames(new QLabel), + streamIcon(new QLabel), streamTime(new QLabel), + recordIcon(new QLabel), recordTime(new QLabel), cpuUsage(new QLabel), transparentPixmap(20, 20), greenPixmap(20, 20), grayPixmap(20, 20), - redPixmap(20, 20) + redPixmap(20, 20), + recordingActivePixmap(QIcon(":/res/images/recording-active.svg") + .pixmap(QSize(20, 20))), + recordingPausePixmap(QIcon(":/res/images/recording-pause.svg") + .pixmap(QSize(20, 20))), + recordingPauseInactivePixmap( + QIcon(":/res/images/recording-pause-inactive.svg") + .pixmap(QSize(20, 20))), + recordingInactivePixmap(QIcon(":/res/images/recording-inactive.svg") + .pixmap(QSize(20, 20))), + streamingActivePixmap(QIcon(":/res/images/streaming-active.svg") + .pixmap(QSize(20, 20))), + streamingInactivePixmap(QIcon(":/res/images/streaming-inactive.svg") + .pixmap(QSize(20, 20))) { streamTime->setText(QString("LIVE: 00:00:00")); recordTime->setText(QString("REC: 00:00:00")); cpuUsage->setText(QString("CPU: 0.0%, 0.00 fps")); + streamIcon->setPixmap(streamingInactivePixmap); + recordIcon->setPixmap(recordingInactivePixmap); + QWidget *brWidget = new QWidget(this); QHBoxLayout *brLayout = new QHBoxLayout(brWidget); brLayout->setContentsMargins(0, 0, 0, 0); @@ -39,8 +57,12 @@ OBSBasicStatusBar::OBSBasicStatusBar(QWidget *parent) delayInfo->setAlignment(Qt::AlignVCenter); droppedFrames->setAlignment(Qt::AlignRight); droppedFrames->setAlignment(Qt::AlignVCenter); + streamIcon->setAlignment(Qt::AlignRight); + streamIcon->setAlignment(Qt::AlignVCenter); streamTime->setAlignment(Qt::AlignRight); streamTime->setAlignment(Qt::AlignVCenter); + recordIcon->setAlignment(Qt::AlignRight); + recordIcon->setAlignment(Qt::AlignVCenter); recordTime->setAlignment(Qt::AlignRight); recordTime->setAlignment(Qt::AlignVCenter); cpuUsage->setAlignment(Qt::AlignRight); @@ -50,13 +72,15 @@ OBSBasicStatusBar::OBSBasicStatusBar(QWidget *parent) delayInfo->setIndent(20); droppedFrames->setIndent(20); - streamTime->setIndent(20); - recordTime->setIndent(20); + streamIcon->setIndent(20); + recordIcon->setIndent(20); cpuUsage->setIndent(20); kbps->setIndent(10); addPermanentWidget(droppedFrames); + addPermanentWidget(streamIcon); addPermanentWidget(streamTime); + addPermanentWidget(recordIcon); addPermanentWidget(recordTime); addPermanentWidget(cpuUsage); addPermanentWidget(delayInfo); @@ -93,6 +117,14 @@ void OBSBasicStatusBar::Activate() statusSquare->setPixmap(grayPixmap); } } + + if (streamOutput) { + streamIcon->setPixmap(streamingActivePixmap); + } + + if (recordOutput) { + recordIcon->setPixmap(recordingActivePixmap); + } } void OBSBasicStatusBar::Deactivate() @@ -103,11 +135,13 @@ void OBSBasicStatusBar::Deactivate() if (!streamOutput) { streamTime->setText(QString("LIVE: 00:00:00")); + streamIcon->setPixmap(streamingInactivePixmap); totalStreamSeconds = 0; } if (!recordOutput) { recordTime->setText(QString("REC: 00:00:00")); + recordIcon->setPixmap(recordingInactivePixmap); totalRecordSeconds = 0; } @@ -247,25 +281,26 @@ void OBSBasicStatusBar::UpdateRecordTime() { bool paused = os_atomic_load_bool(&recording_paused); - if (!paused) + if (!paused) { totalRecordSeconds++; - QString text; - - if (paused) { - text = QStringLiteral("REC: PAUSED"); - } else { int seconds = totalRecordSeconds % 60; int totalMinutes = totalRecordSeconds / 60; int minutes = totalMinutes % 60; int hours = totalMinutes / 60; - text = QString::asprintf("REC: %02d:%02d:%02d", hours, minutes, - seconds); - } + QString text = QString::asprintf("REC: %02d:%02d:%02d", hours, + minutes, seconds); - recordTime->setText(text); - recordTime->setMinimumWidth(recordTime->width()); + recordTime->setText(text); + recordTime->setMinimumWidth(recordTime->width()); + } else { + recordIcon->setPixmap(streamPauseIconToggle + ? recordingPauseInactivePixmap + : recordingPausePixmap); + + streamPauseIconToggle = !streamPauseIconToggle; + } } void OBSBasicStatusBar::UpdateDroppedFrames() @@ -483,3 +518,22 @@ void OBSBasicStatusBar::RecordingStopped() recordOutput = nullptr; Deactivate(); } + +void OBSBasicStatusBar::RecordingPaused() +{ + QString text = QStringLiteral("REC: PAUSED"); + recordTime->setText(text); + recordTime->setMinimumWidth(recordTime->width()); + + if (recordOutput) { + recordIcon->setPixmap(recordingPausePixmap); + streamPauseIconToggle = true; + } +} + +void OBSBasicStatusBar::RecordingUnpaused() +{ + if (recordOutput) { + recordIcon->setPixmap(recordingActivePixmap); + } +} diff --git a/UI/window-basic-status-bar.hpp b/UI/window-basic-status-bar.hpp index 972bf87..65e3fd4 100644 --- a/UI/window-basic-status-bar.hpp +++ b/UI/window-basic-status-bar.hpp @@ -14,8 +14,10 @@ class OBSBasicStatusBar : public QStatusBar { private: QLabel *delayInfo; QLabel *droppedFrames; + QLabel *streamIcon; QLabel *streamTime; QLabel *recordTime; + QLabel *recordIcon; QLabel *cpuUsage; QLabel *kbps; QLabel *statusSquare; @@ -24,6 +26,7 @@ private: obs_output_t *recordOutput = nullptr; bool active = false; bool overloadedNotify = true; + bool streamPauseIconToggle = false; int retries = 0; int totalStreamSeconds = 0; @@ -48,6 +51,13 @@ private: QPixmap grayPixmap; QPixmap redPixmap; + QPixmap recordingActivePixmap; + QPixmap recordingPausePixmap; + QPixmap recordingPauseInactivePixmap; + QPixmap recordingInactivePixmap; + QPixmap streamingActivePixmap; + QPixmap streamingInactivePixmap; + float lastCongestion = 0.0f; QPointer refreshTimer; @@ -81,6 +91,8 @@ public: void StreamStopped(); void RecordingStarted(obs_output_t *output); void RecordingStopped(); + void RecordingPaused(); + void RecordingUnpaused(); void ReconnectClear(); }; diff --git a/UI/window-importer.cpp b/UI/window-importer.cpp index e550279..3e21ad5 100644 --- a/UI/window-importer.cpp +++ b/UI/window-importer.cpp @@ -92,6 +92,9 @@ QWidget *ImporterEntryPathItemDelegate::createEditor( QSizePolicy::ControlType::LineEdit)); layout->addWidget(text); + QObject::connect(text, SIGNAL(editingFinished()), this, + SLOT(updateText())); + QToolButton *browseButton = new QToolButton(); browseButton->setText("..."); browseButton->setSizePolicy(buttonSizePolicy); @@ -121,8 +124,6 @@ void ImporterEntryPathItemDelegate::setEditorData( { QLineEdit *text = editor->findChild(); text->setText(index.data().toString()); - QObject::connect(text, SIGNAL(textEdited(QString)), this, - SLOT(updateText())); editor->setProperty(PATH_LIST_PROP, QVariant()); } diff --git a/UI/window-projector.cpp b/UI/window-projector.cpp index 34dcef9..ffb9ea0 100644 --- a/UI/window-projector.cpp +++ b/UI/window-projector.cpp @@ -58,9 +58,6 @@ OBSProjector::OBSProjector(QWidget *widget, obs_source_t *source_, int monitor, connect(this, &OBSQTDisplay::DisplayCreated, addDrawCallback); - if (isFullScreen()) - SetHideCursor(); - if (type == ProjectorType::Multiview) { obs_enter_graphics(); @@ -169,8 +166,9 @@ void OBSProjector::SetMonitor(int monitor) { savedMonitor = monitor; QScreen *screen = QGuiApplication::screens()[monitor]; - showFullScreen(); setGeometry(screen->geometry()); + showFullScreen(); + SetHideCursor(); } void OBSProjector::SetHideCursor() @@ -1034,7 +1032,6 @@ void OBSProjector::OpenFullScreenProjector() int monitor = sender()->property("monitor").toInt(); SetMonitor(monitor); - SetHideCursor(); UpdateProjectorTitle(QT_UTF8(obs_source_get_name(source))); } diff --git a/UI/window-remux.cpp b/UI/window-remux.cpp index 6a94ed5..9fa6263 100644 --- a/UI/window-remux.cpp +++ b/UI/window-remux.cpp @@ -112,6 +112,9 @@ QWidget *RemuxEntryPathItemDelegate::createEditor( QSizePolicy::ControlType::LineEdit)); layout->addWidget(text); + QObject::connect(text, SIGNAL(editingFinished()), this, + SLOT(updateText())); + QToolButton *browseButton = new QToolButton(); browseButton->setText("..."); browseButton->setSizePolicy(buttonSizePolicy); @@ -143,8 +146,6 @@ void RemuxEntryPathItemDelegate::setEditorData(QWidget *editor, { QLineEdit *text = editor->findChild(); text->setText(index.data().toString()); - QObject::connect(text, SIGNAL(textEdited(QString)), this, - SLOT(updateText())); editor->setProperty(PATH_LIST_PROP, QVariant()); } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 5ca04fd..251adff 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -55,7 +55,7 @@ jobs: condition: or(ne(variables['Build.Reason'], 'PullRequest'), eq(variables['prHasCILabel'], true)) inputs: pathtoPublish: './nightly' - artifactName: build + artifactName: macbuild - job: 'Build_Windows32' dependsOn: Prebuild diff --git a/cmake/winrc/obs-module.rc.in b/cmake/winrc/obs-module.rc.in new file mode 100644 index 0000000..a071576 --- /dev/null +++ b/cmake/winrc/obs-module.rc.in @@ -0,0 +1,24 @@ +1 VERSIONINFO +FILEVERSION ${UI_VERSION_MAJOR},${UI_VERSION_MINOR},${UI_VERSION_PATCH},0 +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904B0" + BEGIN + VALUE "CompanyName", "${OBS_COMPANY_NAME}" + VALUE "FileDescription", "${MODULE_DESCRIPTION}" + VALUE "FileVersion", "${UI_VERSION}" + VALUE "ProductName", "${OBS_PRODUCT_NAME}" + VALUE "ProductVersion", "${UI_VERSION}" + VALUE "Comments", "${OBS_COMMENTS}" + VALUE "LegalCopyright", "${OBS_LEGAL_COPYRIGHT}" + VALUE "InternalName", "${PROJECT_NAME}" + VALUE "OriginalFilename", "${PROJECT_NAME}" + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0409, 0x04B0 + END +END \ No newline at end of file diff --git a/deps/glad/CMakeLists.txt b/deps/glad/CMakeLists.txt index 79c4d3b..2c4cf13 100644 --- a/deps/glad/CMakeLists.txt +++ b/deps/glad/CMakeLists.txt @@ -11,9 +11,12 @@ set(glad_SOURCES include/glad/glad.h) if(WIN32) + set(MODULE_DESCRIPTION "Glad OpenGL Loading Library") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obsglad.rc) set(glad_PLATFORM_SOURCES src/glad_wgl.c - include/glad/glad_wgl.h) + include/glad/glad_wgl.h + obsglad.rc) elseif(NOT APPLE) set(glad_PLATFORM_SOURCES src/glad_glx.c diff --git a/deps/obs-scripting/CMakeLists.txt b/deps/obs-scripting/CMakeLists.txt index 0421ec9..7dd316f 100644 --- a/deps/obs-scripting/CMakeLists.txt +++ b/deps/obs-scripting/CMakeLists.txt @@ -158,6 +158,13 @@ set(obs-scripting_HEADERS cstrcache.h ) +if(WIN32) + set(MODULE_DESCRIPTION "OBS Studio scripting module") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obs-scripting.rc) + list(APPEND obs-scripting_SOURCES + obs-scripting.rc) +endif() + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/swig) if(PYTHONLIBS_FOUND) diff --git a/deps/w32-pthreads/CMakeLists.txt b/deps/w32-pthreads/CMakeLists.txt index 992ec69..7fd3808 100644 --- a/deps/w32-pthreads/CMakeLists.txt +++ b/deps/w32-pthreads/CMakeLists.txt @@ -4,8 +4,11 @@ if(NOT WIN32) return() endif() +set(MODULE_DESCRIPTION "POSIX Threads for Windows") +configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in w32-pthreads.rc) set(w32-pthreads_SOURCES - pthread.c) + pthread.c + w32-pthreads.rc) set(w32-pthreads_HEADERS implement.h diff --git a/docs/sphinx/conf.py b/docs/sphinx/conf.py index 47ee2ec..55d2aa0 100644 --- a/docs/sphinx/conf.py +++ b/docs/sphinx/conf.py @@ -57,9 +57,9 @@ author = 'Hugh Bailey' # built documents. # # The short X.Y version. -version = '20.1.0' +version = '25.0.0' # The full version, including alpha/beta/rc tags. -release = '20.1.0' +release = '25.0.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/docs/sphinx/reference-properties.rst b/docs/sphinx/reference-properties.rst index 7024b01..e06418a 100644 --- a/docs/sphinx/reference-properties.rst +++ b/docs/sphinx/reference-properties.rst @@ -71,6 +71,10 @@ General Functions --------------------- +.. function:: obs_properties_t *obs_properties_get_parent(obs_properties_t *props) + +--------------------- + Property Object Functions ------------------------- @@ -276,6 +280,29 @@ Property Object Functions --------------------- +.. function:: obs_property_t *obs_properties_add_group(obs_properties_t *props, const char *name, const char *description, enum obs_group_type type, obs_properties_t *group) + + Adds a property group. + + :param name: Setting identifier string + :param description: Localized name shown to user + :param type: Can be one of the following values: + + - **OBS_GROUP_NORMAL** - A normal group with just a name and content. + - **OBS_GROUP_CHECKABLE** - A checkable group with a checkbox, name and content. + + :param group: Group to add + + :return: The property + + Important Related Functions: + + - :c:func:`obs_property_group_type` + - :c:func:`obs_property_group_content` + - :c:func:`obs_properties_get_parent` + +--------------------- + Property Enumeration Functions ------------------------------ @@ -340,6 +367,7 @@ Property Enumeration Functions - OBS_PROPERTY_FONT - OBS_PROPERTY_EDITABLE_LIST - OBS_PROPERTY_FRAME_RATE + - OBS_PROPERTY_GROUP --------------------- @@ -467,6 +495,20 @@ Property Enumeration Functions --------------------- +.. function:: enum obs_group_type obs_property_group_type(obs_property_t *p) + + :return: One of the following values: + + - OBS_COMBO_INVALID + - OBS_GROUP_NORMAL + - OBS_GROUP_CHECKABLE + +--------------------- + +.. function:: obs_properties_t *obs_property_group_content(obs_property_t *p) + +--------------------- + Property Modification Functions ------------------------------- diff --git a/formatcode.sh b/formatcode.sh index 87a5478..f585bc2 100755 --- a/formatcode.sh +++ b/formatcode.sh @@ -14,10 +14,8 @@ set -o nounset # Get CPU count OS=$(uname) NPROC=1 -if [[ $OS = "Linux" ]] ; then - NPROC=$(nproc) -elif [[ ${OS} = "Darwin" ]] ; then - NPROC=$(sysctl -n hw.physicalcpu) +if [[ $OS = "Linux" || $OS = "Darwin" ]] ; then + NPROC=$(getconf _NPROCESSORS_ONLN) fi # Discover clang-format diff --git a/libobs-d3d11/CMakeLists.txt b/libobs-d3d11/CMakeLists.txt index 582f215..9bd76cd 100644 --- a/libobs-d3d11/CMakeLists.txt +++ b/libobs-d3d11/CMakeLists.txt @@ -4,6 +4,9 @@ include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/libobs") add_definitions(-DLIBOBS_EXPORTS) +set(MODULE_DESCRIPTION "OBS Library D3D11 wrapper") +configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in libobs-d3d11.rc) + if(NOT DEFINED GPU_PRIORITY_VAL OR "${GPU_PRIORITY_VAL}" STREQUAL "" OR "${GPU_PRIORITY_VAL}" STREQUAL "0") set(USE_GPU_PRIORITY FALSE) @@ -30,7 +33,8 @@ set(libobs-d3d11_SOURCES d3d11-vertexbuffer.cpp d3d11-duplicator.cpp d3d11-rebuild.cpp - d3d11-zstencilbuffer.cpp) + d3d11-zstencilbuffer.cpp + libobs-d3d11.rc) set(libobs-d3d11_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/d3d11-config.h diff --git a/libobs-opengl/CMakeLists.txt b/libobs-opengl/CMakeLists.txt index 086d652..1d53d51 100644 --- a/libobs-opengl/CMakeLists.txt +++ b/libobs-opengl/CMakeLists.txt @@ -7,8 +7,11 @@ include_directories(${OPENGL_INCLUDE_DIR}) add_definitions(-DLIBOBS_EXPORTS) if(WIN32) + set(MODULE_DESCRIPTION "OBS Library OpenGL wrapper") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in libobs-opengl.rc) set(libobs-opengl_PLATFORM_SOURCES - gl-windows.c) + gl-windows.c + libobs-opengl.rc) elseif(APPLE) set(libobs-opengl_PLATFORM_SOURCES gl-cocoa.m) diff --git a/libobs-opengl/gl-shaderparser.c b/libobs-opengl/gl-shaderparser.c index f66e852..aaaa056 100644 --- a/libobs-opengl/gl-shaderparser.c +++ b/libobs-opengl/gl-shaderparser.c @@ -270,6 +270,7 @@ static inline void gl_write_structs(struct gl_shader_parser *glsp) * mul -> (change to operator) * rsqrt -> inversesqrt * saturate -> (use clamp) + * sincos -> (map to manual sin/cos calls) * tex* -> texture * tex*grad -> textureGrad * tex*lod -> textureLod @@ -301,6 +302,51 @@ static bool gl_write_mul(struct gl_shader_parser *glsp, return true; } +static bool gl_write_sincos(struct gl_shader_parser *glsp, + struct cf_token **p_token) +{ + struct cf_parser *cfp = &glsp->parser.cfp; + struct dstr var = {0}; + bool success = false; + + cfp->cur_token = *p_token; + + if (!cf_next_token(cfp)) + return false; + if (!cf_token_is(cfp, "(")) + return false; + + dstr_printf(&var, "sincos_var_internal_%d", glsp->sincos_counter++); + + dstr_cat(&glsp->gl_string, "float "); + dstr_cat_dstr(&glsp->gl_string, &var); + dstr_cat(&glsp->gl_string, " = "); + gl_write_function_contents(glsp, &cfp->cur_token, ","); + dstr_cat(&glsp->gl_string, "); "); + + if (!cf_next_token(cfp)) + goto fail; + gl_write_function_contents(glsp, &cfp->cur_token, ","); + dstr_cat(&glsp->gl_string, " = sin("); + dstr_cat_dstr(&glsp->gl_string, &var); + dstr_cat(&glsp->gl_string, "); "); + + if (!cf_next_token(cfp)) + goto fail; + gl_write_function_contents(glsp, &cfp->cur_token, ")"); + dstr_cat(&glsp->gl_string, " = cos("); + dstr_cat_dstr(&glsp->gl_string, &var); + dstr_cat(&glsp->gl_string, ")"); + + success = true; + +fail: + dstr_free(&var); + + *p_token = cfp->cur_token; + return success; +} + static bool gl_write_saturate(struct gl_shader_parser *glsp, struct cf_token **p_token) { @@ -404,7 +450,7 @@ static bool gl_write_intrinsic(struct gl_shader_parser *glsp, bool written = true; if (strref_cmp(&token->str, "atan2") == 0) { - dstr_cat(&glsp->gl_string, "atan2"); + dstr_cat(&glsp->gl_string, "atan"); } else if (strref_cmp(&token->str, "ddx") == 0) { dstr_cat(&glsp->gl_string, "dFdx"); } else if (strref_cmp(&token->str, "ddy") == 0) { @@ -421,6 +467,8 @@ static bool gl_write_intrinsic(struct gl_shader_parser *glsp, written = gl_write_saturate(glsp, &token); } else if (strref_cmp(&token->str, "mul") == 0) { written = gl_write_mul(glsp, &token); + } else if (strref_cmp(&token->str, "sincos") == 0) { + written = gl_write_sincos(glsp, &token); } else { struct shader_var *var = sp_getparam(glsp, token); if (var && astrcmp_n(var->type, "texture", 7) == 0) diff --git a/libobs-opengl/gl-shaderparser.h b/libobs-opengl/gl-shaderparser.h index 0667aa5..af837fc 100644 --- a/libobs-opengl/gl-shaderparser.h +++ b/libobs-opengl/gl-shaderparser.h @@ -48,6 +48,7 @@ struct gl_shader_parser { const char *output_prefix; struct shader_parser parser; struct dstr gl_string; + int sincos_counter; DARRAY(uint32_t) texture_samplers; DARRAY(struct gl_parser_attrib) attribs; @@ -70,6 +71,7 @@ static inline void gl_shader_parser_init(struct gl_shader_parser *glsp, dstr_init(&glsp->gl_string); da_init(glsp->texture_samplers); da_init(glsp->attribs); + glsp->sincos_counter = 1; } static inline void gl_shader_parser_free(struct gl_shader_parser *glsp) diff --git a/libobs-opengl/gl-subsystem.c b/libobs-opengl/gl-subsystem.c index 5af89c4..deede95 100644 --- a/libobs-opengl/gl-subsystem.c +++ b/libobs-opengl/gl-subsystem.c @@ -1264,7 +1264,6 @@ void device_set_viewport(gs_device_t *device, int x, int y, int width, int height) { uint32_t base_height = 0; - int gl_y = 0; /* GL uses bottom-up coordinates for viewports. We want top-down */ if (device->cur_render_target) { @@ -1274,7 +1273,8 @@ void device_set_viewport(gs_device_t *device, int x, int y, int width, gl_getclientsize(device->cur_swap, &dw, &base_height); } - if (base_height) + GLint gl_y = y; + if (base_height && !device->cur_fbo) gl_y = base_height - y - height; glViewport(x, gl_y, width, height); diff --git a/libobs-winrt/winrt-capture.cpp b/libobs-winrt/winrt-capture.cpp index 8b1472c..1893001 100644 --- a/libobs-winrt/winrt-capture.cpp +++ b/libobs-winrt/winrt-capture.cpp @@ -18,10 +18,14 @@ try { return winrt::Windows::Foundation::Metadata::ApiInformation:: IsApiContractPresent(L"Windows.Foundation.UniversalApiContract", 8); -} catch (winrt::hresult_error &err) { +} catch (const winrt::hresult_error &err) { blog(LOG_ERROR, "winrt_capture_supported (0x%08X): %ls", err.to_abi(), err.message().c_str()); return false; +} catch (...) { + blog(LOG_ERROR, "winrt_capture_supported (0x%08X)", + winrt::to_hresult()); + return false; } extern "C" EXPORT BOOL winrt_capture_cursor_toggle_supported() @@ -34,10 +38,14 @@ try { #else return false; #endif -} catch (winrt::hresult_error &err) { +} catch (const winrt::hresult_error &err) { blog(LOG_ERROR, "winrt_capture_cursor_toggle_supported (0x%08X): %ls", err.to_abi(), err.message().c_str()); return false; +} catch (...) { + blog(LOG_ERROR, "winrt_capture_cursor_toggle_supported (0x%08X)", + winrt::to_hresult()); + return false; } template @@ -353,6 +361,10 @@ try { blog(LOG_ERROR, "CreateForWindow (0x%08X): %ls", err.to_abi(), err.message().c_str()); return nullptr; + } catch (...) { + blog(LOG_ERROR, "CreateForWindow (0x%08X)", + winrt::to_hresult()); + return nullptr; } const winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice @@ -406,10 +418,13 @@ try { return capture; -} catch (winrt::hresult_error &err) { +} catch (const winrt::hresult_error &err) { blog(LOG_ERROR, "winrt_capture_init (0x%08X): %ls", err.to_abi(), err.message().c_str()); return nullptr; +} catch (...) { + blog(LOG_ERROR, "winrt_capture_init (0x%08X)", winrt::to_hresult()); + return nullptr; } extern "C" EXPORT void winrt_capture_free(struct winrt_capture *capture) diff --git a/libobs/CMakeLists.txt b/libobs/CMakeLists.txt index 84889e6..0b592d7 100644 --- a/libobs/CMakeLists.txt +++ b/libobs/CMakeLists.txt @@ -81,12 +81,22 @@ add_definitions(-DLIBOBS_EXPORTS) include_directories(${OBS_JANSSON_INCLUDE_DIRS}) if(WIN32) + set(MODULE_DESCRIPTION "OBS Library") + file(STRINGS obs-config.h _version_parse REGEX "^.*(MAJOR|MINOR|PATCH)_VER[ \t]+[0-9]+[ \t]*$") + + string(REGEX REPLACE ".*MAJOR_VER[ \t]+([0-9]+).*" "\\1" UI_VERSION_MAJOR "${_version_parse}") + string(REGEX REPLACE ".*MINOR_VER[ \t]+([0-9]+).*" "\\1" UI_VERSION_MINOR "${_version_parse}") + string(REGEX REPLACE ".*PATCH_VER[ \t]+([0-9]+).*" "\\1" UI_VERSION_PATCH "${_version_parse}") + set(UI_VERSION "${UI_VERSION_MAJOR}.${UI_VERSION_MINOR}.${UI_VERSION_PATCH}") + + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in libobs.rc) set(libobs_PLATFORM_SOURCES obs-win-crash-handler.c obs-windows.c util/threading-windows.c util/pipe-windows.c - util/platform-windows.c) + util/platform-windows.c + libobs.rc) set(libobs_PLATFORM_HEADERS util/threading-windows.h util/windows/win-registry.h diff --git a/libobs/obs-cocoa.m b/libobs/obs-cocoa.m index 4f0d30d..71cfaba 100644 --- a/libobs/obs-cocoa.m +++ b/libobs/obs-cocoa.m @@ -65,7 +65,7 @@ void add_default_module_paths(void) [NSRunningApplication currentApplication]; NSURL *bundleURL = [app bundleURL]; NSURL *pluginsURL = [bundleURL - URLByAppendingPathComponent:@"Contents/Plugins"]; + URLByAppendingPathComponent:@"Contents/PlugIns"]; NSURL *dataURL = [bundleURL URLByAppendingPathComponent: @"Contents/Resources/data/obs-plugins/%module%"]; @@ -175,6 +175,8 @@ static void log_os_name(id pi, SEL UTF8StringSel) blog(LOG_INFO, "OS Name: %s", name ? name : "Unknown"); } +static bool using_10_15_or_above = true; + static void log_os_version(id pi, SEL UTF8StringSel) { typedef id (*version_func)(id, SEL); @@ -186,6 +188,16 @@ static void log_os_version(id pi, SEL UTF8StringSel) const char *version = UTF8String(vs, UTF8StringSel); blog(LOG_INFO, "OS Version: %s", version ? version : "Unknown"); + + if (version) { + int major; + int minor; + + int count = sscanf(version, "Version %d.%d", &major, &minor); + if (count == 2 && major == 10) { + using_10_15_or_above = minor >= 15; + } + } } static void log_os(void) @@ -239,6 +251,7 @@ static bool dstr_from_cfstring(struct dstr *str, CFStringRef ref) struct obs_hotkeys_platform { volatile long refs; + bool secure_input_activated; TISInputSourceRef tis; CFDataRef layout_data; UCKeyboardLayout *layout; @@ -1749,6 +1762,14 @@ bool obs_hotkeys_platform_is_pressed(obs_hotkeys_platform_t *plat, if (key >= OBS_KEY_LAST_VALUE) return false; + /* if secure input is activated, kill hotkeys. + * + * TODO: rewrite all mac hotkey code, suspect there's a bug in 10.15 + * causing the crash internally. */ + if (plat->secure_input_activated) { + return false; + } + for (size_t i = 0; i < plat->keys[key].num;) { IOHIDElementRef element = plat->keys[key].array[i]; IOHIDValueRef value = 0; @@ -1758,6 +1779,11 @@ bool obs_hotkeys_platform_is_pressed(obs_hotkeys_platform_t *plat, continue; } + if (using_10_15_or_above && IsSecureEventInputEnabled()) { + plat->secure_input_activated = true; + return false; + } + if (IOHIDDeviceGetValue(device, element, &value) != kIOReturnSuccess) { i += 1; diff --git a/libobs/obs-config.h b/libobs/obs-config.h index 1cc3672..3fb5ddb 100644 --- a/libobs/obs-config.h +++ b/libobs/obs-config.h @@ -41,7 +41,7 @@ * * Reset to zero each major or minor version */ -#define LIBOBS_API_PATCH_VER 3 +#define LIBOBS_API_PATCH_VER 8 #define MAKE_SEMANTIC_VERSION(major, minor, patch) \ ((major << 24) | (minor << 16) | patch) diff --git a/libobs/obs-encoder.c b/libobs/obs-encoder.c index 6ba2faf..d15662a 100644 --- a/libobs/obs-encoder.c +++ b/libobs/obs-encoder.c @@ -276,6 +276,8 @@ static void obs_encoder_actually_destroy(obs_encoder_t *encoder) obs_context_data_free(&encoder->context); if (encoder->owns_info_id) bfree((void *)encoder->info.id); + if (encoder->last_error_message) + bfree(encoder->last_error_message); bfree(encoder); } } @@ -521,6 +523,7 @@ void obs_encoder_shutdown(obs_encoder_t *encoder) encoder->offset_usec = 0; encoder->start_ts = 0; } + obs_encoder_set_last_error(encoder, NULL); pthread_mutex_unlock(&encoder->init_mutex); } @@ -1484,3 +1487,25 @@ bool obs_encoder_paused(const obs_encoder_t *encoder) ? os_atomic_load_bool(&encoder->paused) : false; } + +const char *obs_encoder_get_last_error(obs_encoder_t *encoder) +{ + if (!obs_encoder_valid(encoder, "obs_encoder_get_last_error")) + return NULL; + + return encoder->last_error_message; +} + +void obs_encoder_set_last_error(obs_encoder_t *encoder, const char *message) +{ + if (!obs_encoder_valid(encoder, "obs_encoder_set_last_error")) + return; + + if (encoder->last_error_message) + bfree(encoder->last_error_message); + + if (message) + encoder->last_error_message = bstrdup(message); + else + encoder->last_error_message = NULL; +} diff --git a/libobs/obs-internal.h b/libobs/obs-internal.h index b67446c..94013d6 100644 --- a/libobs/obs-internal.h +++ b/libobs/obs-internal.h @@ -1076,6 +1076,7 @@ struct obs_encoder { struct pause_data pause; const char *profile_encoder_encode_name; + char *last_error_message; }; extern struct obs_encoder_info *find_encoder(const char *id); diff --git a/libobs/obs-output.c b/libobs/obs-output.c index a680970..7fd31d7 100644 --- a/libobs/obs-output.c +++ b/libobs/obs-output.c @@ -1979,6 +1979,9 @@ static inline bool initialize_audio_encoders(obs_output_t *output, { for (size_t i = 0; i < num_mixes; i++) { if (!obs_encoder_initialize(output->audio_encoders[i])) { + obs_output_set_last_error( + output, obs_encoder_get_last_error( + output->audio_encoders[i])); return false; } } @@ -2038,8 +2041,12 @@ bool obs_output_initialize_encoders(obs_output_t *output, uint32_t flags) if (!encoded) return false; - if (has_video && !obs_encoder_initialize(output->video_encoder)) + if (has_video && !obs_encoder_initialize(output->video_encoder)) { + obs_output_set_last_error( + output, + obs_encoder_get_last_error(output->video_encoder)); return false; + } if (has_audio && !initialize_audio_encoders(output, num_mixes)) return false; diff --git a/libobs/obs.c b/libobs/obs.c index fd9218a..717260f 100644 --- a/libobs/obs.c +++ b/libobs/obs.c @@ -2108,7 +2108,8 @@ obs_data_array_t *obs_save_sources_filtered(obs_save_source_filter_cb cb, while (source) { if ((source->info.type != OBS_SOURCE_TYPE_FILTER) != 0 && - !source->context.private && cb(data_, source)) { + !source->context.private && !source->removed && + cb(data_, source)) { obs_data_t *source_data = obs_save_source(source); obs_data_array_push_back(array, source_data); diff --git a/libobs/obs.h b/libobs/obs.h index 0d3851c..d091ebe 100644 --- a/libobs/obs.h +++ b/libobs/obs.h @@ -2102,6 +2102,10 @@ EXPORT void *obs_encoder_create_rerouted(obs_encoder_t *encoder, /** Returns whether encoder is paused */ EXPORT bool obs_encoder_paused(const obs_encoder_t *output); +EXPORT const char *obs_encoder_get_last_error(obs_encoder_t *encoder); +EXPORT void obs_encoder_set_last_error(obs_encoder_t *encoder, + const char *message); + /* ------------------------------------------------------------------------- */ /* Stream Services */ diff --git a/libobs/util/platform-nix.c b/libobs/util/platform-nix.c index d91ddd6..1dd8107 100644 --- a/libobs/util/platform-nix.c +++ b/libobs/util/platform-nix.c @@ -275,7 +275,20 @@ char *os_get_program_data_path_ptr(const char *name) char *os_get_executable_path_ptr(const char *name) { char exe[PATH_MAX]; +#if defined(__FreeBSD__) || defined(__DragonFly__) + int sysctlname[4] = {CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1}; + size_t pathlen = PATH_MAX; + ssize_t count; + if (sysctl(sysctlname, nitems(sysctlname), exe, &pathlen, NULL, 0) == + -1) { + blog(LOG_ERROR, "sysctl(KERN_PROC_PATHNAME) failed, errno %d", + errno); + return NULL; + } + count = pathlen; +#else ssize_t count = readlink("/proc/self/exe", exe, PATH_MAX); +#endif const char *path_out = NULL; struct dstr path; diff --git a/libobs/util/simde/check.h b/libobs/util/simde/check.h deleted file mode 100644 index 2ad107e..0000000 --- a/libobs/util/simde/check.h +++ /dev/null @@ -1,258 +0,0 @@ -/* Check (assertions) - * Portable Snippets - https://gitub.com/nemequ/portable-snippets - * Created by Evan Nemerson - * - * To the extent possible under law, the authors have waived all - * copyright and related or neighboring rights to this code. For - * details, see the Creative Commons Zero 1.0 Universal license at - * https://creativecommons.org/publicdomain/zero/1.0/ - */ - -#if !defined(SIMDE_CHECK_H) -#define SIMDE_CHECK_H - -#if !defined(SIMDE_NDEBUG) && !defined(SIMDE_DEBUG) -#define SIMDE_NDEBUG 1 -#endif - -#include - -#if !defined(_WIN32) -#define SIMDE_SIZE_MODIFIER "z" -#define SIMDE_CHAR_MODIFIER "hh" -#define SIMDE_SHORT_MODIFIER "h" -#else -#if defined(_M_X64) || defined(__amd64__) -#define SIMDE_SIZE_MODIFIER "I64" -#else -#define SIMDE_SIZE_MODIFIER "" -#endif -#define SIMDE_CHAR_MODIFIER "" -#define SIMDE_SHORT_MODIFIER "" -#endif - -#if defined(_MSC_VER) && (_MSC_VER >= 1500) -#define SIMDE__PUSH_DISABLE_MSVC_C4127 \ - __pragma(warning(push)) __pragma(warning(disable : 4127)) -#define SIMDE__POP_DISABLE_MSVC_C4127 __pragma(warning(pop)) -#else -#define SIMDE__PUSH_DISABLE_MSVC_C4127 -#define SIMDE__POP_DISABLE_MSVC_C4127 -#endif - -#if !defined(simde_errorf) -#include -#include -#define simde_errorf(format, ...) \ - (fprintf(stderr, format, __VA_ARGS__), abort()) -#endif - -#define simde_error(msg) simde_errorf("%s", msg) - -#if defined(SIMDE_NDEBUG) -#if defined(SIMDE_CHECK_FAIL_DEFINED) -#define simde_assert(expr) -#else -#if defined(HEDLEY_ASSUME) -#define simde_assert(expr) HEDLEY_ASSUME(expr) -#elif HEDLEY_GCC_VERSION_CHECK(4, 5, 0) -#define simde_assert(expr) ((void)(!!(expr) ? 1 : (__builtin_unreachable(), 1))) -#elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) -#define simde_assert(expr) __assume(expr) -#else -#define simde_assert(expr) -#endif -#endif -#define simde_assert_true(expr) simde_assert(expr) -#define simde_assert_false(expr) simde_assert(!(expr)) -#define simde_assert_type_full(prefix, suffix, T, fmt, a, op, b) \ - simde_assert(((a)op(b))) -#define simde_assert_double_equal(a, b, precision) -#define simde_assert_string_equal(a, b) -#define simde_assert_string_not_equal(a, b) -#define simde_assert_memory_equal(size, a, b) -#define simde_assert_memory_not_equal(size, a, b) -#else -#define simde_assert(expr) \ - do { \ - if (!HEDLEY_LIKELY(expr)) { \ - simde_error("assertion failed: " #expr "\n"); \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 - -#define simde_assert_true(expr) \ - do { \ - if (!HEDLEY_LIKELY(expr)) { \ - simde_error("assertion failed: " #expr \ - " is not true\n"); \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 - -#define simde_assert_false(expr) \ - do { \ - if (!HEDLEY_LIKELY(!(expr))) { \ - simde_error("assertion failed: " #expr \ - " is not false\n"); \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 - -#define simde_assert_type_full(prefix, suffix, T, fmt, a, op, b) \ - do { \ - T simde_tmp_a_ = (a); \ - T simde_tmp_b_ = (b); \ - if (!(simde_tmp_a_ op simde_tmp_b_)) { \ - simde_errorf("assertion failed: %s %s %s (" prefix \ - "%" fmt suffix " %s " prefix \ - "%" fmt suffix ")\n", \ - #a, #op, #b, simde_tmp_a_, #op, \ - simde_tmp_b_); \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 - -#define simde_assert_double_equal(a, b, precision) \ - do { \ - const double simde_tmp_a_ = (a); \ - const double simde_tmp_b_ = (b); \ - const double simde_tmp_diff_ = \ - ((simde_tmp_a_ - simde_tmp_b_) < 0) \ - ? -(simde_tmp_a_ - simde_tmp_b_) \ - : (simde_tmp_a_ - simde_tmp_b_); \ - if (HEDLEY_UNLIKELY(simde_tmp_diff_ > 1e-##precision)) { \ - simde_errorf( \ - "assertion failed: %s == %s (%0." #precision \ - "g == %0." #precision "g)\n", \ - #a, #b, simde_tmp_a_, simde_tmp_b_); \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 - -#include -#define simde_assert_string_equal(a, b) \ - do { \ - const char *simde_tmp_a_ = a; \ - const char *simde_tmp_b_ = b; \ - if (HEDLEY_UNLIKELY(strcmp(simde_tmp_a_, simde_tmp_b_) != \ - 0)) { \ - simde_errorf( \ - "assertion failed: string %s == %s (\"%s\" == \"%s\")\n", \ - #a, #b, simde_tmp_a_, simde_tmp_b_); \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 - -#define simde_assert_string_not_equal(a, b) \ - do { \ - const char *simde_tmp_a_ = a; \ - const char *simde_tmp_b_ = b; \ - if (HEDLEY_UNLIKELY(strcmp(simde_tmp_a_, simde_tmp_b_) == \ - 0)) { \ - simde_errorf( \ - "assertion failed: string %s != %s (\"%s\" == \"%s\")\n", \ - #a, #b, simde_tmp_a_, simde_tmp_b_); \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 - -#define simde_assert_memory_equal(size, a, b) \ - do { \ - const unsigned char *simde_tmp_a_ = \ - (const unsigned char *)(a); \ - const unsigned char *simde_tmp_b_ = \ - (const unsigned char *)(b); \ - const size_t simde_tmp_size_ = (size); \ - if (HEDLEY_UNLIKELY(memcmp(simde_tmp_a_, simde_tmp_b_, \ - simde_tmp_size_)) != 0) { \ - size_t simde_tmp_pos_; \ - for (simde_tmp_pos_ = 0; \ - simde_tmp_pos_ < simde_tmp_size_; \ - simde_tmp_pos_++) { \ - if (simde_tmp_a_[simde_tmp_pos_] != \ - simde_tmp_b_[simde_tmp_pos_]) { \ - simde_errorf( \ - "assertion failed: memory %s == %s, at offset %" SIMDE_SIZE_MODIFIER \ - "u\n", \ - #a, #b, simde_tmp_pos_); \ - break; \ - } \ - } \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 - -#define simde_assert_memory_not_equal(size, a, b) \ - do { \ - const unsigned char *simde_tmp_a_ = \ - (const unsigned char *)(a); \ - const unsigned char *simde_tmp_b_ = \ - (const unsigned char *)(b); \ - const size_t simde_tmp_size_ = (size); \ - if (HEDLEY_UNLIKELY(memcmp(simde_tmp_a_, simde_tmp_b_, \ - simde_tmp_size_)) == 0) { \ - simde_errorf( \ - "assertion failed: memory %s != %s (%" SIMDE_SIZE_MODIFIER \ - "u bytes)\n", \ - #a, #b, simde_tmp_size_); \ - } \ - SIMDE__PUSH_DISABLE_MSVC_C4127 \ - } while (0) SIMDE__POP_DISABLE_MSVC_C4127 -#endif - -#define simde_assert_type(T, fmt, a, op, b) \ - simde_assert_type_full("", "", T, fmt, a, op, b) - -#define simde_assert_char(a, op, b) \ - simde_assert_type_full("'\\x", "'", char, \ - "02" SIMDE_CHAR_MODIFIER "x", a, op, b) -#define simde_assert_uchar(a, op, b) \ - simde_assert_type_full("'\\x", "'", unsigned char, \ - "02" SIMDE_CHAR_MODIFIER "x", a, op, b) -#define simde_assert_short(a, op, b) \ - simde_assert_type(short, SIMDE_SHORT_MODIFIER "d", a, op, b) -#define simde_assert_ushort(a, op, b) \ - simde_assert_type(unsigned short, SIMDE_SHORT_MODIFIER "u", a, op, b) -#define simde_assert_int(a, op, b) simde_assert_type(int, "d", a, op, b) -#define simde_assert_uint(a, op, b) \ - simde_assert_type(unsigned int, "u", a, op, b) -#define simde_assert_long(a, op, b) simde_assert_type(long int, "ld", a, op, b) -#define simde_assert_ulong(a, op, b) \ - simde_assert_type(unsigned long int, "lu", a, op, b) -#define simde_assert_llong(a, op, b) \ - simde_assert_type(long long int, "lld", a, op, b) -#define simde_assert_ullong(a, op, b) \ - simde_assert_type(unsigned long long int, "llu", a, op, b) - -#define simde_assert_size(a, op, b) \ - simde_assert_type(size_t, SIMDE_SIZE_MODIFIER "u", a, op, b) - -#define simde_assert_float(a, op, b) simde_assert_type(float, "f", a, op, b) -#define simde_assert_double(a, op, b) simde_assert_type(double, "g", a, op, b) -#define simde_assert_ptr(a, op, b) \ - simde_assert_type(const void *, "p", a, op, b) - -#define simde_assert_int8(a, op, b) simde_assert_type(int8_t, PRIi8, a, op, b) -#define simde_assert_uint8(a, op, b) simde_assert_type(uint8_t, PRIu8, a, op, b) -#define simde_assert_int16(a, op, b) \ - simde_assert_type(int16_t, PRIi16, a, op, b) -#define simde_assert_uint16(a, op, b) \ - simde_assert_type(uint16_t, PRIu16, a, op, b) -#define simde_assert_int32(a, op, b) \ - simde_assert_type(int32_t, PRIi32, a, op, b) -#define simde_assert_uint32(a, op, b) \ - simde_assert_type(uint32_t, PRIu32, a, op, b) -#define simde_assert_int64(a, op, b) \ - simde_assert_type(int64_t, PRIi64, a, op, b) -#define simde_assert_uint64(a, op, b) \ - simde_assert_type(uint64_t, PRIu64, a, op, b) - -#define simde_assert_ptr_equal(a, b) simde_assert_ptr(a, ==, b) -#define simde_assert_ptr_not_equal(a, b) simde_assert_ptr(a, !=, b) -#define simde_assert_null(ptr) simde_assert_ptr(ptr, ==, NULL) -#define simde_assert_not_null(ptr) simde_assert_ptr(ptr, !=, NULL) -#define simde_assert_ptr_null(ptr) simde_assert_ptr(ptr, ==, NULL) -#define simde_assert_ptr_not_null(ptr) simde_assert_ptr(ptr, !=, NULL) - -#endif /* !defined(SIMDE_CHECK_H) */ diff --git a/libobs/util/simde/hedley.h b/libobs/util/simde/hedley.h deleted file mode 100644 index 3c9cc49..0000000 --- a/libobs/util/simde/hedley.h +++ /dev/null @@ -1,1616 +0,0 @@ -/* Hedley - https://nemequ.github.io/hedley - * Created by Evan Nemerson - * - * To the extent possible under law, the author(s) have dedicated all - * copyright and related and neighboring rights to this software to - * the public domain worldwide. This software is distributed without - * any warranty. - * - * For details, see . - * SPDX-License-Identifier: CC0-1.0 - */ - -#if !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < 10) -#if defined(HEDLEY_VERSION) -#undef HEDLEY_VERSION -#endif -#define HEDLEY_VERSION 10 - -#if defined(HEDLEY_STRINGIFY_EX) -#undef HEDLEY_STRINGIFY_EX -#endif -#define HEDLEY_STRINGIFY_EX(x) #x - -#if defined(HEDLEY_STRINGIFY) -#undef HEDLEY_STRINGIFY -#endif -#define HEDLEY_STRINGIFY(x) HEDLEY_STRINGIFY_EX(x) - -#if defined(HEDLEY_CONCAT_EX) -#undef HEDLEY_CONCAT_EX -#endif -#define HEDLEY_CONCAT_EX(a, b) a##b - -#if defined(HEDLEY_CONCAT) -#undef HEDLEY_CONCAT -#endif -#define HEDLEY_CONCAT(a, b) HEDLEY_CONCAT_EX(a, b) - -#if defined(HEDLEY_VERSION_ENCODE) -#undef HEDLEY_VERSION_ENCODE -#endif -#define HEDLEY_VERSION_ENCODE(major, minor, revision) \ - (((major)*1000000) + ((minor)*1000) + (revision)) - -#if defined(HEDLEY_VERSION_DECODE_MAJOR) -#undef HEDLEY_VERSION_DECODE_MAJOR -#endif -#define HEDLEY_VERSION_DECODE_MAJOR(version) ((version) / 1000000) - -#if defined(HEDLEY_VERSION_DECODE_MINOR) -#undef HEDLEY_VERSION_DECODE_MINOR -#endif -#define HEDLEY_VERSION_DECODE_MINOR(version) (((version) % 1000000) / 1000) - -#if defined(HEDLEY_VERSION_DECODE_REVISION) -#undef HEDLEY_VERSION_DECODE_REVISION -#endif -#define HEDLEY_VERSION_DECODE_REVISION(version) ((version) % 1000) - -#if defined(HEDLEY_GNUC_VERSION) -#undef HEDLEY_GNUC_VERSION -#endif -#if defined(__GNUC__) && defined(__GNUC_PATCHLEVEL__) -#define HEDLEY_GNUC_VERSION \ - HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__) -#elif defined(__GNUC__) -#define HEDLEY_GNUC_VERSION HEDLEY_VERSION_ENCODE(__GNUC__, __GNUC_MINOR__, 0) -#endif - -#if defined(HEDLEY_GNUC_VERSION_CHECK) -#undef HEDLEY_GNUC_VERSION_CHECK -#endif -#if defined(HEDLEY_GNUC_VERSION) -#define HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_GNUC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_MSVC_VERSION) -#undef HEDLEY_MSVC_VERSION -#endif -#if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140000000) -#define HEDLEY_MSVC_VERSION \ - HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 10000000, \ - (_MSC_FULL_VER % 10000000) / 100000, \ - (_MSC_FULL_VER % 100000) / 100) -#elif defined(_MSC_FULL_VER) -#define HEDLEY_MSVC_VERSION \ - HEDLEY_VERSION_ENCODE(_MSC_FULL_VER / 1000000, \ - (_MSC_FULL_VER % 1000000) / 10000, \ - (_MSC_FULL_VER % 10000) / 10) -#elif defined(_MSC_VER) -#define HEDLEY_MSVC_VERSION \ - HEDLEY_VERSION_ENCODE(_MSC_VER / 100, _MSC_VER % 100, 0) -#endif - -#if defined(HEDLEY_MSVC_VERSION_CHECK) -#undef HEDLEY_MSVC_VERSION_CHECK -#endif -#if !defined(_MSC_VER) -#define HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) (0) -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) -#define HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) \ - (_MSC_FULL_VER >= ((major * 10000000) + (minor * 100000) + (patch))) -#elif defined(_MSC_VER) && (_MSC_VER >= 1200) -#define HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) \ - (_MSC_FULL_VER >= ((major * 1000000) + (minor * 10000) + (patch))) -#else -#define HEDLEY_MSVC_VERSION_CHECK(major, minor, patch) \ - (_MSC_VER >= ((major * 100) + (minor))) -#endif - -#if defined(HEDLEY_INTEL_VERSION) -#undef HEDLEY_INTEL_VERSION -#endif -#if defined(__INTEL_COMPILER) && defined(__INTEL_COMPILER_UPDATE) -#define HEDLEY_INTEL_VERSION \ - HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, \ - __INTEL_COMPILER_UPDATE) -#elif defined(__INTEL_COMPILER) -#define HEDLEY_INTEL_VERSION \ - HEDLEY_VERSION_ENCODE(__INTEL_COMPILER / 100, __INTEL_COMPILER % 100, 0) -#endif - -#if defined(HEDLEY_INTEL_VERSION_CHECK) -#undef HEDLEY_INTEL_VERSION_CHECK -#endif -#if defined(HEDLEY_INTEL_VERSION) -#define HEDLEY_INTEL_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_INTEL_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_INTEL_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_PGI_VERSION) -#undef HEDLEY_PGI_VERSION -#endif -#if defined(__PGI) && defined(__PGIC__) && defined(__PGIC_MINOR__) && \ - defined(__PGIC_PATCHLEVEL__) -#define HEDLEY_PGI_VERSION \ - HEDLEY_VERSION_ENCODE(__PGIC__, __PGIC_MINOR__, __PGIC_PATCHLEVEL__) -#endif - -#if defined(HEDLEY_PGI_VERSION_CHECK) -#undef HEDLEY_PGI_VERSION_CHECK -#endif -#if defined(HEDLEY_PGI_VERSION) -#define HEDLEY_PGI_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_PGI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_PGI_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_SUNPRO_VERSION) -#undef HEDLEY_SUNPRO_VERSION -#endif -#if defined(__SUNPRO_C) && (__SUNPRO_C > 0x1000) -#define HEDLEY_SUNPRO_VERSION \ - HEDLEY_VERSION_ENCODE((((__SUNPRO_C >> 16) & 0xf) * 10) + \ - ((__SUNPRO_C >> 12) & 0xf), \ - (((__SUNPRO_C >> 8) & 0xf) * 10) + \ - ((__SUNPRO_C >> 4) & 0xf), \ - (__SUNPRO_C & 0xf) * 10) -#elif defined(__SUNPRO_C) -#define HEDLEY_SUNPRO_VERSION \ - HEDLEY_VERSION_ENCODE((__SUNPRO_C >> 8) & 0xf, \ - (__SUNPRO_C >> 4) & 0xf, (__SUNPRO_C)&0xf) -#elif defined(__SUNPRO_CC) && (__SUNPRO_CC > 0x1000) -#define HEDLEY_SUNPRO_VERSION \ - HEDLEY_VERSION_ENCODE((((__SUNPRO_CC >> 16) & 0xf) * 10) + \ - ((__SUNPRO_CC >> 12) & 0xf), \ - (((__SUNPRO_CC >> 8) & 0xf) * 10) + \ - ((__SUNPRO_CC >> 4) & 0xf), \ - (__SUNPRO_CC & 0xf) * 10) -#elif defined(__SUNPRO_CC) -#define HEDLEY_SUNPRO_VERSION \ - HEDLEY_VERSION_ENCODE((__SUNPRO_CC >> 8) & 0xf, \ - (__SUNPRO_CC >> 4) & 0xf, (__SUNPRO_CC)&0xf) -#endif - -#if defined(HEDLEY_SUNPRO_VERSION_CHECK) -#undef HEDLEY_SUNPRO_VERSION_CHECK -#endif -#if defined(HEDLEY_SUNPRO_VERSION) -#define HEDLEY_SUNPRO_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_SUNPRO_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_SUNPRO_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_EMSCRIPTEN_VERSION) -#undef HEDLEY_EMSCRIPTEN_VERSION -#endif -#if defined(__EMSCRIPTEN__) -#define HEDLEY_EMSCRIPTEN_VERSION \ - HEDLEY_VERSION_ENCODE(__EMSCRIPTEN_major__, __EMSCRIPTEN_minor__, \ - __EMSCRIPTEN_tiny__) -#endif - -#if defined(HEDLEY_EMSCRIPTEN_VERSION_CHECK) -#undef HEDLEY_EMSCRIPTEN_VERSION_CHECK -#endif -#if defined(HEDLEY_EMSCRIPTEN_VERSION) -#define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_EMSCRIPTEN_VERSION >= \ - HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_EMSCRIPTEN_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_ARM_VERSION) -#undef HEDLEY_ARM_VERSION -#endif -#if defined(__CC_ARM) && defined(__ARMCOMPILER_VERSION) -#define HEDLEY_ARM_VERSION \ - HEDLEY_VERSION_ENCODE(__ARMCOMPILER_VERSION / 1000000, \ - (__ARMCOMPILER_VERSION % 1000000) / 10000, \ - (__ARMCOMPILER_VERSION % 10000) / 100) -#elif defined(__CC_ARM) && defined(__ARMCC_VERSION) -#define HEDLEY_ARM_VERSION \ - HEDLEY_VERSION_ENCODE(__ARMCC_VERSION / 1000000, \ - (__ARMCC_VERSION % 1000000) / 10000, \ - (__ARMCC_VERSION % 10000) / 100) -#endif - -#if defined(HEDLEY_ARM_VERSION_CHECK) -#undef HEDLEY_ARM_VERSION_CHECK -#endif -#if defined(HEDLEY_ARM_VERSION) -#define HEDLEY_ARM_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_ARM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_ARM_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_IBM_VERSION) -#undef HEDLEY_IBM_VERSION -#endif -#if defined(__ibmxl__) -#define HEDLEY_IBM_VERSION \ - HEDLEY_VERSION_ENCODE(__ibmxl_version__, __ibmxl_release__, \ - __ibmxl_modification__) -#elif defined(__xlC__) && defined(__xlC_ver__) -#define HEDLEY_IBM_VERSION \ - HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, \ - (__xlC_ver__ >> 8) & 0xff) -#elif defined(__xlC__) -#define HEDLEY_IBM_VERSION \ - HEDLEY_VERSION_ENCODE(__xlC__ >> 8, __xlC__ & 0xff, 0) -#endif - -#if defined(HEDLEY_IBM_VERSION_CHECK) -#undef HEDLEY_IBM_VERSION_CHECK -#endif -#if defined(HEDLEY_IBM_VERSION) -#define HEDLEY_IBM_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_IBM_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_IBM_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_TI_VERSION) -#undef HEDLEY_TI_VERSION -#endif -#if defined(__TI_COMPILER_VERSION__) -#define HEDLEY_TI_VERSION \ - HEDLEY_VERSION_ENCODE(__TI_COMPILER_VERSION__ / 1000000, \ - (__TI_COMPILER_VERSION__ % 1000000) / 1000, \ - (__TI_COMPILER_VERSION__ % 1000)) -#endif - -#if defined(HEDLEY_TI_VERSION_CHECK) -#undef HEDLEY_TI_VERSION_CHECK -#endif -#if defined(HEDLEY_TI_VERSION) -#define HEDLEY_TI_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_TI_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_TI_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_CRAY_VERSION) -#undef HEDLEY_CRAY_VERSION -#endif -#if defined(_CRAYC) -#if defined(_RELEASE_PATCHLEVEL) -#define HEDLEY_CRAY_VERSION \ - HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, \ - _RELEASE_PATCHLEVEL) -#else -#define HEDLEY_CRAY_VERSION \ - HEDLEY_VERSION_ENCODE(_RELEASE_MAJOR, _RELEASE_MINOR, 0) -#endif -#endif - -#if defined(HEDLEY_CRAY_VERSION_CHECK) -#undef HEDLEY_CRAY_VERSION_CHECK -#endif -#if defined(HEDLEY_CRAY_VERSION) -#define HEDLEY_CRAY_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_CRAY_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_CRAY_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_IAR_VERSION) -#undef HEDLEY_IAR_VERSION -#endif -#if defined(__IAR_SYSTEMS_ICC__) -#if __VER__ > 1000 -#define HEDLEY_IAR_VERSION \ - HEDLEY_VERSION_ENCODE((__VER__ / 1000000), ((__VER__ / 1000) % 1000), \ - (__VER__ % 1000)) -#else -#define HEDLEY_IAR_VERSION HEDLEY_VERSION_ENCODE(VER / 100, __VER__ % 100, 0) -#endif -#endif - -#if defined(HEDLEY_IAR_VERSION_CHECK) -#undef HEDLEY_IAR_VERSION_CHECK -#endif -#if defined(HEDLEY_IAR_VERSION) -#define HEDLEY_IAR_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_IAR_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_IAR_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_TINYC_VERSION) -#undef HEDLEY_TINYC_VERSION -#endif -#if defined(__TINYC__) -#define HEDLEY_TINYC_VERSION \ - HEDLEY_VERSION_ENCODE(__TINYC__ / 1000, (__TINYC__ / 100) % 10, \ - __TINYC__ % 100) -#endif - -#if defined(HEDLEY_TINYC_VERSION_CHECK) -#undef HEDLEY_TINYC_VERSION_CHECK -#endif -#if defined(HEDLEY_TINYC_VERSION) -#define HEDLEY_TINYC_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_TINYC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_TINYC_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_DMC_VERSION) -#undef HEDLEY_DMC_VERSION -#endif -#if defined(__DMC__) -#define HEDLEY_DMC_VERSION \ - HEDLEY_VERSION_ENCODE(__DMC__ >> 8, (__DMC__ >> 4) & 0xf, __DMC__ & 0xf) -#endif - -#if defined(HEDLEY_DMC_VERSION_CHECK) -#undef HEDLEY_DMC_VERSION_CHECK -#endif -#if defined(HEDLEY_DMC_VERSION) -#define HEDLEY_DMC_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_DMC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_DMC_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_COMPCERT_VERSION) -#undef HEDLEY_COMPCERT_VERSION -#endif -#if defined(__COMPCERT_VERSION__) -#define HEDLEY_COMPCERT_VERSION \ - HEDLEY_VERSION_ENCODE(__COMPCERT_VERSION__ / 10000, \ - (__COMPCERT_VERSION__ / 100) % 100, \ - __COMPCERT_VERSION__ % 100) -#endif - -#if defined(HEDLEY_COMPCERT_VERSION_CHECK) -#undef HEDLEY_COMPCERT_VERSION_CHECK -#endif -#if defined(HEDLEY_COMPCERT_VERSION) -#define HEDLEY_COMPCERT_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_COMPCERT_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_COMPCERT_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_PELLES_VERSION) -#undef HEDLEY_PELLES_VERSION -#endif -#if defined(__POCC__) -#define HEDLEY_PELLES_VERSION \ - HEDLEY_VERSION_ENCODE(__POCC__ / 100, __POCC__ % 100, 0) -#endif - -#if defined(HEDLEY_PELLES_VERSION_CHECK) -#undef HEDLEY_PELLES_VERSION_CHECK -#endif -#if defined(HEDLEY_PELLES_VERSION) -#define HEDLEY_PELLES_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_PELLES_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_PELLES_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_GCC_VERSION) -#undef HEDLEY_GCC_VERSION -#endif -#if defined(HEDLEY_GNUC_VERSION) && !defined(__clang__) && \ - !defined(HEDLEY_INTEL_VERSION) && !defined(HEDLEY_PGI_VERSION) && \ - !defined(HEDLEY_ARM_VERSION) && !defined(HEDLEY_TI_VERSION) && \ - !defined(__COMPCERT__) -#define HEDLEY_GCC_VERSION HEDLEY_GNUC_VERSION -#endif - -#if defined(HEDLEY_GCC_VERSION_CHECK) -#undef HEDLEY_GCC_VERSION_CHECK -#endif -#if defined(HEDLEY_GCC_VERSION) -#define HEDLEY_GCC_VERSION_CHECK(major, minor, patch) \ - (HEDLEY_GCC_VERSION >= HEDLEY_VERSION_ENCODE(major, minor, patch)) -#else -#define HEDLEY_GCC_VERSION_CHECK(major, minor, patch) (0) -#endif - -#if defined(HEDLEY_HAS_ATTRIBUTE) -#undef HEDLEY_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) -#define HEDLEY_HAS_ATTRIBUTE(attribute) __has_attribute(attribute) -#else -#define HEDLEY_HAS_ATTRIBUTE(attribute) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_ATTRIBUTE) -#undef HEDLEY_GNUC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) -#define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \ - __has_attribute(attribute) -#else -#define HEDLEY_GNUC_HAS_ATTRIBUTE(attribute, major, minor, patch) \ - HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_GCC_HAS_ATTRIBUTE) -#undef HEDLEY_GCC_HAS_ATTRIBUTE -#endif -#if defined(__has_attribute) -#define HEDLEY_GCC_HAS_ATTRIBUTE(attribute, major, minor, patch) \ - __has_attribute(attribute) -#else -#define HEDLEY_GCC_HAS_ATTRIBUTE(attribute, major, minor, patch) \ - HEDLEY_GCC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_HAS_CPP_ATTRIBUTE) -#undef HEDLEY_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) -#define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) __has_cpp_attribute(attribute) -#else -#define HEDLEY_HAS_CPP_ATTRIBUTE(attribute) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_CPP_ATTRIBUTE) -#undef HEDLEY_GNUC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) -#define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \ - __has_cpp_attribute(attribute) -#else -#define HEDLEY_GNUC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \ - HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_GCC_HAS_CPP_ATTRIBUTE) -#undef HEDLEY_GCC_HAS_CPP_ATTRIBUTE -#endif -#if defined(__has_cpp_attribute) && defined(__cplusplus) -#define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \ - __has_cpp_attribute(attribute) -#else -#define HEDLEY_GCC_HAS_CPP_ATTRIBUTE(attribute, major, minor, patch) \ - HEDLEY_GCC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_HAS_BUILTIN) -#undef HEDLEY_HAS_BUILTIN -#endif -#if defined(__has_builtin) -#define HEDLEY_HAS_BUILTIN(builtin) __has_builtin(builtin) -#else -#define HEDLEY_HAS_BUILTIN(builtin) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_BUILTIN) -#undef HEDLEY_GNUC_HAS_BUILTIN -#endif -#if defined(__has_builtin) -#define HEDLEY_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \ - __has_builtin(builtin) -#else -#define HEDLEY_GNUC_HAS_BUILTIN(builtin, major, minor, patch) \ - HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_GCC_HAS_BUILTIN) -#undef HEDLEY_GCC_HAS_BUILTIN -#endif -#if defined(__has_builtin) -#define HEDLEY_GCC_HAS_BUILTIN(builtin, major, minor, patch) \ - __has_builtin(builtin) -#else -#define HEDLEY_GCC_HAS_BUILTIN(builtin, major, minor, patch) \ - HEDLEY_GCC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_HAS_FEATURE) -#undef HEDLEY_HAS_FEATURE -#endif -#if defined(__has_feature) -#define HEDLEY_HAS_FEATURE(feature) __has_feature(feature) -#else -#define HEDLEY_HAS_FEATURE(feature) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_FEATURE) -#undef HEDLEY_GNUC_HAS_FEATURE -#endif -#if defined(__has_feature) -#define HEDLEY_GNUC_HAS_FEATURE(feature, major, minor, patch) \ - __has_feature(feature) -#else -#define HEDLEY_GNUC_HAS_FEATURE(feature, major, minor, patch) \ - HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_GCC_HAS_FEATURE) -#undef HEDLEY_GCC_HAS_FEATURE -#endif -#if defined(__has_feature) -#define HEDLEY_GCC_HAS_FEATURE(feature, major, minor, patch) \ - __has_feature(feature) -#else -#define HEDLEY_GCC_HAS_FEATURE(feature, major, minor, patch) \ - HEDLEY_GCC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_HAS_EXTENSION) -#undef HEDLEY_HAS_EXTENSION -#endif -#if defined(__has_extension) -#define HEDLEY_HAS_EXTENSION(extension) __has_extension(extension) -#else -#define HEDLEY_HAS_EXTENSION(extension) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_EXTENSION) -#undef HEDLEY_GNUC_HAS_EXTENSION -#endif -#if defined(__has_extension) -#define HEDLEY_GNUC_HAS_EXTENSION(extension, major, minor, patch) \ - __has_extension(extension) -#else -#define HEDLEY_GNUC_HAS_EXTENSION(extension, major, minor, patch) \ - HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_GCC_HAS_EXTENSION) -#undef HEDLEY_GCC_HAS_EXTENSION -#endif -#if defined(__has_extension) -#define HEDLEY_GCC_HAS_EXTENSION(extension, major, minor, patch) \ - __has_extension(extension) -#else -#define HEDLEY_GCC_HAS_EXTENSION(extension, major, minor, patch) \ - HEDLEY_GCC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_HAS_DECLSPEC_ATTRIBUTE) -#undef HEDLEY_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) -#define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) \ - __has_declspec_attribute(attribute) -#else -#define HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE) -#undef HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) -#define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \ - __has_declspec_attribute(attribute) -#else -#define HEDLEY_GNUC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \ - HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE) -#undef HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE -#endif -#if defined(__has_declspec_attribute) -#define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \ - __has_declspec_attribute(attribute) -#else -#define HEDLEY_GCC_HAS_DECLSPEC_ATTRIBUTE(attribute, major, minor, patch) \ - HEDLEY_GCC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_HAS_WARNING) -#undef HEDLEY_HAS_WARNING -#endif -#if defined(__has_warning) -#define HEDLEY_HAS_WARNING(warning) __has_warning(warning) -#else -#define HEDLEY_HAS_WARNING(warning) (0) -#endif - -#if defined(HEDLEY_GNUC_HAS_WARNING) -#undef HEDLEY_GNUC_HAS_WARNING -#endif -#if defined(__has_warning) -#define HEDLEY_GNUC_HAS_WARNING(warning, major, minor, patch) \ - __has_warning(warning) -#else -#define HEDLEY_GNUC_HAS_WARNING(warning, major, minor, patch) \ - HEDLEY_GNUC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_GCC_HAS_WARNING) -#undef HEDLEY_GCC_HAS_WARNING -#endif -#if defined(__has_warning) -#define HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch) \ - __has_warning(warning) -#else -#define HEDLEY_GCC_HAS_WARNING(warning, major, minor, patch) \ - HEDLEY_GCC_VERSION_CHECK(major, minor, patch) -#endif - -#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - defined(__clang__) || HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || \ - HEDLEY_PGI_VERSION_CHECK(18, 4, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(6, 0, 0) || \ - HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) || \ - HEDLEY_TINYC_VERSION_CHECK(0, 9, 17) || \ - HEDLEY_SUNPRO_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_IBM_VERSION_CHECK(10, 1, 0) && defined(__C99_PRAGMA_OPERATOR)) -#define HEDLEY_PRAGMA(value) _Pragma(#value) -#elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) -#define HEDLEY_PRAGMA(value) __pragma(value) -#else -#define HEDLEY_PRAGMA(value) -#endif - -#if defined(HEDLEY_DIAGNOSTIC_PUSH) -#undef HEDLEY_DIAGNOSTIC_PUSH -#endif -#if defined(HEDLEY_DIAGNOSTIC_POP) -#undef HEDLEY_DIAGNOSTIC_POP -#endif -#if defined(__clang__) -#define HEDLEY_DIAGNOSTIC_PUSH _Pragma("clang diagnostic push") -#define HEDLEY_DIAGNOSTIC_POP _Pragma("clang diagnostic pop") -#elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") -#define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#elif HEDLEY_GCC_VERSION_CHECK(4, 6, 0) -#define HEDLEY_DIAGNOSTIC_PUSH _Pragma("GCC diagnostic push") -#define HEDLEY_DIAGNOSTIC_POP _Pragma("GCC diagnostic pop") -#elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) -#define HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(push)) -#define HEDLEY_DIAGNOSTIC_POP __pragma(warning(pop)) -#elif HEDLEY_ARM_VERSION_CHECK(5, 6, 0) -#define HEDLEY_DIAGNOSTIC_PUSH _Pragma("push") -#define HEDLEY_DIAGNOSTIC_POP _Pragma("pop") -#elif HEDLEY_TI_VERSION_CHECK(8, 1, 0) -#define HEDLEY_DIAGNOSTIC_PUSH _Pragma("diag_push") -#define HEDLEY_DIAGNOSTIC_POP _Pragma("diag_pop") -#elif HEDLEY_PELLES_VERSION_CHECK(2, 90, 0) -#define HEDLEY_DIAGNOSTIC_PUSH _Pragma("warning(push)") -#define HEDLEY_DIAGNOSTIC_POP _Pragma("warning(pop)") -#else -#define HEDLEY_DIAGNOSTIC_PUSH -#define HEDLEY_DIAGNOSTIC_POP -#endif - -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED) -#undef HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif -#if HEDLEY_HAS_WARNING("-Wdeprecated-declarations") -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \ - _Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \ - _Pragma("warning(disable:1478 1786)") -#elif HEDLEY_PGI_VERSION_CHECK(17, 10, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1215,1444") -#elif HEDLEY_GCC_VERSION_CHECK(4, 3, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \ - _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") -#elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED __pragma(warning(disable : 4996)) -#elif HEDLEY_TI_VERSION_CHECK(8, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("diag_suppress 1291,1718") -#elif HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && !defined(__cplusplus) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \ - _Pragma("error_messages(off,E_DEPRECATED_ATT,E_DEPRECATED_ATT_MESS)") -#elif HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) && defined(__cplusplus) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \ - _Pragma("error_messages(off,symdeprecated,symdeprecated2)") -#elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED \ - _Pragma("diag_suppress=Pe1444,Pe1215") -#elif HEDLEY_PELLES_VERSION_CHECK(2, 90, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED _Pragma("warn(disable:2241)") -#else -#define HEDLEY_DIAGNOSTIC_DISABLE_DEPRECATED -#endif - -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS) -#undef HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -#define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - _Pragma("clang diagnostic ignored \"-Wunknown-pragmas\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - _Pragma("warning(disable:161)") -#elif HEDLEY_PGI_VERSION_CHECK(17, 10, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 1675") -#elif HEDLEY_GCC_VERSION_CHECK(4, 3, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - _Pragma("GCC diagnostic ignored \"-Wunknown-pragmas\"") -#elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - __pragma(warning(disable : 4068)) -#elif HEDLEY_TI_VERSION_CHECK(8, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress 163") -#elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS _Pragma("diag_suppress=Pe161") -#else -#define HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS -#endif - -#if defined(HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL) -#undef HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif -#if HEDLEY_HAS_WARNING("-Wcast-qual") -#define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - _Pragma("clang diagnostic ignored \"-Wcast-qual\"") -#elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - _Pragma("warning(disable:2203 2331)") -#elif HEDLEY_GCC_VERSION_CHECK(3, 0, 0) -#define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL \ - _Pragma("GCC diagnostic ignored \"-Wcast-qual\"") -#else -#define HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL -#endif - -#if defined(HEDLEY_DEPRECATED) -#undef HEDLEY_DEPRECATED -#endif -#if defined(HEDLEY_DEPRECATED_FOR) -#undef HEDLEY_DEPRECATED_FOR -#endif -#if defined(__cplusplus) && (__cplusplus >= 201402L) -#define HEDLEY_DEPRECATED(since) [[deprecated("Since " #since)]] -#define HEDLEY_DEPRECATED_FOR(since, replacement) \ - [[deprecated("Since " #since "; use " #replacement)]] -#elif HEDLEY_HAS_EXTENSION(attribute_deprecated_with_message) || \ - HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 13, 0) || \ - HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 3, 0) -#define HEDLEY_DEPRECATED(since) \ - __attribute__((__deprecated__("Since " #since))) -#define HEDLEY_DEPRECATED_FOR(since, replacement) \ - __attribute__((__deprecated__("Since " #since "; use " #replacement))) -#elif HEDLEY_HAS_ATTRIBUTE(deprecated) || HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -#define HEDLEY_DEPRECATED(since) __attribute__((__deprecated__)) -#define HEDLEY_DEPRECATED_FOR(since, replacement) \ - __attribute__((__deprecated__)) -#elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) -#define HEDLEY_DEPRECATED(since) __declspec(deprecated("Since " #since)) -#define HEDLEY_DEPRECATED_FOR(since, replacement) \ - __declspec(deprecated("Since " #since "; use " #replacement)) -#elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || \ - HEDLEY_PELLES_VERSION_CHECK(6, 50, 0) -#define HEDLEY_DEPRECATED(since) __declspec(deprecated) -#define HEDLEY_DEPRECATED_FOR(since, replacement) __declspec(deprecated) -#elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0) -#define HEDLEY_DEPRECATED(since) _Pragma("deprecated") -#define HEDLEY_DEPRECATED_FOR(since, replacement) _Pragma("deprecated") -#else -#define HEDLEY_DEPRECATED(since) -#define HEDLEY_DEPRECATED_FOR(since, replacement) -#endif - -#if defined(HEDLEY_UNAVAILABLE) -#undef HEDLEY_UNAVAILABLE -#endif -#if HEDLEY_HAS_ATTRIBUTE(warning) || HEDLEY_GCC_VERSION_CHECK(4, 3, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_UNAVAILABLE(available_since) \ - __attribute__((__warning__("Not available until " #available_since))) -#else -#define HEDLEY_UNAVAILABLE(available_since) -#endif - -#if defined(HEDLEY_WARN_UNUSED_RESULT) -#undef HEDLEY_WARN_UNUSED_RESULT -#endif -#if defined(__cplusplus) && (__cplusplus >= 201703L) -#define HEDLEY_WARN_UNUSED_RESULT [[nodiscard]] -#elif HEDLEY_HAS_ATTRIBUTE(warn_unused_result) || \ - HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \ - HEDLEY_PGI_VERSION_CHECK(17, 10, 0) -#define HEDLEY_WARN_UNUSED_RESULT __attribute__((__warn_unused_result__)) -#elif defined(_Check_return_) /* SAL */ -#define HEDLEY_WARN_UNUSED_RESULT _Check_return_ -#else -#define HEDLEY_WARN_UNUSED_RESULT -#endif - -#if defined(HEDLEY_SENTINEL) -#undef HEDLEY_SENTINEL -#endif -#if HEDLEY_HAS_ATTRIBUTE(sentinel) || HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_ARM_VERSION_CHECK(5, 4, 0) -#define HEDLEY_SENTINEL(position) __attribute__((__sentinel__(position))) -#else -#define HEDLEY_SENTINEL(position) -#endif - -#if defined(HEDLEY_NO_RETURN) -#undef HEDLEY_NO_RETURN -#endif -#if HEDLEY_IAR_VERSION_CHECK(8, 0, 0) -#define HEDLEY_NO_RETURN __noreturn -#elif HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -#define HEDLEY_NO_RETURN _Noreturn -#elif defined(__cplusplus) && (__cplusplus >= 201103L) -#define HEDLEY_NO_RETURN [[noreturn]] -#elif HEDLEY_HAS_ATTRIBUTE(noreturn) || HEDLEY_GCC_VERSION_CHECK(3, 2, 0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(18, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(17, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -#define HEDLEY_NO_RETURN __attribute__((__noreturn__)) -#elif HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) -#define HEDLEY_NO_RETURN _Pragma("does_not_return") -#elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) -#define HEDLEY_NO_RETURN __declspec(noreturn) -#elif HEDLEY_TI_VERSION_CHECK(6, 0, 0) && defined(__cplusplus) -#define HEDLEY_NO_RETURN _Pragma("FUNC_NEVER_RETURNS;") -#elif HEDLEY_COMPCERT_VERSION_CHECK(3, 2, 0) -#define HEDLEY_NO_RETURN __attribute((noreturn)) -#elif HEDLEY_PELLES_VERSION_CHECK(9, 0, 0) -#define HEDLEY_NO_RETURN __declspec(noreturn) -#else -#define HEDLEY_NO_RETURN -#endif - -#if defined(HEDLEY_UNREACHABLE) -#undef HEDLEY_UNREACHABLE -#endif -#if defined(HEDLEY_UNREACHABLE_RETURN) -#undef HEDLEY_UNREACHABLE_RETURN -#endif -#if (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && \ - (!defined(HEDLEY_ARM_VERSION))) || \ - HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_IBM_VERSION_CHECK(13, 1, 5) -#define HEDLEY_UNREACHABLE() __builtin_unreachable() -#elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) -#define HEDLEY_UNREACHABLE() __assume(0) -#elif HEDLEY_TI_VERSION_CHECK(6, 0, 0) -#if defined(__cplusplus) -#define HEDLEY_UNREACHABLE() std::_nassert(0) -#else -#define HEDLEY_UNREACHABLE() _nassert(0) -#endif -#define HEDLEY_UNREACHABLE_RETURN(value) return value -#elif defined(EXIT_FAILURE) -#define HEDLEY_UNREACHABLE() abort() -#else -#define HEDLEY_UNREACHABLE() -#define HEDLEY_UNREACHABLE_RETURN(value) return value -#endif -#if !defined(HEDLEY_UNREACHABLE_RETURN) -#define HEDLEY_UNREACHABLE_RETURN(value) HEDLEY_UNREACHABLE() -#endif - -#if defined(HEDLEY_ASSUME) -#undef HEDLEY_ASSUME -#endif -#if HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) || HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_ASSUME(expr) __assume(expr) -#elif HEDLEY_HAS_BUILTIN(__builtin_assume) -#define HEDLEY_ASSUME(expr) __builtin_assume(expr) -#elif HEDLEY_TI_VERSION_CHECK(6, 0, 0) -#if defined(__cplusplus) -#define HEDLEY_ASSUME(expr) std::_nassert(expr) -#else -#define HEDLEY_ASSUME(expr) _nassert(expr) -#endif -#elif (HEDLEY_HAS_BUILTIN(__builtin_unreachable) && \ - !defined(HEDLEY_ARM_VERSION)) || \ - HEDLEY_GCC_VERSION_CHECK(4, 5, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_IBM_VERSION_CHECK(13, 1, 5) -#define HEDLEY_ASSUME(expr) ((void)((expr) ? 1 : (__builtin_unreachable(), 1))) -#else -#define HEDLEY_ASSUME(expr) ((void)(expr)) -#endif - -HEDLEY_DIAGNOSTIC_PUSH -#if HEDLEY_HAS_WARNING("-Wvariadic-macros") || HEDLEY_GCC_VERSION_CHECK(4, 0, 0) -#if defined(__clang__) -#pragma clang diagnostic ignored "-Wvariadic-macros" -#elif defined(HEDLEY_GCC_VERSION) -#pragma GCC diagnostic ignored "-Wvariadic-macros" -#endif -#endif -#if defined(HEDLEY_NON_NULL) -#undef HEDLEY_NON_NULL -#endif -#if HEDLEY_HAS_ATTRIBUTE(nonnull) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) -#define HEDLEY_NON_NULL(...) __attribute__((__nonnull__(__VA_ARGS__))) -#else -#define HEDLEY_NON_NULL(...) -#endif -HEDLEY_DIAGNOSTIC_POP - -#if defined(HEDLEY_PRINTF_FORMAT) -#undef HEDLEY_PRINTF_FORMAT -#endif -#if defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format, 4, 4, 0) && \ - !defined(__USE_MINGW_ANSI_STDIO) -#define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \ - __attribute__((__format__(ms_printf, string_idx, first_to_check))) -#elif defined(__MINGW32__) && HEDLEY_GCC_HAS_ATTRIBUTE(format, 4, 4, 0) && \ - defined(__USE_MINGW_ANSI_STDIO) -#define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \ - __attribute__((__format__(gnu_printf, string_idx, first_to_check))) -#elif HEDLEY_HAS_ATTRIBUTE(format) || HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_ARM_VERSION_CHECK(5, 6, 0) || \ - HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -#define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \ - __attribute__((__format__(__printf__, string_idx, first_to_check))) -#elif HEDLEY_PELLES_VERSION_CHECK(6, 0, 0) -#define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) \ - __declspec(vaformat(printf, string_idx, first_to_check)) -#else -#define HEDLEY_PRINTF_FORMAT(string_idx, first_to_check) -#endif - -#if defined(HEDLEY_CONSTEXPR) -#undef HEDLEY_CONSTEXPR -#endif -#if defined(__cplusplus) -#if __cplusplus >= 201103L -#define HEDLEY_CONSTEXPR constexpr -#endif -#endif -#if !defined(HEDLEY_CONSTEXPR) -#define HEDLEY_CONSTEXPR -#endif - -#if defined(HEDLEY_PREDICT) -#undef HEDLEY_PREDICT -#endif -#if defined(HEDLEY_LIKELY) -#undef HEDLEY_LIKELY -#endif -#if defined(HEDLEY_UNLIKELY) -#undef HEDLEY_UNLIKELY -#endif -#if defined(HEDLEY_UNPREDICTABLE) -#undef HEDLEY_UNPREDICTABLE -#endif -#if HEDLEY_HAS_BUILTIN(__builtin_unpredictable) -#define HEDLEY_UNPREDICTABLE(expr) __builtin_unpredictable(!!(expr)) -#endif -#if HEDLEY_HAS_BUILTIN(__builtin_expect_with_probability) || \ - HEDLEY_GCC_VERSION_CHECK(9, 0, 0) -#define HEDLEY_PREDICT(expr, value, probability) \ - __builtin_expect_with_probability(expr, value, probability) -#define HEDLEY_PREDICT_TRUE(expr, probability) \ - __builtin_expect_with_probability(!!(expr), 1, probability) -#define HEDLEY_PREDICT_FALSE(expr, probability) \ - __builtin_expect_with_probability(!!(expr), 0, probability) -#define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -#define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#if !defined(HEDLEY_BUILTIN_UNPREDICTABLE) -#define HEDLEY_BUILTIN_UNPREDICTABLE(expr) \ - __builtin_expect_with_probability(!!(expr), 1, 0.5) -#endif -#elif HEDLEY_HAS_BUILTIN(__builtin_expect) || \ - HEDLEY_GCC_VERSION_CHECK(3, 0, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0) && defined(__cplusplus)) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(6, 1, 0) || \ - HEDLEY_TINYC_VERSION_CHECK(0, 9, 27) -#define HEDLEY_PREDICT(expr, expected, probability) \ - (((probability) >= 0.9) ? __builtin_expect(!!(expr), (expected)) \ - : (((void)(expected)), !!(expr))) -#define HEDLEY_PREDICT_TRUE(expr, probability) \ - (__extension__({ \ - HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) \ - ? __builtin_expect(!!(expr), 1) \ - : ((hedley_probability_ <= 0.1) \ - ? __builtin_expect(!!(expr), 0) \ - : !!(expr))); \ - })) -#define HEDLEY_PREDICT_FALSE(expr, probability) \ - (__extension__({ \ - HEDLEY_CONSTEXPR double hedley_probability_ = (probability); \ - ((hedley_probability_ >= 0.9) \ - ? __builtin_expect(!!(expr), 0) \ - : ((hedley_probability_ <= 0.1) \ - ? __builtin_expect(!!(expr), 1) \ - : !!(expr))); \ - })) -#define HEDLEY_LIKELY(expr) __builtin_expect(!!(expr), 1) -#define HEDLEY_UNLIKELY(expr) __builtin_expect(!!(expr), 0) -#else -#define HEDLEY_PREDICT(expr, expected, probability) \ - (((void)(expected)), !!(expr)) -#define HEDLEY_PREDICT_TRUE(expr, probability) (!!(expr)) -#define HEDLEY_PREDICT_FALSE(expr, probability) (!!(expr)) -#define HEDLEY_LIKELY(expr) (!!(expr)) -#define HEDLEY_UNLIKELY(expr) (!!(expr)) -#endif -#if !defined(HEDLEY_UNPREDICTABLE) -#define HEDLEY_UNPREDICTABLE(expr) HEDLEY_PREDICT(expr, 1, 0.5) -#endif - -#if defined(HEDLEY_MALLOC) -#undef HEDLEY_MALLOC -#endif -#if HEDLEY_HAS_ATTRIBUTE(malloc) || HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -#define HEDLEY_MALLOC __attribute__((__malloc__)) -#elif HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) -#define HEDLEY_MALLOC _Pragma("returns_new_memory") -#elif HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) -#define HEDLEY_MALLOC __declspec(restrict) -#else -#define HEDLEY_MALLOC -#endif - -#if defined(HEDLEY_PURE) -#undef HEDLEY_PURE -#endif -#if HEDLEY_HAS_ATTRIBUTE(pure) || HEDLEY_GCC_VERSION_CHECK(2, 96, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - HEDLEY_PGI_VERSION_CHECK(17, 10, 0) -#define HEDLEY_PURE __attribute__((__pure__)) -#elif HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) -#define HEDLEY_PURE _Pragma("does_not_write_global_data") -#elif HEDLEY_TI_VERSION_CHECK(6, 0, 0) && defined(__cplusplus) -#define HEDLEY_PURE _Pragma("FUNC_IS_PURE;") -#else -#define HEDLEY_PURE -#endif - -#if defined(HEDLEY_CONST) -#undef HEDLEY_CONST -#endif -#if HEDLEY_HAS_ATTRIBUTE(const) || HEDLEY_GCC_VERSION_CHECK(2, 5, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) || \ - HEDLEY_PGI_VERSION_CHECK(17, 10, 0) -#define HEDLEY_CONST __attribute__((__const__)) -#elif HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) -#define HEDLEY_CONST _Pragma("no_side_effect") -#else -#define HEDLEY_CONST HEDLEY_PURE -#endif - -#if defined(HEDLEY_RESTRICT) -#undef HEDLEY_RESTRICT -#endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__cplusplus) -#define HEDLEY_RESTRICT restrict -#elif HEDLEY_GCC_VERSION_CHECK(3, 1, 0) || \ - HEDLEY_MSVC_VERSION_CHECK(14, 0, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - HEDLEY_PGI_VERSION_CHECK(17, 10, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5, 14, 0) && defined(__cplusplus)) || \ - HEDLEY_IAR_VERSION_CHECK(8, 0, 0) || defined(__clang__) -#define HEDLEY_RESTRICT __restrict -#elif HEDLEY_SUNPRO_VERSION_CHECK(5, 3, 0) && !defined(__cplusplus) -#define HEDLEY_RESTRICT _Restrict -#else -#define HEDLEY_RESTRICT -#endif - -#if defined(HEDLEY_INLINE) -#undef HEDLEY_INLINE -#endif -#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)) || \ - (defined(__cplusplus) && (__cplusplus >= 199711L)) -#define HEDLEY_INLINE inline -#elif defined(HEDLEY_GCC_VERSION) || HEDLEY_ARM_VERSION_CHECK(6, 2, 0) -#define HEDLEY_INLINE __inline__ -#elif HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || HEDLEY_TI_VERSION_CHECK(8, 0, 0) -#define HEDLEY_INLINE __inline -#else -#define HEDLEY_INLINE -#endif - -#if defined(HEDLEY_ALWAYS_INLINE) -#undef HEDLEY_ALWAYS_INLINE -#endif -#if HEDLEY_HAS_ATTRIBUTE(always_inline) || \ - HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -#define HEDLEY_ALWAYS_INLINE __attribute__((__always_inline__)) HEDLEY_INLINE -#elif HEDLEY_MSVC_VERSION_CHECK(12, 0, 0) -#define HEDLEY_ALWAYS_INLINE __forceinline -#elif HEDLEY_TI_VERSION_CHECK(7, 0, 0) && defined(__cplusplus) -#define HEDLEY_ALWAYS_INLINE _Pragma("FUNC_ALWAYS_INLINE;") -#elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0) -#define HEDLEY_ALWAYS_INLINE _Pragma("inline=forced") -#else -#define HEDLEY_ALWAYS_INLINE HEDLEY_INLINE -#endif - -#if defined(HEDLEY_NEVER_INLINE) -#undef HEDLEY_NEVER_INLINE -#endif -#if HEDLEY_HAS_ATTRIBUTE(noinline) || HEDLEY_GCC_VERSION_CHECK(4, 0, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(10, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -#define HEDLEY_NEVER_INLINE __attribute__((__noinline__)) -#elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) -#define HEDLEY_NEVER_INLINE __declspec(noinline) -#elif HEDLEY_PGI_VERSION_CHECK(10, 2, 0) -#define HEDLEY_NEVER_INLINE _Pragma("noinline") -#elif HEDLEY_TI_VERSION_CHECK(6, 0, 0) && defined(__cplusplus) -#define HEDLEY_NEVER_INLINE _Pragma("FUNC_CANNOT_INLINE;") -#elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0) -#define HEDLEY_NEVER_INLINE _Pragma("inline=never") -#elif HEDLEY_COMPCERT_VERSION_CHECK(3, 2, 0) -#define HEDLEY_NEVER_INLINE __attribute((noinline)) -#elif HEDLEY_PELLES_VERSION_CHECK(9, 0, 0) -#define HEDLEY_NEVER_INLINE __declspec(noinline) -#else -#define HEDLEY_NEVER_INLINE -#endif - -#if defined(HEDLEY_PRIVATE) -#undef HEDLEY_PRIVATE -#endif -#if defined(HEDLEY_PUBLIC) -#undef HEDLEY_PUBLIC -#endif -#if defined(HEDLEY_IMPORT) -#undef HEDLEY_IMPORT -#endif -#if defined(_WIN32) || defined(__CYGWIN__) -#define HEDLEY_PRIVATE -#define HEDLEY_PUBLIC __declspec(dllexport) -#define HEDLEY_IMPORT __declspec(dllimport) -#else -#if HEDLEY_HAS_ATTRIBUTE(visibility) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 11, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(8, 0, 0) || \ - (HEDLEY_TI_VERSION_CHECK(7, 3, 0) && defined(__TI_EABI__) && \ - defined(__TI_GNU_ATTRIBUTE_SUPPORT__)) -#define HEDLEY_PRIVATE __attribute__((__visibility__("hidden"))) -#define HEDLEY_PUBLIC __attribute__((__visibility__("default"))) -#else -#define HEDLEY_PRIVATE -#define HEDLEY_PUBLIC -#endif -#define HEDLEY_IMPORT extern -#endif - -#if defined(HEDLEY_NO_THROW) -#undef HEDLEY_NO_THROW -#endif -#if HEDLEY_HAS_ATTRIBUTE(nothrow) || HEDLEY_GCC_VERSION_CHECK(3, 3, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_NO_THROW __attribute__((__nothrow__)) -#elif HEDLEY_MSVC_VERSION_CHECK(13, 1, 0) || HEDLEY_ARM_VERSION_CHECK(4, 1, 0) -#define HEDLEY_NO_THROW __declspec(nothrow) -#else -#define HEDLEY_NO_THROW -#endif - -#if defined(HEDLEY_FALL_THROUGH) -#undef HEDLEY_FALL_THROUGH -#endif -#if defined(__cplusplus) && \ - (!defined(HEDLEY_SUNPRO_VERSION) || \ - HEDLEY_SUNPRO_VERSION_CHECK(5, 15, 0)) && \ - !defined(HEDLEY_PGI_VERSION) -#if (__cplusplus >= 201703L) || \ - ((__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(fallthrough)) -#define HEDLEY_FALL_THROUGH [[fallthrough]] -#elif (__cplusplus >= 201103L) && HEDLEY_HAS_CPP_ATTRIBUTE(clang::fallthrough) -#define HEDLEY_FALL_THROUGH [[clang::fallthrough]] -#elif (__cplusplus >= 201103L) && HEDLEY_GCC_VERSION_CHECK(7, 0, 0) -#define HEDLEY_FALL_THROUGH [[gnu::fallthrough]] -#endif -#endif -#if !defined(HEDLEY_FALL_THROUGH) -#if HEDLEY_GNUC_HAS_ATTRIBUTE(fallthrough, 7, 0, 0) && \ - !defined(HEDLEY_PGI_VERSION) -#define HEDLEY_FALL_THROUGH __attribute__((__fallthrough__)) -#elif defined(__fallthrough) /* SAL */ -#define HEDLEY_FALL_THROUGH __fallthrough -#else -#define HEDLEY_FALL_THROUGH -#endif -#endif - -#if defined(HEDLEY_RETURNS_NON_NULL) -#undef HEDLEY_RETURNS_NON_NULL -#endif -#if HEDLEY_HAS_ATTRIBUTE(returns_nonnull) || HEDLEY_GCC_VERSION_CHECK(4, 9, 0) -#define HEDLEY_RETURNS_NON_NULL __attribute__((__returns_nonnull__)) -#elif defined(_Ret_notnull_) /* SAL */ -#define HEDLEY_RETURNS_NON_NULL _Ret_notnull_ -#else -#define HEDLEY_RETURNS_NON_NULL -#endif - -#if defined(HEDLEY_ARRAY_PARAM) -#undef HEDLEY_ARRAY_PARAM -#endif -#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ - !defined(__STDC_NO_VLA__) && !defined(__cplusplus) && \ - !defined(HEDLEY_PGI_VERSION) && !defined(HEDLEY_TINYC_VERSION) -#define HEDLEY_ARRAY_PARAM(name) (name) -#else -#define HEDLEY_ARRAY_PARAM(name) -#endif - -#if defined(HEDLEY_IS_CONSTANT) -#undef HEDLEY_IS_CONSTANT -#endif -#if defined(HEDLEY_REQUIRE_CONSTEXPR) -#undef HEDLEY_REQUIRE_CONSTEXPR -#endif -/* Note the double-underscore. For internal use only; no API - * guarantees! */ -#if defined(HEDLEY__IS_CONSTEXPR) -#undef HEDLEY__IS_CONSTEXPR -#endif - -#if HEDLEY_HAS_BUILTIN(__builtin_constant_p) || \ - HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_TINYC_VERSION_CHECK(0, 9, 19) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - HEDLEY_TI_VERSION_CHECK(6, 1, 0) || \ - (HEDLEY_SUNPRO_VERSION_CHECK(5, 10, 0) && !defined(__cplusplus)) || \ - HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) -#define HEDLEY_IS_CONSTANT(expr) __builtin_constant_p(expr) -#endif -#if !defined(__cplusplus) -#if HEDLEY_HAS_BUILTIN(__builtin_types_compatible_p) || \ - HEDLEY_GCC_VERSION_CHECK(3, 4, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_IBM_VERSION_CHECK(13, 1, 0) || \ - HEDLEY_CRAY_VERSION_CHECK(8, 1, 0) || \ - HEDLEY_ARM_VERSION_CHECK(5, 4, 0) || \ - HEDLEY_TINYC_VERSION_CHECK(0, 9, 24) -#if defined(__INTPTR_TYPE__) -#define HEDLEY__IS_CONSTEXPR(expr) \ - __builtin_types_compatible_p( \ - __typeof__((1 ? (void *)((__INTPTR_TYPE__)((expr)*0)) \ - : (int *)0)), \ - int *) -#else -#include -#define HEDLEY__IS_CONSTEXPR(expr) \ - __builtin_types_compatible_p( \ - __typeof__((1 ? (void *)((intptr_t)((expr)*0)) : (int *)0)), \ - int *) -#endif -#elif (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) && \ - !defined(HEDLEY_SUNPRO_VERSION) && !defined(HEDLEY_PGI_VERSION)) || \ - HEDLEY_HAS_EXTENSION(c_generic_selections) || \ - HEDLEY_GCC_VERSION_CHECK(4, 9, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(17, 0, 0) || \ - HEDLEY_IBM_VERSION_CHECK(12, 1, 0) || \ - HEDLEY_ARM_VERSION_CHECK(5, 3, 0) -#if defined(__INTPTR_TYPE__) -#define HEDLEY__IS_CONSTEXPR(expr) \ - _Generic((1 ? (void *)((__INTPTR_TYPE__)((expr)*0)) : (int *)0), \ - int * : 1, void * : 0) -#else -#include -#define HEDLEY__IS_CONSTEXPR(expr) \ - _Generic((1 ? (void *)((intptr_t)*0) : (int *)0), int * : 1, void * : 0) -#endif -#elif defined(HEDLEY_GCC_VERSION) || defined(HEDLEY_INTEL_VERSION) || \ - defined(HEDLEY_TINYC_VERSION) || defined(HEDLEY_TI_VERSION) || \ - defined(__clang__) -#define HEDLEY__IS_CONSTEXPR(expr) \ - (sizeof(void) != sizeof(*(1 ? ((void *)((expr)*0L)) : ((struct { \ - char v[sizeof(void) * 2]; \ - } *)1)))) -#endif -#endif -#if defined(HEDLEY__IS_CONSTEXPR) -#if !defined(HEDLEY_IS_CONSTANT) -#define HEDLEY_IS_CONSTANT(expr) HEDLEY__IS_CONSTEXPR(expr) -#endif -#define HEDLEY_REQUIRE_CONSTEXPR(expr) \ - (HEDLEY__IS_CONSTEXPR(expr) ? (expr) : (-1)) -#else -#if !defined(HEDLEY_IS_CONSTANT) -#define HEDLEY_IS_CONSTANT(expr) (0) -#endif -#define HEDLEY_REQUIRE_CONSTEXPR(expr) (expr) -#endif - -#if defined(HEDLEY_BEGIN_C_DECLS) -#undef HEDLEY_BEGIN_C_DECLS -#endif -#if defined(HEDLEY_END_C_DECLS) -#undef HEDLEY_END_C_DECLS -#endif -#if defined(HEDLEY_C_DECL) -#undef HEDLEY_C_DECL -#endif -#if defined(__cplusplus) -#define HEDLEY_BEGIN_C_DECLS extern "C" { -#define HEDLEY_END_C_DECLS } -#define HEDLEY_C_DECL extern "C" -#else -#define HEDLEY_BEGIN_C_DECLS -#define HEDLEY_END_C_DECLS -#define HEDLEY_C_DECL -#endif - -#if defined(HEDLEY_STATIC_ASSERT) -#undef HEDLEY_STATIC_ASSERT -#endif -#if !defined(__cplusplus) && \ - ((defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \ - HEDLEY_HAS_FEATURE(c_static_assert) || \ - HEDLEY_GCC_VERSION_CHECK(6, 0, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || defined(_Static_assert)) -#define HEDLEY_STATIC_ASSERT(expr, message) _Static_assert(expr, message) -#elif (defined(__cplusplus) && (__cplusplus >= 201103L)) || \ - HEDLEY_MSVC_VERSION_CHECK(16, 0, 0) || \ - (defined(__cplusplus) && HEDLEY_TI_VERSION_CHECK(8, 3, 0)) -#define HEDLEY_STATIC_ASSERT(expr, message) static_assert(expr, message) -#else -#define HEDLEY_STATIC_ASSERT(expr, message) -#endif - -#if defined(HEDLEY_CONST_CAST) -#undef HEDLEY_CONST_CAST -#endif -#if defined(__cplusplus) -#define HEDLEY_CONST_CAST(T, expr) (const_cast(expr)) -#elif HEDLEY_HAS_WARNING("-Wcast-qual") || \ - HEDLEY_GCC_VERSION_CHECK(4, 6, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_CONST_CAST(T, expr) \ - (__extension__({ \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_CAST_QUAL((T)(expr)); \ - HEDLEY_DIAGNOSTIC_POP \ - })) -#else -#define HEDLEY_CONST_CAST(T, expr) ((T)(expr)) -#endif - -#if defined(HEDLEY_REINTERPRET_CAST) -#undef HEDLEY_REINTERPRET_CAST -#endif -#if defined(__cplusplus) -#define HEDLEY_REINTERPRET_CAST(T, expr) (reinterpret_cast(expr)) -#else -#define HEDLEY_REINTERPRET_CAST(T, expr) (*((T *)&(expr))) -#endif - -#if defined(HEDLEY_STATIC_CAST) -#undef HEDLEY_STATIC_CAST -#endif -#if defined(__cplusplus) -#define HEDLEY_STATIC_CAST(T, expr) (static_cast(expr)) -#else -#define HEDLEY_STATIC_CAST(T, expr) ((T)(expr)) -#endif - -#if defined(HEDLEY_CPP_CAST) -#undef HEDLEY_CPP_CAST -#endif -#if defined(__cplusplus) -#define HEDLEY_CPP_CAST(T, expr) static_cast(expr) -#else -#define HEDLEY_CPP_CAST(T, expr) (expr) -#endif - -#if defined(HEDLEY_MESSAGE) -#undef HEDLEY_MESSAGE -#endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -#define HEDLEY_MESSAGE(msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - HEDLEY_PRAGMA(message msg) \ - HEDLEY_DIAGNOSTIC_POP -#elif HEDLEY_GCC_VERSION_CHECK(4, 4, 0) || HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) -#define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message msg) -#elif HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) -#define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(_CRI message msg) -#elif HEDLEY_IAR_VERSION_CHECK(8, 0, 0) -#define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) -#elif HEDLEY_PELLES_VERSION_CHECK(2, 0, 0) -#define HEDLEY_MESSAGE(msg) HEDLEY_PRAGMA(message(msg)) -#else -#define HEDLEY_MESSAGE(msg) -#endif - -#if defined(HEDLEY_WARNING) -#undef HEDLEY_WARNING -#endif -#if HEDLEY_HAS_WARNING("-Wunknown-pragmas") -#define HEDLEY_WARNING(msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - HEDLEY_DIAGNOSTIC_DISABLE_UNKNOWN_PRAGMAS \ - HEDLEY_PRAGMA(clang warning msg) \ - HEDLEY_DIAGNOSTIC_POP -#elif HEDLEY_GCC_VERSION_CHECK(4, 8, 0) || HEDLEY_PGI_VERSION_CHECK(18, 4, 0) -#define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(GCC warning msg) -#elif HEDLEY_MSVC_VERSION_CHECK(15, 0, 0) -#define HEDLEY_WARNING(msg) HEDLEY_PRAGMA(message(msg)) -#else -#define HEDLEY_WARNING(msg) HEDLEY_MESSAGE(msg) -#endif - -#if defined(HEDLEY_REQUIRE_MSG) -#undef HEDLEY_REQUIRE_MSG -#endif -#if HEDLEY_HAS_ATTRIBUTE(diagnose_if) -#if HEDLEY_HAS_WARNING("-Wgcc-compat") -#define HEDLEY_REQUIRE_MSG(expr, msg) \ - HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((__diagnose_if__(!(expr), msg, "error"))) \ - HEDLEY_DIAGNOSTIC_POP -#else -#define HEDLEY_REQUIRE_MSG(expr, msg) \ - __attribute__((__diagnose_if__(!(expr), msg, "error"))) -#endif -#else -#define HEDLEY_REQUIRE_MSG(expr, msg) -#endif - -#if defined(HEDLEY_REQUIRE) -#undef HEDLEY_REQUIRE -#endif -#define HEDLEY_REQUIRE(expr) HEDLEY_REQUIRE_MSG(expr, #expr) - -#if defined(HEDLEY_FLAGS) -#undef HEDLEY_FLAGS -#endif -#if HEDLEY_HAS_ATTRIBUTE(flag_enum) -#define HEDLEY_FLAGS __attribute__((__flag_enum__)) -#endif - -#if defined(HEDLEY_FLAGS_CAST) -#undef HEDLEY_FLAGS_CAST -#endif -#if HEDLEY_INTEL_VERSION_CHECK(19, 0, 0) -#define HEDLEY_FLAGS_CAST(T, expr) \ - (__extension__({ \ - HEDLEY_DIAGNOSTIC_PUSH \ - _Pragma("warning(disable:188)")((T)(expr)); \ - HEDLEY_DIAGNOSTIC_POP \ - })) -#else -#define HEDLEY_FLAGS_CAST(T, expr) HEDLEY_STATIC_CAST(T, expr) -#endif - -#if defined(HEDLEY_EMPTY_BASES) -#undef HEDLEY_EMPTY_BASES -#endif -#if HEDLEY_MSVC_VERSION_CHECK(19, 0, 23918) && \ - !HEDLEY_MSVC_VERSION_CHECK(20, 0, 0) -#define HEDLEY_EMPTY_BASES __declspec(empty_bases) -#else -#define HEDLEY_EMPTY_BASES -#endif - -/* Remaining macros are deprecated. */ - -#if defined(HEDLEY_GCC_NOT_CLANG_VERSION_CHECK) -#undef HEDLEY_GCC_NOT_CLANG_VERSION_CHECK -#endif -#if defined(__clang__) -#define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major, minor, patch) (0) -#else -#define HEDLEY_GCC_NOT_CLANG_VERSION_CHECK(major, minor, patch) \ - HEDLEY_GCC_VERSION_CHECK(major, minor, patch) -#endif - -#if defined(HEDLEY_CLANG_HAS_ATTRIBUTE) -#undef HEDLEY_CLANG_HAS_ATTRIBUTE -#endif -#define HEDLEY_CLANG_HAS_ATTRIBUTE(attribute) HEDLEY_HAS_ATTRIBUTE(attribute) - -#if defined(HEDLEY_CLANG_HAS_CPP_ATTRIBUTE) -#undef HEDLEY_CLANG_HAS_CPP_ATTRIBUTE -#endif -#define HEDLEY_CLANG_HAS_CPP_ATTRIBUTE(attribute) \ - HEDLEY_HAS_CPP_ATTRIBUTE(attribute) - -#if defined(HEDLEY_CLANG_HAS_BUILTIN) -#undef HEDLEY_CLANG_HAS_BUILTIN -#endif -#define HEDLEY_CLANG_HAS_BUILTIN(builtin) HEDLEY_HAS_BUILTIN(builtin) - -#if defined(HEDLEY_CLANG_HAS_FEATURE) -#undef HEDLEY_CLANG_HAS_FEATURE -#endif -#define HEDLEY_CLANG_HAS_FEATURE(feature) HEDLEY_HAS_FEATURE(feature) - -#if defined(HEDLEY_CLANG_HAS_EXTENSION) -#undef HEDLEY_CLANG_HAS_EXTENSION -#endif -#define HEDLEY_CLANG_HAS_EXTENSION(extension) HEDLEY_HAS_EXTENSION(extension) - -#if defined(HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE) -#undef HEDLEY_CLANG_HAS_DECLSPEC_DECLSPEC_ATTRIBUTE -#endif -#define HEDLEY_CLANG_HAS_DECLSPEC_ATTRIBUTE(attribute) \ - HEDLEY_HAS_DECLSPEC_ATTRIBUTE(attribute) - -#if defined(HEDLEY_CLANG_HAS_WARNING) -#undef HEDLEY_CLANG_HAS_WARNING -#endif -#define HEDLEY_CLANG_HAS_WARNING(warning) HEDLEY_HAS_WARNING(warning) - -#endif /* !defined(HEDLEY_VERSION) || (HEDLEY_VERSION < X) */ diff --git a/libobs/util/simde/mmx.h b/libobs/util/simde/mmx.h deleted file mode 100644 index fd38acb..0000000 --- a/libobs/util/simde/mmx.h +++ /dev/null @@ -1,1356 +0,0 @@ -/* Copyright (c) 2017-2018 Evan Nemerson - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(SIMDE__MMX_H) -#if !defined(SIMDE__MMX_H) -#define SIMDE__MMX_H -#endif -#include "simde-common.h" - -#if defined(SIMDE_MMX_FORCE_NATIVE) -#define SIMDE_MMX_NATIVE -#elif defined(__MMX__) && !defined(SIMDE_MMX_NO_NATIVE) && \ - !defined(SIMDE_NO_NATIVE) -#define SIMDE_MMX_NATIVE -#elif defined(__ARM_NEON) && !defined(SIMDE_MMX_NO_NEON) && \ - !defined(SIMDE_NO_NEON) -#define SIMDE_MMX_NEON -#endif - -#if defined(SIMDE_MMX_NATIVE) -#include -#else -#if defined(SIMDE_MMX_NEON) -#include -#endif -#endif -#include -#include -#include -#include - -SIMDE__BEGIN_DECLS - -typedef union { -#if defined(SIMDE__ENABLE_GCC_VEC_EXT) - int8_t i8 __attribute__((__vector_size__(8), __may_alias__)); - int16_t i16 __attribute__((__vector_size__(8), __may_alias__)); - int32_t i32 __attribute__((__vector_size__(8), __may_alias__)); - int64_t i64 __attribute__((__vector_size__(8), __may_alias__)); - uint8_t u8 __attribute__((__vector_size__(8), __may_alias__)); - uint16_t u16 __attribute__((__vector_size__(8), __may_alias__)); - uint32_t u32 __attribute__((__vector_size__(8), __may_alias__)); - uint64_t u64 __attribute__((__vector_size__(8), __may_alias__)); - simde_float32 f32 __attribute__((__vector_size__(8), __may_alias__)); -#else - int8_t i8[8]; - int16_t i16[4]; - int32_t i32[2]; - int64_t i64[1]; - uint8_t u8[8]; - uint16_t u16[4]; - uint32_t u32[2]; - uint64_t u64[1]; - simde_float32 f32[2]; -#endif - -#if defined(SIMDE_MMX_NATIVE) - __m64 n; -#elif defined(SIMDE_MMX_NEON) - int8x8_t neon_i8; - int16x4_t neon_i16; - int32x2_t neon_i32; - int64x1_t neon_i64; - uint8x8_t neon_u8; - uint16x4_t neon_u16; - uint32x2_t neon_u32; - uint64x1_t neon_u64; - float32x2_t neon_f32; -#endif -} simde__m64; - -#if defined(SIMDE_MMX_NATIVE) -HEDLEY_STATIC_ASSERT(sizeof(__m64) == sizeof(simde__m64), - "__m64 size doesn't match simde__m64 size"); -SIMDE__FUNCTION_ATTRIBUTES simde__m64 SIMDE__M64_C(__m64 v) -{ - simde__m64 r; - r.n = v; - return r; -} -#elif defined(SIMDE_MMX_NEON) -#define SIMDE__M64_NEON_C(T, expr) \ - (simde__m64) { .neon_##T = (expr) } -#endif -HEDLEY_STATIC_ASSERT(8 == sizeof(simde__m64), "__m64 size incorrect"); - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_add_pi8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_add_pi8(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < 8; i++) { - r.i8[i] = a.i8[i] + b.i8[i]; - } - return r; -#endif -} -#define simde_m_paddb(a, b) simde_mm_add_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_add_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_add_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - r.i16[i] = a.i16[i] + b.i16[i]; - } - return r; -#endif -} -#define simde_m_paddw(a, b) simde_mm_add_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_add_pi32(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_add_pi32(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int32_t)); i++) { - r.i32[i] = a.i32[i] + b.i32[i]; - } - return r; -#endif -} -#define simde_m_paddd(a, b) simde_mm_add_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_adds_pi8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_adds_pi8(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 8; i++) { - if ((((b.i8[i]) > 0) && ((a.i8[i]) > (INT8_MAX - (b.i8[i]))))) { - r.i8[i] = INT8_MAX; - } else if ((((b.i8[i]) < 0) && - ((a.i8[i]) < (INT8_MIN - (b.i8[i]))))) { - r.i8[i] = INT8_MIN; - } else { - r.i8[i] = (a.i8[i]) + (b.i8[i]); - } - } - return r; -#endif -} -#define simde_m_paddsb(a, b) simde_mm_adds_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_adds_pu8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_adds_pu8(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < 8; i++) { - const int32_t x = a.u8[i] + b.u8[i]; - if (x < 0) - r.u8[i] = 0; - else if (x > UINT8_MAX) - r.u8[i] = UINT8_MAX; - else - r.u8[i] = (uint8_t)x; - } - return r; -#endif -} -#define simde_m_paddusb(a, b) simde_mm_adds_pu8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_adds_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_adds_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 4; i++) { - if ((((b.i16[i]) > 0) && - ((a.i16[i]) > (INT16_MAX - (b.i16[i]))))) { - r.i16[i] = INT16_MAX; - } else if ((((b.i16[i]) < 0) && - ((a.i16[i]) < (SHRT_MIN - (b.i16[i]))))) { - r.i16[i] = SHRT_MIN; - } else { - r.i16[i] = (a.i16[i]) + (b.i16[i]); - } - } - return r; -#endif -} -#define simde_m_paddsw(a, b) simde_mm_adds_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_adds_pu16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_adds_pu16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - const uint32_t x = a.u16[i] + b.u16[i]; - if (x > UINT16_MAX) - r.u16[i] = UINT16_MAX; - else - r.u16[i] = (uint16_t)x; - } - return r; -#endif -} -#define simde_m_paddusw(a, b) simde_mm_adds_pu16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_and_si64(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_and_si64(a.n, b.n)); -#else - simde__m64 r; - r.i64[0] = a.i64[0] & b.i64[0]; - return r; -#endif -} -#define simde_m_pand(a, b) simde_mm_and_si64(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_andnot_si64(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_andnot_si64(a.n, b.n)); -#else - simde__m64 r; - r.i64[0] = ~(a.i64[0]) & b.i64[0]; - return r; -#endif -} -#define simde_m_pandn(a, b) simde_mm_andnot_si64(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cmpeq_pi8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_cmpeq_pi8(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 8; i++) { - r.i8[i] = (a.i8[i] == b.i8[i]) * 0xff; - } - return r; -#endif -} -#define simde_m_pcmpeqb(a, b) simde_mm_cmpeq_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cmpeq_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_cmpeq_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 4; i++) { - r.i16[i] = (a.i16[i] == b.i16[i]) * 0xffff; - } - return r; -#endif -} -#define simde_m_pcmpeqw(a, b) simde_mm_cmpeq_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cmpeq_pi32(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_cmpeq_pi32(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 2; i++) { - r.i32[i] = (a.i32[i] == b.i32[i]) * 0xffffffff; - } - return r; -#endif -} -#define simde_m_pcmpeqd(a, b) simde_mm_cmpeq_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cmpgt_pi8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_cmpgt_pi8(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 8; i++) { - r.i8[i] = (a.i8[i] > b.i8[i]) * 0xff; - } - return r; -#endif -} -#define simde_m_pcmpgtb(a, b) simde_mm_cmpgt_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cmpgt_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_cmpgt_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 4; i++) { - r.i16[i] = (a.i16[i] > b.i16[i]) * 0xffff; - } - return r; -#endif -} -#define simde_m_pcmpgtw(a, b) simde_mm_cmpgt_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cmpgt_pi32(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_cmpgt_pi32(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 2; i++) { - r.i32[i] = (a.i32[i] > b.i32[i]) * 0xffffffff; - } - return r; -#endif -} -#define simde_m_pcmpgtd(a, b) simde_mm_cmpgt_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -int64_t simde_mm_cvtm64_si64(simde__m64 a) -{ -#if defined(SIMDE_MMX_NATIVE) && defined(SIMDE_ARCH_AMD64) && !defined(__PGI) - return _mm_cvtm64_si64(a.n); -#else - return a.i64[0]; -#endif -} -#define simde_m_to_int64(a) simde_mm_cvtm64_si64(a) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvtsi32_si64(int32_t a) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_cvtsi32_si64(a)); -#else - simde__m64 r; - r.i32[0] = a; - r.i32[1] = 0; - return r; -#endif -} -#define simde_m_from_int(a) simde_mm_cvtsi32_si64(a) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvtsi64_m64(int64_t a) -{ -#if defined(SIMDE_MMX_NATIVE) && defined(SIMDE_ARCH_AMD64) && !defined(__PGI) - return SIMDE__M64_C(_mm_cvtsi64_m64(a)); -#else - simde__m64 r; - r.i64[0] = a; - return r; -#endif -} -#define simde_m_from_int64(a) simde_mm_cvtsi64_m64(a) - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvtsi64_si32(simde__m64 a) -{ -#if defined(SIMDE_MMX_NATIVE) - return _mm_cvtsi64_si32(a.n); -#else - return a.i32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_empty(void) -{ -#if defined(SIMDE_MMX_NATIVE) - _mm_empty(); -#else -#endif -} -#define simde_m_empty() simde_mm_empty() - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_madd_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_madd_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 4; i += 2) { - r.i32[i / 2] = - (a.i16[i] * b.i16[i]) + (a.i16[i + 1] * b.i16[i + 1]); - } - return r; -#endif -} -#define simde_m_pmaddwd(a, b) simde_mm_madd_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_mulhi_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_mulhi_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 4; i++) { - r.i16[i] = (int16_t)((a.i16[i] * b.i16[i]) >> 16); - } - return r; -#endif -} -#define simde_m_pmulhw(a, b) simde_mm_mulhi_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_mullo_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_mullo_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (int i = 0; i < 4; i++) { - r.i16[i] = (int16_t)((a.i16[i] * b.i16[i]) & 0xffff); - } - return r; -#endif -} -#define simde_m_pmullw(a, b) simde_mm_mullo_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_or_si64(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_or_si64(a.n, b.n)); -#else - simde__m64 r; - r.i64[0] = a.i64[0] | b.i64[0]; - return r; -#endif -} -#define simde_m_por(a, b) simde_mm_or_si64(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_packs_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_packs_pi16(a.n, b.n)); -#else - simde__m64 r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - if (a.i16[i] < INT8_MIN) { - r.i8[i] = INT8_MIN; - } else if (a.i16[i] > INT8_MAX) { - r.i8[i] = INT8_MAX; - } else { - r.i8[i] = (int8_t)a.i16[i]; - } - } - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - if (b.i16[i] < INT8_MIN) { - r.i8[i + 4] = INT8_MIN; - } else if (b.i16[i] > INT8_MAX) { - r.i8[i + 4] = INT8_MAX; - } else { - r.i8[i + 4] = (int8_t)b.i16[i]; - } - } - - return r; -#endif -} -#define simde_m_packsswb(a, b) simde_mm_packs_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_packs_pi32(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_packs_pi32(a.n, b.n)); -#else - simde__m64 r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(a.i32[0])); i++) { - if (a.i32[i] < SHRT_MIN) { - r.i16[i] = SHRT_MIN; - } else if (a.i32[i] > INT16_MAX) { - r.i16[i] = INT16_MAX; - } else { - r.i16[i] = (int16_t)a.i32[i]; - } - } - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(b.i32[0])); i++) { - if (b.i32[i] < SHRT_MIN) { - r.i16[i + 2] = SHRT_MIN; - } else if (b.i32[i] > INT16_MAX) { - r.i16[i + 2] = INT16_MAX; - } else { - r.i16[i + 2] = (int16_t)b.i32[i]; - } - } - - return r; -#endif -} -#define simde_m_packssdw(a, b) simde_mm_packs_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_packs_pu16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_packs_pu16(a.n, b.n)); -#else - simde__m64 r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - if (a.i16[i] > UINT8_MAX) { - r.u8[i] = UINT8_MAX; - } else if (a.i16[i] < 0) { - r.u8[i] = 0; - } else { - r.u8[i] = (int8_t)a.i16[i]; - } - } - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - if (b.i16[i] > UINT8_MAX) { - r.u8[i + 4] = UINT8_MAX; - } else if (b.i16[i] < 0) { - r.u8[i + 4] = 0; - } else { - r.u8[i + 4] = (int8_t)b.i16[i]; - } - } - - return r; -#endif -} -#define simde_m_packuswb(a, b) simde_mm_packs_pu16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_set_pi8(int8_t e7, int8_t e6, int8_t e5, int8_t e4, - int8_t e3, int8_t e2, int8_t e1, int8_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set_pi8(e7, e6, e5, e4, e3, e2, e1, e0)); -#else - simde__m64 r; - r.i8[0] = e0; - r.i8[1] = e1; - r.i8[2] = e2; - r.i8[3] = e3; - r.i8[4] = e4; - r.i8[5] = e5; - r.i8[6] = e6; - r.i8[7] = e7; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_x_mm_set_pu8(uint8_t e7, uint8_t e6, uint8_t e5, uint8_t e4, - uint8_t e3, uint8_t e2, uint8_t e1, uint8_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set_pi8((int8_t)e7, (int8_t)e6, (int8_t)e5, - (int8_t)e4, (int8_t)e3, (int8_t)e2, - (int8_t)e1, (int8_t)e0)); -#else - simde__m64 r; - r.u8[0] = e0; - r.u8[1] = e1; - r.u8[2] = e2; - r.u8[3] = e3; - r.u8[4] = e4; - r.u8[5] = e5; - r.u8[6] = e6; - r.u8[7] = e7; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_set_pi16(int16_t e3, int16_t e2, int16_t e1, int16_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set_pi16(e3, e2, e1, e0)); -#else - simde__m64 r; - r.i16[0] = e0; - r.i16[1] = e1; - r.i16[2] = e2; - r.i16[3] = e3; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_x_mm_set_pu16(uint16_t e3, uint16_t e2, uint16_t e1, - uint16_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set_pi16((int16_t)e3, (int16_t)e2, (int16_t)e1, - (int16_t)e0)); -#else - simde__m64 r; - r.u16[0] = e0; - r.u16[1] = e1; - r.u16[2] = e2; - r.u16[3] = e3; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_x_mm_set_pu32(uint32_t e1, uint32_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set_pi32((int32_t)e1, (int32_t)e0)); -#else - simde__m64 r; - r.u32[0] = e0; - r.u32[1] = e1; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_set_pi32(int32_t e1, int32_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set_pi32(e1, e0)); -#else - simde__m64 r; - r.i32[0] = e0; - r.i32[1] = e1; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_set1_pi8(int8_t a) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set1_pi8(a)); -#else - return simde_mm_set_pi8(a, a, a, a, a, a, a, a); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_set1_pi16(int16_t a) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set1_pi16(a)); -#else - return simde_mm_set_pi16(a, a, a, a); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_set1_pi32(int32_t a) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_set1_pi32(a)); -#else - return simde_mm_set_pi32(a, a); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_setr_pi8(int8_t e7, int8_t e6, int8_t e5, int8_t e4, - int8_t e3, int8_t e2, int8_t e1, int8_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_setr_pi8(e7, e6, e5, e4, e3, e2, e1, e0)); -#else - return simde_mm_set_pi8(e0, e1, e2, e3, e4, e5, e6, e7); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_setr_pi16(int16_t e3, int16_t e2, int16_t e1, int16_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_setr_pi16(e3, e2, e1, e0)); -#else - return simde_mm_set_pi16(e0, e1, e2, e3); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_setr_pi32(int32_t e1, int32_t e0) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_setr_pi32(e1, e0)); -#else - return simde_mm_set_pi32(e0, e1); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_setzero_si64(void) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_setzero_si64()); -#else - return simde_mm_set_pi32(0, 0); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sll_pi16(simde__m64 a, simde__m64 count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_sll_pi16(a.n, count.n)); -#else - simde__m64 r; - - if (HEDLEY_UNLIKELY(count.u64[0] > 15)) { - memset(&r, 0, sizeof(r)); - return r; - } - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u16) / sizeof(r.u16[0])); i++) { - r.u16[i] = a.u16[i] << count.u64[0]; - } - return r; -#endif -} -#define simde_m_psllw(a, count) simde_mm_sll_pi16(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sll_pi32(simde__m64 a, simde__m64 count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_sll_pi32(a.n, count.n)); -#else - simde__m64 r; - - if (HEDLEY_UNLIKELY(count.u64[0] > 31)) { - memset(&r, 0, sizeof(r)); - return r; - } - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u32) / sizeof(r.u32[0])); i++) { - r.u32[i] = a.u32[i] << count.u64[0]; - } - return r; -#endif -} -#define simde_m_pslld(a, count) simde_mm_sll_pi32(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_slli_pi16(simde__m64 a, int count) -{ -#if defined(SIMDE_MMX_NATIVE) && !defined(__PGI) - return SIMDE__M64_C(_mm_slli_pi16(a.n, count)); -#else - simde__m64 r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u16) / sizeof(r.u16[0])); i++) { - r.u16[i] = a.u16[i] << count; - } - - return r; -#endif -} -#define simde_m_psllwi(a, count) simde_mm_slli_pi16(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_slli_pi32(simde__m64 a, int count) -{ -#if defined(SIMDE_MMX_NATIVE) && !defined(__PGI) - return SIMDE__M64_C(_mm_slli_pi32(a.n, count)); -#else - simde__m64 r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int)); i++) { - r.u32[i] = a.u32[i] << count; - } - - return r; -#endif -} -#define simde_m_pslldi(a, b) simde_mm_slli_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_slli_si64(simde__m64 a, int count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_slli_si64(a.n, count)); -#else - simde__m64 r; - r.u64[0] = a.u64[0] << count; - return r; -#endif -} -#define simde_m_psllqi(a, count) simde_mm_slli_si64(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sll_si64(simde__m64 a, simde__m64 count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_sll_si64(a.n, count.n)); -#else - simde__m64 r; - - if (HEDLEY_UNLIKELY(count.u64[0] > 63)) { - memset(&r, 0, sizeof(r)); - return r; - } - - r.u64[0] = a.u64[0] << count.u64[0]; - - return r; -#endif -} -#define simde_m_psllq(a, count) simde_mm_sll_si64(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_srl_pi16(simde__m64 a, simde__m64 count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_srl_pi16(a.n, count.n)); -#else - simde__m64 r; - - if (HEDLEY_UNLIKELY(count.u64[0] > 15)) { - memset(&r, 0, sizeof(r)); - return r; - } - - SIMDE__VECTORIZE - for (size_t i = 0; i < sizeof(r.u16) / sizeof(r.u16[0]); i++) { - r.u16[i] = a.u16[i] >> count.u64[0]; - } - return r; -#endif -} -#define simde_m_psrlw(a, count) simde_mm_srl_pi16(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_srl_pi32(simde__m64 a, simde__m64 count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_srl_pi32(a.n, count.n)); -#else - simde__m64 r; - - if (HEDLEY_UNLIKELY(count.u64[0] > 31)) { - memset(&r, 0, sizeof(r)); - return r; - } - - SIMDE__VECTORIZE - for (size_t i = 0; i < sizeof(r.u32) / sizeof(r.u32[0]); i++) { - r.u32[i] = a.u32[i] >> count.u64[0]; - } - return r; -#endif -} -#define simde_m_psrld(a, count) simde_mm_srl_pi32(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_srli_pi16(simde__m64 a, int count) -{ -#if defined(SIMDE_MMX_NATIVE) && !defined(__PGI) - return SIMDE__M64_C(_mm_srli_pi16(a.n, count)); -#else - simde__m64 r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(uint16_t)); i++) { - r.u16[i] = a.u16[i] >> count; - } - - return r; -#endif -} -#define simde_m_psrlwi(a, count) simde_mm_srli_pi16(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_srli_pi32(simde__m64 a, int count) -{ -#if defined(SIMDE_MMX_NATIVE) && !defined(__PGI) - return SIMDE__M64_C(_mm_srli_pi32(a.n, count)); -#else - simde__m64 r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int)); i++) { - r.u32[i] = a.u32[i] >> count; - } - - return r; -#endif -} -#define simde_m_psrldi(a, count) simde_mm_srli_pi32(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_srli_si64(simde__m64 a, int count) -{ -#if defined(SIMDE_MMX_NATIVE) && !defined(__PGI) - return SIMDE__M64_C(_mm_srli_si64(a.n, count)); -#else - simde__m64 r; - r.u64[0] = a.u64[0] >> count; - return r; -#endif -} -#define simde_m_psrlqi(a, count) simde_mm_srli_si64(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_srl_si64(simde__m64 a, simde__m64 count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_srl_si64(a.n, count.n)); -#else - simde__m64 r; - - if (HEDLEY_UNLIKELY(count.u64[0] > 63)) { - memset(&r, 0, sizeof(r)); - return r; - } - - r.u64[0] = a.u64[0] >> count.u64[0]; - return r; -#endif -} -#define simde_m_psrlq(a, count) simde_mm_srl_si64(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_srai_pi16(simde__m64 a, int count) -{ -#if defined(SIMDE_MMX_NATIVE) && !defined(__PGI) - return SIMDE__M64_C(_mm_srai_pi16(a.n, count)); -#else - simde__m64 r; - - const uint16_t m = - (uint16_t)((~0U) << ((sizeof(int16_t) * CHAR_BIT) - count)); - - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - const uint16_t is_neg = ((uint16_t)( - ((a.u16[i]) >> ((sizeof(int16_t) * CHAR_BIT) - 1)))); - r.u16[i] = (a.u16[i] >> count) | (m * is_neg); - } - - return r; -#endif -} -#define simde_m_psrawi(a, count) simde_mm_srai_pi16(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_srai_pi32(simde__m64 a, int count) -{ -#if defined(SIMDE_MMX_NATIVE) && !defined(__PGI) - return SIMDE__M64_C(_mm_srai_pi32(a.n, count)); -#else - simde__m64 r; - - const uint32_t m = - (uint32_t)((~0U) << ((sizeof(int) * CHAR_BIT) - count)); - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int)); i++) { - const uint32_t is_neg = ((uint32_t)( - ((a.u32[i]) >> ((sizeof(int) * CHAR_BIT) - 1)))); - r.u32[i] = (a.u32[i] >> count) | (m * is_neg); - } - - return r; -#endif -} -#define simde_m_srai_pi32(a, count) simde_mm_srai_pi32(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sra_pi16(simde__m64 a, simde__m64 count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_sra_pi16(a.n, count.n)); -#else - simde__m64 r; - int cnt = (int)count.i64[0]; - - if (cnt > 15 || cnt < 0) { - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); - i++) { - r.u16[i] = (a.i16[i] < 0) ? 0xffff : 0x0000; - } - } else { - const uint16_t m = (uint16_t)( - (~0U) << ((sizeof(int16_t) * CHAR_BIT) - cnt)); - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); - i++) { - const uint16_t is_neg = a.i16[i] < 0; - r.u16[i] = (a.u16[i] >> cnt) | (m * is_neg); - } - } - - return r; -#endif -} -#define simde_m_psraw(a, count) simde_mm_sra_pi16(a, count) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sra_pi32(simde__m64 a, simde__m64 count) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_sra_pi32(a.n, count.n)); -#else - simde__m64 r; - const uint64_t cnt = count.u64[0]; - - if (cnt > 31) { - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); - i++) { - r.u32[i] = (a.i32[i] < 0) ? UINT32_MAX : 0; - } - } else if (cnt == 0) { - memcpy(&r, &a, sizeof(r)); - } else { - const uint32_t m = (uint32_t)( - (~0U) << ((sizeof(int32_t) * CHAR_BIT) - cnt)); - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); - i++) { - const uint32_t is_neg = a.i32[i] < 0; - r.u32[i] = (a.u32[i] >> cnt) | (m * is_neg); - } - } - - return r; -#endif -} -#define simde_m_psrad(a, b) simde_mm_sra_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sub_pi8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_sub_pi8(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < 8; i++) { - r.i8[i] = a.i8[i] - b.i8[i]; - } - return r; -#endif -} -#define simde_m_psubb(a, b) simde_mm_sub_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sub_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_sub_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - r.i16[i] = a.i16[i] - b.i16[i]; - } - return r; -#endif -} -#define simde_m_psubw(a, b) simde_mm_sub_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sub_pi32(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_sub_pi32(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int)); i++) { - r.i32[i] = a.i32[i] - b.i32[i]; - } - return r; -#endif -} -#define simde_m_psubd(a, b) simde_mm_sub_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_subs_pi8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_subs_pi8(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8); i++) { - if (((b.i8[i]) > 0 && (a.i8[i]) < INT8_MIN + (b.i8[i]))) { - r.i8[i] = INT8_MIN; - } else if ((b.i8[i]) < 0 && (a.i8[i]) > INT8_MAX + (b.i8[i])) { - r.i8[i] = INT8_MAX; - } else { - r.i8[i] = (a.i8[i]) - (b.i8[i]); - } - } - return r; -#endif -} -#define simde_m_psubsb(a, b) simde_mm_subs_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_subs_pu8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_subs_pu8(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8); i++) { - const int32_t x = a.u8[i] - b.u8[i]; - if (x < 0) { - r.u8[i] = 0; - } else if (x > UINT8_MAX) { - r.u8[i] = UINT8_MAX; - } else { - r.u8[i] = (uint8_t)x; - } - } - return r; -#endif -} -#define simde_m_psubusb(a, b) simde_mm_subs_pu8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_subs_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_subs_pi16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(int16_t)); i++) { - if (((b.i16[i]) > 0 && (a.i16[i]) < SHRT_MIN + (b.i16[i]))) { - r.i16[i] = SHRT_MIN; - } else if ((b.i16[i]) < 0 && - (a.i16[i]) > INT16_MAX + (b.i16[i])) { - r.i16[i] = INT16_MAX; - } else { - r.i16[i] = (a.i16[i]) - (b.i16[i]); - } - } - return r; -#endif -} -#define simde_m_psubsw(a, b) simde_mm_subs_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_subs_pu16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_subs_pu16(a.n, b.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (8 / sizeof(uint16_t)); i++) { - const int x = a.u16[i] - b.u16[i]; - if (x < 0) { - r.u16[i] = 0; - } else if (x > UINT16_MAX) { - r.u16[i] = UINT16_MAX; - } else { - r.u16[i] = (uint16_t)x; - } - } - return r; -#endif -} -#define simde_m_psubusw(a, b) simde_mm_subs_pu16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_unpackhi_pi8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_unpackhi_pi8(a.n, b.n)); -#else - simde__m64 r; - r.i8[0] = a.i8[4]; - r.i8[1] = b.i8[4]; - r.i8[2] = a.i8[5]; - r.i8[3] = b.i8[5]; - r.i8[4] = a.i8[6]; - r.i8[5] = b.i8[6]; - r.i8[6] = a.i8[7]; - r.i8[7] = b.i8[7]; - return r; -#endif -} -#define simde_m_punpckhbw(a, b) simde_mm_unpackhi_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_unpackhi_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_unpackhi_pi16(a.n, b.n)); -#else - simde__m64 r; - r.i16[0] = a.i16[2]; - r.i16[1] = b.i16[2]; - r.i16[2] = a.i16[3]; - r.i16[3] = b.i16[3]; - return r; -#endif -} -#define simde_m_punpckhwd(a, b) simde_mm_unpackhi_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_unpackhi_pi32(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_unpackhi_pi32(a.n, b.n)); -#else - simde__m64 r; - r.i32[0] = a.i32[1]; - r.i32[1] = b.i32[1]; - return r; -#endif -} -#define simde_m_punpckhdq(a, b) simde_mm_unpackhi_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_unpacklo_pi8(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_unpacklo_pi8(a.n, b.n)); -#else - simde__m64 r; - r.i8[0] = a.i8[0]; - r.i8[1] = b.i8[0]; - r.i8[2] = a.i8[1]; - r.i8[3] = b.i8[1]; - r.i8[4] = a.i8[2]; - r.i8[5] = b.i8[2]; - r.i8[6] = a.i8[3]; - r.i8[7] = b.i8[3]; - return r; -#endif -} -#define simde_m_punpcklbw(a, b) simde_mm_unpacklo_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_unpacklo_pi16(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_unpacklo_pi16(a.n, b.n)); -#else - simde__m64 r; - r.i16[0] = a.i16[0]; - r.i16[1] = b.i16[0]; - r.i16[2] = a.i16[1]; - r.i16[3] = b.i16[1]; - return r; -#endif -} -#define simde_m_punpcklwd(a, b) simde_mm_unpacklo_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_unpacklo_pi32(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_unpacklo_pi32(a.n, b.n)); -#else - simde__m64 r; - r.i32[0] = a.i32[0]; - r.i32[1] = b.i32[0]; - return r; -#endif -} -#define simde_m_punpckldq(a, b) simde_mm_unpacklo_pi32(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_xor_si64(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_MMX_NATIVE) - return SIMDE__M64_C(_mm_xor_si64(a.n, b.n)); -#else - simde__m64 r; - r.i64[0] = a.i64[0] ^ b.i64[0]; - return r; -#endif -} -#define simde_m_pxor(a, b) simde_mm_xor_si64(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_m_to_int(simde__m64 a) -{ -#if defined(SIMDE_MMX_NATIVE) - return _m_to_int(a.n); -#else - return a.i32[0]; -#endif -} - -SIMDE__END_DECLS - -#endif /* !defined(SIMDE__MMX_H) */ diff --git a/libobs/util/simde/simde-arch.h b/libobs/util/simde/simde-arch.h deleted file mode 100644 index 532304c..0000000 --- a/libobs/util/simde/simde-arch.h +++ /dev/null @@ -1,355 +0,0 @@ -/* Architecture detection - * Created by Evan Nemerson - * - * To the extent possible under law, the authors have waived all - * copyright and related or neighboring rights to this code. For - * details, see the Creative Commons Zero 1.0 Universal license at - * - * - * Different compilers define different preprocessor macros for the - * same architecture. This is an attempt to provide a single - * interface which is usable on any compiler. - * - * In general, a macro named SIMDE_ARCH_* is defined for each - * architecture the CPU supports. When there are multiple possible - * versions, we try to define the macro to the target version. For - * example, if you want to check for i586+, you could do something - * like: - * - * #if defined(SIMDE_ARCH_X86) && (SIMDE_ARCH_X86 >= 5) - * ... - * #endif - * - * You could also just check that SIMDE_ARCH_X86 >= 5 without checking - * if it's defined first, but some compilers may emit a warning about - * an undefined macro being used (e.g., GCC with -Wundef). - * - * This was originally created for SIMDe - * (hence the prefix), but this - * header has no dependencies and may be used anywhere. It is - * originally based on information from - * , though it - * has been enhanced with additional information. - * - * If you improve this file, or find a bug, please file the issue at - * . If you copy this into - * your project, even if you change the prefix, please keep the links - * to SIMDe intact so others know where to report issues, submit - * enhancements, and find the latest version. */ - -#if !defined(SIMDE_ARCH_H) -#define SIMDE_ARCH_H - -/* Alpha - */ -#if defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) -#if defined(__alpha_ev6__) -#define SIMDE_ARCH_ALPHA 6 -#elif defined(__alpha_ev5__) -#define SIMDE_ARCH_ALPHA 5 -#elif defined(__alpha_ev4__) -#define SIMDE_ARCH_ALPHA 4 -#else -#define SIMDE_ARCH_ALPHA 1 -#endif -#endif - -/* Atmel AVR - */ -#if defined(__AVR_ARCH__) -#define SIMDE_ARCH_AVR __AVR_ARCH__ -#endif - -/* AMD64 / x86_64 - */ -#if defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || \ - defined(__x86_64) || defined(_M_X66) || defined(_M_AMD64) -#define SIMDE_ARCH_AMD64 1 -#endif - -/* ARM - */ -#if defined(__ARM_ARCH_8A__) -#define SIMDE_ARCH_ARM 82 -#elif defined(__ARM_ARCH_8R__) -#define SIMDE_ARCH_ARM 81 -#elif defined(__ARM_ARCH_8__) -#define SIMDE_ARCH_ARM 80 -#elif defined(__ARM_ARCH_7S__) -#define SIMDE_ARCH_ARM 74 -#elif defined(__ARM_ARCH_7M__) -#define SIMDE_ARCH_ARM 73 -#elif defined(__ARM_ARCH_7R__) -#define SIMDE_ARCH_ARM 72 -#elif defined(__ARM_ARCH_7A__) -#define SIMDE_ARCH_ARM 71 -#elif defined(__ARM_ARCH_7__) -#define SIMDE_ARCH_ARM 70 -#elif defined(__ARM_ARCH) -#define SIMDE_ARCH_ARM (__ARM_ARCH * 10) -#elif defined(_M_ARM) -#define SIMDE_ARCH_ARM (_M_ARM * 10) -#elif defined(__arm__) || defined(__thumb__) || defined(__TARGET_ARCH_ARM) || \ - defined(_ARM) || defined(_M_ARM) || defined(_M_ARM) -#define SIMDE_ARCH_ARM 1 -#endif - -/* AArch64 - */ -#if defined(__aarch64__) || defined(_M_ARM64) -#define SIMDE_ARCH_AARCH64 10 -#endif - -/* Blackfin - */ -#if defined(__bfin) || defined(__BFIN__) || defined(__bfin__) -#define SIMDE_ARCH_BLACKFIN 1 -#endif - -/* CRIS - */ -#if defined(__CRIS_arch_version) -#define SIMDE_ARCH_CRIS __CRIS_arch_version -#elif defined(__cris__) || defined(__cris) || defined(__CRIS) || \ - defined(__CRIS__) -#define SIMDE_ARCH_CRIS 1 -#endif - -/* Convex - */ -#if defined(__convex_c38__) -#define SIMDE_ARCH_CONVEX 38 -#elif defined(__convex_c34__) -#define SIMDE_ARCH_CONVEX 34 -#elif defined(__convex_c32__) -#define SIMDE_ARCH_CONVEX 32 -#elif defined(__convex_c2__) -#define SIMDE_ARCH_CONVEX 2 -#elif defined(__convex__) -#define SIMDE_ARCH_CONVEX 1 -#endif - -/* Adapteva Epiphany - */ -#if defined(__epiphany__) -#define SIMDE_ARCH_EPIPHANY 1 -#endif - -/* Fujitsu FR-V - */ -#if defined(__frv__) -#define SIMDE_ARCH_FRV 1 -#endif - -/* H8/300 - */ -#if defined(__H8300__) -#define SIMDE_ARCH_H8300 -#endif - -/* HP/PA / PA-RISC - */ -#if defined(__PA8000__) || defined(__HPPA20__) || defined(__RISC2_0__) || \ - defined(_PA_RISC2_0) -#define SIMDE_ARCH_HPPA 20 -#elif defined(__PA7100__) || defined(__HPPA11__) || defined(_PA_RISC1_1) -#define SIMDE_ARCH_HPPA 11 -#elif defined(_PA_RISC1_0) -#define SIMDE_ARCH_HPPA 10 -#elif defined(__hppa__) || defined(__HPPA__) || defined(__hppa) -#define SIMDE_ARCH_HPPA 1 -#endif - -/* x86 - */ -#if defined(_M_IX86) -#define SIMDE_ARCH_X86 (_M_IX86 / 100) -#elif defined(__I86__) -#define SIMDE_ARCH_X86 __I86__ -#elif defined(i686) || defined(__i686) || defined(__i686__) -#define SIMDE_ARCH_X86 6 -#elif defined(i586) || defined(__i586) || defined(__i586__) -#define SIMDE_ARCH_X86 5 -#elif defined(i486) || defined(__i486) || defined(__i486__) -#define SIMDE_ARCH_X86 4 -#elif defined(i386) || defined(__i386) || defined(__i386__) -#define SIMDE_ARCH_X86 3 -#elif defined(_X86_) || defined(__X86__) || defined(__THW_INTEL__) -#define SIMDE_ARCH_X86 3 -#endif - -/* Itanium - */ -#if defined(__ia64__) || defined(_IA64) || defined(__IA64__) || \ - defined(__ia64) || defined(_M_IA64) || defined(__itanium__) -#define SIMDE_ARCH_IA64 1 -#endif - -/* Renesas M32R - */ -#if defined(__m32r__) || defined(__M32R__) -#define SIMDE_ARCH_M32R -#endif - -/* Motorola 68000 - */ -#if defined(__mc68060__) || defined(__MC68060__) -#define SIMDE_ARCH_M68K 68060 -#elif defined(__mc68040__) || defined(__MC68040__) -#define SIMDE_ARCH_M68K 68040 -#elif defined(__mc68030__) || defined(__MC68030__) -#define SIMDE_ARCH_M68K 68030 -#elif defined(__mc68020__) || defined(__MC68020__) -#define SIMDE_ARCH_M68K 68020 -#elif defined(__mc68010__) || defined(__MC68010__) -#define SIMDE_ARCH_M68K 68010 -#elif defined(__mc68000__) || defined(__MC68000__) -#define SIMDE_ARCH_M68K 68000 -#endif - -/* Xilinx MicroBlaze - */ -#if defined(__MICROBLAZE__) || defined(__microblaze__) -#define SIMDE_ARCH_MICROBLAZE -#endif - -/* MIPS - */ -#if defined(_MIPS_ISA_MIPS64R2) -#define SIMDE_ARCH_MIPS 642 -#elif defined(_MIPS_ISA_MIPS64) -#define SIMDE_ARCH_MIPS 640 -#elif defined(_MIPS_ISA_MIPS32R2) -#define SIMDE_ARCH_MIPS 322 -#elif defined(_MIPS_ISA_MIPS32) -#define SIMDE_ARCH_MIPS 320 -#elif defined(_MIPS_ISA_MIPS4) -#define SIMDE_ARCH_MIPS 4 -#elif defined(_MIPS_ISA_MIPS3) -#define SIMDE_ARCH_MIPS 3 -#elif defined(_MIPS_ISA_MIPS2) -#define SIMDE_ARCH_MIPS 2 -#elif defined(_MIPS_ISA_MIPS1) -#define SIMDE_ARCH_MIPS 1 -#elif defined(_MIPS_ISA_MIPS) || defined(__mips) || defined(__MIPS__) -#define SIMDE_ARCH_MIPS 1 -#endif - -/* Matsushita MN10300 - */ -#if defined(__MN10300__) || defined(__mn10300__) -#define SIMDE_ARCH_MN10300 1 -#endif - -/* POWER - */ -#if defined(_M_PPC) -#define SIMDE_ARCH_POWER _M_PPC -#elif defined(_ARCH_PWR8) -#define SIMDE_ARCH_POWER 800 -#elif defined(_ARCH_PWR7) -#define SIMDE_ARCH_POWER 700 -#elif defined(_ARCH_PWR6) -#define SIMDE_ARCH_POWER 600 -#elif defined(_ARCH_PWR5) -#define SIMDE_ARCH_POWER 500 -#elif defined(_ARCH_PWR4) -#define SIMDE_ARCH_POWER 400 -#elif defined(_ARCH_440) || defined(__ppc440__) -#define SIMDE_ARCH_POWER 440 -#elif defined(_ARCH_450) || defined(__ppc450__) -#define SIMDE_ARCH_POWER 450 -#elif defined(_ARCH_601) || defined(__ppc601__) -#define SIMDE_ARCH_POWER 601 -#elif defined(_ARCH_603) || defined(__ppc603__) -#define SIMDE_ARCH_POWER 603 -#elif defined(_ARCH_604) || defined(__ppc604__) -#define SIMDE_ARCH_POWER 604 -#elif defined(_ARCH_605) || defined(__ppc605__) -#define SIMDE_ARCH_POWER 605 -#elif defined(_ARCH_620) || defined(__ppc620__) -#define SIMDE_ARCH_POWER 620 -#elif defined(__powerpc) || defined(__powerpc__) || defined(__POWERPC__) || \ - defined(__ppc__) || defined(__PPC__) || defined(_ARCH_PPC) || \ - defined(__ppc) -#define SIMDE_ARCH_POWER 1 -#endif - -/* SPARC - */ -#if defined(__sparc_v9__) || defined(__sparcv9) -#define SIMDE_ARCH_SPARC 9 -#elif defined(__sparc_v8__) || defined(__sparcv8) -#define SIMDE_ARCH_SPARC 8 -#elif defined(__sparc_v7__) || defined(__sparcv7) -#define SIMDE_ARCH_SPARC 7 -#elif defined(__sparc_v6__) || defined(__sparcv6) -#define SIMDE_ARCH_SPARC 6 -#elif defined(__sparc_v5__) || defined(__sparcv5) -#define SIMDE_ARCH_SPARC 5 -#elif defined(__sparc_v4__) || defined(__sparcv4) -#define SIMDE_ARCH_SPARC 4 -#elif defined(__sparc_v3__) || defined(__sparcv3) -#define SIMDE_ARCH_SPARC 3 -#elif defined(__sparc_v2__) || defined(__sparcv2) -#define SIMDE_ARCH_SPARC 2 -#elif defined(__sparc_v1__) || defined(__sparcv1) -#define SIMDE_ARCH_SPARC 1 -#elif defined(__sparc__) || defined(__sparc) -#define SIMDE_ARCH_SPARC 1 -#endif - -/* SuperH - */ -#if defined(__sh5__) || defined(__SH5__) -#define SIMDE_ARCH_SUPERH 5 -#elif defined(__sh4__) || defined(__SH4__) -#define SIMDE_ARCH_SUPERH 4 -#elif defined(__sh3__) || defined(__SH3__) -#define SIMDE_ARCH_SUPERH 3 -#elif defined(__sh2__) || defined(__SH2__) -#define SIMDE_ARCH_SUPERH 2 -#elif defined(__sh1__) || defined(__SH1__) -#define SIMDE_ARCH_SUPERH 1 -#elif defined(__sh__) || defined(__SH__) -#define SIMDE_ARCH_SUPERH 1 -#endif - -/* IBM System z - */ -#if defined(__370__) || defined(__THW_370__) || defined(__s390__) || \ - defined(__s390x__) || defined(__zarch__) || defined(__SYSC_ZARCH__) -#define SIMDE_ARCH_SYSTEMZ -#endif - -/* TMS320 DSP - */ -#if defined(_TMS320C6740) || defined(__TMS320C6740__) -#define SIMDE_ARCH_TMS320 6740 -#elif defined(_TMS320C6700_PLUS) || defined(__TMS320C6700_PLUS__) -#define SIMDE_ARCH_TMS320 6701 -#elif defined(_TMS320C6700) || defined(__TMS320C6700__) -#define SIMDE_ARCH_TMS320 6700 -#elif defined(_TMS320C6600) || defined(__TMS320C6600__) -#define SIMDE_ARCH_TMS320 6600 -#elif defined(_TMS320C6400_PLUS) || defined(__TMS320C6400_PLUS__) -#define SIMDE_ARCH_TMS320 6401 -#elif defined(_TMS320C6400) || defined(__TMS320C6400__) -#define SIMDE_ARCH_TMS320 6400 -#elif defined(_TMS320C6200) || defined(__TMS320C6200__) -#define SIMDE_ARCH_TMS320 6200 -#elif defined(_TMS320C55X) || defined(__TMS320C55X__) -#define SIMDE_ARCH_TMS320 550 -#elif defined(_TMS320C54X) || defined(__TMS320C54X__) -#define SIMDE_ARCH_TMS320 540 -#elif defined(_TMS320C28X) || defined(__TMS320C28X__) -#define SIMDE_ARCH_TMS320 280 -#endif - -/* Xtensa - */ -#if defined(__xtensa__) || defined(__XTENSA__) -#define SIMDE_ARCH_XTENSA 1 -#endif - -#endif /* !defined(SIMDE_ARCH_H) */ diff --git a/libobs/util/simde/simde-common.h b/libobs/util/simde/simde-common.h deleted file mode 100644 index 7279d54..0000000 --- a/libobs/util/simde/simde-common.h +++ /dev/null @@ -1,278 +0,0 @@ -/* Copyright (c) 2017-2019 Evan Nemerson - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#if !defined(SIMDE_COMMON_H) -#define SIMDE_COMMON_H - -#include "hedley.h" -#include "check.h" -#include "simde-arch.h" - -#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L) -#define SIMDE_ALIGN(alignment) _Alignas(alignment) -#elif (defined(__cplusplus) && (__cplusplus >= 201103L)) -#define SIMDE_ALIGN(alignment) alignas(alignment) -#elif HEDLEY_GCC_VERSION_CHECK(2, 95, 0) || \ - HEDLEY_CRAY_VERSION_CHECK(8, 4, 0) || \ - HEDLEY_IBM_VERSION_CHECK(11, 1, 0) || \ - HEDLEY_INTEL_VERSION_CHECK(13, 0, 0) || \ - HEDLEY_PGI_VERSION_CHECK(19, 4, 0) || \ - HEDLEY_ARM_VERSION_CHECK(4, 1, 0) || \ - HEDLEY_TINYC_VERSION_CHECK(0, 9, 24) || \ - HEDLEY_TI_VERSION_CHECK(8, 1, 0) -#define SIMDE_ALIGN(alignment) __attribute__((aligned(alignment))) -#elif defined(_MSC_VER) && (!defined(_M_IX86) || defined(_M_AMD64)) -#define SIMDE_ALIGN(alignment) __declspec(align(alignment)) -#else -#define SIMDE_ALIGN(alignment) -#endif - -#define simde_assert_aligned(alignment, val) \ - simde_assert_int(((uintptr_t)(val)) % (alignment), ==, 0) - -#if HEDLEY_GCC_HAS_ATTRIBUTE(vector_size, 4, 6, 0) -#define SIMDE__ENABLE_GCC_VEC_EXT -#endif - -#if !defined(SIMDE_ENABLE_OPENMP) && \ - ((defined(_OPENMP) && (_OPENMP >= 201307L)) || \ - (defined(_OPENMP_SIMD) && (_OPENMP_SIMD >= 201307L))) -#define SIMDE_ENABLE_OPENMP -#endif - -#if !defined(SIMDE_ENABLE_CILKPLUS) && defined(__cilk) -#define SIMDE_ENABLE_CILKPLUS -#endif - -#if defined(SIMDE_ENABLE_OPENMP) -#define SIMDE__VECTORIZE _Pragma("omp simd") -#define SIMDE__VECTORIZE_SAFELEN(l) HEDLEY_PRAGMA(omp simd safelen(l)) -#define SIMDE__VECTORIZE_REDUCTION(r) HEDLEY_PRAGMA(omp simd reduction(r)) -#define SIMDE__VECTORIZE_ALIGNED(a) HEDLEY_PRAGMA(omp simd aligned(a)) -#elif defined(SIMDE_ENABLE_CILKPLUS) -#define SIMDE__VECTORIZE _Pragma("simd") -#define SIMDE__VECTORIZE_SAFELEN(l) HEDLEY_PRAGMA(simd vectorlength(l)) -#define SIMDE__VECTORIZE_REDUCTION(r) HEDLEY_PRAGMA(simd reduction(r)) -#define SIMDE__VECTORIZE_ALIGNED(a) HEDLEY_PRAGMA(simd aligned(a)) -#elif defined(__INTEL_COMPILER) -#define SIMDE__VECTORIZE _Pragma("simd") -#define SIMDE__VECTORIZE_SAFELEN(l) HEDLEY_PRAGMA(simd vectorlength(l)) -#define SIMDE__VECTORIZE_REDUCTION(r) HEDLEY_PRAGMA(simd reduction(r)) -#define SIMDE__VECTORIZE_ALIGNED(a) -#elif defined(__clang__) -#define SIMDE__VECTORIZE _Pragma("clang loop vectorize(enable)") -#define SIMDE__VECTORIZE_SAFELEN(l) HEDLEY_PRAGMA(clang loop vectorize_width(l)) -#define SIMDE__VECTORIZE_REDUCTION(r) SIMDE__VECTORIZE -#define SIMDE__VECTORIZE_ALIGNED(a) -#elif HEDLEY_GCC_VERSION_CHECK(4, 9, 0) -#define SIMDE__VECTORIZE _Pragma("GCC ivdep") -#define SIMDE__VECTORIZE_SAFELEN(l) SIMDE__VECTORIZE -#define SIMDE__VECTORIZE_REDUCTION(r) SIMDE__VECTORIZE -#define SIMDE__VECTORIZE_ALIGNED(a) -#elif HEDLEY_CRAY_VERSION_CHECK(5, 0, 0) -#define SIMDE__VECTORIZE _Pragma("_CRI ivdep") -#define SIMDE__VECTORIZE_SAFELEN(l) SIMDE__VECTORIZE -#define SIMDE__VECTORIZE_REDUCTION(r) SIMDE__VECTORIZE -#define SIMDE__VECTORIZE_ALIGNED(a) -#else -#define SIMDE__VECTORIZE -#define SIMDE__VECTORIZE_SAFELEN(l) -#define SIMDE__VECTORIZE_REDUCTION(r) -#define SIMDE__VECTORIZE_ALIGNED(a) -#endif - -#if HEDLEY_GCC_HAS_ATTRIBUTE(unused, 3, 1, 0) -#define SIMDE__UNUSED __attribute__((__unused__)) -#else -#define SIMDE__UNUSED -#endif - -#if HEDLEY_GCC_HAS_ATTRIBUTE(artificial, 4, 3, 0) -#define SIMDE__ARTIFICIAL __attribute__((__artificial__)) -#else -#define SIMDE__ARTIFICIAL -#endif - -/* Intended for checking coverage, you should never use this in - production. */ -#if defined(SIMDE_NO_INLINE) -#define SIMDE__FUNCTION_ATTRIBUTES HEDLEY_NEVER_INLINE SIMDE__UNUSED static -#else -#define SIMDE__FUNCTION_ATTRIBUTES HEDLEY_INLINE SIMDE__ARTIFICIAL static -#endif - -#if defined(_MSC_VER) -#define SIMDE__BEGIN_DECLS \ - HEDLEY_DIAGNOSTIC_PUSH __pragma(warning(disable : 4996 4204)) \ - HEDLEY_BEGIN_C_DECLS -#define SIMDE__END_DECLS HEDLEY_DIAGNOSTIC_POP HEDLEY_END_C_DECLS -#else -#define SIMDE__BEGIN_DECLS HEDLEY_BEGIN_C_DECLS -#define SIMDE__END_DECLS HEDLEY_END_C_DECLS -#endif - -#if defined(__SIZEOF_INT128__) -#define SIMDE__HAVE_INT128 -typedef __int128 simde_int128; -typedef unsigned __int128 simde_uint128; -#endif - -/* TODO: we should at least make an attempt to detect the correct - types for simde_float32/float64 instead of just assuming float and - double. */ - -#if !defined(SIMDE_FLOAT32_TYPE) -#define SIMDE_FLOAT32_TYPE float -#define SIMDE_FLOAT32_C(value) value##f -#else -#define SIMDE_FLOAT32_C(value) ((SIMDE_FLOAT32_TYPE)value) -#endif -typedef SIMDE_FLOAT32_TYPE simde_float32; -HEDLEY_STATIC_ASSERT(sizeof(simde_float32) == 4, - "Unable to find 32-bit floating-point type."); - -#if !defined(SIMDE_FLOAT64_TYPE) -#define SIMDE_FLOAT64_TYPE double -#define SIMDE_FLOAT64_C(value) value -#else -#define SIMDE_FLOAT32_C(value) ((SIMDE_FLOAT64_TYPE)value) -#endif -typedef SIMDE_FLOAT64_TYPE simde_float64; -HEDLEY_STATIC_ASSERT(sizeof(simde_float64) == 8, - "Unable to find 64-bit floating-point type."); - -/* Whether to assume that the compiler can auto-vectorize reasonably - well. This will cause SIMDe to attempt to compose vector - operations using more simple vector operations instead of minimize - serial work. - - As an example, consider the _mm_add_ss(a, b) function from SSE, - which returns { a0 + b0, a1, a2, a3 }. This pattern is repeated - for other operations (sub, mul, etc.). - - The naïve implementation would result in loading a0 and b0, adding - them into a temporary variable, then splicing that value into a new - vector with the remaining elements from a. - - On platforms which support vectorization, it's generally faster to - simply perform the operation on the entire vector to avoid having - to move data between SIMD registers and non-SIMD registers. - Basically, instead of the temporary variable being (a0 + b0) it - would be a vector of (a + b), which is then combined with a to form - the result. - - By default, SIMDe will prefer the pure-vector versions if we detect - a vector ISA extension, but this can be overridden by defining - SIMDE_NO_ASSUME_VECTORIZATION. You can also define - SIMDE_ASSUME_VECTORIZATION if you want to force SIMDe to use the - vectorized version. */ -#if !defined(SIMDE_NO_ASSUME_VECTORIZATION) && \ - !defined(SIMDE_ASSUME_VECTORIZATION) -#if defined(__SSE__) || defined(__ARM_NEON) || defined(__mips_msa) || \ - defined(__ALTIVEC__) -#define SIMDE_ASSUME_VECTORIZATION -#endif -#endif - -/* GCC and clang have built-in functions to handle shuffling of - vectors, but the implementations are slightly different. This - macro is just an abstraction over them. Note that elem_size is in - bits but vec_size is in bytes. */ -#if HEDLEY_CLANG_HAS_BUILTIN(__builtin_shufflevector) -#define SIMDE__SHUFFLE_VECTOR(elem_size, vec_size, a, b, ...) \ - __builtin_shufflevector(a, b, __VA_ARGS__) -#elif HEDLEY_GCC_HAS_BUILTIN(__builtin_shuffle, 4, 7, 0) && \ - !defined(__INTEL_COMPILER) -#define SIMDE__SHUFFLE_VECTOR(elem_size, vec_size, a, b, ...) \ - __builtin_shuffle(a, b, \ - (int##elem_size##_t __attribute__( \ - (__vector_size__(vec_size)))){__VA_ARGS__}) -#endif - -/* Some algorithms are iterative, and fewer iterations means less - accuracy. Lower values here will result in faster, but less - accurate, calculations for some functions. */ -#if !defined(SIMDE_ACCURACY_ITERS) -#define SIMDE_ACCURACY_ITERS 2 -#endif - -/* This will probably move into Hedley at some point, but I'd like to - more thoroughly check for other compilers which define __GNUC__ - first. */ -#if defined(SIMDE__REALLY_GCC) -#undef SIMDE__REALLY_GCC -#endif -#if !defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) -#define SIMDE__REALLY_GCC 0 -#else -#define SIMDE__REALLY_GCC 1 -#endif - -#if defined(SIMDE__ASSUME_ALIGNED) -#undef SIMDE__ASSUME_ALIGNED -#endif -#if HEDLEY_INTEL_VERSION_CHECK(9, 0, 0) -#define SIMDE__ASSUME_ALIGNED(ptr, align) __assume_aligned(ptr, align) -#elif HEDLEY_MSVC_VERSION_CHECK(13, 10, 0) -#define SIMDE__ASSUME_ALIGNED(ptr, align) \ - __assume((((char *)ptr) - ((char *)0)) % (align) == 0) -#elif HEDLEY_GCC_HAS_BUILTIN(__builtin_assume_aligned, 4, 7, 0) -#define SIMDE__ASSUME_ALIGNED(ptr, align) \ - (ptr = (__typeof__(ptr))__builtin_assume_aligned((ptr), align)) -#elif HEDLEY_CLANG_HAS_BUILTIN(__builtin_assume) -#define SIMDE__ASSUME_ALIGNED(ptr, align) \ - __builtin_assume((((char *)ptr) - ((char *)0)) % (align) == 0) -#elif HEDLEY_GCC_HAS_BUILTIN(__builtin_unreachable, 4, 5, 0) -#define SIMDE__ASSUME_ALIGNED(ptr, align) \ - ((((char *)ptr) - ((char *)0)) % (align) == 0) \ - ? (1) \ - : (__builtin_unreachable(), 0) -#else -#define SIMDE__ASSUME_ALIGNED(ptr, align) -#endif - -/* Sometimes we run into problems with specific versions of compilers - which make the native versions unusable for us. Often this is due - to missing functions, sometimes buggy implementations, etc. These - macros are how we check for specific bugs. As they are fixed we'll - start only defining them for problematic compiler versions. */ - -#if !defined(SIMDE_IGNORE_COMPILER_BUGS) -#if SIMDE__REALLY_GCC -#if !HEDLEY_GCC_VERSION_CHECK(4, 9, 0) -#define SIMDE_BUG_GCC_REV_208793 -#endif -#if !HEDLEY_GCC_VERSION_CHECK(5, 0, 0) -#define SIMDE_BUG_GCC_BAD_MM_SRA_EPI32 /* TODO: find relevant bug or commit */ -#endif -#if !HEDLEY_GCC_VERSION_CHECK(4, 6, 0) -#define SIMDE_BUG_GCC_BAD_MM_EXTRACT_EPI8 /* TODO: find relevant bug or commit */ -#endif -#endif -#if defined(__EMSCRIPTEN__) -#define SIMDE_BUG_EMSCRIPTEN_MISSING_IMPL /* Placeholder for (as yet) unfiled issues. */ -#define SIMDE_BUG_EMSCRIPTEN_5242 -#endif -#endif - -#endif /* !defined(SIMDE_COMMON_H) */ diff --git a/libobs/util/simde/sse.h b/libobs/util/simde/sse.h deleted file mode 100644 index 6f07881..0000000 --- a/libobs/util/simde/sse.h +++ /dev/null @@ -1,2591 +0,0 @@ -/* Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Copyright: - * 2017 Evan Nemerson - * 2015-2017 John W. Ratcliff - * 2015 Brandon Rowlett - * 2015 Ken Fast - */ - -#if !defined(SIMDE__SSE_H) -#if !defined(SIMDE__SSE_H) -#define SIMDE__SSE_H -#endif -#include "mmx.h" - -#if defined(SIMDE_SSE_NATIVE) -#undef SIMDE_SSE_NATIVE -#endif -#if defined(SIMDE_SSE_FORCE_NATIVE) -#define SIMDE_SSE_NATIVE -#elif defined(__SSE__) && !defined(SIMDE_SSE_NO_NATIVE) && \ - !defined(SIMDE_NO_NATIVE) -#define SIMDE_SSE_NATIVE -#elif defined(__ARM_NEON) && !defined(SIMDE_SSE_NO_NEON) && \ - !defined(SIMDE_NO_NEON) -#define SIMDE_SSE_NEON -#endif - -#if defined(SIMDE_SSE_NATIVE) && !defined(SIMDE_MMX_NATIVE) -#if defined(SIMDE_SSE_FORCE_NATIVE) -#error Native SSE support requires native MMX support -#else -#warning Native SSE support requires native MMX support, disabling -#undef SIMDE_SSE_NATIVE -#endif -#elif defined(SIMDE_SSE_NEON) && !defined(SIMDE_MMX_NEON) -#warning SSE3 NEON support requires MMX NEON support, disabling -#undef SIMDE_SSE3_NEON -#endif - -#if defined(SIMDE_SSE_NATIVE) -#include -#else -#if defined(SIMDE_SSE_NEON) -#include -#endif - -#if !defined(__INTEL_COMPILER) && defined(__STDC_VERSION__) && \ - (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) -#include -#elif defined(_WIN32) -#include -#endif -#endif - -#include -#include - -#define SIMDE_ALIGN(alignment) __attribute__((aligned(alignment))) -SIMDE__BEGIN_DECLS - -typedef SIMDE_ALIGN(16) union { -#if defined(SIMDE__ENABLE_GCC_VEC_EXT) - int8_t i8 __attribute__((__vector_size__(16), __may_alias__)); - int16_t i16 __attribute__((__vector_size__(16), __may_alias__)); - int32_t i32 __attribute__((__vector_size__(16), __may_alias__)); - int64_t i64 __attribute__((__vector_size__(16), __may_alias__)); - uint8_t u8 __attribute__((__vector_size__(16), __may_alias__)); - uint16_t u16 __attribute__((__vector_size__(16), __may_alias__)); - uint32_t u32 __attribute__((__vector_size__(16), __may_alias__)); - uint64_t u64 __attribute__((__vector_size__(16), __may_alias__)); -#if defined(SIMDE__HAVE_INT128) - simde_int128 i128 __attribute__((__vector_size__(16), __may_alias__)); - simde_uint128 u128 __attribute__((__vector_size__(16), __may_alias__)); -#endif - simde_float32 f32 __attribute__((__vector_size__(16), __may_alias__)); -#else - int8_t i8[16]; - int16_t i16[8]; - int32_t i32[4]; - int64_t i64[2]; - uint8_t u8[16]; - uint16_t u16[8]; - uint32_t u32[4]; - uint64_t u64[2]; -#if defined(SIMDE__HAVE_INT128) - simde_int128 i128[1]; - simde_uint128 u128[1]; -#endif - simde_float32 f32[4]; -#endif - -#if defined(SIMDE_SSE_NATIVE) - __m128 n; -#elif defined(SIMDE_SSE_NEON) - int8x16_t neon_i8; - int16x8_t neon_i16; - int32x4_t neon_i32; - int64x2_t neon_i64; - uint8x16_t neon_u8; - uint16x8_t neon_u16; - uint32x4_t neon_u32; - uint64x2_t neon_u64; - float32x4_t neon_f32; -#endif -} simde__m128; - -#if defined(SIMDE_SSE_NATIVE) -HEDLEY_STATIC_ASSERT(sizeof(__m128) == sizeof(simde__m128), - "__m128 size doesn't match simde__m128 size"); -SIMDE__FUNCTION_ATTRIBUTES simde__m128 SIMDE__M128_C(__m128 v) -{ - simde__m128 r; - r.n = v; - return r; -} -#elif defined(SIMDE_SSE_NEON) -#define SIMDE__M128_NEON_C(T, expr) \ - (simde__m128) { .neon_##T = expr } -#endif -HEDLEY_STATIC_ASSERT(16 == sizeof(simde__m128), "simde__m128 size incorrect"); - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_add_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_add_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vaddq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = a.f32[i] + b.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_add_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_add_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32_t b0 = vgetq_lane_f32(b.neon_f32, 0); - float32x4_t value = vsetq_lane_f32(b0, vdupq_n_f32(0), 0); - /* the upper values in the result must be the remnants of . */ - r.neon_f32 = vaddq_f32(a.neon_f32, value); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR(32, 16, a.f32, simde_mm_add_ps(a, b).f32, - 4, 1, 2, 3); -#else - r.f32[0] = a.f32[0] + b.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_and_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_and_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_i32 = vandq_s32(a.neon_i32, b.neon_i32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = a.i32[i] & b.i32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_andnot_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_andnot_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_i32 = vbicq_s32(b.neon_i32, a.neon_i32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = ~(a.i32[i]) & b.i32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_avg_pu16(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_avg_pu16(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u16 = vrhadd_u16(b.neon_u16, a.neon_u16); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < 4; i++) { - r.u16[i] = (a.u16[i] + b.u16[i] + 1) >> 1; - } -#endif - - return r; -} -#define simde_m_pavgw(a, b) simde_mm_avg_pu16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_avg_pu8(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_avg_pu8(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u8 = vrhadd_u8(b.neon_u8, a.neon_u8); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < 8; i++) { - r.u8[i] = (a.u8[i] + b.u8[i] + 1) >> 1; - } -#endif - - return r; -} -#define simde_m_pavgb(a, b) simde_mm_avg_pu8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpeq_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpeq_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vceqq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = (a.f32[i] == b.f32[i]) ? 0xffffffff : 0; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpeq_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpeq_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t s = - vreinterpretq_f32_u32(vceqq_f32(a.neon_f32, b.neon_f32)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR(32, 16, a.f32, - simde_mm_cmpeq_ps(a, b).f32, 4, 1, 2, 3); -#else - r.u32[0] = (a.f32[0] == b.f32[0]) ? 0xffffffff : 0; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = a.u32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpge_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpge_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vcgeq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = (a.f32[i] >= b.f32[i]) ? 0xffffffff : 0; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpge_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) - r.n = _mm_cmpge_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t s = - vreinterpretq_f32_u32(vcgeq_f32(a.neon_f32, b.neon_f32)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR(32, 16, a.f32, - simde_mm_cmpge_ps(a, b).f32, 4, 1, 2, 3); -#else - r.u32[0] = (a.f32[0] >= b.f32[0]) ? 0xffffffff : 0; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = a.u32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpgt_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpgt_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vcgtq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = (a.f32[i] > b.f32[i]) ? 0xffffffff : 0; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpgt_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) - r.n = _mm_cmpgt_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t s = - vreinterpretq_f32_u32(vcgtq_f32(a.neon_f32, b.neon_f32)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR(32, 16, a.f32, - simde_mm_cmpgt_ps(a, b).f32, 4, 1, 2, 3); -#else - r.u32[0] = (a.f32[0] > b.f32[0]) ? 0xffffffff : 0; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = a.u32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmple_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmple_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vcleq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = (a.f32[i] <= b.f32[i]) ? 0xffffffff : 0; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmple_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmple_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t s = - vreinterpretq_f32_u32(vcleq_f32(a.neon_f32, b.neon_f32)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR(32, 16, a.f32, - simde_mm_cmple_ps(a, b).f32, 4, 1, 2, 3); -#else - r.u32[0] = (a.f32[0] <= b.f32[0]) ? 0xffffffff : 0; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = a.u32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmplt_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmplt_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vcltq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = (a.f32[i] < b.f32[i]) ? 0xffffffff : 0; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmplt_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmplt_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t s = - vreinterpretq_f32_u32(vcltq_f32(a.neon_f32, b.neon_f32)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR(32, 16, a.f32, - simde_mm_cmplt_ps(a, b).f32, 4, 1, 2, 3); -#else - r.u32[0] = (a.f32[0] < b.f32[0]) ? 0xffffffff : 0; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = a.u32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpneq_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpneq_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vmvnq_u32(vceqq_f32(a.neon_f32, b.neon_f32)); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = (a.f32[i] != b.f32[i]) ? 0xffffffff : 0; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpneq_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpneq_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t e = - vreinterpretq_f32_u32(vceqq_f32(a.neon_f32, b.neon_f32)); - float32x4_t s = - vreinterpretq_f32_u32(vmvnq_u32(vreinterpretq_u32_f32(e))); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR(32, 16, a.f32, - simde_mm_cmpneq_ps(a, b).f32, 4, 1, 2, 3); -#else - r.u32[0] = (a.f32[0] != b.f32[0]) ? 0xffffffff : 0; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = a.u32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpnge_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpnge_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vcltq_f32(a.neon_f32, b.neon_f32); -#else - r = simde_mm_cmplt_ps(a, b); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpnge_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) - r.n = _mm_cmpnge_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t s = - vreinterpretq_f32_u32(vcltq_f32(a.neon_f32, b.neon_f32)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#else - r = simde_mm_cmplt_ss(a, b); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpngt_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpngt_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vcleq_f32(a.neon_f32, b.neon_f32); -#else - r = simde_mm_cmple_ps(a, b); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpngt_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) - r.n = _mm_cmpngt_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t s = - vreinterpretq_f32_u32(vcleq_f32(a.neon_f32, b.neon_f32)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#else - r = simde_mm_cmple_ss(a, b); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpnle_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpnle_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vcgtq_f32(a.neon_f32, b.neon_f32); -#else - r = simde_mm_cmpgt_ps(a, b); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpnle_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpnle_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t s = - vreinterpretq_f32_u32(vcgtq_f32(a.neon_f32, b.neon_f32)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#else - r = simde_mm_cmpgt_ss(a, b); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpnlt_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpnlt_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_u32 = vcgeq_f32(a.neon_f32, b.neon_f32); -#else - r = simde_mm_cmpge_ps(a, b); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpnlt_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpnlt_ss(a.n, b.n); -#else - r = simde_mm_cmpge_ss(a, b); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpord_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpord_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - /* Note: NEON does not have ordered compare builtin - Need to compare a eq a and b eq b to check for NaN - Do AND of results to get final */ - uint32x4_t ceqaa = vceqq_f32(a.neon_f32, a.neon_f32); - uint32x4_t ceqbb = vceqq_f32(b.neon_f32, b.neon_f32); - r.neon_u32 = vandq_u32(ceqaa, ceqbb); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = (isnan(a.f32[i]) || isnan(b.f32[i])) ? 0 - : 0xffffffff; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpord_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpord_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - uint32x4_t ceqaa = vceqq_f32(a.neon_f32, a.neon_f32); - uint32x4_t ceqbb = vceqq_f32(b.neon_f32, b.neon_f32); - float32x4_t s = vreinterpretq_f32_u32(vandq_u32(ceqaa, ceqbb)); - float32x4_t t = vextq_f32(a.neon_f32, s, 1); - r.neon_f32 = vextq_f32(t, t, 3); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR(32, 16, a.f32, - simde_mm_cmpord_ps(a, b).f32, 4, 1, 2, 3); -#else - r.u32[0] = (isnan(a.f32[0]) || isnan(b.f32[0])) ? 0 : 0xffffffff; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = a.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpunord_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cmpunord_ps(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.u32[i] = (isnan(a.f32[i]) || isnan(b.f32[i])) ? 0xffffffff - : 0; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cmpunord_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) - r.n = _mm_cmpunord_ss(a.n, b.n); -#elif defined(SIMDE__SHUFFLE_VECTOR) && defined(SIMDE_ASSUME_VECTORIZATION) - r.f32 = SIMDE__SHUFFLE_VECTOR( - 32, 16, a.f32, simde_mm_cmpunord_ps(a, b).f32, 4, 1, 2, 3); -#else - r.u32[0] = (isnan(a.f32[0]) || isnan(b.f32[0])) ? 0xffffffff : 0; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = a.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comieq_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_comieq_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - uint32x4_t a_not_nan = vceqq_f32(a.neon_f32, a.neon_f32); - uint32x4_t b_not_nan = vceqq_f32(b.neon_f32, b.neon_f32); - uint32x4_t a_or_b_nan = vmvnq_u32(vandq_u32(a_not_nan, b_not_nan)); - uint32x4_t a_eq_b = vceqq_f32(a.neon_f32, b.neon_f32); - return (vgetq_lane_u32(vorrq_u32(a_or_b_nan, a_eq_b), 0) != 0) ? 1 : 0; -#else - return a.f32[0] == b.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comige_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_comige_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - uint32x4_t a_not_nan = vceqq_f32(a.neon_f32, a.neon_f32); - uint32x4_t b_not_nan = vceqq_f32(b.neon_f32, b.neon_f32); - uint32x4_t a_and_b_not_nan = vandq_u32(a_not_nan, b_not_nan); - uint32x4_t a_ge_b = vcgeq_f32(a.neon_f32, b.neon_f32); - return (vgetq_lane_u32(vandq_u32(a_and_b_not_nan, a_ge_b), 0) != 0) ? 1 - : 0; -#else - return a.f32[0] >= b.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comigt_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_comigt_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - uint32x4_t a_not_nan = vceqq_f32(a.neon_f32, a.neon_f32); - uint32x4_t b_not_nan = vceqq_f32(b.neon_f32, b.neon_f32); - uint32x4_t a_and_b_not_nan = vandq_u32(a_not_nan, b_not_nan); - uint32x4_t a_gt_b = vcgtq_f32(a.neon_f32, b.neon_f32); - return (vgetq_lane_u32(vandq_u32(a_and_b_not_nan, a_gt_b), 0) != 0) ? 1 - : 0; -#else - return a.f32[0] > b.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comile_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_comile_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - uint32x4_t a_not_nan = vceqq_f32(a.neon_f32, a.neon_f32); - uint32x4_t b_not_nan = vceqq_f32(b.neon_f32, b.neon_f32); - uint32x4_t a_or_b_nan = vmvnq_u32(vandq_u32(a_not_nan, b_not_nan)); - uint32x4_t a_le_b = vcleq_f32(a.neon_f32, b.neon_f32); - return (vgetq_lane_u32(vorrq_u32(a_or_b_nan, a_le_b), 0) != 0) ? 1 : 0; -#else - return a.f32[0] <= b.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comilt_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_comilt_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NATIVE) - uint32x4_t a_not_nan = vceqq_f32(a.neon_f32, a.neon_f32); - uint32x4_t b_not_nan = vceqq_f32(b.neon_f32, b.neon_f32); - uint32x4_t a_or_b_nan = vmvnq_u32(vandq_u32(a_not_nan, b_not_nan)); - uint32x4_t a_lt_b = vcltq_f32(a.neon_f32, b.neon_f32); - return (vgetq_lane_u32(vorrq_u32(a_or_b_nan, a_lt_b), 0) != 0) ? 1 : 0; -#else - return a.f32[0] < b.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comineq_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_comineq_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - uint32x4_t a_not_nan = vceqq_f32(a.neon_f32, a.neon_f32); - uint32x4_t b_not_nan = vceqq_f32(b.neon_f32, b.neon_f32); - uint32x4_t a_and_b_not_nan = vandq_u32(a_not_nan, b_not_nan); - uint32x4_t a_neq_b = vmvnq_u32(vceqq_f32(a.neon_f32, b.neon_f32)); - return (vgetq_lane_u32(vandq_u32(a_and_b_not_nan, a_neq_b), 0) != 0) - ? 1 - : 0; -#else - return a.f32[0] != b.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvt_pi2ps(simde__m128 a, simde__m64 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvt_pi2ps(a.n, b.n); -#else - r.f32[0] = (simde_float32)b.i32[0]; - r.f32[1] = (simde_float32)b.i32[1]; - r.i32[2] = a.i32[2]; - r.i32[3] = a.i32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvt_ps2pi(simde__m128 a) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvt_ps2pi(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (int32_t)a.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvt_si2ss(simde__m128 a, int32_t b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvt_si2ss(a.n, b); -#else - r.f32[0] = (simde_float32)b; - r.i32[1] = a.i32[1]; - r.i32[2] = a.i32[2]; - r.i32[3] = a.i32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvt_ss2si(simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_cvt_ss2si(a.n); -#else - return (int32_t)a.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtpi16_ps(simde__m64 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtpi16_ps(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = (simde_float32)a.i16[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtpi32_ps(simde__m128 a, simde__m64 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtpi32_ps(a.n, b.n); -#else - r.f32[0] = (simde_float32)b.i32[0]; - r.f32[1] = (simde_float32)b.i32[1]; - r.i32[2] = a.i32[2]; - r.i32[3] = a.i32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtpi32x2_ps(simde__m64 a, simde__m64 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtpi32x2_ps(a.n, b.n); -#else - r.f32[0] = (simde_float32)a.i32[0]; - r.f32[1] = (simde_float32)a.i32[1]; - r.f32[2] = (simde_float32)b.i32[0]; - r.f32[3] = (simde_float32)b.i32[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtpi8_ps(simde__m64 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtpi8_ps(a.n); -#else - r.f32[0] = (simde_float32)a.i8[0]; - r.f32[1] = (simde_float32)a.i8[1]; - r.f32[2] = (simde_float32)a.i8[2]; - r.f32[3] = (simde_float32)a.i8[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvtps_pi16(simde__m128 a) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtps_pi16(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = (int16_t)a.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvtps_pi32(simde__m128 a) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtps_pi32(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (int32_t)a.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvtps_pi8(simde__m128 a) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtps_pi8(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(a.f32) / sizeof(a.f32[0])); i++) { - r.i8[i] = (int8_t)a.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtpu16_ps(simde__m64 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtpu16_ps(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = (simde_float32)a.u16[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtpu8_ps(simde__m64 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtpu8_ps(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < 4; i++) { - r.f32[i] = (simde_float32)a.u8[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtsi32_ss(simde__m128 a, int32_t b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtsi32_ss(a.n, b); -#else - r.f32[0] = (simde_float32)b; - SIMDE__VECTORIZE - for (size_t i = 1; i < 4; i++) { - r.i32[i] = a.i32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtsi64_ss(simde__m128 a, int64_t b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if !defined(__PGI) - r.n = _mm_cvtsi64_ss(a.n, b); -#else - r.n = _mm_cvtsi64x_ss(a.n, b); -#endif -#else - r.f32[0] = (simde_float32)b; - SIMDE__VECTORIZE - for (size_t i = 1; i < 4; i++) { - r.i32[i] = a.i32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde_float32 simde_mm_cvtss_f32(simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_cvtss_f32(a.n); -#elif defined(SIMDE_SSE_NEON) - return vgetq_lane_f32(a.neon_f32, 0); -#else - return a.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvtss_si32(simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_cvtss_si32(a.n); -#else - return (int32_t)a.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int64_t simde_mm_cvtss_si64(simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if !defined(__PGI) - return _mm_cvtss_si64(a.n); -#else - return _mm_cvtss_si64x(a.n); -#endif -#else - return (int64_t)a.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvtt_ps2pi(simde__m128 a) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvtt_ps2pi(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.i32[i] = (int32_t)truncf(a.f32[i]); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvtt_ss2si(simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_cvtt_ss2si(a.n); -#else - return (int32_t)truncf(a.f32[0]); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvttps_pi32(simde__m128 a) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_cvttps_pi32(a.n); -#else - r = simde_mm_cvtt_ps2pi(a); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvttss_si32(simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_cvttss_si32(a.n); -#else - return (int32_t)truncf(a.f32[0]); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int64_t simde_mm_cvttss_si64(simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if defined(__PGI) - return _mm_cvttss_si64x(a.n); -#else - return _mm_cvttss_si64(a.n); -#endif -#else - return (int64_t)truncf(a.f32[0]); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_div_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_div_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t recip0 = vrecpeq_f32(b.neon_f32); - float32x4_t recip1 = vmulq_f32(recip0, vrecpsq_f32(recip0, b.neon_f32)); - r.neon_f32 = vmulq_f32(a.neon_f32, recip1); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = a.f32[i] / b.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_div_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_div_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32_t value = vgetq_lane_f32(simde_mm_div_ps(a, b).neon_f32, 0); - r.neon_f32 = vsetq_lane_f32(value, a.neon_f32, 0); -#else - r.f32[0] = a.f32[0] / b.f32[0]; - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = a.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_extract_pi16(simde__m64 a, const int imm8) -{ - return a.u16[imm8]; -} -#if defined(SIMDE_SSE_NATIVE) -#define simde_mm_extract_pi16(a, imm8) _mm_extract_pi16(a.n, imm8) -#endif -#define simde_m_pextrw(a, imm8) simde_mm_extract_pi16(a.n, imm8) - -enum { -#if defined(SIMDE_SSE_NATIVE) - simde_MM_ROUND_NEAREST = _MM_ROUND_NEAREST, - simde_MM_ROUND_DOWN = _MM_ROUND_DOWN, - simde_MM_ROUND_UP = _MM_ROUND_UP, - simde_MM_ROUND_TOWARD_ZERO = _MM_ROUND_TOWARD_ZERO -#else - simde_MM_ROUND_NEAREST -#if defined(FE_TONEAREST) - = FE_TONEAREST -#endif - , - - simde_MM_ROUND_DOWN -#if defined(FE_DOWNWARD) - = FE_DOWNWARD -#endif - , - - simde_MM_ROUND_UP -#if defined(FE_UPWARD) - = FE_UPWARD -#endif - , - - simde_MM_ROUND_TOWARD_ZERO -#if defined(FE_TOWARDZERO) - = FE_TOWARDZERO -#endif -#endif -}; - -SIMDE__FUNCTION_ATTRIBUTES -unsigned int simde_MM_GET_ROUNDING_MODE(void) -{ -#if defined(SIMDE_SSE_NATIVE) - return _MM_GET_ROUNDING_MODE(); -#else - return fegetround(); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_MM_SET_ROUNDING_MODE(unsigned int a) -{ -#if defined(SIMDE_SSE_NATIVE) - _MM_SET_ROUNDING_MODE(a); -#else - fesetround((int)a); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_insert_pi16(simde__m64 a, int16_t i, const int imm8) -{ - simde__m64 r; - r.i64[0] = a.i64[0]; - r.i16[imm8] = i; - return r; -} -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) -#define simde_mm_insert_pi16(a, i, imm8) \ - SIMDE__M64_C(_mm_insert_pi16((a).n, i, imm8)); -#endif -#define simde_m_pinsrw(a, i, imm8) \ - SIMDE__M64_C(simde_mm_insert_pi16((a).n, i, imm8)); - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 -simde_mm_load_ps(simde_float32 const mem_addr[HEDLEY_ARRAY_PARAM(4)]) -{ - simde__m128 r; - - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_load_ps(mem_addr); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vld1q_f32(mem_addr); -#else - memcpy(&r, mem_addr, sizeof(r.f32)); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_load_ps1(simde_float32 const *mem_addr) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_load_ps1(mem_addr); -#else - const simde_float32 v = *mem_addr; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.f32[i] = v; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_load_ss(simde_float32 const *mem_addr) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_load_ss(mem_addr); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vsetq_lane_f32(*mem_addr, vdupq_n_f32(0), 0); -#else - r.f32[0] = *mem_addr; - r.i32[1] = 0; - r.i32[2] = 0; - r.i32[3] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_load1_ps(simde_float32 const *mem_addr) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_load1_ps(mem_addr); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vld1q_dup_f32(mem_addr); -#else - r = simde_mm_load_ps1(mem_addr); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_loadh_pi(simde__m128 a, simde__m64 const *mem_addr) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_loadh_pi(a.n, (__m64 *)mem_addr); -#else - r.f32[0] = a.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = mem_addr->f32[0]; - r.f32[3] = mem_addr->f32[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_loadl_pi(simde__m128 a, simde__m64 const *mem_addr) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_loadl_pi(a.n, (__m64 *)mem_addr); -#else - r.f32[0] = mem_addr->f32[0]; - r.f32[1] = mem_addr->f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 -simde_mm_loadr_ps(simde_float32 const mem_addr[HEDLEY_ARRAY_PARAM(4)]) -{ - simde__m128 r; - - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_loadr_ps(mem_addr); -#else - r.f32[0] = mem_addr[3]; - r.f32[1] = mem_addr[2]; - r.f32[2] = mem_addr[1]; - r.f32[3] = mem_addr[0]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 -simde_mm_loadu_ps(simde_float32 const mem_addr[HEDLEY_ARRAY_PARAM(4)]) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_loadu_ps(mem_addr); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vld1q_f32(mem_addr); -#else - r.f32[0] = mem_addr[0]; - r.f32[1] = mem_addr[1]; - r.f32[2] = mem_addr[2]; - r.f32[3] = mem_addr[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_maskmove_si64(simde__m64 a, simde__m64 mask, char *mem_addr) -{ -#if defined(SIMDE_SSE_NATIVE) - _mm_maskmove_si64(a.n, mask.n, mem_addr); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(a.i8) / sizeof(a.i8[0])); i++) - if (mask.i8[i] < 0) - mem_addr[i] = a.i8[i]; -#endif -} -#define simde_m_maskmovq(a, mask, mem_addr) \ - simde_mm_maskmove_si64(a, mask, mem_addr) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_max_pi16(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_max_pi16(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = (a.i16[i] > b.i16[i]) ? a.i16[i] : b.i16[i]; - } -#endif - - return r; -} -#define simde_m_pmaxsw(a, b) simde_mm_max_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_max_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_max_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vmaxq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = (a.f32[i] > b.f32[i]) ? a.f32[i] : b.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_max_pu8(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_max_pu8(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u8) / sizeof(r.u8[0])); i++) { - r.u8[i] = (a.u8[i] > b.u8[i]) ? a.u8[i] : b.u8[i]; - } -#endif - - return r; -} -#define simde_m_pmaxub(a, b) simde_mm_max_pu8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_max_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_max_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32_t value = vgetq_lane_f32(vmaxq_f32(a.neon_f32, b.neon_f32), 0); - r.neon_f32 = vsetq_lane_f32(value, a.neon_f32, 0); -#else - r.f32[0] = (a.f32[0] > b.f32[0]) ? a.f32[0] : b.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_min_pi16(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_min_pi16(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = (a.i16[i] < b.i16[i]) ? a.i16[i] : b.i16[i]; - } -#endif - - return r; -} -#define simde_m_pminsw(a, b) simde_mm_min_pi16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_min_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_min_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vminq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = (a.f32[i] < b.f32[i]) ? a.f32[i] : b.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_min_pu8(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_min_pu8(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u8) / sizeof(r.u8[0])); i++) { - r.u8[i] = (a.u8[i] < b.u8[i]) ? a.u8[i] : b.u8[i]; - } -#endif - - return r; -} -#define simde_m_pminub(a, b) simde_mm_min_pu8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_min_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_min_ss(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32_t value = vgetq_lane_f32(vminq_f32(a.neon_f32, b.neon_f32), 0); - r.neon_f32 = vsetq_lane_f32(value, a.neon_f32, 0); -#else - r.f32[0] = (a.f32[0] < b.f32[0]) ? a.f32[0] : b.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_move_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_move_ss(a.n, b.n); -#else - r.f32[0] = b.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_movehl_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_movehl_ps(a.n, b.n); -#else - r.f32[0] = b.f32[2]; - r.f32[1] = b.f32[3]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_movelh_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_movelh_ps(a.n, b.n); -#else - r.f32[0] = a.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = b.f32[0]; - r.f32[3] = b.f32[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_movemask_pi8(simde__m64 a) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_movemask_pi8(a.n); -#else - int r = 0; - const size_t nmemb = sizeof(a.i8) / sizeof(a.i8[0]); - - SIMDE__VECTORIZE_REDUCTION(| : r) - for (size_t i = 0; i < nmemb; i++) { - r |= (a.u8[nmemb - 1 - i] >> 7) << (nmemb - 1 - i); - } - - return r; -#endif -} -#define simde_m_pmovmskb(a, b) simde_mm_movemask_pi8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_movemask_ps(simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_movemask_ps(a.n); -#elif defined(SIMDE_SSE_NEON) - /* TODO: check to see if NEON version is faster than the portable version */ - static const uint32x4_t movemask = {1, 2, 4, 8}; - static const uint32x4_t highbit = {0x80000000, 0x80000000, 0x80000000, - 0x80000000}; - uint32x4_t t0 = a.neon_u32; - uint32x4_t t1 = vtstq_u32(t0, highbit); - uint32x4_t t2 = vandq_u32(t1, movemask); - uint32x2_t t3 = vorr_u32(vget_low_u32(t2), vget_high_u32(t2)); - return vget_lane_u32(t3, 0) | vget_lane_u32(t3, 1); -#else - int r = 0; - - SIMDE__VECTORIZE_REDUCTION(| : r) - for (size_t i = 0; i < sizeof(a.u32) / sizeof(a.u32[0]); i++) { - r |= (a.u32[i] >> ((sizeof(a.u32[i]) * CHAR_BIT) - 1)) << i; - } - - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_mul_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_mul_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vmulq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = a.f32[i] * b.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_mul_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_mul_ss(a.n, b.n); -#else - r.f32[0] = a.f32[0] * b.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_mulhi_pu16(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_mulhi_pu16(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u16) / sizeof(r.u16[0])); i++) { - r.u16[i] = (a.u16[i] * b.u16[i]) >> 16; - } -#endif - - return r; -} -#define simde_m_pmulhuw(a, b) simde_mm_mulhi_pu16(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_or_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_or_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_i32 = vorrq_s32(a.neon_i32, b.neon_i32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u32) / sizeof(r.u32[0])); i++) { - r.u32[i] = a.u32[i] | b.u32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_prefetch(char const *p, int i) -{ - (void)p; - (void)i; -} -#if defined(SIMDE_SSE_NATIVE) -#define simde_mm_prefetch(p, i) _mm_prefetch(p, i) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_rcp_ps(simde__m128 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_rcp_ps(a.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t recip = vrecpeq_f32(a.neon_f32); - -#if !defined(SIMDE_MM_RCP_PS_ITERS) -#define SIMDE_MM_RCP_PS_ITERS SIMDE_ACCURACY_ITERS -#endif - - for (int i = 0; i < SIMDE_MM_RCP_PS_ITERS; ++i) { - recip = vmulq_f32(recip, vrecpsq_f32(recip, a.neon_f32)); - } - - r.neon_f32 = recip; -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = 1.0f / a.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_rcp_ss(simde__m128 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_rcp_ss(a.n); -#else - r.f32[0] = 1.0f / a.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_rsqrt_ps(simde__m128 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_rsqrt_ps(a.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vrsqrteq_f32(a.neon_f32); -#elif defined(__STDC_IEC_559__) - /* http://h14s.p5r.org/2012/09/0x5f3759df.html?mwh=1 */ - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.i32[i] = INT32_C(0x5f3759df) - (a.i32[i] >> 1); - -#if SIMDE_ACCURACY_ITERS > 2 - const float half = SIMDE_FLOAT32_C(0.5) * a.f32[i]; - for (int ai = 2; ai < SIMDE_ACCURACY_ITERS; ai++) - r.f32[i] *= SIMDE_FLOAT32_C(1.5) - - (half * r.f32[i] * r.f32[i]); -#endif - } -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = 1.0f / sqrtf(a.f32[i]); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_rsqrt_ss(simde__m128 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_rsqrt_ss(a.n); -#elif defined(__STDC_IEC_559__) - { - r.i32[0] = INT32_C(0x5f3759df) - (a.i32[0] >> 1); - -#if SIMDE_ACCURACY_ITERS > 2 - float half = SIMDE_FLOAT32_C(0.5) * a.f32[0]; - for (int ai = 2; ai < SIMDE_ACCURACY_ITERS; ai++) - r.f32[0] *= SIMDE_FLOAT32_C(1.5) - - (half * r.f32[0] * r.f32[0]); -#endif - } - r.f32[0] = 1.0f / sqrtf(a.f32[0]); - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#else - r.f32[0] = 1.0f / sqrtf(a.f32[0]); - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sad_pu8(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_sad_pu8(a.n, b.n); -#else - uint16_t sum = 0; - - SIMDE__VECTORIZE_REDUCTION(+ : sum) - for (size_t i = 0; i < (sizeof(r.u8) / sizeof(r.u8[0])); i++) { - sum += (uint8_t)abs(a.u8[i] - b.u8[i]); - } - - r.i16[0] = sum; - r.i16[1] = 0; - r.i16[2] = 0; - r.i16[3] = 0; -#endif - - return r; -} -#define simde_m_psadbw(a, b) simde_mm_sad_pu8(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_set_ps(simde_float32 e3, simde_float32 e2, - simde_float32 e1, simde_float32 e0) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_set_ps(e3, e2, e1, e0); -#elif defined(SIMDE_SSE_NEON) - SIMDE_ALIGN(16) simde_float32 data[4] = {e0, e1, e2, e3}; - r.neon_f32 = vld1q_f32(data); -#else - r.f32[0] = e0; - r.f32[1] = e1; - r.f32[2] = e2; - r.f32[3] = e3; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_set_ps1(simde_float32 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_set1_ps(a); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vdupq_n_f32(a); -#else - r = simde_mm_set_ps(a, a, a, a); -#endif - - return r; -} -#define simde_mm_set1_ps(a) simde_mm_set_ps1(a) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_set_ss(simde_float32 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_set_ss(a); -#else - r = simde_mm_set_ps(0, 0, 0, a); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_setr_ps(simde_float32 e3, simde_float32 e2, - simde_float32 e1, simde_float32 e0) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_setr_ps(e3, e2, e1, e0); -#elif defined(SIMDE_SSE_NEON) - SIMDE_ALIGN(16) simde_float32 data[4] = {e3, e2, e1, e0}; - r.neon_f32 = vld1q_f32(data); -#else - r = simde_mm_set_ps(e0, e1, e2, e3); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_setzero_ps(void) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_setzero_ps(); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vdupq_n_f32(0.0f); -#else - r = simde_mm_set_ps(0.0f, 0.0f, 0.0f, 0.0f); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_sfence(void) -{ - /* TODO: Use Hedley. */ -#if defined(SIMDE_SSE_NATIVE) - _mm_sfence(); -#elif defined(__GNUC__) && \ - ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) - __atomic_thread_fence(__ATOMIC_SEQ_CST); -#elif !defined(__INTEL_COMPILER) && defined(__STDC_VERSION__) && \ - (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) -#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ < 9) - __atomic_thread_fence(__ATOMIC_SEQ_CST); -#else - atomic_thread_fence(memory_order_seq_cst); -#endif -#elif defined(_MSC_VER) - MemoryBarrier(); -#elif defined(__GNUC__) && \ - ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)) - __atomic_thread_fence(__ATOMIC_SEQ_CST); -#elif HEDLEY_CLANG_HAS_FEATURE(c_atomic) - __c11_atomic_thread_fence(__ATOMIC_SEQ_CST) -#elif defined(__GNUC__) && \ - ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 1)) - __sync_synchronize(); -#elif (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x5140)) || \ - (defined(__SUNPRO_CC) && (__SUNPRO_CC >= 0x5140)) - __atomic_thread_fence(__ATOMIC_SEQ_CST); -#elif defined(_OPENMP) -#pragma omp critical(simde_mm_sfence_) - { - } -#endif -} - -#define SIMDE_MM_SHUFFLE(z, y, x, w) \ - (((z) << 6) | ((y) << 4) | ((x) << 2) | (w)) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_shuffle_pi16(simde__m64 a, const int imm8) -{ - simde__m64 r; - for (size_t i = 0; i < sizeof(r.u16) / sizeof(r.u16[0]); i++) { - r.i16[i] = a.i16[(imm8 >> (i * 2)) & 3]; - } - return r; -} -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) -#define simde_mm_shuffle_pi16(a, imm8) SIMDE__M64_C(_mm_shuffle_pi16(a.n, imm8)) -#elif defined(SIMDE__SHUFFLE_VECTOR) -#define simde_mm_shuffle_pi16(a, imm8) \ - ({ \ - const simde__m64 simde__tmp_a_ = a; \ - (simde__m64){.i16 = SIMDE__SHUFFLE_VECTOR( \ - 16, 8, (simde__tmp_a_).i16, \ - (simde__tmp_a_).i16, (((imm8)) & 3), \ - (((imm8) >> 2) & 3), (((imm8) >> 4) & 3), \ - (((imm8) >> 6) & 3))}; \ - }) -#endif - -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) -#define simde_m_pshufw(a, imm8) SIMDE__M64_C(_m_pshufw(a.n, imm8)) -#else -#define simde_m_pshufw(a, imm8) simde_mm_shuffle_pi16(a, imm8) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_shuffle_ps(simde__m128 a, simde__m128 b, const int imm8) -{ - simde__m128 r; - r.f32[0] = a.f32[(imm8 >> 0) & 3]; - r.f32[1] = a.f32[(imm8 >> 2) & 3]; - r.f32[2] = b.f32[(imm8 >> 4) & 3]; - r.f32[3] = b.f32[(imm8 >> 6) & 3]; - return r; -} -#if defined(SIMDE_SSE_NATIVE) && !defined(__PGI) -#define simde_mm_shuffle_ps(a, b, imm8) \ - SIMDE__M128_C(_mm_shuffle_ps(a.n, b.n, imm8)) -#elif defined(SIMDE__SHUFFLE_VECTOR) -#define simde_mm_shuffle_ps(a, b, imm8) \ - ({ \ - (simde__m128){.f32 = SIMDE__SHUFFLE_VECTOR( \ - 32, 16, (a).f32, (b).f32, \ - (((imm8)) & 3), (((imm8) >> 2) & 3), \ - (((imm8) >> 4) & 3) + 4, \ - (((imm8) >> 6) & 3) + 4)}; \ - }) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_sqrt_ps(simde__m128 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_sqrt_ps(a.n); -#elif defined(SIMDE_SSE_NEON) - float32x4_t recipsq = vrsqrteq_f32(a.neon_f32); - float32x4_t sq = vrecpeq_f32(recipsq); - /* ??? use step versions of both sqrt and recip for better accuracy? */ - r.neon_f32 = sq; -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < sizeof(r.f32) / sizeof(r.f32[0]); i++) { - r.f32[i] = sqrtf(a.f32[i]); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_sqrt_ss(simde__m128 a) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_sqrt_ss(a.n); -#elif defined(SIMDE_SSE_NEON) - float32_t value = vgetq_lane_f32(simde_mm_sqrt_ps(a).neon_f32, 0); - r.neon_f32 = vsetq_lane_f32(value, a.neon_f32, 0); -#else - r.f32[0] = sqrtf(a.f32[0]); - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_store_ps(simde_float32 mem_addr[4], simde__m128 a) -{ - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE_NATIVE) - _mm_store_ps(mem_addr, a.n); -#elif defined(SIMDE_SSE_NEON) - vst1q_f32(mem_addr, a.neon_f32); -#else - SIMDE__VECTORIZE_ALIGNED(mem_addr : 16) - for (size_t i = 0; i < sizeof(a.f32) / sizeof(a.f32[0]); i++) { - mem_addr[i] = a.f32[i]; - } -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_store_ps1(simde_float32 mem_addr[4], simde__m128 a) -{ - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE_NATIVE) - _mm_store_ps1(mem_addr, a.n); -#else - SIMDE__VECTORIZE_ALIGNED(mem_addr : 16) - for (size_t i = 0; i < sizeof(a.f32) / sizeof(a.f32[0]); i++) { - mem_addr[i] = a.f32[0]; - } -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_store_ss(simde_float32 *mem_addr, simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - _mm_store_ss(mem_addr, a.n); -#elif defined(SIMDE_SSE_NEON) - vst1q_lane_f32(mem_addr, a.neon_f32, 0); -#else - *mem_addr = a.f32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_store1_ps(simde_float32 mem_addr[4], simde__m128 a) -{ - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE_NATIVE) - _mm_store1_ps(mem_addr, a.n); -#else - simde_mm_store_ps1(mem_addr, a); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storeh_pi(simde__m64 *mem_addr, simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - _mm_storeh_pi(&(mem_addr->n), a.n); -#else - mem_addr->f32[0] = a.f32[2]; - mem_addr->f32[1] = a.f32[3]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storel_pi(simde__m64 *mem_addr, simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - _mm_storel_pi(&(mem_addr->n), a.n); -#else - mem_addr->f32[0] = a.f32[0]; - mem_addr->f32[1] = a.f32[1]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storer_ps(simde_float32 mem_addr[4], simde__m128 a) -{ - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE_NATIVE) - _mm_storer_ps(mem_addr, a.n); -#else - SIMDE__VECTORIZE_ALIGNED(mem_addr : 16) - for (size_t i = 0; i < sizeof(a.f32) / sizeof(a.f32[0]); i++) { - mem_addr[i] = - a.f32[((sizeof(a.f32) / sizeof(a.f32[0])) - 1) - i]; - } -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storeu_ps(simde_float32 mem_addr[4], simde__m128 a) -{ -#if defined(SIMDE_SSE_NATIVE) - _mm_storeu_ps(mem_addr, a.n); -#elif defined(SIMDE_SSE_NEON) - vst1q_f32(mem_addr, a.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < sizeof(a.f32) / sizeof(a.f32[0]); i++) { - mem_addr[i] = a.f32[i]; - } -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_sub_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_sub_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_f32 = vsubq_f32(a.neon_f32, b.neon_f32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = a.f32[i] - b.f32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_sub_ss(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_sub_ss(a.n, b.n); -#else - r.f32[0] = a.f32[0] - b.f32[0]; - r.f32[1] = a.f32[1]; - r.f32[2] = a.f32[2]; - r.f32[3] = a.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomieq_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_ucomieq_ss(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f32[0] == b.f32[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomige_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_ucomige_ss(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f32[0] >= b.f32[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomigt_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_ucomigt_ss(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f32[0] > b.f32[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomile_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_ucomile_ss(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f32[0] <= b.f32[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomilt_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_ucomilt_ss(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f32[0] < b.f32[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomineq_ss(simde__m128 a, simde__m128 b) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_ucomineq_ss(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f32[0] != b.f32[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -#if defined(SIMDE_SSE_NATIVE) -#if defined(__has_builtin) -#if __has_builtin(__builtin_ia32_undef128) -#define SIMDE__HAVE_UNDEFINED128 -#endif -#elif !defined(__PGI) && !defined(SIMDE_BUG_GCC_REV_208793) -#define SIMDE__HAVE_UNDEFINED128 -#endif -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_undefined_ps(void) -{ - simde__m128 r; - -#if defined(SIMDE__HAVE_UNDEFINED128) - r.n = _mm_undefined_ps(); -#else - r = simde_mm_setzero_ps(); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_unpackhi_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_unpackhi_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x2_t a1 = vget_high_f32(a.neon_f32); - float32x2_t b1 = vget_high_f32(b.neon_f32); - float32x2x2_t result = vzip_f32(a1, b1); - r.neon_f32 = vcombine_f32(result.val[0], result.val[1]); -#else - r.f32[0] = a.f32[2]; - r.f32[1] = b.f32[2]; - r.f32[2] = a.f32[3]; - r.f32[3] = b.f32[3]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_unpacklo_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_unpacklo_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - float32x2_t a1 = vget_low_f32(a.neon_f32); - float32x2_t b1 = vget_low_f32(b.neon_f32); - float32x2x2_t result = vzip_f32(a1, b1); - r.neon_f32 = vcombine_f32(result.val[0], result.val[1]); -#else - r.f32[0] = a.f32[0]; - r.f32[1] = b.f32[0]; - r.f32[2] = a.f32[1]; - r.f32[3] = b.f32[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_xor_ps(simde__m128 a, simde__m128 b) -{ - simde__m128 r; - -#if defined(SIMDE_SSE_NATIVE) - r.n = _mm_xor_ps(a.n, b.n); -#elif defined(SIMDE_SSE_NEON) - r.neon_i32 = veorq_s32(a.neon_i32, b.neon_i32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u32) / sizeof(r.u32[0])); i++) { - r.u32[i] = a.u32[i] ^ b.u32[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_stream_pi(simde__m64 *mem_addr, simde__m64 a) -{ -#if defined(SIMDE_SSE_NATIVE) - _mm_stream_pi(&(mem_addr->n), a.n); -#else - mem_addr->i64[0] = a.i64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_stream_ps(simde_float32 mem_addr[4], simde__m128 a) -{ - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE_NATIVE) - _mm_stream_ps(mem_addr, a.n); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - memcpy(mem_addr, &a, sizeof(a)); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -uint32_t simde_mm_getcsr(void) -{ -#if defined(SIMDE_SSE_NATIVE) - return _mm_getcsr(); -#else - uint32_t r = 0; - int rounding_mode = fegetround(); - - switch (rounding_mode) { - case FE_TONEAREST: - break; - case FE_UPWARD: - r |= 2 << 13; - break; - case FE_DOWNWARD: - r |= 1 << 13; - break; - case FE_TOWARDZERO: - r = 3 << 13; - break; - } - - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_setcsr(uint32_t a) -{ -#if defined(SIMDE_SSE_NATIVE) - _mm_setcsr(a); -#else - switch ((a >> 13) & 3) { - case 0: - fesetround(FE_TONEAREST); - break; - case 1: - fesetround(FE_DOWNWARD); - break; - case 2: - fesetround(FE_UPWARD); - break; - case 3: - fesetround(FE_TOWARDZERO); - break; - } -#endif -} - -#define SIMDE_MM_TRANSPOSE4_PS(row0, row1, row2, row3) \ - do { \ - simde__m128 tmp3, tmp2, tmp1, tmp0; \ - tmp0 = simde_mm_unpacklo_ps((row0), (row1)); \ - tmp2 = simde_mm_unpacklo_ps((row2), (row3)); \ - tmp1 = simde_mm_unpackhi_ps((row0), (row1)); \ - tmp3 = simde_mm_unpackhi_ps((row2), (row3)); \ - row0 = simde_mm_movelh_ps(tmp0, tmp2); \ - row1 = simde_mm_movehl_ps(tmp2, tmp0); \ - row2 = simde_mm_movelh_ps(tmp1, tmp3); \ - row3 = simde_mm_movehl_ps(tmp3, tmp1); \ - } while (0) - -SIMDE__END_DECLS - -#endif /* !defined(SIMDE__SSE_H) */ diff --git a/libobs/util/simde/sse2.h b/libobs/util/simde/sse2.h deleted file mode 100644 index caad0a4..0000000 --- a/libobs/util/simde/sse2.h +++ /dev/null @@ -1,4197 +0,0 @@ -/* Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - * - * Copyright: - * 2017 Evan Nemerson - * 2015-2017 John W. Ratcliff - * 2015 Brandon Rowlett - * 2015 Ken Fast - * 2017 Hasindu Gamaarachchi - * 2018 Jeff Daily - */ - -#if !defined(SIMDE__SSE2_H) -#if !defined(SIMDE__SSE2_H) -#define SIMDE__SSE2_H -#endif -#include "sse.h" - -#if defined(SIMDE_SSE2_NATIVE) -#undef SIMDE_SSE2_NATIVE -#endif -#if defined(SIMDE_SSE2_FORCE_NATIVE) -#define SIMDE_SSE2_NATIVE -#elif defined(__SSE2__) && !defined(SIMDE_SSE2_NO_NATIVE) && \ - !defined(SIMDE_NO_NATIVE) -#define SIMDE_SSE2_NATIVE -#elif defined(__ARM_NEON) && !defined(SIMDE_SSE2_NO_NEON) && \ - !defined(SIMDE_NO_NEON) -#define SIMDE_SSE2_NEON -#endif - -#if defined(SIMDE_SSE2_NATIVE) && !defined(SIMDE_SSE_NATIVE) -#if defined(SIMDE_SSE2_FORCE_NATIVE) -#error Native SSE2 support requires native SSE support -#else -#warning Native SSE2 support requires native SSE support, disabling -#undef SIMDE_SSE2_NATIVE -#endif -#elif defined(SIMDE_SSE2_NEON) && !defined(SIMDE_SSE_NEON) -#warning SSE2 NEON support requires SSE NEON support, disabling -#undef SIMDE_SSE_NEON -#endif - -#if defined(SIMDE_SSE2_NATIVE) -#include -#else -#if defined(SIMDE_SSE2_NEON) -#include -#endif -#endif - -#include -#include -#include - -#define vreinterpretq_m128i_s32(v) \ - (simde__m128i) { .neon_i32 = v } -#define vreinterpretq_m128i_u64(v) \ - (simde__m128i) { .neon_u64 = v } - -#define vreinterpretq_s32_m128i(a) a.neon_i32 -#define vreinterpretq_u64_m128i(a) a.neon_u64 - -SIMDE__BEGIN_DECLS - -typedef SIMDE_ALIGN(16) union { -#if defined(SIMDE__ENABLE_GCC_VEC_EXT) - int8_t i8 __attribute__((__vector_size__(16), __may_alias__)); - int16_t i16 __attribute__((__vector_size__(16), __may_alias__)); - int32_t i32 __attribute__((__vector_size__(16), __may_alias__)); - int64_t i64 __attribute__((__vector_size__(16), __may_alias__)); - uint8_t u8 __attribute__((__vector_size__(16), __may_alias__)); - uint16_t u16 __attribute__((__vector_size__(16), __may_alias__)); - uint32_t u32 __attribute__((__vector_size__(16), __may_alias__)); - uint64_t u64 __attribute__((__vector_size__(16), __may_alias__)); -#if defined(SIMDE__HAVE_INT128) - simde_int128 i128 __attribute__((__vector_size__(16), __may_alias__)); - simde_uint128 u128 __attribute__((__vector_size__(16), __may_alias__)); -#endif - simde_float32 f32 __attribute__((__vector_size__(16), __may_alias__)); - simde_float64 f64 __attribute__((__vector_size__(16), __may_alias__)); -#else - int8_t i8[16]; - int16_t i16[8]; - int32_t i32[4]; - int64_t i64[2]; - uint8_t u8[16]; - uint16_t u16[8]; - uint32_t u32[4]; - uint64_t u64[2]; -#if defined(SIMDE__HAVE_INT128) - simde_int128 i128[1]; - simde_uint128 u128[1]; -#endif - simde_float32 f32[4]; - simde_float64 f64[2]; -#endif - -#if defined(SIMDE_SSE2_NATIVE) - __m128i n; -#elif defined(SIMDE_SSE2_NEON) - int8x16_t neon_i8; - int16x8_t neon_i16; - int32x4_t neon_i32; - int64x2_t neon_i64; - uint8x16_t neon_u8; - uint16x8_t neon_u16; - uint32x4_t neon_u32; - uint64x2_t neon_u64; - float32x4_t neon_f32; -#if defined(SIMDE_ARCH_AMD64) - float64x2_t neon_f64; -#endif -#endif -} simde__m128i; - -typedef SIMDE_ALIGN(16) union { -#if defined(SIMDE__ENABLE_GCC_VEC_EXT) - int8_t i8 __attribute__((__vector_size__(16), __may_alias__)); - int16_t i16 __attribute__((__vector_size__(16), __may_alias__)); - int32_t i32 __attribute__((__vector_size__(16), __may_alias__)); - int64_t i64 __attribute__((__vector_size__(16), __may_alias__)); - uint8_t u8 __attribute__((__vector_size__(16), __may_alias__)); - uint16_t u16 __attribute__((__vector_size__(16), __may_alias__)); - uint32_t u32 __attribute__((__vector_size__(16), __may_alias__)); - uint64_t u64 __attribute__((__vector_size__(16), __may_alias__)); - simde_float32 f32 __attribute__((__vector_size__(16), __may_alias__)); - simde_float64 f64 __attribute__((__vector_size__(16), __may_alias__)); -#else - int8_t i8[16]; - int16_t i16[8]; - int32_t i32[4]; - int64_t i64[2]; - uint8_t u8[16]; - uint16_t u16[8]; - uint32_t u32[4]; - uint64_t u64[2]; - simde_float32 f32[4]; - simde_float64 f64[2]; -#endif - -#if defined(SIMDE_SSE2_NATIVE) - __m128d n; -#elif defined(SIMDE_SSE2_NEON) - int8x16_t neon_i8; - int16x8_t neon_i16; - int32x4_t neon_i32; - int64x2_t neon_i64; - uint8x16_t neon_u8; - uint16x8_t neon_u16; - uint32x4_t neon_u32; - uint64x2_t neon_u64; - float32x4_t neon_f32; -#if defined(SIMDE_ARCH_AMD64) - float64x2_t neon_f64; -#endif -#endif -} simde__m128d; - -#if defined(SIMDE_SSE2_NATIVE) -HEDLEY_STATIC_ASSERT(sizeof(__m128i) == sizeof(simde__m128i), - "__m128i size doesn't match simde__m128i size"); -HEDLEY_STATIC_ASSERT(sizeof(__m128d) == sizeof(simde__m128d), - "__m128d size doesn't match simde__m128d size"); -SIMDE__FUNCTION_ATTRIBUTES simde__m128i SIMDE__M128I_C(__m128i v) -{ - simde__m128i r; - r.n = v; - return r; -} -SIMDE__FUNCTION_ATTRIBUTES simde__m128d SIMDE__M128D_C(__m128d v) -{ - simde__m128d r; - r.n = v; - return r; -} -#elif defined(SIMDE_SSE_NEON) -#define SIMDE__M128I_NEON_C(T, expr) \ - (simde__m128i) { .neon_##T = expr } -#define SIMDE__M128D_NEON_C(T, expr) \ - (simde__m128d) { .neon_##T = expr } -#endif -HEDLEY_STATIC_ASSERT(16 == sizeof(simde__m128i), "simde__m128i size incorrect"); -HEDLEY_STATIC_ASSERT(16 == sizeof(simde__m128d), "simde__m128d size incorrect"); - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_add_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_add_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i8, vaddq_s8(a.neon_i8, b.neon_i8)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i8) / sizeof(r.i8[0])); i++) { - r.i8[i] = a.i8[i] + b.i8[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_add_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_add_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i16, vaddq_s16(a.neon_i16, b.neon_i16)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = a.i16[i] + b.i16[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_add_epi32(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_add_epi32(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i32, vaddq_s32(a.neon_i32, b.neon_i32)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = a.i32[i] + b.i32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_add_epi64(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_add_epi64(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i64, vaddq_s64(a.neon_i64, b.neon_i64)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] + b.i64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_add_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_add_pd(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) && defined(SIMDE_ARCH_AMD64) - return SIMDE__M128I_NEON_C(f64, vaddq_f64(a.neon_f64, b.neon_f64)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = a.f64[i] + b.f64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_add_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_add_sd(a.n, b.n)); -#else - simde__m128d r; - r.f64[0] = a.f64[0] + b.f64[0]; - r.f64[1] = a.f64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_add_si64(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M64_C(_mm_add_si64(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M64_NEON_C(i64, vadd_s64(a.neon_i64, b.neon_i64)); -#else - simde__m64 r; - r.i64[0] = a.i64[0] + b.i64[0]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_adds_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_adds_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i8, vqaddq_s8(a.neon_i8, b.neon_i8)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i8) / sizeof(r.i8[0])); i++) { - if ((((b.i8[i]) > 0) && ((a.i8[i]) > (INT8_MAX - (b.i8[i]))))) { - r.i8[i] = INT8_MAX; - } else if ((((b.i8[i]) < 0) && - ((a.i8[i]) < (INT8_MIN - (b.i8[i]))))) { - r.i8[i] = INT8_MIN; - } else { - r.i8[i] = (a.i8[i]) + (b.i8[i]); - } - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_adds_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_adds_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i16, vqaddq_s16(a.neon_i16, b.neon_i16)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - if ((((b.i16[i]) > 0) && - ((a.i16[i]) > (INT16_MAX - (b.i16[i]))))) { - r.i16[i] = INT16_MAX; - } else if ((((b.i16[i]) < 0) && - ((a.i16[i]) < (INT16_MIN - (b.i16[i]))))) { - r.i16[i] = INT16_MIN; - } else { - r.i16[i] = (a.i16[i]) + (b.i16[i]); - } - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_adds_epu8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_adds_epu8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(u8, vqaddq_u8(a.neon_u8, b.neon_u8)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u8) / sizeof(r.u8[0])); i++) { - r.u8[i] = ((UINT8_MAX - a.u8[i]) > b.u8[i]) - ? (a.u8[i] + b.u8[i]) - : UINT8_MAX; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_adds_epu16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_adds_epu16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(u16, vqaddq_u16(a.neon_u16, b.neon_u16)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u16) / sizeof(r.u16[0])); i++) { - r.u16[i] = ((UINT16_MAX - a.u16[i]) > b.u16[i]) - ? (a.u16[i] + b.u16[i]) - : UINT16_MAX; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_and_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_and_pd(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128D_NEON_C(i32, vandq_s32(a.neon_i32, b.neon_i32)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u64) / sizeof(r.u64[0])); i++) { - r.u64[i] = a.u64[i] & b.u64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_and_si128(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_and_si128(a.n, b.n)); -#elif defined(SIMDE_SSE_NEON) - return SIMDE__M128I_NEON_C(i32, vandq_s32(b.neon_i32, a.neon_i32)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] & b.i64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_andnot_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_andnot_pd(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128D_NEON_C(i32, vbicq_s32(a.neon_i32, b.neon_i32)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u64) / sizeof(r.u64[0])); i++) { - r.u64[i] = ~a.u64[i] & b.u64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_andnot_si128(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_andnot_si128(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i32, vbicq_s32(b.neon_i32, a.neon_i32)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = ~(a.i64[i]) & b.i64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_avg_epu8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_avg_epu8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(u8, vrhaddq_u8(b.neon_u8, a.neon_u8)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u8) / sizeof(r.u8[0])); i++) { - r.u8[i] = (a.u8[i] + b.u8[i] + 1) >> 1; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_avg_epu16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_avg_epu16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(u16, vrhaddq_u16(b.neon_u16, a.neon_u16)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u16) / sizeof(r.u16[0])); i++) { - r.u16[i] = (a.u16[i] + b.u16[i] + 1) >> 1; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_bslli_si128(simde__m128i a, const int imm8) -{ - simde__m128i r; - - if (HEDLEY_UNLIKELY(imm8 > 15)) { - r.u64[0] = 0; - r.u64[1] = 0; - return r; - } - - const int s = imm8 * 8; - -#if defined(SIMDE__HAVE_INT128) - r.u128[0] = a.u128[0] << s; -#else - if (s < 64) { - r.u64[0] = (a.u64[0] << s); - r.u64[1] = (a.u64[1] << s) | (a.u64[0] >> (64 - s)); - } else { - r.u64[0] = 0; - r.u64[1] = a.u64[0] << (s - 64); - } -#endif - - return r; -} -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) -#define simde_mm_bslli_si128(a, imm8) SIMDE__M128I_C(_mm_slli_si128(a.n, imm8)) -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_bslli_si128(a, imm8) \ - SIMDE__M128I_NEON_C( \ - i8, \ - (((imm8) <= 0) ? ((a).neon_i8) \ - : (((imm8) > 15) ? (vdupq_n_s8(0)) \ - : (vextq_s8(vdupq_n_s8(0), \ - (a).neon_i8, \ - 16 - (imm8)))))) -#endif -#define simde_mm_slli_si128(a, imm8) simde_mm_bslli_si128(a, imm8) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_bsrli_si128(simde__m128i a, const int imm8) -{ - simde__m128i r; - - if (HEDLEY_UNLIKELY(imm8 > 15)) { - r.u64[0] = 0; - r.u64[1] = 0; - return r; - } - - const int s = imm8 * 8; - -#if defined(SIMDE__HAVE_INT128) - r.u128[0] = a.u128[0] >> s; -#else - if (s < 64) { - r.u64[0] = (a.u64[0] >> s) | (a.u64[1] << (64 - s)); - r.u64[1] = (a.u64[1] >> s); - } else { - r.u64[0] = a.u64[1] >> (s - 64); - r.u64[1] = 0; - } -#endif - - return r; -} -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) -#define simde_mm_bsrli_si128(a, imm8) SIMDE__M128I_C(_mm_srli_si128(a.n, imm8)) -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_bsrli_si128(a, imm8) \ - SIMDE__M128I_NEON_C( \ - i8, \ - ((imm8) <= 0) \ - ? ((a).neon_i8) \ - : (((imm8) > 15) ? (vdupq_n_s8(0)) \ - : (vextq_s8((a).neon_i8, \ - vdupq_n_s8(0), (imm8))))) -#endif -#define simde_mm_srli_si128(a, imm8) simde_mm_bsrli_si128(a, imm8) - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_clflush(void const *p) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_clflush(p); -#else - (void)p; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comieq_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_comieq_sd(a.n, b.n); -#else - return a.f64[0] == b.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comige_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_comige_sd(a.n, b.n); -#else - return a.f64[0] >= b.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comigt_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_comigt_sd(a.n, b.n); -#else - return a.f64[0] > b.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comile_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_comile_sd(a.n, b.n); -#else - return a.f64[0] <= b.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comilt_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_comilt_sd(a.n, b.n); -#else - return a.f64[0] < b.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_comineq_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_comineq_sd(a.n, b.n); -#else - return a.f64[0] != b.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_castpd_ps(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128_C(_mm_castpd_ps(a.n)); -#else - union { - simde__m128d pd; - simde__m128 ps; - } r; - r.pd = a; - return r.ps; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_castpd_si128(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_castpd_si128(a.n)); -#else - union { - simde__m128d pd; - simde__m128i si128; - } r; - r.pd = a; - return r.si128; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_castps_pd(simde__m128 a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_castps_pd(a.n)); -#else - union { - simde__m128 ps; - simde__m128d pd; - } r; - r.ps = a; - return r.pd; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_castps_si128(simde__m128 a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_castps_si128(a.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i32, a.neon_i32); -#else - union { - simde__m128 ps; - simde__m128i si128; - } r; - r.ps = a; - return r.si128; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_castsi128_pd(simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_castsi128_pd(a.n)); -#else - union { - simde__m128i si128; - simde__m128d pd; - } r; - r.si128 = a; - return r.pd; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_castsi128_ps(simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128_C(_mm_castsi128_ps(a.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128_NEON_C(f32, a.neon_f32); -#else - union { - simde__m128i si128; - simde__m128 ps; - } r; - r.si128 = a; - return r.ps; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmpeq_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmpeq_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i8, vreinterpretq_s8_u8(vceqq_s8(b.neon_i8, a.neon_i8))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i8) / sizeof(r.i8[0])); i++) { - r.i8[i] = (a.i8[i] == b.i8[i]) ? 0xff : 0x00; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmpeq_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmpeq_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i16, vreinterpretq_s16_u16(vceqq_s16(b.neon_i16, a.neon_i16))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = (a.i16[i] == b.i16[i]) ? 0xffff : 0x0000; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmpeq_epi32(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmpeq_epi32(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i32, vreinterpretq_s32_u32(vceqq_s32(b.neon_i32, a.neon_i32))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (a.i32[i] == b.i32[i]) ? 0xffffffff : 0x00000000; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpeq_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpeq_pd(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128D_NEON_C( - i32, vreinterpretq_s32_u32( - vceqq_s32(vreinterpretq_s32_f32(b.neon_f32), - vreinterpretq_s32_f32(a.neon_f32)))); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.u64[i] = (a.f64[i] == b.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpeq_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpeq_sd(a.n, b.n)); -#else - simde__m128d r; - r.u64[0] = (a.f64[0] == b.f64[0]) ? ~UINT64_C(0) : 0; - r.u64[1] = a.u64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpneq_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpneq_pd(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128D_NEON_C(f32, - vreinterpretq_f32_u16(vmvnq_u16( - vceqq_s16(b.neon_i16, a.neon_i16)))); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.u64[i] = (a.f64[i] != b.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpneq_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpneq_sd(a.n, b.n)); -#else - simde__m128d r; - r.u64[0] = (a.f64[0] != b.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); - r.u64[1] = a.u64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmplt_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmplt_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i8, vreinterpretq_s8_u8(vcltq_s8(a.neon_i8, b.neon_i8))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i8) / sizeof(r.i8[0])); i++) { - r.i8[i] = (a.i8[i] < b.i8[i]) ? 0xff : 0x00; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmplt_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmplt_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i16, vreinterpretq_s16_u16(vcltq_s16(a.neon_i16, b.neon_i16))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = (a.i16[i] < b.i16[i]) ? 0xffff : 0x0000; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmplt_epi32(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmplt_epi32(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i32, vreinterpretq_s32_u32(vcltq_s32(a.neon_i32, b.neon_i32))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (a.i32[i] < b.i32[i]) ? 0xffffffff : 0x00000000; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmplt_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmplt_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.u64[i] = (a.f64[i] < b.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmplt_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmplt_sd(a.n, b.n)); -#else - simde__m128d r; - r.u64[0] = (a.f64[0] < b.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); - r.u64[1] = a.u64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmple_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmple_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.u64[i] = (a.f64[i] <= b.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmple_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmple_sd(a.n, b.n)); -#else - simde__m128d r; - r.u64[0] = (a.f64[0] <= b.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); - r.u64[1] = a.u64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmpgt_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmpgt_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i8, vreinterpretq_s8_u8(vcgtq_s8(a.neon_i8, b.neon_i8))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i8) / sizeof(r.i8[0])); i++) { - r.i8[i] = (a.i8[i] > b.i8[i]) ? 0xff : 0x00; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmpgt_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmpgt_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i16, vreinterpretq_s16_u16(vcgtq_s16(a.neon_i16, b.neon_i16))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = (a.i16[i] > b.i16[i]) ? 0xffff : 0x0000; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cmpgt_epi32(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cmpgt_epi32(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C( - i32, vreinterpretq_s32_u32(vcgtq_s32(a.neon_i32, b.neon_i32))); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (a.i32[i] > b.i32[i]) ? 0xffffffff : 0x00000000; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpgt_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpgt_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.u64[i] = (a.f64[i] > b.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpgt_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) - return SIMDE__M128D_C(_mm_cmpgt_sd(a.n, b.n)); -#else - simde__m128d r; - r.u64[0] = (a.f64[0] > b.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); - r.u64[1] = a.u64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpge_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpge_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.u64[i] = (a.f64[i] >= b.f64[i]) ? ~UINT64_C(0) : UINT64_C(0); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpge_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) - return SIMDE__M128D_C(_mm_cmpge_sd(a.n, b.n)); -#else - simde__m128d r; - r.u64[0] = (a.f64[0] >= b.f64[0]) ? ~UINT64_C(0) : UINT64_C(0); - r.u64[1] = a.u64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpnge_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpnge_pd(a.n, b.n)); -#else - return simde_mm_cmplt_pd(a, b); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpnge_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) - return SIMDE__M128D_C(_mm_cmpnge_sd(a.n, b.n)); -#else - return simde_mm_cmplt_sd(a, b); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpnlt_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpnlt_pd(a.n, b.n)); -#else - return simde_mm_cmpge_pd(a, b); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpnlt_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpnlt_sd(a.n, b.n)); -#else - return simde_mm_cmpge_sd(a, b); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpnle_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpnle_pd(a.n, b.n)); -#else - return simde_mm_cmpgt_pd(a, b); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpnle_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpnle_sd(a.n, b.n)); -#else - return simde_mm_cmpgt_sd(a, b); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpord_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpord_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.u64[i] = (!isnan(a.f64[i]) && !isnan(b.f64[i])) ? ~UINT64_C(0) - : UINT64_C(0); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpord_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpord_sd(a.n, b.n)); -#else - simde__m128d r; - r.u64[0] = (!isnan(a.f64[0]) && !isnan(b.f64[0])) ? ~UINT64_C(0) - : UINT64_C(0); - r.u64[1] = a.u64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpunord_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpunord_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.u64[i] = (isnan(a.f64[i]) || isnan(b.f64[i])) ? ~UINT64_C(0) - : UINT64_C(0); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cmpunord_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cmpunord_sd(a.n, b.n)); -#else - simde__m128d r; - r.u64[0] = (isnan(a.f64[0]) || isnan(b.f64[0])) ? ~UINT64_C(0) - : UINT64_C(0); - r.u64[1] = a.u64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cvtepi32_pd(simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cvtepi32_pd(a.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = (simde_float64)a.i32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtepi32_ps(simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128_C(_mm_cvtepi32_ps(a.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128_NEON_C(f32, vcvtq_f32_s32(a.neon_i32)); -#else - simde__m128 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f32) / sizeof(r.f32[0])); i++) { - r.f32[i] = (simde_float32)a.i32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cvtpd_epi32(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cvtpd_epi32(a.n)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.i32[i] = (int32_t)a.f64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvtpd_pi32(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M64_C(_mm_cvtpd_pi32(a.n)); -#else - simde__m64 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (int32_t)a.f64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtpd_ps(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128_C(_mm_cvtpd_ps(a.n)); -#else - simde__m128 r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(a.f64) / sizeof(a.f64[0])); i++) { - r.f32[i] = (simde_float32)a.f64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cvtpi32_pd(simde__m64 a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cvtpi32_pd(a.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = (simde_float64)a.i32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cvtps_epi32(simde__m128 a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_cvtps_epi32(a.n)); -#elif defined(SIMDE_SSE2_NEON) -/* The default rounding mode on SSE is 'round to even', which ArmV7 - does not support! It is supported on ARMv8 however. */ -#if defined(SIMDE_ARCH_AARCH64) - return SIMDE__M128I_NEON_C(i32, vcvtnq_s32_f32(a.neon_f32)); -#else - uint32x4_t signmask = vdupq_n_u32(0x80000000); - float32x4_t half = vbslq_f32(signmask, a.neon_f32, - vdupq_n_f32(0.5f)); /* +/- 0.5 */ - int32x4_t r_normal = vcvtq_s32_f32( - vaddq_f32(a.neon_f32, half)); /* round to integer: [a + 0.5]*/ - int32x4_t r_trunc = - vcvtq_s32_f32(a.neon_f32); /* truncate to integer: [a] */ - int32x4_t plusone = vshrq_n_s32(vnegq_s32(r_trunc), 31); /* 1 or 0 */ - int32x4_t r_even = vbicq_s32(vaddq_s32(r_trunc, plusone), - vdupq_n_s32(1)); /* ([a] + {0,1}) & ~1 */ - float32x4_t delta = vsubq_f32( - a.neon_f32, - vcvtq_f32_s32(r_trunc)); /* compute delta: delta = (a - [a]) */ - uint32x4_t is_delta_half = - vceqq_f32(delta, half); /* delta == +/- 0.5 */ - return SIMDE__M128I_NEON_C(i32, - vbslq_s32(is_delta_half, r_even, r_normal)); -#endif -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (int32_t)a.f32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cvtps_pd(simde__m128 a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cvtps_pd(a.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = a.f32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -double simde_mm_cvtsd_f64(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) - return _mm_cvtsd_f64(a.n); -#else - return a.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvtsd_si32(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_cvtsd_si32(a.n); -#else - return (int32_t)a.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvtsd_si64(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if defined(__PGI) - return _mm_cvtsd_si64x(a.n); -#else - return _mm_cvtsd_si64(a.n); -#endif -#else - return (int32_t)a.f64[0]; -#endif -} -#define simde_mm_cvtsd_si64x(a) simde_mm_cvtsd_si64(a) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128 simde_mm_cvtsd_ss(simde__m128 a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128_C(_mm_cvtsd_ss(a.n, b.n)); -#else - simde__m128 r; - - r.f32[0] = (simde_float32)b.f64[0]; - - SIMDE__VECTORIZE - for (size_t i = 1; i < (sizeof(r) / sizeof(r.i32[0])); i++) { - r.i32[i] = a.i32[i]; - } - - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvtsi128_si32(simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_cvtsi128_si32(a.n); -#elif defined(SIMDE_SSE2_NEON) - return vgetq_lane_s32(a.neon_i32, 0); -#else - return a.i32[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int64_t simde_mm_cvtsi128_si64(simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if defined(__PGI) - return _mm_cvtsi128_si64x(a.n); -#else - return _mm_cvtsi128_si64(a.n); -#endif -#else - return a.i64[0]; -#endif -} -#define simde_mm_cvtsi128_si64x(a) simde_mm_cvtsi128_si64(a) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cvtsi32_sd(simde__m128d a, int32_t b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_cvtsi32_sd(a.n, b)); -#else - simde__m128d r; - - r.f64[0] = (simde_float64)b; - r.i64[1] = a.i64[1]; - - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cvtsi32_si128(int32_t a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_cvtsi32_si128(a); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i32 = vsetq_lane_s32(a, vdupq_n_s32(0), 0); -#else - r.i32[0] = a; - r.i32[1] = 0; - r.i32[2] = 0; - r.i32[3] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cvtsi64_sd(simde__m128d a, int32_t b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if !defined(__PGI) - r.n = _mm_cvtsi64_sd(a.n, b); -#else - r.n = _mm_cvtsi64x_sd(a.n, b); -#endif -#else - r.f64[0] = (simde_float64)b; - r.f64[1] = a.f64[1]; -#endif - - return r; -} -#define simde_mm_cvtsi64x_sd(a, b) simde_mm_cvtsi64(a, b) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cvtsi64_si128(int64_t a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if !defined(__PGI) - r.n = _mm_cvtsi64_si128(a); -#else - r.n = _mm_cvtsi64x_si128(a); -#endif -#else - r.i64[0] = a; - r.i64[1] = 0; -#endif - - return r; -} -#define simde_mm_cvtsi64x_si128(a) simde_mm_cvtsi64_si128(a) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_cvtss_sd(simde__m128d a, simde__m128 b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_cvtss_sd(a.n, b.n); -#else - r.f64[0] = b.f32[0]; - r.i64[1] = a.i64[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cvttpd_epi32(simde__m128d a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_cvttpd_epi32(a.n); -#else - for (size_t i = 0; i < (sizeof(a.f64) / sizeof(a.f64[0])); i++) { - r.i32[i] = (int32_t)trunc(a.f64[i]); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_cvttpd_pi32(simde__m128d a) -{ - simde__m64 r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_cvttpd_pi32(a.n); -#else - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (int32_t)trunc(a.f64[i]); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_cvttps_epi32(simde__m128 a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_cvttps_epi32(a.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i32 = vcvtq_s32_f32(a.neon_f32); -#else - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = (int32_t)truncf(a.f32[i]); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_cvttsd_si32(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_cvttsd_si32(a.n); -#else - return (int32_t)trunc(a.f64[0]); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int64_t simde_mm_cvttsd_si64(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if !defined(__PGI) - return _mm_cvttsd_si64(a.n); -#else - return _mm_cvttsd_si64x(a.n); -#endif -#else - return (int64_t)trunc(a.f64[0]); -#endif -} -#define simde_mm_cvttsd_si64x(a) simde_mm_cvttsd_si64(a) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_div_pd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_div_pd(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = a.f64[i] / b.f64[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_div_sd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_div_sd(a.n, b.n); -#else - r.f64[0] = a.f64[0] / b.f64[0]; - r.f64[1] = a.f64[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_extract_epi16(simde__m128i a, const int imm8) -{ - return a.u16[imm8 & 7]; -} -#if defined(SIMDE_SSE2_NATIVE) && \ - (!defined(SIMDE__REALLY_GCC) || HEDLEY_GCC_VERSION_CHECK(4, 6, 0)) -#define simde_mm_extract_epi16(a, imm8) _mm_extract_epi16(a.n, imm8) -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_extract_epi16(a, imm8) \ - (vgetq_lane_s16((a).neon_i16, (imm8)) & ((int32_t)UINT32_C(0x0000ffff))) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_insert_epi16(simde__m128i a, int32_t i, const int imm8) -{ - a.u16[imm8 & 7] = (int16_t)i; - return a; -} -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) -#define simde_mm_insert_epi16(a, i, imm8) \ - SIMDE__M128I_C(_mm_insert_epi16((a).n, (i), (imm8))) -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_insert_epi16(a, i, imm8) \ - SIMDE__M128I_NEON_C(i16, vsetq_lane_s16((i), a.neon_i16, (imm8))) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d -simde_mm_load_pd(simde_float64 const mem_addr[HEDLEY_ARRAY_PARAM(2)]) -{ - simde__m128d r; - - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_load_pd(mem_addr); -#elif defined(SIMDE_SSE2_NEON) - r.neon_u32 = vld1q_u32((uint32_t const *)mem_addr); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - memcpy(&r, mem_addr, sizeof(r)); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_load_pd1(simde_float64 const *mem_addr) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_load_pd1(mem_addr); -#else - r.f64[0] = *mem_addr; - r.f64[1] = *mem_addr; -#endif - - return r; -} -#define simde_mm_load1_pd(mem_addr) simde_mm_load_pd1(mem_addr) - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_load_sd(simde_float64 const *mem_addr) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_load_sd(mem_addr); -#else - memcpy(&r, mem_addr, sizeof(simde_float64)); - r.u64[1] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_load_si128(simde__m128i const *mem_addr) -{ - simde__m128i r; - - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_load_si128(&(mem_addr->n)); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i32 = vld1q_s32((int32_t const *)mem_addr); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - memcpy(&r, mem_addr, sizeof(r)); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_loadh_pd(simde__m128d a, simde_float64 const *mem_addr) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_loadh_pd(a.n, mem_addr); -#else - simde_float64 t; - memcpy(&t, mem_addr, sizeof(t)); - r.f64[0] = a.f64[0]; - r.f64[1] = t; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_loadl_epi64(simde__m128i const *mem_addr) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_loadl_epi64(&mem_addr->n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i32 = vcombine_s32(vld1_s32((int32_t const *)mem_addr), - vcreate_s32(0)); -#else - r.u64[0] = mem_addr->u64[0]; - r.u64[1] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_loadl_pd(simde__m128d a, simde_float64 const *mem_addr) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_loadl_pd(a.n, mem_addr); -#else - memcpy(&r, mem_addr, sizeof(simde_float64)); - r.u64[1] = a.u64[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d -simde_mm_loadr_pd(simde_float64 const mem_addr[HEDLEY_ARRAY_PARAM(2)]) -{ - simde__m128d r; - - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_loadr_pd(mem_addr); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - r.f64[0] = mem_addr[1]; - r.f64[1] = mem_addr[0]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d -simde_mm_loadu_pd(simde_float64 const mem_addr[HEDLEY_ARRAY_PARAM(2)]) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_loadu_pd(mem_addr); -#else - simde_float64 l, h; - memcpy(&l, &mem_addr[0], sizeof(l)); - memcpy(&h, &mem_addr[1], sizeof(h)); - r.f64[0] = l; - r.f64[1] = h; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_loadu_si128(simde__m128i const *mem_addr) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_loadu_si128(&((*mem_addr).n)); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i32 = vld1q_s32((int32_t const *)mem_addr); -#else - memcpy(&r, mem_addr, sizeof(r)); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_madd_epi16(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_madd_epi16(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - int32x4_t pl = - vmull_s16(vget_low_s16(a.neon_i16), vget_low_s16(b.neon_i16)); - int32x4_t ph = - vmull_s16(vget_high_s16(a.neon_i16), vget_high_s16(b.neon_i16)); - int32x2_t rl = vpadd_s32(vget_low_s32(pl), vget_high_s32(pl)); - int32x2_t rh = vpadd_s32(vget_low_s32(ph), vget_high_s32(ph)); - r.neon_i32 = vcombine_s32(rl, rh); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r) / sizeof(r.i16[0])); i += 2) { - r.i32[i / 2] = - (a.i16[i] * b.i16[i]) + (a.i16[i + 1] * b.i16[i + 1]); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_maskmoveu_si128(simde__m128i a, simde__m128i mask, - int8_t mem_addr[HEDLEY_ARRAY_PARAM(16)]) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_maskmoveu_si128(a.n, mask.n, (char *)mem_addr); -#else - for (size_t i = 0; i < 16; i++) { - if (mask.u8[i] & 0x80) { - mem_addr[i] = a.i8[i]; - } - } -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_movemask_epi8(simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_movemask_epi8(a.n); -#elif defined(SIMDE_SSE2_NEON) - uint8x16_t input = a.neon_u8; - SIMDE_ALIGN(16) - static const int8_t xr[8] = {-7, -6, -5, -4, -3, -2, -1, 0}; - uint8x8_t mask_and = vdup_n_u8(0x80); - int8x8_t mask_shift = vld1_s8(xr); - - uint8x8_t lo = vget_low_u8(input); - uint8x8_t hi = vget_high_u8(input); - - lo = vand_u8(lo, mask_and); - lo = vshl_u8(lo, mask_shift); - - hi = vand_u8(hi, mask_and); - hi = vshl_u8(hi, mask_shift); - - lo = vpadd_u8(lo, lo); - lo = vpadd_u8(lo, lo); - lo = vpadd_u8(lo, lo); - - hi = vpadd_u8(hi, hi); - hi = vpadd_u8(hi, hi); - hi = vpadd_u8(hi, hi); - - return ((hi[0] << 8) | (lo[0] & 0xFF)); -#else - int32_t r = 0; - SIMDE__VECTORIZE_REDUCTION(| : r) - for (size_t i = 0; i < 16; i++) { - r |= (a.u8[15 - i] >> 7) << (15 - i); - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int32_t simde_mm_movemask_pd(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_movemask_pd(a.n); -#else - int32_t r = 0; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(a.u64) / sizeof(a.u64[0])); i++) { - r |= (a.u64[i] >> 63) << i; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_movepi64_pi64(simde__m128i a) -{ - simde__m64 r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_movepi64_pi64(a.n); -#else - r.i64[0] = a.i64[0]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_movpi64_epi64(simde__m64 a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_movpi64_epi64(a.n); -#else - r.i64[0] = a.i64[0]; - r.i64[1] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_min_epi16(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_min_epi16(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i16 = vminq_s16(a.neon_i16, b.neon_i16); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = (a.i16[i] < b.i16[i]) ? a.i16[i] : b.i16[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_min_epu8(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_min_epu8(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_u8 = vminq_u8(a.neon_u8, b.neon_u8); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u8) / sizeof(r.u8[0])); i++) { - r.u8[i] = (a.u8[i] < b.u8[i]) ? a.u8[i] : b.u8[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_min_pd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_min_pd(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = (a.f64[i] < b.f64[i]) ? a.f64[i] : b.f64[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_min_sd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_min_sd(a.n, b.n); -#else - r.f64[0] = (a.f64[0] < b.f64[0]) ? a.f64[0] : b.f64[0]; - r.f64[1] = a.f64[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_max_epi16(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_max_epi16(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i16 = vmaxq_s16(a.neon_i16, b.neon_i16); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = (a.i16[i] > b.i16[i]) ? a.i16[i] : b.i16[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_max_epu8(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_max_epu8(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_u8 = vmaxq_u8(a.neon_u8, b.neon_u8); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u8) / sizeof(r.u8[0])); i++) { - r.u8[i] = (a.u8[i] > b.u8[i]) ? a.u8[i] : b.u8[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_max_pd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_max_pd(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = (a.f64[i] > b.f64[i]) ? a.f64[i] : b.f64[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_max_sd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_max_sd(a.n, b.n); -#else - r.f64[0] = (a.f64[0] > b.f64[0]) ? a.f64[0] : b.f64[0]; - r.f64[1] = a.f64[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_move_epi64(simde__m128i a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_move_epi64(a.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i64 = vsetq_lane_s64(0, a.neon_i64, 1); -#else - r.i64[0] = a.i64[0]; - r.i64[1] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_move_sd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_move_sd(a.n, b.n); -#else - r.f64[0] = b.f64[0]; - r.f64[1] = a.f64[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_mul_epu32(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_mul_epu32(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u64) / sizeof(r.u64[0])); i++) { - r.u64[i] = ((uint64_t)a.u32[i * 2]) * ((uint64_t)b.u32[i * 2]); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_x_mm_mul_epi64(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] * b.i64[i]; - } - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_x_mm_mod_epi64(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] % b.i64[i]; - } - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_mul_pd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_mul_pd(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = a.f64[i] * b.f64[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_mul_sd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_mul_sd(a.n, b.n); -#else - r.f64[0] = a.f64[0] * b.f64[0]; - r.f64[1] = a.f64[1]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_mul_su32(simde__m64 a, simde__m64 b) -{ - simde__m64 r; - -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) - r.n = _mm_mul_su32(a.n, b.n); -#else - r.u64[0] = ((uint64_t)a.u32[0]) * ((uint64_t)b.u32[0]); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_mulhi_epi16(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_mulhi_epi16(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - int16x4_t a3210 = vget_low_s16(a.neon_i16); - int16x4_t b3210 = vget_low_s16(b.neon_i16); - int32x4_t ab3210 = vmull_s16(a3210, b3210); /* 3333222211110000 */ - int16x4_t a7654 = vget_high_s16(a.neon_i16); - int16x4_t b7654 = vget_high_s16(b.neon_i16); - int32x4_t ab7654 = vmull_s16(a7654, b7654); /* 7777666655554444 */ - uint16x8x2_t rv = vuzpq_u16(vreinterpretq_u16_s32(ab3210), - vreinterpretq_u16_s32(ab7654)); - r.neon_u16 = rv.val[1]; -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.u16[i] = (uint16_t)(((uint32_t)(((int32_t)a.i16[i]) * - ((int32_t)b.i16[i]))) >> - 16); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_mulhi_epu16(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) - r.n = _mm_mulhi_epu16(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u16) / sizeof(r.u16[0])); i++) { - r.u16[i] = (uint16_t)( - (((uint32_t)a.u16[i]) * ((uint32_t)b.u16[i])) >> 16); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_mullo_epi16(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_mullo_epi16(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i16 = vmulq_s16(a.neon_i16, b.neon_i16); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.u16[i] = (uint16_t)(((uint32_t)(((int32_t)a.i16[i]) * - ((int32_t)b.i16[i]))) & - 0xffff); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_or_pd(simde__m128d a, simde__m128d b) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_or_pd(a.n, b.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] | b.i64[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_or_si128(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_or_si128(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i32 = vorrq_s32(a.neon_i32, b.neon_i32); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] | b.i64[i]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_packs_epi16(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_packs_epi16(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i8 = vcombine_s8(vqmovn_s16(a.neon_i16), vqmovn_s16(b.neon_i16)); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i8[i] = (a.i16[i] > INT8_MAX) - ? INT8_MAX - : ((a.i16[i] < INT8_MIN) - ? INT8_MIN - : ((int8_t)a.i16[i])); - r.i8[i + 8] = (b.i16[i] > INT8_MAX) - ? INT8_MAX - : ((b.i16[i] < INT8_MIN) - ? INT8_MIN - : ((int8_t)b.i16[i])); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_packs_epi32(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_packs_epi32(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i16 = - vcombine_s16(vqmovn_s32(a.neon_i32), vqmovn_s32(b.neon_i32)); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i16[i] = (a.i32[i] > INT16_MAX) - ? INT16_MAX - : ((a.i32[i] < INT16_MIN) - ? INT16_MIN - : ((int16_t)a.i32[i])); - r.i16[i + 4] = (b.i32[i] > INT16_MAX) - ? INT16_MAX - : ((b.i32[i] < INT16_MIN) - ? INT16_MIN - : ((int16_t)b.i32[i])); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_packus_epi16(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_packus_epi16(a.n, b.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_u8 = - vcombine_u8(vqmovun_s16(a.neon_i16), vqmovun_s16(b.neon_i16)); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.u8[i] = (a.i16[i] > UINT8_MAX) - ? UINT8_MAX - : ((a.i16[i] < 0) ? 0 : ((int8_t)a.i16[i])); - r.u8[i + 8] = - (b.i16[i] > UINT8_MAX) - ? UINT8_MAX - : ((b.i16[i] < 0) ? 0 : ((int8_t)b.i16[i])); - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_pause(void) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_pause(); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sad_epu8(simde__m128i a, simde__m128i b) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_sad_epu8(a.n, b.n); -#else - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - uint16_t tmp = 0; - SIMDE__VECTORIZE_REDUCTION(+ : tmp) - for (size_t j = 0; j < ((sizeof(r.u8) / sizeof(r.u8[0])) / 2); - j++) { - const size_t e = j + (i * 8); - tmp += (a.u8[e] > b.u8[e]) ? (a.u8[e] - b.u8[e]) - : (b.u8[e] - a.u8[e]); - } - r.i64[i] = tmp; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set_epi8(int8_t e15, int8_t e14, int8_t e13, int8_t e12, - int8_t e11, int8_t e10, int8_t e9, int8_t e8, - int8_t e7, int8_t e6, int8_t e5, int8_t e4, - int8_t e3, int8_t e2, int8_t e1, int8_t e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set_epi8(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, e4, - e3, e2, e1, e0); -#else - r.i8[0] = e0; - r.i8[1] = e1; - r.i8[2] = e2; - r.i8[3] = e3; - r.i8[4] = e4; - r.i8[5] = e5; - r.i8[6] = e6; - r.i8[7] = e7; - r.i8[8] = e8; - r.i8[9] = e9; - r.i8[10] = e10; - r.i8[11] = e11; - r.i8[12] = e12; - r.i8[13] = e13; - r.i8[14] = e14; - r.i8[15] = e15; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set_epi16(int16_t e7, int16_t e6, int16_t e5, int16_t e4, - int16_t e3, int16_t e2, int16_t e1, int16_t e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set_epi16(e7, e6, e5, e4, e3, e2, e1, e0); -#elif defined(SIMDE_SSE2_NEON) - SIMDE_ALIGN(16) int16_t data[8] = {e0, e1, e2, e3, e4, e5, e6, e7}; - r.neon_i16 = vld1q_s16(data); -#else - r.i16[0] = e0; - r.i16[1] = e1; - r.i16[2] = e2; - r.i16[3] = e3; - r.i16[4] = e4; - r.i16[5] = e5; - r.i16[6] = e6; - r.i16[7] = e7; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set_epi32(int32_t e3, int32_t e2, int32_t e1, int32_t e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set_epi32(e3, e2, e1, e0); -#elif defined(SIMDE_SSE2_NEON) - SIMDE_ALIGN(16) int32_t data[4] = {e0, e1, e2, e3}; - r.neon_i32 = vld1q_s32(data); -#else - r.i32[0] = e0; - r.i32[1] = e1; - r.i32[2] = e2; - r.i32[3] = e3; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set_epi64(simde__m64 e1, simde__m64 e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set_epi64(e1.n, e0.n); -#else - r.i64[0] = e0.i64[0]; - r.i64[1] = e1.i64[0]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set_epi64x(int64_t e1, int64_t e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set_epi64x(e1, e0); -#elif defined(SIMDE_SSE2_NEON) - r = SIMDE__M128I_NEON_C(i64, - vcombine_s64(vdup_n_s64(e0), vdup_n_s64(e1))); -#else - r.i64[0] = e0; - r.i64[1] = e1; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_x_mm_set_epu8(uint8_t e15, uint8_t e14, uint8_t e13, - uint8_t e12, uint8_t e11, uint8_t e10, - uint8_t e9, uint8_t e8, uint8_t e7, uint8_t e6, - uint8_t e5, uint8_t e4, uint8_t e3, uint8_t e2, - uint8_t e1, uint8_t e0) -{ - simde__m128i r; - - r.u8[0] = e0; - r.u8[1] = e1; - r.u8[2] = e2; - r.u8[3] = e3; - r.u8[4] = e4; - r.u8[5] = e5; - r.u8[6] = e6; - r.u8[7] = e7; - r.u8[8] = e8; - r.u8[9] = e9; - r.u8[10] = e10; - r.u8[11] = e11; - r.u8[12] = e12; - r.u8[13] = e13; - r.u8[14] = e14; - r.u8[15] = e15; - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_x_mm_set_epu16(uint16_t e7, uint16_t e6, uint16_t e5, - uint16_t e4, uint16_t e3, uint16_t e2, - uint16_t e1, uint16_t e0) -{ - simde__m128i r; - - r.u16[0] = e0; - r.u16[1] = e1; - r.u16[2] = e2; - r.u16[3] = e3; - r.u16[4] = e4; - r.u16[5] = e5; - r.u16[6] = e6; - r.u16[7] = e7; - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_x_mm_set_epu32(uint32_t e3, uint32_t e2, uint32_t e1, - uint32_t e0) -{ - simde__m128i r; - - r.u32[0] = e0; - r.u32[1] = e1; - r.u32[2] = e2; - r.u32[3] = e3; - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_x_mm_set_epu64x(uint64_t e1, uint64_t e0) -{ - simde__m128i r; - - r.u64[0] = e0; - r.u64[1] = e1; - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_set_pd(simde_float64 e1, simde_float64 e0) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set_pd(e1, e0); -#else - r.f64[0] = e0; - r.f64[1] = e1; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_set_pd1(simde_float64 a) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set1_pd(a); -#else - r.f64[0] = a; - r.f64[1] = a; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_set_sd(simde_float64 a) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set_sd(a); -#else - r.f64[0] = a; - r.u64[1] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set1_epi8(int8_t a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set1_epi8(a); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i8 = vdupq_n_s8(a); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i8) / sizeof(r.i8[0])); i++) { - r.i8[i] = a; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set1_epi16(int16_t a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set1_epi16(a); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i16 = vdupq_n_s16(a); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = a; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set1_epi32(int32_t a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set1_epi32(a); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i32 = vdupq_n_s32(a); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = a; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set1_epi64x(int64_t a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set1_epi64x(a); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i64 = vmovq_n_s64(a); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_set1_epi64(simde__m64 a) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set1_epi64(a.n); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[0]; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_set1_pd(simde_float64 a) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_set1_pd(a); -#else - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.f64[i] = a; - } -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_setr_epi8(int8_t e15, int8_t e14, int8_t e13, int8_t e12, - int8_t e11, int8_t e10, int8_t e9, int8_t e8, - int8_t e7, int8_t e6, int8_t e5, int8_t e4, - int8_t e3, int8_t e2, int8_t e1, int8_t e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_setr_epi8(e15, e14, e13, e12, e11, e10, e9, e8, e7, e6, e5, - e4, e3, e2, e1, e0); -#elif defined(SIMDE_SSE2_NEON) - int8_t t[] = {e15, e14, e13, e12, e11, e10, e9, e8, - e7, e6, e5, e4, e3, e2, e1, e0}; - r.neon_i8 = vld1q_s8(t); -#else - r.i8[0] = e15; - r.i8[1] = e14; - r.i8[2] = e13; - r.i8[3] = e12; - r.i8[4] = e11; - r.i8[5] = e10; - r.i8[6] = e9; - r.i8[7] = e8; - r.i8[8] = e7; - r.i8[9] = e6; - r.i8[10] = e5; - r.i8[11] = e4; - r.i8[12] = e3; - r.i8[13] = e2; - r.i8[14] = e1; - r.i8[15] = e0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_setr_epi16(int16_t e7, int16_t e6, int16_t e5, int16_t e4, - int16_t e3, int16_t e2, int16_t e1, int16_t e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_setr_epi16(e7, e6, e5, e4, e3, e2, e1, e0); -#elif defined(SIMDE_SSE2_NEON) - int16_t t[] = {e7, e6, e5, e4, e3, e2, e1, e0}; - r.neon_i16 = vld1q_s16(t); -#else - r.i16[0] = e7; - r.i16[1] = e6; - r.i16[2] = e5; - r.i16[3] = e4; - r.i16[4] = e3; - r.i16[5] = e2; - r.i16[6] = e1; - r.i16[7] = e0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_setr_epi32(int32_t e3, int32_t e2, int32_t e1, int32_t e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_setr_epi32(e3, e2, e1, e0); -#elif defined(SIMDE_SSE2_NEON) - int32_t t[] = {e3, e2, e1, e0}; - r.neon_i32 = vld1q_s32(t); -#else - r.i32[0] = e3; - r.i32[1] = e2; - r.i32[2] = e1; - r.i32[3] = e0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_setr_epi64(simde__m64 e1, simde__m64 e0) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_setr_epi64(e1.n, e0.n); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i64 = vcombine_s64(e1.neon_i64, e0.neon_i64); -#else - r.i64[0] = e1.i64[0]; - r.i64[1] = e0.i64[0]; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_setr_pd(simde_float64 e1, simde_float64 e0) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_setr_pd(e1, e0); -#else - r.f64[0] = e1; - r.f64[1] = e0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_setzero_pd(void) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_setzero_pd(); -#else - r.u64[0] = 0; - r.u64[1] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_setzero_si128(void) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) - r.n = _mm_setzero_si128(); -#elif defined(SIMDE_SSE2_NEON) - r.neon_i32 = vdupq_n_s32(0); -#else - r.u64[0] = 0; - r.u64[1] = 0; -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_shuffle_epi32(simde__m128i a, const int imm8) -{ - simde__m128i r; - - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = a.i32[(imm8 >> (i * 2)) & 3]; - } - - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_shuffle_epi32(a, imm8) \ - SIMDE__M128I_C(_mm_shuffle_epi32((a).n, (imm8))) -#elif defined(SIMDE__SHUFFLE_VECTOR) -#define simde_mm_shuffle_epi32(a, imm8) \ - ({ \ - const simde__m128i simde__tmp_a_ = a; \ - (simde__m128i){.i32 = SIMDE__SHUFFLE_VECTOR( \ - 32, 16, (simde__tmp_a_).i32, \ - (simde__tmp_a_).i32, ((imm8)) & 3, \ - ((imm8) >> 2) & 3, ((imm8) >> 4) & 3, \ - ((imm8) >> 6) & 3)}; \ - }) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_shuffle_pd(simde__m128d a, simde__m128d b, const int imm8) -{ - simde__m128d r; - - r.f64[0] = ((imm8 & 1) == 0) ? a.f64[0] : a.f64[1]; - r.f64[1] = ((imm8 & 2) == 0) ? b.f64[0] : b.f64[1]; - - return r; -} -#if defined(SIMDE_SSE2_NATIVE) && !defined(__PGI) -#define simde_mm_shuffle_pd(a, b, imm8) \ - SIMDE__M128D_C(_mm_shuffle_pd((a).n, (b).n, (imm8))) -#elif defined(SIMDE__SHUFFLE_VECTOR) -#define simde_mm_shuffle_pd(a, b, imm8) \ - ({ \ - (simde__m128d){.f64 = SIMDE__SHUFFLE_VECTOR( \ - 64, 16, (a).f64, (b).f64, \ - (((imm8)) & 1), \ - (((imm8) >> 1) & 1) + 2)}; \ - }) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_shufflehi_epi16(simde__m128i a, const int imm8) -{ - simde__m128i r; - - r.i64[0] = a.i64[0]; - for (size_t i = 4; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = a.i16[((imm8 >> ((i - 4) * 2)) & 3) + 4]; - } - - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_shufflehi_epi16(a, imm8) \ - SIMDE__M128I_C(_mm_shufflehi_epi16((a).n, (imm8))) -#elif defined(SIMDE__SHUFFLE_VECTOR) -#define simde_mm_shufflehi_epi16(a, imm8) \ - ({ \ - const simde__m128i simde__tmp_a_ = a; \ - (simde__m128i){.i16 = SIMDE__SHUFFLE_VECTOR( \ - 16, 16, (simde__tmp_a_).i16, \ - (simde__tmp_a_).i16, 0, 1, 2, 3, \ - (((imm8)) & 3) + 4, \ - (((imm8) >> 2) & 3) + 4, \ - (((imm8) >> 4) & 3) + 4, \ - (((imm8) >> 6) & 3) + 4)}; \ - }) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_shufflelo_epi16(simde__m128i a, const int imm8) -{ - simde__m128i r; - - for (size_t i = 0; i < ((sizeof(r.i16) / sizeof(r.i16[0])) / 2); i++) { - r.i16[i] = a.i16[((imm8 >> (i * 2)) & 3)]; - } - r.i64[1] = a.i64[1]; - - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_shufflelo_epi16(a, imm8) \ - SIMDE__M128I_C(_mm_shufflelo_epi16((a).n, (imm8))) -#elif defined(SIMDE__SHUFFLE_VECTOR) -#define simde_mm_shufflelo_epi16(a, imm8) \ - ({ \ - const simde__m128i simde__tmp_a_ = a; \ - (simde__m128i){.i16 = SIMDE__SHUFFLE_VECTOR( \ - 16, 16, (simde__tmp_a_).i16, \ - (simde__tmp_a_).i16, (((imm8)) & 3), \ - (((imm8) >> 2) & 3), \ - (((imm8) >> 4) & 3), \ - (((imm8) >> 6) & 3), 4, 5, 6, 7)}; \ - }) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sll_epi16(simde__m128i a, simde__m128i count) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_sll_epi16(a.n, count.n)); -#else - simde__m128i r; - - if (count.u64[0] > 15) - return simde_mm_setzero_si128(); - const int s = (int)(count.u64[0]); - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u16) / sizeof(r.u16[0])); i++) { - r.u16[i] = a.u16[i] << s; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sll_epi32(simde__m128i a, simde__m128i count) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_sll_epi32(a.n, count.n)); -#else - simde__m128i r; - - if (count.u64[0] > 31) - return simde_mm_setzero_si128(); - const int s = (int)(count.u64[0]); - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = a.i32[i] << s; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sll_epi64(simde__m128i a, simde__m128i count) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_sll_epi64(a.n, count.n)); -#else - simde__m128i r; - - if (count.u64[0] > 63) - return simde_mm_setzero_si128(); - const int s = (int)(count.u64[0]); - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] << s; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_sqrt_pd(simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_sqrt_pd(a.n)); -#else - simde__m128d r; - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = sqrt(a.f64[i]); - } - - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_sqrt_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_sqrt_sd(a.n, b.n)); -#else - simde__m128d r; - r.f64[0] = sqrt(b.f64[0]); - r.f64[1] = a.f64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_srl_epi16(simde__m128i a, simde__m128i count) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_srl_epi16(a.n, count.n)); -#else - simde__m128i r; - - if (count.u64[0] > 15) - return simde_mm_setzero_si128(); - const int s = (int)(count.u64[0]); - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u16) / sizeof(r.u16[0])); i++) { - r.u16[i] = a.u16[i] >> s; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_srl_epi32(simde__m128i a, simde__m128i count) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_srl_epi32(a.n, count.n)); -#else - simde__m128i r; - - if (count.u64[0] > 31) - return simde_mm_setzero_si128(); - const int s = (int)(count.u64[0]); - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u32) / sizeof(r.u32[0])); i++) { - r.u32[i] = a.u32[i] >> s; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_srl_epi64(simde__m128i a, simde__m128i count) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_srl_epi64(a.n, count.n)); -#else - simde__m128i r; - - if (count.u64[0] > 31) - return simde_mm_setzero_si128(); - const int s = (int)(count.u64[0]); - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.u64) / sizeof(r.u64[0])); i++) { - r.u64[i] = a.u64[i] >> s; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_srai_epi16(simde__m128i a, int imm8) -{ - simde__m128i r; - - const uint16_t m = - (uint16_t)((~0U) << ((sizeof(int16_t) * CHAR_BIT) - imm8)); - - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r) / sizeof(r.u16[0])); i++) { - const uint16_t is_neg = ((uint16_t)( - ((a.u16[i]) >> ((sizeof(int16_t) * CHAR_BIT) - 1)))); - r.u16[i] = (a.u16[i] >> imm8) | (m * is_neg); - } - - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_srai_epi16(a, imm8) \ - SIMDE__M128I_C(_mm_srai_epi16((a).n, (imm8))); -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_srai_epi32(simde__m128i a, int imm8) -{ - simde__m128i r; - - const uint32_t m = - (uint32_t)((~0U) << ((sizeof(int) * CHAR_BIT) - imm8)); - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r) / sizeof(r.u32[0])); i++) { - uint32_t is_neg = ((uint32_t)( - ((a.u32[i]) >> ((sizeof(int32_t) * CHAR_BIT) - 1)))); - r.u32[i] = (a.u32[i] >> imm8) | (m * is_neg); - } - - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_srai_epi32(a, imm8) \ - SIMDE__M128I_C(_mm_srai_epi32((a).n, (imm8))) -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_srai_epi32(a, imm8) \ - SIMDE__M128I_NEON_C( \ - i32, \ - ((imm8) <= 0) \ - ? (a.neon_i32) \ - : (((imm8) > 31) \ - ? (vshrq_n_s32(vshrq_n_s32(a.neon_i32, 16), \ - 16)) \ - : (vshrq_n_s32(a.neon_i32, (imm8))))) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sra_epi16(simde__m128i a, simde__m128i count) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_sra_epi16(a.n, count.n)); -#else - simde__m128i r; - int cnt = (int)count.i64[0]; - - if (cnt > 15 || cnt < 0) { - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); - i++) { - r.u16[i] = (a.i16[i] < 0) ? 0xffff : 0x0000; - } - } else { - const uint16_t m = (uint16_t)( - (~0U) << ((sizeof(int16_t) * CHAR_BIT) - cnt)); - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); - i++) { - const uint16_t is_neg = a.i16[i] < 0; - r.u16[i] = (a.u16[i] >> cnt) | (m * is_neg); - } - } - - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sra_epi32(simde__m128i a, simde__m128i count) -{ -#if defined(SIMDE_SSE2_NATIVE) && !defined(SIMDE_BUG_GCC_BAD_MM_SRA_EPI32) - return SIMDE__M128I_C(_mm_sra_epi32(a.n, count.n)); -#else - simde__m128i r; - const uint64_t cnt = count.u64[0]; - - if (cnt > 31) { - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); - i++) { - r.u32[i] = (a.i32[i] < 0) ? UINT32_MAX : 0; - } - } else if (cnt == 0) { - memcpy(&r, &a, sizeof(r)); - } else { - const uint32_t m = (uint32_t)( - (~0U) << ((sizeof(int32_t) * CHAR_BIT) - cnt)); - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); - i++) { - const uint32_t is_neg = a.i32[i] < 0; - r.u32[i] = (a.u32[i] >> cnt) | (m * is_neg); - } - } - - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_slli_epi16(simde__m128i a, const int imm8) -{ - simde__m128i r; - const int s = (imm8 > ((int)sizeof(r.i16[0]) * CHAR_BIT) - 1) ? 0 - : imm8; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = a.i16[i] << s; - } - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_slli_epi16(a, imm8) SIMDE__M128I_C(_mm_slli_epi16(a.n, imm8)); -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_slli_epi16(a, imm8) \ - SIMDE__M128I_NEON_C( \ - i16, ((imm8) <= 0) \ - ? ((a).neon_i16) \ - : (((imm8) > 31) ? (vdupq_n_s16(0)) \ - : (vshlq_n_s16((a).neon_i16, \ - (imm8))))) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_slli_epi32(simde__m128i a, const int imm8) -{ - simde__m128i r; - const int s = (imm8 > ((int)sizeof(r.i32[0]) * CHAR_BIT) - 1) ? 0 - : imm8; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = a.i32[i] << s; - } - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_slli_epi32(a, imm8) SIMDE__M128I_C(_mm_slli_epi32(a.n, imm8)); -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_slli_epi32(a, imm8) \ - SIMDE__M128I_NEON_C( \ - i32, ((imm8) <= 0) \ - ? ((a).neon_i32) \ - : (((imm8) > 31) ? (vdupq_n_s32(0)) \ - : (vshlq_n_s32((a).neon_i32, \ - (imm8))))) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_slli_epi64(simde__m128i a, const int imm8) -{ - simde__m128i r; - const int s = (imm8 > ((int)sizeof(r.i64[0]) * CHAR_BIT) - 1) ? 0 - : imm8; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] << s; - } - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_slli_epi64(a, imm8) SIMDE__M128I_C(_mm_slli_epi64(a.n, imm8)); -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_srli_epi16(simde__m128i a, const int imm8) -{ - simde__m128i r; - const int s = (imm8 > ((int)sizeof(r.i16[0]) * CHAR_BIT) - 1) ? 0 - : imm8; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.u16[i] = a.u16[i] >> s; - } - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_srli_epi16(a, imm8) SIMDE__M128I_C(_mm_srli_epi16(a.n, imm8)); -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_srli_epi16(a, imm8) \ - SIMDE__M128I_NEON_C( \ - u16, ((imm8) <= 0) \ - ? ((a).neon_u16) \ - : (((imm8) > 31) ? (vdupq_n_u16(0)) \ - : (vshrq_n_u16((a).neon_u16, \ - (imm8))))) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_srli_epi32(simde__m128i a, const int imm8) -{ - simde__m128i r; - const int s = (imm8 > ((int)sizeof(r.i32[0]) * CHAR_BIT) - 1) ? 0 - : imm8; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.u32[i] = a.u32[i] >> s; - } - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_srli_epi32(a, imm8) SIMDE__M128I_C(_mm_srli_epi32(a.n, imm8)) -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_srli_epi32(a, imm8) \ - SIMDE__M128I_NEON_C( \ - u32, ((imm8) <= 0) \ - ? ((a).neon_u32) \ - : (((imm8) > 31) ? (vdupq_n_u32(0)) \ - : (vshrq_n_u32((a).neon_u32, \ - (imm8))))) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_srli_epi64(simde__m128i a, const int imm8) -{ - simde__m128i r; - const unsigned char s = imm8 & 255; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - if (s > 63) { - r.u64[i] = 0; - } else { - r.u64[i] = a.u64[i] >> s; - } - } - return r; -} -#if defined(SIMDE_SSE2_NATIVE) -#define simde_mm_srli_epi64(a, imm8) SIMDE__M128I_C(_mm_srli_epi64(a.n, imm8)) -#elif defined(SIMDE_SSE2_NEON) -#define simde_mm_srli_epi64(a, imm8) \ - SIMDE__M128I_NEON_C( \ - u64, \ - (((imm8)&255) < 0 || ((imm8)&255) > 63) \ - ? (vdupq_n_u64(0)) \ - : ((((imm8)&255) == 0) \ - ? (a.neon_u64) \ - : (vshrq_n_u64((a).neon_u64, (imm8)&255)))) -#endif - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_store_pd(simde_float64 mem_addr[HEDLEY_ARRAY_PARAM(2)], - simde__m128d a) -{ - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE2_NATIVE) - _mm_store_pd(mem_addr, a.n); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - memcpy(mem_addr, &a, sizeof(a)); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_store1_pd(simde_float64 mem_addr[HEDLEY_ARRAY_PARAM(2)], - simde__m128d a) -{ - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE2_NATIVE) - _mm_store1_pd(mem_addr, a.n); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - mem_addr[0] = a.f64[0]; - mem_addr[1] = a.f64[0]; -#endif -} -#define simde_mm_store_pd1(mem_addr, a) simde_mm_store1_pd(mem_addr, a) - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_store_sd(simde_float64 *mem_addr, simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_store_sd(mem_addr, a.n); -#else - memcpy(mem_addr, &a, sizeof(a.f64[0])); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_store_si128(simde__m128i *mem_addr, simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_store_si128(&mem_addr->n, a.n); -#elif defined(SIMDE_SSE2_NEON) - vst1q_s32((int32_t *)mem_addr, a.neon_i32); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - memcpy(mem_addr, &a, sizeof(a)); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storeh_pd(simde_float64 *mem_addr, simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_storeh_pd(mem_addr, a.n); -#else - *mem_addr = a.f64[1]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storel_epi64(simde__m128i *mem_addr, simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_storel_epi64(&(mem_addr->n), a.n); -#elif defined(SIMDE_SSE2_NEON) - mem_addr->i64[0] = vgetq_lane_s64(a.neon_i64, 0); -#else - mem_addr->i64[0] = a.i64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storel_pd(simde_float64 *mem_addr, simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_storel_pd(mem_addr, a.n); -#else - *mem_addr = a.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storer_pd(simde_float64 mem_addr[2], simde__m128d a) -{ - simde_assert_aligned(16, mem_addr); - -#if defined(SIMDE_SSE2_NATIVE) - _mm_storer_pd(mem_addr, a.n); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - mem_addr[0] = a.f64[1]; - mem_addr[1] = a.f64[0]; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storeu_pd(simde_float64 *mem_addr, simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_storeu_pd(mem_addr, a.n); -#else - memcpy(mem_addr, &a, sizeof(a)); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_storeu_si128(simde__m128i *mem_addr, simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_storeu_si128(&mem_addr->n, a.n); -#elif defined(SIMDE_SSE2_NEON) - int32_t v[4]; - vst1q_s32(v, a.neon_i32); - memcpy(mem_addr, v, sizeof(v)); -#else - memcpy(mem_addr, &a, sizeof(a)); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_stream_pd(simde_float64 mem_addr[HEDLEY_ARRAY_PARAM(2)], - simde__m128d a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_stream_pd(mem_addr, a.n); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - memcpy(mem_addr, &a, sizeof(a)); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_stream_si128(simde__m128i *mem_addr, simde__m128i a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_stream_si128(&mem_addr->n, a.n); -#else - SIMDE__ASSUME_ALIGNED(mem_addr, 16); - memcpy(mem_addr, &a, sizeof(a)); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_stream_si32(int32_t *mem_addr, int32_t a) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_stream_si32(mem_addr, a); -#else - *mem_addr = a; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_stream_si64(int64_t *mem_addr, int64_t a) -{ -#if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE_ARCH_AMD64) -#if defined(SIMDE__REALLY_GCC) && !HEDLEY_GCC_VERSION_CHECK(4, 8, 0) - *mem_addr = a; -#elif defined(__GNUC__) - _mm_stream_si64((long long *)mem_addr, a); -#else - _mm_stream_si64(mem_addr, a); -#endif -#else - *mem_addr = a; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sub_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_sub_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i8, vsubq_s8(a.neon_i8, b.neon_i8)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i8) / sizeof(r.i8[0])); i++) { - r.i8[i] = a.i8[i] - b.i8[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sub_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_sub_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i16, vsubq_s16(a.neon_i16, b.neon_i16)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i16) / sizeof(r.i16[0])); i++) { - r.i16[i] = a.i16[i] - b.i16[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sub_epi32(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_sub_epi32(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i32, vsubq_s32(a.neon_i32, b.neon_i32)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = a.i32[i] - b.i32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_sub_epi64(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_sub_epi64(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i64, vsubq_s64(a.neon_i64, b.neon_i64)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] - b.i64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_sub_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_sub_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.f64) / sizeof(r.f64[0])); i++) { - r.f64[i] = a.f64[i] - b.f64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_sub_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_sub_sd(a.n, b.n)); -#else - simde__m128d r; - r.f64[0] = a.f64[0] - b.f64[0]; - r.f64[1] = a.f64[1]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m64 simde_mm_sub_si64(simde__m64 a, simde__m64 b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M64_C(_mm_sub_si64(a.n, b.n)); -#else - simde__m64 r; - r.i64[0] = a.i64[0] - b.i64[0]; - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_subs_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_subs_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i8, vqsubq_s8(a.neon_i8, b.neon_i8)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r) / sizeof(r.i8[0])); i++) { - if (((b.i8[i]) > 0 && (a.i8[i]) < INT8_MIN + (b.i8[i]))) { - r.i8[i] = INT8_MIN; - } else if ((b.i8[i]) < 0 && (a.i8[i]) > INT8_MAX + (b.i8[i])) { - r.i8[i] = INT8_MAX; - } else { - r.i8[i] = (a.i8[i]) - (b.i8[i]); - } - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_subs_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_subs_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i16, vqsubq_s16(a.neon_i16, b.neon_i16)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r) / sizeof(r.i16[0])); i++) { - if (((b.i16[i]) > 0 && (a.i16[i]) < INT16_MIN + (b.i16[i]))) { - r.i16[i] = INT16_MIN; - } else if ((b.i16[i]) < 0 && - (a.i16[i]) > INT16_MAX + (b.i16[i])) { - r.i16[i] = INT16_MAX; - } else { - r.i16[i] = (a.i16[i]) - (b.i16[i]); - } - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_subs_epu8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_subs_epu8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(u8, vqsubq_u8(a.neon_u8, b.neon_u8)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r) / sizeof(r.i8[0])); i++) { - const int32_t x = a.u8[i] - b.u8[i]; - if (x < 0) { - r.u8[i] = 0; - } else if (x > UINT8_MAX) { - r.u8[i] = UINT8_MAX; - } else { - r.u8[i] = (uint8_t)x; - } - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_subs_epu16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_subs_epu16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(u16, vqsubq_u16(a.neon_u16, b.neon_u16)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r) / sizeof(r.i16[0])); i++) { - const int32_t x = a.u16[i] - b.u16[i]; - if (x < 0) { - r.u16[i] = 0; - } else if (x > UINT16_MAX) { - r.u16[i] = UINT16_MAX; - } else { - r.u16[i] = (uint16_t)x; - } - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomieq_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_ucomieq_sd(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f64[0] == b.f64[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomige_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_ucomige_sd(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f64[0] >= b.f64[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomigt_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_ucomigt_sd(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f64[0] > b.f64[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomile_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_ucomile_sd(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f64[0] <= b.f64[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomilt_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_ucomilt_sd(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f64[0] < b.f64[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -int simde_mm_ucomineq_sd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return _mm_ucomineq_sd(a.n, b.n); -#else - fenv_t envp; - int x = feholdexcept(&envp); - int r = a.f64[0] != b.f64[0]; - if (HEDLEY_LIKELY(x == 0)) - fesetenv(&envp); - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_undefined_pd(void) -{ - simde__m128d r; - -#if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE__HAVE_UNDEFINED128) - r.n = _mm_undefined_pd(); -#else - r = simde_mm_setzero_pd(); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_undefined_si128(void) -{ - simde__m128i r; - -#if defined(SIMDE_SSE2_NATIVE) && defined(SIMDE__HAVE_UNDEFINED128) - r.n = _mm_undefined_si128(); -#else - r = simde_mm_setzero_si128(); -#endif - - return r; -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_lfence(void) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_lfence(); -#else - simde_mm_sfence(); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -void simde_mm_mfence(void) -{ -#if defined(SIMDE_SSE2_NATIVE) - _mm_mfence(); -#else - simde_mm_sfence(); -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_unpackhi_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_unpackhi_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - int8x8_t a1 = vreinterpret_s8_s16(vget_high_s16(a.neon_i16)); - int8x8_t b1 = vreinterpret_s8_s16(vget_high_s16(b.neon_i16)); - int8x8x2_t result = vzip_s8(a1, b1); - return SIMDE__M128I_NEON_C(i8, - vcombine_s8(result.val[0], result.val[1])); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.i8[0])) / 2); i++) { - r.i8[(i * 2)] = a.i8[i + ((sizeof(r) / sizeof(r.i8[0])) / 2)]; - r.i8[(i * 2) + 1] = - b.i8[i + ((sizeof(r) / sizeof(r.i8[0])) / 2)]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_unpackhi_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_unpackhi_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - int16x4_t a1 = vget_high_s16(a.neon_i16); - int16x4_t b1 = vget_high_s16(b.neon_i16); - int16x4x2_t result = vzip_s16(a1, b1); - return SIMDE__M128I_NEON_C(i16, - vcombine_s16(result.val[0], result.val[1])); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.i16[0])) / 2); i++) { - r.i16[(i * 2)] = - a.i16[i + ((sizeof(r) / sizeof(r.i16[0])) / 2)]; - r.i16[(i * 2) + 1] = - b.i16[i + ((sizeof(r) / sizeof(r.i16[0])) / 2)]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_unpackhi_epi32(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_unpackhi_epi32(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - int32x2_t a1 = vget_high_s32(a.neon_i32); - int32x2_t b1 = vget_high_s32(b.neon_i32); - int32x2x2_t result = vzip_s32(a1, b1); - return SIMDE__M128I_NEON_C(i32, - vcombine_s32(result.val[0], result.val[1])); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.i32[0])) / 2); i++) { - r.i32[(i * 2)] = - a.i32[i + ((sizeof(r) / sizeof(r.i32[0])) / 2)]; - r.i32[(i * 2) + 1] = - b.i32[i + ((sizeof(r) / sizeof(r.i32[0])) / 2)]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_unpackhi_epi64(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_unpackhi_epi64(a.n, b.n)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.i64[0])) / 2); i++) { - r.i64[(i * 2)] = - a.i64[i + ((sizeof(r) / sizeof(r.i64[0])) / 2)]; - r.i64[(i * 2) + 1] = - b.i64[i + ((sizeof(r) / sizeof(r.i64[0])) / 2)]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_unpackhi_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_unpackhi_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.f64[0])) / 2); i++) { - r.f64[(i * 2)] = - a.f64[i + ((sizeof(r) / sizeof(r.f64[0])) / 2)]; - r.f64[(i * 2) + 1] = - b.f64[i + ((sizeof(r) / sizeof(r.f64[0])) / 2)]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_unpacklo_epi8(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_unpacklo_epi8(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - int8x8_t a1 = vreinterpret_s8_s16(vget_low_s16(a.neon_i16)); - int8x8_t b1 = vreinterpret_s8_s16(vget_low_s16(b.neon_i16)); - int8x8x2_t result = vzip_s8(a1, b1); - return SIMDE__M128I_NEON_C(i8, - vcombine_s8(result.val[0], result.val[1])); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.i8[0])) / 2); i++) { - r.i8[(i * 2)] = a.i8[i]; - r.i8[(i * 2) + 1] = b.i8[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_unpacklo_epi16(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_unpacklo_epi16(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - int16x4_t a1 = vget_low_s16(a.neon_i16); - int16x4_t b1 = vget_low_s16(b.neon_i16); - int16x4x2_t result = vzip_s16(a1, b1); - return SIMDE__M128I_NEON_C(i16, - vcombine_s16(result.val[0], result.val[1])); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.i16[0])) / 2); i++) { - r.i16[(i * 2)] = a.i16[i]; - r.i16[(i * 2) + 1] = b.i16[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_unpacklo_epi32(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_unpacklo_epi32(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - int32x2_t a1 = vget_low_s32(a.neon_i32); - int32x2_t b1 = vget_low_s32(b.neon_i32); - int32x2x2_t result = vzip_s32(a1, b1); - return SIMDE__M128I_NEON_C(i32, - vcombine_s32(result.val[0], result.val[1])); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.i32[0])) / 2); i++) { - r.i32[(i * 2)] = a.i32[i]; - r.i32[(i * 2) + 1] = b.i32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_unpacklo_epi64(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_unpacklo_epi64(a.n, b.n)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.i64[0])) / 2); i++) { - r.i64[(i * 2)] = a.i64[i]; - r.i64[(i * 2) + 1] = b.i64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_unpacklo_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_unpacklo_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < ((sizeof(r) / sizeof(r.f64[0])) / 2); i++) { - r.f64[(i * 2)] = a.f64[i]; - r.f64[(i * 2) + 1] = b.f64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128d simde_mm_xor_pd(simde__m128d a, simde__m128d b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128D_C(_mm_xor_pd(a.n, b.n)); -#else - simde__m128d r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i64) / sizeof(r.i64[0])); i++) { - r.i64[i] = a.i64[i] ^ b.i64[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_mm_xor_si128(simde__m128i a, simde__m128i b) -{ -#if defined(SIMDE_SSE2_NATIVE) - return SIMDE__M128I_C(_mm_xor_si128(a.n, b.n)); -#elif defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i32, veorq_s32(a.neon_i32, b.neon_i32)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = a.i32[i] ^ b.i32[i]; - } - return r; -#endif -} - -SIMDE__FUNCTION_ATTRIBUTES -simde__m128i simde_x_mm_not_si128(simde__m128i a) -{ -#if defined(SIMDE_SSE2_NEON) - return SIMDE__M128I_NEON_C(i32, vmvnq_s32(a.neon_i32)); -#else - simde__m128i r; - SIMDE__VECTORIZE - for (size_t i = 0; i < (sizeof(r.i32) / sizeof(r.i32[0])); i++) { - r.i32[i] = ~(a.i32[i]); - } - return r; -#endif -} - -SIMDE__END_DECLS - -#endif /* !defined(SIMDE__SSE2_H) */ diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index b081121..3b63e21 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -46,6 +46,7 @@ elseif("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") add_subdirectory(linux-pulseaudio) add_subdirectory(linux-v4l2) add_subdirectory(linux-jack) + add_subdirectory(linux-alsa) endif() option(BUILD_BROWSER "Build browser plugin" OFF) diff --git a/plugins/coreaudio-encoder/CMakeLists.txt b/plugins/coreaudio-encoder/CMakeLists.txt index e6dd2b4..a300a70 100644 --- a/plugins/coreaudio-encoder/CMakeLists.txt +++ b/plugins/coreaudio-encoder/CMakeLists.txt @@ -4,6 +4,10 @@ set(coreaudio-encoder_SOURCES encoder.cpp) if (WIN32) + set(MODULE_DESCRIPTION "OBS Core Audio encoder") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in coreaudio-encoder.rc) + list(APPEND coreaudio-encoder_SOURCES + coreaudio-encoder.rc) set(coreaudio-encoder_HEADERS windows-imports.h) set(coreaudio-encoder_LIBS ) diff --git a/plugins/decklink/decklink-output.cpp b/plugins/decklink/decklink-output.cpp index 431a9c5..5a97dba 100644 --- a/plugins/decklink/decklink-output.cpp +++ b/plugins/decklink/decklink-output.cpp @@ -60,6 +60,9 @@ static bool decklink_output_start(void *data) device.Set(deviceEnum->FindByHash(decklink->deviceHash)); + if (!device) + return false; + DeckLinkDeviceMode *mode = device->FindOutputMode(decklink->modeID); decklink->SetSize(mode->GetWidth(), mode->GetHeight()); diff --git a/plugins/decklink/win/CMakeLists.txt b/plugins/decklink/win/CMakeLists.txt index 005dbb8..bdab65e 100644 --- a/plugins/decklink/win/CMakeLists.txt +++ b/plugins/decklink/win/CMakeLists.txt @@ -31,6 +31,8 @@ set(win-decklink_HEADERS ../util.hpp ) +set(MODULE_DESCRIPTION "OBS DeckLink Windows module") +configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in win-decklink.rc) set(win-decklink_SOURCES ../plugin-main.cpp ../decklink-devices.cpp @@ -46,7 +48,7 @@ set(win-decklink_SOURCES ../audio-repack.c platform.cpp ../util.cpp - ) + win-decklink.rc) add_idl_files(win-decklink-sdk_GENERATED_FILES ${win-decklink-sdk_IDLS} diff --git a/plugins/image-source/CMakeLists.txt b/plugins/image-source/CMakeLists.txt index 56eb5fc..6f983ed 100644 --- a/plugins/image-source/CMakeLists.txt +++ b/plugins/image-source/CMakeLists.txt @@ -10,6 +10,13 @@ set(image-source_SOURCES color-source.c obs-slideshow.c) +if(WIN32) + set(MODULE_DESCRIPTION "OBS image module") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in image-source.rc) + list(APPEND image-source_SOURCES + image-source.rc) +endif() + add_library(image-source MODULE ${image-source_SOURCES}) target_link_libraries(image-source diff --git a/plugins/linux-jack/jack-wrapper.c b/plugins/linux-jack/jack-wrapper.c index b733a6f..f639b0c 100644 --- a/plugins/linux-jack/jack-wrapper.c +++ b/plugins/linux-jack/jack-wrapper.c @@ -43,6 +43,8 @@ static enum speaker_layout jack_channels_to_obs_speakers(uint_fast32_t channels) return SPEAKERS_STEREO; case 3: return SPEAKERS_2POINT1; + case 4: + return SPEAKERS_4POINT0; case 5: return SPEAKERS_4POINT1; case 6: diff --git a/plugins/linux-v4l2/v4l2-controls.c b/plugins/linux-v4l2/v4l2-controls.c index 1ffdab8..7034050 100644 --- a/plugins/linux-v4l2/v4l2-controls.c +++ b/plugins/linux-v4l2/v4l2-controls.c @@ -95,7 +95,7 @@ static inline bool valid_control(struct v4l2_queryctrl *qctrl) return (qctrl->flags & INVALID_CONTROL_FLAGS) == 0; } -static inline bool add_control_property(obs_properties_t *props, +static inline void add_control_property(obs_properties_t *props, obs_data_t *settings, int_fast32_t dev, struct v4l2_queryctrl *qctrl) { diff --git a/plugins/mac-capture/window-utils.h b/plugins/mac-capture/window-utils.h index da0743a..588e9ed 100644 --- a/plugins/mac-capture/window-utils.h +++ b/plugins/mac-capture/window-utils.h @@ -6,6 +6,7 @@ struct cocoa_window { CGWindowID window_id; + int owner_pid; pthread_mutex_t name_lock; NSString *owner_name; diff --git a/plugins/mac-capture/window-utils.m b/plugins/mac-capture/window-utils.m index 0380df6..aa2a390 100644 --- a/plugins/mac-capture/window-utils.m +++ b/plugins/mac-capture/window-utils.m @@ -60,8 +60,11 @@ bool find_window(cocoa_window_t cw, obs_data_t *settings, bool force) NSNumber *window_id = (NSNumber *)dict[WINDOW_NUMBER]; cw->window_id = window_id.intValue; + NSNumber *owner_pid = (NSNumber *)dict[OWNER_PID]; + cw->owner_pid = owner_pid.intValue; obs_data_set_int(settings, "window", cw->window_id); + obs_data_set_int(settings, "owner_pid", cw->owner_pid); return true; } @@ -78,7 +81,41 @@ void init_window(cocoa_window_t cw, obs_data_t *settings) cw->window_name = @(obs_data_get_string(settings, "window_name")); [cw->owner_name retain]; [cw->window_name retain]; - find_window(cw, settings, true); + + // Find initial window. + pthread_mutex_lock(&cw->name_lock); + + if (!cw->window_name.length && !cw->owner_name.length) + goto invalid_name; + + NSNumber *owner_pid = @(obs_data_get_int(settings, "owner_pid")); + NSNumber *window_id = @(obs_data_get_int(settings, "window")); + for (NSDictionary *dict in enumerate_windows()) { + bool owner_names_match = + [cw->owner_name isEqualToString:dict[OWNER_NAME]]; + bool ids_match = + [owner_pid isEqualToNumber:dict[OWNER_PID]] && + [window_id isEqualToNumber:dict[WINDOW_NUMBER]]; + bool window_names_match = + [cw->window_name isEqualToString:dict[WINDOW_NAME]]; + + if (owner_names_match && (ids_match || window_names_match)) { + pthread_mutex_unlock(&cw->name_lock); + + NSNumber *window_id = (NSNumber *)dict[WINDOW_NUMBER]; + cw->window_id = window_id.intValue; + NSNumber *owner_pid = (NSNumber *)dict[OWNER_PID]; + cw->owner_pid = owner_pid.intValue; + + obs_data_set_int(settings, "window", cw->window_id); + obs_data_set_int(settings, "owner_pid", cw->owner_pid); + return; + } + } + +invalid_name: + pthread_mutex_unlock(&cw->name_lock); + return; } void destroy_window(cocoa_window_t cw) @@ -99,6 +136,7 @@ void update_window(cocoa_window_t cw, obs_data_t *settings) [cw->window_name retain]; pthread_mutex_unlock(&cw->name_lock); + cw->owner_pid = obs_data_get_int(settings, "owner_pid"); cw->window_id = obs_data_get_int(settings, "window"); } diff --git a/plugins/mac-syphon/CMakeLists.txt b/plugins/mac-syphon/CMakeLists.txt index 66ca8ae..a67b94f 100644 --- a/plugins/mac-syphon/CMakeLists.txt +++ b/plugins/mac-syphon/CMakeLists.txt @@ -55,6 +55,9 @@ set(syphon_SOURCES syphon-framework/SyphonServerDirectory.m ) +add_library(syphon-framework ${syphon_HEADERS} + ${syphon_SOURCES}) + set(mac-syphon_HEADERS ) @@ -70,15 +73,17 @@ add_definitions(-DSYPHON_UNIQUE_CLASS_NAME_PREFIX=OBS_ -include add_library(mac-syphon MODULE ${mac-syphon_SOURCES} - ${mac-syphon_HEADERS} - ${syphon_HEADERS} - ${syphon_SOURCES}) + ${mac-syphon_HEADERS}) target_link_libraries(mac-syphon libobs + syphon-framework ${COCOA} ${IOSURF} ${SCRIPTINGBRIDGE} ${OPENGL_gl_LIBRARY}) +set_property (TARGET mac-syphon APPEND_STRING PROPERTY + COMPILE_FLAGS "-fobjc-arc") + install_obs_plugin_with_data(mac-syphon data) diff --git a/plugins/mac-syphon/syphon.m b/plugins/mac-syphon/syphon.m index 61d452d..8d93dbf 100644 --- a/plugins/mac-syphon/syphon.m +++ b/plugins/mac-syphon/syphon.m @@ -41,12 +41,6 @@ struct syphon { }; typedef struct syphon *syphon_t; -static inline void objc_release(NSObject **obj) -{ - [*obj release]; - *obj = nil; -} - static inline void update_properties(syphon_t s) { obs_source_update_properties(s->source); @@ -101,10 +95,7 @@ static void stop_client(syphon_t s) obs_enter_graphics(); if (s->client) { - @autoreleasepool { - [s->client stop]; - objc_release(&s->client); - } + [s->client stop]; } if (s->tex) { @@ -178,16 +169,6 @@ static inline void check_description(syphon_t s, NSDictionary *desc) surfaces_string.UTF8String); } -static inline bool update_string(NSString **str, NSString *new) -{ - if (!new) - return false; - - [*str release]; - *str = [new retain]; - return true; -} - static inline void handle_new_frame(syphon_t s, SYPHON_CLIENT_UNIQUE_CLASS_NAME *client) { @@ -233,35 +214,26 @@ static void create_client(syphon_t s) NSDictionary *desc = find_by_uuid(servers, s->uuid); if (!desc) { desc = servers[0]; - if (update_string(&s->uuid, - desc[SyphonServerDescriptionUUIDKey])) + if (![s->uuid isEqualToString: + desc[SyphonServerDescriptionUUIDKey]]) { s->uuid_changed = true; + } } check_version(s, desc); check_description(s, desc); - @autoreleasepool { - s->client = [[SYPHON_CLIENT_UNIQUE_CLASS_NAME alloc] - initWithServerDescription:desc - options:nil - newFrameHandler:^( - SYPHON_CLIENT_UNIQUE_CLASS_NAME - *client) { - handle_new_frame(s, client); - }]; - } + s->client = [[SYPHON_CLIENT_UNIQUE_CLASS_NAME alloc] + initWithServerDescription:desc + options:nil + newFrameHandler:^( + SYPHON_CLIENT_UNIQUE_CLASS_NAME *client) { + handle_new_frame(s, client); + }]; s->active = true; } -static inline void release_settings(syphon_t s) -{ - [s->app_name release]; - [s->name release]; - [s->uuid release]; -} - static inline bool load_syphon_settings(syphon_t s, obs_data_t *settings) { NSString *app_name = @(obs_data_get_string(settings, "app_name")); @@ -275,10 +247,9 @@ static inline bool load_syphon_settings(syphon_t s, obs_data_t *settings) if ([uuid isEqual:s->uuid] && equal_names) return false; - release_settings(s); - s->app_name = [app_name retain]; - s->name = [name retain]; - s->uuid = [uuid retain]; + s->app_name = app_name; + s->name = name; + s->uuid = uuid; s->uuid_changed = false; return true; } @@ -299,10 +270,12 @@ static inline void update_from_announce(syphon_t s, NSDictionary *info) !([app_name isEqual:s->app_name] && [name isEqual:s->name])) return; - update_string(&s->app_name, app_name); - update_string(&s->name, name); - if (update_string(&s->uuid, uuid)) + s->app_name = app_name; + s->name = name; + if (![s->uuid isEqualToString:uuid]) { + s->uuid = uuid; s->uuid_changed = true; + } create_client(s); } @@ -324,8 +297,6 @@ static inline void update_inject_state(syphon_t s, NSDictionary *info, if (!(s->inject_server_found = announce)) { s->inject_wait_time = 0.f; - - objc_release(&s->inject_uuid); LOG(LOG_INFO, "Injected server retired: " "[%s] InjectedSyphon (%s)", @@ -336,7 +307,7 @@ static inline void update_inject_state(syphon_t s, NSDictionary *info, if (s->inject_uuid) //TODO: track multiple injected instances? return; - s->inject_uuid = [uuid retain]; + s->inject_uuid = uuid; LOG(LOG_INFO, "Injected server found: [%s] %s (%s)", app_name.UTF8String, name.UTF8String, uuid.UTF8String); } @@ -487,26 +458,31 @@ static void *syphon_create_internal(obs_data_t *settings, obs_source_t *source) s->source = source; - if (!init_obs_graphics_objects(s)) - goto fail; + if (!init_obs_graphics_objects(s)) { + syphon_destroy_internal(s); + return NULL; + } - if (!load_syphon_settings(s, settings)) - goto fail; + if (!load_syphon_settings(s, settings)) { + syphon_destroy_internal(s); + return NULL; + } const char *inject_info = obs_data_get_string(settings, "application"); s->inject_info = obs_data_create_from_json(inject_info); s->inject_active = obs_data_get_bool(settings, "inject"); s->inject_app = @(obs_data_get_string(s->inject_info, "name")); - if (s->inject_app) - [s->inject_app retain]; - - if (!create_syphon_listeners(s)) - goto fail; + if (!create_syphon_listeners(s)) { + syphon_destroy_internal(s); + return NULL; + } NSWorkspace *ws = [NSWorkspace sharedWorkspace]; - if (!create_applications_observer(s, ws)) - goto fail; + if (!create_applications_observer(s, ws)) { + syphon_destroy_internal(s); + return NULL; + } if (s->inject_active) find_and_inject_target(s, ws.runningApplications, false); @@ -519,10 +495,6 @@ static void *syphon_create_internal(obs_data_t *settings, obs_source_t *source) obs_data_get_bool(settings, "allow_transparency"); return s; - -fail: - syphon_destroy_internal(s); - return NULL; } static void *syphon_create(obs_data_t *settings, obs_source_t *source) @@ -550,15 +522,9 @@ static inline void syphon_destroy_internal(syphon_t s) [ws removeObserver:s->launch_listener forKeyPath:NSStringFromSelector(@selector (runningApplications))]; - objc_release(&s->launch_listener); - - objc_release(&s->inject_app); - objc_release(&s->inject_uuid); obs_data_release(s->inject_info); - release_settings(s); - obs_enter_graphics(); stop_client(s); @@ -1198,11 +1164,7 @@ static inline void update_inject(syphon_t s, obs_data_t *settings) obs_data_t *prev = s->inject_info; s->inject_info = obs_data_create_from_json(inject_str); - NSString *prev_app = s->inject_app; - s->inject_app = [@(obs_data_get_string(s->inject_info, "name")) retain]; - [prev_app release]; - - objc_release(&s->inject_uuid); + s->inject_app = @(obs_data_get_string(s->inject_info, "name")); SyphonServerDirectory *ssd = [SyphonServerDirectory sharedDirectory]; NSArray *servers = [ssd serversMatchingName:@"InjectedSyphon" diff --git a/plugins/obs-ffmpeg/CMakeLists.txt b/plugins/obs-ffmpeg/CMakeLists.txt index a9551b2..007b053 100644 --- a/plugins/obs-ffmpeg/CMakeLists.txt +++ b/plugins/obs-ffmpeg/CMakeLists.txt @@ -46,9 +46,12 @@ if(ENABLE_FFMPEG_LOGGING) endif() if(WIN32) + set(MODULE_DESCRIPTION "OBS FFmpeg module") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obs-ffmpeg.rc) list(APPEND obs-ffmpeg_SOURCES jim-nvenc.c - jim-nvenc-helpers.c) + jim-nvenc-helpers.c + obs-ffmpeg.rc) list(APPEND obs-ffmpeg_HEADERS jim-nvenc.h) endif() diff --git a/plugins/obs-ffmpeg/data/locale/en-US.ini b/plugins/obs-ffmpeg/data/locale/en-US.ini index ffd5034..d140a10 100644 --- a/plugins/obs-ffmpeg/data/locale/en-US.ini +++ b/plugins/obs-ffmpeg/data/locale/en-US.ini @@ -58,3 +58,11 @@ ReplayBuffer.Save="Save Replay" HelperProcessFailed="Unable to start the recording helper process. Check that OBS files have not been blocked or removed by any 3rd party antivirus / security software." UnableToWritePath="Unable to write to %1. Make sure you're using a recording path which your user account is allowed to write to and that there is sufficient disk space." WarnWindowsDefender="If Windows 10 Ransomware Protection is enabled it can also cause this error. Try turning off controlled folder access in Windows Security / Virus & threat protection settings." + +NVENC.Error="Failed to open NVENC codec: %1" +NVENC.GenericError="Check your video drivers are up to date. Try closing other recording software which might be using NVENC such as NVIDIA Shadowplay or Windows 10 Game DVR." +NVENC.BadGPUIndex="You have selected GPU %1 in your output encoder settings. Set this back to 0 and try again." +NVENC.OutdatedDriver="Your current video card driver does not support this NVENC version, please update your drivers." +NVENC.UnsupportedDevice="NVENC Error: Unsupported device. Check your video card supports NVENC and that the drivers are up to date." +NVENC.TooManySessions="NVENC Error: Too many concurrent sessions. Try closing other recording software which might be using NVENC such as NVIDIA Shadowplay or Windows 10 Game DVR." +NVENC.CheckDrivers="Please check your video drivers are up to date." diff --git a/plugins/obs-ffmpeg/jim-nvenc-helpers.c b/plugins/obs-ffmpeg/jim-nvenc-helpers.c index 2caa89c..bf6b58e 100644 --- a/plugins/obs-ffmpeg/jim-nvenc-helpers.c +++ b/plugins/obs-ffmpeg/jim-nvenc-helpers.c @@ -1,6 +1,7 @@ #include "jim-nvenc.h" #include #include +#include static void *nvenc_lib = NULL; static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER; @@ -9,18 +10,40 @@ NV_CREATE_INSTANCE_FUNC nv_create_instance = NULL; #define error(format, ...) blog(LOG_ERROR, "[jim-nvenc] " format, ##__VA_ARGS__) -static inline bool nv_failed(NVENCSTATUS err, const char *func, - const char *call) +bool nv_failed(obs_encoder_t *encoder, NVENCSTATUS err, const char *func, + const char *call) { - if (err == NV_ENC_SUCCESS) + struct dstr error_message = {0}; + + switch (err) { + case NV_ENC_SUCCESS: return false; + case NV_ENC_ERR_OUT_OF_MEMORY: + obs_encoder_set_last_error( + encoder, obs_module_text("NVENC.TooManySessions")); + break; + + case NV_ENC_ERR_UNSUPPORTED_DEVICE: + obs_encoder_set_last_error( + encoder, obs_module_text("NVENC.UnsupportedDevice")); + break; + + default: + dstr_printf(&error_message, + "NVENC Error: %s: %s failed: %d (%s)", func, call, + (int)err, nv_error_name(err)); + obs_encoder_set_last_error(encoder, error_message.array); + dstr_free(&error_message); + break; + } + error("%s: %s failed: %d (%s)", func, call, (int)err, nv_error_name(err)); return true; } -#define NV_FAILED(x) nv_failed(x, __FUNCTION__, #x) +#define NV_FAILED(e, x) nv_failed(e, x, __FUNCTION__, #x) bool load_nvenc_lib(void) { @@ -83,7 +106,7 @@ const char *nv_error_name(NVENCSTATUS err) return "Unknown Error"; } -static inline bool init_nvenc_internal(void) +static inline bool init_nvenc_internal(obs_encoder_t *encoder) { static bool initialized = false; static bool success = false; @@ -95,17 +118,24 @@ static inline bool init_nvenc_internal(void) NV_MAX_VER_FUNC nv_max_ver = (NV_MAX_VER_FUNC)load_nv_func( "NvEncodeAPIGetMaxSupportedVersion"); if (!nv_max_ver) { + obs_encoder_set_last_error( + encoder, + "Missing NvEncodeAPIGetMaxSupportedVersion, check " + "your video card drivers are up to date."); return false; } uint32_t ver = 0; - if (NV_FAILED(nv_max_ver(&ver))) { + if (NV_FAILED(encoder, nv_max_ver(&ver))) { return false; } uint32_t cur_ver = (NVENCAPI_MAJOR_VERSION << 4) | NVENCAPI_MINOR_VERSION; if (cur_ver > ver) { + obs_encoder_set_last_error( + encoder, obs_module_text("NVENC.OutdatedDriver")); + error("Current driver version does not support this NVENC " "version, please upgrade your driver"); return false; @@ -114,10 +144,13 @@ static inline bool init_nvenc_internal(void) nv_create_instance = (NV_CREATE_INSTANCE_FUNC)load_nv_func( "NvEncodeAPICreateInstance"); if (!nv_create_instance) { + obs_encoder_set_last_error( + encoder, "Missing NvEncodeAPICreateInstance, check " + "your video card drivers are up to date."); return false; } - if (NV_FAILED(nv_create_instance(&nv))) { + if (NV_FAILED(encoder, nv_create_instance(&nv))) { return false; } @@ -125,12 +158,12 @@ static inline bool init_nvenc_internal(void) return true; } -bool init_nvenc(void) +bool init_nvenc(obs_encoder_t *encoder) { bool success; pthread_mutex_lock(&init_mutex); - success = init_nvenc_internal(); + success = init_nvenc_internal(encoder); pthread_mutex_unlock(&init_mutex); return success; diff --git a/plugins/obs-ffmpeg/jim-nvenc.c b/plugins/obs-ffmpeg/jim-nvenc.c index 9278572..5856115 100644 --- a/plugins/obs-ffmpeg/jim-nvenc.c +++ b/plugins/obs-ffmpeg/jim-nvenc.c @@ -81,18 +81,7 @@ struct nv_bitstream { HANDLE event; }; -static inline bool nv_failed(struct nvenc_data *enc, NVENCSTATUS err, - const char *func, const char *call) -{ - if (err == NV_ENC_SUCCESS) - return false; - - error("%s: %s failed: %d (%s)", func, call, (int)err, - nv_error_name(err)); - return true; -} - -#define NV_FAILED(x) nv_failed(enc, x, __FUNCTION__, #x) +#define NV_FAILED(x) nv_failed(enc->encoder, x, __FUNCTION__, #x) static bool nv_bitstream_init(struct nvenc_data *enc, struct nv_bitstream *bs) { @@ -400,7 +389,8 @@ static bool init_encoder(struct nvenc_data *enc, obs_data_t *settings) err = nv.nvEncGetEncodePresetConfig(enc->session, NV_ENC_CODEC_H264_GUID, nv_preset, &preset_config); - if (nv_failed(enc, err, __FUNCTION__, "nvEncGetEncodePresetConfig")) { + if (nv_failed(enc->encoder, err, __FUNCTION__, + "nvEncGetEncodePresetConfig")) { return false; } @@ -578,16 +568,19 @@ static void *nvenc_create(obs_data_t *settings, obs_encoder_t *encoder) * gpu other than the one OBS is currently running on. */ int gpu = (int)obs_data_get_int(settings, "gpu"); if (gpu != 0) { + info("different GPU selected by user, falling back to ffmpeg"); goto fail; } if (obs_encoder_scaling_enabled(encoder)) { + info("scaling enabled, falling back to ffmpeg"); goto fail; } if (!obs_nv12_tex_active()) { + info("nv12 not active, falling back to ffmpeg"); goto fail; } - if (!init_nvenc()) { + if (!init_nvenc(encoder)) { goto fail; } if (NV_FAILED(nv_create_instance(&init))) { @@ -766,7 +759,8 @@ static bool get_encoded_packet(struct nvenc_data *enc, bool finalize) if (nvtex->mapped_res) { NVENCSTATUS err; err = nv.nvEncUnmapInputResource(s, nvtex->mapped_res); - if (nv_failed(enc, err, __FUNCTION__, "unmap")) { + if (nv_failed(enc->encoder, err, __FUNCTION__, + "unmap")) { return false; } nvtex->mapped_res = NULL; @@ -859,7 +853,8 @@ static bool nvenc_encode_tex(void *data, uint32_t handle, int64_t pts, err = nv.nvEncEncodePicture(enc->session, ¶ms); if (err != NV_ENC_SUCCESS && err != NV_ENC_ERR_NEED_MORE_INPUT) { - nv_failed(enc, err, __FUNCTION__, "nvEncEncodePicture"); + nv_failed(enc->encoder, err, __FUNCTION__, + "nvEncEncodePicture"); return false; } diff --git a/plugins/obs-ffmpeg/jim-nvenc.h b/plugins/obs-ffmpeg/jim-nvenc.h index 00ee545..cdd60aa 100644 --- a/plugins/obs-ffmpeg/jim-nvenc.h +++ b/plugins/obs-ffmpeg/jim-nvenc.h @@ -12,4 +12,6 @@ typedef NVENCSTATUS(NVENCAPI *NV_CREATE_INSTANCE_FUNC)( extern const char *nv_error_name(NVENCSTATUS err); extern NV_ENCODE_API_FUNCTION_LIST nv; extern NV_CREATE_INSTANCE_FUNC nv_create_instance; -extern bool init_nvenc(void); +extern bool init_nvenc(obs_encoder_t *encoder); +bool nv_failed(obs_encoder_t *encoder, NVENCSTATUS err, const char *func, + const char *call); diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c b/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c index 2f2ee7d..2e38994 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-audio-encoders.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -143,6 +144,11 @@ static bool initialize_codec(struct enc_encoder *enc) ret = avcodec_open2(enc->context, enc->codec, NULL); if (ret < 0) { + struct dstr error_message = {0}; + dstr_printf(&error_message, "Failed to open AAC codec: %s", + av_err2str(ret)); + obs_encoder_set_last_error(enc->encoder, error_message.array); + dstr_free(&error_message); warn("Failed to open AAC codec: %s", av_err2str(ret)); return false; } diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c b/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c index 05e4bd1..142e14d 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-nvenc.c @@ -88,8 +88,50 @@ static bool nvenc_init_codec(struct nvenc_encoder *enc) { int ret; + // avcodec_open2 will overwrite priv_data, we call this to get a + // local copy of the "gpu" setting for improved error messages. + int64_t gpu; + if (av_opt_get_int(enc->context->priv_data, "gpu", 0, &gpu) < 0) { + gpu = -1; + } + ret = avcodec_open2(enc->context, enc->nvenc, NULL); if (ret < 0) { + // if we were a fallback from jim-nvenc, there may already be a + // more useful error returned from that, so don't overwrite. + // this can be removed if / when ffmpeg fallback is removed. + if (!obs_encoder_get_last_error(enc->encoder)) { + struct dstr error_message = {0}; + + dstr_copy(&error_message, + obs_module_text("NVENC.Error")); + dstr_replace(&error_message, "%1", av_err2str(ret)); + dstr_cat(&error_message, "\r\n\r\n"); + + if (gpu > 0) { + // if a non-zero GPU failed, almost always + // user error. tell then to fix it. + char gpu_str[16]; + snprintf(gpu_str, sizeof(gpu_str) - 1, "%d", + (int)gpu); + gpu_str[sizeof(gpu_str) - 1] = 0; + + dstr_cat(&error_message, + obs_module_text("NVENC.BadGPUIndex")); + dstr_replace(&error_message, "%1", gpu_str); + } else if (ret == AVERROR_EXTERNAL) { + // special case for common NVENC error + dstr_cat(&error_message, + obs_module_text("NVENC.GenericError")); + } else { + dstr_cat(&error_message, + obs_module_text("NVENC.CheckDrivers")); + } + + obs_encoder_set_last_error(enc->encoder, + error_message.array); + dstr_free(&error_message); + } warn("Failed to open NVENC codec: %s", av_err2str(ret)); return false; } @@ -296,6 +338,8 @@ static void *nvenc_create(obs_data_t *settings, obs_encoder_t *encoder) blog(LOG_INFO, "---------------------------------"); if (!enc->nvenc) { + obs_encoder_set_last_error(encoder, + "Couldn't find NVENC encoder"); warn("Couldn't find encoder"); goto fail; } diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-source.c b/plugins/obs-ffmpeg/obs-ffmpeg-source.c index 666be13..e7a96f6 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-source.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-source.c @@ -258,10 +258,11 @@ static void media_stopped(void *opaque) struct ffmpeg_source *s = opaque; if (s->is_clear_on_media_end) { obs_source_output_video(s->source, NULL); - if (s->close_when_inactive && s->media_valid) - s->destroy_media = true; } + if (s->close_when_inactive && s->media_valid) + s->destroy_media = true; + set_media_state(s, OBS_MEDIA_STATE_ENDED); obs_source_media_ended(s->source); } diff --git a/plugins/obs-ffmpeg/obs-ffmpeg.c b/plugins/obs-ffmpeg/obs-ffmpeg.c index 86c6abc..309bec3 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg.c @@ -240,6 +240,11 @@ bool obs_module_load(void) #ifdef _WIN32 if (get_win_ver_int() > 0x0601) { jim_nvenc_load(); + } else { + // if on Win 7, new nvenc isn't available so there's + // no nvenc encoder for the user to select, expose + // the old encoder directly + nvenc_encoder_info.caps &= ~OBS_ENCODER_CAP_INTERNAL; } #endif obs_register_encoder(&nvenc_encoder_info); diff --git a/plugins/obs-filters/CMakeLists.txt b/plugins/obs-filters/CMakeLists.txt index d6cf13c..077bae1 100644 --- a/plugins/obs-filters/CMakeLists.txt +++ b/plugins/obs-filters/CMakeLists.txt @@ -54,6 +54,13 @@ set(obs-filters_SOURCES expander-filter.c luma-key-filter.c) +if(WIN32) + set(MODULE_DESCRIPTION "OBS A/V Filters") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obs-filters.rc) + list(APPEND obs-filters_SOURCES + obs-filters.rc) +endif() + add_library(obs-filters MODULE ${obs-filters_SOURCES} ${obs-filters_config_HEADERS} diff --git a/plugins/obs-filters/color-grade-filter.c b/plugins/obs-filters/color-grade-filter.c index ff6345c..cb8e2b7 100644 --- a/plugins/obs-filters/color-grade-filter.c +++ b/plugins/obs-filters/color-grade-filter.c @@ -329,7 +329,7 @@ static obs_properties_t *color_grade_filter_properties(void *data) obs_properties_t *props = obs_properties_create(); struct dstr filter_str = {0}; - dstr_cat(&filter_str, "(*.cube *.png)"); + dstr_cat(&filter_str, "PNG/Cube (*.cube *.png)"); if (s && s->file && *s->file) { dstr_copy(&path, s->file); diff --git a/plugins/obs-outputs/CMakeLists.txt b/plugins/obs-outputs/CMakeLists.txt index a55b80d..de5f05d 100644 --- a/plugins/obs-outputs/CMakeLists.txt +++ b/plugins/obs-outputs/CMakeLists.txt @@ -156,6 +156,13 @@ set(obs-outputs_SOURCES flv-mux.c net-if.c) +if(WIN32) + set(MODULE_DESCRIPTION "OBS output module") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obs-outputs.rc) + list(APPEND obs-outputs_SOURCES + obs-outputs.rc) +endif() + add_library(obs-outputs MODULE ${ftl_SOURCES} ${ftl_HEADERS} diff --git a/plugins/obs-outputs/librtmp/rtmp.c b/plugins/obs-outputs/librtmp/rtmp.c index 119bb62..894582b 100644 --- a/plugins/obs-outputs/librtmp/rtmp.c +++ b/plugins/obs-outputs/librtmp/rtmp.c @@ -360,6 +360,8 @@ error: mbedtls_x509_crt_free(chain); free(chain); r->RTMP_TLS_ctx->cacert = NULL; +#else /* USE_MBEDTLS */ + UNUSED_PARAMETER(r); #endif /* USE_MBEDTLS */ } @@ -407,6 +409,7 @@ RTMP_TLS_Init(RTMP *r) SSL_CTX_set_default_verify_paths(RTMP_TLS_ctx); #endif #else + UNUSED_PARAMETER(r); #endif } @@ -429,6 +432,8 @@ RTMP_TLS_Free(RTMP *r) { // NO mbedtls_net_free() BECAUSE WE SET IT UP BY HAND! free(r->RTMP_TLS_ctx); r->RTMP_TLS_ctx = NULL; +#else + UNUSED_PARAMETER(r); #endif } diff --git a/plugins/obs-text/CMakeLists.txt b/plugins/obs-text/CMakeLists.txt index 973f2a7..9a3003e 100644 --- a/plugins/obs-text/CMakeLists.txt +++ b/plugins/obs-text/CMakeLists.txt @@ -5,8 +5,11 @@ endif() project(obs-text) if(WIN32) + set(MODULE_DESCRIPTION "OBS GDI+ text module") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obs-text.rc) set(obs-text_PLATFORM_SOURCES - gdiplus/obs-text.cpp) + gdiplus/obs-text.cpp + obs-text.rc) set(obs-text_PLATFORM_DEPS gdiplus) endif() diff --git a/plugins/obs-transitions/CMakeLists.txt b/plugins/obs-transitions/CMakeLists.txt index 16e471b..4a4ef1a 100644 --- a/plugins/obs-transitions/CMakeLists.txt +++ b/plugins/obs-transitions/CMakeLists.txt @@ -11,6 +11,13 @@ set(obs-transitions_SOURCES transition-stinger.c ) +if(WIN32) + set(MODULE_DESCRIPTION "OBS Transitions module") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obs-transitions.rc) + list(APPEND obs-transitions_SOURCES + obs-transitions.rc) +endif() + add_library(obs-transitions MODULE ${obs-transitions_SOURCES}) target_link_libraries(obs-transitions diff --git a/plugins/obs-x264/CMakeLists.txt b/plugins/obs-x264/CMakeLists.txt index 7d4ea8b..4a95db2 100644 --- a/plugins/obs-x264/CMakeLists.txt +++ b/plugins/obs-x264/CMakeLists.txt @@ -8,6 +8,13 @@ set(obs-x264_SOURCES obs-x264.c obs-x264-plugin-main.c) +if(WIN32) + set(MODULE_DESCRIPTION "OBS x264 encoder") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in obs-x264.rc) + list(APPEND obs-x264_SOURCES + obs-x264.rc) +endif() + add_library(obs-x264 MODULE ${obs-x264_SOURCES}) target_link_libraries(obs-x264 diff --git a/plugins/rtmp-services/CMakeLists.txt b/plugins/rtmp-services/CMakeLists.txt index a799f00..b565e3f 100644 --- a/plugins/rtmp-services/CMakeLists.txt +++ b/plugins/rtmp-services/CMakeLists.txt @@ -13,6 +13,13 @@ set(rtmp-services_SOURCES rtmp-custom.c rtmp-services-main.c) +if(WIN32) + set(MODULE_DESCRIPTION "OBS RTMP Services") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in rtmp-services.rc) + list(APPEND rtmp-services_SOURCES + rtmp-services.rc) +endif() + set(rtmp-services_HEADERS twitch.h younow.h diff --git a/plugins/rtmp-services/data/package.json b/plugins/rtmp-services/data/package.json old mode 100755 new mode 100644 index 3af847b..fba419d --- a/plugins/rtmp-services/data/package.json +++ b/plugins/rtmp-services/data/package.json @@ -1,10 +1,10 @@ { "url": "https://obsproject.com/obs2_update/rtmp-services", - "version": 125, + "version": 131, "files": [ { "name": "services.json", - "version": 125 + "version": 131 } ] } diff --git a/plugins/rtmp-services/data/services.json b/plugins/rtmp-services/data/services.json old mode 100755 new mode 100644 index 854ca86..b97ac3b --- a/plugins/rtmp-services/data/services.json +++ b/plugins/rtmp-services/data/services.json @@ -893,57 +893,61 @@ "name": "Castr.io", "servers": [ { - "name": "Chicago US", + "name": "US-East (Chicago, IL)", "url": "rtmp://cg.castr.io/static" }, { - "name": "Los Angeles US", - "url": "rtmp://la.castr.io/static" - }, - { - "name": "New York US", + "name": "US-East (New York, NY)", "url": "rtmp://ny.castr.io/static" }, { - "name": "Miami US", + "name": "US-East (Miami, FL)", "url": "rtmp://mi.castr.io/static" }, { - "name": "Montreal CA", + "name": "US-West (Seattle, WA)", + "url": "rtmp://se.castr.io/static" + }, + { + "name": "US-West (Los Angeles, CA)", + "url": "rtmp://la.castr.io/static" + }, + { + "name": "US-Central (Dallas, TX)", + "url": "rtmp://da.castr.io/static" + }, + { + "name": "NA-East (Toronto, CA)", "url": "rtmp://qc.castr.io/static" }, { - "name": "London UK", - "url": "rtmp://uk.castr.io/static" - }, - { - "name": "Frankfurt DE", - "url": "rtmp://de.castr.io/static" - }, - { - "name": "Frankfurt DE 2", - "url": "rtmp://fr.castr.io/static" - }, - { - "name": "Moscow RU", - "url": "rtmp://ru.castr.io/static" - }, - { - "name": "Singapore", - "url": "rtmp://sg.castr.io/static" - }, - { - "name": "Sydney AU", - "url": "rtmp://au.castr.io/static" - }, - { - "name": "Brazil", + "name": "SA (Sao Paulo, BR)", "url": "rtmp://br.castr.io/static" }, { - "name": "India", + "name": "EU-West (London, UK)", + "url": "rtmp://uk.castr.io/static" + }, + { + "name": "EU-Central (Frankfurt, DE)", + "url": "rtmp://fr.castr.io/static" + }, + { + "name": "Russia (Moscow)", + "url": "rtmp://ru.castr.io/static" + }, + { + "name": "Asia (Singapore)", + "url": "rtmp://sg.castr.io/static" + }, + { + "name": "Asia (India)", "url": "rtmp://in.castr.io/static" }, + { + "name": "Australia (Sydney)", + "url": "rtmp://au.castr.io/static" + }, { "name": "US Central", "url": "rtmp://us-central.castr.io/static" @@ -975,10 +979,6 @@ { "name": "Singapore", "url": "rtmp://sg-central.castr.io/static" - }, - { - "name": "India", - "url": "rtmp://in.castr.io/static" } ], "recommended": { @@ -1128,7 +1128,7 @@ "servers": [ { "name": "Auto", - "url": "rtmp://s-sd.stripcdn.com/ext" + "url": "rtmp://s-sd.stripst.com/ext" } ], "recommended": { @@ -1494,14 +1494,28 @@ "name": "Bongacams", "servers": [ { - "name": "Default", - "url": "rtmp://origin.bcrncdn.com:1934/live" + "name": "Automatic / Default", + "url": "rtmp://auto.origin.gnsbc.com:1934/live" + }, + { + "name": "Automatic / Backup", + "url": "rtmp://origin.bcvidorigin.com:1934/live" + }, + { + "name": "Europe", + "url": "rtmp://z-eu.origin.gnsbc.com:1934/live" + }, + { + "name": "North America", + "url": "rtmp://z-us.origin.gnsbc.com:1934/live" } ], "recommend": { "keyint": 2, "max video bitrate": 6000, - "max audio bitrate": 192 + "max audio bitrate": 192, + "bframes": 0, + "x264opts": "tune=zerolatency" } }, { @@ -1518,16 +1532,20 @@ } }, { - "name": "ChathostessModels", + "name": "Chathostess", "servers": [ { - "name": "ChathostessModels - Default", + "name": "Chathostess - Default", "url": "rtmp://wowza01.foobarweb.com/cmschatsys_video" + }, + { + "name": "Chathostess - Backup", + "url": "rtmp://wowza05.foobarweb.com/cmschatsys_video" } ], "recommended": { "keyint": 2, - "max video bitrate": 3000, + "max video bitrate": 3600, "max audio bitrate": 128 } }, @@ -1733,6 +1751,73 @@ "recommended": { "keyint": 2 } + }, + { + "name": "niconico, premium member (ニコニコ生放送 プレミアム会員)", + "servers": [ + { + "name": "Default", + "url": "rtmp://aliveorigin.dmc.nico/named_input" + } + ], + "recommended": { + "keyint": 2, + "profile": "high", + "max audio bitrate": 192, + "max video bitrate": 5808, + "x264opts": "tune=zerolatency" + } + }, + { + "name": "niconico, free member (ニコニコ生放送 一般会員)", + "servers": [ + { + "name": "Default", + "url": "rtmp://aliveorigin.dmc.nico/named_input" + } + ], + "recommended": { + "keyint": 2, + "profile": "high", + "max audio bitrate": 96, + "max video bitrate": 904, + "x264opts": "tune=zerolatency" + } + }, + { + "name": "WASD.TV", + "servers": [ + { + "name": "Automatic", + "url": "rtmp://push.rtmp.wasd.tv/live" + }, + { + "name": "Russia, Moscow", + "url": "rtmp://ru-moscow.rtmp.wasd.tv/live" + }, + { + "name": "Germany, Frankfurt", + "url": "rtmp://de-frankfurt.rtmp.wasd.tv/live" + }, + { + "name": "Finland, Helsinki", + "url": "rtmp://fi-helsinki.rtmp.wasd.tv/live" + } + ], + "recommended": { + "keyint": 2, + "max video bitrate": 10000, + "max audio bitrate": 192 + } + }, + { + "name": "VirtWish", + "servers": [ + { + "name": "Default", + "url": "rtmp://rtmp.virtwish.com/live" + } + ] } ] } diff --git a/plugins/rtmp-services/rtmp-custom.c b/plugins/rtmp-services/rtmp-custom.c index 4f6c1ad..921be2f 100644 --- a/plugins/rtmp-services/rtmp-custom.c +++ b/plugins/rtmp-services/rtmp-custom.c @@ -18,6 +18,8 @@ static void rtmp_custom_update(void *data, obs_data_t *settings) bfree(service->server); bfree(service->key); + bfree(service->username); + bfree(service->password); service->server = bstrdup(obs_data_get_string(settings, "server")); service->key = bstrdup(obs_data_get_string(settings, "key")); diff --git a/plugins/text-freetype2/CMakeLists.txt b/plugins/text-freetype2/CMakeLists.txt index 26af549..66ee93c 100644 --- a/plugins/text-freetype2/CMakeLists.txt +++ b/plugins/text-freetype2/CMakeLists.txt @@ -14,9 +14,12 @@ elseif(NOT FREETYPE_FOUND) endif() if(WIN32) + set(MODULE_DESCRIPTION "OBS Freetype text module") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in text-freetype2.rc) set(text-freetype2_PLATFORM_SOURCES find-font.c - find-font-windows.c) + find-font-windows.c + text-freetype2.rc) elseif(APPLE) find_package(Iconv QUIET) if(NOT ICONV_FOUND AND ENABLE_FREETYPE) diff --git a/plugins/vlc-video/CMakeLists.txt b/plugins/vlc-video/CMakeLists.txt index bcc95fd..26370e7 100644 --- a/plugins/vlc-video/CMakeLists.txt +++ b/plugins/vlc-video/CMakeLists.txt @@ -31,6 +31,13 @@ set(vlc-video_SOURCES vlc-video-source.c ) +if(WIN32) + set(MODULE_DESCRIPTION "OBS VLC module") + configure_file(${CMAKE_SOURCE_DIR}/cmake/winrc/obs-module.rc.in vlc-video.rc) + list(APPEND vlc-video_SOURCES + vlc-video.rc) +endif() + add_library(vlc-video MODULE ${vlc-video_SOURCES} ${vlc-video_HEADERS})