diff --git a/.clang-format b/.clang-format index 249d707f..5f744c6d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,18 +1,28 @@ -# Format Style Options - Created with Clang Power Tools --- -AllowShortFunctionsOnASingleLine: None -AllowShortIfStatementsOnASingleLine: true BasedOnStyle: LLVM -BinPackArguments: false -BinPackParameters: false +AlignAfterOpenBracket: Align +AlignEscapedNewlines: Left +AllowAllArgumentsOnNextLine: 'false' +AllowShortBlocksOnASingleLine: 'false' +AllowShortFunctionsOnASingleLine: None +AllowShortIfStatementsOnASingleLine: Never +BinPackArguments: 'false' +BinPackParameters: 'false' BreakBeforeBraces: Allman BreakConstructorInitializers: AfterColon -ColumnLimit: 160 -ConstructorInitializerAllOnOneLineOrOnePerLine: true -ConstructorInitializerIndentWidth : 2 -ContinuationIndentWidth: 2 -MaxEmptyLinesToKeep: 2 +ColumnLimit: '120' +ConstructorInitializerAllOnOneLineOrOnePerLine: 'true' +ConstructorInitializerIndentWidth: '2' +ContinuationIndentWidth: '2' +MaxEmptyLinesToKeep: '1' PointerAlignment: Middle -SpacesInAngles: true -SpacesInParentheses: true +SortIncludes: 'false' +SortUsingDeclarations: 'false' +SpaceBeforeParens: Never +SpacesInAngles: 'true' +SpacesInParentheses: 'true' +SpacesInSquareBrackets: 'true' +UseTab: Never +AlignConsecutiveAssignments: AcrossComments + ... diff --git a/.github/scripts/windows-publish.ps1 b/.github/scripts/windows-publish.ps1 index 9fa3ff66..af2ead91 100644 --- a/.github/scripts/windows-publish.ps1 +++ b/.github/scripts/windows-publish.ps1 @@ -27,6 +27,7 @@ function Main() { New-Item -ItemType Directory $archiveName New-Item -ItemType Directory $archiveName\locale + New-Item -ItemType Directory $archiveName\opencc # 拷贝exe Copy-Item release\$targetName $archiveName\ Write-Host "copy item finished..." @@ -43,13 +44,19 @@ function Main() { Write-Host "copy redist dll..." Copy-Item "LICENSE.txt" $archiveName\ Write-Host "copy license.." + Copy-Item "opencc\*" $archiveName\opencc\ + Write-Host "opencc config files.." # 拷贝WinSDK dll $sdkDll="{0}Redist\{1}ucrt\DLLs\{2}\*.dll" -f $env:winSdkDir.Trim(),$env:winSdkVer.Trim(),$env:msvcArch Write-Host "copy sdk dll$($sdkDll)" Copy-Item $sdkDll $archiveName\ Copy-Item winlibs\lib\msvc\*.dll $archiveName\ Copy-Item locale\*.qm $archiveName\locale\ - # Copy-Item qtsingleapplication\lib\*.dll $archiveName\ + Write-Host "copy qwebengine zh_CN translation" + Copy-Item thirdparty\qwebengine_ts\*.qm $archiveName\locale\ + $webengineqm="{0}\translations\qtwebengine_*.qm" -f $env:QTDIR.Trim() + Write-Host "copy qtwebengine qm from $($webengineqm)" + Copy-Item $webengineqm $archiveName\locale\ Write-Host "compress zip..." # 打包zip Compress-Archive -Path $archiveName -DestinationPath $archiveName'.zip' diff --git a/.github/workflows/AutoTag.yml b/.github/workflows/AutoTag.yml new file mode 100644 index 00000000..5be72e12 --- /dev/null +++ b/.github/workflows/AutoTag.yml @@ -0,0 +1,51 @@ +name: AutoTag +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +on: + workflow_dispatch: + push: + branches: + - dev + - master + # - staged + paths-ignore: + - 'docs/**' + - ".github/**" + - "howto/**" + - "*.md" + - ".clang-format" + pull_request: + branches: + - dev + - master + # - staged + paths-ignore: + - 'docs/**' + - ".github/**" + - "howto/**" + - "*.md" +jobs: + build: + name: Build + runs-on: ubuntu-latest + + env: + version: 22.4.Summer + # 步骤 + steps: + - uses: actions/checkout@v3 + + - name: set git short sha + id: git + run: | + echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)" + - name: Bump version and push tag + id: tag_version + uses: mathieudutour/github-tag-action@v6.0 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + custom_tag: ${{env.version}}-${{ steps.git.outputs.sha_short }} + + + \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml deleted file mode 100644 index 3cb2b5d9..00000000 --- a/.github/workflows/codeql-analysis.yml +++ /dev/null @@ -1,84 +0,0 @@ -# For most projects, this workflow file will not need changing; you simply need -# to commit it to your repository. -# -# You may wish to alter this file to override the set of languages analyzed, -# or to provide custom queries or build logic. -# -# ******** NOTE ******** -# We have attempted to detect the languages in your repository. Please check -# the `language` matrix defined below to confirm you have the correct set of -# supported CodeQL languages. -# -name: "CodeQL" - -on: - push: - branches: [ dev ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ dev ] - schedule: - - cron: '40 15 * * 6' - -jobs: - analyze: - name: Analyze - runs-on: ${{ matrix.os }} - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'cpp', 'javascript' ] - os: [ubuntu-20.04] - qt_ver: [5.15.2] - qt_arch: [gcc_64] - # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] - # Learn more about CodeQL language support at https://git.io/codeql-language-support - - steps: - - name: Install Qt - uses: jurplel/install-qt-action@v2.13.0 - with: - version: ${{ matrix.qt_ver }} - cached: 'false' - modules: qtwebengine - - name: ubuntu install thirdparty dependencies - run: | - sudo apt-get install git pkg-config build-essential qt5-qmake - sudo apt-get install libvorbis-dev zlib1g-dev libhunspell-dev x11proto-record-dev - sudo apt-get install qtdeclarative5-dev libxtst-dev liblzo2-dev libbz2-dev - sudo apt-get install libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev - sudo apt-get install libqt5webkit5-dev libqt5svg5-dev libqt5x11extras5-dev qttools5-dev - sudo apt-get install qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins libopencc-dev libzstd-dev - sudo ln -sf /usr/bin/x86_64-linux-gnu-ld.gold /usr/bin/ld - - name: Checkout repository - uses: actions/checkout@v2 - - # Initializes the CodeQL tools for scanning. - - name: Initialize CodeQL - uses: github/codeql-action/init@v1 - with: - languages: ${{ matrix.language }} - # If you wish to specify custom queries, you can do so here or in a config file. - # By default, queries listed here will override any specified in a config file. - # Prefix the list here with "+" to use these queries and those in the config file. - # queries: ./path/to/local/query, your-org/your-repo/queries@main - - - # ℹ️ Command-line programs to run using the OS shell. - # 📚 https://git.io/JvXDl - - # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines - # and modify them (or add more) to build your code if your project - # uses a compiled language - - - run: | - qmake CONFIG+=release PREFIX=/usr CONFIG+=zim_support CONFIG+=chinese_conversion_support - make INSTALL_ROOT=appdir -j`nproc` ; # find appdir/ - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/macos-6.2.yml b/.github/workflows/macos-6.2.yml new file mode 100644 index 00000000..503de16e --- /dev/null +++ b/.github/workflows/macos-6.2.yml @@ -0,0 +1,123 @@ +name: macos-6.2 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +on: + workflow_run: + workflows: [AutoTag] + types: [completed] + workflow_dispatch: + # push: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" + # - ".clang-format" + # pull_request: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-11] + qt_ver: [6.2.3] + qt_arch: [clang_64] + env: + targetName: GoldenDict + version: 22.4.Summer + + steps: + # macos 11.0 默认环境变了,要指定 + - name: prepare env + if: ${{ matrix.os == 'macos-11' }} + run: | + softwareupdate --all --install --force + sudo xcode-select --print-path + sudo xcode-select --switch /Library/Developer/CommandLineTools + - uses: actions/setup-python@v3 + with: + python-version: '3.9' + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt_ver }} + arch: ${{ matrix.qt_arch }} + cached: 'false' + modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia + setup-python: 'false' + py7zrversion: '==0.18.1' + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: build macos + run: | + wget ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2 + tar xvjf eb-4.4.3.tar.bz2 + cd eb-4.4.3 && ./configure && make -j 8 && sudo make install && cd .. + #brew install qt # or use official offline installer + brew install opencc libao hunspell ffmpeg@5 libtiff xz lzo libogg libvorbis zstd + qmake CONFIG+=release CONFIG+=zim_support CONFIG+=chinese_conversion_support + make + # 打包 + - name: package + run: | + macdeployqt ${targetName}.app -qmldir=. -verbose=1 -dmg + otool -L GoldenDict.app/Contents/MacOS/GoldenDict + - name: Set outputs + id: vars + run: | + echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)" + echo "::set-output name=release_date::$(date +'%Y%m%d')" + echo "::set-output name=release_time::$(date +'%H%M%S')" + echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')" + + previousTag=$(git tag --sort=-creatordate | sed -n 2p) + echo "previousTag : $previousTag" + + CHANGELOG="$(git log --oneline --no-decorate $previousTag..HEAD)" + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" + echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" + # tag 上传Release + - name: uploadRelease + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ env.targetName }}.dmg + asset_name: ${{ matrix.qt_ver }}-${{ env.targetName }}_${{ matrix.os }}_${{ steps.vars.outputs.sha_short }}.dmg + tag: v${{env.version}}-${{ steps.vars.outputs.sha_short }} + overwrite: true + release_name: win-linux-macos-${{steps.vars.outputs.release_date}} + prerelease: false + body: | + release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} + branch: ${{ github.ref_name }} + commit: ${{ steps.vars.outputs.sha_short }} + Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} + Windows built with: msvc64 Visual studio 2019 + # goldendict.exe can not used alone + if you have a previous version. replace this maybe ok. if not ,download the whole bundle. + + AppImage built with: Ubuntu-20.04 ,latest gcc + macos built with: macos-10.15,macos-11.0,clang_64 x86_64(Intel Kind) + auto built by github action. use on your on risk:-) + + CHANGES: + ${{ steps.vars.outputs.COMMIT_SUMMARY }} diff --git a/.github/workflows/macos-m1.yml b/.github/workflows/macos-m1.yml new file mode 100644 index 00000000..080d93fd --- /dev/null +++ b/.github/workflows/macos-m1.yml @@ -0,0 +1,127 @@ +name: macos-m1 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +on: + workflow_dispatch: + # push: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" + # - ".clang-format" + # pull_request: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-11] + qt_ver: [6.2.2] + qt_arch: [clang_64] + env: + targetName: GoldenDict + steps: + - name: prepare env + run: | + softwareupdate --all --install --force + sudo xcode-select --switch /Applications/Xcode.app + sudo xcode-select --print-path + #sudo xcode-select --switch /Library/Developer/CommandLineTools + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt_ver }} + arch: ${{ matrix.qt_arch }} + cached: 'false' + modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia + setup-python: 'false' + - uses: actions/checkout@v3 + with: + fetch-depth: 1 + - name: Set outputs + id: githash + run: | + echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + + - name: build macos + run: | + brew install pcre2 harfbuzz freetype + brew install cmake ninja python + brew install automake + brew install autoconf + brew install libtool + git clone https://github.com/xiph/vorbis.git + cd vorbis + ./autogen.sh + ./configure + make + sudo make install + cd .. + brew install opencc + brew install ffmpeg@5 + #brew reinstall $(brew deps ffmpeg) ffmpeg + brew install libao + brew install libiconv + brew install lzo + brew install libogg + brew install zstd + brew install libtiff + #brew install libvorbis --force + #brew link libvorbis --force + brew install hunspell + + # brew install qt@6 + brew install pkg-config + # CONFIG+=chinese_conversion_support + #file /usr/local/lib/libzstd.dylib + file /usr/local/lib/QtGui.framework/QtGui + qmake CONFIG+=no_extra_tiff_handler CONFIG+=release CONFIG+=zim_support QMAKE_APPLE_DEVICE_ARCHS="arm64" CONFIG+=no_epwing_support CONFIG+=no_ffmpeg_player #CONFIG+=no_qtmultimedia_player + make + # 打包 + - name: package + run: | + macdeployqt ${targetName}.app -qmldir=. -verbose=1 -dmg + - name: Set outputs + id: vars + run: | + echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)" + echo "::set-output name=release_date::$(date +'%Y%m%d')" + echo "::set-output name=release_time::$(date +'%H%M%S')" + echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')" + # tag 上传Release +# - name: uploadRelease +# uses: svenstaro/upload-release-action@v2 +# with: +# repo_token: ${{ secrets.GITHUB_TOKEN }} +# file: ${{ env.targetName }}.dmg +# asset_name: ${{ env.targetName }}-M1_${{ matrix.os }}_${{ matrix.qt_ver }}_${{ steps.vars.outputs.sha_short }}.dmg +# tag: v${{ steps.autotag.outputs.version }}-${{ steps.vars.outputs.sha_short }} +# overwrite: true +# release_name: win-ubuntu-macos-${{ github.ref_name }}-${{steps.vars.outputs.release_date}} +# prerelease: false +# body: | +# release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} +# branch: ${{ github.ref_name }} +# commit: ${{ steps.vars.outputs.sha_short }} +# Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} +# Windows built with: msvc64 Visual studio 2019 +# goldendict.exe was provided alone ,if you have a previous version. replace this maybe ok. if not ,download the whole bundle. +# AppImage built with: Ubuntu-20.04 ,latest gcc +# macos built with: macos-10.15,macos-11.0,clang_64 x86_64(Intel Kind) +# This is a prerelease version ,auto build by github action. use on your on risk:-) diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml new file mode 100644 index 00000000..80ea8874 --- /dev/null +++ b/.github/workflows/macos.yml @@ -0,0 +1,124 @@ +name: macos +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +on: + workflow_run: + workflows: [AutoTag] + types: [completed] + workflow_dispatch: + # push: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" + # - ".clang-format" + # pull_request: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [macos-10.15,macos-11.0] + qt_ver: [5.15.2] + qt_arch: [clang_64] + env: + targetName: GoldenDict + version: 22.4.Summer + + steps: + # macos 11.0 默认环境变了,要指定 + - name: prepare env + if: ${{ matrix.os == 'macos-11.0' }} + run: | + softwareupdate --all --install --force + sudo xcode-select --print-path + sudo xcode-select --switch /Library/Developer/CommandLineTools + # brew install qt@6 + - uses: actions/setup-python@v3 + with: + python-version: '3.9' + - name: Install Qt + uses: jurplel/install-qt-action@v2 + # if: ${{ matrix.qt_ver == '5.15.2' }} + with: + version: ${{ matrix.qt_ver }} + cached: 'false' + modules: qtwebengine + setup-python: 'false' + py7zrversion: '==0.18.1' + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: build macos + run: | + wget ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2 + tar xvjf eb-4.4.3.tar.bz2 + cd eb-4.4.3 && ./configure && make -j 8 && sudo make install && cd .. + #brew install qt # or use official offline installer + brew install opencc libao hunspell ffmpeg@5 libtiff xz lzo libogg libvorbis zstd + qmake CONFIG+=release CONFIG+=zim_support CONFIG+=chinese_conversion_support + make + # 打包 + - name: package + run: | + macdeployqt ${targetName}.app -qmldir=. -verbose=1 -dmg + otool -L GoldenDict.app/Contents/MacOS/GoldenDict + + - name: Set outputs + id: vars + run: | + echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)" + echo "::set-output name=release_date::$(date +'%Y%m%d')" + echo "::set-output name=release_time::$(date +'%H%M%S')" + echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')" + + previousTag=$(git tag --sort=-creatordate | sed -n 2p) + echo "previousTag : $previousTag" + + CHANGELOG="$(git log --oneline --no-decorate $previousTag..HEAD)" + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" + echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" + # tag 上传Release + - name: uploadRelease + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ env.targetName }}.dmg + asset_name: ${{ matrix.qt_ver }}-${{ env.targetName }}_${{ matrix.os }}_${{ steps.vars.outputs.sha_short }}.dmg + tag: v${{env.version}}-${{ steps.vars.outputs.sha_short }} + overwrite: true + release_name: win-linux-macos-${{steps.vars.outputs.release_date}} + prerelease: false + body: | + release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} + branch: ${{ github.ref_name }} + commit: ${{ steps.vars.outputs.sha_short }} + Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} + Windows built with: msvc64 Visual studio 2019 + ## goldendict.exe can not used alone + if you have a previous version. replace this maybe ok. if not ,download the whole bundle. + + AppImage built with: Ubuntu-20.04 ,latest gcc + macos built with: macos-10.15,macos-11.0,clang_64 x86_64(Intel Kind) + auto built by github action. use on your on risk:-) + + CHANGES: + ${{ steps.vars.outputs.COMMIT_SUMMARY }} diff --git a/.github/workflows/ubuntu-6.2.yml b/.github/workflows/ubuntu-6.2.yml new file mode 100644 index 00000000..1be967d1 --- /dev/null +++ b/.github/workflows/ubuntu-6.2.yml @@ -0,0 +1,134 @@ +name: Ubuntu-6.2 +# Qt官方没有linux平台的x86包 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +on: + # workflow_run: + # workflows: [AutoTag] + # types: [completed] + workflow_dispatch: + # push: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" + # - ".clang-format" + # pull_request: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" +jobs: + build: + name: Build + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest] + qt_ver: [6.2.3] + qt_arch: [gcc_64] + env: + version: 22.4.Summer + steps: + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + version: ${{ matrix.qt_ver }} + arch: ${{ matrix.qt_arch }} + cached: 'false' + modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia + - name: ubuntu install thirdparty dependencies + run: | + sudo apt-get install git pkg-config build-essential + sudo apt-get install libvorbis-dev zlib1g-dev libhunspell-dev x11proto-record-dev + sudo apt-get install libxtst-dev liblzo2-dev libbz2-dev + sudo apt-get install libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev + sudo apt-get install doxygen libzstd-dev libxkbcommon-dev libgstreamer-plugins-base1.0-0 libgstreamer-gl1.0-0 + sudo ln -sf /usr/bin/x86_64-linux-gnu-ld.gold /usr/bin/ld + + #build opencc + git clone https://github.com/BYVoid/OpenCC + cd OpenCC/ + make PREFIX=/usr -j$(nproc) + sudo make install + cd .. + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: build goldendict + run: | + qmake CONFIG+=release PREFIX=/usr CONFIG+=zim_support CONFIG+=chinese_conversion_support + make INSTALL_ROOT=appdir -j`nproc` install; find appdir/ + + #copy missing shared dll to appdir. + mkdir -p appdir/usr/lib + # mkdir -p appdir/usr/libexec + cp $(ldd appdir/usr/bin/goldendict | grep -o '\W/[^ ]*' |grep gobject ) appdir/usr/lib + cp $(ldd appdir/usr/bin/goldendict | grep -o '\W/[^ ]*' |grep libpango ) appdir/usr/lib + # cp $${env.Qt6_DIR}/libexec/QtWebEngineProcess appdir/usr/libexec + - name: Build AppImage + run: | + wget -c -nv "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" + chmod a+x linuxdeploy-plugin-qt-x86_64.AppImage + wget -c -nv "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" + chmod a+x linuxdeploy-x86_64.AppImage + ./linuxdeploy-x86_64.AppImage --appdir appdir --output appimage --plugin qt -i redist/icons/goldendict.png -d redist/org.goldendict.GoldenDict.desktop + # - uses: actions/upload-artifact@v2 + # with: + # name: AppImage + # path: './*.AppImage*' + - name: Set outputs + id: vars + run: | + echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)" + echo "::set-output name=release_date::$(date +'%Y%m%d')" + echo "::set-output name=release_time::$(date +'%H%M%S')" + echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')" + echo "::set-output name=appname::$(ls *.AppImage*)" + + previousTag=$(git tag --sort=-creatordate | sed -n 2p) + echo "previousTag : $previousTag" + + CHANGELOG="$(git log --oneline --no-decorate $previousTag..HEAD)" + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" + echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" + - name: uploadRelease + # if: startsWith(github.event.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ steps.vars.outputs.appname }} + asset_name: ${{ matrix.qt_ver }}-${{ steps.vars.outputs.appname }} + tag: v${{env.version}}-${{ steps.vars.outputs.sha_short }} + overwrite: true + release_name: win-linux-macos-${{steps.vars.outputs.release_date}} + prerelease: false + body: | + release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} + branch: ${{ github.ref_name }} + commit: ${{ steps.vars.outputs.sha_short }} + Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} + Windows built with: msvc64 Visual studio 2019 + # goldendict.exe can not used alone + if you have a previous version. replace this maybe ok. if not ,download the whole bundle. + + AppImage built with: Ubuntu-20.04 ,latest gcc + macos built with: macos-10.15,macos-11.0,clang_64 x86_64(Intel Kind) + auto built by github action. use on your on risk:-) + + CHANGES: + ${{ steps.vars.outputs.COMMIT_SUMMARY }} diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 3a8378e5..7e37db9c 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -1,19 +1,34 @@ name: Ubuntu # Qt官方没有linux平台的x86包 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true on: + workflow_run: + workflows: [AutoTag] + types: [completed] workflow_dispatch: - push: - branches: - - dev - # paths: - # - '*.pro' - # - '.github/**' - pull_request: - branches: - - dev - # paths: - # - '*.pro' - # - '.github/**' + # push: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" + # - ".clang-format" + # pull_request: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" jobs: build: name: Build @@ -23,9 +38,11 @@ jobs: os: [ubuntu-20.04] qt_ver: [5.15.2] qt_arch: [gcc_64] + env: + version: 22.4.Summer steps: - name: Install Qt - uses: jurplel/install-qt-action@v2.13.0 + uses: jurplel/install-qt-action@v3 with: version: ${{ matrix.qt_ver }} cached: 'false' @@ -37,21 +54,28 @@ jobs: sudo apt-get install qtdeclarative5-dev libxtst-dev liblzo2-dev libbz2-dev sudo apt-get install libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev sudo apt-get install libqt5webkit5-dev libqt5svg5-dev libqt5x11extras5-dev qttools5-dev - sudo apt-get install qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins libopencc-dev libzstd-dev + sudo apt-get install qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins doxygen libzstd-dev #libopencc-dev sudo ln -sf /usr/bin/x86_64-linux-gnu-ld.gold /usr/bin/ld - - uses: actions/checkout@v2 + git clone https://github.com/BYVoid/OpenCC + pwd + cd OpenCC/ + make PREFIX=/usr -j$(nproc) + sudo make install + cd .. + - uses: actions/checkout@v3 with: - fetch-depth: 1 - # - name: build singleapplication - # run: | - # cd qtsingleapplication - # qmake - # make + fetch-depth: 0 + - name: build goldendict run: | qmake CONFIG+=release PREFIX=/usr CONFIG+=zim_support CONFIG+=chinese_conversion_support make INSTALL_ROOT=appdir -j`nproc` install; find appdir/ - ls -al + + #copy missing shared dll to appdir. + mkdir -p appdir/usr/lib + cp $(ldd appdir/usr/bin/goldendict | grep -o '\W/[^ ]*' |grep gobject ) appdir/usr/lib + cp $(ldd appdir/usr/bin/goldendict | grep -o '\W/[^ ]*' |grep libpango ) appdir/usr/lib + - name: Build AppImage run: | wget -c -nv "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage" @@ -59,35 +83,47 @@ jobs: wget -c -nv "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage" chmod a+x linuxdeploy-x86_64.AppImage ./linuxdeploy-x86_64.AppImage --appdir appdir --output appimage --plugin qt -i redist/icons/goldendict.png -d redist/org.goldendict.GoldenDict.desktop - - uses: actions/upload-artifact@v2 - with: - name: AppImage - path: './*.AppImage*' + - name: Set outputs id: vars run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" + echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)" echo "::set-output name=release_date::$(date +'%Y%m%d')" echo "::set-output name=release_time::$(date +'%H%M%S')" echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')" echo "::set-output name=appname::$(ls *.AppImage*)" + + previousTag=$(git tag --sort=-creatordate | sed -n 2p) + echo "previousTag : $previousTag" + + CHANGELOG="$(git log --oneline --no-decorate $previousTag..HEAD)" + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" + echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" - name: uploadRelease # if: startsWith(github.event.ref, 'refs/tags/') uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ steps.vars.outputs.appname }} - asset_name: ${{ steps.vars.outputs.appname }} - tag: prerelease-${{steps.vars.outputs.release_date}} + asset_name: ${{ matrix.qt_ver }}-${{ steps.vars.outputs.appname }} + tag: v${{env.version}}-${{ steps.vars.outputs.sha_short }} overwrite: true - release_name: Ubuntu-Windows-${{ github.ref_name }}.${{ steps.vars.outputs.sha_short }} built on ${{steps.vars.outputs.release_date}} ${{steps.vars.outputs.release_time_clock}} - prerelease: true + release_name: win-linux-macos-${{steps.vars.outputs.release_date}} + prerelease: false body: | release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} branch: ${{ github.ref_name }} commit: ${{ steps.vars.outputs.sha_short }} Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} Windows built with: msvc64 Visual studio 2019 - AppImage built with: Ubuntu-20.04 ,latest gcc + ## goldendict.exe can not used alone + if you have a previous version. replace this maybe ok. if not ,download the whole bundle. - This is a prerelease version ,auto build by github action. use on your on risk:-) \ No newline at end of file + AppImage built with: Ubuntu-20.04 ,latest gcc + macos built with: macos-10.15,macos-11.0,clang_64 x86_64(Intel Kind) + auto built by github action. use on your on risk:-) + + CHANGES: + ${{ steps.vars.outputs.COMMIT_SUMMARY }} diff --git a/.github/workflows/windows-6.2.yml b/.github/workflows/windows-6.2.yml new file mode 100644 index 00000000..e11906ef --- /dev/null +++ b/.github/workflows/windows-6.2.yml @@ -0,0 +1,170 @@ +name: Windows-6.2 +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +on: + workflow_run: + workflows: [AutoTag] + types: [completed] + workflow_dispatch: + # push代码时触发workflow + # push: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" + # - ".clang-format" + # pull_request: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" +jobs: + build: + name: Build + # 运行平台, windows-latest目前是windows server 2019 + # 参考文档 https://github.com/actions/virtual-environments/blob/main/images/win/Windows2019-Readme.md + runs-on: windows-2019 + strategy: + # 矩阵配置 + matrix: + # qt_ver: [5.15.2,6.2.2] + include: + # 5.15.2 参考 https://mirrors.cloud.tencent.com/qt/online/qtsdkrepository/windows_x86/desktop/qt5_5152/ + # - qt_ver: 5.15.2 + # qt_arch: win64_msvc2019_64 + # msvc_arch: x64 + # qt_target: x64 + # qt_arch_install: msvc2019_64 + - qt_ver: 6.2.3 + qt_arch: win64_msvc2019_64 + msvc_arch: x64 + qt_target: x64 + qt_arch_install: msvc2019_64 + env: + targetName: GoldenDict.exe + version: 22.4.Summer + # 步骤 + steps: + # 安装Qt + - name: Install Qt + uses: jurplel/install-qt-action@v3 + with: + # Version of Qt to install + version: ${{ matrix.qt_ver }} + # Target platform for build + # target: ${{ matrix.qt_target }} + arch: ${{ matrix.qt_arch }} + cached: 'false' + modules: qtwebengine qtwebchannel qtpositioning qt5compat qtmultimedia + + # 拉取代码 + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set outputs + id: vars + shell: bash + run: | + echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)" + echo "::set-output name=release_date::$(date +'%Y%m%d')" + echo "::set-output name=release_time::$(date +'%H%M%S')" + echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')" + + previousTag=$(git tag --sort=-creatordate | sed -n 2p) + echo "previousTag : $previousTag" + + CHANGELOG="$(git log --oneline --no-decorate $previousTag..HEAD)" + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" + echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" + + # # msvc编译 + # - uses: ilammy/msvc-dev-cmd@v1 + # with: + # arch: ${{ matrix.msvc_arch }} + - name: msvc-build goldendict + id: build + shell: cmd + run: | + call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }} + qmake "CONFIG+=zim_support" CONFIG+=release + nmake + + echo winSdkDir=%WindowsSdkDir% >> %GITHUB_ENV% + echo winSdkVer=%WindowsSdkVersion% >> %GITHUB_ENV% + echo vcToolsInstallDir=%VCToolsInstallDir% >> %GITHUB_ENV% + echo vcToolsRedistDir=%VCToolsRedistDir% >> %GITHUB_ENV% + echo QTDIR=%Qt6_DIR% >> %GITHUB_ENV% + + # 打包 + - name: package + id: package + env: + archiveName: GoldenDict-${{ github.ref_name }}.${{ steps.vars.outputs.sha_short }}-${{ steps.vars.outputs.release_time }} + msvcArch: ${{ matrix.msvc_arch }} + shell: pwsh + run: | + & .github\scripts\windows-publish.ps1 ${env:archiveName} ${env:targetName} + $name = ${env:archiveName} + echo "::set-output name=packageName::$name" + # tag 查询github-Release + # 上传artifacts +# - uses: actions/upload-artifact@v2 +# with: +# name: ${{ steps.package.outputs.packageName }} +# path: ${{ steps.package.outputs.packageName }}.zip + # tag 上传Release + - name: uploadRelease + # if: startsWith(github.event.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ${{ steps.package.outputs.packageName }}.zip + asset_name: ${{ matrix.qt_ver }}-${{ steps.package.outputs.packageName }}.zip + tag: v${{env.version}}-${{ steps.vars.outputs.sha_short }} + overwrite: true + release_name: win-linux-macos-${{steps.vars.outputs.release_date}} + prerelease: false + body: | + release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} + branch: ${{ github.ref_name }} + commit: ${{ steps.vars.outputs.sha_short }} + Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} + Windows built with: msvc64 Visual studio 2019 + AppImage built with: Ubuntu-20.04 ,latest gcc + + auto built by github action. use on your on risk:-) + - name: upload goldendict.exe only + # if: startsWith(github.event.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: release/${{ env.targetName }} + asset_name: ${{ matrix.qt_ver }}-${{ env.targetName }} + tag: v${{env.version}}-${{ steps.vars.outputs.sha_short }} + overwrite: true + release_name: win-linux-macos-${{steps.vars.outputs.release_date}} + prerelease: false + body: | + release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} + branch: ${{ github.ref_name }} + commit: ${{ steps.vars.outputs.sha_short }} + Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} + Windows built with: msvc64 Visual studio 2019 + goldendict.exe was provided alone ,if you have a previous version. replace this maybe ok. if not ,download the whole bundle. + AppImage built with: Ubuntu-20.04 ,latest gcc + macos built with: macos-10.15,macos-11.0,clang_64 x86_64(Intel Kind) + auto built by github action. use on your on risk:-) diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index e7fd316d..1ca48229 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -1,19 +1,34 @@ name: Windows +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true on: + workflow_run: + workflows: [AutoTag] + types: [completed] workflow_dispatch: # push代码时触发workflow - push: - branches: - - dev - # paths: - # - '*.pro' - # - '.github/**' - pull_request: - branches: - - dev - # paths: - # - '*.pro' - # - '.github/**' + # push: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" + # - ".clang-format" + # pull_request: + # branches: + # - dev + # - master + # # - staged + # paths-ignore: + # - 'docs/**' + # - ".github/**" + # - "howto/**" + # - "*.md" jobs: build: name: Build @@ -25,13 +40,19 @@ jobs: matrix: include: # 5.15.2 参考 https://mirrors.cloud.tencent.com/qt/online/qtsdkrepository/windows_x86/desktop/qt5_5152/ - - qt_ver: 5.15.2 + - qt_ver: 5.15.2 qt_arch: win64_msvc2019_64 msvc_arch: x64 qt_target: x64 - qt_arch_install: msvc2019_64 + qt_arch_install: msvc2019_64 + # - qt_ver: 6.2.3 + # qt_arch: win64_msvc2019_64 + # msvc_arch: x64 + # qt_target: x64 + # qt_arch_install: msvc2019_64 env: targetName: GoldenDict.exe + version: 22.4.Summer # 步骤 steps: # 安装Qt @@ -47,30 +68,42 @@ jobs: cached: 'false' modules: qtwebengine # 拉取代码 - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 with: - fetch-depth: 1 + fetch-depth: 0 + + - name: Set outputs + id: vars + shell: bash + run: | + echo "::set-output name=sha_short::$(git rev-parse --short=8 HEAD)" + echo "::set-output name=release_date::$(date +'%Y%m%d')" + echo "::set-output name=release_time::$(date +'%H%M%S')" + echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')" + + previousTag=$(git tag --sort=-creatordate | sed -n 2p) + echo "previousTag : $previousTag" + + CHANGELOG="$(git log --oneline --no-decorate $previousTag..HEAD)" + CHANGELOG="${CHANGELOG//'%'/'%25'}" + CHANGELOG="${CHANGELOG//$'\n'/'%0A'}" + CHANGELOG="${CHANGELOG//$'\r'/'%0D'}" + echo "::set-output name=COMMIT_SUMMARY::$(echo "$CHANGELOG")" # msvc编译 - name: msvc-build goldendict id: build shell: cmd run: | call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.msvc_arch }} - qmake "CONFIG+=zim_support" + qmake "CONFIG+=zim_support" CONFIG+=release nmake echo winSdkDir=%WindowsSdkDir% >> %GITHUB_ENV% echo winSdkVer=%WindowsSdkVersion% >> %GITHUB_ENV% echo vcToolsInstallDir=%VCToolsInstallDir% >> %GITHUB_ENV% echo vcToolsRedistDir=%VCToolsRedistDir% >> %GITHUB_ENV% + echo QTDIR=%Qt5_DIR% >> %GITHUB_ENV% - - name: Set outputs - id: vars - run: | - echo "::set-output name=sha_short::$(git rev-parse --short HEAD)" - echo "::set-output name=release_date::$(date +'%Y%m%d')" - echo "::set-output name=release_time::$(date +'%H%M%S')" - echo "::set-output name=release_time_clock::$(date +'%H:%M:%S')" # 打包 - name: package id: package @@ -95,17 +128,45 @@ jobs: with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ steps.package.outputs.packageName }}.zip - asset_name: ${{ steps.package.outputs.packageName }}.zip - tag: prerelease-${{steps.vars.outputs.release_date}} + asset_name: ${{ matrix.qt_ver }}-${{ steps.package.outputs.packageName }}.zip + tag: v${{env.version}}-${{ steps.vars.outputs.sha_short }} overwrite: true - release_name: Ubuntu-Windows-${{ github.ref_name }}.${{ steps.vars.outputs.sha_short }} built on ${{steps.vars.outputs.release_date}} ${{steps.vars.outputs.release_time_clock}} - prerelease: true + release_name: win-linux-macos-${{steps.vars.outputs.release_date}} + prerelease: false body: | release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} branch: ${{ github.ref_name }} commit: ${{ steps.vars.outputs.sha_short }} Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} Windows built with: msvc64 Visual studio 2019 + ## goldendict.exe can not used alone + if you have a previous version. replace this maybe ok. if not ,download the whole bundle. AppImage built with: Ubuntu-20.04 ,latest gcc - This is a prerelease version ,auto build by github action. use on your on risk:-) + auto built by github action. use on your on risk:-) + + CHANGES: + ${{ steps.vars.outputs.COMMIT_SUMMARY }} + - name: upload goldendict.exe only + # if: startsWith(github.event.ref, 'refs/tags/') + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: release/${{ env.targetName }} + asset_name: ${{ matrix.qt_ver }}-${{ env.targetName }} + tag: v${{env.version}}-${{ steps.vars.outputs.sha_short }} + overwrite: true + release_name: win-linux-macos-${{steps.vars.outputs.release_date}} + prerelease: false + body: | + release on date: ${{steps.vars.outputs.release_date}} time: ${{steps.vars.outputs.release_time_clock}} + branch: ${{ github.ref_name }} + commit: ${{ steps.vars.outputs.sha_short }} + Qt version: ${{ matrix.qt_ver }} ${{ matrix.qt_arch }} + Windows built with: msvc64 Visual studio 2019 + ## goldendict.exe can not used alone + if you have a previous version. replace this maybe ok. if not ,download the whole bundle. + + AppImage built with: Ubuntu-20.04 ,latest gcc + macos built with: macos-10.15,macos-11.0,clang_64 x86_64(Intel Kind) + auto built by github action. use on your on risk:-) diff --git a/.gitignore b/.gitignore index c41c87e8..eac3e6a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,11 @@ *.o *~ -mouseover_win32/*.dll -mouseover_win32/*.a - locale/*.qm debug/ build/ release/ tmp/ -goldendict -winlibs/lib32-48/ Makefile Makefile.Debug @@ -27,8 +22,6 @@ version.txt .gitattributes -/goldendict.app/ -/GoldenDict.app/ *.dmg .DS_Store @@ -40,3 +33,6 @@ GoldenDict.xcodeproj/ *.opensdf *.suo *.vcxproj.user +/.idea +/.vs +/.vscode diff --git a/CHANGES.md b/CHANGES.md index 2311b0d8..d8686986 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,21 +1,43 @@ -# all the changes: -- replace webkit with webenginewidgets -- clean old code. - - remove old `if 0` code section - - qt_version check - - remove IS_QT_5 check - rename qt4x5.hh to utils.hh,for the name is not proper now. - - QString::SkipEmptyParts=>Qt::SkipEmptyParts - - remove "CONFIG+=old_hunspell" -- remove iconv partly,use qtextcodec instead. - - when parse mdx dictionary ,use qtextcodec - - when parse dsl dictionary ,use qtextcodec instead of iconv +# Changes + +## Until to now + +- **CLEANING OLD/USELESS CODE** +- mac m1 Sillion chip support from [@ngn999](https://github.com/ngn999) + +## Until to 2022-3-24 + +- upgrade opencc to 2020-04-26 version(through vcpkg) +- upgrade ffmpeg dependency to 4.4(on windows),code support to 5.0 +- fix: double click word to translate ,right context menu does not display. +- add macos release workflow ,though not verified. +- fix:middle button open in new tab does not work. +- optimize: large memory consumption ,when have large collection of dictionaries.even when query a small group of dictionaries. +- peformance: dsl parse performance . + when have very long lines,the line will be split into two parts .the remaining part was considered a normal headword ,and hanged when expand parts. +- support qt6.2.3 +- performance improve when edit dictionary groups. + +## Until to 2022-2-2 + +- replace webkit with webenginewidgets +- clean old code. + - remove old `if 0` code section + - qt_version check + - remove IS_QT_5 check + + rename qt4x5.hh to utils.hh,for the name is not proper now. + - QString::SkipEmptyParts=>Qt::SkipEmptyParts + - remove "CONFIG+=old_hunspell" +- remove iconv partly,use qtextcodec instead. + - when parse mdx dictionary ,use qtextcodec + - when parse dsl dictionary ,use qtextcodec instead of iconv - fix the old bug https://github.com/goldendict/goldendict/issues/1322 by the way -- remove dependency of iconv lib completely,use qtextcodec instead. has not merge into this PR yet. in this branch https://github.com/xiaoyifang/goldendict/tree/remove-iconv-lib -- bug, found dictionaries panel show all the dictionaries which is not correct. -- bug,F12 inspect function. -- bug ,double click event.in webengineview widget. the mouse event was eated by child widget. + fix the old bug https://github.com/goldendict/goldendict/issues/1322 by the way +- remove dependency of iconv lib completely,use qtextcodec instead. has not merge into this PR yet. in this branch https://github.com/xiaoyifang/goldendict/tree/remove-iconv-lib +- bug, found dictionaries panel show all the dictionaries which is not correct. +- bug,F12 inspect function. +- bug ,double click event.in webengineview widget. the mouse event was eated by child widget. - bug,bword link (hunspell dictionary) navigation error. - single click to select the word ~(**work inside iframe**)~ - Fix:open image url in external viewer. (only worked with external images) diff --git a/GoldenDict.exe.manifest b/GoldenDict.exe.manifest deleted file mode 100644 index c1375d4e..00000000 --- a/GoldenDict.exe.manifest +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/README.md b/README.md index 7ef6ea1a..311903f9 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e507f9bf83bd48f7a5b76f71dfe9f0dd)](https://app.codacy.com/gh/xiaoyifang/goldendict?utm_source=github.com&utm_medium=referral&utm_content=xiaoyifang/goldendict&utm_campaign=Badge_Grade_Settings) [![Windows](https://github.com/xiaoyifang/goldendict/actions/workflows/windows.yml/badge.svg)](https://github.com/xiaoyifang/goldendict/actions/workflows/windows.yml) [![Ubuntu](https://github.com/xiaoyifang/goldendict/actions/workflows/ubuntu.yml/badge.svg)](https://github.com/xiaoyifang/goldendict/actions/workflows/ubuntu.yml) +[![macos](https://github.com/xiaoyifang/goldendict/actions/workflows/macos.yml/badge.svg)](https://github.com/xiaoyifang/goldendict/actions/workflows/macos.yml) ## Introduction @@ -6,7 +8,7 @@ ## Requirements -This code has been run and tested on Windows XP/Vista/7, Ubuntu Linux, Mac OS X. +This code has been run and tested on Windows 10/11, Ubuntu Linux, Mac OS X. ### External Deps @@ -23,24 +25,36 @@ This code has been run and tested on Windows XP/Vista/7, Ubuntu Linux, Mac OS X. libvorbis-dev zlib1g-dev libhunspell-dev x11proto-record-dev \ qtdeclarative5-dev libxtst-dev liblzo2-dev libbz2-dev \ libao-dev libavutil-dev libavformat-dev libtiff5-dev libeb16-dev \ - libqt5webkit5-dev libqt5svg5-dev libqt5x11extras5-dev qttools5-dev \ + libqt5svg5-dev libqt5x11extras5-dev qttools5-dev \ qttools5-dev-tools qtmultimedia5-dev libqt5multimedia5-plugins ## How to build First, clone this repository, e.g.: - git clone git://github.com/goldendict/goldendict.git + git clone https://github.com/goldendict/goldendict.git + +### Linux And then invoke `qmake-qt5` and `make`: cd goldendict && qmake-qt5 && make -make sure that `qmake` is from Qt 5 installation. If not, you can try -finding it at a path like `/usr/lib/x86_64-linux-gnu/qt5/bin/qmake`. +### macOS +``` +wget ftp://ftp.sra.co.jp/pub/misc/eb/eb-4.4.3.tar.bz2 +tar xvjf eb-4.4.3.tar.bz2 +cd eb-4.4.3 && ./configure && make -j 8 && sudo make install +brew install qt # or use official offline installer +brew install opencc libao hunspell ffmpeg libtiff xz lzo libogg libvorbis +qmake CONFIG+=release CONFIG+=zim_support CONFIG+=chinese_conversion_support +make +make install +``` +### Windows + Alternatively, you might want to load `goldendict.pro` file from within Qt Creator, especially on Windows. -Note: `libhunspell` version > 1.5. ### Building with Chinese conversion support @@ -100,9 +114,7 @@ Then, invoke `make clean` before `make` because the setting change: ### Building under Windows with MS Visual Studio -To build GoldenDict with Visual Studio take one of next library packs and unpack it to `"winlibs/lib/msvc"` folder in GoldenDict sources folder. -[GoldenDict_libs_VS2015_x86_v4.7z](http://www.mediafire.com/file/0a7ygy9rn99oevm/GoldenDict_libs_VS2015_x86_v4.7z) - for MS Visual Studio 2015, 32 bit -[GoldenDict_libs_VS2015_x64_v4.7z](http://www.mediafire.com/file/yoy2q8af0s1467m/GoldenDict_libs_VS2015_x64_v4.7z) - for MS Visual Studio 2015, 64 bit +the source code has offered precompile x64 windows libs on winlibs/lib/msvc. you can build your own version either. To build with Visual Studio. check this [how to build with visual studio](howto/how%20to%20build%20and%20debug%20with%20VS2019.md) diff --git a/aard.cc b/aard.cc index e41433c7..ef0ee50e 100644 --- a/aard.cc +++ b/aard.cc @@ -261,7 +261,7 @@ class AardDictionary: public BtreeIndexing::BtreeDictionary vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual QString const& getDescription(); @@ -826,7 +826,7 @@ sptr< Dictionary::DataRequest > AardDictionary::getArticle( wstring const & word vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new AardArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -838,7 +838,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing & initializing, unsigned maxHeadwordsToExpand ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; @@ -940,8 +940,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( quint16 volumes = qFromBigEndian( dictHeader.totalVolumes ); if( volumes > 1 ) { - QString ss; - ss.sprintf( " (%i/%i)", qFromBigEndian( dictHeader.volume ), volumes ); + QString ss=QString( " (%1/%2)").arg( qFromBigEndian( dictHeader.volume ), volumes ); dictName += ss.toLocal8Bit().data(); } diff --git a/aard.hh b/aard.hh index 686dfa14..6b7305a9 100644 --- a/aard.hh +++ b/aard.hh @@ -17,7 +17,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing &, unsigned maxHeadwordsToExpand ) - THROW_SPEC( std::exception ); + ; } diff --git a/article-style-st-lingoes-blue.css b/article-style-st-lingoes-blue.css index fb3eefb7..8dbef05b 100644 --- a/article-style-st-lingoes-blue.css +++ b/article-style-st-lingoes-blue.css @@ -134,6 +134,12 @@ a:hover { display: none; } +/* Headers */ +h3 { + color: inherit; + font-family: Arial; +} + /* The first headword in a (possibly) multi-headword DSL article */ .gdarticlebody > div:first-child .dsl_headwords, .gdarticlebody > h3:first-child { @@ -162,12 +168,6 @@ code::selection { background: #839EC7; } -/* Headers */ -h3 { - color: inherit; - font-family: Arial; -} - /******** DSL Dictionaries ****************/ /* DSL headwords */ @@ -226,9 +226,6 @@ h3 { -webkit-border-radius: 100px; text-align: center; vertical-align: text-bottom; -} - -.dsl_s_wav a { color: #FFF; border: 1px solid #798415; -webkit-box-shadow: 1px 1px #CCC, inset -1px -1px #4E7500; diff --git a/article-style.css b/article-style.css index d1c3c5af..835b7f42 100644 --- a/article-style.css +++ b/article-style.css @@ -129,7 +129,7 @@ pre.sdct_m } /* StarDict type 'l' -- Pure meaning which used to be in locale encoding. */ -pre.sdct_m +pre.sdct_l { } @@ -791,6 +791,8 @@ div.xdxf font-style: italic; } +.mwiki td.mw-label { vertical-align: top; } +.mwiki td.mw-submit { white-space: nowrap; } /** * Forms */ @@ -801,9 +803,6 @@ div.xdxf .mwiki body.rtl td.mw-input { text-align: right; } .mwiki body.rtl td.mw-submit { text-align: right; } -.mwiki td.mw-label { vertical-align: top; } -.mwiki td.mw-submit { white-space: nowrap; } - /** * Image captions */ @@ -2887,7 +2886,7 @@ in bg url to hide it from iemac */ /****** Wiktionary-specific excerpts *********/ .mwiki .audiolink a { - background: url("http://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/16px-Loudspeaker.svg.png") center left no-repeat !important; + background: url("https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/Loudspeaker.svg/16px-Loudspeaker.svg.png") center left no-repeat !important; padding-left: 20px !important; padding-right: 0 !important; } diff --git a/article_inspect.cpp b/article_inspect.cpp new file mode 100644 index 00000000..084e9a1f --- /dev/null +++ b/article_inspect.cpp @@ -0,0 +1,37 @@ +#include "article_inspect.h" +#include +#if (QT_VERSION > QT_VERSION_CHECK(6,0,0)) +#include +#endif +ArticleInspector::ArticleInspector( QWidget * parent ) : QDialog( parent, Qt::WindowType::Window ) +{ + setAttribute( Qt::WidgetAttribute::WA_DeleteOnClose, false ); + QVBoxLayout * v = new QVBoxLayout( this ); + v->setSpacing( 0 ); + v->setContentsMargins( 0, 0, 0, 0 ); + inspectView = new QWebEngineView(); + v->addWidget( inspectView ); +} + +void ArticleInspector::setInspectPage( QWebEngineView * view ) +{ + auto page=view->page(); + this->inspectedPage = page; + page->setDevToolsPage( inspectView->page() ); +#if( QT_VERSION > QT_VERSION_CHECK( 6, 0, 0 ) ) + // without this line, application will crash on qt6.2 ,see https://bugreports.qt.io/browse/QTBUG-101724 + if( view->lastContextMenuRequest() ) + { + page->triggerAction( QWebEnginePage::InspectElement ); + } +#else + page->triggerAction( QWebEnginePage::InspectElement ); +#endif + raise(); + show(); +} + +void ArticleInspector::closeEvent( QCloseEvent * ) +{ + inspectedPage->setDevToolsPage( nullptr ); +} diff --git a/article_inspect.h b/article_inspect.h new file mode 100644 index 00000000..98f6d31c --- /dev/null +++ b/article_inspect.h @@ -0,0 +1,24 @@ +#ifndef ARTICLE_INSPECT_H +#define ARTICLE_INSPECT_H + +#include +#include +#include +#include + +class ArticleInspector : public QDialog +{ + Q_OBJECT + QWebEngineView * inspectView = nullptr; + QWebEnginePage * inspectedPage = nullptr; +public: + ArticleInspector( QWidget * parent = nullptr ); + + void setInspectPage( QWebEngineView * view); + +private: + + virtual void closeEvent( QCloseEvent * ); +}; + +#endif // ARTICLE_INSPECT_H diff --git a/article_maker.cc b/article_maker.cc index 84257130..db56ca2b 100644 --- a/article_maker.cc +++ b/article_maker.cc @@ -56,7 +56,7 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, result += ""; - result += ""; + result += ""; //custom javascript result += ""; @@ -126,7 +126,7 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, } } - result += "" + Html::escape( Utf8::encode( gd::toWString( word ) ) ) + ""; + result += "" + Html::escape( word.toStdString()) + ""; // This doesn't seem to be much of influence right now, but we'll keep // it anyway. diff --git a/article_netmgr.cc b/article_netmgr.cc index c88d1d22..356b68e4 100644 --- a/article_netmgr.cc +++ b/article_netmgr.cc @@ -1,14 +1,8 @@ /* This file is (c) 2008-2012 Konstantin Isakov * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ -#if defined( _MSC_VER ) && _MSC_VER < 1800 // VS2012 and older -#include -#else #include -#endif - #include - #include "article_netmgr.hh" #include "wstring_qt.hh" #include "gddebug.hh" @@ -32,7 +26,7 @@ using std::string; connect( baseReply, SIGNAL( metaDataChanged() ), this, SLOT( applyMetaData() ) ); - connect( baseReply, SIGNAL( error( QNetworkReply::NetworkError) ), + connect( baseReply, SIGNAL( errorOccurred( QNetworkReply::NetworkError) ), this, SLOT( applyError( QNetworkReply::NetworkError ) ) ); connect( baseReply, SIGNAL( readyRead() ), this, SLOT( readDataFromBase() ) ); @@ -113,8 +107,8 @@ using std::string; baseReply->attribute( QNetworkRequest::HttpPipeliningWasUsedAttribute ) ); setAttribute( QNetworkRequest::BackgroundRequestAttribute, baseReply->attribute( QNetworkRequest::BackgroundRequestAttribute ) ); - setAttribute( QNetworkRequest::SpdyWasUsedAttribute, - baseReply->attribute( QNetworkRequest::SpdyWasUsedAttribute ) ); + setAttribute( QNetworkRequest::Http2WasUsedAttribute, + baseReply->attribute( QNetworkRequest::Http2WasUsedAttribute ) ); emit metaDataChanged(); } @@ -133,7 +127,7 @@ using std::string; void AllowFrameReply::applyError( QNetworkReply::NetworkError code ) { setError( code, baseReply->errorString() ); - emit error( code ); + emit errorOccurred( code ); } void AllowFrameReply::readDataFromBase() @@ -283,7 +277,7 @@ QNetworkReply * ArticleNetworkAccessManager::createRequest( Operation op, QNetworkRequest newReq(req); if ( hideGoldenDictHeader && req.url().scheme().startsWith("http", Qt::CaseInsensitive)) { - newReq.setRawHeader("User-Agent", req.rawHeader("User-Agent").replace(qApp->applicationName(), "")); + newReq.setRawHeader("User-Agent", req.rawHeader("User-Agent").replace(qApp->applicationName().toUtf8(), "")); } QNetworkReply * reply = QNetworkAccessManager::createRequest( op, newReq, outgoingData ); @@ -336,8 +330,8 @@ sptr< Dictionary::DataRequest > ArticleNetworkAccessManager::getResource( // See if we have some dictionaries muted - QSet< QString > mutedDicts = - QSet< QString >::fromList( Utils::Url::queryItemValue( url, "muted" ).split( ',' ) ); + QStringList mutedDictLists=Utils::Url::queryItemValue( url, "muted" ).split( ',' ); + QSet< QString > mutedDicts ( mutedDictLists.begin(),mutedDictLists.end()); // Unpack contexts @@ -525,7 +519,7 @@ void ArticleResourceReply::readyReadSlot() void ArticleResourceReply::finishedSlot() { if (req->dataSize() < 0) { - emit error(ContentNotFoundError); + emit errorOccurred(ContentNotFoundError); setError(ContentNotFoundError, "content not found"); } @@ -569,5 +563,6 @@ void LocalSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob) connect(reply,&QNetworkReply::finished,requestJob,[=](){ requestJob->reply("text/html",reply); }); + connect(requestJob, &QObject::destroyed, reply, &QObject::deleteLater); } diff --git a/articleview.cc b/articleview.cc index 38101edf..c96d198f 100644 --- a/articleview.cc +++ b/articleview.cc @@ -2,6 +2,7 @@ * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ #include "articleview.hh" +#include "QtCore/qvariant.h" #include "folding.hh" #include "fulltextsearch.hh" #include "gddebug.hh" @@ -28,7 +29,14 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(5,0,0) && QT_VERSION < QT_VERSION_CHECK(6,0,0)) #include +#endif +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#include +#include +#endif #ifdef Q_OS_WIN32 #include #include @@ -172,27 +180,6 @@ public: void ArticleView::emitJavascriptFinished(){ emit notifyJavascriptFinished(); } -//in webengine,javascript has been executed in async mode ,for simpility,use EventLoop to simulate sync execution. -//a better solution would be to replace it with callback etc. -QString ArticleView::runJavaScriptSync(QWebEnginePage* frame, const QString& variable) -{ - qDebug("%s", QString("runJavascriptScriptSync:%1").arg(variable).toLatin1().data()); - - QString result; - QSharedPointer loop = QSharedPointer(new QEventLoop()); - QTimer::singleShot(1000, loop.data(), &QEventLoop::quit); - frame->runJavaScript(variable, [=,&result](const QVariant &v) - { - if(loop->isRunning()){ - if(v.isValid()) - result = v.toString(); - loop->quit(); - } - }); - - loop->exec(); - return result; -} namespace { @@ -218,14 +205,11 @@ QString ArticleView::scrollToFromDictionaryId( QString const & dictionaryId ) return scrollToPrefix + dictionaryId; } -ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, - AudioPlayerPtr const & audioPlayer_, +ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, AudioPlayerPtr const & audioPlayer_, std::vector< sptr< Dictionary::Class > > const & allDictionaries_, - Instances::Groups const & groups_, bool popupView_, - Config::Class const & cfg_, - QAction & openSearchAction_, - QAction * dictionaryBarToggled_, - GroupComboBox const * groupComboBox_ ): + Instances::Groups const & groups_, bool popupView_, Config::Class const & cfg_, + QAction & openSearchAction_, QAction * dictionaryBarToggled_, + GroupComboBox const * groupComboBox_ ) : QFrame( parent ), articleNetMgr( nm ), audioPlayer( audioPlayer_ ), @@ -324,24 +308,28 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, inspectAction.setText( tr( "Inspect" ) ); ui.definition->addAction( &inspectAction ); - QWebEnginePage *page = ui.definition->page(); - connect(&inspectAction, &QAction::triggered, this, [page, this]() { - if (inspectView == nullptr || !inspectView->isVisible()) { - inspectView = new QWebEngineView(); - page->setDevToolsPage(inspectView->page()); - page->triggerAction(QWebEnginePage::InspectElement); - inspectView->show(); - } - }); + + connect(&inspectAction, &QAction::triggered, this, &ArticleView::inspectElement); ui.definition->installEventFilter( this ); ui.searchFrame->installEventFilter( this ); ui.ftsSearchFrame->installEventFilter( this ); - QWebEngineSettings * settings = ui.definition->page()->settings(); + QWebEngineSettings * settings = ui.definition->settings(); + settings->setUnknownUrlSchemePolicy(QWebEngineSettings::UnknownUrlSchemePolicy::DisallowUnknownUrlSchemes); +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true ); settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true ); settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false); + settings->defaultSettings()->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins); + settings->defaultSettings()->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false); +#else + settings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true ); + settings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true ); + settings->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false ); + settings->setAttribute( QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins ); + settings->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false ); +#endif // Load the default blank page instantly, so there would be no flicker. QString contentType; @@ -395,7 +383,7 @@ void ArticleView::showDefinition( Config::InputPhrase const & phrase, unsigned g QString const & scrollTo, Contexts const & contexts_ ) { - currentWord = phrase.phrase; + currentWord = phrase.phrase.trimmed(); currentActiveDictIds.clear(); // first, let's stop the player audioPlayer->stop(); @@ -473,7 +461,7 @@ void ArticleView::showDefinition( QString const & word, QStringList const & dict { if( dictIDs.isEmpty() ) return; - currentWord = word; + currentWord = word.trimmed(); // first, let's stop the player audioPlayer->stop(); @@ -515,47 +503,31 @@ void ArticleView::showAnticipation() ui.definition->setCursor( Qt::WaitCursor ); } +void ArticleView::inspectElement(){ + if( inspector == nullptr ) + { + inspector = new ArticleInspector( this ); + inspector->setWindowTitle( tr( "Inspect" ) ); + } + inspector->setInspectPage( ui.definition ); +} + void ArticleView::loadFinished( bool result ) { setZoomFactor(cfg.preferences.zoomFactor); QUrl url = ui.definition->url(); qDebug() << "article view loaded url:" << url.url ().left (200); - QVariant userDataVariant = ui.definition->property("currentArticle"); - - if ( userDataVariant.isValid() ) - { - double sx = 0, sy = 0; - - QVariant qsx=ui.definition->property("sx"); - if ( qsx.type() == QVariant::Double ) - sx = qsx.toDouble(); - - QVariant qsy = ui.definition->property("sx"); - if ( qsy.type() == QVariant::Double ) - sy = qsy.toDouble(); - - if ( sx != 0 || sy != 0 ) - { - // Restore scroll position - ui.definition->page()->runJavaScript( - QString( "window.scroll( %1, %2 );" ).arg( sx ).arg( sy ) ); - } - } - else + if( cfg.preferences.autoScrollToTargetArticle ) { QString const scrollTo = Utils::Url::queryItemValue( url, "scrollto" ); if( isScrollTo( scrollTo ) ) { - // There is no active article saved in history, but we have it as a parameter. - // setCurrentArticle will save it and scroll there. setCurrentArticle( scrollTo, true ); } } - ui.definition->unsetCursor(); - //QApplication::restoreOverrideCursor(); // Expand collapsed article if only one loaded ui.definition->page()->runJavaScript( QString( "gdCheckArticlesNumber();" ) ); @@ -690,11 +662,15 @@ void ArticleView::setCurrentArticle( QString const & id, bool moveToIt ) return; // No action on background page, scrollIntoView there don't work if(moveToIt){ - QString script=QString(" var elem=document.getElementById('%1'); if(elem!=undefined){elem.scrollIntoView(true);}").arg(id); - onJsActiveArticleChanged(id); - ui.definition->page()->runJavaScript(script); - ui.definition->setProperty("currentArticle",id); - setActiveArticleId(id.mid(7)); + QString dictId = id.mid( 7 ); + if( dictId.isEmpty() ) + return; + QString script = QString( "var elem=document.getElementById('%1'); " + "if(elem!=undefined){elem.scrollIntoView(true);} gdMakeArticleActive('%2',true);" ) + .arg( id, dictId ); + onJsActiveArticleChanged( id ); + ui.definition->page()->runJavaScript( script ); + setActiveArticleId( dictId ); } } @@ -704,13 +680,13 @@ void ArticleView::selectCurrentArticle() QString( "gdSelectArticle( '%1' );var elem=document.getElementById('%2'); if(elem!=undefined){elem.scrollIntoView(true);}" ).arg( getActiveArticleId() ,getCurrentArticle()) ); } -bool ArticleView::isFramedArticle( QString const & ca ) +void ArticleView::isFramedArticle( QString const & ca, const std::function< void( bool ) > & callback ) { - if ( ca.isEmpty() ) - return false; + if( ca.isEmpty() ) + callback( false ); - QString result=runJavaScriptSync( ui.definition->page(), QString( "!!document.getElementById('gdexpandframe-%1');" ).arg( ca.mid( 7 ) ) ); - return result=="true"; + ui.definition->page()->runJavaScript( QString( "!!document.getElementById('gdexpandframe-%1');" ).arg( ca.mid( 7 ) ), + [ callback ]( const QVariant & res ) { callback( res.toBool() ); } ); } bool ArticleView::isExternalLink( QUrl const & url ) @@ -722,39 +698,41 @@ void ArticleView::tryMangleWebsiteClickedUrl( QUrl & url, Contexts & contexts ) { // Don't try mangling audio urls, even if they are from the framed websites - if( ( url.scheme() == "http" || url.scheme() == "https" ) - && ! Dictionary::WebMultimediaDownload::isAudioUrl( url ) ) + if( ( url.scheme() == "http" || url.scheme() == "https" ) && !Dictionary::WebMultimediaDownload::isAudioUrl( url ) ) { // Maybe a link inside a website was clicked? QString ca = getCurrentArticle(); + isFramedArticle( ca, + [ &url, &contexts, &ca ]( bool framed ) + { + if( framed ) + { + // QVariant result = runJavaScriptSync( ui.definition->page(), "gdLastUrlText" ); + QVariant result; - if ( isFramedArticle( ca ) ) - { - //QVariant result = runJavaScriptSync( ui.definition->page(), "gdLastUrlText" ); - QVariant result ; + if( result.type() == QVariant::String ) + { + // Looks this way + contexts[ dictionaryIdFromScrollTo( ca ) ] = QString::fromLatin1( url.toEncoded() ); - if ( result.type() == QVariant::String ) - { - // Looks this way - contexts[ dictionaryIdFromScrollTo( ca ) ] = QString::fromLatin1( url.toEncoded() ); + QUrl target; - QUrl target; + QString queryWord = result.toString(); - QString queryWord = result.toString(); + // Empty requests are treated as no request, so we work this around by + // adding a space. + if( queryWord.isEmpty() ) + queryWord = " "; - // Empty requests are treated as no request, so we work this around by - // adding a space. - if ( queryWord.isEmpty() ) - queryWord = " "; + target.setScheme( "gdlookup" ); + target.setHost( "localhost" ); + target.setPath( "/" + queryWord ); - target.setScheme( "gdlookup" ); - target.setHost( "localhost" ); - target.setPath( "/" + queryWord ); - - url = target; - } - } + url = target; + } + } + } ); } } @@ -833,6 +811,17 @@ bool ArticleView::handleF3( QObject * /*obj*/, QEvent * ev ) bool ArticleView::eventFilter( QObject * obj, QEvent * ev ) { +#ifdef Q_OS_MAC + + if( ev->type() == QEvent::NativeGesture ) + { + qDebug() << "it's a Native Gesture!"; + // handle Qt::ZoomNativeGesture Qt::SmartZoomNativeGesture here + // ignore swipe left/right. + // QWebEngine can handle Qt::SmartZoomNativeGesture. + } + +#else if( ev->type() == QEvent::Gesture ) { Gestures::GestureResult result; @@ -859,15 +848,17 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev ) int delta = result == Gestures::SWIPE_UP ? -120 : 120; QWidget *widget = static_cast< QWidget * >( obj ); + QPoint angleDelta(0, delta); + QPoint pixelDetal; QWidget *child = widget->childAt( widget->mapFromGlobal( pt ) ); if( child ) { - QWheelEvent whev( child->mapFromGlobal( pt ), pt, delta, Qt::NoButton, Qt::NoModifier ); + QWheelEvent whev( child->mapFromGlobal( pt ), pt, pixelDetal,angleDelta, Qt::NoButton, Qt::NoModifier,Qt::NoScrollPhase,false); qApp->sendEvent( child, &whev ); } else { - QWheelEvent whev( widget->mapFromGlobal( pt ), pt, delta, Qt::NoButton, Qt::NoModifier ); + QWheelEvent whev( widget->mapFromGlobal( pt ), pt,pixelDetal, angleDelta,Qt::NoButton, Qt::NoModifier,Qt::NoScrollPhase,false ); qApp->sendEvent( widget, &whev ); } } @@ -875,6 +866,7 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev ) return handled; } +#endif if( ev->type() == QEvent::MouseMove ) { @@ -925,6 +917,21 @@ bool ArticleView::eventFilter( QObject * obj, QEvent * ev ) return true; } } + else if( ev->type() == QEvent::Wheel ) + { + QWheelEvent * pe = static_cast< QWheelEvent * >( ev ); + if( pe->modifiers().testFlag( Qt::ControlModifier ) ) + { + if( pe->angleDelta().y() > 0 ) + { + zoomIn(); + } + else + { + zoomOut(); + } + } + } } else return QFrame::eventFilter( obj, ev ); @@ -1105,6 +1112,7 @@ void ArticleView::linkClicked( QUrl const & url_ ) ( kmod & ( Qt::ControlModifier | Qt::ShiftModifier ) ) ) ) { // Mid button or Control/Shift is currently pressed - open the link in new tab + ui.definition->resetMidButtonPressed(); emit openLinkInNewTab( url, ui.definition->url(), getCurrentArticle(), contexts ); } else @@ -1114,6 +1122,10 @@ void ArticleView::linkClicked( QUrl const & url_ ) void ArticleView::linkClickedInHtml( QUrl const & url_ ) { emit ui.definition->linkClickedInHtml(url_); + if(!url_.isEmpty()) + { + linkClicked( url_ ); + } } void ArticleView::openLink( QUrl const & url, QUrl const & ref, QString const & scrollTo, @@ -1626,12 +1638,16 @@ void ArticleView::forward() ui.definition->forward(); } -bool ArticleView::hasSound() +void ArticleView::hasSound( const std::function< void( bool ) > & callback ) { - QVariant v = runJavaScriptSync( ui.definition->page(),"gdAudioLinks.first" ); - if ( v.type() == QVariant::String ) - return !v.toString().isEmpty(); - return false; + ui.definition->page()->runJavaScript( "gdAudioLinks.first", + [ callback ]( const QVariant & v ) + { + bool has = false; + if( v.type() == QVariant::String ) + has = !v.toString().isEmpty(); + callback( has ); + } ); } //use webengine javascript to playsound @@ -1643,27 +1659,24 @@ void ArticleView::playSound() " } " " return link;})(); "; - QString soundScript = runJavaScriptSync(ui.definition->page(), variable); - // ui.definition->page()->runJavaScript(variable); - if (!soundScript.isEmpty()) - openLink(QUrl::fromEncoded(soundScript.toUtf8()), ui.definition->url()); + ui.definition->page()->runJavaScript(variable,[this](const QVariant & result){ + if (result.type() == QVariant::String) { + QString soundScript = result.toString(); + if (!soundScript.isEmpty()) + openLink(QUrl::fromEncoded(soundScript.toUtf8()), ui.definition->url()); + } + }); } // use eventloop to turn the async callback to sync execution. -QString ArticleView::toHtml() +void ArticleView::toHtml( const std::function< void( QString & ) > & callback ) { - QString result; - QSharedPointer loop = QSharedPointer(new QEventLoop()); - QTimer::singleShot(1000, loop.data(), &QEventLoop::quit); - - ui.definition->page()->toHtml([loop, &result](const QString &content) { - if (loop->isRunning()) { - result = content; - loop->quit(); - } - }); - loop->exec(); - return result; + ui.definition->page()->toHtml( + [ = ]( const QString & content ) + { + QString html = content; + callback( html ); + } ); } void ArticleView::setHtml(const QString& content,const QUrl& baseUrl){ @@ -1688,15 +1701,24 @@ Config::InputPhrase ArticleView::getPhrase() const void ArticleView::print( QPrinter * printer ) const { - //ui.definition->page()->print(printer, [](bool result) {}); - QEventLoop loop; - bool result; - auto printPreview = [&](bool success) { result = success; loop.quit(); }; - ui.definition->page()->print(printer, std::move(printPreview)); - loop.exec(); - if (!result) { - qDebug()<<"print failed"; - } + QEventLoop loop; + bool result; + auto printPreview = [ & ]( bool success ) + { + result = success; + loop.quit(); + }; +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) + ui.definition->page()->print( printer, std::move( printPreview ) ); +#else + connect( ui.definition, &QWebEngineView::printFinished, &loop, std::move( printPreview ) ); + ui.definition->print( printer ); +#endif + loop.exec(); + if( !result ) + { + qDebug() << "print failed"; + } } void ArticleView::contextMenuRequested( QPoint const & pos ) @@ -1720,10 +1742,14 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) QAction * addHeaderToHistoryAction = 0; QAction * sendWordToInputLineAction = 0; QAction * saveImageAction = 0; - QAction * saveSoundAction = 0; + QAction * saveSoundAction = 0; - QWebEngineContextMenuData menuData=r->contextMenuData(); - QUrl targetUrl(menuData.linkUrl()); +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) + const QWebEngineContextMenuData * menuData = &(r->contextMenuData()); +#else + QWebEngineContextMenuRequest * menuData = ui.definition->lastContextMenuRequest(); +#endif + QUrl targetUrl(menuData->linkUrl()); Contexts contexts; tryMangleWebsiteClickedUrl( targetUrl, contexts ); @@ -1752,9 +1778,13 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) } QUrl imageUrl; - if( !popupView && menuData.mediaType ()==QWebEngineContextMenuData::MediaTypeImage) +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) + if( !popupView && menuData->mediaType ()==QWebEngineContextMenuData::MediaTypeImage) +#else + if( !popupView && menuData->mediaType ()==QWebEngineContextMenuRequest::MediaType::MediaTypeImage) +#endif { - imageUrl = menuData.mediaUrl (); + imageUrl = menuData->mediaUrl (); if( !imageUrl.isEmpty() ) { menu.addAction( ui.definition->pageAction( QWebEnginePage::CopyImageToClipboard ) ); @@ -2012,7 +2042,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) } } - qDebug( "title = %s\n", r->title().toLocal8Bit().data() ); + qDebug()<< "title = "<< r->title(); } @@ -2142,19 +2172,21 @@ void ArticleView::moveOneArticleUp() void ArticleView::moveOneArticleDown() { QString current = getCurrentArticle(); - - if ( current.size() ) + QString currentDictId = dictionaryIdFromScrollTo( current ); + QStringList lst = getArticlesList(); + // if current article is empty .use the first as default. + if( currentDictId.isEmpty() && !lst.isEmpty() ) { - QStringList lst = getArticlesList(); + currentDictId = lst[ 0 ]; + } - int idx = lst.indexOf( dictionaryIdFromScrollTo( current ) ); + int idx = lst.indexOf( currentDictId ); - if ( idx != -1 ) - { - idx = ( idx + 1 ) % lst.size(); + if( idx != -1 ) + { + idx = ( idx + 1 ) % lst.size(); - setCurrentArticle( scrollToFromDictionaryId( lst[ idx ] ), true ); - } + setCurrentArticle( scrollToFromDictionaryId( lst[ idx ] ), true ); } } @@ -2235,17 +2267,19 @@ void ArticleView::onJsActiveArticleChanged(QString const & id) if ( !isScrollTo( id ) ) return; // Incorrect id - emit activeArticleChanged( this, dictionaryIdFromScrollTo( id ) ); + QString dictId = dictionaryIdFromScrollTo( id ); + setActiveArticleId( dictId ); + emit activeArticleChanged( this, dictId ); } void ArticleView::doubleClicked( QPoint pos ) { // We might want to initiate translation of the selected word - + audioPlayer->stop(); if ( cfg.preferences.doubleClickTranslates ) { QString selectedText = ui.definition->selectedText(); - + emit sendWordToInputLine( selectedText ); // Do some checks to make sure there's a sensible selection indeed if ( Folding::applyWhitespaceOnly( gd::toWString( selectedText ) ).size() && selectedText.size() < 60 ) @@ -2330,12 +2364,22 @@ bool ArticleView::findText(QString& text, const QWebEnginePage::FindFlags& f) // turn async to sync invoke. QSharedPointer loop = QSharedPointer(new QEventLoop()); QTimer::singleShot(1000, loop.data(), &QEventLoop::quit); +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + ui.definition->findText(text, f, [&](const QWebEngineFindTextResult& result) + { + if(loop->isRunning()){ + r = result.numberOfMatches()>0; + loop->quit(); + } }); +#else ui.definition->findText(text, f, [&](bool result) - { - if(loop->isRunning()){ - r = result; - loop->quit(); - } }); + { + if(loop->isRunning()){ + r = result; + loop->quit(); + } }); +#endif + loop->exec(); return r; @@ -2459,10 +2503,9 @@ void ArticleView::highlightFTSResults() else regexp.setPattern( regString ); - QRegularExpression::PatternOptions patternOptions = QRegularExpression::DotMatchesEverythingOption - | QRegularExpression::UseUnicodePropertiesOption - | QRegularExpression::MultilineOption - | QRegularExpression::InvertedGreedinessOption; + QRegularExpression::PatternOptions patternOptions = + QRegularExpression::DotMatchesEverythingOption | QRegularExpression::UseUnicodePropertiesOption | + QRegularExpression::MultilineOption | QRegularExpression::InvertedGreedinessOption; if( !Utils::Url::hasQueryItem( url, "matchcase" ) ) patternOptions |= QRegularExpression::CaseInsensitiveOption; regexp.setPatternOptions( patternOptions ); @@ -2470,84 +2513,69 @@ void ArticleView::highlightFTSResults() if( regexp.pattern().isEmpty() || !regexp.isValid() ) return; - - sptr< AccentMarkHandler > marksHandler = ignoreDiacritics ? - new DiacriticsHandler : new AccentMarkHandler; + sptr< AccentMarkHandler > marksHandler = ignoreDiacritics ? new DiacriticsHandler : new AccentMarkHandler; // Clear any current selection - if ( ui.definition->selectedText().size() ) + if( ui.definition->selectedText().size() ) { - ui.definition->page()-> - runJavaScript( "window.getSelection().removeAllRanges();_=0;" ); + ui.definition->page()->runJavaScript( "window.getSelection().removeAllRanges();_=0;" ); } - QString pageText = getWebPageTextSync(ui.definition->page()); - marksHandler->setText( pageText ); - - QRegularExpressionMatchIterator it = regexp.globalMatch( marksHandler->normalizedText() ); - while( it.hasNext() ) - { - QRegularExpressionMatch match = it.next(); - - // Mirror pos and matched length to original string - int pos = match.capturedStart(); - int spos = marksHandler->mirrorPosition( pos ); - int matched = marksHandler->mirrorPosition( pos + match.capturedLength() ) - spos; - - // Add mark pos (if presented) - while( spos + matched < pageText.length() - && pageText[ spos + matched ].category() == QChar::Mark_NonSpacing ) - matched++; - - if( matched > FTS::MaxMatchLengthForHighlightResults ) + ui.definition->page()->toPlainText( + [ & ]( const QString pageText ) { - gdWarning( "ArticleView::highlightFTSResults(): Too long match - skipped (matched length %i, allowed %i)", - match.capturedLength(), FTS::MaxMatchLengthForHighlightResults ); - } - else - allMatches.append( pageText.mid( spos, matched ) ); - } + marksHandler->setText( pageText ); - ftsSearchMatchCase = Utils::Url::hasQueryItem( url, "matchcase" ); + QRegularExpressionMatchIterator it = regexp.globalMatch( marksHandler->normalizedText() ); + while( it.hasNext() ) + { + QRegularExpressionMatch match = it.next(); - QWebEnginePage::FindFlags flags ( 0 ); + // Mirror pos and matched length to original string + int pos = match.capturedStart(); + int spos = marksHandler->mirrorPosition( pos ); + int matched = marksHandler->mirrorPosition( pos + match.capturedLength() ) - spos; - if( ftsSearchMatchCase ) - flags |= QWebEnginePage::FindCaseSensitively; + // Add mark pos (if presented) + while( spos + matched < pageText.length() && pageText[ spos + matched ].category() == QChar::Mark_NonSpacing ) + matched++; - for( int x = 0; x < allMatches.size(); x++ ) - ui.definition->findText( allMatches.at( x ), flags ); + if( matched > FTS::MaxMatchLengthForHighlightResults ) + { + gdWarning( "ArticleView::highlightFTSResults(): Too long match - skipped (matched length %i, allowed %i)", + match.capturedLength(), + FTS::MaxMatchLengthForHighlightResults ); + } + else + allMatches.append( pageText.mid( spos, matched ) ); + } - if( !allMatches.isEmpty() ) - { - ui.definition->findText( allMatches.at( 0 ), flags ); - //if( ui.definition->findText( allMatches.at( 0 ), flags ) ) - { - ui.definition->page()-> - runJavaScript( QString( "%1=window.getSelection().getRangeAt(0);_=0;" ) - .arg( rangeVarName ) ); - } - } + ftsSearchMatchCase = Utils::Url::hasQueryItem( url, "matchcase" ); - ui.ftsSearchFrame->show(); - ui.ftsSearchPrevious->setEnabled( false ); - ui.ftsSearchNext->setEnabled( allMatches.size()>1 ); + QWebEnginePage::FindFlags flags( 0 ); - ftsSearchIsOpened = true; -} + if( ftsSearchMatchCase ) + flags |= QWebEnginePage::FindCaseSensitively; -QString ArticleView::getWebPageTextSync(QWebEnginePage * page){ - QString planText; - QSharedPointer loop = QSharedPointer(new QEventLoop()); - QTimer::singleShot(1000, loop.data(), &QEventLoop::quit); - page->toPlainText([&](const QString &result) - { - if(loop->isRunning()){ - planText = result; - loop->quit(); - } }); - loop->exec(); - return planText; + for( int x = 0; x < allMatches.size(); x++ ) + ui.definition->findText( allMatches.at( x ), flags ); + + if( !allMatches.isEmpty() ) + { + ui.definition->findText( allMatches.at( 0 ), flags ); + // if( ui.definition->findText( allMatches.at( 0 ), flags ) ) + { + ui.definition->page()->runJavaScript( + QString( "%1=window.getSelection().getRangeAt(0);_=0;" ).arg( rangeVarName ) ); + } + } + + ui.ftsSearchFrame->show(); + ui.ftsSearchPrevious->setEnabled( false ); + ui.ftsSearchNext->setEnabled( allMatches.size() > 1 ); + + ftsSearchIsOpened = true; + } ); } void ArticleView::setActiveDictIds(ActiveDictIds ad) { @@ -2589,7 +2617,18 @@ void ArticleView::performFtsFindOperation( bool backwards ) if (ftsPosition > 0) { ftsPosition -= 1; } - +#if( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) ) + ui.definition->findText( allMatches.at( ftsPosition ), + flags | QWebEnginePage::FindBackward, + [ this ]( const QWebEngineFindTextResult & result ) + { + if( result.numberOfMatches ()== 0 ) + return; + ui.ftsSearchPrevious->setEnabled(true); + if (!ui.ftsSearchNext->isEnabled()) + ui.ftsSearchNext->setEnabled(true); + }); +#else ui.definition->findText(allMatches.at(ftsPosition), flags | QWebEnginePage::FindBackward, [this](bool res) { @@ -2597,10 +2636,21 @@ void ArticleView::performFtsFindOperation( bool backwards ) if (!ui.ftsSearchNext->isEnabled()) ui.ftsSearchNext->setEnabled(res); }); +#endif } else { if (ftsPosition < allMatches.size() - 1) { ftsPosition += 1; } +#if( QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 ) ) + ui.definition->findText(allMatches.at(ftsPosition), flags, [this](const QWebEngineFindTextResult & result ) { + if( result.numberOfMatches() == 0 ) + return; + ui.ftsSearchNext->setEnabled(true); + if (!ui.ftsSearchPrevious->isEnabled()) + ui.ftsSearchPrevious->setEnabled(true); + }); + } +#else ui.definition->findText(allMatches.at(ftsPosition), flags, [this](bool res) { ui.ftsSearchNext->setEnabled(res); @@ -2608,7 +2658,7 @@ void ArticleView::performFtsFindOperation( bool backwards ) ui.ftsSearchPrevious->setEnabled(res); }); } - +#endif // Store new highlighted selection ui.definition->page()-> runJavaScript( QString( "%1=window.getSelection().getRangeAt(0);_=0;" ) @@ -2625,148 +2675,6 @@ void ArticleView::on_ftsSearchNext_clicked() performFtsFindOperation( false ); } -#ifdef Q_OS_WIN32 - -void ArticleView::readTag( const QString & from, QString & to, int & count ) -{ - QChar ch, prev_ch; - bool inQuote = false, inDoublequote = false; - - to.append( ch = prev_ch = from[ count++ ] ); - while( count < from.size() ) - { - ch = from[ count ]; - if( ch == '>' && !( inQuote || inDoublequote ) ) - { - to.append( ch ); - break; - } - if( ch == '\'' ) - inQuote = !inQuote; - if( ch == '\"' ) - inDoublequote = !inDoublequote; - to.append( prev_ch = ch ); - count++; - } -} - -QString ArticleView::insertSpans( QString const & html ) -{ - QChar ch; - QString newContent; - bool inSpan = false, escaped = false; - - /// Enclose every word in string (exclude tags) with - - for( int i = 0; i < html.size(); i++ ) - { - ch = html[ i ]; - if( ch == '&' ) - { - escaped = true; - if( inSpan ) - { - newContent.append( "" ); - inSpan = false; - } - newContent.append( ch ); - continue; - } - - if( ch == '<' ) // Skip tag - { - escaped = false; - if( inSpan ) - { - newContent.append( "" ); - inSpan = false; - } - readTag( html, newContent, i ); - continue; - } - - if( escaped ) - { - if( ch == ';' ) - escaped = false; - newContent.append( ch ); - continue; - } - - if( !inSpan && ( ch.isLetterOrNumber() || ch.isLowSurrogate() ) ) - { - newContent.append( ""); - inSpan = true; - } - - if( inSpan && !( ch.isLetterOrNumber() || ch.isLowSurrogate() ) ) - { - newContent.append( ""); - inSpan = false; - } - - if( ch.isLowSurrogate() ) - { - newContent.append( ch ); - ch = html[ ++i ]; - } - - newContent.append( ch ); - if( ch == '-' && !( html[ i + 1 ] == ' ' || ( i > 0 && html[ i - 1 ] == ' ' ) ) ) - newContent.append( " " ); - } - if( inSpan ) - newContent.append( "" ); - return newContent; -} - -QString ArticleView::checkElement( QWebEnginePage & page, QPoint const & pt ) -{ - return runJavaScriptSync(&page, QString( - " var a= document.elementFromPoint(%1,%2);" - "var nodename=a.nodeName.toLowerCase();" - "if(nodename==\"body\"||nodename==\"html\"||nodename==\"head\")" - "{" - " return '';" - "}" - "return a.textContent;") - .arg(pt.x()) - .arg(pt.y())); -} - -QString ArticleView::wordAtPoint( int x, int y ) -{ - QString word; - - if( popupView ) - return word; - - QPoint pos = mapFromGlobal( QPoint( x, y ) ); - //todo - QWebEnginePage *frame = ui.definition->page(); - if( !frame ) - return word; - - QPointF scrollPoint=frame->scrollPosition(); - - QPoint posWithScroll = pos + QPoint((int)scrollPoint.x(),(int)scrollPoint.y()); - - /// Find target HTML element - QString nodeValue = runJavaScriptSync(frame, QString( - "var a= document.elementFromPoint(%1,%2);" - "var nodename=a.nodeName.toLowerCase();" - "if(nodename==\"body\"||nodename==\"html\"||nodename==\"head\")" - "{" - " return '';" - "}" - "return a.textContent;") - .arg(posWithScroll.x()) - .arg(posWithScroll.y())); - return nodeValue; -} - -#endif - ResourceToSaveHandler::ResourceToSaveHandler(ArticleView * view, QString const & fileName ) : QObject( view ), fileName( fileName ), diff --git a/articleview.hh b/articleview.hh index 9e3ea0d4..a7c501ab 100644 --- a/articleview.hh +++ b/articleview.hh @@ -15,6 +15,10 @@ #include "groupcombobox.hh" #include "ui_articleview.h" #include "globalbroadcaster.h" +#include "article_inspect.h" +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif class ResourceToSaveHandler; class ArticleViewAgent ; @@ -45,7 +49,7 @@ class ArticleView: public QFrame QString rangeVarName; //used to hold the F12 inspect source view. - QWebEngineView *inspectView = nullptr; + ArticleInspector * inspector = nullptr; /// Any resource we've decided to download off the dictionary gets stored here. /// Full vector capacity is used for search requests, where we have to make @@ -108,8 +112,6 @@ public: /// Returns "gdfrom-" + dictionaryId. static QString scrollToFromDictionaryId( QString const & dictionaryId ); - QString runJavaScriptSync(QWebEnginePage* frame, const QString& variable); - void emitJavascriptFinished(); /// Shows the definition of the given word with the given group. @@ -154,8 +156,6 @@ public: /// Called when preference changes void setSelectionBySingleClick( bool set ); - QString getWebPageTextSync(QWebEnginePage * page); - public slots: /// Goes back in history @@ -175,22 +175,23 @@ public: { ui.definition->reload(); } /// Returns true if there's an audio reference on the page, false otherwise. - bool hasSound(); + void hasSound( const std::function< void( bool has ) > & callback ); /// Plays the first audio reference on the page, if any. void playSound(); void setZoomFactor( qreal factor ) { - if(ui.definition->zoomFactor()!=factor){ - qDebug()<<"set zoom factor:"<zoomFactor(); + if(!qFuzzyCompare(existedFactor,factor)){ + qDebug()<<"zoom factor ,existed:"<setZoomFactor( factor ); - ui.definition->page()->setZoomFactor(factor); + //ui.definition->page()->setZoomFactor(factor); } } /// Returns current article's text in .html format - QString toHtml(); + void toHtml( const std::function< void( QString & ) > & callback ); void setHtml(const QString& content, const QUrl& baseUrl); void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl()); @@ -302,7 +303,7 @@ public slots: //aim to receive signal from html. the fragment url click to navigation through page wil not be intecepted by weburlinteceptor Q_INVOKABLE void linkClickedInHtml( QUrl const & ); private slots: - + void inspectElement(); void loadFinished( bool ok ); void loadProgress(int); void handleTitleChanged( QString const & title ); @@ -364,7 +365,7 @@ private: /// Checks if the given article in form of "gdfrom-xxx" is inside a "website" /// frame. - bool isFramedArticle( QString const & ); + void isFramedArticle( QString const & article, const std::function< void( bool framed ) > & callback ); /// Checks if the given link is to be opened externally, as opposed to opening /// it in-place. @@ -405,18 +406,6 @@ private: // We need this to hide the search bar when we're showed void showEvent( QShowEvent * ); -#ifdef Q_OS_WIN32 - - /// Search inside web page for word under cursor - -private: - QString insertSpans( QString const & html ); - void readTag( QString const & from, QString & to, int & count ); - QString checkElement( QWebEnginePage & elem, const QPoint & pt ); -public: - QString wordAtPoint( int x, int y ); -#endif - }; class ResourceToSaveHandler: public QObject diff --git a/articlewebview.cc b/articlewebview.cc index 126f2890..ad697013 100644 --- a/articlewebview.cc +++ b/articlewebview.cc @@ -6,6 +6,8 @@ #include #include #include +#include +#include #ifdef Q_OS_WIN32 #include @@ -14,8 +16,7 @@ ArticleWebView::ArticleWebView( QWidget *parent ): QWebEngineView( parent ), midButtonPressed( false ), - selectionBySingleClick( false ), - showInspectorDirectly( true ) + selectionBySingleClick( false ) { } @@ -26,6 +27,7 @@ ArticleWebView::~ArticleWebView() void ArticleWebView::setUp( Config::Class * cfg ) { this->cfg = cfg; + setZoomFactor(cfg->preferences.zoomFactor); } void ArticleWebView::triggerPageAction( QWebEnginePage::WebAction action, bool checked ) @@ -33,19 +35,30 @@ void ArticleWebView::triggerPageAction( QWebEnginePage::WebAction action, bool c QWebEngineView::triggerPageAction( action, checked ); } +QWebEngineView * ArticleWebView::createWindow( QWebEnginePage::WebWindowType type ) +{ + if(type==QWebEnginePage::WebWindowType::WebDialog) + { + QMainWindow * dlg = new QMainWindow( this ); + QWebEngineView * view = new QWebEngineView( dlg ); + dlg->setCentralWidget(view); + dlg->resize(400,400); + dlg->show(); + + return view; + } + return QWebEngineView::createWindow(type); +} + bool ArticleWebView::event( QEvent * event ) { - if (event->type() == QEvent::ChildAdded) { - QChildEvent *child_ev = static_cast(event); + if( event->type() == QEvent::ChildAdded ) + { + QChildEvent * child_ev = static_cast< QChildEvent * >( event ); + child_ev->child()->installEventFilter( this ); + } -// // there is also QObject child that should be ignored here; -// // use only QOpenGLWidget child -// QOpenGLWidget *w = static_cast(child_ev->child()); - - child_ev->child()->installEventFilter(this); - } - - return QWebEngineView::event(event); + return QWebEngineView::event( event ); } void ArticleWebView::linkClickedInHtml(QUrl const& ){ @@ -87,10 +100,17 @@ bool ArticleWebView::eventFilter(QObject *obj, QEvent *ev) { if (ev->type() == QEvent::Wheel) { QWheelEvent *pe = static_cast(ev); wheelEvent(pe); + + if ( pe->modifiers().testFlag( Qt::ControlModifier ) ) + { + return true; + } } - if (ev->type() == QEvent::FocusIn) { - QFocusEvent *pe = static_cast(ev); - focusInEvent(pe); + if( ev->type() == QEvent::FocusIn ) + { + QFocusEvent * pe = static_cast< QFocusEvent * >( ev ); + focusInEvent( pe ); + return true; } return QWebEngineView::eventFilter(obj, ev); @@ -98,7 +118,7 @@ bool ArticleWebView::eventFilter(QObject *obj, QEvent *ev) { void ArticleWebView::mousePressEvent(QMouseEvent *event) { - if (event->buttons() & Qt::MidButton) + if (event->buttons() & Qt::MiddleButton) midButtonPressed = true; } @@ -127,10 +147,10 @@ void ArticleWebView::sendCustomMouseEvent( QEvent::Type type) { } void ArticleWebView::mouseReleaseEvent(QMouseEvent *event) { - bool noMidButton = !( event->buttons() & Qt::MidButton ); + bool noMidButton = !( event->buttons() & Qt::MiddleButton ); - if ( midButtonPressed & noMidButton ) - midButtonPressed = false; +// if ( midButtonPressed & noMidButton ) +// midButtonPressed = false; } void ArticleWebView::doubleClickAction(QMouseEvent *event) { @@ -169,7 +189,7 @@ void ArticleWebView::wheelEvent( QWheelEvent *ev ) SystemParametersInfo( SPI_GETWHEELSCROLLLINES, 0, &nLines, 0 ); if( nLines == WHEEL_PAGESCROLL ) { - QKeyEvent kev( QEvent::KeyPress, ev->delta() > 0 ? Qt::Key_PageUp : Qt::Key_PageDown, + QKeyEvent kev( QEvent::KeyPress, ev->angleDelta ().y () > 0 ? Qt::Key_PageUp : Qt::Key_PageDown, Qt::NoModifier ); auto childrens = this->children(); for (auto child : childrens) { diff --git a/articlewebview.hh b/articlewebview.hh index 18ddd8f7..ac954bfc 100644 --- a/articlewebview.hh +++ b/articlewebview.hh @@ -8,7 +8,6 @@ #include #include #include -#include #include /// A thin wrapper around QWebEngineView to accommodate to some ArticleView's needs. @@ -17,8 +16,6 @@ /// to the view's current state. This is used to open links in new tabs when /// they are clicked with middle button. There's also an added possibility to /// get double-click events after the fact with the doubleClicked() signal. -/// 2. Manage our own QWebInspector instance. In order to show inspector correctly, -/// use triggerPageAction( QWebEnginePage::InspectElement ) instead. class ArticleWebView: public QWebEngineView { Q_OBJECT @@ -27,11 +24,14 @@ public: ArticleWebView( QWidget * parent ); ~ArticleWebView(); - void setUp( Config::Class * cfg ); bool isMidButtonPressed() const { return midButtonPressed; } + void resetMidButtonPressed() + { + midButtonPressed = false; + } void setSelectionBySingleClick( bool set ) { selectionBySingleClick = set; } @@ -48,7 +48,7 @@ public: void doubleClicked( QPoint pos ); protected: - + QWebEngineView *createWindow(QWebEnginePage::WebWindowType type); bool event( QEvent * event ); void singleClickAction(QMouseEvent *event); void sendCustomMouseEvent(QEvent::Type type); @@ -66,7 +66,6 @@ private: bool midButtonPressed; bool selectionBySingleClick; - bool showInspectorDirectly; //MouseDbClickEvent will also emit MousePressEvent which conflict the single click event. //this variable used to distinguish the single click and real double click. diff --git a/autotests/goldendict-test.pro b/autotests/goldendict-test.pro new file mode 100644 index 00000000..82570c14 --- /dev/null +++ b/autotests/goldendict-test.pro @@ -0,0 +1,23 @@ +QT -= gui + +CONFIG += c++11 console +CONFIG -= app_bundle +CONFIG += qtestlib + +# You can make your code fail to compile if it uses deprecated APIs. +# In order to do so, uncomment the following line. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +HEADERS+= \ + ../iconv.hh \ + ../wstring.hh \ + ../wstring_qt.hh +SOURCES += \ + test-qtextcodec-convert.cpp \ + ../iconv.cc \ + ../wstring_qt.cc + +# Default rules for deployment. +qnx: target.path = /tmp/$${TARGET}/bin +else: unix:!android: target.path = /opt/$${TARGET}/bin +!isEmpty(target.path): INSTALLS += target diff --git a/autotests/test-qtextcodec-convert.cpp b/autotests/test-qtextcodec-convert.cpp new file mode 100644 index 00000000..62788354 --- /dev/null +++ b/autotests/test-qtextcodec-convert.cpp @@ -0,0 +1,49 @@ +#include +#include +#include "../iconv.hh" +#include +#include "../wstring_qt.hh" + +//used to test Iconv.cc +class testQTextCodec : public QObject +{ + Q_OBJECT +private slots: + void testConvert(); + void testToWstring(); + void testToUtf8(); +}; + +void testQTextCodec::testConvert() +{ + Iconv conv( "utf-8", Iconv::GdWchar ); + const char s[] = { 0x61, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00 }; + void const * in = &s[ 0 ]; + size_t len = 12; + QString r = conv.convert( in, len ); + QCOMPARE( r, "abc" ); +} + +void testQTextCodec::testToWstring() +{ + const char s[] = { 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x63 }; + gd::wstring r1 = Iconv::toWstring( "UTF-32BE", s, 12 ); + + QCOMPARE( r1.size(), 3 ); + QCOMPARE( r1, U"abc" ); + char32_t * arr = (char32_t*)r1.c_str (); + QCOMPARE( arr[ 0 ], 0x00000061 ); +} + +void testQTextCodec::testToUtf8() +{ + const char s[] = { 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x63 }; + std::string r1 = Iconv::toUtf8 ( "UTF-32BE", s, 12 ); + + QCOMPARE( r1.size(), 3 ); + QCOMPARE( r1, u8"abc" ); + char * arr = (char*)r1.c_str (); + QCOMPARE( arr[ 0 ], 0x61 ); +} +QTEST_MAIN(testQTextCodec) +#include "test-qtextcodec-convert.moc" diff --git a/belarusiantranslit.cc b/belarusiantranslit.cc index 7811ed89..80fa06ad 100644 --- a/belarusiantranslit.cc +++ b/belarusiantranslit.cc @@ -406,7 +406,7 @@ public: } }; -std::vector< sptr< Dictionary::Class > > makeDictionaries() THROW_SPEC( std::exception ) +std::vector< sptr< Dictionary::Class > > makeDictionaries() { static BelarusianLatinToClassicTable t0; static BelarusianLatinToSchoolTable t1; diff --git a/belarusiantranslit.hh b/belarusiantranslit.hh index 5c622071..c09de673 100644 --- a/belarusiantranslit.hh +++ b/belarusiantranslit.hh @@ -10,7 +10,7 @@ // Support for Belarusian transliteration namespace BelarusianTranslit { -std::vector< sptr< Dictionary::Class > > makeDictionaries() THROW_SPEC( std::exception ); +std::vector< sptr< Dictionary::Class > > makeDictionaries() ; } diff --git a/bgl.cc b/bgl.cc index c62596c7..ec11ba0b 100644 --- a/bgl.cc +++ b/bgl.cc @@ -31,7 +31,11 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include @@ -174,20 +178,7 @@ namespace } // Convert the word from utf8 to wide chars - - if ( wcharBuffer.size() <= word.size() ) - wcharBuffer.resize( word.size() + 1 ); - - long result = Utf8::decode( word.c_str(), word.size(), - &wcharBuffer.front() ); - - if ( result < 0 ) - { - gdWarning( "Failed to decode utf8 of headword \"%s\", skipping it.", word.c_str() ); - return; - } - - indexedWords.addWord( wstring( &wcharBuffer.front(), result ), articleOffset ); + indexedWords.addWord( Utf8::decode( word ), articleOffset ); } @@ -226,16 +217,16 @@ namespace { return idxHeader.langTo; } virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString, int searchMode, bool matchCase, @@ -609,7 +600,7 @@ void BglHeadwordsRequest::run() sptr< Dictionary::WordSearchRequest > BglDictionary::findHeadwordsForSynonym( wstring const & word ) - THROW_SPEC( std::exception ) + { return synonymSearchEnabled ? new BglHeadwordsRequest( word, *this ) : Class::findHeadwordsForSynonym( word ); @@ -933,7 +924,7 @@ sptr< Dictionary::DataRequest > BglDictionary::getArticle( wstring const & word, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new BglArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -1077,7 +1068,7 @@ void BglResourceRequest::run() } sptr< Dictionary::DataRequest > BglDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { return new BglResourceRequest( idxMutex, idx, idxHeader.resourceListOffset, idxHeader.resourcesCount, name ); @@ -1100,7 +1091,7 @@ sptr< Dictionary::DataRequest > BglDictionary::getResource( string const & name while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - result += str.midRef( pos, match.capturedStart() - pos ); + result += str.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QRegularExpressionMatchIterator itValue = oneValueExp.globalMatch( match.captured( 1 ) ); @@ -1113,7 +1104,7 @@ sptr< Dictionary::DataRequest > BglDictionary::getResource( string const & name if( pos ) { - result += str.midRef( pos ); + result += str.mid( pos ); str = result; } @@ -1178,7 +1169,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/bgl.hh b/bgl.hh index 05ea64d9..0fb3e659 100644 --- a/bgl.hh +++ b/bgl.hh @@ -23,7 +23,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; } diff --git a/bgl_babylon.cc b/bgl_babylon.cc index 198778d2..16bdf561 100644 --- a/bgl_babylon.cc +++ b/bgl_babylon.cc @@ -27,7 +27,6 @@ #include #include #include -#include #include #include "gddebug.hh" #include "ufile.hh" @@ -36,6 +35,7 @@ #include #include #include "dictionary.hh" +#include "wstring_qt.hh" #ifdef _WIN32 #include @@ -198,6 +198,7 @@ bool Babylon::read(std::string &source_charset, std::string &target_charset) { headword.clear(); definition.clear(); + switch( block.type ) { case 0: @@ -534,7 +535,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler ) { try { - transcription = Iconv::toUtf8( "CP1252", block.data + pos + 3, length ); + transcription = Iconv::toUtf8( "Windows-1252", block.data + pos + 3, length ); } catch( Iconv::Ex & e ) { @@ -565,7 +566,7 @@ bgl_entry Babylon::readEntry( ResourceHandler * resourceHandler ) { try { - transcription = Iconv::toUtf8( "CP1252", block.data + pos + 4, length ); + transcription = Iconv::toUtf8( "Windows-1252", block.data + pos + 4, length ); } catch( Iconv::Ex & e ) { @@ -759,42 +760,14 @@ void Babylon::convertToUtf8( std::string &s, unsigned int type ) if( charset == "UTF-8" ) return; - iconv_t cd = iconv_open( "UTF-8", charset.c_str() ); - if( cd == (iconv_t)(-1) ) - throw exIconv(); + Iconv conv_("UTF-8", charset.c_str()); - char *outbuf, *defbuf; - size_t inbufbytes, outbufbytes; - - inbufbytes = s.size(); - outbufbytes = s.size() * 6; + size_t inbufbytes = s.size(); char *inbuf; inbuf = (char *)s.data(); - outbuf = (char*)malloc( outbufbytes + 1 ); - if( !outbuf ) - { - iconv_close( cd ); - throw exAllocation(); - } + const void* test = inbuf; - memset( outbuf, '\0', outbufbytes + 1 ); - defbuf = outbuf; - while (inbufbytes) { - if (iconv(cd, &inbuf, &inbufbytes, &outbuf, &outbufbytes) == (size_t)-1) { - gdWarning( "\"%s\" - error in iconv conversion (%s)\n", inbuf, strerror( errno ) ); - break; -// inbuf++; -// inbufbytes--; - } - } - - // Flush the state. This fixes CP1255 problems. - iconv( cd, 0, 0, &outbuf, &outbufbytes ); - - if( inbufbytes == 0 ) - s = std::string( defbuf ); - - free( defbuf ); - iconv_close( cd ); + QString convStr = conv_.convert(test,inbufbytes); + s = gd::toStdString(convStr); } diff --git a/bgl_babylon.hh b/bgl_babylon.hh index 2947c338..e1694be6 100644 --- a/bgl_babylon.hh +++ b/bgl_babylon.hh @@ -27,11 +27,7 @@ #include #include #include -#if defined( _MSC_VER ) && _MSC_VER < 1800 // VS2012 and older -#include -#else #include -#endif //const std::string bgl_language[] = { #ifndef blgCode2Int diff --git a/broken_xrecord.cc b/broken_xrecord.cc index d3f1b00a..bf95eca4 100644 --- a/broken_xrecord.cc +++ b/broken_xrecord.cc @@ -8,8 +8,12 @@ #ifdef HAVE_X11 #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include #endif +#endif bool isRECORDBroken() { diff --git a/btreeidx.cc b/btreeidx.cc index ab6dfc93..645ae4e1 100644 --- a/btreeidx.cc +++ b/btreeidx.cc @@ -462,7 +462,7 @@ BtreeWordSearchRequest::~BtreeWordSearchRequest() sptr< Dictionary::WordSearchRequest > BtreeDictionary::prefixMatch( wstring const & str, unsigned long maxResults ) - THROW_SPEC( std::exception ) + { return new BtreeWordSearchRequest( *this, str, 0, -1, true, maxResults ); } @@ -470,7 +470,7 @@ sptr< Dictionary::WordSearchRequest > BtreeDictionary::prefixMatch( sptr< Dictionary::WordSearchRequest > BtreeDictionary::stemmedMatch( wstring const & str, unsigned minLength, unsigned maxSuffixVariation, unsigned long maxResults ) - THROW_SPEC( std::exception ) + { return new BtreeWordSearchRequest( *this, str, minLength, (int)maxSuffixVariation, false, maxResults ); @@ -526,8 +526,8 @@ char const * BtreeIndex::findChainOffsetExactOrPrefix( wstring const & target, // Lookup the index by traversing the index btree - vector< wchar > wcharBuffer; - + // vector< wchar > wcharBuffer; + wstring w_word; exactMatch = false; // Read a node @@ -615,20 +615,10 @@ char const * BtreeIndex::findChainOffsetExactOrPrefix( wstring const & target, --closestString; size_t wordSize = strlen( closestString ); - - if ( wcharBuffer.size() <= wordSize ) - wcharBuffer.resize( wordSize + 1 ); - - long result = Utf8::decode( closestString, wordSize, &wcharBuffer.front() ); - if ( result < 0 ) - throw Utf8::exCantDecode( closestString ); - - wcharBuffer[ result ] = 0; + w_word = Utf8::decode( string( closestString, wordSize ) ); - //GD_DPRINTF( "Checking against %s\n", closestString ); - - compareResult = target.compare( &wcharBuffer.front() ); + compareResult = target.compare( w_word); if ( !compareResult ) { @@ -749,22 +739,12 @@ char const * BtreeIndex::findChainOffsetExactOrPrefix( wstring const & target, ptr += sizeof( uint32_t ); size_t wordSize = strlen( ptr ); + + w_word = Utf8::decode( string( ptr, wordSize ) ); - if ( wcharBuffer.size() <= wordSize ) - wcharBuffer.resize( wordSize + 1 ); - - //GD_DPRINTF( "checking against word %s, left = %u\n", ptr, leafEntries ); - - long result = Utf8::decode( ptr, wordSize, &wcharBuffer.front() ); - - if ( result < 0 ) - throw Utf8::exCantDecode( ptr ); - - wcharBuffer[ result ] = 0; - - wstring foldedWord = Folding::apply( &wcharBuffer.front() ); + wstring foldedWord = Folding::apply( w_word ); if( foldedWord.empty() ) - foldedWord = Folding::applyWhitespaceOnly( &wcharBuffer.front() ); + foldedWord = Folding::applyWhitespaceOnly( w_word ); int compareResult = target.compare( foldedWord ); @@ -1071,22 +1051,10 @@ void IndexedWords::addWord( wstring const & word, uint32_t articleOffset, unsign // Safeguard us against various bugs here. Don't attempt adding words // which are freakishly huge. - if ( wordSize > maxHeadwordSize ) + if( wordSize > maxHeadwordSize ) { -#define MAX_LOG_WORD_SIZE 500 - string headword; - if( wordSize <= MAX_LOG_WORD_SIZE ) - headword = Utf8::encode( word ); - else - { - std::vector< char > buffer( MAX_LOG_WORD_SIZE * 4 ); - headword = string( &buffer.front(), - Utf8::encode( wordBegin, MAX_LOG_WORD_SIZE, &buffer.front() ) ); - headword += "..."; - } - gdWarning( "Skipped too long headword: \"%s\"", headword.c_str() ); + qWarning() << "Skipped too long headword: " << word.substr( 0, 100 ).c_str() << "size:" << wordSize; return; -#undef MAX_LOG_WORD_SIZE } // Skip any leading whitespace @@ -1118,17 +1086,11 @@ void IndexedWords::addWord( wstring const & word, uint32_t articleOffset, unsign wstring folded = Folding::applyWhitespaceOnly( wstring( wordBegin, wordSize ) ); if( !folded.empty() ) { - iterator i = insert( - IndexedWords::value_type( - string( &utfBuffer.front(), - Utf8::encode( folded.data(), folded.size(), &utfBuffer.front() ) ), - vector< WordArticleLink >() ) ).first; + iterator i = insert( { Utf8::encode( folded ), + vector< WordArticleLink >() } ) + .first; - // Try to conserve memory somewhat -- slow insertions are ok - i->second.reserve( i->second.size() + 1 ); - - string utfWord( &utfBuffer.front(), - Utf8::encode( wordBegin, wordSize, &utfBuffer.front() ) ); + string utfWord=Utf8::encode( wstring(wordBegin, wordSize )) ; string utfPrefix; i->second.push_back( WordArticleLink( utfWord, articleOffset, utfPrefix ) ); } @@ -1142,24 +1104,15 @@ void IndexedWords::addWord( wstring const & word, uint32_t articleOffset, unsign // Insert this word wstring folded = Folding::apply( nextChar ); - - iterator i = insert( - IndexedWords::value_type( - string( &utfBuffer.front(), - Utf8::encode( folded.data(), folded.size(), &utfBuffer.front() ) ), - vector< WordArticleLink >() ) ).first; - if ( ( i->second.size() < 1024 ) || ( nextChar == wordBegin ) ) // Don't overpopulate chains with middle matches + iterator i = insert( { Utf8::encode( folded ), vector< WordArticleLink >() } ).first; + + if( ( i->second.size() < 1024 ) || ( nextChar == wordBegin ) ) // Don't overpopulate chains with middle matches { - // Try to conserve memory somewhat -- slow insertions are ok - i->second.reserve( i->second.size() + 1 ); - - string utfWord( &utfBuffer.front(), - Utf8::encode( nextChar, wordSize - ( nextChar - wordBegin ), &utfBuffer.front() ) ); - - string utfPrefix( &utfBuffer.front(), - Utf8::encode( wordBegin, nextChar - wordBegin, &utfBuffer.front() ) ); - + string utfWord = Utf8::encode( wstring( nextChar, wordSize - ( nextChar - wordBegin ) ) ); + + string utfPrefix = Utf8::encode( wstring( wordBegin, nextChar - wordBegin ) ); + i->second.push_back( WordArticleLink( utfWord, articleOffset, utfPrefix ) ); } @@ -1437,16 +1390,17 @@ void BtreeIndex::getHeadwordsFromOffsets( QList & offsets, for( unsigned i = 0; i < result.size(); i++ ) { - QList< uint32_t >::Iterator it = qBinaryFind( begOffsets, endOffsets, - result.at( i ).articleOffset ); + uint32_t articleOffset = result.at(i).articleOffset; + QList::Iterator it = std::lower_bound( begOffsets, endOffsets, + articleOffset ); - if( it != offsets.end() ) + if( it!=offsets.end()) { if( isCancelled && Utils::AtomicInt::loadAcquire( *isCancelled ) ) return; headwords.append( QString::fromUtf8( ( result[ i ].prefix + result[ i ].word ).c_str() ) ); - offsets.erase( it ); + offsets.erase( it); begOffsets = offsets.begin(); endOffsets = offsets.end(); } diff --git a/btreeidx.hh b/btreeidx.hh index 8be0bc3c..deb3a6b6 100644 --- a/btreeidx.hh +++ b/btreeidx.hh @@ -14,13 +14,8 @@ #include #include #include -#include "cpp_features.hh" -#if defined( _MSC_VER ) && _MSC_VER < 1800 // VS2012 and older -#include -#else #include -#endif /// A base for the dictionary which creates a btree index to look up /// the words. @@ -167,13 +162,13 @@ public: /// need not to implement this function. virtual sptr< Dictionary::WordSearchRequest > prefixMatch( wstring const &, unsigned long ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::WordSearchRequest > stemmedMatch( wstring const &, unsigned minLength, unsigned maxSuffixVariation, unsigned long maxResults ) - THROW_SPEC( std::exception ); + ; virtual bool isLocalDictionary() { return true; } diff --git a/chinese.cc b/chinese.cc index c7242008..400a0115 100644 --- a/chinese.cc +++ b/chinese.cc @@ -4,11 +4,11 @@ #include "chinese.hh" #include #include -#ifdef Q_OS_MAC +// #ifdef Q_OS_MAC #include -#endif +// #endif #include -#include +// #include #include "folding.hh" #include "gddebug.hh" #include "transliteration.hh" @@ -18,11 +18,11 @@ namespace Chinese { class CharacterConversionDictionary: public Transliteration::BaseTransliterationDictionary { -#ifdef Q_OS_MAC +// #ifdef Q_OS_MAC opencc_t converter; -#else - opencc::SimpleConverter* converter; -#endif +// #else +// opencc::SimpleConverter* converter; +// #endif public: @@ -42,16 +42,16 @@ CharacterConversionDictionary::CharacterConversionDictionary( std::string const converter( NULL ) { try { -#ifdef Q_OS_MAC +// #ifdef Q_OS_MAC converter = opencc_open( openccConfig.toLocal8Bit().constData() ); if( converter == reinterpret_cast< opencc_t >( -1 ) ) { gdWarning( "CharacterConversionDictionary: failed to initialize OpenCC from config %s: %s\n", openccConfig.toLocal8Bit().constData(), opencc_error() ); } -#else - converter = new opencc::SimpleConverter( openccConfig.toLocal8Bit().constData() ); -#endif +// #else +// converter = new opencc::SimpleConverter( openccConfig.toLocal8Bit().constData() ); +// #endif } catch ( std::runtime_error& e ) { gdWarning( "CharacterConversionDictionary: failed to initialize OpenCC from config %s: %s\n", openccConfig.toLocal8Bit().constData(), e.what() ); @@ -60,13 +60,13 @@ CharacterConversionDictionary::CharacterConversionDictionary( std::string const CharacterConversionDictionary::~CharacterConversionDictionary() { -#ifdef Q_OS_MAC +// #ifdef Q_OS_MAC if ( converter != NULL && converter != reinterpret_cast< opencc_t >( -1 ) ) opencc_close( converter ); -#else - if ( converter != NULL ) - delete converter; -#endif +// #else +// if ( converter != NULL ) +// delete converter; +// #endif } std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings( gd::wstring const & str ) @@ -81,7 +81,7 @@ std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings( gd::wstring result; try { -#ifdef Q_OS_MAC +// #ifdef Q_OS_MAC if ( converter != NULL && converter != reinterpret_cast< opencc_t >( -1 ) ) { char * tmp = opencc_convert_utf8( converter, input.c_str(), input.length() ); @@ -93,9 +93,9 @@ std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings( else gdWarning( "OpenCC: conversion failed %s\n", opencc_error() ); } -#else - output = converter->Convert( input ); -#endif +// #else +// output = converter->Convert( input ); +// #endif result = Utf8::decode( output ); } catch ( std::exception& ex ) { gdWarning( "OpenCC: conversion failed %s\n", ex.what() ); @@ -109,7 +109,7 @@ std::vector< gd::wstring > CharacterConversionDictionary::getAlternateWritings( } std::vector< sptr< Dictionary::Class > > makeDictionaries( Config::Chinese const & cfg ) - THROW_SPEC( std::exception ) + { std::vector< sptr< Dictionary::Class > > result; diff --git a/chinese.hh b/chinese.hh index 162e0571..e42d27c5 100644 --- a/chinese.hh +++ b/chinese.hh @@ -12,7 +12,7 @@ namespace Chinese { std::vector< sptr< Dictionary::Class > > makeDictionaries( Config::Chinese const & ) - THROW_SPEC( std::exception ); + ; } diff --git a/chunkedstorage.hh b/chunkedstorage.hh index 0ef2a017..b92c6aed 100644 --- a/chunkedstorage.hh +++ b/chunkedstorage.hh @@ -8,11 +8,7 @@ #include "file.hh" #include -#if defined( _MSC_VER ) && _MSC_VER < 1800 // VS2012 and older -#include -#else #include -#endif /// A chunked compression storage. We use this for articles' bodies. The idea /// is to store data in a separately-compressed chunks, much like in dictzip, diff --git a/config.cc b/config.cc index 15c7b4f6..113a3304 100644 --- a/config.cc +++ b/config.cc @@ -9,11 +9,7 @@ #include #include "gddebug.hh" -#if defined( _MSC_VER ) && _MSC_VER < 1800 // VS2012 and older -#include -#else #include -#endif #ifdef Q_OS_WIN32 #include "shlobj.h" @@ -217,6 +213,7 @@ Preferences::Preferences(): autoStart( false ), doubleClickTranslates( true ), selectWordBySingleClick( false ), + autoScrollToTargetArticle( true ), escKeyHidesMainWindow( false ), alwaysOnTop ( false ), searchInDock ( false ), @@ -446,7 +443,7 @@ void saveMutedDictionaries( QDomDocument & dd, QDomElement & muted, } -Class load() THROW_SPEC( exError ) +Class load() { QString configName = getConfigFileName(); @@ -862,6 +859,9 @@ Class load() THROW_SPEC( exError ) if ( !preferences.namedItem( "selectWordBySingleClick" ).isNull() ) c.preferences.selectWordBySingleClick = ( preferences.namedItem( "selectWordBySingleClick" ).toElement().text() == "1" ); + if ( !preferences.namedItem( "autoScrollToTargetArticle" ).isNull() ) + c.preferences.autoScrollToTargetArticle = ( preferences.namedItem( "autoScrollToTargetArticle" ).toElement().text() == "1" ); + if ( !preferences.namedItem( "escKeyHidesMainWindow" ).isNull() ) c.preferences.escKeyHidesMainWindow = ( preferences.namedItem( "escKeyHidesMainWindow" ).toElement().text() == "1" ); @@ -1278,7 +1278,7 @@ void saveGroup( Group const & data, QDomElement & group ) } -void save( Class const & c ) THROW_SPEC( exError ) +void save( Class const & c ) { QFile configFile( getConfigFileName() + ".tmp" ); @@ -1725,6 +1725,10 @@ void save( Class const & c ) THROW_SPEC( exError ) opt.appendChild( dd.createTextNode( c.preferences.selectWordBySingleClick ? "1":"0" ) ); preferences.appendChild( opt ); + opt = dd.createElement( "autoScrollToTargetArticle" ); + opt.appendChild( dd.createTextNode( c.preferences.autoScrollToTargetArticle ? "1":"0" ) ); + preferences.appendChild( opt ); + opt = dd.createElement( "escKeyHidesMainWindow" ); opt.appendChild( dd.createTextNode( c.preferences.escKeyHidesMainWindow ? "1":"0" ) ); preferences.appendChild( opt ); @@ -2202,12 +2206,12 @@ QString getConfigFileName() return getHomeDir().absoluteFilePath( "config" ); } -QString getConfigDir() THROW_SPEC( exError ) +QString getConfigDir() { return getHomeDir().path() + QDir::separator(); } -QString getIndexDir() THROW_SPEC( exError ) +QString getIndexDir() { QDir result = getHomeDir(); @@ -2228,12 +2232,12 @@ QString getIndexDir() THROW_SPEC( exError ) return result.path() + QDir::separator(); } -QString getPidFileName() THROW_SPEC( exError ) +QString getPidFileName() { return getHomeDir().filePath( "pid" ); } -QString getHistoryFileName() THROW_SPEC( exError ) +QString getHistoryFileName() { QString homeHistoryPath = getHomeDir().filePath( "history" ); @@ -2249,22 +2253,22 @@ QString getHistoryFileName() THROW_SPEC( exError ) return homeHistoryPath; } -QString getFavoritiesFileName() THROW_SPEC( exError ) +QString getFavoritiesFileName() { return getHomeDir().filePath( "favorites" ); } -QString getUserCssFileName() THROW_SPEC( exError ) +QString getUserCssFileName() { return getHomeDir().filePath( "article-style.css" ); } -QString getUserCssPrintFileName() THROW_SPEC( exError ) +QString getUserCssPrintFileName() { return getHomeDir().filePath( "article-style-print.css" ); } -QString getUserQtCssFileName() THROW_SPEC( exError ) +QString getUserQtCssFileName() { return getHomeDir().filePath( "qt-style.css" ); } @@ -2281,12 +2285,17 @@ QString getProgramDataDir() throw() #endif } +QString getEmbedLocDir() throw() +{ + return ":/locale"; +} + QString getLocDir() throw() { - if ( QDir( getProgramDataDir() ).cd( "locale" ) ) - return getProgramDataDir() + "/locale"; - else - return QCoreApplication::applicationDirPath() + "/locale"; + if ( QDir( getProgramDataDir() ).cd( "locale" ) ) + return getProgramDataDir() + "/locale"; + else + return QCoreApplication::applicationDirPath() + "/locale"; } QString getHelpDir() throw() @@ -2348,7 +2357,7 @@ QString getPortableVersionMorphoDir() throw() return QString(); } -QString getStylesDir() throw() +QString getStylesDir() { QDir result = getHomeDir(); diff --git a/config.hh b/config.hh index bb7b247c..117478f9 100644 --- a/config.hh +++ b/config.hh @@ -12,7 +12,6 @@ #include #include #include -#include "cpp_features.hh" #include "ex.hh" #ifdef Q_OS_WIN @@ -293,6 +292,7 @@ struct Preferences bool autoStart; bool doubleClickTranslates; bool selectWordBySingleClick; + bool autoScrollToTargetArticle; bool escKeyHidesMainWindow; bool alwaysOnTop; @@ -763,44 +763,45 @@ DEF_EX( exCantWriteConfigFile, "Can't write the configuration file", exError ) DEF_EX( exMalformedConfigFile, "The configuration file is malformed", exError ) /// Loads the configuration, or creates the default one if none is present -Class load() THROW_SPEC( exError ); +Class load() ; /// Saves the configuration -void save( Class const & ) THROW_SPEC( exError ); +void save( Class const & ) ; /// Returns the configuration file name. QString getConfigFileName(); /// Returns the main configuration directory. -QString getConfigDir() THROW_SPEC( exError ); +QString getConfigDir() ; /// Returns the index directory, where the indices are to be stored. -QString getIndexDir() THROW_SPEC( exError ); +QString getIndexDir() ; /// Returns the filename of a .pid file which should store current pid of /// the process. -QString getPidFileName() THROW_SPEC( exError ); +QString getPidFileName() ; /// Returns the filename of a history file which stores search history. -QString getHistoryFileName() THROW_SPEC( exError ); +QString getHistoryFileName() ; /// Returns the filename of a favorities file. -QString getFavoritiesFileName() THROW_SPEC( exError ); +QString getFavoritiesFileName() ; /// Returns the user .css file name. -QString getUserCssFileName() THROW_SPEC( exError ); +QString getUserCssFileName() ; /// Returns the user .css file name used for printing only. -QString getUserCssPrintFileName() THROW_SPEC( exError ); +QString getUserCssPrintFileName() ; /// Returns the user .css file name for the Qt interface customization. -QString getUserQtCssFileName() THROW_SPEC( exError ); +QString getUserQtCssFileName() ; /// Returns the program's data dir. Under Linux that would be something like /// /usr/share/apps/goldendict, under Windows C:/Program Files/GoldenDict. QString getProgramDataDir() throw(); /// Returns the directory storing program localizized files (.qm). +QString getEmbedLocDir() throw(); QString getLocDir() throw(); /// Returns the directory storing program help files (.qch). @@ -824,7 +825,7 @@ QString getPortableVersionDictionaryDir() throw(); QString getPortableVersionMorphoDir() throw(); /// Returns the add-on styles directory. -QString getStylesDir() throw(); +QString getStylesDir(); /// Returns the directory where user-specific non-essential (cached) data should be written. QString getCacheDir() throw(); diff --git a/cpp_features.hh b/cpp_features.hh deleted file mode 100644 index e15544b3..00000000 --- a/cpp_features.hh +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef __CPP_HH_INCLUDED__ -#define __CPP_HH_INCLUDED__ - -#if __cplusplus > 199711L -#define THROW_SPEC(...) -#else -#define THROW_SPEC(...) throw(__VA_ARGS__) -#endif - -#endif // CPP_HH diff --git a/delegate.cc b/delegate.cc index ffeeb102..d1b5cd8d 100644 --- a/delegate.cc +++ b/delegate.cc @@ -1,4 +1,4 @@ -#include +#include #include "delegate.hh" diff --git a/dictdfiles.cc b/dictdfiles.cc index c33797b7..f8607269 100644 --- a/dictdfiles.cc +++ b/dictdfiles.cc @@ -124,7 +124,7 @@ public: vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual QString const& getDescription(); @@ -258,7 +258,7 @@ sptr< Dictionary::DataRequest > DictdDictionary::getArticle( wstring const & wor vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { try { @@ -371,7 +371,7 @@ sptr< Dictionary::DataRequest > DictdDictionary::getArticle( wstring const & wor while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewString += articleString.midRef( pos, match.capturedStart() - pos ); + articleNewString += articleString.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString link = match.captured( 1 ); @@ -385,7 +385,7 @@ sptr< Dictionary::DataRequest > DictdDictionary::getArticle( wstring const & wor } if( pos ) { - articleNewString += articleString.midRef( pos ); + articleNewString += articleString.mid( pos ); articleString = articleNewString; articleNewString.clear(); } @@ -450,8 +450,8 @@ QString const& DictdDictionary::getDescription() if( !dictionaryDescription.isEmpty() ) return dictionaryDescription; - sptr< Dictionary::DataRequest > req = getArticle( GD_NATIVE_TO_WS( L"00databaseinfo" ), - vector< wstring >(), wstring(), false ); + sptr< Dictionary::DataRequest > req = + getArticle( U"00databaseinfo" , vector< wstring >(), wstring(), false ); if( req->dataSize() > 0 ) dictionaryDescription = Html::unescape( QString::fromUtf8( req->getFullData().data(), req->getFullData().size() ), true ); @@ -583,7 +583,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/dictdfiles.hh b/dictdfiles.hh index a71a1e6c..d4c6584d 100644 --- a/dictdfiles.hh +++ b/dictdfiles.hh @@ -16,7 +16,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; } diff --git a/dictheadwords.cc b/dictheadwords.cc index 201290b3..3e370e3d 100644 --- a/dictheadwords.cc +++ b/dictheadwords.cc @@ -6,6 +6,9 @@ #include "mainwindow.hh" #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif #include #include #include diff --git a/dictionary.cc b/dictionary.cc index 4a185564..5a20875f 100644 --- a/dictionary.cc +++ b/dictionary.cc @@ -73,7 +73,7 @@ size_t WordSearchRequest::matchesCount() return matches.size(); } -WordMatch WordSearchRequest::operator [] ( size_t index ) THROW_SPEC( exIndexOutOfRange ) +WordMatch WordSearchRequest::operator [] ( size_t index ) { Mutex::Lock _( dataMutex ); @@ -83,7 +83,7 @@ WordMatch WordSearchRequest::operator [] ( size_t index ) THROW_SPEC( exIndexOut return matches[ index ]; } -vector< WordMatch > & WordSearchRequest::getAllMatches() THROW_SPEC( exRequestUnfinished ) +vector< WordMatch > & WordSearchRequest::getAllMatches() { if ( !isFinished() ) throw exRequestUnfinished(); @@ -112,7 +112,7 @@ long DataRequest::dataSize() } void DataRequest::getDataSlice( size_t offset, size_t size, void * buffer ) - THROW_SPEC( exSliceOutOfRange ) + { if ( size == 0 ) return; @@ -125,7 +125,7 @@ void DataRequest::getDataSlice( size_t offset, size_t size, void * buffer ) memcpy( buffer, &data[ offset ], size ); } -vector< char > & DataRequest::getFullData() THROW_SPEC( exRequestUnfinished ) +vector< char > & DataRequest::getFullData() { if ( !isFinished() ) throw exRequestUnfinished(); @@ -147,13 +147,13 @@ sptr< WordSearchRequest > Class::stemmedMatch( wstring const & /*str*/, unsigned /*minLength*/, unsigned /*maxSuffixVariation*/, unsigned long /*maxResults*/ ) - THROW_SPEC( std::exception ) + { return new WordSearchRequestInstant(); } sptr< WordSearchRequest > Class::findHeadwordsForSynonym( wstring const & ) - THROW_SPEC( std::exception ) + { return new WordSearchRequestInstant(); } @@ -165,7 +165,7 @@ vector< wstring > Class::getAlternateWritings( wstring const & ) } sptr< DataRequest > Class::getResource( string const & /*name*/ ) - THROW_SPEC( std::exception ) + { return new DataRequestInstant( false ); } @@ -487,13 +487,13 @@ bool needToRebuildIndex( vector< string > const & dictionaryFiles, ZipFile::SplitZipFile zf( name ); if( !zf.exists() ) return true; - ts = zf.lastModified().toTime_t(); + ts = zf.lastModified().toSecsSinceEpoch(); } else { if ( !fileInfo.exists() ) return true; - ts = fileInfo.lastModified().toTime_t(); + ts = fileInfo.lastModified().toSecsSinceEpoch(); } if ( ts > lastModified ) @@ -505,7 +505,7 @@ bool needToRebuildIndex( vector< string > const & dictionaryFiles, if ( !fileInfo.exists() ) return true; - return fileInfo.lastModified().toTime_t() < lastModified; + return fileInfo.lastModified().toSecsSinceEpoch() < lastModified; } QString generateRandomDictionaryId() @@ -516,5 +516,14 @@ QString generateRandomDictionaryId() QCryptographicHash::Md5 ).toHex() ); } - +QMap< std::string, sptr< Dictionary::Class > > +dictToMap( std::vector< sptr< Dictionary::Class > > const & dicts ) +{ + QMap< std::string, sptr< Dictionary::Class > > dictMap; + for( auto dict : dicts ) + { + dictMap.insert( dict.get()->getId(), dict ); + } + return dictMap; +} } diff --git a/dictionary.hh b/dictionary.hh index 148793a5..b21933e2 100644 --- a/dictionary.hh +++ b/dictionary.hh @@ -9,7 +9,6 @@ #include #include #include -#include "cpp_features.hh" #include "sptr.hh" #include "ex.hh" #include "mutex.hh" @@ -144,11 +143,11 @@ public: /// Returns the match with the given zero-based index, which should be less /// than matchesCount(). - WordMatch operator [] ( size_t index ) THROW_SPEC( exIndexOutOfRange ); + WordMatch operator [] ( size_t index ) ; /// Returns all the matches found. Since no further locking can or would be /// done, this can only be called after the request has finished. - vector< WordMatch > & getAllMatches() THROW_SPEC( exRequestUnfinished ); + vector< WordMatch > & getAllMatches() ; /// Returns true if the match was uncertain -- that is, there may be more /// results in the dictionary itself, the dictionary index isn't good enough @@ -188,11 +187,11 @@ public: /// Writes "size" bytes starting from "offset" of the data read to the given /// buffer. "size + offset" must be <= than dataSize(). void getDataSlice( size_t offset, size_t size, void * buffer ) - THROW_SPEC( exSliceOutOfRange ); + ; /// Returns all the data read. Since no further locking can or would be /// done, this can only be called after the request has finished. - vector< char > & getFullData() THROW_SPEC( exRequestUnfinished ); + vector< char > & getFullData() ; DataRequest(): hasAnyData( false ) {} @@ -344,7 +343,7 @@ public: /// be stored. The whole operation is supposed to be fast, though some /// dictionaries, the network ones particularly, may of course be slow. virtual sptr< WordSearchRequest > prefixMatch( wstring const &, - unsigned long maxResults ) THROW_SPEC( std::exception )=0; + unsigned long maxResults ) =0; /// Looks up a given word in the dictionary, aiming to find different forms /// of the given word by allowing suffix variations. This means allowing words @@ -357,14 +356,14 @@ public: virtual sptr< WordSearchRequest > stemmedMatch( wstring const &, unsigned minLength, unsigned maxSuffixVariation, - unsigned long maxResults ) THROW_SPEC( std::exception ); + unsigned long maxResults ) ; /// Finds known headwords for the given word, that is, the words for which /// the given word is a synonym. If a dictionary can't perform this operation, /// it should leave the default implementation which always returns an empty /// result. virtual sptr< WordSearchRequest > findHeadwordsForSynonym( wstring const & ) - THROW_SPEC( std::exception ); + ; /// For a given word, provides alternate writings of it which are to be looked /// up alongside with it. Transliteration dictionaries implement this. The @@ -385,14 +384,14 @@ public: vector< wstring > const & alts, wstring const & context = wstring(), bool ignoreDiacritics = false ) - THROW_SPEC( std::exception )=0; + =0; /// Loads contents of a resource named 'name' into the 'data' vector. This is /// usually a picture file referenced in the article or something like that. /// The default implementation always returns the non-existing resource /// response. virtual sptr< DataRequest > getResource( string const & /*name*/ ) - THROW_SPEC( std::exception ); + ; /// Returns a results of full-text search of given string similar getArticle(). virtual sptr< DataRequest > getSearchResults( QString const & searchString, @@ -480,6 +479,9 @@ bool needToRebuildIndex( vector< string > const & dictionaryFiles, /// dictionaries. QString generateRandomDictionaryId(); +QMap< std::string, sptr< Dictionary::Class > > +dictToMap( std::vector< sptr< Dictionary::Class > > const & dicts ); + } #endif diff --git a/dictionarybar.cc b/dictionarybar.cc index 74ff65f1..8ad0ad0c 100644 --- a/dictionarybar.cc +++ b/dictionarybar.cc @@ -211,7 +211,7 @@ void DictionaryBar::showContextMenu( QContextMenuEvent * event, bool extended ) { QString command( editDictionaryCommand ); command.replace( "%GDDICT%", "\"" + dictFilename + "\"" ); - if( !QProcess::startDetached( command ) ) + if( !QProcess::startDetached( command ,QStringList()) ) QApplication::beep(); } diff --git a/dictserver.cc b/dictserver.cc index fdc464e5..65761655 100644 --- a/dictserver.cc +++ b/dictserver.cc @@ -103,7 +103,7 @@ bool connectToServer( QTcpSocket & socket, QString const & url, QString authCommand = QString( "AUTH " ); QString authString = msgId; - int pos = serverUrl.userInfo().indexOf( QRegExp( "[:;]" ) ); + int pos = serverUrl.userInfo().indexOf( QRegularExpression( "[:;]" ) ); if( pos > 0 ) { authCommand += serverUrl.userInfo().left( pos ); @@ -200,11 +200,11 @@ public: if( pos < 0 ) url = "dict://" + url; - databases = database_.split( QRegExp( "[ ,;]" ), Qt::SkipEmptyParts ); + databases = database_.split( QRegularExpression( "[ ,;]" ), Qt::SkipEmptyParts ); if( databases.isEmpty() ) databases.append( "*" ); - strategies = strategies_.split( QRegExp( "[ ,;]" ), Qt::SkipEmptyParts ); + strategies = strategies_.split( QRegularExpression( "[ ,;]" ), Qt::SkipEmptyParts ); if( strategies.isEmpty() ) strategies.append( "prefix" ); } @@ -222,11 +222,11 @@ public: { return 0; } virtual sptr< WordSearchRequest > prefixMatch( wstring const &, - unsigned long maxResults ) THROW_SPEC( std::exception ); + unsigned long maxResults ) ; virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ) - THROW_SPEC( std::exception ); + ; virtual quint32 getLangFrom() const { return langId; } @@ -830,7 +830,7 @@ void DictServerArticleRequest::run() while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewText += articleText.midRef( pos, match.capturedStart() - pos ); + articleNewText += articleText.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString phonetic_text = match.captured( 1 ); @@ -840,7 +840,7 @@ void DictServerArticleRequest::run() } if( pos ) { - articleNewText += articleText.midRef( pos ); + articleNewText += articleText.mid( pos ); articleText = articleNewText; articleNewText.clear(); } @@ -852,7 +852,7 @@ void DictServerArticleRequest::run() while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewText += articleText.midRef( pos, match.capturedStart() - pos ); + articleNewText += articleText.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString link = match.captured( 1 ); @@ -866,7 +866,7 @@ void DictServerArticleRequest::run() } if( pos ) { - articleNewText += articleText.midRef( pos ); + articleNewText += articleText.mid( pos ); articleText = articleNewText; articleNewText.clear(); } @@ -918,7 +918,7 @@ void DictServerArticleRequest::cancel() sptr< WordSearchRequest > DictServerDictionary::prefixMatch( wstring const & word, unsigned long maxResults ) - THROW_SPEC( std::exception ) + { (void) maxResults; if ( word.size() > 80 ) @@ -934,7 +934,7 @@ sptr< WordSearchRequest > DictServerDictionary::prefixMatch( wstring const & wor sptr< DataRequest > DictServerDictionary::getArticle( wstring const & word, vector< wstring > const &, wstring const &, bool ) - THROW_SPEC( std::exception ) + { if ( word.size() > 80 ) { @@ -949,7 +949,7 @@ sptr< DataRequest > DictServerDictionary::getArticle( wstring const & word, } // Anonimuos namespace vector< sptr< Dictionary::Class > > makeDictionaries( Config::DictServers const & servers ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > result; diff --git a/dictserver.hh b/dictserver.hh index 39d093e5..fa387d8a 100644 --- a/dictserver.hh +++ b/dictserver.hh @@ -12,7 +12,7 @@ using std::string; vector< sptr< Dictionary::Class > > makeDictionaries( Config::DictServers const & servers ) - THROW_SPEC( std::exception ); + ; } diff --git a/dictzip.c b/dictzip.c index fd362239..1ac3c62d 100644 --- a/dictzip.c +++ b/dictzip.c @@ -349,11 +349,13 @@ static enum DZ_ERRORS dict_read_header( const char *filename, } header->chunks = xmalloc( sizeof( header->chunks[0] ) * header->chunkCount ); - if( header->chunks == 0 ) { - return DZ_ERR_NOMEMORY; - } + if( header->chunks == 0 ) + { + fclose( str ); + return DZ_ERR_NOMEMORY; + } - for (i = 0; i < header->chunkCount; i++) { + for (i = 0; i < header->chunkCount; i++) { header->chunks[i] = getc( str ) << 0; header->chunks[i] |= getc( str ) << 8; } diff --git a/docs/_config.yml b/docs/_config.yml new file mode 100644 index 00000000..c4192631 --- /dev/null +++ b/docs/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman \ No newline at end of file diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..c3569675 --- /dev/null +++ b/docs/index.md @@ -0,0 +1,22 @@ +## Welcome to GitHub Pages + +This page serves as a release note page + +### Releases + +https://github.com/xiaoyifang/goldendict/releases + + +### version guideline +https://github.com/xiaoyifang/goldendict/wiki/Version--guideline + +the first version has been named as 22.2.xxx.commit_hash. + +22 means 2022 year. + +2 means 2th month of the year. + + +### Support or Contact + +Having trouble with Pages? Check out our [documentation](https://docs.github.com/categories/github-pages-basics/) or [contact support](https://support.github.com/contact) and we’ll help you sort it out. diff --git a/dsl.cc b/dsl.cc index 6be3be6d..b6b845a1 100644 --- a/dsl.cc +++ b/dsl.cc @@ -217,10 +217,10 @@ public: vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString, int searchMode, bool matchCase, @@ -580,7 +580,7 @@ void DslDictionary::loadArticle( uint32_t address, if ( !articleBody ) { // throw exCantReadFile( getDictionaryFilenames()[ 0 ] ); - articleData = GD_NATIVE_TO_WS( L"\n\r\t" ) + gd::toWString( QString( "DICTZIP error: " ) + dict_error_str( dz ) ); +articleData = U"\n\r\t" + gd::toWString( QString( "DICTZIP error: " ) + dict_error_str( dz ) ); } else { @@ -616,7 +616,7 @@ void DslDictionary::loadArticle( uint32_t address, { size_t begin = pos; - pos = articleData.find_first_of( GD_NATIVE_TO_WS( L"\n\r" ), begin ); + pos = articleData.find_first_of( U"\n\r" , begin ); if ( pos == wstring::npos ) pos = articleData.size(); @@ -741,7 +741,7 @@ void DslDictionary::loadArticle( uint32_t address, if( insidedCard ) { // Check for next insided headword - wstring::size_type hpos = articleData.find_first_of( GD_NATIVE_TO_WS( L"\n\r" ), pos ); + wstring::size_type hpos = articleData.find_first_of( U"\n\r" , pos ); if ( hpos == wstring::npos ) hpos = articleData.size(); @@ -820,13 +820,11 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) return result; } - if ( node.tagName == GD_NATIVE_TO_WS( L"b" ) ) + if( node.tagName == U"b" ) result += "" + processNodeChildren( node ) + ""; - else - if ( node.tagName == GD_NATIVE_TO_WS( L"i" ) ) + else if( node.tagName == U"i" ) result += "" + processNodeChildren( node ) + ""; - else - if ( node.tagName == GD_NATIVE_TO_WS( L"u" ) ) + else if( node.tagName == U"u" ) { string nodeText = processNodeChildren( node ); @@ -836,39 +834,32 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) result += "" + nodeText + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"c" ) ) + else if( node.tagName == U"c" ) { result += "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"*" ) ) + else if( node.tagName == U"*" ) { string id = "O" + getId().substr( 0, 7 ) + "_" + QString::number( articleNom ).toStdString() + "_opt_" + QString::number( optionalPartNom++ ).toStdString(); result += "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"m" ) ) - result += "
" + processNodeChildren( node ) + "
"; + else if( node.tagName == U"m" ) + result += "
" + processNodeChildren( node ) + "
"; else if ( node.tagName.size() == 2 && node.tagName[ 0 ] == L'm' && iswdigit( node.tagName[ 1 ] ) ) result += "
" + processNodeChildren( node ) + "
"; - else - if ( node.tagName == GD_NATIVE_TO_WS( L"trn" ) ) + else if( node.tagName == U"trn" ) result += "" + processNodeChildren( node ) + ""; - else - if ( node.tagName == GD_NATIVE_TO_WS( L"ex" ) ) + else if( node.tagName == U"ex" ) result += "" + processNodeChildren( node ) + ""; - else - if ( node.tagName == GD_NATIVE_TO_WS( L"com" ) ) + else if( node.tagName == U"com" ) result += "" + processNodeChildren( node ) + ""; - else - if ( node.tagName == GD_NATIVE_TO_WS( L"s" ) || node.tagName == GD_NATIVE_TO_WS( L"video" ) ) + else if( node.tagName == U"s" || node.tagName == U"video" ) { string filename = Filetype::simplifyString( Utf8::encode( node.renderAsText() ), false ); string n = resourceDir1 + FsEncoding::encode( filename ); @@ -1013,8 +1004,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) + "\">" + processNodeChildren( node ) + ""; } } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"url" ) ) + else if( node.tagName == U"url" ) { string link = Html::escape( Filetype::simplifyString( Utf8::encode( node.renderAsText() ), false ) ); if( QUrl::fromEncoded( link.c_str() ).scheme().isEmpty() ) @@ -1037,13 +1027,11 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) result += "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"!trs" ) ) + else if( node.tagName == U"!trs" ) { result += "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"p") ) + else if( node.tagName == U"p" ) { result += ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"'" ) ) + else if( node.tagName == U"'" ) { // There are two ways to display the stress: by adding an accent sign or via font styles. // We generate two spans, one with accented data and another one without it, so the @@ -1101,8 +1088,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) + "" + data + Utf8::encode( wstring( 1, 0x301 ) ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"lang" ) ) + else if( node.tagName == U"lang" ) { result += ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"ref" ) ) + else if( node.tagName == U"ref" ) { QUrl url; @@ -1158,8 +1143,7 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) result += string( "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"@" ) ) + else if( node.tagName == U"@" ) { // Special case - insided card header was not parsed @@ -1174,23 +1158,19 @@ string DslDictionary::nodeToHtml( ArticleDom::Node const & node ) result += string( "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"sub" ) ) + else if( node.tagName == U"sub" ) { result += "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"sup" ) ) + else if( node.tagName == U"sup" ) { result += "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"t" ) ) + else if( node.tagName == U"t" ) { result += "" + processNodeChildren( node ) + ""; } - else - if ( node.tagName == GD_NATIVE_TO_WS( L"br" ) ) + else if( node.tagName == U"br" ) { result += "
"; } @@ -1377,7 +1357,7 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword, { size_t begin = pos; - pos = articleData.find_first_of( GD_NATIVE_TO_WS( L"\n\r" ), begin ); + pos = articleData.find_first_of( U"\n\r" , begin ); if ( articleHeadword.empty() ) { @@ -1445,7 +1425,7 @@ void DslDictionary::getArticleText( uint32_t articleAddress, QString & headword, if( insidedCard ) { // Check for next insided headword - wstring::size_type hpos = articleData.find_first_of( GD_NATIVE_TO_WS( L"\n\r" ), pos ); + wstring::size_type hpos = articleData.find_first_of( U"\n\r" , pos ); if ( hpos == wstring::npos ) hpos = articleData.size(); @@ -1797,7 +1777,7 @@ sptr< Dictionary::DataRequest > DslDictionary::getArticle( wstring const & word, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new DslArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -1983,7 +1963,7 @@ void DslResourceRequest::run() } sptr< Dictionary::DataRequest > DslDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { return new DslResourceRequest( *this, name ); } @@ -2008,7 +1988,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing & initializing, int maxPictureWidth, unsigned int maxHeadwordSize ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; @@ -2075,37 +2055,37 @@ vector< sptr< Dictionary::Class > > makeDictionaries( try { // Here we intercept any errors during the read to save line at // which the incident happened. We need alive scanner for that. - if ( scanner.getDictionaryName() == GD_NATIVE_TO_WS( L"Abbrev" ) ) - continue; // For now just skip abbreviations + if( scanner.getDictionaryName() == U"Abbrev" ) + continue; // For now just skip abbreviations - // Building the index - initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) ); + // Building the index + initializing.indexingDictionary( Utf8::encode( scanner.getDictionaryName() ) ); - gdDebug( "Dsl: Building the index for dictionary: %s\n", - gd::toQString( scanner.getDictionaryName() ).toUtf8().data() ); + gdDebug( "Dsl: Building the index for dictionary: %s\n", + gd::toQString( scanner.getDictionaryName() ).toUtf8().data() ); - File::Class idx( indexFile, "wb" ); + File::Class idx( indexFile, "wb" ); - IdxHeader idxHeader; + IdxHeader idxHeader; - memset( &idxHeader, 0, sizeof( idxHeader ) ); + memset( &idxHeader, 0, sizeof( idxHeader ) ); - // We write a dummy header first. At the end of the process the header - // will be rewritten with the right values. + // We write a dummy header first. At the end of the process the header + // will be rewritten with the right values. - idx.write( idxHeader ); + idx.write( idxHeader ); - string dictionaryName = Utf8::encode( scanner.getDictionaryName() ); + string dictionaryName = Utf8::encode( scanner.getDictionaryName() ); - idx.write( (uint32_t) dictionaryName.size() ); - idx.write( dictionaryName.data(), dictionaryName.size() ); + idx.write( (uint32_t)dictionaryName.size() ); + idx.write( dictionaryName.data(), dictionaryName.size() ); - string soundDictName = Utf8::encode( scanner.getSoundDictionaryName() ); - if( !soundDictName.empty() ) - { - idxHeader.hasSoundDictionaryName = 1; - idx.write( (uint32_t) soundDictName.size() ); - idx.write( soundDictName.data(), soundDictName.size() ); + string soundDictName = Utf8::encode( scanner.getSoundDictionaryName() ); + if( !soundDictName.empty() ) + { + idxHeader.hasSoundDictionaryName = 1; + idx.write( (uint32_t)soundDictName.size() ); + idx.write( soundDictName.data(), soundDictName.size() ); } idxHeader.dslEncoding = scanner.getEncoding(); @@ -2163,7 +2143,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( if ( eof ) break; - curString.erase( 0, curString.find_first_not_of( GD_NATIVE_TO_WS( L" \t" ) ) ); + curString.erase( 0, curString.find_first_not_of( U" \t" ) ); if ( keys.size() ) expandTildes( curString, keys.front() ); diff --git a/dsl.hh b/dsl.hh index 958cbed0..8641723f 100644 --- a/dsl.hh +++ b/dsl.hh @@ -17,7 +17,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing &, int maxPictureWidth, unsigned int maxHeadwordSize ) - THROW_SPEC( std::exception ); + ; } diff --git a/dsl_details.cc b/dsl_details.cc index 843224f4..ddc02922 100644 --- a/dsl_details.cc +++ b/dsl_details.cc @@ -144,12 +144,10 @@ string findCodeForDslId( int id ) bool isAtSignFirst( wstring const & str ) { // Test if '@' is first in string except spaces and dsl tags - QRegExp reg( "[ \\t]*(?:\\[[^\\]]+\\][ \\t]*)*@", Qt::CaseInsensitive, QRegExp::RegExp2 ); - return reg.indexIn( gd::toQString( str ) ) == 0; + QRegularExpression reg( "[ \\t]*(?:\\[[^\\]]+\\][ \\t]*)*@", QRegularExpression::PatternOption::CaseInsensitiveOption); + return gd::toQString( str ).indexOf (reg) == 0; } - - /////////////// ArticleDom wstring ArticleDom::Node::renderAsText( bool stripTrsTag ) const @@ -160,7 +158,7 @@ wstring ArticleDom::Node::renderAsText( bool stripTrsTag ) const wstring result; for( list< Node >::const_iterator i = begin(); i != end(); ++i ) - if( !stripTrsTag || i->tagName != GD_NATIVE_TO_WS( L"!trs" ) ) + if( !stripTrsTag || i->tagName != U"!trs" ) result += i->renderAsText( stripTrsTag ); return result; @@ -169,8 +167,7 @@ wstring ArticleDom::Node::renderAsText( bool stripTrsTag ) const // Returns true if src == 'm' and dest is 'mX', where X is a digit static inline bool checkM( wstring const & dest, wstring const & src ) { - return ( src == GD_NATIVE_TO_WS( L"m" ) && dest.size() == 2 && - dest[ 0 ] == L'm' && iswdigit( dest[ 1 ] ) ); + return ( src == U"m" && dest.size() == 2 && dest[ 0 ] == L'm' && iswdigit( dest[ 1 ] ) ); } ArticleDom::ArticleDom( wstring const & str, string const & dictName, @@ -252,7 +249,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, wstring linkText = Folding::trimWhitespace( *entry ); ArticleDom nodeDom( linkText, dictName, headword_ ); - Node link( Node::Tag(), GD_NATIVE_TO_WS( L"@" ), wstring() ); + Node link( Node::Tag(), U"@" , wstring() ); for( Node::iterator n = nodeDom.root.begin(); n != nodeDom.root.end(); ++n ) link.push_back( *n ); @@ -262,13 +259,13 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, { root.push_back( link ); if( entry != allLinkEntries.end() ) // Add line break before next entry - root.push_back( Node( Node::Tag(), GD_NATIVE_TO_WS( L"br" ), wstring() ) ); + root.push_back( Node( Node::Tag(), U"br" , wstring() ) ); } else { stack.back()->push_back( link ); if( entry != allLinkEntries.end() ) - stack.back()->push_back( Node( Node::Tag(), GD_NATIVE_TO_WS( L"br" ), wstring() ) ); + stack.back()->push_back( Node( Node::Tag(), U"br" , wstring() ) ); } } @@ -349,7 +346,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, } // If the tag is [t], we update the transcriptionCount - if ( name == GD_NATIVE_TO_WS( L"t" ) ) + if( name == U"t" ) { if ( isClosing ) { @@ -361,7 +358,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, } // If the tag is [s], we update the mediaCount - if ( name == GD_NATIVE_TO_WS( L"s" ) ) + if( name == U"s" ) { if ( isClosing ) { @@ -374,14 +371,13 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, if ( !isClosing ) { - if ( name == GD_NATIVE_TO_WS( L"m" ) || - ( name.size() == 2 && name[ 0 ] == L'm' && iswdigit( name[ 1 ] ) ) ) + if( name == U"m" || ( name.size() == 2 && name[ 0 ] == L'm' && iswdigit( name[ 1 ] ) ) ) { // Opening an 'mX' or 'm' tag closes any previous 'm' tag - closeTag( GD_NATIVE_TO_WS( L"m" ), stack, false ); + closeTag( U"m" , stack, false ); } openTag( name, attrs, stack ); - if ( name == GD_NATIVE_TO_WS( L"br" ) ) + if( name == U"br" ) { // [br] tag don't have closing tag closeTag( name, stack ); @@ -465,7 +461,7 @@ ArticleDom::ArticleDom( wstring const & str, string const & dictName, processUnsortedParts( linkText, true ); ArticleDom nodeDom( linkText, dictName, headword_ ); - Node link( Node::Tag(), GD_NATIVE_TO_WS( L"ref" ), wstring() ); + Node link( Node::Tag(), U"ref" , wstring() ); for( Node::iterator n = nodeDom.root.begin(); n != nodeDom.root.end(); ++n ) link.push_back( *n ); @@ -640,7 +636,7 @@ void ArticleDom::openTag( wstring const & name, { list< Node > nodesToReopen; - if( name == GD_NATIVE_TO_WS( L"m" ) || checkM( name, GD_NATIVE_TO_WS( L"m" ) ) ) + if( name == U"m" || checkM( name, U"m" ) ) { // All tags above [m] tag will be closed and reopened after // to avoid break this tag by closing some other tag. @@ -734,7 +730,7 @@ void ArticleDom::closeTag( wstring const & name, nodesToReopen.push_back( Node( Node::Tag(), stack.back()->tagName, stack.back()->tagAttrs ) ); - if ( stack.back()->empty() && stack.back()->tagName != GD_NATIVE_TO_WS( L"br" ) ) + if( stack.back()->empty() && stack.back()->tagName != U"br" ) { // Empty nodes except [br] tag are deleted since they're no use @@ -780,7 +776,7 @@ void ArticleDom::closeTag( wstring const & name, } } -void ArticleDom::nextChar() THROW_SPEC( eot ) +void ArticleDom::nextChar() { if ( !*stringPos ) throw eot(); @@ -825,7 +821,7 @@ bool ArticleDom::atSignFirstInLine() /////////////// DslScanner -DslScanner::DslScanner( string const & fileName ) THROW_SPEC( Ex, Iconv::Ex ): +DslScanner::DslScanner( string const & fileName ) : encoding( Utf8::Windows1252 ), readBufferPtr( readBuffer ), readBufferLeft( 0 ), linesRead( 0 ) { @@ -917,19 +913,15 @@ DslScanner::DslScanner( string const & fileName ) THROW_SPEC( Ex, Iconv::Ex ): bool isLangTo = false; bool isSoundDict = false; - if ( !str.compare( 0, 5, GD_NATIVE_TO_WS( L"#NAME" ), 5 ) ) + if( !str.compare( 0, 5, U"#NAME" , 5 ) ) isName = true; - else - if ( !str.compare( 0, 15, GD_NATIVE_TO_WS( L"#INDEX_LANGUAGE" ), 15 ) ) + else if( !str.compare( 0, 15, U"#INDEX_LANGUAGE" , 15 ) ) isLangFrom = true; - else - if ( !str.compare( 0, 18, GD_NATIVE_TO_WS( L"#CONTENTS_LANGUAGE" ), 18 ) ) + else if( !str.compare( 0, 18, U"#CONTENTS_LANGUAGE" , 18 ) ) isLangTo = true; - else - if ( !str.compare( 0, 17, GD_NATIVE_TO_WS( L"#SOUND_DICTIONARY" ), 17 ) ) + else if( !str.compare( 0, 17, U"#SOUND_DICTIONARY" , 17 ) ) isSoundDict = true; - else - if ( str.compare( 0, 17, GD_NATIVE_TO_WS( L"#SOURCE_CODE_PAGE" ), 17 ) ) + else if( str.compare( 0, 17, U"#SOURCE_CODE_PAGE" , 17 ) ) continue; // Locate the argument @@ -962,14 +954,11 @@ DslScanner::DslScanner( string const & fileName ) THROW_SPEC( Ex, Iconv::Ex ): // We don't need that! GD_FDPRINTF( stderr, "Warning: encoding was specified in a Unicode file, ignoring.\n" ); } - else - if ( !wcscasecmp( arg.c_str(), GD_NATIVE_TO_WS( L"Latin" ) ) ) + else if( !arg.compare( U"Latin" ) ) encoding = Utf8::Windows1252; - else - if ( !wcscasecmp( arg.c_str(), GD_NATIVE_TO_WS( L"Cyrillic" ) ) ) + else if( !arg.compare( U"Cyrillic" ) ) encoding = Utf8::Windows1251; - else - if ( !wcscasecmp( arg.c_str(), GD_NATIVE_TO_WS( L"EasternEuropean" ) ) ) + else if( !arg.compare( U"EasternEuropean" ) ) encoding = Utf8::Windows1250; else { @@ -995,8 +984,7 @@ DslScanner::~DslScanner() throw() gzclose( f ); } -bool DslScanner::readNextLine( wstring & out, size_t & offset, bool only_head_word ) THROW_SPEC( Ex, - Iconv::Ex ) +bool DslScanner::readNextLine( wstring & out, size_t & offset, bool only_head_word ) { offset = (size_t)( gztell( f ) - readBufferLeft/*+pos*/ ); @@ -1042,7 +1030,7 @@ bool DslScanner::readNextLine( wstring & out, size_t & offset, bool only_head_wo #ifdef __WIN32 out=line.toStdU32String(); #else - out=line.toStdWString(); + out=line.toStdU32String(); #endif return true; @@ -1050,7 +1038,7 @@ bool DslScanner::readNextLine( wstring & out, size_t & offset, bool only_head_wo } bool DslScanner::readNextLineWithoutComments( wstring & out, size_t & offset , bool only_headword) - THROW_SPEC( Ex, Iconv::Ex ) + { wstring str; bool commentToNextLine = false; @@ -1163,6 +1151,12 @@ void expandOptionalParts( wstring & str, list< wstring > * result, list< wstring > * headwords; headwords = inside_recurse ? result : &expanded; + //if str is too long ,it can never be headwords. + //todo? + if( str.size() > 100 ) + { + return; + } for( ; x < str.size(); ) { wchar ch = str[ x ]; @@ -1257,8 +1251,8 @@ void expandOptionalParts( wstring & str, list< wstring > * result, } } -static const wstring openBraces( GD_NATIVE_TO_WS( L"{{" ) ); -static const wstring closeBraces( GD_NATIVE_TO_WS( L"}}" ) ); +static const wstring openBraces( U"{{" ); +static const wstring closeBraces( U"}}" ); void stripComments( wstring & str, bool & nextLine ) { @@ -1357,11 +1351,11 @@ namespace quint32 dslLanguageToId( wstring const & name ) { - static wstring newSp( GD_NATIVE_TO_WS( L"newspelling" ) ); - static wstring st( GD_NATIVE_TO_WS( L"standard" ) ); - static wstring ms( GD_NATIVE_TO_WS( L"modernsort" ) ); - static wstring ts( GD_NATIVE_TO_WS( L"traditionalsort" ) ); - static wstring prc( GD_NATIVE_TO_WS( L"prc" ) ); + static wstring newSp( U"newspelling" ); + static wstring st( U"standard" ); + static wstring ms( U"modernsort" ); + static wstring ts( U"traditionalsort" ); + static wstring prc( U"prc" ); // Any of those endings are to be removed diff --git a/dsl_details.hh b/dsl_details.hh index 0b22335d..2349c349 100644 --- a/dsl_details.hh +++ b/dsl_details.hh @@ -10,7 +10,11 @@ #include #include "dictionary.hh" #include "iconv.hh" +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #include "utf8.hh" @@ -91,7 +95,7 @@ private: unsigned transcriptionCount; // >0 = inside a [t] tag unsigned mediaCount; // >0 = inside a [s] tag - void nextChar() THROW_SPEC( eot ); + void nextChar() ; /// Information for diagnostic purposes string dictionaryName; @@ -125,7 +129,7 @@ public: DEF_EX( exUnknownCodePage, "The .dsl file specified an unknown code page", Ex ) DEF_EX( exEncodingError, "Encoding error", Ex ) // Should never happen really - DslScanner( string const & fileName ) THROW_SPEC( Ex, Iconv::Ex ); + DslScanner( string const & fileName ) ; ~DslScanner() throw(); /// Returns the detected encoding of this file. @@ -154,10 +158,10 @@ public: /// If end of file is reached, false is returned. /// Reading begins from the first line after the headers (ones which start /// with #). - bool readNextLine( wstring &, size_t & offset, bool only_head_word = false ) THROW_SPEC( Ex, Iconv::Ex ); + bool readNextLine( wstring &, size_t & offset, bool only_head_word = false ) ; /// Similar readNextLine but strip all DSL comments {{...}} - bool readNextLineWithoutComments( wstring &, size_t & offset, bool only_headword = false ) THROW_SPEC( Ex, Iconv::Ex ); + bool readNextLineWithoutComments( wstring &, size_t & offset, bool only_headword = false ) ; /// Returns the number of lines read so far from the file. unsigned getLinesRead() const diff --git a/editdictionaries.cc b/editdictionaries.cc index 239dca5b..37626f16 100644 --- a/editdictionaries.cc +++ b/editdictionaries.cc @@ -11,17 +11,19 @@ using std::vector; EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_, vector< sptr< Dictionary::Class > > & dictionaries_, + QMap > & dictMap_, Instances::Groups & groupInstances_, QNetworkAccessManager & dictNetMgr_ ): QDialog( parent, Qt::WindowSystemMenuHint | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint ), cfg( cfg_ ), dictionaries( dictionaries_ ), + dictMap(dictMap_), groupInstances( groupInstances_ ), dictNetMgr( dictNetMgr_ ), origCfg( cfg ), sources( this, cfg ), orderAndProps( new OrderAndProps( this, cfg.dictionaryOrder, cfg.inactiveDictionaries, - dictionaries ) ), + dictionaries, dictMap ) ), groups( new Groups( this, dictionaries, cfg.groups, orderAndProps->getCurrentDictionaryOrder() ) ), dictionariesChanged( false ), groupsChanged( false ), @@ -73,8 +75,12 @@ EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_, void EditDictionaries::editGroup( unsigned id ) { + ui.tabs->setTabVisible( 0, false ); + if ( id == Instances::Group::AllGroupId ) + { ui.tabs->setCurrentIndex( 1 ); + } else { ui.tabs->setCurrentIndex( 2 ); @@ -207,15 +213,14 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups ) groupInstances.clear(); // Those hold pointers to dictionaries, we need to // free them. - ui.tabs->setUpdatesEnabled( false ); - ui.tabs->removeTab( 1 ); - ui.tabs->removeTab( 1 ); + + groups.reset(); orderAndProps.reset(); loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); - + dictMap = Dictionary::dictToMap(dictionaries); // If no changes to groups were made, update the original data bool noGroupEdits = ( origCfg.groups == savedGroups ); @@ -240,13 +245,15 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups ) if ( rebuildGroups ) { - orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries ); + orderAndProps = new OrderAndProps( this, savedOrder, savedInactive, dictionaries, dictMap ); + groups = new Groups( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() ); + + ui.tabs->removeTab( 1 ); + ui.tabs->removeTab( 1 ); ui.tabs->insertTab( 1, orderAndProps.get(), QIcon(":/icons/book.svg"), tr( "&Dictionaries" ) ); - groups = new Groups( this, dictionaries, savedGroups, orderAndProps->getCurrentDictionaryOrder() ); ui.tabs->insertTab( 2, groups.get(), QIcon(":/icons/bookcase.svg"), tr( "&Groups" ) ); - ui.tabs->setUpdatesEnabled( true ); if ( noGroupEdits ) origCfg.groups = groups->getGroups(); @@ -257,6 +264,8 @@ void EditDictionaries::acceptChangedSources( bool rebuildGroups ) if ( noInactiveEdits ) origCfg.inactiveDictionaries = orderAndProps->getCurrentInactiveDictionaries(); } + ui.tabs->setUpdatesEnabled( true ); + } void EditDictionaries::helpRequested() diff --git a/editdictionaries.hh b/editdictionaries.hh index 14affb18..a6de3819 100644 --- a/editdictionaries.hh +++ b/editdictionaries.hh @@ -23,6 +23,7 @@ public: EditDictionaries( QWidget * parent, Config::Class & cfg, std::vector< sptr< Dictionary::Class > > & dictionaries, + QMap > & dictMap_, Instances::Groups & groupInstances, // We only clear those on rescan QNetworkAccessManager & dictNetMgr ); @@ -73,6 +74,7 @@ private: Config::Class & cfg; std::vector< sptr< Dictionary::Class > > & dictionaries; + QMap > & dictMap; Instances::Groups & groupInstances; QNetworkAccessManager & dictNetMgr; diff --git a/epwing.cc b/epwing.cc index fa61ed53..cd5eec5c 100644 --- a/epwing.cc +++ b/epwing.cc @@ -120,10 +120,10 @@ public: vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString, int searchMode, bool matchCase, @@ -153,13 +153,13 @@ public: virtual sptr< Dictionary::WordSearchRequest > prefixMatch( wstring const &, unsigned long ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::WordSearchRequest > stemmedMatch( wstring const &, unsigned minLength, unsigned maxSuffixVariation, unsigned long maxResults ) - THROW_SPEC( std::exception ); + ; protected: @@ -657,7 +657,7 @@ sptr< Dictionary::DataRequest > EpwingDictionary::getArticle( wstring const & wo vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new EpwingArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -785,7 +785,7 @@ void EpwingResourceRequest::run() } sptr< Dictionary::DataRequest > EpwingDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { return new EpwingResourceRequest( *this, name ); } @@ -932,7 +932,7 @@ void EpwingWordSearchRequest::findMatches() sptr< Dictionary::WordSearchRequest > EpwingDictionary::prefixMatch( wstring const & str, unsigned long maxResults ) - THROW_SPEC( std::exception ) + { return new EpwingWordSearchRequest( *this, str, 0, -1, true, maxResults ); } @@ -940,7 +940,7 @@ sptr< Dictionary::WordSearchRequest > EpwingDictionary::prefixMatch( sptr< Dictionary::WordSearchRequest > EpwingDictionary::stemmedMatch( wstring const & str, unsigned minLength, unsigned maxSuffixVariation, unsigned long maxResults ) - THROW_SPEC( std::exception ) + { return new EpwingWordSearchRequest( *this, str, minLength, (int)maxSuffixVariation, false, maxResults ); @@ -952,14 +952,12 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; vector< string > dictFiles; - QByteArray catName; - catName += QDir::separator(); - catName += "catalogs"; + QByteArray catName = QString("%1catalogs").arg(QDir::separator()).toUtf8(); for( vector< string >::const_iterator i = fileNames.begin(); i != fileNames.end(); ++i ) diff --git a/epwing.hh b/epwing.hh index 9b94e3d0..8ce85e26 100644 --- a/epwing.hh +++ b/epwing.hh @@ -13,7 +13,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; } #endif // __EPWING_HH__INCLUDED__ diff --git a/epwing_book.cc b/epwing_book.cc index 18f38298..4ed8c931 100644 --- a/epwing_book.cc +++ b/epwing_book.cc @@ -13,6 +13,9 @@ #include "wstring_qt.hh" #include "folding.hh" #include "epwing_charmap.hh" +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif #if defined( Q_OS_WIN32 ) || defined( Q_OS_MAC ) #define _FILE_OFFSET_BITS 64 @@ -550,7 +553,8 @@ bool EpwingBook::setSubBook( int book_nom ) if( f.open( QFile::ReadOnly | QFile::Text ) ) { QTextStream ts( &f ); - ts.setCodec( "UTF-8" ); + //todo? +// ts.setCodec( "UTF-8" ); QString line = ts.readLine(); while( !line.isEmpty() ) @@ -853,7 +857,7 @@ bool EpwingBook::getNextHeadword( EpwingHeadword & head ) { EB_Position pos; - QRegExp badLinks( "#(v|n)\\d" ); + QRegularExpression badLinks( "#(v|n)\\d" ); // At first we check references queue while( !LinksQueue.isEmpty() ) @@ -1031,7 +1035,8 @@ void EpwingBook::fixHeadword( QString & headword ) return; QString fixed = headword; - fixed.remove( QRegExp( "/[^/]+/", Qt::CaseSensitive ) ); + QRegularExpression leadingSlashRx( "/[^/]+/" ); + fixed.remove(leadingSlashRx ); if( isHeadwordCorrect( fixed ) ) { @@ -1202,8 +1207,8 @@ void EpwingBook::finalizeText( QString & text ) // Replace references int pos = 0; - QRegExp reg1( "" ); - QRegExp reg2( "" ); + QRegularExpression reg1( "" ); + QRegularExpression reg2( "" ); EContainer cont( this, true ); @@ -1239,13 +1244,14 @@ void EpwingBook::finalizeText( QString & text ) QString link = ""; - text.replace( reg1.cap(), link ); + //todo ? iterate cap ,or replace as a whole? + text.replace( reg1, link ); pos = text.indexOf( reg2, pos ); if( pos < 0 ) break; - text.replace( reg2.cap(), "" ); + text.replace( reg2, "" ); } } @@ -1732,8 +1738,7 @@ QByteArray EpwingBook::handleReference( EB_Hook_Code code, const unsigned int * if( refOpenCount > refCloseCount ) return QByteArray(); - QString str; - str.sprintf( "", refOpenCount ); + QString str=QString( "").arg( refOpenCount ); refOpenCount += 1; return str.toUtf8(); } @@ -1747,7 +1752,7 @@ QByteArray EpwingBook::handleReference( EB_Hook_Code code, const unsigned int * refOffsets.append( argv[ 2 ] ); QString str; - str.sprintf( "", refCloseCount ); + str.asprintf( "", refCloseCount ); refCloseCount += 1; return str.toUtf8(); diff --git a/epwing_book.hh b/epwing_book.hh index d7be2d3c..5e2b99b5 100644 --- a/epwing_book.hh +++ b/epwing_book.hh @@ -12,7 +12,11 @@ #include "mutex.hh" #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #include #include diff --git a/epwing_charmap.cc b/epwing_charmap.cc index 78994a96..c08c4a65 100644 --- a/epwing_charmap.cc +++ b/epwing_charmap.cc @@ -19,9 +19,9 @@ QByteArray EpwingCharmap::mapToUtf8( QString const & code ) return QByteArray(); } -void EpwingCharmap::addEntry( QString const & code, QChar ch ) +void EpwingCharmap::addEntry( QString const & code, int ch ) { - charMap[ code ] = ch; + charMap[ code ] = QChar(ch); } EpwingCharmap::EpwingCharmap() diff --git a/epwing_charmap.hh b/epwing_charmap.hh index 37eed5aa..546b10b9 100644 --- a/epwing_charmap.hh +++ b/epwing_charmap.hh @@ -20,7 +20,7 @@ public: private: EpwingCharmap(); - void addEntry( QString const & code, QChar ch ); + void addEntry( QString const & code, int ch ); QMap< QString, QChar > charMap; }; diff --git a/externalviewer.cc b/externalviewer.cc index 71683fc3..ac76003c 100644 --- a/externalviewer.cc +++ b/externalviewer.cc @@ -10,7 +10,7 @@ ExternalViewer::ExternalViewer( const char * data, int size, QString const & extension, QString const & viewerCmdLine_, QObject * parent) - THROW_SPEC( exCantCreateTempFile ): + : QObject( parent ), tempFile( QDir::temp().filePath( QString( "gd-XXXXXXXX." ) + extension ) ), viewer( this ), @@ -31,7 +31,7 @@ ExternalViewer::ExternalViewer( const char * data, int size, GD_DPRINTF( "%s\n", tempFile.fileName().toLocal8Bit().data() ); } -void ExternalViewer::start() THROW_SPEC( exCantRunViewer ) +void ExternalViewer::start() { connect( &viewer, SIGNAL( finished( int, QProcess::ExitStatus ) ), this, SLOT( deleteLater() ) ); diff --git a/externalviewer.hh b/externalviewer.hh index a17f967c..b7bb6ba6 100644 --- a/externalviewer.hh +++ b/externalviewer.hh @@ -8,7 +8,6 @@ #include #include #include "ex.hh" -#include "cpp_features.hh" /// An external viewer, opens resources in other programs class ExternalViewer: public QObject @@ -29,11 +28,11 @@ public: ExternalViewer( const char * data, int size, QString const & extension, QString const & viewerCmdLine, QObject * parent = 0 ) - THROW_SPEC( exCantCreateTempFile ); + ; // Once this is called, the object will be deleted when it's done, even if // the function throws. - void start() THROW_SPEC( exCantRunViewer ); + void start() ; /// If the external process is running, requests its termination and returns /// false - expect the QObject::destroyed() signal to be emitted soon. diff --git a/extlineedit.cc b/extlineedit.cc index ecaa7bda..e2ba7de3 100644 --- a/extlineedit.cc +++ b/extlineedit.cc @@ -110,14 +110,12 @@ void ExtLineEdit::updateButtonPositions() iconPos = (iconPos == Left ? Right : Left); if (iconPos == ExtLineEdit::Right) { - int right; - getTextMargins(0, 0, &right, 0); - const int iconoffset = right + 4; + QMargins qm=textMargins(); + const int iconoffset = qm.right() + 4; iconButtons[i]->setGeometry(contentRect.adjusted(width() - iconoffset, 0, 0, 0)); } else { - int left; - getTextMargins(&left, 0, 0, 0); - const int iconoffset = left + 4; + QMargins qm=textMargins(); + const int iconoffset = qm.left() + 4; iconButtons[i]->setGeometry(contentRect.adjusted(0, 0, -width() + iconoffset, 0)); } } diff --git a/favoritespanewidget.cc b/favoritespanewidget.cc index 392b4156..c5e4847e 100644 --- a/favoritespanewidget.cc +++ b/favoritespanewidget.cc @@ -907,7 +907,8 @@ void FavoritesModel::removeItemsForIndexes( const QModelIndexList & idxList ) for( int i = lowestLevel; i >= 0; i-- ) { QModelIndexList idxSublist = itemsToDelete[ i ]; - std::sort( idxSublist.begin(), idxSublist.end(), qGreater< QModelIndex >() ); + // std::greater does not work as operator < not implemented + std::sort( idxSublist.begin(), idxSublist.end(), std::not2( std::less< QModelIndex >() ) ); it = idxSublist.begin(); for( ; it != idxSublist.end(); ++it ) diff --git a/ffmpegaudio.cc b/ffmpegaudio.cc index e38f8bc6..172185ec 100644 --- a/ffmpegaudio.cc +++ b/ffmpegaudio.cc @@ -52,9 +52,6 @@ AudioService & AudioService::instance() AudioService::AudioService() { -#if LIBAVFORMAT_VERSION_MAJOR < 58 || ( LIBAVFORMAT_VERSION_MAJOR == 58 && LIBAVFORMAT_VERSION_MINOR < 9 ) - av_register_all(); -#endif ao_initialize(); } @@ -94,7 +91,11 @@ struct DecoderContext QByteArray audioData_; QDataStream audioDataStream_; AVFormatContext * formatContext_; +#if LIBAVCODEC_VERSION_MAJOR < 59 AVCodec * codec_; +#else + const AVCodec * codec_; +#endif AVCodecContext * codecContext_; AVIOContext * avioContext_; AVStream * audioStream_; @@ -151,11 +152,8 @@ bool DecoderContext::openCodec( QString & errorString ) return false; } -#if LIBAVCODEC_VERSION_MAJOR < 56 || ( LIBAVCODEC_VERSION_MAJOR == 56 && LIBAVCODEC_VERSION_MINOR < 56 ) - unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + FF_INPUT_BUFFER_PADDING_SIZE ); -#else unsigned char * avioBuffer = ( unsigned char * )av_malloc( kBufferSize + AV_INPUT_BUFFER_PADDING_SIZE ); -#endif + if ( !avioBuffer ) { errorString = QObject::tr( "av_malloc() failed." ); @@ -198,11 +196,7 @@ bool DecoderContext::openCodec( QString & errorString ) // Find audio stream, use the first audio stream if available for ( unsigned i = 0; i < formatContext_->nb_streams; i++ ) { -#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 ) - if ( formatContext_->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO ) -#else - if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ) -#endif + if ( formatContext_->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO ) { audioStream_ = formatContext_->streams[i]; break; @@ -214,15 +208,6 @@ bool DecoderContext::openCodec( QString & errorString ) return false; } -#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 33 ) - codecContext_ = audioStream_->codec; - codec_ = avcodec_find_decoder( codecContext_->codec_id ); - if ( !codec_ ) - { - errorString = QObject::tr( "Codec [id: %1] not found." ).arg( codecContext_->codec_id ); - return false; - } -#else codec_ = avcodec_find_decoder( audioStream_->codecpar->codec_id ); if ( !codec_ ) { @@ -236,7 +221,6 @@ bool DecoderContext::openCodec( QString & errorString ) return false; } avcodec_parameters_to_context( codecContext_, audioStream_->codecpar ); -#endif ret = avcodec_open2( codecContext_, codec_, NULL ); if ( ret < 0 ) @@ -313,9 +297,7 @@ void DecoderContext::closeCodec() { audioStream_->discard = AVDISCARD_ALL; avcodec_close( codecContext_ ); -#if LIBAVCODEC_VERSION_MAJOR > 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR >= 33 ) avcodec_free_context( &codecContext_ ); -#endif } avformat_close_input( &formatContext_ ); @@ -397,11 +379,7 @@ void DecoderContext::closeOutputDevice() bool DecoderContext::play( QString & errorString ) { -#if LIBAVCODEC_VERSION_MAJOR < 55 || ( LIBAVCODEC_VERSION_MAJOR == 55 && LIBAVCODEC_VERSION_MINOR < 28 ) - AVFrame * frame = avcodec_alloc_frame(); -#else AVFrame * frame = av_frame_alloc(); -#endif if ( !frame ) { errorString = QObject::tr( "avcodec_alloc_frame() failed." ); @@ -417,22 +395,6 @@ bool DecoderContext::play( QString & errorString ) if ( packet.stream_index == audioStream_->index ) { AVPacket pack = packet; -#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 ) - int gotFrame = 0; - do - { - int len = avcodec_decode_audio4( codecContext_, frame, &gotFrame, &pack ); - if ( !Utils::AtomicInt::loadAcquire( isCancelled_ ) && gotFrame ) - { - playFrame( frame ); - } - if( len <= 0 || Utils::AtomicInt::loadAcquire( isCancelled_ ) ) - break; - pack.size -= len; - pack.data += len; - } - while( pack.size > 0 ); -#else int ret = avcodec_send_packet( codecContext_, &pack ); /* read all the output frames (in general there may be any number of them) */ while( ret >= 0 ) @@ -444,30 +406,13 @@ bool DecoderContext::play( QString & errorString ) playFrame( frame ); } -#endif + } - // av_free_packet() must be called after each call to av_read_frame() -#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 7 ) - av_free_packet( &packet ); -#else + av_packet_unref( &packet ); -#endif + } -#if LIBAVCODEC_VERSION_MAJOR < 57 || ( LIBAVCODEC_VERSION_MAJOR == 57 && LIBAVCODEC_VERSION_MINOR < 37 ) - if ( !Utils::AtomicInt::loadAcquire( isCancelled_ ) && - codecContext_->codec->capabilities & CODEC_CAP_DELAY ) - { - av_init_packet( &packet ); - int gotFrame = 0; - while ( avcodec_decode_audio4( codecContext_, frame, &gotFrame, &packet ) >= 0 && gotFrame ) - { - if ( Utils::AtomicInt::loadAcquire( isCancelled_ ) ) - break; - playFrame( frame ); - } - } -#else /* flush the decoder */ av_init_packet( &packet ); packet.data = NULL; @@ -480,28 +425,10 @@ bool DecoderContext::play( QString & errorString ) break; playFrame( frame ); } -#endif - -#if LIBAVCODEC_VERSION_MAJOR < 54 - av_free( frame ); -#elif LIBAVCODEC_VERSION_MAJOR < 55 || ( LIBAVCODEC_VERSION_MAJOR == 55 && LIBAVCODEC_VERSION_MINOR < 28 ) - avcodec_free_frame( &frame ); -#else av_frame_free( &frame ); -#endif - return true; } -static inline int32_t toInt32( double v ) -{ - if ( v >= 1.0 ) - return 0x7fffffffL; - else if ( v <= -1.0 ) - return 0x80000000L; - return floor( v * 2147483648.0 ); -} - bool DecoderContext::normalizeAudio( AVFrame * frame, vector & samples ) { int lineSize = 0; diff --git a/file.cc b/file.cc index bfb9514e..9391028a 100644 --- a/file.cc +++ b/file.cc @@ -88,7 +88,7 @@ bool exists( char const * filename ) throw() #endif } -void Class::open( char const * filename, char const * mode ) THROW_SPEC( exCantOpen ) +void Class::open( char const * filename, char const * mode ) { QFile::OpenMode openMode = QIODevice::Text; const char * pch = mode; @@ -118,19 +118,19 @@ void Class::open( char const * filename, char const * mode ) THROW_SPEC( exCantO throw exCantOpen( std::string( filename ) + ": " + f.errorString().toUtf8().data() ); } -Class::Class( char const * filename, char const * mode ) THROW_SPEC( exCantOpen ): +Class::Class( char const * filename, char const * mode ) : writeBuffer( 0 ) { open( filename, mode ); } Class::Class( std::string const & filename, char const * mode ) - THROW_SPEC( exCantOpen ): writeBuffer( 0 ) + : writeBuffer( 0 ) { open( filename.c_str(), mode ); } -void Class::read( void * buf, qint64 size ) THROW_SPEC( exReadError, exWriteError ) +void Class::read( void * buf, qint64 size ) { if ( !size ) return; @@ -144,7 +144,7 @@ void Class::read( void * buf, qint64 size ) THROW_SPEC( exReadError, exWriteErro throw exReadError(); } -size_t Class::readRecords( void * buf, qint64 size, size_t count ) THROW_SPEC( exWriteError ) +size_t Class::readRecords( void * buf, qint64 size, size_t count ) { if ( writeBuffer ) flushWriteBuffer(); @@ -153,7 +153,7 @@ size_t Class::readRecords( void * buf, qint64 size, size_t count ) THROW_SPEC( e return result < 0 ? result : result / size; } -void Class::write( void const * buf, qint64 size ) THROW_SPEC( exWriteError, exAllocation ) +void Class::write( void const * buf, qint64 size ) { if ( !size ) return; @@ -201,7 +201,7 @@ void Class::write( void const * buf, qint64 size ) THROW_SPEC( exWriteError, exA } size_t Class::writeRecords( void const * buf, qint64 size, size_t count ) - THROW_SPEC( exWriteError ) + { flushWriteBuffer(); @@ -210,7 +210,7 @@ size_t Class::writeRecords( void const * buf, qint64 size, size_t count ) } char * Class::gets( char * s, int size, bool stripNl ) - THROW_SPEC( exWriteError ) + { if ( writeBuffer ) flushWriteBuffer(); @@ -237,7 +237,7 @@ char * Class::gets( char * s, int size, bool stripNl ) return result; } -std::string Class::gets( bool stripNl ) THROW_SPEC( exReadError, exWriteError ) +std::string Class::gets( bool stripNl ) { char buf[ 1024 ]; @@ -247,7 +247,7 @@ std::string Class::gets( bool stripNl ) THROW_SPEC( exReadError, exWriteError ) return std::string( buf ); } -void Class::seek( qint64 offset ) THROW_SPEC( exSeekError, exWriteError ) +void Class::seek( qint64 offset ) { if ( writeBuffer ) flushWriteBuffer(); @@ -256,7 +256,7 @@ void Class::seek( qint64 offset ) THROW_SPEC( exSeekError, exWriteError ) throw exSeekError(); } -void Class::seekCur( qint64 offset ) THROW_SPEC( exSeekError, exWriteError ) +void Class::seekCur( qint64 offset ) { if ( writeBuffer ) flushWriteBuffer(); @@ -265,7 +265,7 @@ void Class::seekCur( qint64 offset ) THROW_SPEC( exSeekError, exWriteError ) throw exSeekError(); } -void Class::seekEnd( qint64 offset ) THROW_SPEC( exSeekError, exWriteError ) +void Class::seekEnd( qint64 offset ) { if ( writeBuffer ) flushWriteBuffer(); @@ -274,12 +274,12 @@ void Class::seekEnd( qint64 offset ) THROW_SPEC( exSeekError, exWriteError ) throw exSeekError(); } -void Class::rewind() THROW_SPEC( exSeekError, exWriteError ) +void Class::rewind() { seek( 0 ); } -qint64 Class::tell() THROW_SPEC( exSeekError ) +qint64 Class::tell() { qint64 result = f.pos(); @@ -292,7 +292,7 @@ qint64 Class::tell() THROW_SPEC( exSeekError ) return result; } -bool Class::eof() THROW_SPEC( exWriteError ) +bool Class::eof() { if ( writeBuffer ) flushWriteBuffer(); @@ -300,14 +300,14 @@ bool Class::eof() THROW_SPEC( exWriteError ) return f.atEnd(); } -QFile & Class::file() THROW_SPEC( exWriteError ) +QFile & Class::file() { flushWriteBuffer(); return f; } -void Class::close() THROW_SPEC( exWriteError ) +void Class::close() { releaseWriteBuffer(); f.close(); @@ -328,7 +328,7 @@ Class::~Class() throw() } } -void Class::flushWriteBuffer() THROW_SPEC( exWriteError ) +void Class::flushWriteBuffer() { if ( writeBuffer && writeBufferLeft != WriteBufferSize ) { @@ -341,7 +341,7 @@ void Class::flushWriteBuffer() THROW_SPEC( exWriteError ) } } -void Class::releaseWriteBuffer() THROW_SPEC( exWriteError ) +void Class::releaseWriteBuffer() { flushWriteBuffer(); diff --git a/file.hh b/file.hh index 5bcd2ec1..81281647 100644 --- a/file.hh +++ b/file.hh @@ -8,7 +8,6 @@ #include #include #include -#include "cpp_features.hh" #include "ex.hh" /// A simple wrapper over FILE * operations with added write-buffering, @@ -42,29 +41,29 @@ class Class char * writeBuffer; qint64 writeBufferLeft; - void open( char const * filename, char const * mode ) THROW_SPEC( exCantOpen ); + void open( char const * filename, char const * mode ) ; public: - Class( char const * filename, char const * mode ) THROW_SPEC( exCantOpen ); + Class( char const * filename, char const * mode ) ; - Class( std::string const & filename, char const * mode ) THROW_SPEC( exCantOpen ); + Class( std::string const & filename, char const * mode ) ; /// Reads the number of bytes to the buffer, throws an error if it /// failed to fill the whole buffer (short read, i/o error etc). - void read( void * buf, qint64 size ) THROW_SPEC( exReadError, exWriteError ); + void read( void * buf, qint64 size ) ; template< typename T > - void read( T & value ) THROW_SPEC( exReadError, exWriteError ) + void read( T & value ) { read( &value, sizeof( value ) ); } template< typename T > - T read() THROW_SPEC( exReadError, exWriteError ) + T read() { T value; read( value ); return value; } /// Attempts reading at most 'count' records sized 'size'. Returns /// the number of records it managed to read, up to 'count'. - size_t readRecords( void * buf, qint64 size, size_t count ) THROW_SPEC( exWriteError ); + size_t readRecords( void * buf, qint64 size, size_t count ) ; /// Writes the number of bytes from the buffer, throws an error if it /// failed to write the whole buffer (short write, i/o error etc). @@ -72,10 +71,10 @@ public: /// end up on disk immediately, or a short write may occur later /// than it really did. If you don't want write buffering, use /// writeRecords() function instead. - void write( void const * buf, qint64 size ) THROW_SPEC( exWriteError, exAllocation ); + void write( void const * buf, qint64 size ) ; template< typename T > - void write( T const & value ) THROW_SPEC( exWriteError ) + void write( T const & value ) { write( &value, sizeof( value ) ); } /// Attempts writing at most 'count' records sized 'size'. Returns @@ -83,46 +82,46 @@ public: /// This function does not employ buffering, but flushes the buffer if it /// was used before. size_t writeRecords( void const * buf, qint64 size, size_t count ) - THROW_SPEC( exWriteError ); + ; /// Reads a string from the file. Unlike the normal fgets(), this one /// can strip the trailing newline character, if this was requested. /// Returns either s or 0 if no characters were read. - char * gets( char * s, int size, bool stripNl = false ) THROW_SPEC( exWriteError ); + char * gets( char * s, int size, bool stripNl = false ) ; /// Like the above, but uses its own local internal buffer (1024 bytes /// currently), and strips newlines by default. - std::string gets( bool stripNl = true ) THROW_SPEC( exReadError, exWriteError ); + std::string gets( bool stripNl = true ) ; /// Seeks in the file, relative to its beginning. - void seek( qint64 offset ) THROW_SPEC( exSeekError, exWriteError ); + void seek( qint64 offset ) ; /// Seeks in the file, relative to the current position. - void seekCur( qint64 offset ) THROW_SPEC( exSeekError, exWriteError ); + void seekCur( qint64 offset ) ; /// Seeks in the file, relative to the end of file. - void seekEnd( qint64 offset = 0 ) THROW_SPEC( exSeekError, exWriteError ); + void seekEnd( qint64 offset = 0 ) ; /// Seeks to the beginning of file - void rewind() THROW_SPEC( exSeekError, exWriteError ); + void rewind() ; /// Tells the current position within the file, relative to its beginning. - qint64 tell() THROW_SPEC( exSeekError ); + qint64 tell() ; /// Returns true if end-of-file condition is set. - bool eof() THROW_SPEC( exWriteError ); + bool eof() ; /// Returns the underlying FILE * record, so other operations can be /// performed on it. - QFile & file() THROW_SPEC( exWriteError ); + QFile & file() ; /// Closes the file. No further operations are valid. - void close() THROW_SPEC( exWriteError ); + void close() ; ~Class() throw(); private: - void flushWriteBuffer() THROW_SPEC( exWriteError ); - void releaseWriteBuffer() THROW_SPEC( exWriteError ); + void flushWriteBuffer() ; + void releaseWriteBuffer() ; }; } diff --git a/flags/folder.png b/flags/folder.png index fc6f17e9..1c5f38d5 100644 Binary files a/flags/folder.png and b/flags/folder.png differ diff --git a/folding.cc b/folding.cc index 2efab88c..6136b817 100644 --- a/folding.cc +++ b/folding.cc @@ -622,6 +622,8 @@ wstring trimWhitespaceOrPunct( wstring const & in ) wstring trimWhitespace( wstring const & in ) { + if( in.empty() ) + return in; wchar const * wordBegin = in.c_str(); wstring::size_type wordSize = in.size(); diff --git a/forvo.cc b/forvo.cc index 2014f93c..3488a085 100644 --- a/forvo.cc +++ b/forvo.cc @@ -55,7 +55,7 @@ public: { return 0; } virtual sptr< WordSearchRequest > prefixMatch( wstring const & /*word*/, - unsigned long /*maxResults*/ ) THROW_SPEC( std::exception ) + unsigned long /*maxResults*/ ) { sptr< WordSearchRequestInstant > sr = new WordSearchRequestInstant; @@ -66,7 +66,7 @@ public: virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ) - THROW_SPEC( std::exception ); + ; protected: @@ -77,7 +77,7 @@ protected: sptr< DataRequest > ForvoDictionary::getArticle( wstring const & word, vector< wstring > const & alts, wstring const &, bool ) - THROW_SPEC( std::exception ) + { if ( word.size() > 80 ) { @@ -347,7 +347,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Dictionary::Initializing &, Config::Forvo const & forvo, QNetworkAccessManager & mgr ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > result; diff --git a/forvo.hh b/forvo.hh index c9588ed6..0607ba79 100644 --- a/forvo.hh +++ b/forvo.hh @@ -21,7 +21,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Dictionary::Initializing &, Config::Forvo const &, QNetworkAccessManager & ) - THROW_SPEC( std::exception ); + ; /// Exposed here for moc class ForvoArticleRequest: public Dictionary::DataRequest diff --git a/ftshelpers.cc b/ftshelpers.cc index d3920b64..0d775282 100644 --- a/ftshelpers.cc +++ b/ftshelpers.cc @@ -71,10 +71,10 @@ bool parseSearchString( QString const & str, QStringList & indexWords, { searchWords.clear(); indexWords.clear(); - QRegExp spacesRegExp( "\\W+" ); - QRegExp wordRegExp( QString( "\\w{" ) + QString::number( FTS::MinimumWordSize ) + ",}" ); - QRegExp setsRegExp( "\\[[^\\]]+\\]", Qt::CaseInsensitive, QRegExp::RegExp2 ); - QRegExp regexRegExp( "\\\\[afnrtvdDwWsSbB]|\\\\x([0-9A-Fa-f]{4})|\\\\0([0-7]{3})", Qt::CaseSensitive, QRegExp::RegExp2 ); + QRegularExpression spacesRegExp( "\\W+" ); + QRegularExpression wordRegExp( QString( "\\w{" ) + QString::number( FTS::MinimumWordSize ) + ",}" ); + QRegularExpression setsRegExp( "\\[[^\\]]+\\]", QRegularExpression::CaseInsensitiveOption ); + QRegularExpression regexRegExp( "\\\\[afnrtvdDwWsSbB]|\\\\x([0-9A-Fa-f]{4})|\\\\0([0-7]{3})", QRegularExpression::CaseInsensitiveOption); hasCJK = false; for( int x = 0; x < str.size(); x++ ) diff --git a/ftshelpers.hh b/ftshelpers.hh index 0c3530aa..f8392d09 100644 --- a/ftshelpers.hh +++ b/ftshelpers.hh @@ -2,7 +2,11 @@ #define __FTSHELPERS_HH_INCLUDED__ #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #include #include diff --git a/fulltextsearch.cc b/fulltextsearch.cc index a7ad4595..02b24dce 100644 --- a/fulltextsearch.cc +++ b/fulltextsearch.cc @@ -17,6 +17,7 @@ #include "initializing.hh" #include #include +#include #endif @@ -248,8 +249,7 @@ FullTextSearchDialog::FullTextSearchDialog( QWidget * parent, oldBarStyle = 0; - if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA - && ( QSysInfo::windowsVersion() & QSysInfo::WV_NT_based ) + if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7 && !IsThemeActive() ) { QStyle * barStyle = WindowsStyle::instance().getStyle(); @@ -649,7 +649,7 @@ Q_UNUSED( parent ); for( int x = 0; x < hws.length(); x++ ) { - QList< FtsHeadword >::iterator it = qBinaryFind( headwords.begin(), headwords.end(), hws.at( x ) ); + QList< FtsHeadword >::iterator it = std::lower_bound( headwords.begin(), headwords.end(), hws.at( x ) ); if( it != headwords.end() ) { it->dictIDs.push_back( hws.at( x ).dictIDs.front() ); diff --git a/fulltextsearch.hh b/fulltextsearch.hh index 75586cf3..e588b3ae 100644 --- a/fulltextsearch.hh +++ b/fulltextsearch.hh @@ -3,7 +3,11 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #include #include diff --git a/gddebug.cc b/gddebug.cc index 57cd7ab1..df57aa5d 100644 --- a/gddebug.cc +++ b/gddebug.cc @@ -1,9 +1,13 @@ /* This file is (c) 2013 Abs62 * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ -#include #include #include "gddebug.hh" +#if(QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else +#include +#endif QFile * logFilePtr; static QTextCodec * utf8Codec; @@ -23,7 +27,7 @@ QTextCodec *localeCodec = 0; QTextCodec::setCodecForLocale( utf8Codec ); } - qWarning( "%s", QString().vsprintf( msg, ap ).toUtf8().data() ); + qWarning( "%s", QString().vasprintf( msg, ap ).toUtf8().data() ); if( logFilePtr && logFilePtr->isOpen() ) { @@ -48,7 +52,7 @@ QTextCodec *localeCodec = 0; QTextCodec::setCodecForLocale( utf8Codec ); } - qDebug( "%s", QString().vsprintf( msg, ap ).toUtf8().data() ); + qDebug( "%s", QString().vasprintf( msg, ap ).toUtf8().data() ); if( logFilePtr && logFilePtr->isOpen() ) { diff --git a/generators/Makefile b/generators/Makefile deleted file mode 100644 index 635ab062..00000000 --- a/generators/Makefile +++ /dev/null @@ -1,13 +0,0 @@ - -.PHONY: all clean - -all: ../inc_case_folding.hh ../inc_diacritic_folding.hh - -generate: generate.cc - c++ -W -Wall $< -o $@ - -../inc_case_folding.hh ../inc_diacritic_folding.hh: CaseFolding.txt DiacriticFolding.txt generate - ./generate - -clean: - rm -f generate diff --git a/german.cc b/german.cc index 402896c3..7caaadaf 100644 --- a/german.cc +++ b/german.cc @@ -40,7 +40,7 @@ GermanTable::GermanTable() } -sptr< Dictionary::Class > makeDictionary() THROW_SPEC( std::exception ) +sptr< Dictionary::Class > makeDictionary() { static GermanTable t; diff --git a/german.hh b/german.hh index d4c82d32..38afbe71 100644 --- a/german.hh +++ b/german.hh @@ -9,7 +9,7 @@ // Support for German transliteration namespace GermanTranslit { -sptr< Dictionary::Class > makeDictionary() THROW_SPEC( std::exception ); +sptr< Dictionary::Class > makeDictionary() ; } diff --git a/gls.cc b/gls.cc index d1fc2c13..3bc28fc1 100644 --- a/gls.cc +++ b/gls.cc @@ -32,7 +32,11 @@ #include #include - +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else +#include +#endif #include #include #include @@ -83,7 +87,7 @@ public: DEF_EX_STR( exMalformedGlsFile, "The .gls file is malformed:", Ex ) DEF_EX( exEncodingError, "Encoding error", Ex ) // Should never happen really - GlsScanner( string const & fileName ) THROW_SPEC( Ex, Iconv::Ex ); + GlsScanner( string const & fileName ) ; ~GlsScanner() throw(); /// Returns the detected encoding of this file. @@ -116,13 +120,13 @@ public: /// If end of file is reached, false is returned. /// Reading begins from the first line after the headers (ones which end /// by the "### Glossary section:" line). - bool readNextLine( wstring &, size_t & offset ) THROW_SPEC( Ex, Iconv::Ex ); + bool readNextLine( wstring &, size_t & offset ) ; /// Returns the number of lines read so far from the file. unsigned getLinesRead() const { return linesRead; } }; -GlsScanner::GlsScanner( string const & fileName ) THROW_SPEC( Ex, Iconv::Ex ): +GlsScanner::GlsScanner( string const & fileName ) : encoding( Utf8::Utf8 ), readBufferPtr( readBuffer ), readBufferLeft( 0 ), linesRead( 0 ) { @@ -179,13 +183,13 @@ GlsScanner::GlsScanner( string const & fileName ) THROW_SPEC( Ex, Iconv::Ex ): wstring str; wstring *currentField = 0; - wstring mark = GD_NATIVE_TO_WS( L"###" ); - wstring titleMark = GD_NATIVE_TO_WS( L"### Glossary title:" ); - wstring authorMark = GD_NATIVE_TO_WS( L"### Author:" ); - wstring descriptionMark = GD_NATIVE_TO_WS( L"### Description:" ); - wstring langFromMark = GD_NATIVE_TO_WS( L"### Source language:" ); - wstring langToMark = GD_NATIVE_TO_WS( L"### Target language:" ); - wstring endOfHeaderMark = GD_NATIVE_TO_WS( L"### Glossary section:" ); + wstring mark = U"###" ; + wstring titleMark = U"### Glossary title:" ; + wstring authorMark = U"### Author:" ; + wstring descriptionMark = U"### Description:" ; + wstring langFromMark = U"### Source language:" ; + wstring langToMark = U"### Target language:" ; + wstring endOfHeaderMark = U"### Glossary section:" ; size_t offset; for( ; ; ) @@ -242,8 +246,7 @@ GlsScanner::GlsScanner( string const & fileName ) THROW_SPEC( Ex, Iconv::Ex ): } } -bool GlsScanner::readNextLine( wstring & out, size_t & offset ) THROW_SPEC( Ex, - Iconv::Ex ) +bool GlsScanner::readNextLine( wstring & out, size_t & offset ) { offset = (size_t)(gztell(f) - readBufferLeft); @@ -285,13 +288,8 @@ bool GlsScanner::readNextLine( wstring & out, size_t & offset ) THROW_SPEC( Ex, readBufferPtr += pos; linesRead++; -#ifdef __WIN32 - out = line.toStdU32String(); -#else - out = line.toStdWString(); -#endif - return true; - + out = line.toStdU32String(); + return true; } } @@ -393,16 +391,16 @@ public: { return idxHeader.langTo; } virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; virtual QString const& getDescription(); @@ -766,7 +764,7 @@ QString & GlsDictionary::filterResource( QString & article ) while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewText += article.midRef( pos, match.capturedStart() - pos ); + articleNewText += article.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString link = match.captured( 3 ); @@ -798,7 +796,7 @@ QString & GlsDictionary::filterResource( QString & article ) } if( pos ) { - articleNewText += article.midRef( pos ); + articleNewText += article.mid( pos ); article = articleNewText; articleNewText.clear(); } @@ -817,7 +815,7 @@ QString & GlsDictionary::filterResource( QString & article ) while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewText += article.midRef( pos, match.capturedStart() - pos ); + articleNewText += article.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString src = match.captured( 2 ); @@ -838,7 +836,7 @@ QString & GlsDictionary::filterResource( QString & article ) } if( pos ) { - articleNewText += article.midRef( pos ); + articleNewText += article.mid( pos ); article = articleNewText; articleNewText.clear(); } @@ -979,7 +977,7 @@ void GlsHeadwordsRequest::run() sptr< Dictionary::WordSearchRequest > GlsDictionary::findHeadwordsForSynonym( wstring const & word ) - THROW_SPEC( std::exception ) + { return synonymSearchEnabled ? new GlsHeadwordsRequest( word, *this ) : Class::findHeadwordsForSynonym( word ); @@ -1161,7 +1159,7 @@ sptr< Dictionary::DataRequest > GlsDictionary::getArticle( wstring const & word, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new GlsArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -1337,7 +1335,7 @@ void GlsResourceRequest::run() while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - newCSS += css.midRef( pos, match.capturedStart() - pos ); + newCSS += css.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString url = match.captured( 2 ); @@ -1355,7 +1353,7 @@ void GlsResourceRequest::run() } if( pos ) { - newCSS += css.midRef( pos ); + newCSS += css.mid( pos ); css = newCSS; newCSS.clear(); } @@ -1380,7 +1378,7 @@ void GlsResourceRequest::run() } sptr< Dictionary::DataRequest > GlsDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { return new GlsResourceRequest( *this, name ); } @@ -1403,7 +1401,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/gls.hh b/gls.hh index 6b96e9be..b022d094 100644 --- a/gls.hh +++ b/gls.hh @@ -13,7 +13,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; } diff --git a/goldendict.pro b/goldendict.pro index 04530b7e..9e3f4c71 100644 --- a/goldendict.pro +++ b/goldendict.pro @@ -1,18 +1,18 @@ TEMPLATE = app TARGET = goldendict -VERSION = 1.5.0-RC2+git +VERSION = 22.4.Summer # Generate version file. We do this here and in a build rule described later. # The build rule is required since qmake isn't run each time the project is # rebuilt; and doing it here is required too since any other way the RCC # compiler would complain if version.txt wouldn't exist (fresh checkouts). -system(git describe --tags --always --dirty > version.txt): hasGit=1 +system(git describe --tags --always --dirty): hasGit=1 -isEmpty( hasGit ) { - message(Failed to precisely describe the version via Git -- using the default version string) - system(echo $$VERSION > version.txt) +!isEmpty(hasGit){ + GIT_HASH=$$system(git rev-parse --short=8 HEAD ) } +system(echo $${VERSION}.$${GIT_HASH} > version.txt) # DEPENDPATH += . generators INCLUDEPATH += . @@ -21,21 +21,23 @@ QT += core \ gui \ xml \ network \ - svg - -QT += widgets \ + svg \ + widgets \ webenginewidgets\ webchannel\ printsupport \ help +greaterThan(QT_MAJOR_VERSION, 5): QT += webenginecore core5compat + +DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x050F00 + # QMediaPlayer is not available in Qt4. !CONFIG( no_qtmultimedia_player ) { QT += multimedia DEFINES += MAKE_QTMULTIMEDIA_PLAYER } - !CONFIG( no_ffmpeg_player ) { DEFINES += MAKE_FFMPEG_PLAYER } @@ -43,24 +45,32 @@ QT += widgets \ QT += sql CONFIG += exceptions \ rtti \ - stl - # lrelease #lrelease generate qm under target folder. - -QM_FILES_INSTALL_PATH = /locale/ + stl \ + c++14 \ + lrelease \ + embed_translations + +mac { + DEBUG:CONFIG += app_bundle +} + +QM_FILES_RESOURCE_PREFIX = /locale/ OBJECTS_DIR = build UI_DIR = build MOC_DIR = build -RCC_DIR = build +#RCC_DIR = build LIBS += \ -lz \ -lbz2 \ -llzo2 +CONFIG+=utf8_source + win32 { TARGET = GoldenDict win32-msvc* { - VERSION = 1.5.0 # More complicated things cause errors during compilation under MSVC++ + VERSION = 22.4.1 # VS does not recognize 22.2.xxx,cause errors during compilation under MSVC++ DEFINES += __WIN32 _CRT_SECURE_NO_WARNINGS contains(QMAKE_TARGET.arch, x86_64) { DEFINES += NOMINMAX __WIN64 @@ -76,8 +86,7 @@ win32 { HUNSPELL_LIB = hunspell } - LIBS += -liconv \ - -lwsock32 \ + LIBS += -lwsock32 \ -lpsapi \ -lole32 \ -loleaut32 \ @@ -94,8 +103,7 @@ win32 { -lavcodec } - - RC_FILE = goldendict.rc + RC_ICONS += icons/programicon.ico icons/programicon_old.ico INCLUDEPATH += winlibs/include # Enable console in Debug mode on Windows, with useful logging messages @@ -105,8 +113,6 @@ win32 { gcc48:QMAKE_CXXFLAGS += -Wno-unused-local-typedefs - CONFIG += zim_support - !CONFIG( no_chinese_conversion_support ) { CONFIG += chinese_conversion_support } @@ -115,14 +121,13 @@ win32 { } unix:!mac { - DEFINES += HAVE_X11 - # This is to keep symbols for backtraces - QMAKE_CXXFLAGS += -rdynamic - QMAKE_LFLAGS += -rdynamic + DEFINES += HAVE_X11 - QT += x11extras + lessThan(QT_MAJOR_VERSION, 6): QT += x11extras + greaterThan(QT_MAJOR_VERSION, 5): QT += gui-private CONFIG += link_pkgconfig + PKGCONFIG += vorbisfile \ vorbis \ ogg \ @@ -135,7 +140,7 @@ unix:!mac { libswresample \ } arm { - LIBS += -liconv + #LIBS += -liconv } else { LIBS += -lX11 -lXtst } @@ -168,7 +173,7 @@ unix:!mac { INSTALLS += helps } freebsd { - LIBS += -liconv -lexecinfo + LIBS += -lexecinfo } mac { TARGET = GoldenDict @@ -178,52 +183,44 @@ mac { # CONFIG += x86 x86_64 ppc LIBS = -lz \ -lbz2 \ - -liconv \ -lvorbisfile \ -lvorbis \ -logg \ - -lhunspell-1.6.1 \ + -lhunspell-1.7.0 \ -llzo2 !CONFIG( no_ffmpeg_player ) { LIBS += -lao \ - -lswresample-gd \ - -lavutil-gd \ - -lavformat-gd \ - -lavcodec-gd + -lswresample \ + -lavutil \ + -lavformat \ + -lavcodec } - INCLUDEPATH = $${PWD}/maclibs/include - LIBS += -L$${PWD}/maclibs/lib -framework AppKit -framework Carbon + QT_CONFIG -= no-pkg-config + CONFIG += link_pkgconfig + INCLUDEPATH = /opt/homebrew/include /usr/local/include + LIBS += -L/opt/homebrew/lib -L/usr/local/lib -framework AppKit -framework Carbon OBJECTIVE_SOURCES += lionsupport.mm \ machotkeywrapper.mm \ macmouseover.mm \ speechclient_mac.mm ICON = icons/macicon.icns QMAKE_INFO_PLIST = myInfo.plist - QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks & \ - cp -nR $${PWD}/maclibs/lib/ GoldenDict.app/Contents/Frameworks/ & \ - mkdir -p GoldenDict.app/Contents/MacOS/locale & \ - cp -R locale/*.qm GoldenDict.app/Contents/MacOS/locale/ & \ - mkdir -p GoldenDict.app/Contents/MacOS/help & \ + QMAKE_POST_LINK = mkdir -p GoldenDict.app/Contents/Frameworks && \ + mkdir -p GoldenDict.app/Contents/MacOS/help && \ cp -R $${PWD}/help/*.qch GoldenDict.app/Contents/MacOS/help/ CONFIG += zim_support !CONFIG( no_chinese_conversion_support ) { CONFIG += chinese_conversion_support - CONFIG( x86 ) { - QMAKE_POST_LINK += & mkdir -p GoldenDict.app/Contents/MacOS/opencc & \ - cp -R $${PWD}/opencc/*.json GoldenDict.app/Contents/MacOS/opencc/ & \ - cp -R $${PWD}/opencc/*.ocd GoldenDict.app/Contents/MacOS/opencc/ - } else { - QMAKE_POST_LINK += & mkdir -p GoldenDict.app/Contents/MacOS/opencc & \ - cp -R $${PWD}/opencc/x64/*.json GoldenDict.app/Contents/MacOS/opencc/ & \ - cp -R $${PWD}/opencc/x64/*.ocd GoldenDict.app/Contents/MacOS/opencc/ - } + QMAKE_POST_LINK += && mkdir -p GoldenDict.app/Contents/MacOS/opencc && \ + cp -R $${PWD}/opencc/*.* GoldenDict.app/Contents/MacOS/opencc/ } } DEFINES += PROGRAM_VERSION=\\\"$$VERSION\\\" # Input HEADERS += folding.hh \ + article_inspect.h \ globalbroadcaster.h \ inc_case_folding.hh \ inc_diacritic_folding.hh \ @@ -268,7 +265,6 @@ HEADERS += folding.hh \ wordfinder.hh \ groupcombobox.hh \ keyboardstate.hh \ - mouseover.hh \ preferences.hh \ mutex.hh \ mediawiki.hh \ @@ -345,7 +341,6 @@ HEADERS += folding.hh \ gls.hh \ splitfile.hh \ favoritespanewidget.hh \ - cpp_features.hh \ treeview.hh FORMS += groups.ui \ @@ -365,6 +360,7 @@ FORMS += groups.ui \ fulltextsearch.ui SOURCES += folding.cc \ + article_inspect.cpp \ globalbroadcaster.cpp \ main.cc \ dictionary.cc \ @@ -404,7 +400,6 @@ SOURCES += folding.cc \ wordfinder.cc \ groupcombobox.cc \ keyboardstate.cc \ - mouseover.cc \ preferences.cc \ mutex.cc \ mediawiki.cc \ @@ -412,7 +407,6 @@ SOURCES += folding.cc \ hunspell.cc \ dictdfiles.cc \ audiolink.cc \ - wstring.cc \ wstring_qt.cc \ processwrapper.cc \ hotkeywrapper.cc \ @@ -484,19 +478,16 @@ win32 { FORMS += texttospeechsource.ui SOURCES += wordbyauto.cc \ guids.c \ - x64.cc \ speechclient_win.cc \ texttospeechsource.cc \ speechhlp.cc HEADERS += wordbyauto.hh \ uiauto.hh \ - x64.hh \ texttospeechsource.hh \ sapi.hh \ sphelper.hh \ speechclient.hh \ - speechhlp.hh \ - hotkeys.h + speechhlp.hh } mac { @@ -549,20 +540,12 @@ CONFIG( chinese_conversion_support ) { chineseconversion.hh SOURCES += chinese.cc \ chineseconversion.cc - win32-msvc* { - Debug: LIBS += -lopenccd - Release: LIBS += -lopencc - } else { - mac { - LIBS += -lopencc.2 - } else { - LIBS += -lopencc - } - } + LIBS += -lopencc } RESOURCES += resources.qrc \ flags.qrc +#EXTRA_TRANSLATIONS += thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts TRANSLATIONS += locale/ru_RU.ts \ locale/zh_CN.ts \ locale/cs_CZ.ts \ @@ -605,50 +588,10 @@ TRANSLATIONS += locale/ru_RU.ts \ # Build version file !isEmpty( hasGit ) { - QMAKE_EXTRA_TARGETS += revtarget PRE_TARGETDEPS += $$PWD/version.txt - revtarget.target = $$PWD/version.txt - - !win32 { - revtarget.commands = cd $$PWD; git describe --tags --always --dirty > $$revtarget.target - } else { - revtarget.commands = git --git-dir=\"$$PWD/.git\" describe --tags --always --dirty > $$revtarget.target - } - - ALL_SOURCES = $$SOURCES $$HEADERS $$FORMS - for(src, ALL_SOURCES) { - QUALIFIED_SOURCES += $${PWD}/$${src} - } - revtarget.depends = $$QUALIFIED_SOURCES } -# This makes qmake generate translations -isEmpty(QMAKE_LRELEASE):QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease - - -# The *.qm files might not exist when qmake is run for the first time, -# causing the standard install rule to be ignored, and no translations -# will be installed. With this, we create the qm files during qmake run. -!win32 { - system($${QMAKE_LRELEASE} -silent $${_PRO_FILE_} 2> /dev/null) -} -else{ - system($${QMAKE_LRELEASE} -silent $${_PRO_FILE_}) -} - -updateqm.input = TRANSLATIONS -updateqm.output = locale/${QMAKE_FILE_BASE}.qm -updateqm.commands = $$QMAKE_LRELEASE \ - ${QMAKE_FILE_IN} \ - -qm \ - ${QMAKE_FILE_OUT} -updateqm.CONFIG += no_link -QMAKE_EXTRA_COMPILERS += updateqm -TS_OUT = $$TRANSLATIONS -TS_OUT ~= s/.ts/.qm/g -PRE_TARGETDEPS += $$TS_OUT - -include( qtsingleapplication/src/qtsingleapplication.pri ) +include( thirdparty/qtsingleapplication/src/qtsingleapplication.pri ) diff --git a/goldendict.rc b/goldendict.rc deleted file mode 100644 index f6fbce0c..00000000 --- a/goldendict.rc +++ /dev/null @@ -1,39 +0,0 @@ -#include "windows.h" - -IDI_ICON1 ICON DISCARDABLE "icons/programicon.ico" -IDI_ICON2 ICON DISCARDABLE "icons/programicon_old.ico" -#define GOLDENDICT_VER 1,5,0,0 -#define GOLDENDICT_VER_STR "1.5.0" - -#if !defined( _MSC_VER ) && !defined( GD_NO_MANIFEST ) // Visual Studio embeds the manifest automatically -1 RT_MANIFEST GoldenDict.exe.manifest -#endif - -1 VERSIONINFO - FILEVERSION GOLDENDICT_VER - PRODUCTVERSION GOLDENDICT_VER - FILEFLAGS 0x0L - FILEFLAGSMASK 0x3fL - FILEOS 0x00040004L - FILETYPE 0x1L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "000004b0" - BEGIN - VALUE "CompanyName", "GoldenDict" - VALUE "FileDescription", "GoldenDict dictionary lookup program" - VALUE "FileVersion", GOLDENDICT_VER_STR - VALUE "LegalCopyright", "www.goldendict.org" - VALUE "InternalName", "goldendict" - VALUE "OriginalFilename", "goldendict.exe" - VALUE "ProductName", "GoldenDict" - VALUE "ProductVersion", GOLDENDICT_VER_STR - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x0, 1200 - END -END diff --git a/greektranslit.cc b/greektranslit.cc index 2533513c..8f4f8dc4 100644 --- a/greektranslit.cc +++ b/greektranslit.cc @@ -831,7 +831,7 @@ GreekTable::GreekTable() } -sptr< Dictionary::Class > makeDictionary() THROW_SPEC( std::exception ) +sptr< Dictionary::Class > makeDictionary() { static GreekTable t; diff --git a/greektranslit.hh b/greektranslit.hh index 9f0d125b..184f4220 100644 --- a/greektranslit.hh +++ b/greektranslit.hh @@ -9,7 +9,7 @@ // Support for Greek transliteration namespace GreekTranslit { -sptr< Dictionary::Class > makeDictionary() THROW_SPEC( std::exception ); +sptr< Dictionary::Class > makeDictionary() ; } diff --git a/groups.cc b/groups.cc index d9514bd0..d36b9520 100644 --- a/groups.cc +++ b/groups.cc @@ -20,7 +20,7 @@ Groups::Groups( QWidget * parent, // Populate the dictionaries' list ui.dictionaries->setAsSource(); - ui.dictionaries->populate( Instances::Group( order, dicts, Config::Group() ).dictionaries, + ui.dictionaries->populate( Instances::Group( order, Dictionary::dictToMap(dicts), Config::Group() ).dictionaries, dicts ); ui.searchLine->applyTo( ui.dictionaries ); @@ -87,14 +87,13 @@ void Groups::editGroup( unsigned id ) void Groups::updateDictionaryOrder( Config::Group const & order ) { // Make sure it differs from what we have + auto dictMap = Dictionary::dictToMap( dicts ); + Instances::Group newOrder( order, dictMap, Config::Group() ); - Instances::Group newOrder( order, dicts, Config::Group() ); - - if ( ui.dictionaries->getCurrentDictionaries() != newOrder.dictionaries ) + if( ui.dictionaries->getCurrentDictionaries() != newOrder.dictionaries ) { // Repopulate - ui.dictionaries->populate( Instances::Group( order, dicts, Config::Group() ).dictionaries, - dicts ); + ui.dictionaries->populate( Instances::Group( order, dictMap, Config::Group() ).dictionaries, dicts ); } } diff --git a/groups_widgets.cc b/groups_widgets.cc index ef9079a4..f1142d0b 100644 --- a/groups_widgets.cc +++ b/groups_widgets.cc @@ -31,7 +31,8 @@ DictGroupWidget::DictGroupWidget( QWidget * parent, groupId( group.id ) { ui.setupUi( this ); - ui.dictionaries->populate( Instances::Group( group, dicts, Config::Group() ).dictionaries, dicts ); + auto dictMap = Dictionary::dictToMap(dicts); + ui.dictionaries->populate( Instances::Group( group, dictMap, Config::Group() ).dictionaries, dicts ); // Populate icons' list @@ -260,7 +261,7 @@ QVariant DictListModel::data( QModelIndex const & index, int role ) const case Qt::DecorationRole: // make all icons of the same size to avoid visual size/alignment problems - return item->getIcon().pixmap( 32 ).scaledToHeight( 21, Qt::SmoothTransformation ); + return item->getIcon(); default:; } @@ -328,7 +329,7 @@ bool DictListModel::setData( QModelIndex const & index, const QVariant & value, g.dictionaries.push_back( Config::DictionaryRef( value.toString(), QString() ) ); - Instances::Group i( g, *allDicts, Config::Group() ); + Instances::Group i( g, Dictionary::dictToMap(*allDicts), Config::Group() ); if ( i.dictionaries.size() == 1 ) { @@ -584,8 +585,7 @@ void DictGroupsWidget::populate( Config::Groups const & groups, { DictGroupWidget *gr = new DictGroupWidget( this, *allDicts, groups[ x ] ); addTab( gr, escapeAmps( groups[ x ].name ) ); - connect( gr, SIGNAL( showDictionaryInfo( QString const & ) ), - this, SIGNAL( showDictionaryInfo( QString const & ) ) ); + connect( gr, &DictGroupWidget::showDictionaryInfo,this, &DictGroupsWidget::showDictionaryInfo ); connect( gr->getModel(), SIGNAL( contentChanged() ), this, SLOT( tabDataChanged() ) ); setCurrentIndex( x ); @@ -744,8 +744,8 @@ void DictGroupsWidget::addAutoGroups() dictMap[ name ] = vd; } - QStringList groupList = dictMap.uniqueKeys(); - QStringList morphoList = morphoMap.uniqueKeys(); + QStringList groupList = dictMap.keys(); + QStringList morphoList = morphoMap.keys(); // Insert morphology dictionaries into corresponding lists diff --git a/helpwindow.cc b/helpwindow.cc index 9652fb7f..fb81d04d 100644 --- a/helpwindow.cc +++ b/helpwindow.cc @@ -11,6 +11,7 @@ #include "helpwindow.hh" #include "gddebug.hh" +#include namespace Help { @@ -25,9 +26,11 @@ void HelpBrowser::showHelpForKeyword( QString const & id ) { if ( helpEngine ) { - QMap< QString, QUrl > links = helpEngine->linksForIdentifier( id ); - if( !links.isEmpty() ) - setSource( links.constBegin().value() ); + QList links = helpEngine->documentsForIdentifier(id); + if (!links.isEmpty()) { + QHelpLink link=links.constFirst(); + setSource(link.url); + } } } @@ -251,7 +254,7 @@ void HelpWindow::applyZoomFactor() zoomInAction->setEnabled( cfg.preferences.helpZoomFactor < 5 ); zoomOutAction->setEnabled( cfg.preferences.helpZoomFactor > 0.2 ); - zoomBaseAction->setEnabled( cfg.preferences.helpZoomFactor != 1.0 ); + zoomBaseAction->setEnabled( !qFuzzyCompare(cfg.preferences.helpZoomFactor, 1.0) ); if( fontSize > 0 ) { diff --git a/hotkeyedit.cc b/hotkeyedit.cc index cf255dde..6ba4f27d 100644 --- a/hotkeyedit.cc +++ b/hotkeyedit.cc @@ -87,7 +87,7 @@ void HotKeyEdit::keyPressEvent( QKeyEvent * event ) // Delete current combo currentKey1 = 0; currentKey2 = 0; - currentModifiers = 0; + currentModifiers = Qt::NoModifier; continuingCombo = false; } else diff --git a/hotkeys.c b/hotkeys.c deleted file mode 100644 index bdc0c52d..00000000 --- a/hotkeys.c +++ /dev/null @@ -1,211 +0,0 @@ -#include -#include "hotkeys.h" -#include "stdio.h" - -static LRESULT CALLBACK lowLevelKeyboardProc(int, WPARAM, LPARAM); - -// Max number of hotkeys -#define MAX_HOTKEYS 5 - -// Max time interval between first and second part of hotkey (ms) -#define MAX_KEYS_TIME_INTERVAL 500 - -static HINSTANCE hInstance; -static HWND hGDWindow; -static HHOOK hKbdHook; - -typedef struct HotkeyStruct -{ - DWORD key1; - DWORD key2; - DWORD mods; - DWORD lasttime; -} HotkeyStruct; - -static HotkeyStruct hotkeys[ MAX_HOTKEYS ]; - -__declspec (dllexport) void removeHook() -{ - if( hKbdHook ) - { - UnhookWindowsHookEx( hKbdHook ); - hKbdHook = 0; - } -} - -__declspec (dllexport) BOOL setHook( HWND hwnd ) -{ - hGDWindow = hwnd; - removeHook(); - hKbdHook = SetWindowsHookEx( WH_KEYBOARD_LL, lowLevelKeyboardProc, hInstance, 0 ); - return hKbdHook != 0; -} - -__declspec (dllexport) BOOL setHotkeys( DWORD key1, DWORD key2, DWORD modifiers, int nom ) -{ - if( nom < 0 || nom >= MAX_HOTKEYS ) - return FALSE; - hotkeys[ nom ].key1 = key1; - hotkeys[ nom ].key2 = key2; - hotkeys[ nom ].mods = modifiers; - hotkeys[ nom ].lasttime = 0; - return TRUE; -} - -__declspec (dllexport) void clearHotkeys() -{ - int i; - for( i = 0; i < MAX_HOTKEYS; i++ ) - memset( hotkeys + i, 0, sizeof( HotkeyStruct ) ); -} - -static BOOL isModifiersPressed( DWORD modifiers ) -{ - int n = GetAsyncKeyState( VK_MENU ) & 0x8000; - if( ( ( modifiers & MOD_ALT ) && n == 0 ) - || ( ( modifiers & MOD_ALT ) == 0 && n ) ) - return FALSE; - - n = GetAsyncKeyState( VK_SHIFT ) & 0x8000; - if( ( ( modifiers & MOD_SHIFT ) && n == 0 ) - || ( ( modifiers & MOD_SHIFT ) == 0 && n ) ) - return FALSE; - - n = GetAsyncKeyState( VK_CONTROL ) & 0x8000; - if( ( ( modifiers & MOD_CONTROL ) && n == 0 ) - || ( ( modifiers & MOD_CONTROL ) == 0 && n ) ) - return FALSE; - - n = ( GetAsyncKeyState( VK_LWIN ) & 0x8000 ) | ( GetAsyncKeyState( VK_RWIN ) & 0x8000 ); - if( ( ( modifiers & MOD_WIN ) && n == 0 ) - || ( ( modifiers & MOD_WIN ) == 0 && n ) ) - return FALSE; - - return TRUE; -} - -static LRESULT CALLBACK lowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) -{ -int i; -PKBDLLHOOKSTRUCT p; -BOOL stop = FALSE; - - if ( nCode < 0 ) return CallNextHookEx( hKbdHook, nCode, wParam, lParam ); - - if( nCode == HC_ACTION ) - { - p = (PKBDLLHOOKSTRUCT)lParam; - - for( ; ; ) - { - // Check hotkeys - - if( wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN ) - { - DWORD new_time = GetTickCount(); - - // Check if key is second part of hotkey - - for( i = 0; i < MAX_HOTKEYS; i++ ) - { - if( hotkeys[ i ].key1 == 0 ) - break; - if( hotkeys[ i ].key2 == 0 || hotkeys[ i ].lasttime == 0 ) - continue; - if( hotkeys[ i ].key2 == p->vkCode && isModifiersPressed( hotkeys[ i ].mods ) ) - { - if( new_time - hotkeys[ i ].lasttime <= MAX_KEYS_TIME_INTERVAL ) - { - // Hotkey completed - // Clear all flags for first part - - int j; - for( j = 0; j < MAX_HOTKEYS; j++ ) - hotkeys[ j ].lasttime = 0; - - PostMessage( hGDWindow, GD_HOTKEY_MESSAGE, (WPARAM)i, 0 ); - - stop = TRUE; - break; - } - else - { - // Interval exceeded, reset time - hotkeys[ i ].lasttime = new_time; - continue; - } - } - else - { - // Key is not second part, clear flag - hotkeys[ i ].lasttime = 0; - } - } - if( stop ) - break; - - // Check if key is first part of hotkey - - for( i = 0; i < MAX_HOTKEYS; i++ ) - { - if( hotkeys[ i ].key1 == 0 ) - break; - if( hotkeys[ i ].key1 == p->vkCode && isModifiersPressed( hotkeys[ i ].mods ) ) - { - // Match found - if( hotkeys[ i ].key2 == 0 ) - { - // No second part, hotkey completed - - // Clear all flags for first part - int j; - for( j = 0; j < MAX_HOTKEYS; j++ ) - hotkeys[ j ].lasttime = 0; - - PostMessage( hGDWindow, GD_HOTKEY_MESSAGE, (WPARAM)i, 0 ); - - stop = TRUE; - break; - } - else - { - // First part detected, need wait for second part - hotkeys[ i ].lasttime = new_time; - break; - } - } - } - } - break; - } - } - - LRESULT result = CallNextHookEx(hKbdHook, nCode, wParam, lParam); - return ( stop ? 1 : result ); -} - -BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , - DWORD reason /* Reason this function is being called. */ , - LPVOID reserved /* Not used. */ ) -{ -(void) reserved; - switch (reason) - { - case DLL_PROCESS_ATTACH: - hInstance = hInst; - break; - - case DLL_PROCESS_DETACH: - removeHook(); - break; - - case DLL_THREAD_ATTACH: - break; - - case DLL_THREAD_DETACH: - break; - } - - /* Returns TRUE on success, FALSE on failure */ - return TRUE; -} diff --git a/hotkeys.h b/hotkeys.h deleted file mode 100644 index 24f96b8e..00000000 --- a/hotkeys.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __HOTKEYS_H_INCLUDED__ -#define __HOTKEYS_H_INCLUDED__ - -#include - -// Message if hotkey completed; WPARAM - hotkey number -#define GD_HOTKEY_MESSAGE ( WM_APP + 1 ) - -typedef BOOL ( *setHookProc )( HWND hwnd ); -typedef void ( *removeHookProc )(); -typedef BOOL ( *setHotkeysProc )( DWORD, DWORD, DWORD, int ); -typedef void ( *clearHotkeysProc )(); - -#endif // __HOTKEYS_H_INCLUDED__ diff --git a/hotkeys.pro b/hotkeys.pro deleted file mode 100644 index 4cd4ffd6..00000000 --- a/hotkeys.pro +++ /dev/null @@ -1,22 +0,0 @@ -#------------------------------------------------- -# -# DLL for global hotkeys handling -# Should be build for Windows only -# Place GdHotkey.dll beside GoldenDict.exe -# -#------------------------------------------------- - -win32 { - QT -= core gui - - TARGET = GdHotkeys - TEMPLATE = lib - - DEFINES += HOTKEYS_LIBRARY - - SOURCES += \ - hotkeys.c - - HEADERS += \ - hotkeys.h \ -} diff --git a/hotkeywrapper.cc b/hotkeywrapper.cc index c9481982..c942253c 100644 --- a/hotkeywrapper.cc +++ b/hotkeywrapper.cc @@ -108,25 +108,7 @@ HotkeyWrapper::HotkeyWrapper(QObject *parent) : QThread( parent ), #ifdef Q_OS_WIN hwnd=(HWND)((static_cast(parent))->winId()); - dllHandler.hDLLHandle = LoadLibraryA( "GdHotkeys.dll" ); - if( dllHandler.hDLLHandle ) - { - dllHandler.setHook = ( setHookProc )GetProcAddress( dllHandler.hDLLHandle, "setHook" ); - dllHandler.removeHook = ( removeHookProc )GetProcAddress( dllHandler.hDLLHandle, "removeHook" ); - dllHandler.setHotkeys = ( setHotkeysProc )GetProcAddress( dllHandler.hDLLHandle, "setHotkeys" ); - dllHandler.clearHotkeys = ( clearHotkeysProc )GetProcAddress( dllHandler.hDLLHandle, "clearHotkeys" ); - - if( !dllHandler.setHook || !dllHandler.removeHook || !dllHandler.setHotkeys || !dllHandler.clearHotkeys ) - { - FreeLibrary( dllHandler.hDLLHandle ); - dllHandler.hDLLHandle = 0; - } - } - - if( dllHandler.hDLLHandle ) - gdWarning( "Handle global hotkeys via GdHotkeys.dll" ); - else - gdWarning( "Handle global hotkeys via RegisterHotkey()" ); + gdWarning( "Handle global hotkeys via RegisterHotkey()" ); #else init(); @@ -137,10 +119,6 @@ HotkeyWrapper::HotkeyWrapper(QObject *parent) : QThread( parent ), HotkeyWrapper::~HotkeyWrapper() { unregister(); -#ifdef Q_OS_WIN32 - if( dllHandler.hDLLHandle ) - FreeLibrary( dllHandler.hDLLHandle ); -#endif } void HotkeyWrapper::waitKey2() @@ -330,14 +308,6 @@ bool HotkeyWrapper::setGlobalKey( int key, int key2, hotkeys.append( HotkeyStruct( vk, vk2, mod, handle, id ) ); - if( dllHandler.hDLLHandle ) - { - dllHandler.removeHook(); - dllHandler.setHotkeys( vk, vk2, mod, hotkeys.size() - 1 ); - dllHandler.setHook( hwnd ); - return true; - } - if (!RegisterHotKey(hwnd, id++, mod, vk)) return false; @@ -347,20 +317,16 @@ bool HotkeyWrapper::setGlobalKey( int key, int key2, return true; } +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) bool HotkeyWrapper::winEvent ( MSG * message, long * result ) +#else +bool HotkeyWrapper::winEvent ( MSG * message, qintptr * result ) +#endif { (void) result; if (message->message == WM_HOTKEY) return checkState( (message->lParam >> 16), (message->lParam & 0xffff) ); - if( message->message == GD_HOTKEY_MESSAGE ) - { - int n = (int)message->wParam; - if( n < hotkeys.size() && n >= 0 ) - emit hotkeyActivated( hotkeys.at( n ).handle ); - return true; - } - return false; } @@ -457,32 +423,28 @@ quint32 HotkeyWrapper::nativeKey(int key) void HotkeyWrapper::unregister() { - if( dllHandler.hDLLHandle ) + for( int i = 0; i < hotkeys.count(); i++ ) { - dllHandler.removeHook(); - dllHandler.clearHotkeys(); - } - else - { - for (int i = 0; i < hotkeys.count(); i++) - { - HotkeyStruct const & hk = hotkeys.at( i ); + HotkeyStruct const & hk = hotkeys.at( i ); - UnregisterHotKey( hwnd, hk.id ); + UnregisterHotKey( hwnd, hk.id ); - if ( hk.key2 && hk.key2 != hk.key ) - UnregisterHotKey( hwnd, hk.id+1 ); - } + if( hk.key2 && hk.key2 != hk.key ) + UnregisterHotKey( hwnd, hk.id + 1 ); } (static_cast(qApp))->unregisterWrapper(this); } +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) bool QHotkeyApplication::nativeEventFilter( const QByteArray & /*eventType*/, void * message, long * result ) +#else +bool QHotkeyApplication::nativeEventFilter( const QByteArray & /*eventType*/, void * message, qintptr * result ) +#endif { MSG * msg = reinterpret_cast< MSG * >( message ); - if ( msg->message == WM_HOTKEY || msg->message == GD_HOTKEY_MESSAGE ) + if( msg->message == WM_HOTKEY ) { for (int i = 0; i < hotkeyWrappers.size(); i++) { @@ -491,12 +453,6 @@ bool QHotkeyApplication::nativeEventFilter( const QByteArray & /*eventType*/, vo } } - if( mainWindow ) - { - if( ( static_cast< MainWindow * >( mainWindow ) )->handleGDMessage( msg, result ) ) - return true; - } - return false; } diff --git a/hotkeywrapper.hh b/hotkeywrapper.hh index 08a6e8cc..844458b2 100644 --- a/hotkeywrapper.hh +++ b/hotkeywrapper.hh @@ -9,7 +9,11 @@ #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #undef Bool @@ -27,10 +31,6 @@ #include "qtsingleapplication.h" #include "utils.hh" -#ifdef Q_OS_WIN32 -#include "hotkeys.h" -#endif - ////////////////////////////////////////////////////////////////////////// struct HotkeyStruct @@ -70,10 +70,6 @@ public: /// Unregisters everything void unregister(); -#ifdef Q_OS_WIN32 - bool handleViaDLL() - { return dllHandler.hDLLHandle != 0; } -#endif signals: @@ -100,20 +96,14 @@ private: HotkeyStruct state2waiter; #ifdef Q_OS_WIN32 + +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) virtual bool winEvent ( MSG * message, long * result ); +#else + virtual bool winEvent ( MSG * message, qintptr * result ); +#endif HWND hwnd; - struct DLL_HANDLER - { - HMODULE hDLLHandle; - setHookProc setHook; - removeHookProc removeHook; - setHotkeysProc setHotkeys; - clearHotkeysProc clearHotkeys; - }; - - DLL_HANDLER dllHandler; - #elif defined(Q_OS_MAC) public: @@ -255,7 +245,13 @@ protected: void unregisterWrapper(HotkeyWrapper *wrapper); #ifdef Q_OS_WIN32 + +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) virtual bool nativeEventFilter( const QByteArray & eventType, void * message, long * result ); +#else + virtual bool nativeEventFilter( const QByteArray & eventType, void * message, qintptr * result ); +#endif + QWidget * mainWindow; public: diff --git a/howto/How to use ocr together with GoldenDict.md b/howto/How to use ocr together with GoldenDict.md index 59ec4e8c..a23caa4c 100644 --- a/howto/How to use ocr together with GoldenDict.md +++ b/howto/How to use ocr together with GoldenDict.md @@ -11,7 +11,9 @@ Thanks to: - [Capture2Text Linux Port](https://github.com/GSam/Capture2Text ) - [another on nixos](https://github.com/sikmir/nur-packages/blob/7c876e3fb20160781207a8f652fb052647e6da0d/pkgs/misc/capture2text/default.nix) from [sikmir](https://github.com/goldendict/goldendict/issues/1445#issuecomment-1022972220) -# Configuration +# Download release or compile by yourself +https://github.com/xiaoyifang/Capture2Text/releases +# Configuration on Windows after installation of both software. configure the Capture2Text ,see screenshot following ## configure external `Call Executable` path (Windows for example) diff --git a/howto/how to build ffmpeg for visual studio.md b/howto/how to build ffmpeg for visual studio.md new file mode 100644 index 00000000..8b78740f --- /dev/null +++ b/howto/how to build ffmpeg for visual studio.md @@ -0,0 +1,41 @@ +# use vcpkg to build the ffmpeg. +- folow the instructions https://trac.ffmpeg.org/wiki/CompilationGuide/vcpkg +- run command +``` +vcpkg.exe install ffmpeg[core,avcodec,avdevice,avfilter,avformat,speex,avresample,mp3lame,opus,sdl2,swresample,vorbis]:x64-windows-rel +``` +- copy dll and libs in vcpkg\installed\x64-windows-rel to goldendict's winlibs\lib\msvc + +**pros**: can be compiled with speex. + +# alternative Method : +just download the ffmpeg from official website: https://github.com/BtbN/FFmpeg-Builds/releases +can replace the dlls and libs in the winlibs\lib\msvc + +**cons**: seems lacks libspeex or I just download the wrong package. + +**pros**: easy to manage. + + +# I have tried the following methods no luck. +## - use the scripts provided by the following url + +https://github.com/Microsoft/FFmpegInterop/issues/67 + +https://github.com/Microsoft/FFmpegInterop + + +did not know how to link with libspeex. + +## - conan + + conan seems has not included libspeex option up to now. + + +# links worth checking: +https://stackoverflow.com/a/44556505/968188 + +# notes + +winlib/scripts/ffmpeg-configure-mingw32.sh is the script provided by goldendict . +though I have compiled it wiht mingw32 ,I do not know how to use it to compile for visual studio . diff --git a/hunspell.cc b/hunspell.cc index 51542610..c09638c3 100644 --- a/hunspell.cc +++ b/hunspell.cc @@ -13,7 +13,11 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #include #include @@ -73,16 +77,16 @@ public: virtual sptr< WordSearchRequest > prefixMatch( wstring const &, unsigned long maxResults ) - THROW_SPEC( std::exception ); + ; virtual sptr< WordSearchRequest > findHeadwordsForSynonym( wstring const & ) - THROW_SPEC( std::exception ); + ; virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ) - THROW_SPEC( std::exception ); + ; virtual bool isLocalDictionary() { return true; } @@ -329,7 +333,7 @@ void HunspellArticleRequest::run() sptr< DataRequest > HunspellDictionary::getArticle( wstring const & word, vector< wstring > const &, wstring const &, bool ) - THROW_SPEC( std::exception ) + { return new HunspellArticleRequest( word, getHunspellMutex(), hunspell ); } @@ -503,7 +507,7 @@ QVector< wstring > suggest( wstring & word, Mutex & hunspellMutex, Hunspell & hu sptr< WordSearchRequest > HunspellDictionary::findHeadwordsForSynonym( wstring const & word ) - THROW_SPEC( std::exception ) + { return new HunspellHeadwordsRequest( word, getHunspellMutex(), hunspell ); } @@ -618,7 +622,7 @@ void HunspellPrefixMatchRequest::run() sptr< WordSearchRequest > HunspellDictionary::prefixMatch( wstring const & word, unsigned long /*maxResults*/ ) - THROW_SPEC( std::exception ) + { return new HunspellPrefixMatchRequest( word, getHunspellMutex(), hunspell ); } @@ -734,10 +738,8 @@ string encodeToHunspell( Hunspell & hunspell, wstring const & str ) void * out = &result.front(); size_t outLeft = result.size(); - if ( conv.convert( in, inLeft, out, outLeft ) != Iconv::Success ) - throw Iconv::Ex(); - - return string( &result.front(), result.size() - outLeft ); + QString convStr= conv.convert( in, inLeft); + return FsEncoding::encode(convStr); } wstring decodeFromHunspell( Hunspell & hunspell, char const * str ) @@ -752,16 +754,13 @@ wstring decodeFromHunspell( Hunspell & hunspell, char const * str ) void * out = &result.front(); size_t outLeft = result.size() * sizeof( wchar ); - if ( conv.convert( in, inLeft, out, outLeft ) != Iconv::Success ) - throw Iconv::Ex(); - - return wstring( &result.front(), result.size() - outLeft/sizeof( wchar ) ); + QString convStr= conv.convert( in, inLeft); + return gd::toWString(convStr); } - } vector< sptr< Dictionary::Class > > makeDictionaries( Config::Hunspell const & cfg ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > result; diff --git a/hunspell.hh b/hunspell.hh index bdeb99c2..ee52b81d 100644 --- a/hunspell.hh +++ b/hunspell.hh @@ -34,7 +34,7 @@ struct DataFiles vector< DataFiles > findDataFiles( QString const & path ); vector< sptr< Dictionary::Class > > makeDictionaries( Config::Hunspell const & ) - THROW_SPEC( std::exception ); + ; } diff --git a/icons/playsound.png b/icons/playsound.png index deb213d5..4ad18fee 100644 Binary files a/icons/playsound.png and b/icons/playsound.png differ diff --git a/icons/playsound_full.png b/icons/playsound_full.png index 0c5dce4c..d0db327e 100644 Binary files a/icons/playsound_full.png and b/icons/playsound_full.png differ diff --git a/icons/readme.txt b/icons/readme.txt index 5360be37..6ac0d7b9 100644 --- a/icons/readme.txt +++ b/icons/readme.txt @@ -52,4 +52,9 @@ pushbin https://commons.wikimedia.org/wiki/File:Arrow_bottom_svg.svg license:public domain lists: -1downarrow \ No newline at end of file +1downarrow + + +these two icons from sertoli @ https://forum.freemdict.com/u/sertoli/summary +playsound.png +playsound_full.png \ No newline at end of file diff --git a/icons/wiktionary.png b/icons/wiktionary.png new file mode 100644 index 00000000..f2b124c4 Binary files /dev/null and b/icons/wiktionary.png differ diff --git a/iconv.cc b/iconv.cc index b7ddb40a..c266440e 100644 --- a/iconv.cc +++ b/iconv.cc @@ -6,74 +6,33 @@ #include #include #include +#include "wstring_qt.hh" -#ifdef __WIN32 -char const * const Iconv::GdWchar = "UCS-4LE"; -#else -char const * const Iconv::GdWchar = "WCHAR_T"; -#endif - +char const * const Iconv::GdWchar = "UTF-32LE"; char const * const Iconv::Utf16Le = "UTF-16LE"; char const * const Iconv::Utf8 = "UTF-8"; using gd::wchar; -Iconv::Iconv( char const * to, char const * from ) THROW_SPEC( exCantInit ): - state( iconv_open( to, from ) ) +Iconv::Iconv( char const * to, char const * from ) { - if ( state == (iconv_t) -1 ) - throw exCantInit( strerror( errno ) ); + codec = QTextCodec::codecForName(from); } -void Iconv::reinit( char const * to, char const * from ) THROW_SPEC( exCantInit ) +Iconv::~Iconv() { - iconv_close( state ); - - state = iconv_open( to, from ); - - if ( state == (iconv_t) -1 ) - throw exCantInit( strerror( errno ) ); + } -Iconv::~Iconv() throw() +QString Iconv::convert(void const* & inBuf, size_t& inBytesLeft) { - iconv_close( state ); -} - -Iconv::Result Iconv::convert( void const * & inBuf, size_t & inBytesLeft, - void * & outBuf, size_t & outBytesLeft ) - THROW_SPEC( exIncorrectSeq, exOther ) -{ - size_t result = iconv( state, -// #ifdef __WIN32 -// (char const **)&inBuf, -// #else - (char **)&inBuf, -// #endif - &inBytesLeft, - (char **)&outBuf, &outBytesLeft ); - - if ( result == (size_t) -1 ) - { - switch( errno ) - { - case EILSEQ: - throw exIncorrectSeq(); - case EINVAL: - return NeedMoreIn; - case E2BIG: - return NeedMoreOut; - default: - throw exOther( strerror( errno ) ); - } - } - - return Success; + return codec->toUnicode(static_cast(inBuf), inBytesLeft); + } gd::wstring Iconv::toWstring( char const * fromEncoding, void const * fromData, size_t dataSize ) - THROW_SPEC( exCantInit, exIncorrectSeq, exPrematureEnd, exOther ) + { /// Special-case the dataSize == 0 to avoid any kind of iconv-specific /// behaviour in that regard. @@ -86,35 +45,13 @@ gd::wstring Iconv::toWstring( char const * fromEncoding, void const * fromData, /// This size is usually enough, but may be enlarged during the conversion std::vector< wchar > outBuf( dataSize ); - void * outBufPtr = &outBuf.front(); - - size_t outBufLeft = outBuf.size() * sizeof( wchar ); - - for( ; ; ) - { - switch( ic.convert( fromData, dataSize, outBufPtr, outBufLeft ) ) - { - case Success: - return gd::wstring( &outBuf.front(), - outBuf.size() - outBufLeft / sizeof( wchar ) ); - case NeedMoreIn: - throw exPrematureEnd(); - case NeedMoreOut: - { - // Grow the buffer and retry - // The pointer may get invalidated so we save the diff and restore it - size_t offset = (wchar *)outBufPtr - &outBuf.front(); - outBuf.resize( outBuf.size() + 256 ); - outBufPtr = &outBuf.front() + offset; - outBufLeft += 256; - } - } - } + QString outStr = ic.convert(fromData, dataSize); + return gd::toWString(outStr); } std::string Iconv::toUtf8( char const * fromEncoding, void const * fromData, size_t dataSize ) - THROW_SPEC( exCantInit, exIncorrectSeq, exPrematureEnd, exOther ) + { // Similar to toWstring @@ -125,29 +62,7 @@ std::string Iconv::toUtf8( char const * fromEncoding, void const * fromData, std::vector< char > outBuf( dataSize ); - void * outBufPtr = &outBuf.front(); - - size_t outBufLeft = outBuf.size(); - - for( ; ; ) - { - switch( ic.convert( fromData, dataSize, outBufPtr, outBufLeft ) ) - { - case Success: - return std::string( &outBuf.front(), - outBuf.size() - outBufLeft ); - case NeedMoreIn: - throw exPrematureEnd(); - case NeedMoreOut: - { - // Grow the buffer and retry - // The pointer may get invalidated so we save the diff and restore it - size_t offset = (char *)outBufPtr - &outBuf.front(); - outBuf.resize( outBuf.size() + 256 ); - outBufPtr = &outBuf.front() + offset; - outBufLeft += 256; - } - } - } + QString outStr = ic.convert(fromData, dataSize); + return gd::toStdString(outStr); } diff --git a/iconv.hh b/iconv.hh index 4edad0fd..8cda0c81 100644 --- a/iconv.hh +++ b/iconv.hh @@ -4,23 +4,20 @@ #ifndef __ICONV_HH_INCLUDED__ #define __ICONV_HH_INCLUDED__ -#include +#include + #include "wstring.hh" #include "ex.hh" -#include "cpp_features.hh" /// A wrapper for the iconv() character set conversion functions class Iconv { - iconv_t state; + //iconv_t state; + QTextCodec* codec; public: DEF_EX( Ex, "Iconv exception", std::exception ) - DEF_EX_STR( exCantInit, "Can't initialize iconv conversion:", Ex ) - DEF_EX( exIncorrectSeq, "Invalid character sequence encountered during character conversion", Ex ) - DEF_EX( exPrematureEnd, "Character sequence ended prematurely during character conversion", Ex ) - DEF_EX_STR( exOther, "An error has occurred during character conversion:", Ex ) // Some predefined character sets' names @@ -28,35 +25,20 @@ public: static char const * const Utf16Le; static char const * const Utf8; - Iconv( char const * to, char const * from ) THROW_SPEC( exCantInit ); + Iconv( char const * to, char const * from ); - // Changes to another pair of encodings. All the internal state is reset. - void reinit( char const * to, char const * from ) THROW_SPEC( exCantInit ); + ~Iconv(); - ~Iconv() throw(); - - enum Result - { - Success, // All the data was successfully converted - NeedMoreIn, // Input has an incomplete multibyte character at its end - NeedMoreOut // The output buffer can't hold the result - }; - - Result convert( void const * & inBuf, size_t & inBytesLeft, - void * & outBuf, size_t & outBytesLeft ) THROW_SPEC( exIncorrectSeq, - exOther ); + QString convert(void const* & inBuf, size_t& inBytesLeft); // Converts a given block of data from the given encoding to a wide string. static gd::wstring toWstring( char const * fromEncoding, void const * fromData, - size_t dataSize ) - THROW_SPEC( exCantInit, exIncorrectSeq, exPrematureEnd, exOther ); + size_t dataSize ); // Converts a given block of data from the given encoding to an utf8-encoded // string. static std::string toUtf8( char const * fromEncoding, void const * fromData, - size_t dataSize ) - THROW_SPEC( exCantInit, exIncorrectSeq, exPrematureEnd, exOther ); - + size_t dataSize ); private: // Copying/assigning not supported diff --git a/indexedzip.cc b/indexedzip.cc index 6f06bd21..c5b77713 100644 --- a/indexedzip.cc +++ b/indexedzip.cc @@ -8,7 +8,11 @@ #include "utf8.hh" #include "iconv.hh" #include "wstring_qt.hh" - +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else +#include +#endif #include using namespace BtreeIndexing; diff --git a/initializing.cc b/initializing.cc index e6d68b4f..8d1d4a81 100644 --- a/initializing.cc +++ b/initializing.cc @@ -8,6 +8,7 @@ #if defined( Q_OS_WIN32 ) #include #include +#include WindowsStyle::WindowsStyle() { @@ -41,8 +42,7 @@ Initializing::Initializing( QWidget * parent, bool showOnStartup ): QDialog( par oldBarStyle = 0; - if( QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA - && ( QSysInfo::windowsVersion() & QSysInfo::WV_NT_based ) + if( QOperatingSystemVersion::current () >= QOperatingSystemVersion::Windows7 && !IsThemeActive() ) { QStyle * barStyle = WindowsStyle::instance().getStyle(); diff --git a/instances.cc b/instances.cc index fda59f22..c39cfe52 100644 --- a/instances.cc +++ b/instances.cc @@ -11,7 +11,7 @@ using std::set; using std::string; Group::Group( Config::Group const & cfgGroup, - vector< sptr< Dictionary::Class > > const & allDictionaries, + QMap > const & allDictionaries, Config::Group const & inactiveGroup ): id( cfgGroup.id ), name( cfgGroup.name ), @@ -22,70 +22,33 @@ Group::Group( Config::Group const & cfgGroup, if ( !cfgGroup.iconData.isEmpty() ) iconData = iconFromData( cfgGroup.iconData ); - vector< sptr< Dictionary::Class > > groupDicts; + QMap > groupDicts; + QVector dictOrderList; for( unsigned x = 0; x < (unsigned)cfgGroup.dictionaries.size(); ++x ) { std::string id = cfgGroup.dictionaries[ x ].id.toStdString(); - bool added = false; - - for( unsigned y = allDictionaries.size(); y--; ) - if ( allDictionaries[ y ]->getId() == id ) - { - groupDicts.push_back( allDictionaries[ y ] ); - added = true; - break; - } - - if ( !added ) - { - // Try matching by name instead - QString qname = cfgGroup.dictionaries[ x ].name; - std::string name = qname.toUtf8().data(); - - if ( !qname.isEmpty() ) - { - - // To avoid duplicates in dictionaries list we don't add dictionary - // if it with such name was already added or presented in rest of list - - unsigned n; - for( n = 0; n < groupDicts.size(); n++ ) - if( groupDicts[ n ]->getName() == name ) - break; - if( n < groupDicts.size() ) - continue; - - for( n = x + 1; n < (unsigned)cfgGroup.dictionaries.size(); n++ ) - if( cfgGroup.dictionaries[ n ].name == qname ) - break; - if( n < (unsigned)cfgGroup.dictionaries.size() ) - continue; - - for( unsigned y = 0; y < allDictionaries.size(); ++y ) - if ( allDictionaries[ y ]->getName() == name ) - { - groupDicts.push_back( allDictionaries[ y ] ); - break; - } - } + if(allDictionaries.contains(id)){ + groupDicts.insert(id, allDictionaries[ id ] ); + dictOrderList.push_back(id); } } // Remove inactive dictionaries - - if( inactiveGroup.dictionaries.isEmpty() ) - dictionaries = groupDicts; - else + if( !inactiveGroup.dictionaries.isEmpty() ) { set< string > inactiveSet; for( int i = 0; i < inactiveGroup.dictionaries.size(); i++ ) - inactiveSet.insert( inactiveGroup.dictionaries[ i ].id.toStdString() ); - - for( unsigned i = 0; i < groupDicts.size(); i++ ) - if( inactiveSet.find( groupDicts[ i ]->getId() ) == inactiveSet.end() ) - dictionaries.push_back( groupDicts[ i ] ); + { + string id=inactiveGroup.dictionaries[ i ].id.toStdString(); + groupDicts.remove(id); + dictOrderList.removeOne(id); + } + } + for(const auto & dictId : dictOrderList) + { + dictionaries.push_back(groupDicts[dictId]); } } diff --git a/instances.hh b/instances.hh index f4ac1d57..1ce40b18 100644 --- a/instances.hh +++ b/instances.hh @@ -29,7 +29,7 @@ struct Group /// Instantiates the given group from its configuration. If some dictionary /// wasn't found, it just skips it. Group( Config::Group const & cfgGroup, - vector< sptr< Dictionary::Class > > const & allDictionaries, + QMap > const & allDictionaries, Config::Group const & inactiveGroup ); /// Creates an empty group. diff --git a/keyboardstate.cc b/keyboardstate.cc index 29c986ff..b6163f19 100644 --- a/keyboardstate.cc +++ b/keyboardstate.cc @@ -7,7 +7,11 @@ #ifdef Q_OS_WIN32 #include #elif defined(HAVE_X11) +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #include #elif defined Q_OS_MAC diff --git a/langcoder.cc b/langcoder.cc index 90e00e90..56eb7637 100644 --- a/langcoder.cc +++ b/langcoder.cc @@ -9,7 +9,9 @@ #ifdef _MSC_VER #include #endif - +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif #include #include diff --git a/language.cc b/language.cc index 5fdfc439..55d03cd7 100644 --- a/language.cc +++ b/language.cc @@ -3,11 +3,7 @@ #include #include -#if defined( _MSC_VER ) && _MSC_VER < 1800 // VS2012 and older -#include -#else #include -#endif namespace Language { @@ -464,6 +460,6 @@ QString localizedStringForId( Id langId ) if( iconId.isEmpty() ) return name; else - return QString( " %2" ).arg( iconId ).arg( name ); + return QString( " %2" ).arg( iconId , name ); } } diff --git a/loaddictionaries.cc b/loaddictionaries.cc index 24bdd1aa..60a8adb5 100644 --- a/loaddictionaries.cc +++ b/loaddictionaries.cc @@ -131,6 +131,14 @@ void LoadDictionaries::handlePath( Config::Path const & path ) allFiles.push_back( FsEncoding::encode( QDir::toNativeSeparators( fullName ) ) ); } + { + vector< sptr< Dictionary::Class > > mdxDictionaries = + Mdx::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ); + + dictionaries.insert( dictionaries.end(), mdxDictionaries.begin(), + mdxDictionaries.end() ); + } + { vector< sptr< Dictionary::Class > > bglDictionaries = Bgl::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ); @@ -199,13 +207,6 @@ void LoadDictionaries::handlePath( Config::Path const & path ) dictionaries.insert( dictionaries.end(), zipSoundsDictionaries.begin(), zipSoundsDictionaries.end() ); } - { - vector< sptr< Dictionary::Class > > mdxDictionaries = - Mdx::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ); - - dictionaries.insert( dictionaries.end(), mdxDictionaries.begin(), - mdxDictionaries.end() ); - } { vector< sptr< Dictionary::Class > > glsDictionaries = Gls::makeDictionaries( allFiles, FsEncoding::encode( Config::getIndexDir() ), *this ); diff --git a/locale/sk_SK.ts b/locale/sk_SK.ts index 9c02bfe7..b8dbedaf 100644 --- a/locale/sk_SK.ts +++ b/locale/sk_SK.ts @@ -69,7 +69,7 @@ <h3 align="center">Welcome to <b>GoldenDict</b>!</h3><p>To start working with the program, first visit <b>Edit|Dictionaries</b> to add some directory paths where to search for the dictionary files, set up various Wikipedia sites or other sources, adjust dictionary order or create dictionary groups.<p>And then you're ready to look up your words! You can do that in this window by using a pane to the left, or you can <a href="Working with popup">look up words from other active applications</a>. <p>To customize program, check out the available preferences at <b>Edit|Preferences</b>. All settings there have tooltips, be sure to read them if you are in doubt about anything.<p>Should you need further help, have any questions, suggestions or just wonder what the others think, you are welcome at the program's <a href="http://goldendict.org/forum/">forum</a>.<p>Check program's <a href="http://goldendict.org/">website</a> for the updates. <p>(c) 2008-2013 Konstantin Isakov. Licensed under GPLv3 or later. - <h3 align="center">Vitajte v programe <b>GoldenDict</b>!</h3><p>Prácu v programe začnite v <b>Upraviť|Slovníky</b>, kde môžete pridať cesty k priečinkom v ktorých budú vyhľadané slovníky, nastaviť rôzne stránky Wikipedie a iné zdroje, upraviť poradenie poradenie slovníkov alebo vytvoriť slovníkové skupiny.</p><p>Potom budete môcť začať vyhľadať slová! Môžete tak robiť v tomto okne s použitím panela vľavo, alebo môžete <a href="Working with popup">vyhľadávať slová z iných aktívnych aplikácií</a>.</p><p>Úpravu vlastností programu môžete urobiť <b>Upraviť|Nastavenia…</b>. Všetky nastavenia majú popisy, ktoré vám pomôžu, pokiaľ si nebudete niečim istý.</p><p>Pokiaľ budete potrebovať ďalšiu pomoc, máte nejaké návrhy, alebo len chcete vedieť, čo si myslia iný, tak ste vítaní na <a href="http://goldendict.org/forum/">diskusnom fóre</a>.</p><p>Aktualizácie hľadajte na <a href="http://goldendict.org/">stránkach GoldenDict</a>.</p><p>(c) 2008-2013 Konstantin Isakov. Licencované pod GPLv3 alebo novšou. + <h3 align="center">Vitajte v programe <b>GoldenDict</b>!</h3><p>Prácu v programe začnite v <b>Upraviť|Slovníky</b>, kde môžete pridať cesty ku priečinkom, v ktorých sa budú vyhľadávať slovníky, nastaviť rôzne stránky Wikipedie a iné zdroje, upraviť poradie slovníkov alebo vytvoriť skupiny slovníkov.</p><p>Potom môžete začať vyhľadávať slová! Môžete tak urobiť v tomto okne s použitím panela vľavo, alebo môžete <a href="Working with popup">vyhľadávať slová z iných aktívnych aplikácií</a>.</p><p>Úpravu vlastností programu môžete urobiť v ponuke <b>Upraviť|Nastavenia…</b>. Všetky nastavenia majú popisy, ktoré vám pomôžu, pokiaľ si nebudete niečím istý.</p><p>Ak potrebujete ďalšiu pomoc, máte návrhy na zlepšenie alebo sa chcete dozvedieť, čo si myslia iní, ste vítaní na <a href="http://goldendict.org/forum/">diskusnom fóre</a>.</p><p>Aktualizácie hľadajte na <a href="http://goldendict.org/">stránkach GoldenDict</a>.</p><p>(c) 2008-2013 Konstantin Isakov. Licencované pod GPLv3 alebo novšou. @@ -2494,7 +2494,7 @@ medzi klasickou a školskou ortografiou v azbuke) &Zoom - &Zväčšenie + P&riblíženie @@ -2660,12 +2660,12 @@ medzi klasickou a školskou ortografiou v azbuke) &Always on Top - &Vždy na vrchu + &Vždy navrchu Always on Top - Vždy na vrchu + Vždy navrchu @@ -2788,7 +2788,7 @@ medzi klasickou a školskou ortografiou v azbuke) &Menubar - &Panel s ponukou + Panel s p&onukou @@ -2814,7 +2814,7 @@ medzi klasickou a školskou ortografiou v azbuke) Scan Popup - Vyskakovanie okno + Vyskakovacie okno @@ -3480,7 +3480,7 @@ With this on however, it will hide the main window. &Scan Popup - Vy&skakovacie okno + Vys&kakovacie okno @@ -3937,30 +3937,33 @@ Povoľte toto nastavenie na obídenie problému. Maximum network cache size: - + Maximálna veľkosť vyr. pamäte siete: Maximum disk space occupied by GoldenDict's network cache in %1 If set to 0 the network disk cache will be disabled. - + Maximálny priestor na disku obsadený vyrovnávacou pamäťou siete GoldenDict v +%1 +Ak nastavíte na 0, vyrovnávacia pamäť siete bude vypnutá. MiB - + MiB When this option is enabled, GoldenDict clears its network cache from disk during exit. - + Ak zapnete túto možnosť, GoldenDict +vyčistí vyrovnávaciu pamäť siete pri ukončení aplikácie. Clear network cache on exit - + Vyčistiť vyr. pamäť siete pri ukončení @@ -3988,12 +3991,12 @@ na stiahnutie. ScanPopup unpinned window flags - + Neštandardné príznaky nepripnutého vysk. okna Experiment with non-default flags if the unpinned scan popup window misbehaves - + Experimentujte s neštandardnými príznakmi v prípade, že sa nepripnuté vyskakovacie okno správa nepredvídateľne @@ -4071,17 +4074,18 @@ na stiahnutie. Turn this option on to ignore unreasonably long input text from mouse-over, selection, clipboard or command line - + Zapnite túto možnosť, ak chcete ignorovať neprimerane +dlhý text pri navigácií myšou, výbere, v obsahu schránky alebo v príkaze Ignore input phrases longer than - + Ignorovať vstupné frázy dlhšie ako Input phrases longer than this size will be ignored - + Vstupné frázy dlhšie ako táto veľkosť sa budú ignorovať @@ -4142,7 +4146,7 @@ from mouse-over, selection, clipboard or command line MB - + MB @@ -4653,7 +4657,7 @@ vhodné slovníky dole k vhodným skupinám. Live pronunciations from <a href="http://www.forvo.com/">forvo.com</a>. The site allows people to record and share word pronunciations. You can listen to them from GoldenDict. - Živá výslovnosť z <a href="http://www.forvo.com/">forvo.com</a>. Stánky umožňujú ľuďom nahrávať a zdieľa výslovnosť slov. V GoldenDicte si ich môžete vypočuť. + Živá výslovnosť z <a href="http://www.forvo.com/">forvo.com</a>. Stránky umožňujú ľuďom nahrávať a zdieľať výslovnosť slov. V GoldenDicte si ich môžete vypočuť. diff --git a/locale/zh_CN.ts b/locale/zh_CN.ts index 6070cc66..6f63d97c 100644 --- a/locale/zh_CN.ts +++ b/locale/zh_CN.ts @@ -3852,7 +3852,20 @@ Plugin must be installed for this option to work. 显示弹出窗口之前先显示一个旗标窗口,点击旗标以显示弹出窗口。 - + + Normally, clicking on a link, double-clicking on a word or looking up +selection in an article loads the translation and almost immediately +scrolls to the article from the same dictionary. With this option off, +however, the article from the topmost dictionary is shown. + 单击link或双击翻译的时候是否自动定位到当前正在浏览的词典。 + + + + Automatically scroll to target article + 自动定位到当前词典 + + + Show scan flag when word is selected 单词被选中时显示扫描旗标 diff --git a/lsa.cc b/lsa.cc index aaf48ce3..a6944a43 100644 --- a/lsa.cc +++ b/lsa.cc @@ -179,10 +179,10 @@ public: vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; protected: @@ -217,7 +217,7 @@ sptr< Dictionary::DataRequest > LsaDictionary::getArticle( wstring const & word, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { vector< WordArticleLink > chain = findArticles( word, ignoreDiacritics ); @@ -399,7 +399,7 @@ __attribute__((packed)) ; sptr< Dictionary::DataRequest > LsaDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { // See if the name ends in .wav. Remove that extension then @@ -524,7 +524,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/lsa.hh b/lsa.hh index 6bb2456d..96751f71 100644 --- a/lsa.hh +++ b/lsa.hh @@ -16,7 +16,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; } diff --git a/maclibs/include/ao/ao.h b/maclibs/include/ao/ao.h deleted file mode 100644 index e0c347de..00000000 --- a/maclibs/include/ao/ao.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * - * ao.h - * - * Original Copyright (C) Aaron Holtzman - May 1999 - * Modifications Copyright (C) Stan Seibert - July 2000, July 2001 - * More Modifications Copyright (C) Jack Moffitt - October 2000 - * - * This file is part of libao, a cross-platform audio outputlibrary. See - * README for a history of this source code. - * - * libao is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * libao is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -#ifndef __AO_H__ -#define __AO_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include -#include -#include -#include "os_types.h" - -/* --- Constants ---*/ - -#define AO_TYPE_LIVE 1 -#define AO_TYPE_FILE 2 - - -#define AO_ENODRIVER 1 -#define AO_ENOTFILE 2 -#define AO_ENOTLIVE 3 -#define AO_EBADOPTION 4 -#define AO_EOPENDEVICE 5 -#define AO_EOPENFILE 6 -#define AO_EFILEEXISTS 7 -#define AO_EBADFORMAT 8 - -#define AO_EFAIL 100 - - -#define AO_FMT_LITTLE 1 -#define AO_FMT_BIG 2 -#define AO_FMT_NATIVE 4 - -/* --- Structures --- */ - -typedef struct ao_info { - int type; /* live output or file output? */ - char *name; /* full name of driver */ - char *short_name; /* short name of driver */ - char *author; /* driver author */ - char *comment; /* driver comment */ - int preferred_byte_format; - int priority; - char **options; - int option_count; -} ao_info; - -typedef struct ao_functions ao_functions; -typedef struct ao_device ao_device; - -typedef struct ao_sample_format { - int bits; /* bits per sample */ - int rate; /* samples per second (in a single channel) */ - int channels; /* number of audio channels */ - int byte_format; /* Byte ordering in sample, see constants below */ - char *matrix; /* input channel location/ordering */ -} ao_sample_format; - -typedef struct ao_option { - char *key; - char *value; - struct ao_option *next; -} ao_option; - -#if defined(AO_BUILDING_LIBAO) -#include "ao_private.h" -#endif - -/* --- Functions --- */ - -/* library setup/teardown */ -void ao_initialize(void); -void ao_shutdown(void); - -/* device setup/playback/teardown */ -int ao_append_global_option(const char *key, - const char *value); -int ao_append_option(ao_option **options, - const char *key, - const char *value); -void ao_free_options(ao_option *options); -ao_device* ao_open_live(int driver_id, - ao_sample_format *format, - ao_option *option); -ao_device* ao_open_file(int driver_id, - const char *filename, - int overwrite, - ao_sample_format *format, - ao_option *option); - -int ao_play(ao_device *device, - char *output_samples, - uint_32 num_bytes); -int ao_close(ao_device *device); - -/* driver information */ -int ao_driver_id(const char *short_name); -int ao_default_driver_id(void); -ao_info *ao_driver_info(int driver_id); -ao_info **ao_driver_info_list(int *driver_count); -const char *ao_file_extension(int driver_id); - -/* miscellaneous */ -int ao_is_big_endian(void); - - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __AO_H__ */ diff --git a/maclibs/include/ao/os_types.h b/maclibs/include/ao/os_types.h deleted file mode 100644 index 8a565535..00000000 --- a/maclibs/include/ao/os_types.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * - * os_types.h - * - * Original Copyright (C) Aaron Holtzman - May 1999 - * Modifications Copyright (C) Stan Seibert - July 2000 - * - * This file is part of libao, a cross-platform audio output library. See - * README for a history of this source code. - * - * libao is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * libao is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* Set type sizes for this platform (Requires Autoconf) */ - -#ifndef __OS_TYPES_H__ -#define __OS_TYPES_H__ - -typedef unsigned char uint_8; -typedef unsigned short uint_16; -typedef unsigned int uint_32; -typedef signed char sint_8; -typedef signed short sint_16; -typedef signed int sint_32; - -#endif /* __OS_TYPES_H__ */ diff --git a/maclibs/include/ao/plugin.h b/maclibs/include/ao/plugin.h deleted file mode 100644 index 77043967..00000000 --- a/maclibs/include/ao/plugin.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * - * plugin.h - function declarations for libao plugins - * - * Copyright (C) Stan Seibert - June 2001 - * - * This file is part of libao, a cross-platform audio outputlibrary. See - * README for a history of this source code. - * - * libao is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * libao is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Make; see the file COPYING. If not, write to - * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. - * - */ -#ifndef __PLUGIN_H__ -#define __PLUGIN_H__ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include -#include "os_types.h" - -int ao_plugin_test(); -ao_info *ao_plugin_driver_info(); -int ao_plugin_device_init(ao_device *device); -int ao_plugin_set_option(ao_device *device, const char *key, const char *value); -int ao_plugin_open(ao_device *device, ao_sample_format *format); -int ao_plugin_play(ao_device *device, const char *output_samples, - uint_32 num_bytes); -int ao_plugin_close(ao_device *device); -void ao_plugin_device_clear(ao_device *device); -const char *ao_plugin_file_extension(); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif /* __PLUGIN_H__ */ diff --git a/maclibs/include/eb/appendix.h b/maclibs/include/eb/appendix.h deleted file mode 100644 index 9cef1a5d..00000000 --- a/maclibs/include/eb/appendix.h +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- C -*- - * Copyright (c) 1997-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef EB_APPENDIX_H -#define EB_APPENDIX_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef EB_BUILD_LIBRARY -#include "eb.h" -#else -#include -#endif - -/* - * Function declarations. - */ -/* appendix.c */ -void eb_initialize_appendix(EB_Appendix *appendix); -void eb_finalize_appendix(EB_Appendix *appendix); -EB_Error_Code eb_bind_appendix(EB_Appendix *appendix, const char *path); -int eb_is_appendix_bound(EB_Appendix *appendix); -EB_Error_Code eb_appendix_path(EB_Appendix *appendix, char *path); - -/* appsub.c */ -EB_Error_Code eb_load_all_appendix_subbooks(EB_Appendix *appendix); -EB_Error_Code eb_appendix_subbook_list(EB_Appendix *appendix, - EB_Subbook_Code *subbook_list, int *subbook_count); -EB_Error_Code eb_appendix_subbook(EB_Appendix *appendix, - EB_Subbook_Code *subbook_code); -EB_Error_Code eb_appendix_subbook_directory(EB_Appendix *appendix, - char *directory); -EB_Error_Code eb_appendix_subbook_directory2(EB_Appendix *appendix, - EB_Subbook_Code subbook_code, char *directory); -EB_Error_Code eb_set_appendix_subbook(EB_Appendix *appendix, - EB_Subbook_Code subbook_code); -void eb_unset_appendix_subbook(EB_Appendix *appendix); - -/* narwalt.c */ -int eb_have_narrow_alt(EB_Appendix *appendix); -EB_Error_Code eb_narrow_alt_start(EB_Appendix *appendix, int *start); -EB_Error_Code eb_narrow_alt_end(EB_Appendix *appendix, int *end); -EB_Error_Code eb_narrow_alt_character_text(EB_Appendix *appendix, - int character_number, char *text); -EB_Error_Code eb_forward_narrow_alt_character(EB_Appendix *appendix, - int n, int *character_number); -EB_Error_Code eb_backward_narrow_alt_character(EB_Appendix *appendix, - int n, int *character_number); - -/* stopcode.c */ -int eb_have_stop_code(EB_Appendix *appendix); -EB_Error_Code eb_stop_code(EB_Appendix *appendix, int *); - -/* widealt.c */ -int eb_have_wide_alt(EB_Appendix *appendix); -EB_Error_Code eb_wide_alt_start(EB_Appendix *appendix, int *start); -EB_Error_Code eb_wide_alt_end(EB_Appendix *appendix, int *end); -EB_Error_Code eb_wide_alt_character_text(EB_Appendix *appendix, - int character_number, char *text); -EB_Error_Code eb_forward_wide_alt_character(EB_Appendix *appendix, int n, - int *character_number); -EB_Error_Code eb_backward_wide_alt_character(EB_Appendix *appendix, int n, - int *character_number); - -/* for backward compatibility */ -#define eb_suspend_appendix eb_unset_appendix_subbook -#define eb_initialize_all_appendix_subbooks eb_load_all_appendix_subbooks - -#ifdef __cplusplus -} -#endif - -#endif /* not EB_APPENDIX_H */ diff --git a/maclibs/include/eb/binary.h b/maclibs/include/eb/binary.h deleted file mode 100644 index 031ca468..00000000 --- a/maclibs/include/eb/binary.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- C -*- - * Copyright (c) 2001-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef EB_BINARY_H -#define EB_BINARY_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef EB_BUILD_LIBRARY -#include "defs.h" -#else -#include -#endif - -/* - * Function declarations. - */ -/* binary.c */ -EB_Error_Code eb_set_binary_mono_graphic(EB_Book *book, - const EB_Position *position, int width, int height); -EB_Error_Code eb_set_binary_gray_graphic(EB_Book *book, - const EB_Position *position, int width, int height); -EB_Error_Code eb_set_binary_wave(EB_Book *book, - const EB_Position *start_position, const EB_Position *end_position); -EB_Error_Code eb_set_binary_color_graphic(EB_Book *book, - const EB_Position *position); -EB_Error_Code eb_set_binary_mpeg(EB_Book *book, const unsigned int *argv); -EB_Error_Code eb_read_binary(EB_Book *book, size_t binary_max_length, - char *binary, ssize_t *binary_length); -void eb_unset_binary(EB_Book *book); - -/* filename.c */ -EB_Error_Code eb_compose_movie_file_name(const unsigned int *argv, - char *composed_file_name); -EB_Error_Code eb_compose_movie_path_name(EB_Book *book, - const unsigned int *argv, char *composed_path_name); -EB_Error_Code eb_decompose_movie_file_name(unsigned int *argv, - const char *composed_file_name); - -#ifdef __cplusplus -} -#endif - -#endif /* not EB_BINARY_H */ diff --git a/maclibs/include/eb/booklist.h b/maclibs/include/eb/booklist.h deleted file mode 100644 index e239414e..00000000 --- a/maclibs/include/eb/booklist.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- C -*- - * Copyright (c) 1997-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef EB_BOOKLIST_H -#define EB_BOOKLIST_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef EB_BUILD_LIBRARY -#include "eb.h" -#else -#include -#endif - -/* - * Function declarations. - */ -/* booklist.c */ -void eb_initialize_booklist(EB_BookList *booklist); -void eb_finalize_booklist(EB_BookList *booklist); -EB_Error_Code eb_bind_booklist(EB_BookList *booklist, const char *path); -EB_Error_Code eb_booklist_book_count(EB_BookList *booklist, int *book_count); -EB_Error_Code eb_booklist_book_name(EB_BookList *booklist, int book_index, - char **book_name); -EB_Error_Code eb_booklist_book_title(EB_BookList *booklist, int book_index, - char **book_title); - - -#ifdef __cplusplus -} -#endif - -#endif /* not EB_BOOKLIST_H */ diff --git a/maclibs/include/eb/defs.h b/maclibs/include/eb/defs.h deleted file mode 100644 index bd63cfee..00000000 --- a/maclibs/include/eb/defs.h +++ /dev/null @@ -1,1040 +0,0 @@ -/* -*- C -*- - * Copyright (c) 1997-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef EB_DEFS_H -#define EB_DEFS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -#ifdef EB_BUILD_LIBRARY -#include "sysdefs.h" -#include "zio.h" -#else -#include -#include -#endif - -#ifdef EB_ENABLE_PTHREAD -#include -#endif - -/* - * Disc code - */ -#define EB_DISC_EB 0 -#define EB_DISC_EPWING 1 -#define EB_DISC_INVALID -1 - -/* - * Character codes. - */ -#define EB_CHARCODE_ISO8859_1 1 -#define EB_CHARCODE_JISX0208 2 -#define EB_CHARCODE_JISX0208_GB2312 3 -#define EB_CHARCODE_INVALID -1 - -/* - * Special book ID for cache to represent "no cache data for any book". - */ -#define EB_BOOK_NONE -1 - -/* - * Special disc code, subbook code, multi search ID, and multi search - * entry ID, for representing error state. - */ -#define EB_SUBBOOK_INVALID -1 -#define EB_MULTI_INVALID -1 - -/* - * Size of a page (The term `page' means `block' in JIS X 4081). - */ -#define EB_SIZE_PAGE 2048 - -/* - * Maximum length of a word to be searched. - */ -#define EB_MAX_WORD_LENGTH 255 - -/* - * Maximum length of an EB* book title. - */ -#define EB_MAX_EB_TITLE_LENGTH 30 - -/* - * Maximum length of an EPWING book title. - */ -#define EB_MAX_EPWING_TITLE_LENGTH 80 - -/* - * Maximum length of a book title. - */ -#define EB_MAX_TITLE_LENGTH 80 - -/* - * Maximum length of a word to be searched. - */ -#if defined(PATH_MAX) -#define EB_MAX_PATH_LENGTH PATH_MAX -#elif defined(MAXPATHLEN) -#define EB_MAX_PATH_LENGTH MAXPATHLEN -#else -#define EB_MAX_PATH_LENGTH 1024 -#endif - -/* - * Maximum length of a directory name. - */ -#define EB_MAX_DIRECTORY_NAME_LENGTH 8 - -/* - * Maximum length of a file name under a certain directory. - * prefix(8 chars) + '.' + suffix(3 chars) + ';' + digit(1 char) - */ -#define EB_MAX_FILE_NAME_LENGTH 14 - -/* - * Maximum length of a label for multi-search entry. - */ -#define EB_MAX_MULTI_LABEL_LENGTH 30 - -/* - * Maximum length of alternation text string for a private character. - */ -#define EB_MAX_ALTERNATION_TEXT_LENGTH 31 - -/* - * Maximum length of title for multi search. - */ -#define EB_MAX_MULTI_TITLE_LENGTH 32 - -/* - * Maximum number of font heights in a subbok. - */ -#define EB_MAX_FONTS 4 - -/* - * Maximum number of subbooks in a book. - */ -#define EB_MAX_SUBBOOKS 50 - -/* - * Maximum number of multi-search types in a subbook. - */ -#define EB_MAX_MULTI_SEARCHES 10 - -/* - * Maximum number of entries in a multi-search. - */ -#define EB_MAX_MULTI_ENTRIES 5 - -/* - * Maximum number of entries in a keyword search. - */ -#define EB_MAX_KEYWORDS EB_MAX_MULTI_ENTRIES - -/* - * Maximum number of entries in a cross search. - */ -#define EB_MAX_CROSS_ENTRIES EB_MAX_MULTI_ENTRIES - -/* - * Maximum number of characters for alternation cache. - */ -#define EB_MAX_ALTERNATION_CACHE 16 - -/* - * The number of text hooks. - */ -#define EB_NUMBER_OF_HOOKS 54 - -/* - * The number of search contexts required by a book. - */ -#define EB_NUMBER_OF_SEARCH_CONTEXTS EB_MAX_MULTI_ENTRIES - -/* - * Types for various codes. - */ -typedef int EB_Error_Code; -typedef int EB_Book_Code; -typedef int EB_Disc_Code; -typedef int EB_Case_Code; -typedef int EB_Suffix_Code; -typedef int EB_Character_Code; -typedef int EB_Font_Code; -typedef int EB_Word_Code; -typedef int EB_Subbook_Code; -typedef int EB_Index_Style_Code; -typedef int EB_Search_Code; -typedef int EB_Text_Code; -typedef int EB_Text_Status_Code; -typedef int EB_Multi_Search_Code; -typedef int EB_Hook_Code; -typedef int EB_Binary_Code; - -/* - * Typedef for Structures. - */ -#ifdef EB_ENABLE_PTHREAD -typedef struct EB_Lock_Struct EB_Lock; -#endif -typedef struct EB_Position_Struct EB_Position; -typedef struct EB_Alternation_Cache_Struct EB_Alternation_Cache; -typedef struct EB_Appendix_Subbook_Struct EB_Appendix_Subbook; -typedef struct EB_Appendix_Struct EB_Appendix; -typedef struct EB_Font_Struct EB_Font; -typedef struct EB_Search_Struct EB_Search; -typedef struct EB_Multi_Search_Struct EB_Multi_Search; -typedef struct EB_Subbook_Struct EB_Subbook; -typedef struct EB_Text_Context_Struct EB_Text_Context; -typedef struct EB_Binary_Context_Struct EB_Binary_Context; -typedef struct EB_Search_Context_Struct EB_Search_Context; -typedef struct EB_Book_Struct EB_Book; -typedef struct EB_Hit_Struct EB_Hit; -typedef struct EB_Hook_Struct EB_Hook; -typedef struct EB_Hookset_Struct EB_Hookset; -typedef struct EB_BookList_Entry EB_BookList_Entry; -typedef struct EB_BookList EB_BookList; - -/* - * Pthreads lock. - */ -#ifdef EB_ENABLE_PTHREAD -struct EB_Lock_Struct { - /* - * Lock count. (For emulating recursive lock). - */ - int lock_count; - - /* - * Mutex for `lock_count'. - */ - pthread_mutex_t lock_count_mutex; - - /* - * Mutex for struct entity. - */ - pthread_mutex_t entity_mutex; -}; -#endif /* EB_ENABLE_PTHREAD */ - -/* - * A pair of page and offset. - */ -struct EB_Position_Struct { - /* - * Page. (1, 2, 3 ...) - */ - int page; - - /* - * Offset in `page'. (0 ... 2047) - */ - int offset; -}; - -/* - * Chace of aternation text. - */ -struct EB_Alternation_Cache_Struct { - /* - * Character number. - */ - int character_number; - - /* - * Alternation string for `char_no'. - */ - char text[EB_MAX_ALTERNATION_TEXT_LENGTH + 1]; -}; - -/* - * An appendix for a subbook. - */ -struct EB_Appendix_Subbook_Struct { - - /* - * Initialization flag. - */ - int initialized; - - /* - * Subbook ID. - */ - EB_Subbook_Code code; - - /* - * Directory name. - */ - char directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; - - /* - * Sub-directory name. (EPWING only) - */ - char data_directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; - - /* - * File name. - */ - char file_name[EB_MAX_FILE_NAME_LENGTH + 1]; - - /* - * Character code of the book. - */ - EB_Character_Code character_code; - - /* - * Start character number of the narrow/wide font. - */ - int narrow_start; - int wide_start; - - /* - * End character number of the narrow/wide font. - */ - int narrow_end; - int wide_end; - - /* - * Start page number of the narrow/wide font. - */ - int narrow_page; - int wide_page; - - /* - * Stop code (first and second characters). - */ - int stop_code0; - int stop_code1; - - /* - * Compression Information for appendix file. - */ - Zio zio; -}; - -/* - * Additional resources for a book. - */ -struct EB_Appendix_Struct { - /* - * Book ID. - */ - EB_Book_Code code; - - /* - * Path of the book. - */ - char *path; - - /* - * The length of the path. - */ - size_t path_length; - - /* - * Disc type. EB (EB/EBG/EBXA/EBXA-C/S-EBXA) or EPWING. - */ - EB_Disc_Code disc_code; - - /* - * The number of subbooks the book has. - */ - int subbook_count; - - /* - * Subbook list. - */ - EB_Appendix_Subbook *subbooks; - - /* - * Current subbook. - */ - EB_Appendix_Subbook *subbook_current; - - /* - * ebnet socket file. - */ -#ifdef EB_ENABLE_EBNET - int ebnet_file; -#endif - - /* - * Lock. - */ -#ifdef EB_ENABLE_PTHREAD - EB_Lock lock; -#endif - - /* - * Cache table for alternation text. - */ - EB_Alternation_Cache narrow_cache[EB_MAX_ALTERNATION_CACHE]; - EB_Alternation_Cache wide_cache[EB_MAX_ALTERNATION_CACHE]; -}; - -/* - * A font in a subbook. - */ -struct EB_Font_Struct { - /* - * Font Code. - * This font is not available, if the code is EB_FONT_INVALID. - */ - EB_Font_Code font_code; - - /* - * Whether the object has been initialized. - */ - int initialized; - - /* - * Character numbers of the start and end of the font. - */ - int start; - int end; - - /* - * Page number of the start page of the font data. - * Used in EB* only. (In EPWING, it is alyways 1). - */ - int page; - - /* - * File name of the font. (EPWING only) - */ - char file_name[EB_MAX_FILE_NAME_LENGTH + 1]; - - /* - * Font data cache. - */ - char *glyphs; - - /* - * Compression Information. - */ - Zio zio; -}; - -/* - * Search methods in a subbook. - */ -struct EB_Search_Struct { - /* - * Index ID. - */ - int index_id; - - /* - * Page number of the start page of an index. - * This search method is not available, if `start_page' is 0, - */ - int start_page; - int end_page; - - /* - * Page number of the start page of candidates. - * (for multi search entry) - */ - int candidates_page; - - /* - * Index style flags. - */ - EB_Index_Style_Code katakana; - EB_Index_Style_Code lower; - EB_Index_Style_Code mark; - EB_Index_Style_Code long_vowel; - EB_Index_Style_Code double_consonant; - EB_Index_Style_Code contracted_sound; - EB_Index_Style_Code voiced_consonant; - EB_Index_Style_Code small_vowel; - EB_Index_Style_Code p_sound; - EB_Index_Style_Code space; - - /* - * Label. (for an entry in multi search) - */ - char label[EB_MAX_MULTI_LABEL_LENGTH + 1]; -}; - -/* - * A multi-search entry in a subbook. - */ -struct EB_Multi_Search_Struct { - /* - * Search method information. - */ - EB_Search search; - - /* - * Search title. (EPWING only) - */ - char title[EB_MAX_MULTI_TITLE_LENGTH + 1]; - - /* - * The number of entries the multi search has. - */ - int entry_count; - - /* - * List of Word entry information. - */ - EB_Search entries[EB_MAX_MULTI_ENTRIES]; -}; - -/* - * A subbook in a book. - */ -struct EB_Subbook_Struct { - /* - * Whether the object has been initialized. - */ - int initialized; - - /* - * Index page. - */ - int index_page; - - /* - * Subbook ID. - * This subbook is not available, if the code is EB_SUBBOOK_INVALID. - */ - EB_Subbook_Code code; - - /* - * File descriptor and compression information for text file. - */ - Zio text_zio; - - /* - * File descriptor and compression information for graphic file. - */ - Zio graphic_zio; - - /* - * File descriptor and compression information for sound file. - */ - Zio sound_zio; - - /* - * File descriptor and compression information for movie file. - */ - Zio movie_zio; - - /* - * Title of the subbook. - */ - char title[EB_MAX_TITLE_LENGTH + 1]; - - /* - * Subbook directory name. - */ - char directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; - - /* - * Sub-directory names. (EPWING only) - */ - char data_directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; - char gaiji_directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; - char movie_directory_name[EB_MAX_DIRECTORY_NAME_LENGTH + 1]; - - /* - * File names. - */ - char text_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; - char graphic_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; - char sound_file_name[EB_MAX_FILE_NAME_LENGTH + 1]; - - /* - * Compression hints of Text, graphic and sound files. - * (temporary need, EPWING only). - */ - Zio_Code text_hint_zio_code; - Zio_Code graphic_hint_zio_code; - Zio_Code sound_hint_zio_code; - - /* - * Page number where search method titles are stored. - * (temporary need, EPWING only). - */ - int search_title_page; - - /* - * The top page of search methods. - */ - EB_Search word_alphabet; - EB_Search word_asis; - EB_Search word_kana; - EB_Search endword_alphabet; - EB_Search endword_asis; - EB_Search endword_kana; - EB_Search keyword; - EB_Search menu; - EB_Search image_menu; - EB_Search cross; - EB_Search copyright; - EB_Search text; - EB_Search sound; - - /* - * The number of multi-search methods the subbook has. - */ - int multi_count; - - /* - * The top page of multi search methods. - */ - EB_Multi_Search multis[EB_MAX_MULTI_SEARCHES]; - - /* - * Font list. - */ - EB_Font narrow_fonts[EB_MAX_FONTS]; - EB_Font wide_fonts[EB_MAX_FONTS]; - - /* - * Current narrow and wide fonts. - */ - EB_Font *narrow_current; - EB_Font *wide_current; -}; - -/* - * Length of cache buffer in a binary context. - * It must be greater than 38, size of GIF preamble. - * It must be greater than 44, size of WAVE sound header. - * It must be greater than 118, size of BMP header + info + 16 rgbquads. - */ -#define EB_SIZE_BINARY_CACHE_BUFFER 128 - -/* - * Context parameters for binary data. - */ -struct EB_Binary_Context_Struct { - /* - * Binary type ID. - * The context is not active, if this code is EB_BINARY_INVALID. - */ - EB_Binary_Code code; - - /* - * Compress information. - */ - Zio *zio; - - /* - * Location of the the binary data, relative to the start of the file. - */ - off_t location; - - /* - * Data size. - * Size zero means that the binary has no size information. - */ - size_t size; - - /* - * The current offset of binary data. - */ - size_t offset; - - /* - * Cache buffer. - */ - char cache_buffer[EB_SIZE_BINARY_CACHE_BUFFER]; - - /* - * Length of cached data. - */ - size_t cache_length; - - /* - * Current offset of cached data. - */ - size_t cache_offset; - - /* - * Width of Image. (monochrome graphic only) - */ - int width; -}; - -/* - * Context parameters for text reading. - */ -struct EB_Text_Context_Struct { - /* - * Current text content type. - * The context is not active, if this code is EB_TEXT_INVALID. - */ - EB_Text_Code code; - - /* - * Current offset pointer of the START or HONMON file. - */ - off_t location; - - /* - * The current point of a buffer on which text is written. - */ - char *out; - - /* - * Length of `out'. - */ - size_t out_rest_length; - - /* - * Unprocessed string that a hook function writes on text. - */ - char *unprocessed; - - /* - * Size of `unprocessed'. - */ - size_t unprocessed_size; - - /* - * Length of the current output text phrase. - */ - size_t out_step; - - /* - * Narrow character region flag. - */ - int narrow_flag; - - /* - * Whether a printable character has been appeared in the current - * text content. - */ - int printable_count; - - /* - * EOF flag of the current subbook. - */ - int file_end_flag; - - /* - * Status of the current text processing. - */ - EB_Text_Status_Code text_status; - - /* - * Skip until `skipcode' appears. - */ - int skip_code; - - /* - * Stop-code automatically set by EB Library. - */ - int auto_stop_code; - - /* - * The current candidate word for multi search. - */ - char candidate[EB_MAX_WORD_LENGTH + 1]; - - /* - * Whether the current text point is in the candidate word or not. - */ - int is_candidate; - - /* - * Whether the current text point is in EBXA-C gaiji area. - */ - int ebxac_gaiji_flag; -}; - -/* - * Context parameters for word search. - */ -struct EB_Search_Context_Struct { - /* - * Current search method type. - * The context is not active, if this code is EB_SEARCH_NONE. - */ - EB_Search_Code code; - - /* - * Function which compares word to search and pattern in an index page. - */ - int (*compare_pre)(const char *word, const char *pattern, - size_t length); - int (*compare_single)(const char *word, const char *pattern, - size_t length); - int (*compare_group)(const char *word, const char *pattern, - size_t length); - - /* - * Result of comparison by `compare'. - */ - int comparison_result; - - /* - * Word to search. - */ - char word[EB_MAX_WORD_LENGTH + 1]; - - /* - * Canonicalized word to search. - */ - char canonicalized_word[EB_MAX_WORD_LENGTH + 1]; - - /* - * Page which is searched currently. - */ - int page; - - /* - * Offset which is searched currently in the page. - */ - int offset; - - /* - * Page ID of the current page. - */ - int page_id; - - /* - * How many entries in the current page. - */ - int entry_count; - - /* - * Entry index pointer. - */ - int entry_index; - - /* - * Length of the current entry. - */ - int entry_length; - - /* - * Arrangement style of entries in the current page (fixed or variable). - */ - int entry_arrangement; - - /* - * In a group entry or not. - */ - int in_group_entry; - - /* - * Current heading position (for keyword search). - */ - EB_Position keyword_heading; -}; - -/* - * A book. - */ -struct EB_Book_Struct { - /* - * Book ID. - */ - EB_Book_Code code; - - /* - * Disc type. EB* or EPWING. - */ - EB_Disc_Code disc_code; - - /* - * Character code of the book. - */ - EB_Character_Code character_code; - - /* - * Path of the book. - */ - char *path; - - /* - * The length of the path. - */ - size_t path_length; - - /* - * The number of subbooks the book has. - */ - int subbook_count; - - /* - * Subbook list. - */ - EB_Subbook *subbooks; - - /* - * Current subbook. - */ - EB_Subbook *subbook_current; - - /* - * Context parameters for text reading. - */ - EB_Text_Context text_context; - - /* - * Context parameters for binary reading. - */ - EB_Binary_Context binary_context; - - /* - * Context parameters for text reading. - */ - EB_Search_Context search_contexts[EB_NUMBER_OF_SEARCH_CONTEXTS]; - - /* - * ebnet socket file. - */ -#ifdef EB_ENABLE_EBNET - int ebnet_file; -#endif - - /* - * Lock. - */ -#ifdef EB_ENABLE_PTHREAD - EB_Lock lock; -#endif -}; - -/* - * In a word search, heading and text locations of a matched entry - * are stored. - */ -struct EB_Hit_Struct { - /* - * Heading position. - */ - EB_Position heading; - - /* - * Text position. - */ - EB_Position text; -}; - -/* - * A text hook. - */ -struct EB_Hook_Struct { - /* - * Hook code. - */ - EB_Hook_Code code; - - /* - * Hook function for the hook code `code'. - */ - EB_Error_Code (*function)(EB_Book *book, EB_Appendix *appendix, - void *container, EB_Hook_Code hook_code, int argc, - const unsigned int *argv); -}; - -/* - * A set of text hooks. - */ -struct EB_Hookset_Struct { - /* - * List of hooks. - */ - EB_Hook hooks[EB_NUMBER_OF_HOOKS]; - - /* - * Lock. - */ -#ifdef EB_ENABLE_PTHREAD - EB_Lock lock; -#endif -}; - -/* - * An entry of book list. - */ -struct EB_BookList_Entry { - /* - * name. - */ - char *name; - - /* - * Title. - */ - char *title; -}; - -/* - * Book list. - */ -struct EB_BookList { - /* - * Book List ID. - */ - EB_Book_Code code; - - /* - * The number of book entries this list has. - */ - int entry_count; - - /* - * The maximum number of book entries that `entries' can memory. - */ - int max_entry_count; - - /* - * Book entries. - */ - EB_BookList_Entry *entries; - - /* - * Lock. - */ -#ifdef EB_ENABLE_PTHREAD - EB_Lock lock; -#endif -}; - -/* for backward compatibility */ -#define EB_Multi_Entry_Code int - -#ifdef __cplusplus -} -#endif - -#endif /* not EB_DEFS_H */ diff --git a/maclibs/include/eb/eb.h b/maclibs/include/eb/eb.h deleted file mode 100644 index 9adf57a9..00000000 --- a/maclibs/include/eb/eb.h +++ /dev/null @@ -1,155 +0,0 @@ -/* -*- C -*- - * Copyright (c) 1997-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef EB_EB_H -#define EB_EB_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef EB_BUILD_LIBRARY -#include "defs.h" -#else -#include -#endif - -#include - -/* - * Function declarations. - */ -/* book.c */ -void eb_initialize_book(EB_Book *book); -EB_Error_Code eb_bind(EB_Book *book, const char *path); -void eb_finalize_book(EB_Book *book); -int eb_is_bound(EB_Book *book); -EB_Error_Code eb_path(EB_Book *book, char *path); -EB_Error_Code eb_disc_type(EB_Book *book, EB_Disc_Code *disc_code); -EB_Error_Code eb_character_code(EB_Book *book, - EB_Character_Code *character_code); - -/* copyright.h */ -int eb_have_copyright(EB_Book *book); -EB_Error_Code eb_copyright(EB_Book *book, EB_Position *position); -EB_Error_Code eb_search_cross(EB_Book *book, - const char * const input_words[]); - -/* cross.c */ -int eb_have_cross_search(EB_Book *book); - -/* eb.c */ -EB_Error_Code eb_initialize_library(void); -void eb_finalize_library(void); - -/* endword.c */ -int eb_have_endword_search(EB_Book *book); -EB_Error_Code eb_search_endword(EB_Book *book, const char *input_word); - -/* exactword.c */ -int eb_have_exactword_search(EB_Book *book); -EB_Error_Code eb_search_exactword(EB_Book *book, const char *input_word); - -/* graphic.c */ -int eb_have_graphic_search(EB_Book *book); - -/* keyword.c */ -int eb_have_keyword_search(EB_Book *book); -EB_Error_Code eb_search_keyword(EB_Book *book, - const char * const input_words[]); - -/* lock.c */ -int eb_pthread_enabled(void); - -/* log.c */ -void eb_set_log_function(void (*function)(const char *message, va_list ap)); -void eb_enable_log(void); -void eb_disable_log(void); -void eb_log(const char *message, ...); -void eb_log_stderr(const char *message, va_list ap); - -/* menu.c */ -int eb_have_menu(EB_Book *book); -EB_Error_Code eb_menu(EB_Book *book, EB_Position *position); -int eb_have_image_menu(EB_Book *book); -EB_Error_Code eb_image_menu(EB_Book *book, EB_Position *position); - -/* multi.c */ -int eb_have_multi_search(EB_Book *book); -EB_Error_Code eb_multi_title(EB_Book *book, EB_Multi_Search_Code multi_id, - char *title); -EB_Error_Code eb_multi_search_list(EB_Book *book, - EB_Multi_Search_Code *search_list, int *search_count); -EB_Error_Code eb_multi_entry_count(EB_Book *book, - EB_Multi_Search_Code multi_id, int *entry_count); -EB_Error_Code eb_multi_entry_list(EB_Book *book, - EB_Multi_Search_Code multi_id, int *entry_list, int *entry_count); -EB_Error_Code eb_multi_entry_label(EB_Book *book, - EB_Multi_Search_Code multi_id, int entry_index, char *label); -int eb_multi_entry_have_candidates(EB_Book *book, - EB_Multi_Search_Code multi_id, int entry_index); -EB_Error_Code eb_multi_entry_candidates(EB_Book *book, - EB_Multi_Search_Code multi_id, int entry_index, EB_Position *position); -EB_Error_Code eb_search_multi(EB_Book *book, EB_Multi_Search_Code multi_id, - const char * const input_words[]); - -/* text.c */ -int eb_have_text(EB_Book *book); -EB_Error_Code eb_text(EB_Book *book, EB_Position *position); - -/* search.c */ -EB_Error_Code eb_hit_list(EB_Book *book, int max_hit_count, EB_Hit *hit_list, - int *hit_count); - -/* subbook.c */ -EB_Error_Code eb_load_all_subbooks(EB_Book *book); -EB_Error_Code eb_subbook_list(EB_Book *book, EB_Subbook_Code *subbook_list, - int *subbook_count); -EB_Error_Code eb_subbook(EB_Book *book, EB_Subbook_Code *subbook_code); -EB_Error_Code eb_subbook_title(EB_Book *book, char *title); -EB_Error_Code eb_subbook_title2(EB_Book *book, EB_Subbook_Code subbook_code, - char *title); -EB_Error_Code eb_subbook_directory(EB_Book *book, char *directory); -EB_Error_Code eb_subbook_directory2(EB_Book *book, - EB_Subbook_Code subbook_code, char *directory); -EB_Error_Code eb_set_subbook(EB_Book *book, EB_Subbook_Code subbook_code); -void eb_unset_subbook(EB_Book *book); - -/* word.c */ -int eb_have_word_search(EB_Book *book); -EB_Error_Code eb_search_word(EB_Book *book, const char *input_word); - -/* for backward compatibility */ -#define eb_suspend eb_unset_subbook -#define eb_initialize_all_subbooks eb_load_all_subbooks - -#ifdef __cplusplus -} -#endif - -#endif /* not EB_EB_H */ diff --git a/maclibs/include/eb/error.h b/maclibs/include/eb/error.h deleted file mode 100644 index b2f2b392..00000000 --- a/maclibs/include/eb/error.h +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- C -*- - * Copyright (c) 1997-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef EB_ERROR_H -#define EB_ERROR_H - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef EB_BUILD_LIBRARY -#include "defs.h" -#else -#include -#endif - -/* - * Error codes. - */ -#define EB_SUCCESS 0 -#define EB_ERR_MEMORY_EXHAUSTED 1 -#define EB_ERR_EMPTY_FILE_NAME 2 -#define EB_ERR_TOO_LONG_FILE_NAME 3 -#define EB_ERR_BAD_FILE_NAME 4 - -#define EB_ERR_BAD_DIR_NAME 5 -#define EB_ERR_TOO_LONG_WORD 6 -#define EB_ERR_BAD_WORD 7 -#define EB_ERR_EMPTY_WORD 8 -#define EB_ERR_FAIL_GETCWD 9 - -#define EB_ERR_FAIL_OPEN_CAT 10 -#define EB_ERR_FAIL_OPEN_CATAPP 11 -#define EB_ERR_FAIL_OPEN_TEXT 12 -#define EB_ERR_FAIL_OPEN_FONT 13 -#define EB_ERR_FAIL_OPEN_APP 14 - -#define EB_ERR_FAIL_OPEN_BINARY 15 -#define EB_ERR_FAIL_READ_CAT 16 -#define EB_ERR_FAIL_READ_CATAPP 17 -#define EB_ERR_FAIL_READ_TEXT 18 -#define EB_ERR_FAIL_READ_FONT 19 - -#define EB_ERR_FAIL_READ_APP 20 -#define EB_ERR_FAIL_READ_BINARY 21 -#define EB_ERR_FAIL_SEEK_CAT 22 -#define EB_ERR_FAIL_SEEK_CATAPP 23 -#define EB_ERR_FAIL_SEEK_TEXT 24 - -#define EB_ERR_FAIL_SEEK_FONT 25 -#define EB_ERR_FAIL_SEEK_APP 26 -#define EB_ERR_FAIL_SEEK_BINARY 27 -#define EB_ERR_UNEXP_CAT 28 -#define EB_ERR_UNEXP_CATAPP 29 - -#define EB_ERR_UNEXP_TEXT 30 -#define EB_ERR_UNEXP_FONT 31 -#define EB_ERR_UNEXP_APP 32 -#define EB_ERR_UNEXP_BINARY 33 -#define EB_ERR_UNBOUND_BOOK 34 - -#define EB_ERR_UNBOUND_APP 35 -#define EB_ERR_NO_SUB 36 -#define EB_ERR_NO_APPSUB 37 -#define EB_ERR_NO_FONT 38 -#define EB_ERR_NO_TEXT 39 - -#define EB_ERR_NO_STOPCODE 40 -#define EB_ERR_NO_ALT 41 -#define EB_ERR_NO_CUR_SUB 42 -#define EB_ERR_NO_CUR_APPSUB 43 -#define EB_ERR_NO_CUR_FONT 44 - -#define EB_ERR_NO_CUR_BINARY 45 -#define EB_ERR_NO_SUCH_SUB 46 -#define EB_ERR_NO_SUCH_APPSUB 47 -#define EB_ERR_NO_SUCH_FONT 48 -#define EB_ERR_NO_SUCH_CHAR_BMP 49 - -#define EB_ERR_NO_SUCH_CHAR_TEXT 50 -#define EB_ERR_NO_SUCH_SEARCH 51 -#define EB_ERR_NO_SUCH_HOOK 52 -#define EB_ERR_NO_SUCH_BINARY 53 -#define EB_ERR_DIFF_CONTENT 54 - -#define EB_ERR_NO_PREV_SEARCH 55 -#define EB_ERR_NO_SUCH_MULTI_ID 56 -#define EB_ERR_NO_SUCH_ENTRY_ID 57 -#define EB_ERR_TOO_MANY_WORDS 58 -#define EB_ERR_NO_WORD 59 - -#define EB_ERR_NO_CANDIDATES 60 -#define EB_ERR_END_OF_CONTENT 61 -#define EB_ERR_NO_PREV_SEEK 62 -#define EB_ERR_EBNET_UNSUPPORTED 63 -#define EB_ERR_EBNET_FAIL_CONNECT 64 - -#define EB_ERR_EBNET_SERVER_BUSY 65 -#define EB_ERR_EBNET_NO_PERMISSION 66 -#define EB_ERR_UNBOUND_BOOKLIST 67 -#define EB_ERR_NO_SUCH_BOOK 68 - - -/* - * The number of error codes. - */ -#define EB_NUMBER_OF_ERRORS 69 - -/* - * The maximum length of an error message. - */ -#define EB_MAX_ERROR_MESSAGE_LENGTH 127 - -/* - * Function declarations. - */ -/* error.c */ -const char *eb_error_string(EB_Error_Code error_code); -const char *eb_error_message(EB_Error_Code error_code); - -#ifdef __cplusplus -} -#endif - -#endif /* not EB_ERROR_H */ diff --git a/maclibs/include/eb/font.h b/maclibs/include/eb/font.h deleted file mode 100644 index bd4d6758..00000000 --- a/maclibs/include/eb/font.h +++ /dev/null @@ -1,200 +0,0 @@ -/* -*- C -*- - * Copyright (c) 1997-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef EB_FONT_H -#define EB_FONT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef EB_BUILD_LIBRARY -#include "defs.h" -#else -#include -#endif - -/* - * Font types. - */ -#define EB_FONT_16 0 -#define EB_FONT_24 1 -#define EB_FONT_30 2 -#define EB_FONT_48 3 -#define EB_FONT_INVALID -1 - -/* - * Font sizes. - */ -#define EB_SIZE_NARROW_FONT_16 16 -#define EB_SIZE_WIDE_FONT_16 32 -#define EB_SIZE_NARROW_FONT_24 48 -#define EB_SIZE_WIDE_FONT_24 72 -#define EB_SIZE_NARROW_FONT_30 60 -#define EB_SIZE_WIDE_FONT_30 120 -#define EB_SIZE_NARROW_FONT_48 144 -#define EB_SIZE_WIDE_FONT_48 288 - -/* - * Font width. - */ -#define EB_WIDTH_NARROW_FONT_16 8 -#define EB_WIDTH_WIDE_FONT_16 16 -#define EB_WIDTH_NARROW_FONT_24 16 -#define EB_WIDTH_WIDE_FONT_24 24 -#define EB_WIDTH_NARROW_FONT_30 16 -#define EB_WIDTH_WIDE_FONT_30 32 -#define EB_WIDTH_NARROW_FONT_48 24 -#define EB_WIDTH_WIDE_FONT_48 48 - -/* - * Font height. - */ -#define EB_HEIGHT_FONT_16 16 -#define EB_HEIGHT_FONT_24 24 -#define EB_HEIGHT_FONT_30 30 -#define EB_HEIGHT_FONT_48 48 - -/* - * Bitmap image sizes. - */ -#define EB_SIZE_NARROW_FONT_16_XBM 184 -#define EB_SIZE_WIDE_FONT_16_XBM 284 -#define EB_SIZE_NARROW_FONT_16_XPM 266 -#define EB_SIZE_WIDE_FONT_16_XPM 395 -#define EB_SIZE_NARROW_FONT_16_GIF 186 -#define EB_SIZE_WIDE_FONT_16_GIF 314 -#define EB_SIZE_NARROW_FONT_16_BMP 126 -#define EB_SIZE_WIDE_FONT_16_BMP 126 -#define EB_SIZE_NARROW_FONT_16_PNG 131 -#define EB_SIZE_WIDE_FONT_16_PNG 147 - -#define EB_SIZE_NARROW_FONT_24_XBM 383 -#define EB_SIZE_WIDE_FONT_24_XBM 533 -#define EB_SIZE_NARROW_FONT_24_XPM 555 -#define EB_SIZE_WIDE_FONT_24_XPM 747 -#define EB_SIZE_NARROW_FONT_24_GIF 450 -#define EB_SIZE_WIDE_FONT_24_GIF 642 -#define EB_SIZE_NARROW_FONT_24_BMP 158 -#define EB_SIZE_WIDE_FONT_24_BMP 158 -#define EB_SIZE_NARROW_FONT_24_PNG 171 -#define EB_SIZE_WIDE_FONT_24_PNG 195 - -#define EB_SIZE_NARROW_FONT_30_XBM 458 -#define EB_SIZE_WIDE_FONT_30_XBM 833 -#define EB_SIZE_NARROW_FONT_30_XPM 675 -#define EB_SIZE_WIDE_FONT_30_XPM 1155 -#define EB_SIZE_NARROW_FONT_30_GIF 552 -#define EB_SIZE_WIDE_FONT_30_GIF 1032 -#define EB_SIZE_NARROW_FONT_30_BMP 182 -#define EB_SIZE_WIDE_FONT_30_BMP 182 -#define EB_SIZE_NARROW_FONT_30_PNG 189 -#define EB_SIZE_WIDE_FONT_30_PNG 249 - -#define EB_SIZE_NARROW_FONT_48_XBM 983 -#define EB_SIZE_WIDE_FONT_48_XBM 1883 -#define EB_SIZE_NARROW_FONT_48_XPM 1419 -#define EB_SIZE_WIDE_FONT_48_XPM 2571 -#define EB_SIZE_NARROW_FONT_48_GIF 1242 -#define EB_SIZE_WIDE_FONT_48_GIF 2394 -#define EB_SIZE_NARROW_FONT_48_BMP 254 -#define EB_SIZE_WIDE_FONT_48_BMP 446 -#define EB_SIZE_NARROW_FONT_48_PNG 291 -#define EB_SIZE_WIDE_FONT_48_PNG 435 - -#define EB_SIZE_FONT_IMAGE EB_SIZE_WIDE_FONT_48_XPM - -/* - * Function declarations. - */ -/* bitmap.c */ -EB_Error_Code eb_narrow_font_xbm_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_narrow_font_xpm_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_narrow_font_gif_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_narrow_font_bmp_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_narrow_font_png_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_wide_font_xbm_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_wide_font_xpm_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_wide_font_gif_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_wide_font_bmp_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_wide_font_png_size(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_bitmap_to_xbm(const char *bitmap, int width, int height, - char *xbm, size_t *xbm_length); -EB_Error_Code eb_bitmap_to_xpm(const char *bitmap, int width, int height, - char *xpm, size_t *xpm_length); -EB_Error_Code eb_bitmap_to_gif(const char *bitmap, int width, int height, - char *gif, size_t *gif_length); -EB_Error_Code eb_bitmap_to_bmp(const char *bitmap, int width, int height, - char *bmp, size_t *bmp_length); -EB_Error_Code eb_bitmap_to_png(const char *bitmap, int width, int height, - char *png, size_t *png_length); - -/* font.c */ -EB_Error_Code eb_font(EB_Book *book, EB_Font_Code *font_code); -EB_Error_Code eb_set_font(EB_Book *book, EB_Font_Code font_code); -void eb_unset_font(EB_Book *book); -EB_Error_Code eb_font_list(EB_Book *book, EB_Font_Code *font_list, - int *font_count); -int eb_have_font(EB_Book *book, EB_Font_Code font_code); -EB_Error_Code eb_font_height(EB_Book *book, int *height); -EB_Error_Code eb_font_height2(EB_Font_Code font_code, int *height); - -/* narwfont.c */ -int eb_have_narrow_font(EB_Book *book); -EB_Error_Code eb_narrow_font_width(EB_Book *book, int *width); -EB_Error_Code eb_narrow_font_width2(EB_Font_Code font_code, int *width); -EB_Error_Code eb_narrow_font_size(EB_Book *book, size_t *size); -EB_Error_Code eb_narrow_font_size2(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_narrow_font_start(EB_Book *book, int *start); -EB_Error_Code eb_narrow_font_end(EB_Book *book, int *end); -EB_Error_Code eb_narrow_font_character_bitmap(EB_Book *book, int, char *); -EB_Error_Code eb_forward_narrow_font_character(EB_Book *book, int, int *); -EB_Error_Code eb_backward_narrow_font_character(EB_Book *book, int, int *); - -/* widefont.c */ -int eb_have_wide_font(EB_Book *book); -EB_Error_Code eb_wide_font_width(EB_Book *book, int *width); -EB_Error_Code eb_wide_font_width2(EB_Font_Code font_code, int *width); -EB_Error_Code eb_wide_font_size(EB_Book *book, size_t *size); -EB_Error_Code eb_wide_font_size2(EB_Font_Code font_code, size_t *size); -EB_Error_Code eb_wide_font_start(EB_Book *book, int *start); -EB_Error_Code eb_wide_font_end(EB_Book *book, int *end); -EB_Error_Code eb_wide_font_character_bitmap(EB_Book *book, - int character_number, char *bitmap); -EB_Error_Code eb_forward_wide_font_character(EB_Book *book, int n, - int *character_number); -EB_Error_Code eb_backward_wide_font_character(EB_Book *book, int n, - int *character_number); - -#ifdef __cplusplus -} -#endif - -#endif /* not EB_FONT_H */ diff --git a/maclibs/include/eb/sysdefs.h b/maclibs/include/eb/sysdefs.h deleted file mode 100644 index e66f8776..00000000 --- a/maclibs/include/eb/sysdefs.h +++ /dev/null @@ -1,4 +0,0 @@ -/* automatically generated by Makefile. */ -#define EB_VERSION_STRING "4.4.3" -#define EB_VERSION_MAJOR 4 -#define EB_VERSION_MINOR 4 diff --git a/maclibs/include/eb/text.h b/maclibs/include/eb/text.h deleted file mode 100644 index caba03ea..00000000 --- a/maclibs/include/eb/text.h +++ /dev/null @@ -1,166 +0,0 @@ -/* -*- C -*- - * Copyright (c) 1997-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef EB_TEXT_H -#define EB_TEXT_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#ifdef EB_BUILD_LIBRARY -#include "defs.h" -#else -#include -#endif - -/* - * Hook codes. - * (When you add or remove a hook, update EB_NUMER_OF_HOOKS in defs.h.) - */ -#define EB_HOOK_NULL -1 -#define EB_HOOK_INITIALIZE 0 -#define EB_HOOK_BEGIN_NARROW 1 -#define EB_HOOK_END_NARROW 2 -#define EB_HOOK_BEGIN_SUBSCRIPT 3 -#define EB_HOOK_END_SUBSCRIPT 4 - -#define EB_HOOK_SET_INDENT 5 -#define EB_HOOK_NEWLINE 6 -#define EB_HOOK_BEGIN_SUPERSCRIPT 7 -#define EB_HOOK_END_SUPERSCRIPT 8 -#define EB_HOOK_BEGIN_NO_NEWLINE 9 - -#define EB_HOOK_END_NO_NEWLINE 10 -#define EB_HOOK_BEGIN_EMPHASIS 11 -#define EB_HOOK_END_EMPHASIS 12 -#define EB_HOOK_BEGIN_CANDIDATE 13 -#define EB_HOOK_END_CANDIDATE_GROUP 14 - -#define EB_HOOK_END_CANDIDATE_LEAF 15 -#define EB_HOOK_BEGIN_REFERENCE 16 -#define EB_HOOK_END_REFERENCE 17 -#define EB_HOOK_BEGIN_KEYWORD 18 -#define EB_HOOK_END_KEYWORD 19 - -#define EB_HOOK_NARROW_FONT 20 -#define EB_HOOK_WIDE_FONT 21 -#define EB_HOOK_ISO8859_1 22 -#define EB_HOOK_NARROW_JISX0208 23 -#define EB_HOOK_WIDE_JISX0208 24 - -#define EB_HOOK_GB2312 25 -#define EB_HOOK_BEGIN_MONO_GRAPHIC 26 -#define EB_HOOK_END_MONO_GRAPHIC 27 -#define EB_HOOK_BEGIN_GRAY_GRAPHIC 28 -#define EB_HOOK_END_GRAY_GRAPHIC 29 - -#define EB_HOOK_BEGIN_COLOR_BMP 30 -#define EB_HOOK_BEGIN_COLOR_JPEG 31 -#define EB_HOOK_BEGIN_IN_COLOR_BMP 32 -#define EB_HOOK_BEGIN_IN_COLOR_JPEG 33 -#define EB_HOOK_END_COLOR_GRAPHIC 34 - -#define EB_HOOK_END_IN_COLOR_GRAPHIC 35 -#define EB_HOOK_BEGIN_WAVE 36 -#define EB_HOOK_END_WAVE 37 -#define EB_HOOK_BEGIN_MPEG 38 -#define EB_HOOK_END_MPEG 39 - -#define EB_HOOK_BEGIN_GRAPHIC_REFERENCE 40 -#define EB_HOOK_END_GRAPHIC_REFERENCE 41 -#define EB_HOOK_GRAPHIC_REFERENCE 42 -#define EB_HOOK_BEGIN_DECORATION 43 -#define EB_HOOK_END_DECORATION 44 - -#define EB_HOOK_BEGIN_IMAGE_PAGE 45 -#define EB_HOOK_END_IMAGE_PAGE 46 -#define EB_HOOK_BEGIN_CLICKABLE_AREA 47 -#define EB_HOOK_END_CLICKABLE_AREA 48 - -#define EB_HOOK_BEGIN_UNICODE 49 -#define EB_HOOK_END_UNICODE 50 -#define EB_HOOK_BEGIN_EBXAC_GAIJI 51 -#define EB_HOOK_END_EBXAC_GAIJI 52 -#define EB_HOOK_EBXAC_GAIJI 53 - -/* - * Function declarations. - */ -/* hook.c */ -void eb_initialize_hookset(EB_Hookset *hookset); -void eb_finalize_hookset(EB_Hookset *hookset); -EB_Error_Code eb_set_hook(EB_Hookset *hookset, const EB_Hook *hook); -EB_Error_Code eb_set_hooks(EB_Hookset *hookset, const EB_Hook *hook); -EB_Error_Code eb_hook_euc_to_ascii(EB_Book *book, EB_Appendix *appendix, - void *container, EB_Hook_Code hook_code, int argc, - const unsigned int *argv); -EB_Error_Code eb_hook_stop_code(EB_Book *book, EB_Appendix *appendix, - void *container, EB_Hook_Code hook_code, int argc, - const unsigned int *argv); -EB_Error_Code eb_hook_narrow_character_text(EB_Book *book, - EB_Appendix *appendix, void *container, EB_Hook_Code hook_code, int argc, - const unsigned int *argv); -EB_Error_Code eb_hook_wide_character_text(EB_Book *book, - EB_Appendix *appendix, void *container, EB_Hook_Code hook_code, int argc, - const unsigned int *argv); -EB_Error_Code eb_hook_newline(EB_Book *book, EB_Appendix *appendix, - void *container, EB_Hook_Code hook_code, int argc, - const unsigned int *argv); -EB_Error_Code eb_hook_empty(EB_Book *book, EB_Appendix *appendix, - void *container, EB_Hook_Code hook_code, int argc, - const unsigned int *argv); - -/* readtext.c */ -EB_Error_Code eb_seek_text(EB_Book *book, const EB_Position *position); -EB_Error_Code eb_tell_text(EB_Book *book, EB_Position *position); -EB_Error_Code eb_read_text(EB_Book *book, EB_Appendix *appendix, - EB_Hookset *hookset, void *container, size_t text_max_length, char *text, - ssize_t *text_length); -EB_Error_Code eb_read_heading(EB_Book *book, EB_Appendix *appendix, - EB_Hookset *hookset, void *container, size_t text_max_length, char *text, - ssize_t *text_length); -EB_Error_Code eb_read_rawtext(EB_Book *book, size_t text_max_length, - char *text, ssize_t *text_length); -int eb_is_text_stopped(EB_Book *book); -EB_Error_Code eb_write_text_byte1(EB_Book *book, int byte1); -EB_Error_Code eb_write_text_byte2(EB_Book *book, int byte1, int byte2); -EB_Error_Code eb_write_text_string(EB_Book *book, const char *string); -EB_Error_Code eb_write_text(EB_Book *book, const char * stream, - size_t stream_length); -const char *eb_current_candidate(EB_Book *book); -EB_Error_Code eb_forward_text(EB_Book *book, EB_Appendix *appendix); -EB_Error_Code eb_backward_text(EB_Book *book, EB_Appendix *appendix); - -#ifdef __cplusplus -} -#endif - -#endif /* not EB_TEXT_H */ diff --git a/maclibs/include/eb/zio.h b/maclibs/include/eb/zio.h deleted file mode 100644 index 0cb7bbd8..00000000 --- a/maclibs/include/eb/zio.h +++ /dev/null @@ -1,237 +0,0 @@ -/* -*- C -*- - * Copyright (c) 2001-2006 Motoyuki Kasahara - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef ZIO_H -#define ZIO_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/* - * Header size of the ebzip compression file. - */ -#define ZIO_SIZE_EBZIP_HEADER 22 - -/* - * Margin size for ebzip compression buffer. - * (Since compressed data is larger than original in the worst case, - * we must add margin to a compression buffer.) - */ -#define ZIO_SIZE_EBZIP_MARGIN 1024 - -/* - * Maximum ebzio compression level. - */ -#define ZIO_MAX_EBZIP_LEVEL 5 - -/* - * Huffman node types. - */ -#define ZIO_HUFFMAN_NODE_INTERMEDIATE 0 -#define ZIO_HUFFMAN_NODE_EOF 1 -#define ZIO_HUFFMAN_NODE_LEAF8 2 -#define ZIO_HUFFMAN_NODE_LEAF16 3 -#define ZIO_HUFFMAN_NODE_LEAF32 4 - -/* - * Compression type codes. - */ -#define ZIO_PLAIN 0 -#define ZIO_EBZIP1 1 -#define ZIO_EPWING 2 -#define ZIO_EPWING6 3 -#define ZIO_SEBXA 4 -#define ZIO_INVALID -1 -#define ZIO_REOPEN -2 - -/* - * Compression type. - */ -typedef int Zio_Code; - -/* - * A node of static Huffman tree. - */ -typedef struct Zio_Huffman_Node_Struct Zio_Huffman_Node; - -struct Zio_Huffman_Node_Struct { - /* - * node type (ITNERMEDIATE, LEAF8, LEAF16, LEAF32 or EOF). - */ - int type; - - /* - * Value of a leaf node. - */ - unsigned int value; - - /* - * Frequency of a node. - */ - int frequency; - - /* - * Left child. - */ - Zio_Huffman_Node *left; - - /* - * Right child. - */ - Zio_Huffman_Node *right; -}; - -/* - * Compression information of a book. - */ -typedef struct Zio_Struct Zio; - -struct Zio_Struct { - /* - * ID. - */ - int id; - - /* - * Zio type. (PLAIN, EBZIP, EPWING, EPWING6 or SEBXA) - */ - Zio_Code code; - - /* - * File descriptor. - */ - int file; - - /* - * Current location. - */ - off_t location; - - /* - * Size of an uncompressed file. - */ - off_t file_size; - - /* - * Slice size of an EBZIP compressed file. - */ - size_t slice_size; - - /* - * Compression level. (EBZIP compression only) - */ - int zip_level; - - /* - * Length of an index. (EBZIP compression only) - */ - int index_width; - - /* - * Adler-32 check sum of an uncompressed file. (EBZIP compression only) - */ - unsigned int crc; - - /* - * mtime of an uncompressed file. (EBZIP compression only) - */ - time_t mtime; - - /* - * Location of an index table. (EPWING and S-EBXA compression only) - */ - off_t index_location; - - /* - * Length of an index table. (EPWING and S-EBXA compression only) - */ - size_t index_length; - - /* - * Location of a frequency table. (EPWING compression only) - */ - off_t frequencies_location; - - /* - * Length of a frequency table. (EPWING compression only) - */ - size_t frequencies_length; - - /* - * Huffman tree nodes. (EPWING compression only) - */ - Zio_Huffman_Node *huffman_nodes; - - /* - * Root node of a Huffman tree. (EPWING compression only) - */ - Zio_Huffman_Node *huffman_root; - - /* - * Region of compressed pages. (S-EBXA compression only) - */ - off_t zio_start_location; - off_t zio_end_location; - - /* - * Add this value to offset written in index. (S-EBXA compression only) - */ - off_t index_base; - - /* - * ebnet mode flag. - */ - int is_ebnet; -}; - -/* - * Function declarations. - */ -/* zio.c */ -int zio_initialize_library(void); -void zio_finalize_library(void); -void zio_initialize(Zio *zio); -void zio_finalize(Zio *zio); -int zio_set_sebxa_mode(Zio *zio, off_t index_location, off_t index_base, - off_t zio_start_location, off_t zio_end_location); -int zio_open(Zio *zio, const char *file_name, Zio_Code zio_code); -void zio_close(Zio *zio); -int zio_file(Zio *zio); -Zio_Code zio_mode(Zio *zio); -off_t zio_lseek(Zio *zio, off_t offset, int whence); -ssize_t zio_read(Zio *zio, char *buffer, size_t length); - -#ifdef __cplusplus -} -#endif - -#endif /* not ZIO_H */ diff --git a/maclibs/include/hunspell/affentry.hxx b/maclibs/include/hunspell/affentry.hxx deleted file mode 100644 index 4bafc043..00000000 --- a/maclibs/include/hunspell/affentry.hxx +++ /dev/null @@ -1,223 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef AFFIX_HXX_ -#define AFFIX_HXX_ - -#include "atypes.hxx" -#include "baseaffix.hxx" -#include "affixmgr.hxx" - -/* A Prefix Entry */ - -class PfxEntry : public AffEntry { - private: - PfxEntry(const PfxEntry&); - PfxEntry& operator=(const PfxEntry&); - - private: - AffixMgr* pmyMgr; - - PfxEntry* next; - PfxEntry* nexteq; - PfxEntry* nextne; - PfxEntry* flgnxt; - - public: - explicit PfxEntry(AffixMgr* pmgr); - - bool allowCross() const { return ((opts & aeXPRODUCT) != 0); } - struct hentry* checkword(const char* word, - int len, - char in_compound, - const FLAG needflag = FLAG_NULL); - - struct hentry* check_twosfx(const char* word, - int len, - char in_compound, - const FLAG needflag = FLAG_NULL); - - std::string check_morph(const char* word, - int len, - char in_compound, - const FLAG needflag = FLAG_NULL); - - std::string check_twosfx_morph(const char* word, - int len, - char in_compound, - const FLAG needflag = FLAG_NULL); - - FLAG getFlag() { return aflag; } - const char* getKey() { return appnd.c_str(); } - std::string add(const char* word, size_t len); - - inline short getKeyLen() { return appnd.size(); } - - inline const char* getMorph() { return morphcode; } - - inline const unsigned short* getCont() { return contclass; } - inline short getContLen() { return contclasslen; } - - inline PfxEntry* getNext() { return next; } - inline PfxEntry* getNextNE() { return nextne; } - inline PfxEntry* getNextEQ() { return nexteq; } - inline PfxEntry* getFlgNxt() { return flgnxt; } - - inline void setNext(PfxEntry* ptr) { next = ptr; } - inline void setNextNE(PfxEntry* ptr) { nextne = ptr; } - inline void setNextEQ(PfxEntry* ptr) { nexteq = ptr; } - inline void setFlgNxt(PfxEntry* ptr) { flgnxt = ptr; } - - inline char* nextchar(char* p); - inline int test_condition(const char* st); -}; - -/* A Suffix Entry */ - -class SfxEntry : public AffEntry { - private: - SfxEntry(const SfxEntry&); - SfxEntry& operator=(const SfxEntry&); - - private: - AffixMgr* pmyMgr; - std::string rappnd; - - SfxEntry* next; - SfxEntry* nexteq; - SfxEntry* nextne; - SfxEntry* flgnxt; - - SfxEntry* l_morph; - SfxEntry* r_morph; - SfxEntry* eq_morph; - - public: - explicit SfxEntry(AffixMgr* pmgr); - - bool allowCross() const { return ((opts & aeXPRODUCT) != 0); } - struct hentry* checkword(const char* word, - int len, - int optflags, - PfxEntry* ppfx, - const FLAG cclass, - const FLAG needflag, - const FLAG badflag); - - struct hentry* check_twosfx(const char* word, - int len, - int optflags, - PfxEntry* ppfx, - const FLAG needflag = FLAG_NULL); - - std::string check_twosfx_morph(const char* word, - int len, - int optflags, - PfxEntry* ppfx, - const FLAG needflag = FLAG_NULL); - struct hentry* get_next_homonym(struct hentry* he); - struct hentry* get_next_homonym(struct hentry* word, - int optflags, - PfxEntry* ppfx, - const FLAG cclass, - const FLAG needflag); - - FLAG getFlag() { return aflag; } - const char* getKey() { return rappnd.c_str(); } - std::string add(const char* word, size_t len); - - inline const char* getMorph() { return morphcode; } - - inline const unsigned short* getCont() { return contclass; } - inline short getContLen() { return contclasslen; } - inline const char* getAffix() { return appnd.c_str(); } - - inline short getKeyLen() { return appnd.size(); } - - inline SfxEntry* getNext() { return next; } - inline SfxEntry* getNextNE() { return nextne; } - inline SfxEntry* getNextEQ() { return nexteq; } - - inline SfxEntry* getLM() { return l_morph; } - inline SfxEntry* getRM() { return r_morph; } - inline SfxEntry* getEQM() { return eq_morph; } - inline SfxEntry* getFlgNxt() { return flgnxt; } - - inline void setNext(SfxEntry* ptr) { next = ptr; } - inline void setNextNE(SfxEntry* ptr) { nextne = ptr; } - inline void setNextEQ(SfxEntry* ptr) { nexteq = ptr; } - inline void setFlgNxt(SfxEntry* ptr) { flgnxt = ptr; } - void initReverseWord(); - - inline char* nextchar(char* p); - inline int test_condition(const char* st, const char* begin); -}; - -#endif diff --git a/maclibs/include/hunspell/affixmgr.hxx b/maclibs/include/hunspell/affixmgr.hxx deleted file mode 100644 index d41e69cf..00000000 --- a/maclibs/include/hunspell/affixmgr.hxx +++ /dev/null @@ -1,369 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef AFFIXMGR_HXX_ -#define AFFIXMGR_HXX_ - -#include - -#include -#include - -#include "atypes.hxx" -#include "baseaffix.hxx" -#include "hashmgr.hxx" -#include "phonet.hxx" -#include "replist.hxx" - -// check flag duplication -#define dupSFX (1 << 0) -#define dupPFX (1 << 1) - -class PfxEntry; -class SfxEntry; - -class AffixMgr { - PfxEntry* pStart[SETSIZE]; - SfxEntry* sStart[SETSIZE]; - PfxEntry* pFlag[SETSIZE]; - SfxEntry* sFlag[SETSIZE]; - const std::vector& alldic; - const HashMgr* pHMgr; - std::string keystring; - std::string trystring; - std::string encoding; - struct cs_info* csconv; - int utf8; - int complexprefixes; - FLAG compoundflag; - FLAG compoundbegin; - FLAG compoundmiddle; - FLAG compoundend; - FLAG compoundroot; - FLAG compoundforbidflag; - FLAG compoundpermitflag; - int compoundmoresuffixes; - int checkcompounddup; - int checkcompoundrep; - int checkcompoundcase; - int checkcompoundtriple; - int simplifiedtriple; - FLAG forbiddenword; - FLAG nosuggest; - FLAG nongramsuggest; - FLAG needaffix; - int cpdmin; - bool parsedrep; - std::vector reptable; - RepList* iconvtable; - RepList* oconvtable; - bool parsedmaptable; - std::vector maptable; - bool parsedbreaktable; - std::vector breaktable; - bool parsedcheckcpd; - std::vector checkcpdtable; - int simplifiedcpd; - bool parseddefcpd; - std::vector defcpdtable; - phonetable* phone; - int maxngramsugs; - int maxcpdsugs; - int maxdiff; - int onlymaxdiff; - int nosplitsugs; - int sugswithdots; - int cpdwordmax; - int cpdmaxsyllable; - std::string cpdvowels; // vowels (for calculating of Hungarian compounding limit, - std::vector cpdvowels_utf16; //vowels for UTF-8 encoding - std::string cpdsyllablenum; // syllable count incrementing flag - const char* pfxappnd; // BUG: not stateless - const char* sfxappnd; // BUG: not stateless - int sfxextra; // BUG: not stateless - FLAG sfxflag; // BUG: not stateless - char* derived; // BUG: not stateless - SfxEntry* sfx; // BUG: not stateless - PfxEntry* pfx; // BUG: not stateless - int checknum; - std::string wordchars; // letters + spec. word characters - std::vector wordchars_utf16; - std::string ignorechars; // letters + spec. word characters - std::vector ignorechars_utf16; - std::string version; // affix and dictionary file version string - std::string lang; // language - int langnum; - FLAG lemma_present; - FLAG circumfix; - FLAG onlyincompound; - FLAG keepcase; - FLAG forceucase; - FLAG warn; - int forbidwarn; - FLAG substandard; - int checksharps; - int fullstrip; - - int havecontclass; // boolean variable - char contclasses[CONTSIZE]; // flags of possible continuing classes (twofold - // affix) - - public: - AffixMgr(const char* affpath, const std::vector& ptr, const char* key = NULL); - ~AffixMgr(); - struct hentry* affix_check(const char* word, - int len, - const unsigned short needflag = (unsigned short)0, - char in_compound = IN_CPD_NOT); - struct hentry* prefix_check(const char* word, - int len, - char in_compound, - const FLAG needflag = FLAG_NULL); - inline int isSubset(const char* s1, const char* s2); - struct hentry* prefix_check_twosfx(const char* word, - int len, - char in_compound, - const FLAG needflag = FLAG_NULL); - inline int isRevSubset(const char* s1, const char* end_of_s2, int len); - struct hentry* suffix_check(const char* word, - int len, - int sfxopts, - PfxEntry* ppfx, - const FLAG cclass = FLAG_NULL, - const FLAG needflag = FLAG_NULL, - char in_compound = IN_CPD_NOT); - struct hentry* suffix_check_twosfx(const char* word, - int len, - int sfxopts, - PfxEntry* ppfx, - const FLAG needflag = FLAG_NULL); - - std::string affix_check_morph(const char* word, - int len, - const FLAG needflag = FLAG_NULL, - char in_compound = IN_CPD_NOT); - std::string prefix_check_morph(const char* word, - int len, - char in_compound, - const FLAG needflag = FLAG_NULL); - std::string suffix_check_morph(const char* word, - int len, - int sfxopts, - PfxEntry* ppfx, - const FLAG cclass = FLAG_NULL, - const FLAG needflag = FLAG_NULL, - char in_compound = IN_CPD_NOT); - - std::string prefix_check_twosfx_morph(const char* word, - int len, - char in_compound, - const FLAG needflag = FLAG_NULL); - std::string suffix_check_twosfx_morph(const char* word, - int len, - int sfxopts, - PfxEntry* ppfx, - const FLAG needflag = FLAG_NULL); - - std::string morphgen(const char* ts, - int wl, - const unsigned short* ap, - unsigned short al, - const char* morph, - const char* targetmorph, - int level); - - int expand_rootword(struct guessword* wlst, - int maxn, - const char* ts, - int wl, - const unsigned short* ap, - unsigned short al, - const char* bad, - int, - const char*); - - short get_syllable(const std::string& word); - int cpdrep_check(const char* word, int len); - int cpdpat_check(const char* word, - int len, - hentry* r1, - hentry* r2, - const char affixed); - int defcpd_check(hentry*** words, - short wnum, - hentry* rv, - hentry** rwords, - char all); - int cpdcase_check(const char* word, int len); - inline int candidate_check(const char* word, int len); - void setcminmax(int* cmin, int* cmax, const char* word, int len); - struct hentry* compound_check(const std::string& word, - short wordnum, - short numsyllable, - short maxwordnum, - short wnum, - hentry** words, - hentry** rwords, - char hu_mov_rule, - char is_sug, - int* info); - - int compound_check_morph(const char* word, - int len, - short wordnum, - short numsyllable, - short maxwordnum, - short wnum, - hentry** words, - hentry** rwords, - char hu_mov_rule, - std::string& result, - const std::string* partresult); - - std::vector get_suffix_words(short unsigned* suff, - int len, - const char* root_word); - - struct hentry* lookup(const char* word); - const std::vector& get_reptable() const; - RepList* get_iconvtable() const; - RepList* get_oconvtable() const; - struct phonetable* get_phonetable() const; - const std::vector& get_maptable() const; - const std::vector& get_breaktable() const; - const std::string& get_encoding(); - int get_langnum() const; - char* get_key_string(); - char* get_try_string() const; - const std::string& get_wordchars() const; - const std::vector& get_wordchars_utf16() const; - const char* get_ignore() const; - const std::vector& get_ignore_utf16() const; - int get_compound() const; - FLAG get_compoundflag() const; - FLAG get_forbiddenword() const; - FLAG get_nosuggest() const; - FLAG get_nongramsuggest() const; - FLAG get_needaffix() const; - FLAG get_onlyincompound() const; - const char* get_derived() const; - const std::string& get_version() const; - int have_contclass() const; - int get_utf8() const; - int get_complexprefixes() const; - char* get_suffixed(char) const; - int get_maxngramsugs() const; - int get_maxcpdsugs() const; - int get_maxdiff() const; - int get_onlymaxdiff() const; - int get_nosplitsugs() const; - int get_sugswithdots(void) const; - FLAG get_keepcase(void) const; - FLAG get_forceucase(void) const; - FLAG get_warn(void) const; - int get_forbidwarn(void) const; - int get_checksharps(void) const; - char* encode_flag(unsigned short aflag) const; - int get_fullstrip() const; - - private: - int parse_file(const char* affpath, const char* key); - bool parse_flag(const std::string& line, unsigned short* out, FileMgr* af); - bool parse_num(const std::string& line, int* out, FileMgr* af); - bool parse_cpdsyllable(const std::string& line, FileMgr* af); - bool parse_reptable(const std::string& line, FileMgr* af); - bool parse_convtable(const std::string& line, - FileMgr* af, - RepList** rl, - const std::string& keyword); - bool parse_phonetable(const std::string& line, FileMgr* af); - bool parse_maptable(const std::string& line, FileMgr* af); - bool parse_breaktable(const std::string& line, FileMgr* af); - bool parse_checkcpdtable(const std::string& line, FileMgr* af); - bool parse_defcpdtable(const std::string& line, FileMgr* af); - bool parse_affix(const std::string& line, const char at, FileMgr* af, char* dupflags); - - void reverse_condition(std::string&); - std::string& debugflag(std::string& result, unsigned short flag); - int condlen(const char*); - int encodeit(AffEntry& entry, const char* cs); - int build_pfxtree(PfxEntry* pfxptr); - int build_sfxtree(SfxEntry* sfxptr); - int process_pfx_order(); - int process_sfx_order(); - PfxEntry* process_pfx_in_order(PfxEntry* ptr, PfxEntry* nptr); - SfxEntry* process_sfx_in_order(SfxEntry* ptr, SfxEntry* nptr); - int process_pfx_tree_to_list(); - int process_sfx_tree_to_list(); - int redundant_condition(char, const char* strip, int stripl, const char* cond, int); - void finishFileMgr(FileMgr* afflst); -}; - -#endif diff --git a/maclibs/include/hunspell/atypes.hxx b/maclibs/include/hunspell/atypes.hxx deleted file mode 100644 index f8415231..00000000 --- a/maclibs/include/hunspell/atypes.hxx +++ /dev/null @@ -1,119 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef ATYPES_HXX_ -#define ATYPES_HXX_ - -#ifndef HUNSPELL_WARNING -#include -#ifdef HUNSPELL_WARNING_ON -#define HUNSPELL_WARNING fprintf -#else -// empty inline function to switch off warnings (instead of the C99 standard -// variadic macros) -static inline void HUNSPELL_WARNING(FILE*, const char*, ...) {} -#endif -#endif - -// HUNSTEM def. -#define HUNSTEM - -#include "w_char.hxx" -#include -#include -#include - -#define SETSIZE 256 -#define CONTSIZE 65536 - -// AffEntry options -#define aeXPRODUCT (1 << 0) -#define aeUTF8 (1 << 1) -#define aeALIASF (1 << 2) -#define aeALIASM (1 << 3) -#define aeLONGCOND (1 << 4) - -// compound options -#define IN_CPD_NOT 0 -#define IN_CPD_BEGIN 1 -#define IN_CPD_END 2 -#define IN_CPD_OTHER 3 - -// info options -#define SPELL_COMPOUND (1 << 0) -#define SPELL_FORBIDDEN (1 << 1) -#define SPELL_ALLCAP (1 << 2) -#define SPELL_NOCAP (1 << 3) -#define SPELL_INITCAP (1 << 4) -#define SPELL_ORIGCAP (1 << 5) -#define SPELL_WARN (1 << 6) - -#define MINCPDLEN 3 -#define MAXCOMPOUND 10 -#define MAXCONDLEN 20 -#define MAXCONDLEN_1 (MAXCONDLEN - sizeof(char*)) - -#define MAXACC 1000 - -#define FLAG unsigned short -#define FLAG_NULL 0x00 -#define FREE_FLAG(a) a = 0 - -#define TESTAFF(a, b, c) (std::binary_search(a, a + c, b)) - -struct guessword { - char* word; - bool allow; - char* orig; -}; - -typedef std::vector mapentry; -typedef std::vector flagentry; - -struct patentry { - std::string pattern; - std::string pattern2; - std::string pattern3; - FLAG cond; - FLAG cond2; - patentry() - : cond(FLAG_NULL) - , cond2(FLAG_NULL) { - } -}; - -#endif diff --git a/maclibs/include/hunspell/baseaffix.hxx b/maclibs/include/hunspell/baseaffix.hxx deleted file mode 100644 index 9191dba4..00000000 --- a/maclibs/include/hunspell/baseaffix.hxx +++ /dev/null @@ -1,74 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef BASEAFF_HXX_ -#define BASEAFF_HXX_ - -#include - -class AffEntry { - private: - AffEntry(const AffEntry&); - AffEntry& operator=(const AffEntry&); - - public: - AffEntry() - : numconds(0), - opts(0), - aflag(0), - morphcode(0), - contclass(NULL), - contclasslen(0) {} - virtual ~AffEntry(); - std::string appnd; - std::string strip; - unsigned char numconds; - char opts; - unsigned short aflag; - union { - char conds[MAXCONDLEN]; - struct { - char conds1[MAXCONDLEN_1]; - char* conds2; - } l; - } c; - char* morphcode; - unsigned short* contclass; - short contclasslen; -}; - -#endif diff --git a/maclibs/include/hunspell/csutil.hxx b/maclibs/include/hunspell/csutil.hxx deleted file mode 100644 index 5d83f809..00000000 --- a/maclibs/include/hunspell/csutil.hxx +++ /dev/null @@ -1,314 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef CSUTIL_HXX_ -#define CSUTIL_HXX_ - -#include "hunvisapi.h" - -// First some base level utility routines - -#include -#include -#include -#include -#include "w_char.hxx" -#include "htypes.hxx" - -#ifdef MOZILLA_CLIENT -#include "nscore.h" // for mozalloc headers -#endif - -// casing -#define NOCAP 0 -#define INITCAP 1 -#define ALLCAP 2 -#define HUHCAP 3 -#define HUHINITCAP 4 - -// default encoding and keystring -#define SPELL_ENCODING "ISO8859-1" -#define SPELL_KEYSTRING "qwertyuiop|asdfghjkl|zxcvbnm" - -// default morphological fields -#define MORPH_STEM "st:" -#define MORPH_ALLOMORPH "al:" -#define MORPH_POS "po:" -#define MORPH_DERI_PFX "dp:" -#define MORPH_INFL_PFX "ip:" -#define MORPH_TERM_PFX "tp:" -#define MORPH_DERI_SFX "ds:" -#define MORPH_INFL_SFX "is:" -#define MORPH_TERM_SFX "ts:" -#define MORPH_SURF_PFX "sp:" -#define MORPH_FREQ "fr:" -#define MORPH_PHON "ph:" -#define MORPH_HYPH "hy:" -#define MORPH_PART "pa:" -#define MORPH_FLAG "fl:" -#define MORPH_HENTRY "_H:" -#define MORPH_TAG_LEN strlen(MORPH_STEM) - -#define MSEP_FLD ' ' -#define MSEP_REC '\n' -#define MSEP_ALT '\v' - -// default flags -#define DEFAULTFLAGS 65510 -#define FORBIDDENWORD 65510 -#define ONLYUPCASEFLAG 65511 - -// fix long pathname problem of WIN32 by using w_char std::fstream::open override -LIBHUNSPELL_DLL_EXPORTED void myopen(std::ifstream& stream, const char* path, - std::ios_base::openmode mode); - -// convert UTF-16 characters to UTF-8 -LIBHUNSPELL_DLL_EXPORTED std::string& u16_u8(std::string& dest, - const std::vector& src); - -// convert UTF-8 characters to UTF-16 -LIBHUNSPELL_DLL_EXPORTED int u8_u16(std::vector& dest, - const std::string& src); - -// remove end of line char(s) -LIBHUNSPELL_DLL_EXPORTED void mychomp(std::string& s); - -// duplicate string -LIBHUNSPELL_DLL_EXPORTED char* mystrdup(const char* s); - -// parse into tokens with char delimiter -LIBHUNSPELL_DLL_EXPORTED std::string::const_iterator mystrsep(const std::string &str, - std::string::const_iterator& start); - -// replace pat by rep in word and return word -LIBHUNSPELL_DLL_EXPORTED std::string& mystrrep(std::string& str, - const std::string& search, - const std::string& replace); - -// append s to ends of every lines in text -LIBHUNSPELL_DLL_EXPORTED std::string& strlinecat(std::string& str, - const std::string& apd); - -// tokenize into lines with new line -LIBHUNSPELL_DLL_EXPORTED std::vector line_tok(const std::string& text, - char breakchar); - -// tokenize into lines with new line and uniq in place -LIBHUNSPELL_DLL_EXPORTED void line_uniq(std::string& text, char breakchar); - -LIBHUNSPELL_DLL_EXPORTED void line_uniq_app(std::string& text, char breakchar); - -// reverse word -LIBHUNSPELL_DLL_EXPORTED size_t reverseword(std::string& word); - -// reverse word -LIBHUNSPELL_DLL_EXPORTED size_t reverseword_utf(std::string&); - -// remove duplicates -LIBHUNSPELL_DLL_EXPORTED void uniqlist(std::vector& list); - -// character encoding information -struct cs_info { - unsigned char ccase; - unsigned char clower; - unsigned char cupper; -}; - -LIBHUNSPELL_DLL_EXPORTED void initialize_utf_tbl(); -LIBHUNSPELL_DLL_EXPORTED void free_utf_tbl(); -LIBHUNSPELL_DLL_EXPORTED unsigned short unicodetoupper(unsigned short c, - int langnum); -LIBHUNSPELL_DLL_EXPORTED w_char upper_utf(w_char u, int langnum); -LIBHUNSPELL_DLL_EXPORTED w_char lower_utf(w_char u, int langnum); -LIBHUNSPELL_DLL_EXPORTED unsigned short unicodetolower(unsigned short c, - int langnum); -LIBHUNSPELL_DLL_EXPORTED int unicodeisalpha(unsigned short c); - -LIBHUNSPELL_DLL_EXPORTED struct cs_info* get_current_cs(const std::string& es); - -// get language identifiers of language codes -LIBHUNSPELL_DLL_EXPORTED int get_lang_num(const std::string& lang); - -// get characters of the given 8bit encoding with lower- and uppercase forms -LIBHUNSPELL_DLL_EXPORTED std::string get_casechars(const char* enc); - -// convert std::string to all caps -LIBHUNSPELL_DLL_EXPORTED std::string& mkallcap(std::string& s, - const struct cs_info* csconv); - -// convert null terminated string to all little -LIBHUNSPELL_DLL_EXPORTED std::string& mkallsmall(std::string& s, - const struct cs_info* csconv); - -// convert first letter of string to little -LIBHUNSPELL_DLL_EXPORTED std::string& mkinitsmall(std::string& s, - const struct cs_info* csconv); - -// convert first letter of string to capital -LIBHUNSPELL_DLL_EXPORTED std::string& mkinitcap(std::string& s, - const struct cs_info* csconv); - -// convert first letter of UTF-8 string to capital -LIBHUNSPELL_DLL_EXPORTED std::vector& -mkinitcap_utf(std::vector& u, int langnum); - -// convert UTF-8 string to little -LIBHUNSPELL_DLL_EXPORTED std::vector& -mkallsmall_utf(std::vector& u, int langnum); - -// convert first letter of UTF-8 string to little -LIBHUNSPELL_DLL_EXPORTED std::vector& -mkinitsmall_utf(std::vector& u, int langnum); - -// convert UTF-8 string to capital -LIBHUNSPELL_DLL_EXPORTED std::vector& -mkallcap_utf(std::vector& u, int langnum); - -// get type of capitalization -LIBHUNSPELL_DLL_EXPORTED int get_captype(const std::string& q, cs_info*); - -// get type of capitalization (UTF-8) -LIBHUNSPELL_DLL_EXPORTED int get_captype_utf8(const std::vector& q, int langnum); - -// strip all ignored characters in the string -LIBHUNSPELL_DLL_EXPORTED size_t remove_ignored_chars_utf( - std::string& word, - const std::vector& ignored_chars); - -// strip all ignored characters in the string -LIBHUNSPELL_DLL_EXPORTED size_t remove_ignored_chars( - std::string& word, - const std::string& ignored_chars); - -LIBHUNSPELL_DLL_EXPORTED bool parse_string(const std::string& line, - std::string& out, - int ln); - -LIBHUNSPELL_DLL_EXPORTED bool parse_array(const std::string& line, - std::string& out, - std::vector& out_utf16, - int utf8, - int ln); - -LIBHUNSPELL_DLL_EXPORTED int fieldlen(const char* r); - -LIBHUNSPELL_DLL_EXPORTED bool copy_field(std::string& dest, - const std::string& morph, - const std::string& var); - -// conversion function for protected memory -LIBHUNSPELL_DLL_EXPORTED void store_pointer(char* dest, char* source); - -// conversion function for protected memory -LIBHUNSPELL_DLL_EXPORTED char* get_stored_pointer(const char* s); - -// hash entry macros -LIBHUNSPELL_DLL_EXPORTED inline char* HENTRY_DATA(struct hentry* h) { - char* ret; - if (!h->var) - ret = NULL; - else if (h->var & H_OPT_ALIASM) - ret = get_stored_pointer(HENTRY_WORD(h) + h->blen + 1); - else - ret = HENTRY_WORD(h) + h->blen + 1; - return ret; -} - -LIBHUNSPELL_DLL_EXPORTED inline const char* HENTRY_DATA( - const struct hentry* h) { - const char* ret; - if (!h->var) - ret = NULL; - else if (h->var & H_OPT_ALIASM) - ret = get_stored_pointer(HENTRY_WORD(h) + h->blen + 1); - else - ret = HENTRY_WORD(h) + h->blen + 1; - return ret; -} - -// NULL-free version for warning-free OOo build -LIBHUNSPELL_DLL_EXPORTED inline const char* HENTRY_DATA2( - const struct hentry* h) { - const char* ret; - if (!h->var) - ret = ""; - else if (h->var & H_OPT_ALIASM) - ret = get_stored_pointer(HENTRY_WORD(h) + h->blen + 1); - else - ret = HENTRY_WORD(h) + h->blen + 1; - return ret; -} - -LIBHUNSPELL_DLL_EXPORTED inline char* HENTRY_FIND(struct hentry* h, - const char* p) { - return (HENTRY_DATA(h) ? strstr(HENTRY_DATA(h), p) : NULL); -} - -#endif diff --git a/maclibs/include/hunspell/filemgr.hxx b/maclibs/include/hunspell/filemgr.hxx deleted file mode 100644 index 62433aee..00000000 --- a/maclibs/include/hunspell/filemgr.hxx +++ /dev/null @@ -1,98 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* file manager class - read lines of files [filename] OR [filename.hz] */ -#ifndef FILEMGR_HXX_ -#define FILEMGR_HXX_ - -#include "hunzip.hxx" -#include -#include -#include - -class FileMgr { - private: - FileMgr(const FileMgr&); - FileMgr& operator=(const FileMgr&); - - protected: - std::ifstream fin; - Hunzip* hin; - char in[BUFSIZE + 50]; // input buffer - int fail(const char* err, const char* par); - int linenum; - - public: - FileMgr(const char* filename, const char* key = NULL); - ~FileMgr(); - bool getline(std::string&); - int getlinenum(); -}; -#endif diff --git a/maclibs/include/hunspell/hashmgr.hxx b/maclibs/include/hunspell/hashmgr.hxx deleted file mode 100644 index da485d7a..00000000 --- a/maclibs/include/hunspell/hashmgr.hxx +++ /dev/null @@ -1,145 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef HASHMGR_HXX_ -#define HASHMGR_HXX_ - -#include -#include -#include - -#include "htypes.hxx" -#include "filemgr.hxx" -#include "w_char.hxx" - -enum flag { FLAG_CHAR, FLAG_LONG, FLAG_NUM, FLAG_UNI }; - -class HashMgr { - int tablesize; - struct hentry** tableptr; - flag flag_mode; - int complexprefixes; - int utf8; - unsigned short forbiddenword; - int langnum; - std::string enc; - std::string lang; - struct cs_info* csconv; - std::string ignorechars; - std::vector ignorechars_utf16; - int numaliasf; // flag vector `compression' with aliases - unsigned short** aliasf; - unsigned short* aliasflen; - int numaliasm; // morphological desciption `compression' with aliases - char** aliasm; - - public: - HashMgr(const char* tpath, const char* apath, const char* key = NULL); - ~HashMgr(); - - struct hentry* lookup(const char*) const; - int hash(const char*) const; - struct hentry* walk_hashtable(int& col, struct hentry* hp) const; - - int add(const std::string& word); - int add_with_affix(const std::string& word, const std::string& pattern); - int remove(const std::string& word); - int decode_flags(unsigned short** result, const std::string& flags, FileMgr* af) const; - bool decode_flags(std::vector& result, const std::string& flags, FileMgr* af) const; - unsigned short decode_flag(const char* flag) const; - char* encode_flag(unsigned short flag) const; - int is_aliasf() const; - int get_aliasf(int index, unsigned short** fvec, FileMgr* af) const; - int is_aliasm() const; - char* get_aliasm(int index) const; - - private: - int get_clen_and_captype(const std::string& word, int* captype); - int get_clen_and_captype(const std::string& word, int* captype, std::vector &workbuf); - int load_tables(const char* tpath, const char* key); - int add_word(const std::string& word, - int wcl, - unsigned short* ap, - int al, - const std::string* desc, - bool onlyupcase); - int load_config(const char* affpath, const char* key); - bool parse_aliasf(const std::string& line, FileMgr* af); - int add_hidden_capitalized_word(const std::string& word, - int wcl, - unsigned short* flags, - int al, - const std::string* dp, - int captype); - bool parse_aliasm(const std::string& line, FileMgr* af); - int remove_forbidden_flag(const std::string& word); -}; - -#endif diff --git a/maclibs/include/hunspell/htypes.hxx b/maclibs/include/hunspell/htypes.hxx deleted file mode 100644 index 8f66a008..00000000 --- a/maclibs/include/hunspell/htypes.hxx +++ /dev/null @@ -1,68 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef HTYPES_HXX_ -#define HTYPES_HXX_ - -#define ROTATE_LEN 5 - -#define ROTATE(v, q) \ - (v) = ((v) << (q)) | (((v) >> (32 - q)) & ((1 << (q)) - 1)); - -// hentry options -#define H_OPT (1 << 0) -#define H_OPT_ALIASM (1 << 1) -#define H_OPT_PHON (1 << 2) - -// see also csutil.hxx -#define HENTRY_WORD(h) &(h->word[0]) - -// approx. number of user defined words -#define USERWORD 1000 - -struct hentry { - unsigned char blen; // word length in bytes - unsigned char clen; // word length in characters (different for UTF-8 enc.) - short alen; // length of affix flag vector - unsigned short* astr; // affix flag vector - struct hentry* next; // next word with same hash code - struct hentry* next_homonym; // next homonym word (with same hash code) - char var; // variable fields (only for special pronounciation yet) - char word[1]; // variable-length word (8-bit or UTF-8 encoding) -}; - -#endif diff --git a/maclibs/include/hunspell/hunspell.h b/maclibs/include/hunspell/hunspell.h deleted file mode 100644 index 3aca30ab..00000000 --- a/maclibs/include/hunspell/hunspell.h +++ /dev/null @@ -1,162 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Hunspell, based on MySpell. - * - * The Initial Developers of the Original Code are - * Kevin Hendricks (MySpell) and Németh László (Hunspell). - * Portions created by the Initial Developers are Copyright (C) 2002-2005 - * the Initial Developers. All Rights Reserved. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef MYSPELLMGR_H_ -#define MYSPELLMGR_H_ - -#include "hunvisapi.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct Hunhandle Hunhandle; - -LIBHUNSPELL_DLL_EXPORTED Hunhandle* Hunspell_create(const char* affpath, - const char* dpath); - -LIBHUNSPELL_DLL_EXPORTED Hunhandle* Hunspell_create_key(const char* affpath, - const char* dpath, - const char* key); - -LIBHUNSPELL_DLL_EXPORTED void Hunspell_destroy(Hunhandle* pHunspell); - -/* load extra dictionaries (only dic files) - * output: 0 = additional dictionary slots available, 1 = slots are now full*/ -LIBHUNSPELL_DLL_EXPORTED int Hunspell_add_dic(Hunhandle* pHunspell, - const char* dpath); - -/* spell(word) - spellcheck word - * output: 0 = bad word, not 0 = good word - */ -LIBHUNSPELL_DLL_EXPORTED int Hunspell_spell(Hunhandle* pHunspell, const char*); - -LIBHUNSPELL_DLL_EXPORTED char* Hunspell_get_dic_encoding(Hunhandle* pHunspell); - -/* suggest(suggestions, word) - search suggestions - * input: pointer to an array of strings pointer and the (bad) word - * array of strings pointer (here *slst) may not be initialized - * output: number of suggestions in string array, and suggestions in - * a newly allocated array of strings (*slts will be NULL when number - * of suggestion equals 0.) - */ -LIBHUNSPELL_DLL_EXPORTED int Hunspell_suggest(Hunhandle* pHunspell, - char*** slst, - const char* word); - -/* morphological functions */ - -/* analyze(result, word) - morphological analysis of the word */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_analyze(Hunhandle* pHunspell, - char*** slst, - const char* word); - -/* stem(result, word) - stemmer function */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_stem(Hunhandle* pHunspell, - char*** slst, - const char* word); - -/* stem(result, analysis, n) - get stems from a morph. analysis - * example: - * char ** result, result2; - * int n1 = Hunspell_analyze(result, "words"); - * int n2 = Hunspell_stem2(result2, result, n1); - */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_stem2(Hunhandle* pHunspell, - char*** slst, - char** desc, - int n); - -/* generate(result, word, word2) - morphological generation by example(s) */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_generate(Hunhandle* pHunspell, - char*** slst, - const char* word, - const char* word2); - -/* generate(result, word, desc, n) - generation by morph. description(s) - * example: - * char ** result; - * char * affix = "is:plural"; // description depends from dictionaries, too - * int n = Hunspell_generate2(result, "word", &affix, 1); - * for (int i = 0; i < n; i++) printf("%s\n", result[i]); - */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_generate2(Hunhandle* pHunspell, - char*** slst, - const char* word, - char** desc, - int n); - -/* functions for run-time modification of the dictionary */ - -/* add word to the run-time dictionary */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_add(Hunhandle* pHunspell, - const char* word); - -/* add word to the run-time dictionary with affix flags of - * the example (a dictionary word): Hunspell will recognize - * affixed forms of the new word, too. - */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_add_with_affix(Hunhandle* pHunspell, - const char* word, - const char* example); - -/* remove word from the run-time dictionary */ - -LIBHUNSPELL_DLL_EXPORTED int Hunspell_remove(Hunhandle* pHunspell, - const char* word); - -/* free suggestion lists */ - -LIBHUNSPELL_DLL_EXPORTED void Hunspell_free_list(Hunhandle* pHunspell, - char*** slst, - int n); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/maclibs/include/hunspell/hunspell.hxx b/maclibs/include/hunspell/hunspell.hxx deleted file mode 100644 index a06bdd43..00000000 --- a/maclibs/include/hunspell/hunspell.hxx +++ /dev/null @@ -1,229 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ -#ifndef MYSPELLMGR_HXX_ -#define MYSPELLMGR_HXX_ - -#include "hunvisapi.h" -#include "w_char.hxx" -#include "atypes.hxx" -#include -#include - -#define SPELL_XML "" - -#define MAXSUGGESTION 15 -#define MAXSHARPS 5 - -#ifndef MAXWORDLEN -#define MAXWORDLEN 100 -#endif - -#if defined __GNUC__ && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)) -# define H_DEPRECATED __attribute__((__deprecated__)) -#elif defined(_MSC_VER) && (_MSC_VER >= 1300) -# define H_DEPRECATED __declspec(deprecated) -#else -# define H_DEPRECATED -#endif - -class HunspellImpl; - -class LIBHUNSPELL_DLL_EXPORTED Hunspell { - private: - Hunspell(const Hunspell&); - Hunspell& operator=(const Hunspell&); - - private: - HunspellImpl* m_Impl; - - public: - /* Hunspell(aff, dic) - constructor of Hunspell class - * input: path of affix file and dictionary file - * - * In WIN32 environment, use UTF-8 encoded paths started with the long path - * prefix \\\\?\\ to handle system-independent character encoding and very - * long path names (without the long path prefix Hunspell will use fopen() - * with system-dependent character encoding instead of _wfopen()). - */ - Hunspell(const char* affpath, const char* dpath, const char* key = NULL); - ~Hunspell(); - - /* load extra dictionaries (only dic files) */ - int add_dic(const char* dpath, const char* key = NULL); - - /* spell(word) - spellcheck word - * output: false = bad word, true = good word - * - * plus output: - * info: information bit array, fields: - * SPELL_COMPOUND = a compound word - * SPELL_FORBIDDEN = an explicit forbidden word - * root: root (stem), when input is a word with affix(es) - */ - bool spell(const std::string& word, int* info = NULL, std::string* root = NULL); - H_DEPRECATED int spell(const char* word, int* info = NULL, char** root = NULL); - - /* suggest(suggestions, word) - search suggestions - * input: pointer to an array of strings pointer and the (bad) word - * array of strings pointer (here *slst) may not be initialized - * output: number of suggestions in string array, and suggestions in - * a newly allocated array of strings (*slts will be NULL when number - * of suggestion equals 0.) - */ - std::vector suggest(const std::string& word); - H_DEPRECATED int suggest(char*** slst, const char* word); - - /* Suggest words from suffix rules - * suffix_suggest(suggestions, root_word) - * input: pointer to an array of strings pointer and the word - * array of strings pointer (here *slst) may not be initialized - * output: number of suggestions in string array, and suggestions in - * a newly allocated array of strings (*slts will be NULL when number - * of suggestion equals 0.) - */ - std::vector suffix_suggest(const std::string& root_word); - H_DEPRECATED int suffix_suggest(char*** slst, const char* root_word); - - /* deallocate suggestion lists */ - H_DEPRECATED void free_list(char*** slst, int n); - - const std::string& get_dict_encoding() const; - char* get_dic_encoding(); - - /* morphological functions */ - - /* analyze(result, word) - morphological analysis of the word */ - std::vector analyze(const std::string& word); - H_DEPRECATED int analyze(char*** slst, const char* word); - - /* stem(word) - stemmer function */ - std::vector stem(const std::string& word); - H_DEPRECATED int stem(char*** slst, const char* word); - - /* stem(analysis, n) - get stems from a morph. analysis - * example: - * char ** result, result2; - * int n1 = analyze(&result, "words"); - * int n2 = stem(&result2, result, n1); - */ - std::vector stem(const std::vector& morph); - H_DEPRECATED int stem(char*** slst, char** morph, int n); - - /* generate(result, word, word2) - morphological generation by example(s) */ - std::vector generate(const std::string& word, const std::string& word2); - H_DEPRECATED int generate(char*** slst, const char* word, const char* word2); - - /* generate(result, word, desc, n) - generation by morph. description(s) - * example: - * char ** result; - * char * affix = "is:plural"; // description depends from dictionaries, too - * int n = generate(&result, "word", &affix, 1); - * for (int i = 0; i < n; i++) printf("%s\n", result[i]); - */ - std::vector generate(const std::string& word, const std::vector& pl); - H_DEPRECATED int generate(char*** slst, const char* word, char** desc, int n); - - /* functions for run-time modification of the dictionary */ - - /* add word to the run-time dictionary */ - - int add(const std::string& word); - - /* add word to the run-time dictionary with affix flags of - * the example (a dictionary word): Hunspell will recognize - * affixed forms of the new word, too. - */ - - int add_with_affix(const std::string& word, const std::string& example); - - /* remove word from the run-time dictionary */ - - int remove(const std::string& word); - - /* other */ - - /* get extra word characters definied in affix file for tokenization */ - const char* get_wordchars() const; - const std::string& get_wordchars_cpp() const; - const std::vector& get_wordchars_utf16() const; - - struct cs_info* get_csconv(); - - const char* get_version() const; - const std::string& get_version_cpp() const; - - int get_langnum() const; - - /* need for putdic */ - bool input_conv(const std::string& word, std::string& dest); - H_DEPRECATED int input_conv(const char* word, char* dest, size_t destsize); -}; - -#endif diff --git a/maclibs/include/hunspell/hunvisapi.h b/maclibs/include/hunspell/hunvisapi.h deleted file mode 100644 index eb2b3480..00000000 --- a/maclibs/include/hunspell/hunvisapi.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef HUNSPELL_VISIBILITY_H_ -#define HUNSPELL_VISIBILITY_H_ - -#if defined(HUNSPELL_STATIC) -# define LIBHUNSPELL_DLL_EXPORTED -#elif defined(_MSC_VER) -# if defined(BUILDING_LIBHUNSPELL) -# define LIBHUNSPELL_DLL_EXPORTED __declspec(dllexport) -# else -# define LIBHUNSPELL_DLL_EXPORTED __declspec(dllimport) -# endif -#elif defined(BUILDING_LIBHUNSPELL) && 1 -# define LIBHUNSPELL_DLL_EXPORTED __attribute__((__visibility__("default"))) -#else -# define LIBHUNSPELL_DLL_EXPORTED -#endif - -#endif diff --git a/maclibs/include/hunspell/hunzip.hxx b/maclibs/include/hunspell/hunzip.hxx deleted file mode 100644 index ea2bc58d..00000000 --- a/maclibs/include/hunspell/hunzip.hxx +++ /dev/null @@ -1,87 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* hunzip: file decompression for sorted dictionaries with optional encryption, - * algorithm: prefix-suffix encoding and 16-bit Huffman encoding */ - -#ifndef HUNZIP_HXX_ -#define HUNZIP_HXX_ - -#include "hunvisapi.h" - -#include -#include -#include - -#define BUFSIZE 65536 -#define HZIP_EXTENSION ".hz" - -#define MSG_OPEN "error: %s: cannot open\n" -#define MSG_FORMAT "error: %s: not in hzip format\n" -#define MSG_MEMORY "error: %s: missing memory\n" -#define MSG_KEY "error: %s: missing or bad password\n" - -struct bit { - unsigned char c[2]; - int v[2]; -}; - -class LIBHUNSPELL_DLL_EXPORTED Hunzip { - private: - Hunzip(const Hunzip&); - Hunzip& operator=(const Hunzip&); - - protected: - char* filename; - std::ifstream fin; - int bufsiz, lastbit, inc, inbits, outc; - std::vector dec; // code table - char in[BUFSIZE]; // input buffer - char out[BUFSIZE + 1]; // Huffman-decoded buffer - char line[BUFSIZE + 50]; // decoded line - int getcode(const char* key); - int getbuf(); - int fail(const char* err, const char* par); - - public: - Hunzip(const char* filename, const char* key = NULL); - ~Hunzip(); - bool is_open() { return fin.is_open(); } - bool getline(std::string& dest); -}; - -#endif diff --git a/maclibs/include/hunspell/langnum.hxx b/maclibs/include/hunspell/langnum.hxx deleted file mode 100644 index a64d3d78..00000000 --- a/maclibs/include/hunspell/langnum.hxx +++ /dev/null @@ -1,75 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef LANGNUM_HXX_ -#define LANGNUM_HXX_ - -/* - language numbers for language specific codes - see https://wiki.openoffice.org/w/index.php?title=Languages&oldid=230199 -*/ - -enum { - LANG_ar = 96, - LANG_az = 100, // custom number - LANG_bg = 41, - LANG_ca = 37, - LANG_cs = 42, - LANG_da = 45, - LANG_de = 49, - LANG_el = 30, - LANG_en = 01, - LANG_es = 34, - LANG_eu = 10, - LANG_fr = 02, - LANG_gl = 38, - LANG_hr = 78, - LANG_hu = 36, - LANG_it = 39, - LANG_la = 99, // custom number - LANG_lv = 101, // custom number - LANG_nl = 31, - LANG_pl = 48, - LANG_pt = 03, - LANG_ru = 07, - LANG_sv = 50, - LANG_tr = 90, - LANG_uk = 80, - LANG_xx = 999 -}; - -#endif diff --git a/maclibs/include/hunspell/phonet.hxx b/maclibs/include/hunspell/phonet.hxx deleted file mode 100644 index 2d58b3ba..00000000 --- a/maclibs/include/hunspell/phonet.hxx +++ /dev/null @@ -1,50 +0,0 @@ -/* phonetic.c - generic replacement aglogithms for phonetic transformation - Copyright (C) 2000 Bjoern Jacke - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License version 2.1 as published by the Free Software Foundation; - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; If not, see - . - - Changelog: - - 2000-01-05 Bjoern Jacke - Initial Release insprired by the article about phonetic - transformations out of c't 25/1999 - - 2007-07-26 Bjoern Jacke - Released under MPL/GPL/LGPL tri-license for Hunspell - - 2007-08-23 Laszlo Nemeth - Porting from Aspell to Hunspell using C-like structs -*/ - -#ifndef PHONET_HXX_ -#define PHONET_HXX_ - -#define HASHSIZE 256 -#define MAXPHONETLEN 256 -#define MAXPHONETUTF8LEN (MAXPHONETLEN * 4) - -#include "hunvisapi.h" - -struct phonetable { - char utf8; - std::vector rules; - int hash[HASHSIZE]; -}; - -LIBHUNSPELL_DLL_EXPORTED void init_phonet_hash(phonetable& parms); - -LIBHUNSPELL_DLL_EXPORTED std::string phonet(const std::string& inword, - phonetable& phone); - -#endif diff --git a/maclibs/include/hunspell/replist.hxx b/maclibs/include/hunspell/replist.hxx deleted file mode 100644 index 1e3efa41..00000000 --- a/maclibs/include/hunspell/replist.hxx +++ /dev/null @@ -1,100 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* string replacement list class */ -#ifndef REPLIST_HXX_ -#define REPLIST_HXX_ - -#include "w_char.hxx" - -#include -#include - -class RepList { - private: - RepList(const RepList&); - RepList& operator=(const RepList&); - - protected: - replentry** dat; - int size; - int pos; - - public: - explicit RepList(int n); - ~RepList(); - - int add(const std::string& pat1, const std::string& pat2); - replentry* item(int n); - int find(const char* word); - std::string replace(const char* word, int n, bool atstart); - bool conv(const std::string& word, std::string& dest); -}; -#endif diff --git a/maclibs/include/hunspell/suggestmgr.hxx b/maclibs/include/hunspell/suggestmgr.hxx deleted file mode 100644 index 19ffc03a..00000000 --- a/maclibs/include/hunspell/suggestmgr.hxx +++ /dev/null @@ -1,188 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -/* - * Copyright 2002 Kevin B. Hendricks, Stratford, Ontario, Canada - * And Contributors. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * 3. All modifications to the source code must be clearly marked as - * such. Binary redistributions based on modified source code - * must be clearly marked as modified versions in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY KEVIN B. HENDRICKS AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL - * KEVIN B. HENDRICKS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#ifndef SUGGESTMGR_HXX_ -#define SUGGESTMGR_HXX_ - -#define MAX_ROOTS 100 -#define MAX_WORDS 100 -#define MAX_GUESS 200 -#define MAXNGRAMSUGS 4 -#define MAXPHONSUGS 2 -#define MAXCOMPOUNDSUGS 3 - -// timelimit: max ~1/4 sec (process time on Linux) for a time consuming function -#define TIMELIMIT (CLOCKS_PER_SEC >> 2) -#define MINTIMER 100 -#define MAXPLUSTIMER 100 - -#define NGRAM_LONGER_WORSE (1 << 0) -#define NGRAM_ANY_MISMATCH (1 << 1) -#define NGRAM_LOWERING (1 << 2) -#define NGRAM_WEIGHTED (1 << 3) - -#include "atypes.hxx" -#include "affixmgr.hxx" -#include "hashmgr.hxx" -#include "langnum.hxx" -#include - -enum { LCS_UP, LCS_LEFT, LCS_UPLEFT }; - -class SuggestMgr { - private: - SuggestMgr(const SuggestMgr&); - SuggestMgr& operator=(const SuggestMgr&); - - private: - char* ckey; - size_t ckeyl; - std::vector ckey_utf; - - char* ctry; - size_t ctryl; - std::vector ctry_utf; - - AffixMgr* pAMgr; - unsigned int maxSug; - struct cs_info* csconv; - int utf8; - int langnum; - int nosplitsugs; - int maxngramsugs; - int maxcpdsugs; - int complexprefixes; - - public: - SuggestMgr(const char* tryme, unsigned int maxn, AffixMgr* aptr); - ~SuggestMgr(); - - void suggest(std::vector& slst, const char* word, int* onlycmpdsug); - void ngsuggest(std::vector& slst, const char* word, const std::vector& rHMgr); - - std::string suggest_morph(const std::string& word); - std::string suggest_gen(const std::vector& pl, const std::string& pattern); - - private: - void testsug(std::vector& wlst, - const std::string& candidate, - int cpdsuggest, - int* timer, - clock_t* timelimit); - int checkword(const std::string& word, int, int*, clock_t*); - int check_forbidden(const char*, int); - - void capchars(std::vector&, const char*, int); - int replchars(std::vector&, const char*, int); - int doubletwochars(std::vector&, const char*, int); - int forgotchar(std::vector&, const char*, int); - int swapchar(std::vector&, const char*, int); - int longswapchar(std::vector&, const char*, int); - int movechar(std::vector&, const char*, int); - int extrachar(std::vector&, const char*, int); - int badcharkey(std::vector&, const char*, int); - int badchar(std::vector&, const char*, int); - int twowords(std::vector&, const char*, int); - - void capchars_utf(std::vector&, const w_char*, int wl, int); - int doubletwochars_utf(std::vector&, const w_char*, int wl, int); - int forgotchar_utf(std::vector&, const w_char*, int wl, int); - int extrachar_utf(std::vector&, const w_char*, int wl, int); - int badcharkey_utf(std::vector&, const w_char*, int wl, int); - int badchar_utf(std::vector&, const w_char*, int wl, int); - int swapchar_utf(std::vector&, const w_char*, int wl, int); - int longswapchar_utf(std::vector&, const w_char*, int, int); - int movechar_utf(std::vector&, const w_char*, int, int); - - int mapchars(std::vector&, const char*, int); - int map_related(const char*, - std::string&, - int, - std::vector& wlst, - int, - const std::vector&, - int*, - clock_t*); - int ngram(int n, const std::vector& su1, - const std::vector& su2, int opt); - int ngram(int n, const std::string& s1, const std::string& s2, int opt); - int mystrlen(const char* word); - int leftcommonsubstring(const std::vector& su1, - const std::vector& su2); - int leftcommonsubstring(const char* s1, const char* s2); - int commoncharacterpositions(const char* s1, const char* s2, int* is_swap); - void bubblesort(char** rwd, char** rwd2, int* rsc, int n); - void lcs(const char* s, const char* s2, int* l1, int* l2, char** result); - int lcslen(const char* s, const char* s2); - int lcslen(const std::string& s, const std::string& s2); - std::string suggest_hentry_gen(hentry* rv, const char* pattern); -}; - -#endif diff --git a/maclibs/include/hunspell/w_char.hxx b/maclibs/include/hunspell/w_char.hxx deleted file mode 100644 index 5accb756..00000000 --- a/maclibs/include/hunspell/w_char.hxx +++ /dev/null @@ -1,72 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * Copyright (C) 2002-2017 Németh László - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * Hunspell is based on MySpell which is Copyright (C) 2002 Kevin Hendricks. - * - * Contributor(s): David Einstein, Davide Prina, Giuseppe Modugno, - * Gianluca Turconi, Simon Brouwer, Noll János, Bíró Árpád, - * Goldman Eleonóra, Sarlós Tamás, Bencsáth Boldizsár, Halácsy Péter, - * Dvornik László, Gefferth András, Nagy Viktor, Varga Dániel, Chris Halls, - * Rene Engelhard, Bram Moolenaar, Dafydd Jones, Harri Pitkänen - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef W_CHAR_HXX_ -#define W_CHAR_HXX_ - -#include - -#ifndef GCC -struct w_char { -#else -struct __attribute__((packed)) w_char { -#endif - unsigned char l; - unsigned char h; - - friend bool operator<(const w_char a, const w_char b) { - unsigned short a_idx = (a.h << 8) + a.l; - unsigned short b_idx = (b.h << 8) + b.l; - return a_idx < b_idx; - } - - friend bool operator==(const w_char a, const w_char b) { - return (((a).l == (b).l) && ((a).h == (b).h)); - } - - friend bool operator!=(const w_char a, const w_char b) { - return !(a == b);; - } -}; - -// two character arrays -struct replentry { - std::string pattern; - std::string outstrings[4]; // med, ini, fin, isol -}; - -#endif diff --git a/maclibs/include/iconv.h b/maclibs/include/iconv.h deleted file mode 100644 index b6535d0c..00000000 --- a/maclibs/include/iconv.h +++ /dev/null @@ -1,247 +0,0 @@ -/* Copyright (C) 1999-2003, 2005-2006, 2008-2011 Free Software Foundation, Inc. - This file is part of the GNU LIBICONV Library. - - The GNU LIBICONV Library is free software; you can redistribute it - and/or modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - The GNU LIBICONV Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU LIBICONV Library; see the file COPYING.LIB. - If not, see . */ - -/* When installed, this file is called "iconv.h". */ - -#ifndef _LIBICONV_H -#define _LIBICONV_H - -#define _LIBICONV_VERSION 0x010F /* version number: (major<<8) + minor */ - -#if 1 && BUILDING_LIBICONV -#define LIBICONV_DLL_EXPORTED __attribute__((__visibility__("default"))) -#else -#define LIBICONV_DLL_EXPORTED -#endif -extern LIBICONV_DLL_EXPORTED int _libiconv_version; /* Likewise */ - -/* We would like to #include any system header file which could define - iconv_t, 1. in order to eliminate the risk that the user gets compilation - errors because some other system header file includes /usr/include/iconv.h - which defines iconv_t or declares iconv after this file, 2. when compiling - for LIBICONV_PLUG, we need the proper iconv_t type in order to produce - binary compatible code. - But gcc's #include_next is not portable. Thus, once libiconv's iconv.h - has been installed in /usr/local/include, there is no way any more to - include the original /usr/include/iconv.h. We simply have to get away - without it. - Ad 1. The risk that a system header file does - #include "iconv.h" or #include_next "iconv.h" - is small. They all do #include . - Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It - has to be a scalar type because (iconv_t)(-1) is a possible return value - from iconv_open().) */ - -/* Define iconv_t ourselves. */ -#undef iconv_t -#define iconv_t libiconv_t -typedef void* iconv_t; - -/* Get size_t declaration. - Get wchar_t declaration if it exists. */ -#include - -/* Get errno declaration and values. */ -#include -/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, - have EILSEQ in a different header. On these systems, define EILSEQ - ourselves. */ -#ifndef EILSEQ -#define EILSEQ -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Allocates descriptor for code conversion from encoding ‘fromcode’ to - encoding ‘tocode’. */ -#ifndef LIBICONV_PLUG -#define iconv_open libiconv_open -#endif -extern LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode); - -/* Converts, using conversion descriptor ‘cd’, at most ‘*inbytesleft’ bytes - starting at ‘*inbuf’, writing at most ‘*outbytesleft’ bytes starting at - ‘*outbuf’. - Decrements ‘*inbytesleft’ and increments ‘*inbuf’ by the same amount. - Decrements ‘*outbytesleft’ and increments ‘*outbuf’ by the same amount. */ -#ifndef LIBICONV_PLUG -#define iconv libiconv -#endif -extern LIBICONV_DLL_EXPORTED size_t iconv (iconv_t cd, char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); - -/* Frees resources allocated for conversion descriptor ‘cd’. */ -#ifndef LIBICONV_PLUG -#define iconv_close libiconv_close -#endif -extern LIBICONV_DLL_EXPORTED int iconv_close (iconv_t cd); - - -#ifdef __cplusplus -} -#endif - - -#ifndef LIBICONV_PLUG - -/* Nonstandard extensions. */ - -#if 1 -#if 0 -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#endif -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* A type that holds all memory needed by a conversion descriptor. - A pointer to such an object can be used as an iconv_t. */ -typedef struct { - void* dummy1[28]; -#if 1 - mbstate_t dummy2; -#endif -} iconv_allocation_t; - -/* Allocates descriptor for code conversion from encoding ‘fromcode’ to - encoding ‘tocode’ into preallocated memory. Returns an error indicator - (0 or -1 with errno set). */ -#define iconv_open_into libiconv_open_into -extern LIBICONV_DLL_EXPORTED int iconv_open_into (const char* tocode, const char* fromcode, - iconv_allocation_t* resultp); - -/* Control of attributes. */ -#define iconvctl libiconvctl -extern LIBICONV_DLL_EXPORTED int iconvctl (iconv_t cd, int request, void* argument); - -/* Hook performed after every successful conversion of a Unicode character. */ -typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data); -/* Hook performed after every successful conversion of a wide character. */ -typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data); -/* Set of hooks. */ -struct iconv_hooks { - iconv_unicode_char_hook uc_hook; - iconv_wide_char_hook wc_hook; - void* data; -}; - -/* Fallback function. Invoked when a small number of bytes could not be - converted to a Unicode character. This function should process all - bytes from inbuf and may produce replacement Unicode characters by calling - the write_replacement callback repeatedly. */ -typedef void (*iconv_unicode_mb_to_uc_fallback) - (const char* inbuf, size_t inbufsize, - void (*write_replacement) (const unsigned int *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -/* Fallback function. Invoked when a Unicode character could not be converted - to the target encoding. This function should process the character and - may produce replacement bytes (in the target encoding) by calling the - write_replacement callback repeatedly. */ -typedef void (*iconv_unicode_uc_to_mb_fallback) - (unsigned int code, - void (*write_replacement) (const char *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -#if 1 -/* Fallback function. Invoked when a number of bytes could not be converted to - a wide character. This function should process all bytes from inbuf and may - produce replacement wide characters by calling the write_replacement - callback repeatedly. */ -typedef void (*iconv_wchar_mb_to_wc_fallback) - (const char* inbuf, size_t inbufsize, - void (*write_replacement) (const wchar_t *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -/* Fallback function. Invoked when a wide character could not be converted to - the target encoding. This function should process the character and may - produce replacement bytes (in the target encoding) by calling the - write_replacement callback repeatedly. */ -typedef void (*iconv_wchar_wc_to_mb_fallback) - (wchar_t code, - void (*write_replacement) (const char *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -#else -/* If the wchar_t type does not exist, these two fallback functions are never - invoked. Their argument list therefore does not matter. */ -typedef void (*iconv_wchar_mb_to_wc_fallback) (); -typedef void (*iconv_wchar_wc_to_mb_fallback) (); -#endif -/* Set of fallbacks. */ -struct iconv_fallbacks { - iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; - iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; - iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback; - iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback; - void* data; -}; - -/* Requests for iconvctl. */ -#define ICONV_TRIVIALP 0 /* int *argument */ -#define ICONV_GET_TRANSLITERATE 1 /* int *argument */ -#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ -#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ -#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ -#define ICONV_SET_HOOKS 5 /* const struct iconv_hooks *argument */ -#define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument */ - -/* Listing of locale independent encodings. */ -#define iconvlist libiconvlist -extern LIBICONV_DLL_EXPORTED void iconvlist (int (*do_one) (unsigned int namescount, - const char * const * names, - void* data), - void* data); - -/* Canonicalize an encoding name. - The result is either a canonical encoding name, or name itself. */ -extern LIBICONV_DLL_EXPORTED const char * iconv_canonicalize (const char * name); - -/* Support for relocatable packages. */ - -/* Sets the original and the current installation prefix of the package. - Relocation simply replaces a pathname starting with the original prefix - by the corresponding pathname with the current prefix instead. Both - prefixes should be directory names without trailing slash (i.e. use "" - instead of "/"). */ -extern LIBICONV_DLL_EXPORTED void libiconv_set_relocation_prefix (const char *orig_prefix, - const char *curr_prefix); - -#ifdef __cplusplus -} -#endif - -#endif - - -#endif /* _LIBICONV_H */ diff --git a/maclibs/include/libavcodec/avcodec.h b/maclibs/include/libavcodec/avcodec.h deleted file mode 100644 index d234271c..00000000 --- a/maclibs/include/libavcodec/avcodec.h +++ /dev/null @@ -1,6228 +0,0 @@ -/* - * copyright (c) 2001 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_AVCODEC_H -#define AVCODEC_AVCODEC_H - -/** - * @file - * @ingroup libavc - * Libavcodec external API header - */ - -#include -#include "libavutil/samplefmt.h" -#include "libavutil/attributes.h" -#include "libavutil/avutil.h" -#include "libavutil/buffer.h" -#include "libavutil/cpu.h" -#include "libavutil/channel_layout.h" -#include "libavutil/dict.h" -#include "libavutil/frame.h" -#include "libavutil/hwcontext.h" -#include "libavutil/log.h" -#include "libavutil/pixfmt.h" -#include "libavutil/rational.h" - -#include "version.h" - -/** - * @defgroup libavc libavcodec - * Encoding/Decoding Library - * - * @{ - * - * @defgroup lavc_decoding Decoding - * @{ - * @} - * - * @defgroup lavc_encoding Encoding - * @{ - * @} - * - * @defgroup lavc_codec Codecs - * @{ - * @defgroup lavc_codec_native Native Codecs - * @{ - * @} - * @defgroup lavc_codec_wrappers External library wrappers - * @{ - * @} - * @defgroup lavc_codec_hwaccel Hardware Accelerators bridge - * @{ - * @} - * @} - * @defgroup lavc_internal Internal - * @{ - * @} - * @} - */ - -/** - * @ingroup libavc - * @defgroup lavc_encdec send/receive encoding and decoding API overview - * @{ - * - * The avcodec_send_packet()/avcodec_receive_frame()/avcodec_send_frame()/ - * avcodec_receive_packet() functions provide an encode/decode API, which - * decouples input and output. - * - * The API is very similar for encoding/decoding and audio/video, and works as - * follows: - * - Set up and open the AVCodecContext as usual. - * - Send valid input: - * - For decoding, call avcodec_send_packet() to give the decoder raw - * compressed data in an AVPacket. - * - For encoding, call avcodec_send_frame() to give the encoder an AVFrame - * containing uncompressed audio or video. - * In both cases, it is recommended that AVPackets and AVFrames are - * refcounted, or libavcodec might have to copy the input data. (libavformat - * always returns refcounted AVPackets, and av_frame_get_buffer() allocates - * refcounted AVFrames.) - * - Receive output in a loop. Periodically call one of the avcodec_receive_*() - * functions and process their output: - * - For decoding, call avcodec_receive_frame(). On success, it will return - * an AVFrame containing uncompressed audio or video data. - * - For encoding, call avcodec_receive_packet(). On success, it will return - * an AVPacket with a compressed frame. - * Repeat this call until it returns AVERROR(EAGAIN) or an error. The - * AVERROR(EAGAIN) return value means that new input data is required to - * return new output. In this case, continue with sending input. For each - * input frame/packet, the codec will typically return 1 output frame/packet, - * but it can also be 0 or more than 1. - * - * At the beginning of decoding or encoding, the codec might accept multiple - * input frames/packets without returning a frame, until its internal buffers - * are filled. This situation is handled transparently if you follow the steps - * outlined above. - * - * In theory, sending input can result in EAGAIN - this should happen only if - * not all output was received. You can use this to structure alternative decode - * or encode loops other than the one suggested above. For example, you could - * try sending new input on each iteration, and try to receive output if that - * returns EAGAIN. - * - * End of stream situations. These require "flushing" (aka draining) the codec, - * as the codec might buffer multiple frames or packets internally for - * performance or out of necessity (consider B-frames). - * This is handled as follows: - * - Instead of valid input, send NULL to the avcodec_send_packet() (decoding) - * or avcodec_send_frame() (encoding) functions. This will enter draining - * mode. - * - Call avcodec_receive_frame() (decoding) or avcodec_receive_packet() - * (encoding) in a loop until AVERROR_EOF is returned. The functions will - * not return AVERROR(EAGAIN), unless you forgot to enter draining mode. - * - Before decoding can be resumed again, the codec has to be reset with - * avcodec_flush_buffers(). - * - * Using the API as outlined above is highly recommended. But it is also - * possible to call functions outside of this rigid schema. For example, you can - * call avcodec_send_packet() repeatedly without calling - * avcodec_receive_frame(). In this case, avcodec_send_packet() will succeed - * until the codec's internal buffer has been filled up (which is typically of - * size 1 per output frame, after initial input), and then reject input with - * AVERROR(EAGAIN). Once it starts rejecting input, you have no choice but to - * read at least some output. - * - * Not all codecs will follow a rigid and predictable dataflow; the only - * guarantee is that an AVERROR(EAGAIN) return value on a send/receive call on - * one end implies that a receive/send call on the other end will succeed, or - * at least will not fail with AVERROR(EAGAIN). In general, no codec will - * permit unlimited buffering of input or output. - * - * This API replaces the following legacy functions: - * - avcodec_decode_video2() and avcodec_decode_audio4(): - * Use avcodec_send_packet() to feed input to the decoder, then use - * avcodec_receive_frame() to receive decoded frames after each packet. - * Unlike with the old video decoding API, multiple frames might result from - * a packet. For audio, splitting the input packet into frames by partially - * decoding packets becomes transparent to the API user. You never need to - * feed an AVPacket to the API twice (unless it is rejected with AVERROR(EAGAIN) - then - * no data was read from the packet). - * Additionally, sending a flush/draining packet is required only once. - * - avcodec_encode_video2()/avcodec_encode_audio2(): - * Use avcodec_send_frame() to feed input to the encoder, then use - * avcodec_receive_packet() to receive encoded packets. - * Providing user-allocated buffers for avcodec_receive_packet() is not - * possible. - * - The new API does not handle subtitles yet. - * - * Mixing new and old function calls on the same AVCodecContext is not allowed, - * and will result in undefined behavior. - * - * Some codecs might require using the new API; using the old API will return - * an error when calling it. All codecs support the new API. - * - * A codec is not allowed to return AVERROR(EAGAIN) for both sending and receiving. This - * would be an invalid state, which could put the codec user into an endless - * loop. The API has no concept of time either: it cannot happen that trying to - * do avcodec_send_packet() results in AVERROR(EAGAIN), but a repeated call 1 second - * later accepts the packet (with no other receive/flush API calls involved). - * The API is a strict state machine, and the passage of time is not supposed - * to influence it. Some timing-dependent behavior might still be deemed - * acceptable in certain cases. But it must never result in both send/receive - * returning EAGAIN at the same time at any point. It must also absolutely be - * avoided that the current state is "unstable" and can "flip-flop" between - * the send/receive APIs allowing progress. For example, it's not allowed that - * the codec randomly decides that it actually wants to consume a packet now - * instead of returning a frame, after it just returned AVERROR(EAGAIN) on an - * avcodec_send_packet() call. - * @} - */ - -/** - * @defgroup lavc_core Core functions/structures. - * @ingroup libavc - * - * Basic definitions, functions for querying libavcodec capabilities, - * allocating core structures, etc. - * @{ - */ - - -/** - * Identify the syntax and semantics of the bitstream. - * The principle is roughly: - * Two decoders with the same ID can decode the same streams. - * Two encoders with the same ID can encode compatible streams. - * There may be slight deviations from the principle due to implementation - * details. - * - * If you add a codec ID to this list, add it so that - * 1. no value of an existing codec ID changes (that would break ABI), - * 2. it is as close as possible to similar codecs - * - * After adding new codec IDs, do not forget to add an entry to the codec - * descriptor list and bump libavcodec minor version. - */ -enum AVCodecID { - AV_CODEC_ID_NONE, - - /* video codecs */ - AV_CODEC_ID_MPEG1VIDEO, - AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding - AV_CODEC_ID_H261, - AV_CODEC_ID_H263, - AV_CODEC_ID_RV10, - AV_CODEC_ID_RV20, - AV_CODEC_ID_MJPEG, - AV_CODEC_ID_MJPEGB, - AV_CODEC_ID_LJPEG, - AV_CODEC_ID_SP5X, - AV_CODEC_ID_JPEGLS, - AV_CODEC_ID_MPEG4, - AV_CODEC_ID_RAWVIDEO, - AV_CODEC_ID_MSMPEG4V1, - AV_CODEC_ID_MSMPEG4V2, - AV_CODEC_ID_MSMPEG4V3, - AV_CODEC_ID_WMV1, - AV_CODEC_ID_WMV2, - AV_CODEC_ID_H263P, - AV_CODEC_ID_H263I, - AV_CODEC_ID_FLV1, - AV_CODEC_ID_SVQ1, - AV_CODEC_ID_SVQ3, - AV_CODEC_ID_DVVIDEO, - AV_CODEC_ID_HUFFYUV, - AV_CODEC_ID_CYUV, - AV_CODEC_ID_H264, - AV_CODEC_ID_INDEO3, - AV_CODEC_ID_VP3, - AV_CODEC_ID_THEORA, - AV_CODEC_ID_ASV1, - AV_CODEC_ID_ASV2, - AV_CODEC_ID_FFV1, - AV_CODEC_ID_4XM, - AV_CODEC_ID_VCR1, - AV_CODEC_ID_CLJR, - AV_CODEC_ID_MDEC, - AV_CODEC_ID_ROQ, - AV_CODEC_ID_INTERPLAY_VIDEO, - AV_CODEC_ID_XAN_WC3, - AV_CODEC_ID_XAN_WC4, - AV_CODEC_ID_RPZA, - AV_CODEC_ID_CINEPAK, - AV_CODEC_ID_WS_VQA, - AV_CODEC_ID_MSRLE, - AV_CODEC_ID_MSVIDEO1, - AV_CODEC_ID_IDCIN, - AV_CODEC_ID_8BPS, - AV_CODEC_ID_SMC, - AV_CODEC_ID_FLIC, - AV_CODEC_ID_TRUEMOTION1, - AV_CODEC_ID_VMDVIDEO, - AV_CODEC_ID_MSZH, - AV_CODEC_ID_ZLIB, - AV_CODEC_ID_QTRLE, - AV_CODEC_ID_TSCC, - AV_CODEC_ID_ULTI, - AV_CODEC_ID_QDRAW, - AV_CODEC_ID_VIXL, - AV_CODEC_ID_QPEG, - AV_CODEC_ID_PNG, - AV_CODEC_ID_PPM, - AV_CODEC_ID_PBM, - AV_CODEC_ID_PGM, - AV_CODEC_ID_PGMYUV, - AV_CODEC_ID_PAM, - AV_CODEC_ID_FFVHUFF, - AV_CODEC_ID_RV30, - AV_CODEC_ID_RV40, - AV_CODEC_ID_VC1, - AV_CODEC_ID_WMV3, - AV_CODEC_ID_LOCO, - AV_CODEC_ID_WNV1, - AV_CODEC_ID_AASC, - AV_CODEC_ID_INDEO2, - AV_CODEC_ID_FRAPS, - AV_CODEC_ID_TRUEMOTION2, - AV_CODEC_ID_BMP, - AV_CODEC_ID_CSCD, - AV_CODEC_ID_MMVIDEO, - AV_CODEC_ID_ZMBV, - AV_CODEC_ID_AVS, - AV_CODEC_ID_SMACKVIDEO, - AV_CODEC_ID_NUV, - AV_CODEC_ID_KMVC, - AV_CODEC_ID_FLASHSV, - AV_CODEC_ID_CAVS, - AV_CODEC_ID_JPEG2000, - AV_CODEC_ID_VMNC, - AV_CODEC_ID_VP5, - AV_CODEC_ID_VP6, - AV_CODEC_ID_VP6F, - AV_CODEC_ID_TARGA, - AV_CODEC_ID_DSICINVIDEO, - AV_CODEC_ID_TIERTEXSEQVIDEO, - AV_CODEC_ID_TIFF, - AV_CODEC_ID_GIF, - AV_CODEC_ID_DXA, - AV_CODEC_ID_DNXHD, - AV_CODEC_ID_THP, - AV_CODEC_ID_SGI, - AV_CODEC_ID_C93, - AV_CODEC_ID_BETHSOFTVID, - AV_CODEC_ID_PTX, - AV_CODEC_ID_TXD, - AV_CODEC_ID_VP6A, - AV_CODEC_ID_AMV, - AV_CODEC_ID_VB, - AV_CODEC_ID_PCX, - AV_CODEC_ID_SUNRAST, - AV_CODEC_ID_INDEO4, - AV_CODEC_ID_INDEO5, - AV_CODEC_ID_MIMIC, - AV_CODEC_ID_RL2, - AV_CODEC_ID_ESCAPE124, - AV_CODEC_ID_DIRAC, - AV_CODEC_ID_BFI, - AV_CODEC_ID_CMV, - AV_CODEC_ID_MOTIONPIXELS, - AV_CODEC_ID_TGV, - AV_CODEC_ID_TGQ, - AV_CODEC_ID_TQI, - AV_CODEC_ID_AURA, - AV_CODEC_ID_AURA2, - AV_CODEC_ID_V210X, - AV_CODEC_ID_TMV, - AV_CODEC_ID_V210, - AV_CODEC_ID_DPX, - AV_CODEC_ID_MAD, - AV_CODEC_ID_FRWU, - AV_CODEC_ID_FLASHSV2, - AV_CODEC_ID_CDGRAPHICS, - AV_CODEC_ID_R210, - AV_CODEC_ID_ANM, - AV_CODEC_ID_BINKVIDEO, - AV_CODEC_ID_IFF_ILBM, -#define AV_CODEC_ID_IFF_BYTERUN1 AV_CODEC_ID_IFF_ILBM - AV_CODEC_ID_KGV1, - AV_CODEC_ID_YOP, - AV_CODEC_ID_VP8, - AV_CODEC_ID_PICTOR, - AV_CODEC_ID_ANSI, - AV_CODEC_ID_A64_MULTI, - AV_CODEC_ID_A64_MULTI5, - AV_CODEC_ID_R10K, - AV_CODEC_ID_MXPEG, - AV_CODEC_ID_LAGARITH, - AV_CODEC_ID_PRORES, - AV_CODEC_ID_JV, - AV_CODEC_ID_DFA, - AV_CODEC_ID_WMV3IMAGE, - AV_CODEC_ID_VC1IMAGE, - AV_CODEC_ID_UTVIDEO, - AV_CODEC_ID_BMV_VIDEO, - AV_CODEC_ID_VBLE, - AV_CODEC_ID_DXTORY, - AV_CODEC_ID_V410, - AV_CODEC_ID_XWD, - AV_CODEC_ID_CDXL, - AV_CODEC_ID_XBM, - AV_CODEC_ID_ZEROCODEC, - AV_CODEC_ID_MSS1, - AV_CODEC_ID_MSA1, - AV_CODEC_ID_TSCC2, - AV_CODEC_ID_MTS2, - AV_CODEC_ID_CLLC, - AV_CODEC_ID_MSS2, - AV_CODEC_ID_VP9, - AV_CODEC_ID_AIC, - AV_CODEC_ID_ESCAPE130, - AV_CODEC_ID_G2M, - AV_CODEC_ID_WEBP, - AV_CODEC_ID_HNM4_VIDEO, - AV_CODEC_ID_HEVC, -#define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC - AV_CODEC_ID_FIC, - AV_CODEC_ID_ALIAS_PIX, - AV_CODEC_ID_BRENDER_PIX, - AV_CODEC_ID_PAF_VIDEO, - AV_CODEC_ID_EXR, - AV_CODEC_ID_VP7, - AV_CODEC_ID_SANM, - AV_CODEC_ID_SGIRLE, - AV_CODEC_ID_MVC1, - AV_CODEC_ID_MVC2, - AV_CODEC_ID_HQX, - AV_CODEC_ID_TDSC, - AV_CODEC_ID_HQ_HQA, - AV_CODEC_ID_HAP, - AV_CODEC_ID_DDS, - AV_CODEC_ID_DXV, - AV_CODEC_ID_SCREENPRESSO, - AV_CODEC_ID_RSCC, - AV_CODEC_ID_AVS2, - - AV_CODEC_ID_Y41P = 0x8000, - AV_CODEC_ID_AVRP, - AV_CODEC_ID_012V, - AV_CODEC_ID_AVUI, - AV_CODEC_ID_AYUV, - AV_CODEC_ID_TARGA_Y216, - AV_CODEC_ID_V308, - AV_CODEC_ID_V408, - AV_CODEC_ID_YUV4, - AV_CODEC_ID_AVRN, - AV_CODEC_ID_CPIA, - AV_CODEC_ID_XFACE, - AV_CODEC_ID_SNOW, - AV_CODEC_ID_SMVJPEG, - AV_CODEC_ID_APNG, - AV_CODEC_ID_DAALA, - AV_CODEC_ID_CFHD, - AV_CODEC_ID_TRUEMOTION2RT, - AV_CODEC_ID_M101, - AV_CODEC_ID_MAGICYUV, - AV_CODEC_ID_SHEERVIDEO, - AV_CODEC_ID_YLC, - AV_CODEC_ID_PSD, - AV_CODEC_ID_PIXLET, - AV_CODEC_ID_SPEEDHQ, - AV_CODEC_ID_FMVC, - AV_CODEC_ID_SCPR, - AV_CODEC_ID_CLEARVIDEO, - AV_CODEC_ID_XPM, - AV_CODEC_ID_AV1, - AV_CODEC_ID_BITPACKED, - AV_CODEC_ID_MSCC, - AV_CODEC_ID_SRGC, - AV_CODEC_ID_SVG, - AV_CODEC_ID_GDV, - AV_CODEC_ID_FITS, - AV_CODEC_ID_IMM4, - AV_CODEC_ID_PROSUMER, - AV_CODEC_ID_MWSC, - AV_CODEC_ID_WCMV, - AV_CODEC_ID_RASC, - AV_CODEC_ID_HYMT, - AV_CODEC_ID_ARBC, - AV_CODEC_ID_AGM, - AV_CODEC_ID_LSCR, - AV_CODEC_ID_VP4, - - /* various PCM "codecs" */ - AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs - AV_CODEC_ID_PCM_S16LE = 0x10000, - AV_CODEC_ID_PCM_S16BE, - AV_CODEC_ID_PCM_U16LE, - AV_CODEC_ID_PCM_U16BE, - AV_CODEC_ID_PCM_S8, - AV_CODEC_ID_PCM_U8, - AV_CODEC_ID_PCM_MULAW, - AV_CODEC_ID_PCM_ALAW, - AV_CODEC_ID_PCM_S32LE, - AV_CODEC_ID_PCM_S32BE, - AV_CODEC_ID_PCM_U32LE, - AV_CODEC_ID_PCM_U32BE, - AV_CODEC_ID_PCM_S24LE, - AV_CODEC_ID_PCM_S24BE, - AV_CODEC_ID_PCM_U24LE, - AV_CODEC_ID_PCM_U24BE, - AV_CODEC_ID_PCM_S24DAUD, - AV_CODEC_ID_PCM_ZORK, - AV_CODEC_ID_PCM_S16LE_PLANAR, - AV_CODEC_ID_PCM_DVD, - AV_CODEC_ID_PCM_F32BE, - AV_CODEC_ID_PCM_F32LE, - AV_CODEC_ID_PCM_F64BE, - AV_CODEC_ID_PCM_F64LE, - AV_CODEC_ID_PCM_BLURAY, - AV_CODEC_ID_PCM_LXF, - AV_CODEC_ID_S302M, - AV_CODEC_ID_PCM_S8_PLANAR, - AV_CODEC_ID_PCM_S24LE_PLANAR, - AV_CODEC_ID_PCM_S32LE_PLANAR, - AV_CODEC_ID_PCM_S16BE_PLANAR, - - AV_CODEC_ID_PCM_S64LE = 0x10800, - AV_CODEC_ID_PCM_S64BE, - AV_CODEC_ID_PCM_F16LE, - AV_CODEC_ID_PCM_F24LE, - AV_CODEC_ID_PCM_VIDC, - - /* various ADPCM codecs */ - AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, - AV_CODEC_ID_ADPCM_IMA_WAV, - AV_CODEC_ID_ADPCM_IMA_DK3, - AV_CODEC_ID_ADPCM_IMA_DK4, - AV_CODEC_ID_ADPCM_IMA_WS, - AV_CODEC_ID_ADPCM_IMA_SMJPEG, - AV_CODEC_ID_ADPCM_MS, - AV_CODEC_ID_ADPCM_4XM, - AV_CODEC_ID_ADPCM_XA, - AV_CODEC_ID_ADPCM_ADX, - AV_CODEC_ID_ADPCM_EA, - AV_CODEC_ID_ADPCM_G726, - AV_CODEC_ID_ADPCM_CT, - AV_CODEC_ID_ADPCM_SWF, - AV_CODEC_ID_ADPCM_YAMAHA, - AV_CODEC_ID_ADPCM_SBPRO_4, - AV_CODEC_ID_ADPCM_SBPRO_3, - AV_CODEC_ID_ADPCM_SBPRO_2, - AV_CODEC_ID_ADPCM_THP, - AV_CODEC_ID_ADPCM_IMA_AMV, - AV_CODEC_ID_ADPCM_EA_R1, - AV_CODEC_ID_ADPCM_EA_R3, - AV_CODEC_ID_ADPCM_EA_R2, - AV_CODEC_ID_ADPCM_IMA_EA_SEAD, - AV_CODEC_ID_ADPCM_IMA_EA_EACS, - AV_CODEC_ID_ADPCM_EA_XAS, - AV_CODEC_ID_ADPCM_EA_MAXIS_XA, - AV_CODEC_ID_ADPCM_IMA_ISS, - AV_CODEC_ID_ADPCM_G722, - AV_CODEC_ID_ADPCM_IMA_APC, - AV_CODEC_ID_ADPCM_VIMA, - - AV_CODEC_ID_ADPCM_AFC = 0x11800, - AV_CODEC_ID_ADPCM_IMA_OKI, - AV_CODEC_ID_ADPCM_DTK, - AV_CODEC_ID_ADPCM_IMA_RAD, - AV_CODEC_ID_ADPCM_G726LE, - AV_CODEC_ID_ADPCM_THP_LE, - AV_CODEC_ID_ADPCM_PSX, - AV_CODEC_ID_ADPCM_AICA, - AV_CODEC_ID_ADPCM_IMA_DAT4, - AV_CODEC_ID_ADPCM_MTAF, - AV_CODEC_ID_ADPCM_AGM, - - /* AMR */ - AV_CODEC_ID_AMR_NB = 0x12000, - AV_CODEC_ID_AMR_WB, - - /* RealAudio codecs*/ - AV_CODEC_ID_RA_144 = 0x13000, - AV_CODEC_ID_RA_288, - - /* various DPCM codecs */ - AV_CODEC_ID_ROQ_DPCM = 0x14000, - AV_CODEC_ID_INTERPLAY_DPCM, - AV_CODEC_ID_XAN_DPCM, - AV_CODEC_ID_SOL_DPCM, - - AV_CODEC_ID_SDX2_DPCM = 0x14800, - AV_CODEC_ID_GREMLIN_DPCM, - - /* audio codecs */ - AV_CODEC_ID_MP2 = 0x15000, - AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 - AV_CODEC_ID_AAC, - AV_CODEC_ID_AC3, - AV_CODEC_ID_DTS, - AV_CODEC_ID_VORBIS, - AV_CODEC_ID_DVAUDIO, - AV_CODEC_ID_WMAV1, - AV_CODEC_ID_WMAV2, - AV_CODEC_ID_MACE3, - AV_CODEC_ID_MACE6, - AV_CODEC_ID_VMDAUDIO, - AV_CODEC_ID_FLAC, - AV_CODEC_ID_MP3ADU, - AV_CODEC_ID_MP3ON4, - AV_CODEC_ID_SHORTEN, - AV_CODEC_ID_ALAC, - AV_CODEC_ID_WESTWOOD_SND1, - AV_CODEC_ID_GSM, ///< as in Berlin toast format - AV_CODEC_ID_QDM2, - AV_CODEC_ID_COOK, - AV_CODEC_ID_TRUESPEECH, - AV_CODEC_ID_TTA, - AV_CODEC_ID_SMACKAUDIO, - AV_CODEC_ID_QCELP, - AV_CODEC_ID_WAVPACK, - AV_CODEC_ID_DSICINAUDIO, - AV_CODEC_ID_IMC, - AV_CODEC_ID_MUSEPACK7, - AV_CODEC_ID_MLP, - AV_CODEC_ID_GSM_MS, /* as found in WAV */ - AV_CODEC_ID_ATRAC3, - AV_CODEC_ID_APE, - AV_CODEC_ID_NELLYMOSER, - AV_CODEC_ID_MUSEPACK8, - AV_CODEC_ID_SPEEX, - AV_CODEC_ID_WMAVOICE, - AV_CODEC_ID_WMAPRO, - AV_CODEC_ID_WMALOSSLESS, - AV_CODEC_ID_ATRAC3P, - AV_CODEC_ID_EAC3, - AV_CODEC_ID_SIPR, - AV_CODEC_ID_MP1, - AV_CODEC_ID_TWINVQ, - AV_CODEC_ID_TRUEHD, - AV_CODEC_ID_MP4ALS, - AV_CODEC_ID_ATRAC1, - AV_CODEC_ID_BINKAUDIO_RDFT, - AV_CODEC_ID_BINKAUDIO_DCT, - AV_CODEC_ID_AAC_LATM, - AV_CODEC_ID_QDMC, - AV_CODEC_ID_CELT, - AV_CODEC_ID_G723_1, - AV_CODEC_ID_G729, - AV_CODEC_ID_8SVX_EXP, - AV_CODEC_ID_8SVX_FIB, - AV_CODEC_ID_BMV_AUDIO, - AV_CODEC_ID_RALF, - AV_CODEC_ID_IAC, - AV_CODEC_ID_ILBC, - AV_CODEC_ID_OPUS, - AV_CODEC_ID_COMFORT_NOISE, - AV_CODEC_ID_TAK, - AV_CODEC_ID_METASOUND, - AV_CODEC_ID_PAF_AUDIO, - AV_CODEC_ID_ON2AVC, - AV_CODEC_ID_DSS_SP, - AV_CODEC_ID_CODEC2, - - AV_CODEC_ID_FFWAVESYNTH = 0x15800, - AV_CODEC_ID_SONIC, - AV_CODEC_ID_SONIC_LS, - AV_CODEC_ID_EVRC, - AV_CODEC_ID_SMV, - AV_CODEC_ID_DSD_LSBF, - AV_CODEC_ID_DSD_MSBF, - AV_CODEC_ID_DSD_LSBF_PLANAR, - AV_CODEC_ID_DSD_MSBF_PLANAR, - AV_CODEC_ID_4GV, - AV_CODEC_ID_INTERPLAY_ACM, - AV_CODEC_ID_XMA1, - AV_CODEC_ID_XMA2, - AV_CODEC_ID_DST, - AV_CODEC_ID_ATRAC3AL, - AV_CODEC_ID_ATRAC3PAL, - AV_CODEC_ID_DOLBY_E, - AV_CODEC_ID_APTX, - AV_CODEC_ID_APTX_HD, - AV_CODEC_ID_SBC, - AV_CODEC_ID_ATRAC9, - AV_CODEC_ID_HCOM, - - /* subtitle codecs */ - AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. - AV_CODEC_ID_DVD_SUBTITLE = 0x17000, - AV_CODEC_ID_DVB_SUBTITLE, - AV_CODEC_ID_TEXT, ///< raw UTF-8 text - AV_CODEC_ID_XSUB, - AV_CODEC_ID_SSA, - AV_CODEC_ID_MOV_TEXT, - AV_CODEC_ID_HDMV_PGS_SUBTITLE, - AV_CODEC_ID_DVB_TELETEXT, - AV_CODEC_ID_SRT, - - AV_CODEC_ID_MICRODVD = 0x17800, - AV_CODEC_ID_EIA_608, - AV_CODEC_ID_JACOSUB, - AV_CODEC_ID_SAMI, - AV_CODEC_ID_REALTEXT, - AV_CODEC_ID_STL, - AV_CODEC_ID_SUBVIEWER1, - AV_CODEC_ID_SUBVIEWER, - AV_CODEC_ID_SUBRIP, - AV_CODEC_ID_WEBVTT, - AV_CODEC_ID_MPL2, - AV_CODEC_ID_VPLAYER, - AV_CODEC_ID_PJS, - AV_CODEC_ID_ASS, - AV_CODEC_ID_HDMV_TEXT_SUBTITLE, - AV_CODEC_ID_TTML, - AV_CODEC_ID_ARIB_CAPTION, - - /* other specific kind of codecs (generally used for attachments) */ - AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. - AV_CODEC_ID_TTF = 0x18000, - - AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of program stream. - AV_CODEC_ID_BINTEXT = 0x18800, - AV_CODEC_ID_XBIN, - AV_CODEC_ID_IDF, - AV_CODEC_ID_OTF, - AV_CODEC_ID_SMPTE_KLV, - AV_CODEC_ID_DVD_NAV, - AV_CODEC_ID_TIMED_ID3, - AV_CODEC_ID_BIN_DATA, - - - AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it - - AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS - * stream (only used by libavformat) */ - AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems - * stream (only used by libavformat) */ - AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. - AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket -}; - -/** - * This struct describes the properties of a single codec described by an - * AVCodecID. - * @see avcodec_descriptor_get() - */ -typedef struct AVCodecDescriptor { - enum AVCodecID id; - enum AVMediaType type; - /** - * Name of the codec described by this descriptor. It is non-empty and - * unique for each codec descriptor. It should contain alphanumeric - * characters and '_' only. - */ - const char *name; - /** - * A more descriptive name for this codec. May be NULL. - */ - const char *long_name; - /** - * Codec properties, a combination of AV_CODEC_PROP_* flags. - */ - int props; - /** - * MIME type(s) associated with the codec. - * May be NULL; if not, a NULL-terminated array of MIME types. - * The first item is always non-NULL and is the preferred MIME type. - */ - const char *const *mime_types; - /** - * If non-NULL, an array of profiles recognized for this codec. - * Terminated with FF_PROFILE_UNKNOWN. - */ - const struct AVProfile *profiles; -} AVCodecDescriptor; - -/** - * Codec uses only intra compression. - * Video and audio codecs only. - */ -#define AV_CODEC_PROP_INTRA_ONLY (1 << 0) -/** - * Codec supports lossy compression. Audio and video codecs only. - * @note a codec may support both lossy and lossless - * compression modes - */ -#define AV_CODEC_PROP_LOSSY (1 << 1) -/** - * Codec supports lossless compression. Audio and video codecs only. - */ -#define AV_CODEC_PROP_LOSSLESS (1 << 2) -/** - * Codec supports frame reordering. That is, the coded order (the order in which - * the encoded packets are output by the encoders / stored / input to the - * decoders) may be different from the presentation order of the corresponding - * frames. - * - * For codecs that do not have this property set, PTS and DTS should always be - * equal. - */ -#define AV_CODEC_PROP_REORDER (1 << 3) -/** - * Subtitle codec is bitmap based - * Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field. - */ -#define AV_CODEC_PROP_BITMAP_SUB (1 << 16) -/** - * Subtitle codec is text based. - * Decoded AVSubtitle data can be read from the AVSubtitleRect->ass field. - */ -#define AV_CODEC_PROP_TEXT_SUB (1 << 17) - -/** - * @ingroup lavc_decoding - * Required number of additionally allocated bytes at the end of the input bitstream for decoding. - * This is mainly needed because some optimized bitstream readers read - * 32 or 64 bit at once and could read over the end.
- * Note: If the first 23 bits of the additional bytes are not 0, then damaged - * MPEG bitstreams could cause overread and segfault. - */ -#define AV_INPUT_BUFFER_PADDING_SIZE 64 - -/** - * @ingroup lavc_encoding - * minimum encoding buffer size - * Used to avoid some checks during header writing. - */ -#define AV_INPUT_BUFFER_MIN_SIZE 16384 - -/** - * @ingroup lavc_decoding - */ -enum AVDiscard{ - /* We leave some space between them for extensions (drop some - * keyframes for intra-only or drop just some bidir frames). */ - AVDISCARD_NONE =-16, ///< discard nothing - AVDISCARD_DEFAULT = 0, ///< discard useless packets like 0 size packets in avi - AVDISCARD_NONREF = 8, ///< discard all non reference - AVDISCARD_BIDIR = 16, ///< discard all bidirectional frames - AVDISCARD_NONINTRA= 24, ///< discard all non intra frames - AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes - AVDISCARD_ALL = 48, ///< discard all -}; - -enum AVAudioServiceType { - AV_AUDIO_SERVICE_TYPE_MAIN = 0, - AV_AUDIO_SERVICE_TYPE_EFFECTS = 1, - AV_AUDIO_SERVICE_TYPE_VISUALLY_IMPAIRED = 2, - AV_AUDIO_SERVICE_TYPE_HEARING_IMPAIRED = 3, - AV_AUDIO_SERVICE_TYPE_DIALOGUE = 4, - AV_AUDIO_SERVICE_TYPE_COMMENTARY = 5, - AV_AUDIO_SERVICE_TYPE_EMERGENCY = 6, - AV_AUDIO_SERVICE_TYPE_VOICE_OVER = 7, - AV_AUDIO_SERVICE_TYPE_KARAOKE = 8, - AV_AUDIO_SERVICE_TYPE_NB , ///< Not part of ABI -}; - -/** - * @ingroup lavc_encoding - */ -typedef struct RcOverride{ - int start_frame; - int end_frame; - int qscale; // If this is 0 then quality_factor will be used instead. - float quality_factor; -} RcOverride; - -/* encoding support - These flags can be passed in AVCodecContext.flags before initialization. - Note: Not everything is supported yet. -*/ - -/** - * Allow decoders to produce frames with data planes that are not aligned - * to CPU requirements (e.g. due to cropping). - */ -#define AV_CODEC_FLAG_UNALIGNED (1 << 0) -/** - * Use fixed qscale. - */ -#define AV_CODEC_FLAG_QSCALE (1 << 1) -/** - * 4 MV per MB allowed / advanced prediction for H.263. - */ -#define AV_CODEC_FLAG_4MV (1 << 2) -/** - * Output even those frames that might be corrupted. - */ -#define AV_CODEC_FLAG_OUTPUT_CORRUPT (1 << 3) -/** - * Use qpel MC. - */ -#define AV_CODEC_FLAG_QPEL (1 << 4) -/** - * Don't output frames whose parameters differ from first - * decoded frame in stream. - */ -#define AV_CODEC_FLAG_DROPCHANGED (1 << 5) -/** - * Use internal 2pass ratecontrol in first pass mode. - */ -#define AV_CODEC_FLAG_PASS1 (1 << 9) -/** - * Use internal 2pass ratecontrol in second pass mode. - */ -#define AV_CODEC_FLAG_PASS2 (1 << 10) -/** - * loop filter. - */ -#define AV_CODEC_FLAG_LOOP_FILTER (1 << 11) -/** - * Only decode/encode grayscale. - */ -#define AV_CODEC_FLAG_GRAY (1 << 13) -/** - * error[?] variables will be set during encoding. - */ -#define AV_CODEC_FLAG_PSNR (1 << 15) -/** - * Input bitstream might be truncated at a random location - * instead of only at frame boundaries. - */ -#define AV_CODEC_FLAG_TRUNCATED (1 << 16) -/** - * Use interlaced DCT. - */ -#define AV_CODEC_FLAG_INTERLACED_DCT (1 << 18) -/** - * Force low delay. - */ -#define AV_CODEC_FLAG_LOW_DELAY (1 << 19) -/** - * Place global headers in extradata instead of every keyframe. - */ -#define AV_CODEC_FLAG_GLOBAL_HEADER (1 << 22) -/** - * Use only bitexact stuff (except (I)DCT). - */ -#define AV_CODEC_FLAG_BITEXACT (1 << 23) -/* Fx : Flag for H.263+ extra options */ -/** - * H.263 advanced intra coding / MPEG-4 AC prediction - */ -#define AV_CODEC_FLAG_AC_PRED (1 << 24) -/** - * interlaced motion estimation - */ -#define AV_CODEC_FLAG_INTERLACED_ME (1 << 29) -#define AV_CODEC_FLAG_CLOSED_GOP (1U << 31) - -/** - * Allow non spec compliant speedup tricks. - */ -#define AV_CODEC_FLAG2_FAST (1 << 0) -/** - * Skip bitstream encoding. - */ -#define AV_CODEC_FLAG2_NO_OUTPUT (1 << 2) -/** - * Place global headers at every keyframe instead of in extradata. - */ -#define AV_CODEC_FLAG2_LOCAL_HEADER (1 << 3) - -/** - * timecode is in drop frame format. DEPRECATED!!!! - */ -#define AV_CODEC_FLAG2_DROP_FRAME_TIMECODE (1 << 13) - -/** - * Input bitstream might be truncated at a packet boundaries - * instead of only at frame boundaries. - */ -#define AV_CODEC_FLAG2_CHUNKS (1 << 15) -/** - * Discard cropping information from SPS. - */ -#define AV_CODEC_FLAG2_IGNORE_CROP (1 << 16) - -/** - * Show all frames before the first keyframe - */ -#define AV_CODEC_FLAG2_SHOW_ALL (1 << 22) -/** - * Export motion vectors through frame side data - */ -#define AV_CODEC_FLAG2_EXPORT_MVS (1 << 28) -/** - * Do not skip samples and export skip information as frame side data - */ -#define AV_CODEC_FLAG2_SKIP_MANUAL (1 << 29) -/** - * Do not reset ASS ReadOrder field on flush (subtitles decoding) - */ -#define AV_CODEC_FLAG2_RO_FLUSH_NOOP (1 << 30) - -/* Unsupported options : - * Syntax Arithmetic coding (SAC) - * Reference Picture Selection - * Independent Segment Decoding */ -/* /Fx */ -/* codec capabilities */ - -/** - * Decoder can use draw_horiz_band callback. - */ -#define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0) -/** - * Codec uses get_buffer() for allocating buffers and supports custom allocators. - * If not set, it might not use get_buffer() at all or use operations that - * assume the buffer was allocated by avcodec_default_get_buffer. - */ -#define AV_CODEC_CAP_DR1 (1 << 1) -#define AV_CODEC_CAP_TRUNCATED (1 << 3) -/** - * Encoder or decoder requires flushing with NULL input at the end in order to - * give the complete and correct output. - * - * NOTE: If this flag is not set, the codec is guaranteed to never be fed with - * with NULL data. The user can still send NULL data to the public encode - * or decode function, but libavcodec will not pass it along to the codec - * unless this flag is set. - * - * Decoders: - * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL, - * avpkt->size=0 at the end to get the delayed data until the decoder no longer - * returns frames. - * - * Encoders: - * The encoder needs to be fed with NULL data at the end of encoding until the - * encoder no longer returns data. - * - * NOTE: For encoders implementing the AVCodec.encode2() function, setting this - * flag also means that the encoder must set the pts and duration for - * each output packet. If this flag is not set, the pts and duration will - * be determined by libavcodec from the input frame. - */ -#define AV_CODEC_CAP_DELAY (1 << 5) -/** - * Codec can be fed a final frame with a smaller size. - * This can be used to prevent truncation of the last audio samples. - */ -#define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6) - -/** - * Codec can output multiple frames per AVPacket - * Normally demuxers return one frame at a time, demuxers which do not do - * are connected to a parser to split what they return into proper frames. - * This flag is reserved to the very rare category of codecs which have a - * bitstream that cannot be split into frames without timeconsuming - * operations like full decoding. Demuxers carrying such bitstreams thus - * may return multiple frames in a packet. This has many disadvantages like - * prohibiting stream copy in many cases thus it should only be considered - * as a last resort. - */ -#define AV_CODEC_CAP_SUBFRAMES (1 << 8) -/** - * Codec is experimental and is thus avoided in favor of non experimental - * encoders - */ -#define AV_CODEC_CAP_EXPERIMENTAL (1 << 9) -/** - * Codec should fill in channel configuration and samplerate instead of container - */ -#define AV_CODEC_CAP_CHANNEL_CONF (1 << 10) -/** - * Codec supports frame-level multithreading. - */ -#define AV_CODEC_CAP_FRAME_THREADS (1 << 12) -/** - * Codec supports slice-based (or partition-based) multithreading. - */ -#define AV_CODEC_CAP_SLICE_THREADS (1 << 13) -/** - * Codec supports changed parameters at any point. - */ -#define AV_CODEC_CAP_PARAM_CHANGE (1 << 14) -/** - * Codec supports avctx->thread_count == 0 (auto). - */ -#define AV_CODEC_CAP_AUTO_THREADS (1 << 15) -/** - * Audio encoder supports receiving a different number of samples in each call. - */ -#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16) -/** - * Decoder is not a preferred choice for probing. - * This indicates that the decoder is not a good choice for probing. - * It could for example be an expensive to spin up hardware decoder, - * or it could simply not provide a lot of useful information about - * the stream. - * A decoder marked with this flag should only be used as last resort - * choice for probing. - */ -#define AV_CODEC_CAP_AVOID_PROBING (1 << 17) -/** - * Codec is intra only. - */ -#define AV_CODEC_CAP_INTRA_ONLY 0x40000000 -/** - * Codec is lossless. - */ -#define AV_CODEC_CAP_LOSSLESS 0x80000000 - -/** - * Codec is backed by a hardware implementation. Typically used to - * identify a non-hwaccel hardware decoder. For information about hwaccels, use - * avcodec_get_hw_config() instead. - */ -#define AV_CODEC_CAP_HARDWARE (1 << 18) - -/** - * Codec is potentially backed by a hardware implementation, but not - * necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the - * implementation provides some sort of internal fallback. - */ -#define AV_CODEC_CAP_HYBRID (1 << 19) - -/** - * This codec takes the reordered_opaque field from input AVFrames - * and returns it in the corresponding field in AVCodecContext after - * encoding. - */ -#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20) - -/** - * Pan Scan area. - * This specifies the area which should be displayed. - * Note there may be multiple such areas for one frame. - */ -typedef struct AVPanScan { - /** - * id - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int id; - - /** - * width and height in 1/16 pel - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int width; - int height; - - /** - * position of the top left corner in 1/16 pel for up to 3 fields/frames - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int16_t position[3][2]; -} AVPanScan; - -/** - * This structure describes the bitrate properties of an encoded bitstream. It - * roughly corresponds to a subset the VBV parameters for MPEG-2 or HRD - * parameters for H.264/HEVC. - */ -typedef struct AVCPBProperties { - /** - * Maximum bitrate of the stream, in bits per second. - * Zero if unknown or unspecified. - */ -#if FF_API_UNSANITIZED_BITRATES - int max_bitrate; -#else - int64_t max_bitrate; -#endif - /** - * Minimum bitrate of the stream, in bits per second. - * Zero if unknown or unspecified. - */ -#if FF_API_UNSANITIZED_BITRATES - int min_bitrate; -#else - int64_t min_bitrate; -#endif - /** - * Average bitrate of the stream, in bits per second. - * Zero if unknown or unspecified. - */ -#if FF_API_UNSANITIZED_BITRATES - int avg_bitrate; -#else - int64_t avg_bitrate; -#endif - - /** - * The size of the buffer to which the ratecontrol is applied, in bits. - * Zero if unknown or unspecified. - */ - int buffer_size; - - /** - * The delay between the time the packet this structure is associated with - * is received and the time when it should be decoded, in periods of a 27MHz - * clock. - * - * UINT64_MAX when unknown or unspecified. - */ - uint64_t vbv_delay; -} AVCPBProperties; - -/** - * The decoder will keep a reference to the frame and may reuse it later. - */ -#define AV_GET_BUFFER_FLAG_REF (1 << 0) - -/** - * @defgroup lavc_packet AVPacket - * - * Types and functions for working with AVPacket. - * @{ - */ -enum AVPacketSideDataType { - /** - * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE - * bytes worth of palette. This side data signals that a new palette is - * present. - */ - AV_PKT_DATA_PALETTE, - - /** - * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format - * that the extradata buffer was changed and the receiving side should - * act upon it appropriately. The new extradata is embedded in the side - * data buffer and should be immediately used for processing the current - * frame or packet. - */ - AV_PKT_DATA_NEW_EXTRADATA, - - /** - * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: - * @code - * u32le param_flags - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) - * s32le channel_count - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) - * u64le channel_layout - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) - * s32le sample_rate - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) - * s32le width - * s32le height - * @endcode - */ - AV_PKT_DATA_PARAM_CHANGE, - - /** - * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of - * structures with info about macroblocks relevant to splitting the - * packet into smaller packets on macroblock edges (e.g. as for RFC 2190). - * That is, it does not necessarily contain info about all macroblocks, - * as long as the distance between macroblocks in the info is smaller - * than the target payload size. - * Each MB info structure is 12 bytes, and is laid out as follows: - * @code - * u32le bit offset from the start of the packet - * u8 current quantizer at the start of the macroblock - * u8 GOB number - * u16le macroblock address within the GOB - * u8 horizontal MV predictor - * u8 vertical MV predictor - * u8 horizontal MV predictor for block number 3 - * u8 vertical MV predictor for block number 3 - * @endcode - */ - AV_PKT_DATA_H263_MB_INFO, - - /** - * This side data should be associated with an audio stream and contains - * ReplayGain information in form of the AVReplayGain struct. - */ - AV_PKT_DATA_REPLAYGAIN, - - /** - * This side data contains a 3x3 transformation matrix describing an affine - * transformation that needs to be applied to the decoded video frames for - * correct presentation. - * - * See libavutil/display.h for a detailed description of the data. - */ - AV_PKT_DATA_DISPLAYMATRIX, - - /** - * This side data should be associated with a video stream and contains - * Stereoscopic 3D information in form of the AVStereo3D struct. - */ - AV_PKT_DATA_STEREO3D, - - /** - * This side data should be associated with an audio stream and corresponds - * to enum AVAudioServiceType. - */ - AV_PKT_DATA_AUDIO_SERVICE_TYPE, - - /** - * This side data contains quality related information from the encoder. - * @code - * u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad). - * u8 picture type - * u8 error count - * u16 reserved - * u64le[error count] sum of squared differences between encoder in and output - * @endcode - */ - AV_PKT_DATA_QUALITY_STATS, - - /** - * This side data contains an integer value representing the stream index - * of a "fallback" track. A fallback track indicates an alternate - * track to use when the current track can not be decoded for some reason. - * e.g. no decoder available for codec. - */ - AV_PKT_DATA_FALLBACK_TRACK, - - /** - * This side data corresponds to the AVCPBProperties struct. - */ - AV_PKT_DATA_CPB_PROPERTIES, - - /** - * Recommmends skipping the specified number of samples - * @code - * u32le number of samples to skip from start of this packet - * u32le number of samples to skip from end of this packet - * u8 reason for start skip - * u8 reason for end skip (0=padding silence, 1=convergence) - * @endcode - */ - AV_PKT_DATA_SKIP_SAMPLES, - - /** - * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that - * the packet may contain "dual mono" audio specific to Japanese DTV - * and if it is true, recommends only the selected channel to be used. - * @code - * u8 selected channels (0=mail/left, 1=sub/right, 2=both) - * @endcode - */ - AV_PKT_DATA_JP_DUALMONO, - - /** - * A list of zero terminated key/value strings. There is no end marker for - * the list, so it is required to rely on the side data size to stop. - */ - AV_PKT_DATA_STRINGS_METADATA, - - /** - * Subtitle event position - * @code - * u32le x1 - * u32le y1 - * u32le x2 - * u32le y2 - * @endcode - */ - AV_PKT_DATA_SUBTITLE_POSITION, - - /** - * Data found in BlockAdditional element of matroska container. There is - * no end marker for the data, so it is required to rely on the side data - * size to recognize the end. 8 byte id (as found in BlockAddId) followed - * by data. - */ - AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, - - /** - * The optional first identifier line of a WebVTT cue. - */ - AV_PKT_DATA_WEBVTT_IDENTIFIER, - - /** - * The optional settings (rendering instructions) that immediately - * follow the timestamp specifier of a WebVTT cue. - */ - AV_PKT_DATA_WEBVTT_SETTINGS, - - /** - * A list of zero terminated key/value strings. There is no end marker for - * the list, so it is required to rely on the side data size to stop. This - * side data includes updated metadata which appeared in the stream. - */ - AV_PKT_DATA_METADATA_UPDATE, - - /** - * MPEGTS stream ID as uint8_t, this is required to pass the stream ID - * information from the demuxer to the corresponding muxer. - */ - AV_PKT_DATA_MPEGTS_STREAM_ID, - - /** - * Mastering display metadata (based on SMPTE-2086:2014). This metadata - * should be associated with a video stream and contains data in the form - * of the AVMasteringDisplayMetadata struct. - */ - AV_PKT_DATA_MASTERING_DISPLAY_METADATA, - - /** - * This side data should be associated with a video stream and corresponds - * to the AVSphericalMapping structure. - */ - AV_PKT_DATA_SPHERICAL, - - /** - * Content light level (based on CTA-861.3). This metadata should be - * associated with a video stream and contains data in the form of the - * AVContentLightMetadata struct. - */ - AV_PKT_DATA_CONTENT_LIGHT_LEVEL, - - /** - * ATSC A53 Part 4 Closed Captions. This metadata should be associated with - * a video stream. A53 CC bitstream is stored as uint8_t in AVPacketSideData.data. - * The number of bytes of CC data is AVPacketSideData.size. - */ - AV_PKT_DATA_A53_CC, - - /** - * This side data is encryption initialization data. - * The format is not part of ABI, use av_encryption_init_info_* methods to - * access. - */ - AV_PKT_DATA_ENCRYPTION_INIT_INFO, - - /** - * This side data contains encryption info for how to decrypt the packet. - * The format is not part of ABI, use av_encryption_info_* methods to access. - */ - AV_PKT_DATA_ENCRYPTION_INFO, - - /** - * Active Format Description data consisting of a single byte as specified - * in ETSI TS 101 154 using AVActiveFormatDescription enum. - */ - AV_PKT_DATA_AFD, - - /** - * The number of side data types. - * This is not part of the public API/ABI in the sense that it may - * change when new side data types are added. - * This must stay the last enum value. - * If its value becomes huge, some code using it - * needs to be updated as it assumes it to be smaller than other limits. - */ - AV_PKT_DATA_NB -}; - -#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED - -typedef struct AVPacketSideData { - uint8_t *data; - int size; - enum AVPacketSideDataType type; -} AVPacketSideData; - -/** - * This structure stores compressed data. It is typically exported by demuxers - * and then passed as input to decoders, or received as output from encoders and - * then passed to muxers. - * - * For video, it should typically contain one compressed frame. For audio it may - * contain several compressed frames. Encoders are allowed to output empty - * packets, with no compressed data, containing only side data - * (e.g. to update some stream parameters at the end of encoding). - * - * AVPacket is one of the few structs in FFmpeg, whose size is a part of public - * ABI. Thus it may be allocated on stack and no new fields can be added to it - * without libavcodec and libavformat major bump. - * - * The semantics of data ownership depends on the buf field. - * If it is set, the packet data is dynamically allocated and is - * valid indefinitely until a call to av_packet_unref() reduces the - * reference count to 0. - * - * If the buf field is not set av_packet_ref() would make a copy instead - * of increasing the reference count. - * - * The side data is always allocated with av_malloc(), copied by - * av_packet_ref() and freed by av_packet_unref(). - * - * @see av_packet_ref - * @see av_packet_unref - */ -typedef struct AVPacket { - /** - * A reference to the reference-counted buffer where the packet data is - * stored. - * May be NULL, then the packet data is not reference-counted. - */ - AVBufferRef *buf; - /** - * Presentation timestamp in AVStream->time_base units; the time at which - * the decompressed packet will be presented to the user. - * Can be AV_NOPTS_VALUE if it is not stored in the file. - * pts MUST be larger or equal to dts as presentation cannot happen before - * decompression, unless one wants to view hex dumps. Some formats misuse - * the terms dts and pts/cts to mean something different. Such timestamps - * must be converted to true pts/dts before they are stored in AVPacket. - */ - int64_t pts; - /** - * Decompression timestamp in AVStream->time_base units; the time at which - * the packet is decompressed. - * Can be AV_NOPTS_VALUE if it is not stored in the file. - */ - int64_t dts; - uint8_t *data; - int size; - int stream_index; - /** - * A combination of AV_PKT_FLAG values - */ - int flags; - /** - * Additional packet data that can be provided by the container. - * Packet can contain several types of side information. - */ - AVPacketSideData *side_data; - int side_data_elems; - - /** - * Duration of this packet in AVStream->time_base units, 0 if unknown. - * Equals next_pts - this_pts in presentation order. - */ - int64_t duration; - - int64_t pos; ///< byte position in stream, -1 if unknown - -#if FF_API_CONVERGENCE_DURATION - /** - * @deprecated Same as the duration field, but as int64_t. This was required - * for Matroska subtitles, whose duration values could overflow when the - * duration field was still an int. - */ - attribute_deprecated - int64_t convergence_duration; -#endif -} AVPacket; -#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe -#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted -/** - * Flag is used to discard packets which are required to maintain valid - * decoder state but are not required for output and should be dropped - * after decoding. - **/ -#define AV_PKT_FLAG_DISCARD 0x0004 -/** - * The packet comes from a trusted source. - * - * Otherwise-unsafe constructs such as arbitrary pointers to data - * outside the packet may be followed. - */ -#define AV_PKT_FLAG_TRUSTED 0x0008 -/** - * Flag is used to indicate packets that contain frames that can - * be discarded by the decoder. I.e. Non-reference frames. - */ -#define AV_PKT_FLAG_DISPOSABLE 0x0010 - - -enum AVSideDataParamChangeFlags { - AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, - AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, - AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, - AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, -}; -/** - * @} - */ - -struct AVCodecInternal; - -enum AVFieldOrder { - AV_FIELD_UNKNOWN, - AV_FIELD_PROGRESSIVE, - AV_FIELD_TT, //< Top coded_first, top displayed first - AV_FIELD_BB, //< Bottom coded first, bottom displayed first - AV_FIELD_TB, //< Top coded first, bottom displayed first - AV_FIELD_BT, //< Bottom coded first, top displayed first -}; - -/** - * main external API structure. - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. - * You can use AVOptions (av_opt* / av_set/get*()) to access these fields from user - * applications. - * The name string for AVOptions options matches the associated command line - * parameter name and can be found in libavcodec/options_table.h - * The AVOption/command line parameter names differ in some cases from the C - * structure field names for historic reasons or brevity. - * sizeof(AVCodecContext) must not be used outside libav*. - */ -typedef struct AVCodecContext { - /** - * information on struct for av_log - * - set by avcodec_alloc_context3 - */ - const AVClass *av_class; - int log_level_offset; - - enum AVMediaType codec_type; /* see AVMEDIA_TYPE_xxx */ - const struct AVCodec *codec; - enum AVCodecID codec_id; /* see AV_CODEC_ID_xxx */ - - /** - * fourcc (LSB first, so "ABCD" -> ('D'<<24) + ('C'<<16) + ('B'<<8) + 'A'). - * This is used to work around some encoder bugs. - * A demuxer should set this to what is stored in the field used to identify the codec. - * If there are multiple such fields in a container then the demuxer should choose the one - * which maximizes the information about the used codec. - * If the codec tag field in a container is larger than 32 bits then the demuxer should - * remap the longer ID to 32 bits with a table or other structure. Alternatively a new - * extra_codec_tag + size could be added but for this a clear advantage must be demonstrated - * first. - * - encoding: Set by user, if not then the default based on codec_id will be used. - * - decoding: Set by user, will be converted to uppercase by libavcodec during init. - */ - unsigned int codec_tag; - - void *priv_data; - - /** - * Private context used for internal data. - * - * Unlike priv_data, this is not codec-specific. It is used in general - * libavcodec functions. - */ - struct AVCodecInternal *internal; - - /** - * Private data of the user, can be used to carry app specific stuff. - * - encoding: Set by user. - * - decoding: Set by user. - */ - void *opaque; - - /** - * the average bitrate - * - encoding: Set by user; unused for constant quantizer encoding. - * - decoding: Set by user, may be overwritten by libavcodec - * if this info is available in the stream - */ - int64_t bit_rate; - - /** - * number of bits the bitstream is allowed to diverge from the reference. - * the reference can be CBR (for CBR pass1) or VBR (for pass2) - * - encoding: Set by user; unused for constant quantizer encoding. - * - decoding: unused - */ - int bit_rate_tolerance; - - /** - * Global quality for codecs which cannot change it per frame. - * This should be proportional to MPEG-1/2/4 qscale. - * - encoding: Set by user. - * - decoding: unused - */ - int global_quality; - - /** - * - encoding: Set by user. - * - decoding: unused - */ - int compression_level; -#define FF_COMPRESSION_DEFAULT -1 - - /** - * AV_CODEC_FLAG_*. - * - encoding: Set by user. - * - decoding: Set by user. - */ - int flags; - - /** - * AV_CODEC_FLAG2_* - * - encoding: Set by user. - * - decoding: Set by user. - */ - int flags2; - - /** - * some codecs need / can use extradata like Huffman tables. - * MJPEG: Huffman tables - * rv10: additional flags - * MPEG-4: global headers (they can be in the bitstream or here) - * The allocated memory should be AV_INPUT_BUFFER_PADDING_SIZE bytes larger - * than extradata_size to avoid problems if it is read with the bitstream reader. - * The bytewise contents of extradata must not depend on the architecture or CPU endianness. - * Must be allocated with the av_malloc() family of functions. - * - encoding: Set/allocated/freed by libavcodec. - * - decoding: Set/allocated/freed by user. - */ - uint8_t *extradata; - int extradata_size; - - /** - * This is the fundamental unit of time (in seconds) in terms - * of which frame timestamps are represented. For fixed-fps content, - * timebase should be 1/framerate and timestamp increments should be - * identically 1. - * This often, but not always is the inverse of the frame rate or field rate - * for video. 1/time_base is not the average frame rate if the frame rate is not - * constant. - * - * Like containers, elementary streams also can store timestamps, 1/time_base - * is the unit in which these timestamps are specified. - * As example of such codec time base see ISO/IEC 14496-2:2001(E) - * vop_time_increment_resolution and fixed_vop_rate - * (fixed_vop_rate == 0 implies that it is different from the framerate) - * - * - encoding: MUST be set by user. - * - decoding: the use of this field for decoding is deprecated. - * Use framerate instead. - */ - AVRational time_base; - - /** - * For some codecs, the time base is closer to the field rate than the frame rate. - * Most notably, H.264 and MPEG-2 specify time_base as half of frame duration - * if no telecine is used ... - * - * Set to time_base ticks per frame. Default 1, e.g., H.264/MPEG-2 set it to 2. - */ - int ticks_per_frame; - - /** - * Codec delay. - * - * Encoding: Number of frames delay there will be from the encoder input to - * the decoder output. (we assume the decoder matches the spec) - * Decoding: Number of frames delay in addition to what a standard decoder - * as specified in the spec would produce. - * - * Video: - * Number of frames the decoded output will be delayed relative to the - * encoded input. - * - * Audio: - * For encoding, this field is unused (see initial_padding). - * - * For decoding, this is the number of samples the decoder needs to - * output before the decoder's output is valid. When seeking, you should - * start decoding this many samples prior to your desired seek point. - * - * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. - */ - int delay; - - - /* video only */ - /** - * picture width / height. - * - * @note Those fields may not match the values of the last - * AVFrame output by avcodec_decode_video2 due frame - * reordering. - * - * - encoding: MUST be set by user. - * - decoding: May be set by the user before opening the decoder if known e.g. - * from the container. Some decoders will require the dimensions - * to be set by the caller. During decoding, the decoder may - * overwrite those values as required while parsing the data. - */ - int width, height; - - /** - * Bitstream width / height, may be different from width/height e.g. when - * the decoded frame is cropped before being output or lowres is enabled. - * - * @note Those field may not match the value of the last - * AVFrame output by avcodec_receive_frame() due frame - * reordering. - * - * - encoding: unused - * - decoding: May be set by the user before opening the decoder if known - * e.g. from the container. During decoding, the decoder may - * overwrite those values as required while parsing the data. - */ - int coded_width, coded_height; - - /** - * the number of pictures in a group of pictures, or 0 for intra_only - * - encoding: Set by user. - * - decoding: unused - */ - int gop_size; - - /** - * Pixel format, see AV_PIX_FMT_xxx. - * May be set by the demuxer if known from headers. - * May be overridden by the decoder if it knows better. - * - * @note This field may not match the value of the last - * AVFrame output by avcodec_receive_frame() due frame - * reordering. - * - * - encoding: Set by user. - * - decoding: Set by user if known, overridden by libavcodec while - * parsing the data. - */ - enum AVPixelFormat pix_fmt; - - /** - * If non NULL, 'draw_horiz_band' is called by the libavcodec - * decoder to draw a horizontal band. It improves cache usage. Not - * all codecs can do that. You must check the codec capabilities - * beforehand. - * When multithreading is used, it may be called from multiple threads - * at the same time; threads might draw different parts of the same AVFrame, - * or multiple AVFrames, and there is no guarantee that slices will be drawn - * in order. - * The function is also used by hardware acceleration APIs. - * It is called at least once during frame decoding to pass - * the data needed for hardware render. - * In that mode instead of pixel data, AVFrame points to - * a structure specific to the acceleration API. The application - * reads the structure and can change some fields to indicate progress - * or mark state. - * - encoding: unused - * - decoding: Set by user. - * @param height the height of the slice - * @param y the y position of the slice - * @param type 1->top field, 2->bottom field, 3->frame - * @param offset offset into the AVFrame.data from which the slice should be read - */ - void (*draw_horiz_band)(struct AVCodecContext *s, - const AVFrame *src, int offset[AV_NUM_DATA_POINTERS], - int y, int type, int height); - - /** - * callback to negotiate the pixelFormat - * @param fmt is the list of formats which are supported by the codec, - * it is terminated by -1 as 0 is a valid format, the formats are ordered by quality. - * The first is always the native one. - * @note The callback may be called again immediately if initialization for - * the selected (hardware-accelerated) pixel format failed. - * @warning Behavior is undefined if the callback returns a value not - * in the fmt list of formats. - * @return the chosen format - * - encoding: unused - * - decoding: Set by user, if not set the native format will be chosen. - */ - enum AVPixelFormat (*get_format)(struct AVCodecContext *s, const enum AVPixelFormat * fmt); - - /** - * maximum number of B-frames between non-B-frames - * Note: The output will be delayed by max_b_frames+1 relative to the input. - * - encoding: Set by user. - * - decoding: unused - */ - int max_b_frames; - - /** - * qscale factor between IP and B-frames - * If > 0 then the last P-frame quantizer will be used (q= lastp_q*factor+offset). - * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). - * - encoding: Set by user. - * - decoding: unused - */ - float b_quant_factor; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int b_frame_strategy; -#endif - - /** - * qscale offset between IP and B-frames - * - encoding: Set by user. - * - decoding: unused - */ - float b_quant_offset; - - /** - * Size of the frame reordering buffer in the decoder. - * For MPEG-2 it is 1 IPB or 0 low delay IP. - * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. - */ - int has_b_frames; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int mpeg_quant; -#endif - - /** - * qscale factor between P- and I-frames - * If > 0 then the last P-frame quantizer will be used (q = lastp_q * factor + offset). - * If < 0 then normal ratecontrol will be done (q= -normal_q*factor+offset). - * - encoding: Set by user. - * - decoding: unused - */ - float i_quant_factor; - - /** - * qscale offset between P and I-frames - * - encoding: Set by user. - * - decoding: unused - */ - float i_quant_offset; - - /** - * luminance masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float lumi_masking; - - /** - * temporary complexity masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float temporal_cplx_masking; - - /** - * spatial complexity masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float spatial_cplx_masking; - - /** - * p block masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float p_masking; - - /** - * darkness masking (0-> disabled) - * - encoding: Set by user. - * - decoding: unused - */ - float dark_masking; - - /** - * slice count - * - encoding: Set by libavcodec. - * - decoding: Set by user (or 0). - */ - int slice_count; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int prediction_method; -#define FF_PRED_LEFT 0 -#define FF_PRED_PLANE 1 -#define FF_PRED_MEDIAN 2 -#endif - - /** - * slice offsets in the frame in bytes - * - encoding: Set/allocated by libavcodec. - * - decoding: Set/allocated by user (or NULL). - */ - int *slice_offset; - - /** - * sample aspect ratio (0 if unknown) - * That is the width of a pixel divided by the height of the pixel. - * Numerator and denominator must be relatively prime and smaller than 256 for some video standards. - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - AVRational sample_aspect_ratio; - - /** - * motion estimation comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int me_cmp; - /** - * subpixel motion estimation comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int me_sub_cmp; - /** - * macroblock comparison function (not supported yet) - * - encoding: Set by user. - * - decoding: unused - */ - int mb_cmp; - /** - * interlaced DCT comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int ildct_cmp; -#define FF_CMP_SAD 0 -#define FF_CMP_SSE 1 -#define FF_CMP_SATD 2 -#define FF_CMP_DCT 3 -#define FF_CMP_PSNR 4 -#define FF_CMP_BIT 5 -#define FF_CMP_RD 6 -#define FF_CMP_ZERO 7 -#define FF_CMP_VSAD 8 -#define FF_CMP_VSSE 9 -#define FF_CMP_NSSE 10 -#define FF_CMP_W53 11 -#define FF_CMP_W97 12 -#define FF_CMP_DCTMAX 13 -#define FF_CMP_DCT264 14 -#define FF_CMP_MEDIAN_SAD 15 -#define FF_CMP_CHROMA 256 - - /** - * ME diamond size & shape - * - encoding: Set by user. - * - decoding: unused - */ - int dia_size; - - /** - * amount of previous MV predictors (2a+1 x 2a+1 square) - * - encoding: Set by user. - * - decoding: unused - */ - int last_predictor_count; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int pre_me; -#endif - - /** - * motion estimation prepass comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int me_pre_cmp; - - /** - * ME prepass diamond size & shape - * - encoding: Set by user. - * - decoding: unused - */ - int pre_dia_size; - - /** - * subpel ME quality - * - encoding: Set by user. - * - decoding: unused - */ - int me_subpel_quality; - - /** - * maximum motion estimation search range in subpel units - * If 0 then no limit. - * - * - encoding: Set by user. - * - decoding: unused - */ - int me_range; - - /** - * slice flags - * - encoding: unused - * - decoding: Set by user. - */ - int slice_flags; -#define SLICE_FLAG_CODED_ORDER 0x0001 ///< draw_horiz_band() is called in coded order instead of display -#define SLICE_FLAG_ALLOW_FIELD 0x0002 ///< allow draw_horiz_band() with field slices (MPEG-2 field pics) -#define SLICE_FLAG_ALLOW_PLANE 0x0004 ///< allow draw_horiz_band() with 1 component at a time (SVQ1) - - /** - * macroblock decision mode - * - encoding: Set by user. - * - decoding: unused - */ - int mb_decision; -#define FF_MB_DECISION_SIMPLE 0 ///< uses mb_cmp -#define FF_MB_DECISION_BITS 1 ///< chooses the one which needs the fewest bits -#define FF_MB_DECISION_RD 2 ///< rate distortion - - /** - * custom intra quantization matrix - * Must be allocated with the av_malloc() family of functions, and will be freed in - * avcodec_free_context(). - * - encoding: Set/allocated by user, freed by libavcodec. Can be NULL. - * - decoding: Set/allocated/freed by libavcodec. - */ - uint16_t *intra_matrix; - - /** - * custom inter quantization matrix - * Must be allocated with the av_malloc() family of functions, and will be freed in - * avcodec_free_context(). - * - encoding: Set/allocated by user, freed by libavcodec. Can be NULL. - * - decoding: Set/allocated/freed by libavcodec. - */ - uint16_t *inter_matrix; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int scenechange_threshold; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int noise_reduction; -#endif - - /** - * precision of the intra DC coefficient - 8 - * - encoding: Set by user. - * - decoding: Set by libavcodec - */ - int intra_dc_precision; - - /** - * Number of macroblock rows at the top which are skipped. - * - encoding: unused - * - decoding: Set by user. - */ - int skip_top; - - /** - * Number of macroblock rows at the bottom which are skipped. - * - encoding: unused - * - decoding: Set by user. - */ - int skip_bottom; - - /** - * minimum MB Lagrange multiplier - * - encoding: Set by user. - * - decoding: unused - */ - int mb_lmin; - - /** - * maximum MB Lagrange multiplier - * - encoding: Set by user. - * - decoding: unused - */ - int mb_lmax; - -#if FF_API_PRIVATE_OPT - /** - * @deprecated use encoder private options instead - */ - attribute_deprecated - int me_penalty_compensation; -#endif - - /** - * - encoding: Set by user. - * - decoding: unused - */ - int bidir_refine; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int brd_scale; -#endif - - /** - * minimum GOP size - * - encoding: Set by user. - * - decoding: unused - */ - int keyint_min; - - /** - * number of reference frames - * - encoding: Set by user. - * - decoding: Set by lavc. - */ - int refs; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int chromaoffset; -#endif - - /** - * Note: Value depends upon the compare function used for fullpel ME. - * - encoding: Set by user. - * - decoding: unused - */ - int mv0_threshold; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int b_sensitivity; -#endif - - /** - * Chromaticity coordinates of the source primaries. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorPrimaries color_primaries; - - /** - * Color Transfer Characteristic. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorTransferCharacteristic color_trc; - - /** - * YUV colorspace type. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorSpace colorspace; - - /** - * MPEG vs JPEG YUV range. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorRange color_range; - - /** - * This defines the location of chroma samples. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVChromaLocation chroma_sample_location; - - /** - * Number of slices. - * Indicates number of picture subdivisions. Used for parallelized - * decoding. - * - encoding: Set by user - * - decoding: unused - */ - int slices; - - /** Field order - * - encoding: set by libavcodec - * - decoding: Set by user. - */ - enum AVFieldOrder field_order; - - /* audio only */ - int sample_rate; ///< samples per second - int channels; ///< number of audio channels - - /** - * audio sample format - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - enum AVSampleFormat sample_fmt; ///< sample format - - /* The following data should not be initialized. */ - /** - * Number of samples per channel in an audio frame. - * - * - encoding: set by libavcodec in avcodec_open2(). Each submitted frame - * except the last must contain exactly frame_size samples per channel. - * May be 0 when the codec has AV_CODEC_CAP_VARIABLE_FRAME_SIZE set, then the - * frame size is not restricted. - * - decoding: may be set by some decoders to indicate constant frame size - */ - int frame_size; - - /** - * Frame counter, set by libavcodec. - * - * - decoding: total number of frames returned from the decoder so far. - * - encoding: total number of frames passed to the encoder so far. - * - * @note the counter is not incremented if encoding/decoding resulted in - * an error. - */ - int frame_number; - - /** - * number of bytes per packet if constant and known or 0 - * Used by some WAV based audio codecs. - */ - int block_align; - - /** - * Audio cutoff bandwidth (0 means "automatic") - * - encoding: Set by user. - * - decoding: unused - */ - int cutoff; - - /** - * Audio channel layout. - * - encoding: set by user. - * - decoding: set by user, may be overwritten by libavcodec. - */ - uint64_t channel_layout; - - /** - * Request decoder to use this channel layout if it can (0 for default) - * - encoding: unused - * - decoding: Set by user. - */ - uint64_t request_channel_layout; - - /** - * Type of service that the audio stream conveys. - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - enum AVAudioServiceType audio_service_type; - - /** - * desired sample format - * - encoding: Not used. - * - decoding: Set by user. - * Decoder will decode to this format if it can. - */ - enum AVSampleFormat request_sample_fmt; - - /** - * This callback is called at the beginning of each frame to get data - * buffer(s) for it. There may be one contiguous buffer for all the data or - * there may be a buffer per each data plane or anything in between. What - * this means is, you may set however many entries in buf[] you feel necessary. - * Each buffer must be reference-counted using the AVBuffer API (see description - * of buf[] below). - * - * The following fields will be set in the frame before this callback is - * called: - * - format - * - width, height (video only) - * - sample_rate, channel_layout, nb_samples (audio only) - * Their values may differ from the corresponding values in - * AVCodecContext. This callback must use the frame values, not the codec - * context values, to calculate the required buffer size. - * - * This callback must fill the following fields in the frame: - * - data[] - * - linesize[] - * - extended_data: - * * if the data is planar audio with more than 8 channels, then this - * callback must allocate and fill extended_data to contain all pointers - * to all data planes. data[] must hold as many pointers as it can. - * extended_data must be allocated with av_malloc() and will be freed in - * av_frame_unref(). - * * otherwise extended_data must point to data - * - buf[] must contain one or more pointers to AVBufferRef structures. Each of - * the frame's data and extended_data pointers must be contained in these. That - * is, one AVBufferRef for each allocated chunk of memory, not necessarily one - * AVBufferRef per data[] entry. See: av_buffer_create(), av_buffer_alloc(), - * and av_buffer_ref(). - * - extended_buf and nb_extended_buf must be allocated with av_malloc() by - * this callback and filled with the extra buffers if there are more - * buffers than buf[] can hold. extended_buf will be freed in - * av_frame_unref(). - * - * If AV_CODEC_CAP_DR1 is not set then get_buffer2() must call - * avcodec_default_get_buffer2() instead of providing buffers allocated by - * some other means. - * - * Each data plane must be aligned to the maximum required by the target - * CPU. - * - * @see avcodec_default_get_buffer2() - * - * Video: - * - * If AV_GET_BUFFER_FLAG_REF is set in flags then the frame may be reused - * (read and/or written to if it is writable) later by libavcodec. - * - * avcodec_align_dimensions2() should be used to find the required width and - * height, as they normally need to be rounded up to the next multiple of 16. - * - * Some decoders do not support linesizes changing between frames. - * - * If frame multithreading is used and thread_safe_callbacks is set, - * this callback may be called from a different thread, but not from more - * than one at once. Does not need to be reentrant. - * - * @see avcodec_align_dimensions2() - * - * Audio: - * - * Decoders request a buffer of a particular size by setting - * AVFrame.nb_samples prior to calling get_buffer2(). The decoder may, - * however, utilize only part of the buffer by setting AVFrame.nb_samples - * to a smaller value in the output frame. - * - * As a convenience, av_samples_get_buffer_size() and - * av_samples_fill_arrays() in libavutil may be used by custom get_buffer2() - * functions to find the required data size and to fill data pointers and - * linesize. In AVFrame.linesize, only linesize[0] may be set for audio - * since all planes must be the same size. - * - * @see av_samples_get_buffer_size(), av_samples_fill_arrays() - * - * - encoding: unused - * - decoding: Set by libavcodec, user can override. - */ - int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags); - - /** - * If non-zero, the decoded audio and video frames returned from - * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted - * and are valid indefinitely. The caller must free them with - * av_frame_unref() when they are not needed anymore. - * Otherwise, the decoded frames must not be freed by the caller and are - * only valid until the next decode call. - * - * This is always automatically enabled if avcodec_receive_frame() is used. - * - * - encoding: unused - * - decoding: set by the caller before avcodec_open2(). - */ - attribute_deprecated - int refcounted_frames; - - /* - encoding parameters */ - float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) - float qblur; ///< amount of qscale smoothing over time (0.0-1.0) - - /** - * minimum quantizer - * - encoding: Set by user. - * - decoding: unused - */ - int qmin; - - /** - * maximum quantizer - * - encoding: Set by user. - * - decoding: unused - */ - int qmax; - - /** - * maximum quantizer difference between frames - * - encoding: Set by user. - * - decoding: unused - */ - int max_qdiff; - - /** - * decoder bitstream buffer size - * - encoding: Set by user. - * - decoding: unused - */ - int rc_buffer_size; - - /** - * ratecontrol override, see RcOverride - * - encoding: Allocated/set/freed by user. - * - decoding: unused - */ - int rc_override_count; - RcOverride *rc_override; - - /** - * maximum bitrate - * - encoding: Set by user. - * - decoding: Set by user, may be overwritten by libavcodec. - */ - int64_t rc_max_rate; - - /** - * minimum bitrate - * - encoding: Set by user. - * - decoding: unused - */ - int64_t rc_min_rate; - - /** - * Ratecontrol attempt to use, at maximum, of what can be used without an underflow. - * - encoding: Set by user. - * - decoding: unused. - */ - float rc_max_available_vbv_use; - - /** - * Ratecontrol attempt to use, at least, times the amount needed to prevent a vbv overflow. - * - encoding: Set by user. - * - decoding: unused. - */ - float rc_min_vbv_overflow_use; - - /** - * Number of bits which should be loaded into the rc buffer before decoding starts. - * - encoding: Set by user. - * - decoding: unused - */ - int rc_initial_buffer_occupancy; - -#if FF_API_CODER_TYPE -#define FF_CODER_TYPE_VLC 0 -#define FF_CODER_TYPE_AC 1 -#define FF_CODER_TYPE_RAW 2 -#define FF_CODER_TYPE_RLE 3 - /** - * @deprecated use encoder private options instead - */ - attribute_deprecated - int coder_type; -#endif /* FF_API_CODER_TYPE */ - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int context_model; -#endif - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int frame_skip_threshold; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int frame_skip_factor; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int frame_skip_exp; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int frame_skip_cmp; -#endif /* FF_API_PRIVATE_OPT */ - - /** - * trellis RD quantization - * - encoding: Set by user. - * - decoding: unused - */ - int trellis; - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int min_prediction_order; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int max_prediction_order; - - /** @deprecated use encoder private options instead */ - attribute_deprecated - int64_t timecode_frame_start; -#endif - -#if FF_API_RTP_CALLBACK - /** - * @deprecated unused - */ - /* The RTP callback: This function is called */ - /* every time the encoder has a packet to send. */ - /* It depends on the encoder if the data starts */ - /* with a Start Code (it should). H.263 does. */ - /* mb_nb contains the number of macroblocks */ - /* encoded in the RTP payload. */ - attribute_deprecated - void (*rtp_callback)(struct AVCodecContext *avctx, void *data, int size, int mb_nb); -#endif - -#if FF_API_PRIVATE_OPT - /** @deprecated use encoder private options instead */ - attribute_deprecated - int rtp_payload_size; /* The size of the RTP payload: the coder will */ - /* do its best to deliver a chunk with size */ - /* below rtp_payload_size, the chunk will start */ - /* with a start code on some codecs like H.263. */ - /* This doesn't take account of any particular */ - /* headers inside the transmitted RTP payload. */ -#endif - -#if FF_API_STAT_BITS - /* statistics, used for 2-pass encoding */ - attribute_deprecated - int mv_bits; - attribute_deprecated - int header_bits; - attribute_deprecated - int i_tex_bits; - attribute_deprecated - int p_tex_bits; - attribute_deprecated - int i_count; - attribute_deprecated - int p_count; - attribute_deprecated - int skip_count; - attribute_deprecated - int misc_bits; - - /** @deprecated this field is unused */ - attribute_deprecated - int frame_bits; -#endif - - /** - * pass1 encoding statistics output buffer - * - encoding: Set by libavcodec. - * - decoding: unused - */ - char *stats_out; - - /** - * pass2 encoding statistics input buffer - * Concatenated stuff from stats_out of pass1 should be placed here. - * - encoding: Allocated/set/freed by user. - * - decoding: unused - */ - char *stats_in; - - /** - * Work around bugs in encoders which sometimes cannot be detected automatically. - * - encoding: Set by user - * - decoding: Set by user - */ - int workaround_bugs; -#define FF_BUG_AUTODETECT 1 ///< autodetection -#define FF_BUG_XVID_ILACE 4 -#define FF_BUG_UMP4 8 -#define FF_BUG_NO_PADDING 16 -#define FF_BUG_AMV 32 -#define FF_BUG_QPEL_CHROMA 64 -#define FF_BUG_STD_QPEL 128 -#define FF_BUG_QPEL_CHROMA2 256 -#define FF_BUG_DIRECT_BLOCKSIZE 512 -#define FF_BUG_EDGE 1024 -#define FF_BUG_HPEL_CHROMA 2048 -#define FF_BUG_DC_CLIP 4096 -#define FF_BUG_MS 8192 ///< Work around various bugs in Microsoft's broken decoders. -#define FF_BUG_TRUNCATED 16384 -#define FF_BUG_IEDGE 32768 - - /** - * strictly follow the standard (MPEG-4, ...). - * - encoding: Set by user. - * - decoding: Set by user. - * Setting this to STRICT or higher means the encoder and decoder will - * generally do stupid things, whereas setting it to unofficial or lower - * will mean the encoder might produce output that is not supported by all - * spec-compliant decoders. Decoders don't differentiate between normal, - * unofficial and experimental (that is, they always try to decode things - * when they can) unless they are explicitly asked to behave stupidly - * (=strictly conform to the specs) - */ - int strict_std_compliance; -#define FF_COMPLIANCE_VERY_STRICT 2 ///< Strictly conform to an older more strict version of the spec or reference software. -#define FF_COMPLIANCE_STRICT 1 ///< Strictly conform to all the things in the spec no matter what consequences. -#define FF_COMPLIANCE_NORMAL 0 -#define FF_COMPLIANCE_UNOFFICIAL -1 ///< Allow unofficial extensions -#define FF_COMPLIANCE_EXPERIMENTAL -2 ///< Allow nonstandardized experimental things. - - /** - * error concealment flags - * - encoding: unused - * - decoding: Set by user. - */ - int error_concealment; -#define FF_EC_GUESS_MVS 1 -#define FF_EC_DEBLOCK 2 -#define FF_EC_FAVOR_INTER 256 - - /** - * debug - * - encoding: Set by user. - * - decoding: Set by user. - */ - int debug; -#define FF_DEBUG_PICT_INFO 1 -#define FF_DEBUG_RC 2 -#define FF_DEBUG_BITSTREAM 4 -#define FF_DEBUG_MB_TYPE 8 -#define FF_DEBUG_QP 16 -#if FF_API_DEBUG_MV -/** - * @deprecated this option does nothing - */ -#define FF_DEBUG_MV 32 -#endif -#define FF_DEBUG_DCT_COEFF 0x00000040 -#define FF_DEBUG_SKIP 0x00000080 -#define FF_DEBUG_STARTCODE 0x00000100 -#define FF_DEBUG_ER 0x00000400 -#define FF_DEBUG_MMCO 0x00000800 -#define FF_DEBUG_BUGS 0x00001000 -#if FF_API_DEBUG_MV -#define FF_DEBUG_VIS_QP 0x00002000 -#define FF_DEBUG_VIS_MB_TYPE 0x00004000 -#endif -#define FF_DEBUG_BUFFERS 0x00008000 -#define FF_DEBUG_THREADS 0x00010000 -#define FF_DEBUG_GREEN_MD 0x00800000 -#define FF_DEBUG_NOMC 0x01000000 - -#if FF_API_DEBUG_MV - /** - * debug - * - encoding: Set by user. - * - decoding: Set by user. - */ - int debug_mv; -#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 // visualize forward predicted MVs of P-frames -#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 // visualize forward predicted MVs of B-frames -#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames -#endif - - /** - * Error recognition; may misdetect some more or less valid parts as errors. - * - encoding: unused - * - decoding: Set by user. - */ - int err_recognition; - -/** - * Verify checksums embedded in the bitstream (could be of either encoded or - * decoded data, depending on the codec) and print an error message on mismatch. - * If AV_EF_EXPLODE is also set, a mismatching checksum will result in the - * decoder returning an error. - */ -#define AV_EF_CRCCHECK (1<<0) -#define AV_EF_BITSTREAM (1<<1) ///< detect bitstream specification deviations -#define AV_EF_BUFFER (1<<2) ///< detect improper bitstream length -#define AV_EF_EXPLODE (1<<3) ///< abort decoding on minor error detection - -#define AV_EF_IGNORE_ERR (1<<15) ///< ignore errors and continue -#define AV_EF_CAREFUL (1<<16) ///< consider things that violate the spec, are fast to calculate and have not been seen in the wild as errors -#define AV_EF_COMPLIANT (1<<17) ///< consider all spec non compliances as errors -#define AV_EF_AGGRESSIVE (1<<18) ///< consider things that a sane encoder should not do as an error - - - /** - * opaque 64-bit number (generally a PTS) that will be reordered and - * output in AVFrame.reordered_opaque - * - encoding: Set by libavcodec to the reordered_opaque of the input - * frame corresponding to the last returned packet. Only - * supported by encoders with the - * AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE capability. - * - decoding: Set by user. - */ - int64_t reordered_opaque; - - /** - * Hardware accelerator in use - * - encoding: unused. - * - decoding: Set by libavcodec - */ - const struct AVHWAccel *hwaccel; - - /** - * Hardware accelerator context. - * For some hardware accelerators, a global context needs to be - * provided by the user. In that case, this holds display-dependent - * data FFmpeg cannot instantiate itself. Please refer to the - * FFmpeg HW accelerator documentation to know how to fill this - * is. e.g. for VA API, this is a struct vaapi_context. - * - encoding: unused - * - decoding: Set by user - */ - void *hwaccel_context; - - /** - * error - * - encoding: Set by libavcodec if flags & AV_CODEC_FLAG_PSNR. - * - decoding: unused - */ - uint64_t error[AV_NUM_DATA_POINTERS]; - - /** - * DCT algorithm, see FF_DCT_* below - * - encoding: Set by user. - * - decoding: unused - */ - int dct_algo; -#define FF_DCT_AUTO 0 -#define FF_DCT_FASTINT 1 -#define FF_DCT_INT 2 -#define FF_DCT_MMX 3 -#define FF_DCT_ALTIVEC 5 -#define FF_DCT_FAAN 6 - - /** - * IDCT algorithm, see FF_IDCT_* below. - * - encoding: Set by user. - * - decoding: Set by user. - */ - int idct_algo; -#define FF_IDCT_AUTO 0 -#define FF_IDCT_INT 1 -#define FF_IDCT_SIMPLE 2 -#define FF_IDCT_SIMPLEMMX 3 -#define FF_IDCT_ARM 7 -#define FF_IDCT_ALTIVEC 8 -#define FF_IDCT_SIMPLEARM 10 -#define FF_IDCT_XVID 14 -#define FF_IDCT_SIMPLEARMV5TE 16 -#define FF_IDCT_SIMPLEARMV6 17 -#define FF_IDCT_FAAN 20 -#define FF_IDCT_SIMPLENEON 22 -#define FF_IDCT_NONE 24 /* Used by XvMC to extract IDCT coefficients with FF_IDCT_PERM_NONE */ -#define FF_IDCT_SIMPLEAUTO 128 - - /** - * bits per sample/pixel from the demuxer (needed for huffyuv). - * - encoding: Set by libavcodec. - * - decoding: Set by user. - */ - int bits_per_coded_sample; - - /** - * Bits per sample/pixel of internal libavcodec pixel/sample format. - * - encoding: set by user. - * - decoding: set by libavcodec. - */ - int bits_per_raw_sample; - -#if FF_API_LOWRES - /** - * low resolution decoding, 1-> 1/2 size, 2->1/4 size - * - encoding: unused - * - decoding: Set by user. - */ - int lowres; -#endif - -#if FF_API_CODED_FRAME - /** - * the picture in the bitstream - * - encoding: Set by libavcodec. - * - decoding: unused - * - * @deprecated use the quality factor packet side data instead - */ - attribute_deprecated AVFrame *coded_frame; -#endif - - /** - * thread count - * is used to decide how many independent tasks should be passed to execute() - * - encoding: Set by user. - * - decoding: Set by user. - */ - int thread_count; - - /** - * Which multithreading methods to use. - * Use of FF_THREAD_FRAME will increase decoding delay by one frame per thread, - * so clients which cannot provide future frames should not use it. - * - * - encoding: Set by user, otherwise the default is used. - * - decoding: Set by user, otherwise the default is used. - */ - int thread_type; -#define FF_THREAD_FRAME 1 ///< Decode more than one frame at once -#define FF_THREAD_SLICE 2 ///< Decode more than one part of a single frame at once - - /** - * Which multithreading methods are in use by the codec. - * - encoding: Set by libavcodec. - * - decoding: Set by libavcodec. - */ - int active_thread_type; - - /** - * Set by the client if its custom get_buffer() callback can be called - * synchronously from another thread, which allows faster multithreaded decoding. - * draw_horiz_band() will be called from other threads regardless of this setting. - * Ignored if the default get_buffer() is used. - * - encoding: Set by user. - * - decoding: Set by user. - */ - int thread_safe_callbacks; - - /** - * The codec may call this to execute several independent things. - * It will return only after finishing all tasks. - * The user may replace this with some multithreaded implementation, - * the default implementation will execute the parts serially. - * @param count the number of things to execute - * - encoding: Set by libavcodec, user can override. - * - decoding: Set by libavcodec, user can override. - */ - int (*execute)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg), void *arg2, int *ret, int count, int size); - - /** - * The codec may call this to execute several independent things. - * It will return only after finishing all tasks. - * The user may replace this with some multithreaded implementation, - * the default implementation will execute the parts serially. - * Also see avcodec_thread_init and e.g. the --enable-pthread configure option. - * @param c context passed also to func - * @param count the number of things to execute - * @param arg2 argument passed unchanged to func - * @param ret return values of executed functions, must have space for "count" values. May be NULL. - * @param func function that will be called count times, with jobnr from 0 to count-1. - * threadnr will be in the range 0 to c->thread_count-1 < MAX_THREADS and so that no - * two instances of func executing at the same time will have the same threadnr. - * @return always 0 currently, but code should handle a future improvement where when any call to func - * returns < 0 no further calls to func may be done and < 0 is returned. - * - encoding: Set by libavcodec, user can override. - * - decoding: Set by libavcodec, user can override. - */ - int (*execute2)(struct AVCodecContext *c, int (*func)(struct AVCodecContext *c2, void *arg, int jobnr, int threadnr), void *arg2, int *ret, int count); - - /** - * noise vs. sse weight for the nsse comparison function - * - encoding: Set by user. - * - decoding: unused - */ - int nsse_weight; - - /** - * profile - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int profile; -#define FF_PROFILE_UNKNOWN -99 -#define FF_PROFILE_RESERVED -100 - -#define FF_PROFILE_AAC_MAIN 0 -#define FF_PROFILE_AAC_LOW 1 -#define FF_PROFILE_AAC_SSR 2 -#define FF_PROFILE_AAC_LTP 3 -#define FF_PROFILE_AAC_HE 4 -#define FF_PROFILE_AAC_HE_V2 28 -#define FF_PROFILE_AAC_LD 22 -#define FF_PROFILE_AAC_ELD 38 -#define FF_PROFILE_MPEG2_AAC_LOW 128 -#define FF_PROFILE_MPEG2_AAC_HE 131 - -#define FF_PROFILE_DNXHD 0 -#define FF_PROFILE_DNXHR_LB 1 -#define FF_PROFILE_DNXHR_SQ 2 -#define FF_PROFILE_DNXHR_HQ 3 -#define FF_PROFILE_DNXHR_HQX 4 -#define FF_PROFILE_DNXHR_444 5 - -#define FF_PROFILE_DTS 20 -#define FF_PROFILE_DTS_ES 30 -#define FF_PROFILE_DTS_96_24 40 -#define FF_PROFILE_DTS_HD_HRA 50 -#define FF_PROFILE_DTS_HD_MA 60 -#define FF_PROFILE_DTS_EXPRESS 70 - -#define FF_PROFILE_MPEG2_422 0 -#define FF_PROFILE_MPEG2_HIGH 1 -#define FF_PROFILE_MPEG2_SS 2 -#define FF_PROFILE_MPEG2_SNR_SCALABLE 3 -#define FF_PROFILE_MPEG2_MAIN 4 -#define FF_PROFILE_MPEG2_SIMPLE 5 - -#define FF_PROFILE_H264_CONSTRAINED (1<<9) // 8+1; constraint_set1_flag -#define FF_PROFILE_H264_INTRA (1<<11) // 8+3; constraint_set3_flag - -#define FF_PROFILE_H264_BASELINE 66 -#define FF_PROFILE_H264_CONSTRAINED_BASELINE (66|FF_PROFILE_H264_CONSTRAINED) -#define FF_PROFILE_H264_MAIN 77 -#define FF_PROFILE_H264_EXTENDED 88 -#define FF_PROFILE_H264_HIGH 100 -#define FF_PROFILE_H264_HIGH_10 110 -#define FF_PROFILE_H264_HIGH_10_INTRA (110|FF_PROFILE_H264_INTRA) -#define FF_PROFILE_H264_MULTIVIEW_HIGH 118 -#define FF_PROFILE_H264_HIGH_422 122 -#define FF_PROFILE_H264_HIGH_422_INTRA (122|FF_PROFILE_H264_INTRA) -#define FF_PROFILE_H264_STEREO_HIGH 128 -#define FF_PROFILE_H264_HIGH_444 144 -#define FF_PROFILE_H264_HIGH_444_PREDICTIVE 244 -#define FF_PROFILE_H264_HIGH_444_INTRA (244|FF_PROFILE_H264_INTRA) -#define FF_PROFILE_H264_CAVLC_444 44 - -#define FF_PROFILE_VC1_SIMPLE 0 -#define FF_PROFILE_VC1_MAIN 1 -#define FF_PROFILE_VC1_COMPLEX 2 -#define FF_PROFILE_VC1_ADVANCED 3 - -#define FF_PROFILE_MPEG4_SIMPLE 0 -#define FF_PROFILE_MPEG4_SIMPLE_SCALABLE 1 -#define FF_PROFILE_MPEG4_CORE 2 -#define FF_PROFILE_MPEG4_MAIN 3 -#define FF_PROFILE_MPEG4_N_BIT 4 -#define FF_PROFILE_MPEG4_SCALABLE_TEXTURE 5 -#define FF_PROFILE_MPEG4_SIMPLE_FACE_ANIMATION 6 -#define FF_PROFILE_MPEG4_BASIC_ANIMATED_TEXTURE 7 -#define FF_PROFILE_MPEG4_HYBRID 8 -#define FF_PROFILE_MPEG4_ADVANCED_REAL_TIME 9 -#define FF_PROFILE_MPEG4_CORE_SCALABLE 10 -#define FF_PROFILE_MPEG4_ADVANCED_CODING 11 -#define FF_PROFILE_MPEG4_ADVANCED_CORE 12 -#define FF_PROFILE_MPEG4_ADVANCED_SCALABLE_TEXTURE 13 -#define FF_PROFILE_MPEG4_SIMPLE_STUDIO 14 -#define FF_PROFILE_MPEG4_ADVANCED_SIMPLE 15 - -#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_0 1 -#define FF_PROFILE_JPEG2000_CSTREAM_RESTRICTION_1 2 -#define FF_PROFILE_JPEG2000_CSTREAM_NO_RESTRICTION 32768 -#define FF_PROFILE_JPEG2000_DCINEMA_2K 3 -#define FF_PROFILE_JPEG2000_DCINEMA_4K 4 - -#define FF_PROFILE_VP9_0 0 -#define FF_PROFILE_VP9_1 1 -#define FF_PROFILE_VP9_2 2 -#define FF_PROFILE_VP9_3 3 - -#define FF_PROFILE_HEVC_MAIN 1 -#define FF_PROFILE_HEVC_MAIN_10 2 -#define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 -#define FF_PROFILE_HEVC_REXT 4 - -#define FF_PROFILE_AV1_MAIN 0 -#define FF_PROFILE_AV1_HIGH 1 -#define FF_PROFILE_AV1_PROFESSIONAL 2 - -#define FF_PROFILE_MJPEG_HUFFMAN_BASELINE_DCT 0xc0 -#define FF_PROFILE_MJPEG_HUFFMAN_EXTENDED_SEQUENTIAL_DCT 0xc1 -#define FF_PROFILE_MJPEG_HUFFMAN_PROGRESSIVE_DCT 0xc2 -#define FF_PROFILE_MJPEG_HUFFMAN_LOSSLESS 0xc3 -#define FF_PROFILE_MJPEG_JPEG_LS 0xf7 - -#define FF_PROFILE_SBC_MSBC 1 - -#define FF_PROFILE_PRORES_PROXY 0 -#define FF_PROFILE_PRORES_LT 1 -#define FF_PROFILE_PRORES_STANDARD 2 -#define FF_PROFILE_PRORES_HQ 3 -#define FF_PROFILE_PRORES_4444 4 -#define FF_PROFILE_PRORES_XQ 5 - -#define FF_PROFILE_ARIB_PROFILE_A 0 -#define FF_PROFILE_ARIB_PROFILE_C 1 - - /** - * level - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - int level; -#define FF_LEVEL_UNKNOWN -99 - - /** - * Skip loop filtering for selected frames. - * - encoding: unused - * - decoding: Set by user. - */ - enum AVDiscard skip_loop_filter; - - /** - * Skip IDCT/dequantization for selected frames. - * - encoding: unused - * - decoding: Set by user. - */ - enum AVDiscard skip_idct; - - /** - * Skip decoding for selected frames. - * - encoding: unused - * - decoding: Set by user. - */ - enum AVDiscard skip_frame; - - /** - * Header containing style information for text subtitles. - * For SUBTITLE_ASS subtitle type, it should contain the whole ASS - * [Script Info] and [V4+ Styles] section, plus the [Events] line and - * the Format line following. It shouldn't include any Dialogue line. - * - encoding: Set/allocated/freed by user (before avcodec_open2()) - * - decoding: Set/allocated/freed by libavcodec (by avcodec_open2()) - */ - uint8_t *subtitle_header; - int subtitle_header_size; - -#if FF_API_VBV_DELAY - /** - * VBV delay coded in the last frame (in periods of a 27 MHz clock). - * Used for compliant TS muxing. - * - encoding: Set by libavcodec. - * - decoding: unused. - * @deprecated this value is now exported as a part of - * AV_PKT_DATA_CPB_PROPERTIES packet side data - */ - attribute_deprecated - uint64_t vbv_delay; -#endif - -#if FF_API_SIDEDATA_ONLY_PKT - /** - * Encoding only and set by default. Allow encoders to output packets - * that do not contain any encoded data, only side data. - * - * Some encoders need to output such packets, e.g. to update some stream - * parameters at the end of encoding. - * - * @deprecated this field disables the default behaviour and - * it is kept only for compatibility. - */ - attribute_deprecated - int side_data_only_packets; -#endif - - /** - * Audio only. The number of "priming" samples (padding) inserted by the - * encoder at the beginning of the audio. I.e. this number of leading - * decoded samples must be discarded by the caller to get the original audio - * without leading padding. - * - * - decoding: unused - * - encoding: Set by libavcodec. The timestamps on the output packets are - * adjusted by the encoder so that they always refer to the - * first sample of the data actually contained in the packet, - * including any added padding. E.g. if the timebase is - * 1/samplerate and the timestamp of the first input sample is - * 0, the timestamp of the first output packet will be - * -initial_padding. - */ - int initial_padding; - - /** - * - decoding: For codecs that store a framerate value in the compressed - * bitstream, the decoder may export it here. { 0, 1} when - * unknown. - * - encoding: May be used to signal the framerate of CFR content to an - * encoder. - */ - AVRational framerate; - - /** - * Nominal unaccelerated pixel format, see AV_PIX_FMT_xxx. - * - encoding: unused. - * - decoding: Set by libavcodec before calling get_format() - */ - enum AVPixelFormat sw_pix_fmt; - - /** - * Timebase in which pkt_dts/pts and AVPacket.dts/pts are. - * - encoding unused. - * - decoding set by user. - */ - AVRational pkt_timebase; - - /** - * AVCodecDescriptor - * - encoding: unused. - * - decoding: set by libavcodec. - */ - const AVCodecDescriptor *codec_descriptor; - -#if !FF_API_LOWRES - /** - * low resolution decoding, 1-> 1/2 size, 2->1/4 size - * - encoding: unused - * - decoding: Set by user. - */ - int lowres; -#endif - - /** - * Current statistics for PTS correction. - * - decoding: maintained and used by libavcodec, not intended to be used by user apps - * - encoding: unused - */ - int64_t pts_correction_num_faulty_pts; /// Number of incorrect PTS values so far - int64_t pts_correction_num_faulty_dts; /// Number of incorrect DTS values so far - int64_t pts_correction_last_pts; /// PTS of the last frame - int64_t pts_correction_last_dts; /// DTS of the last frame - - /** - * Character encoding of the input subtitles file. - * - decoding: set by user - * - encoding: unused - */ - char *sub_charenc; - - /** - * Subtitles character encoding mode. Formats or codecs might be adjusting - * this setting (if they are doing the conversion themselves for instance). - * - decoding: set by libavcodec - * - encoding: unused - */ - int sub_charenc_mode; -#define FF_SUB_CHARENC_MODE_DO_NOTHING -1 ///< do nothing (demuxer outputs a stream supposed to be already in UTF-8, or the codec is bitmap for instance) -#define FF_SUB_CHARENC_MODE_AUTOMATIC 0 ///< libavcodec will select the mode itself -#define FF_SUB_CHARENC_MODE_PRE_DECODER 1 ///< the AVPacket data needs to be recoded to UTF-8 before being fed to the decoder, requires iconv -#define FF_SUB_CHARENC_MODE_IGNORE 2 ///< neither convert the subtitles, nor check them for valid UTF-8 - - /** - * Skip processing alpha if supported by codec. - * Note that if the format uses pre-multiplied alpha (common with VP6, - * and recommended due to better video quality/compression) - * the image will look as if alpha-blended onto a black background. - * However for formats that do not use pre-multiplied alpha - * there might be serious artefacts (though e.g. libswscale currently - * assumes pre-multiplied alpha anyway). - * - * - decoding: set by user - * - encoding: unused - */ - int skip_alpha; - - /** - * Number of samples to skip after a discontinuity - * - decoding: unused - * - encoding: set by libavcodec - */ - int seek_preroll; - -#if !FF_API_DEBUG_MV - /** - * debug motion vectors - * - encoding: Set by user. - * - decoding: Set by user. - */ - int debug_mv; -#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames -#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames -#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 //visualize backward predicted MVs of B frames -#endif - - /** - * custom intra quantization matrix - * - encoding: Set by user, can be NULL. - * - decoding: unused. - */ - uint16_t *chroma_intra_matrix; - - /** - * dump format separator. - * can be ", " or "\n " or anything else - * - encoding: Set by user. - * - decoding: Set by user. - */ - uint8_t *dump_separator; - - /** - * ',' separated list of allowed decoders. - * If NULL then all are allowed - * - encoding: unused - * - decoding: set by user - */ - char *codec_whitelist; - - /** - * Properties of the stream that gets decoded - * - encoding: unused - * - decoding: set by libavcodec - */ - unsigned properties; -#define FF_CODEC_PROPERTY_LOSSLESS 0x00000001 -#define FF_CODEC_PROPERTY_CLOSED_CAPTIONS 0x00000002 - - /** - * Additional data associated with the entire coded stream. - * - * - decoding: unused - * - encoding: may be set by libavcodec after avcodec_open2(). - */ - AVPacketSideData *coded_side_data; - int nb_coded_side_data; - - /** - * A reference to the AVHWFramesContext describing the input (for encoding) - * or output (decoding) frames. The reference is set by the caller and - * afterwards owned (and freed) by libavcodec - it should never be read by - * the caller after being set. - * - * - decoding: This field should be set by the caller from the get_format() - * callback. The previous reference (if any) will always be - * unreffed by libavcodec before the get_format() call. - * - * If the default get_buffer2() is used with a hwaccel pixel - * format, then this AVHWFramesContext will be used for - * allocating the frame buffers. - * - * - encoding: For hardware encoders configured to use a hwaccel pixel - * format, this field should be set by the caller to a reference - * to the AVHWFramesContext describing input frames. - * AVHWFramesContext.format must be equal to - * AVCodecContext.pix_fmt. - * - * This field should be set before avcodec_open2() is called. - */ - AVBufferRef *hw_frames_ctx; - - /** - * Control the form of AVSubtitle.rects[N]->ass - * - decoding: set by user - * - encoding: unused - */ - int sub_text_format; -#define FF_SUB_TEXT_FMT_ASS 0 -#if FF_API_ASS_TIMING -#define FF_SUB_TEXT_FMT_ASS_WITH_TIMINGS 1 -#endif - - /** - * Audio only. The amount of padding (in samples) appended by the encoder to - * the end of the audio. I.e. this number of decoded samples must be - * discarded by the caller from the end of the stream to get the original - * audio without any trailing padding. - * - * - decoding: unused - * - encoding: unused - */ - int trailing_padding; - - /** - * The number of pixels per image to maximally accept. - * - * - decoding: set by user - * - encoding: set by user - */ - int64_t max_pixels; - - /** - * A reference to the AVHWDeviceContext describing the device which will - * be used by a hardware encoder/decoder. The reference is set by the - * caller and afterwards owned (and freed) by libavcodec. - * - * This should be used if either the codec device does not require - * hardware frames or any that are used are to be allocated internally by - * libavcodec. If the user wishes to supply any of the frames used as - * encoder input or decoder output then hw_frames_ctx should be used - * instead. When hw_frames_ctx is set in get_format() for a decoder, this - * field will be ignored while decoding the associated stream segment, but - * may again be used on a following one after another get_format() call. - * - * For both encoders and decoders this field should be set before - * avcodec_open2() is called and must not be written to thereafter. - * - * Note that some decoders may require this field to be set initially in - * order to support hw_frames_ctx at all - in that case, all frames - * contexts used must be created on the same device. - */ - AVBufferRef *hw_device_ctx; - - /** - * Bit set of AV_HWACCEL_FLAG_* flags, which affect hardware accelerated - * decoding (if active). - * - encoding: unused - * - decoding: Set by user (either before avcodec_open2(), or in the - * AVCodecContext.get_format callback) - */ - int hwaccel_flags; - - /** - * Video decoding only. Certain video codecs support cropping, meaning that - * only a sub-rectangle of the decoded frame is intended for display. This - * option controls how cropping is handled by libavcodec. - * - * When set to 1 (the default), libavcodec will apply cropping internally. - * I.e. it will modify the output frame width/height fields and offset the - * data pointers (only by as much as possible while preserving alignment, or - * by the full amount if the AV_CODEC_FLAG_UNALIGNED flag is set) so that - * the frames output by the decoder refer only to the cropped area. The - * crop_* fields of the output frames will be zero. - * - * When set to 0, the width/height fields of the output frames will be set - * to the coded dimensions and the crop_* fields will describe the cropping - * rectangle. Applying the cropping is left to the caller. - * - * @warning When hardware acceleration with opaque output frames is used, - * libavcodec is unable to apply cropping from the top/left border. - * - * @note when this option is set to zero, the width/height fields of the - * AVCodecContext and output AVFrames have different meanings. The codec - * context fields store display dimensions (with the coded dimensions in - * coded_width/height), while the frame fields store the coded dimensions - * (with the display dimensions being determined by the crop_* fields). - */ - int apply_cropping; - - /* - * Video decoding only. Sets the number of extra hardware frames which - * the decoder will allocate for use by the caller. This must be set - * before avcodec_open2() is called. - * - * Some hardware decoders require all frames that they will use for - * output to be defined in advance before decoding starts. For such - * decoders, the hardware frame pool must therefore be of a fixed size. - * The extra frames set here are on top of any number that the decoder - * needs internally in order to operate normally (for example, frames - * used as reference pictures). - */ - int extra_hw_frames; - - /** - * The percentage of damaged samples to discard a frame. - * - * - decoding: set by user - * - encoding: unused - */ - int discard_damaged_percentage; -} AVCodecContext; - -#if FF_API_CODEC_GET_SET -/** - * Accessors for some AVCodecContext fields. These used to be provided for ABI - * compatibility, and do not need to be used anymore. - */ -attribute_deprecated -AVRational av_codec_get_pkt_timebase (const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_pkt_timebase (AVCodecContext *avctx, AVRational val); - -attribute_deprecated -const AVCodecDescriptor *av_codec_get_codec_descriptor(const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_codec_descriptor(AVCodecContext *avctx, const AVCodecDescriptor *desc); - -attribute_deprecated -unsigned av_codec_get_codec_properties(const AVCodecContext *avctx); - -#if FF_API_LOWRES -attribute_deprecated -int av_codec_get_lowres(const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_lowres(AVCodecContext *avctx, int val); -#endif - -attribute_deprecated -int av_codec_get_seek_preroll(const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_seek_preroll(AVCodecContext *avctx, int val); - -attribute_deprecated -uint16_t *av_codec_get_chroma_intra_matrix(const AVCodecContext *avctx); -attribute_deprecated -void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val); -#endif - -/** - * AVProfile. - */ -typedef struct AVProfile { - int profile; - const char *name; ///< short name for the profile -} AVProfile; - -enum { - /** - * The codec supports this format via the hw_device_ctx interface. - * - * When selecting this format, AVCodecContext.hw_device_ctx should - * have been set to a device of the specified type before calling - * avcodec_open2(). - */ - AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01, - /** - * The codec supports this format via the hw_frames_ctx interface. - * - * When selecting this format for a decoder, - * AVCodecContext.hw_frames_ctx should be set to a suitable frames - * context inside the get_format() callback. The frames context - * must have been created on a device of the specified type. - */ - AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02, - /** - * The codec supports this format by some internal method. - * - * This format can be selected without any additional configuration - - * no device or frames context is required. - */ - AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04, - /** - * The codec supports this format by some ad-hoc method. - * - * Additional settings and/or function calls are required. See the - * codec-specific documentation for details. (Methods requiring - * this sort of configuration are deprecated and others should be - * used in preference.) - */ - AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08, -}; - -typedef struct AVCodecHWConfig { - /** - * A hardware pixel format which the codec can use. - */ - enum AVPixelFormat pix_fmt; - /** - * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible - * setup methods which can be used with this configuration. - */ - int methods; - /** - * The device type associated with the configuration. - * - * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and - * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused. - */ - enum AVHWDeviceType device_type; -} AVCodecHWConfig; - -typedef struct AVCodecDefault AVCodecDefault; - -struct AVSubtitle; - -/** - * AVCodec. - */ -typedef struct AVCodec { - /** - * Name of the codec implementation. - * The name is globally unique among encoders and among decoders (but an - * encoder and a decoder can share the same name). - * This is the primary way to find a codec from the user perspective. - */ - const char *name; - /** - * Descriptive name for the codec, meant to be more human readable than name. - * You should use the NULL_IF_CONFIG_SMALL() macro to define it. - */ - const char *long_name; - enum AVMediaType type; - enum AVCodecID id; - /** - * Codec capabilities. - * see AV_CODEC_CAP_* - */ - int capabilities; - const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} - const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 - const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 - const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 - const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 - uint8_t max_lowres; ///< maximum value for lowres supported by the decoder - const AVClass *priv_class; ///< AVClass for the private context - const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} - - /** - * Group name of the codec implementation. - * This is a short symbolic name of the wrapper backing this codec. A - * wrapper uses some kind of external implementation for the codec, such - * as an external library, or a codec implementation provided by the OS or - * the hardware. - * If this field is NULL, this is a builtin, libavcodec native codec. - * If non-NULL, this will be the suffix in AVCodec.name in most cases - * (usually AVCodec.name will be of the form "_"). - */ - const char *wrapper_name; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - int priv_data_size; - struct AVCodec *next; - /** - * @name Frame-level threading support functions - * @{ - */ - /** - * If defined, called on thread contexts when they are created. - * If the codec allocates writable tables in init(), re-allocate them here. - * priv_data will be set to a copy of the original. - */ - int (*init_thread_copy)(AVCodecContext *); - /** - * Copy necessary context variables from a previous thread context to the current one. - * If not defined, the next thread will start automatically; otherwise, the codec - * must call ff_thread_finish_setup(). - * - * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. - */ - int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src); - /** @} */ - - /** - * Private codec-specific defaults. - */ - const AVCodecDefault *defaults; - - /** - * Initialize codec static data, called from avcodec_register(). - * - * This is not intended for time consuming operations as it is - * run for every codec regardless of that codec being used. - */ - void (*init_static_data)(struct AVCodec *codec); - - int (*init)(AVCodecContext *); - int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, - const struct AVSubtitle *sub); - /** - * Encode data to an AVPacket. - * - * @param avctx codec context - * @param avpkt output AVPacket (may contain a user-provided buffer) - * @param[in] frame AVFrame containing the raw data to be encoded - * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a - * non-empty packet was returned in avpkt. - * @return 0 on success, negative error code on failure - */ - int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, - int *got_packet_ptr); - int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); - int (*close)(AVCodecContext *); - /** - * Encode API with decoupled packet/frame dataflow. The API is the - * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except - * that: - * - never called if the codec is closed or the wrong type, - * - if AV_CODEC_CAP_DELAY is not set, drain frames are never sent, - * - only one drain frame is ever passed down, - */ - int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame); - int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt); - - /** - * Decode API with decoupled packet/frame dataflow. This function is called - * to get one output frame. It should call ff_decode_get_packet() to obtain - * input data. - */ - int (*receive_frame)(AVCodecContext *avctx, AVFrame *frame); - /** - * Flush buffers. - * Will be called when seeking - */ - void (*flush)(AVCodecContext *); - /** - * Internal codec capabilities. - * See FF_CODEC_CAP_* in internal.h - */ - int caps_internal; - - /** - * Decoding only, a comma-separated list of bitstream filters to apply to - * packets before decoding. - */ - const char *bsfs; - - /** - * Array of pointers to hardware configurations supported by the codec, - * or NULL if no hardware supported. The array is terminated by a NULL - * pointer. - * - * The user can only access this field via avcodec_get_hw_config(). - */ - const struct AVCodecHWConfigInternal **hw_configs; -} AVCodec; - -#if FF_API_CODEC_GET_SET -attribute_deprecated -int av_codec_get_max_lowres(const AVCodec *codec); -#endif - -struct MpegEncContext; - -/** - * Retrieve supported hardware configurations for a codec. - * - * Values of index from zero to some maximum return the indexed configuration - * descriptor; all other values return NULL. If the codec does not support - * any hardware configurations then it will always return NULL. - */ -const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index); - -/** - * @defgroup lavc_hwaccel AVHWAccel - * - * @note Nothing in this structure should be accessed by the user. At some - * point in future it will not be externally visible at all. - * - * @{ - */ -typedef struct AVHWAccel { - /** - * Name of the hardware accelerated codec. - * The name is globally unique among encoders and among decoders (but an - * encoder and a decoder can share the same name). - */ - const char *name; - - /** - * Type of codec implemented by the hardware accelerator. - * - * See AVMEDIA_TYPE_xxx - */ - enum AVMediaType type; - - /** - * Codec implemented by the hardware accelerator. - * - * See AV_CODEC_ID_xxx - */ - enum AVCodecID id; - - /** - * Supported pixel format. - * - * Only hardware accelerated formats are supported here. - */ - enum AVPixelFormat pix_fmt; - - /** - * Hardware accelerated codec capabilities. - * see AV_HWACCEL_CODEC_CAP_* - */ - int capabilities; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - - /** - * Allocate a custom buffer - */ - int (*alloc_frame)(AVCodecContext *avctx, AVFrame *frame); - - /** - * Called at the beginning of each frame or field picture. - * - * Meaningful frame information (codec specific) is guaranteed to - * be parsed at this point. This function is mandatory. - * - * Note that buf can be NULL along with buf_size set to 0. - * Otherwise, this means the whole frame is available at this point. - * - * @param avctx the codec context - * @param buf the frame data buffer base - * @param buf_size the size of the frame in bytes - * @return zero if successful, a negative value otherwise - */ - int (*start_frame)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); - - /** - * Callback for parameter data (SPS/PPS/VPS etc). - * - * Useful for hardware decoders which keep persistent state about the - * video parameters, and need to receive any changes to update that state. - * - * @param avctx the codec context - * @param type the nal unit type - * @param buf the nal unit data buffer - * @param buf_size the size of the nal unit in bytes - * @return zero if successful, a negative value otherwise - */ - int (*decode_params)(AVCodecContext *avctx, int type, const uint8_t *buf, uint32_t buf_size); - - /** - * Callback for each slice. - * - * Meaningful slice information (codec specific) is guaranteed to - * be parsed at this point. This function is mandatory. - * The only exception is XvMC, that works on MB level. - * - * @param avctx the codec context - * @param buf the slice data buffer base - * @param buf_size the size of the slice in bytes - * @return zero if successful, a negative value otherwise - */ - int (*decode_slice)(AVCodecContext *avctx, const uint8_t *buf, uint32_t buf_size); - - /** - * Called at the end of each frame or field picture. - * - * The whole picture is parsed at this point and can now be sent - * to the hardware accelerator. This function is mandatory. - * - * @param avctx the codec context - * @return zero if successful, a negative value otherwise - */ - int (*end_frame)(AVCodecContext *avctx); - - /** - * Size of per-frame hardware accelerator private data. - * - * Private data is allocated with av_mallocz() before - * AVCodecContext.get_buffer() and deallocated after - * AVCodecContext.release_buffer(). - */ - int frame_priv_data_size; - - /** - * Called for every Macroblock in a slice. - * - * XvMC uses it to replace the ff_mpv_reconstruct_mb(). - * Instead of decoding to raw picture, MB parameters are - * stored in an array provided by the video driver. - * - * @param s the mpeg context - */ - void (*decode_mb)(struct MpegEncContext *s); - - /** - * Initialize the hwaccel private data. - * - * This will be called from ff_get_format(), after hwaccel and - * hwaccel_context are set and the hwaccel private data in AVCodecInternal - * is allocated. - */ - int (*init)(AVCodecContext *avctx); - - /** - * Uninitialize the hwaccel private data. - * - * This will be called from get_format() or avcodec_close(), after hwaccel - * and hwaccel_context are already uninitialized. - */ - int (*uninit)(AVCodecContext *avctx); - - /** - * Size of the private data to allocate in - * AVCodecInternal.hwaccel_priv_data. - */ - int priv_data_size; - - /** - * Internal hwaccel capabilities. - */ - int caps_internal; - - /** - * Fill the given hw_frames context with current codec parameters. Called - * from get_format. Refer to avcodec_get_hw_frames_parameters() for - * details. - * - * This CAN be called before AVHWAccel.init is called, and you must assume - * that avctx->hwaccel_priv_data is invalid. - */ - int (*frame_params)(AVCodecContext *avctx, AVBufferRef *hw_frames_ctx); -} AVHWAccel; - -/** - * HWAccel is experimental and is thus avoided in favor of non experimental - * codecs - */ -#define AV_HWACCEL_CODEC_CAP_EXPERIMENTAL 0x0200 - -/** - * Hardware acceleration should be used for decoding even if the codec level - * used is unknown or higher than the maximum supported level reported by the - * hardware driver. - * - * It's generally a good idea to pass this flag unless you have a specific - * reason not to, as hardware tends to under-report supported levels. - */ -#define AV_HWACCEL_FLAG_IGNORE_LEVEL (1 << 0) - -/** - * Hardware acceleration can output YUV pixel formats with a different chroma - * sampling than 4:2:0 and/or other than 8 bits per component. - */ -#define AV_HWACCEL_FLAG_ALLOW_HIGH_DEPTH (1 << 1) - -/** - * Hardware acceleration should still be attempted for decoding when the - * codec profile does not match the reported capabilities of the hardware. - * - * For example, this can be used to try to decode baseline profile H.264 - * streams in hardware - it will often succeed, because many streams marked - * as baseline profile actually conform to constrained baseline profile. - * - * @warning If the stream is actually not supported then the behaviour is - * undefined, and may include returning entirely incorrect output - * while indicating success. - */ -#define AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH (1 << 2) - -/** - * @} - */ - -#if FF_API_AVPICTURE -/** - * @defgroup lavc_picture AVPicture - * - * Functions for working with AVPicture - * @{ - */ - -/** - * Picture data structure. - * - * Up to four components can be stored into it, the last component is - * alpha. - * @deprecated use AVFrame or imgutils functions instead - */ -typedef struct AVPicture { - attribute_deprecated - uint8_t *data[AV_NUM_DATA_POINTERS]; ///< pointers to the image data planes - attribute_deprecated - int linesize[AV_NUM_DATA_POINTERS]; ///< number of bytes per line -} AVPicture; - -/** - * @} - */ -#endif - -enum AVSubtitleType { - SUBTITLE_NONE, - - SUBTITLE_BITMAP, ///< A bitmap, pict will be set - - /** - * Plain text, the text field must be set by the decoder and is - * authoritative. ass and pict fields may contain approximations. - */ - SUBTITLE_TEXT, - - /** - * Formatted text, the ass field must be set by the decoder and is - * authoritative. pict and text fields may contain approximations. - */ - SUBTITLE_ASS, -}; - -#define AV_SUBTITLE_FLAG_FORCED 0x00000001 - -typedef struct AVSubtitleRect { - int x; ///< top left corner of pict, undefined when pict is not set - int y; ///< top left corner of pict, undefined when pict is not set - int w; ///< width of pict, undefined when pict is not set - int h; ///< height of pict, undefined when pict is not set - int nb_colors; ///< number of colors in pict, undefined when pict is not set - -#if FF_API_AVPICTURE - /** - * @deprecated unused - */ - attribute_deprecated - AVPicture pict; -#endif - /** - * data+linesize for the bitmap of this subtitle. - * Can be set for text/ass as well once they are rendered. - */ - uint8_t *data[4]; - int linesize[4]; - - enum AVSubtitleType type; - - char *text; ///< 0 terminated plain UTF-8 text - - /** - * 0 terminated ASS/SSA compatible event line. - * The presentation of this is unaffected by the other values in this - * struct. - */ - char *ass; - - int flags; -} AVSubtitleRect; - -typedef struct AVSubtitle { - uint16_t format; /* 0 = graphics */ - uint32_t start_display_time; /* relative to packet pts, in ms */ - uint32_t end_display_time; /* relative to packet pts, in ms */ - unsigned num_rects; - AVSubtitleRect **rects; - int64_t pts; ///< Same as packet pts, in AV_TIME_BASE -} AVSubtitle; - -/** - * This struct describes the properties of an encoded stream. - * - * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must - * be allocated with avcodec_parameters_alloc() and freed with - * avcodec_parameters_free(). - */ -typedef struct AVCodecParameters { - /** - * General type of the encoded data. - */ - enum AVMediaType codec_type; - /** - * Specific type of the encoded data (the codec used). - */ - enum AVCodecID codec_id; - /** - * Additional information about the codec (corresponds to the AVI FOURCC). - */ - uint32_t codec_tag; - - /** - * Extra binary data needed for initializing the decoder, codec-dependent. - * - * Must be allocated with av_malloc() and will be freed by - * avcodec_parameters_free(). The allocated size of extradata must be at - * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding - * bytes zeroed. - */ - uint8_t *extradata; - /** - * Size of the extradata content in bytes. - */ - int extradata_size; - - /** - * - video: the pixel format, the value corresponds to enum AVPixelFormat. - * - audio: the sample format, the value corresponds to enum AVSampleFormat. - */ - int format; - - /** - * The average bitrate of the encoded data (in bits per second). - */ - int64_t bit_rate; - - /** - * The number of bits per sample in the codedwords. - * - * This is basically the bitrate per sample. It is mandatory for a bunch of - * formats to actually decode them. It's the number of bits for one sample in - * the actual coded bitstream. - * - * This could be for example 4 for ADPCM - * For PCM formats this matches bits_per_raw_sample - * Can be 0 - */ - int bits_per_coded_sample; - - /** - * This is the number of valid bits in each output sample. If the - * sample format has more bits, the least significant bits are additional - * padding bits, which are always 0. Use right shifts to reduce the sample - * to its actual size. For example, audio formats with 24 bit samples will - * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32. - * To get the original sample use "(int32_t)sample >> 8"." - * - * For ADPCM this might be 12 or 16 or similar - * Can be 0 - */ - int bits_per_raw_sample; - - /** - * Codec-specific bitstream restrictions that the stream conforms to. - */ - int profile; - int level; - - /** - * Video only. The dimensions of the video frame in pixels. - */ - int width; - int height; - - /** - * Video only. The aspect ratio (width / height) which a single pixel - * should have when displayed. - * - * When the aspect ratio is unknown / undefined, the numerator should be - * set to 0 (the denominator may have any value). - */ - AVRational sample_aspect_ratio; - - /** - * Video only. The order of the fields in interlaced video. - */ - enum AVFieldOrder field_order; - - /** - * Video only. Additional colorspace characteristics. - */ - enum AVColorRange color_range; - enum AVColorPrimaries color_primaries; - enum AVColorTransferCharacteristic color_trc; - enum AVColorSpace color_space; - enum AVChromaLocation chroma_location; - - /** - * Video only. Number of delayed frames. - */ - int video_delay; - - /** - * Audio only. The channel layout bitmask. May be 0 if the channel layout is - * unknown or unspecified, otherwise the number of bits set must be equal to - * the channels field. - */ - uint64_t channel_layout; - /** - * Audio only. The number of audio channels. - */ - int channels; - /** - * Audio only. The number of audio samples per second. - */ - int sample_rate; - /** - * Audio only. The number of bytes per coded audio frame, required by some - * formats. - * - * Corresponds to nBlockAlign in WAVEFORMATEX. - */ - int block_align; - /** - * Audio only. Audio frame size, if known. Required by some formats to be static. - */ - int frame_size; - - /** - * Audio only. The amount of padding (in samples) inserted by the encoder at - * the beginning of the audio. I.e. this number of leading decoded samples - * must be discarded by the caller to get the original audio without leading - * padding. - */ - int initial_padding; - /** - * Audio only. The amount of padding (in samples) appended by the encoder to - * the end of the audio. I.e. this number of decoded samples must be - * discarded by the caller from the end of the stream to get the original - * audio without any trailing padding. - */ - int trailing_padding; - /** - * Audio only. Number of samples to skip after a discontinuity. - */ - int seek_preroll; -} AVCodecParameters; - -/** - * Iterate over all registered codecs. - * - * @param opaque a pointer where libavcodec will store the iteration state. Must - * point to NULL to start the iteration. - * - * @return the next registered codec or NULL when the iteration is - * finished - */ -const AVCodec *av_codec_iterate(void **opaque); - -#if FF_API_NEXT -/** - * If c is NULL, returns the first registered codec, - * if c is non-NULL, returns the next registered codec after c, - * or NULL if c is the last one. - */ -attribute_deprecated -AVCodec *av_codec_next(const AVCodec *c); -#endif - -/** - * Return the LIBAVCODEC_VERSION_INT constant. - */ -unsigned avcodec_version(void); - -/** - * Return the libavcodec build-time configuration. - */ -const char *avcodec_configuration(void); - -/** - * Return the libavcodec license. - */ -const char *avcodec_license(void); - -#if FF_API_NEXT -/** - * Register the codec codec and initialize libavcodec. - * - * @warning either this function or avcodec_register_all() must be called - * before any other libavcodec functions. - * - * @see avcodec_register_all() - */ -attribute_deprecated -void avcodec_register(AVCodec *codec); - -/** - * Register all the codecs, parsers and bitstream filters which were enabled at - * configuration time. If you do not call this function you can select exactly - * which formats you want to support, by using the individual registration - * functions. - * - * @see avcodec_register - * @see av_register_codec_parser - * @see av_register_bitstream_filter - */ -attribute_deprecated -void avcodec_register_all(void); -#endif - -/** - * Allocate an AVCodecContext and set its fields to default values. The - * resulting struct should be freed with avcodec_free_context(). - * - * @param codec if non-NULL, allocate private data and initialize defaults - * for the given codec. It is illegal to then call avcodec_open2() - * with a different codec. - * If NULL, then the codec-specific defaults won't be initialized, - * which may result in suboptimal default settings (this is - * important mainly for encoders, e.g. libx264). - * - * @return An AVCodecContext filled with default values or NULL on failure. - */ -AVCodecContext *avcodec_alloc_context3(const AVCodec *codec); - -/** - * Free the codec context and everything associated with it and write NULL to - * the provided pointer. - */ -void avcodec_free_context(AVCodecContext **avctx); - -#if FF_API_GET_CONTEXT_DEFAULTS -/** - * @deprecated This function should not be used, as closing and opening a codec - * context multiple time is not supported. A new codec context should be - * allocated for each new use. - */ -int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); -#endif - -/** - * Get the AVClass for AVCodecContext. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). - */ -const AVClass *avcodec_get_class(void); - -#if FF_API_COPY_CONTEXT -/** - * Get the AVClass for AVFrame. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). - */ -const AVClass *avcodec_get_frame_class(void); - -/** - * Get the AVClass for AVSubtitleRect. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). - */ -const AVClass *avcodec_get_subtitle_rect_class(void); - -/** - * Copy the settings of the source AVCodecContext into the destination - * AVCodecContext. The resulting destination codec context will be - * unopened, i.e. you are required to call avcodec_open2() before you - * can use this AVCodecContext to decode/encode video/audio data. - * - * @param dest target codec context, should be initialized with - * avcodec_alloc_context3(NULL), but otherwise uninitialized - * @param src source codec context - * @return AVERROR() on error (e.g. memory allocation error), 0 on success - * - * @deprecated The semantics of this function are ill-defined and it should not - * be used. If you need to transfer the stream parameters from one codec context - * to another, use an intermediate AVCodecParameters instance and the - * avcodec_parameters_from_context() / avcodec_parameters_to_context() - * functions. - */ -attribute_deprecated -int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); -#endif - -/** - * Allocate a new AVCodecParameters and set its fields to default values - * (unknown/invalid/0). The returned struct must be freed with - * avcodec_parameters_free(). - */ -AVCodecParameters *avcodec_parameters_alloc(void); - -/** - * Free an AVCodecParameters instance and everything associated with it and - * write NULL to the supplied pointer. - */ -void avcodec_parameters_free(AVCodecParameters **par); - -/** - * Copy the contents of src to dst. Any allocated fields in dst are freed and - * replaced with newly allocated duplicates of the corresponding fields in src. - * - * @return >= 0 on success, a negative AVERROR code on failure. - */ -int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src); - -/** - * Fill the parameters struct based on the values from the supplied codec - * context. Any allocated fields in par are freed and replaced with duplicates - * of the corresponding fields in codec. - * - * @return >= 0 on success, a negative AVERROR code on failure - */ -int avcodec_parameters_from_context(AVCodecParameters *par, - const AVCodecContext *codec); - -/** - * Fill the codec context based on the values from the supplied codec - * parameters. Any allocated fields in codec that have a corresponding field in - * par are freed and replaced with duplicates of the corresponding field in par. - * Fields in codec that do not have a counterpart in par are not touched. - * - * @return >= 0 on success, a negative AVERROR code on failure. - */ -int avcodec_parameters_to_context(AVCodecContext *codec, - const AVCodecParameters *par); - -/** - * Initialize the AVCodecContext to use the given AVCodec. Prior to using this - * function the context has to be allocated with avcodec_alloc_context3(). - * - * The functions avcodec_find_decoder_by_name(), avcodec_find_encoder_by_name(), - * avcodec_find_decoder() and avcodec_find_encoder() provide an easy way for - * retrieving a codec. - * - * @warning This function is not thread safe! - * - * @note Always call this function before using decoding routines (such as - * @ref avcodec_receive_frame()). - * - * @code - * avcodec_register_all(); - * av_dict_set(&opts, "b", "2.5M", 0); - * codec = avcodec_find_decoder(AV_CODEC_ID_H264); - * if (!codec) - * exit(1); - * - * context = avcodec_alloc_context3(codec); - * - * if (avcodec_open2(context, codec, opts) < 0) - * exit(1); - * @endcode - * - * @param avctx The context to initialize. - * @param codec The codec to open this context for. If a non-NULL codec has been - * previously passed to avcodec_alloc_context3() or - * for this context, then this parameter MUST be either NULL or - * equal to the previously passed codec. - * @param options A dictionary filled with AVCodecContext and codec-private options. - * On return this object will be filled with options that were not found. - * - * @return zero on success, a negative value on error - * @see avcodec_alloc_context3(), avcodec_find_decoder(), avcodec_find_encoder(), - * av_dict_set(), av_opt_find(). - */ -int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options); - -/** - * Close a given AVCodecContext and free all the data associated with it - * (but not the AVCodecContext itself). - * - * Calling this function on an AVCodecContext that hasn't been opened will free - * the codec-specific data allocated in avcodec_alloc_context3() with a non-NULL - * codec. Subsequent calls will do nothing. - * - * @note Do not use this function. Use avcodec_free_context() to destroy a - * codec context (either open or closed). Opening and closing a codec context - * multiple times is not supported anymore -- use multiple codec contexts - * instead. - */ -int avcodec_close(AVCodecContext *avctx); - -/** - * Free all allocated data in the given subtitle struct. - * - * @param sub AVSubtitle to free. - */ -void avsubtitle_free(AVSubtitle *sub); - -/** - * @} - */ - -/** - * @addtogroup lavc_packet - * @{ - */ - -/** - * Allocate an AVPacket and set its fields to default values. The resulting - * struct must be freed using av_packet_free(). - * - * @return An AVPacket filled with default values or NULL on failure. - * - * @note this only allocates the AVPacket itself, not the data buffers. Those - * must be allocated through other means such as av_new_packet. - * - * @see av_new_packet - */ -AVPacket *av_packet_alloc(void); - -/** - * Create a new packet that references the same data as src. - * - * This is a shortcut for av_packet_alloc()+av_packet_ref(). - * - * @return newly created AVPacket on success, NULL on error. - * - * @see av_packet_alloc - * @see av_packet_ref - */ -AVPacket *av_packet_clone(const AVPacket *src); - -/** - * Free the packet, if the packet is reference counted, it will be - * unreferenced first. - * - * @param pkt packet to be freed. The pointer will be set to NULL. - * @note passing NULL is a no-op. - */ -void av_packet_free(AVPacket **pkt); - -/** - * Initialize optional fields of a packet with default values. - * - * Note, this does not touch the data and size members, which have to be - * initialized separately. - * - * @param pkt packet - */ -void av_init_packet(AVPacket *pkt); - -/** - * Allocate the payload of a packet and initialize its fields with - * default values. - * - * @param pkt packet - * @param size wanted payload size - * @return 0 if OK, AVERROR_xxx otherwise - */ -int av_new_packet(AVPacket *pkt, int size); - -/** - * Reduce packet size, correctly zeroing padding - * - * @param pkt packet - * @param size new size - */ -void av_shrink_packet(AVPacket *pkt, int size); - -/** - * Increase packet size, correctly zeroing padding - * - * @param pkt packet - * @param grow_by number of bytes by which to increase the size of the packet - */ -int av_grow_packet(AVPacket *pkt, int grow_by); - -/** - * Initialize a reference-counted packet from av_malloc()ed data. - * - * @param pkt packet to be initialized. This function will set the data, size, - * and buf fields, all others are left untouched. - * @param data Data allocated by av_malloc() to be used as packet data. If this - * function returns successfully, the data is owned by the underlying AVBuffer. - * The caller may not access the data through other means. - * @param size size of data in bytes, without the padding. I.e. the full buffer - * size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE. - * - * @return 0 on success, a negative AVERROR on error - */ -int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size); - -#if FF_API_AVPACKET_OLD_API -/** - * @warning This is a hack - the packet memory allocation stuff is broken. The - * packet is allocated if it was not really allocated. - * - * @deprecated Use av_packet_ref or av_packet_make_refcounted - */ -attribute_deprecated -int av_dup_packet(AVPacket *pkt); -/** - * Copy packet, including contents - * - * @return 0 on success, negative AVERROR on fail - * - * @deprecated Use av_packet_ref - */ -attribute_deprecated -int av_copy_packet(AVPacket *dst, const AVPacket *src); - -/** - * Copy packet side data - * - * @return 0 on success, negative AVERROR on fail - * - * @deprecated Use av_packet_copy_props - */ -attribute_deprecated -int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src); - -/** - * Free a packet. - * - * @deprecated Use av_packet_unref - * - * @param pkt packet to free - */ -attribute_deprecated -void av_free_packet(AVPacket *pkt); -#endif -/** - * Allocate new information of a packet. - * - * @param pkt packet - * @param type side information type - * @param size side information size - * @return pointer to fresh allocated data or NULL otherwise - */ -uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, - int size); - -/** - * Wrap an existing array as a packet side data. - * - * @param pkt packet - * @param type side information type - * @param data the side data array. It must be allocated with the av_malloc() - * family of functions. The ownership of the data is transferred to - * pkt. - * @param size side information size - * @return a non-negative number on success, a negative AVERROR code on - * failure. On failure, the packet is unchanged and the data remains - * owned by the caller. - */ -int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, - uint8_t *data, size_t size); - -/** - * Shrink the already allocated side data buffer - * - * @param pkt packet - * @param type side information type - * @param size new side information size - * @return 0 on success, < 0 on failure - */ -int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, - int size); - -/** - * Get side information from packet. - * - * @param pkt packet - * @param type desired side information type - * @param size pointer for side information size to store (optional) - * @return pointer to data if present or NULL otherwise - */ -uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, - int *size); - -#if FF_API_MERGE_SD_API -attribute_deprecated -int av_packet_merge_side_data(AVPacket *pkt); - -attribute_deprecated -int av_packet_split_side_data(AVPacket *pkt); -#endif - -const char *av_packet_side_data_name(enum AVPacketSideDataType type); - -/** - * Pack a dictionary for use in side_data. - * - * @param dict The dictionary to pack. - * @param size pointer to store the size of the returned data - * @return pointer to data if successful, NULL otherwise - */ -uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size); -/** - * Unpack a dictionary from side_data. - * - * @param data data from side_data - * @param size size of the data - * @param dict the metadata storage dictionary - * @return 0 on success, < 0 on failure - */ -int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict); - - -/** - * Convenience function to free all the side data stored. - * All the other fields stay untouched. - * - * @param pkt packet - */ -void av_packet_free_side_data(AVPacket *pkt); - -/** - * Setup a new reference to the data described by a given packet - * - * If src is reference-counted, setup dst as a new reference to the - * buffer in src. Otherwise allocate a new buffer in dst and copy the - * data from src into it. - * - * All the other fields are copied from src. - * - * @see av_packet_unref - * - * @param dst Destination packet - * @param src Source packet - * - * @return 0 on success, a negative AVERROR on error. - */ -int av_packet_ref(AVPacket *dst, const AVPacket *src); - -/** - * Wipe the packet. - * - * Unreference the buffer referenced by the packet and reset the - * remaining packet fields to their default values. - * - * @param pkt The packet to be unreferenced. - */ -void av_packet_unref(AVPacket *pkt); - -/** - * Move every field in src to dst and reset src. - * - * @see av_packet_unref - * - * @param src Source packet, will be reset - * @param dst Destination packet - */ -void av_packet_move_ref(AVPacket *dst, AVPacket *src); - -/** - * Copy only "properties" fields from src to dst. - * - * Properties for the purpose of this function are all the fields - * beside those related to the packet data (buf, data, size) - * - * @param dst Destination packet - * @param src Source packet - * - * @return 0 on success AVERROR on failure. - */ -int av_packet_copy_props(AVPacket *dst, const AVPacket *src); - -/** - * Ensure the data described by a given packet is reference counted. - * - * @note This function does not ensure that the reference will be writable. - * Use av_packet_make_writable instead for that purpose. - * - * @see av_packet_ref - * @see av_packet_make_writable - * - * @param pkt packet whose data should be made reference counted. - * - * @return 0 on success, a negative AVERROR on error. On failure, the - * packet is unchanged. - */ -int av_packet_make_refcounted(AVPacket *pkt); - -/** - * Create a writable reference for the data described by a given packet, - * avoiding data copy if possible. - * - * @param pkt Packet whose data should be made writable. - * - * @return 0 on success, a negative AVERROR on failure. On failure, the - * packet is unchanged. - */ -int av_packet_make_writable(AVPacket *pkt); - -/** - * Convert valid timing fields (timestamps / durations) in a packet from one - * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be - * ignored. - * - * @param pkt packet on which the conversion will be performed - * @param tb_src source timebase, in which the timing fields in pkt are - * expressed - * @param tb_dst destination timebase, to which the timing fields will be - * converted - */ -void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); - -/** - * @} - */ - -/** - * @addtogroup lavc_decoding - * @{ - */ - -/** - * Find a registered decoder with a matching codec ID. - * - * @param id AVCodecID of the requested decoder - * @return A decoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_decoder(enum AVCodecID id); - -/** - * Find a registered decoder with the specified name. - * - * @param name name of the requested decoder - * @return A decoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_decoder_by_name(const char *name); - -/** - * The default callback for AVCodecContext.get_buffer2(). It is made public so - * it can be called by custom get_buffer2() implementations for decoders without - * AV_CODEC_CAP_DR1 set. - */ -int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags); - -/** - * Modify width and height values so that they will result in a memory - * buffer that is acceptable for the codec if you do not use any horizontal - * padding. - * - * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened. - */ -void avcodec_align_dimensions(AVCodecContext *s, int *width, int *height); - -/** - * Modify width and height values so that they will result in a memory - * buffer that is acceptable for the codec if you also ensure that all - * line sizes are a multiple of the respective linesize_align[i]. - * - * May only be used if a codec with AV_CODEC_CAP_DR1 has been opened. - */ -void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, - int linesize_align[AV_NUM_DATA_POINTERS]); - -/** - * Converts AVChromaLocation to swscale x/y chroma position. - * - * The positions represent the chroma (0,0) position in a coordinates system - * with luma (0,0) representing the origin and luma(1,1) representing 256,256 - * - * @param xpos horizontal chroma sample position - * @param ypos vertical chroma sample position - */ -int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); - -/** - * Converts swscale x/y chroma position to AVChromaLocation. - * - * The positions represent the chroma (0,0) position in a coordinates system - * with luma (0,0) representing the origin and luma(1,1) representing 256,256 - * - * @param xpos horizontal chroma sample position - * @param ypos vertical chroma sample position - */ -enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); - -/** - * Decode the audio frame of size avpkt->size from avpkt->data into frame. - * - * Some decoders may support multiple frames in a single AVPacket. Such - * decoders would then just decode the first frame and the return value would be - * less than the packet size. In this case, avcodec_decode_audio4 has to be - * called again with an AVPacket containing the remaining data in order to - * decode the second frame, etc... Even if no frames are returned, the packet - * needs to be fed to the decoder with remaining data until it is completely - * consumed or an error occurs. - * - * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input - * and output. This means that for some packets they will not immediately - * produce decoded output and need to be flushed at the end of decoding to get - * all the decoded data. Flushing is done by calling this function with packets - * with avpkt->data set to NULL and avpkt->size set to 0 until it stops - * returning samples. It is safe to flush even those decoders that are not - * marked with AV_CODEC_CAP_DELAY, then no samples will be returned. - * - * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE - * larger than the actual read bytes because some optimized bitstream - * readers read 32 or 64 bits at once and could read over the end. - * - * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() - * before packets may be fed to the decoder. - * - * @param avctx the codec context - * @param[out] frame The AVFrame in which to store decoded audio samples. - * The decoder will allocate a buffer for the decoded frame by - * calling the AVCodecContext.get_buffer2() callback. - * When AVCodecContext.refcounted_frames is set to 1, the frame is - * reference counted and the returned reference belongs to the - * caller. The caller must release the frame using av_frame_unref() - * when the frame is no longer needed. The caller may safely write - * to the frame if av_frame_is_writable() returns 1. - * When AVCodecContext.refcounted_frames is set to 0, the returned - * reference belongs to the decoder and is valid only until the - * next call to this function or until closing or flushing the - * decoder. The caller may not write to it. - * @param[out] got_frame_ptr Zero if no frame could be decoded, otherwise it is - * non-zero. Note that this field being set to zero - * does not mean that an error has occurred. For - * decoders with AV_CODEC_CAP_DELAY set, no given decode - * call is guaranteed to produce a frame. - * @param[in] avpkt The input AVPacket containing the input buffer. - * At least avpkt->data and avpkt->size should be set. Some - * decoders might also require additional fields to be set. - * @return A negative error code is returned if an error occurred during - * decoding, otherwise the number of bytes consumed from the input - * AVPacket is returned. - * -* @deprecated Use avcodec_send_packet() and avcodec_receive_frame(). - */ -attribute_deprecated -int avcodec_decode_audio4(AVCodecContext *avctx, AVFrame *frame, - int *got_frame_ptr, const AVPacket *avpkt); - -/** - * Decode the video frame of size avpkt->size from avpkt->data into picture. - * Some decoders may support multiple frames in a single AVPacket, such - * decoders would then just decode the first frame. - * - * @warning The input buffer must be AV_INPUT_BUFFER_PADDING_SIZE larger than - * the actual read bytes because some optimized bitstream readers read 32 or 64 - * bits at once and could read over the end. - * - * @warning The end of the input buffer buf should be set to 0 to ensure that - * no overreading happens for damaged MPEG streams. - * - * @note Codecs which have the AV_CODEC_CAP_DELAY capability set have a delay - * between input and output, these need to be fed with avpkt->data=NULL, - * avpkt->size=0 at the end to return the remaining frames. - * - * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() - * before packets may be fed to the decoder. - * - * @param avctx the codec context - * @param[out] picture The AVFrame in which the decoded video frame will be stored. - * Use av_frame_alloc() to get an AVFrame. The codec will - * allocate memory for the actual bitmap by calling the - * AVCodecContext.get_buffer2() callback. - * When AVCodecContext.refcounted_frames is set to 1, the frame is - * reference counted and the returned reference belongs to the - * caller. The caller must release the frame using av_frame_unref() - * when the frame is no longer needed. The caller may safely write - * to the frame if av_frame_is_writable() returns 1. - * When AVCodecContext.refcounted_frames is set to 0, the returned - * reference belongs to the decoder and is valid only until the - * next call to this function or until closing or flushing the - * decoder. The caller may not write to it. - * - * @param[in] avpkt The input AVPacket containing the input buffer. - * You can create such packet with av_init_packet() and by then setting - * data and size, some decoders might in addition need other fields like - * flags&AV_PKT_FLAG_KEY. All decoders are designed to use the least - * fields possible. - * @param[in,out] got_picture_ptr Zero if no frame could be decompressed, otherwise, it is nonzero. - * @return On error a negative value is returned, otherwise the number of bytes - * used or zero if no frame could be decompressed. - * - * @deprecated Use avcodec_send_packet() and avcodec_receive_frame(). - */ -attribute_deprecated -int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, - int *got_picture_ptr, - const AVPacket *avpkt); - -/** - * Decode a subtitle message. - * Return a negative value on error, otherwise return the number of bytes used. - * If no subtitle could be decompressed, got_sub_ptr is zero. - * Otherwise, the subtitle is stored in *sub. - * Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for - * simplicity, because the performance difference is expect to be negligible - * and reusing a get_buffer written for video codecs would probably perform badly - * due to a potentially very different allocation pattern. - * - * Some decoders (those marked with AV_CODEC_CAP_DELAY) have a delay between input - * and output. This means that for some packets they will not immediately - * produce decoded output and need to be flushed at the end of decoding to get - * all the decoded data. Flushing is done by calling this function with packets - * with avpkt->data set to NULL and avpkt->size set to 0 until it stops - * returning subtitles. It is safe to flush even those decoders that are not - * marked with AV_CODEC_CAP_DELAY, then no subtitles will be returned. - * - * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() - * before packets may be fed to the decoder. - * - * @param avctx the codec context - * @param[out] sub The Preallocated AVSubtitle in which the decoded subtitle will be stored, - * must be freed with avsubtitle_free if *got_sub_ptr is set. - * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. - * @param[in] avpkt The input AVPacket containing the input buffer. - */ -int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, - int *got_sub_ptr, - AVPacket *avpkt); - -/** - * Supply raw packet data as input to a decoder. - * - * Internally, this call will copy relevant AVCodecContext fields, which can - * influence decoding per-packet, and apply them when the packet is actually - * decoded. (For example AVCodecContext.skip_frame, which might direct the - * decoder to drop the frame contained by the packet sent with this function.) - * - * @warning The input buffer, avpkt->data must be AV_INPUT_BUFFER_PADDING_SIZE - * larger than the actual read bytes because some optimized bitstream - * readers read 32 or 64 bits at once and could read over the end. - * - * @warning Do not mix this API with the legacy API (like avcodec_decode_video2()) - * on the same AVCodecContext. It will return unexpected results now - * or in future libavcodec versions. - * - * @note The AVCodecContext MUST have been opened with @ref avcodec_open2() - * before packets may be fed to the decoder. - * - * @param avctx codec context - * @param[in] avpkt The input AVPacket. Usually, this will be a single video - * frame, or several complete audio frames. - * Ownership of the packet remains with the caller, and the - * decoder will not write to the packet. The decoder may create - * a reference to the packet data (or copy it if the packet is - * not reference-counted). - * Unlike with older APIs, the packet is always fully consumed, - * and if it contains multiple frames (e.g. some audio codecs), - * will require you to call avcodec_receive_frame() multiple - * times afterwards before you can send a new packet. - * It can be NULL (or an AVPacket with data set to NULL and - * size set to 0); in this case, it is considered a flush - * packet, which signals the end of the stream. Sending the - * first flush packet will return success. Subsequent ones are - * unnecessary and will return AVERROR_EOF. If the decoder - * still has frames buffered, it will return them after sending - * a flush packet. - * - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): input is not accepted in the current state - user - * must read output with avcodec_receive_frame() (once - * all output is read, the packet should be resent, and - * the call will not fail with EAGAIN). - * AVERROR_EOF: the decoder has been flushed, and no new packets can - * be sent to it (also returned if more than 1 flush - * packet is sent) - * AVERROR(EINVAL): codec not opened, it is an encoder, or requires flush - * AVERROR(ENOMEM): failed to add packet to internal queue, or similar - * other errors: legitimate decoding errors - */ -int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt); - -/** - * Return decoded output data from a decoder. - * - * @param avctx codec context - * @param frame This will be set to a reference-counted video or audio - * frame (depending on the decoder type) allocated by the - * decoder. Note that the function will always call - * av_frame_unref(frame) before doing anything else. - * - * @return - * 0: success, a frame was returned - * AVERROR(EAGAIN): output is not available in this state - user must try - * to send new input - * AVERROR_EOF: the decoder has been fully flushed, and there will be - * no more output frames - * AVERROR(EINVAL): codec not opened, or it is an encoder - * AVERROR_INPUT_CHANGED: current decoded frame has changed parameters - * with respect to first decoded frame. Applicable - * when flag AV_CODEC_FLAG_DROPCHANGED is set. - * other negative values: legitimate decoding errors - */ -int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); - -/** - * Supply a raw video or audio frame to the encoder. Use avcodec_receive_packet() - * to retrieve buffered output packets. - * - * @param avctx codec context - * @param[in] frame AVFrame containing the raw audio or video frame to be encoded. - * Ownership of the frame remains with the caller, and the - * encoder will not write to the frame. The encoder may create - * a reference to the frame data (or copy it if the frame is - * not reference-counted). - * It can be NULL, in which case it is considered a flush - * packet. This signals the end of the stream. If the encoder - * still has packets buffered, it will return them after this - * call. Once flushing mode has been entered, additional flush - * packets are ignored, and sending frames will return - * AVERROR_EOF. - * - * For audio: - * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame - * can have any number of samples. - * If it is not set, frame->nb_samples must be equal to - * avctx->frame_size for all frames except the last. - * The final frame may be smaller than avctx->frame_size. - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): input is not accepted in the current state - user - * must read output with avcodec_receive_packet() (once - * all output is read, the packet should be resent, and - * the call will not fail with EAGAIN). - * AVERROR_EOF: the encoder has been flushed, and no new frames can - * be sent to it - * AVERROR(EINVAL): codec not opened, refcounted_frames not set, it is a - * decoder, or requires flush - * AVERROR(ENOMEM): failed to add packet to internal queue, or similar - * other errors: legitimate decoding errors - */ -int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); - -/** - * Read encoded data from the encoder. - * - * @param avctx codec context - * @param avpkt This will be set to a reference-counted packet allocated by the - * encoder. Note that the function will always call - * av_frame_unref(frame) before doing anything else. - * @return 0 on success, otherwise negative error code: - * AVERROR(EAGAIN): output is not available in the current state - user - * must try to send input - * AVERROR_EOF: the encoder has been fully flushed, and there will be - * no more output packets - * AVERROR(EINVAL): codec not opened, or it is an encoder - * other errors: legitimate decoding errors - */ -int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt); - -/** - * Create and return a AVHWFramesContext with values adequate for hardware - * decoding. This is meant to get called from the get_format callback, and is - * a helper for preparing a AVHWFramesContext for AVCodecContext.hw_frames_ctx. - * This API is for decoding with certain hardware acceleration modes/APIs only. - * - * The returned AVHWFramesContext is not initialized. The caller must do this - * with av_hwframe_ctx_init(). - * - * Calling this function is not a requirement, but makes it simpler to avoid - * codec or hardware API specific details when manually allocating frames. - * - * Alternatively to this, an API user can set AVCodecContext.hw_device_ctx, - * which sets up AVCodecContext.hw_frames_ctx fully automatically, and makes - * it unnecessary to call this function or having to care about - * AVHWFramesContext initialization at all. - * - * There are a number of requirements for calling this function: - * - * - It must be called from get_format with the same avctx parameter that was - * passed to get_format. Calling it outside of get_format is not allowed, and - * can trigger undefined behavior. - * - The function is not always supported (see description of return values). - * Even if this function returns successfully, hwaccel initialization could - * fail later. (The degree to which implementations check whether the stream - * is actually supported varies. Some do this check only after the user's - * get_format callback returns.) - * - The hw_pix_fmt must be one of the choices suggested by get_format. If the - * user decides to use a AVHWFramesContext prepared with this API function, - * the user must return the same hw_pix_fmt from get_format. - * - The device_ref passed to this function must support the given hw_pix_fmt. - * - After calling this API function, it is the user's responsibility to - * initialize the AVHWFramesContext (returned by the out_frames_ref parameter), - * and to set AVCodecContext.hw_frames_ctx to it. If done, this must be done - * before returning from get_format (this is implied by the normal - * AVCodecContext.hw_frames_ctx API rules). - * - The AVHWFramesContext parameters may change every time time get_format is - * called. Also, AVCodecContext.hw_frames_ctx is reset before get_format. So - * you are inherently required to go through this process again on every - * get_format call. - * - It is perfectly possible to call this function without actually using - * the resulting AVHWFramesContext. One use-case might be trying to reuse a - * previously initialized AVHWFramesContext, and calling this API function - * only to test whether the required frame parameters have changed. - * - Fields that use dynamically allocated values of any kind must not be set - * by the user unless setting them is explicitly allowed by the documentation. - * If the user sets AVHWFramesContext.free and AVHWFramesContext.user_opaque, - * the new free callback must call the potentially set previous free callback. - * This API call may set any dynamically allocated fields, including the free - * callback. - * - * The function will set at least the following fields on AVHWFramesContext - * (potentially more, depending on hwaccel API): - * - * - All fields set by av_hwframe_ctx_alloc(). - * - Set the format field to hw_pix_fmt. - * - Set the sw_format field to the most suited and most versatile format. (An - * implication is that this will prefer generic formats over opaque formats - * with arbitrary restrictions, if possible.) - * - Set the width/height fields to the coded frame size, rounded up to the - * API-specific minimum alignment. - * - Only _if_ the hwaccel requires a pre-allocated pool: set the initial_pool_size - * field to the number of maximum reference surfaces possible with the codec, - * plus 1 surface for the user to work (meaning the user can safely reference - * at most 1 decoded surface at a time), plus additional buffering introduced - * by frame threading. If the hwaccel does not require pre-allocation, the - * field is left to 0, and the decoder will allocate new surfaces on demand - * during decoding. - * - Possibly AVHWFramesContext.hwctx fields, depending on the underlying - * hardware API. - * - * Essentially, out_frames_ref returns the same as av_hwframe_ctx_alloc(), but - * with basic frame parameters set. - * - * The function is stateless, and does not change the AVCodecContext or the - * device_ref AVHWDeviceContext. - * - * @param avctx The context which is currently calling get_format, and which - * implicitly contains all state needed for filling the returned - * AVHWFramesContext properly. - * @param device_ref A reference to the AVHWDeviceContext describing the device - * which will be used by the hardware decoder. - * @param hw_pix_fmt The hwaccel format you are going to return from get_format. - * @param out_frames_ref On success, set to a reference to an _uninitialized_ - * AVHWFramesContext, created from the given device_ref. - * Fields will be set to values required for decoding. - * Not changed if an error is returned. - * @return zero on success, a negative value on error. The following error codes - * have special semantics: - * AVERROR(ENOENT): the decoder does not support this functionality. Setup - * is always manual, or it is a decoder which does not - * support setting AVCodecContext.hw_frames_ctx at all, - * or it is a software format. - * AVERROR(EINVAL): it is known that hardware decoding is not supported for - * this configuration, or the device_ref is not supported - * for the hwaccel referenced by hw_pix_fmt. - */ -int avcodec_get_hw_frames_parameters(AVCodecContext *avctx, - AVBufferRef *device_ref, - enum AVPixelFormat hw_pix_fmt, - AVBufferRef **out_frames_ref); - - - -/** - * @defgroup lavc_parsing Frame parsing - * @{ - */ - -enum AVPictureStructure { - AV_PICTURE_STRUCTURE_UNKNOWN, //< unknown - AV_PICTURE_STRUCTURE_TOP_FIELD, //< coded as top field - AV_PICTURE_STRUCTURE_BOTTOM_FIELD, //< coded as bottom field - AV_PICTURE_STRUCTURE_FRAME, //< coded as frame -}; - -typedef struct AVCodecParserContext { - void *priv_data; - struct AVCodecParser *parser; - int64_t frame_offset; /* offset of the current frame */ - int64_t cur_offset; /* current offset - (incremented by each av_parser_parse()) */ - int64_t next_frame_offset; /* offset of the next frame */ - /* video info */ - int pict_type; /* XXX: Put it back in AVCodecContext. */ - /** - * This field is used for proper frame duration computation in lavf. - * It signals, how much longer the frame duration of the current frame - * is compared to normal frame duration. - * - * frame_duration = (1 + repeat_pict) * time_base - * - * It is used by codecs like H.264 to display telecined material. - */ - int repeat_pict; /* XXX: Put it back in AVCodecContext. */ - int64_t pts; /* pts of the current frame */ - int64_t dts; /* dts of the current frame */ - - /* private data */ - int64_t last_pts; - int64_t last_dts; - int fetch_timestamp; - -#define AV_PARSER_PTS_NB 4 - int cur_frame_start_index; - int64_t cur_frame_offset[AV_PARSER_PTS_NB]; - int64_t cur_frame_pts[AV_PARSER_PTS_NB]; - int64_t cur_frame_dts[AV_PARSER_PTS_NB]; - - int flags; -#define PARSER_FLAG_COMPLETE_FRAMES 0x0001 -#define PARSER_FLAG_ONCE 0x0002 -/// Set if the parser has a valid file offset -#define PARSER_FLAG_FETCHED_OFFSET 0x0004 -#define PARSER_FLAG_USE_CODEC_TS 0x1000 - - int64_t offset; ///< byte offset from starting packet start - int64_t cur_frame_end[AV_PARSER_PTS_NB]; - - /** - * Set by parser to 1 for key frames and 0 for non-key frames. - * It is initialized to -1, so if the parser doesn't set this flag, - * old-style fallback using AV_PICTURE_TYPE_I picture type as key frames - * will be used. - */ - int key_frame; - -#if FF_API_CONVERGENCE_DURATION - /** - * @deprecated unused - */ - attribute_deprecated - int64_t convergence_duration; -#endif - - // Timestamp generation support: - /** - * Synchronization point for start of timestamp generation. - * - * Set to >0 for sync point, 0 for no sync point and <0 for undefined - * (default). - * - * For example, this corresponds to presence of H.264 buffering period - * SEI message. - */ - int dts_sync_point; - - /** - * Offset of the current timestamp against last timestamp sync point in - * units of AVCodecContext.time_base. - * - * Set to INT_MIN when dts_sync_point unused. Otherwise, it must - * contain a valid timestamp offset. - * - * Note that the timestamp of sync point has usually a nonzero - * dts_ref_dts_delta, which refers to the previous sync point. Offset of - * the next frame after timestamp sync point will be usually 1. - * - * For example, this corresponds to H.264 cpb_removal_delay. - */ - int dts_ref_dts_delta; - - /** - * Presentation delay of current frame in units of AVCodecContext.time_base. - * - * Set to INT_MIN when dts_sync_point unused. Otherwise, it must - * contain valid non-negative timestamp delta (presentation time of a frame - * must not lie in the past). - * - * This delay represents the difference between decoding and presentation - * time of the frame. - * - * For example, this corresponds to H.264 dpb_output_delay. - */ - int pts_dts_delta; - - /** - * Position of the packet in file. - * - * Analogous to cur_frame_pts/dts - */ - int64_t cur_frame_pos[AV_PARSER_PTS_NB]; - - /** - * Byte position of currently parsed frame in stream. - */ - int64_t pos; - - /** - * Previous frame byte position. - */ - int64_t last_pos; - - /** - * Duration of the current frame. - * For audio, this is in units of 1 / AVCodecContext.sample_rate. - * For all other types, this is in units of AVCodecContext.time_base. - */ - int duration; - - enum AVFieldOrder field_order; - - /** - * Indicate whether a picture is coded as a frame, top field or bottom field. - * - * For example, H.264 field_pic_flag equal to 0 corresponds to - * AV_PICTURE_STRUCTURE_FRAME. An H.264 picture with field_pic_flag - * equal to 1 and bottom_field_flag equal to 0 corresponds to - * AV_PICTURE_STRUCTURE_TOP_FIELD. - */ - enum AVPictureStructure picture_structure; - - /** - * Picture number incremented in presentation or output order. - * This field may be reinitialized at the first picture of a new sequence. - * - * For example, this corresponds to H.264 PicOrderCnt. - */ - int output_picture_number; - - /** - * Dimensions of the decoded video intended for presentation. - */ - int width; - int height; - - /** - * Dimensions of the coded video. - */ - int coded_width; - int coded_height; - - /** - * The format of the coded data, corresponds to enum AVPixelFormat for video - * and for enum AVSampleFormat for audio. - * - * Note that a decoder can have considerable freedom in how exactly it - * decodes the data, so the format reported here might be different from the - * one returned by a decoder. - */ - int format; -} AVCodecParserContext; - -typedef struct AVCodecParser { - int codec_ids[5]; /* several codec IDs are permitted */ - int priv_data_size; - int (*parser_init)(AVCodecParserContext *s); - /* This callback never returns an error, a negative value means that - * the frame start was in a previous packet. */ - int (*parser_parse)(AVCodecParserContext *s, - AVCodecContext *avctx, - const uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size); - void (*parser_close)(AVCodecParserContext *s); - int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); - struct AVCodecParser *next; -} AVCodecParser; - -/** - * Iterate over all registered codec parsers. - * - * @param opaque a pointer where libavcodec will store the iteration state. Must - * point to NULL to start the iteration. - * - * @return the next registered codec parser or NULL when the iteration is - * finished - */ -const AVCodecParser *av_parser_iterate(void **opaque); - -attribute_deprecated -AVCodecParser *av_parser_next(const AVCodecParser *c); - -attribute_deprecated -void av_register_codec_parser(AVCodecParser *parser); -AVCodecParserContext *av_parser_init(int codec_id); - -/** - * Parse a packet. - * - * @param s parser context. - * @param avctx codec context. - * @param poutbuf set to pointer to parsed buffer or NULL if not yet finished. - * @param poutbuf_size set to size of parsed buffer or zero if not yet finished. - * @param buf input buffer. - * @param buf_size buffer size in bytes without the padding. I.e. the full buffer - size is assumed to be buf_size + AV_INPUT_BUFFER_PADDING_SIZE. - To signal EOF, this should be 0 (so that the last frame - can be output). - * @param pts input presentation timestamp. - * @param dts input decoding timestamp. - * @param pos input byte position in stream. - * @return the number of bytes of the input bitstream used. - * - * Example: - * @code - * while(in_len){ - * len = av_parser_parse2(myparser, AVCodecContext, &data, &size, - * in_data, in_len, - * pts, dts, pos); - * in_data += len; - * in_len -= len; - * - * if(size) - * decode_frame(data, size); - * } - * @endcode - */ -int av_parser_parse2(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, - int64_t pts, int64_t dts, - int64_t pos); - -/** - * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed - * @deprecated use AVBitStreamFilter - */ -int av_parser_change(AVCodecParserContext *s, - AVCodecContext *avctx, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); -void av_parser_close(AVCodecParserContext *s); - -/** - * @} - * @} - */ - -/** - * @addtogroup lavc_encoding - * @{ - */ - -/** - * Find a registered encoder with a matching codec ID. - * - * @param id AVCodecID of the requested encoder - * @return An encoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_encoder(enum AVCodecID id); - -/** - * Find a registered encoder with the specified name. - * - * @param name name of the requested encoder - * @return An encoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_encoder_by_name(const char *name); - -/** - * Encode a frame of audio. - * - * Takes input samples from frame and writes the next output packet, if - * available, to avpkt. The output packet does not necessarily contain data for - * the most recent frame, as encoders can delay, split, and combine input frames - * internally as needed. - * - * @param avctx codec context - * @param avpkt output AVPacket. - * The user can supply an output buffer by setting - * avpkt->data and avpkt->size prior to calling the - * function, but if the size of the user-provided data is not - * large enough, encoding will fail. If avpkt->data and - * avpkt->size are set, avpkt->destruct must also be set. All - * other AVPacket fields will be reset by the encoder using - * av_init_packet(). If avpkt->data is NULL, the encoder will - * allocate it. The encoder will set avpkt->size to the size - * of the output packet. - * - * If this function fails or produces no output, avpkt will be - * freed using av_packet_unref(). - * @param[in] frame AVFrame containing the raw audio data to be encoded. - * May be NULL when flushing an encoder that has the - * AV_CODEC_CAP_DELAY capability set. - * If AV_CODEC_CAP_VARIABLE_FRAME_SIZE is set, then each frame - * can have any number of samples. - * If it is not set, frame->nb_samples must be equal to - * avctx->frame_size for all frames except the last. - * The final frame may be smaller than avctx->frame_size. - * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the - * output packet is non-empty, and to 0 if it is - * empty. If the function returns an error, the - * packet can be assumed to be invalid, and the - * value of got_packet_ptr is undefined and should - * not be used. - * @return 0 on success, negative error code on failure - * - * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead - */ -attribute_deprecated -int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, - const AVFrame *frame, int *got_packet_ptr); - -/** - * Encode a frame of video. - * - * Takes input raw video data from frame and writes the next output packet, if - * available, to avpkt. The output packet does not necessarily contain data for - * the most recent frame, as encoders can delay and reorder input frames - * internally as needed. - * - * @param avctx codec context - * @param avpkt output AVPacket. - * The user can supply an output buffer by setting - * avpkt->data and avpkt->size prior to calling the - * function, but if the size of the user-provided data is not - * large enough, encoding will fail. All other AVPacket fields - * will be reset by the encoder using av_init_packet(). If - * avpkt->data is NULL, the encoder will allocate it. - * The encoder will set avpkt->size to the size of the - * output packet. The returned data (if any) belongs to the - * caller, he is responsible for freeing it. - * - * If this function fails or produces no output, avpkt will be - * freed using av_packet_unref(). - * @param[in] frame AVFrame containing the raw video data to be encoded. - * May be NULL when flushing an encoder that has the - * AV_CODEC_CAP_DELAY capability set. - * @param[out] got_packet_ptr This field is set to 1 by libavcodec if the - * output packet is non-empty, and to 0 if it is - * empty. If the function returns an error, the - * packet can be assumed to be invalid, and the - * value of got_packet_ptr is undefined and should - * not be used. - * @return 0 on success, negative error code on failure - * - * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead - */ -attribute_deprecated -int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, - const AVFrame *frame, int *got_packet_ptr); - -int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, - const AVSubtitle *sub); - - -/** - * @} - */ - -#if FF_API_AVPICTURE -/** - * @addtogroup lavc_picture - * @{ - */ - -/** - * @deprecated unused - */ -attribute_deprecated -int avpicture_alloc(AVPicture *picture, enum AVPixelFormat pix_fmt, int width, int height); - -/** - * @deprecated unused - */ -attribute_deprecated -void avpicture_free(AVPicture *picture); - -/** - * @deprecated use av_image_fill_arrays() instead. - */ -attribute_deprecated -int avpicture_fill(AVPicture *picture, const uint8_t *ptr, - enum AVPixelFormat pix_fmt, int width, int height); - -/** - * @deprecated use av_image_copy_to_buffer() instead. - */ -attribute_deprecated -int avpicture_layout(const AVPicture *src, enum AVPixelFormat pix_fmt, - int width, int height, - unsigned char *dest, int dest_size); - -/** - * @deprecated use av_image_get_buffer_size() instead. - */ -attribute_deprecated -int avpicture_get_size(enum AVPixelFormat pix_fmt, int width, int height); - -/** - * @deprecated av_image_copy() instead. - */ -attribute_deprecated -void av_picture_copy(AVPicture *dst, const AVPicture *src, - enum AVPixelFormat pix_fmt, int width, int height); - -/** - * @deprecated unused - */ -attribute_deprecated -int av_picture_crop(AVPicture *dst, const AVPicture *src, - enum AVPixelFormat pix_fmt, int top_band, int left_band); - -/** - * @deprecated unused - */ -attribute_deprecated -int av_picture_pad(AVPicture *dst, const AVPicture *src, int height, int width, enum AVPixelFormat pix_fmt, - int padtop, int padbottom, int padleft, int padright, int *color); - -/** - * @} - */ -#endif - -/** - * @defgroup lavc_misc Utility functions - * @ingroup libavc - * - * Miscellaneous utility functions related to both encoding and decoding - * (or neither). - * @{ - */ - -/** - * @defgroup lavc_misc_pixfmt Pixel formats - * - * Functions for working with pixel formats. - * @{ - */ - -#if FF_API_GETCHROMA -/** - * @deprecated Use av_pix_fmt_get_chroma_sub_sample - */ - -attribute_deprecated -void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift); -#endif - -/** - * Return a value representing the fourCC code associated to the - * pixel format pix_fmt, or 0 if no associated fourCC code can be - * found. - */ -unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt); - -/** - * @deprecated see av_get_pix_fmt_loss() - */ -int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, - int has_alpha); - -/** - * Find the best pixel format to convert to given a certain source pixel - * format. When converting from one pixel format to another, information loss - * may occur. For example, when converting from RGB24 to GRAY, the color - * information will be lost. Similarly, other losses occur when converting from - * some formats to other formats. avcodec_find_best_pix_fmt_of_2() searches which of - * the given pixel formats should be used to suffer the least amount of loss. - * The pixel formats from which it chooses one, are determined by the - * pix_fmt_list parameter. - * - * - * @param[in] pix_fmt_list AV_PIX_FMT_NONE terminated array of pixel formats to choose from - * @param[in] src_pix_fmt source pixel format - * @param[in] has_alpha Whether the source pixel format alpha channel is used. - * @param[out] loss_ptr Combination of flags informing you what kind of losses will occur. - * @return The best pixel format to convert to or -1 if none was found. - */ -enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *pix_fmt_list, - enum AVPixelFormat src_pix_fmt, - int has_alpha, int *loss_ptr); - -/** - * @deprecated see av_find_best_pix_fmt_of_2() - */ -enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, - enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); - -attribute_deprecated -enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, - enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); - -enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt); - -/** - * @} - */ - -#if FF_API_TAG_STRING -/** - * Put a string representing the codec tag codec_tag in buf. - * - * @param buf buffer to place codec tag in - * @param buf_size size in bytes of buf - * @param codec_tag codec tag to assign - * @return the length of the string that would have been generated if - * enough space had been available, excluding the trailing null - * - * @deprecated see av_fourcc_make_string() and av_fourcc2str(). - */ -attribute_deprecated -size_t av_get_codec_tag_string(char *buf, size_t buf_size, unsigned int codec_tag); -#endif - -void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode); - -/** - * Return a name for the specified profile, if available. - * - * @param codec the codec that is searched for the given profile - * @param profile the profile value for which a name is requested - * @return A name for the profile if found, NULL otherwise. - */ -const char *av_get_profile_name(const AVCodec *codec, int profile); - -/** - * Return a name for the specified profile, if available. - * - * @param codec_id the ID of the codec to which the requested profile belongs - * @param profile the profile value for which a name is requested - * @return A name for the profile if found, NULL otherwise. - * - * @note unlike av_get_profile_name(), which searches a list of profiles - * supported by a specific decoder or encoder implementation, this - * function searches the list of profiles from the AVCodecDescriptor - */ -const char *avcodec_profile_name(enum AVCodecID codec_id, int profile); - -int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size); -int avcodec_default_execute2(AVCodecContext *c, int (*func)(AVCodecContext *c2, void *arg2, int, int),void *arg, int *ret, int count); -//FIXME func typedef - -/** - * Fill AVFrame audio data and linesize pointers. - * - * The buffer buf must be a preallocated buffer with a size big enough - * to contain the specified samples amount. The filled AVFrame data - * pointers will point to this buffer. - * - * AVFrame extended_data channel pointers are allocated if necessary for - * planar audio. - * - * @param frame the AVFrame - * frame->nb_samples must be set prior to calling the - * function. This function fills in frame->data, - * frame->extended_data, frame->linesize[0]. - * @param nb_channels channel count - * @param sample_fmt sample format - * @param buf buffer to use for frame data - * @param buf_size size of buffer - * @param align plane size sample alignment (0 = default) - * @return >=0 on success, negative error code on failure - * @todo return the size in bytes required to store the samples in - * case of success, at the next libavutil bump - */ -int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, - enum AVSampleFormat sample_fmt, const uint8_t *buf, - int buf_size, int align); - -/** - * Reset the internal decoder state / flush internal buffers. Should be called - * e.g. when seeking or when switching to a different stream. - * - * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 0), - * this invalidates the frames previously returned from the decoder. When - * refcounted frames are used, the decoder just releases any references it might - * keep internally, but the caller's reference remains valid. - */ -void avcodec_flush_buffers(AVCodecContext *avctx); - -/** - * Return codec bits per sample. - * - * @param[in] codec_id the codec - * @return Number of bits per sample or zero if unknown for the given codec. - */ -int av_get_bits_per_sample(enum AVCodecID codec_id); - -/** - * Return the PCM codec associated with a sample format. - * @param be endianness, 0 for little, 1 for big, - * -1 (or anything else) for native - * @return AV_CODEC_ID_PCM_* or AV_CODEC_ID_NONE - */ -enum AVCodecID av_get_pcm_codec(enum AVSampleFormat fmt, int be); - -/** - * Return codec bits per sample. - * Only return non-zero if the bits per sample is exactly correct, not an - * approximation. - * - * @param[in] codec_id the codec - * @return Number of bits per sample or zero if unknown for the given codec. - */ -int av_get_exact_bits_per_sample(enum AVCodecID codec_id); - -/** - * Return audio frame duration. - * - * @param avctx codec context - * @param frame_bytes size of the frame, or 0 if unknown - * @return frame duration, in samples, if known. 0 if not able to - * determine. - */ -int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes); - -/** - * This function is the same as av_get_audio_frame_duration(), except it works - * with AVCodecParameters instead of an AVCodecContext. - */ -int av_get_audio_frame_duration2(AVCodecParameters *par, int frame_bytes); - -#if FF_API_OLD_BSF -typedef struct AVBitStreamFilterContext { - void *priv_data; - const struct AVBitStreamFilter *filter; - AVCodecParserContext *parser; - struct AVBitStreamFilterContext *next; - /** - * Internal default arguments, used if NULL is passed to av_bitstream_filter_filter(). - * Not for access by library users. - */ - char *args; -} AVBitStreamFilterContext; -#endif - -typedef struct AVBSFInternal AVBSFInternal; - -/** - * The bitstream filter state. - * - * This struct must be allocated with av_bsf_alloc() and freed with - * av_bsf_free(). - * - * The fields in the struct will only be changed (by the caller or by the - * filter) as described in their documentation, and are to be considered - * immutable otherwise. - */ -typedef struct AVBSFContext { - /** - * A class for logging and AVOptions - */ - const AVClass *av_class; - - /** - * The bitstream filter this context is an instance of. - */ - const struct AVBitStreamFilter *filter; - - /** - * Opaque libavcodec internal data. Must not be touched by the caller in any - * way. - */ - AVBSFInternal *internal; - - /** - * Opaque filter-specific private data. If filter->priv_class is non-NULL, - * this is an AVOptions-enabled struct. - */ - void *priv_data; - - /** - * Parameters of the input stream. This field is allocated in - * av_bsf_alloc(), it needs to be filled by the caller before - * av_bsf_init(). - */ - AVCodecParameters *par_in; - - /** - * Parameters of the output stream. This field is allocated in - * av_bsf_alloc(), it is set by the filter in av_bsf_init(). - */ - AVCodecParameters *par_out; - - /** - * The timebase used for the timestamps of the input packets. Set by the - * caller before av_bsf_init(). - */ - AVRational time_base_in; - - /** - * The timebase used for the timestamps of the output packets. Set by the - * filter in av_bsf_init(). - */ - AVRational time_base_out; -} AVBSFContext; - -typedef struct AVBitStreamFilter { - const char *name; - - /** - * A list of codec ids supported by the filter, terminated by - * AV_CODEC_ID_NONE. - * May be NULL, in that case the bitstream filter works with any codec id. - */ - const enum AVCodecID *codec_ids; - - /** - * A class for the private data, used to declare bitstream filter private - * AVOptions. This field is NULL for bitstream filters that do not declare - * any options. - * - * If this field is non-NULL, the first member of the filter private data - * must be a pointer to AVClass, which will be set by libavcodec generic - * code to this class. - */ - const AVClass *priv_class; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - - int priv_data_size; - int (*init)(AVBSFContext *ctx); - int (*filter)(AVBSFContext *ctx, AVPacket *pkt); - void (*close)(AVBSFContext *ctx); - void (*flush)(AVBSFContext *ctx); -} AVBitStreamFilter; - -#if FF_API_OLD_BSF -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use the new bitstream filtering API (using AVBSFContext). - */ -attribute_deprecated -void av_register_bitstream_filter(AVBitStreamFilter *bsf); -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use av_bsf_get_by_name(), av_bsf_alloc(), and av_bsf_init() - * from the new bitstream filtering API (using AVBSFContext). - */ -attribute_deprecated -AVBitStreamFilterContext *av_bitstream_filter_init(const char *name); -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use av_bsf_send_packet() and av_bsf_receive_packet() from the - * new bitstream filtering API (using AVBSFContext). - */ -attribute_deprecated -int av_bitstream_filter_filter(AVBitStreamFilterContext *bsfc, - AVCodecContext *avctx, const char *args, - uint8_t **poutbuf, int *poutbuf_size, - const uint8_t *buf, int buf_size, int keyframe); -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use av_bsf_free() from the new bitstream filtering API (using - * AVBSFContext). - */ -attribute_deprecated -void av_bitstream_filter_close(AVBitStreamFilterContext *bsf); -/** - * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) - * is deprecated. Use av_bsf_iterate() from the new bitstream filtering API (using - * AVBSFContext). - */ -attribute_deprecated -const AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f); -#endif - -/** - * @return a bitstream filter with the specified name or NULL if no such - * bitstream filter exists. - */ -const AVBitStreamFilter *av_bsf_get_by_name(const char *name); - -/** - * Iterate over all registered bitstream filters. - * - * @param opaque a pointer where libavcodec will store the iteration state. Must - * point to NULL to start the iteration. - * - * @return the next registered bitstream filter or NULL when the iteration is - * finished - */ -const AVBitStreamFilter *av_bsf_iterate(void **opaque); -#if FF_API_NEXT -attribute_deprecated -const AVBitStreamFilter *av_bsf_next(void **opaque); -#endif - -/** - * Allocate a context for a given bitstream filter. The caller must fill in the - * context parameters as described in the documentation and then call - * av_bsf_init() before sending any data to the filter. - * - * @param filter the filter for which to allocate an instance. - * @param ctx a pointer into which the pointer to the newly-allocated context - * will be written. It must be freed with av_bsf_free() after the - * filtering is done. - * - * @return 0 on success, a negative AVERROR code on failure - */ -int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx); - -/** - * Prepare the filter for use, after all the parameters and options have been - * set. - */ -int av_bsf_init(AVBSFContext *ctx); - -/** - * Submit a packet for filtering. - * - * After sending each packet, the filter must be completely drained by calling - * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or - * AVERROR_EOF. - * - * @param pkt the packet to filter. The bitstream filter will take ownership of - * the packet and reset the contents of pkt. pkt is not touched if an error occurs. - * This parameter may be NULL, which signals the end of the stream (i.e. no more - * packets will be sent). That will cause the filter to output any packets it - * may have buffered internally. - * - * @return 0 on success, a negative AVERROR on error. - */ -int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); - -/** - * Retrieve a filtered packet. - * - * @param[out] pkt this struct will be filled with the contents of the filtered - * packet. It is owned by the caller and must be freed using - * av_packet_unref() when it is no longer needed. - * This parameter should be "clean" (i.e. freshly allocated - * with av_packet_alloc() or unreffed with av_packet_unref()) - * when this function is called. If this function returns - * successfully, the contents of pkt will be completely - * overwritten by the returned data. On failure, pkt is not - * touched. - * - * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the - * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there - * will be no further output from the filter. Another negative AVERROR value if - * an error occurs. - * - * @note one input packet may result in several output packets, so after sending - * a packet with av_bsf_send_packet(), this function needs to be called - * repeatedly until it stops returning 0. It is also possible for a filter to - * output fewer packets than were sent to it, so this function may return - * AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call. - */ -int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt); - -/** - * Reset the internal bitstream filter state / flush internal buffers. - */ -void av_bsf_flush(AVBSFContext *ctx); - -/** - * Free a bitstream filter context and everything associated with it; write NULL - * into the supplied pointer. - */ -void av_bsf_free(AVBSFContext **ctx); - -/** - * Get the AVClass for AVBSFContext. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). - */ -const AVClass *av_bsf_get_class(void); - -/** - * Structure for chain/list of bitstream filters. - * Empty list can be allocated by av_bsf_list_alloc(). - */ -typedef struct AVBSFList AVBSFList; - -/** - * Allocate empty list of bitstream filters. - * The list must be later freed by av_bsf_list_free() - * or finalized by av_bsf_list_finalize(). - * - * @return Pointer to @ref AVBSFList on success, NULL in case of failure - */ -AVBSFList *av_bsf_list_alloc(void); - -/** - * Free list of bitstream filters. - * - * @param lst Pointer to pointer returned by av_bsf_list_alloc() - */ -void av_bsf_list_free(AVBSFList **lst); - -/** - * Append bitstream filter to the list of bitstream filters. - * - * @param lst List to append to - * @param bsf Filter context to be appended - * - * @return >=0 on success, negative AVERROR in case of failure - */ -int av_bsf_list_append(AVBSFList *lst, AVBSFContext *bsf); - -/** - * Construct new bitstream filter context given it's name and options - * and append it to the list of bitstream filters. - * - * @param lst List to append to - * @param bsf_name Name of the bitstream filter - * @param options Options for the bitstream filter, can be set to NULL - * - * @return >=0 on success, negative AVERROR in case of failure - */ -int av_bsf_list_append2(AVBSFList *lst, const char * bsf_name, AVDictionary **options); -/** - * Finalize list of bitstream filters. - * - * This function will transform @ref AVBSFList to single @ref AVBSFContext, - * so the whole chain of bitstream filters can be treated as single filter - * freshly allocated by av_bsf_alloc(). - * If the call is successful, @ref AVBSFList structure is freed and lst - * will be set to NULL. In case of failure, caller is responsible for - * freeing the structure by av_bsf_list_free() - * - * @param lst Filter list structure to be transformed - * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure - * representing the chain of bitstream filters - * - * @return >=0 on success, negative AVERROR in case of failure - */ -int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf); - -/** - * Parse string describing list of bitstream filters and create single - * @ref AVBSFContext describing the whole chain of bitstream filters. - * Resulting @ref AVBSFContext can be treated as any other @ref AVBSFContext freshly - * allocated by av_bsf_alloc(). - * - * @param str String describing chain of bitstream filters in format - * `bsf1[=opt1=val1:opt2=val2][,bsf2]` - * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure - * representing the chain of bitstream filters - * - * @return >=0 on success, negative AVERROR in case of failure - */ -int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf); - -/** - * Get null/pass-through bitstream filter. - * - * @param[out] bsf Pointer to be set to new instance of pass-through bitstream filter - * - * @return - */ -int av_bsf_get_null_filter(AVBSFContext **bsf); - -/* memory */ - -/** - * Same behaviour av_fast_malloc but the buffer has additional - * AV_INPUT_BUFFER_PADDING_SIZE at the end which will always be 0. - * - * In addition the whole buffer will initially and after resizes - * be 0-initialized so that no uninitialized data will ever appear. - */ -void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size); - -/** - * Same behaviour av_fast_padded_malloc except that buffer will always - * be 0-initialized after call. - */ -void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size); - -/** - * Encode extradata length to a buffer. Used by xiph codecs. - * - * @param s buffer to write to; must be at least (v/255+1) bytes long - * @param v size of extradata in bytes - * @return number of bytes written to the buffer. - */ -unsigned int av_xiphlacing(unsigned char *s, unsigned int v); - -#if FF_API_USER_VISIBLE_AVHWACCEL -/** - * Register the hardware accelerator hwaccel. - * - * @deprecated This function doesn't do anything. - */ -attribute_deprecated -void av_register_hwaccel(AVHWAccel *hwaccel); - -/** - * If hwaccel is NULL, returns the first registered hardware accelerator, - * if hwaccel is non-NULL, returns the next registered hardware accelerator - * after hwaccel, or NULL if hwaccel is the last one. - * - * @deprecated AVHWaccel structures contain no user-serviceable parts, so - * this function should not be used. - */ -attribute_deprecated -AVHWAccel *av_hwaccel_next(const AVHWAccel *hwaccel); -#endif - -#if FF_API_LOCKMGR -/** - * Lock operation used by lockmgr - * - * @deprecated Deprecated together with av_lockmgr_register(). - */ -enum AVLockOp { - AV_LOCK_CREATE, ///< Create a mutex - AV_LOCK_OBTAIN, ///< Lock the mutex - AV_LOCK_RELEASE, ///< Unlock the mutex - AV_LOCK_DESTROY, ///< Free mutex resources -}; - -/** - * Register a user provided lock manager supporting the operations - * specified by AVLockOp. The "mutex" argument to the function points - * to a (void *) where the lockmgr should store/get a pointer to a user - * allocated mutex. It is NULL upon AV_LOCK_CREATE and equal to the - * value left by the last call for all other ops. If the lock manager is - * unable to perform the op then it should leave the mutex in the same - * state as when it was called and return a non-zero value. However, - * when called with AV_LOCK_DESTROY the mutex will always be assumed to - * have been successfully destroyed. If av_lockmgr_register succeeds - * it will return a non-negative value, if it fails it will return a - * negative value and destroy all mutex and unregister all callbacks. - * av_lockmgr_register is not thread-safe, it must be called from a - * single thread before any calls which make use of locking are used. - * - * @param cb User defined callback. av_lockmgr_register invokes calls - * to this callback and the previously registered callback. - * The callback will be used to create more than one mutex - * each of which must be backed by its own underlying locking - * mechanism (i.e. do not use a single static object to - * implement your lock manager). If cb is set to NULL the - * lockmgr will be unregistered. - * - * @deprecated This function does nothing, and always returns 0. Be sure to - * build with thread support to get basic thread safety. - */ -attribute_deprecated -int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); -#endif - -/** - * Get the type of the given codec. - */ -enum AVMediaType avcodec_get_type(enum AVCodecID codec_id); - -/** - * Get the name of a codec. - * @return a static string identifying the codec; never NULL - */ -const char *avcodec_get_name(enum AVCodecID id); - -/** - * @return a positive value if s is open (i.e. avcodec_open2() was called on it - * with no corresponding avcodec_close()), 0 otherwise. - */ -int avcodec_is_open(AVCodecContext *s); - -/** - * @return a non-zero number if codec is an encoder, zero otherwise - */ -int av_codec_is_encoder(const AVCodec *codec); - -/** - * @return a non-zero number if codec is a decoder, zero otherwise - */ -int av_codec_is_decoder(const AVCodec *codec); - -/** - * @return descriptor for given codec ID or NULL if no descriptor exists. - */ -const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id); - -/** - * Iterate over all codec descriptors known to libavcodec. - * - * @param prev previous descriptor. NULL to get the first descriptor. - * - * @return next descriptor or NULL after the last descriptor - */ -const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev); - -/** - * @return codec descriptor with the given name or NULL if no such descriptor - * exists. - */ -const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name); - -/** - * Allocate a CPB properties structure and initialize its fields to default - * values. - * - * @param size if non-NULL, the size of the allocated struct will be written - * here. This is useful for embedding it in side data. - * - * @return the newly allocated struct or NULL on failure - */ -AVCPBProperties *av_cpb_properties_alloc(size_t *size); - -/** - * @} - */ - -#endif /* AVCODEC_AVCODEC_H */ diff --git a/maclibs/include/libavcodec/avfft.h b/maclibs/include/libavcodec/avfft.h deleted file mode 100644 index 0c0f9b8d..00000000 --- a/maclibs/include/libavcodec/avfft.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_AVFFT_H -#define AVCODEC_AVFFT_H - -/** - * @file - * @ingroup lavc_fft - * FFT functions - */ - -/** - * @defgroup lavc_fft FFT functions - * @ingroup lavc_misc - * - * @{ - */ - -typedef float FFTSample; - -typedef struct FFTComplex { - FFTSample re, im; -} FFTComplex; - -typedef struct FFTContext FFTContext; - -/** - * Set up a complex FFT. - * @param nbits log2 of the length of the input array - * @param inverse if 0 perform the forward transform, if 1 perform the inverse - */ -FFTContext *av_fft_init(int nbits, int inverse); - -/** - * Do the permutation needed BEFORE calling ff_fft_calc(). - */ -void av_fft_permute(FFTContext *s, FFTComplex *z); - -/** - * Do a complex FFT with the parameters defined in av_fft_init(). The - * input data must be permuted before. No 1.0/sqrt(n) normalization is done. - */ -void av_fft_calc(FFTContext *s, FFTComplex *z); - -void av_fft_end(FFTContext *s); - -FFTContext *av_mdct_init(int nbits, int inverse, double scale); -void av_imdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); -void av_imdct_half(FFTContext *s, FFTSample *output, const FFTSample *input); -void av_mdct_calc(FFTContext *s, FFTSample *output, const FFTSample *input); -void av_mdct_end(FFTContext *s); - -/* Real Discrete Fourier Transform */ - -enum RDFTransformType { - DFT_R2C, - IDFT_C2R, - IDFT_R2C, - DFT_C2R, -}; - -typedef struct RDFTContext RDFTContext; - -/** - * Set up a real FFT. - * @param nbits log2 of the length of the input array - * @param trans the type of transform - */ -RDFTContext *av_rdft_init(int nbits, enum RDFTransformType trans); -void av_rdft_calc(RDFTContext *s, FFTSample *data); -void av_rdft_end(RDFTContext *s); - -/* Discrete Cosine Transform */ - -typedef struct DCTContext DCTContext; - -enum DCTTransformType { - DCT_II = 0, - DCT_III, - DCT_I, - DST_I, -}; - -/** - * Set up DCT. - * - * @param nbits size of the input array: - * (1 << nbits) for DCT-II, DCT-III and DST-I - * (1 << nbits) + 1 for DCT-I - * @param type the type of transform - * - * @note the first element of the input of DST-I is ignored - */ -DCTContext *av_dct_init(int nbits, enum DCTTransformType type); -void av_dct_calc(DCTContext *s, FFTSample *data); -void av_dct_end (DCTContext *s); - -/** - * @} - */ - -#endif /* AVCODEC_AVFFT_H */ diff --git a/maclibs/include/libavcodec/vaapi.h b/maclibs/include/libavcodec/vaapi.h deleted file mode 100644 index 2cf7da58..00000000 --- a/maclibs/include/libavcodec/vaapi.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Video Acceleration API (shared data between FFmpeg and the video player) - * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1 - * - * Copyright (C) 2008-2009 Splitted-Desktop Systems - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_VAAPI_H -#define AVCODEC_VAAPI_H - -/** - * @file - * @ingroup lavc_codec_hwaccel_vaapi - * Public libavcodec VA API header. - */ - -#include -#include "libavutil/attributes.h" -#include "version.h" - -#if FF_API_STRUCT_VAAPI_CONTEXT - -/** - * @defgroup lavc_codec_hwaccel_vaapi VA API Decoding - * @ingroup lavc_codec_hwaccel - * @{ - */ - -/** - * This structure is used to share data between the FFmpeg library and - * the client video application. - * This shall be zero-allocated and available as - * AVCodecContext.hwaccel_context. All user members can be set once - * during initialization or through each AVCodecContext.get_buffer() - * function call. In any case, they must be valid prior to calling - * decoding functions. - * - * Deprecated: use AVCodecContext.hw_frames_ctx instead. - */ -struct attribute_deprecated vaapi_context { - /** - * Window system dependent data - * - * - encoding: unused - * - decoding: Set by user - */ - void *display; - - /** - * Configuration ID - * - * - encoding: unused - * - decoding: Set by user - */ - uint32_t config_id; - - /** - * Context ID (video decode pipeline) - * - * - encoding: unused - * - decoding: Set by user - */ - uint32_t context_id; -}; - -/* @} */ - -#endif /* FF_API_STRUCT_VAAPI_CONTEXT */ - -#endif /* AVCODEC_VAAPI_H */ diff --git a/maclibs/include/libavcodec/vdpau.h b/maclibs/include/libavcodec/vdpau.h deleted file mode 100644 index 4d999433..00000000 --- a/maclibs/include/libavcodec/vdpau.h +++ /dev/null @@ -1,176 +0,0 @@ -/* - * The Video Decode and Presentation API for UNIX (VDPAU) is used for - * hardware-accelerated decoding of MPEG-1/2, H.264 and VC-1. - * - * Copyright (C) 2008 NVIDIA - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_VDPAU_H -#define AVCODEC_VDPAU_H - -/** - * @file - * @ingroup lavc_codec_hwaccel_vdpau - * Public libavcodec VDPAU header. - */ - - -/** - * @defgroup lavc_codec_hwaccel_vdpau VDPAU Decoder and Renderer - * @ingroup lavc_codec_hwaccel - * - * VDPAU hardware acceleration has two modules - * - VDPAU decoding - * - VDPAU presentation - * - * The VDPAU decoding module parses all headers using FFmpeg - * parsing mechanisms and uses VDPAU for the actual decoding. - * - * As per the current implementation, the actual decoding - * and rendering (API calls) are done as part of the VDPAU - * presentation (vo_vdpau.c) module. - * - * @{ - */ - -#include - -#include "libavutil/avconfig.h" -#include "libavutil/attributes.h" - -#include "avcodec.h" -#include "version.h" - -struct AVCodecContext; -struct AVFrame; - -typedef int (*AVVDPAU_Render2)(struct AVCodecContext *, struct AVFrame *, - const VdpPictureInfo *, uint32_t, - const VdpBitstreamBuffer *); - -/** - * This structure is used to share data between the libavcodec library and - * the client video application. - * The user shall allocate the structure via the av_alloc_vdpau_hwaccel - * function and make it available as - * AVCodecContext.hwaccel_context. Members can be set by the user once - * during initialization or through each AVCodecContext.get_buffer() - * function call. In any case, they must be valid prior to calling - * decoding functions. - * - * The size of this structure is not a part of the public ABI and must not - * be used outside of libavcodec. Use av_vdpau_alloc_context() to allocate an - * AVVDPAUContext. - */ -typedef struct AVVDPAUContext { - /** - * VDPAU decoder handle - * - * Set by user. - */ - VdpDecoder decoder; - - /** - * VDPAU decoder render callback - * - * Set by the user. - */ - VdpDecoderRender *render; - - AVVDPAU_Render2 render2; -} AVVDPAUContext; - -/** - * @brief allocation function for AVVDPAUContext - * - * Allows extending the struct without breaking API/ABI - */ -AVVDPAUContext *av_alloc_vdpaucontext(void); - -AVVDPAU_Render2 av_vdpau_hwaccel_get_render2(const AVVDPAUContext *); -void av_vdpau_hwaccel_set_render2(AVVDPAUContext *, AVVDPAU_Render2); - -/** - * Associate a VDPAU device with a codec context for hardware acceleration. - * This function is meant to be called from the get_format() codec callback, - * or earlier. It can also be called after avcodec_flush_buffers() to change - * the underlying VDPAU device mid-stream (e.g. to recover from non-transparent - * display preemption). - * - * @note get_format() must return AV_PIX_FMT_VDPAU if this function completes - * successfully. - * - * @param avctx decoding context whose get_format() callback is invoked - * @param device VDPAU device handle to use for hardware acceleration - * @param get_proc_address VDPAU device driver - * @param flags zero of more OR'd AV_HWACCEL_FLAG_* flags - * - * @return 0 on success, an AVERROR code on failure. - */ -int av_vdpau_bind_context(AVCodecContext *avctx, VdpDevice device, - VdpGetProcAddress *get_proc_address, unsigned flags); - -/** - * Gets the parameters to create an adequate VDPAU video surface for the codec - * context using VDPAU hardware decoding acceleration. - * - * @note Behavior is undefined if the context was not successfully bound to a - * VDPAU device using av_vdpau_bind_context(). - * - * @param avctx the codec context being used for decoding the stream - * @param type storage space for the VDPAU video surface chroma type - * (or NULL to ignore) - * @param width storage space for the VDPAU video surface pixel width - * (or NULL to ignore) - * @param height storage space for the VDPAU video surface pixel height - * (or NULL to ignore) - * - * @return 0 on success, a negative AVERROR code on failure. - */ -int av_vdpau_get_surface_parameters(AVCodecContext *avctx, VdpChromaType *type, - uint32_t *width, uint32_t *height); - -/** - * Allocate an AVVDPAUContext. - * - * @return Newly-allocated AVVDPAUContext or NULL on failure. - */ -AVVDPAUContext *av_vdpau_alloc_context(void); - -#if FF_API_VDPAU_PROFILE -/** - * Get a decoder profile that should be used for initializing a VDPAU decoder. - * Should be called from the AVCodecContext.get_format() callback. - * - * @deprecated Use av_vdpau_bind_context() instead. - * - * @param avctx the codec context being used for decoding the stream - * @param profile a pointer into which the result will be written on success. - * The contents of profile are undefined if this function returns - * an error. - * - * @return 0 on success (non-negative), a negative AVERROR on failure. - */ -attribute_deprecated -int av_vdpau_get_profile(AVCodecContext *avctx, VdpDecoderProfile *profile); -#endif - -/* @}*/ - -#endif /* AVCODEC_VDPAU_H */ diff --git a/maclibs/include/libavcodec/version.h b/maclibs/include/libavcodec/version.h deleted file mode 100644 index 3331d473..00000000 --- a/maclibs/include/libavcodec/version.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_VERSION_H -#define AVCODEC_VERSION_H - -/** - * @file - * @ingroup libavc - * Libavcodec version macros. - */ - -#include "libavutil/version.h" - -#define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 54 -#define LIBAVCODEC_VERSION_MICRO 100 - -#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ - LIBAVCODEC_VERSION_MINOR, \ - LIBAVCODEC_VERSION_MICRO) -#define LIBAVCODEC_VERSION AV_VERSION(LIBAVCODEC_VERSION_MAJOR, \ - LIBAVCODEC_VERSION_MINOR, \ - LIBAVCODEC_VERSION_MICRO) -#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT - -#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION) - -/** - * FF_API_* defines may be placed below to indicate public API that will be - * dropped at a future version bump. The defines themselves are not part of - * the public API and may change, break or disappear at any time. - * - * @note, when bumping the major version it is recommended to manually - * disable each FF_API_* in its own commit instead of disabling them all - * at once through the bump. This improves the git bisect-ability of the change. - */ - -#ifndef FF_API_LOWRES -#define FF_API_LOWRES (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_DEBUG_MV -#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 58) -#endif -#ifndef FF_API_AVCTX_TIMEBASE -#define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_CODED_FRAME -#define FF_API_CODED_FRAME (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_SIDEDATA_ONLY_PKT -#define FF_API_SIDEDATA_ONLY_PKT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_VDPAU_PROFILE -#define FF_API_VDPAU_PROFILE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_CONVERGENCE_DURATION -#define FF_API_CONVERGENCE_DURATION (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_AVPICTURE -#define FF_API_AVPICTURE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_AVPACKET_OLD_API -#define FF_API_AVPACKET_OLD_API (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_RTP_CALLBACK -#define FF_API_RTP_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_VBV_DELAY -#define FF_API_VBV_DELAY (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_CODER_TYPE -#define FF_API_CODER_TYPE (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_STAT_BITS -#define FF_API_STAT_BITS (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_PRIVATE_OPT -#define FF_API_PRIVATE_OPT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_ASS_TIMING -#define FF_API_ASS_TIMING (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OLD_BSF -#define FF_API_OLD_BSF (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_COPY_CONTEXT -#define FF_API_COPY_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_GET_CONTEXT_DEFAULTS -#define FF_API_GET_CONTEXT_DEFAULTS (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_NVENC_OLD_NAME -#define FF_API_NVENC_OLD_NAME (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_STRUCT_VAAPI_CONTEXT -#define FF_API_STRUCT_VAAPI_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_MERGE_SD_API -#define FF_API_MERGE_SD_API (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_TAG_STRING -#define FF_API_TAG_STRING (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_GETCHROMA -#define FF_API_GETCHROMA (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_CODEC_GET_SET -#define FF_API_CODEC_GET_SET (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_USER_VISIBLE_AVHWACCEL -#define FF_API_USER_VISIBLE_AVHWACCEL (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_LOCKMGR -#define FF_API_LOCKMGR (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_NEXT -#define FF_API_NEXT (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_UNSANITIZED_BITRATES -#define FF_API_UNSANITIZED_BITRATES (LIBAVCODEC_VERSION_MAJOR < 59) -#endif - - -#endif /* AVCODEC_VERSION_H */ diff --git a/maclibs/include/libavcodec/xvmc.h b/maclibs/include/libavcodec/xvmc.h deleted file mode 100644 index 465ee78d..00000000 --- a/maclibs/include/libavcodec/xvmc.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - * Copyright (C) 2003 Ivan Kalvachev - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVCODEC_XVMC_H -#define AVCODEC_XVMC_H - -/** - * @file - * @ingroup lavc_codec_hwaccel_xvmc - * Public libavcodec XvMC header. - */ - -#include - -#include "libavutil/attributes.h" -#include "version.h" -#include "avcodec.h" - -/** - * @defgroup lavc_codec_hwaccel_xvmc XvMC - * @ingroup lavc_codec_hwaccel - * - * @{ - */ - -#define AV_XVMC_ID 0x1DC711C0 /**< special value to ensure that regular pixel routines haven't corrupted the struct - the number is 1337 speak for the letters IDCT MCo (motion compensation) */ - -struct attribute_deprecated xvmc_pix_fmt { - /** The field contains the special constant value AV_XVMC_ID. - It is used as a test that the application correctly uses the API, - and that there is no corruption caused by pixel routines. - - application - set during initialization - - libavcodec - unchanged - */ - int xvmc_id; - - /** Pointer to the block array allocated by XvMCCreateBlocks(). - The array has to be freed by XvMCDestroyBlocks(). - Each group of 64 values represents one data block of differential - pixel information (in MoCo mode) or coefficients for IDCT. - - application - set the pointer during initialization - - libavcodec - fills coefficients/pixel data into the array - */ - short* data_blocks; - - /** Pointer to the macroblock description array allocated by - XvMCCreateMacroBlocks() and freed by XvMCDestroyMacroBlocks(). - - application - set the pointer during initialization - - libavcodec - fills description data into the array - */ - XvMCMacroBlock* mv_blocks; - - /** Number of macroblock descriptions that can be stored in the mv_blocks - array. - - application - set during initialization - - libavcodec - unchanged - */ - int allocated_mv_blocks; - - /** Number of blocks that can be stored at once in the data_blocks array. - - application - set during initialization - - libavcodec - unchanged - */ - int allocated_data_blocks; - - /** Indicate that the hardware would interpret data_blocks as IDCT - coefficients and perform IDCT on them. - - application - set during initialization - - libavcodec - unchanged - */ - int idct; - - /** In MoCo mode it indicates that intra macroblocks are assumed to be in - unsigned format; same as the XVMC_INTRA_UNSIGNED flag. - - application - set during initialization - - libavcodec - unchanged - */ - int unsigned_intra; - - /** Pointer to the surface allocated by XvMCCreateSurface(). - It has to be freed by XvMCDestroySurface() on application exit. - It identifies the frame and its state on the video hardware. - - application - set during initialization - - libavcodec - unchanged - */ - XvMCSurface* p_surface; - -/** Set by the decoder before calling ff_draw_horiz_band(), - needed by the XvMCRenderSurface function. */ -//@{ - /** Pointer to the surface used as past reference - - application - unchanged - - libavcodec - set - */ - XvMCSurface* p_past_surface; - - /** Pointer to the surface used as future reference - - application - unchanged - - libavcodec - set - */ - XvMCSurface* p_future_surface; - - /** top/bottom field or frame - - application - unchanged - - libavcodec - set - */ - unsigned int picture_structure; - - /** XVMC_SECOND_FIELD - 1st or 2nd field in the sequence - - application - unchanged - - libavcodec - set - */ - unsigned int flags; -//}@ - - /** Number of macroblock descriptions in the mv_blocks array - that have already been passed to the hardware. - - application - zeroes it on get_buffer(). - A successful ff_draw_horiz_band() may increment it - with filled_mb_block_num or zero both. - - libavcodec - unchanged - */ - int start_mv_blocks_num; - - /** Number of new macroblock descriptions in the mv_blocks array (after - start_mv_blocks_num) that are filled by libavcodec and have to be - passed to the hardware. - - application - zeroes it on get_buffer() or after successful - ff_draw_horiz_band(). - - libavcodec - increment with one of each stored MB - */ - int filled_mv_blocks_num; - - /** Number of the next free data block; one data block consists of - 64 short values in the data_blocks array. - All blocks before this one have already been claimed by placing their - position into the corresponding block description structure field, - that are part of the mv_blocks array. - - application - zeroes it on get_buffer(). - A successful ff_draw_horiz_band() may zero it together - with start_mb_blocks_num. - - libavcodec - each decoded macroblock increases it by the number - of coded blocks it contains. - */ - int next_free_data_block_num; -}; - -/** - * @} - */ - -#endif /* AVCODEC_XVMC_H */ diff --git a/maclibs/include/libavformat/avformat.h b/maclibs/include/libavformat/avformat.h deleted file mode 100644 index 6eb329f1..00000000 --- a/maclibs/include/libavformat/avformat.h +++ /dev/null @@ -1,3092 +0,0 @@ -/* - * copyright (c) 2001 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVFORMAT_AVFORMAT_H -#define AVFORMAT_AVFORMAT_H - -/** - * @file - * @ingroup libavf - * Main libavformat public API header - */ - -/** - * @defgroup libavf libavformat - * I/O and Muxing/Demuxing Library - * - * Libavformat (lavf) is a library for dealing with various media container - * formats. Its main two purposes are demuxing - i.e. splitting a media file - * into component streams, and the reverse process of muxing - writing supplied - * data in a specified container format. It also has an @ref lavf_io - * "I/O module" which supports a number of protocols for accessing the data (e.g. - * file, tcp, http and others). - * Unless you are absolutely sure you won't use libavformat's network - * capabilities, you should also call avformat_network_init(). - * - * A supported input format is described by an AVInputFormat struct, conversely - * an output format is described by AVOutputFormat. You can iterate over all - * input/output formats using the av_demuxer_iterate / av_muxer_iterate() functions. - * The protocols layer is not part of the public API, so you can only get the names - * of supported protocols with the avio_enum_protocols() function. - * - * Main lavf structure used for both muxing and demuxing is AVFormatContext, - * which exports all information about the file being read or written. As with - * most Libavformat structures, its size is not part of public ABI, so it cannot be - * allocated on stack or directly with av_malloc(). To create an - * AVFormatContext, use avformat_alloc_context() (some functions, like - * avformat_open_input() might do that for you). - * - * Most importantly an AVFormatContext contains: - * @li the @ref AVFormatContext.iformat "input" or @ref AVFormatContext.oformat - * "output" format. It is either autodetected or set by user for input; - * always set by user for output. - * @li an @ref AVFormatContext.streams "array" of AVStreams, which describe all - * elementary streams stored in the file. AVStreams are typically referred to - * using their index in this array. - * @li an @ref AVFormatContext.pb "I/O context". It is either opened by lavf or - * set by user for input, always set by user for output (unless you are dealing - * with an AVFMT_NOFILE format). - * - * @section lavf_options Passing options to (de)muxers - * It is possible to configure lavf muxers and demuxers using the @ref avoptions - * mechanism. Generic (format-independent) libavformat options are provided by - * AVFormatContext, they can be examined from a user program by calling - * av_opt_next() / av_opt_find() on an allocated AVFormatContext (or its AVClass - * from avformat_get_class()). Private (format-specific) options are provided by - * AVFormatContext.priv_data if and only if AVInputFormat.priv_class / - * AVOutputFormat.priv_class of the corresponding format struct is non-NULL. - * Further options may be provided by the @ref AVFormatContext.pb "I/O context", - * if its AVClass is non-NULL, and the protocols layer. See the discussion on - * nesting in @ref avoptions documentation to learn how to access those. - * - * @section urls - * URL strings in libavformat are made of a scheme/protocol, a ':', and a - * scheme specific string. URLs without a scheme and ':' used for local files - * are supported but deprecated. "file:" should be used for local files. - * - * It is important that the scheme string is not taken from untrusted - * sources without checks. - * - * Note that some schemes/protocols are quite powerful, allowing access to - * both local and remote files, parts of them, concatenations of them, local - * audio and video devices and so on. - * - * @{ - * - * @defgroup lavf_decoding Demuxing - * @{ - * Demuxers read a media file and split it into chunks of data (@em packets). A - * @ref AVPacket "packet" contains one or more encoded frames which belongs to a - * single elementary stream. In the lavf API this process is represented by the - * avformat_open_input() function for opening a file, av_read_frame() for - * reading a single packet and finally avformat_close_input(), which does the - * cleanup. - * - * @section lavf_decoding_open Opening a media file - * The minimum information required to open a file is its URL, which - * is passed to avformat_open_input(), as in the following code: - * @code - * const char *url = "file:in.mp3"; - * AVFormatContext *s = NULL; - * int ret = avformat_open_input(&s, url, NULL, NULL); - * if (ret < 0) - * abort(); - * @endcode - * The above code attempts to allocate an AVFormatContext, open the - * specified file (autodetecting the format) and read the header, exporting the - * information stored there into s. Some formats do not have a header or do not - * store enough information there, so it is recommended that you call the - * avformat_find_stream_info() function which tries to read and decode a few - * frames to find missing information. - * - * In some cases you might want to preallocate an AVFormatContext yourself with - * avformat_alloc_context() and do some tweaking on it before passing it to - * avformat_open_input(). One such case is when you want to use custom functions - * for reading input data instead of lavf internal I/O layer. - * To do that, create your own AVIOContext with avio_alloc_context(), passing - * your reading callbacks to it. Then set the @em pb field of your - * AVFormatContext to newly created AVIOContext. - * - * Since the format of the opened file is in general not known until after - * avformat_open_input() has returned, it is not possible to set demuxer private - * options on a preallocated context. Instead, the options should be passed to - * avformat_open_input() wrapped in an AVDictionary: - * @code - * AVDictionary *options = NULL; - * av_dict_set(&options, "video_size", "640x480", 0); - * av_dict_set(&options, "pixel_format", "rgb24", 0); - * - * if (avformat_open_input(&s, url, NULL, &options) < 0) - * abort(); - * av_dict_free(&options); - * @endcode - * This code passes the private options 'video_size' and 'pixel_format' to the - * demuxer. They would be necessary for e.g. the rawvideo demuxer, since it - * cannot know how to interpret raw video data otherwise. If the format turns - * out to be something different than raw video, those options will not be - * recognized by the demuxer and therefore will not be applied. Such unrecognized - * options are then returned in the options dictionary (recognized options are - * consumed). The calling program can handle such unrecognized options as it - * wishes, e.g. - * @code - * AVDictionaryEntry *e; - * if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) { - * fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key); - * abort(); - * } - * @endcode - * - * After you have finished reading the file, you must close it with - * avformat_close_input(). It will free everything associated with the file. - * - * @section lavf_decoding_read Reading from an opened file - * Reading data from an opened AVFormatContext is done by repeatedly calling - * av_read_frame() on it. Each call, if successful, will return an AVPacket - * containing encoded data for one AVStream, identified by - * AVPacket.stream_index. This packet may be passed straight into the libavcodec - * decoding functions avcodec_send_packet() or avcodec_decode_subtitle2() if the - * caller wishes to decode the data. - * - * AVPacket.pts, AVPacket.dts and AVPacket.duration timing information will be - * set if known. They may also be unset (i.e. AV_NOPTS_VALUE for - * pts/dts, 0 for duration) if the stream does not provide them. The timing - * information will be in AVStream.time_base units, i.e. it has to be - * multiplied by the timebase to convert them to seconds. - * - * If AVPacket.buf is set on the returned packet, then the packet is - * allocated dynamically and the user may keep it indefinitely. - * Otherwise, if AVPacket.buf is NULL, the packet data is backed by a - * static storage somewhere inside the demuxer and the packet is only valid - * until the next av_read_frame() call or closing the file. If the caller - * requires a longer lifetime, av_packet_make_refcounted() will ensure that - * the data is reference counted, copying the data if necessary. - * In both cases, the packet must be freed with av_packet_unref() when it is no - * longer needed. - * - * @section lavf_decoding_seek Seeking - * @} - * - * @defgroup lavf_encoding Muxing - * @{ - * Muxers take encoded data in the form of @ref AVPacket "AVPackets" and write - * it into files or other output bytestreams in the specified container format. - * - * The main API functions for muxing are avformat_write_header() for writing the - * file header, av_write_frame() / av_interleaved_write_frame() for writing the - * packets and av_write_trailer() for finalizing the file. - * - * At the beginning of the muxing process, the caller must first call - * avformat_alloc_context() to create a muxing context. The caller then sets up - * the muxer by filling the various fields in this context: - * - * - The @ref AVFormatContext.oformat "oformat" field must be set to select the - * muxer that will be used. - * - Unless the format is of the AVFMT_NOFILE type, the @ref AVFormatContext.pb - * "pb" field must be set to an opened IO context, either returned from - * avio_open2() or a custom one. - * - Unless the format is of the AVFMT_NOSTREAMS type, at least one stream must - * be created with the avformat_new_stream() function. The caller should fill - * the @ref AVStream.codecpar "stream codec parameters" information, such as the - * codec @ref AVCodecParameters.codec_type "type", @ref AVCodecParameters.codec_id - * "id" and other parameters (e.g. width / height, the pixel or sample format, - * etc.) as known. The @ref AVStream.time_base "stream timebase" should - * be set to the timebase that the caller desires to use for this stream (note - * that the timebase actually used by the muxer can be different, as will be - * described later). - * - It is advised to manually initialize only the relevant fields in - * AVCodecParameters, rather than using @ref avcodec_parameters_copy() during - * remuxing: there is no guarantee that the codec context values remain valid - * for both input and output format contexts. - * - The caller may fill in additional information, such as @ref - * AVFormatContext.metadata "global" or @ref AVStream.metadata "per-stream" - * metadata, @ref AVFormatContext.chapters "chapters", @ref - * AVFormatContext.programs "programs", etc. as described in the - * AVFormatContext documentation. Whether such information will actually be - * stored in the output depends on what the container format and the muxer - * support. - * - * When the muxing context is fully set up, the caller must call - * avformat_write_header() to initialize the muxer internals and write the file - * header. Whether anything actually is written to the IO context at this step - * depends on the muxer, but this function must always be called. Any muxer - * private options must be passed in the options parameter to this function. - * - * The data is then sent to the muxer by repeatedly calling av_write_frame() or - * av_interleaved_write_frame() (consult those functions' documentation for - * discussion on the difference between them; only one of them may be used with - * a single muxing context, they should not be mixed). Do note that the timing - * information on the packets sent to the muxer must be in the corresponding - * AVStream's timebase. That timebase is set by the muxer (in the - * avformat_write_header() step) and may be different from the timebase - * requested by the caller. - * - * Once all the data has been written, the caller must call av_write_trailer() - * to flush any buffered packets and finalize the output file, then close the IO - * context (if any) and finally free the muxing context with - * avformat_free_context(). - * @} - * - * @defgroup lavf_io I/O Read/Write - * @{ - * @section lavf_io_dirlist Directory listing - * The directory listing API makes it possible to list files on remote servers. - * - * Some of possible use cases: - * - an "open file" dialog to choose files from a remote location, - * - a recursive media finder providing a player with an ability to play all - * files from a given directory. - * - * @subsection lavf_io_dirlist_open Opening a directory - * At first, a directory needs to be opened by calling avio_open_dir() - * supplied with a URL and, optionally, ::AVDictionary containing - * protocol-specific parameters. The function returns zero or positive - * integer and allocates AVIODirContext on success. - * - * @code - * AVIODirContext *ctx = NULL; - * if (avio_open_dir(&ctx, "smb://example.com/some_dir", NULL) < 0) { - * fprintf(stderr, "Cannot open directory.\n"); - * abort(); - * } - * @endcode - * - * This code tries to open a sample directory using smb protocol without - * any additional parameters. - * - * @subsection lavf_io_dirlist_read Reading entries - * Each directory's entry (i.e. file, another directory, anything else - * within ::AVIODirEntryType) is represented by AVIODirEntry. - * Reading consecutive entries from an opened AVIODirContext is done by - * repeatedly calling avio_read_dir() on it. Each call returns zero or - * positive integer if successful. Reading can be stopped right after the - * NULL entry has been read -- it means there are no entries left to be - * read. The following code reads all entries from a directory associated - * with ctx and prints their names to standard output. - * @code - * AVIODirEntry *entry = NULL; - * for (;;) { - * if (avio_read_dir(ctx, &entry) < 0) { - * fprintf(stderr, "Cannot list directory.\n"); - * abort(); - * } - * if (!entry) - * break; - * printf("%s\n", entry->name); - * avio_free_directory_entry(&entry); - * } - * @endcode - * @} - * - * @defgroup lavf_codec Demuxers - * @{ - * @defgroup lavf_codec_native Native Demuxers - * @{ - * @} - * @defgroup lavf_codec_wrappers External library wrappers - * @{ - * @} - * @} - * @defgroup lavf_protos I/O Protocols - * @{ - * @} - * @defgroup lavf_internal Internal - * @{ - * @} - * @} - */ - -#include -#include /* FILE */ -#include "libavcodec/avcodec.h" -#include "libavutil/dict.h" -#include "libavutil/log.h" - -#include "avio.h" -#include "libavformat/version.h" - -struct AVFormatContext; - -struct AVDeviceInfoList; -struct AVDeviceCapabilitiesQuery; - -/** - * @defgroup metadata_api Public Metadata API - * @{ - * @ingroup libavf - * The metadata API allows libavformat to export metadata tags to a client - * application when demuxing. Conversely it allows a client application to - * set metadata when muxing. - * - * Metadata is exported or set as pairs of key/value strings in the 'metadata' - * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs - * using the @ref lavu_dict "AVDictionary" API. Like all strings in FFmpeg, - * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata - * exported by demuxers isn't checked to be valid UTF-8 in most cases. - * - * Important concepts to keep in mind: - * - Keys are unique; there can never be 2 tags with the same key. This is - * also meant semantically, i.e., a demuxer should not knowingly produce - * several keys that are literally different but semantically identical. - * E.g., key=Author5, key=Author6. In this example, all authors must be - * placed in the same tag. - * - Metadata is flat, not hierarchical; there are no subtags. If you - * want to store, e.g., the email address of the child of producer Alice - * and actor Bob, that could have key=alice_and_bobs_childs_email_address. - * - Several modifiers can be applied to the tag name. This is done by - * appending a dash character ('-') and the modifier name in the order - * they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng. - * - language -- a tag whose value is localized for a particular language - * is appended with the ISO 639-2/B 3-letter language code. - * For example: Author-ger=Michael, Author-eng=Mike - * The original/default language is in the unqualified "Author" tag. - * A demuxer should set a default if it sets any translated tag. - * - sorting -- a modified version of a tag that should be used for - * sorting will have '-sort' appended. E.g. artist="The Beatles", - * artist-sort="Beatles, The". - * - Some protocols and demuxers support metadata updates. After a successful - * call to av_read_packet(), AVFormatContext.event_flags or AVStream.event_flags - * will be updated to indicate if metadata changed. In order to detect metadata - * changes on a stream, you need to loop through all streams in the AVFormatContext - * and check their individual event_flags. - * - * - Demuxers attempt to export metadata in a generic format, however tags - * with no generic equivalents are left as they are stored in the container. - * Follows a list of generic tag names: - * - @verbatim - album -- name of the set this work belongs to - album_artist -- main creator of the set/album, if different from artist. - e.g. "Various Artists" for compilation albums. - artist -- main creator of the work - comment -- any additional description of the file. - composer -- who composed the work, if different from artist. - copyright -- name of copyright holder. - creation_time-- date when the file was created, preferably in ISO 8601. - date -- date when the work was created, preferably in ISO 8601. - disc -- number of a subset, e.g. disc in a multi-disc collection. - encoder -- name/settings of the software/hardware that produced the file. - encoded_by -- person/group who created the file. - filename -- original name of the file. - genre -- . - language -- main language in which the work is performed, preferably - in ISO 639-2 format. Multiple languages can be specified by - separating them with commas. - performer -- artist who performed the work, if different from artist. - E.g for "Also sprach Zarathustra", artist would be "Richard - Strauss" and performer "London Philharmonic Orchestra". - publisher -- name of the label/publisher. - service_name -- name of the service in broadcasting (channel name). - service_provider -- name of the service provider in broadcasting. - title -- name of the work. - track -- number of this work in the set, can be in form current/total. - variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of - @endverbatim - * - * Look in the examples section for an application example how to use the Metadata API. - * - * @} - */ - -/* packet functions */ - - -/** - * Allocate and read the payload of a packet and initialize its - * fields with default values. - * - * @param s associated IO context - * @param pkt packet - * @param size desired payload size - * @return >0 (read size) if OK, AVERROR_xxx otherwise - */ -int av_get_packet(AVIOContext *s, AVPacket *pkt, int size); - - -/** - * Read data and append it to the current content of the AVPacket. - * If pkt->size is 0 this is identical to av_get_packet. - * Note that this uses av_grow_packet and thus involves a realloc - * which is inefficient. Thus this function should only be used - * when there is no reasonable way to know (an upper bound of) - * the final size. - * - * @param s associated IO context - * @param pkt packet - * @param size amount of data to read - * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data - * will not be lost even if an error occurs. - */ -int av_append_packet(AVIOContext *s, AVPacket *pkt, int size); - -/*************************************************/ -/* input/output formats */ - -struct AVCodecTag; - -/** - * This structure contains the data a format has to probe a file. - */ -typedef struct AVProbeData { - const char *filename; - unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */ - int buf_size; /**< Size of buf except extra allocated bytes */ - const char *mime_type; /**< mime_type, when known. */ -} AVProbeData; - -#define AVPROBE_SCORE_RETRY (AVPROBE_SCORE_MAX/4) -#define AVPROBE_SCORE_STREAM_RETRY (AVPROBE_SCORE_MAX/4-1) - -#define AVPROBE_SCORE_EXTENSION 50 ///< score for file extension -#define AVPROBE_SCORE_MIME 75 ///< score for file mime type -#define AVPROBE_SCORE_MAX 100 ///< maximum score - -#define AVPROBE_PADDING_SIZE 32 ///< extra allocated bytes at the end of the probe buffer - -/// Demuxer will use avio_open, no opened file should be provided by the caller. -#define AVFMT_NOFILE 0x0001 -#define AVFMT_NEEDNUMBER 0x0002 /**< Needs '%d' in filename. */ -#define AVFMT_SHOW_IDS 0x0008 /**< Show format stream IDs numbers. */ -#define AVFMT_GLOBALHEADER 0x0040 /**< Format wants global header. */ -#define AVFMT_NOTIMESTAMPS 0x0080 /**< Format does not need / have any timestamps. */ -#define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */ -#define AVFMT_TS_DISCONT 0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */ -#define AVFMT_VARIABLE_FPS 0x0400 /**< Format allows variable fps. */ -#define AVFMT_NODIMENSIONS 0x0800 /**< Format does not need width/height */ -#define AVFMT_NOSTREAMS 0x1000 /**< Format does not require any streams */ -#define AVFMT_NOBINSEARCH 0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */ -#define AVFMT_NOGENSEARCH 0x4000 /**< Format does not allow to fall back on generic search */ -#define AVFMT_NO_BYTE_SEEK 0x8000 /**< Format does not allow seeking by bytes */ -#define AVFMT_ALLOW_FLUSH 0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */ -#define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly - increasing timestamps, but they must - still be monotonic */ -#define AVFMT_TS_NEGATIVE 0x40000 /**< Format allows muxing negative - timestamps. If not set the timestamp - will be shifted in av_write_frame and - av_interleaved_write_frame so they - start from 0. - The user or muxer can override this through - AVFormatContext.avoid_negative_ts - */ - -#define AVFMT_SEEK_TO_PTS 0x4000000 /**< Seeking is based on PTS */ - -/** - * @addtogroup lavf_encoding - * @{ - */ -typedef struct AVOutputFormat { - const char *name; - /** - * Descriptive name for the format, meant to be more human-readable - * than name. You should use the NULL_IF_CONFIG_SMALL() macro - * to define it. - */ - const char *long_name; - const char *mime_type; - const char *extensions; /**< comma-separated filename extensions */ - /* output support */ - enum AVCodecID audio_codec; /**< default audio codec */ - enum AVCodecID video_codec; /**< default video codec */ - enum AVCodecID subtitle_codec; /**< default subtitle codec */ - /** - * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, - * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS, - * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH, - * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE - */ - int flags; - - /** - * List of supported codec_id-codec_tag pairs, ordered by "better - * choice first". The arrays are all terminated by AV_CODEC_ID_NONE. - */ - const struct AVCodecTag * const *codec_tag; - - - const AVClass *priv_class; ///< AVClass for the private context - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavformat and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - /** - * The ff_const59 define is not part of the public API and will - * be removed without further warning. - */ -#if FF_API_AVIOFORMAT -#define ff_const59 -#else -#define ff_const59 const -#endif - ff_const59 struct AVOutputFormat *next; - /** - * size of private data so that it can be allocated in the wrapper - */ - int priv_data_size; - - int (*write_header)(struct AVFormatContext *); - /** - * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags, - * pkt can be NULL in order to flush data buffered in the muxer. - * When flushing, return 0 if there still is more data to flush, - * or 1 if everything was flushed and there is no more buffered - * data. - */ - int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); - int (*write_trailer)(struct AVFormatContext *); - /** - * Currently only used to set pixel format if not YUV420P. - */ - int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, - AVPacket *in, int flush); - /** - * Test if the given codec can be stored in this container. - * - * @return 1 if the codec is supported, 0 if it is not. - * A negative number if unknown. - * MKTAG('A', 'P', 'I', 'C') if the codec is only supported as AV_DISPOSITION_ATTACHED_PIC - */ - int (*query_codec)(enum AVCodecID id, int std_compliance); - - void (*get_output_timestamp)(struct AVFormatContext *s, int stream, - int64_t *dts, int64_t *wall); - /** - * Allows sending messages from application to device. - */ - int (*control_message)(struct AVFormatContext *s, int type, - void *data, size_t data_size); - - /** - * Write an uncoded AVFrame. - * - * See av_write_uncoded_frame() for details. - * - * The library will free *frame afterwards, but the muxer can prevent it - * by setting the pointer to NULL. - */ - int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index, - AVFrame **frame, unsigned flags); - /** - * Returns device list with it properties. - * @see avdevice_list_devices() for more details. - */ - int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list); - /** - * Initialize device capabilities submodule. - * @see avdevice_capabilities_create() for more details. - */ - int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); - /** - * Free device capabilities submodule. - * @see avdevice_capabilities_free() for more details. - */ - int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); - enum AVCodecID data_codec; /**< default data codec */ - /** - * Initialize format. May allocate data here, and set any AVFormatContext or - * AVStream parameters that need to be set before packets are sent. - * This method must not write output. - * - * Return 0 if streams were fully configured, 1 if not, negative AVERROR on failure - * - * Any allocations made here must be freed in deinit(). - */ - int (*init)(struct AVFormatContext *); - /** - * Deinitialize format. If present, this is called whenever the muxer is being - * destroyed, regardless of whether or not the header has been written. - * - * If a trailer is being written, this is called after write_trailer(). - * - * This is called if init() fails as well. - */ - void (*deinit)(struct AVFormatContext *); - /** - * Set up any necessary bitstream filtering and extract any extra data needed - * for the global header. - * Return 0 if more packets from this stream must be checked; 1 if not. - */ - int (*check_bitstream)(struct AVFormatContext *, const AVPacket *pkt); -} AVOutputFormat; -/** - * @} - */ - -/** - * @addtogroup lavf_decoding - * @{ - */ -typedef struct AVInputFormat { - /** - * A comma separated list of short names for the format. New names - * may be appended with a minor bump. - */ - const char *name; - - /** - * Descriptive name for the format, meant to be more human-readable - * than name. You should use the NULL_IF_CONFIG_SMALL() macro - * to define it. - */ - const char *long_name; - - /** - * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS, - * AVFMT_NOTIMESTAMPS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH, - * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS. - */ - int flags; - - /** - * If extensions are defined, then no probe is done. You should - * usually not use extension format guessing because it is not - * reliable enough - */ - const char *extensions; - - const struct AVCodecTag * const *codec_tag; - - const AVClass *priv_class; ///< AVClass for the private context - - /** - * Comma-separated list of mime types. - * It is used check for matching mime types while probing. - * @see av_probe_input_format2 - */ - const char *mime_type; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavformat and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - ff_const59 struct AVInputFormat *next; - - /** - * Raw demuxers store their codec ID here. - */ - int raw_codec_id; - - /** - * Size of private data so that it can be allocated in the wrapper. - */ - int priv_data_size; - - /** - * Tell if a given file has a chance of being parsed as this format. - * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes - * big so you do not have to check for that unless you need more. - */ - int (*read_probe)(const AVProbeData *); - - /** - * Read the format header and initialize the AVFormatContext - * structure. Return 0 if OK. 'avformat_new_stream' should be - * called to create new streams. - */ - int (*read_header)(struct AVFormatContext *); - - /** - * Read one packet and put it in 'pkt'. pts and flags are also - * set. 'avformat_new_stream' can be called only if the flag - * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a - * background thread). - * @return 0 on success, < 0 on error. - * When returning an error, pkt must not have been allocated - * or must be freed before returning - */ - int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); - - /** - * Close the stream. The AVFormatContext and AVStreams are not - * freed by this function - */ - int (*read_close)(struct AVFormatContext *); - - /** - * Seek to a given timestamp relative to the frames in - * stream component stream_index. - * @param stream_index Must not be -1. - * @param flags Selects which direction should be preferred if no exact - * match is available. - * @return >= 0 on success (but not necessarily the new offset) - */ - int (*read_seek)(struct AVFormatContext *, - int stream_index, int64_t timestamp, int flags); - - /** - * Get the next timestamp in stream[stream_index].time_base units. - * @return the timestamp or AV_NOPTS_VALUE if an error occurred - */ - int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index, - int64_t *pos, int64_t pos_limit); - - /** - * Start/resume playing - only meaningful if using a network-based format - * (RTSP). - */ - int (*read_play)(struct AVFormatContext *); - - /** - * Pause playing - only meaningful if using a network-based format - * (RTSP). - */ - int (*read_pause)(struct AVFormatContext *); - - /** - * Seek to timestamp ts. - * Seeking will be done so that the point from which all active streams - * can be presented successfully will be closest to ts and within min/max_ts. - * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. - */ - int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); - - /** - * Returns device list with it properties. - * @see avdevice_list_devices() for more details. - */ - int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list); - - /** - * Initialize device capabilities submodule. - * @see avdevice_capabilities_create() for more details. - */ - int (*create_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); - - /** - * Free device capabilities submodule. - * @see avdevice_capabilities_free() for more details. - */ - int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); -} AVInputFormat; -/** - * @} - */ - -enum AVStreamParseType { - AVSTREAM_PARSE_NONE, - AVSTREAM_PARSE_FULL, /**< full parsing and repack */ - AVSTREAM_PARSE_HEADERS, /**< Only parse headers, do not repack. */ - AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */ - AVSTREAM_PARSE_FULL_ONCE, /**< full parsing and repack of the first frame only, only implemented for H.264 currently */ - AVSTREAM_PARSE_FULL_RAW, /**< full parsing and repack with timestamp and position generation by parser for raw - this assumes that each packet in the file contains no demuxer level headers and - just codec level data, otherwise position generation would fail */ -}; - -typedef struct AVIndexEntry { - int64_t pos; - int64_t timestamp; /**< - * Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are available - * when seeking to this entry. That means preferable PTS on keyframe based formats. - * But demuxers can choose to store a different timestamp, if it is more convenient for the implementation or nothing better - * is known - */ -#define AVINDEX_KEYFRAME 0x0001 -#define AVINDEX_DISCARD_FRAME 0x0002 /** - * Flag is used to indicate which frame should be discarded after decoding. - */ - int flags:2; - int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment). - int min_distance; /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */ -} AVIndexEntry; - -#define AV_DISPOSITION_DEFAULT 0x0001 -#define AV_DISPOSITION_DUB 0x0002 -#define AV_DISPOSITION_ORIGINAL 0x0004 -#define AV_DISPOSITION_COMMENT 0x0008 -#define AV_DISPOSITION_LYRICS 0x0010 -#define AV_DISPOSITION_KARAOKE 0x0020 - -/** - * Track should be used during playback by default. - * Useful for subtitle track that should be displayed - * even when user did not explicitly ask for subtitles. - */ -#define AV_DISPOSITION_FORCED 0x0040 -#define AV_DISPOSITION_HEARING_IMPAIRED 0x0080 /**< stream for hearing impaired audiences */ -#define AV_DISPOSITION_VISUAL_IMPAIRED 0x0100 /**< stream for visual impaired audiences */ -#define AV_DISPOSITION_CLEAN_EFFECTS 0x0200 /**< stream without voice */ -/** - * The stream is stored in the file as an attached picture/"cover art" (e.g. - * APIC frame in ID3v2). The first (usually only) packet associated with it - * will be returned among the first few packets read from the file unless - * seeking takes place. It can also be accessed at any time in - * AVStream.attached_pic. - */ -#define AV_DISPOSITION_ATTACHED_PIC 0x0400 -/** - * The stream is sparse, and contains thumbnail images, often corresponding - * to chapter markers. Only ever used with AV_DISPOSITION_ATTACHED_PIC. - */ -#define AV_DISPOSITION_TIMED_THUMBNAILS 0x0800 - -typedef struct AVStreamInternal AVStreamInternal; - -/** - * To specify text track kind (different from subtitles default). - */ -#define AV_DISPOSITION_CAPTIONS 0x10000 -#define AV_DISPOSITION_DESCRIPTIONS 0x20000 -#define AV_DISPOSITION_METADATA 0x40000 -#define AV_DISPOSITION_DEPENDENT 0x80000 ///< dependent audio stream (mix_type=0 in mpegts) -#define AV_DISPOSITION_STILL_IMAGE 0x100000 ///< still images in video stream (still_picture_flag=1 in mpegts) - -/** - * Options for behavior on timestamp wrap detection. - */ -#define AV_PTS_WRAP_IGNORE 0 ///< ignore the wrap -#define AV_PTS_WRAP_ADD_OFFSET 1 ///< add the format specific offset on wrap detection -#define AV_PTS_WRAP_SUB_OFFSET -1 ///< subtract the format specific offset on wrap detection - -/** - * Stream structure. - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. - * sizeof(AVStream) must not be used outside libav*. - */ -typedef struct AVStream { - int index; /**< stream index in AVFormatContext */ - /** - * Format-specific stream ID. - * decoding: set by libavformat - * encoding: set by the user, replaced by libavformat if left unset - */ - int id; -#if FF_API_LAVF_AVCTX - /** - * @deprecated use the codecpar struct instead - */ - attribute_deprecated - AVCodecContext *codec; -#endif - void *priv_data; - - /** - * This is the fundamental unit of time (in seconds) in terms - * of which frame timestamps are represented. - * - * decoding: set by libavformat - * encoding: May be set by the caller before avformat_write_header() to - * provide a hint to the muxer about the desired timebase. In - * avformat_write_header(), the muxer will overwrite this field - * with the timebase that will actually be used for the timestamps - * written into the file (which may or may not be related to the - * user-provided one, depending on the format). - */ - AVRational time_base; - - /** - * Decoding: pts of the first frame of the stream in presentation order, in stream time base. - * Only set this if you are absolutely 100% sure that the value you set - * it to really is the pts of the first frame. - * This may be undefined (AV_NOPTS_VALUE). - * @note The ASF header does NOT contain a correct start_time the ASF - * demuxer must NOT set this. - */ - int64_t start_time; - - /** - * Decoding: duration of the stream, in stream time base. - * If a source file does not specify a duration, but does specify - * a bitrate, this value will be estimated from bitrate and file size. - * - * Encoding: May be set by the caller before avformat_write_header() to - * provide a hint to the muxer about the estimated duration. - */ - int64_t duration; - - int64_t nb_frames; ///< number of frames in this stream if known or 0 - - int disposition; /**< AV_DISPOSITION_* bit field */ - - enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed. - - /** - * sample aspect ratio (0 if unknown) - * - encoding: Set by user. - * - decoding: Set by libavformat. - */ - AVRational sample_aspect_ratio; - - AVDictionary *metadata; - - /** - * Average framerate - * - * - demuxing: May be set by libavformat when creating the stream or in - * avformat_find_stream_info(). - * - muxing: May be set by the caller before avformat_write_header(). - */ - AVRational avg_frame_rate; - - /** - * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet - * will contain the attached picture. - * - * decoding: set by libavformat, must not be modified by the caller. - * encoding: unused - */ - AVPacket attached_pic; - - /** - * An array of side data that applies to the whole stream (i.e. the - * container does not allow it to change between packets). - * - * There may be no overlap between the side data in this array and side data - * in the packets. I.e. a given side data is either exported by the muxer - * (demuxing) / set by the caller (muxing) in this array, then it never - * appears in the packets, or the side data is exported / sent through - * the packets (always in the first packet where the value becomes known or - * changes), then it does not appear in this array. - * - * - demuxing: Set by libavformat when the stream is created. - * - muxing: May be set by the caller before avformat_write_header(). - * - * Freed by libavformat in avformat_free_context(). - * - * @see av_format_inject_global_side_data() - */ - AVPacketSideData *side_data; - /** - * The number of elements in the AVStream.side_data array. - */ - int nb_side_data; - - /** - * Flags for the user to detect events happening on the stream. Flags must - * be cleared by the user once the event has been handled. - * A combination of AVSTREAM_EVENT_FLAG_*. - */ - int event_flags; -#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata. - - /** - * Real base framerate of the stream. - * This is the lowest framerate with which all timestamps can be - * represented accurately (it is the least common multiple of all - * framerates in the stream). Note, this value is just a guess! - * For example, if the time base is 1/90000 and all frames have either - * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1. - */ - AVRational r_frame_rate; - -#if FF_API_LAVF_FFSERVER - /** - * String containing pairs of key and values describing recommended encoder configuration. - * Pairs are separated by ','. - * Keys are separated from values by '='. - * - * @deprecated unused - */ - attribute_deprecated - char *recommended_encoder_configuration; -#endif - - /** - * Codec parameters associated with this stream. Allocated and freed by - * libavformat in avformat_new_stream() and avformat_free_context() - * respectively. - * - * - demuxing: filled by libavformat on stream creation or in - * avformat_find_stream_info() - * - muxing: filled by the caller before avformat_write_header() - */ - AVCodecParameters *codecpar; - - /***************************************************************** - * All fields below this line are not part of the public API. They - * may not be used outside of libavformat and can be changed and - * removed at will. - * Internal note: be aware that physically removing these fields - * will break ABI. Replace removed fields with dummy fields, and - * add new fields to AVStreamInternal. - ***************************************************************** - */ - -#define MAX_STD_TIMEBASES (30*12+30+3+6) - /** - * Stream information used internally by avformat_find_stream_info() - */ - struct { - int64_t last_dts; - int64_t duration_gcd; - int duration_count; - int64_t rfps_duration_sum; - double (*duration_error)[2][MAX_STD_TIMEBASES]; - int64_t codec_info_duration; - int64_t codec_info_duration_fields; - int frame_delay_evidence; - - /** - * 0 -> decoder has not been searched for yet. - * >0 -> decoder found - * <0 -> decoder with codec_id == -found_decoder has not been found - */ - int found_decoder; - - int64_t last_duration; - - /** - * Those are used for average framerate estimation. - */ - int64_t fps_first_dts; - int fps_first_dts_idx; - int64_t fps_last_dts; - int fps_last_dts_idx; - - } *info; - - int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ - - // Timestamp generation support: - /** - * Timestamp corresponding to the last dts sync point. - * - * Initialized when AVCodecParserContext.dts_sync_point >= 0 and - * a DTS is received from the underlying container. Otherwise set to - * AV_NOPTS_VALUE by default. - */ - int64_t first_dts; - int64_t cur_dts; - int64_t last_IP_pts; - int last_IP_duration; - - /** - * Number of packets to buffer for codec probing - */ - int probe_packets; - - /** - * Number of frames that have been demuxed during avformat_find_stream_info() - */ - int codec_info_nb_frames; - - /* av_read_frame() support */ - enum AVStreamParseType need_parsing; - struct AVCodecParserContext *parser; - - /** - * last packet in packet_buffer for this stream when muxing. - */ - struct AVPacketList *last_in_packet_buffer; - AVProbeData probe_data; -#define MAX_REORDER_DELAY 16 - int64_t pts_buffer[MAX_REORDER_DELAY+1]; - - AVIndexEntry *index_entries; /**< Only used if the format does not - support seeking natively. */ - int nb_index_entries; - unsigned int index_entries_allocated_size; - - /** - * Stream Identifier - * This is the MPEG-TS stream identifier +1 - * 0 means unknown - */ - int stream_identifier; - - /** - * Details of the MPEG-TS program which created this stream. - */ - int program_num; - int pmt_version; - int pmt_stream_idx; - - int64_t interleaver_chunk_size; - int64_t interleaver_chunk_duration; - - /** - * stream probing state - * -1 -> probing finished - * 0 -> no probing requested - * rest -> perform probing with request_probe being the minimum score to accept. - * NOT PART OF PUBLIC API - */ - int request_probe; - /** - * Indicates that everything up to the next keyframe - * should be discarded. - */ - int skip_to_keyframe; - - /** - * Number of samples to skip at the start of the frame decoded from the next packet. - */ - int skip_samples; - - /** - * If not 0, the number of samples that should be skipped from the start of - * the stream (the samples are removed from packets with pts==0, which also - * assumes negative timestamps do not happen). - * Intended for use with formats such as mp3 with ad-hoc gapless audio - * support. - */ - int64_t start_skip_samples; - - /** - * If not 0, the first audio sample that should be discarded from the stream. - * This is broken by design (needs global sample count), but can't be - * avoided for broken by design formats such as mp3 with ad-hoc gapless - * audio support. - */ - int64_t first_discard_sample; - - /** - * The sample after last sample that is intended to be discarded after - * first_discard_sample. Works on frame boundaries only. Used to prevent - * early EOF if the gapless info is broken (considered concatenated mp3s). - */ - int64_t last_discard_sample; - - /** - * Number of internally decoded frames, used internally in libavformat, do not access - * its lifetime differs from info which is why it is not in that structure. - */ - int nb_decoded_frames; - - /** - * Timestamp offset added to timestamps before muxing - * NOT PART OF PUBLIC API - */ - int64_t mux_ts_offset; - - /** - * Internal data to check for wrapping of the time stamp - */ - int64_t pts_wrap_reference; - - /** - * Options for behavior, when a wrap is detected. - * - * Defined by AV_PTS_WRAP_ values. - * - * If correction is enabled, there are two possibilities: - * If the first time stamp is near the wrap point, the wrap offset - * will be subtracted, which will create negative time stamps. - * Otherwise the offset will be added. - */ - int pts_wrap_behavior; - - /** - * Internal data to prevent doing update_initial_durations() twice - */ - int update_initial_durations_done; - - /** - * Internal data to generate dts from pts - */ - int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; - uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; - - /** - * Internal data to analyze DTS and detect faulty mpeg streams - */ - int64_t last_dts_for_order_check; - uint8_t dts_ordered; - uint8_t dts_misordered; - - /** - * Internal data to inject global side data - */ - int inject_global_side_data; - - /** - * display aspect ratio (0 if unknown) - * - encoding: unused - * - decoding: Set by libavformat to calculate sample_aspect_ratio internally - */ - AVRational display_aspect_ratio; - - /** - * An opaque field for libavformat internal usage. - * Must not be accessed in any way by callers. - */ - AVStreamInternal *internal; -} AVStream; - -#if FF_API_FORMAT_GET_SET -/** - * Accessors for some AVStream fields. These used to be provided for ABI - * compatibility, and do not need to be used anymore. - */ -attribute_deprecated -AVRational av_stream_get_r_frame_rate(const AVStream *s); -attribute_deprecated -void av_stream_set_r_frame_rate(AVStream *s, AVRational r); -#if FF_API_LAVF_FFSERVER -attribute_deprecated -char* av_stream_get_recommended_encoder_configuration(const AVStream *s); -attribute_deprecated -void av_stream_set_recommended_encoder_configuration(AVStream *s, char *configuration); -#endif -#endif - -struct AVCodecParserContext *av_stream_get_parser(const AVStream *s); - -/** - * Returns the pts of the last muxed packet + its duration - * - * the retuned value is undefined when used with a demuxer. - */ -int64_t av_stream_get_end_pts(const AVStream *st); - -#define AV_PROGRAM_RUNNING 1 - -/** - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. - * sizeof(AVProgram) must not be used outside libav*. - */ -typedef struct AVProgram { - int id; - int flags; - enum AVDiscard discard; ///< selects which program to discard and which to feed to the caller - unsigned int *stream_index; - unsigned int nb_stream_indexes; - AVDictionary *metadata; - - int program_num; - int pmt_pid; - int pcr_pid; - int pmt_version; - - /***************************************************************** - * All fields below this line are not part of the public API. They - * may not be used outside of libavformat and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - int64_t start_time; - int64_t end_time; - - int64_t pts_wrap_reference; ///< reference dts for wrap detection - int pts_wrap_behavior; ///< behavior on wrap detection -} AVProgram; - -#define AVFMTCTX_NOHEADER 0x0001 /**< signal that no header is present - (streams are added dynamically) */ -#define AVFMTCTX_UNSEEKABLE 0x0002 /**< signal that the stream is definitely - not seekable, and attempts to call the - seek function will fail. For some - network protocols (e.g. HLS), this can - change dynamically at runtime. */ - -typedef struct AVChapter { - int id; ///< unique ID to identify the chapter - AVRational time_base; ///< time base in which the start/end timestamps are specified - int64_t start, end; ///< chapter start/end time in time_base units - AVDictionary *metadata; -} AVChapter; - - -/** - * Callback used by devices to communicate with application. - */ -typedef int (*av_format_control_message)(struct AVFormatContext *s, int type, - void *data, size_t data_size); - -typedef int (*AVOpenCallback)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, - const AVIOInterruptCB *int_cb, AVDictionary **options); - -/** - * The duration of a video can be estimated through various ways, and this enum can be used - * to know how the duration was estimated. - */ -enum AVDurationEstimationMethod { - AVFMT_DURATION_FROM_PTS, ///< Duration accurately estimated from PTSes - AVFMT_DURATION_FROM_STREAM, ///< Duration estimated from a stream with a known duration - AVFMT_DURATION_FROM_BITRATE ///< Duration estimated from bitrate (less accurate) -}; - -typedef struct AVFormatInternal AVFormatInternal; - -/** - * Format I/O context. - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. - * sizeof(AVFormatContext) must not be used outside libav*, use - * avformat_alloc_context() to create an AVFormatContext. - * - * Fields can be accessed through AVOptions (av_opt*), - * the name string used matches the associated command line parameter name and - * can be found in libavformat/options_table.h. - * The AVOption/command line parameter names differ in some cases from the C - * structure field names for historic reasons or brevity. - */ -typedef struct AVFormatContext { - /** - * A class for logging and @ref avoptions. Set by avformat_alloc_context(). - * Exports (de)muxer private options if they exist. - */ - const AVClass *av_class; - - /** - * The input container format. - * - * Demuxing only, set by avformat_open_input(). - */ - ff_const59 struct AVInputFormat *iformat; - - /** - * The output container format. - * - * Muxing only, must be set by the caller before avformat_write_header(). - */ - ff_const59 struct AVOutputFormat *oformat; - - /** - * Format private data. This is an AVOptions-enabled struct - * if and only if iformat/oformat.priv_class is not NULL. - * - * - muxing: set by avformat_write_header() - * - demuxing: set by avformat_open_input() - */ - void *priv_data; - - /** - * I/O context. - * - * - demuxing: either set by the user before avformat_open_input() (then - * the user must close it manually) or set by avformat_open_input(). - * - muxing: set by the user before avformat_write_header(). The caller must - * take care of closing / freeing the IO context. - * - * Do NOT set this field if AVFMT_NOFILE flag is set in - * iformat/oformat.flags. In such a case, the (de)muxer will handle - * I/O in some other way and this field will be NULL. - */ - AVIOContext *pb; - - /* stream info */ - /** - * Flags signalling stream properties. A combination of AVFMTCTX_*. - * Set by libavformat. - */ - int ctx_flags; - - /** - * Number of elements in AVFormatContext.streams. - * - * Set by avformat_new_stream(), must not be modified by any other code. - */ - unsigned int nb_streams; - /** - * A list of all streams in the file. New streams are created with - * avformat_new_stream(). - * - * - demuxing: streams are created by libavformat in avformat_open_input(). - * If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also - * appear in av_read_frame(). - * - muxing: streams are created by the user before avformat_write_header(). - * - * Freed by libavformat in avformat_free_context(). - */ - AVStream **streams; - -#if FF_API_FORMAT_FILENAME - /** - * input or output filename - * - * - demuxing: set by avformat_open_input() - * - muxing: may be set by the caller before avformat_write_header() - * - * @deprecated Use url instead. - */ - attribute_deprecated - char filename[1024]; -#endif - - /** - * input or output URL. Unlike the old filename field, this field has no - * length restriction. - * - * - demuxing: set by avformat_open_input(), initialized to an empty - * string if url parameter was NULL in avformat_open_input(). - * - muxing: may be set by the caller before calling avformat_write_header() - * (or avformat_init_output() if that is called first) to a string - * which is freeable by av_free(). Set to an empty string if it - * was NULL in avformat_init_output(). - * - * Freed by libavformat in avformat_free_context(). - */ - char *url; - - /** - * Position of the first frame of the component, in - * AV_TIME_BASE fractional seconds. NEVER set this value directly: - * It is deduced from the AVStream values. - * - * Demuxing only, set by libavformat. - */ - int64_t start_time; - - /** - * Duration of the stream, in AV_TIME_BASE fractional - * seconds. Only set this value if you know none of the individual stream - * durations and also do not set any of them. This is deduced from the - * AVStream values if not set. - * - * Demuxing only, set by libavformat. - */ - int64_t duration; - - /** - * Total stream bitrate in bit/s, 0 if not - * available. Never set it directly if the file_size and the - * duration are known as FFmpeg can compute it automatically. - */ - int64_t bit_rate; - - unsigned int packet_size; - int max_delay; - - /** - * Flags modifying the (de)muxer behaviour. A combination of AVFMT_FLAG_*. - * Set by the user before avformat_open_input() / avformat_write_header(). - */ - int flags; -#define AVFMT_FLAG_GENPTS 0x0001 ///< Generate missing pts even if it requires parsing future frames. -#define AVFMT_FLAG_IGNIDX 0x0002 ///< Ignore index. -#define AVFMT_FLAG_NONBLOCK 0x0004 ///< Do not block when reading packets from input. -#define AVFMT_FLAG_IGNDTS 0x0008 ///< Ignore DTS on frames that contain both DTS & PTS -#define AVFMT_FLAG_NOFILLIN 0x0010 ///< Do not infer any values from other values, just return what is stored in the container -#define AVFMT_FLAG_NOPARSE 0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled -#define AVFMT_FLAG_NOBUFFER 0x0040 ///< Do not buffer frames when possible -#define AVFMT_FLAG_CUSTOM_IO 0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it. -#define AVFMT_FLAG_DISCARD_CORRUPT 0x0100 ///< Discard frames marked corrupted -#define AVFMT_FLAG_FLUSH_PACKETS 0x0200 ///< Flush the AVIOContext every packet. -/** - * When muxing, try to avoid writing any random/volatile data to the output. - * This includes any random IDs, real-time timestamps/dates, muxer version, etc. - * - * This flag is mainly intended for testing. - */ -#define AVFMT_FLAG_BITEXACT 0x0400 -#if FF_API_LAVF_MP4A_LATM -#define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Deprecated, does nothing. -#endif -#define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) -#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted) -#if FF_API_LAVF_KEEPSIDE_FLAG -#define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Deprecated, does nothing. -#endif -#define AVFMT_FLAG_FAST_SEEK 0x80000 ///< Enable fast, but inaccurate seeks for some formats -#define AVFMT_FLAG_SHORTEST 0x100000 ///< Stop muxing when the shortest stream stops. -#define AVFMT_FLAG_AUTO_BSF 0x200000 ///< Add bitstream filters as requested by the muxer - - /** - * Maximum size of the data read from input for determining - * the input container format. - * Demuxing only, set by the caller before avformat_open_input(). - */ - int64_t probesize; - - /** - * Maximum duration (in AV_TIME_BASE units) of the data read - * from input in avformat_find_stream_info(). - * Demuxing only, set by the caller before avformat_find_stream_info(). - * Can be set to 0 to let avformat choose using a heuristic. - */ - int64_t max_analyze_duration; - - const uint8_t *key; - int keylen; - - unsigned int nb_programs; - AVProgram **programs; - - /** - * Forced video codec_id. - * Demuxing: Set by user. - */ - enum AVCodecID video_codec_id; - - /** - * Forced audio codec_id. - * Demuxing: Set by user. - */ - enum AVCodecID audio_codec_id; - - /** - * Forced subtitle codec_id. - * Demuxing: Set by user. - */ - enum AVCodecID subtitle_codec_id; - - /** - * Maximum amount of memory in bytes to use for the index of each stream. - * If the index exceeds this size, entries will be discarded as - * needed to maintain a smaller size. This can lead to slower or less - * accurate seeking (depends on demuxer). - * Demuxers for which a full in-memory index is mandatory will ignore - * this. - * - muxing: unused - * - demuxing: set by user - */ - unsigned int max_index_size; - - /** - * Maximum amount of memory in bytes to use for buffering frames - * obtained from realtime capture devices. - */ - unsigned int max_picture_buffer; - - /** - * Number of chapters in AVChapter array. - * When muxing, chapters are normally written in the file header, - * so nb_chapters should normally be initialized before write_header - * is called. Some muxers (e.g. mov and mkv) can also write chapters - * in the trailer. To write chapters in the trailer, nb_chapters - * must be zero when write_header is called and non-zero when - * write_trailer is called. - * - muxing: set by user - * - demuxing: set by libavformat - */ - unsigned int nb_chapters; - AVChapter **chapters; - - /** - * Metadata that applies to the whole file. - * - * - demuxing: set by libavformat in avformat_open_input() - * - muxing: may be set by the caller before avformat_write_header() - * - * Freed by libavformat in avformat_free_context(). - */ - AVDictionary *metadata; - - /** - * Start time of the stream in real world time, in microseconds - * since the Unix epoch (00:00 1st January 1970). That is, pts=0 in the - * stream was captured at this real world time. - * - muxing: Set by the caller before avformat_write_header(). If set to - * either 0 or AV_NOPTS_VALUE, then the current wall-time will - * be used. - * - demuxing: Set by libavformat. AV_NOPTS_VALUE if unknown. Note that - * the value may become known after some number of frames - * have been received. - */ - int64_t start_time_realtime; - - /** - * The number of frames used for determining the framerate in - * avformat_find_stream_info(). - * Demuxing only, set by the caller before avformat_find_stream_info(). - */ - int fps_probe_size; - - /** - * Error recognition; higher values will detect more errors but may - * misdetect some more or less valid parts as errors. - * Demuxing only, set by the caller before avformat_open_input(). - */ - int error_recognition; - - /** - * Custom interrupt callbacks for the I/O layer. - * - * demuxing: set by the user before avformat_open_input(). - * muxing: set by the user before avformat_write_header() - * (mainly useful for AVFMT_NOFILE formats). The callback - * should also be passed to avio_open2() if it's used to - * open the file. - */ - AVIOInterruptCB interrupt_callback; - - /** - * Flags to enable debugging. - */ - int debug; -#define FF_FDEBUG_TS 0x0001 - - /** - * Maximum buffering duration for interleaving. - * - * To ensure all the streams are interleaved correctly, - * av_interleaved_write_frame() will wait until it has at least one packet - * for each stream before actually writing any packets to the output file. - * When some streams are "sparse" (i.e. there are large gaps between - * successive packets), this can result in excessive buffering. - * - * This field specifies the maximum difference between the timestamps of the - * first and the last packet in the muxing queue, above which libavformat - * will output a packet regardless of whether it has queued a packet for all - * the streams. - * - * Muxing only, set by the caller before avformat_write_header(). - */ - int64_t max_interleave_delta; - - /** - * Allow non-standard and experimental extension - * @see AVCodecContext.strict_std_compliance - */ - int strict_std_compliance; - - /** - * Flags for the user to detect events happening on the file. Flags must - * be cleared by the user once the event has been handled. - * A combination of AVFMT_EVENT_FLAG_*. - */ - int event_flags; -#define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata. - - /** - * Maximum number of packets to read while waiting for the first timestamp. - * Decoding only. - */ - int max_ts_probe; - - /** - * Avoid negative timestamps during muxing. - * Any value of the AVFMT_AVOID_NEG_TS_* constants. - * Note, this only works when using av_interleaved_write_frame. (interleave_packet_per_dts is in use) - * - muxing: Set by user - * - demuxing: unused - */ - int avoid_negative_ts; -#define AVFMT_AVOID_NEG_TS_AUTO -1 ///< Enabled when required by target format -#define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative -#define AVFMT_AVOID_NEG_TS_MAKE_ZERO 2 ///< Shift timestamps so that they start at 0 - - /** - * Transport stream id. - * This will be moved into demuxer private options. Thus no API/ABI compatibility - */ - int ts_id; - - /** - * Audio preload in microseconds. - * Note, not all formats support this and unpredictable things may happen if it is used when not supported. - * - encoding: Set by user - * - decoding: unused - */ - int audio_preload; - - /** - * Max chunk time in microseconds. - * Note, not all formats support this and unpredictable things may happen if it is used when not supported. - * - encoding: Set by user - * - decoding: unused - */ - int max_chunk_duration; - - /** - * Max chunk size in bytes - * Note, not all formats support this and unpredictable things may happen if it is used when not supported. - * - encoding: Set by user - * - decoding: unused - */ - int max_chunk_size; - - /** - * forces the use of wallclock timestamps as pts/dts of packets - * This has undefined results in the presence of B frames. - * - encoding: unused - * - decoding: Set by user - */ - int use_wallclock_as_timestamps; - - /** - * avio flags, used to force AVIO_FLAG_DIRECT. - * - encoding: unused - * - decoding: Set by user - */ - int avio_flags; - - /** - * The duration field can be estimated through various ways, and this field can be used - * to know how the duration was estimated. - * - encoding: unused - * - decoding: Read by user - */ - enum AVDurationEstimationMethod duration_estimation_method; - - /** - * Skip initial bytes when opening stream - * - encoding: unused - * - decoding: Set by user - */ - int64_t skip_initial_bytes; - - /** - * Correct single timestamp overflows - * - encoding: unused - * - decoding: Set by user - */ - unsigned int correct_ts_overflow; - - /** - * Force seeking to any (also non key) frames. - * - encoding: unused - * - decoding: Set by user - */ - int seek2any; - - /** - * Flush the I/O context after each packet. - * - encoding: Set by user - * - decoding: unused - */ - int flush_packets; - - /** - * format probing score. - * The maximal score is AVPROBE_SCORE_MAX, its set when the demuxer probes - * the format. - * - encoding: unused - * - decoding: set by avformat, read by user - */ - int probe_score; - - /** - * number of bytes to read maximally to identify format. - * - encoding: unused - * - decoding: set by user - */ - int format_probesize; - - /** - * ',' separated list of allowed decoders. - * If NULL then all are allowed - * - encoding: unused - * - decoding: set by user - */ - char *codec_whitelist; - - /** - * ',' separated list of allowed demuxers. - * If NULL then all are allowed - * - encoding: unused - * - decoding: set by user - */ - char *format_whitelist; - - /** - * An opaque field for libavformat internal usage. - * Must not be accessed in any way by callers. - */ - AVFormatInternal *internal; - - /** - * IO repositioned flag. - * This is set by avformat when the underlaying IO context read pointer - * is repositioned, for example when doing byte based seeking. - * Demuxers can use the flag to detect such changes. - */ - int io_repositioned; - - /** - * Forced video codec. - * This allows forcing a specific decoder, even when there are multiple with - * the same codec_id. - * Demuxing: Set by user - */ - AVCodec *video_codec; - - /** - * Forced audio codec. - * This allows forcing a specific decoder, even when there are multiple with - * the same codec_id. - * Demuxing: Set by user - */ - AVCodec *audio_codec; - - /** - * Forced subtitle codec. - * This allows forcing a specific decoder, even when there are multiple with - * the same codec_id. - * Demuxing: Set by user - */ - AVCodec *subtitle_codec; - - /** - * Forced data codec. - * This allows forcing a specific decoder, even when there are multiple with - * the same codec_id. - * Demuxing: Set by user - */ - AVCodec *data_codec; - - /** - * Number of bytes to be written as padding in a metadata header. - * Demuxing: Unused. - * Muxing: Set by user via av_format_set_metadata_header_padding. - */ - int metadata_header_padding; - - /** - * User data. - * This is a place for some private data of the user. - */ - void *opaque; - - /** - * Callback used by devices to communicate with application. - */ - av_format_control_message control_message_cb; - - /** - * Output timestamp offset, in microseconds. - * Muxing: set by user - */ - int64_t output_ts_offset; - - /** - * dump format separator. - * can be ", " or "\n " or anything else - * - muxing: Set by user. - * - demuxing: Set by user. - */ - uint8_t *dump_separator; - - /** - * Forced Data codec_id. - * Demuxing: Set by user. - */ - enum AVCodecID data_codec_id; - -#if FF_API_OLD_OPEN_CALLBACKS - /** - * Called to open further IO contexts when needed for demuxing. - * - * This can be set by the user application to perform security checks on - * the URLs before opening them. - * The function should behave like avio_open2(), AVFormatContext is provided - * as contextual information and to reach AVFormatContext.opaque. - * - * If NULL then some simple checks are used together with avio_open2(). - * - * Must not be accessed directly from outside avformat. - * @See av_format_set_open_cb() - * - * Demuxing: Set by user. - * - * @deprecated Use io_open and io_close. - */ - attribute_deprecated - int (*open_cb)(struct AVFormatContext *s, AVIOContext **p, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options); -#endif - - /** - * ',' separated list of allowed protocols. - * - encoding: unused - * - decoding: set by user - */ - char *protocol_whitelist; - - /** - * A callback for opening new IO streams. - * - * Whenever a muxer or a demuxer needs to open an IO stream (typically from - * avformat_open_input() for demuxers, but for certain formats can happen at - * other times as well), it will call this callback to obtain an IO context. - * - * @param s the format context - * @param pb on success, the newly opened IO context should be returned here - * @param url the url to open - * @param flags a combination of AVIO_FLAG_* - * @param options a dictionary of additional options, with the same - * semantics as in avio_open2() - * @return 0 on success, a negative AVERROR code on failure - * - * @note Certain muxers and demuxers do nesting, i.e. they open one or more - * additional internal format contexts. Thus the AVFormatContext pointer - * passed to this callback may be different from the one facing the caller. - * It will, however, have the same 'opaque' field. - */ - int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, - int flags, AVDictionary **options); - - /** - * A callback for closing the streams opened with AVFormatContext.io_open(). - */ - void (*io_close)(struct AVFormatContext *s, AVIOContext *pb); - - /** - * ',' separated list of disallowed protocols. - * - encoding: unused - * - decoding: set by user - */ - char *protocol_blacklist; - - /** - * The maximum number of streams. - * - encoding: unused - * - decoding: set by user - */ - int max_streams; - - /** - * Skip duration calcuation in estimate_timings_from_pts. - * - encoding: unused - * - decoding: set by user - */ - int skip_estimate_duration_from_pts; -} AVFormatContext; - -#if FF_API_FORMAT_GET_SET -/** - * Accessors for some AVFormatContext fields. These used to be provided for ABI - * compatibility, and do not need to be used anymore. - */ -attribute_deprecated -int av_format_get_probe_score(const AVFormatContext *s); -attribute_deprecated -AVCodec * av_format_get_video_codec(const AVFormatContext *s); -attribute_deprecated -void av_format_set_video_codec(AVFormatContext *s, AVCodec *c); -attribute_deprecated -AVCodec * av_format_get_audio_codec(const AVFormatContext *s); -attribute_deprecated -void av_format_set_audio_codec(AVFormatContext *s, AVCodec *c); -attribute_deprecated -AVCodec * av_format_get_subtitle_codec(const AVFormatContext *s); -attribute_deprecated -void av_format_set_subtitle_codec(AVFormatContext *s, AVCodec *c); -attribute_deprecated -AVCodec * av_format_get_data_codec(const AVFormatContext *s); -attribute_deprecated -void av_format_set_data_codec(AVFormatContext *s, AVCodec *c); -attribute_deprecated -int av_format_get_metadata_header_padding(const AVFormatContext *s); -attribute_deprecated -void av_format_set_metadata_header_padding(AVFormatContext *s, int c); -attribute_deprecated -void * av_format_get_opaque(const AVFormatContext *s); -attribute_deprecated -void av_format_set_opaque(AVFormatContext *s, void *opaque); -attribute_deprecated -av_format_control_message av_format_get_control_message_cb(const AVFormatContext *s); -attribute_deprecated -void av_format_set_control_message_cb(AVFormatContext *s, av_format_control_message callback); -#if FF_API_OLD_OPEN_CALLBACKS -attribute_deprecated AVOpenCallback av_format_get_open_cb(const AVFormatContext *s); -attribute_deprecated void av_format_set_open_cb(AVFormatContext *s, AVOpenCallback callback); -#endif -#endif - -/** - * This function will cause global side data to be injected in the next packet - * of each stream as well as after any subsequent seek. - */ -void av_format_inject_global_side_data(AVFormatContext *s); - -/** - * Returns the method used to set ctx->duration. - * - * @return AVFMT_DURATION_FROM_PTS, AVFMT_DURATION_FROM_STREAM, or AVFMT_DURATION_FROM_BITRATE. - */ -enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx); - -typedef struct AVPacketList { - AVPacket pkt; - struct AVPacketList *next; -} AVPacketList; - - -/** - * @defgroup lavf_core Core functions - * @ingroup libavf - * - * Functions for querying libavformat capabilities, allocating core structures, - * etc. - * @{ - */ - -/** - * Return the LIBAVFORMAT_VERSION_INT constant. - */ -unsigned avformat_version(void); - -/** - * Return the libavformat build-time configuration. - */ -const char *avformat_configuration(void); - -/** - * Return the libavformat license. - */ -const char *avformat_license(void); - -#if FF_API_NEXT -/** - * Initialize libavformat and register all the muxers, demuxers and - * protocols. If you do not call this function, then you can select - * exactly which formats you want to support. - * - * @see av_register_input_format() - * @see av_register_output_format() - */ -attribute_deprecated -void av_register_all(void); - -attribute_deprecated -void av_register_input_format(AVInputFormat *format); -attribute_deprecated -void av_register_output_format(AVOutputFormat *format); -#endif - -/** - * Do global initialization of network libraries. This is optional, - * and not recommended anymore. - * - * This functions only exists to work around thread-safety issues - * with older GnuTLS or OpenSSL libraries. If libavformat is linked - * to newer versions of those libraries, or if you do not use them, - * calling this function is unnecessary. Otherwise, you need to call - * this function before any other threads using them are started. - * - * This function will be deprecated once support for older GnuTLS and - * OpenSSL libraries is removed, and this function has no purpose - * anymore. - */ -int avformat_network_init(void); - -/** - * Undo the initialization done by avformat_network_init. Call it only - * once for each time you called avformat_network_init. - */ -int avformat_network_deinit(void); - -#if FF_API_NEXT -/** - * If f is NULL, returns the first registered input format, - * if f is non-NULL, returns the next registered input format after f - * or NULL if f is the last one. - */ -attribute_deprecated -AVInputFormat *av_iformat_next(const AVInputFormat *f); - -/** - * If f is NULL, returns the first registered output format, - * if f is non-NULL, returns the next registered output format after f - * or NULL if f is the last one. - */ -attribute_deprecated -AVOutputFormat *av_oformat_next(const AVOutputFormat *f); -#endif - -/** - * Iterate over all registered muxers. - * - * @param opaque a pointer where libavformat will store the iteration state. Must - * point to NULL to start the iteration. - * - * @return the next registered muxer or NULL when the iteration is - * finished - */ -const AVOutputFormat *av_muxer_iterate(void **opaque); - -/** - * Iterate over all registered demuxers. - * - * @param opaque a pointer where libavformat will store the iteration state. Must - * point to NULL to start the iteration. - * - * @return the next registered demuxer or NULL when the iteration is - * finished - */ -const AVInputFormat *av_demuxer_iterate(void **opaque); - -/** - * Allocate an AVFormatContext. - * avformat_free_context() can be used to free the context and everything - * allocated by the framework within it. - */ -AVFormatContext *avformat_alloc_context(void); - -/** - * Free an AVFormatContext and all its streams. - * @param s context to free - */ -void avformat_free_context(AVFormatContext *s); - -/** - * Get the AVClass for AVFormatContext. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). - */ -const AVClass *avformat_get_class(void); - -/** - * Add a new stream to a media file. - * - * When demuxing, it is called by the demuxer in read_header(). If the - * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also - * be called in read_packet(). - * - * When muxing, should be called by the user before avformat_write_header(). - * - * User is required to call avcodec_close() and avformat_free_context() to - * clean up the allocation by avformat_new_stream(). - * - * @param s media file handle - * @param c If non-NULL, the AVCodecContext corresponding to the new stream - * will be initialized to use this codec. This is needed for e.g. codec-specific - * defaults to be set, so codec should be provided if it is known. - * - * @return newly created stream or NULL on error. - */ -AVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c); - -/** - * Wrap an existing array as stream side data. - * - * @param st stream - * @param type side information type - * @param data the side data array. It must be allocated with the av_malloc() - * family of functions. The ownership of the data is transferred to - * st. - * @param size side information size - * @return zero on success, a negative AVERROR code on failure. On failure, - * the stream is unchanged and the data remains owned by the caller. - */ -int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, - uint8_t *data, size_t size); - -/** - * Allocate new information from stream. - * - * @param stream stream - * @param type desired side information type - * @param size side information size - * @return pointer to fresh allocated data or NULL otherwise - */ -uint8_t *av_stream_new_side_data(AVStream *stream, - enum AVPacketSideDataType type, int size); -/** - * Get side information from stream. - * - * @param stream stream - * @param type desired side information type - * @param size pointer for side information size to store (optional) - * @return pointer to data if present or NULL otherwise - */ -uint8_t *av_stream_get_side_data(const AVStream *stream, - enum AVPacketSideDataType type, int *size); - -AVProgram *av_new_program(AVFormatContext *s, int id); - -/** - * @} - */ - - -/** - * Allocate an AVFormatContext for an output format. - * avformat_free_context() can be used to free the context and - * everything allocated by the framework within it. - * - * @param *ctx is set to the created format context, or to NULL in - * case of failure - * @param oformat format to use for allocating the context, if NULL - * format_name and filename are used instead - * @param format_name the name of output format to use for allocating the - * context, if NULL filename is used instead - * @param filename the name of the filename to use for allocating the - * context, may be NULL - * @return >= 0 in case of success, a negative AVERROR code in case of - * failure - */ -int avformat_alloc_output_context2(AVFormatContext **ctx, ff_const59 AVOutputFormat *oformat, - const char *format_name, const char *filename); - -/** - * @addtogroup lavf_decoding - * @{ - */ - -/** - * Find AVInputFormat based on the short name of the input format. - */ -ff_const59 AVInputFormat *av_find_input_format(const char *short_name); - -/** - * Guess the file format. - * - * @param pd data to be probed - * @param is_opened Whether the file is already opened; determines whether - * demuxers with or without AVFMT_NOFILE are probed. - */ -ff_const59 AVInputFormat *av_probe_input_format(ff_const59 AVProbeData *pd, int is_opened); - -/** - * Guess the file format. - * - * @param pd data to be probed - * @param is_opened Whether the file is already opened; determines whether - * demuxers with or without AVFMT_NOFILE are probed. - * @param score_max A probe score larger that this is required to accept a - * detection, the variable is set to the actual detection - * score afterwards. - * If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended - * to retry with a larger probe buffer. - */ -ff_const59 AVInputFormat *av_probe_input_format2(ff_const59 AVProbeData *pd, int is_opened, int *score_max); - -/** - * Guess the file format. - * - * @param is_opened Whether the file is already opened; determines whether - * demuxers with or without AVFMT_NOFILE are probed. - * @param score_ret The score of the best detection. - */ -ff_const59 AVInputFormat *av_probe_input_format3(ff_const59 AVProbeData *pd, int is_opened, int *score_ret); - -/** - * Probe a bytestream to determine the input format. Each time a probe returns - * with a score that is too low, the probe buffer size is increased and another - * attempt is made. When the maximum probe size is reached, the input format - * with the highest score is returned. - * - * @param pb the bytestream to probe - * @param fmt the input format is put here - * @param url the url of the stream - * @param logctx the log context - * @param offset the offset within the bytestream to probe from - * @param max_probe_size the maximum probe buffer size (zero for default) - * @return the score in case of success, a negative value corresponding to an - * the maximal score is AVPROBE_SCORE_MAX - * AVERROR code otherwise - */ -int av_probe_input_buffer2(AVIOContext *pb, ff_const59 AVInputFormat **fmt, - const char *url, void *logctx, - unsigned int offset, unsigned int max_probe_size); - -/** - * Like av_probe_input_buffer2() but returns 0 on success - */ -int av_probe_input_buffer(AVIOContext *pb, ff_const59 AVInputFormat **fmt, - const char *url, void *logctx, - unsigned int offset, unsigned int max_probe_size); - -/** - * Open an input stream and read the header. The codecs are not opened. - * The stream must be closed with avformat_close_input(). - * - * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context). - * May be a pointer to NULL, in which case an AVFormatContext is allocated by this - * function and written into ps. - * Note that a user-supplied AVFormatContext will be freed on failure. - * @param url URL of the stream to open. - * @param fmt If non-NULL, this parameter forces a specific input format. - * Otherwise the format is autodetected. - * @param options A dictionary filled with AVFormatContext and demuxer-private options. - * On return this parameter will be destroyed and replaced with a dict containing - * options that were not found. May be NULL. - * - * @return 0 on success, a negative AVERROR on failure. - * - * @note If you want to use custom IO, preallocate the format context and set its pb field. - */ -int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options); - -attribute_deprecated -int av_demuxer_open(AVFormatContext *ic); - -/** - * Read packets of a media file to get stream information. This - * is useful for file formats with no headers such as MPEG. This - * function also computes the real framerate in case of MPEG-2 repeat - * frame mode. - * The logical file position is not changed by this function; - * examined packets may be buffered for later processing. - * - * @param ic media file handle - * @param options If non-NULL, an ic.nb_streams long array of pointers to - * dictionaries, where i-th member contains options for - * codec corresponding to i-th stream. - * On return each dictionary will be filled with options that were not found. - * @return >=0 if OK, AVERROR_xxx on error - * - * @note this function isn't guaranteed to open all the codecs, so - * options being non-empty at return is a perfectly normal behavior. - * - * @todo Let the user decide somehow what information is needed so that - * we do not waste time getting stuff the user does not need. - */ -int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options); - -/** - * Find the programs which belong to a given stream. - * - * @param ic media file handle - * @param last the last found program, the search will start after this - * program, or from the beginning if it is NULL - * @param s stream index - * @return the next program which belongs to s, NULL if no program is found or - * the last program is not among the programs of ic. - */ -AVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s); - -void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx); - -/** - * Find the "best" stream in the file. - * The best stream is determined according to various heuristics as the most - * likely to be what the user expects. - * If the decoder parameter is non-NULL, av_find_best_stream will find the - * default decoder for the stream's codec; streams for which no decoder can - * be found are ignored. - * - * @param ic media file handle - * @param type stream type: video, audio, subtitles, etc. - * @param wanted_stream_nb user-requested stream number, - * or -1 for automatic selection - * @param related_stream try to find a stream related (eg. in the same - * program) to this one, or -1 if none - * @param decoder_ret if non-NULL, returns the decoder for the - * selected stream - * @param flags flags; none are currently defined - * @return the non-negative stream number in case of success, - * AVERROR_STREAM_NOT_FOUND if no stream with the requested type - * could be found, - * AVERROR_DECODER_NOT_FOUND if streams were found but no decoder - * @note If av_find_best_stream returns successfully and decoder_ret is not - * NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec. - */ -int av_find_best_stream(AVFormatContext *ic, - enum AVMediaType type, - int wanted_stream_nb, - int related_stream, - AVCodec **decoder_ret, - int flags); - -/** - * Return the next frame of a stream. - * This function returns what is stored in the file, and does not validate - * that what is there are valid frames for the decoder. It will split what is - * stored in the file into frames and return one for each call. It will not - * omit invalid data between valid frames so as to give the decoder the maximum - * information possible for decoding. - * - * If pkt->buf is NULL, then the packet is valid until the next - * av_read_frame() or until avformat_close_input(). Otherwise the packet - * is valid indefinitely. In both cases the packet must be freed with - * av_packet_unref when it is no longer needed. For video, the packet contains - * exactly one frame. For audio, it contains an integer number of frames if each - * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames - * have a variable size (e.g. MPEG audio), then it contains one frame. - * - * pkt->pts, pkt->dts and pkt->duration are always set to correct - * values in AVStream.time_base units (and guessed if the format cannot - * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format - * has B-frames, so it is better to rely on pkt->dts if you do not - * decompress the payload. - * - * @return 0 if OK, < 0 on error or end of file - */ -int av_read_frame(AVFormatContext *s, AVPacket *pkt); - -/** - * Seek to the keyframe at timestamp. - * 'timestamp' in 'stream_index'. - * - * @param s media file handle - * @param stream_index If stream_index is (-1), a default - * stream is selected, and timestamp is automatically converted - * from AV_TIME_BASE units to the stream specific time_base. - * @param timestamp Timestamp in AVStream.time_base units - * or, if no stream is specified, in AV_TIME_BASE units. - * @param flags flags which select direction and seeking mode - * @return >= 0 on success - */ -int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, - int flags); - -/** - * Seek to timestamp ts. - * Seeking will be done so that the point from which all active streams - * can be presented successfully will be closest to ts and within min/max_ts. - * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL. - * - * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and - * are the file position (this may not be supported by all demuxers). - * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames - * in the stream with stream_index (this may not be supported by all demuxers). - * Otherwise all timestamps are in units of the stream selected by stream_index - * or if stream_index is -1, in AV_TIME_BASE units. - * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as - * keyframes (this may not be supported by all demuxers). - * If flags contain AVSEEK_FLAG_BACKWARD, it is ignored. - * - * @param s media file handle - * @param stream_index index of the stream which is used as time base reference - * @param min_ts smallest acceptable timestamp - * @param ts target timestamp - * @param max_ts largest acceptable timestamp - * @param flags flags - * @return >=0 on success, error code otherwise - * - * @note This is part of the new seek API which is still under construction. - * Thus do not use this yet. It may change at any time, do not expect - * ABI compatibility yet! - */ -int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); - -/** - * Discard all internally buffered data. This can be useful when dealing with - * discontinuities in the byte stream. Generally works only with formats that - * can resync. This includes headerless formats like MPEG-TS/TS but should also - * work with NUT, Ogg and in a limited way AVI for example. - * - * The set of streams, the detected duration, stream parameters and codecs do - * not change when calling this function. If you want a complete reset, it's - * better to open a new AVFormatContext. - * - * This does not flush the AVIOContext (s->pb). If necessary, call - * avio_flush(s->pb) before calling this function. - * - * @param s media file handle - * @return >=0 on success, error code otherwise - */ -int avformat_flush(AVFormatContext *s); - -/** - * Start playing a network-based stream (e.g. RTSP stream) at the - * current position. - */ -int av_read_play(AVFormatContext *s); - -/** - * Pause a network-based stream (e.g. RTSP stream). - * - * Use av_read_play() to resume it. - */ -int av_read_pause(AVFormatContext *s); - -/** - * Close an opened input AVFormatContext. Free it and all its contents - * and set *s to NULL. - */ -void avformat_close_input(AVFormatContext **s); -/** - * @} - */ - -#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward -#define AVSEEK_FLAG_BYTE 2 ///< seeking based on position in bytes -#define AVSEEK_FLAG_ANY 4 ///< seek to any frame, even non-keyframes -#define AVSEEK_FLAG_FRAME 8 ///< seeking based on frame number - -/** - * @addtogroup lavf_encoding - * @{ - */ - -#define AVSTREAM_INIT_IN_WRITE_HEADER 0 ///< stream parameters initialized in avformat_write_header -#define AVSTREAM_INIT_IN_INIT_OUTPUT 1 ///< stream parameters initialized in avformat_init_output - -/** - * Allocate the stream private data and write the stream header to - * an output media file. - * - * @param s Media file handle, must be allocated with avformat_alloc_context(). - * Its oformat field must be set to the desired output format; - * Its pb field must be set to an already opened AVIOContext. - * @param options An AVDictionary filled with AVFormatContext and muxer-private options. - * On return this parameter will be destroyed and replaced with a dict containing - * options that were not found. May be NULL. - * - * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec had not already been fully initialized in avformat_init, - * AVSTREAM_INIT_IN_INIT_OUTPUT on success if the codec had already been fully initialized in avformat_init, - * negative AVERROR on failure. - * - * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_init_output. - */ -av_warn_unused_result -int avformat_write_header(AVFormatContext *s, AVDictionary **options); - -/** - * Allocate the stream private data and initialize the codec, but do not write the header. - * May optionally be used before avformat_write_header to initialize stream parameters - * before actually writing the header. - * If using this function, do not pass the same options to avformat_write_header. - * - * @param s Media file handle, must be allocated with avformat_alloc_context(). - * Its oformat field must be set to the desired output format; - * Its pb field must be set to an already opened AVIOContext. - * @param options An AVDictionary filled with AVFormatContext and muxer-private options. - * On return this parameter will be destroyed and replaced with a dict containing - * options that were not found. May be NULL. - * - * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec requires avformat_write_header to fully initialize, - * AVSTREAM_INIT_IN_INIT_OUTPUT on success if the codec has been fully initialized, - * negative AVERROR on failure. - * - * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_write_header. - */ -av_warn_unused_result -int avformat_init_output(AVFormatContext *s, AVDictionary **options); - -/** - * Write a packet to an output media file. - * - * This function passes the packet directly to the muxer, without any buffering - * or reordering. The caller is responsible for correctly interleaving the - * packets if the format requires it. Callers that want libavformat to handle - * the interleaving should call av_interleaved_write_frame() instead of this - * function. - * - * @param s media file handle - * @param pkt The packet containing the data to be written. Note that unlike - * av_interleaved_write_frame(), this function does not take - * ownership of the packet passed to it (though some muxers may make - * an internal reference to the input packet). - *
- * This parameter can be NULL (at any time, not just at the end), in - * order to immediately flush data buffered within the muxer, for - * muxers that buffer up data internally before writing it to the - * output. - *
- * Packet's @ref AVPacket.stream_index "stream_index" field must be - * set to the index of the corresponding stream in @ref - * AVFormatContext.streams "s->streams". - *
- * The timestamps (@ref AVPacket.pts "pts", @ref AVPacket.dts "dts") - * must be set to correct values in the stream's timebase (unless the - * output format is flagged with the AVFMT_NOTIMESTAMPS flag, then - * they can be set to AV_NOPTS_VALUE). - * The dts for subsequent packets passed to this function must be strictly - * increasing when compared in their respective timebases (unless the - * output format is flagged with the AVFMT_TS_NONSTRICT, then they - * merely have to be nondecreasing). @ref AVPacket.duration - * "duration") should also be set if known. - * @return < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush - * - * @see av_interleaved_write_frame() - */ -int av_write_frame(AVFormatContext *s, AVPacket *pkt); - -/** - * Write a packet to an output media file ensuring correct interleaving. - * - * This function will buffer the packets internally as needed to make sure the - * packets in the output file are properly interleaved in the order of - * increasing dts. Callers doing their own interleaving should call - * av_write_frame() instead of this function. - * - * Using this function instead of av_write_frame() can give muxers advance - * knowledge of future packets, improving e.g. the behaviour of the mp4 - * muxer for VFR content in fragmenting mode. - * - * @param s media file handle - * @param pkt The packet containing the data to be written. - *
- * If the packet is reference-counted, this function will take - * ownership of this reference and unreference it later when it sees - * fit. - * The caller must not access the data through this reference after - * this function returns. If the packet is not reference-counted, - * libavformat will make a copy. - *
- * This parameter can be NULL (at any time, not just at the end), to - * flush the interleaving queues. - *
- * Packet's @ref AVPacket.stream_index "stream_index" field must be - * set to the index of the corresponding stream in @ref - * AVFormatContext.streams "s->streams". - *
- * The timestamps (@ref AVPacket.pts "pts", @ref AVPacket.dts "dts") - * must be set to correct values in the stream's timebase (unless the - * output format is flagged with the AVFMT_NOTIMESTAMPS flag, then - * they can be set to AV_NOPTS_VALUE). - * The dts for subsequent packets in one stream must be strictly - * increasing (unless the output format is flagged with the - * AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing). - * @ref AVPacket.duration "duration") should also be set if known. - * - * @return 0 on success, a negative AVERROR on error. Libavformat will always - * take care of freeing the packet, even if this function fails. - * - * @see av_write_frame(), AVFormatContext.max_interleave_delta - */ -int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); - -/** - * Write an uncoded frame to an output media file. - * - * The frame must be correctly interleaved according to the container - * specification; if not, then av_interleaved_write_frame() must be used. - * - * See av_interleaved_write_frame() for details. - */ -int av_write_uncoded_frame(AVFormatContext *s, int stream_index, - AVFrame *frame); - -/** - * Write an uncoded frame to an output media file. - * - * If the muxer supports it, this function makes it possible to write an AVFrame - * structure directly, without encoding it into a packet. - * It is mostly useful for devices and similar special muxers that use raw - * video or PCM data and will not serialize it into a byte stream. - * - * To test whether it is possible to use it with a given muxer and stream, - * use av_write_uncoded_frame_query(). - * - * The caller gives up ownership of the frame and must not access it - * afterwards. - * - * @return >=0 for success, a negative code on error - */ -int av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index, - AVFrame *frame); - -/** - * Test whether a muxer supports uncoded frame. - * - * @return >=0 if an uncoded frame can be written to that muxer and stream, - * <0 if not - */ -int av_write_uncoded_frame_query(AVFormatContext *s, int stream_index); - -/** - * Write the stream trailer to an output media file and free the - * file private data. - * - * May only be called after a successful call to avformat_write_header. - * - * @param s media file handle - * @return 0 if OK, AVERROR_xxx on error - */ -int av_write_trailer(AVFormatContext *s); - -/** - * Return the output format in the list of registered output formats - * which best matches the provided parameters, or return NULL if - * there is no match. - * - * @param short_name if non-NULL checks if short_name matches with the - * names of the registered formats - * @param filename if non-NULL checks if filename terminates with the - * extensions of the registered formats - * @param mime_type if non-NULL checks if mime_type matches with the - * MIME type of the registered formats - */ -ff_const59 AVOutputFormat *av_guess_format(const char *short_name, - const char *filename, - const char *mime_type); - -/** - * Guess the codec ID based upon muxer and filename. - */ -enum AVCodecID av_guess_codec(ff_const59 AVOutputFormat *fmt, const char *short_name, - const char *filename, const char *mime_type, - enum AVMediaType type); - -/** - * Get timing information for the data currently output. - * The exact meaning of "currently output" depends on the format. - * It is mostly relevant for devices that have an internal buffer and/or - * work in real time. - * @param s media file handle - * @param stream stream in the media file - * @param[out] dts DTS of the last packet output for the stream, in stream - * time_base units - * @param[out] wall absolute time when that packet whas output, - * in microsecond - * @return 0 if OK, AVERROR(ENOSYS) if the format does not support it - * Note: some formats or devices may not allow to measure dts and wall - * atomically. - */ -int av_get_output_timestamp(struct AVFormatContext *s, int stream, - int64_t *dts, int64_t *wall); - - -/** - * @} - */ - - -/** - * @defgroup lavf_misc Utility functions - * @ingroup libavf - * @{ - * - * Miscellaneous utility functions related to both muxing and demuxing - * (or neither). - */ - -/** - * Send a nice hexadecimal dump of a buffer to the specified file stream. - * - * @param f The file stream pointer where the dump should be sent to. - * @param buf buffer - * @param size buffer size - * - * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2 - */ -void av_hex_dump(FILE *f, const uint8_t *buf, int size); - -/** - * Send a nice hexadecimal dump of a buffer to the log. - * - * @param avcl A pointer to an arbitrary struct of which the first field is a - * pointer to an AVClass struct. - * @param level The importance level of the message, lower values signifying - * higher importance. - * @param buf buffer - * @param size buffer size - * - * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2 - */ -void av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size); - -/** - * Send a nice dump of a packet to the specified file stream. - * - * @param f The file stream pointer where the dump should be sent to. - * @param pkt packet to dump - * @param dump_payload True if the payload must be displayed, too. - * @param st AVStream that the packet belongs to - */ -void av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st); - - -/** - * Send a nice dump of a packet to the log. - * - * @param avcl A pointer to an arbitrary struct of which the first field is a - * pointer to an AVClass struct. - * @param level The importance level of the message, lower values signifying - * higher importance. - * @param pkt packet to dump - * @param dump_payload True if the payload must be displayed, too. - * @param st AVStream that the packet belongs to - */ -void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload, - const AVStream *st); - -/** - * Get the AVCodecID for the given codec tag tag. - * If no codec id is found returns AV_CODEC_ID_NONE. - * - * @param tags list of supported codec_id-codec_tag pairs, as stored - * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag - * @param tag codec tag to match to a codec ID - */ -enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag); - -/** - * Get the codec tag for the given codec id id. - * If no codec tag is found returns 0. - * - * @param tags list of supported codec_id-codec_tag pairs, as stored - * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag - * @param id codec ID to match to a codec tag - */ -unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id); - -/** - * Get the codec tag for the given codec id. - * - * @param tags list of supported codec_id - codec_tag pairs, as stored - * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag - * @param id codec id that should be searched for in the list - * @param tag A pointer to the found tag - * @return 0 if id was not found in tags, > 0 if it was found - */ -int av_codec_get_tag2(const struct AVCodecTag * const *tags, enum AVCodecID id, - unsigned int *tag); - -int av_find_default_stream_index(AVFormatContext *s); - -/** - * Get the index for a specific timestamp. - * - * @param st stream that the timestamp belongs to - * @param timestamp timestamp to retrieve the index for - * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond - * to the timestamp which is <= the requested one, if backward - * is 0, then it will be >= - * if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise - * @return < 0 if no such timestamp could be found - */ -int av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags); - -/** - * Add an index entry into a sorted list. Update the entry if the list - * already contains it. - * - * @param timestamp timestamp in the time base of the given stream - */ -int av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp, - int size, int distance, int flags); - - -/** - * Split a URL string into components. - * - * The pointers to buffers for storing individual components may be null, - * in order to ignore that component. Buffers for components not found are - * set to empty strings. If the port is not found, it is set to a negative - * value. - * - * @param proto the buffer for the protocol - * @param proto_size the size of the proto buffer - * @param authorization the buffer for the authorization - * @param authorization_size the size of the authorization buffer - * @param hostname the buffer for the host name - * @param hostname_size the size of the hostname buffer - * @param port_ptr a pointer to store the port number in - * @param path the buffer for the path - * @param path_size the size of the path buffer - * @param url the URL to split - */ -void av_url_split(char *proto, int proto_size, - char *authorization, int authorization_size, - char *hostname, int hostname_size, - int *port_ptr, - char *path, int path_size, - const char *url); - - -/** - * Print detailed information about the input or output format, such as - * duration, bitrate, streams, container, programs, metadata, side data, - * codec and time base. - * - * @param ic the context to analyze - * @param index index of the stream to dump information about - * @param url the URL to print, such as source or destination file - * @param is_output Select whether the specified context is an input(0) or output(1) - */ -void av_dump_format(AVFormatContext *ic, - int index, - const char *url, - int is_output); - - -#define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1 ///< Allow multiple %d - -/** - * Return in 'buf' the path with '%d' replaced by a number. - * - * Also handles the '%0nd' format where 'n' is the total number - * of digits and '%%'. - * - * @param buf destination buffer - * @param buf_size destination buffer size - * @param path numbered sequence string - * @param number frame number - * @param flags AV_FRAME_FILENAME_FLAGS_* - * @return 0 if OK, -1 on format error - */ -int av_get_frame_filename2(char *buf, int buf_size, - const char *path, int number, int flags); - -int av_get_frame_filename(char *buf, int buf_size, - const char *path, int number); - -/** - * Check whether filename actually is a numbered sequence generator. - * - * @param filename possible numbered sequence string - * @return 1 if a valid numbered sequence string, 0 otherwise - */ -int av_filename_number_test(const char *filename); - -/** - * Generate an SDP for an RTP session. - * - * Note, this overwrites the id values of AVStreams in the muxer contexts - * for getting unique dynamic payload types. - * - * @param ac array of AVFormatContexts describing the RTP streams. If the - * array is composed by only one context, such context can contain - * multiple AVStreams (one AVStream per RTP stream). Otherwise, - * all the contexts in the array (an AVCodecContext per RTP stream) - * must contain only one AVStream. - * @param n_files number of AVCodecContexts contained in ac - * @param buf buffer where the SDP will be stored (must be allocated by - * the caller) - * @param size the size of the buffer - * @return 0 if OK, AVERROR_xxx on error - */ -int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size); - -/** - * Return a positive value if the given filename has one of the given - * extensions, 0 otherwise. - * - * @param filename file name to check against the given extensions - * @param extensions a comma-separated list of filename extensions - */ -int av_match_ext(const char *filename, const char *extensions); - -/** - * Test if the given container can store a codec. - * - * @param ofmt container to check for compatibility - * @param codec_id codec to potentially store in container - * @param std_compliance standards compliance level, one of FF_COMPLIANCE_* - * - * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot. - * A negative number if this information is not available. - */ -int avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id, - int std_compliance); - -/** - * @defgroup riff_fourcc RIFF FourCCs - * @{ - * Get the tables mapping RIFF FourCCs to libavcodec AVCodecIDs. The tables are - * meant to be passed to av_codec_get_id()/av_codec_get_tag() as in the - * following code: - * @code - * uint32_t tag = MKTAG('H', '2', '6', '4'); - * const struct AVCodecTag *table[] = { avformat_get_riff_video_tags(), 0 }; - * enum AVCodecID id = av_codec_get_id(table, tag); - * @endcode - */ -/** - * @return the table mapping RIFF FourCCs for video to libavcodec AVCodecID. - */ -const struct AVCodecTag *avformat_get_riff_video_tags(void); -/** - * @return the table mapping RIFF FourCCs for audio to AVCodecID. - */ -const struct AVCodecTag *avformat_get_riff_audio_tags(void); -/** - * @return the table mapping MOV FourCCs for video to libavcodec AVCodecID. - */ -const struct AVCodecTag *avformat_get_mov_video_tags(void); -/** - * @return the table mapping MOV FourCCs for audio to AVCodecID. - */ -const struct AVCodecTag *avformat_get_mov_audio_tags(void); - -/** - * @} - */ - -/** - * Guess the sample aspect ratio of a frame, based on both the stream and the - * frame aspect ratio. - * - * Since the frame aspect ratio is set by the codec but the stream aspect ratio - * is set by the demuxer, these two may not be equal. This function tries to - * return the value that you should use if you would like to display the frame. - * - * Basic logic is to use the stream aspect ratio if it is set to something sane - * otherwise use the frame aspect ratio. This way a container setting, which is - * usually easy to modify can override the coded value in the frames. - * - * @param format the format context which the stream is part of - * @param stream the stream which the frame is part of - * @param frame the frame with the aspect ratio to be determined - * @return the guessed (valid) sample_aspect_ratio, 0/1 if no idea - */ -AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame); - -/** - * Guess the frame rate, based on both the container and codec information. - * - * @param ctx the format context which the stream is part of - * @param stream the stream which the frame is part of - * @param frame the frame for which the frame rate should be determined, may be NULL - * @return the guessed (valid) frame rate, 0/1 if no idea - */ -AVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame); - -/** - * Check if the stream st contained in s is matched by the stream specifier - * spec. - * - * See the "stream specifiers" chapter in the documentation for the syntax - * of spec. - * - * @return >0 if st is matched by spec; - * 0 if st is not matched by spec; - * AVERROR code if spec is invalid - * - * @note A stream specifier can match several streams in the format. - */ -int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st, - const char *spec); - -int avformat_queue_attached_pictures(AVFormatContext *s); - -#if FF_API_OLD_BSF -/** - * Apply a list of bitstream filters to a packet. - * - * @param codec AVCodecContext, usually from an AVStream - * @param pkt the packet to apply filters to. If, on success, the returned - * packet has size == 0 and side_data_elems == 0, it indicates that - * the packet should be dropped - * @param bsfc a NULL-terminated list of filters to apply - * @return >=0 on success; - * AVERROR code on failure - */ -attribute_deprecated -int av_apply_bitstream_filters(AVCodecContext *codec, AVPacket *pkt, - AVBitStreamFilterContext *bsfc); -#endif - -enum AVTimebaseSource { - AVFMT_TBCF_AUTO = -1, - AVFMT_TBCF_DECODER, - AVFMT_TBCF_DEMUXER, -#if FF_API_R_FRAME_RATE - AVFMT_TBCF_R_FRAMERATE, -#endif -}; - -/** - * Transfer internal timing information from one stream to another. - * - * This function is useful when doing stream copy. - * - * @param ofmt target output format for ost - * @param ost output stream which needs timings copy and adjustments - * @param ist reference input stream to copy timings from - * @param copy_tb define from where the stream codec timebase needs to be imported - */ -int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt, - AVStream *ost, const AVStream *ist, - enum AVTimebaseSource copy_tb); - -/** - * Get the internal codec timebase from a stream. - * - * @param st input stream to extract the timebase from - */ -AVRational av_stream_get_codec_timebase(const AVStream *st); - -/** - * @} - */ - -#endif /* AVFORMAT_AVFORMAT_H */ diff --git a/maclibs/include/libavformat/avio.h b/maclibs/include/libavformat/avio.h deleted file mode 100644 index dcb8dcdf..00000000 --- a/maclibs/include/libavformat/avio.h +++ /dev/null @@ -1,861 +0,0 @@ -/* - * copyright (c) 2001 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ -#ifndef AVFORMAT_AVIO_H -#define AVFORMAT_AVIO_H - -/** - * @file - * @ingroup lavf_io - * Buffered I/O operations - */ - -#include - -#include "libavutil/common.h" -#include "libavutil/dict.h" -#include "libavutil/log.h" - -#include "libavformat/version.h" - -/** - * Seeking works like for a local file. - */ -#define AVIO_SEEKABLE_NORMAL (1 << 0) - -/** - * Seeking by timestamp with avio_seek_time() is possible. - */ -#define AVIO_SEEKABLE_TIME (1 << 1) - -/** - * Callback for checking whether to abort blocking functions. - * AVERROR_EXIT is returned in this case by the interrupted - * function. During blocking operations, callback is called with - * opaque as parameter. If the callback returns 1, the - * blocking operation will be aborted. - * - * No members can be added to this struct without a major bump, if - * new elements have been added after this struct in AVFormatContext - * or AVIOContext. - */ -typedef struct AVIOInterruptCB { - int (*callback)(void*); - void *opaque; -} AVIOInterruptCB; - -/** - * Directory entry types. - */ -enum AVIODirEntryType { - AVIO_ENTRY_UNKNOWN, - AVIO_ENTRY_BLOCK_DEVICE, - AVIO_ENTRY_CHARACTER_DEVICE, - AVIO_ENTRY_DIRECTORY, - AVIO_ENTRY_NAMED_PIPE, - AVIO_ENTRY_SYMBOLIC_LINK, - AVIO_ENTRY_SOCKET, - AVIO_ENTRY_FILE, - AVIO_ENTRY_SERVER, - AVIO_ENTRY_SHARE, - AVIO_ENTRY_WORKGROUP, -}; - -/** - * Describes single entry of the directory. - * - * Only name and type fields are guaranteed be set. - * Rest of fields are protocol or/and platform dependent and might be unknown. - */ -typedef struct AVIODirEntry { - char *name; /**< Filename */ - int type; /**< Type of the entry */ - int utf8; /**< Set to 1 when name is encoded with UTF-8, 0 otherwise. - Name can be encoded with UTF-8 even though 0 is set. */ - int64_t size; /**< File size in bytes, -1 if unknown. */ - int64_t modification_timestamp; /**< Time of last modification in microseconds since unix - epoch, -1 if unknown. */ - int64_t access_timestamp; /**< Time of last access in microseconds since unix epoch, - -1 if unknown. */ - int64_t status_change_timestamp; /**< Time of last status change in microseconds since unix - epoch, -1 if unknown. */ - int64_t user_id; /**< User ID of owner, -1 if unknown. */ - int64_t group_id; /**< Group ID of owner, -1 if unknown. */ - int64_t filemode; /**< Unix file mode, -1 if unknown. */ -} AVIODirEntry; - -typedef struct AVIODirContext { - struct URLContext *url_context; -} AVIODirContext; - -/** - * Different data types that can be returned via the AVIO - * write_data_type callback. - */ -enum AVIODataMarkerType { - /** - * Header data; this needs to be present for the stream to be decodeable. - */ - AVIO_DATA_MARKER_HEADER, - /** - * A point in the output bytestream where a decoder can start decoding - * (i.e. a keyframe). A demuxer/decoder given the data flagged with - * AVIO_DATA_MARKER_HEADER, followed by any AVIO_DATA_MARKER_SYNC_POINT, - * should give decodeable results. - */ - AVIO_DATA_MARKER_SYNC_POINT, - /** - * A point in the output bytestream where a demuxer can start parsing - * (for non self synchronizing bytestream formats). That is, any - * non-keyframe packet start point. - */ - AVIO_DATA_MARKER_BOUNDARY_POINT, - /** - * This is any, unlabelled data. It can either be a muxer not marking - * any positions at all, it can be an actual boundary/sync point - * that the muxer chooses not to mark, or a later part of a packet/fragment - * that is cut into multiple write callbacks due to limited IO buffer size. - */ - AVIO_DATA_MARKER_UNKNOWN, - /** - * Trailer data, which doesn't contain actual content, but only for - * finalizing the output file. - */ - AVIO_DATA_MARKER_TRAILER, - /** - * A point in the output bytestream where the underlying AVIOContext might - * flush the buffer depending on latency or buffering requirements. Typically - * means the end of a packet. - */ - AVIO_DATA_MARKER_FLUSH_POINT, -}; - -/** - * Bytestream IO Context. - * New fields can be added to the end with minor version bumps. - * Removal, reordering and changes to existing fields require a major - * version bump. - * sizeof(AVIOContext) must not be used outside libav*. - * - * @note None of the function pointers in AVIOContext should be called - * directly, they should only be set by the client application - * when implementing custom I/O. Normally these are set to the - * function pointers specified in avio_alloc_context() - */ -typedef struct AVIOContext { - /** - * A class for private options. - * - * If this AVIOContext is created by avio_open2(), av_class is set and - * passes the options down to protocols. - * - * If this AVIOContext is manually allocated, then av_class may be set by - * the caller. - * - * warning -- this field can be NULL, be sure to not pass this AVIOContext - * to any av_opt_* functions in that case. - */ - const AVClass *av_class; - - /* - * The following shows the relationship between buffer, buf_ptr, - * buf_ptr_max, buf_end, buf_size, and pos, when reading and when writing - * (since AVIOContext is used for both): - * - ********************************************************************************** - * READING - ********************************************************************************** - * - * | buffer_size | - * |---------------------------------------| - * | | - * - * buffer buf_ptr buf_end - * +---------------+-----------------------+ - * |/ / / / / / / /|/ / / / / / /| | - * read buffer: |/ / consumed / | to be read /| | - * |/ / / / / / / /|/ / / / / / /| | - * +---------------+-----------------------+ - * - * pos - * +-------------------------------------------+-----------------+ - * input file: | | | - * +-------------------------------------------+-----------------+ - * - * - ********************************************************************************** - * WRITING - ********************************************************************************** - * - * | buffer_size | - * |--------------------------------------| - * | | - * - * buf_ptr_max - * buffer (buf_ptr) buf_end - * +-----------------------+--------------+ - * |/ / / / / / / / / / / /| | - * write buffer: | / / to be flushed / / | | - * |/ / / / / / / / / / / /| | - * +-----------------------+--------------+ - * buf_ptr can be in this - * due to a backward seek - * - * pos - * +-------------+----------------------------------------------+ - * output file: | | | - * +-------------+----------------------------------------------+ - * - */ - unsigned char *buffer; /**< Start of the buffer. */ - int buffer_size; /**< Maximum buffer size */ - unsigned char *buf_ptr; /**< Current position in the buffer */ - unsigned char *buf_end; /**< End of the data, may be less than - buffer+buffer_size if the read function returned - less data than requested, e.g. for streams where - no more data has been received yet. */ - void *opaque; /**< A private pointer, passed to the read/write/seek/... - functions. */ - int (*read_packet)(void *opaque, uint8_t *buf, int buf_size); - int (*write_packet)(void *opaque, uint8_t *buf, int buf_size); - int64_t (*seek)(void *opaque, int64_t offset, int whence); - int64_t pos; /**< position in the file of the current buffer */ - int eof_reached; /**< true if was unable to read due to error or eof */ - int write_flag; /**< true if open for writing */ - int max_packet_size; - unsigned long checksum; - unsigned char *checksum_ptr; - unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size); - int error; /**< contains the error code or 0 if no error happened */ - /** - * Pause or resume playback for network streaming protocols - e.g. MMS. - */ - int (*read_pause)(void *opaque, int pause); - /** - * Seek to a given timestamp in stream with the specified stream_index. - * Needed for some network streaming protocols which don't support seeking - * to byte position. - */ - int64_t (*read_seek)(void *opaque, int stream_index, - int64_t timestamp, int flags); - /** - * A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable. - */ - int seekable; - - /** - * max filesize, used to limit allocations - * This field is internal to libavformat and access from outside is not allowed. - */ - int64_t maxsize; - - /** - * avio_read and avio_write should if possible be satisfied directly - * instead of going through a buffer, and avio_seek will always - * call the underlying seek function directly. - */ - int direct; - - /** - * Bytes read statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int64_t bytes_read; - - /** - * seek statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int seek_count; - - /** - * writeout statistic - * This field is internal to libavformat and access from outside is not allowed. - */ - int writeout_count; - - /** - * Original buffer size - * used internally after probing and ensure seekback to reset the buffer size - * This field is internal to libavformat and access from outside is not allowed. - */ - int orig_buffer_size; - - /** - * Threshold to favor readahead over seek. - * This is current internal only, do not use from outside. - */ - int short_seek_threshold; - - /** - * ',' separated list of allowed protocols. - */ - const char *protocol_whitelist; - - /** - * ',' separated list of disallowed protocols. - */ - const char *protocol_blacklist; - - /** - * A callback that is used instead of write_packet. - */ - int (*write_data_type)(void *opaque, uint8_t *buf, int buf_size, - enum AVIODataMarkerType type, int64_t time); - /** - * If set, don't call write_data_type separately for AVIO_DATA_MARKER_BOUNDARY_POINT, - * but ignore them and treat them as AVIO_DATA_MARKER_UNKNOWN (to avoid needlessly - * small chunks of data returned from the callback). - */ - int ignore_boundary_point; - - /** - * Internal, not meant to be used from outside of AVIOContext. - */ - enum AVIODataMarkerType current_type; - int64_t last_time; - - /** - * A callback that is used instead of short_seek_threshold. - * This is current internal only, do not use from outside. - */ - int (*short_seek_get)(void *opaque); - - int64_t written; - - /** - * Maximum reached position before a backward seek in the write buffer, - * used keeping track of already written data for a later flush. - */ - unsigned char *buf_ptr_max; - - /** - * Try to buffer at least this amount of data before flushing it - */ - int min_packet_size; -} AVIOContext; - -/** - * Return the name of the protocol that will handle the passed URL. - * - * NULL is returned if no protocol could be found for the given URL. - * - * @return Name of the protocol or NULL. - */ -const char *avio_find_protocol_name(const char *url); - -/** - * Return AVIO_FLAG_* access flags corresponding to the access permissions - * of the resource in url, or a negative value corresponding to an - * AVERROR code in case of failure. The returned access flags are - * masked by the value in flags. - * - * @note This function is intrinsically unsafe, in the sense that the - * checked resource may change its existence or permission status from - * one call to another. Thus you should not trust the returned value, - * unless you are sure that no other processes are accessing the - * checked resource. - */ -int avio_check(const char *url, int flags); - -/** - * Move or rename a resource. - * - * @note url_src and url_dst should share the same protocol and authority. - * - * @param url_src url to resource to be moved - * @param url_dst new url to resource if the operation succeeded - * @return >=0 on success or negative on error. - */ -int avpriv_io_move(const char *url_src, const char *url_dst); - -/** - * Delete a resource. - * - * @param url resource to be deleted. - * @return >=0 on success or negative on error. - */ -int avpriv_io_delete(const char *url); - -/** - * Open directory for reading. - * - * @param s directory read context. Pointer to a NULL pointer must be passed. - * @param url directory to be listed. - * @param options A dictionary filled with protocol-private options. On return - * this parameter will be destroyed and replaced with a dictionary - * containing options that were not found. May be NULL. - * @return >=0 on success or negative on error. - */ -int avio_open_dir(AVIODirContext **s, const char *url, AVDictionary **options); - -/** - * Get next directory entry. - * - * Returned entry must be freed with avio_free_directory_entry(). In particular - * it may outlive AVIODirContext. - * - * @param s directory read context. - * @param[out] next next entry or NULL when no more entries. - * @return >=0 on success or negative on error. End of list is not considered an - * error. - */ -int avio_read_dir(AVIODirContext *s, AVIODirEntry **next); - -/** - * Close directory. - * - * @note Entries created using avio_read_dir() are not deleted and must be - * freeded with avio_free_directory_entry(). - * - * @param s directory read context. - * @return >=0 on success or negative on error. - */ -int avio_close_dir(AVIODirContext **s); - -/** - * Free entry allocated by avio_read_dir(). - * - * @param entry entry to be freed. - */ -void avio_free_directory_entry(AVIODirEntry **entry); - -/** - * Allocate and initialize an AVIOContext for buffered I/O. It must be later - * freed with avio_context_free(). - * - * @param buffer Memory block for input/output operations via AVIOContext. - * The buffer must be allocated with av_malloc() and friends. - * It may be freed and replaced with a new buffer by libavformat. - * AVIOContext.buffer holds the buffer currently in use, - * which must be later freed with av_free(). - * @param buffer_size The buffer size is very important for performance. - * For protocols with fixed blocksize it should be set to this blocksize. - * For others a typical size is a cache page, e.g. 4kb. - * @param write_flag Set to 1 if the buffer should be writable, 0 otherwise. - * @param opaque An opaque pointer to user-specific data. - * @param read_packet A function for refilling the buffer, may be NULL. - * For stream protocols, must never return 0 but rather - * a proper AVERROR code. - * @param write_packet A function for writing the buffer contents, may be NULL. - * The function may not change the input buffers content. - * @param seek A function for seeking to specified byte position, may be NULL. - * - * @return Allocated AVIOContext or NULL on failure. - */ -AVIOContext *avio_alloc_context( - unsigned char *buffer, - int buffer_size, - int write_flag, - void *opaque, - int (*read_packet)(void *opaque, uint8_t *buf, int buf_size), - int (*write_packet)(void *opaque, uint8_t *buf, int buf_size), - int64_t (*seek)(void *opaque, int64_t offset, int whence)); - -/** - * Free the supplied IO context and everything associated with it. - * - * @param s Double pointer to the IO context. This function will write NULL - * into s. - */ -void avio_context_free(AVIOContext **s); - -void avio_w8(AVIOContext *s, int b); -void avio_write(AVIOContext *s, const unsigned char *buf, int size); -void avio_wl64(AVIOContext *s, uint64_t val); -void avio_wb64(AVIOContext *s, uint64_t val); -void avio_wl32(AVIOContext *s, unsigned int val); -void avio_wb32(AVIOContext *s, unsigned int val); -void avio_wl24(AVIOContext *s, unsigned int val); -void avio_wb24(AVIOContext *s, unsigned int val); -void avio_wl16(AVIOContext *s, unsigned int val); -void avio_wb16(AVIOContext *s, unsigned int val); - -/** - * Write a NULL-terminated string. - * @return number of bytes written. - */ -int avio_put_str(AVIOContext *s, const char *str); - -/** - * Convert an UTF-8 string to UTF-16LE and write it. - * @param s the AVIOContext - * @param str NULL-terminated UTF-8 string - * - * @return number of bytes written. - */ -int avio_put_str16le(AVIOContext *s, const char *str); - -/** - * Convert an UTF-8 string to UTF-16BE and write it. - * @param s the AVIOContext - * @param str NULL-terminated UTF-8 string - * - * @return number of bytes written. - */ -int avio_put_str16be(AVIOContext *s, const char *str); - -/** - * Mark the written bytestream as a specific type. - * - * Zero-length ranges are omitted from the output. - * - * @param time the stream time the current bytestream pos corresponds to - * (in AV_TIME_BASE units), or AV_NOPTS_VALUE if unknown or not - * applicable - * @param type the kind of data written starting at the current pos - */ -void avio_write_marker(AVIOContext *s, int64_t time, enum AVIODataMarkerType type); - -/** - * ORing this as the "whence" parameter to a seek function causes it to - * return the filesize without seeking anywhere. Supporting this is optional. - * If it is not supported then the seek function will return <0. - */ -#define AVSEEK_SIZE 0x10000 - -/** - * Passing this flag as the "whence" parameter to a seek function causes it to - * seek by any means (like reopening and linear reading) or other normally unreasonable - * means that can be extremely slow. - * This may be ignored by the seek code. - */ -#define AVSEEK_FORCE 0x20000 - -/** - * fseek() equivalent for AVIOContext. - * @return new position or AVERROR. - */ -int64_t avio_seek(AVIOContext *s, int64_t offset, int whence); - -/** - * Skip given number of bytes forward - * @return new position or AVERROR. - */ -int64_t avio_skip(AVIOContext *s, int64_t offset); - -/** - * ftell() equivalent for AVIOContext. - * @return position or AVERROR. - */ -static av_always_inline int64_t avio_tell(AVIOContext *s) -{ - return avio_seek(s, 0, SEEK_CUR); -} - -/** - * Get the filesize. - * @return filesize or AVERROR - */ -int64_t avio_size(AVIOContext *s); - -/** - * Similar to feof() but also returns nonzero on read errors. - * @return non zero if and only if at end of file or a read error happened when reading. - */ -int avio_feof(AVIOContext *s); - -/** @warning Writes up to 4 KiB per call */ -int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); - -/** - * Force flushing of buffered data. - * - * For write streams, force the buffered data to be immediately written to the output, - * without to wait to fill the internal buffer. - * - * For read streams, discard all currently buffered data, and advance the - * reported file position to that of the underlying stream. This does not - * read new data, and does not perform any seeks. - */ -void avio_flush(AVIOContext *s); - -/** - * Read size bytes from AVIOContext into buf. - * @return number of bytes read or AVERROR - */ -int avio_read(AVIOContext *s, unsigned char *buf, int size); - -/** - * Read size bytes from AVIOContext into buf. Unlike avio_read(), this is allowed - * to read fewer bytes than requested. The missing bytes can be read in the next - * call. This always tries to read at least 1 byte. - * Useful to reduce latency in certain cases. - * @return number of bytes read or AVERROR - */ -int avio_read_partial(AVIOContext *s, unsigned char *buf, int size); - -/** - * @name Functions for reading from AVIOContext - * @{ - * - * @note return 0 if EOF, so you cannot use it if EOF handling is - * necessary - */ -int avio_r8 (AVIOContext *s); -unsigned int avio_rl16(AVIOContext *s); -unsigned int avio_rl24(AVIOContext *s); -unsigned int avio_rl32(AVIOContext *s); -uint64_t avio_rl64(AVIOContext *s); -unsigned int avio_rb16(AVIOContext *s); -unsigned int avio_rb24(AVIOContext *s); -unsigned int avio_rb32(AVIOContext *s); -uint64_t avio_rb64(AVIOContext *s); -/** - * @} - */ - -/** - * Read a string from pb into buf. The reading will terminate when either - * a NULL character was encountered, maxlen bytes have been read, or nothing - * more can be read from pb. The result is guaranteed to be NULL-terminated, it - * will be truncated if buf is too small. - * Note that the string is not interpreted or validated in any way, it - * might get truncated in the middle of a sequence for multi-byte encodings. - * - * @return number of bytes read (is always <= maxlen). - * If reading ends on EOF or error, the return value will be one more than - * bytes actually read. - */ -int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen); - -/** - * Read a UTF-16 string from pb and convert it to UTF-8. - * The reading will terminate when either a null or invalid character was - * encountered or maxlen bytes have been read. - * @return number of bytes read (is always <= maxlen) - */ -int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen); -int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen); - - -/** - * @name URL open modes - * The flags argument to avio_open must be one of the following - * constants, optionally ORed with other flags. - * @{ - */ -#define AVIO_FLAG_READ 1 /**< read-only */ -#define AVIO_FLAG_WRITE 2 /**< write-only */ -#define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) /**< read-write pseudo flag */ -/** - * @} - */ - -/** - * Use non-blocking mode. - * If this flag is set, operations on the context will return - * AVERROR(EAGAIN) if they can not be performed immediately. - * If this flag is not set, operations on the context will never return - * AVERROR(EAGAIN). - * Note that this flag does not affect the opening/connecting of the - * context. Connecting a protocol will always block if necessary (e.g. on - * network protocols) but never hang (e.g. on busy devices). - * Warning: non-blocking protocols is work-in-progress; this flag may be - * silently ignored. - */ -#define AVIO_FLAG_NONBLOCK 8 - -/** - * Use direct mode. - * avio_read and avio_write should if possible be satisfied directly - * instead of going through a buffer, and avio_seek will always - * call the underlying seek function directly. - */ -#define AVIO_FLAG_DIRECT 0x8000 - -/** - * Create and initialize a AVIOContext for accessing the - * resource indicated by url. - * @note When the resource indicated by url has been opened in - * read+write mode, the AVIOContext can be used only for writing. - * - * @param s Used to return the pointer to the created AVIOContext. - * In case of failure the pointed to value is set to NULL. - * @param url resource to access - * @param flags flags which control how the resource indicated by url - * is to be opened - * @return >= 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure - */ -int avio_open(AVIOContext **s, const char *url, int flags); - -/** - * Create and initialize a AVIOContext for accessing the - * resource indicated by url. - * @note When the resource indicated by url has been opened in - * read+write mode, the AVIOContext can be used only for writing. - * - * @param s Used to return the pointer to the created AVIOContext. - * In case of failure the pointed to value is set to NULL. - * @param url resource to access - * @param flags flags which control how the resource indicated by url - * is to be opened - * @param int_cb an interrupt callback to be used at the protocols level - * @param options A dictionary filled with protocol-private options. On return - * this parameter will be destroyed and replaced with a dict containing options - * that were not found. May be NULL. - * @return >= 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure - */ -int avio_open2(AVIOContext **s, const char *url, int flags, - const AVIOInterruptCB *int_cb, AVDictionary **options); - -/** - * Close the resource accessed by the AVIOContext s and free it. - * This function can only be used if s was opened by avio_open(). - * - * The internal buffer is automatically flushed before closing the - * resource. - * - * @return 0 on success, an AVERROR < 0 on error. - * @see avio_closep - */ -int avio_close(AVIOContext *s); - -/** - * Close the resource accessed by the AVIOContext *s, free it - * and set the pointer pointing to it to NULL. - * This function can only be used if s was opened by avio_open(). - * - * The internal buffer is automatically flushed before closing the - * resource. - * - * @return 0 on success, an AVERROR < 0 on error. - * @see avio_close - */ -int avio_closep(AVIOContext **s); - - -/** - * Open a write only memory stream. - * - * @param s new IO context - * @return zero if no error. - */ -int avio_open_dyn_buf(AVIOContext **s); - -/** - * Return the written size and a pointer to the buffer. - * The AVIOContext stream is left intact. - * The buffer must NOT be freed. - * No padding is added to the buffer. - * - * @param s IO context - * @param pbuffer pointer to a byte buffer - * @return the length of the byte buffer - */ -int avio_get_dyn_buf(AVIOContext *s, uint8_t **pbuffer); - -/** - * Return the written size and a pointer to the buffer. The buffer - * must be freed with av_free(). - * Padding of AV_INPUT_BUFFER_PADDING_SIZE is added to the buffer. - * - * @param s IO context - * @param pbuffer pointer to a byte buffer - * @return the length of the byte buffer - */ -int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); - -/** - * Iterate through names of available protocols. - * - * @param opaque A private pointer representing current protocol. - * It must be a pointer to NULL on first iteration and will - * be updated by successive calls to avio_enum_protocols. - * @param output If set to 1, iterate over output protocols, - * otherwise over input protocols. - * - * @return A static string containing the name of current protocol or NULL - */ -const char *avio_enum_protocols(void **opaque, int output); - -/** - * Pause and resume playing - only meaningful if using a network streaming - * protocol (e.g. MMS). - * - * @param h IO context from which to call the read_pause function pointer - * @param pause 1 for pause, 0 for resume - */ -int avio_pause(AVIOContext *h, int pause); - -/** - * Seek to a given timestamp relative to some component stream. - * Only meaningful if using a network streaming protocol (e.g. MMS.). - * - * @param h IO context from which to call the seek function pointers - * @param stream_index The stream index that the timestamp is relative to. - * If stream_index is (-1) the timestamp should be in AV_TIME_BASE - * units from the beginning of the presentation. - * If a stream_index >= 0 is used and the protocol does not support - * seeking based on component streams, the call will fail. - * @param timestamp timestamp in AVStream.time_base units - * or if there is no stream specified then in AV_TIME_BASE units. - * @param flags Optional combination of AVSEEK_FLAG_BACKWARD, AVSEEK_FLAG_BYTE - * and AVSEEK_FLAG_ANY. The protocol may silently ignore - * AVSEEK_FLAG_BACKWARD and AVSEEK_FLAG_ANY, but AVSEEK_FLAG_BYTE will - * fail if used and not supported. - * @return >= 0 on success - * @see AVInputFormat::read_seek - */ -int64_t avio_seek_time(AVIOContext *h, int stream_index, - int64_t timestamp, int flags); - -/* Avoid a warning. The header can not be included because it breaks c++. */ -struct AVBPrint; - -/** - * Read contents of h into print buffer, up to max_size bytes, or up to EOF. - * - * @return 0 for success (max_size bytes read or EOF reached), negative error - * code otherwise - */ -int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size); - -/** - * Accept and allocate a client context on a server context. - * @param s the server context - * @param c the client context, must be unallocated - * @return >= 0 on success or a negative value corresponding - * to an AVERROR on failure - */ -int avio_accept(AVIOContext *s, AVIOContext **c); - -/** - * Perform one step of the protocol handshake to accept a new client. - * This function must be called on a client returned by avio_accept() before - * using it as a read/write context. - * It is separate from avio_accept() because it may block. - * A step of the handshake is defined by places where the application may - * decide to change the proceedings. - * For example, on a protocol with a request header and a reply header, each - * one can constitute a step because the application may use the parameters - * from the request to change parameters in the reply; or each individual - * chunk of the request can constitute a step. - * If the handshake is already finished, avio_handshake() does nothing and - * returns 0 immediately. - * - * @param c the client context to perform the handshake on - * @return 0 on a complete and successful handshake - * > 0 if the handshake progressed, but is not complete - * < 0 for an AVERROR code - */ -int avio_handshake(AVIOContext *c); -#endif /* AVFORMAT_AVIO_H */ diff --git a/maclibs/include/libavformat/version.h b/maclibs/include/libavformat/version.h deleted file mode 100644 index 22ed534b..00000000 --- a/maclibs/include/libavformat/version.h +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Version macros. - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVFORMAT_VERSION_H -#define AVFORMAT_VERSION_H - -/** - * @file - * @ingroup libavf - * Libavformat version macros - */ - -#include "libavutil/version.h" - -// Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) -// Also please add any ticket numbers that you believe might be affected here -#define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 29 -#define LIBAVFORMAT_VERSION_MICRO 100 - -#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ - LIBAVFORMAT_VERSION_MINOR, \ - LIBAVFORMAT_VERSION_MICRO) -#define LIBAVFORMAT_VERSION AV_VERSION(LIBAVFORMAT_VERSION_MAJOR, \ - LIBAVFORMAT_VERSION_MINOR, \ - LIBAVFORMAT_VERSION_MICRO) -#define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT - -#define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) - -/** - * FF_API_* defines may be placed below to indicate public API that will be - * dropped at a future version bump. The defines themselves are not part of - * the public API and may change, break or disappear at any time. - * - * @note, when bumping the major version it is recommended to manually - * disable each FF_API_* in its own commit instead of disabling them all - * at once through the bump. This improves the git bisect-ability of the change. - * - */ -#ifndef FF_API_COMPUTE_PKT_FIELDS2 -#define FF_API_COMPUTE_PKT_FIELDS2 (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OLD_OPEN_CALLBACKS -#define FF_API_OLD_OPEN_CALLBACKS (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_LAVF_AVCTX -#define FF_API_LAVF_AVCTX (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_HTTP_USER_AGENT -#define FF_API_HTTP_USER_AGENT (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_HLS_WRAP -#define FF_API_HLS_WRAP (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_HLS_USE_LOCALTIME -#define FF_API_HLS_USE_LOCALTIME (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_LAVF_KEEPSIDE_FLAG -#define FF_API_LAVF_KEEPSIDE_FLAG (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OLD_ROTATE_API -#define FF_API_OLD_ROTATE_API (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_FORMAT_GET_SET -#define FF_API_FORMAT_GET_SET (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OLD_AVIO_EOF_0 -#define FF_API_OLD_AVIO_EOF_0 (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_LAVF_FFSERVER -#define FF_API_LAVF_FFSERVER (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_FORMAT_FILENAME -#define FF_API_FORMAT_FILENAME (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_OLD_RTSP_OPTIONS -#define FF_API_OLD_RTSP_OPTIONS (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_NEXT -#define FF_API_NEXT (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_DASH_MIN_SEG_DURATION -#define FF_API_DASH_MIN_SEG_DURATION (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_LAVF_MP4A_LATM -#define FF_API_LAVF_MP4A_LATM (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_AVIOFORMAT -#define FF_API_AVIOFORMAT (LIBAVFORMAT_VERSION_MAJOR < 59) -#endif - - -#ifndef FF_API_R_FRAME_RATE -#define FF_API_R_FRAME_RATE 1 -#endif -#endif /* AVFORMAT_VERSION_H */ diff --git a/maclibs/include/libavutil/attributes.h b/maclibs/include/libavutil/attributes.h deleted file mode 100644 index ced108aa..00000000 --- a/maclibs/include/libavutil/attributes.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * Macro definitions for various function/variable attributes - */ - -#ifndef AVUTIL_ATTRIBUTES_H -#define AVUTIL_ATTRIBUTES_H - -#ifdef __GNUC__ -# define AV_GCC_VERSION_AT_LEAST(x,y) (__GNUC__ > (x) || __GNUC__ == (x) && __GNUC_MINOR__ >= (y)) -# define AV_GCC_VERSION_AT_MOST(x,y) (__GNUC__ < (x) || __GNUC__ == (x) && __GNUC_MINOR__ <= (y)) -#else -# define AV_GCC_VERSION_AT_LEAST(x,y) 0 -# define AV_GCC_VERSION_AT_MOST(x,y) 0 -#endif - -#ifndef av_always_inline -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define av_always_inline __attribute__((always_inline)) inline -#elif defined(_MSC_VER) -# define av_always_inline __forceinline -#else -# define av_always_inline inline -#endif -#endif - -#ifndef av_extern_inline -#if defined(__ICL) && __ICL >= 1210 || defined(__GNUC_STDC_INLINE__) -# define av_extern_inline extern inline -#else -# define av_extern_inline inline -#endif -#endif - -#if AV_GCC_VERSION_AT_LEAST(3,4) -# define av_warn_unused_result __attribute__((warn_unused_result)) -#else -# define av_warn_unused_result -#endif - -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define av_noinline __attribute__((noinline)) -#elif defined(_MSC_VER) -# define av_noinline __declspec(noinline) -#else -# define av_noinline -#endif - -#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__) -# define av_pure __attribute__((pure)) -#else -# define av_pure -#endif - -#if AV_GCC_VERSION_AT_LEAST(2,6) || defined(__clang__) -# define av_const __attribute__((const)) -#else -# define av_const -#endif - -#if AV_GCC_VERSION_AT_LEAST(4,3) || defined(__clang__) -# define av_cold __attribute__((cold)) -#else -# define av_cold -#endif - -#if AV_GCC_VERSION_AT_LEAST(4,1) && !defined(__llvm__) -# define av_flatten __attribute__((flatten)) -#else -# define av_flatten -#endif - -#if AV_GCC_VERSION_AT_LEAST(3,1) -# define attribute_deprecated __attribute__((deprecated)) -#elif defined(_MSC_VER) -# define attribute_deprecated __declspec(deprecated) -#else -# define attribute_deprecated -#endif - -/** - * Disable warnings about deprecated features - * This is useful for sections of code kept for backward compatibility and - * scheduled for removal. - */ -#ifndef AV_NOWARN_DEPRECATED -#if AV_GCC_VERSION_AT_LEAST(4,6) -# define AV_NOWARN_DEPRECATED(code) \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"") \ - code \ - _Pragma("GCC diagnostic pop") -#elif defined(_MSC_VER) -# define AV_NOWARN_DEPRECATED(code) \ - __pragma(warning(push)) \ - __pragma(warning(disable : 4996)) \ - code; \ - __pragma(warning(pop)) -#else -# define AV_NOWARN_DEPRECATED(code) code -#endif -#endif - -#if defined(__GNUC__) || defined(__clang__) -# define av_unused __attribute__((unused)) -#else -# define av_unused -#endif - -/** - * Mark a variable as used and prevent the compiler from optimizing it - * away. This is useful for variables accessed only from inline - * assembler without the compiler being aware. - */ -#if AV_GCC_VERSION_AT_LEAST(3,1) || defined(__clang__) -# define av_used __attribute__((used)) -#else -# define av_used -#endif - -#if AV_GCC_VERSION_AT_LEAST(3,3) || defined(__clang__) -# define av_alias __attribute__((may_alias)) -#else -# define av_alias -#endif - -#if (defined(__GNUC__) || defined(__clang__)) && !defined(__INTEL_COMPILER) -# define av_uninit(x) x=x -#else -# define av_uninit(x) x -#endif - -#if defined(__GNUC__) || defined(__clang__) -# define av_builtin_constant_p __builtin_constant_p -# define av_printf_format(fmtpos, attrpos) __attribute__((__format__(__printf__, fmtpos, attrpos))) -#else -# define av_builtin_constant_p(x) 0 -# define av_printf_format(fmtpos, attrpos) -#endif - -#if AV_GCC_VERSION_AT_LEAST(2,5) || defined(__clang__) -# define av_noreturn __attribute__((noreturn)) -#else -# define av_noreturn -#endif - -#endif /* AVUTIL_ATTRIBUTES_H */ diff --git a/maclibs/include/libavutil/avconfig.h b/maclibs/include/libavutil/avconfig.h deleted file mode 100644 index c289fbb5..00000000 --- a/maclibs/include/libavutil/avconfig.h +++ /dev/null @@ -1,6 +0,0 @@ -/* Generated by ffmpeg configure */ -#ifndef AVUTIL_AVCONFIG_H -#define AVUTIL_AVCONFIG_H -#define AV_HAVE_BIGENDIAN 0 -#define AV_HAVE_FAST_UNALIGNED 1 -#endif /* AVUTIL_AVCONFIG_H */ diff --git a/maclibs/include/libavutil/avutil.h b/maclibs/include/libavutil/avutil.h deleted file mode 100644 index 4d633156..00000000 --- a/maclibs/include/libavutil/avutil.h +++ /dev/null @@ -1,365 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_AVUTIL_H -#define AVUTIL_AVUTIL_H - -/** - * @file - * @ingroup lavu - * Convenience header that includes @ref lavu "libavutil"'s core. - */ - -/** - * @mainpage - * - * @section ffmpeg_intro Introduction - * - * This document describes the usage of the different libraries - * provided by FFmpeg. - * - * @li @ref libavc "libavcodec" encoding/decoding library - * @li @ref lavfi "libavfilter" graph-based frame editing library - * @li @ref libavf "libavformat" I/O and muxing/demuxing library - * @li @ref lavd "libavdevice" special devices muxing/demuxing library - * @li @ref lavu "libavutil" common utility library - * @li @ref lswr "libswresample" audio resampling, format conversion and mixing - * @li @ref lpp "libpostproc" post processing library - * @li @ref libsws "libswscale" color conversion and scaling library - * - * @section ffmpeg_versioning Versioning and compatibility - * - * Each of the FFmpeg libraries contains a version.h header, which defines a - * major, minor and micro version number with the - * LIBRARYNAME_VERSION_{MAJOR,MINOR,MICRO} macros. The major version - * number is incremented with backward incompatible changes - e.g. removing - * parts of the public API, reordering public struct members, etc. The minor - * version number is incremented for backward compatible API changes or major - * new features - e.g. adding a new public function or a new decoder. The micro - * version number is incremented for smaller changes that a calling program - * might still want to check for - e.g. changing behavior in a previously - * unspecified situation. - * - * FFmpeg guarantees backward API and ABI compatibility for each library as long - * as its major version number is unchanged. This means that no public symbols - * will be removed or renamed. Types and names of the public struct members and - * values of public macros and enums will remain the same (unless they were - * explicitly declared as not part of the public API). Documented behavior will - * not change. - * - * In other words, any correct program that works with a given FFmpeg snapshot - * should work just as well without any changes with any later snapshot with the - * same major versions. This applies to both rebuilding the program against new - * FFmpeg versions or to replacing the dynamic FFmpeg libraries that a program - * links against. - * - * However, new public symbols may be added and new members may be appended to - * public structs whose size is not part of public ABI (most public structs in - * FFmpeg). New macros and enum values may be added. Behavior in undocumented - * situations may change slightly (and be documented). All those are accompanied - * by an entry in doc/APIchanges and incrementing either the minor or micro - * version number. - */ - -/** - * @defgroup lavu libavutil - * Common code shared across all FFmpeg libraries. - * - * @note - * libavutil is designed to be modular. In most cases, in order to use the - * functions provided by one component of libavutil you must explicitly include - * the specific header containing that feature. If you are only using - * media-related components, you could simply include libavutil/avutil.h, which - * brings in most of the "core" components. - * - * @{ - * - * @defgroup lavu_crypto Crypto and Hashing - * - * @{ - * @} - * - * @defgroup lavu_math Mathematics - * @{ - * - * @} - * - * @defgroup lavu_string String Manipulation - * - * @{ - * - * @} - * - * @defgroup lavu_mem Memory Management - * - * @{ - * - * @} - * - * @defgroup lavu_data Data Structures - * @{ - * - * @} - * - * @defgroup lavu_video Video related - * - * @{ - * - * @} - * - * @defgroup lavu_audio Audio related - * - * @{ - * - * @} - * - * @defgroup lavu_error Error Codes - * - * @{ - * - * @} - * - * @defgroup lavu_log Logging Facility - * - * @{ - * - * @} - * - * @defgroup lavu_misc Other - * - * @{ - * - * @defgroup preproc_misc Preprocessor String Macros - * - * @{ - * - * @} - * - * @defgroup version_utils Library Version Macros - * - * @{ - * - * @} - */ - - -/** - * @addtogroup lavu_ver - * @{ - */ - -/** - * Return the LIBAVUTIL_VERSION_INT constant. - */ -unsigned avutil_version(void); - -/** - * Return an informative version string. This usually is the actual release - * version number or a git commit description. This string has no fixed format - * and can change any time. It should never be parsed by code. - */ -const char *av_version_info(void); - -/** - * Return the libavutil build-time configuration. - */ -const char *avutil_configuration(void); - -/** - * Return the libavutil license. - */ -const char *avutil_license(void); - -/** - * @} - */ - -/** - * @addtogroup lavu_media Media Type - * @brief Media Type - */ - -enum AVMediaType { - AVMEDIA_TYPE_UNKNOWN = -1, ///< Usually treated as AVMEDIA_TYPE_DATA - AVMEDIA_TYPE_VIDEO, - AVMEDIA_TYPE_AUDIO, - AVMEDIA_TYPE_DATA, ///< Opaque data information usually continuous - AVMEDIA_TYPE_SUBTITLE, - AVMEDIA_TYPE_ATTACHMENT, ///< Opaque data information usually sparse - AVMEDIA_TYPE_NB -}; - -/** - * Return a string describing the media_type enum, NULL if media_type - * is unknown. - */ -const char *av_get_media_type_string(enum AVMediaType media_type); - -/** - * @defgroup lavu_const Constants - * @{ - * - * @defgroup lavu_enc Encoding specific - * - * @note those definition should move to avcodec - * @{ - */ - -#define FF_LAMBDA_SHIFT 7 -#define FF_LAMBDA_SCALE (1< - -/** - * @defgroup lavu_buffer AVBuffer - * @ingroup lavu_data - * - * @{ - * AVBuffer is an API for reference-counted data buffers. - * - * There are two core objects in this API -- AVBuffer and AVBufferRef. AVBuffer - * represents the data buffer itself; it is opaque and not meant to be accessed - * by the caller directly, but only through AVBufferRef. However, the caller may - * e.g. compare two AVBuffer pointers to check whether two different references - * are describing the same data buffer. AVBufferRef represents a single - * reference to an AVBuffer and it is the object that may be manipulated by the - * caller directly. - * - * There are two functions provided for creating a new AVBuffer with a single - * reference -- av_buffer_alloc() to just allocate a new buffer, and - * av_buffer_create() to wrap an existing array in an AVBuffer. From an existing - * reference, additional references may be created with av_buffer_ref(). - * Use av_buffer_unref() to free a reference (this will automatically free the - * data once all the references are freed). - * - * The convention throughout this API and the rest of FFmpeg is such that the - * buffer is considered writable if there exists only one reference to it (and - * it has not been marked as read-only). The av_buffer_is_writable() function is - * provided to check whether this is true and av_buffer_make_writable() will - * automatically create a new writable buffer when necessary. - * Of course nothing prevents the calling code from violating this convention, - * however that is safe only when all the existing references are under its - * control. - * - * @note Referencing and unreferencing the buffers is thread-safe and thus - * may be done from multiple threads simultaneously without any need for - * additional locking. - * - * @note Two different references to the same buffer can point to different - * parts of the buffer (i.e. their AVBufferRef.data will not be equal). - */ - -/** - * A reference counted buffer type. It is opaque and is meant to be used through - * references (AVBufferRef). - */ -typedef struct AVBuffer AVBuffer; - -/** - * A reference to a data buffer. - * - * The size of this struct is not a part of the public ABI and it is not meant - * to be allocated directly. - */ -typedef struct AVBufferRef { - AVBuffer *buffer; - - /** - * The data buffer. It is considered writable if and only if - * this is the only reference to the buffer, in which case - * av_buffer_is_writable() returns 1. - */ - uint8_t *data; - /** - * Size of data in bytes. - */ - int size; -} AVBufferRef; - -/** - * Allocate an AVBuffer of the given size using av_malloc(). - * - * @return an AVBufferRef of given size or NULL when out of memory - */ -AVBufferRef *av_buffer_alloc(int size); - -/** - * Same as av_buffer_alloc(), except the returned buffer will be initialized - * to zero. - */ -AVBufferRef *av_buffer_allocz(int size); - -/** - * Always treat the buffer as read-only, even when it has only one - * reference. - */ -#define AV_BUFFER_FLAG_READONLY (1 << 0) - -/** - * Create an AVBuffer from an existing array. - * - * If this function is successful, data is owned by the AVBuffer. The caller may - * only access data through the returned AVBufferRef and references derived from - * it. - * If this function fails, data is left untouched. - * @param data data array - * @param size size of data in bytes - * @param free a callback for freeing this buffer's data - * @param opaque parameter to be got for processing or passed to free - * @param flags a combination of AV_BUFFER_FLAG_* - * - * @return an AVBufferRef referring to data on success, NULL on failure. - */ -AVBufferRef *av_buffer_create(uint8_t *data, int size, - void (*free)(void *opaque, uint8_t *data), - void *opaque, int flags); - -/** - * Default free callback, which calls av_free() on the buffer data. - * This function is meant to be passed to av_buffer_create(), not called - * directly. - */ -void av_buffer_default_free(void *opaque, uint8_t *data); - -/** - * Create a new reference to an AVBuffer. - * - * @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on - * failure. - */ -AVBufferRef *av_buffer_ref(AVBufferRef *buf); - -/** - * Free a given reference and automatically free the buffer if there are no more - * references to it. - * - * @param buf the reference to be freed. The pointer is set to NULL on return. - */ -void av_buffer_unref(AVBufferRef **buf); - -/** - * @return 1 if the caller may write to the data referred to by buf (which is - * true if and only if buf is the only reference to the underlying AVBuffer). - * Return 0 otherwise. - * A positive answer is valid until av_buffer_ref() is called on buf. - */ -int av_buffer_is_writable(const AVBufferRef *buf); - -/** - * @return the opaque parameter set by av_buffer_create. - */ -void *av_buffer_get_opaque(const AVBufferRef *buf); - -int av_buffer_get_ref_count(const AVBufferRef *buf); - -/** - * Create a writable reference from a given buffer reference, avoiding data copy - * if possible. - * - * @param buf buffer reference to make writable. On success, buf is either left - * untouched, or it is unreferenced and a new writable AVBufferRef is - * written in its place. On failure, buf is left untouched. - * @return 0 on success, a negative AVERROR on failure. - */ -int av_buffer_make_writable(AVBufferRef **buf); - -/** - * Reallocate a given buffer. - * - * @param buf a buffer reference to reallocate. On success, buf will be - * unreferenced and a new reference with the required size will be - * written in its place. On failure buf will be left untouched. *buf - * may be NULL, then a new buffer is allocated. - * @param size required new buffer size. - * @return 0 on success, a negative AVERROR on failure. - * - * @note the buffer is actually reallocated with av_realloc() only if it was - * initially allocated through av_buffer_realloc(NULL) and there is only one - * reference to it (i.e. the one passed to this function). In all other cases - * a new buffer is allocated and the data is copied. - */ -int av_buffer_realloc(AVBufferRef **buf, int size); - -/** - * @} - */ - -/** - * @defgroup lavu_bufferpool AVBufferPool - * @ingroup lavu_data - * - * @{ - * AVBufferPool is an API for a lock-free thread-safe pool of AVBuffers. - * - * Frequently allocating and freeing large buffers may be slow. AVBufferPool is - * meant to solve this in cases when the caller needs a set of buffers of the - * same size (the most obvious use case being buffers for raw video or audio - * frames). - * - * At the beginning, the user must call av_buffer_pool_init() to create the - * buffer pool. Then whenever a buffer is needed, call av_buffer_pool_get() to - * get a reference to a new buffer, similar to av_buffer_alloc(). This new - * reference works in all aspects the same way as the one created by - * av_buffer_alloc(). However, when the last reference to this buffer is - * unreferenced, it is returned to the pool instead of being freed and will be - * reused for subsequent av_buffer_pool_get() calls. - * - * When the caller is done with the pool and no longer needs to allocate any new - * buffers, av_buffer_pool_uninit() must be called to mark the pool as freeable. - * Once all the buffers are released, it will automatically be freed. - * - * Allocating and releasing buffers with this API is thread-safe as long as - * either the default alloc callback is used, or the user-supplied one is - * thread-safe. - */ - -/** - * The buffer pool. This structure is opaque and not meant to be accessed - * directly. It is allocated with av_buffer_pool_init() and freed with - * av_buffer_pool_uninit(). - */ -typedef struct AVBufferPool AVBufferPool; - -/** - * Allocate and initialize a buffer pool. - * - * @param size size of each buffer in this pool - * @param alloc a function that will be used to allocate new buffers when the - * pool is empty. May be NULL, then the default allocator will be used - * (av_buffer_alloc()). - * @return newly created buffer pool on success, NULL on error. - */ -AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); - -/** - * Allocate and initialize a buffer pool with a more complex allocator. - * - * @param size size of each buffer in this pool - * @param opaque arbitrary user data used by the allocator - * @param alloc a function that will be used to allocate new buffers when the - * pool is empty. - * @param pool_free a function that will be called immediately before the pool - * is freed. I.e. after av_buffer_pool_uninit() is called - * by the caller and all the frames are returned to the pool - * and freed. It is intended to uninitialize the user opaque - * data. - * @return newly created buffer pool on success, NULL on error. - */ -AVBufferPool *av_buffer_pool_init2(int size, void *opaque, - AVBufferRef* (*alloc)(void *opaque, int size), - void (*pool_free)(void *opaque)); - -/** - * Mark the pool as being available for freeing. It will actually be freed only - * once all the allocated buffers associated with the pool are released. Thus it - * is safe to call this function while some of the allocated buffers are still - * in use. - * - * @param pool pointer to the pool to be freed. It will be set to NULL. - */ -void av_buffer_pool_uninit(AVBufferPool **pool); - -/** - * Allocate a new AVBuffer, reusing an old buffer from the pool when available. - * This function may be called simultaneously from multiple threads. - * - * @return a reference to the new buffer on success, NULL on error. - */ -AVBufferRef *av_buffer_pool_get(AVBufferPool *pool); - -/** - * @} - */ - -#endif /* AVUTIL_BUFFER_H */ diff --git a/maclibs/include/libavutil/channel_layout.h b/maclibs/include/libavutil/channel_layout.h deleted file mode 100644 index 50bb8f03..00000000 --- a/maclibs/include/libavutil/channel_layout.h +++ /dev/null @@ -1,232 +0,0 @@ -/* - * Copyright (c) 2006 Michael Niedermayer - * Copyright (c) 2008 Peter Ross - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_CHANNEL_LAYOUT_H -#define AVUTIL_CHANNEL_LAYOUT_H - -#include - -/** - * @file - * audio channel layout utility functions - */ - -/** - * @addtogroup lavu_audio - * @{ - */ - -/** - * @defgroup channel_masks Audio channel masks - * - * A channel layout is a 64-bits integer with a bit set for every channel. - * The number of bits set must be equal to the number of channels. - * The value 0 means that the channel layout is not known. - * @note this data structure is not powerful enough to handle channels - * combinations that have the same channel multiple times, such as - * dual-mono. - * - * @{ - */ -#define AV_CH_FRONT_LEFT 0x00000001 -#define AV_CH_FRONT_RIGHT 0x00000002 -#define AV_CH_FRONT_CENTER 0x00000004 -#define AV_CH_LOW_FREQUENCY 0x00000008 -#define AV_CH_BACK_LEFT 0x00000010 -#define AV_CH_BACK_RIGHT 0x00000020 -#define AV_CH_FRONT_LEFT_OF_CENTER 0x00000040 -#define AV_CH_FRONT_RIGHT_OF_CENTER 0x00000080 -#define AV_CH_BACK_CENTER 0x00000100 -#define AV_CH_SIDE_LEFT 0x00000200 -#define AV_CH_SIDE_RIGHT 0x00000400 -#define AV_CH_TOP_CENTER 0x00000800 -#define AV_CH_TOP_FRONT_LEFT 0x00001000 -#define AV_CH_TOP_FRONT_CENTER 0x00002000 -#define AV_CH_TOP_FRONT_RIGHT 0x00004000 -#define AV_CH_TOP_BACK_LEFT 0x00008000 -#define AV_CH_TOP_BACK_CENTER 0x00010000 -#define AV_CH_TOP_BACK_RIGHT 0x00020000 -#define AV_CH_STEREO_LEFT 0x20000000 ///< Stereo downmix. -#define AV_CH_STEREO_RIGHT 0x40000000 ///< See AV_CH_STEREO_LEFT. -#define AV_CH_WIDE_LEFT 0x0000000080000000ULL -#define AV_CH_WIDE_RIGHT 0x0000000100000000ULL -#define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL -#define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL -#define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL - -/** Channel mask value used for AVCodecContext.request_channel_layout - to indicate that the user requests the channel order of the decoder output - to be the native codec channel order. */ -#define AV_CH_LAYOUT_NATIVE 0x8000000000000000ULL - -/** - * @} - * @defgroup channel_mask_c Audio channel layouts - * @{ - * */ -#define AV_CH_LAYOUT_MONO (AV_CH_FRONT_CENTER) -#define AV_CH_LAYOUT_STEREO (AV_CH_FRONT_LEFT|AV_CH_FRONT_RIGHT) -#define AV_CH_LAYOUT_2POINT1 (AV_CH_LAYOUT_STEREO|AV_CH_LOW_FREQUENCY) -#define AV_CH_LAYOUT_2_1 (AV_CH_LAYOUT_STEREO|AV_CH_BACK_CENTER) -#define AV_CH_LAYOUT_SURROUND (AV_CH_LAYOUT_STEREO|AV_CH_FRONT_CENTER) -#define AV_CH_LAYOUT_3POINT1 (AV_CH_LAYOUT_SURROUND|AV_CH_LOW_FREQUENCY) -#define AV_CH_LAYOUT_4POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_CENTER) -#define AV_CH_LAYOUT_4POINT1 (AV_CH_LAYOUT_4POINT0|AV_CH_LOW_FREQUENCY) -#define AV_CH_LAYOUT_2_2 (AV_CH_LAYOUT_STEREO|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) -#define AV_CH_LAYOUT_QUAD (AV_CH_LAYOUT_STEREO|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_5POINT0 (AV_CH_LAYOUT_SURROUND|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT) -#define AV_CH_LAYOUT_5POINT1 (AV_CH_LAYOUT_5POINT0|AV_CH_LOW_FREQUENCY) -#define AV_CH_LAYOUT_5POINT0_BACK (AV_CH_LAYOUT_SURROUND|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_5POINT1_BACK (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_LOW_FREQUENCY) -#define AV_CH_LAYOUT_6POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_CENTER) -#define AV_CH_LAYOUT_6POINT0_FRONT (AV_CH_LAYOUT_2_2|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) -#define AV_CH_LAYOUT_HEXAGONAL (AV_CH_LAYOUT_5POINT0_BACK|AV_CH_BACK_CENTER) -#define AV_CH_LAYOUT_6POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_CENTER) -#define AV_CH_LAYOUT_6POINT1_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_BACK_CENTER) -#define AV_CH_LAYOUT_6POINT1_FRONT (AV_CH_LAYOUT_6POINT0_FRONT|AV_CH_LOW_FREQUENCY) -#define AV_CH_LAYOUT_7POINT0 (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_7POINT0_FRONT (AV_CH_LAYOUT_5POINT0|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) -#define AV_CH_LAYOUT_7POINT1 (AV_CH_LAYOUT_5POINT1|AV_CH_BACK_LEFT|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_7POINT1_WIDE (AV_CH_LAYOUT_5POINT1|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) -#define AV_CH_LAYOUT_7POINT1_WIDE_BACK (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER) -#define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT) -#define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) -#define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) - -enum AVMatrixEncoding { - AV_MATRIX_ENCODING_NONE, - AV_MATRIX_ENCODING_DOLBY, - AV_MATRIX_ENCODING_DPLII, - AV_MATRIX_ENCODING_DPLIIX, - AV_MATRIX_ENCODING_DPLIIZ, - AV_MATRIX_ENCODING_DOLBYEX, - AV_MATRIX_ENCODING_DOLBYHEADPHONE, - AV_MATRIX_ENCODING_NB -}; - -/** - * Return a channel layout id that matches name, or 0 if no match is found. - * - * name can be one or several of the following notations, - * separated by '+' or '|': - * - the name of an usual channel layout (mono, stereo, 4.0, quad, 5.0, - * 5.0(side), 5.1, 5.1(side), 7.1, 7.1(wide), downmix); - * - the name of a single channel (FL, FR, FC, LFE, BL, BR, FLC, FRC, BC, - * SL, SR, TC, TFL, TFC, TFR, TBL, TBC, TBR, DL, DR); - * - a number of channels, in decimal, followed by 'c', yielding - * the default channel layout for that number of channels (@see - * av_get_default_channel_layout); - * - a channel layout mask, in hexadecimal starting with "0x" (see the - * AV_CH_* macros). - * - * Example: "stereo+FC" = "2c+FC" = "2c+1c" = "0x7" - */ -uint64_t av_get_channel_layout(const char *name); - -/** - * Return a channel layout and the number of channels based on the specified name. - * - * This function is similar to (@see av_get_channel_layout), but can also parse - * unknown channel layout specifications. - * - * @param[in] name channel layout specification string - * @param[out] channel_layout parsed channel layout (0 if unknown) - * @param[out] nb_channels number of channels - * - * @return 0 on success, AVERROR(EINVAL) if the parsing fails. - */ -int av_get_extended_channel_layout(const char *name, uint64_t* channel_layout, int* nb_channels); - -/** - * Return a description of a channel layout. - * If nb_channels is <= 0, it is guessed from the channel_layout. - * - * @param buf put here the string containing the channel layout - * @param buf_size size in bytes of the buffer - */ -void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout); - -struct AVBPrint; -/** - * Append a description of a channel layout to a bprint buffer. - */ -void av_bprint_channel_layout(struct AVBPrint *bp, int nb_channels, uint64_t channel_layout); - -/** - * Return the number of channels in the channel layout. - */ -int av_get_channel_layout_nb_channels(uint64_t channel_layout); - -/** - * Return default channel layout for a given number of channels. - */ -int64_t av_get_default_channel_layout(int nb_channels); - -/** - * Get the index of a channel in channel_layout. - * - * @param channel a channel layout describing exactly one channel which must be - * present in channel_layout. - * - * @return index of channel in channel_layout on success, a negative AVERROR - * on error. - */ -int av_get_channel_layout_channel_index(uint64_t channel_layout, - uint64_t channel); - -/** - * Get the channel with the given index in channel_layout. - */ -uint64_t av_channel_layout_extract_channel(uint64_t channel_layout, int index); - -/** - * Get the name of a given channel. - * - * @return channel name on success, NULL on error. - */ -const char *av_get_channel_name(uint64_t channel); - -/** - * Get the description of a given channel. - * - * @param channel a channel layout with a single channel - * @return channel description on success, NULL on error - */ -const char *av_get_channel_description(uint64_t channel); - -/** - * Get the value and name of a standard channel layout. - * - * @param[in] index index in an internal list, starting at 0 - * @param[out] layout channel layout mask - * @param[out] name name of the layout - * @return 0 if the layout exists, - * <0 if index is beyond the limits - */ -int av_get_standard_channel_layout(unsigned index, uint64_t *layout, - const char **name); - -/** - * @} - * @} - */ - -#endif /* AVUTIL_CHANNEL_LAYOUT_H */ diff --git a/maclibs/include/libavutil/common.h b/maclibs/include/libavutil/common.h deleted file mode 100644 index 8db02911..00000000 --- a/maclibs/include/libavutil/common.h +++ /dev/null @@ -1,560 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * common internal and external API header - */ - -#ifndef AVUTIL_COMMON_H -#define AVUTIL_COMMON_H - -#if defined(__cplusplus) && !defined(__STDC_CONSTANT_MACROS) && !defined(UINT64_C) -#error missing -D__STDC_CONSTANT_MACROS / #define __STDC_CONSTANT_MACROS -#endif - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "attributes.h" -#include "macros.h" -#include "version.h" -#include "libavutil/avconfig.h" - -#if AV_HAVE_BIGENDIAN -# define AV_NE(be, le) (be) -#else -# define AV_NE(be, le) (le) -#endif - -//rounded division & shift -#define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) -/* assume b>0 */ -#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) -/* Fast a/(1<=0 and b>=0 */ -#define AV_CEIL_RSHIFT(a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) \ - : ((a) + (1<<(b)) - 1) >> (b)) -/* Backwards compat. */ -#define FF_CEIL_RSHIFT AV_CEIL_RSHIFT - -#define FFUDIV(a,b) (((a)>0 ?(a):(a)-(b)+1) / (b)) -#define FFUMOD(a,b) ((a)-(b)*FFUDIV(a,b)) - -/** - * Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they - * are not representable as absolute values of their type. This is the same - * as with *abs() - * @see FFNABS() - */ -#define FFABS(a) ((a) >= 0 ? (a) : (-(a))) -#define FFSIGN(a) ((a) > 0 ? 1 : -1) - -/** - * Negative Absolute value. - * this works for all integers of all types. - * As with many macros, this evaluates its argument twice, it thus must not have - * a sideeffect, that is FFNABS(x++) has undefined behavior. - */ -#define FFNABS(a) ((a) <= 0 ? (a) : (-(a))) - -/** - * Comparator. - * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0 - * if x == y. This is useful for instance in a qsort comparator callback. - * Furthermore, compilers are able to optimize this to branchless code, and - * there is no risk of overflow with signed types. - * As with many macros, this evaluates its argument multiple times, it thus - * must not have a side-effect. - */ -#define FFDIFFSIGN(x,y) (((x)>(y)) - ((x)<(y))) - -#define FFMAX(a,b) ((a) > (b) ? (a) : (b)) -#define FFMAX3(a,b,c) FFMAX(FFMAX(a,b),c) -#define FFMIN(a,b) ((a) > (b) ? (b) : (a)) -#define FFMIN3(a,b,c) FFMIN(FFMIN(a,b),c) - -#define FFSWAP(type,a,b) do{type SWAP_tmp= b; b= a; a= SWAP_tmp;}while(0) -#define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0])) - -/* misc math functions */ - -#ifdef HAVE_AV_CONFIG_H -# include "config.h" -# include "intmath.h" -#endif - -/* Pull in unguarded fallback defines at the end of this file. */ -#include "common.h" - -#ifndef av_log2 -av_const int av_log2(unsigned v); -#endif - -#ifndef av_log2_16bit -av_const int av_log2_16bit(unsigned v); -#endif - -/** - * Clip a signed integer value into the amin-amax range. - * @param a value to clip - * @param amin minimum value of the clip range - * @param amax maximum value of the clip range - * @return clipped value - */ -static av_always_inline av_const int av_clip_c(int a, int amin, int amax) -{ -#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 - if (amin > amax) abort(); -#endif - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; -} - -/** - * Clip a signed 64bit integer value into the amin-amax range. - * @param a value to clip - * @param amin minimum value of the clip range - * @param amax maximum value of the clip range - * @return clipped value - */ -static av_always_inline av_const int64_t av_clip64_c(int64_t a, int64_t amin, int64_t amax) -{ -#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 - if (amin > amax) abort(); -#endif - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; -} - -/** - * Clip a signed integer value into the 0-255 range. - * @param a value to clip - * @return clipped value - */ -static av_always_inline av_const uint8_t av_clip_uint8_c(int a) -{ - if (a&(~0xFF)) return (~a)>>31; - else return a; -} - -/** - * Clip a signed integer value into the -128,127 range. - * @param a value to clip - * @return clipped value - */ -static av_always_inline av_const int8_t av_clip_int8_c(int a) -{ - if ((a+0x80U) & ~0xFF) return (a>>31) ^ 0x7F; - else return a; -} - -/** - * Clip a signed integer value into the 0-65535 range. - * @param a value to clip - * @return clipped value - */ -static av_always_inline av_const uint16_t av_clip_uint16_c(int a) -{ - if (a&(~0xFFFF)) return (~a)>>31; - else return a; -} - -/** - * Clip a signed integer value into the -32768,32767 range. - * @param a value to clip - * @return clipped value - */ -static av_always_inline av_const int16_t av_clip_int16_c(int a) -{ - if ((a+0x8000U) & ~0xFFFF) return (a>>31) ^ 0x7FFF; - else return a; -} - -/** - * Clip a signed 64-bit integer value into the -2147483648,2147483647 range. - * @param a value to clip - * @return clipped value - */ -static av_always_inline av_const int32_t av_clipl_int32_c(int64_t a) -{ - if ((a+0x80000000u) & ~UINT64_C(0xFFFFFFFF)) return (int32_t)((a>>63) ^ 0x7FFFFFFF); - else return (int32_t)a; -} - -/** - * Clip a signed integer into the -(2^p),(2^p-1) range. - * @param a value to clip - * @param p bit position to clip at - * @return clipped value - */ -static av_always_inline av_const int av_clip_intp2_c(int a, int p) -{ - if (((unsigned)a + (1 << p)) & ~((2 << p) - 1)) - return (a >> 31) ^ ((1 << p) - 1); - else - return a; -} - -/** - * Clip a signed integer to an unsigned power of two range. - * @param a value to clip - * @param p bit position to clip at - * @return clipped value - */ -static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p) -{ - if (a & ~((1<> 31 & ((1<= 2 - if (amin > amax) abort(); -#endif - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; -} - -/** - * Clip a double value into the amin-amax range. - * @param a value to clip - * @param amin minimum value of the clip range - * @param amax maximum value of the clip range - * @return clipped value - */ -static av_always_inline av_const double av_clipd_c(double a, double amin, double amax) -{ -#if defined(HAVE_AV_CONFIG_H) && defined(ASSERT_LEVEL) && ASSERT_LEVEL >= 2 - if (amin > amax) abort(); -#endif - if (a < amin) return amin; - else if (a > amax) return amax; - else return a; -} - -/** Compute ceil(log2(x)). - * @param x value used to compute ceil(log2(x)) - * @return computed ceiling of log2(x) - */ -static av_always_inline av_const int av_ceil_log2_c(int x) -{ - return av_log2((x - 1) << 1); -} - -/** - * Count number of bits set to one in x - * @param x value to count bits of - * @return the number of bits set to one in x - */ -static av_always_inline av_const int av_popcount_c(uint32_t x) -{ - x -= (x >> 1) & 0x55555555; - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - x = (x + (x >> 4)) & 0x0F0F0F0F; - x += x >> 8; - return (x + (x >> 16)) & 0x3F; -} - -/** - * Count number of bits set to one in x - * @param x value to count bits of - * @return the number of bits set to one in x - */ -static av_always_inline av_const int av_popcount64_c(uint64_t x) -{ - return av_popcount((uint32_t)x) + av_popcount((uint32_t)(x >> 32)); -} - -static av_always_inline av_const int av_parity_c(uint32_t v) -{ - return av_popcount(v) & 1; -} - -#define MKTAG(a,b,c,d) ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24)) -#define MKBETAG(a,b,c,d) ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24)) - -/** - * Convert a UTF-8 character (up to 4 bytes) to its 32-bit UCS-4 encoded form. - * - * @param val Output value, must be an lvalue of type uint32_t. - * @param GET_BYTE Expression reading one byte from the input. - * Evaluated up to 7 times (4 for the currently - * assigned Unicode range). With a memory buffer - * input, this could be *ptr++. - * @param ERROR Expression to be evaluated on invalid input, - * typically a goto statement. - * - * @warning ERROR should not contain a loop control statement which - * could interact with the internal while loop, and should force an - * exit from the macro code (e.g. through a goto or a return) in order - * to prevent undefined results. - */ -#define GET_UTF8(val, GET_BYTE, ERROR)\ - val= (GET_BYTE);\ - {\ - uint32_t top = (val & 128) >> 1;\ - if ((val & 0xc0) == 0x80 || val >= 0xFE)\ - ERROR\ - while (val & top) {\ - int tmp= (GET_BYTE) - 128;\ - if(tmp>>6)\ - ERROR\ - val= (val<<6) + tmp;\ - top <<= 5;\ - }\ - val &= (top << 1) - 1;\ - } - -/** - * Convert a UTF-16 character (2 or 4 bytes) to its 32-bit UCS-4 encoded form. - * - * @param val Output value, must be an lvalue of type uint32_t. - * @param GET_16BIT Expression returning two bytes of UTF-16 data converted - * to native byte order. Evaluated one or two times. - * @param ERROR Expression to be evaluated on invalid input, - * typically a goto statement. - */ -#define GET_UTF16(val, GET_16BIT, ERROR)\ - val = GET_16BIT;\ - {\ - unsigned int hi = val - 0xD800;\ - if (hi < 0x800) {\ - val = GET_16BIT - 0xDC00;\ - if (val > 0x3FFU || hi > 0x3FFU)\ - ERROR\ - val += (hi<<10) + 0x10000;\ - }\ - }\ - -/** - * @def PUT_UTF8(val, tmp, PUT_BYTE) - * Convert a 32-bit Unicode character to its UTF-8 encoded form (up to 4 bytes long). - * @param val is an input-only argument and should be of type uint32_t. It holds - * a UCS-4 encoded Unicode character that is to be converted to UTF-8. If - * val is given as a function it is executed only once. - * @param tmp is a temporary variable and should be of type uint8_t. It - * represents an intermediate value during conversion that is to be - * output by PUT_BYTE. - * @param PUT_BYTE writes the converted UTF-8 bytes to any proper destination. - * It could be a function or a statement, and uses tmp as the input byte. - * For example, PUT_BYTE could be "*output++ = tmp;" PUT_BYTE will be - * executed up to 4 times for values in the valid UTF-8 range and up to - * 7 times in the general case, depending on the length of the converted - * Unicode character. - */ -#define PUT_UTF8(val, tmp, PUT_BYTE)\ - {\ - int bytes, shift;\ - uint32_t in = val;\ - if (in < 0x80) {\ - tmp = in;\ - PUT_BYTE\ - } else {\ - bytes = (av_log2(in) + 4) / 5;\ - shift = (bytes - 1) * 6;\ - tmp = (256 - (256 >> bytes)) | (in >> shift);\ - PUT_BYTE\ - while (shift >= 6) {\ - shift -= 6;\ - tmp = 0x80 | ((in >> shift) & 0x3f);\ - PUT_BYTE\ - }\ - }\ - } - -/** - * @def PUT_UTF16(val, tmp, PUT_16BIT) - * Convert a 32-bit Unicode character to its UTF-16 encoded form (2 or 4 bytes). - * @param val is an input-only argument and should be of type uint32_t. It holds - * a UCS-4 encoded Unicode character that is to be converted to UTF-16. If - * val is given as a function it is executed only once. - * @param tmp is a temporary variable and should be of type uint16_t. It - * represents an intermediate value during conversion that is to be - * output by PUT_16BIT. - * @param PUT_16BIT writes the converted UTF-16 data to any proper destination - * in desired endianness. It could be a function or a statement, and uses tmp - * as the input byte. For example, PUT_BYTE could be "*output++ = tmp;" - * PUT_BYTE will be executed 1 or 2 times depending on input character. - */ -#define PUT_UTF16(val, tmp, PUT_16BIT)\ - {\ - uint32_t in = val;\ - if (in < 0x10000) {\ - tmp = in;\ - PUT_16BIT\ - } else {\ - tmp = 0xD800 | ((in - 0x10000) >> 10);\ - PUT_16BIT\ - tmp = 0xDC00 | ((in - 0x10000) & 0x3FF);\ - PUT_16BIT\ - }\ - }\ - - - -#include "mem.h" - -#ifdef HAVE_AV_CONFIG_H -# include "internal.h" -#endif /* HAVE_AV_CONFIG_H */ - -#endif /* AVUTIL_COMMON_H */ - -/* - * The following definitions are outside the multiple inclusion guard - * to ensure they are immediately available in intmath.h. - */ - -#ifndef av_ceil_log2 -# define av_ceil_log2 av_ceil_log2_c -#endif -#ifndef av_clip -# define av_clip av_clip_c -#endif -#ifndef av_clip64 -# define av_clip64 av_clip64_c -#endif -#ifndef av_clip_uint8 -# define av_clip_uint8 av_clip_uint8_c -#endif -#ifndef av_clip_int8 -# define av_clip_int8 av_clip_int8_c -#endif -#ifndef av_clip_uint16 -# define av_clip_uint16 av_clip_uint16_c -#endif -#ifndef av_clip_int16 -# define av_clip_int16 av_clip_int16_c -#endif -#ifndef av_clipl_int32 -# define av_clipl_int32 av_clipl_int32_c -#endif -#ifndef av_clip_intp2 -# define av_clip_intp2 av_clip_intp2_c -#endif -#ifndef av_clip_uintp2 -# define av_clip_uintp2 av_clip_uintp2_c -#endif -#ifndef av_mod_uintp2 -# define av_mod_uintp2 av_mod_uintp2_c -#endif -#ifndef av_sat_add32 -# define av_sat_add32 av_sat_add32_c -#endif -#ifndef av_sat_dadd32 -# define av_sat_dadd32 av_sat_dadd32_c -#endif -#ifndef av_sat_sub32 -# define av_sat_sub32 av_sat_sub32_c -#endif -#ifndef av_sat_dsub32 -# define av_sat_dsub32 av_sat_dsub32_c -#endif -#ifndef av_clipf -# define av_clipf av_clipf_c -#endif -#ifndef av_clipd -# define av_clipd av_clipd_c -#endif -#ifndef av_popcount -# define av_popcount av_popcount_c -#endif -#ifndef av_popcount64 -# define av_popcount64 av_popcount64_c -#endif -#ifndef av_parity -# define av_parity av_parity_c -#endif diff --git a/maclibs/include/libavutil/cpu.h b/maclibs/include/libavutil/cpu.h deleted file mode 100644 index 8bb9eb60..00000000 --- a/maclibs/include/libavutil/cpu.h +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2000, 2001, 2002 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_CPU_H -#define AVUTIL_CPU_H - -#include - -#include "attributes.h" - -#define AV_CPU_FLAG_FORCE 0x80000000 /* force usage of selected flags (OR) */ - - /* lower 16 bits - CPU features */ -#define AV_CPU_FLAG_MMX 0x0001 ///< standard MMX -#define AV_CPU_FLAG_MMXEXT 0x0002 ///< SSE integer functions or AMD MMX ext -#define AV_CPU_FLAG_MMX2 0x0002 ///< SSE integer functions or AMD MMX ext -#define AV_CPU_FLAG_3DNOW 0x0004 ///< AMD 3DNOW -#define AV_CPU_FLAG_SSE 0x0008 ///< SSE functions -#define AV_CPU_FLAG_SSE2 0x0010 ///< PIV SSE2 functions -#define AV_CPU_FLAG_SSE2SLOW 0x40000000 ///< SSE2 supported, but usually not faster - ///< than regular MMX/SSE (e.g. Core1) -#define AV_CPU_FLAG_3DNOWEXT 0x0020 ///< AMD 3DNowExt -#define AV_CPU_FLAG_SSE3 0x0040 ///< Prescott SSE3 functions -#define AV_CPU_FLAG_SSE3SLOW 0x20000000 ///< SSE3 supported, but usually not faster - ///< than regular MMX/SSE (e.g. Core1) -#define AV_CPU_FLAG_SSSE3 0x0080 ///< Conroe SSSE3 functions -#define AV_CPU_FLAG_SSSE3SLOW 0x4000000 ///< SSSE3 supported, but usually not faster -#define AV_CPU_FLAG_ATOM 0x10000000 ///< Atom processor, some SSSE3 instructions are slower -#define AV_CPU_FLAG_SSE4 0x0100 ///< Penryn SSE4.1 functions -#define AV_CPU_FLAG_SSE42 0x0200 ///< Nehalem SSE4.2 functions -#define AV_CPU_FLAG_AESNI 0x80000 ///< Advanced Encryption Standard functions -#define AV_CPU_FLAG_AVX 0x4000 ///< AVX functions: requires OS support even if YMM registers aren't used -#define AV_CPU_FLAG_AVXSLOW 0x8000000 ///< AVX supported, but slow when using YMM registers (e.g. Bulldozer) -#define AV_CPU_FLAG_XOP 0x0400 ///< Bulldozer XOP functions -#define AV_CPU_FLAG_FMA4 0x0800 ///< Bulldozer FMA4 functions -#define AV_CPU_FLAG_CMOV 0x1000 ///< supports cmov instruction -#define AV_CPU_FLAG_AVX2 0x8000 ///< AVX2 functions: requires OS support even if YMM registers aren't used -#define AV_CPU_FLAG_FMA3 0x10000 ///< Haswell FMA3 functions -#define AV_CPU_FLAG_BMI1 0x20000 ///< Bit Manipulation Instruction Set 1 -#define AV_CPU_FLAG_BMI2 0x40000 ///< Bit Manipulation Instruction Set 2 -#define AV_CPU_FLAG_AVX512 0x100000 ///< AVX-512 functions: requires OS support even if YMM/ZMM registers aren't used - -#define AV_CPU_FLAG_ALTIVEC 0x0001 ///< standard -#define AV_CPU_FLAG_VSX 0x0002 ///< ISA 2.06 -#define AV_CPU_FLAG_POWER8 0x0004 ///< ISA 2.07 - -#define AV_CPU_FLAG_ARMV5TE (1 << 0) -#define AV_CPU_FLAG_ARMV6 (1 << 1) -#define AV_CPU_FLAG_ARMV6T2 (1 << 2) -#define AV_CPU_FLAG_VFP (1 << 3) -#define AV_CPU_FLAG_VFPV3 (1 << 4) -#define AV_CPU_FLAG_NEON (1 << 5) -#define AV_CPU_FLAG_ARMV8 (1 << 6) -#define AV_CPU_FLAG_VFP_VM (1 << 7) ///< VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations -#define AV_CPU_FLAG_SETEND (1 <<16) - -/** - * Return the flags which specify extensions supported by the CPU. - * The returned value is affected by av_force_cpu_flags() if that was used - * before. So av_get_cpu_flags() can easily be used in an application to - * detect the enabled cpu flags. - */ -int av_get_cpu_flags(void); - -/** - * Disables cpu detection and forces the specified flags. - * -1 is a special case that disables forcing of specific flags. - */ -void av_force_cpu_flags(int flags); - -/** - * Set a mask on flags returned by av_get_cpu_flags(). - * This function is mainly useful for testing. - * Please use av_force_cpu_flags() and av_get_cpu_flags() instead which are more flexible - */ -attribute_deprecated void av_set_cpu_flags_mask(int mask); - -/** - * Parse CPU flags from a string. - * - * The returned flags contain the specified flags as well as related unspecified flags. - * - * This function exists only for compatibility with libav. - * Please use av_parse_cpu_caps() when possible. - * @return a combination of AV_CPU_* flags, negative on error. - */ -attribute_deprecated -int av_parse_cpu_flags(const char *s); - -/** - * Parse CPU caps from a string and update the given AV_CPU_* flags based on that. - * - * @return negative on error. - */ -int av_parse_cpu_caps(unsigned *flags, const char *s); - -/** - * @return the number of logical CPU cores present. - */ -int av_cpu_count(void); - -/** - * Get the maximum data alignment that may be required by FFmpeg. - * - * Note that this is affected by the build configuration and the CPU flags mask, - * so e.g. if the CPU supports AVX, but libavutil has been built with - * --disable-avx or the AV_CPU_FLAG_AVX flag has been disabled through - * av_set_cpu_flags_mask(), then this function will behave as if AVX is not - * present. - */ -size_t av_cpu_max_align(void); - -#endif /* AVUTIL_CPU_H */ diff --git a/maclibs/include/libavutil/dict.h b/maclibs/include/libavutil/dict.h deleted file mode 100644 index 118f1f00..00000000 --- a/maclibs/include/libavutil/dict.h +++ /dev/null @@ -1,200 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * Public dictionary API. - * @deprecated - * AVDictionary is provided for compatibility with libav. It is both in - * implementation as well as API inefficient. It does not scale and is - * extremely slow with large dictionaries. - * It is recommended that new code uses our tree container from tree.c/h - * where applicable, which uses AVL trees to achieve O(log n) performance. - */ - -#ifndef AVUTIL_DICT_H -#define AVUTIL_DICT_H - -#include - -#include "version.h" - -/** - * @addtogroup lavu_dict AVDictionary - * @ingroup lavu_data - * - * @brief Simple key:value store - * - * @{ - * Dictionaries are used for storing key:value pairs. To create - * an AVDictionary, simply pass an address of a NULL pointer to - * av_dict_set(). NULL can be used as an empty dictionary wherever - * a pointer to an AVDictionary is required. - * Use av_dict_get() to retrieve an entry or iterate over all - * entries and finally av_dict_free() to free the dictionary - * and all its contents. - * - @code - AVDictionary *d = NULL; // "create" an empty dictionary - AVDictionaryEntry *t = NULL; - - av_dict_set(&d, "foo", "bar", 0); // add an entry - - char *k = av_strdup("key"); // if your strings are already allocated, - char *v = av_strdup("value"); // you can avoid copying them like this - av_dict_set(&d, k, v, AV_DICT_DONT_STRDUP_KEY | AV_DICT_DONT_STRDUP_VAL); - - while (t = av_dict_get(d, "", t, AV_DICT_IGNORE_SUFFIX)) { - <....> // iterate over all entries in d - } - av_dict_free(&d); - @endcode - */ - -#define AV_DICT_MATCH_CASE 1 /**< Only get an entry with exact-case key match. Only relevant in av_dict_get(). */ -#define AV_DICT_IGNORE_SUFFIX 2 /**< Return first entry in a dictionary whose first part corresponds to the search key, - ignoring the suffix of the found key string. Only relevant in av_dict_get(). */ -#define AV_DICT_DONT_STRDUP_KEY 4 /**< Take ownership of a key that's been - allocated with av_malloc() or another memory allocation function. */ -#define AV_DICT_DONT_STRDUP_VAL 8 /**< Take ownership of a value that's been - allocated with av_malloc() or another memory allocation function. */ -#define AV_DICT_DONT_OVERWRITE 16 ///< Don't overwrite existing entries. -#define AV_DICT_APPEND 32 /**< If the entry already exists, append to it. Note that no - delimiter is added, the strings are simply concatenated. */ -#define AV_DICT_MULTIKEY 64 /**< Allow to store several equal keys in the dictionary */ - -typedef struct AVDictionaryEntry { - char *key; - char *value; -} AVDictionaryEntry; - -typedef struct AVDictionary AVDictionary; - -/** - * Get a dictionary entry with matching key. - * - * The returned entry key or value must not be changed, or it will - * cause undefined behavior. - * - * To iterate through all the dictionary entries, you can set the matching key - * to the null string "" and set the AV_DICT_IGNORE_SUFFIX flag. - * - * @param prev Set to the previous matching element to find the next. - * If set to NULL the first matching element is returned. - * @param key matching key - * @param flags a collection of AV_DICT_* flags controlling how the entry is retrieved - * @return found entry or NULL in case no matching entry was found in the dictionary - */ -AVDictionaryEntry *av_dict_get(const AVDictionary *m, const char *key, - const AVDictionaryEntry *prev, int flags); - -/** - * Get number of entries in dictionary. - * - * @param m dictionary - * @return number of entries in dictionary - */ -int av_dict_count(const AVDictionary *m); - -/** - * Set the given entry in *pm, overwriting an existing entry. - * - * Note: If AV_DICT_DONT_STRDUP_KEY or AV_DICT_DONT_STRDUP_VAL is set, - * these arguments will be freed on error. - * - * Warning: Adding a new entry to a dictionary invalidates all existing entries - * previously returned with av_dict_get. - * - * @param pm pointer to a pointer to a dictionary struct. If *pm is NULL - * a dictionary struct is allocated and put in *pm. - * @param key entry key to add to *pm (will either be av_strduped or added as a new key depending on flags) - * @param value entry value to add to *pm (will be av_strduped or added as a new key depending on flags). - * Passing a NULL value will cause an existing entry to be deleted. - * @return >= 0 on success otherwise an error code <0 - */ -int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags); - -/** - * Convenience wrapper for av_dict_set that converts the value to a string - * and stores it. - * - * Note: If AV_DICT_DONT_STRDUP_KEY is set, key will be freed on error. - */ -int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags); - -/** - * Parse the key/value pairs list and add the parsed entries to a dictionary. - * - * In case of failure, all the successfully set entries are stored in - * *pm. You may need to manually free the created dictionary. - * - * @param key_val_sep a 0-terminated list of characters used to separate - * key from value - * @param pairs_sep a 0-terminated list of characters used to separate - * two pairs from each other - * @param flags flags to use when adding to dictionary. - * AV_DICT_DONT_STRDUP_KEY and AV_DICT_DONT_STRDUP_VAL - * are ignored since the key/value tokens will always - * be duplicated. - * @return 0 on success, negative AVERROR code on failure - */ -int av_dict_parse_string(AVDictionary **pm, const char *str, - const char *key_val_sep, const char *pairs_sep, - int flags); - -/** - * Copy entries from one AVDictionary struct into another. - * @param dst pointer to a pointer to a AVDictionary struct. If *dst is NULL, - * this function will allocate a struct for you and put it in *dst - * @param src pointer to source AVDictionary struct - * @param flags flags to use when setting entries in *dst - * @note metadata is read using the AV_DICT_IGNORE_SUFFIX flag - * @return 0 on success, negative AVERROR code on failure. If dst was allocated - * by this function, callers should free the associated memory. - */ -int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags); - -/** - * Free all the memory allocated for an AVDictionary struct - * and all keys and values. - */ -void av_dict_free(AVDictionary **m); - -/** - * Get dictionary entries as a string. - * - * Create a string containing dictionary's entries. - * Such string may be passed back to av_dict_parse_string(). - * @note String is escaped with backslashes ('\'). - * - * @param[in] m dictionary - * @param[out] buffer Pointer to buffer that will be allocated with string containg entries. - * Buffer must be freed by the caller when is no longer needed. - * @param[in] key_val_sep character used to separate key from value - * @param[in] pairs_sep character used to separate two pairs from each other - * @return >= 0 on success, negative on error - * @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same. - */ -int av_dict_get_string(const AVDictionary *m, char **buffer, - const char key_val_sep, const char pairs_sep); - -/** - * @} - */ - -#endif /* AVUTIL_DICT_H */ diff --git a/maclibs/include/libavutil/error.h b/maclibs/include/libavutil/error.h deleted file mode 100644 index 71df4da3..00000000 --- a/maclibs/include/libavutil/error.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * error code definitions - */ - -#ifndef AVUTIL_ERROR_H -#define AVUTIL_ERROR_H - -#include -#include - -/** - * @addtogroup lavu_error - * - * @{ - */ - - -/* error handling */ -#if EDOM > 0 -#define AVERROR(e) (-(e)) ///< Returns a negative error code from a POSIX error code, to return from library functions. -#define AVUNERROR(e) (-(e)) ///< Returns a POSIX error code from a library function error return value. -#else -/* Some platforms have E* and errno already negated. */ -#define AVERROR(e) (e) -#define AVUNERROR(e) (e) -#endif - -#define FFERRTAG(a, b, c, d) (-(int)MKTAG(a, b, c, d)) - -#define AVERROR_BSF_NOT_FOUND FFERRTAG(0xF8,'B','S','F') ///< Bitstream filter not found -#define AVERROR_BUG FFERRTAG( 'B','U','G','!') ///< Internal bug, also see AVERROR_BUG2 -#define AVERROR_BUFFER_TOO_SMALL FFERRTAG( 'B','U','F','S') ///< Buffer too small -#define AVERROR_DECODER_NOT_FOUND FFERRTAG(0xF8,'D','E','C') ///< Decoder not found -#define AVERROR_DEMUXER_NOT_FOUND FFERRTAG(0xF8,'D','E','M') ///< Demuxer not found -#define AVERROR_ENCODER_NOT_FOUND FFERRTAG(0xF8,'E','N','C') ///< Encoder not found -#define AVERROR_EOF FFERRTAG( 'E','O','F',' ') ///< End of file -#define AVERROR_EXIT FFERRTAG( 'E','X','I','T') ///< Immediate exit was requested; the called function should not be restarted -#define AVERROR_EXTERNAL FFERRTAG( 'E','X','T',' ') ///< Generic error in an external library -#define AVERROR_FILTER_NOT_FOUND FFERRTAG(0xF8,'F','I','L') ///< Filter not found -#define AVERROR_INVALIDDATA FFERRTAG( 'I','N','D','A') ///< Invalid data found when processing input -#define AVERROR_MUXER_NOT_FOUND FFERRTAG(0xF8,'M','U','X') ///< Muxer not found -#define AVERROR_OPTION_NOT_FOUND FFERRTAG(0xF8,'O','P','T') ///< Option not found -#define AVERROR_PATCHWELCOME FFERRTAG( 'P','A','W','E') ///< Not yet implemented in FFmpeg, patches welcome -#define AVERROR_PROTOCOL_NOT_FOUND FFERRTAG(0xF8,'P','R','O') ///< Protocol not found - -#define AVERROR_STREAM_NOT_FOUND FFERRTAG(0xF8,'S','T','R') ///< Stream not found -/** - * This is semantically identical to AVERROR_BUG - * it has been introduced in Libav after our AVERROR_BUG and with a modified value. - */ -#define AVERROR_BUG2 FFERRTAG( 'B','U','G',' ') -#define AVERROR_UNKNOWN FFERRTAG( 'U','N','K','N') ///< Unknown error, typically from an external library -#define AVERROR_EXPERIMENTAL (-0x2bb2afa8) ///< Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it. -#define AVERROR_INPUT_CHANGED (-0x636e6701) ///< Input changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_OUTPUT_CHANGED) -#define AVERROR_OUTPUT_CHANGED (-0x636e6702) ///< Output changed between calls. Reconfiguration is required. (can be OR-ed with AVERROR_INPUT_CHANGED) -/* HTTP & RTSP errors */ -#define AVERROR_HTTP_BAD_REQUEST FFERRTAG(0xF8,'4','0','0') -#define AVERROR_HTTP_UNAUTHORIZED FFERRTAG(0xF8,'4','0','1') -#define AVERROR_HTTP_FORBIDDEN FFERRTAG(0xF8,'4','0','3') -#define AVERROR_HTTP_NOT_FOUND FFERRTAG(0xF8,'4','0','4') -#define AVERROR_HTTP_OTHER_4XX FFERRTAG(0xF8,'4','X','X') -#define AVERROR_HTTP_SERVER_ERROR FFERRTAG(0xF8,'5','X','X') - -#define AV_ERROR_MAX_STRING_SIZE 64 - -/** - * Put a description of the AVERROR code errnum in errbuf. - * In case of failure the global variable errno is set to indicate the - * error. Even in case of failure av_strerror() will print a generic - * error message indicating the errnum provided to errbuf. - * - * @param errnum error code to describe - * @param errbuf buffer to which description is written - * @param errbuf_size the size in bytes of errbuf - * @return 0 on success, a negative value if a description for errnum - * cannot be found - */ -int av_strerror(int errnum, char *errbuf, size_t errbuf_size); - -/** - * Fill the provided buffer with a string containing an error string - * corresponding to the AVERROR code errnum. - * - * @param errbuf a buffer - * @param errbuf_size size in bytes of errbuf - * @param errnum error code to describe - * @return the buffer in input, filled with the error description - * @see av_strerror() - */ -static inline char *av_make_error_string(char *errbuf, size_t errbuf_size, int errnum) -{ - av_strerror(errnum, errbuf, errbuf_size); - return errbuf; -} - -/** - * Convenience macro, the return value should be used only directly in - * function arguments but never stand-alone. - */ -#define av_err2str(errnum) \ - av_make_error_string((char[AV_ERROR_MAX_STRING_SIZE]){0}, AV_ERROR_MAX_STRING_SIZE, errnum) - -/** - * @} - */ - -#endif /* AVUTIL_ERROR_H */ diff --git a/maclibs/include/libavutil/frame.h b/maclibs/include/libavutil/frame.h deleted file mode 100644 index 5d3231e7..00000000 --- a/maclibs/include/libavutil/frame.h +++ /dev/null @@ -1,971 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * @ingroup lavu_frame - * reference-counted frame API - */ - -#ifndef AVUTIL_FRAME_H -#define AVUTIL_FRAME_H - -#include -#include - -#include "avutil.h" -#include "buffer.h" -#include "dict.h" -#include "rational.h" -#include "samplefmt.h" -#include "pixfmt.h" -#include "version.h" - - -/** - * @defgroup lavu_frame AVFrame - * @ingroup lavu_data - * - * @{ - * AVFrame is an abstraction for reference-counted raw multimedia data. - */ - -enum AVFrameSideDataType { - /** - * The data is the AVPanScan struct defined in libavcodec. - */ - AV_FRAME_DATA_PANSCAN, - /** - * ATSC A53 Part 4 Closed Captions. - * A53 CC bitstream is stored as uint8_t in AVFrameSideData.data. - * The number of bytes of CC data is AVFrameSideData.size. - */ - AV_FRAME_DATA_A53_CC, - /** - * Stereoscopic 3d metadata. - * The data is the AVStereo3D struct defined in libavutil/stereo3d.h. - */ - AV_FRAME_DATA_STEREO3D, - /** - * The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h. - */ - AV_FRAME_DATA_MATRIXENCODING, - /** - * Metadata relevant to a downmix procedure. - * The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h. - */ - AV_FRAME_DATA_DOWNMIX_INFO, - /** - * ReplayGain information in the form of the AVReplayGain struct. - */ - AV_FRAME_DATA_REPLAYGAIN, - /** - * This side data contains a 3x3 transformation matrix describing an affine - * transformation that needs to be applied to the frame for correct - * presentation. - * - * See libavutil/display.h for a detailed description of the data. - */ - AV_FRAME_DATA_DISPLAYMATRIX, - /** - * Active Format Description data consisting of a single byte as specified - * in ETSI TS 101 154 using AVActiveFormatDescription enum. - */ - AV_FRAME_DATA_AFD, - /** - * Motion vectors exported by some codecs (on demand through the export_mvs - * flag set in the libavcodec AVCodecContext flags2 option). - * The data is the AVMotionVector struct defined in - * libavutil/motion_vector.h. - */ - AV_FRAME_DATA_MOTION_VECTORS, - /** - * Recommmends skipping the specified number of samples. This is exported - * only if the "skip_manual" AVOption is set in libavcodec. - * This has the same format as AV_PKT_DATA_SKIP_SAMPLES. - * @code - * u32le number of samples to skip from start of this packet - * u32le number of samples to skip from end of this packet - * u8 reason for start skip - * u8 reason for end skip (0=padding silence, 1=convergence) - * @endcode - */ - AV_FRAME_DATA_SKIP_SAMPLES, - /** - * This side data must be associated with an audio frame and corresponds to - * enum AVAudioServiceType defined in avcodec.h. - */ - AV_FRAME_DATA_AUDIO_SERVICE_TYPE, - /** - * Mastering display metadata associated with a video frame. The payload is - * an AVMasteringDisplayMetadata type and contains information about the - * mastering display color volume. - */ - AV_FRAME_DATA_MASTERING_DISPLAY_METADATA, - /** - * The GOP timecode in 25 bit timecode format. Data format is 64-bit integer. - * This is set on the first frame of a GOP that has a temporal reference of 0. - */ - AV_FRAME_DATA_GOP_TIMECODE, - - /** - * The data represents the AVSphericalMapping structure defined in - * libavutil/spherical.h. - */ - AV_FRAME_DATA_SPHERICAL, - - /** - * Content light level (based on CTA-861.3). This payload contains data in - * the form of the AVContentLightMetadata struct. - */ - AV_FRAME_DATA_CONTENT_LIGHT_LEVEL, - - /** - * The data contains an ICC profile as an opaque octet buffer following the - * format described by ISO 15076-1 with an optional name defined in the - * metadata key entry "name". - */ - AV_FRAME_DATA_ICC_PROFILE, - -#if FF_API_FRAME_QP - /** - * Implementation-specific description of the format of AV_FRAME_QP_TABLE_DATA. - * The contents of this side data are undocumented and internal; use - * av_frame_set_qp_table() and av_frame_get_qp_table() to access this in a - * meaningful way instead. - */ - AV_FRAME_DATA_QP_TABLE_PROPERTIES, - - /** - * Raw QP table data. Its format is described by - * AV_FRAME_DATA_QP_TABLE_PROPERTIES. Use av_frame_set_qp_table() and - * av_frame_get_qp_table() to access this instead. - */ - AV_FRAME_DATA_QP_TABLE_DATA, -#endif - - /** - * Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t - * where the first uint32_t describes how many (1-3) of the other timecodes are used. - * The timecode format is described in the av_timecode_get_smpte_from_framenum() - * function in libavutil/timecode.c. - */ - AV_FRAME_DATA_S12M_TIMECODE, - - /** - * HDR dynamic metadata associated with a video frame. The payload is - * an AVDynamicHDRPlus type and contains information for color - * volume transform - application 4 of SMPTE 2094-40:2016 standard. - */ - AV_FRAME_DATA_DYNAMIC_HDR_PLUS, - - /** - * Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of - * array element is implied by AVFrameSideData.size / AVRegionOfInterest.self_size. - */ - AV_FRAME_DATA_REGIONS_OF_INTEREST, -}; - -enum AVActiveFormatDescription { - AV_AFD_SAME = 8, - AV_AFD_4_3 = 9, - AV_AFD_16_9 = 10, - AV_AFD_14_9 = 11, - AV_AFD_4_3_SP_14_9 = 13, - AV_AFD_16_9_SP_14_9 = 14, - AV_AFD_SP_4_3 = 15, -}; - - -/** - * Structure to hold side data for an AVFrame. - * - * sizeof(AVFrameSideData) is not a part of the public ABI, so new fields may be added - * to the end with a minor bump. - */ -typedef struct AVFrameSideData { - enum AVFrameSideDataType type; - uint8_t *data; - int size; - AVDictionary *metadata; - AVBufferRef *buf; -} AVFrameSideData; - -/** - * Structure describing a single Region Of Interest. - * - * When multiple regions are defined in a single side-data block, they - * should be ordered from most to least important - some encoders are only - * capable of supporting a limited number of distinct regions, so will have - * to truncate the list. - * - * When overlapping regions are defined, the first region containing a given - * area of the frame applies. - */ -typedef struct AVRegionOfInterest { - /** - * Must be set to the size of this data structure (that is, - * sizeof(AVRegionOfInterest)). - */ - uint32_t self_size; - /** - * Distance in pixels from the top edge of the frame to the top and - * bottom edges and from the left edge of the frame to the left and - * right edges of the rectangle defining this region of interest. - * - * The constraints on a region are encoder dependent, so the region - * actually affected may be slightly larger for alignment or other - * reasons. - */ - int top; - int bottom; - int left; - int right; - /** - * Quantisation offset. - * - * Must be in the range -1 to +1. A value of zero indicates no quality - * change. A negative value asks for better quality (less quantisation), - * while a positive value asks for worse quality (greater quantisation). - * - * The range is calibrated so that the extreme values indicate the - * largest possible offset - if the rest of the frame is encoded with the - * worst possible quality, an offset of -1 indicates that this region - * should be encoded with the best possible quality anyway. Intermediate - * values are then interpolated in some codec-dependent way. - * - * For example, in 10-bit H.264 the quantisation parameter varies between - * -12 and 51. A typical qoffset value of -1/10 therefore indicates that - * this region should be encoded with a QP around one-tenth of the full - * range better than the rest of the frame. So, if most of the frame - * were to be encoded with a QP of around 30, this region would get a QP - * of around 24 (an offset of approximately -1/10 * (51 - -12) = -6.3). - * An extreme value of -1 would indicate that this region should be - * encoded with the best possible quality regardless of the treatment of - * the rest of the frame - that is, should be encoded at a QP of -12. - */ - AVRational qoffset; -} AVRegionOfInterest; - -/** - * This structure describes decoded (raw) audio or video data. - * - * AVFrame must be allocated using av_frame_alloc(). Note that this only - * allocates the AVFrame itself, the buffers for the data must be managed - * through other means (see below). - * AVFrame must be freed with av_frame_free(). - * - * AVFrame is typically allocated once and then reused multiple times to hold - * different data (e.g. a single AVFrame to hold frames received from a - * decoder). In such a case, av_frame_unref() will free any references held by - * the frame and reset it to its original clean state before it - * is reused again. - * - * The data described by an AVFrame is usually reference counted through the - * AVBuffer API. The underlying buffer references are stored in AVFrame.buf / - * AVFrame.extended_buf. An AVFrame is considered to be reference counted if at - * least one reference is set, i.e. if AVFrame.buf[0] != NULL. In such a case, - * every single data plane must be contained in one of the buffers in - * AVFrame.buf or AVFrame.extended_buf. - * There may be a single buffer for all the data, or one separate buffer for - * each plane, or anything in between. - * - * sizeof(AVFrame) is not a part of the public ABI, so new fields may be added - * to the end with a minor bump. - * - * Fields can be accessed through AVOptions, the name string used, matches the - * C structure field name for fields accessible through AVOptions. The AVClass - * for AVFrame can be obtained from avcodec_get_frame_class() - */ -typedef struct AVFrame { -#define AV_NUM_DATA_POINTERS 8 - /** - * pointer to the picture/channel planes. - * This might be different from the first allocated byte - * - * Some decoders access areas outside 0,0 - width,height, please - * see avcodec_align_dimensions2(). Some filters and swscale can read - * up to 16 bytes beyond the planes, if these filters are to be used, - * then 16 extra bytes must be allocated. - * - * NOTE: Except for hwaccel formats, pointers not needed by the format - * MUST be set to NULL. - */ - uint8_t *data[AV_NUM_DATA_POINTERS]; - - /** - * For video, size in bytes of each picture line. - * For audio, size in bytes of each plane. - * - * For audio, only linesize[0] may be set. For planar audio, each channel - * plane must be the same size. - * - * For video the linesizes should be multiples of the CPUs alignment - * preference, this is 16 or 32 for modern desktop CPUs. - * Some code requires such alignment other code can be slower without - * correct alignment, for yet other it makes no difference. - * - * @note The linesize may be larger than the size of usable data -- there - * may be extra padding present for performance reasons. - */ - int linesize[AV_NUM_DATA_POINTERS]; - - /** - * pointers to the data planes/channels. - * - * For video, this should simply point to data[]. - * - * For planar audio, each channel has a separate data pointer, and - * linesize[0] contains the size of each channel buffer. - * For packed audio, there is just one data pointer, and linesize[0] - * contains the total size of the buffer for all channels. - * - * Note: Both data and extended_data should always be set in a valid frame, - * but for planar audio with more channels that can fit in data, - * extended_data must be used in order to access all channels. - */ - uint8_t **extended_data; - - /** - * @name Video dimensions - * Video frames only. The coded dimensions (in pixels) of the video frame, - * i.e. the size of the rectangle that contains some well-defined values. - * - * @note The part of the frame intended for display/presentation is further - * restricted by the @ref cropping "Cropping rectangle". - * @{ - */ - int width, height; - /** - * @} - */ - - /** - * number of audio samples (per channel) described by this frame - */ - int nb_samples; - - /** - * format of the frame, -1 if unknown or unset - * Values correspond to enum AVPixelFormat for video frames, - * enum AVSampleFormat for audio) - */ - int format; - - /** - * 1 -> keyframe, 0-> not - */ - int key_frame; - - /** - * Picture type of the frame. - */ - enum AVPictureType pict_type; - - /** - * Sample aspect ratio for the video frame, 0/1 if unknown/unspecified. - */ - AVRational sample_aspect_ratio; - - /** - * Presentation timestamp in time_base units (time when frame should be shown to user). - */ - int64_t pts; - -#if FF_API_PKT_PTS - /** - * PTS copied from the AVPacket that was decoded to produce this frame. - * @deprecated use the pts field instead - */ - attribute_deprecated - int64_t pkt_pts; -#endif - - /** - * DTS copied from the AVPacket that triggered returning this frame. (if frame threading isn't used) - * This is also the Presentation time of this AVFrame calculated from - * only AVPacket.dts values without pts values. - */ - int64_t pkt_dts; - - /** - * picture number in bitstream order - */ - int coded_picture_number; - /** - * picture number in display order - */ - int display_picture_number; - - /** - * quality (between 1 (good) and FF_LAMBDA_MAX (bad)) - */ - int quality; - - /** - * for some private data of the user - */ - void *opaque; - -#if FF_API_ERROR_FRAME - /** - * @deprecated unused - */ - attribute_deprecated - uint64_t error[AV_NUM_DATA_POINTERS]; -#endif - - /** - * When decoding, this signals how much the picture must be delayed. - * extra_delay = repeat_pict / (2*fps) - */ - int repeat_pict; - - /** - * The content of the picture is interlaced. - */ - int interlaced_frame; - - /** - * If the content is interlaced, is top field displayed first. - */ - int top_field_first; - - /** - * Tell user application that palette has changed from previous frame. - */ - int palette_has_changed; - - /** - * reordered opaque 64 bits (generally an integer or a double precision float - * PTS but can be anything). - * The user sets AVCodecContext.reordered_opaque to represent the input at - * that time, - * the decoder reorders values as needed and sets AVFrame.reordered_opaque - * to exactly one of the values provided by the user through AVCodecContext.reordered_opaque - */ - int64_t reordered_opaque; - - /** - * Sample rate of the audio data. - */ - int sample_rate; - - /** - * Channel layout of the audio data. - */ - uint64_t channel_layout; - - /** - * AVBuffer references backing the data for this frame. If all elements of - * this array are NULL, then this frame is not reference counted. This array - * must be filled contiguously -- if buf[i] is non-NULL then buf[j] must - * also be non-NULL for all j < i. - * - * There may be at most one AVBuffer per data plane, so for video this array - * always contains all the references. For planar audio with more than - * AV_NUM_DATA_POINTERS channels, there may be more buffers than can fit in - * this array. Then the extra AVBufferRef pointers are stored in the - * extended_buf array. - */ - AVBufferRef *buf[AV_NUM_DATA_POINTERS]; - - /** - * For planar audio which requires more than AV_NUM_DATA_POINTERS - * AVBufferRef pointers, this array will hold all the references which - * cannot fit into AVFrame.buf. - * - * Note that this is different from AVFrame.extended_data, which always - * contains all the pointers. This array only contains the extra pointers, - * which cannot fit into AVFrame.buf. - * - * This array is always allocated using av_malloc() by whoever constructs - * the frame. It is freed in av_frame_unref(). - */ - AVBufferRef **extended_buf; - /** - * Number of elements in extended_buf. - */ - int nb_extended_buf; - - AVFrameSideData **side_data; - int nb_side_data; - -/** - * @defgroup lavu_frame_flags AV_FRAME_FLAGS - * @ingroup lavu_frame - * Flags describing additional frame properties. - * - * @{ - */ - -/** - * The frame data may be corrupted, e.g. due to decoding errors. - */ -#define AV_FRAME_FLAG_CORRUPT (1 << 0) -/** - * A flag to mark the frames which need to be decoded, but shouldn't be output. - */ -#define AV_FRAME_FLAG_DISCARD (1 << 2) -/** - * @} - */ - - /** - * Frame flags, a combination of @ref lavu_frame_flags - */ - int flags; - - /** - * MPEG vs JPEG YUV range. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorRange color_range; - - enum AVColorPrimaries color_primaries; - - enum AVColorTransferCharacteristic color_trc; - - /** - * YUV colorspace type. - * - encoding: Set by user - * - decoding: Set by libavcodec - */ - enum AVColorSpace colorspace; - - enum AVChromaLocation chroma_location; - - /** - * frame timestamp estimated using various heuristics, in stream time base - * - encoding: unused - * - decoding: set by libavcodec, read by user. - */ - int64_t best_effort_timestamp; - - /** - * reordered pos from the last AVPacket that has been input into the decoder - * - encoding: unused - * - decoding: Read by user. - */ - int64_t pkt_pos; - - /** - * duration of the corresponding packet, expressed in - * AVStream->time_base units, 0 if unknown. - * - encoding: unused - * - decoding: Read by user. - */ - int64_t pkt_duration; - - /** - * metadata. - * - encoding: Set by user. - * - decoding: Set by libavcodec. - */ - AVDictionary *metadata; - - /** - * decode error flags of the frame, set to a combination of - * FF_DECODE_ERROR_xxx flags if the decoder produced a frame, but there - * were errors during the decoding. - * - encoding: unused - * - decoding: set by libavcodec, read by user. - */ - int decode_error_flags; -#define FF_DECODE_ERROR_INVALID_BITSTREAM 1 -#define FF_DECODE_ERROR_MISSING_REFERENCE 2 -#define FF_DECODE_ERROR_CONCEALMENT_ACTIVE 4 -#define FF_DECODE_ERROR_DECODE_SLICES 8 - - /** - * number of audio channels, only used for audio. - * - encoding: unused - * - decoding: Read by user. - */ - int channels; - - /** - * size of the corresponding packet containing the compressed - * frame. - * It is set to a negative value if unknown. - * - encoding: unused - * - decoding: set by libavcodec, read by user. - */ - int pkt_size; - -#if FF_API_FRAME_QP - /** - * QP table - */ - attribute_deprecated - int8_t *qscale_table; - /** - * QP store stride - */ - attribute_deprecated - int qstride; - - attribute_deprecated - int qscale_type; - - attribute_deprecated - AVBufferRef *qp_table_buf; -#endif - /** - * For hwaccel-format frames, this should be a reference to the - * AVHWFramesContext describing the frame. - */ - AVBufferRef *hw_frames_ctx; - - /** - * AVBufferRef for free use by the API user. FFmpeg will never check the - * contents of the buffer ref. FFmpeg calls av_buffer_unref() on it when - * the frame is unreferenced. av_frame_copy_props() calls create a new - * reference with av_buffer_ref() for the target frame's opaque_ref field. - * - * This is unrelated to the opaque field, although it serves a similar - * purpose. - */ - AVBufferRef *opaque_ref; - - /** - * @anchor cropping - * @name Cropping - * Video frames only. The number of pixels to discard from the the - * top/bottom/left/right border of the frame to obtain the sub-rectangle of - * the frame intended for presentation. - * @{ - */ - size_t crop_top; - size_t crop_bottom; - size_t crop_left; - size_t crop_right; - /** - * @} - */ - - /** - * AVBufferRef for internal use by a single libav* library. - * Must not be used to transfer data between libraries. - * Has to be NULL when ownership of the frame leaves the respective library. - * - * Code outside the FFmpeg libs should never check or change the contents of the buffer ref. - * - * FFmpeg calls av_buffer_unref() on it when the frame is unreferenced. - * av_frame_copy_props() calls create a new reference with av_buffer_ref() - * for the target frame's private_ref field. - */ - AVBufferRef *private_ref; -} AVFrame; - -#if FF_API_FRAME_GET_SET -/** - * Accessors for some AVFrame fields. These used to be provided for ABI - * compatibility, and do not need to be used anymore. - */ -attribute_deprecated -int64_t av_frame_get_best_effort_timestamp(const AVFrame *frame); -attribute_deprecated -void av_frame_set_best_effort_timestamp(AVFrame *frame, int64_t val); -attribute_deprecated -int64_t av_frame_get_pkt_duration (const AVFrame *frame); -attribute_deprecated -void av_frame_set_pkt_duration (AVFrame *frame, int64_t val); -attribute_deprecated -int64_t av_frame_get_pkt_pos (const AVFrame *frame); -attribute_deprecated -void av_frame_set_pkt_pos (AVFrame *frame, int64_t val); -attribute_deprecated -int64_t av_frame_get_channel_layout (const AVFrame *frame); -attribute_deprecated -void av_frame_set_channel_layout (AVFrame *frame, int64_t val); -attribute_deprecated -int av_frame_get_channels (const AVFrame *frame); -attribute_deprecated -void av_frame_set_channels (AVFrame *frame, int val); -attribute_deprecated -int av_frame_get_sample_rate (const AVFrame *frame); -attribute_deprecated -void av_frame_set_sample_rate (AVFrame *frame, int val); -attribute_deprecated -AVDictionary *av_frame_get_metadata (const AVFrame *frame); -attribute_deprecated -void av_frame_set_metadata (AVFrame *frame, AVDictionary *val); -attribute_deprecated -int av_frame_get_decode_error_flags (const AVFrame *frame); -attribute_deprecated -void av_frame_set_decode_error_flags (AVFrame *frame, int val); -attribute_deprecated -int av_frame_get_pkt_size(const AVFrame *frame); -attribute_deprecated -void av_frame_set_pkt_size(AVFrame *frame, int val); -#if FF_API_FRAME_QP -attribute_deprecated -int8_t *av_frame_get_qp_table(AVFrame *f, int *stride, int *type); -attribute_deprecated -int av_frame_set_qp_table(AVFrame *f, AVBufferRef *buf, int stride, int type); -#endif -attribute_deprecated -enum AVColorSpace av_frame_get_colorspace(const AVFrame *frame); -attribute_deprecated -void av_frame_set_colorspace(AVFrame *frame, enum AVColorSpace val); -attribute_deprecated -enum AVColorRange av_frame_get_color_range(const AVFrame *frame); -attribute_deprecated -void av_frame_set_color_range(AVFrame *frame, enum AVColorRange val); -#endif - -/** - * Get the name of a colorspace. - * @return a static string identifying the colorspace; can be NULL. - */ -const char *av_get_colorspace_name(enum AVColorSpace val); - -/** - * Allocate an AVFrame and set its fields to default values. The resulting - * struct must be freed using av_frame_free(). - * - * @return An AVFrame filled with default values or NULL on failure. - * - * @note this only allocates the AVFrame itself, not the data buffers. Those - * must be allocated through other means, e.g. with av_frame_get_buffer() or - * manually. - */ -AVFrame *av_frame_alloc(void); - -/** - * Free the frame and any dynamically allocated objects in it, - * e.g. extended_data. If the frame is reference counted, it will be - * unreferenced first. - * - * @param frame frame to be freed. The pointer will be set to NULL. - */ -void av_frame_free(AVFrame **frame); - -/** - * Set up a new reference to the data described by the source frame. - * - * Copy frame properties from src to dst and create a new reference for each - * AVBufferRef from src. - * - * If src is not reference counted, new buffers are allocated and the data is - * copied. - * - * @warning: dst MUST have been either unreferenced with av_frame_unref(dst), - * or newly allocated with av_frame_alloc() before calling this - * function, or undefined behavior will occur. - * - * @return 0 on success, a negative AVERROR on error - */ -int av_frame_ref(AVFrame *dst, const AVFrame *src); - -/** - * Create a new frame that references the same data as src. - * - * This is a shortcut for av_frame_alloc()+av_frame_ref(). - * - * @return newly created AVFrame on success, NULL on error. - */ -AVFrame *av_frame_clone(const AVFrame *src); - -/** - * Unreference all the buffers referenced by frame and reset the frame fields. - */ -void av_frame_unref(AVFrame *frame); - -/** - * Move everything contained in src to dst and reset src. - * - * @warning: dst is not unreferenced, but directly overwritten without reading - * or deallocating its contents. Call av_frame_unref(dst) manually - * before calling this function to ensure that no memory is leaked. - */ -void av_frame_move_ref(AVFrame *dst, AVFrame *src); - -/** - * Allocate new buffer(s) for audio or video data. - * - * The following fields must be set on frame before calling this function: - * - format (pixel format for video, sample format for audio) - * - width and height for video - * - nb_samples and channel_layout for audio - * - * This function will fill AVFrame.data and AVFrame.buf arrays and, if - * necessary, allocate and fill AVFrame.extended_data and AVFrame.extended_buf. - * For planar formats, one buffer will be allocated for each plane. - * - * @warning: if frame already has been allocated, calling this function will - * leak memory. In addition, undefined behavior can occur in certain - * cases. - * - * @param frame frame in which to store the new buffers. - * @param align Required buffer size alignment. If equal to 0, alignment will be - * chosen automatically for the current CPU. It is highly - * recommended to pass 0 here unless you know what you are doing. - * - * @return 0 on success, a negative AVERROR on error. - */ -int av_frame_get_buffer(AVFrame *frame, int align); - -/** - * Check if the frame data is writable. - * - * @return A positive value if the frame data is writable (which is true if and - * only if each of the underlying buffers has only one reference, namely the one - * stored in this frame). Return 0 otherwise. - * - * If 1 is returned the answer is valid until av_buffer_ref() is called on any - * of the underlying AVBufferRefs (e.g. through av_frame_ref() or directly). - * - * @see av_frame_make_writable(), av_buffer_is_writable() - */ -int av_frame_is_writable(AVFrame *frame); - -/** - * Ensure that the frame data is writable, avoiding data copy if possible. - * - * Do nothing if the frame is writable, allocate new buffers and copy the data - * if it is not. - * - * @return 0 on success, a negative AVERROR on error. - * - * @see av_frame_is_writable(), av_buffer_is_writable(), - * av_buffer_make_writable() - */ -int av_frame_make_writable(AVFrame *frame); - -/** - * Copy the frame data from src to dst. - * - * This function does not allocate anything, dst must be already initialized and - * allocated with the same parameters as src. - * - * This function only copies the frame data (i.e. the contents of the data / - * extended data arrays), not any other properties. - * - * @return >= 0 on success, a negative AVERROR on error. - */ -int av_frame_copy(AVFrame *dst, const AVFrame *src); - -/** - * Copy only "metadata" fields from src to dst. - * - * Metadata for the purpose of this function are those fields that do not affect - * the data layout in the buffers. E.g. pts, sample rate (for audio) or sample - * aspect ratio (for video), but not width/height or channel layout. - * Side data is also copied. - */ -int av_frame_copy_props(AVFrame *dst, const AVFrame *src); - -/** - * Get the buffer reference a given data plane is stored in. - * - * @param plane index of the data plane of interest in frame->extended_data. - * - * @return the buffer reference that contains the plane or NULL if the input - * frame is not valid. - */ -AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane); - -/** - * Add a new side data to a frame. - * - * @param frame a frame to which the side data should be added - * @param type type of the added side data - * @param size size of the side data - * - * @return newly added side data on success, NULL on error - */ -AVFrameSideData *av_frame_new_side_data(AVFrame *frame, - enum AVFrameSideDataType type, - int size); - -/** - * Add a new side data to a frame from an existing AVBufferRef - * - * @param frame a frame to which the side data should be added - * @param type the type of the added side data - * @param buf an AVBufferRef to add as side data. The ownership of - * the reference is transferred to the frame. - * - * @return newly added side data on success, NULL on error. On failure - * the frame is unchanged and the AVBufferRef remains owned by - * the caller. - */ -AVFrameSideData *av_frame_new_side_data_from_buf(AVFrame *frame, - enum AVFrameSideDataType type, - AVBufferRef *buf); - -/** - * @return a pointer to the side data of a given type on success, NULL if there - * is no side data with such type in this frame. - */ -AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, - enum AVFrameSideDataType type); - -/** - * If side data of the supplied type exists in the frame, free it and remove it - * from the frame. - */ -void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type); - - -/** - * Flags for frame cropping. - */ -enum { - /** - * Apply the maximum possible cropping, even if it requires setting the - * AVFrame.data[] entries to unaligned pointers. Passing unaligned data - * to FFmpeg API is generally not allowed, and causes undefined behavior - * (such as crashes). You can pass unaligned data only to FFmpeg APIs that - * are explicitly documented to accept it. Use this flag only if you - * absolutely know what you are doing. - */ - AV_FRAME_CROP_UNALIGNED = 1 << 0, -}; - -/** - * Crop the given video AVFrame according to its crop_left/crop_top/crop_right/ - * crop_bottom fields. If cropping is successful, the function will adjust the - * data pointers and the width/height fields, and set the crop fields to 0. - * - * In all cases, the cropping boundaries will be rounded to the inherent - * alignment of the pixel format. In some cases, such as for opaque hwaccel - * formats, the left/top cropping is ignored. The crop fields are set to 0 even - * if the cropping was rounded or ignored. - * - * @param frame the frame which should be cropped - * @param flags Some combination of AV_FRAME_CROP_* flags, or 0. - * - * @return >= 0 on success, a negative AVERROR on error. If the cropping fields - * were invalid, AVERROR(ERANGE) is returned, and nothing is changed. - */ -int av_frame_apply_cropping(AVFrame *frame, int flags); - -/** - * @return a string identifying the side data type - */ -const char *av_frame_side_data_name(enum AVFrameSideDataType type); - -/** - * @} - */ - -#endif /* AVUTIL_FRAME_H */ diff --git a/maclibs/include/libavutil/hwcontext.h b/maclibs/include/libavutil/hwcontext.h deleted file mode 100644 index f5a4b623..00000000 --- a/maclibs/include/libavutil/hwcontext.h +++ /dev/null @@ -1,584 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_HWCONTEXT_H -#define AVUTIL_HWCONTEXT_H - -#include "buffer.h" -#include "frame.h" -#include "log.h" -#include "pixfmt.h" - -enum AVHWDeviceType { - AV_HWDEVICE_TYPE_NONE, - AV_HWDEVICE_TYPE_VDPAU, - AV_HWDEVICE_TYPE_CUDA, - AV_HWDEVICE_TYPE_VAAPI, - AV_HWDEVICE_TYPE_DXVA2, - AV_HWDEVICE_TYPE_QSV, - AV_HWDEVICE_TYPE_VIDEOTOOLBOX, - AV_HWDEVICE_TYPE_D3D11VA, - AV_HWDEVICE_TYPE_DRM, - AV_HWDEVICE_TYPE_OPENCL, - AV_HWDEVICE_TYPE_MEDIACODEC, -}; - -typedef struct AVHWDeviceInternal AVHWDeviceInternal; - -/** - * This struct aggregates all the (hardware/vendor-specific) "high-level" state, - * i.e. state that is not tied to a concrete processing configuration. - * E.g., in an API that supports hardware-accelerated encoding and decoding, - * this struct will (if possible) wrap the state that is common to both encoding - * and decoding and from which specific instances of encoders or decoders can be - * derived. - * - * This struct is reference-counted with the AVBuffer mechanism. The - * av_hwdevice_ctx_alloc() constructor yields a reference, whose data field - * points to the actual AVHWDeviceContext. Further objects derived from - * AVHWDeviceContext (such as AVHWFramesContext, describing a frame pool with - * specific properties) will hold an internal reference to it. After all the - * references are released, the AVHWDeviceContext itself will be freed, - * optionally invoking a user-specified callback for uninitializing the hardware - * state. - */ -typedef struct AVHWDeviceContext { - /** - * A class for logging. Set by av_hwdevice_ctx_alloc(). - */ - const AVClass *av_class; - - /** - * Private data used internally by libavutil. Must not be accessed in any - * way by the caller. - */ - AVHWDeviceInternal *internal; - - /** - * This field identifies the underlying API used for hardware access. - * - * This field is set when this struct is allocated and never changed - * afterwards. - */ - enum AVHWDeviceType type; - - /** - * The format-specific data, allocated and freed by libavutil along with - * this context. - * - * Should be cast by the user to the format-specific context defined in the - * corresponding header (hwcontext_*.h) and filled as described in the - * documentation before calling av_hwdevice_ctx_init(). - * - * After calling av_hwdevice_ctx_init() this struct should not be modified - * by the caller. - */ - void *hwctx; - - /** - * This field may be set by the caller before calling av_hwdevice_ctx_init(). - * - * If non-NULL, this callback will be called when the last reference to - * this context is unreferenced, immediately before it is freed. - * - * @note when other objects (e.g an AVHWFramesContext) are derived from this - * struct, this callback will be invoked after all such child objects - * are fully uninitialized and their respective destructors invoked. - */ - void (*free)(struct AVHWDeviceContext *ctx); - - /** - * Arbitrary user data, to be used e.g. by the free() callback. - */ - void *user_opaque; -} AVHWDeviceContext; - -typedef struct AVHWFramesInternal AVHWFramesInternal; - -/** - * This struct describes a set or pool of "hardware" frames (i.e. those with - * data not located in normal system memory). All the frames in the pool are - * assumed to be allocated in the same way and interchangeable. - * - * This struct is reference-counted with the AVBuffer mechanism and tied to a - * given AVHWDeviceContext instance. The av_hwframe_ctx_alloc() constructor - * yields a reference, whose data field points to the actual AVHWFramesContext - * struct. - */ -typedef struct AVHWFramesContext { - /** - * A class for logging. - */ - const AVClass *av_class; - - /** - * Private data used internally by libavutil. Must not be accessed in any - * way by the caller. - */ - AVHWFramesInternal *internal; - - /** - * A reference to the parent AVHWDeviceContext. This reference is owned and - * managed by the enclosing AVHWFramesContext, but the caller may derive - * additional references from it. - */ - AVBufferRef *device_ref; - - /** - * The parent AVHWDeviceContext. This is simply a pointer to - * device_ref->data provided for convenience. - * - * Set by libavutil in av_hwframe_ctx_init(). - */ - AVHWDeviceContext *device_ctx; - - /** - * The format-specific data, allocated and freed automatically along with - * this context. - * - * Should be cast by the user to the format-specific context defined in the - * corresponding header (hwframe_*.h) and filled as described in the - * documentation before calling av_hwframe_ctx_init(). - * - * After any frames using this context are created, the contents of this - * struct should not be modified by the caller. - */ - void *hwctx; - - /** - * This field may be set by the caller before calling av_hwframe_ctx_init(). - * - * If non-NULL, this callback will be called when the last reference to - * this context is unreferenced, immediately before it is freed. - */ - void (*free)(struct AVHWFramesContext *ctx); - - /** - * Arbitrary user data, to be used e.g. by the free() callback. - */ - void *user_opaque; - - /** - * A pool from which the frames are allocated by av_hwframe_get_buffer(). - * This field may be set by the caller before calling av_hwframe_ctx_init(). - * The buffers returned by calling av_buffer_pool_get() on this pool must - * have the properties described in the documentation in the corresponding hw - * type's header (hwcontext_*.h). The pool will be freed strictly before - * this struct's free() callback is invoked. - * - * This field may be NULL, then libavutil will attempt to allocate a pool - * internally. Note that certain device types enforce pools allocated at - * fixed size (frame count), which cannot be extended dynamically. In such a - * case, initial_pool_size must be set appropriately. - */ - AVBufferPool *pool; - - /** - * Initial size of the frame pool. If a device type does not support - * dynamically resizing the pool, then this is also the maximum pool size. - * - * May be set by the caller before calling av_hwframe_ctx_init(). Must be - * set if pool is NULL and the device type does not support dynamic pools. - */ - int initial_pool_size; - - /** - * The pixel format identifying the underlying HW surface type. - * - * Must be a hwaccel format, i.e. the corresponding descriptor must have the - * AV_PIX_FMT_FLAG_HWACCEL flag set. - * - * Must be set by the user before calling av_hwframe_ctx_init(). - */ - enum AVPixelFormat format; - - /** - * The pixel format identifying the actual data layout of the hardware - * frames. - * - * Must be set by the caller before calling av_hwframe_ctx_init(). - * - * @note when the underlying API does not provide the exact data layout, but - * only the colorspace/bit depth, this field should be set to the fully - * planar version of that format (e.g. for 8-bit 420 YUV it should be - * AV_PIX_FMT_YUV420P, not AV_PIX_FMT_NV12 or anything else). - */ - enum AVPixelFormat sw_format; - - /** - * The allocated dimensions of the frames in this pool. - * - * Must be set by the user before calling av_hwframe_ctx_init(). - */ - int width, height; -} AVHWFramesContext; - -/** - * Look up an AVHWDeviceType by name. - * - * @param name String name of the device type (case-insensitive). - * @return The type from enum AVHWDeviceType, or AV_HWDEVICE_TYPE_NONE if - * not found. - */ -enum AVHWDeviceType av_hwdevice_find_type_by_name(const char *name); - -/** Get the string name of an AVHWDeviceType. - * - * @param type Type from enum AVHWDeviceType. - * @return Pointer to a static string containing the name, or NULL if the type - * is not valid. - */ -const char *av_hwdevice_get_type_name(enum AVHWDeviceType type); - -/** - * Iterate over supported device types. - * - * @param type AV_HWDEVICE_TYPE_NONE initially, then the previous type - * returned by this function in subsequent iterations. - * @return The next usable device type from enum AVHWDeviceType, or - * AV_HWDEVICE_TYPE_NONE if there are no more. - */ -enum AVHWDeviceType av_hwdevice_iterate_types(enum AVHWDeviceType prev); - -/** - * Allocate an AVHWDeviceContext for a given hardware type. - * - * @param type the type of the hardware device to allocate. - * @return a reference to the newly created AVHWDeviceContext on success or NULL - * on failure. - */ -AVBufferRef *av_hwdevice_ctx_alloc(enum AVHWDeviceType type); - -/** - * Finalize the device context before use. This function must be called after - * the context is filled with all the required information and before it is - * used in any way. - * - * @param ref a reference to the AVHWDeviceContext - * @return 0 on success, a negative AVERROR code on failure - */ -int av_hwdevice_ctx_init(AVBufferRef *ref); - -/** - * Open a device of the specified type and create an AVHWDeviceContext for it. - * - * This is a convenience function intended to cover the simple cases. Callers - * who need to fine-tune device creation/management should open the device - * manually and then wrap it in an AVHWDeviceContext using - * av_hwdevice_ctx_alloc()/av_hwdevice_ctx_init(). - * - * The returned context is already initialized and ready for use, the caller - * should not call av_hwdevice_ctx_init() on it. The user_opaque/free fields of - * the created AVHWDeviceContext are set by this function and should not be - * touched by the caller. - * - * @param device_ctx On success, a reference to the newly-created device context - * will be written here. The reference is owned by the caller - * and must be released with av_buffer_unref() when no longer - * needed. On failure, NULL will be written to this pointer. - * @param type The type of the device to create. - * @param device A type-specific string identifying the device to open. - * @param opts A dictionary of additional (type-specific) options to use in - * opening the device. The dictionary remains owned by the caller. - * @param flags currently unused - * - * @return 0 on success, a negative AVERROR code on failure. - */ -int av_hwdevice_ctx_create(AVBufferRef **device_ctx, enum AVHWDeviceType type, - const char *device, AVDictionary *opts, int flags); - -/** - * Create a new device of the specified type from an existing device. - * - * If the source device is a device of the target type or was originally - * derived from such a device (possibly through one or more intermediate - * devices of other types), then this will return a reference to the - * existing device of the same type as is requested. - * - * Otherwise, it will attempt to derive a new device from the given source - * device. If direct derivation to the new type is not implemented, it will - * attempt the same derivation from each ancestor of the source device in - * turn looking for an implemented derivation method. - * - * @param dst_ctx On success, a reference to the newly-created - * AVHWDeviceContext. - * @param type The type of the new device to create. - * @param src_ctx A reference to an existing AVHWDeviceContext which will be - * used to create the new device. - * @param flags Currently unused; should be set to zero. - * @return Zero on success, a negative AVERROR code on failure. - */ -int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ctx, - enum AVHWDeviceType type, - AVBufferRef *src_ctx, int flags); - - -/** - * Allocate an AVHWFramesContext tied to a given device context. - * - * @param device_ctx a reference to a AVHWDeviceContext. This function will make - * a new reference for internal use, the one passed to the - * function remains owned by the caller. - * @return a reference to the newly created AVHWFramesContext on success or NULL - * on failure. - */ -AVBufferRef *av_hwframe_ctx_alloc(AVBufferRef *device_ctx); - -/** - * Finalize the context before use. This function must be called after the - * context is filled with all the required information and before it is attached - * to any frames. - * - * @param ref a reference to the AVHWFramesContext - * @return 0 on success, a negative AVERROR code on failure - */ -int av_hwframe_ctx_init(AVBufferRef *ref); - -/** - * Allocate a new frame attached to the given AVHWFramesContext. - * - * @param hwframe_ctx a reference to an AVHWFramesContext - * @param frame an empty (freshly allocated or unreffed) frame to be filled with - * newly allocated buffers. - * @param flags currently unused, should be set to zero - * @return 0 on success, a negative AVERROR code on failure - */ -int av_hwframe_get_buffer(AVBufferRef *hwframe_ctx, AVFrame *frame, int flags); - -/** - * Copy data to or from a hw surface. At least one of dst/src must have an - * AVHWFramesContext attached. - * - * If src has an AVHWFramesContext attached, then the format of dst (if set) - * must use one of the formats returned by av_hwframe_transfer_get_formats(src, - * AV_HWFRAME_TRANSFER_DIRECTION_FROM). - * If dst has an AVHWFramesContext attached, then the format of src must use one - * of the formats returned by av_hwframe_transfer_get_formats(dst, - * AV_HWFRAME_TRANSFER_DIRECTION_TO) - * - * dst may be "clean" (i.e. with data/buf pointers unset), in which case the - * data buffers will be allocated by this function using av_frame_get_buffer(). - * If dst->format is set, then this format will be used, otherwise (when - * dst->format is AV_PIX_FMT_NONE) the first acceptable format will be chosen. - * - * The two frames must have matching allocated dimensions (i.e. equal to - * AVHWFramesContext.width/height), since not all device types support - * transferring a sub-rectangle of the whole surface. The display dimensions - * (i.e. AVFrame.width/height) may be smaller than the allocated dimensions, but - * also have to be equal for both frames. When the display dimensions are - * smaller than the allocated dimensions, the content of the padding in the - * destination frame is unspecified. - * - * @param dst the destination frame. dst is not touched on failure. - * @param src the source frame. - * @param flags currently unused, should be set to zero - * @return 0 on success, a negative AVERROR error code on failure. - */ -int av_hwframe_transfer_data(AVFrame *dst, const AVFrame *src, int flags); - -enum AVHWFrameTransferDirection { - /** - * Transfer the data from the queried hw frame. - */ - AV_HWFRAME_TRANSFER_DIRECTION_FROM, - - /** - * Transfer the data to the queried hw frame. - */ - AV_HWFRAME_TRANSFER_DIRECTION_TO, -}; - -/** - * Get a list of possible source or target formats usable in - * av_hwframe_transfer_data(). - * - * @param hwframe_ctx the frame context to obtain the information for - * @param dir the direction of the transfer - * @param formats the pointer to the output format list will be written here. - * The list is terminated with AV_PIX_FMT_NONE and must be freed - * by the caller when no longer needed using av_free(). - * If this function returns successfully, the format list will - * have at least one item (not counting the terminator). - * On failure, the contents of this pointer are unspecified. - * @param flags currently unused, should be set to zero - * @return 0 on success, a negative AVERROR code on failure. - */ -int av_hwframe_transfer_get_formats(AVBufferRef *hwframe_ctx, - enum AVHWFrameTransferDirection dir, - enum AVPixelFormat **formats, int flags); - - -/** - * This struct describes the constraints on hardware frames attached to - * a given device with a hardware-specific configuration. This is returned - * by av_hwdevice_get_hwframe_constraints() and must be freed by - * av_hwframe_constraints_free() after use. - */ -typedef struct AVHWFramesConstraints { - /** - * A list of possible values for format in the hw_frames_ctx, - * terminated by AV_PIX_FMT_NONE. This member will always be filled. - */ - enum AVPixelFormat *valid_hw_formats; - - /** - * A list of possible values for sw_format in the hw_frames_ctx, - * terminated by AV_PIX_FMT_NONE. Can be NULL if this information is - * not known. - */ - enum AVPixelFormat *valid_sw_formats; - - /** - * The minimum size of frames in this hw_frames_ctx. - * (Zero if not known.) - */ - int min_width; - int min_height; - - /** - * The maximum size of frames in this hw_frames_ctx. - * (INT_MAX if not known / no limit.) - */ - int max_width; - int max_height; -} AVHWFramesConstraints; - -/** - * Allocate a HW-specific configuration structure for a given HW device. - * After use, the user must free all members as required by the specific - * hardware structure being used, then free the structure itself with - * av_free(). - * - * @param device_ctx a reference to the associated AVHWDeviceContext. - * @return The newly created HW-specific configuration structure on - * success or NULL on failure. - */ -void *av_hwdevice_hwconfig_alloc(AVBufferRef *device_ctx); - -/** - * Get the constraints on HW frames given a device and the HW-specific - * configuration to be used with that device. If no HW-specific - * configuration is provided, returns the maximum possible capabilities - * of the device. - * - * @param ref a reference to the associated AVHWDeviceContext. - * @param hwconfig a filled HW-specific configuration structure, or NULL - * to return the maximum possible capabilities of the device. - * @return AVHWFramesConstraints structure describing the constraints - * on the device, or NULL if not available. - */ -AVHWFramesConstraints *av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, - const void *hwconfig); - -/** - * Free an AVHWFrameConstraints structure. - * - * @param constraints The (filled or unfilled) AVHWFrameConstraints structure. - */ -void av_hwframe_constraints_free(AVHWFramesConstraints **constraints); - - -/** - * Flags to apply to frame mappings. - */ -enum { - /** - * The mapping must be readable. - */ - AV_HWFRAME_MAP_READ = 1 << 0, - /** - * The mapping must be writeable. - */ - AV_HWFRAME_MAP_WRITE = 1 << 1, - /** - * The mapped frame will be overwritten completely in subsequent - * operations, so the current frame data need not be loaded. Any values - * which are not overwritten are unspecified. - */ - AV_HWFRAME_MAP_OVERWRITE = 1 << 2, - /** - * The mapping must be direct. That is, there must not be any copying in - * the map or unmap steps. Note that performance of direct mappings may - * be much lower than normal memory. - */ - AV_HWFRAME_MAP_DIRECT = 1 << 3, -}; - -/** - * Map a hardware frame. - * - * This has a number of different possible effects, depending on the format - * and origin of the src and dst frames. On input, src should be a usable - * frame with valid buffers and dst should be blank (typically as just created - * by av_frame_alloc()). src should have an associated hwframe context, and - * dst may optionally have a format and associated hwframe context. - * - * If src was created by mapping a frame from the hwframe context of dst, - * then this function undoes the mapping - dst is replaced by a reference to - * the frame that src was originally mapped from. - * - * If both src and dst have an associated hwframe context, then this function - * attempts to map the src frame from its hardware context to that of dst and - * then fill dst with appropriate data to be usable there. This will only be - * possible if the hwframe contexts and associated devices are compatible - - * given compatible devices, av_hwframe_ctx_create_derived() can be used to - * create a hwframe context for dst in which mapping should be possible. - * - * If src has a hwframe context but dst does not, then the src frame is - * mapped to normal memory and should thereafter be usable as a normal frame. - * If the format is set on dst, then the mapping will attempt to create dst - * with that format and fail if it is not possible. If format is unset (is - * AV_PIX_FMT_NONE) then dst will be mapped with whatever the most appropriate - * format to use is (probably the sw_format of the src hwframe context). - * - * A return value of AVERROR(ENOSYS) indicates that the mapping is not - * possible with the given arguments and hwframe setup, while other return - * values indicate that it failed somehow. - * - * @param dst Destination frame, to contain the mapping. - * @param src Source frame, to be mapped. - * @param flags Some combination of AV_HWFRAME_MAP_* flags. - * @return Zero on success, negative AVERROR code on failure. - */ -int av_hwframe_map(AVFrame *dst, const AVFrame *src, int flags); - - -/** - * Create and initialise an AVHWFramesContext as a mapping of another existing - * AVHWFramesContext on a different device. - * - * av_hwframe_ctx_init() should not be called after this. - * - * @param derived_frame_ctx On success, a reference to the newly created - * AVHWFramesContext. - * @param derived_device_ctx A reference to the device to create the new - * AVHWFramesContext on. - * @param source_frame_ctx A reference to an existing AVHWFramesContext - * which will be mapped to the derived context. - * @param flags Some combination of AV_HWFRAME_MAP_* flags, defining the - * mapping parameters to apply to frames which are allocated - * in the derived device. - * @return Zero on success, negative AVERROR code on failure. - */ -int av_hwframe_ctx_create_derived(AVBufferRef **derived_frame_ctx, - enum AVPixelFormat format, - AVBufferRef *derived_device_ctx, - AVBufferRef *source_frame_ctx, - int flags); - -#endif /* AVUTIL_HWCONTEXT_H */ diff --git a/maclibs/include/libavutil/intfloat.h b/maclibs/include/libavutil/intfloat.h deleted file mode 100644 index fe3d7ec4..00000000 --- a/maclibs/include/libavutil/intfloat.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2011 Mans Rullgard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_INTFLOAT_H -#define AVUTIL_INTFLOAT_H - -#include -#include "attributes.h" - -union av_intfloat32 { - uint32_t i; - float f; -}; - -union av_intfloat64 { - uint64_t i; - double f; -}; - -/** - * Reinterpret a 32-bit integer as a float. - */ -static av_always_inline float av_int2float(uint32_t i) -{ - union av_intfloat32 v; - v.i = i; - return v.f; -} - -/** - * Reinterpret a float as a 32-bit integer. - */ -static av_always_inline uint32_t av_float2int(float f) -{ - union av_intfloat32 v; - v.f = f; - return v.i; -} - -/** - * Reinterpret a 64-bit integer as a double. - */ -static av_always_inline double av_int2double(uint64_t i) -{ - union av_intfloat64 v; - v.i = i; - return v.f; -} - -/** - * Reinterpret a double as a 64-bit integer. - */ -static av_always_inline uint64_t av_double2int(double f) -{ - union av_intfloat64 v; - v.f = f; - return v.i; -} - -#endif /* AVUTIL_INTFLOAT_H */ diff --git a/maclibs/include/libavutil/log.h b/maclibs/include/libavutil/log.h deleted file mode 100644 index d9554e60..00000000 --- a/maclibs/include/libavutil/log.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_LOG_H -#define AVUTIL_LOG_H - -#include -#include "avutil.h" -#include "attributes.h" -#include "version.h" - -typedef enum { - AV_CLASS_CATEGORY_NA = 0, - AV_CLASS_CATEGORY_INPUT, - AV_CLASS_CATEGORY_OUTPUT, - AV_CLASS_CATEGORY_MUXER, - AV_CLASS_CATEGORY_DEMUXER, - AV_CLASS_CATEGORY_ENCODER, - AV_CLASS_CATEGORY_DECODER, - AV_CLASS_CATEGORY_FILTER, - AV_CLASS_CATEGORY_BITSTREAM_FILTER, - AV_CLASS_CATEGORY_SWSCALER, - AV_CLASS_CATEGORY_SWRESAMPLER, - AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT = 40, - AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT, - AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT, - AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT, - AV_CLASS_CATEGORY_DEVICE_OUTPUT, - AV_CLASS_CATEGORY_DEVICE_INPUT, - AV_CLASS_CATEGORY_NB ///< not part of ABI/API -}AVClassCategory; - -#define AV_IS_INPUT_DEVICE(category) \ - (((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT) || \ - ((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT) || \ - ((category) == AV_CLASS_CATEGORY_DEVICE_INPUT)) - -#define AV_IS_OUTPUT_DEVICE(category) \ - (((category) == AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT) || \ - ((category) == AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT) || \ - ((category) == AV_CLASS_CATEGORY_DEVICE_OUTPUT)) - -struct AVOptionRanges; - -/** - * Describe the class of an AVClass context structure. That is an - * arbitrary struct of which the first field is a pointer to an - * AVClass struct (e.g. AVCodecContext, AVFormatContext etc.). - */ -typedef struct AVClass { - /** - * The name of the class; usually it is the same name as the - * context structure type to which the AVClass is associated. - */ - const char* class_name; - - /** - * A pointer to a function which returns the name of a context - * instance ctx associated with the class. - */ - const char* (*item_name)(void* ctx); - - /** - * a pointer to the first option specified in the class if any or NULL - * - * @see av_set_default_options() - */ - const struct AVOption *option; - - /** - * LIBAVUTIL_VERSION with which this structure was created. - * This is used to allow fields to be added without requiring major - * version bumps everywhere. - */ - - int version; - - /** - * Offset in the structure where log_level_offset is stored. - * 0 means there is no such variable - */ - int log_level_offset_offset; - - /** - * Offset in the structure where a pointer to the parent context for - * logging is stored. For example a decoder could pass its AVCodecContext - * to eval as such a parent context, which an av_log() implementation - * could then leverage to display the parent context. - * The offset can be NULL. - */ - int parent_log_context_offset; - - /** - * Return next AVOptions-enabled child or NULL - */ - void* (*child_next)(void *obj, void *prev); - - /** - * Return an AVClass corresponding to the next potential - * AVOptions-enabled child. - * - * The difference between child_next and this is that - * child_next iterates over _already existing_ objects, while - * child_class_next iterates over _all possible_ children. - */ - const struct AVClass* (*child_class_next)(const struct AVClass *prev); - - /** - * Category used for visualization (like color) - * This is only set if the category is equal for all objects using this class. - * available since version (51 << 16 | 56 << 8 | 100) - */ - AVClassCategory category; - - /** - * Callback to return the category. - * available since version (51 << 16 | 59 << 8 | 100) - */ - AVClassCategory (*get_category)(void* ctx); - - /** - * Callback to return the supported/allowed ranges. - * available since version (52.12) - */ - int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags); -} AVClass; - -/** - * @addtogroup lavu_log - * - * @{ - * - * @defgroup lavu_log_constants Logging Constants - * - * @{ - */ - -/** - * Print no output. - */ -#define AV_LOG_QUIET -8 - -/** - * Something went really wrong and we will crash now. - */ -#define AV_LOG_PANIC 0 - -/** - * Something went wrong and recovery is not possible. - * For example, no header was found for a format which depends - * on headers or an illegal combination of parameters is used. - */ -#define AV_LOG_FATAL 8 - -/** - * Something went wrong and cannot losslessly be recovered. - * However, not all future data is affected. - */ -#define AV_LOG_ERROR 16 - -/** - * Something somehow does not look correct. This may or may not - * lead to problems. An example would be the use of '-vstrict -2'. - */ -#define AV_LOG_WARNING 24 - -/** - * Standard information. - */ -#define AV_LOG_INFO 32 - -/** - * Detailed information. - */ -#define AV_LOG_VERBOSE 40 - -/** - * Stuff which is only useful for libav* developers. - */ -#define AV_LOG_DEBUG 48 - -/** - * Extremely verbose debugging, useful for libav* development. - */ -#define AV_LOG_TRACE 56 - -#define AV_LOG_MAX_OFFSET (AV_LOG_TRACE - AV_LOG_QUIET) - -/** - * @} - */ - -/** - * Sets additional colors for extended debugging sessions. - * @code - av_log(ctx, AV_LOG_DEBUG|AV_LOG_C(134), "Message in purple\n"); - @endcode - * Requires 256color terminal support. Uses outside debugging is not - * recommended. - */ -#define AV_LOG_C(x) ((x) << 8) - -/** - * Send the specified message to the log if the level is less than or equal - * to the current av_log_level. By default, all logging messages are sent to - * stderr. This behavior can be altered by setting a different logging callback - * function. - * @see av_log_set_callback - * - * @param avcl A pointer to an arbitrary struct of which the first field is a - * pointer to an AVClass struct or NULL if general log. - * @param level The importance level of the message expressed using a @ref - * lavu_log_constants "Logging Constant". - * @param fmt The format string (printf-compatible) that specifies how - * subsequent arguments are converted to output. - */ -void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); - - -/** - * Send the specified message to the log if the level is less than or equal - * to the current av_log_level. By default, all logging messages are sent to - * stderr. This behavior can be altered by setting a different logging callback - * function. - * @see av_log_set_callback - * - * @param avcl A pointer to an arbitrary struct of which the first field is a - * pointer to an AVClass struct. - * @param level The importance level of the message expressed using a @ref - * lavu_log_constants "Logging Constant". - * @param fmt The format string (printf-compatible) that specifies how - * subsequent arguments are converted to output. - * @param vl The arguments referenced by the format string. - */ -void av_vlog(void *avcl, int level, const char *fmt, va_list vl); - -/** - * Get the current log level - * - * @see lavu_log_constants - * - * @return Current log level - */ -int av_log_get_level(void); - -/** - * Set the log level - * - * @see lavu_log_constants - * - * @param level Logging level - */ -void av_log_set_level(int level); - -/** - * Set the logging callback - * - * @note The callback must be thread safe, even if the application does not use - * threads itself as some codecs are multithreaded. - * - * @see av_log_default_callback - * - * @param callback A logging function with a compatible signature. - */ -void av_log_set_callback(void (*callback)(void*, int, const char*, va_list)); - -/** - * Default logging callback - * - * It prints the message to stderr, optionally colorizing it. - * - * @param avcl A pointer to an arbitrary struct of which the first field is a - * pointer to an AVClass struct. - * @param level The importance level of the message expressed using a @ref - * lavu_log_constants "Logging Constant". - * @param fmt The format string (printf-compatible) that specifies how - * subsequent arguments are converted to output. - * @param vl The arguments referenced by the format string. - */ -void av_log_default_callback(void *avcl, int level, const char *fmt, - va_list vl); - -/** - * Return the context name - * - * @param ctx The AVClass context - * - * @return The AVClass class_name - */ -const char* av_default_item_name(void* ctx); -AVClassCategory av_default_get_category(void *ptr); - -/** - * Format a line of log the same way as the default callback. - * @param line buffer to receive the formatted line - * @param line_size size of the buffer - * @param print_prefix used to store whether the prefix must be printed; - * must point to a persistent integer initially set to 1 - */ -void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl, - char *line, int line_size, int *print_prefix); - -/** - * Format a line of log the same way as the default callback. - * @param line buffer to receive the formatted line; - * may be NULL if line_size is 0 - * @param line_size size of the buffer; at most line_size-1 characters will - * be written to the buffer, plus one null terminator - * @param print_prefix used to store whether the prefix must be printed; - * must point to a persistent integer initially set to 1 - * @return Returns a negative value if an error occurred, otherwise returns - * the number of characters that would have been written for a - * sufficiently large buffer, not including the terminating null - * character. If the return value is not less than line_size, it means - * that the log message was truncated to fit the buffer. - */ -int av_log_format_line2(void *ptr, int level, const char *fmt, va_list vl, - char *line, int line_size, int *print_prefix); - -/** - * Skip repeated messages, this requires the user app to use av_log() instead of - * (f)printf as the 2 would otherwise interfere and lead to - * "Last message repeated x times" messages below (f)printf messages with some - * bad luck. - * Also to receive the last, "last repeated" line if any, the user app must - * call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end - */ -#define AV_LOG_SKIP_REPEATED 1 - -/** - * Include the log severity in messages originating from codecs. - * - * Results in messages such as: - * [rawvideo @ 0xDEADBEEF] [error] encode did not produce valid pts - */ -#define AV_LOG_PRINT_LEVEL 2 - -void av_log_set_flags(int arg); -int av_log_get_flags(void); - -/** - * @} - */ - -#endif /* AVUTIL_LOG_H */ diff --git a/maclibs/include/libavutil/mathematics.h b/maclibs/include/libavutil/mathematics.h deleted file mode 100644 index 54901800..00000000 --- a/maclibs/include/libavutil/mathematics.h +++ /dev/null @@ -1,242 +0,0 @@ -/* - * copyright (c) 2005-2012 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * @addtogroup lavu_math - * Mathematical utilities for working with timestamp and time base. - */ - -#ifndef AVUTIL_MATHEMATICS_H -#define AVUTIL_MATHEMATICS_H - -#include -#include -#include "attributes.h" -#include "rational.h" -#include "intfloat.h" - -#ifndef M_E -#define M_E 2.7182818284590452354 /* e */ -#endif -#ifndef M_LN2 -#define M_LN2 0.69314718055994530942 /* log_e 2 */ -#endif -#ifndef M_LN10 -#define M_LN10 2.30258509299404568402 /* log_e 10 */ -#endif -#ifndef M_LOG2_10 -#define M_LOG2_10 3.32192809488736234787 /* log_2 10 */ -#endif -#ifndef M_PHI -#define M_PHI 1.61803398874989484820 /* phi / golden ratio */ -#endif -#ifndef M_PI -#define M_PI 3.14159265358979323846 /* pi */ -#endif -#ifndef M_PI_2 -#define M_PI_2 1.57079632679489661923 /* pi/2 */ -#endif -#ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ -#endif -#ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ -#endif -#ifndef NAN -#define NAN av_int2float(0x7fc00000) -#endif -#ifndef INFINITY -#define INFINITY av_int2float(0x7f800000) -#endif - -/** - * @addtogroup lavu_math - * - * @{ - */ - -/** - * Rounding methods. - */ -enum AVRounding { - AV_ROUND_ZERO = 0, ///< Round toward zero. - AV_ROUND_INF = 1, ///< Round away from zero. - AV_ROUND_DOWN = 2, ///< Round toward -infinity. - AV_ROUND_UP = 3, ///< Round toward +infinity. - AV_ROUND_NEAR_INF = 5, ///< Round to nearest and halfway cases away from zero. - /** - * Flag telling rescaling functions to pass `INT64_MIN`/`MAX` through - * unchanged, avoiding special cases for #AV_NOPTS_VALUE. - * - * Unlike other values of the enumeration AVRounding, this value is a - * bitmask that must be used in conjunction with another value of the - * enumeration through a bitwise OR, in order to set behavior for normal - * cases. - * - * @code{.c} - * av_rescale_rnd(3, 1, 2, AV_ROUND_UP | AV_ROUND_PASS_MINMAX); - * // Rescaling 3: - * // Calculating 3 * 1 / 2 - * // 3 / 2 is rounded up to 2 - * // => 2 - * - * av_rescale_rnd(AV_NOPTS_VALUE, 1, 2, AV_ROUND_UP | AV_ROUND_PASS_MINMAX); - * // Rescaling AV_NOPTS_VALUE: - * // AV_NOPTS_VALUE == INT64_MIN - * // AV_NOPTS_VALUE is passed through - * // => AV_NOPTS_VALUE - * @endcode - */ - AV_ROUND_PASS_MINMAX = 8192, -}; - -/** - * Compute the greatest common divisor of two integer operands. - * - * @param a,b Operands - * @return GCD of a and b up to sign; if a >= 0 and b >= 0, return value is >= 0; - * if a == 0 and b == 0, returns 0. - */ -int64_t av_const av_gcd(int64_t a, int64_t b); - -/** - * Rescale a 64-bit integer with rounding to nearest. - * - * The operation is mathematically equivalent to `a * b / c`, but writing that - * directly can overflow. - * - * This function is equivalent to av_rescale_rnd() with #AV_ROUND_NEAR_INF. - * - * @see av_rescale_rnd(), av_rescale_q(), av_rescale_q_rnd() - */ -int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; - -/** - * Rescale a 64-bit integer with specified rounding. - * - * The operation is mathematically equivalent to `a * b / c`, but writing that - * directly can overflow, and does not support different rounding methods. - * - * @see av_rescale(), av_rescale_q(), av_rescale_q_rnd() - */ -int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd) av_const; - -/** - * Rescale a 64-bit integer by 2 rational numbers. - * - * The operation is mathematically equivalent to `a * bq / cq`. - * - * This function is equivalent to av_rescale_q_rnd() with #AV_ROUND_NEAR_INF. - * - * @see av_rescale(), av_rescale_rnd(), av_rescale_q_rnd() - */ -int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq) av_const; - -/** - * Rescale a 64-bit integer by 2 rational numbers with specified rounding. - * - * The operation is mathematically equivalent to `a * bq / cq`. - * - * @see av_rescale(), av_rescale_rnd(), av_rescale_q() - */ -int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, - enum AVRounding rnd) av_const; - -/** - * Compare two timestamps each in its own time base. - * - * @return One of the following values: - * - -1 if `ts_a` is before `ts_b` - * - 1 if `ts_a` is after `ts_b` - * - 0 if they represent the same position - * - * @warning - * The result of the function is undefined if one of the timestamps is outside - * the `int64_t` range when represented in the other's timebase. - */ -int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b); - -/** - * Compare the remainders of two integer operands divided by a common divisor. - * - * In other words, compare the least significant `log2(mod)` bits of integers - * `a` and `b`. - * - * @code{.c} - * av_compare_mod(0x11, 0x02, 0x10) < 0 // since 0x11 % 0x10 (0x1) < 0x02 % 0x10 (0x2) - * av_compare_mod(0x11, 0x02, 0x20) > 0 // since 0x11 % 0x20 (0x11) > 0x02 % 0x20 (0x02) - * @endcode - * - * @param a,b Operands - * @param mod Divisor; must be a power of 2 - * @return - * - a negative value if `a % mod < b % mod` - * - a positive value if `a % mod > b % mod` - * - zero if `a % mod == b % mod` - */ -int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod); - -/** - * Rescale a timestamp while preserving known durations. - * - * This function is designed to be called per audio packet to scale the input - * timestamp to a different time base. Compared to a simple av_rescale_q() - * call, this function is robust against possible inconsistent frame durations. - * - * The `last` parameter is a state variable that must be preserved for all - * subsequent calls for the same stream. For the first call, `*last` should be - * initialized to #AV_NOPTS_VALUE. - * - * @param[in] in_tb Input time base - * @param[in] in_ts Input timestamp - * @param[in] fs_tb Duration time base; typically this is finer-grained - * (greater) than `in_tb` and `out_tb` - * @param[in] duration Duration till the next call to this function (i.e. - * duration of the current packet/frame) - * @param[in,out] last Pointer to a timestamp expressed in terms of - * `fs_tb`, acting as a state variable - * @param[in] out_tb Output timebase - * @return Timestamp expressed in terms of `out_tb` - * - * @note In the context of this function, "duration" is in term of samples, not - * seconds. - */ -int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb); - -/** - * Add a value to a timestamp. - * - * This function guarantees that when the same value is repeatly added that - * no accumulation of rounding errors occurs. - * - * @param[in] ts Input timestamp - * @param[in] ts_tb Input timestamp time base - * @param[in] inc Value to be added - * @param[in] inc_tb Time base of `inc` - */ -int64_t av_add_stable(AVRational ts_tb, int64_t ts, AVRational inc_tb, int64_t inc); - - -/** - * @} - */ - -#endif /* AVUTIL_MATHEMATICS_H */ diff --git a/maclibs/include/libavutil/mem.h b/maclibs/include/libavutil/mem.h deleted file mode 100644 index 5fb1a02d..00000000 --- a/maclibs/include/libavutil/mem.h +++ /dev/null @@ -1,700 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * @ingroup lavu_mem - * Memory handling functions - */ - -#ifndef AVUTIL_MEM_H -#define AVUTIL_MEM_H - -#include -#include - -#include "attributes.h" -#include "error.h" -#include "avutil.h" - -/** - * @addtogroup lavu_mem - * Utilities for manipulating memory. - * - * FFmpeg has several applications of memory that are not required of a typical - * program. For example, the computing-heavy components like video decoding and - * encoding can be sped up significantly through the use of aligned memory. - * - * However, for each of FFmpeg's applications of memory, there might not be a - * recognized or standardized API for that specific use. Memory alignment, for - * instance, varies wildly depending on operating systems, architectures, and - * compilers. Hence, this component of @ref libavutil is created to make - * dealing with memory consistently possible on all platforms. - * - * @{ - * - * @defgroup lavu_mem_macros Alignment Macros - * Helper macros for declaring aligned variables. - * @{ - */ - -/** - * @def DECLARE_ALIGNED(n,t,v) - * Declare a variable that is aligned in memory. - * - * @code{.c} - * DECLARE_ALIGNED(16, uint16_t, aligned_int) = 42; - * DECLARE_ALIGNED(32, uint8_t, aligned_array)[128]; - * - * // The default-alignment equivalent would be - * uint16_t aligned_int = 42; - * uint8_t aligned_array[128]; - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -/** - * @def DECLARE_ASM_ALIGNED(n,t,v) - * Declare an aligned variable appropriate for use in inline assembly code. - * - * @code{.c} - * DECLARE_ASM_ALIGNED(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -/** - * @def DECLARE_ASM_CONST(n,t,v) - * Declare a static constant aligned variable appropriate for use in inline - * assembly code. - * - * @code{.c} - * DECLARE_ASM_CONST(16, uint64_t, pw_08) = UINT64_C(0x0008000800080008); - * @endcode - * - * @param n Minimum alignment in bytes - * @param t Type of the variable (or array element) - * @param v Name of the variable - */ - -#if defined(__INTEL_COMPILER) && __INTEL_COMPILER < 1110 || defined(__SUNPRO_C) - #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_CONST(n,t,v) const t __attribute__ ((aligned (n))) v -#elif defined(__DJGPP__) - #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (FFMIN(n, 16)))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v - #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (FFMIN(n, 16)))) v -#elif defined(__GNUC__) || defined(__clang__) - #define DECLARE_ALIGNED(n,t,v) t __attribute__ ((aligned (n))) v - #define DECLARE_ASM_ALIGNED(n,t,v) t av_used __attribute__ ((aligned (n))) v - #define DECLARE_ASM_CONST(n,t,v) static const t av_used __attribute__ ((aligned (n))) v -#elif defined(_MSC_VER) - #define DECLARE_ALIGNED(n,t,v) __declspec(align(n)) t v - #define DECLARE_ASM_ALIGNED(n,t,v) __declspec(align(n)) t v - #define DECLARE_ASM_CONST(n,t,v) __declspec(align(n)) static const t v -#else - #define DECLARE_ALIGNED(n,t,v) t v - #define DECLARE_ASM_ALIGNED(n,t,v) t v - #define DECLARE_ASM_CONST(n,t,v) static const t v -#endif - -/** - * @} - */ - -/** - * @defgroup lavu_mem_attrs Function Attributes - * Function attributes applicable to memory handling functions. - * - * These function attributes can help compilers emit more useful warnings, or - * generate better code. - * @{ - */ - -/** - * @def av_malloc_attrib - * Function attribute denoting a malloc-like function. - * - * @see Function attribute `malloc` in GCC's documentation - */ - -#if AV_GCC_VERSION_AT_LEAST(3,1) - #define av_malloc_attrib __attribute__((__malloc__)) -#else - #define av_malloc_attrib -#endif - -/** - * @def av_alloc_size(...) - * Function attribute used on a function that allocates memory, whose size is - * given by the specified parameter(s). - * - * @code{.c} - * void *av_malloc(size_t size) av_alloc_size(1); - * void *av_calloc(size_t nmemb, size_t size) av_alloc_size(1, 2); - * @endcode - * - * @param ... One or two parameter indexes, separated by a comma - * - * @see Function attribute `alloc_size` in GCC's documentation - */ - -#if AV_GCC_VERSION_AT_LEAST(4,3) - #define av_alloc_size(...) __attribute__((alloc_size(__VA_ARGS__))) -#else - #define av_alloc_size(...) -#endif - -/** - * @} - */ - -/** - * @defgroup lavu_mem_funcs Heap Management - * Functions responsible for allocating, freeing, and copying memory. - * - * All memory allocation functions have a built-in upper limit of `INT_MAX` - * bytes. This may be changed with av_max_alloc(), although exercise extreme - * caution when doing so. - * - * @{ - */ - -/** - * Allocate a memory block with alignment suitable for all memory accesses - * (including vectors if available on the CPU). - * - * @param size Size in bytes for the memory block to be allocated - * @return Pointer to the allocated block, or `NULL` if the block cannot - * be allocated - * @see av_mallocz() - */ -void *av_malloc(size_t size) av_malloc_attrib av_alloc_size(1); - -/** - * Allocate a memory block with alignment suitable for all memory accesses - * (including vectors if available on the CPU) and zero all the bytes of the - * block. - * - * @param size Size in bytes for the memory block to be allocated - * @return Pointer to the allocated block, or `NULL` if it cannot be allocated - * @see av_malloc() - */ -void *av_mallocz(size_t size) av_malloc_attrib av_alloc_size(1); - -/** - * Allocate a memory block for an array with av_malloc(). - * - * The allocated memory will have size `size * nmemb` bytes. - * - * @param nmemb Number of element - * @param size Size of a single element - * @return Pointer to the allocated block, or `NULL` if the block cannot - * be allocated - * @see av_malloc() - */ -av_alloc_size(1, 2) void *av_malloc_array(size_t nmemb, size_t size); - -/** - * Allocate a memory block for an array with av_mallocz(). - * - * The allocated memory will have size `size * nmemb` bytes. - * - * @param nmemb Number of elements - * @param size Size of the single element - * @return Pointer to the allocated block, or `NULL` if the block cannot - * be allocated - * - * @see av_mallocz() - * @see av_malloc_array() - */ -av_alloc_size(1, 2) void *av_mallocz_array(size_t nmemb, size_t size); - -/** - * Non-inlined equivalent of av_mallocz_array(). - * - * Created for symmetry with the calloc() C function. - */ -void *av_calloc(size_t nmemb, size_t size) av_malloc_attrib; - -/** - * Allocate, reallocate, or free a block of memory. - * - * If `ptr` is `NULL` and `size` > 0, allocate a new block. If `size` is - * zero, free the memory block pointed to by `ptr`. Otherwise, expand or - * shrink that block of memory according to `size`. - * - * @param ptr Pointer to a memory block already allocated with - * av_realloc() or `NULL` - * @param size Size in bytes of the memory block to be allocated or - * reallocated - * - * @return Pointer to a newly-reallocated block or `NULL` if the block - * cannot be reallocated or the function is used to free the memory block - * - * @warning Unlike av_malloc(), the returned pointer is not guaranteed to be - * correctly aligned. - * @see av_fast_realloc() - * @see av_reallocp() - */ -void *av_realloc(void *ptr, size_t size) av_alloc_size(2); - -/** - * Allocate, reallocate, or free a block of memory through a pointer to a - * pointer. - * - * If `*ptr` is `NULL` and `size` > 0, allocate a new block. If `size` is - * zero, free the memory block pointed to by `*ptr`. Otherwise, expand or - * shrink that block of memory according to `size`. - * - * @param[in,out] ptr Pointer to a pointer to a memory block already allocated - * with av_realloc(), or a pointer to `NULL`. The pointer - * is updated on success, or freed on failure. - * @param[in] size Size in bytes for the memory block to be allocated or - * reallocated - * - * @return Zero on success, an AVERROR error code on failure - * - * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be - * correctly aligned. - */ -av_warn_unused_result -int av_reallocp(void *ptr, size_t size); - -/** - * Allocate, reallocate, or free a block of memory. - * - * This function does the same thing as av_realloc(), except: - * - It takes two size arguments and allocates `nelem * elsize` bytes, - * after checking the result of the multiplication for integer overflow. - * - It frees the input block in case of failure, thus avoiding the memory - * leak with the classic - * @code{.c} - * buf = realloc(buf); - * if (!buf) - * return -1; - * @endcode - * pattern. - */ -void *av_realloc_f(void *ptr, size_t nelem, size_t elsize); - -/** - * Allocate, reallocate, or free an array. - * - * If `ptr` is `NULL` and `nmemb` > 0, allocate a new block. If - * `nmemb` is zero, free the memory block pointed to by `ptr`. - * - * @param ptr Pointer to a memory block already allocated with - * av_realloc() or `NULL` - * @param nmemb Number of elements in the array - * @param size Size of the single element of the array - * - * @return Pointer to a newly-reallocated block or NULL if the block - * cannot be reallocated or the function is used to free the memory block - * - * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be - * correctly aligned. - * @see av_reallocp_array() - */ -av_alloc_size(2, 3) void *av_realloc_array(void *ptr, size_t nmemb, size_t size); - -/** - * Allocate, reallocate, or free an array through a pointer to a pointer. - * - * If `*ptr` is `NULL` and `nmemb` > 0, allocate a new block. If `nmemb` is - * zero, free the memory block pointed to by `*ptr`. - * - * @param[in,out] ptr Pointer to a pointer to a memory block already - * allocated with av_realloc(), or a pointer to `NULL`. - * The pointer is updated on success, or freed on failure. - * @param[in] nmemb Number of elements - * @param[in] size Size of the single element - * - * @return Zero on success, an AVERROR error code on failure - * - * @warning Unlike av_malloc(), the allocated memory is not guaranteed to be - * correctly aligned. - */ -int av_reallocp_array(void *ptr, size_t nmemb, size_t size); - -/** - * Reallocate the given buffer if it is not large enough, otherwise do nothing. - * - * If the given buffer is `NULL`, then a new uninitialized buffer is allocated. - * - * If the given buffer is not large enough, and reallocation fails, `NULL` is - * returned and `*size` is set to 0, but the original buffer is not changed or - * freed. - * - * A typical use pattern follows: - * - * @code{.c} - * uint8_t *buf = ...; - * uint8_t *new_buf = av_fast_realloc(buf, ¤t_size, size_needed); - * if (!new_buf) { - * // Allocation failed; clean up original buffer - * av_freep(&buf); - * return AVERROR(ENOMEM); - * } - * @endcode - * - * @param[in,out] ptr Already allocated buffer, or `NULL` - * @param[in,out] size Pointer to the size of buffer `ptr`. `*size` is - * updated to the new allocated size, in particular 0 - * in case of failure. - * @param[in] min_size Desired minimal size of buffer `ptr` - * @return `ptr` if the buffer is large enough, a pointer to newly reallocated - * buffer if the buffer was not large enough, or `NULL` in case of - * error - * @see av_realloc() - * @see av_fast_malloc() - */ -void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size); - -/** - * Allocate a buffer, reusing the given one if large enough. - * - * Contrary to av_fast_realloc(), the current buffer contents might not be - * preserved and on error the old buffer is freed, thus no special handling to - * avoid memleaks is necessary. - * - * `*ptr` is allowed to be `NULL`, in which case allocation always happens if - * `size_needed` is greater than 0. - * - * @code{.c} - * uint8_t *buf = ...; - * av_fast_malloc(&buf, ¤t_size, size_needed); - * if (!buf) { - * // Allocation failed; buf already freed - * return AVERROR(ENOMEM); - * } - * @endcode - * - * @param[in,out] ptr Pointer to pointer to an already allocated buffer. - * `*ptr` will be overwritten with pointer to new - * buffer on success or `NULL` on failure - * @param[in,out] size Pointer to the size of buffer `*ptr`. `*size` is - * updated to the new allocated size, in particular 0 - * in case of failure. - * @param[in] min_size Desired minimal size of buffer `*ptr` - * @see av_realloc() - * @see av_fast_mallocz() - */ -void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size); - -/** - * Allocate and clear a buffer, reusing the given one if large enough. - * - * Like av_fast_malloc(), but all newly allocated space is initially cleared. - * Reused buffer is not cleared. - * - * `*ptr` is allowed to be `NULL`, in which case allocation always happens if - * `size_needed` is greater than 0. - * - * @param[in,out] ptr Pointer to pointer to an already allocated buffer. - * `*ptr` will be overwritten with pointer to new - * buffer on success or `NULL` on failure - * @param[in,out] size Pointer to the size of buffer `*ptr`. `*size` is - * updated to the new allocated size, in particular 0 - * in case of failure. - * @param[in] min_size Desired minimal size of buffer `*ptr` - * @see av_fast_malloc() - */ -void av_fast_mallocz(void *ptr, unsigned int *size, size_t min_size); - -/** - * Free a memory block which has been allocated with a function of av_malloc() - * or av_realloc() family. - * - * @param ptr Pointer to the memory block which should be freed. - * - * @note `ptr = NULL` is explicitly allowed. - * @note It is recommended that you use av_freep() instead, to prevent leaving - * behind dangling pointers. - * @see av_freep() - */ -void av_free(void *ptr); - -/** - * Free a memory block which has been allocated with a function of av_malloc() - * or av_realloc() family, and set the pointer pointing to it to `NULL`. - * - * @code{.c} - * uint8_t *buf = av_malloc(16); - * av_free(buf); - * // buf now contains a dangling pointer to freed memory, and accidental - * // dereference of buf will result in a use-after-free, which may be a - * // security risk. - * - * uint8_t *buf = av_malloc(16); - * av_freep(&buf); - * // buf is now NULL, and accidental dereference will only result in a - * // NULL-pointer dereference. - * @endcode - * - * @param ptr Pointer to the pointer to the memory block which should be freed - * @note `*ptr = NULL` is safe and leads to no action. - * @see av_free() - */ -void av_freep(void *ptr); - -/** - * Duplicate a string. - * - * @param s String to be duplicated - * @return Pointer to a newly-allocated string containing a - * copy of `s` or `NULL` if the string cannot be allocated - * @see av_strndup() - */ -char *av_strdup(const char *s) av_malloc_attrib; - -/** - * Duplicate a substring of a string. - * - * @param s String to be duplicated - * @param len Maximum length of the resulting string (not counting the - * terminating byte) - * @return Pointer to a newly-allocated string containing a - * substring of `s` or `NULL` if the string cannot be allocated - */ -char *av_strndup(const char *s, size_t len) av_malloc_attrib; - -/** - * Duplicate a buffer with av_malloc(). - * - * @param p Buffer to be duplicated - * @param size Size in bytes of the buffer copied - * @return Pointer to a newly allocated buffer containing a - * copy of `p` or `NULL` if the buffer cannot be allocated - */ -void *av_memdup(const void *p, size_t size); - -/** - * Overlapping memcpy() implementation. - * - * @param dst Destination buffer - * @param back Number of bytes back to start copying (i.e. the initial size of - * the overlapping window); must be > 0 - * @param cnt Number of bytes to copy; must be >= 0 - * - * @note `cnt > back` is valid, this will copy the bytes we just copied, - * thus creating a repeating pattern with a period length of `back`. - */ -void av_memcpy_backptr(uint8_t *dst, int back, int cnt); - -/** - * @} - */ - -/** - * @defgroup lavu_mem_dynarray Dynamic Array - * - * Utilities to make an array grow when needed. - * - * Sometimes, the programmer would want to have an array that can grow when - * needed. The libavutil dynamic array utilities fill that need. - * - * libavutil supports two systems of appending elements onto a dynamically - * allocated array, the first one storing the pointer to the value in the - * array, and the second storing the value directly. In both systems, the - * caller is responsible for maintaining a variable containing the length of - * the array, as well as freeing of the array after use. - * - * The first system stores pointers to values in a block of dynamically - * allocated memory. Since only pointers are stored, the function does not need - * to know the size of the type. Both av_dynarray_add() and - * av_dynarray_add_nofree() implement this system. - * - * @code - * type **array = NULL; //< an array of pointers to values - * int nb = 0; //< a variable to keep track of the length of the array - * - * type to_be_added = ...; - * type to_be_added2 = ...; - * - * av_dynarray_add(&array, &nb, &to_be_added); - * if (nb == 0) - * return AVERROR(ENOMEM); - * - * av_dynarray_add(&array, &nb, &to_be_added2); - * if (nb == 0) - * return AVERROR(ENOMEM); - * - * // Now: - * // nb == 2 - * // &to_be_added == array[0] - * // &to_be_added2 == array[1] - * - * av_freep(&array); - * @endcode - * - * The second system stores the value directly in a block of memory. As a - * result, the function has to know the size of the type. av_dynarray2_add() - * implements this mechanism. - * - * @code - * type *array = NULL; //< an array of values - * int nb = 0; //< a variable to keep track of the length of the array - * - * type to_be_added = ...; - * type to_be_added2 = ...; - * - * type *addr = av_dynarray2_add((void **)&array, &nb, sizeof(*array), NULL); - * if (!addr) - * return AVERROR(ENOMEM); - * memcpy(addr, &to_be_added, sizeof(to_be_added)); - * - * // Shortcut of the above. - * type *addr = av_dynarray2_add((void **)&array, &nb, sizeof(*array), - * (const void *)&to_be_added2); - * if (!addr) - * return AVERROR(ENOMEM); - * - * // Now: - * // nb == 2 - * // to_be_added == array[0] - * // to_be_added2 == array[1] - * - * av_freep(&array); - * @endcode - * - * @{ - */ - -/** - * Add the pointer to an element to a dynamic array. - * - * The array to grow is supposed to be an array of pointers to - * structures, and the element to add must be a pointer to an already - * allocated structure. - * - * The array is reallocated when its size reaches powers of 2. - * Therefore, the amortized cost of adding an element is constant. - * - * In case of success, the pointer to the array is updated in order to - * point to the new grown array, and the number pointed to by `nb_ptr` - * is incremented. - * In case of failure, the array is freed, `*tab_ptr` is set to `NULL` and - * `*nb_ptr` is set to 0. - * - * @param[in,out] tab_ptr Pointer to the array to grow - * @param[in,out] nb_ptr Pointer to the number of elements in the array - * @param[in] elem Element to add - * @see av_dynarray_add_nofree(), av_dynarray2_add() - */ -void av_dynarray_add(void *tab_ptr, int *nb_ptr, void *elem); - -/** - * Add an element to a dynamic array. - * - * Function has the same functionality as av_dynarray_add(), - * but it doesn't free memory on fails. It returns error code - * instead and leave current buffer untouched. - * - * @return >=0 on success, negative otherwise - * @see av_dynarray_add(), av_dynarray2_add() - */ -av_warn_unused_result -int av_dynarray_add_nofree(void *tab_ptr, int *nb_ptr, void *elem); - -/** - * Add an element of size `elem_size` to a dynamic array. - * - * The array is reallocated when its number of elements reaches powers of 2. - * Therefore, the amortized cost of adding an element is constant. - * - * In case of success, the pointer to the array is updated in order to - * point to the new grown array, and the number pointed to by `nb_ptr` - * is incremented. - * In case of failure, the array is freed, `*tab_ptr` is set to `NULL` and - * `*nb_ptr` is set to 0. - * - * @param[in,out] tab_ptr Pointer to the array to grow - * @param[in,out] nb_ptr Pointer to the number of elements in the array - * @param[in] elem_size Size in bytes of an element in the array - * @param[in] elem_data Pointer to the data of the element to add. If - * `NULL`, the space of the newly added element is - * allocated but left uninitialized. - * - * @return Pointer to the data of the element to copy in the newly allocated - * space - * @see av_dynarray_add(), av_dynarray_add_nofree() - */ -void *av_dynarray2_add(void **tab_ptr, int *nb_ptr, size_t elem_size, - const uint8_t *elem_data); - -/** - * @} - */ - -/** - * @defgroup lavu_mem_misc Miscellaneous Functions - * - * Other functions related to memory allocation. - * - * @{ - */ - -/** - * Multiply two `size_t` values checking for overflow. - * - * @param[in] a,b Operands of multiplication - * @param[out] r Pointer to the result of the operation - * @return 0 on success, AVERROR(EINVAL) on overflow - */ -static inline int av_size_mult(size_t a, size_t b, size_t *r) -{ - size_t t = a * b; - /* Hack inspired from glibc: don't try the division if nelem and elsize - * are both less than sqrt(SIZE_MAX). */ - if ((a | b) >= ((size_t)1 << (sizeof(size_t) * 4)) && a && t / a != b) - return AVERROR(EINVAL); - *r = t; - return 0; -} - -/** - * Set the maximum size that may be allocated in one block. - * - * The value specified with this function is effective for all libavutil's @ref - * lavu_mem_funcs "heap management functions." - * - * By default, the max value is defined as `INT_MAX`. - * - * @param max Value to be set as the new maximum size - * - * @warning Exercise extreme caution when using this function. Don't touch - * this if you do not understand the full consequence of doing so. - */ -void av_max_alloc(size_t max); - -/** - * @} - * @} - */ - -#endif /* AVUTIL_MEM_H */ diff --git a/maclibs/include/libavutil/opt.h b/maclibs/include/libavutil/opt.h deleted file mode 100644 index 39f4a8dd..00000000 --- a/maclibs/include/libavutil/opt.h +++ /dev/null @@ -1,865 +0,0 @@ -/* - * AVOptions - * copyright (c) 2005 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_OPT_H -#define AVUTIL_OPT_H - -/** - * @file - * AVOptions - */ - -#include "rational.h" -#include "avutil.h" -#include "dict.h" -#include "log.h" -#include "pixfmt.h" -#include "samplefmt.h" -#include "version.h" - -/** - * @defgroup avoptions AVOptions - * @ingroup lavu_data - * @{ - * AVOptions provide a generic system to declare options on arbitrary structs - * ("objects"). An option can have a help text, a type and a range of possible - * values. Options may then be enumerated, read and written to. - * - * @section avoptions_implement Implementing AVOptions - * This section describes how to add AVOptions capabilities to a struct. - * - * All AVOptions-related information is stored in an AVClass. Therefore - * the first member of the struct should be a pointer to an AVClass describing it. - * The option field of the AVClass must be set to a NULL-terminated static array - * of AVOptions. Each AVOption must have a non-empty name, a type, a default - * value and for number-type AVOptions also a range of allowed values. It must - * also declare an offset in bytes from the start of the struct, where the field - * associated with this AVOption is located. Other fields in the AVOption struct - * should also be set when applicable, but are not required. - * - * The following example illustrates an AVOptions-enabled struct: - * @code - * typedef struct test_struct { - * const AVClass *class; - * int int_opt; - * char *str_opt; - * uint8_t *bin_opt; - * int bin_len; - * } test_struct; - * - * static const AVOption test_options[] = { - * { "test_int", "This is a test option of int type.", offsetof(test_struct, int_opt), - * AV_OPT_TYPE_INT, { .i64 = -1 }, INT_MIN, INT_MAX }, - * { "test_str", "This is a test option of string type.", offsetof(test_struct, str_opt), - * AV_OPT_TYPE_STRING }, - * { "test_bin", "This is a test option of binary type.", offsetof(test_struct, bin_opt), - * AV_OPT_TYPE_BINARY }, - * { NULL }, - * }; - * - * static const AVClass test_class = { - * .class_name = "test class", - * .item_name = av_default_item_name, - * .option = test_options, - * .version = LIBAVUTIL_VERSION_INT, - * }; - * @endcode - * - * Next, when allocating your struct, you must ensure that the AVClass pointer - * is set to the correct value. Then, av_opt_set_defaults() can be called to - * initialize defaults. After that the struct is ready to be used with the - * AVOptions API. - * - * When cleaning up, you may use the av_opt_free() function to automatically - * free all the allocated string and binary options. - * - * Continuing with the above example: - * - * @code - * test_struct *alloc_test_struct(void) - * { - * test_struct *ret = av_mallocz(sizeof(*ret)); - * ret->class = &test_class; - * av_opt_set_defaults(ret); - * return ret; - * } - * void free_test_struct(test_struct **foo) - * { - * av_opt_free(*foo); - * av_freep(foo); - * } - * @endcode - * - * @subsection avoptions_implement_nesting Nesting - * It may happen that an AVOptions-enabled struct contains another - * AVOptions-enabled struct as a member (e.g. AVCodecContext in - * libavcodec exports generic options, while its priv_data field exports - * codec-specific options). In such a case, it is possible to set up the - * parent struct to export a child's options. To do that, simply - * implement AVClass.child_next() and AVClass.child_class_next() in the - * parent struct's AVClass. - * Assuming that the test_struct from above now also contains a - * child_struct field: - * - * @code - * typedef struct child_struct { - * AVClass *class; - * int flags_opt; - * } child_struct; - * static const AVOption child_opts[] = { - * { "test_flags", "This is a test option of flags type.", - * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX }, - * { NULL }, - * }; - * static const AVClass child_class = { - * .class_name = "child class", - * .item_name = av_default_item_name, - * .option = child_opts, - * .version = LIBAVUTIL_VERSION_INT, - * }; - * - * void *child_next(void *obj, void *prev) - * { - * test_struct *t = obj; - * if (!prev && t->child_struct) - * return t->child_struct; - * return NULL - * } - * const AVClass child_class_next(const AVClass *prev) - * { - * return prev ? NULL : &child_class; - * } - * @endcode - * Putting child_next() and child_class_next() as defined above into - * test_class will now make child_struct's options accessible through - * test_struct (again, proper setup as described above needs to be done on - * child_struct right after it is created). - * - * From the above example it might not be clear why both child_next() - * and child_class_next() are needed. The distinction is that child_next() - * iterates over actually existing objects, while child_class_next() - * iterates over all possible child classes. E.g. if an AVCodecContext - * was initialized to use a codec which has private options, then its - * child_next() will return AVCodecContext.priv_data and finish - * iterating. OTOH child_class_next() on AVCodecContext.av_class will - * iterate over all available codecs with private options. - * - * @subsection avoptions_implement_named_constants Named constants - * It is possible to create named constants for options. Simply set the unit - * field of the option the constants should apply to a string and - * create the constants themselves as options of type AV_OPT_TYPE_CONST - * with their unit field set to the same string. - * Their default_val field should contain the value of the named - * constant. - * For example, to add some named constants for the test_flags option - * above, put the following into the child_opts array: - * @code - * { "test_flags", "This is a test option of flags type.", - * offsetof(child_struct, flags_opt), AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT_MIN, INT_MAX, "test_unit" }, - * { "flag1", "This is a flag with value 16", 0, AV_OPT_TYPE_CONST, { .i64 = 16 }, 0, 0, "test_unit" }, - * @endcode - * - * @section avoptions_use Using AVOptions - * This section deals with accessing options in an AVOptions-enabled struct. - * Such structs in FFmpeg are e.g. AVCodecContext in libavcodec or - * AVFormatContext in libavformat. - * - * @subsection avoptions_use_examine Examining AVOptions - * The basic functions for examining options are av_opt_next(), which iterates - * over all options defined for one object, and av_opt_find(), which searches - * for an option with the given name. - * - * The situation is more complicated with nesting. An AVOptions-enabled struct - * may have AVOptions-enabled children. Passing the AV_OPT_SEARCH_CHILDREN flag - * to av_opt_find() will make the function search children recursively. - * - * For enumerating there are basically two cases. The first is when you want to - * get all options that may potentially exist on the struct and its children - * (e.g. when constructing documentation). In that case you should call - * av_opt_child_class_next() recursively on the parent struct's AVClass. The - * second case is when you have an already initialized struct with all its - * children and you want to get all options that can be actually written or read - * from it. In that case you should call av_opt_child_next() recursively (and - * av_opt_next() on each result). - * - * @subsection avoptions_use_get_set Reading and writing AVOptions - * When setting options, you often have a string read directly from the - * user. In such a case, simply passing it to av_opt_set() is enough. For - * non-string type options, av_opt_set() will parse the string according to the - * option type. - * - * Similarly av_opt_get() will read any option type and convert it to a string - * which will be returned. Do not forget that the string is allocated, so you - * have to free it with av_free(). - * - * In some cases it may be more convenient to put all options into an - * AVDictionary and call av_opt_set_dict() on it. A specific case of this - * are the format/codec open functions in lavf/lavc which take a dictionary - * filled with option as a parameter. This makes it possible to set some options - * that cannot be set otherwise, since e.g. the input file format is not known - * before the file is actually opened. - */ - -enum AVOptionType{ - AV_OPT_TYPE_FLAGS, - AV_OPT_TYPE_INT, - AV_OPT_TYPE_INT64, - AV_OPT_TYPE_DOUBLE, - AV_OPT_TYPE_FLOAT, - AV_OPT_TYPE_STRING, - AV_OPT_TYPE_RATIONAL, - AV_OPT_TYPE_BINARY, ///< offset must point to a pointer immediately followed by an int for the length - AV_OPT_TYPE_DICT, - AV_OPT_TYPE_UINT64, - AV_OPT_TYPE_CONST, - AV_OPT_TYPE_IMAGE_SIZE, ///< offset must point to two consecutive integers - AV_OPT_TYPE_PIXEL_FMT, - AV_OPT_TYPE_SAMPLE_FMT, - AV_OPT_TYPE_VIDEO_RATE, ///< offset must point to AVRational - AV_OPT_TYPE_DURATION, - AV_OPT_TYPE_COLOR, - AV_OPT_TYPE_CHANNEL_LAYOUT, - AV_OPT_TYPE_BOOL, -}; - -/** - * AVOption - */ -typedef struct AVOption { - const char *name; - - /** - * short English help text - * @todo What about other languages? - */ - const char *help; - - /** - * The offset relative to the context structure where the option - * value is stored. It should be 0 for named constants. - */ - int offset; - enum AVOptionType type; - - /** - * the default value for scalar options - */ - union { - int64_t i64; - double dbl; - const char *str; - /* TODO those are unused now */ - AVRational q; - } default_val; - double min; ///< minimum valid value for the option - double max; ///< maximum valid value for the option - - int flags; -#define AV_OPT_FLAG_ENCODING_PARAM 1 ///< a generic parameter which can be set by the user for muxing or encoding -#define AV_OPT_FLAG_DECODING_PARAM 2 ///< a generic parameter which can be set by the user for demuxing or decoding -#define AV_OPT_FLAG_AUDIO_PARAM 8 -#define AV_OPT_FLAG_VIDEO_PARAM 16 -#define AV_OPT_FLAG_SUBTITLE_PARAM 32 -/** - * The option is intended for exporting values to the caller. - */ -#define AV_OPT_FLAG_EXPORT 64 -/** - * The option may not be set through the AVOptions API, only read. - * This flag only makes sense when AV_OPT_FLAG_EXPORT is also set. - */ -#define AV_OPT_FLAG_READONLY 128 -#define AV_OPT_FLAG_BSF_PARAM (1<<8) ///< a generic parameter which can be set by the user for bit stream filtering -#define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering -#define AV_OPT_FLAG_DEPRECATED (1<<17) ///< set if option is deprecated, users should refer to AVOption.help text for more information -//FIXME think about enc-audio, ... style flags - - /** - * The logical unit to which the option belongs. Non-constant - * options and corresponding named constants share the same - * unit. May be NULL. - */ - const char *unit; -} AVOption; - -/** - * A single allowed range of values, or a single allowed value. - */ -typedef struct AVOptionRange { - const char *str; - /** - * Value range. - * For string ranges this represents the min/max length. - * For dimensions this represents the min/max pixel count or width/height in multi-component case. - */ - double value_min, value_max; - /** - * Value's component range. - * For string this represents the unicode range for chars, 0-127 limits to ASCII. - */ - double component_min, component_max; - /** - * Range flag. - * If set to 1 the struct encodes a range, if set to 0 a single value. - */ - int is_range; -} AVOptionRange; - -/** - * List of AVOptionRange structs. - */ -typedef struct AVOptionRanges { - /** - * Array of option ranges. - * - * Most of option types use just one component. - * Following describes multi-component option types: - * - * AV_OPT_TYPE_IMAGE_SIZE: - * component index 0: range of pixel count (width * height). - * component index 1: range of width. - * component index 2: range of height. - * - * @note To obtain multi-component version of this structure, user must - * provide AV_OPT_MULTI_COMPONENT_RANGE to av_opt_query_ranges or - * av_opt_query_ranges_default function. - * - * Multi-component range can be read as in following example: - * - * @code - * int range_index, component_index; - * AVOptionRanges *ranges; - * AVOptionRange *range[3]; //may require more than 3 in the future. - * av_opt_query_ranges(&ranges, obj, key, AV_OPT_MULTI_COMPONENT_RANGE); - * for (range_index = 0; range_index < ranges->nb_ranges; range_index++) { - * for (component_index = 0; component_index < ranges->nb_components; component_index++) - * range[component_index] = ranges->range[ranges->nb_ranges * component_index + range_index]; - * //do something with range here. - * } - * av_opt_freep_ranges(&ranges); - * @endcode - */ - AVOptionRange **range; - /** - * Number of ranges per component. - */ - int nb_ranges; - /** - * Number of componentes. - */ - int nb_components; -} AVOptionRanges; - -/** - * Show the obj options. - * - * @param req_flags requested flags for the options to show. Show only the - * options for which it is opt->flags & req_flags. - * @param rej_flags rejected flags for the options to show. Show only the - * options for which it is !(opt->flags & req_flags). - * @param av_log_obj log context to use for showing the options - */ -int av_opt_show2(void *obj, void *av_log_obj, int req_flags, int rej_flags); - -/** - * Set the values of all AVOption fields to their default values. - * - * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass) - */ -void av_opt_set_defaults(void *s); - -/** - * Set the values of all AVOption fields to their default values. Only these - * AVOption fields for which (opt->flags & mask) == flags will have their - * default applied to s. - * - * @param s an AVOption-enabled struct (its first member must be a pointer to AVClass) - * @param mask combination of AV_OPT_FLAG_* - * @param flags combination of AV_OPT_FLAG_* - */ -void av_opt_set_defaults2(void *s, int mask, int flags); - -/** - * Parse the key/value pairs list in opts. For each key/value pair - * found, stores the value in the field in ctx that is named like the - * key. ctx must be an AVClass context, storing is done using - * AVOptions. - * - * @param opts options string to parse, may be NULL - * @param key_val_sep a 0-terminated list of characters used to - * separate key from value - * @param pairs_sep a 0-terminated list of characters used to separate - * two pairs from each other - * @return the number of successfully set key/value pairs, or a negative - * value corresponding to an AVERROR code in case of error: - * AVERROR(EINVAL) if opts cannot be parsed, - * the error code issued by av_opt_set() if a key/value pair - * cannot be set - */ -int av_set_options_string(void *ctx, const char *opts, - const char *key_val_sep, const char *pairs_sep); - -/** - * Parse the key-value pairs list in opts. For each key=value pair found, - * set the value of the corresponding option in ctx. - * - * @param ctx the AVClass object to set options on - * @param opts the options string, key-value pairs separated by a - * delimiter - * @param shorthand a NULL-terminated array of options names for shorthand - * notation: if the first field in opts has no key part, - * the key is taken from the first element of shorthand; - * then again for the second, etc., until either opts is - * finished, shorthand is finished or a named option is - * found; after that, all options must be named - * @param key_val_sep a 0-terminated list of characters used to separate - * key from value, for example '=' - * @param pairs_sep a 0-terminated list of characters used to separate - * two pairs from each other, for example ':' or ',' - * @return the number of successfully set key=value pairs, or a negative - * value corresponding to an AVERROR code in case of error: - * AVERROR(EINVAL) if opts cannot be parsed, - * the error code issued by av_set_string3() if a key/value pair - * cannot be set - * - * Options names must use only the following characters: a-z A-Z 0-9 - . / _ - * Separators must use characters distinct from option names and from each - * other. - */ -int av_opt_set_from_string(void *ctx, const char *opts, - const char *const *shorthand, - const char *key_val_sep, const char *pairs_sep); -/** - * Free all allocated objects in obj. - */ -void av_opt_free(void *obj); - -/** - * Check whether a particular flag is set in a flags field. - * - * @param field_name the name of the flag field option - * @param flag_name the name of the flag to check - * @return non-zero if the flag is set, zero if the flag isn't set, - * isn't of the right type, or the flags field doesn't exist. - */ -int av_opt_flag_is_set(void *obj, const char *field_name, const char *flag_name); - -/** - * Set all the options from a given dictionary on an object. - * - * @param obj a struct whose first element is a pointer to AVClass - * @param options options to process. This dictionary will be freed and replaced - * by a new one containing all options not found in obj. - * Of course this new dictionary needs to be freed by caller - * with av_dict_free(). - * - * @return 0 on success, a negative AVERROR if some option was found in obj, - * but could not be set. - * - * @see av_dict_copy() - */ -int av_opt_set_dict(void *obj, struct AVDictionary **options); - - -/** - * Set all the options from a given dictionary on an object. - * - * @param obj a struct whose first element is a pointer to AVClass - * @param options options to process. This dictionary will be freed and replaced - * by a new one containing all options not found in obj. - * Of course this new dictionary needs to be freed by caller - * with av_dict_free(). - * @param search_flags A combination of AV_OPT_SEARCH_*. - * - * @return 0 on success, a negative AVERROR if some option was found in obj, - * but could not be set. - * - * @see av_dict_copy() - */ -int av_opt_set_dict2(void *obj, struct AVDictionary **options, int search_flags); - -/** - * Extract a key-value pair from the beginning of a string. - * - * @param ropts pointer to the options string, will be updated to - * point to the rest of the string (one of the pairs_sep - * or the final NUL) - * @param key_val_sep a 0-terminated list of characters used to separate - * key from value, for example '=' - * @param pairs_sep a 0-terminated list of characters used to separate - * two pairs from each other, for example ':' or ',' - * @param flags flags; see the AV_OPT_FLAG_* values below - * @param rkey parsed key; must be freed using av_free() - * @param rval parsed value; must be freed using av_free() - * - * @return >=0 for success, or a negative value corresponding to an - * AVERROR code in case of error; in particular: - * AVERROR(EINVAL) if no key is present - * - */ -int av_opt_get_key_value(const char **ropts, - const char *key_val_sep, const char *pairs_sep, - unsigned flags, - char **rkey, char **rval); - -enum { - - /** - * Accept to parse a value without a key; the key will then be returned - * as NULL. - */ - AV_OPT_FLAG_IMPLICIT_KEY = 1, -}; - -/** - * @defgroup opt_eval_funcs Evaluating option strings - * @{ - * This group of functions can be used to evaluate option strings - * and get numbers out of them. They do the same thing as av_opt_set(), - * except the result is written into the caller-supplied pointer. - * - * @param obj a struct whose first element is a pointer to AVClass. - * @param o an option for which the string is to be evaluated. - * @param val string to be evaluated. - * @param *_out value of the string will be written here. - * - * @return 0 on success, a negative number on failure. - */ -int av_opt_eval_flags (void *obj, const AVOption *o, const char *val, int *flags_out); -int av_opt_eval_int (void *obj, const AVOption *o, const char *val, int *int_out); -int av_opt_eval_int64 (void *obj, const AVOption *o, const char *val, int64_t *int64_out); -int av_opt_eval_float (void *obj, const AVOption *o, const char *val, float *float_out); -int av_opt_eval_double(void *obj, const AVOption *o, const char *val, double *double_out); -int av_opt_eval_q (void *obj, const AVOption *o, const char *val, AVRational *q_out); -/** - * @} - */ - -#define AV_OPT_SEARCH_CHILDREN (1 << 0) /**< Search in possible children of the - given object first. */ -/** - * The obj passed to av_opt_find() is fake -- only a double pointer to AVClass - * instead of a required pointer to a struct containing AVClass. This is - * useful for searching for options without needing to allocate the corresponding - * object. - */ -#define AV_OPT_SEARCH_FAKE_OBJ (1 << 1) - -/** - * In av_opt_get, return NULL if the option has a pointer type and is set to NULL, - * rather than returning an empty string. - */ -#define AV_OPT_ALLOW_NULL (1 << 2) - -/** - * Allows av_opt_query_ranges and av_opt_query_ranges_default to return more than - * one component for certain option types. - * @see AVOptionRanges for details. - */ -#define AV_OPT_MULTI_COMPONENT_RANGE (1 << 12) - -/** - * Look for an option in an object. Consider only options which - * have all the specified flags set. - * - * @param[in] obj A pointer to a struct whose first element is a - * pointer to an AVClass. - * Alternatively a double pointer to an AVClass, if - * AV_OPT_SEARCH_FAKE_OBJ search flag is set. - * @param[in] name The name of the option to look for. - * @param[in] unit When searching for named constants, name of the unit - * it belongs to. - * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG). - * @param search_flags A combination of AV_OPT_SEARCH_*. - * - * @return A pointer to the option found, or NULL if no option - * was found. - * - * @note Options found with AV_OPT_SEARCH_CHILDREN flag may not be settable - * directly with av_opt_set(). Use special calls which take an options - * AVDictionary (e.g. avformat_open_input()) to set options found with this - * flag. - */ -const AVOption *av_opt_find(void *obj, const char *name, const char *unit, - int opt_flags, int search_flags); - -/** - * Look for an option in an object. Consider only options which - * have all the specified flags set. - * - * @param[in] obj A pointer to a struct whose first element is a - * pointer to an AVClass. - * Alternatively a double pointer to an AVClass, if - * AV_OPT_SEARCH_FAKE_OBJ search flag is set. - * @param[in] name The name of the option to look for. - * @param[in] unit When searching for named constants, name of the unit - * it belongs to. - * @param opt_flags Find only options with all the specified flags set (AV_OPT_FLAG). - * @param search_flags A combination of AV_OPT_SEARCH_*. - * @param[out] target_obj if non-NULL, an object to which the option belongs will be - * written here. It may be different from obj if AV_OPT_SEARCH_CHILDREN is present - * in search_flags. This parameter is ignored if search_flags contain - * AV_OPT_SEARCH_FAKE_OBJ. - * - * @return A pointer to the option found, or NULL if no option - * was found. - */ -const AVOption *av_opt_find2(void *obj, const char *name, const char *unit, - int opt_flags, int search_flags, void **target_obj); - -/** - * Iterate over all AVOptions belonging to obj. - * - * @param obj an AVOptions-enabled struct or a double pointer to an - * AVClass describing it. - * @param prev result of the previous call to av_opt_next() on this object - * or NULL - * @return next AVOption or NULL - */ -const AVOption *av_opt_next(const void *obj, const AVOption *prev); - -/** - * Iterate over AVOptions-enabled children of obj. - * - * @param prev result of a previous call to this function or NULL - * @return next AVOptions-enabled child or NULL - */ -void *av_opt_child_next(void *obj, void *prev); - -/** - * Iterate over potential AVOptions-enabled children of parent. - * - * @param prev result of a previous call to this function or NULL - * @return AVClass corresponding to next potential child or NULL - */ -const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev); - -/** - * @defgroup opt_set_funcs Option setting functions - * @{ - * Those functions set the field of obj with the given name to value. - * - * @param[in] obj A struct whose first element is a pointer to an AVClass. - * @param[in] name the name of the field to set - * @param[in] val The value to set. In case of av_opt_set() if the field is not - * of a string type, then the given string is parsed. - * SI postfixes and some named scalars are supported. - * If the field is of a numeric type, it has to be a numeric or named - * scalar. Behavior with more than one scalar and +- infix operators - * is undefined. - * If the field is of a flags type, it has to be a sequence of numeric - * scalars or named flags separated by '+' or '-'. Prefixing a flag - * with '+' causes it to be set without affecting the other flags; - * similarly, '-' unsets a flag. - * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN - * is passed here, then the option may be set on a child of obj. - * - * @return 0 if the value has been set, or an AVERROR code in case of - * error: - * AVERROR_OPTION_NOT_FOUND if no matching option exists - * AVERROR(ERANGE) if the value is out of range - * AVERROR(EINVAL) if the value is not valid - */ -int av_opt_set (void *obj, const char *name, const char *val, int search_flags); -int av_opt_set_int (void *obj, const char *name, int64_t val, int search_flags); -int av_opt_set_double (void *obj, const char *name, double val, int search_flags); -int av_opt_set_q (void *obj, const char *name, AVRational val, int search_flags); -int av_opt_set_bin (void *obj, const char *name, const uint8_t *val, int size, int search_flags); -int av_opt_set_image_size(void *obj, const char *name, int w, int h, int search_flags); -int av_opt_set_pixel_fmt (void *obj, const char *name, enum AVPixelFormat fmt, int search_flags); -int av_opt_set_sample_fmt(void *obj, const char *name, enum AVSampleFormat fmt, int search_flags); -int av_opt_set_video_rate(void *obj, const char *name, AVRational val, int search_flags); -int av_opt_set_channel_layout(void *obj, const char *name, int64_t ch_layout, int search_flags); -/** - * @note Any old dictionary present is discarded and replaced with a copy of the new one. The - * caller still owns val is and responsible for freeing it. - */ -int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, int search_flags); - -/** - * Set a binary option to an integer list. - * - * @param obj AVClass object to set options on - * @param name name of the binary option - * @param val pointer to an integer list (must have the correct type with - * regard to the contents of the list) - * @param term list terminator (usually 0 or -1) - * @param flags search flags - */ -#define av_opt_set_int_list(obj, name, val, term, flags) \ - (av_int_list_length(val, term) > INT_MAX / sizeof(*(val)) ? \ - AVERROR(EINVAL) : \ - av_opt_set_bin(obj, name, (const uint8_t *)(val), \ - av_int_list_length(val, term) * sizeof(*(val)), flags)) - -/** - * @} - */ - -/** - * @defgroup opt_get_funcs Option getting functions - * @{ - * Those functions get a value of the option with the given name from an object. - * - * @param[in] obj a struct whose first element is a pointer to an AVClass. - * @param[in] name name of the option to get. - * @param[in] search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN - * is passed here, then the option may be found in a child of obj. - * @param[out] out_val value of the option will be written here - * @return >=0 on success, a negative error code otherwise - */ -/** - * @note the returned string will be av_malloc()ed and must be av_free()ed by the caller - * - * @note if AV_OPT_ALLOW_NULL is set in search_flags in av_opt_get, and the option has - * AV_OPT_TYPE_STRING or AV_OPT_TYPE_BINARY and is set to NULL, *out_val will be set - * to NULL instead of an allocated empty string. - */ -int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val); -int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val); -int av_opt_get_double (void *obj, const char *name, int search_flags, double *out_val); -int av_opt_get_q (void *obj, const char *name, int search_flags, AVRational *out_val); -int av_opt_get_image_size(void *obj, const char *name, int search_flags, int *w_out, int *h_out); -int av_opt_get_pixel_fmt (void *obj, const char *name, int search_flags, enum AVPixelFormat *out_fmt); -int av_opt_get_sample_fmt(void *obj, const char *name, int search_flags, enum AVSampleFormat *out_fmt); -int av_opt_get_video_rate(void *obj, const char *name, int search_flags, AVRational *out_val); -int av_opt_get_channel_layout(void *obj, const char *name, int search_flags, int64_t *ch_layout); -/** - * @param[out] out_val The returned dictionary is a copy of the actual value and must - * be freed with av_dict_free() by the caller - */ -int av_opt_get_dict_val(void *obj, const char *name, int search_flags, AVDictionary **out_val); -/** - * @} - */ -/** - * Gets a pointer to the requested field in a struct. - * This function allows accessing a struct even when its fields are moved or - * renamed since the application making the access has been compiled, - * - * @returns a pointer to the field, it can be cast to the correct type and read - * or written to. - */ -void *av_opt_ptr(const AVClass *avclass, void *obj, const char *name); - -/** - * Free an AVOptionRanges struct and set it to NULL. - */ -void av_opt_freep_ranges(AVOptionRanges **ranges); - -/** - * Get a list of allowed ranges for the given option. - * - * The returned list may depend on other fields in obj like for example profile. - * - * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored - * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance - * AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges - * - * The result must be freed with av_opt_freep_ranges. - * - * @return number of compontents returned on success, a negative errro code otherwise - */ -int av_opt_query_ranges(AVOptionRanges **, void *obj, const char *key, int flags); - -/** - * Copy options from src object into dest object. - * - * Options that require memory allocation (e.g. string or binary) are malloc'ed in dest object. - * Original memory allocated for such options is freed unless both src and dest options points to the same memory. - * - * @param dest Object to copy from - * @param src Object to copy into - * @return 0 on success, negative on error - */ -int av_opt_copy(void *dest, const void *src); - -/** - * Get a default list of allowed ranges for the given option. - * - * This list is constructed without using the AVClass.query_ranges() callback - * and can be used as fallback from within the callback. - * - * @param flags is a bitmask of flags, undefined flags should not be set and should be ignored - * AV_OPT_SEARCH_FAKE_OBJ indicates that the obj is a double pointer to a AVClass instead of a full instance - * AV_OPT_MULTI_COMPONENT_RANGE indicates that function may return more than one component, @see AVOptionRanges - * - * The result must be freed with av_opt_free_ranges. - * - * @return number of compontents returned on success, a negative errro code otherwise - */ -int av_opt_query_ranges_default(AVOptionRanges **, void *obj, const char *key, int flags); - -/** - * Check if given option is set to its default value. - * - * Options o must belong to the obj. This function must not be called to check child's options state. - * @see av_opt_is_set_to_default_by_name(). - * - * @param obj AVClass object to check option on - * @param o option to be checked - * @return >0 when option is set to its default, - * 0 when option is not set its default, - * <0 on error - */ -int av_opt_is_set_to_default(void *obj, const AVOption *o); - -/** - * Check if given option is set to its default value. - * - * @param obj AVClass object to check option on - * @param name option name - * @param search_flags combination of AV_OPT_SEARCH_* - * @return >0 when option is set to its default, - * 0 when option is not set its default, - * <0 on error - */ -int av_opt_is_set_to_default_by_name(void *obj, const char *name, int search_flags); - - -#define AV_OPT_SERIALIZE_SKIP_DEFAULTS 0x00000001 ///< Serialize options that are not set to default values only. -#define AV_OPT_SERIALIZE_OPT_FLAGS_EXACT 0x00000002 ///< Serialize options that exactly match opt_flags only. - -/** - * Serialize object's options. - * - * Create a string containing object's serialized options. - * Such string may be passed back to av_opt_set_from_string() in order to restore option values. - * A key/value or pairs separator occurring in the serialized value or - * name string are escaped through the av_escape() function. - * - * @param[in] obj AVClass object to serialize - * @param[in] opt_flags serialize options with all the specified flags set (AV_OPT_FLAG) - * @param[in] flags combination of AV_OPT_SERIALIZE_* flags - * @param[out] buffer Pointer to buffer that will be allocated with string containg serialized options. - * Buffer must be freed by the caller when is no longer needed. - * @param[in] key_val_sep character used to separate key from value - * @param[in] pairs_sep character used to separate two pairs from each other - * @return >= 0 on success, negative on error - * @warning Separators cannot be neither '\\' nor '\0'. They also cannot be the same. - */ -int av_opt_serialize(void *obj, int opt_flags, int flags, char **buffer, - const char key_val_sep, const char pairs_sep); -/** - * @} - */ - -#endif /* AVUTIL_OPT_H */ diff --git a/maclibs/include/libavutil/pixfmt.h b/maclibs/include/libavutil/pixfmt.h deleted file mode 100644 index 8b54c941..00000000 --- a/maclibs/include/libavutil/pixfmt.h +++ /dev/null @@ -1,552 +0,0 @@ -/* - * copyright (c) 2006 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_PIXFMT_H -#define AVUTIL_PIXFMT_H - -/** - * @file - * pixel format definitions - */ - -#include "libavutil/avconfig.h" -#include "version.h" - -#define AVPALETTE_SIZE 1024 -#define AVPALETTE_COUNT 256 - -/** - * Pixel format. - * - * @note - * AV_PIX_FMT_RGB32 is handled in an endian-specific manner. An RGBA - * color is put together as: - * (A << 24) | (R << 16) | (G << 8) | B - * This is stored as BGRA on little-endian CPU architectures and ARGB on - * big-endian CPUs. - * - * @note - * If the resolution is not a multiple of the chroma subsampling factor - * then the chroma plane resolution must be rounded up. - * - * @par - * When the pixel format is palettized RGB32 (AV_PIX_FMT_PAL8), the palettized - * image data is stored in AVFrame.data[0]. The palette is transported in - * AVFrame.data[1], is 1024 bytes long (256 4-byte entries) and is - * formatted the same as in AV_PIX_FMT_RGB32 described above (i.e., it is - * also endian-specific). Note also that the individual RGB32 palette - * components stored in AVFrame.data[1] should be in the range 0..255. - * This is important as many custom PAL8 video codecs that were designed - * to run on the IBM VGA graphics adapter use 6-bit palette components. - * - * @par - * For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like - * for pal8. This palette is filled in automatically by the function - * allocating the picture. - */ -enum AVPixelFormat { - AV_PIX_FMT_NONE = -1, - AV_PIX_FMT_YUV420P, ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples) - AV_PIX_FMT_YUYV422, ///< packed YUV 4:2:2, 16bpp, Y0 Cb Y1 Cr - AV_PIX_FMT_RGB24, ///< packed RGB 8:8:8, 24bpp, RGBRGB... - AV_PIX_FMT_BGR24, ///< packed RGB 8:8:8, 24bpp, BGRBGR... - AV_PIX_FMT_YUV422P, ///< planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) - AV_PIX_FMT_YUV444P, ///< planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples) - AV_PIX_FMT_YUV410P, ///< planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples) - AV_PIX_FMT_YUV411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) - AV_PIX_FMT_GRAY8, ///< Y , 8bpp - AV_PIX_FMT_MONOWHITE, ///< Y , 1bpp, 0 is white, 1 is black, in each byte pixels are ordered from the msb to the lsb - AV_PIX_FMT_MONOBLACK, ///< Y , 1bpp, 0 is black, 1 is white, in each byte pixels are ordered from the msb to the lsb - AV_PIX_FMT_PAL8, ///< 8 bits with AV_PIX_FMT_RGB32 palette - AV_PIX_FMT_YUVJ420P, ///< planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting color_range - AV_PIX_FMT_YUVJ422P, ///< planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting color_range - AV_PIX_FMT_YUVJ444P, ///< planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting color_range - AV_PIX_FMT_UYVY422, ///< packed YUV 4:2:2, 16bpp, Cb Y0 Cr Y1 - AV_PIX_FMT_UYYVYY411, ///< packed YUV 4:1:1, 12bpp, Cb Y0 Y1 Cr Y2 Y3 - AV_PIX_FMT_BGR8, ///< packed RGB 3:3:2, 8bpp, (msb)2B 3G 3R(lsb) - AV_PIX_FMT_BGR4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1B 2G 1R(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits - AV_PIX_FMT_BGR4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1B 2G 1R(lsb) - AV_PIX_FMT_RGB8, ///< packed RGB 3:3:2, 8bpp, (msb)2R 3G 3B(lsb) - AV_PIX_FMT_RGB4, ///< packed RGB 1:2:1 bitstream, 4bpp, (msb)1R 2G 1B(lsb), a byte contains two pixels, the first pixel in the byte is the one composed by the 4 msb bits - AV_PIX_FMT_RGB4_BYTE, ///< packed RGB 1:2:1, 8bpp, (msb)1R 2G 1B(lsb) - AV_PIX_FMT_NV12, ///< planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) - AV_PIX_FMT_NV21, ///< as above, but U and V bytes are swapped - - AV_PIX_FMT_ARGB, ///< packed ARGB 8:8:8:8, 32bpp, ARGBARGB... - AV_PIX_FMT_RGBA, ///< packed RGBA 8:8:8:8, 32bpp, RGBARGBA... - AV_PIX_FMT_ABGR, ///< packed ABGR 8:8:8:8, 32bpp, ABGRABGR... - AV_PIX_FMT_BGRA, ///< packed BGRA 8:8:8:8, 32bpp, BGRABGRA... - - AV_PIX_FMT_GRAY16BE, ///< Y , 16bpp, big-endian - AV_PIX_FMT_GRAY16LE, ///< Y , 16bpp, little-endian - AV_PIX_FMT_YUV440P, ///< planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples) - AV_PIX_FMT_YUVJ440P, ///< planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range - AV_PIX_FMT_YUVA420P, ///< planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples) - AV_PIX_FMT_RGB48BE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as big-endian - AV_PIX_FMT_RGB48LE, ///< packed RGB 16:16:16, 48bpp, 16R, 16G, 16B, the 2-byte value for each R/G/B component is stored as little-endian - - AV_PIX_FMT_RGB565BE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), big-endian - AV_PIX_FMT_RGB565LE, ///< packed RGB 5:6:5, 16bpp, (msb) 5R 6G 5B(lsb), little-endian - AV_PIX_FMT_RGB555BE, ///< packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), big-endian , X=unused/undefined - AV_PIX_FMT_RGB555LE, ///< packed RGB 5:5:5, 16bpp, (msb)1X 5R 5G 5B(lsb), little-endian, X=unused/undefined - - AV_PIX_FMT_BGR565BE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), big-endian - AV_PIX_FMT_BGR565LE, ///< packed BGR 5:6:5, 16bpp, (msb) 5B 6G 5R(lsb), little-endian - AV_PIX_FMT_BGR555BE, ///< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), big-endian , X=unused/undefined - AV_PIX_FMT_BGR555LE, ///< packed BGR 5:5:5, 16bpp, (msb)1X 5B 5G 5R(lsb), little-endian, X=unused/undefined - -#if FF_API_VAAPI - /** @name Deprecated pixel formats */ - /**@{*/ - AV_PIX_FMT_VAAPI_MOCO, ///< HW acceleration through VA API at motion compensation entry-point, Picture.data[3] contains a vaapi_render_state struct which contains macroblocks as well as various fields extracted from headers - AV_PIX_FMT_VAAPI_IDCT, ///< HW acceleration through VA API at IDCT entry-point, Picture.data[3] contains a vaapi_render_state struct which contains fields extracted from headers - AV_PIX_FMT_VAAPI_VLD, ///< HW decoding through VA API, Picture.data[3] contains a VASurfaceID - /**@}*/ - AV_PIX_FMT_VAAPI = AV_PIX_FMT_VAAPI_VLD, -#else - /** - * Hardware acceleration through VA-API, data[3] contains a - * VASurfaceID. - */ - AV_PIX_FMT_VAAPI, -#endif - - AV_PIX_FMT_YUV420P16LE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian - AV_PIX_FMT_YUV420P16BE, ///< planar YUV 4:2:0, 24bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian - AV_PIX_FMT_YUV422P16LE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian - AV_PIX_FMT_YUV422P16BE, ///< planar YUV 4:2:2, 32bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian - AV_PIX_FMT_YUV444P16LE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - AV_PIX_FMT_YUV444P16BE, ///< planar YUV 4:4:4, 48bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian - AV_PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer - - AV_PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), little-endian, X=unused/undefined - AV_PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4X 4R 4G 4B(lsb), big-endian, X=unused/undefined - AV_PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), little-endian, X=unused/undefined - AV_PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4X 4B 4G 4R(lsb), big-endian, X=unused/undefined - AV_PIX_FMT_YA8, ///< 8 bits gray, 8 bits alpha - - AV_PIX_FMT_Y400A = AV_PIX_FMT_YA8, ///< alias for AV_PIX_FMT_YA8 - AV_PIX_FMT_GRAY8A= AV_PIX_FMT_YA8, ///< alias for AV_PIX_FMT_YA8 - - AV_PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian - AV_PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian - - /** - * The following 12 formats have the disadvantage of needing 1 format for each bit depth. - * Notice that each 9/10 bits sample is stored in 16 bits with extra padding. - * If you want to support multiple bit depths, then using AV_PIX_FMT_YUV420P16* with the bpp stored separately is better. - */ - AV_PIX_FMT_YUV420P9BE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian - AV_PIX_FMT_YUV420P9LE, ///< planar YUV 4:2:0, 13.5bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian - AV_PIX_FMT_YUV420P10BE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian - AV_PIX_FMT_YUV420P10LE,///< planar YUV 4:2:0, 15bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian - AV_PIX_FMT_YUV422P10BE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian - AV_PIX_FMT_YUV422P10LE,///< planar YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian - AV_PIX_FMT_YUV444P9BE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian - AV_PIX_FMT_YUV444P9LE, ///< planar YUV 4:4:4, 27bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - AV_PIX_FMT_YUV444P10BE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian - AV_PIX_FMT_YUV444P10LE,///< planar YUV 4:4:4, 30bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - AV_PIX_FMT_YUV422P9BE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian - AV_PIX_FMT_YUV422P9LE, ///< planar YUV 4:2:2, 18bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian - AV_PIX_FMT_GBRP, ///< planar GBR 4:4:4 24bpp - AV_PIX_FMT_GBR24P = AV_PIX_FMT_GBRP, // alias for #AV_PIX_FMT_GBRP - AV_PIX_FMT_GBRP9BE, ///< planar GBR 4:4:4 27bpp, big-endian - AV_PIX_FMT_GBRP9LE, ///< planar GBR 4:4:4 27bpp, little-endian - AV_PIX_FMT_GBRP10BE, ///< planar GBR 4:4:4 30bpp, big-endian - AV_PIX_FMT_GBRP10LE, ///< planar GBR 4:4:4 30bpp, little-endian - AV_PIX_FMT_GBRP16BE, ///< planar GBR 4:4:4 48bpp, big-endian - AV_PIX_FMT_GBRP16LE, ///< planar GBR 4:4:4 48bpp, little-endian - AV_PIX_FMT_YUVA422P, ///< planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples) - AV_PIX_FMT_YUVA444P, ///< planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples) - AV_PIX_FMT_YUVA420P9BE, ///< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), big-endian - AV_PIX_FMT_YUVA420P9LE, ///< planar YUV 4:2:0 22.5bpp, (1 Cr & Cb sample per 2x2 Y & A samples), little-endian - AV_PIX_FMT_YUVA422P9BE, ///< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), big-endian - AV_PIX_FMT_YUVA422P9LE, ///< planar YUV 4:2:2 27bpp, (1 Cr & Cb sample per 2x1 Y & A samples), little-endian - AV_PIX_FMT_YUVA444P9BE, ///< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), big-endian - AV_PIX_FMT_YUVA444P9LE, ///< planar YUV 4:4:4 36bpp, (1 Cr & Cb sample per 1x1 Y & A samples), little-endian - AV_PIX_FMT_YUVA420P10BE, ///< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian) - AV_PIX_FMT_YUVA420P10LE, ///< planar YUV 4:2:0 25bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian) - AV_PIX_FMT_YUVA422P10BE, ///< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian) - AV_PIX_FMT_YUVA422P10LE, ///< planar YUV 4:2:2 30bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian) - AV_PIX_FMT_YUVA444P10BE, ///< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian) - AV_PIX_FMT_YUVA444P10LE, ///< planar YUV 4:4:4 40bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian) - AV_PIX_FMT_YUVA420P16BE, ///< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, big-endian) - AV_PIX_FMT_YUVA420P16LE, ///< planar YUV 4:2:0 40bpp, (1 Cr & Cb sample per 2x2 Y & A samples, little-endian) - AV_PIX_FMT_YUVA422P16BE, ///< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, big-endian) - AV_PIX_FMT_YUVA422P16LE, ///< planar YUV 4:2:2 48bpp, (1 Cr & Cb sample per 2x1 Y & A samples, little-endian) - AV_PIX_FMT_YUVA444P16BE, ///< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, big-endian) - AV_PIX_FMT_YUVA444P16LE, ///< planar YUV 4:4:4 64bpp, (1 Cr & Cb sample per 1x1 Y & A samples, little-endian) - - AV_PIX_FMT_VDPAU, ///< HW acceleration through VDPAU, Picture.data[3] contains a VdpVideoSurface - - AV_PIX_FMT_XYZ12LE, ///< packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as little-endian, the 4 lower bits are set to 0 - AV_PIX_FMT_XYZ12BE, ///< packed XYZ 4:4:4, 36 bpp, (msb) 12X, 12Y, 12Z (lsb), the 2-byte value for each X/Y/Z is stored as big-endian, the 4 lower bits are set to 0 - AV_PIX_FMT_NV16, ///< interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples) - AV_PIX_FMT_NV20LE, ///< interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian - AV_PIX_FMT_NV20BE, ///< interleaved chroma YUV 4:2:2, 20bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian - - AV_PIX_FMT_RGBA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian - AV_PIX_FMT_RGBA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16R, 16G, 16B, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian - AV_PIX_FMT_BGRA64BE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as big-endian - AV_PIX_FMT_BGRA64LE, ///< packed RGBA 16:16:16:16, 64bpp, 16B, 16G, 16R, 16A, the 2-byte value for each R/G/B/A component is stored as little-endian - - AV_PIX_FMT_YVYU422, ///< packed YUV 4:2:2, 16bpp, Y0 Cr Y1 Cb - - AV_PIX_FMT_YA16BE, ///< 16 bits gray, 16 bits alpha (big-endian) - AV_PIX_FMT_YA16LE, ///< 16 bits gray, 16 bits alpha (little-endian) - - AV_PIX_FMT_GBRAP, ///< planar GBRA 4:4:4:4 32bpp - AV_PIX_FMT_GBRAP16BE, ///< planar GBRA 4:4:4:4 64bpp, big-endian - AV_PIX_FMT_GBRAP16LE, ///< planar GBRA 4:4:4:4 64bpp, little-endian - /** - * HW acceleration through QSV, data[3] contains a pointer to the - * mfxFrameSurface1 structure. - */ - AV_PIX_FMT_QSV, - /** - * HW acceleration though MMAL, data[3] contains a pointer to the - * MMAL_BUFFER_HEADER_T structure. - */ - AV_PIX_FMT_MMAL, - - AV_PIX_FMT_D3D11VA_VLD, ///< HW decoding through Direct3D11 via old API, Picture.data[3] contains a ID3D11VideoDecoderOutputView pointer - - /** - * HW acceleration through CUDA. data[i] contain CUdeviceptr pointers - * exactly as for system memory frames. - */ - AV_PIX_FMT_CUDA, - - AV_PIX_FMT_0RGB, ///< packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined - AV_PIX_FMT_RGB0, ///< packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined - AV_PIX_FMT_0BGR, ///< packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined - AV_PIX_FMT_BGR0, ///< packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined - - AV_PIX_FMT_YUV420P12BE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian - AV_PIX_FMT_YUV420P12LE, ///< planar YUV 4:2:0,18bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian - AV_PIX_FMT_YUV420P14BE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), big-endian - AV_PIX_FMT_YUV420P14LE, ///< planar YUV 4:2:0,21bpp, (1 Cr & Cb sample per 2x2 Y samples), little-endian - AV_PIX_FMT_YUV422P12BE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian - AV_PIX_FMT_YUV422P12LE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian - AV_PIX_FMT_YUV422P14BE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), big-endian - AV_PIX_FMT_YUV422P14LE, ///< planar YUV 4:2:2,28bpp, (1 Cr & Cb sample per 2x1 Y samples), little-endian - AV_PIX_FMT_YUV444P12BE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian - AV_PIX_FMT_YUV444P12LE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - AV_PIX_FMT_YUV444P14BE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), big-endian - AV_PIX_FMT_YUV444P14LE, ///< planar YUV 4:4:4,42bpp, (1 Cr & Cb sample per 1x1 Y samples), little-endian - AV_PIX_FMT_GBRP12BE, ///< planar GBR 4:4:4 36bpp, big-endian - AV_PIX_FMT_GBRP12LE, ///< planar GBR 4:4:4 36bpp, little-endian - AV_PIX_FMT_GBRP14BE, ///< planar GBR 4:4:4 42bpp, big-endian - AV_PIX_FMT_GBRP14LE, ///< planar GBR 4:4:4 42bpp, little-endian - AV_PIX_FMT_YUVJ411P, ///< planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV411P and setting color_range - - AV_PIX_FMT_BAYER_BGGR8, ///< bayer, BGBG..(odd line), GRGR..(even line), 8-bit samples */ - AV_PIX_FMT_BAYER_RGGB8, ///< bayer, RGRG..(odd line), GBGB..(even line), 8-bit samples */ - AV_PIX_FMT_BAYER_GBRG8, ///< bayer, GBGB..(odd line), RGRG..(even line), 8-bit samples */ - AV_PIX_FMT_BAYER_GRBG8, ///< bayer, GRGR..(odd line), BGBG..(even line), 8-bit samples */ - AV_PIX_FMT_BAYER_BGGR16LE, ///< bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, little-endian */ - AV_PIX_FMT_BAYER_BGGR16BE, ///< bayer, BGBG..(odd line), GRGR..(even line), 16-bit samples, big-endian */ - AV_PIX_FMT_BAYER_RGGB16LE, ///< bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, little-endian */ - AV_PIX_FMT_BAYER_RGGB16BE, ///< bayer, RGRG..(odd line), GBGB..(even line), 16-bit samples, big-endian */ - AV_PIX_FMT_BAYER_GBRG16LE, ///< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, little-endian */ - AV_PIX_FMT_BAYER_GBRG16BE, ///< bayer, GBGB..(odd line), RGRG..(even line), 16-bit samples, big-endian */ - AV_PIX_FMT_BAYER_GRBG16LE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, little-endian */ - AV_PIX_FMT_BAYER_GRBG16BE, ///< bayer, GRGR..(odd line), BGBG..(even line), 16-bit samples, big-endian */ - - AV_PIX_FMT_XVMC,///< XVideo Motion Acceleration via common packet passing - - AV_PIX_FMT_YUV440P10LE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian - AV_PIX_FMT_YUV440P10BE, ///< planar YUV 4:4:0,20bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian - AV_PIX_FMT_YUV440P12LE, ///< planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), little-endian - AV_PIX_FMT_YUV440P12BE, ///< planar YUV 4:4:0,24bpp, (1 Cr & Cb sample per 1x2 Y samples), big-endian - AV_PIX_FMT_AYUV64LE, ///< packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), little-endian - AV_PIX_FMT_AYUV64BE, ///< packed AYUV 4:4:4,64bpp (1 Cr & Cb sample per 1x1 Y & A samples), big-endian - - AV_PIX_FMT_VIDEOTOOLBOX, ///< hardware decoding through Videotoolbox - - AV_PIX_FMT_P010LE, ///< like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, little-endian - AV_PIX_FMT_P010BE, ///< like NV12, with 10bpp per component, data in the high bits, zeros in the low bits, big-endian - - AV_PIX_FMT_GBRAP12BE, ///< planar GBR 4:4:4:4 48bpp, big-endian - AV_PIX_FMT_GBRAP12LE, ///< planar GBR 4:4:4:4 48bpp, little-endian - - AV_PIX_FMT_GBRAP10BE, ///< planar GBR 4:4:4:4 40bpp, big-endian - AV_PIX_FMT_GBRAP10LE, ///< planar GBR 4:4:4:4 40bpp, little-endian - - AV_PIX_FMT_MEDIACODEC, ///< hardware decoding through MediaCodec - - AV_PIX_FMT_GRAY12BE, ///< Y , 12bpp, big-endian - AV_PIX_FMT_GRAY12LE, ///< Y , 12bpp, little-endian - AV_PIX_FMT_GRAY10BE, ///< Y , 10bpp, big-endian - AV_PIX_FMT_GRAY10LE, ///< Y , 10bpp, little-endian - - AV_PIX_FMT_P016LE, ///< like NV12, with 16bpp per component, little-endian - AV_PIX_FMT_P016BE, ///< like NV12, with 16bpp per component, big-endian - - /** - * Hardware surfaces for Direct3D11. - * - * This is preferred over the legacy AV_PIX_FMT_D3D11VA_VLD. The new D3D11 - * hwaccel API and filtering support AV_PIX_FMT_D3D11 only. - * - * data[0] contains a ID3D11Texture2D pointer, and data[1] contains the - * texture array index of the frame as intptr_t if the ID3D11Texture2D is - * an array texture (or always 0 if it's a normal texture). - */ - AV_PIX_FMT_D3D11, - - AV_PIX_FMT_GRAY9BE, ///< Y , 9bpp, big-endian - AV_PIX_FMT_GRAY9LE, ///< Y , 9bpp, little-endian - - AV_PIX_FMT_GBRPF32BE, ///< IEEE-754 single precision planar GBR 4:4:4, 96bpp, big-endian - AV_PIX_FMT_GBRPF32LE, ///< IEEE-754 single precision planar GBR 4:4:4, 96bpp, little-endian - AV_PIX_FMT_GBRAPF32BE, ///< IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, big-endian - AV_PIX_FMT_GBRAPF32LE, ///< IEEE-754 single precision planar GBRA 4:4:4:4, 128bpp, little-endian - - /** - * DRM-managed buffers exposed through PRIME buffer sharing. - * - * data[0] points to an AVDRMFrameDescriptor. - */ - AV_PIX_FMT_DRM_PRIME, - /** - * Hardware surfaces for OpenCL. - * - * data[i] contain 2D image objects (typed in C as cl_mem, used - * in OpenCL as image2d_t) for each plane of the surface. - */ - AV_PIX_FMT_OPENCL, - - AV_PIX_FMT_GRAY14BE, ///< Y , 14bpp, big-endian - AV_PIX_FMT_GRAY14LE, ///< Y , 14bpp, little-endian - - AV_PIX_FMT_GRAYF32BE, ///< IEEE-754 single precision Y, 32bpp, big-endian - AV_PIX_FMT_GRAYF32LE, ///< IEEE-754 single precision Y, 32bpp, little-endian - - AV_PIX_FMT_YUVA422P12BE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, big-endian - AV_PIX_FMT_YUVA422P12LE, ///< planar YUV 4:2:2,24bpp, (1 Cr & Cb sample per 2x1 Y samples), 12b alpha, little-endian - AV_PIX_FMT_YUVA444P12BE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, big-endian - AV_PIX_FMT_YUVA444P12LE, ///< planar YUV 4:4:4,36bpp, (1 Cr & Cb sample per 1x1 Y samples), 12b alpha, little-endian - - AV_PIX_FMT_NV24, ///< planar YUV 4:4:4, 24bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (first byte U and the following byte V) - AV_PIX_FMT_NV42, ///< as above, but U and V bytes are swapped - - AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions -}; - -#if AV_HAVE_BIGENDIAN -# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##be -#else -# define AV_PIX_FMT_NE(be, le) AV_PIX_FMT_##le -#endif - -#define AV_PIX_FMT_RGB32 AV_PIX_FMT_NE(ARGB, BGRA) -#define AV_PIX_FMT_RGB32_1 AV_PIX_FMT_NE(RGBA, ABGR) -#define AV_PIX_FMT_BGR32 AV_PIX_FMT_NE(ABGR, RGBA) -#define AV_PIX_FMT_BGR32_1 AV_PIX_FMT_NE(BGRA, ARGB) -#define AV_PIX_FMT_0RGB32 AV_PIX_FMT_NE(0RGB, BGR0) -#define AV_PIX_FMT_0BGR32 AV_PIX_FMT_NE(0BGR, RGB0) - -#define AV_PIX_FMT_GRAY9 AV_PIX_FMT_NE(GRAY9BE, GRAY9LE) -#define AV_PIX_FMT_GRAY10 AV_PIX_FMT_NE(GRAY10BE, GRAY10LE) -#define AV_PIX_FMT_GRAY12 AV_PIX_FMT_NE(GRAY12BE, GRAY12LE) -#define AV_PIX_FMT_GRAY14 AV_PIX_FMT_NE(GRAY14BE, GRAY14LE) -#define AV_PIX_FMT_GRAY16 AV_PIX_FMT_NE(GRAY16BE, GRAY16LE) -#define AV_PIX_FMT_YA16 AV_PIX_FMT_NE(YA16BE, YA16LE) -#define AV_PIX_FMT_RGB48 AV_PIX_FMT_NE(RGB48BE, RGB48LE) -#define AV_PIX_FMT_RGB565 AV_PIX_FMT_NE(RGB565BE, RGB565LE) -#define AV_PIX_FMT_RGB555 AV_PIX_FMT_NE(RGB555BE, RGB555LE) -#define AV_PIX_FMT_RGB444 AV_PIX_FMT_NE(RGB444BE, RGB444LE) -#define AV_PIX_FMT_RGBA64 AV_PIX_FMT_NE(RGBA64BE, RGBA64LE) -#define AV_PIX_FMT_BGR48 AV_PIX_FMT_NE(BGR48BE, BGR48LE) -#define AV_PIX_FMT_BGR565 AV_PIX_FMT_NE(BGR565BE, BGR565LE) -#define AV_PIX_FMT_BGR555 AV_PIX_FMT_NE(BGR555BE, BGR555LE) -#define AV_PIX_FMT_BGR444 AV_PIX_FMT_NE(BGR444BE, BGR444LE) -#define AV_PIX_FMT_BGRA64 AV_PIX_FMT_NE(BGRA64BE, BGRA64LE) - -#define AV_PIX_FMT_YUV420P9 AV_PIX_FMT_NE(YUV420P9BE , YUV420P9LE) -#define AV_PIX_FMT_YUV422P9 AV_PIX_FMT_NE(YUV422P9BE , YUV422P9LE) -#define AV_PIX_FMT_YUV444P9 AV_PIX_FMT_NE(YUV444P9BE , YUV444P9LE) -#define AV_PIX_FMT_YUV420P10 AV_PIX_FMT_NE(YUV420P10BE, YUV420P10LE) -#define AV_PIX_FMT_YUV422P10 AV_PIX_FMT_NE(YUV422P10BE, YUV422P10LE) -#define AV_PIX_FMT_YUV440P10 AV_PIX_FMT_NE(YUV440P10BE, YUV440P10LE) -#define AV_PIX_FMT_YUV444P10 AV_PIX_FMT_NE(YUV444P10BE, YUV444P10LE) -#define AV_PIX_FMT_YUV420P12 AV_PIX_FMT_NE(YUV420P12BE, YUV420P12LE) -#define AV_PIX_FMT_YUV422P12 AV_PIX_FMT_NE(YUV422P12BE, YUV422P12LE) -#define AV_PIX_FMT_YUV440P12 AV_PIX_FMT_NE(YUV440P12BE, YUV440P12LE) -#define AV_PIX_FMT_YUV444P12 AV_PIX_FMT_NE(YUV444P12BE, YUV444P12LE) -#define AV_PIX_FMT_YUV420P14 AV_PIX_FMT_NE(YUV420P14BE, YUV420P14LE) -#define AV_PIX_FMT_YUV422P14 AV_PIX_FMT_NE(YUV422P14BE, YUV422P14LE) -#define AV_PIX_FMT_YUV444P14 AV_PIX_FMT_NE(YUV444P14BE, YUV444P14LE) -#define AV_PIX_FMT_YUV420P16 AV_PIX_FMT_NE(YUV420P16BE, YUV420P16LE) -#define AV_PIX_FMT_YUV422P16 AV_PIX_FMT_NE(YUV422P16BE, YUV422P16LE) -#define AV_PIX_FMT_YUV444P16 AV_PIX_FMT_NE(YUV444P16BE, YUV444P16LE) - -#define AV_PIX_FMT_GBRP9 AV_PIX_FMT_NE(GBRP9BE , GBRP9LE) -#define AV_PIX_FMT_GBRP10 AV_PIX_FMT_NE(GBRP10BE, GBRP10LE) -#define AV_PIX_FMT_GBRP12 AV_PIX_FMT_NE(GBRP12BE, GBRP12LE) -#define AV_PIX_FMT_GBRP14 AV_PIX_FMT_NE(GBRP14BE, GBRP14LE) -#define AV_PIX_FMT_GBRP16 AV_PIX_FMT_NE(GBRP16BE, GBRP16LE) -#define AV_PIX_FMT_GBRAP10 AV_PIX_FMT_NE(GBRAP10BE, GBRAP10LE) -#define AV_PIX_FMT_GBRAP12 AV_PIX_FMT_NE(GBRAP12BE, GBRAP12LE) -#define AV_PIX_FMT_GBRAP16 AV_PIX_FMT_NE(GBRAP16BE, GBRAP16LE) - -#define AV_PIX_FMT_BAYER_BGGR16 AV_PIX_FMT_NE(BAYER_BGGR16BE, BAYER_BGGR16LE) -#define AV_PIX_FMT_BAYER_RGGB16 AV_PIX_FMT_NE(BAYER_RGGB16BE, BAYER_RGGB16LE) -#define AV_PIX_FMT_BAYER_GBRG16 AV_PIX_FMT_NE(BAYER_GBRG16BE, BAYER_GBRG16LE) -#define AV_PIX_FMT_BAYER_GRBG16 AV_PIX_FMT_NE(BAYER_GRBG16BE, BAYER_GRBG16LE) - -#define AV_PIX_FMT_GBRPF32 AV_PIX_FMT_NE(GBRPF32BE, GBRPF32LE) -#define AV_PIX_FMT_GBRAPF32 AV_PIX_FMT_NE(GBRAPF32BE, GBRAPF32LE) - -#define AV_PIX_FMT_GRAYF32 AV_PIX_FMT_NE(GRAYF32BE, GRAYF32LE) - -#define AV_PIX_FMT_YUVA420P9 AV_PIX_FMT_NE(YUVA420P9BE , YUVA420P9LE) -#define AV_PIX_FMT_YUVA422P9 AV_PIX_FMT_NE(YUVA422P9BE , YUVA422P9LE) -#define AV_PIX_FMT_YUVA444P9 AV_PIX_FMT_NE(YUVA444P9BE , YUVA444P9LE) -#define AV_PIX_FMT_YUVA420P10 AV_PIX_FMT_NE(YUVA420P10BE, YUVA420P10LE) -#define AV_PIX_FMT_YUVA422P10 AV_PIX_FMT_NE(YUVA422P10BE, YUVA422P10LE) -#define AV_PIX_FMT_YUVA444P10 AV_PIX_FMT_NE(YUVA444P10BE, YUVA444P10LE) -#define AV_PIX_FMT_YUVA422P12 AV_PIX_FMT_NE(YUVA422P12BE, YUVA422P12LE) -#define AV_PIX_FMT_YUVA444P12 AV_PIX_FMT_NE(YUVA444P12BE, YUVA444P12LE) -#define AV_PIX_FMT_YUVA420P16 AV_PIX_FMT_NE(YUVA420P16BE, YUVA420P16LE) -#define AV_PIX_FMT_YUVA422P16 AV_PIX_FMT_NE(YUVA422P16BE, YUVA422P16LE) -#define AV_PIX_FMT_YUVA444P16 AV_PIX_FMT_NE(YUVA444P16BE, YUVA444P16LE) - -#define AV_PIX_FMT_XYZ12 AV_PIX_FMT_NE(XYZ12BE, XYZ12LE) -#define AV_PIX_FMT_NV20 AV_PIX_FMT_NE(NV20BE, NV20LE) -#define AV_PIX_FMT_AYUV64 AV_PIX_FMT_NE(AYUV64BE, AYUV64LE) -#define AV_PIX_FMT_P010 AV_PIX_FMT_NE(P010BE, P010LE) -#define AV_PIX_FMT_P016 AV_PIX_FMT_NE(P016BE, P016LE) - -/** - * Chromaticity coordinates of the source primaries. - * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.1. - */ -enum AVColorPrimaries { - AVCOL_PRI_RESERVED0 = 0, - AVCOL_PRI_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 / SMPTE RP177 Annex B - AVCOL_PRI_UNSPECIFIED = 2, - AVCOL_PRI_RESERVED = 3, - AVCOL_PRI_BT470M = 4, ///< also FCC Title 47 Code of Federal Regulations 73.682 (a)(20) - - AVCOL_PRI_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM - AVCOL_PRI_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC - AVCOL_PRI_SMPTE240M = 7, ///< functionally identical to above - AVCOL_PRI_FILM = 8, ///< colour filters using Illuminant C - AVCOL_PRI_BT2020 = 9, ///< ITU-R BT2020 - AVCOL_PRI_SMPTE428 = 10, ///< SMPTE ST 428-1 (CIE 1931 XYZ) - AVCOL_PRI_SMPTEST428_1 = AVCOL_PRI_SMPTE428, - AVCOL_PRI_SMPTE431 = 11, ///< SMPTE ST 431-2 (2011) / DCI P3 - AVCOL_PRI_SMPTE432 = 12, ///< SMPTE ST 432-1 (2010) / P3 D65 / Display P3 - AVCOL_PRI_JEDEC_P22 = 22, ///< JEDEC P22 phosphors - AVCOL_PRI_NB ///< Not part of ABI -}; - -/** - * Color Transfer Characteristic. - * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.2. - */ -enum AVColorTransferCharacteristic { - AVCOL_TRC_RESERVED0 = 0, - AVCOL_TRC_BT709 = 1, ///< also ITU-R BT1361 - AVCOL_TRC_UNSPECIFIED = 2, - AVCOL_TRC_RESERVED = 3, - AVCOL_TRC_GAMMA22 = 4, ///< also ITU-R BT470M / ITU-R BT1700 625 PAL & SECAM - AVCOL_TRC_GAMMA28 = 5, ///< also ITU-R BT470BG - AVCOL_TRC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 or 625 / ITU-R BT1358 525 or 625 / ITU-R BT1700 NTSC - AVCOL_TRC_SMPTE240M = 7, - AVCOL_TRC_LINEAR = 8, ///< "Linear transfer characteristics" - AVCOL_TRC_LOG = 9, ///< "Logarithmic transfer characteristic (100:1 range)" - AVCOL_TRC_LOG_SQRT = 10, ///< "Logarithmic transfer characteristic (100 * Sqrt(10) : 1 range)" - AVCOL_TRC_IEC61966_2_4 = 11, ///< IEC 61966-2-4 - AVCOL_TRC_BT1361_ECG = 12, ///< ITU-R BT1361 Extended Colour Gamut - AVCOL_TRC_IEC61966_2_1 = 13, ///< IEC 61966-2-1 (sRGB or sYCC) - AVCOL_TRC_BT2020_10 = 14, ///< ITU-R BT2020 for 10-bit system - AVCOL_TRC_BT2020_12 = 15, ///< ITU-R BT2020 for 12-bit system - AVCOL_TRC_SMPTE2084 = 16, ///< SMPTE ST 2084 for 10-, 12-, 14- and 16-bit systems - AVCOL_TRC_SMPTEST2084 = AVCOL_TRC_SMPTE2084, - AVCOL_TRC_SMPTE428 = 17, ///< SMPTE ST 428-1 - AVCOL_TRC_SMPTEST428_1 = AVCOL_TRC_SMPTE428, - AVCOL_TRC_ARIB_STD_B67 = 18, ///< ARIB STD-B67, known as "Hybrid log-gamma" - AVCOL_TRC_NB ///< Not part of ABI -}; - -/** - * YUV colorspace type. - * These values match the ones defined by ISO/IEC 23001-8_2013 § 7.3. - */ -enum AVColorSpace { - AVCOL_SPC_RGB = 0, ///< order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB) - AVCOL_SPC_BT709 = 1, ///< also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B - AVCOL_SPC_UNSPECIFIED = 2, - AVCOL_SPC_RESERVED = 3, - AVCOL_SPC_FCC = 4, ///< FCC Title 47 Code of Federal Regulations 73.682 (a)(20) - AVCOL_SPC_BT470BG = 5, ///< also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 - AVCOL_SPC_SMPTE170M = 6, ///< also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC - AVCOL_SPC_SMPTE240M = 7, ///< functionally identical to above - AVCOL_SPC_YCGCO = 8, ///< Used by Dirac / VC-2 and H.264 FRext, see ITU-T SG16 - AVCOL_SPC_YCOCG = AVCOL_SPC_YCGCO, - AVCOL_SPC_BT2020_NCL = 9, ///< ITU-R BT2020 non-constant luminance system - AVCOL_SPC_BT2020_CL = 10, ///< ITU-R BT2020 constant luminance system - AVCOL_SPC_SMPTE2085 = 11, ///< SMPTE 2085, Y'D'zD'x - AVCOL_SPC_CHROMA_DERIVED_NCL = 12, ///< Chromaticity-derived non-constant luminance system - AVCOL_SPC_CHROMA_DERIVED_CL = 13, ///< Chromaticity-derived constant luminance system - AVCOL_SPC_ICTCP = 14, ///< ITU-R BT.2100-0, ICtCp - AVCOL_SPC_NB ///< Not part of ABI -}; - -/** - * MPEG vs JPEG YUV range. - */ -enum AVColorRange { - AVCOL_RANGE_UNSPECIFIED = 0, - AVCOL_RANGE_MPEG = 1, ///< the normal 219*2^(n-8) "MPEG" YUV ranges - AVCOL_RANGE_JPEG = 2, ///< the normal 2^n-1 "JPEG" YUV ranges - AVCOL_RANGE_NB ///< Not part of ABI -}; - -/** - * Location of chroma samples. - * - * Illustration showing the location of the first (top left) chroma sample of the - * image, the left shows only luma, the right - * shows the location of the chroma sample, the 2 could be imagined to overlay - * each other but are drawn separately due to limitations of ASCII - * - * 1st 2nd 1st 2nd horizontal luma sample positions - * v v v v - * ______ ______ - *1st luma line > |X X ... |3 4 X ... X are luma samples, - * | |1 2 1-6 are possible chroma positions - *2nd luma line > |X X ... |5 6 X ... 0 is undefined/unknown position - */ -enum AVChromaLocation { - AVCHROMA_LOC_UNSPECIFIED = 0, - AVCHROMA_LOC_LEFT = 1, ///< MPEG-2/4 4:2:0, H.264 default for 4:2:0 - AVCHROMA_LOC_CENTER = 2, ///< MPEG-1 4:2:0, JPEG 4:2:0, H.263 4:2:0 - AVCHROMA_LOC_TOPLEFT = 3, ///< ITU-R 601, SMPTE 274M 296M S314M(DV 4:1:1), mpeg2 4:2:2 - AVCHROMA_LOC_TOP = 4, - AVCHROMA_LOC_BOTTOMLEFT = 5, - AVCHROMA_LOC_BOTTOM = 6, - AVCHROMA_LOC_NB ///< Not part of ABI -}; - -#endif /* AVUTIL_PIXFMT_H */ diff --git a/maclibs/include/libavutil/rational.h b/maclibs/include/libavutil/rational.h deleted file mode 100644 index 5c6b67b4..00000000 --- a/maclibs/include/libavutil/rational.h +++ /dev/null @@ -1,214 +0,0 @@ -/* - * rational numbers - * Copyright (c) 2003 Michael Niedermayer - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * @ingroup lavu_math_rational - * Utilties for rational number calculation. - * @author Michael Niedermayer - */ - -#ifndef AVUTIL_RATIONAL_H -#define AVUTIL_RATIONAL_H - -#include -#include -#include "attributes.h" - -/** - * @defgroup lavu_math_rational AVRational - * @ingroup lavu_math - * Rational number calculation. - * - * While rational numbers can be expressed as floating-point numbers, the - * conversion process is a lossy one, so are floating-point operations. On the - * other hand, the nature of FFmpeg demands highly accurate calculation of - * timestamps. This set of rational number utilities serves as a generic - * interface for manipulating rational numbers as pairs of numerators and - * denominators. - * - * Many of the functions that operate on AVRational's have the suffix `_q`, in - * reference to the mathematical symbol "ℚ" (Q) which denotes the set of all - * rational numbers. - * - * @{ - */ - -/** - * Rational number (pair of numerator and denominator). - */ -typedef struct AVRational{ - int num; ///< Numerator - int den; ///< Denominator -} AVRational; - -/** - * Create an AVRational. - * - * Useful for compilers that do not support compound literals. - * - * @note The return value is not reduced. - * @see av_reduce() - */ -static inline AVRational av_make_q(int num, int den) -{ - AVRational r = { num, den }; - return r; -} - -/** - * Compare two rationals. - * - * @param a First rational - * @param b Second rational - * - * @return One of the following values: - * - 0 if `a == b` - * - 1 if `a > b` - * - -1 if `a < b` - * - `INT_MIN` if one of the values is of the form `0 / 0` - */ -static inline int av_cmp_q(AVRational a, AVRational b){ - const int64_t tmp= a.num * (int64_t)b.den - b.num * (int64_t)a.den; - - if(tmp) return (int)((tmp ^ a.den ^ b.den)>>63)|1; - else if(b.den && a.den) return 0; - else if(a.num && b.num) return (a.num>>31) - (b.num>>31); - else return INT_MIN; -} - -/** - * Convert an AVRational to a `double`. - * @param a AVRational to convert - * @return `a` in floating-point form - * @see av_d2q() - */ -static inline double av_q2d(AVRational a){ - return a.num / (double) a.den; -} - -/** - * Reduce a fraction. - * - * This is useful for framerate calculations. - * - * @param[out] dst_num Destination numerator - * @param[out] dst_den Destination denominator - * @param[in] num Source numerator - * @param[in] den Source denominator - * @param[in] max Maximum allowed values for `dst_num` & `dst_den` - * @return 1 if the operation is exact, 0 otherwise - */ -int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max); - -/** - * Multiply two rationals. - * @param b First rational - * @param c Second rational - * @return b*c - */ -AVRational av_mul_q(AVRational b, AVRational c) av_const; - -/** - * Divide one rational by another. - * @param b First rational - * @param c Second rational - * @return b/c - */ -AVRational av_div_q(AVRational b, AVRational c) av_const; - -/** - * Add two rationals. - * @param b First rational - * @param c Second rational - * @return b+c - */ -AVRational av_add_q(AVRational b, AVRational c) av_const; - -/** - * Subtract one rational from another. - * @param b First rational - * @param c Second rational - * @return b-c - */ -AVRational av_sub_q(AVRational b, AVRational c) av_const; - -/** - * Invert a rational. - * @param q value - * @return 1 / q - */ -static av_always_inline AVRational av_inv_q(AVRational q) -{ - AVRational r = { q.den, q.num }; - return r; -} - -/** - * Convert a double precision floating point number to a rational. - * - * In case of infinity, the returned value is expressed as `{1, 0}` or - * `{-1, 0}` depending on the sign. - * - * @param d `double` to convert - * @param max Maximum allowed numerator and denominator - * @return `d` in AVRational form - * @see av_q2d() - */ -AVRational av_d2q(double d, int max) av_const; - -/** - * Find which of the two rationals is closer to another rational. - * - * @param q Rational to be compared against - * @param q1,q2 Rationals to be tested - * @return One of the following values: - * - 1 if `q1` is nearer to `q` than `q2` - * - -1 if `q2` is nearer to `q` than `q1` - * - 0 if they have the same distance - */ -int av_nearer_q(AVRational q, AVRational q1, AVRational q2); - -/** - * Find the value in a list of rationals nearest a given reference rational. - * - * @param q Reference rational - * @param q_list Array of rationals terminated by `{0, 0}` - * @return Index of the nearest value found in the array - */ -int av_find_nearest_q_idx(AVRational q, const AVRational* q_list); - -/** - * Convert an AVRational to a IEEE 32-bit `float` expressed in fixed-point - * format. - * - * @param q Rational to be converted - * @return Equivalent floating-point value, expressed as an unsigned 32-bit - * integer. - * @note The returned value is platform-indepedant. - */ -uint32_t av_q2intfloat(AVRational q); - -/** - * @} - */ - -#endif /* AVUTIL_RATIONAL_H */ diff --git a/maclibs/include/libavutil/samplefmt.h b/maclibs/include/libavutil/samplefmt.h deleted file mode 100644 index 8cd43ae8..00000000 --- a/maclibs/include/libavutil/samplefmt.h +++ /dev/null @@ -1,272 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef AVUTIL_SAMPLEFMT_H -#define AVUTIL_SAMPLEFMT_H - -#include - -#include "avutil.h" -#include "attributes.h" - -/** - * @addtogroup lavu_audio - * @{ - * - * @defgroup lavu_sampfmts Audio sample formats - * - * Audio sample format enumeration and related convenience functions. - * @{ - */ - -/** - * Audio sample formats - * - * - The data described by the sample format is always in native-endian order. - * Sample values can be expressed by native C types, hence the lack of a signed - * 24-bit sample format even though it is a common raw audio data format. - * - * - The floating-point formats are based on full volume being in the range - * [-1.0, 1.0]. Any values outside this range are beyond full volume level. - * - * - The data layout as used in av_samples_fill_arrays() and elsewhere in FFmpeg - * (such as AVFrame in libavcodec) is as follows: - * - * @par - * For planar sample formats, each audio channel is in a separate data plane, - * and linesize is the buffer size, in bytes, for a single plane. All data - * planes must be the same size. For packed sample formats, only the first data - * plane is used, and samples for each channel are interleaved. In this case, - * linesize is the buffer size, in bytes, for the 1 plane. - * - */ -enum AVSampleFormat { - AV_SAMPLE_FMT_NONE = -1, - AV_SAMPLE_FMT_U8, ///< unsigned 8 bits - AV_SAMPLE_FMT_S16, ///< signed 16 bits - AV_SAMPLE_FMT_S32, ///< signed 32 bits - AV_SAMPLE_FMT_FLT, ///< float - AV_SAMPLE_FMT_DBL, ///< double - - AV_SAMPLE_FMT_U8P, ///< unsigned 8 bits, planar - AV_SAMPLE_FMT_S16P, ///< signed 16 bits, planar - AV_SAMPLE_FMT_S32P, ///< signed 32 bits, planar - AV_SAMPLE_FMT_FLTP, ///< float, planar - AV_SAMPLE_FMT_DBLP, ///< double, planar - AV_SAMPLE_FMT_S64, ///< signed 64 bits - AV_SAMPLE_FMT_S64P, ///< signed 64 bits, planar - - AV_SAMPLE_FMT_NB ///< Number of sample formats. DO NOT USE if linking dynamically -}; - -/** - * Return the name of sample_fmt, or NULL if sample_fmt is not - * recognized. - */ -const char *av_get_sample_fmt_name(enum AVSampleFormat sample_fmt); - -/** - * Return a sample format corresponding to name, or AV_SAMPLE_FMT_NONE - * on error. - */ -enum AVSampleFormat av_get_sample_fmt(const char *name); - -/** - * Return the planar<->packed alternative form of the given sample format, or - * AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the - * requested planar/packed format, the format returned is the same as the - * input. - */ -enum AVSampleFormat av_get_alt_sample_fmt(enum AVSampleFormat sample_fmt, int planar); - -/** - * Get the packed alternative form of the given sample format. - * - * If the passed sample_fmt is already in packed format, the format returned is - * the same as the input. - * - * @return the packed alternative form of the given sample format or - AV_SAMPLE_FMT_NONE on error. - */ -enum AVSampleFormat av_get_packed_sample_fmt(enum AVSampleFormat sample_fmt); - -/** - * Get the planar alternative form of the given sample format. - * - * If the passed sample_fmt is already in planar format, the format returned is - * the same as the input. - * - * @return the planar alternative form of the given sample format or - AV_SAMPLE_FMT_NONE on error. - */ -enum AVSampleFormat av_get_planar_sample_fmt(enum AVSampleFormat sample_fmt); - -/** - * Generate a string corresponding to the sample format with - * sample_fmt, or a header if sample_fmt is negative. - * - * @param buf the buffer where to write the string - * @param buf_size the size of buf - * @param sample_fmt the number of the sample format to print the - * corresponding info string, or a negative value to print the - * corresponding header. - * @return the pointer to the filled buffer or NULL if sample_fmt is - * unknown or in case of other errors - */ -char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); - -/** - * Return number of bytes per sample. - * - * @param sample_fmt the sample format - * @return number of bytes per sample or zero if unknown for the given - * sample format - */ -int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt); - -/** - * Check if the sample format is planar. - * - * @param sample_fmt the sample format to inspect - * @return 1 if the sample format is planar, 0 if it is interleaved - */ -int av_sample_fmt_is_planar(enum AVSampleFormat sample_fmt); - -/** - * Get the required buffer size for the given audio parameters. - * - * @param[out] linesize calculated linesize, may be NULL - * @param nb_channels the number of channels - * @param nb_samples the number of samples in a single channel - * @param sample_fmt the sample format - * @param align buffer size alignment (0 = default, 1 = no alignment) - * @return required buffer size, or negative error code on failure - */ -int av_samples_get_buffer_size(int *linesize, int nb_channels, int nb_samples, - enum AVSampleFormat sample_fmt, int align); - -/** - * @} - * - * @defgroup lavu_sampmanip Samples manipulation - * - * Functions that manipulate audio samples - * @{ - */ - -/** - * Fill plane data pointers and linesize for samples with sample - * format sample_fmt. - * - * The audio_data array is filled with the pointers to the samples data planes: - * for planar, set the start point of each channel's data within the buffer, - * for packed, set the start point of the entire buffer only. - * - * The value pointed to by linesize is set to the aligned size of each - * channel's data buffer for planar layout, or to the aligned size of the - * buffer for all channels for packed layout. - * - * The buffer in buf must be big enough to contain all the samples - * (use av_samples_get_buffer_size() to compute its minimum size), - * otherwise the audio_data pointers will point to invalid data. - * - * @see enum AVSampleFormat - * The documentation for AVSampleFormat describes the data layout. - * - * @param[out] audio_data array to be filled with the pointer for each channel - * @param[out] linesize calculated linesize, may be NULL - * @param buf the pointer to a buffer containing the samples - * @param nb_channels the number of channels - * @param nb_samples the number of samples in a single channel - * @param sample_fmt the sample format - * @param align buffer size alignment (0 = default, 1 = no alignment) - * @return >=0 on success or a negative error code on failure - * @todo return minimum size in bytes required for the buffer in case - * of success at the next bump - */ -int av_samples_fill_arrays(uint8_t **audio_data, int *linesize, - const uint8_t *buf, - int nb_channels, int nb_samples, - enum AVSampleFormat sample_fmt, int align); - -/** - * Allocate a samples buffer for nb_samples samples, and fill data pointers and - * linesize accordingly. - * The allocated samples buffer can be freed by using av_freep(&audio_data[0]) - * Allocated data will be initialized to silence. - * - * @see enum AVSampleFormat - * The documentation for AVSampleFormat describes the data layout. - * - * @param[out] audio_data array to be filled with the pointer for each channel - * @param[out] linesize aligned size for audio buffer(s), may be NULL - * @param nb_channels number of audio channels - * @param nb_samples number of samples per channel - * @param align buffer size alignment (0 = default, 1 = no alignment) - * @return >=0 on success or a negative error code on failure - * @todo return the size of the allocated buffer in case of success at the next bump - * @see av_samples_fill_arrays() - * @see av_samples_alloc_array_and_samples() - */ -int av_samples_alloc(uint8_t **audio_data, int *linesize, int nb_channels, - int nb_samples, enum AVSampleFormat sample_fmt, int align); - -/** - * Allocate a data pointers array, samples buffer for nb_samples - * samples, and fill data pointers and linesize accordingly. - * - * This is the same as av_samples_alloc(), but also allocates the data - * pointers array. - * - * @see av_samples_alloc() - */ -int av_samples_alloc_array_and_samples(uint8_t ***audio_data, int *linesize, int nb_channels, - int nb_samples, enum AVSampleFormat sample_fmt, int align); - -/** - * Copy samples from src to dst. - * - * @param dst destination array of pointers to data planes - * @param src source array of pointers to data planes - * @param dst_offset offset in samples at which the data will be written to dst - * @param src_offset offset in samples at which the data will be read from src - * @param nb_samples number of samples to be copied - * @param nb_channels number of audio channels - * @param sample_fmt audio sample format - */ -int av_samples_copy(uint8_t **dst, uint8_t * const *src, int dst_offset, - int src_offset, int nb_samples, int nb_channels, - enum AVSampleFormat sample_fmt); - -/** - * Fill an audio buffer with silence. - * - * @param audio_data array of pointers to data planes - * @param offset offset in samples at which to start filling - * @param nb_samples number of samples to fill - * @param nb_channels number of audio channels - * @param sample_fmt audio sample format - */ -int av_samples_set_silence(uint8_t **audio_data, int offset, int nb_samples, - int nb_channels, enum AVSampleFormat sample_fmt); - -/** - * @} - * @} - */ -#endif /* AVUTIL_SAMPLEFMT_H */ diff --git a/maclibs/include/libavutil/version.h b/maclibs/include/libavutil/version.h deleted file mode 100644 index 24ca8ab7..00000000 --- a/maclibs/include/libavutil/version.h +++ /dev/null @@ -1,139 +0,0 @@ -/* - * copyright (c) 2003 Fabrice Bellard - * - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -/** - * @file - * @ingroup lavu - * Libavutil version macros - */ - -#ifndef AVUTIL_VERSION_H -#define AVUTIL_VERSION_H - -#include "macros.h" - -/** - * @addtogroup version_utils - * - * Useful to check and match library version in order to maintain - * backward compatibility. - * - * The FFmpeg libraries follow a versioning sheme very similar to - * Semantic Versioning (http://semver.org/) - * The difference is that the component called PATCH is called MICRO in FFmpeg - * and its value is reset to 100 instead of 0 to keep it above or equal to 100. - * Also we do not increase MICRO for every bugfix or change in git master. - * - * Prior to FFmpeg 3.2 point releases did not change any lib version number to - * avoid aliassing different git master checkouts. - * Starting with FFmpeg 3.2, the released library versions will occupy - * a separate MAJOR.MINOR that is not used on the master development branch. - * That is if we branch a release of master 55.10.123 we will bump to 55.11.100 - * for the release and master will continue at 55.12.100 after it. Each new - * point release will then bump the MICRO improving the usefulness of the lib - * versions. - * - * @{ - */ - -#define AV_VERSION_INT(a, b, c) ((a)<<16 | (b)<<8 | (c)) -#define AV_VERSION_DOT(a, b, c) a ##.## b ##.## c -#define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) - -/** - * Extract version components from the full ::AV_VERSION_INT int as returned - * by functions like ::avformat_version() and ::avcodec_version() - */ -#define AV_VERSION_MAJOR(a) ((a) >> 16) -#define AV_VERSION_MINOR(a) (((a) & 0x00FF00) >> 8) -#define AV_VERSION_MICRO(a) ((a) & 0xFF) - -/** - * @} - */ - -/** - * @defgroup lavu_ver Version and Build diagnostics - * - * Macros and function useful to check at compiletime and at runtime - * which version of libavutil is in use. - * - * @{ - */ - -#define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 31 -#define LIBAVUTIL_VERSION_MICRO 100 - -#define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ - LIBAVUTIL_VERSION_MINOR, \ - LIBAVUTIL_VERSION_MICRO) -#define LIBAVUTIL_VERSION AV_VERSION(LIBAVUTIL_VERSION_MAJOR, \ - LIBAVUTIL_VERSION_MINOR, \ - LIBAVUTIL_VERSION_MICRO) -#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT - -#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION) - -/** - * @defgroup lavu_depr_guards Deprecation Guards - * FF_API_* defines may be placed below to indicate public API that will be - * dropped at a future version bump. The defines themselves are not part of - * the public API and may change, break or disappear at any time. - * - * @note, when bumping the major version it is recommended to manually - * disable each FF_API_* in its own commit instead of disabling them all - * at once through the bump. This improves the git bisect-ability of the change. - * - * @{ - */ - -#ifndef FF_API_VAAPI -#define FF_API_VAAPI (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_FRAME_QP -#define FF_API_FRAME_QP (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_PLUS1_MINUS1 -#define FF_API_PLUS1_MINUS1 (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_ERROR_FRAME -#define FF_API_ERROR_FRAME (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_PKT_PTS -#define FF_API_PKT_PTS (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_CRYPTO_SIZE_T -#define FF_API_CRYPTO_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_FRAME_GET_SET -#define FF_API_FRAME_GET_SET (LIBAVUTIL_VERSION_MAJOR < 57) -#endif -#ifndef FF_API_PSEUDOPAL -#define FF_API_PSEUDOPAL (LIBAVUTIL_VERSION_MAJOR < 57) -#endif - - -/** - * @} - * @} - */ - -#endif /* AVUTIL_VERSION_H */ diff --git a/maclibs/include/libswresample/swresample.h b/maclibs/include/libswresample/swresample.h deleted file mode 100644 index c7b84fbc..00000000 --- a/maclibs/include/libswresample/swresample.h +++ /dev/null @@ -1,579 +0,0 @@ -/* - * Copyright (C) 2011-2013 Michael Niedermayer (michaelni@gmx.at) - * - * This file is part of libswresample - * - * libswresample is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * libswresample is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libswresample; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef SWRESAMPLE_SWRESAMPLE_H -#define SWRESAMPLE_SWRESAMPLE_H - -/** - * @file - * @ingroup lswr - * libswresample public header - */ - -/** - * @defgroup lswr libswresample - * @{ - * - * Audio resampling, sample format conversion and mixing library. - * - * Interaction with lswr is done through SwrContext, which is - * allocated with swr_alloc() or swr_alloc_set_opts(). It is opaque, so all parameters - * must be set with the @ref avoptions API. - * - * The first thing you will need to do in order to use lswr is to allocate - * SwrContext. This can be done with swr_alloc() or swr_alloc_set_opts(). If you - * are using the former, you must set options through the @ref avoptions API. - * The latter function provides the same feature, but it allows you to set some - * common options in the same statement. - * - * For example the following code will setup conversion from planar float sample - * format to interleaved signed 16-bit integer, downsampling from 48kHz to - * 44.1kHz and downmixing from 5.1 channels to stereo (using the default mixing - * matrix). This is using the swr_alloc() function. - * @code - * SwrContext *swr = swr_alloc(); - * av_opt_set_channel_layout(swr, "in_channel_layout", AV_CH_LAYOUT_5POINT1, 0); - * av_opt_set_channel_layout(swr, "out_channel_layout", AV_CH_LAYOUT_STEREO, 0); - * av_opt_set_int(swr, "in_sample_rate", 48000, 0); - * av_opt_set_int(swr, "out_sample_rate", 44100, 0); - * av_opt_set_sample_fmt(swr, "in_sample_fmt", AV_SAMPLE_FMT_FLTP, 0); - * av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0); - * @endcode - * - * The same job can be done using swr_alloc_set_opts() as well: - * @code - * SwrContext *swr = swr_alloc_set_opts(NULL, // we're allocating a new context - * AV_CH_LAYOUT_STEREO, // out_ch_layout - * AV_SAMPLE_FMT_S16, // out_sample_fmt - * 44100, // out_sample_rate - * AV_CH_LAYOUT_5POINT1, // in_ch_layout - * AV_SAMPLE_FMT_FLTP, // in_sample_fmt - * 48000, // in_sample_rate - * 0, // log_offset - * NULL); // log_ctx - * @endcode - * - * Once all values have been set, it must be initialized with swr_init(). If - * you need to change the conversion parameters, you can change the parameters - * using @ref AVOptions, as described above in the first example; or by using - * swr_alloc_set_opts(), but with the first argument the allocated context. - * You must then call swr_init() again. - * - * The conversion itself is done by repeatedly calling swr_convert(). - * Note that the samples may get buffered in swr if you provide insufficient - * output space or if sample rate conversion is done, which requires "future" - * samples. Samples that do not require future input can be retrieved at any - * time by using swr_convert() (in_count can be set to 0). - * At the end of conversion the resampling buffer can be flushed by calling - * swr_convert() with NULL in and 0 in_count. - * - * The samples used in the conversion process can be managed with the libavutil - * @ref lavu_sampmanip "samples manipulation" API, including av_samples_alloc() - * function used in the following example. - * - * The delay between input and output, can at any time be found by using - * swr_get_delay(). - * - * The following code demonstrates the conversion loop assuming the parameters - * from above and caller-defined functions get_input() and handle_output(): - * @code - * uint8_t **input; - * int in_samples; - * - * while (get_input(&input, &in_samples)) { - * uint8_t *output; - * int out_samples = av_rescale_rnd(swr_get_delay(swr, 48000) + - * in_samples, 44100, 48000, AV_ROUND_UP); - * av_samples_alloc(&output, NULL, 2, out_samples, - * AV_SAMPLE_FMT_S16, 0); - * out_samples = swr_convert(swr, &output, out_samples, - * input, in_samples); - * handle_output(output, out_samples); - * av_freep(&output); - * } - * @endcode - * - * When the conversion is finished, the conversion - * context and everything associated with it must be freed with swr_free(). - * A swr_close() function is also available, but it exists mainly for - * compatibility with libavresample, and is not required to be called. - * - * There will be no memory leak if the data is not completely flushed before - * swr_free(). - */ - -#include -#include "libavutil/channel_layout.h" -#include "libavutil/frame.h" -#include "libavutil/samplefmt.h" - -#include "libswresample/version.h" - -/** - * @name Option constants - * These constants are used for the @ref avoptions interface for lswr. - * @{ - * - */ - -#define SWR_FLAG_RESAMPLE 1 ///< Force resampling even if equal sample rate -//TODO use int resample ? -//long term TODO can we enable this dynamically? - -/** Dithering algorithms */ -enum SwrDitherType { - SWR_DITHER_NONE = 0, - SWR_DITHER_RECTANGULAR, - SWR_DITHER_TRIANGULAR, - SWR_DITHER_TRIANGULAR_HIGHPASS, - - SWR_DITHER_NS = 64, ///< not part of API/ABI - SWR_DITHER_NS_LIPSHITZ, - SWR_DITHER_NS_F_WEIGHTED, - SWR_DITHER_NS_MODIFIED_E_WEIGHTED, - SWR_DITHER_NS_IMPROVED_E_WEIGHTED, - SWR_DITHER_NS_SHIBATA, - SWR_DITHER_NS_LOW_SHIBATA, - SWR_DITHER_NS_HIGH_SHIBATA, - SWR_DITHER_NB, ///< not part of API/ABI -}; - -/** Resampling Engines */ -enum SwrEngine { - SWR_ENGINE_SWR, /**< SW Resampler */ - SWR_ENGINE_SOXR, /**< SoX Resampler */ - SWR_ENGINE_NB, ///< not part of API/ABI -}; - -/** Resampling Filter Types */ -enum SwrFilterType { - SWR_FILTER_TYPE_CUBIC, /**< Cubic */ - SWR_FILTER_TYPE_BLACKMAN_NUTTALL, /**< Blackman Nuttall windowed sinc */ - SWR_FILTER_TYPE_KAISER, /**< Kaiser windowed sinc */ -}; - -/** - * @} - */ - -/** - * The libswresample context. Unlike libavcodec and libavformat, this structure - * is opaque. This means that if you would like to set options, you must use - * the @ref avoptions API and cannot directly set values to members of the - * structure. - */ -typedef struct SwrContext SwrContext; - -/** - * Get the AVClass for SwrContext. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). - * @return the AVClass of SwrContext - */ -const AVClass *swr_get_class(void); - -/** - * @name SwrContext constructor functions - * @{ - */ - -/** - * Allocate SwrContext. - * - * If you use this function you will need to set the parameters (manually or - * with swr_alloc_set_opts()) before calling swr_init(). - * - * @see swr_alloc_set_opts(), swr_init(), swr_free() - * @return NULL on error, allocated context otherwise - */ -struct SwrContext *swr_alloc(void); - -/** - * Initialize context after user parameters have been set. - * @note The context must be configured using the AVOption API. - * - * @see av_opt_set_int() - * @see av_opt_set_dict() - * - * @param[in,out] s Swr context to initialize - * @return AVERROR error code in case of failure. - */ -int swr_init(struct SwrContext *s); - -/** - * Check whether an swr context has been initialized or not. - * - * @param[in] s Swr context to check - * @see swr_init() - * @return positive if it has been initialized, 0 if not initialized - */ -int swr_is_initialized(struct SwrContext *s); - -/** - * Allocate SwrContext if needed and set/reset common parameters. - * - * This function does not require s to be allocated with swr_alloc(). On the - * other hand, swr_alloc() can use swr_alloc_set_opts() to set the parameters - * on the allocated context. - * - * @param s existing Swr context if available, or NULL if not - * @param out_ch_layout output channel layout (AV_CH_LAYOUT_*) - * @param out_sample_fmt output sample format (AV_SAMPLE_FMT_*). - * @param out_sample_rate output sample rate (frequency in Hz) - * @param in_ch_layout input channel layout (AV_CH_LAYOUT_*) - * @param in_sample_fmt input sample format (AV_SAMPLE_FMT_*). - * @param in_sample_rate input sample rate (frequency in Hz) - * @param log_offset logging level offset - * @param log_ctx parent logging context, can be NULL - * - * @see swr_init(), swr_free() - * @return NULL on error, allocated context otherwise - */ -struct SwrContext *swr_alloc_set_opts(struct SwrContext *s, - int64_t out_ch_layout, enum AVSampleFormat out_sample_fmt, int out_sample_rate, - int64_t in_ch_layout, enum AVSampleFormat in_sample_fmt, int in_sample_rate, - int log_offset, void *log_ctx); - -/** - * @} - * - * @name SwrContext destructor functions - * @{ - */ - -/** - * Free the given SwrContext and set the pointer to NULL. - * - * @param[in] s a pointer to a pointer to Swr context - */ -void swr_free(struct SwrContext **s); - -/** - * Closes the context so that swr_is_initialized() returns 0. - * - * The context can be brought back to life by running swr_init(), - * swr_init() can also be used without swr_close(). - * This function is mainly provided for simplifying the usecase - * where one tries to support libavresample and libswresample. - * - * @param[in,out] s Swr context to be closed - */ -void swr_close(struct SwrContext *s); - -/** - * @} - * - * @name Core conversion functions - * @{ - */ - -/** Convert audio. - * - * in and in_count can be set to 0 to flush the last few samples out at the - * end. - * - * If more input is provided than output space, then the input will be buffered. - * You can avoid this buffering by using swr_get_out_samples() to retrieve an - * upper bound on the required number of output samples for the given number of - * input samples. Conversion will run directly without copying whenever possible. - * - * @param s allocated Swr context, with parameters set - * @param out output buffers, only the first one need be set in case of packed audio - * @param out_count amount of space available for output in samples per channel - * @param in input buffers, only the first one need to be set in case of packed audio - * @param in_count number of input samples available in one channel - * - * @return number of samples output per channel, negative value on error - */ -int swr_convert(struct SwrContext *s, uint8_t **out, int out_count, - const uint8_t **in , int in_count); - -/** - * Convert the next timestamp from input to output - * timestamps are in 1/(in_sample_rate * out_sample_rate) units. - * - * @note There are 2 slightly differently behaving modes. - * @li When automatic timestamp compensation is not used, (min_compensation >= FLT_MAX) - * in this case timestamps will be passed through with delays compensated - * @li When automatic timestamp compensation is used, (min_compensation < FLT_MAX) - * in this case the output timestamps will match output sample numbers. - * See ffmpeg-resampler(1) for the two modes of compensation. - * - * @param s[in] initialized Swr context - * @param pts[in] timestamp for the next input sample, INT64_MIN if unknown - * @see swr_set_compensation(), swr_drop_output(), and swr_inject_silence() are - * function used internally for timestamp compensation. - * @return the output timestamp for the next output sample - */ -int64_t swr_next_pts(struct SwrContext *s, int64_t pts); - -/** - * @} - * - * @name Low-level option setting functions - * These functons provide a means to set low-level options that is not possible - * with the AVOption API. - * @{ - */ - -/** - * Activate resampling compensation ("soft" compensation). This function is - * internally called when needed in swr_next_pts(). - * - * @param[in,out] s allocated Swr context. If it is not initialized, - * or SWR_FLAG_RESAMPLE is not set, swr_init() is - * called with the flag set. - * @param[in] sample_delta delta in PTS per sample - * @param[in] compensation_distance number of samples to compensate for - * @return >= 0 on success, AVERROR error codes if: - * @li @c s is NULL, - * @li @c compensation_distance is less than 0, - * @li @c compensation_distance is 0 but sample_delta is not, - * @li compensation unsupported by resampler, or - * @li swr_init() fails when called. - */ -int swr_set_compensation(struct SwrContext *s, int sample_delta, int compensation_distance); - -/** - * Set a customized input channel mapping. - * - * @param[in,out] s allocated Swr context, not yet initialized - * @param[in] channel_map customized input channel mapping (array of channel - * indexes, -1 for a muted channel) - * @return >= 0 on success, or AVERROR error code in case of failure. - */ -int swr_set_channel_mapping(struct SwrContext *s, const int *channel_map); - -/** - * Generate a channel mixing matrix. - * - * This function is the one used internally by libswresample for building the - * default mixing matrix. It is made public just as a utility function for - * building custom matrices. - * - * @param in_layout input channel layout - * @param out_layout output channel layout - * @param center_mix_level mix level for the center channel - * @param surround_mix_level mix level for the surround channel(s) - * @param lfe_mix_level mix level for the low-frequency effects channel - * @param rematrix_maxval if 1.0, coefficients will be normalized to prevent - * overflow. if INT_MAX, coefficients will not be - * normalized. - * @param[out] matrix mixing coefficients; matrix[i + stride * o] is - * the weight of input channel i in output channel o. - * @param stride distance between adjacent input channels in the - * matrix array - * @param matrix_encoding matrixed stereo downmix mode (e.g. dplii) - * @param log_ctx parent logging context, can be NULL - * @return 0 on success, negative AVERROR code on failure - */ -int swr_build_matrix(uint64_t in_layout, uint64_t out_layout, - double center_mix_level, double surround_mix_level, - double lfe_mix_level, double rematrix_maxval, - double rematrix_volume, double *matrix, - int stride, enum AVMatrixEncoding matrix_encoding, - void *log_ctx); - -/** - * Set a customized remix matrix. - * - * @param s allocated Swr context, not yet initialized - * @param matrix remix coefficients; matrix[i + stride * o] is - * the weight of input channel i in output channel o - * @param stride offset between lines of the matrix - * @return >= 0 on success, or AVERROR error code in case of failure. - */ -int swr_set_matrix(struct SwrContext *s, const double *matrix, int stride); - -/** - * @} - * - * @name Sample handling functions - * @{ - */ - -/** - * Drops the specified number of output samples. - * - * This function, along with swr_inject_silence(), is called by swr_next_pts() - * if needed for "hard" compensation. - * - * @param s allocated Swr context - * @param count number of samples to be dropped - * - * @return >= 0 on success, or a negative AVERROR code on failure - */ -int swr_drop_output(struct SwrContext *s, int count); - -/** - * Injects the specified number of silence samples. - * - * This function, along with swr_drop_output(), is called by swr_next_pts() - * if needed for "hard" compensation. - * - * @param s allocated Swr context - * @param count number of samples to be dropped - * - * @return >= 0 on success, or a negative AVERROR code on failure - */ -int swr_inject_silence(struct SwrContext *s, int count); - -/** - * Gets the delay the next input sample will experience relative to the next output sample. - * - * Swresample can buffer data if more input has been provided than available - * output space, also converting between sample rates needs a delay. - * This function returns the sum of all such delays. - * The exact delay is not necessarily an integer value in either input or - * output sample rate. Especially when downsampling by a large value, the - * output sample rate may be a poor choice to represent the delay, similarly - * for upsampling and the input sample rate. - * - * @param s swr context - * @param base timebase in which the returned delay will be: - * @li if it's set to 1 the returned delay is in seconds - * @li if it's set to 1000 the returned delay is in milliseconds - * @li if it's set to the input sample rate then the returned - * delay is in input samples - * @li if it's set to the output sample rate then the returned - * delay is in output samples - * @li if it's the least common multiple of in_sample_rate and - * out_sample_rate then an exact rounding-free delay will be - * returned - * @returns the delay in 1 / @c base units. - */ -int64_t swr_get_delay(struct SwrContext *s, int64_t base); - -/** - * Find an upper bound on the number of samples that the next swr_convert - * call will output, if called with in_samples of input samples. This - * depends on the internal state, and anything changing the internal state - * (like further swr_convert() calls) will may change the number of samples - * swr_get_out_samples() returns for the same number of input samples. - * - * @param in_samples number of input samples. - * @note any call to swr_inject_silence(), swr_convert(), swr_next_pts() - * or swr_set_compensation() invalidates this limit - * @note it is recommended to pass the correct available buffer size - * to all functions like swr_convert() even if swr_get_out_samples() - * indicates that less would be used. - * @returns an upper bound on the number of samples that the next swr_convert - * will output or a negative value to indicate an error - */ -int swr_get_out_samples(struct SwrContext *s, int in_samples); - -/** - * @} - * - * @name Configuration accessors - * @{ - */ - -/** - * Return the @ref LIBSWRESAMPLE_VERSION_INT constant. - * - * This is useful to check if the build-time libswresample has the same version - * as the run-time one. - * - * @returns the unsigned int-typed version - */ -unsigned swresample_version(void); - -/** - * Return the swr build-time configuration. - * - * @returns the build-time @c ./configure flags - */ -const char *swresample_configuration(void); - -/** - * Return the swr license. - * - * @returns the license of libswresample, determined at build-time - */ -const char *swresample_license(void); - -/** - * @} - * - * @name AVFrame based API - * @{ - */ - -/** - * Convert the samples in the input AVFrame and write them to the output AVFrame. - * - * Input and output AVFrames must have channel_layout, sample_rate and format set. - * - * If the output AVFrame does not have the data pointers allocated the nb_samples - * field will be set using av_frame_get_buffer() - * is called to allocate the frame. - * - * The output AVFrame can be NULL or have fewer allocated samples than required. - * In this case, any remaining samples not written to the output will be added - * to an internal FIFO buffer, to be returned at the next call to this function - * or to swr_convert(). - * - * If converting sample rate, there may be data remaining in the internal - * resampling delay buffer. swr_get_delay() tells the number of - * remaining samples. To get this data as output, call this function or - * swr_convert() with NULL input. - * - * If the SwrContext configuration does not match the output and - * input AVFrame settings the conversion does not take place and depending on - * which AVFrame is not matching AVERROR_OUTPUT_CHANGED, AVERROR_INPUT_CHANGED - * or the result of a bitwise-OR of them is returned. - * - * @see swr_delay() - * @see swr_convert() - * @see swr_get_delay() - * - * @param swr audio resample context - * @param output output AVFrame - * @param input input AVFrame - * @return 0 on success, AVERROR on failure or nonmatching - * configuration. - */ -int swr_convert_frame(SwrContext *swr, - AVFrame *output, const AVFrame *input); - -/** - * Configure or reconfigure the SwrContext using the information - * provided by the AVFrames. - * - * The original resampling context is reset even on failure. - * The function calls swr_close() internally if the context is open. - * - * @see swr_close(); - * - * @param swr audio resample context - * @param output output AVFrame - * @param input input AVFrame - * @return 0 on success, AVERROR on failure. - */ -int swr_config_frame(SwrContext *swr, const AVFrame *out, const AVFrame *in); - -/** - * @} - * @} - */ - -#endif /* SWRESAMPLE_SWRESAMPLE_H */ diff --git a/maclibs/include/libswresample/version.h b/maclibs/include/libswresample/version.h deleted file mode 100644 index a0b361bc..00000000 --- a/maclibs/include/libswresample/version.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Version macros. - * - * This file is part of libswresample - * - * libswresample is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * libswresample is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with libswresample; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#ifndef SWRESAMPLE_VERSION_H -#define SWRESAMPLE_VERSION_H - -/** - * @file - * Libswresample version macros - */ - -#include "libavutil/avutil.h" - -#define LIBSWRESAMPLE_VERSION_MAJOR 3 -#define LIBSWRESAMPLE_VERSION_MINOR 5 -#define LIBSWRESAMPLE_VERSION_MICRO 100 - -#define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ - LIBSWRESAMPLE_VERSION_MINOR, \ - LIBSWRESAMPLE_VERSION_MICRO) -#define LIBSWRESAMPLE_VERSION AV_VERSION(LIBSWRESAMPLE_VERSION_MAJOR, \ - LIBSWRESAMPLE_VERSION_MINOR, \ - LIBSWRESAMPLE_VERSION_MICRO) -#define LIBSWRESAMPLE_BUILD LIBSWRESAMPLE_VERSION_INT - -#define LIBSWRESAMPLE_IDENT "SwR" AV_STRINGIFY(LIBSWRESAMPLE_VERSION) - -#endif /* SWRESAMPLE_VERSION_H */ diff --git a/maclibs/include/lzma.h b/maclibs/include/lzma.h deleted file mode 100644 index ce675a78..00000000 --- a/maclibs/include/lzma.h +++ /dev/null @@ -1,321 +0,0 @@ -/** - * \file api/lzma.h - * \brief The public API of liblzma data compression library - * - * liblzma is a public domain general-purpose data compression library with - * a zlib-like API. The native file format is .xz, but also the old .lzma - * format and raw (no headers) streams are supported. Multiple compression - * algorithms (filters) are supported. Currently LZMA2 is the primary filter. - * - * liblzma is part of XZ Utils . XZ Utils includes - * a gzip-like command line tool named xz and some other tools. XZ Utils - * is developed and maintained by Lasse Collin. - * - * Major parts of liblzma are based on Igor Pavlov's public domain LZMA SDK - * . - * - * The SHA-256 implementation is based on the public domain code found from - * 7-Zip , which has a modified version of the public - * domain SHA-256 code found from Crypto++ . - * The SHA-256 code in Crypto++ was written by Kevin Springle and Wei Dai. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - */ - -#ifndef LZMA_H -#define LZMA_H - -/***************************** - * Required standard headers * - *****************************/ - -/* - * liblzma API headers need some standard types and macros. To allow - * including lzma.h without requiring the application to include other - * headers first, lzma.h includes the required standard headers unless - * they already seem to be included already or if LZMA_MANUAL_HEADERS - * has been defined. - * - * Here's what types and macros are needed and from which headers: - * - stddef.h: size_t, NULL - * - stdint.h: uint8_t, uint32_t, uint64_t, UINT32_C(n), uint64_C(n), - * UINT32_MAX, UINT64_MAX - * - * However, inttypes.h is a little more portable than stdint.h, although - * inttypes.h declares some unneeded things compared to plain stdint.h. - * - * The hacks below aren't perfect, specifically they assume that inttypes.h - * exists and that it typedefs at least uint8_t, uint32_t, and uint64_t, - * and that, in case of incomplete inttypes.h, unsigned int is 32-bit. - * If the application already takes care of setting up all the types and - * macros properly (for example by using gnulib's stdint.h or inttypes.h), - * we try to detect that the macros are already defined and don't include - * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to - * force this file to never include any system headers. - * - * Some could argue that liblzma API should provide all the required types, - * for example lzma_uint64, LZMA_UINT64_C(n), and LZMA_UINT64_MAX. This was - * seen as an unnecessary mess, since most systems already provide all the - * necessary types and macros in the standard headers. - * - * Note that liblzma API still has lzma_bool, because using stdbool.h would - * break C89 and C++ programs on many systems. sizeof(bool) in C99 isn't - * necessarily the same as sizeof(bool) in C++. - */ - -#ifndef LZMA_MANUAL_HEADERS - /* - * I suppose this works portably also in C++. Note that in C++, - * we need to get size_t into the global namespace. - */ -# include - - /* - * Skip inttypes.h if we already have all the required macros. If we - * have the macros, we assume that we have the matching typedefs too. - */ -# if !defined(UINT32_C) || !defined(UINT64_C) \ - || !defined(UINT32_MAX) || !defined(UINT64_MAX) - /* - * MSVC versions older than 2013 have no C99 support, and - * thus they cannot be used to compile liblzma. Using an - * existing liblzma.dll with old MSVC can work though(*), - * but we need to define the required standard integer - * types here in a MSVC-specific way. - * - * (*) If you do this, the existing liblzma.dll probably uses - * a different runtime library than your MSVC-built - * application. Mixing runtimes is generally bad, but - * in this case it should work as long as you avoid - * the few rarely-needed liblzma functions that allocate - * memory and expect the caller to free it using free(). - */ -# if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1800 - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - typedef unsigned __int64 uint64_t; -# else - /* Use the standard inttypes.h. */ -# ifdef __cplusplus - /* - * C99 sections 7.18.2 and 7.18.4 specify - * that C++ implementations define the limit - * and constant macros only if specifically - * requested. Note that if you want the - * format macros (PRIu64 etc.) too, you need - * to define __STDC_FORMAT_MACROS before - * including lzma.h, since re-including - * inttypes.h with __STDC_FORMAT_MACROS - * defined doesn't necessarily work. - */ -# ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -# endif -# ifndef __STDC_CONSTANT_MACROS -# define __STDC_CONSTANT_MACROS 1 -# endif -# endif - -# include -# endif - - /* - * Some old systems have only the typedefs in inttypes.h, and - * lack all the macros. For those systems, we need a few more - * hacks. We assume that unsigned int is 32-bit and unsigned - * long is either 32-bit or 64-bit. If these hacks aren't - * enough, the application has to setup the types manually - * before including lzma.h. - */ -# ifndef UINT32_C -# if defined(_WIN32) && defined(_MSC_VER) -# define UINT32_C(n) n ## UI32 -# else -# define UINT32_C(n) n ## U -# endif -# endif - -# ifndef UINT64_C -# if defined(_WIN32) && defined(_MSC_VER) -# define UINT64_C(n) n ## UI64 -# else - /* Get ULONG_MAX. */ -# include -# if ULONG_MAX == 4294967295UL -# define UINT64_C(n) n ## ULL -# else -# define UINT64_C(n) n ## UL -# endif -# endif -# endif - -# ifndef UINT32_MAX -# define UINT32_MAX (UINT32_C(4294967295)) -# endif - -# ifndef UINT64_MAX -# define UINT64_MAX (UINT64_C(18446744073709551615)) -# endif -# endif -#endif /* ifdef LZMA_MANUAL_HEADERS */ - - -/****************** - * LZMA_API macro * - ******************/ - -/* - * Some systems require that the functions and function pointers are - * declared specially in the headers. LZMA_API_IMPORT is for importing - * symbols and LZMA_API_CALL is to specify the calling convention. - * - * By default it is assumed that the application will link dynamically - * against liblzma. #define LZMA_API_STATIC in your application if you - * want to link against static liblzma. If you don't care about portability - * to operating systems like Windows, or at least don't care about linking - * against static liblzma on them, don't worry about LZMA_API_STATIC. That - * is, most developers will never need to use LZMA_API_STATIC. - * - * The GCC variants are a special case on Windows (Cygwin and MinGW). - * We rely on GCC doing the right thing with its auto-import feature, - * and thus don't use __declspec(dllimport). This way developers don't - * need to worry about LZMA_API_STATIC. Also the calling convention is - * omitted on Cygwin but not on MinGW. - */ -#ifndef LZMA_API_IMPORT -# if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__) -# define LZMA_API_IMPORT __declspec(dllimport) -# else -# define LZMA_API_IMPORT -# endif -#endif - -#ifndef LZMA_API_CALL -# if defined(_WIN32) && !defined(__CYGWIN__) -# define LZMA_API_CALL __cdecl -# else -# define LZMA_API_CALL -# endif -#endif - -#ifndef LZMA_API -# define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL -#endif - - -/*********** - * nothrow * - ***********/ - -/* - * None of the functions in liblzma may throw an exception. Even - * the functions that use callback functions won't throw exceptions, - * because liblzma would break if a callback function threw an exception. - */ -#ifndef lzma_nothrow -# if defined(__cplusplus) -# define lzma_nothrow throw() -# elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) -# define lzma_nothrow __attribute__((__nothrow__)) -# else -# define lzma_nothrow -# endif -#endif - - -/******************** - * GNU C extensions * - ********************/ - -/* - * GNU C extensions are used conditionally in the public API. It doesn't - * break anything if these are sometimes enabled and sometimes not, only - * affects warnings and optimizations. - */ -#if __GNUC__ >= 3 -# ifndef lzma_attribute -# define lzma_attribute(attr) __attribute__(attr) -# endif - - /* warn_unused_result was added in GCC 3.4. */ -# ifndef lzma_attr_warn_unused_result -# if __GNUC__ == 3 && __GNUC_MINOR__ < 4 -# define lzma_attr_warn_unused_result -# endif -# endif - -#else -# ifndef lzma_attribute -# define lzma_attribute(attr) -# endif -#endif - - -#ifndef lzma_attr_pure -# define lzma_attr_pure lzma_attribute((__pure__)) -#endif - -#ifndef lzma_attr_const -# define lzma_attr_const lzma_attribute((__const__)) -#endif - -#ifndef lzma_attr_warn_unused_result -# define lzma_attr_warn_unused_result \ - lzma_attribute((__warn_unused_result__)) -#endif - - -/************** - * Subheaders * - **************/ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Subheaders check that this is defined. It is to prevent including - * them directly from applications. - */ -#define LZMA_H_INTERNAL 1 - -/* Basic features */ -#include "lzma/version.h" -#include "lzma/base.h" -#include "lzma/vli.h" -#include "lzma/check.h" - -/* Filters */ -#include "lzma/filter.h" -#include "lzma/bcj.h" -#include "lzma/delta.h" -#include "lzma/lzma12.h" - -/* Container formats */ -#include "lzma/container.h" - -/* Advanced features */ -#include "lzma/stream_flags.h" -#include "lzma/block.h" -#include "lzma/index.h" -#include "lzma/index_hash.h" - -/* Hardware information */ -#include "lzma/hardware.h" - -/* - * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications - * re-including the subheaders. - */ -#undef LZMA_H_INTERNAL - -#ifdef __cplusplus -} -#endif - -#endif /* ifndef LZMA_H */ diff --git a/maclibs/include/lzma/base.h b/maclibs/include/lzma/base.h deleted file mode 100644 index 7a31a420..00000000 --- a/maclibs/include/lzma/base.h +++ /dev/null @@ -1,654 +0,0 @@ -/** - * \file lzma/base.h - * \brief Data types and functions used in many places in liblzma API - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Boolean - * - * This is here because C89 doesn't have stdbool.h. To set a value for - * variables having type lzma_bool, you can use - * - C99's `true' and `false' from stdbool.h; - * - C++'s internal `true' and `false'; or - * - integers one (true) and zero (false). - */ -typedef unsigned char lzma_bool; - - -/** - * \brief Type of reserved enumeration variable in structures - * - * To avoid breaking library ABI when new features are added, several - * structures contain extra variables that may be used in future. Since - * sizeof(enum) can be different than sizeof(int), and sizeof(enum) may - * even vary depending on the range of enumeration constants, we specify - * a separate type to be used for reserved enumeration variables. All - * enumeration constants in liblzma API will be non-negative and less - * than 128, which should guarantee that the ABI won't break even when - * new constants are added to existing enumerations. - */ -typedef enum { - LZMA_RESERVED_ENUM = 0 -} lzma_reserved_enum; - - -/** - * \brief Return values used by several functions in liblzma - * - * Check the descriptions of specific functions to find out which return - * values they can return. With some functions the return values may have - * more specific meanings than described here; those differences are - * described per-function basis. - */ -typedef enum { - LZMA_OK = 0, - /**< - * \brief Operation completed successfully - */ - - LZMA_STREAM_END = 1, - /**< - * \brief End of stream was reached - * - * In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or - * LZMA_FINISH was finished. In decoder, this indicates - * that all the data was successfully decoded. - * - * In all cases, when LZMA_STREAM_END is returned, the last - * output bytes should be picked from strm->next_out. - */ - - LZMA_NO_CHECK = 2, - /**< - * \brief Input stream has no integrity check - * - * This return value can be returned only if the - * LZMA_TELL_NO_CHECK flag was used when initializing - * the decoder. LZMA_NO_CHECK is just a warning, and - * the decoding can be continued normally. - * - * It is possible to call lzma_get_check() immediately after - * lzma_code has returned LZMA_NO_CHECK. The result will - * naturally be LZMA_CHECK_NONE, but the possibility to call - * lzma_get_check() may be convenient in some applications. - */ - - LZMA_UNSUPPORTED_CHECK = 3, - /**< - * \brief Cannot calculate the integrity check - * - * The usage of this return value is different in encoders - * and decoders. - * - * Encoders can return this value only from the initialization - * function. If initialization fails with this value, the - * encoding cannot be done, because there's no way to produce - * output with the correct integrity check. - * - * Decoders can return this value only from lzma_code() and - * only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when - * initializing the decoder. The decoding can still be - * continued normally even if the check type is unsupported, - * but naturally the check will not be validated, and possible - * errors may go undetected. - * - * With decoder, it is possible to call lzma_get_check() - * immediately after lzma_code() has returned - * LZMA_UNSUPPORTED_CHECK. This way it is possible to find - * out what the unsupported Check ID was. - */ - - LZMA_GET_CHECK = 4, - /**< - * \brief Integrity check type is now available - * - * This value can be returned only by the lzma_code() function - * and only if the decoder was initialized with the - * LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the - * application that it may now call lzma_get_check() to find - * out the Check ID. This can be used, for example, to - * implement a decoder that accepts only files that have - * strong enough integrity check. - */ - - LZMA_MEM_ERROR = 5, - /**< - * \brief Cannot allocate memory - * - * Memory allocation failed, or the size of the allocation - * would be greater than SIZE_MAX. - * - * Due to internal implementation reasons, the coding cannot - * be continued even if more memory were made available after - * LZMA_MEM_ERROR. - */ - - LZMA_MEMLIMIT_ERROR = 6, - /** - * \brief Memory usage limit was reached - * - * Decoder would need more memory than allowed by the - * specified memory usage limit. To continue decoding, - * the memory usage limit has to be increased with - * lzma_memlimit_set(). - */ - - LZMA_FORMAT_ERROR = 7, - /**< - * \brief File format not recognized - * - * The decoder did not recognize the input as supported file - * format. This error can occur, for example, when trying to - * decode .lzma format file with lzma_stream_decoder, - * because lzma_stream_decoder accepts only the .xz format. - */ - - LZMA_OPTIONS_ERROR = 8, - /**< - * \brief Invalid or unsupported options - * - * Invalid or unsupported options, for example - * - unsupported filter(s) or filter options; or - * - reserved bits set in headers (decoder only). - * - * Rebuilding liblzma with more features enabled, or - * upgrading to a newer version of liblzma may help. - */ - - LZMA_DATA_ERROR = 9, - /**< - * \brief Data is corrupt - * - * The usage of this return value is different in encoders - * and decoders. In both encoder and decoder, the coding - * cannot continue after this error. - * - * Encoders return this if size limits of the target file - * format would be exceeded. These limits are huge, thus - * getting this error from an encoder is mostly theoretical. - * For example, the maximum compressed and uncompressed - * size of a .xz Stream is roughly 8 EiB (2^63 bytes). - * - * Decoders return this error if the input data is corrupt. - * This can mean, for example, invalid CRC32 in headers - * or invalid check of uncompressed data. - */ - - LZMA_BUF_ERROR = 10, - /**< - * \brief No progress is possible - * - * This error code is returned when the coder cannot consume - * any new input and produce any new output. The most common - * reason for this error is that the input stream being - * decoded is truncated or corrupt. - * - * This error is not fatal. Coding can be continued normally - * by providing more input and/or more output space, if - * possible. - * - * Typically the first call to lzma_code() that can do no - * progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only - * the second consecutive call doing no progress will return - * LZMA_BUF_ERROR. This is intentional. - * - * With zlib, Z_BUF_ERROR may be returned even if the - * application is doing nothing wrong, so apps will need - * to handle Z_BUF_ERROR specially. The above hack - * guarantees that liblzma never returns LZMA_BUF_ERROR - * to properly written applications unless the input file - * is truncated or corrupt. This should simplify the - * applications a little. - */ - - LZMA_PROG_ERROR = 11, - /**< - * \brief Programming error - * - * This indicates that the arguments given to the function are - * invalid or the internal state of the decoder is corrupt. - * - Function arguments are invalid or the structures - * pointed by the argument pointers are invalid - * e.g. if strm->next_out has been set to NULL and - * strm->avail_out > 0 when calling lzma_code(). - * - lzma_* functions have been called in wrong order - * e.g. lzma_code() was called right after lzma_end(). - * - If errors occur randomly, the reason might be flaky - * hardware. - * - * If you think that your code is correct, this error code - * can be a sign of a bug in liblzma. See the documentation - * how to report bugs. - */ -} lzma_ret; - - -/** - * \brief The `action' argument for lzma_code() - * - * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER, - * or LZMA_FINISH, the same `action' must is used until lzma_code() returns - * LZMA_STREAM_END. Also, the amount of input (that is, strm->avail_in) must - * not be modified by the application until lzma_code() returns - * LZMA_STREAM_END. Changing the `action' or modifying the amount of input - * will make lzma_code() return LZMA_PROG_ERROR. - */ -typedef enum { - LZMA_RUN = 0, - /**< - * \brief Continue coding - * - * Encoder: Encode as much input as possible. Some internal - * buffering will probably be done (depends on the filter - * chain in use), which causes latency: the input used won't - * usually be decodeable from the output of the same - * lzma_code() call. - * - * Decoder: Decode as much input as possible and produce as - * much output as possible. - */ - - LZMA_SYNC_FLUSH = 1, - /**< - * \brief Make all the input available at output - * - * Normally the encoder introduces some latency. - * LZMA_SYNC_FLUSH forces all the buffered data to be - * available at output without resetting the internal - * state of the encoder. This way it is possible to use - * compressed stream for example for communication over - * network. - * - * Only some filters support LZMA_SYNC_FLUSH. Trying to use - * LZMA_SYNC_FLUSH with filters that don't support it will - * make lzma_code() return LZMA_OPTIONS_ERROR. For example, - * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does. - * - * Using LZMA_SYNC_FLUSH very often can dramatically reduce - * the compression ratio. With some filters (for example, - * LZMA2), fine-tuning the compression options may help - * mitigate this problem significantly (for example, - * match finder with LZMA2). - * - * Decoders don't support LZMA_SYNC_FLUSH. - */ - - LZMA_FULL_FLUSH = 2, - /**< - * \brief Finish encoding of the current Block - * - * All the input data going to the current Block must have - * been given to the encoder (the last bytes can still be - * pending in *next_in). Call lzma_code() with LZMA_FULL_FLUSH - * until it returns LZMA_STREAM_END. Then continue normally - * with LZMA_RUN or finish the Stream with LZMA_FINISH. - * - * This action is currently supported only by Stream encoder - * and easy encoder (which uses Stream encoder). If there is - * no unfinished Block, no empty Block is created. - */ - - LZMA_FULL_BARRIER = 4, - /**< - * \brief Finish encoding of the current Block - * - * This is like LZMA_FULL_FLUSH except that this doesn't - * necessarily wait until all the input has been made - * available via the output buffer. That is, lzma_code() - * might return LZMA_STREAM_END as soon as all the input - * has been consumed (avail_in == 0). - * - * LZMA_FULL_BARRIER is useful with a threaded encoder if - * one wants to split the .xz Stream into Blocks at specific - * offsets but doesn't care if the output isn't flushed - * immediately. Using LZMA_FULL_BARRIER allows keeping - * the threads busy while LZMA_FULL_FLUSH would make - * lzma_code() wait until all the threads have finished - * until more data could be passed to the encoder. - * - * With a lzma_stream initialized with the single-threaded - * lzma_stream_encoder() or lzma_easy_encoder(), - * LZMA_FULL_BARRIER is an alias for LZMA_FULL_FLUSH. - */ - - LZMA_FINISH = 3 - /**< - * \brief Finish the coding operation - * - * All the input data must have been given to the encoder - * (the last bytes can still be pending in next_in). - * Call lzma_code() with LZMA_FINISH until it returns - * LZMA_STREAM_END. Once LZMA_FINISH has been used, - * the amount of input must no longer be changed by - * the application. - * - * When decoding, using LZMA_FINISH is optional unless the - * LZMA_CONCATENATED flag was used when the decoder was - * initialized. When LZMA_CONCATENATED was not used, the only - * effect of LZMA_FINISH is that the amount of input must not - * be changed just like in the encoder. - */ -} lzma_action; - - -/** - * \brief Custom functions for memory handling - * - * A pointer to lzma_allocator may be passed via lzma_stream structure - * to liblzma, and some advanced functions take a pointer to lzma_allocator - * as a separate function argument. The library will use the functions - * specified in lzma_allocator for memory handling instead of the default - * malloc() and free(). C++ users should note that the custom memory - * handling functions must not throw exceptions. - * - * Single-threaded mode only: liblzma doesn't make an internal copy of - * lzma_allocator. Thus, it is OK to change these function pointers in - * the middle of the coding process, but obviously it must be done - * carefully to make sure that the replacement `free' can deallocate - * memory allocated by the earlier `alloc' function(s). - * - * Multithreaded mode: liblzma might internally store pointers to the - * lzma_allocator given via the lzma_stream structure. The application - * must not change the allocator pointer in lzma_stream or the contents - * of the pointed lzma_allocator structure until lzma_end() has been used - * to free the memory associated with that lzma_stream. The allocation - * functions might be called simultaneously from multiple threads, and - * thus they must be thread safe. - */ -typedef struct { - /** - * \brief Pointer to a custom memory allocation function - * - * If you don't want a custom allocator, but still want - * custom free(), set this to NULL and liblzma will use - * the standard malloc(). - * - * \param opaque lzma_allocator.opaque (see below) - * \param nmemb Number of elements like in calloc(). liblzma - * will always set nmemb to 1, so it is safe to - * ignore nmemb in a custom allocator if you like. - * The nmemb argument exists only for - * compatibility with zlib and libbzip2. - * \param size Size of an element in bytes. - * liblzma never sets this to zero. - * - * \return Pointer to the beginning of a memory block of - * `size' bytes, or NULL if allocation fails - * for some reason. When allocation fails, functions - * of liblzma return LZMA_MEM_ERROR. - * - * The allocator should not waste time zeroing the allocated buffers. - * This is not only about speed, but also memory usage, since the - * operating system kernel doesn't necessarily allocate the requested - * memory in physical memory until it is actually used. With small - * input files, liblzma may actually need only a fraction of the - * memory that it requested for allocation. - * - * \note LZMA_MEM_ERROR is also used when the size of the - * allocation would be greater than SIZE_MAX. Thus, - * don't assume that the custom allocator must have - * returned NULL if some function from liblzma - * returns LZMA_MEM_ERROR. - */ - void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size); - - /** - * \brief Pointer to a custom memory freeing function - * - * If you don't want a custom freeing function, but still - * want a custom allocator, set this to NULL and liblzma - * will use the standard free(). - * - * \param opaque lzma_allocator.opaque (see below) - * \param ptr Pointer returned by lzma_allocator.alloc(), - * or when it is set to NULL, a pointer returned - * by the standard malloc(). - */ - void (LZMA_API_CALL *free)(void *opaque, void *ptr); - - /** - * \brief Pointer passed to .alloc() and .free() - * - * opaque is passed as the first argument to lzma_allocator.alloc() - * and lzma_allocator.free(). This intended to ease implementing - * custom memory allocation functions for use with liblzma. - * - * If you don't need this, you should set this to NULL. - */ - void *opaque; - -} lzma_allocator; - - -/** - * \brief Internal data structure - * - * The contents of this structure is not visible outside the library. - */ -typedef struct lzma_internal_s lzma_internal; - - -/** - * \brief Passing data to and from liblzma - * - * The lzma_stream structure is used for - * - passing pointers to input and output buffers to liblzma; - * - defining custom memory hander functions; and - * - holding a pointer to coder-specific internal data structures. - * - * Typical usage: - * - * - After allocating lzma_stream (on stack or with malloc()), it must be - * initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details). - * - * - Initialize a coder to the lzma_stream, for example by using - * lzma_easy_encoder() or lzma_auto_decoder(). Some notes: - * - In contrast to zlib, strm->next_in and strm->next_out are - * ignored by all initialization functions, thus it is safe - * to not initialize them yet. - * - The initialization functions always set strm->total_in and - * strm->total_out to zero. - * - If the initialization function fails, no memory is left allocated - * that would require freeing with lzma_end() even if some memory was - * associated with the lzma_stream structure when the initialization - * function was called. - * - * - Use lzma_code() to do the actual work. - * - * - Once the coding has been finished, the existing lzma_stream can be - * reused. It is OK to reuse lzma_stream with different initialization - * function without calling lzma_end() first. Old allocations are - * automatically freed. - * - * - Finally, use lzma_end() to free the allocated memory. lzma_end() never - * frees the lzma_stream structure itself. - * - * Application may modify the values of total_in and total_out as it wants. - * They are updated by liblzma to match the amount of data read and - * written but aren't used for anything else except as a possible return - * values from lzma_get_progress(). - */ -typedef struct { - const uint8_t *next_in; /**< Pointer to the next input byte. */ - size_t avail_in; /**< Number of available input bytes in next_in. */ - uint64_t total_in; /**< Total number of bytes read by liblzma. */ - - uint8_t *next_out; /**< Pointer to the next output position. */ - size_t avail_out; /**< Amount of free space in next_out. */ - uint64_t total_out; /**< Total number of bytes written by liblzma. */ - - /** - * \brief Custom memory allocation functions - * - * In most cases this is NULL which makes liblzma use - * the standard malloc() and free(). - * - * \note In 5.0.x this is not a const pointer. - */ - const lzma_allocator *allocator; - - /** Internal state is not visible to applications. */ - lzma_internal *internal; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. Excluding the initialization of this structure, - * you should not touch these, because the names of these variables - * may change. - */ - void *reserved_ptr1; - void *reserved_ptr2; - void *reserved_ptr3; - void *reserved_ptr4; - uint64_t reserved_int1; - uint64_t reserved_int2; - size_t reserved_int3; - size_t reserved_int4; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - -} lzma_stream; - - -/** - * \brief Initialization for lzma_stream - * - * When you declare an instance of lzma_stream, you can immediately - * initialize it so that initialization functions know that no memory - * has been allocated yet: - * - * lzma_stream strm = LZMA_STREAM_INIT; - * - * If you need to initialize a dynamically allocated lzma_stream, you can use - * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this - * violates the C standard since NULL may have different internal - * representation than zero, but it should be portable enough in practice. - * Anyway, for maximum portability, you can use something like this: - * - * lzma_stream tmp = LZMA_STREAM_INIT; - * *strm = tmp; - */ -#define LZMA_STREAM_INIT \ - { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \ - NULL, NULL, NULL, NULL, 0, 0, 0, 0, \ - LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM } - - -/** - * \brief Encode or decode data - * - * Once the lzma_stream has been successfully initialized (e.g. with - * lzma_stream_encoder()), the actual encoding or decoding is done - * using this function. The application has to update strm->next_in, - * strm->avail_in, strm->next_out, and strm->avail_out to pass input - * to and get output from liblzma. - * - * See the description of the coder-specific initialization function to find - * out what `action' values are supported by the coder. - */ -extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Free memory allocated for the coder data structures - * - * \param strm Pointer to lzma_stream that is at least initialized - * with LZMA_STREAM_INIT. - * - * After lzma_end(strm), strm->internal is guaranteed to be NULL. No other - * members of the lzma_stream structure are touched. - * - * \note zlib indicates an error if application end()s unfinished - * stream structure. liblzma doesn't do this, and assumes that - * application knows what it is doing. - */ -extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow; - - -/** - * \brief Get progress information - * - * In single-threaded mode, applications can get progress information from - * strm->total_in and strm->total_out. In multi-threaded mode this is less - * useful because a significant amount of both input and output data gets - * buffered internally by liblzma. This makes total_in and total_out give - * misleading information and also makes the progress indicator updates - * non-smooth. - * - * This function gives realistic progress information also in multi-threaded - * mode by taking into account the progress made by each thread. In - * single-threaded mode *progress_in and *progress_out are set to - * strm->total_in and strm->total_out, respectively. - */ -extern LZMA_API(void) lzma_get_progress(lzma_stream *strm, - uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow; - - -/** - * \brief Get the memory usage of decoder filter chain - * - * This function is currently supported only when *strm has been initialized - * with a function that takes a memlimit argument. With other functions, you - * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage() - * to estimate the memory requirements. - * - * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big - * the memory usage limit should have been to decode the input. Note that - * this may give misleading information if decoding .xz Streams that have - * multiple Blocks, because each Block can have different memory requirements. - * - * \return How much memory is currently allocated for the filter - * decoders. If no filter chain is currently allocated, - * some non-zero value is still returned, which is less than - * or equal to what any filter chain would indicate as its - * memory requirement. - * - * If this function isn't supported by *strm or some other error - * occurs, zero is returned. - */ -extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the current memory usage limit - * - * This function is supported only when *strm has been initialized with - * a function that takes a memlimit argument. - * - * \return On success, the current memory usage limit is returned - * (always non-zero). On error, zero is returned. - */ -extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Set the memory usage limit - * - * This function is supported only when *strm has been initialized with - * a function that takes a memlimit argument. - * - * \return - LZMA_OK: New memory usage limit successfully set. - * - LZMA_MEMLIMIT_ERROR: The new limit is too small. - * The limit was not changed. - * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't - * support memory usage limit or memlimit was zero. - */ -extern LZMA_API(lzma_ret) lzma_memlimit_set( - lzma_stream *strm, uint64_t memlimit) lzma_nothrow; diff --git a/maclibs/include/lzma/bcj.h b/maclibs/include/lzma/bcj.h deleted file mode 100644 index 8e37538a..00000000 --- a/maclibs/include/lzma/bcj.h +++ /dev/null @@ -1,90 +0,0 @@ -/** - * \file lzma/bcj.h - * \brief Branch/Call/Jump conversion filters - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/* Filter IDs for lzma_filter.id */ - -#define LZMA_FILTER_X86 LZMA_VLI_C(0x04) - /**< - * Filter for x86 binaries - */ - -#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05) - /**< - * Filter for Big endian PowerPC binaries - */ - -#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06) - /**< - * Filter for IA-64 (Itanium) binaries. - */ - -#define LZMA_FILTER_ARM LZMA_VLI_C(0x07) - /**< - * Filter for ARM binaries. - */ - -#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08) - /**< - * Filter for ARM-Thumb binaries. - */ - -#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09) - /**< - * Filter for SPARC binaries. - */ - - -/** - * \brief Options for BCJ filters - * - * The BCJ filters never change the size of the data. Specifying options - * for them is optional: if pointer to options is NULL, default value is - * used. You probably never need to specify options to BCJ filters, so just - * set the options pointer to NULL and be happy. - * - * If options with non-default values have been specified when encoding, - * the same options must also be specified when decoding. - * - * \note At the moment, none of the BCJ filters support - * LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified, - * LZMA_OPTIONS_ERROR will be returned. If there is need, - * partial support for LZMA_SYNC_FLUSH can be added in future. - * Partial means that flushing would be possible only at - * offsets that are multiple of 2, 4, or 16 depending on - * the filter, except x86 which cannot be made to support - * LZMA_SYNC_FLUSH predictably. - */ -typedef struct { - /** - * \brief Start offset for conversions - * - * This setting is useful only when the same filter is used - * _separately_ for multiple sections of the same executable file, - * and the sections contain cross-section branch/call/jump - * instructions. In that case it is beneficial to set the start - * offset of the non-first sections so that the relative addresses - * of the cross-section branch/call/jump instructions will use the - * same absolute addresses as in the first section. - * - * When the pointer to options is NULL, the default value (zero) - * is used. - */ - uint32_t start_offset; - -} lzma_options_bcj; diff --git a/maclibs/include/lzma/block.h b/maclibs/include/lzma/block.h deleted file mode 100644 index 7bdcfd7c..00000000 --- a/maclibs/include/lzma/block.h +++ /dev/null @@ -1,581 +0,0 @@ -/** - * \file lzma/block.h - * \brief .xz Block handling - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Options for the Block and Block Header encoders and decoders - * - * Different Block handling functions use different parts of this structure. - * Some read some members, other functions write, and some do both. Only the - * members listed for reading need to be initialized when the specified - * functions are called. The members marked for writing will be assigned - * new values at some point either by calling the given function or by - * later calls to lzma_code(). - */ -typedef struct { - /** - * \brief Block format version - * - * To prevent API and ABI breakages when new features are needed, - * a version number is used to indicate which fields in this - * structure are in use: - * - liblzma >= 5.0.0: version = 0 is supported. - * - liblzma >= 5.1.4beta: Support for version = 1 was added, - * which adds the ignore_check field. - * - * If version is greater than one, most Block related functions - * will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works - * with any version value). - * - * Read by: - * - All functions that take pointer to lzma_block as argument, - * including lzma_block_header_decode(). - * - * Written by: - * - lzma_block_header_decode() - */ - uint32_t version; - - /** - * \brief Size of the Block Header field - * - * This is always a multiple of four. - * - * Read by: - * - lzma_block_header_encode() - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_size() - * - lzma_block_buffer_encode() - */ - uint32_t header_size; -# define LZMA_BLOCK_HEADER_SIZE_MIN 8 -# define LZMA_BLOCK_HEADER_SIZE_MAX 1024 - - /** - * \brief Type of integrity Check - * - * The Check ID is not stored into the Block Header, thus its value - * must be provided also when decoding. - * - * Read by: - * - lzma_block_header_encode() - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_check check; - - /** - * \brief Size of the Compressed Data in bytes - * - * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder - * will store this value to the Block Header. Block encoder doesn't - * care about this value, but will set it once the encoding has been - * finished. - * - * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will - * verify that the size of the Compressed Data field matches - * compressed_size. - * - * Usually you don't know this value when encoding in streamed mode, - * and thus cannot write this field into the Block Header. - * - * In non-streamed mode you can reserve space for this field before - * encoding the actual Block. After encoding the data, finish the - * Block by encoding the Block Header. Steps in detail: - * - * - Set compressed_size to some big enough value. If you don't know - * better, use LZMA_VLI_MAX, but remember that bigger values take - * more space in Block Header. - * - * - Call lzma_block_header_size() to see how much space you need to - * reserve for the Block Header. - * - * - Encode the Block using lzma_block_encoder() and lzma_code(). - * It sets compressed_size to the correct value. - * - * - Use lzma_block_header_encode() to encode the Block Header. - * Because space was reserved in the first step, you don't need - * to call lzma_block_header_size() anymore, because due to - * reserving, header_size has to be big enough. If it is "too big", - * lzma_block_header_encode() will add enough Header Padding to - * make Block Header to match the size specified by header_size. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_compressed_size() - * - lzma_block_unpadded_size() - * - lzma_block_total_size() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode() - * - lzma_block_compressed_size() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_vli compressed_size; - - /** - * \brief Uncompressed Size in bytes - * - * This is handled very similarly to compressed_size above. - * - * uncompressed_size is needed by fewer functions than - * compressed_size. This is because uncompressed_size isn't - * needed to validate that Block stays within proper limits. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - lzma_vli uncompressed_size; - - /** - * \brief Array of filters - * - * There can be 1-4 filters. The end of the array is marked with - * .id = LZMA_VLI_UNKNOWN. - * - * Read by: - * - lzma_block_header_size() - * - lzma_block_header_encode() - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - * - * Written by: - * - lzma_block_header_decode(): Note that this does NOT free() - * the old filter options structures. All unused filters[] will - * have .id == LZMA_VLI_UNKNOWN and .options == NULL. If - * decoding fails, all filters[] are guaranteed to be - * LZMA_VLI_UNKNOWN and NULL. - * - * \note Because of the array is terminated with - * .id = LZMA_VLI_UNKNOWN, the actual array must - * have LZMA_FILTERS_MAX + 1 members or the Block - * Header decoder will overflow the buffer. - */ - lzma_filter *filters; - - /** - * \brief Raw value stored in the Check field - * - * After successful coding, the first lzma_check_size(check) bytes - * of this array contain the raw value stored in the Check field. - * - * Note that CRC32 and CRC64 are stored in little endian byte order. - * Take it into account if you display the Check values to the user. - * - * Written by: - * - lzma_block_encoder() - * - lzma_block_decoder() - * - lzma_block_buffer_encode() - * - lzma_block_buffer_decode() - */ - uint8_t raw_check[LZMA_CHECK_SIZE_MAX]; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * with the currently supported options, so it is safe to leave these - * uninitialized. - */ - void *reserved_ptr1; - void *reserved_ptr2; - void *reserved_ptr3; - uint32_t reserved_int1; - uint32_t reserved_int2; - lzma_vli reserved_int3; - lzma_vli reserved_int4; - lzma_vli reserved_int5; - lzma_vli reserved_int6; - lzma_vli reserved_int7; - lzma_vli reserved_int8; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - - /** - * \brief A flag to Block decoder to not verify the Check field - * - * This field is supported by liblzma >= 5.1.4beta if .version >= 1. - * - * If this is set to true, the integrity check won't be calculated - * and verified. Unless you know what you are doing, you should - * leave this to false. (A reason to set this to true is when the - * file integrity is verified externally anyway and you want to - * speed up the decompression, which matters mostly when using - * SHA-256 as the integrity check.) - * - * If .version >= 1, read by: - * - lzma_block_decoder() - * - lzma_block_buffer_decode() - * - * Written by (.version is ignored): - * - lzma_block_header_decode() always sets this to false - */ - lzma_bool ignore_check; - - lzma_bool reserved_bool2; - lzma_bool reserved_bool3; - lzma_bool reserved_bool4; - lzma_bool reserved_bool5; - lzma_bool reserved_bool6; - lzma_bool reserved_bool7; - lzma_bool reserved_bool8; - -} lzma_block; - - -/** - * \brief Decode the Block Header Size field - * - * To decode Block Header using lzma_block_header_decode(), the size of the - * Block Header has to be known and stored into lzma_block.header_size. - * The size can be calculated from the first byte of a Block using this macro. - * Note that if the first byte is 0x00, it indicates beginning of Index; use - * this macro only when the byte is not 0x00. - * - * There is no encoding macro, because Block Header encoder is enough for that. - */ -#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4) - - -/** - * \brief Calculate Block Header Size - * - * Calculate the minimum size needed for the Block Header field using the - * settings specified in the lzma_block structure. Note that it is OK to - * increase the calculated header_size value as long as it is a multiple of - * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size - * just means that lzma_block_header_encode() will add Header Padding. - * - * \return - LZMA_OK: Size calculated successfully and stored to - * block->header_size. - * - LZMA_OPTIONS_ERROR: Unsupported version, filters or - * filter options. - * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0. - * - * \note This doesn't check that all the options are valid i.e. this - * may return LZMA_OK even if lzma_block_header_encode() or - * lzma_block_encoder() would fail. If you want to validate the - * filter chain, consider using lzma_memlimit_encoder() which as - * a side-effect validates the filter chain. - */ -extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Block Header - * - * The caller must have calculated the size of the Block Header already with - * lzma_block_header_size(). If a value larger than the one calculated by - * lzma_block_header_size() is used, the Block Header will be padded to the - * specified size. - * - * \param out Beginning of the output buffer. This must be - * at least block->header_size bytes. - * \param block Block options to be encoded. - * - * \return - LZMA_OK: Encoding was successful. block->header_size - * bytes were written to output buffer. - * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. - * - LZMA_PROG_ERROR: Invalid arguments, for example - * block->header_size is invalid or block->filters is NULL. - */ -extern LZMA_API(lzma_ret) lzma_block_header_encode( - const lzma_block *block, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Block Header - * - * block->version should (usually) be set to the highest value supported - * by the application. If the application sets block->version to a value - * higher than supported by the current liblzma version, this function will - * downgrade block->version to the highest value supported by it. Thus one - * should check the value of block->version after calling this function if - * block->version was set to a non-zero value and the application doesn't - * otherwise know that the liblzma version being used is new enough to - * support the specified block->version. - * - * The size of the Block Header must have already been decoded with - * lzma_block_header_size_decode() macro and stored to block->header_size. - * - * The integrity check type from Stream Header must have been stored - * to block->check. - * - * block->filters must have been allocated, but they don't need to be - * initialized (possible existing filter options are not freed). - * - * \param block Destination for Block options. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() (and also free() - * if an error occurs). - * \param in Beginning of the input buffer. This must be - * at least block->header_size bytes. - * - * \return - LZMA_OK: Decoding was successful. block->header_size - * bytes were read from the input buffer. - * - LZMA_OPTIONS_ERROR: The Block Header specifies some - * unsupported options such as unsupported filters. This can - * happen also if block->version was set to a too low value - * compared to what would be required to properly represent - * the information stored in the Block Header. - * - LZMA_DATA_ERROR: Block Header is corrupt, for example, - * the CRC32 doesn't match. - * - LZMA_PROG_ERROR: Invalid arguments, for example - * block->header_size is invalid or block->filters is NULL. - */ -extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block, - const lzma_allocator *allocator, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Validate and set Compressed Size according to Unpadded Size - * - * Block Header stores Compressed Size, but Index has Unpadded Size. If the - * application has already parsed the Index and is now decoding Blocks, - * it can calculate Compressed Size from Unpadded Size. This function does - * exactly that with error checking: - * - * - Compressed Size calculated from Unpadded Size must be positive integer, - * that is, Unpadded Size must be big enough that after Block Header and - * Check fields there's still at least one byte for Compressed Size. - * - * - If Compressed Size was present in Block Header, the new value - * calculated from Unpadded Size is compared against the value - * from Block Header. - * - * \note This function must be called _after_ decoding the Block Header - * field so that it can properly validate Compressed Size if it - * was present in Block Header. - * - * \return - LZMA_OK: block->compressed_size was set successfully. - * - LZMA_DATA_ERROR: unpadded_size is too small compared to - * block->header_size and lzma_check_size(block->check). - * - LZMA_PROG_ERROR: Some values are invalid. For example, - * block->header_size must be a multiple of four and - * between 8 and 1024 inclusive. - */ -extern LZMA_API(lzma_ret) lzma_block_compressed_size( - lzma_block *block, lzma_vli unpadded_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate Unpadded Size - * - * The Index field stores Unpadded Size and Uncompressed Size. The latter - * can be taken directly from the lzma_block structure after coding a Block, - * but Unpadded Size needs to be calculated from Block Header Size, - * Compressed Size, and size of the Check field. This is where this function - * is needed. - * - * \return Unpadded Size on success, or zero on error. - */ -extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate the total encoded size of a Block - * - * This is equivalent to lzma_block_unpadded_size() except that the returned - * value includes the size of the Block Padding field. - * - * \return On success, total encoded size of the Block. On error, - * zero is returned. - */ -extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize .xz Block encoder - * - * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the - * filter chain supports it), and LZMA_FINISH. - * - * \return - LZMA_OK: All good, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID - * that is not supported by this buid of liblzma. Initializing - * the encoder failed. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_encoder( - lzma_stream *strm, lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Block decoder - * - * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using - * LZMA_FINISH is not required. It is supported only for convenience. - * - * \return - LZMA_OK: All good, continue with lzma_code(). - * - LZMA_UNSUPPORTED_CHECK: Initialization was successful, but - * the given Check ID is not supported, thus Check will be - * ignored. - * - LZMA_PROG_ERROR - * - LZMA_MEM_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_decoder( - lzma_stream *strm, lzma_block *block) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate maximum output size for single-call Block encoding - * - * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks. - * See the documentation of lzma_stream_buffer_bound(). - */ -extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size) - lzma_nothrow; - - -/** - * \brief Single-call .xz Block encoder - * - * In contrast to the multi-call encoder initialized with - * lzma_block_encoder(), this function encodes also the Block Header. This - * is required to make it possible to write appropriate Block Header also - * in case the data isn't compressible, and different filter chain has to be - * used to encode the data in uncompressed form using uncompressed chunks - * of the LZMA2 filter. - * - * When the data isn't compressible, header_size, compressed_size, and - * uncompressed_size are set just like when the data was compressible, but - * it is possible that header_size is too small to hold the filter chain - * specified in block->filters, because that isn't necessarily the filter - * chain that was actually used to encode the data. lzma_block_unpadded_size() - * still works normally, because it doesn't read the filters array. - * - * \param block Block options: block->version, block->check, - * and block->filters must have been initialized. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_buffer_encode( - lzma_block *block, const lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call uncompressed .xz Block encoder - * - * This is like lzma_block_buffer_encode() except this doesn't try to - * compress the data and instead encodes the data using LZMA2 uncompressed - * chunks. The required output buffer size can be determined with - * lzma_block_buffer_bound(). - * - * Since the data won't be compressed, this function ignores block->filters. - * This function doesn't take lzma_allocator because this function doesn't - * allocate any memory from the heap. - */ -extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Block decoder - * - * This is single-call equivalent of lzma_block_decoder(), and requires that - * the caller has already decoded Block Header and checked its memory usage. - * - * \param block Block options just like with lzma_block_decoder(). - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_OPTIONS_ERROR - * - LZMA_DATA_ERROR - * - LZMA_MEM_ERROR - * - LZMA_BUF_ERROR: Output buffer was too small. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_block_buffer_decode( - lzma_block *block, const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow; diff --git a/maclibs/include/lzma/check.h b/maclibs/include/lzma/check.h deleted file mode 100644 index 6a243db0..00000000 --- a/maclibs/include/lzma/check.h +++ /dev/null @@ -1,150 +0,0 @@ -/** - * \file lzma/check.h - * \brief Integrity checks - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Type of the integrity check (Check ID) - * - * The .xz format supports multiple types of checks that are calculated - * from the uncompressed data. They vary in both speed and ability to - * detect errors. - */ -typedef enum { - LZMA_CHECK_NONE = 0, - /**< - * No Check is calculated. - * - * Size of the Check field: 0 bytes - */ - - LZMA_CHECK_CRC32 = 1, - /**< - * CRC32 using the polynomial from the IEEE 802.3 standard - * - * Size of the Check field: 4 bytes - */ - - LZMA_CHECK_CRC64 = 4, - /**< - * CRC64 using the polynomial from the ECMA-182 standard - * - * Size of the Check field: 8 bytes - */ - - LZMA_CHECK_SHA256 = 10 - /**< - * SHA-256 - * - * Size of the Check field: 32 bytes - */ -} lzma_check; - - -/** - * \brief Maximum valid Check ID - * - * The .xz file format specification specifies 16 Check IDs (0-15). Some - * of them are only reserved, that is, no actual Check algorithm has been - * assigned. When decoding, liblzma still accepts unknown Check IDs for - * future compatibility. If a valid but unsupported Check ID is detected, - * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK, - * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h. - */ -#define LZMA_CHECK_ID_MAX 15 - - -/** - * \brief Test if the given Check ID is supported - * - * Return true if the given Check ID is supported by this liblzma build. - * Otherwise false is returned. It is safe to call this with a value that - * is not in the range [0, 15]; in that case the return value is always false. - * - * You can assume that LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always - * supported (even if liblzma is built with limited features). - */ -extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Get the size of the Check field with the given Check ID - * - * Although not all Check IDs have a check algorithm associated, the size of - * every Check is already frozen. This function returns the size (in bytes) of - * the Check field with the specified Check ID. The values are: - * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 } - * - * If the argument is not in the range [0, 15], UINT32_MAX is returned. - */ -extern LZMA_API(uint32_t) lzma_check_size(lzma_check check) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Maximum size of a Check field - */ -#define LZMA_CHECK_SIZE_MAX 64 - - -/** - * \brief Calculate CRC32 - * - * Calculate CRC32 using the polynomial from the IEEE 802.3 standard. - * - * \param buf Pointer to the input buffer - * \param size Size of the input buffer - * \param crc Previously returned CRC value. This is used to - * calculate the CRC of a big buffer in smaller chunks. - * Set to zero when starting a new calculation. - * - * \return Updated CRC value, which can be passed to this function - * again to continue CRC calculation. - */ -extern LZMA_API(uint32_t) lzma_crc32( - const uint8_t *buf, size_t size, uint32_t crc) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate CRC64 - * - * Calculate CRC64 using the polynomial from the ECMA-182 standard. - * - * This function is used similarly to lzma_crc32(). See its documentation. - */ -extern LZMA_API(uint64_t) lzma_crc64( - const uint8_t *buf, size_t size, uint64_t crc) - lzma_nothrow lzma_attr_pure; - - -/* - * SHA-256 functions are currently not exported to public API. - * Contact Lasse Collin if you think it should be. - */ - - -/** - * \brief Get the type of the integrity check - * - * This function can be called only immediately after lzma_code() has - * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK. - * Calling this function in any other situation has undefined behavior. - */ -extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm) - lzma_nothrow; diff --git a/maclibs/include/lzma/container.h b/maclibs/include/lzma/container.h deleted file mode 100644 index 86991add..00000000 --- a/maclibs/include/lzma/container.h +++ /dev/null @@ -1,619 +0,0 @@ -/** - * \file lzma/container.h - * \brief File formats - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/************ - * Encoding * - ************/ - -/** - * \brief Default compression preset - * - * It's not straightforward to recommend a default preset, because in some - * cases keeping the resource usage relatively low is more important that - * getting the maximum compression ratio. - */ -#define LZMA_PRESET_DEFAULT UINT32_C(6) - - -/** - * \brief Mask for preset level - * - * This is useful only if you need to extract the level from the preset - * variable. That should be rare. - */ -#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F) - - -/* - * Preset flags - * - * Currently only one flag is defined. - */ - -/** - * \brief Extreme compression preset - * - * This flag modifies the preset to make the encoding significantly slower - * while improving the compression ratio only marginally. This is useful - * when you don't mind wasting time to get as small result as possible. - * - * This flag doesn't affect the memory usage requirements of the decoder (at - * least not significantly). The memory usage of the encoder may be increased - * a little but only at the lowest preset levels (0-3). - */ -#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31) - - -/** - * \brief Multithreading options - */ -typedef struct { - /** - * \brief Flags - * - * Set this to zero if no flags are wanted. - * - * No flags are currently supported. - */ - uint32_t flags; - - /** - * \brief Number of worker threads to use - */ - uint32_t threads; - - /** - * \brief Maximum uncompressed size of a Block - * - * The encoder will start a new .xz Block every block_size bytes. - * Using LZMA_FULL_FLUSH or LZMA_FULL_BARRIER with lzma_code() - * the caller may tell liblzma to start a new Block earlier. - * - * With LZMA2, a recommended block size is 2-4 times the LZMA2 - * dictionary size. With very small dictionaries, it is recommended - * to use at least 1 MiB block size for good compression ratio, even - * if this is more than four times the dictionary size. Note that - * these are only recommendations for typical use cases; feel free - * to use other values. Just keep in mind that using a block size - * less than the LZMA2 dictionary size is waste of RAM. - * - * Set this to 0 to let liblzma choose the block size depending - * on the compression options. For LZMA2 it will be 3*dict_size - * or 1 MiB, whichever is more. - * - * For each thread, about 3 * block_size bytes of memory will be - * allocated. This may change in later liblzma versions. If so, - * the memory usage will probably be reduced, not increased. - */ - uint64_t block_size; - - /** - * \brief Timeout to allow lzma_code() to return early - * - * Multithreading can make liblzma to consume input and produce - * output in a very bursty way: it may first read a lot of input - * to fill internal buffers, then no input or output occurs for - * a while. - * - * In single-threaded mode, lzma_code() won't return until it has - * either consumed all the input or filled the output buffer. If - * this is done in multithreaded mode, it may cause a call - * lzma_code() to take even tens of seconds, which isn't acceptable - * in all applications. - * - * To avoid very long blocking times in lzma_code(), a timeout - * (in milliseconds) may be set here. If lzma_code() would block - * longer than this number of milliseconds, it will return with - * LZMA_OK. Reasonable values are 100 ms or more. The xz command - * line tool uses 300 ms. - * - * If long blocking times are fine for you, set timeout to a special - * value of 0, which will disable the timeout mechanism and will make - * lzma_code() block until all the input is consumed or the output - * buffer has been filled. - * - * \note Even with a timeout, lzma_code() might sometimes take - * somewhat long time to return. No timing guarantees - * are made. - */ - uint32_t timeout; - - /** - * \brief Compression preset (level and possible flags) - * - * The preset is set just like with lzma_easy_encoder(). - * The preset is ignored if filters below is non-NULL. - */ - uint32_t preset; - - /** - * \brief Filter chain (alternative to a preset) - * - * If this is NULL, the preset above is used. Otherwise the preset - * is ignored and the filter chain specified here is used. - */ - const lzma_filter *filters; - - /** - * \brief Integrity check type - * - * See check.h for available checks. The xz command line tool - * defaults to LZMA_CHECK_CRC64, which is a good choice if you - * are unsure. - */ - lzma_check check; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * with the currently supported options, so it is safe to leave these - * uninitialized. - */ - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - uint32_t reserved_int1; - uint32_t reserved_int2; - uint32_t reserved_int3; - uint32_t reserved_int4; - uint64_t reserved_int5; - uint64_t reserved_int6; - uint64_t reserved_int7; - uint64_t reserved_int8; - void *reserved_ptr1; - void *reserved_ptr2; - void *reserved_ptr3; - void *reserved_ptr4; - -} lzma_mt; - - -/** - * \brief Calculate approximate memory usage of easy encoder - * - * This function is a wrapper for lzma_raw_encoder_memusage(). - * - * \param preset Compression preset (level and possible flags) - * - * \return Number of bytes of memory required for the given - * preset when encoding. If an error occurs, for example - * due to unsupported preset, UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate approximate decoder memory usage of a preset - * - * This function is a wrapper for lzma_raw_decoder_memusage(). - * - * \param preset Compression preset (level and possible flags) - * - * \return Number of bytes of memory required to decompress a file - * that was compressed using the given preset. If an error - * occurs, for example due to unsupported preset, UINT64_MAX - * is returned. - */ -extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize .xz Stream encoder using a preset number - * - * This function is intended for those who just want to use the basic features - * if liblzma (that is, most developers out there). - * - * \param strm Pointer to lzma_stream that is at least initialized - * with LZMA_STREAM_INIT. - * \param preset Compression preset to use. A preset consist of level - * number and zero or more flags. Usually flags aren't - * used, so preset is simply a number [0, 9] which match - * the options -0 ... -9 of the xz command line tool. - * Additional flags can be be set using bitwise-or with - * the preset level number, e.g. 6 | LZMA_PRESET_EXTREME. - * \param check Integrity check type to use. See check.h for available - * checks. The xz command line tool defaults to - * LZMA_CHECK_CRC64, which is a good choice if you are - * unsure. LZMA_CHECK_CRC32 is good too as long as the - * uncompressed file is not many gigabytes. - * - * \return - LZMA_OK: Initialization succeeded. Use lzma_code() to - * encode your data. - * - LZMA_MEM_ERROR: Memory allocation failed. - * - LZMA_OPTIONS_ERROR: The given compression preset is not - * supported by this build of liblzma. - * - LZMA_UNSUPPORTED_CHECK: The given check type is not - * supported by this liblzma build. - * - LZMA_PROG_ERROR: One or more of the parameters have values - * that will never be valid. For example, strm == NULL. - * - * If initialization fails (return value is not LZMA_OK), all the memory - * allocated for *strm by liblzma is always freed. Thus, there is no need - * to call lzma_end() after failed initialization. - * - * If initialization succeeds, use lzma_code() to do the actual encoding. - * Valid values for `action' (the second argument of lzma_code()) are - * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future, - * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH. - */ -extern LZMA_API(lzma_ret) lzma_easy_encoder( - lzma_stream *strm, uint32_t preset, lzma_check check) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Stream encoding using a preset number - * - * The maximum required output buffer size can be calculated with - * lzma_stream_buffer_bound(). - * - * \param preset Compression preset to use. See the description - * in lzma_easy_encoder(). - * \param check Type of the integrity check to calculate from - * uncompressed data. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_easy_buffer_encode( - uint32_t preset, lzma_check check, - const lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Initialize .xz Stream encoder using a custom filter chain - * - * \param strm Pointer to properly prepared lzma_stream - * \param filters Array of filters. This must be terminated with - * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h for - * more information. - * \param check Type of the integrity check to calculate from - * uncompressed data. - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm, - const lzma_filter *filters, lzma_check check) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate approximate memory usage of multithreaded .xz encoder - * - * Since doing the encoding in threaded mode doesn't affect the memory - * requirements of single-threaded decompressor, you can use - * lzma_easy_decoder_memusage(options->preset) or - * lzma_raw_decoder_memusage(options->filters) to calculate - * the decompressor memory requirements. - * - * \param options Compression options - * - * \return Number of bytes of memory required for encoding with the - * given options. If an error occurs, for example due to - * unsupported preset or filter chain, UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_stream_encoder_mt_memusage( - const lzma_mt *options) lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize multithreaded .xz Stream encoder - * - * This provides the functionality of lzma_easy_encoder() and - * lzma_stream_encoder() as a single function for multithreaded use. - * - * The supported actions for lzma_code() are LZMA_RUN, LZMA_FULL_FLUSH, - * LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be - * added in the future. - * - * \param strm Pointer to properly prepared lzma_stream - * \param options Pointer to multithreaded compression options - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_encoder_mt( - lzma_stream *strm, const lzma_mt *options) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .lzma encoder (legacy file format) - * - * The .lzma format is sometimes called the LZMA_Alone format, which is the - * reason for the name of this function. The .lzma format supports only the - * LZMA1 filter. There is no support for integrity checks like CRC32. - * - * Use this function if and only if you need to create files readable by - * legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format - * is strongly recommended. - * - * The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH. - * No kind of flushing is supported, because the file format doesn't make - * it possible. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_alone_encoder( - lzma_stream *strm, const lzma_options_lzma *options) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Calculate output buffer size for single-call Stream encoder - * - * When trying to compress uncompressible data, the encoded size will be - * slightly bigger than the input data. This function calculates how much - * output buffer space is required to be sure that lzma_stream_buffer_encode() - * doesn't return LZMA_BUF_ERROR. - * - * The calculated value is not exact, but it is guaranteed to be big enough. - * The actual maximum output space required may be slightly smaller (up to - * about 100 bytes). This should not be a problem in practice. - * - * If the calculated maximum size doesn't fit into size_t or would make the - * Stream grow past LZMA_VLI_MAX (which should never happen in practice), - * zero is returned to indicate the error. - * - * \note The limit calculated by this function applies only to - * single-call encoding. Multi-call encoding may (and probably - * will) have larger maximum expansion when encoding - * uncompressible data. Currently there is no function to - * calculate the maximum expansion of multi-call encoding. - */ -extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size) - lzma_nothrow; - - -/** - * \brief Single-call .xz Stream encoder - * - * \param filters Array of filters. This must be terminated with - * filters[n].id = LZMA_VLI_UNKNOWN. See filter.h - * for more information. - * \param check Type of the integrity check to calculate from - * uncompressed data. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_UNSUPPORTED_CHECK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_buffer_encode( - lzma_filter *filters, lzma_check check, - const lzma_allocator *allocator, - const uint8_t *in, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/************ - * Decoding * - ************/ - -/** - * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream - * being decoded has no integrity check. Note that when used with - * lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK - * if LZMA_TELL_NO_CHECK is used. - */ -#define LZMA_TELL_NO_CHECK UINT32_C(0x01) - - -/** - * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input - * stream has an integrity check, but the type of the integrity check is not - * supported by this liblzma version or build. Such files can still be - * decoded, but the integrity check cannot be verified. - */ -#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02) - - -/** - * This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type - * of the integrity check is known. The type can then be got with - * lzma_get_check(). - */ -#define LZMA_TELL_ANY_CHECK UINT32_C(0x04) - - -/** - * This flag makes lzma_code() not calculate and verify the integrity check - * of the compressed data in .xz files. This means that invalid integrity - * check values won't be detected and LZMA_DATA_ERROR won't be returned in - * such cases. - * - * This flag only affects the checks of the compressed data itself; the CRC32 - * values in the .xz headers will still be verified normally. - * - * Don't use this flag unless you know what you are doing. Possible reasons - * to use this flag: - * - * - Trying to recover data from a corrupt .xz file. - * - * - Speeding up decompression, which matters mostly with SHA-256 - * or with files that have compressed extremely well. It's recommended - * to not use this flag for this purpose unless the file integrity is - * verified externally in some other way. - * - * Support for this flag was added in liblzma 5.1.4beta. - */ -#define LZMA_IGNORE_CHECK UINT32_C(0x10) - - -/** - * This flag enables decoding of concatenated files with file formats that - * allow concatenating compressed files as is. From the formats currently - * supported by liblzma, only the .xz format allows concatenated files. - * Concatenated files are not allowed with the legacy .lzma format. - * - * This flag also affects the usage of the `action' argument for lzma_code(). - * When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END - * unless LZMA_FINISH is used as `action'. Thus, the application has to set - * LZMA_FINISH in the same way as it does when encoding. - * - * If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH - * as `action' for lzma_code(), but the usage of LZMA_FINISH isn't required. - */ -#define LZMA_CONCATENATED UINT32_C(0x08) - - -/** - * \brief Initialize .xz Stream decoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. - * \param flags Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_TELL_ANY_CHECK, LZMA_CONCATENATED - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR: Cannot allocate memory. - * - LZMA_OPTIONS_ERROR: Unsupported flags - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_decoder( - lzma_stream *strm, uint64_t memlimit, uint32_t flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode .xz Streams and .lzma files with autodetection - * - * This decoder autodetects between the .xz and .lzma file formats, and - * calls lzma_stream_decoder() or lzma_alone_decoder() once the type - * of the input file has been detected. - * - * \param strm Pointer to properly prepared lzma_stream - * \param memlimit Memory usage limit as bytes. Use UINT64_MAX - * to effectively disable the limiter. - * \param flags Bitwise-or of flags, or zero for no flags. - * - * \return - LZMA_OK: Initialization was successful. - * - LZMA_MEM_ERROR: Cannot allocate memory. - * - LZMA_OPTIONS_ERROR: Unsupported flags - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_auto_decoder( - lzma_stream *strm, uint64_t memlimit, uint32_t flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .lzma decoder (legacy file format) - * - * Valid `action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH. - * There is no need to use LZMA_FINISH, but allowing it may simplify - * certain types of applications. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_alone_decoder( - lzma_stream *strm, uint64_t memlimit) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Stream decoder - * - * \param memlimit Pointer to how much memory the decoder is allowed - * to allocate. The value pointed by this pointer is - * modified if and only if LZMA_MEMLIMIT_ERROR is - * returned. - * \param flags Bitwise-or of zero or more of the decoder flags: - * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK, - * LZMA_CONCATENATED. Note that LZMA_TELL_ANY_CHECK - * is not allowed and will return LZMA_PROG_ERROR. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if decoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_DATA_ERROR - * - LZMA_NO_CHECK: This can be returned only if using - * the LZMA_TELL_NO_CHECK flag. - * - LZMA_UNSUPPORTED_CHECK: This can be returned only if using - * the LZMA_TELL_UNSUPPORTED_CHECK flag. - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. - * The minimum required memlimit value was stored to *memlimit. - * - LZMA_BUF_ERROR: Output buffer was too small. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_stream_buffer_decode( - uint64_t *memlimit, uint32_t flags, - const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; diff --git a/maclibs/include/lzma/delta.h b/maclibs/include/lzma/delta.h deleted file mode 100644 index 592fc4f8..00000000 --- a/maclibs/include/lzma/delta.h +++ /dev/null @@ -1,77 +0,0 @@ -/** - * \file lzma/delta.h - * \brief Delta filter - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Filter ID - * - * Filter ID of the Delta filter. This is used as lzma_filter.id. - */ -#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03) - - -/** - * \brief Type of the delta calculation - * - * Currently only byte-wise delta is supported. Other possible types could - * be, for example, delta of 16/32/64-bit little/big endian integers, but - * these are not currently planned since byte-wise delta is almost as good. - */ -typedef enum { - LZMA_DELTA_TYPE_BYTE -} lzma_delta_type; - - -/** - * \brief Options for the Delta filter - * - * These options are needed by both encoder and decoder. - */ -typedef struct { - /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */ - lzma_delta_type type; - - /** - * \brief Delta distance - * - * With the only currently supported type, LZMA_DELTA_TYPE_BYTE, - * the distance is as bytes. - * - * Examples: - * - 16-bit stereo audio: distance = 4 bytes - * - 24-bit RGB image data: distance = 3 bytes - */ - uint32_t dist; -# define LZMA_DELTA_DIST_MIN 1 -# define LZMA_DELTA_DIST_MAX 256 - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these - * uninitialized. - */ - uint32_t reserved_int1; - uint32_t reserved_int2; - uint32_t reserved_int3; - uint32_t reserved_int4; - void *reserved_ptr1; - void *reserved_ptr2; - -} lzma_options_delta; diff --git a/maclibs/include/lzma/filter.h b/maclibs/include/lzma/filter.h deleted file mode 100644 index 4e78752b..00000000 --- a/maclibs/include/lzma/filter.h +++ /dev/null @@ -1,425 +0,0 @@ -/** - * \file lzma/filter.h - * \brief Common filter related types and functions - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Maximum number of filters in a chain - * - * A filter chain can have 1-4 filters, of which three are allowed to change - * the size of the data. Usually only one or two filters are needed. - */ -#define LZMA_FILTERS_MAX 4 - - -/** - * \brief Filter options - * - * This structure is used to pass Filter ID and a pointer filter's - * options to liblzma. A few functions work with a single lzma_filter - * structure, while most functions expect a filter chain. - * - * A filter chain is indicated with an array of lzma_filter structures. - * The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter - * array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to - * be able to hold any arbitrary filter chain. This is important when - * using lzma_block_header_decode() from block.h, because too small - * array would make liblzma write past the end of the filters array. - */ -typedef struct { - /** - * \brief Filter ID - * - * Use constants whose name begin with `LZMA_FILTER_' to specify - * different filters. In an array of lzma_filter structures, use - * LZMA_VLI_UNKNOWN to indicate end of filters. - * - * \note This is not an enum, because on some systems enums - * cannot be 64-bit. - */ - lzma_vli id; - - /** - * \brief Pointer to filter-specific options structure - * - * If the filter doesn't need options, set this to NULL. If id is - * set to LZMA_VLI_UNKNOWN, options is ignored, and thus - * doesn't need be initialized. - */ - void *options; - -} lzma_filter; - - -/** - * \brief Test if the given Filter ID is supported for encoding - * - * Return true if the give Filter ID is supported for encoding by this - * liblzma build. Otherwise false is returned. - * - * There is no way to list which filters are available in this particular - * liblzma version and build. It would be useless, because the application - * couldn't know what kind of options the filter would need. - */ -extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Test if the given Filter ID is supported for decoding - * - * Return true if the give Filter ID is supported for decoding by this - * liblzma build. Otherwise false is returned. - */ -extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Copy the filters array - * - * Copy the Filter IDs and filter-specific options from src to dest. - * Up to LZMA_FILTERS_MAX filters are copied, plus the terminating - * .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least - * LZMA_FILTERS_MAX + 1 elements space unless the caller knows that - * src is smaller than that. - * - * Unless the filter-specific options is NULL, the Filter ID has to be - * supported by liblzma, because liblzma needs to know the size of every - * filter-specific options structure. The filter-specific options are not - * validated. If options is NULL, any unsupported Filter IDs are copied - * without returning an error. - * - * Old filter-specific options in dest are not freed, so dest doesn't - * need to be initialized by the caller in any way. - * - * If an error occurs, memory possibly already allocated by this function - * is always freed. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options - * is not NULL. - * - LZMA_PROG_ERROR: src or dest is NULL. - */ -extern LZMA_API(lzma_ret) lzma_filters_copy( - const lzma_filter *src, lzma_filter *dest, - const lzma_allocator *allocator) lzma_nothrow; - - -/** - * \brief Calculate approximate memory requirements for raw encoder - * - * This function can be used to calculate the memory requirements for - * Block and Stream encoders too because Block and Stream encoders don't - * need significantly more memory than raw encoder. - * - * \param filters Array of filters terminated with - * .id == LZMA_VLI_UNKNOWN. - * - * \return Number of bytes of memory required for the given - * filter chain when encoding. If an error occurs, - * for example due to unsupported filter chain, - * UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Calculate approximate memory requirements for raw decoder - * - * This function can be used to calculate the memory requirements for - * Block and Stream decoders too because Block and Stream decoders don't - * need significantly more memory than raw decoder. - * - * \param filters Array of filters terminated with - * .id == LZMA_VLI_UNKNOWN. - * - * \return Number of bytes of memory required for the given - * filter chain when decoding. If an error occurs, - * for example due to unsupported filter chain, - * UINT64_MAX is returned. - */ -extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize raw encoder - * - * This function may be useful when implementing custom file formats. - * - * \param strm Pointer to properly prepared lzma_stream - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * - * The `action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the - * filter chain supports it), or LZMA_FINISH. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_raw_encoder( - lzma_stream *strm, const lzma_filter *filters) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize raw decoder - * - * The initialization of raw decoder goes similarly to raw encoder. - * - * The `action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using - * LZMA_FINISH is not required, it is supported just for convenience. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_raw_decoder( - lzma_stream *strm, const lzma_filter *filters) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Update the filter chain in the encoder - * - * This function is for advanced users only. This function has two slightly - * different purposes: - * - * - After LZMA_FULL_FLUSH when using Stream encoder: Set a new filter - * chain, which will be used starting from the next Block. - * - * - After LZMA_SYNC_FLUSH using Raw, Block, or Stream encoder: Change - * the filter-specific options in the middle of encoding. The actual - * filters in the chain (Filter IDs) cannot be changed. In the future, - * it might become possible to change the filter options without - * using LZMA_SYNC_FLUSH. - * - * While rarely useful, this function may be called also when no data has - * been compressed yet. In that case, this function will behave as if - * LZMA_FULL_FLUSH (Stream encoder) or LZMA_SYNC_FLUSH (Raw or Block - * encoder) had been used right before calling this function. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_filters_update( - lzma_stream *strm, const lzma_filter *filters) lzma_nothrow; - - -/** - * \brief Single-call raw encoder - * - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_size Size of the input buffer - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Not enough output buffer space. - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - * - * \note There is no function to calculate how big output buffer - * would surely be big enough. (lzma_stream_buffer_bound() - * works only for lzma_stream_buffer_encode(); raw encoder - * won't necessarily meet that bound.) - */ -extern LZMA_API(lzma_ret) lzma_raw_buffer_encode( - const lzma_filter *filters, const lzma_allocator *allocator, - const uint8_t *in, size_t in_size, uint8_t *out, - size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Single-call raw decoder - * - * \param filters Array of lzma_filter structures. The end of the - * array must be marked with .id = LZMA_VLI_UNKNOWN. - * \param allocator lzma_allocator for custom allocator functions. - * Set to NULL to use malloc() and free(). - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - */ -extern LZMA_API(lzma_ret) lzma_raw_buffer_decode( - const lzma_filter *filters, const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Get the size of the Filter Properties field - * - * This function may be useful when implementing custom file formats - * using the raw encoder and decoder. - * - * \param size Pointer to uint32_t to hold the size of the properties - * \param filter Filter ID and options (the size of the properties may - * vary depending on the options) - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - * - * \note This function validates the Filter ID, but does not - * necessarily validate the options. Thus, it is possible - * that this returns LZMA_OK while the following call to - * lzma_properties_encode() returns LZMA_OPTIONS_ERROR. - */ -extern LZMA_API(lzma_ret) lzma_properties_size( - uint32_t *size, const lzma_filter *filter) lzma_nothrow; - - -/** - * \brief Encode the Filter Properties field - * - * \param filter Filter ID and options - * \param props Buffer to hold the encoded options. The size of - * buffer must have been already determined with - * lzma_properties_size(). - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_PROG_ERROR - * - * \note Even this function won't validate more options than actually - * necessary. Thus, it is possible that encoding the properties - * succeeds but using the same options to initialize the encoder - * will fail. - * - * \note If lzma_properties_size() indicated that the size - * of the Filter Properties field is zero, calling - * lzma_properties_encode() is not required, but it - * won't do any harm either. - */ -extern LZMA_API(lzma_ret) lzma_properties_encode( - const lzma_filter *filter, uint8_t *props) lzma_nothrow; - - -/** - * \brief Decode the Filter Properties field - * - * \param filter filter->id must have been set to the correct - * Filter ID. filter->options doesn't need to be - * initialized (it's not freed by this function). The - * decoded options will be stored to filter->options. - * filter->options is set to NULL if there are no - * properties or if an error occurs. - * \param allocator Custom memory allocator used to allocate the - * options. Set to NULL to use the default malloc(), - * and in case of an error, also free(). - * \param props Input buffer containing the properties. - * \param props_size Size of the properties. This must be the exact - * size; giving too much or too little input will - * return LZMA_OPTIONS_ERROR. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - */ -extern LZMA_API(lzma_ret) lzma_properties_decode( - lzma_filter *filter, const lzma_allocator *allocator, - const uint8_t *props, size_t props_size) lzma_nothrow; - - -/** - * \brief Calculate encoded size of a Filter Flags field - * - * Knowing the size of Filter Flags is useful to know when allocating - * memory to hold the encoded Filter Flags. - * - * \param size Pointer to integer to hold the calculated size - * \param filter Filter ID and associated options whose encoded - * size is to be calculated - * - * \return - LZMA_OK: *size set successfully. Note that this doesn't - * guarantee that filter->options is valid, thus - * lzma_filter_flags_encode() may still fail. - * - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options. - * - LZMA_PROG_ERROR: Invalid options - * - * \note If you need to calculate size of List of Filter Flags, - * you need to loop over every lzma_filter entry. - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_size( - uint32_t *size, const lzma_filter *filter) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Filter Flags into given buffer - * - * In contrast to some functions, this doesn't allocate the needed buffer. - * This is due to how this function is used internally by liblzma. - * - * \param filter Filter ID and options to be encoded - * \param out Beginning of the output buffer - * \param out_pos out[*out_pos] is the next write position. This - * is updated by the encoder. - * \param out_size out[out_size] is the first byte to not write. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: Invalid or unsupported options. - * - LZMA_PROG_ERROR: Invalid options or not enough output - * buffer space (you should have checked it with - * lzma_filter_flags_size()). - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter, - uint8_t *out, size_t *out_pos, size_t out_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Filter Flags from given buffer - * - * The decoded result is stored into *filter. The old value of - * filter->options is not free()d. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_filter_flags_decode( - lzma_filter *filter, const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow lzma_attr_warn_unused_result; diff --git a/maclibs/include/lzma/hardware.h b/maclibs/include/lzma/hardware.h deleted file mode 100644 index 5321d9af..00000000 --- a/maclibs/include/lzma/hardware.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - * \file lzma/hardware.h - * \brief Hardware information - * - * Since liblzma can consume a lot of system resources, it also provides - * ways to limit the resource usage. Applications linking against liblzma - * need to do the actual decisions how much resources to let liblzma to use. - * To ease making these decisions, liblzma provides functions to find out - * the relevant capabilities of the underlaying hardware. Currently there - * is only a function to find out the amount of RAM, but in the future there - * will be also a function to detect how many concurrent threads the system - * can run. - * - * \note On some operating systems, these function may temporarily - * load a shared library or open file descriptor(s) to find out - * the requested hardware information. Unless the application - * assumes that specific file descriptors are not touched by - * other threads, this should have no effect on thread safety. - * Possible operations involving file descriptors will restart - * the syscalls if they return EINTR. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Get the total amount of physical memory (RAM) in bytes - * - * This function may be useful when determining a reasonable memory - * usage limit for decompressing or how much memory it is OK to use - * for compressing. - * - * \return On success, the total amount of physical memory in bytes - * is returned. If the amount of RAM cannot be determined, - * zero is returned. This can happen if an error occurs - * or if there is no code in liblzma to detect the amount - * of RAM on the specific operating system. - */ -extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; - - -/** - * \brief Get the number of processor cores or threads - * - * This function may be useful when determining how many threads to use. - * If the hardware supports more than one thread per CPU core, the number - * of hardware threads is returned if that information is available. - * - * \brief On success, the number of available CPU threads or cores is - * returned. If this information isn't available or an error - * occurs, zero is returned. - */ -extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow; diff --git a/maclibs/include/lzma/index.h b/maclibs/include/lzma/index.h deleted file mode 100644 index dda60ec1..00000000 --- a/maclibs/include/lzma/index.h +++ /dev/null @@ -1,682 +0,0 @@ -/** - * \file lzma/index.h - * \brief Handling of .xz Index and related information - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Opaque data type to hold the Index(es) and other information - * - * lzma_index often holds just one .xz Index and possibly the Stream Flags - * of the same Stream and size of the Stream Padding field. However, - * multiple lzma_indexes can be concatenated with lzma_index_cat() and then - * there may be information about multiple Streams in the same lzma_index. - * - * Notes about thread safety: Only one thread may modify lzma_index at - * a time. All functions that take non-const pointer to lzma_index - * modify it. As long as no thread is modifying the lzma_index, getting - * information from the same lzma_index can be done from multiple threads - * at the same time with functions that take a const pointer to - * lzma_index or use lzma_index_iter. The same iterator must be used - * only by one thread at a time, of course, but there can be as many - * iterators for the same lzma_index as needed. - */ -typedef struct lzma_index_s lzma_index; - - -/** - * \brief Iterator to get information about Blocks and Streams - */ -typedef struct { - struct { - /** - * \brief Pointer to Stream Flags - * - * This is NULL if Stream Flags have not been set for - * this Stream with lzma_index_stream_flags(). - */ - const lzma_stream_flags *flags; - - const void *reserved_ptr1; - const void *reserved_ptr2; - const void *reserved_ptr3; - - /** - * \brief Stream number in the lzma_index - * - * The first Stream is 1. - */ - lzma_vli number; - - /** - * \brief Number of Blocks in the Stream - * - * If this is zero, the block structure below has - * undefined values. - */ - lzma_vli block_count; - - /** - * \brief Compressed start offset of this Stream - * - * The offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - */ - lzma_vli compressed_offset; - - /** - * \brief Uncompressed start offset of this Stream - * - * The offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - */ - lzma_vli uncompressed_offset; - - /** - * \brief Compressed size of this Stream - * - * This includes all headers except the possible - * Stream Padding after this Stream. - */ - lzma_vli compressed_size; - - /** - * \brief Uncompressed size of this Stream - */ - lzma_vli uncompressed_size; - - /** - * \brief Size of Stream Padding after this Stream - * - * If it hasn't been set with lzma_index_stream_padding(), - * this defaults to zero. Stream Padding is always - * a multiple of four bytes. - */ - lzma_vli padding; - - lzma_vli reserved_vli1; - lzma_vli reserved_vli2; - lzma_vli reserved_vli3; - lzma_vli reserved_vli4; - } stream; - - struct { - /** - * \brief Block number in the file - * - * The first Block is 1. - */ - lzma_vli number_in_file; - - /** - * \brief Compressed start offset of this Block - * - * This offset is relative to the beginning of the - * lzma_index (i.e. usually the beginning of the .xz file). - * Normally this is where you should seek in the .xz file - * to start decompressing this Block. - */ - lzma_vli compressed_file_offset; - - /** - * \brief Uncompressed start offset of this Block - * - * This offset is relative to the beginning of the lzma_index - * (i.e. usually the beginning of the .xz file). - * - * When doing random-access reading, it is possible that - * the target offset is not exactly at Block boundary. One - * will need to compare the target offset against - * uncompressed_file_offset or uncompressed_stream_offset, - * and possibly decode and throw away some amount of data - * before reaching the target offset. - */ - lzma_vli uncompressed_file_offset; - - /** - * \brief Block number in this Stream - * - * The first Block is 1. - */ - lzma_vli number_in_stream; - - /** - * \brief Compressed start offset of this Block - * - * This offset is relative to the beginning of the Stream - * containing this Block. - */ - lzma_vli compressed_stream_offset; - - /** - * \brief Uncompressed start offset of this Block - * - * This offset is relative to the beginning of the Stream - * containing this Block. - */ - lzma_vli uncompressed_stream_offset; - - /** - * \brief Uncompressed size of this Block - * - * You should pass this to the Block decoder if you will - * decode this Block. It will allow the Block decoder to - * validate the uncompressed size. - */ - lzma_vli uncompressed_size; - - /** - * \brief Unpadded size of this Block - * - * You should pass this to the Block decoder if you will - * decode this Block. It will allow the Block decoder to - * validate the unpadded size. - */ - lzma_vli unpadded_size; - - /** - * \brief Total compressed size - * - * This includes all headers and padding in this Block. - * This is useful if you need to know how many bytes - * the Block decoder will actually read. - */ - lzma_vli total_size; - - lzma_vli reserved_vli1; - lzma_vli reserved_vli2; - lzma_vli reserved_vli3; - lzma_vli reserved_vli4; - - const void *reserved_ptr1; - const void *reserved_ptr2; - const void *reserved_ptr3; - const void *reserved_ptr4; - } block; - - /* - * Internal data which is used to store the state of the iterator. - * The exact format may vary between liblzma versions, so don't - * touch these in any way. - */ - union { - const void *p; - size_t s; - lzma_vli v; - } internal[6]; -} lzma_index_iter; - - -/** - * \brief Operation mode for lzma_index_iter_next() - */ -typedef enum { - LZMA_INDEX_ITER_ANY = 0, - /**< - * \brief Get the next Block or Stream - * - * Go to the next Block if the current Stream has at least - * one Block left. Otherwise go to the next Stream even if - * it has no Blocks. If the Stream has no Blocks - * (lzma_index_iter.stream.block_count == 0), - * lzma_index_iter.block will have undefined values. - */ - - LZMA_INDEX_ITER_STREAM = 1, - /**< - * \brief Get the next Stream - * - * Go to the next Stream even if the current Stream has - * unread Blocks left. If the next Stream has at least one - * Block, the iterator will point to the first Block. - * If there are no Blocks, lzma_index_iter.block will have - * undefined values. - */ - - LZMA_INDEX_ITER_BLOCK = 2, - /**< - * \brief Get the next Block - * - * Go to the next Block if the current Stream has at least - * one Block left. If the current Stream has no Blocks left, - * the next Stream with at least one Block is located and - * the iterator will be made to point to the first Block of - * that Stream. - */ - - LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3 - /**< - * \brief Get the next non-empty Block - * - * This is like LZMA_INDEX_ITER_BLOCK except that it will - * skip Blocks whose Uncompressed Size is zero. - */ - -} lzma_index_iter_mode; - - -/** - * \brief Calculate memory usage of lzma_index - * - * On disk, the size of the Index field depends on both the number of Records - * stored and how big values the Records store (due to variable-length integer - * encoding). When the Index is kept in lzma_index structure, the memory usage - * depends only on the number of Records/Blocks stored in the Index(es), and - * in case of concatenated lzma_indexes, the number of Streams. The size in - * RAM is almost always significantly bigger than in the encoded form on disk. - * - * This function calculates an approximate amount of memory needed hold - * the given number of Streams and Blocks in lzma_index structure. This - * value may vary between CPU architectures and also between liblzma versions - * if the internal implementation is modified. - */ -extern LZMA_API(uint64_t) lzma_index_memusage( - lzma_vli streams, lzma_vli blocks) lzma_nothrow; - - -/** - * \brief Calculate the memory usage of an existing lzma_index - * - * This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i), - * lzma_index_block_count(i)). - */ -extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i) - lzma_nothrow; - - -/** - * \brief Allocate and initialize a new lzma_index structure - * - * \return On success, a pointer to an empty initialized lzma_index is - * returned. If allocation fails, NULL is returned. - */ -extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator) - lzma_nothrow; - - -/** - * \brief Deallocate lzma_index - * - * If i is NULL, this does nothing. - */ -extern LZMA_API(void) lzma_index_end( - lzma_index *i, const lzma_allocator *allocator) lzma_nothrow; - - -/** - * \brief Add a new Block to lzma_index - * - * \param i Pointer to a lzma_index structure - * \param allocator Pointer to lzma_allocator, or NULL to - * use malloc() - * \param unpadded_size Unpadded Size of a Block. This can be - * calculated with lzma_block_unpadded_size() - * after encoding or decoding the Block. - * \param uncompressed_size Uncompressed Size of a Block. This can be - * taken directly from lzma_block structure - * after encoding or decoding the Block. - * - * Appending a new Block does not invalidate iterators. For example, - * if an iterator was pointing to the end of the lzma_index, after - * lzma_index_append() it is possible to read the next Block with - * an existing iterator. - * - * \return - LZMA_OK - * - LZMA_MEM_ERROR - * - LZMA_DATA_ERROR: Compressed or uncompressed size of the - * Stream or size of the Index field would grow too big. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_append( - lzma_index *i, const lzma_allocator *allocator, - lzma_vli unpadded_size, lzma_vli uncompressed_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Set the Stream Flags - * - * Set the Stream Flags of the last (and typically the only) Stream - * in lzma_index. This can be useful when reading information from the - * lzma_index, because to decode Blocks, knowing the integrity check type - * is needed. - * - * The given Stream Flags are copied into internal preallocated structure - * in the lzma_index, thus the caller doesn't need to keep the *stream_flags - * available after calling this function. - * - * \return - LZMA_OK - * - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_stream_flags( - lzma_index *i, const lzma_stream_flags *stream_flags) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the types of integrity Checks - * - * If lzma_index_stream_flags() is used to set the Stream Flags for - * every Stream, lzma_index_checks() can be used to get a bitmask to - * indicate which Check types have been used. It can be useful e.g. if - * showing the Check types to the user. - * - * The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10. - */ -extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Set the amount of Stream Padding - * - * Set the amount of Stream Padding of the last (and typically the only) - * Stream in the lzma_index. This is needed when planning to do random-access - * reading within multiple concatenated Streams. - * - * By default, the amount of Stream Padding is assumed to be zero bytes. - * - * \return - LZMA_OK - * - LZMA_DATA_ERROR: The file size would grow too big. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_stream_padding( - lzma_index *i, lzma_vli stream_padding) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the number of Streams - */ -extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the number of Blocks - * - * This returns the total number of Blocks in lzma_index. To get number - * of Blocks in individual Streams, use lzma_index_iter. - */ -extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the size of the Index field as bytes - * - * This is needed to verify the Backward Size field in the Stream Footer. - */ -extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the Stream - * - * If multiple lzma_indexes have been combined, this works as if the Blocks - * were in a single Stream. This is useful if you are going to combine - * Blocks from multiple Streams into a single new Stream. - */ -extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the Blocks - * - * This doesn't include the Stream Header, Stream Footer, Stream Padding, - * or Index fields. - */ -extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the total size of the file - * - * When no lzma_indexes have been combined with lzma_index_cat() and there is - * no Stream Padding, this function is identical to lzma_index_stream_size(). - * If multiple lzma_indexes have been combined, this includes also the headers - * of each separate Stream and the possible Stream Padding fields. - */ -extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Get the uncompressed size of the file - */ -extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i) - lzma_nothrow lzma_attr_pure; - - -/** - * \brief Initialize an iterator - * - * \param iter Pointer to a lzma_index_iter structure - * \param i lzma_index to which the iterator will be associated - * - * This function associates the iterator with the given lzma_index, and calls - * lzma_index_iter_rewind() on the iterator. - * - * This function doesn't allocate any memory, thus there is no - * lzma_index_iter_end(). The iterator is valid as long as the - * associated lzma_index is valid, that is, until lzma_index_end() or - * using it as source in lzma_index_cat(). Specifically, lzma_index doesn't - * become invalid if new Blocks are added to it with lzma_index_append() or - * if it is used as the destination in lzma_index_cat(). - * - * It is safe to make copies of an initialized lzma_index_iter, for example, - * to easily restart reading at some particular position. - */ -extern LZMA_API(void) lzma_index_iter_init( - lzma_index_iter *iter, const lzma_index *i) lzma_nothrow; - - -/** - * \brief Rewind the iterator - * - * Rewind the iterator so that next call to lzma_index_iter_next() will - * return the first Block or Stream. - */ -extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter) - lzma_nothrow; - - -/** - * \brief Get the next Block or Stream - * - * \param iter Iterator initialized with lzma_index_iter_init() - * \param mode Specify what kind of information the caller wants - * to get. See lzma_index_iter_mode for details. - * - * \return If next Block or Stream matching the mode was found, *iter - * is updated and this function returns false. If no Block or - * Stream matching the mode is found, *iter is not modified - * and this function returns true. If mode is set to an unknown - * value, *iter is not modified and this function returns true. - */ -extern LZMA_API(lzma_bool) lzma_index_iter_next( - lzma_index_iter *iter, lzma_index_iter_mode mode) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Locate a Block - * - * If it is possible to seek in the .xz file, it is possible to parse - * the Index field(s) and use lzma_index_iter_locate() to do random-access - * reading with granularity of Block size. - * - * \param iter Iterator that was earlier initialized with - * lzma_index_iter_init(). - * \param target Uncompressed target offset which the caller would - * like to locate from the Stream - * - * If the target is smaller than the uncompressed size of the Stream (can be - * checked with lzma_index_uncompressed_size()): - * - Information about the Stream and Block containing the requested - * uncompressed offset is stored into *iter. - * - Internal state of the iterator is adjusted so that - * lzma_index_iter_next() can be used to read subsequent Blocks or Streams. - * - This function returns false. - * - * If target is greater than the uncompressed size of the Stream, *iter - * is not modified, and this function returns true. - */ -extern LZMA_API(lzma_bool) lzma_index_iter_locate( - lzma_index_iter *iter, lzma_vli target) lzma_nothrow; - - -/** - * \brief Concatenate lzma_indexes - * - * Concatenating lzma_indexes is useful when doing random-access reading in - * multi-Stream .xz file, or when combining multiple Streams into single - * Stream. - * - * \param dest lzma_index after which src is appended - * \param src lzma_index to be appended after dest. If this - * function succeeds, the memory allocated for src - * is freed or moved to be part of dest, and all - * iterators pointing to src will become invalid. - * \param allocator Custom memory allocator; can be NULL to use - * malloc() and free(). - * - * \return - LZMA_OK: lzma_indexes were concatenated successfully. - * src is now a dangling pointer. - * - LZMA_DATA_ERROR: *dest would grow too big. - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src, - const lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Duplicate lzma_index - * - * \return A copy of the lzma_index, or NULL if memory allocation failed. - */ -extern LZMA_API(lzma_index *) lzma_index_dup( - const lzma_index *i, const lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Index encoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param i Pointer to lzma_index which should be encoded. - * - * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. - * It is enough to use only one of them (you can choose freely; use LZMA_RUN - * to support liblzma versions older than 5.0.0). - * - * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_encoder( - lzma_stream *strm, const lzma_index *i) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Initialize .xz Index decoder - * - * \param strm Pointer to properly prepared lzma_stream - * \param i The decoded Index will be made available via - * this pointer. Initially this function will - * set *i to NULL (the old value is ignored). If - * decoding succeeds (lzma_code() returns - * LZMA_STREAM_END), *i will be set to point - * to a new lzma_index, which the application - * has to later free with lzma_index_end(). - * \param memlimit How much memory the resulting lzma_index is - * allowed to require. - * - * The valid `action' values for lzma_code() are LZMA_RUN and LZMA_FINISH. - * It is enough to use only one of them (you can choose freely; use LZMA_RUN - * to support liblzma versions older than 5.0.0). - * - * \return - LZMA_OK: Initialization succeeded, continue with lzma_code(). - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_decoder( - lzma_stream *strm, lzma_index **i, uint64_t memlimit) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Single-call .xz Index encoder - * - * \param i lzma_index to be encoded - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * *out_pos is updated only if encoding succeeds. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_BUF_ERROR: Output buffer is too small. Use - * lzma_index_size() to find out how much output - * space is needed. - * - LZMA_PROG_ERROR - * - * \note This function doesn't take allocator argument since all - * the internal data is allocated on stack. - */ -extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Single-call .xz Index decoder - * - * \param i If decoding succeeds, *i will point to a new - * lzma_index, which the application has to - * later free with lzma_index_end(). If an error - * occurs, *i will be NULL. The old value of *i - * is always ignored and thus doesn't need to be - * initialized by the caller. - * \param memlimit Pointer to how much memory the resulting - * lzma_index is allowed to require. The value - * pointed by this pointer is modified if and only - * if LZMA_MEMLIMIT_ERROR is returned. - * \param allocator Pointer to lzma_allocator, or NULL to use malloc() - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * *in_pos is updated only if decoding succeeds. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_MEM_ERROR - * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached. - * The minimum required memlimit value was stored to *memlimit. - * - LZMA_DATA_ERROR - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i, - uint64_t *memlimit, const lzma_allocator *allocator, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow; diff --git a/maclibs/include/lzma/index_hash.h b/maclibs/include/lzma/index_hash.h deleted file mode 100644 index 9287f1df..00000000 --- a/maclibs/include/lzma/index_hash.h +++ /dev/null @@ -1,107 +0,0 @@ -/** - * \file lzma/index_hash.h - * \brief Validate Index by using a hash function - * - * Hashing makes it possible to use constant amount of memory to validate - * Index of arbitrary size. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - -/** - * \brief Opaque data type to hold the Index hash - */ -typedef struct lzma_index_hash_s lzma_index_hash; - - -/** - * \brief Allocate and initialize a new lzma_index_hash structure - * - * If index_hash is NULL, a new lzma_index_hash structure is allocated, - * initialized, and a pointer to it returned. If allocation fails, NULL - * is returned. - * - * If index_hash is non-NULL, it is reinitialized and the same pointer - * returned. In this case, return value cannot be NULL or a different - * pointer than the index_hash that was given as an argument. - */ -extern LZMA_API(lzma_index_hash *) lzma_index_hash_init( - lzma_index_hash *index_hash, const lzma_allocator *allocator) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Deallocate lzma_index_hash structure - */ -extern LZMA_API(void) lzma_index_hash_end( - lzma_index_hash *index_hash, const lzma_allocator *allocator) - lzma_nothrow; - - -/** - * \brief Add a new Record to an Index hash - * - * \param index Pointer to a lzma_index_hash structure - * \param unpadded_size Unpadded Size of a Block - * \param uncompressed_size Uncompressed Size of a Block - * - * \return - LZMA_OK - * - LZMA_DATA_ERROR: Compressed or uncompressed size of the - * Stream or size of the Index field would grow too big. - * - LZMA_PROG_ERROR: Invalid arguments or this function is being - * used when lzma_index_hash_decode() has already been used. - */ -extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash, - lzma_vli unpadded_size, lzma_vli uncompressed_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode and validate the Index field - * - * After telling the sizes of all Blocks with lzma_index_hash_append(), - * the actual Index field is decoded with this function. Specifically, - * once decoding of the Index field has been started, no more Records - * can be added using lzma_index_hash_append(). - * - * This function doesn't use lzma_stream structure to pass the input data. - * Instead, the input buffer is specified using three arguments. This is - * because it matches better the internal APIs of liblzma. - * - * \param index_hash Pointer to a lzma_index_hash structure - * \param in Pointer to the beginning of the input buffer - * \param in_pos in[*in_pos] is the next byte to process - * \param in_size in[in_size] is the first byte not to process - * - * \return - LZMA_OK: So far good, but more input is needed. - * - LZMA_STREAM_END: Index decoded successfully and it matches - * the Records given with lzma_index_hash_append(). - * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the - * information given with lzma_index_hash_append(). - * - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size. - * - LZMA_PROG_ERROR - */ -extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Get the size of the Index field as bytes - * - * This is needed to verify the Backward Size field in the Stream Footer. - */ -extern LZMA_API(lzma_vli) lzma_index_hash_size( - const lzma_index_hash *index_hash) - lzma_nothrow lzma_attr_pure; diff --git a/maclibs/include/lzma/lzma12.h b/maclibs/include/lzma/lzma12.h deleted file mode 100644 index 4e32fa3a..00000000 --- a/maclibs/include/lzma/lzma12.h +++ /dev/null @@ -1,420 +0,0 @@ -/** - * \file lzma/lzma12.h - * \brief LZMA1 and LZMA2 filters - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief LZMA1 Filter ID - * - * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils, - * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from - * accidentally using LZMA when they actually want LZMA2. - * - * LZMA1 shouldn't be used for new applications unless you _really_ know - * what you are doing. LZMA2 is almost always a better choice. - */ -#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001) - -/** - * \brief LZMA2 Filter ID - * - * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds - * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion - * when trying to compress uncompressible data), possibility to change - * lc/lp/pb in the middle of encoding, and some other internal improvements. - */ -#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21) - - -/** - * \brief Match finders - * - * Match finder has major effect on both speed and compression ratio. - * Usually hash chains are faster than binary trees. - * - * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better - * choice, because binary trees get much higher compression ratio penalty - * with LZMA_SYNC_FLUSH. - * - * The memory usage formulas are only rough estimates, which are closest to - * reality when dict_size is a power of two. The formulas are more complex - * in reality, and can also change a little between liblzma versions. Use - * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage. - */ -typedef enum { - LZMA_MF_HC3 = 0x03, - /**< - * \brief Hash Chain with 2- and 3-byte hashing - * - * Minimum nice_len: 3 - * - * Memory usage: - * - dict_size <= 16 MiB: dict_size * 7.5 - * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB - */ - - LZMA_MF_HC4 = 0x04, - /**< - * \brief Hash Chain with 2-, 3-, and 4-byte hashing - * - * Minimum nice_len: 4 - * - * Memory usage: - * - dict_size <= 32 MiB: dict_size * 7.5 - * - dict_size > 32 MiB: dict_size * 6.5 - */ - - LZMA_MF_BT2 = 0x12, - /**< - * \brief Binary Tree with 2-byte hashing - * - * Minimum nice_len: 2 - * - * Memory usage: dict_size * 9.5 - */ - - LZMA_MF_BT3 = 0x13, - /**< - * \brief Binary Tree with 2- and 3-byte hashing - * - * Minimum nice_len: 3 - * - * Memory usage: - * - dict_size <= 16 MiB: dict_size * 11.5 - * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB - */ - - LZMA_MF_BT4 = 0x14 - /**< - * \brief Binary Tree with 2-, 3-, and 4-byte hashing - * - * Minimum nice_len: 4 - * - * Memory usage: - * - dict_size <= 32 MiB: dict_size * 11.5 - * - dict_size > 32 MiB: dict_size * 10.5 - */ -} lzma_match_finder; - - -/** - * \brief Test if given match finder is supported - * - * Return true if the given match finder is supported by this liblzma build. - * Otherwise false is returned. It is safe to call this with a value that - * isn't listed in lzma_match_finder enumeration; the return value will be - * false. - * - * There is no way to list which match finders are available in this - * particular liblzma version and build. It would be useless, because - * a new match finder, which the application developer wasn't aware, - * could require giving additional options to the encoder that the older - * match finders don't need. - */ -extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Compression modes - * - * This selects the function used to analyze the data produced by the match - * finder. - */ -typedef enum { - LZMA_MODE_FAST = 1, - /**< - * \brief Fast compression - * - * Fast mode is usually at its best when combined with - * a hash chain match finder. - */ - - LZMA_MODE_NORMAL = 2 - /**< - * \brief Normal compression - * - * This is usually notably slower than fast mode. Use this - * together with binary tree match finders to expose the - * full potential of the LZMA1 or LZMA2 encoder. - */ -} lzma_mode; - - -/** - * \brief Test if given compression mode is supported - * - * Return true if the given compression mode is supported by this liblzma - * build. Otherwise false is returned. It is safe to call this with a value - * that isn't listed in lzma_mode enumeration; the return value will be false. - * - * There is no way to list which modes are available in this particular - * liblzma version and build. It would be useless, because a new compression - * mode, which the application developer wasn't aware, could require giving - * additional options to the encoder that the older modes don't need. - */ -extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Options specific to the LZMA1 and LZMA2 filters - * - * Since LZMA1 and LZMA2 share most of the code, it's simplest to share - * the options structure too. For encoding, all but the reserved variables - * need to be initialized unless specifically mentioned otherwise. - * lzma_lzma_preset() can be used to get a good starting point. - * - * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and - * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb. - */ -typedef struct { - /** - * \brief Dictionary size in bytes - * - * Dictionary size indicates how many bytes of the recently processed - * uncompressed data is kept in memory. One method to reduce size of - * the uncompressed data is to store distance-length pairs, which - * indicate what data to repeat from the dictionary buffer. Thus, - * the bigger the dictionary, the better the compression ratio - * usually is. - * - * Maximum size of the dictionary depends on multiple things: - * - Memory usage limit - * - Available address space (not a problem on 64-bit systems) - * - Selected match finder (encoder only) - * - * Currently the maximum dictionary size for encoding is 1.5 GiB - * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit - * systems for certain match finder implementation reasons. In the - * future, there may be match finders that support bigger - * dictionaries. - * - * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e. - * UINT32_MAX), so increasing the maximum dictionary size of the - * encoder won't cause problems for old decoders. - * - * Because extremely small dictionaries sizes would have unneeded - * overhead in the decoder, the minimum dictionary size is 4096 bytes. - * - * \note When decoding, too big dictionary does no other harm - * than wasting memory. - */ - uint32_t dict_size; -# define LZMA_DICT_SIZE_MIN UINT32_C(4096) -# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23) - - /** - * \brief Pointer to an initial dictionary - * - * It is possible to initialize the LZ77 history window using - * a preset dictionary. It is useful when compressing many - * similar, relatively small chunks of data independently from - * each other. The preset dictionary should contain typical - * strings that occur in the files being compressed. The most - * probable strings should be near the end of the preset dictionary. - * - * This feature should be used only in special situations. For - * now, it works correctly only with raw encoding and decoding. - * Currently none of the container formats supported by - * liblzma allow preset dictionary when decoding, thus if - * you create a .xz or .lzma file with preset dictionary, it - * cannot be decoded with the regular decoder functions. In the - * future, the .xz format will likely get support for preset - * dictionary though. - */ - const uint8_t *preset_dict; - - /** - * \brief Size of the preset dictionary - * - * Specifies the size of the preset dictionary. If the size is - * bigger than dict_size, only the last dict_size bytes are - * processed. - * - * This variable is read only when preset_dict is not NULL. - * If preset_dict is not NULL but preset_dict_size is zero, - * no preset dictionary is used (identical to only setting - * preset_dict to NULL). - */ - uint32_t preset_dict_size; - - /** - * \brief Number of literal context bits - * - * How many of the highest bits of the previous uncompressed - * eight-bit byte (also known as `literal') are taken into - * account when predicting the bits of the next literal. - * - * E.g. in typical English text, an upper-case letter is - * often followed by a lower-case letter, and a lower-case - * letter is usually followed by another lower-case letter. - * In the US-ASCII character set, the highest three bits are 010 - * for upper-case letters and 011 for lower-case letters. - * When lc is at least 3, the literal coding can take advantage of - * this property in the uncompressed data. - * - * There is a limit that applies to literal context bits and literal - * position bits together: lc + lp <= 4. Without this limit the - * decoding could become very slow, which could have security related - * results in some cases like email servers doing virus scanning. - * This limit also simplifies the internal implementation in liblzma. - * - * There may be LZMA1 streams that have lc + lp > 4 (maximum possible - * lc would be 8). It is not possible to decode such streams with - * liblzma. - */ - uint32_t lc; -# define LZMA_LCLP_MIN 0 -# define LZMA_LCLP_MAX 4 -# define LZMA_LC_DEFAULT 3 - - /** - * \brief Number of literal position bits - * - * lp affects what kind of alignment in the uncompressed data is - * assumed when encoding literals. A literal is a single 8-bit byte. - * See pb below for more information about alignment. - */ - uint32_t lp; -# define LZMA_LP_DEFAULT 0 - - /** - * \brief Number of position bits - * - * pb affects what kind of alignment in the uncompressed data is - * assumed in general. The default means four-byte alignment - * (2^ pb =2^2=4), which is often a good choice when there's - * no better guess. - * - * When the aligment is known, setting pb accordingly may reduce - * the file size a little. E.g. with text files having one-byte - * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can - * improve compression slightly. For UTF-16 text, pb=1 is a good - * choice. If the alignment is an odd number like 3 bytes, pb=0 - * might be the best choice. - * - * Even though the assumed alignment can be adjusted with pb and - * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment. - * It might be worth taking into account when designing file formats - * that are likely to be often compressed with LZMA1 or LZMA2. - */ - uint32_t pb; -# define LZMA_PB_MIN 0 -# define LZMA_PB_MAX 4 -# define LZMA_PB_DEFAULT 2 - - /** Compression mode */ - lzma_mode mode; - - /** - * \brief Nice length of a match - * - * This determines how many bytes the encoder compares from the match - * candidates when looking for the best match. Once a match of at - * least nice_len bytes long is found, the encoder stops looking for - * better candidates and encodes the match. (Naturally, if the found - * match is actually longer than nice_len, the actual length is - * encoded; it's not truncated to nice_len.) - * - * Bigger values usually increase the compression ratio and - * compression time. For most files, 32 to 128 is a good value, - * which gives very good compression ratio at good speed. - * - * The exact minimum value depends on the match finder. The maximum - * is 273, which is the maximum length of a match that LZMA1 and - * LZMA2 can encode. - */ - uint32_t nice_len; - - /** Match finder ID */ - lzma_match_finder mf; - - /** - * \brief Maximum search depth in the match finder - * - * For every input byte, match finder searches through the hash chain - * or binary tree in a loop, each iteration going one step deeper in - * the chain or tree. The searching stops if - * - a match of at least nice_len bytes long is found; - * - all match candidates from the hash chain or binary tree have - * been checked; or - * - maximum search depth is reached. - * - * Maximum search depth is needed to prevent the match finder from - * wasting too much time in case there are lots of short match - * candidates. On the other hand, stopping the search before all - * candidates have been checked can reduce compression ratio. - * - * Setting depth to zero tells liblzma to use an automatic default - * value, that depends on the selected match finder and nice_len. - * The default is in the range [4, 200] or so (it may vary between - * liblzma versions). - * - * Using a bigger depth value than the default can increase - * compression ratio in some cases. There is no strict maximum value, - * but high values (thousands or millions) should be used with care: - * the encoder could remain fast enough with typical input, but - * malicious input could cause the match finder to slow down - * dramatically, possibly creating a denial of service attack. - */ - uint32_t depth; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the names - * of these variables may change. These are and will never be used - * with the currently supported options, so it is safe to leave these - * uninitialized. - */ - uint32_t reserved_int1; - uint32_t reserved_int2; - uint32_t reserved_int3; - uint32_t reserved_int4; - uint32_t reserved_int5; - uint32_t reserved_int6; - uint32_t reserved_int7; - uint32_t reserved_int8; - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - void *reserved_ptr1; - void *reserved_ptr2; - -} lzma_options_lzma; - - -/** - * \brief Set a compression preset to lzma_options_lzma structure - * - * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9 - * of the xz command line tool. In addition, it is possible to bitwise-or - * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported. - * The flags are defined in container.h, because the flags are used also - * with lzma_easy_encoder(). - * - * The preset values are subject to changes between liblzma versions. - * - * This function is available only if LZMA1 or LZMA2 encoder has been enabled - * when building liblzma. - * - * \return On success, false is returned. If the preset is not - * supported, true is returned. - */ -extern LZMA_API(lzma_bool) lzma_lzma_preset( - lzma_options_lzma *options, uint32_t preset) lzma_nothrow; diff --git a/maclibs/include/lzma/stream_flags.h b/maclibs/include/lzma/stream_flags.h deleted file mode 100644 index bbdd4082..00000000 --- a/maclibs/include/lzma/stream_flags.h +++ /dev/null @@ -1,223 +0,0 @@ -/** - * \file lzma/stream_flags.h - * \brief .xz Stream Header and Stream Footer encoder and decoder - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Size of Stream Header and Stream Footer - * - * Stream Header and Stream Footer have the same size and they are not - * going to change even if a newer version of the .xz file format is - * developed in future. - */ -#define LZMA_STREAM_HEADER_SIZE 12 - - -/** - * \brief Options for encoding/decoding Stream Header and Stream Footer - */ -typedef struct { - /** - * \brief Stream Flags format version - * - * To prevent API and ABI breakages if new features are needed in - * Stream Header or Stream Footer, a version number is used to - * indicate which fields in this structure are in use. For now, - * version must always be zero. With non-zero version, the - * lzma_stream_header_encode() and lzma_stream_footer_encode() - * will return LZMA_OPTIONS_ERROR. - * - * lzma_stream_header_decode() and lzma_stream_footer_decode() - * will always set this to the lowest value that supports all the - * features indicated by the Stream Flags field. The application - * must check that the version number set by the decoding functions - * is supported by the application. Otherwise it is possible that - * the application will decode the Stream incorrectly. - */ - uint32_t version; - - /** - * \brief Backward Size - * - * Backward Size must be a multiple of four bytes. In this Stream - * format version, Backward Size is the size of the Index field. - * - * Backward Size isn't actually part of the Stream Flags field, but - * it is convenient to include in this structure anyway. Backward - * Size is present only in the Stream Footer. There is no need to - * initialize backward_size when encoding Stream Header. - * - * lzma_stream_header_decode() always sets backward_size to - * LZMA_VLI_UNKNOWN so that it is convenient to use - * lzma_stream_flags_compare() when both Stream Header and Stream - * Footer have been decoded. - */ - lzma_vli backward_size; -# define LZMA_BACKWARD_SIZE_MIN 4 -# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34) - - /** - * \brief Check ID - * - * This indicates the type of the integrity check calculated from - * uncompressed data. - */ - lzma_check check; - - /* - * Reserved space to allow possible future extensions without - * breaking the ABI. You should not touch these, because the - * names of these variables may change. - * - * (We will never be able to use all of these since Stream Flags - * is just two bytes plus Backward Size of four bytes. But it's - * nice to have the proper types when they are needed.) - */ - lzma_reserved_enum reserved_enum1; - lzma_reserved_enum reserved_enum2; - lzma_reserved_enum reserved_enum3; - lzma_reserved_enum reserved_enum4; - lzma_bool reserved_bool1; - lzma_bool reserved_bool2; - lzma_bool reserved_bool3; - lzma_bool reserved_bool4; - lzma_bool reserved_bool5; - lzma_bool reserved_bool6; - lzma_bool reserved_bool7; - lzma_bool reserved_bool8; - uint32_t reserved_int1; - uint32_t reserved_int2; - -} lzma_stream_flags; - - -/** - * \brief Encode Stream Header - * - * \param options Stream Header options to be encoded. - * options->backward_size is ignored and doesn't - * need to be initialized. - * \param out Beginning of the output buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: options->version is not supported by - * this liblzma version. - * - LZMA_PROG_ERROR: Invalid options. - */ -extern LZMA_API(lzma_ret) lzma_stream_header_encode( - const lzma_stream_flags *options, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Encode Stream Footer - * - * \param options Stream Footer options to be encoded. - * \param out Beginning of the output buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Encoding was successful. - * - LZMA_OPTIONS_ERROR: options->version is not supported by - * this liblzma version. - * - LZMA_PROG_ERROR: Invalid options. - */ -extern LZMA_API(lzma_ret) lzma_stream_footer_encode( - const lzma_stream_flags *options, uint8_t *out) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Stream Header - * - * \param options Target for the decoded Stream Header options. - * \param in Beginning of the input buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to - * help comparing Stream Flags from Stream Header and Stream Footer with - * lzma_stream_flags_compare(). - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given - * buffer cannot be Stream Header. - * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header - * is corrupt. - * - LZMA_OPTIONS_ERROR: Unsupported options are present - * in the header. - * - * \note When decoding .xz files that contain multiple Streams, it may - * make sense to print "file format not recognized" only if - * decoding of the Stream Header of the _first_ Stream gives - * LZMA_FORMAT_ERROR. If non-first Stream Header gives - * LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is - * probably more appropriate. - * - * For example, Stream decoder in liblzma uses LZMA_DATA_ERROR if - * LZMA_FORMAT_ERROR is returned by lzma_stream_header_decode() - * when decoding non-first Stream. - */ -extern LZMA_API(lzma_ret) lzma_stream_header_decode( - lzma_stream_flags *options, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Decode Stream Footer - * - * \param options Target for the decoded Stream Header options. - * \param in Beginning of the input buffer of - * LZMA_STREAM_HEADER_SIZE bytes. - * - * \return - LZMA_OK: Decoding was successful. - * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given - * buffer cannot be Stream Footer. - * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer - * is corrupt. - * - LZMA_OPTIONS_ERROR: Unsupported options are present - * in Stream Footer. - * - * \note If Stream Header was already decoded successfully, but - * decoding Stream Footer returns LZMA_FORMAT_ERROR, the - * application should probably report some other error message - * than "file format not recognized", since the file more likely - * is corrupt (possibly truncated). Stream decoder in liblzma - * uses LZMA_DATA_ERROR in this situation. - */ -extern LZMA_API(lzma_ret) lzma_stream_footer_decode( - lzma_stream_flags *options, const uint8_t *in) - lzma_nothrow lzma_attr_warn_unused_result; - - -/** - * \brief Compare two lzma_stream_flags structures - * - * backward_size values are compared only if both are not - * LZMA_VLI_UNKNOWN. - * - * \return - LZMA_OK: Both are equal. If either had backward_size set - * to LZMA_VLI_UNKNOWN, backward_size values were not - * compared or validated. - * - LZMA_DATA_ERROR: The structures differ. - * - LZMA_OPTIONS_ERROR: version in either structure is greater - * than the maximum supported version (currently zero). - * - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or - * backward_size. - */ -extern LZMA_API(lzma_ret) lzma_stream_flags_compare( - const lzma_stream_flags *a, const lzma_stream_flags *b) - lzma_nothrow lzma_attr_pure; diff --git a/maclibs/include/lzma/version.h b/maclibs/include/lzma/version.h deleted file mode 100644 index b5e061c2..00000000 --- a/maclibs/include/lzma/version.h +++ /dev/null @@ -1,121 +0,0 @@ -/** - * \file lzma/version.h - * \brief Version number - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/* - * Version number split into components - */ -#define LZMA_VERSION_MAJOR 5 -#define LZMA_VERSION_MINOR 2 -#define LZMA_VERSION_PATCH 3 -#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE - -#ifndef LZMA_VERSION_COMMIT -# define LZMA_VERSION_COMMIT "" -#endif - - -/* - * Map symbolic stability levels to integers. - */ -#define LZMA_VERSION_STABILITY_ALPHA 0 -#define LZMA_VERSION_STABILITY_BETA 1 -#define LZMA_VERSION_STABILITY_STABLE 2 - - -/** - * \brief Compile-time version number - * - * The version number is of format xyyyzzzs where - * - x = major - * - yyy = minor - * - zzz = revision - * - s indicates stability: 0 = alpha, 1 = beta, 2 = stable - * - * The same xyyyzzz triplet is never reused with different stability levels. - * For example, if 5.1.0alpha has been released, there will never be 5.1.0beta - * or 5.1.0 stable. - * - * \note The version number of liblzma has nothing to with - * the version number of Igor Pavlov's LZMA SDK. - */ -#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \ - + LZMA_VERSION_MINOR * UINT32_C(10000) \ - + LZMA_VERSION_PATCH * UINT32_C(10) \ - + LZMA_VERSION_STABILITY) - - -/* - * Macros to construct the compile-time version string - */ -#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA -# define LZMA_VERSION_STABILITY_STRING "alpha" -#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA -# define LZMA_VERSION_STABILITY_STRING "beta" -#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE -# define LZMA_VERSION_STABILITY_STRING "" -#else -# error Incorrect LZMA_VERSION_STABILITY -#endif - -#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \ - #major "." #minor "." #patch stability commit - -#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \ - LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) - - -/** - * \brief Compile-time version as a string - * - * This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable - * versions don't have any "stable" suffix). In future, a snapshot built - * from source code repository may include an additional suffix, for example - * "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form - * in LZMA_VERSION macro. - */ -#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \ - LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \ - LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \ - LZMA_VERSION_COMMIT) - - -/* #ifndef is needed for use with windres (MinGW or Cygwin). */ -#ifndef LZMA_H_INTERNAL_RC - -/** - * \brief Run-time version number as an integer - * - * Return the value of LZMA_VERSION macro at the compile time of liblzma. - * This allows the application to compare if it was built against the same, - * older, or newer version of liblzma that is currently running. - */ -extern LZMA_API(uint32_t) lzma_version_number(void) - lzma_nothrow lzma_attr_const; - - -/** - * \brief Run-time version as a string - * - * This function may be useful if you want to display which version of - * liblzma your application is currently using. - */ -extern LZMA_API(const char *) lzma_version_string(void) - lzma_nothrow lzma_attr_const; - -#endif diff --git a/maclibs/include/lzma/vli.h b/maclibs/include/lzma/vli.h deleted file mode 100644 index 9ad13f2e..00000000 --- a/maclibs/include/lzma/vli.h +++ /dev/null @@ -1,166 +0,0 @@ -/** - * \file lzma/vli.h - * \brief Variable-length integer handling - * - * In the .xz format, most integers are encoded in a variable-length - * representation, which is sometimes called little endian base-128 encoding. - * This saves space when smaller values are more likely than bigger values. - * - * The encoding scheme encodes seven bits to every byte, using minimum - * number of bytes required to represent the given value. Encodings that use - * non-minimum number of bytes are invalid, thus every integer has exactly - * one encoded representation. The maximum number of bits in a VLI is 63, - * thus the vli argument must be less than or equal to UINT64_MAX / 2. You - * should use LZMA_VLI_MAX for clarity. - */ - -/* - * Author: Lasse Collin - * - * This file has been put into the public domain. - * You can do whatever you want with this file. - * - * See ../lzma.h for information about liblzma as a whole. - */ - -#ifndef LZMA_H_INTERNAL -# error Never include this file directly. Use instead. -#endif - - -/** - * \brief Maximum supported value of a variable-length integer - */ -#define LZMA_VLI_MAX (UINT64_MAX / 2) - -/** - * \brief VLI value to denote that the value is unknown - */ -#define LZMA_VLI_UNKNOWN UINT64_MAX - -/** - * \brief Maximum supported encoded length of variable length integers - */ -#define LZMA_VLI_BYTES_MAX 9 - -/** - * \brief VLI constant suffix - */ -#define LZMA_VLI_C(n) UINT64_C(n) - - -/** - * \brief Variable-length integer type - * - * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is - * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the - * underlaying integer type. - * - * lzma_vli will be uint64_t for the foreseeable future. If a bigger size - * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will - * not overflow lzma_vli. This simplifies integer overflow detection. - */ -typedef uint64_t lzma_vli; - - -/** - * \brief Validate a variable-length integer - * - * This is useful to test that application has given acceptable values - * for example in the uncompressed_size and compressed_size variables. - * - * \return True if the integer is representable as VLI or if it - * indicates unknown value. - */ -#define lzma_vli_is_valid(vli) \ - ((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN) - - -/** - * \brief Encode a variable-length integer - * - * This function has two modes: single-call and multi-call. Single-call mode - * encodes the whole integer at once; it is an error if the output buffer is - * too small. Multi-call mode saves the position in *vli_pos, and thus it is - * possible to continue encoding if the buffer becomes full before the whole - * integer has been encoded. - * - * \param vli Integer to be encoded - * \param vli_pos How many VLI-encoded bytes have already been written - * out. When starting to encode a new integer in - * multi-call mode, *vli_pos must be set to zero. - * To use single-call encoding, set vli_pos to NULL. - * \param out Beginning of the output buffer - * \param out_pos The next byte will be written to out[*out_pos]. - * \param out_size Size of the out buffer; the first byte into - * which no data is written to is out[out_size]. - * - * \return Slightly different return values are used in multi-call and - * single-call modes. - * - * Single-call (vli_pos == NULL): - * - LZMA_OK: Integer successfully encoded. - * - LZMA_PROG_ERROR: Arguments are not sane. This can be due - * to too little output space; single-call mode doesn't use - * LZMA_BUF_ERROR, since the application should have checked - * the encoded size with lzma_vli_size(). - * - * Multi-call (vli_pos != NULL): - * - LZMA_OK: So far all OK, but the integer is not - * completely written out yet. - * - LZMA_STREAM_END: Integer successfully encoded. - * - LZMA_BUF_ERROR: No output space was provided. - * - LZMA_PROG_ERROR: Arguments are not sane. - */ -extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos, - uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow; - - -/** - * \brief Decode a variable-length integer - * - * Like lzma_vli_encode(), this function has single-call and multi-call modes. - * - * \param vli Pointer to decoded integer. The decoder will - * initialize it to zero when *vli_pos == 0, so - * application isn't required to initialize *vli. - * \param vli_pos How many bytes have already been decoded. When - * starting to decode a new integer in multi-call - * mode, *vli_pos must be initialized to zero. To - * use single-call decoding, set vli_pos to NULL. - * \param in Beginning of the input buffer - * \param in_pos The next byte will be read from in[*in_pos]. - * \param in_size Size of the input buffer; the first byte that - * won't be read is in[in_size]. - * - * \return Slightly different return values are used in multi-call and - * single-call modes. - * - * Single-call (vli_pos == NULL): - * - LZMA_OK: Integer successfully decoded. - * - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting - * the end of the input buffer before the whole integer was - * decoded; providing no input at all will use LZMA_DATA_ERROR. - * - LZMA_PROG_ERROR: Arguments are not sane. - * - * Multi-call (vli_pos != NULL): - * - LZMA_OK: So far all OK, but the integer is not - * completely decoded yet. - * - LZMA_STREAM_END: Integer successfully decoded. - * - LZMA_DATA_ERROR: Integer is corrupt. - * - LZMA_BUF_ERROR: No input was provided. - * - LZMA_PROG_ERROR: Arguments are not sane. - */ -extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos, - const uint8_t *in, size_t *in_pos, size_t in_size) - lzma_nothrow; - - -/** - * \brief Get the number of bytes required to encode a VLI - * - * \return Number of bytes on success (1-9). If vli isn't valid, - * zero is returned. - */ -extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli) - lzma_nothrow lzma_attr_pure; diff --git a/maclibs/include/lzo/lzo1.h b/maclibs/include/lzo/lzo1.h deleted file mode 100644 index de0fba57..00000000 --- a/maclibs/include/lzo/lzo1.h +++ /dev/null @@ -1,99 +0,0 @@ -/* lzo1.h -- public interface of the LZO1 compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1_H_INCLUDED -#define __LZO1_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1_MEM_COMPRESS ((lzo_uint32) (8192L * lzo_sizeof_dict_t)) -#define LZO1_MEM_DECOMPRESS (0) - - -LZO_EXTERN(int) -lzo1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -LZO_EXTERN(int) -lzo1_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1_99_MEM_COMPRESS ((lzo_uint32) (65536L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1_99_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo1a.h b/maclibs/include/lzo/lzo1a.h deleted file mode 100644 index 0969c67d..00000000 --- a/maclibs/include/lzo/lzo1a.h +++ /dev/null @@ -1,99 +0,0 @@ -/* lzo1a.h -- public interface of the LZO1A compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1A_H_INCLUDED -#define __LZO1A_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1A_MEM_COMPRESS ((lzo_uint32) (8192L * lzo_sizeof_dict_t)) -#define LZO1A_MEM_DECOMPRESS (0) - - -LZO_EXTERN(int) -lzo1a_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -LZO_EXTERN(int) -lzo1a_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1A_99_MEM_COMPRESS ((lzo_uint32) (65536L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1a_99_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo1b.h b/maclibs/include/lzo/lzo1b.h deleted file mode 100644 index da3b597c..00000000 --- a/maclibs/include/lzo/lzo1b.h +++ /dev/null @@ -1,163 +0,0 @@ -/* lzo1b.h -- public interface of the LZO1B compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1B_H_INCLUDED -#define __LZO1B_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1B_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1B_MEM_DECOMPRESS (0) - - -/* compression levels */ -#define LZO1B_BEST_SPEED 1 -#define LZO1B_BEST_COMPRESSION 9 -#define LZO1B_DEFAULT_COMPRESSION (-1) /* fastest by default */ - - -LZO_EXTERN(int) -lzo1b_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - int compression_level ); - -/* decompression */ -LZO_EXTERN(int) -lzo1b_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1b_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1b_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_2_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_3_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_4_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_5_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_6_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_7_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_8_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1b_9_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1B_99_MEM_COMPRESS ((lzo_uint32) (65536L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1b_99_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -#define LZO1B_999_MEM_COMPRESS ((lzo_uint32) (3 * 65536L * sizeof(lzo_xint))) - -LZO_EXTERN(int) -lzo1b_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo1c.h b/maclibs/include/lzo/lzo1c.h deleted file mode 100644 index d5b1b8c5..00000000 --- a/maclibs/include/lzo/lzo1c.h +++ /dev/null @@ -1,163 +0,0 @@ -/* lzo1c.h -- public interface of the LZO1C compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1C_H_INCLUDED -#define __LZO1C_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1C_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1C_MEM_DECOMPRESS (0) - - -/* compression levels */ -#define LZO1C_BEST_SPEED 1 -#define LZO1C_BEST_COMPRESSION 9 -#define LZO1C_DEFAULT_COMPRESSION (-1) /* fastest by default */ - - -LZO_EXTERN(int) -lzo1c_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - int compression_level ); - -/* decompression */ -LZO_EXTERN(int) -lzo1c_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1c_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1c_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_2_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_3_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_4_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_5_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_6_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_7_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_8_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -LZO_EXTERN(int) -lzo1c_9_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1C_99_MEM_COMPRESS ((lzo_uint32) (65536L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1c_99_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -#define LZO1C_999_MEM_COMPRESS ((lzo_uint32) (5 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1c_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo1f.h b/maclibs/include/lzo/lzo1f.h deleted file mode 100644 index 77130703..00000000 --- a/maclibs/include/lzo/lzo1f.h +++ /dev/null @@ -1,111 +0,0 @@ -/* lzo1f.h -- public interface of the LZO1F compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1F_H_INCLUDED -#define __LZO1F_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1F_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1F_MEM_DECOMPRESS (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1f_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1f_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1f_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1F_999_MEM_COMPRESS ((lzo_uint32) (5 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1f_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo1x.h b/maclibs/include/lzo/lzo1x.h deleted file mode 100644 index 9bb993cc..00000000 --- a/maclibs/include/lzo/lzo1x.h +++ /dev/null @@ -1,180 +0,0 @@ -/* lzo1x.h -- public interface of the LZO1X compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1X_H_INCLUDED -#define __LZO1X_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS -#define LZO1X_MEM_DECOMPRESS (0) -#define LZO1X_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1x_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1x_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -#define LZO1X_1_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// special compressor versions -************************************************************************/ - -/* this version needs only 8 KiB work memory */ -#define LZO1X_1_11_MEM_COMPRESS ((lzo_uint32) (2048L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_11_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/* this version needs 16 KiB work memory */ -#define LZO1X_1_12_MEM_COMPRESS ((lzo_uint32) (4096L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_12_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/* use this version if you need a little more compression speed */ -#define LZO1X_1_15_MEM_COMPRESS ((lzo_uint32) (32768L * lzo_sizeof_dict_t)) - -LZO_EXTERN(int) -lzo1x_1_15_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1X_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1x_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1x_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1x_999_compress_level ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len, - lzo_callback_p cb, - int compression_level ); - -LZO_EXTERN(int) -lzo1x_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_bytep dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -LZO_EXTERN(int) -lzo1x_optimize ( lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo1y.h b/maclibs/include/lzo/lzo1y.h deleted file mode 100644 index 359e3580..00000000 --- a/maclibs/include/lzo/lzo1y.h +++ /dev/null @@ -1,148 +0,0 @@ -/* lzo1y.h -- public interface of the LZO1Y compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1Y_H_INCLUDED -#define __LZO1Y_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1Y_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1Y_MEM_DECOMPRESS (0) -#define LZO1Y_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1y_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1y_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1y_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1Y_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1y_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1y_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1y_999_compress_level ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len, - lzo_callback_p cb, - int compression_level ); - -LZO_EXTERN(int) -lzo1y_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_bytep dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -LZO_EXTERN(int) -lzo1y_optimize ( lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo1z.h b/maclibs/include/lzo/lzo1z.h deleted file mode 100644 index f385ca39..00000000 --- a/maclibs/include/lzo/lzo1z.h +++ /dev/null @@ -1,153 +0,0 @@ -/* lzo1z.h -- public interface of the LZO1Z compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO1Z_H_INCLUDED -#define __LZO1Z_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -/* Memory required for the wrkmem parameter. - * When the required size is 0, you can also pass a NULL pointer. - */ - -#define LZO1Z_MEM_COMPRESS ((lzo_uint32) (16384L * lzo_sizeof_dict_t)) -#define LZO1Z_MEM_DECOMPRESS (0) -#define LZO1Z_MEM_OPTIMIZE (0) - - -/* decompression */ -LZO_EXTERN(int) -lzo1z_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo1z_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// -************************************************************************/ - -#if 0 -/* not yet implemented */ -LZO_EXTERN(int) -lzo1z_1_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); -#endif - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO1Z_999_MEM_COMPRESS ((lzo_uint32) (14 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo1z_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - -/*********************************************************************** -// -************************************************************************/ - -LZO_EXTERN(int) -lzo1z_999_compress_dict ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - -LZO_EXTERN(int) -lzo1z_999_compress_level ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len, - lzo_callback_p cb, - int compression_level ); - -LZO_EXTERN(int) -lzo1z_decompress_dict_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */, - const lzo_bytep dict, lzo_uint dict_len ); - - -/*********************************************************************** -// optimize a compressed data block -************************************************************************/ - -#if 0 -/* not yet implemented */ -LZO_EXTERN(int) -lzo1z_optimize ( lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); -#endif - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo2a.h b/maclibs/include/lzo/lzo2a.h deleted file mode 100644 index ef65155e..00000000 --- a/maclibs/include/lzo/lzo2a.h +++ /dev/null @@ -1,95 +0,0 @@ -/* lzo2a.h -- public interface of the LZO2A compression algorithm - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO2A_H_INCLUDED -#define __LZO2A_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// -************************************************************************/ - -#define LZO2A_MEM_DECOMPRESS (0) - -/* decompression */ -LZO_EXTERN(int) -lzo2a_decompress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - -/* safe decompression with overrun testing */ -LZO_EXTERN(int) -lzo2a_decompress_safe ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem /* NOT USED */ ); - - -/*********************************************************************** -// better compression ratio at the cost of more memory and time -************************************************************************/ - -#define LZO2A_999_MEM_COMPRESS ((lzo_uint32) (8 * 16384L * sizeof(short))) - -LZO_EXTERN(int) -lzo2a_999_compress ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzo_asm.h b/maclibs/include/lzo/lzo_asm.h deleted file mode 100644 index 51bea657..00000000 --- a/maclibs/include/lzo/lzo_asm.h +++ /dev/null @@ -1,155 +0,0 @@ -/* lzo_asm.h -- assembler prototypes for the LZO data compression library - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZO_ASM_H_INCLUDED -#define __LZO_ASM_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// i386 assembly decompressors -// -// NOTE: -// ==== -// -// - For reasons of speed all fast assembler decompressors (having '_fast' -// in their name) can access (write to) up to 3 bytes past the end of -// the decompressed ("dst") block. Data past the end of the compressed -// ("src") block is never accessed (read from). -// [ technical note: because data is transferred in 32-bit units ] -// -// - Please also see asm/i386/00README.TXT and doc/LZO.FAQ for more -// important details about the assembler versions. -// -************************************************************************/ - -LZO_EXTERN(int) lzo1c_decompress_asm - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1c_decompress_asm_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); - -LZO_EXTERN(int) lzo1f_decompress_asm_fast - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1f_decompress_asm_fast_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); - -LZO_EXTERN(int) lzo1x_decompress_asm - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1x_decompress_asm_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1x_decompress_asm_fast - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1x_decompress_asm_fast_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); - -LZO_EXTERN(int) lzo1y_decompress_asm - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1y_decompress_asm_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1y_decompress_asm_fast - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); -LZO_EXTERN(int) lzo1y_decompress_asm_fast_safe - (const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem); - - -/*********************************************************************** -// checksum and misc functions -************************************************************************/ - -#if 0 - -LZO_EXTERN(lzo_uint32) -lzo_crc32_asm(lzo_uint32 c, const lzo_bytep buf, lzo_uint len, - const lzo_uint32p tab); - -LZO_EXTERN(lzo_uint32) -lzo_crc32_asm_small(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); - -LZO_EXTERN(int) -lzo_cpuid_asm(lzo_uint32p /* lzo_uint32 info[16] */ ); - -LZO_EXTERN(lzo_uint32) -lzo_rdtsc_asm(lzo_uint32p /* lzo_uint32 ticks[2] */ ); - -#endif - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzoconf.h b/maclibs/include/lzo/lzoconf.h deleted file mode 100644 index 23c6ca93..00000000 --- a/maclibs/include/lzo/lzoconf.h +++ /dev/null @@ -1,446 +0,0 @@ -/* lzoconf.h -- configuration of the LZO data compression library - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZOCONF_H_INCLUDED -#define __LZOCONF_H_INCLUDED 1 - -#define LZO_VERSION 0x2060 -#define LZO_VERSION_STRING "2.06" -#define LZO_VERSION_DATE "Aug 12 2011" - -/* internal Autoconf configuration file - only used when building LZO */ -#if defined(LZO_HAVE_CONFIG_H) -# include -#endif -#include -#include - - -/*********************************************************************** -// LZO requires a conforming -************************************************************************/ - -#if !defined(CHAR_BIT) || (CHAR_BIT != 8) -# error "invalid CHAR_BIT" -#endif -#if !defined(UCHAR_MAX) || !defined(UINT_MAX) || !defined(ULONG_MAX) -# error "check your compiler installation" -#endif -#if (USHRT_MAX < 1) || (UINT_MAX < 1) || (ULONG_MAX < 1) -# error "your limits.h macros are broken" -#endif - -/* get OS and architecture defines */ -#ifndef __LZODEFS_H_INCLUDED -#include "lzodefs.h" -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// some core defines -************************************************************************/ - -#if !defined(LZO_UINT32_C) -# if (UINT_MAX < LZO_0xffffffffL) -# define LZO_UINT32_C(c) c ## UL -# else -# define LZO_UINT32_C(c) ((c) + 0U) -# endif -#endif - -/* memory checkers */ -#if !defined(__LZO_CHECKER) -# if defined(__BOUNDS_CHECKING_ON) -# define __LZO_CHECKER 1 -# elif defined(__CHECKER__) -# define __LZO_CHECKER 1 -# elif defined(__INSURE__) -# define __LZO_CHECKER 1 -# elif defined(__PURIFY__) -# define __LZO_CHECKER 1 -# endif -#endif - - -/*********************************************************************** -// integral and pointer types -************************************************************************/ - -/* lzo_uint should match size_t */ -#if !defined(LZO_UINT_MAX) -# if defined(LZO_ABI_LLP64) /* WIN64 */ -# if defined(LZO_OS_WIN64) - typedef unsigned __int64 lzo_uint; - typedef __int64 lzo_int; -# else - typedef unsigned long long lzo_uint; - typedef long long lzo_int; -# endif -# define LZO_UINT_MAX 0xffffffffffffffffull -# define LZO_INT_MAX 9223372036854775807LL -# define LZO_INT_MIN (-1LL - LZO_INT_MAX) -# elif defined(LZO_ABI_IP32L64) /* MIPS R5900 */ - typedef unsigned int lzo_uint; - typedef int lzo_int; -# define LZO_UINT_MAX UINT_MAX -# define LZO_INT_MAX INT_MAX -# define LZO_INT_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint; - typedef long lzo_int; -# define LZO_UINT_MAX ULONG_MAX -# define LZO_INT_MAX LONG_MAX -# define LZO_INT_MIN LONG_MIN -# else -# error "lzo_uint" -# endif -#endif - -/* Integral types with 32 bits or more. */ -#if !defined(LZO_UINT32_MAX) -# if (UINT_MAX >= LZO_0xffffffffL) - typedef unsigned int lzo_uint32; - typedef int lzo_int32; -# define LZO_UINT32_MAX UINT_MAX -# define LZO_INT32_MAX INT_MAX -# define LZO_INT32_MIN INT_MIN -# elif (ULONG_MAX >= LZO_0xffffffffL) - typedef unsigned long lzo_uint32; - typedef long lzo_int32; -# define LZO_UINT32_MAX ULONG_MAX -# define LZO_INT32_MAX LONG_MAX -# define LZO_INT32_MIN LONG_MIN -# else -# error "lzo_uint32" -# endif -#endif - -/* Integral types with exactly 64 bits. */ -#if !defined(LZO_UINT64_MAX) -# if (LZO_UINT_MAX >= LZO_0xffffffffL) -# if ((((LZO_UINT_MAX) >> 31) >> 31) == 3) -# define lzo_uint64 lzo_uint -# define lzo_int64 lzo_int -# define LZO_UINT64_MAX LZO_UINT_MAX -# define LZO_INT64_MAX LZO_INT_MAX -# define LZO_INT64_MIN LZO_INT_MIN -# endif -# elif (ULONG_MAX >= LZO_0xffffffffL) -# if ((((ULONG_MAX) >> 31) >> 31) == 3) - typedef unsigned long lzo_uint64; - typedef long lzo_int64; -# define LZO_UINT64_MAX ULONG_MAX -# define LZO_INT64_MAX LONG_MAX -# define LZO_INT64_MIN LONG_MIN -# endif -# endif -#endif - -/* The larger type of lzo_uint and lzo_uint32. */ -#if (LZO_UINT_MAX >= LZO_UINT32_MAX) -# define lzo_xint lzo_uint -#else -# define lzo_xint lzo_uint32 -#endif - -/* Memory model that allows to access memory at offsets of lzo_uint. */ -#if !defined(__LZO_MMODEL) -# if (LZO_UINT_MAX <= UINT_MAX) -# define __LZO_MMODEL /*empty*/ -# elif defined(LZO_HAVE_MM_HUGE_PTR) -# define __LZO_MMODEL_HUGE 1 -# define __LZO_MMODEL __huge -# else -# define __LZO_MMODEL /*empty*/ -# endif -#endif - -/* no typedef here because of const-pointer issues */ -#define lzo_bytep unsigned char __LZO_MMODEL * -#define lzo_charp char __LZO_MMODEL * -#define lzo_voidp void __LZO_MMODEL * -#define lzo_shortp short __LZO_MMODEL * -#define lzo_ushortp unsigned short __LZO_MMODEL * -#define lzo_uint32p lzo_uint32 __LZO_MMODEL * -#define lzo_int32p lzo_int32 __LZO_MMODEL * -#if defined(LZO_UINT64_MAX) -#define lzo_uint64p lzo_uint64 __LZO_MMODEL * -#define lzo_int64p lzo_int64 __LZO_MMODEL * -#endif -#define lzo_uintp lzo_uint __LZO_MMODEL * -#define lzo_intp lzo_int __LZO_MMODEL * -#define lzo_xintp lzo_xint __LZO_MMODEL * -#define lzo_voidpp lzo_voidp __LZO_MMODEL * -#define lzo_bytepp lzo_bytep __LZO_MMODEL * -/* deprecated - use 'lzo_bytep' instead of 'lzo_byte *' */ -#define lzo_byte unsigned char __LZO_MMODEL - -typedef int lzo_bool; - - -/*********************************************************************** -// function types -************************************************************************/ - -/* name mangling */ -#if !defined(__LZO_EXTERN_C) -# ifdef __cplusplus -# define __LZO_EXTERN_C extern "C" -# else -# define __LZO_EXTERN_C extern -# endif -#endif - -/* calling convention */ -#if !defined(__LZO_CDECL) -# define __LZO_CDECL __lzo_cdecl -#endif - -/* DLL export information */ -#if !defined(__LZO_EXPORT1) -# define __LZO_EXPORT1 /*empty*/ -#endif -#if !defined(__LZO_EXPORT2) -# define __LZO_EXPORT2 /*empty*/ -#endif - -/* __cdecl calling convention for public C and assembly functions */ -#if !defined(LZO_PUBLIC) -# define LZO_PUBLIC(_rettype) __LZO_EXPORT1 _rettype __LZO_EXPORT2 __LZO_CDECL -#endif -#if !defined(LZO_EXTERN) -# define LZO_EXTERN(_rettype) __LZO_EXTERN_C LZO_PUBLIC(_rettype) -#endif -#if !defined(LZO_PRIVATE) -# define LZO_PRIVATE(_rettype) static _rettype __LZO_CDECL -#endif - -/* function types */ -typedef int -(__LZO_CDECL *lzo_compress_t) ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_CDECL *lzo_decompress_t) ( const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_CDECL *lzo_optimize_t) ( lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem ); - -typedef int -(__LZO_CDECL *lzo_compress_dict_t)(const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - -typedef int -(__LZO_CDECL *lzo_decompress_dict_t)(const lzo_bytep src, lzo_uint src_len, - lzo_bytep dst, lzo_uintp dst_len, - lzo_voidp wrkmem, - const lzo_bytep dict, lzo_uint dict_len ); - - -/* Callback interface. Currently only the progress indicator ("nprogress") - * is used, but this may change in a future release. */ - -struct lzo_callback_t; -typedef struct lzo_callback_t lzo_callback_t; -#define lzo_callback_p lzo_callback_t __LZO_MMODEL * - -/* malloc & free function types */ -typedef lzo_voidp (__LZO_CDECL *lzo_alloc_func_t) - (lzo_callback_p self, lzo_uint items, lzo_uint size); -typedef void (__LZO_CDECL *lzo_free_func_t) - (lzo_callback_p self, lzo_voidp ptr); - -/* a progress indicator callback function */ -typedef void (__LZO_CDECL *lzo_progress_func_t) - (lzo_callback_p, lzo_uint, lzo_uint, int); - -struct lzo_callback_t -{ - /* custom allocators (set to 0 to disable) */ - lzo_alloc_func_t nalloc; /* [not used right now] */ - lzo_free_func_t nfree; /* [not used right now] */ - - /* a progress indicator callback function (set to 0 to disable) */ - lzo_progress_func_t nprogress; - - /* NOTE: the first parameter "self" of the nalloc/nfree/nprogress - * callbacks points back to this struct, so you are free to store - * some extra info in the following variables. */ - lzo_voidp user1; - lzo_xint user2; - lzo_xint user3; -}; - - -/*********************************************************************** -// error codes and prototypes -************************************************************************/ - -/* Error codes for the compression/decompression functions. Negative - * values are errors, positive values will be used for special but - * normal events. - */ -#define LZO_E_OK 0 -#define LZO_E_ERROR (-1) -#define LZO_E_OUT_OF_MEMORY (-2) /* [lzo_alloc_func_t failure] */ -#define LZO_E_NOT_COMPRESSIBLE (-3) /* [not used right now] */ -#define LZO_E_INPUT_OVERRUN (-4) -#define LZO_E_OUTPUT_OVERRUN (-5) -#define LZO_E_LOOKBEHIND_OVERRUN (-6) -#define LZO_E_EOF_NOT_FOUND (-7) -#define LZO_E_INPUT_NOT_CONSUMED (-8) -#define LZO_E_NOT_YET_IMPLEMENTED (-9) /* [not used right now] */ -#define LZO_E_INVALID_ARGUMENT (-10) - - -#ifndef lzo_sizeof_dict_t -# define lzo_sizeof_dict_t ((unsigned)sizeof(lzo_bytep)) -#endif - -/* lzo_init() should be the first function you call. - * Check the return code ! - * - * lzo_init() is a macro to allow checking that the library and the - * compiler's view of various types are consistent. - */ -#define lzo_init() __lzo_init_v2(LZO_VERSION,(int)sizeof(short),(int)sizeof(int),\ - (int)sizeof(long),(int)sizeof(lzo_uint32),(int)sizeof(lzo_uint),\ - (int)lzo_sizeof_dict_t,(int)sizeof(char *),(int)sizeof(lzo_voidp),\ - (int)sizeof(lzo_callback_t)) -LZO_EXTERN(int) __lzo_init_v2(unsigned,int,int,int,int,int,int,int,int,int); - -/* version functions (useful for shared libraries) */ -LZO_EXTERN(unsigned) lzo_version(void); -LZO_EXTERN(const char *) lzo_version_string(void); -LZO_EXTERN(const char *) lzo_version_date(void); -LZO_EXTERN(const lzo_charp) _lzo_version_string(void); -LZO_EXTERN(const lzo_charp) _lzo_version_date(void); - -/* string functions */ -LZO_EXTERN(int) - lzo_memcmp(const lzo_voidp a, const lzo_voidp b, lzo_uint len); -LZO_EXTERN(lzo_voidp) - lzo_memcpy(lzo_voidp dst, const lzo_voidp src, lzo_uint len); -LZO_EXTERN(lzo_voidp) - lzo_memmove(lzo_voidp dst, const lzo_voidp src, lzo_uint len); -LZO_EXTERN(lzo_voidp) - lzo_memset(lzo_voidp buf, int c, lzo_uint len); - -/* checksum functions */ -LZO_EXTERN(lzo_uint32) - lzo_adler32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); -LZO_EXTERN(lzo_uint32) - lzo_crc32(lzo_uint32 c, const lzo_bytep buf, lzo_uint len); -LZO_EXTERN(const lzo_uint32p) - lzo_get_crc32_table(void); - -/* misc. */ -LZO_EXTERN(int) _lzo_config_check(void); -typedef union { lzo_bytep p; lzo_uint u; } __lzo_pu_u; -typedef union { lzo_bytep p; lzo_uint32 u32; } __lzo_pu32_u; -typedef union { void *vp; lzo_bytep bp; lzo_uint u; lzo_uint32 u32; unsigned long l; } lzo_align_t; - -/* align a char pointer on a boundary that is a multiple of 'size' */ -LZO_EXTERN(unsigned) __lzo_align_gap(const lzo_voidp p, lzo_uint size); -#define LZO_PTR_ALIGN_UP(p,size) \ - ((p) + (lzo_uint) __lzo_align_gap((const lzo_voidp)(p),(lzo_uint)(size))) - - -/*********************************************************************** -// deprecated macros - only for backward compatibility with LZO v1.xx -************************************************************************/ - -#if defined(LZO_CFG_COMPAT) - -#define __LZOCONF_H 1 - -#if defined(LZO_ARCH_I086) -# define __LZO_i386 1 -#elif defined(LZO_ARCH_I386) -# define __LZO_i386 1 -#endif - -#if defined(LZO_OS_DOS16) -# define __LZO_DOS 1 -# define __LZO_DOS16 1 -#elif defined(LZO_OS_DOS32) -# define __LZO_DOS 1 -#elif defined(LZO_OS_WIN16) -# define __LZO_WIN 1 -# define __LZO_WIN16 1 -#elif defined(LZO_OS_WIN32) -# define __LZO_WIN 1 -#endif - -#define __LZO_CMODEL /*empty*/ -#define __LZO_DMODEL /*empty*/ -#define __LZO_ENTRY __LZO_CDECL -#define LZO_EXTERN_CDECL LZO_EXTERN -#define LZO_ALIGN LZO_PTR_ALIGN_UP - -#define lzo_compress_asm_t lzo_compress_t -#define lzo_decompress_asm_t lzo_decompress_t - -#endif /* LZO_CFG_COMPAT */ - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzodefs.h b/maclibs/include/lzo/lzodefs.h deleted file mode 100644 index 0e40e332..00000000 --- a/maclibs/include/lzo/lzodefs.h +++ /dev/null @@ -1,1852 +0,0 @@ -/* lzodefs.h -- architecture, OS and compiler specific defines - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZODEFS_H_INCLUDED -#define __LZODEFS_H_INCLUDED 1 - -#if defined(__CYGWIN32__) && !defined(__CYGWIN__) -# define __CYGWIN__ __CYGWIN32__ -#endif -#if defined(__IBMCPP__) && !defined(__IBMC__) -# define __IBMC__ __IBMCPP__ -#endif -#if defined(__ICL) && defined(_WIN32) && !defined(__INTEL_COMPILER) -# define __INTEL_COMPILER __ICL -#endif -#if 1 && defined(__INTERIX) && defined(__GNUC__) && !defined(_ALL_SOURCE) -# define _ALL_SOURCE 1 -#endif -#if defined(__mips__) && defined(__R5900__) -# if !defined(__LONG_MAX__) -# define __LONG_MAX__ 9223372036854775807L -# endif -#endif -#if defined(__INTEL_COMPILER) && defined(__linux__) -# pragma warning(disable: 193) -#endif -#if defined(__KEIL__) && defined(__C166__) -# pragma warning disable = 322 -#elif 0 && defined(__C251__) -# pragma warning disable = 322 -#endif -#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__MWERKS__) -# if (_MSC_VER >= 1300) -# pragma warning(disable: 4668) -# endif -#endif -#if 0 && defined(__WATCOMC__) -# if (__WATCOMC__ >= 1050) && (__WATCOMC__ < 1060) -# pragma warning 203 9 -# endif -#endif -#if defined(__BORLANDC__) && defined(__MSDOS__) && !defined(__FLAT__) -# pragma option -h -#endif -#if 0 -#define LZO_0xffffL 0xfffful -#define LZO_0xffffffffL 0xfffffffful -#else -#define LZO_0xffffL 65535ul -#define LZO_0xffffffffL 4294967295ul -#endif -#if (LZO_0xffffL == LZO_0xffffffffL) -# error "your preprocessor is broken 1" -#endif -#if (16ul * 16384ul != 262144ul) -# error "your preprocessor is broken 2" -#endif -#if 0 -#if (32767 >= 4294967295ul) -# error "your preprocessor is broken 3" -#endif -#if (65535u >= 4294967295ul) -# error "your preprocessor is broken 4" -#endif -#endif -#if (UINT_MAX == LZO_0xffffL) -#if defined(__ZTC__) && defined(__I86__) && !defined(__OS2__) -# if !defined(MSDOS) -# define MSDOS 1 -# endif -# if !defined(_MSDOS) -# define _MSDOS 1 -# endif -#elif 0 && defined(__VERSION) && defined(MB_LEN_MAX) -# if (__VERSION == 520) && (MB_LEN_MAX == 1) -# if !defined(__AZTEC_C__) -# define __AZTEC_C__ __VERSION -# endif -# if !defined(__DOS__) -# define __DOS__ 1 -# endif -# endif -#endif -#endif -#if defined(_MSC_VER) && defined(M_I86HM) && (UINT_MAX == LZO_0xffffL) -# define ptrdiff_t long -# define _PTRDIFF_T_DEFINED 1 -#endif -#if (UINT_MAX == LZO_0xffffL) -# undef __LZO_RENAME_A -# undef __LZO_RENAME_B -# if defined(__AZTEC_C__) && defined(__DOS__) -# define __LZO_RENAME_A 1 -# elif defined(_MSC_VER) && defined(MSDOS) -# if (_MSC_VER < 600) -# define __LZO_RENAME_A 1 -# elif (_MSC_VER < 700) -# define __LZO_RENAME_B 1 -# endif -# elif defined(__TSC__) && defined(__OS2__) -# define __LZO_RENAME_A 1 -# elif defined(__MSDOS__) && defined(__TURBOC__) && (__TURBOC__ < 0x0410) -# define __LZO_RENAME_A 1 -# elif defined(__PACIFIC__) && defined(DOS) -# if !defined(__far) -# define __far far -# endif -# if !defined(__near) -# define __near near -# endif -# endif -# if defined(__LZO_RENAME_A) -# if !defined(__cdecl) -# define __cdecl cdecl -# endif -# if !defined(__far) -# define __far far -# endif -# if !defined(__huge) -# define __huge huge -# endif -# if !defined(__near) -# define __near near -# endif -# if !defined(__pascal) -# define __pascal pascal -# endif -# if !defined(__huge) -# define __huge huge -# endif -# elif defined(__LZO_RENAME_B) -# if !defined(__cdecl) -# define __cdecl _cdecl -# endif -# if !defined(__far) -# define __far _far -# endif -# if !defined(__huge) -# define __huge _huge -# endif -# if !defined(__near) -# define __near _near -# endif -# if !defined(__pascal) -# define __pascal _pascal -# endif -# elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) -# if !defined(__cdecl) -# define __cdecl cdecl -# endif -# if !defined(__pascal) -# define __pascal pascal -# endif -# endif -# undef __LZO_RENAME_A -# undef __LZO_RENAME_B -#endif -#if (UINT_MAX == LZO_0xffffL) -#if defined(__AZTEC_C__) && defined(__DOS__) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -#elif defined(_MSC_VER) && defined(MSDOS) -# if (_MSC_VER < 600) -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -# endif -# if (_MSC_VER < 700) -# define LZO_BROKEN_INTEGRAL_PROMOTION 1 -# define LZO_BROKEN_SIZEOF 1 -# endif -#elif defined(__PACIFIC__) && defined(DOS) -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -#elif defined(__TURBOC__) && defined(__MSDOS__) -# if (__TURBOC__ < 0x0150) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -# define LZO_BROKEN_INTEGRAL_PROMOTION 1 -# endif -# if (__TURBOC__ < 0x0200) -# define LZO_BROKEN_SIZEOF 1 -# endif -# if (__TURBOC__ < 0x0400) && defined(__cplusplus) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# endif -#elif (defined(__PUREC__) || defined(__TURBOC__)) && defined(__TOS__) -# define LZO_BROKEN_CDECL_ALT_SYNTAX 1 -# define LZO_BROKEN_SIZEOF 1 -#endif -#endif -#if defined(__WATCOMC__) && (__WATCOMC__ < 900) -# define LZO_BROKEN_INTEGRAL_CONSTANTS 1 -#endif -#if defined(_CRAY) && defined(_CRAY1) -# define LZO_BROKEN_SIGNED_RIGHT_SHIFT 1 -#endif -#define LZO_PP_STRINGIZE(x) #x -#define LZO_PP_MACRO_EXPAND(x) LZO_PP_STRINGIZE(x) -#define LZO_PP_CONCAT2(a,b) a ## b -#define LZO_PP_CONCAT3(a,b,c) a ## b ## c -#define LZO_PP_CONCAT4(a,b,c,d) a ## b ## c ## d -#define LZO_PP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -#define LZO_PP_ECONCAT2(a,b) LZO_PP_CONCAT2(a,b) -#define LZO_PP_ECONCAT3(a,b,c) LZO_PP_CONCAT3(a,b,c) -#define LZO_PP_ECONCAT4(a,b,c,d) LZO_PP_CONCAT4(a,b,c,d) -#define LZO_PP_ECONCAT5(a,b,c,d,e) LZO_PP_CONCAT5(a,b,c,d,e) -#if 1 -#define LZO_CPP_STRINGIZE(x) #x -#define LZO_CPP_MACRO_EXPAND(x) LZO_CPP_STRINGIZE(x) -#define LZO_CPP_CONCAT2(a,b) a ## b -#define LZO_CPP_CONCAT3(a,b,c) a ## b ## c -#define LZO_CPP_CONCAT4(a,b,c,d) a ## b ## c ## d -#define LZO_CPP_CONCAT5(a,b,c,d,e) a ## b ## c ## d ## e -#define LZO_CPP_ECONCAT2(a,b) LZO_CPP_CONCAT2(a,b) -#define LZO_CPP_ECONCAT3(a,b,c) LZO_CPP_CONCAT3(a,b,c) -#define LZO_CPP_ECONCAT4(a,b,c,d) LZO_CPP_CONCAT4(a,b,c,d) -#define LZO_CPP_ECONCAT5(a,b,c,d,e) LZO_CPP_CONCAT5(a,b,c,d,e) -#endif -#define __LZO_MASK_GEN(o,b) (((((o) << ((b)-1)) - (o)) << 1) + (o)) -#if 1 && defined(__cplusplus) -# if !defined(__STDC_CONSTANT_MACROS) -# define __STDC_CONSTANT_MACROS 1 -# endif -# if !defined(__STDC_LIMIT_MACROS) -# define __STDC_LIMIT_MACROS 1 -# endif -#endif -#if defined(__cplusplus) -# define LZO_EXTERN_C extern "C" -#else -# define LZO_EXTERN_C extern -#endif -#if !defined(__LZO_OS_OVERRIDE) -#if (LZO_OS_FREESTANDING) -# define LZO_INFO_OS "freestanding" -#elif (LZO_OS_EMBEDDED) -# define LZO_INFO_OS "embedded" -#elif 1 && defined(__IAR_SYSTEMS_ICC__) -# define LZO_OS_EMBEDDED 1 -# define LZO_INFO_OS "embedded" -#elif defined(__CYGWIN__) && defined(__GNUC__) -# define LZO_OS_CYGWIN 1 -# define LZO_INFO_OS "cygwin" -#elif defined(__EMX__) && defined(__GNUC__) -# define LZO_OS_EMX 1 -# define LZO_INFO_OS "emx" -#elif defined(__BEOS__) -# define LZO_OS_BEOS 1 -# define LZO_INFO_OS "beos" -#elif defined(__Lynx__) -# define LZO_OS_LYNXOS 1 -# define LZO_INFO_OS "lynxos" -#elif defined(__OS400__) -# define LZO_OS_OS400 1 -# define LZO_INFO_OS "os400" -#elif defined(__QNX__) -# define LZO_OS_QNX 1 -# define LZO_INFO_OS "qnx" -#elif defined(__BORLANDC__) && defined(__DPMI32__) && (__BORLANDC__ >= 0x0460) -# define LZO_OS_DOS32 1 -# define LZO_INFO_OS "dos32" -#elif defined(__BORLANDC__) && defined(__DPMI16__) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" -#elif defined(__ZTC__) && defined(DOS386) -# define LZO_OS_DOS32 1 -# define LZO_INFO_OS "dos32" -#elif defined(__OS2__) || defined(__OS2V2__) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_OS216 1 -# define LZO_INFO_OS "os216" -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_OS_OS2 1 -# define LZO_INFO_OS "os2" -# else -# error "check your limits.h header" -# endif -#elif defined(__WIN64__) || defined(_WIN64) || defined(WIN64) -# define LZO_OS_WIN64 1 -# define LZO_INFO_OS "win64" -#elif defined(__WIN32__) || defined(_WIN32) || defined(WIN32) || defined(__WINDOWS_386__) -# define LZO_OS_WIN32 1 -# define LZO_INFO_OS "win32" -#elif defined(__MWERKS__) && defined(__INTEL__) -# define LZO_OS_WIN32 1 -# define LZO_INFO_OS "win32" -#elif defined(__WINDOWS__) || defined(_WINDOWS) || defined(_Windows) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_WIN16 1 -# define LZO_INFO_OS "win16" -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_OS_WIN32 1 -# define LZO_INFO_OS "win32" -# else -# error "check your limits.h header" -# endif -#elif defined(__DOS__) || defined(__MSDOS__) || defined(_MSDOS) || defined(MSDOS) || (defined(__PACIFIC__) && defined(DOS)) -# if (UINT_MAX == LZO_0xffffL) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_OS_DOS32 1 -# define LZO_INFO_OS "dos32" -# else -# error "check your limits.h header" -# endif -#elif defined(__WATCOMC__) -# if defined(__NT__) && (UINT_MAX == LZO_0xffffL) -# define LZO_OS_DOS16 1 -# define LZO_INFO_OS "dos16" -# elif defined(__NT__) && (__WATCOMC__ < 1100) -# define LZO_OS_WIN32 1 -# define LZO_INFO_OS "win32" -# elif defined(__linux__) || defined(__LINUX__) -# define LZO_OS_POSIX 1 -# define LZO_INFO_OS "posix" -# else -# error "please specify a target using the -bt compiler option" -# endif -#elif defined(__palmos__) -# define LZO_OS_PALMOS 1 -# define LZO_INFO_OS "palmos" -#elif defined(__TOS__) || defined(__atarist__) -# define LZO_OS_TOS 1 -# define LZO_INFO_OS "tos" -#elif defined(macintosh) && !defined(__ppc__) -# define LZO_OS_MACCLASSIC 1 -# define LZO_INFO_OS "macclassic" -#elif defined(__VMS) -# define LZO_OS_VMS 1 -# define LZO_INFO_OS "vms" -#elif ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -# define LZO_OS_CONSOLE 1 -# define LZO_OS_CONSOLE_PS2 1 -# define LZO_INFO_OS "console" -# define LZO_INFO_OS_CONSOLE "ps2" -#elif (defined(__mips__) && defined(__psp__)) -# define LZO_OS_CONSOLE 1 -# define LZO_OS_CONSOLE_PSP 1 -# define LZO_INFO_OS "console" -# define LZO_INFO_OS_CONSOLE "psp" -#else -# define LZO_OS_POSIX 1 -# define LZO_INFO_OS "posix" -#endif -#if (LZO_OS_POSIX) -# if defined(_AIX) || defined(__AIX__) || defined(__aix__) -# define LZO_OS_POSIX_AIX 1 -# define LZO_INFO_OS_POSIX "aix" -# elif defined(__FreeBSD__) -# define LZO_OS_POSIX_FREEBSD 1 -# define LZO_INFO_OS_POSIX "freebsd" -# elif defined(__hpux__) || defined(__hpux) -# define LZO_OS_POSIX_HPUX 1 -# define LZO_INFO_OS_POSIX "hpux" -# elif defined(__INTERIX) -# define LZO_OS_POSIX_INTERIX 1 -# define LZO_INFO_OS_POSIX "interix" -# elif defined(__IRIX__) || defined(__irix__) -# define LZO_OS_POSIX_IRIX 1 -# define LZO_INFO_OS_POSIX "irix" -# elif defined(__linux__) || defined(__linux) || defined(__LINUX__) -# define LZO_OS_POSIX_LINUX 1 -# define LZO_INFO_OS_POSIX "linux" -# elif defined(__APPLE__) || defined(__MACOS__) -# define LZO_OS_POSIX_MACOSX 1 -# define LZO_INFO_OS_POSIX "macosx" -# elif defined(__minix__) || defined(__minix) -# define LZO_OS_POSIX_MINIX 1 -# define LZO_INFO_OS_POSIX "minix" -# elif defined(__NetBSD__) -# define LZO_OS_POSIX_NETBSD 1 -# define LZO_INFO_OS_POSIX "netbsd" -# elif defined(__OpenBSD__) -# define LZO_OS_POSIX_OPENBSD 1 -# define LZO_INFO_OS_POSIX "openbsd" -# elif defined(__osf__) -# define LZO_OS_POSIX_OSF 1 -# define LZO_INFO_OS_POSIX "osf" -# elif defined(__solaris__) || defined(__sun) -# if defined(__SVR4) || defined(__svr4__) -# define LZO_OS_POSIX_SOLARIS 1 -# define LZO_INFO_OS_POSIX "solaris" -# else -# define LZO_OS_POSIX_SUNOS 1 -# define LZO_INFO_OS_POSIX "sunos" -# endif -# elif defined(__ultrix__) || defined(__ultrix) -# define LZO_OS_POSIX_ULTRIX 1 -# define LZO_INFO_OS_POSIX "ultrix" -# elif defined(_UNICOS) -# define LZO_OS_POSIX_UNICOS 1 -# define LZO_INFO_OS_POSIX "unicos" -# else -# define LZO_OS_POSIX_UNKNOWN 1 -# define LZO_INFO_OS_POSIX "unknown" -# endif -#endif -#endif -#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -# if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif -#if (LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_WIN32 || LZO_OS_WIN64) -# if (UINT_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif -#if defined(CIL) && defined(_GNUCC) && defined(__GNUC__) -# define LZO_CC_CILLY 1 -# define LZO_INFO_CC "Cilly" -# if defined(__CILLY__) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CILLY__) -# else -# define LZO_INFO_CCVER "unknown" -# endif -#elif 0 && defined(SDCC) && defined(__VERSION__) && !defined(__GNUC__) -# define LZO_CC_SDCC 1 -# define LZO_INFO_CC "sdcc" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(SDCC) -#elif defined(__PATHSCALE__) && defined(__PATHCC_PATCHLEVEL__) -# define LZO_CC_PATHSCALE (__PATHCC__ * 0x10000L + __PATHCC_MINOR__ * 0x100 + __PATHCC_PATCHLEVEL__) -# define LZO_INFO_CC "Pathscale C" -# define LZO_INFO_CCVER __PATHSCALE__ -#elif defined(__INTEL_COMPILER) -# define LZO_CC_INTELC 1 -# define LZO_INFO_CC "Intel C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__INTEL_COMPILER) -# if defined(_WIN32) || defined(_WIN64) -# define LZO_CC_SYNTAX_MSC 1 -# else -# define LZO_CC_SYNTAX_GNUC 1 -# endif -#elif defined(__POCC__) && defined(_WIN32) -# define LZO_CC_PELLESC 1 -# define LZO_INFO_CC "Pelles C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__POCC__) -#elif defined(__clang__) && defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -# if defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -# else -# define LZO_CC_CLANG_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -# endif -# if defined(__clang_major__) && defined(__clang_minor__) && defined(__clang_patchlevel__) -# define LZO_CC_CLANG_CLANG (__clang_major__ * 0x10000L + __clang_minor__ * 0x100 + __clang_patchlevel__) -# else -# define LZO_CC_CLANG_CLANG 0x010000L -# endif -# define LZO_CC_CLANG LZO_CC_CLANG_GNUC -# define LZO_INFO_CC "clang" -# define LZO_INFO_CCVER __VERSION__ -#elif defined(__llvm__) && defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__VERSION__) -# if defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -# else -# define LZO_CC_LLVM_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -# endif -# define LZO_CC_LLVM LZO_CC_LLVM_GNUC -# define LZO_INFO_CC "llvm-gcc" -# define LZO_INFO_CCVER __VERSION__ -#elif defined(__GNUC__) && defined(__VERSION__) -# if defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100 + __GNUC_PATCHLEVEL__) -# elif defined(__GNUC_MINOR__) -# define LZO_CC_GNUC (__GNUC__ * 0x10000L + __GNUC_MINOR__ * 0x100) -# else -# define LZO_CC_GNUC (__GNUC__ * 0x10000L) -# endif -# define LZO_INFO_CC "gcc" -# define LZO_INFO_CCVER __VERSION__ -#elif defined(__ACK__) && defined(_ACK) -# define LZO_CC_ACK 1 -# define LZO_INFO_CC "Amsterdam Compiler Kit C" -# define LZO_INFO_CCVER "unknown" -#elif defined(__AZTEC_C__) -# define LZO_CC_AZTECC 1 -# define LZO_INFO_CC "Aztec C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__AZTEC_C__) -#elif defined(__CODEGEARC__) -# define LZO_CC_CODEGEARC 1 -# define LZO_INFO_CC "CodeGear C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__CODEGEARC__) -#elif defined(__BORLANDC__) -# define LZO_CC_BORLANDC 1 -# define LZO_INFO_CC "Borland C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__BORLANDC__) -#elif defined(_CRAYC) && defined(_RELEASE) -# define LZO_CC_CRAYC 1 -# define LZO_INFO_CC "Cray C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_RELEASE) -#elif defined(__DMC__) && defined(__SC__) -# define LZO_CC_DMC 1 -# define LZO_INFO_CC "Digital Mars C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DMC__) -#elif defined(__DECC) -# define LZO_CC_DECC 1 -# define LZO_INFO_CC "DEC C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__DECC) -#elif defined(__HIGHC__) -# define LZO_CC_HIGHC 1 -# define LZO_INFO_CC "MetaWare High C" -# define LZO_INFO_CCVER "unknown" -#elif defined(__IAR_SYSTEMS_ICC__) -# define LZO_CC_IARC 1 -# define LZO_INFO_CC "IAR C" -# if defined(__VER__) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__VER__) -# else -# define LZO_INFO_CCVER "unknown" -# endif -#elif defined(__IBMC__) -# define LZO_CC_IBMC 1 -# define LZO_INFO_CC "IBM C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__IBMC__) -#elif defined(__KEIL__) && defined(__C166__) -# define LZO_CC_KEILC 1 -# define LZO_INFO_CC "Keil C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__C166__) -#elif defined(__LCC__) && defined(_WIN32) && defined(__LCCOPTIMLEVEL) -# define LZO_CC_LCCWIN32 1 -# define LZO_INFO_CC "lcc-win32" -# define LZO_INFO_CCVER "unknown" -#elif defined(__LCC__) -# define LZO_CC_LCC 1 -# define LZO_INFO_CC "lcc" -# if defined(__LCC_VERSION__) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__LCC_VERSION__) -# else -# define LZO_INFO_CCVER "unknown" -# endif -#elif defined(_MSC_VER) -# define LZO_CC_MSC 1 -# define LZO_INFO_CC "Microsoft C" -# if defined(_MSC_FULL_VER) -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) "." LZO_PP_MACRO_EXPAND(_MSC_FULL_VER) -# else -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(_MSC_VER) -# endif -#elif defined(__MWERKS__) -# define LZO_CC_MWERKS 1 -# define LZO_INFO_CC "Metrowerks C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__MWERKS__) -#elif (defined(__NDPC__) || defined(__NDPX__)) && defined(__i386) -# define LZO_CC_NDPC 1 -# define LZO_INFO_CC "Microway NDP C" -# define LZO_INFO_CCVER "unknown" -#elif defined(__PACIFIC__) -# define LZO_CC_PACIFICC 1 -# define LZO_INFO_CC "Pacific C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PACIFIC__) -#elif defined(__PGI) && (defined(__linux__) || defined(__WIN32__)) -# define LZO_CC_PGI 1 -# define LZO_INFO_CC "Portland Group PGI C" -# define LZO_INFO_CCVER "unknown" -#elif defined(__PUREC__) && defined(__TOS__) -# define LZO_CC_PUREC 1 -# define LZO_INFO_CC "Pure C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__PUREC__) -#elif defined(__SC__) && defined(__ZTC__) -# define LZO_CC_SYMANTECC 1 -# define LZO_INFO_CC "Symantec C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SC__) -#elif defined(__SUNPRO_C) -# define LZO_INFO_CC "SunPro C" -# if ((__SUNPRO_C)+0 > 0) -# define LZO_CC_SUNPROC __SUNPRO_C -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_C) -# else -# define LZO_CC_SUNPROC 1 -# define LZO_INFO_CCVER "unknown" -# endif -#elif defined(__SUNPRO_CC) -# define LZO_INFO_CC "SunPro C" -# if ((__SUNPRO_CC)+0 > 0) -# define LZO_CC_SUNPROC __SUNPRO_CC -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__SUNPRO_CC) -# else -# define LZO_CC_SUNPROC 1 -# define LZO_INFO_CCVER "unknown" -# endif -#elif defined(__TINYC__) -# define LZO_CC_TINYC 1 -# define LZO_INFO_CC "Tiny C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TINYC__) -#elif defined(__TSC__) -# define LZO_CC_TOPSPEEDC 1 -# define LZO_INFO_CC "TopSpeed C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TSC__) -#elif defined(__WATCOMC__) -# define LZO_CC_WATCOMC 1 -# define LZO_INFO_CC "Watcom C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__WATCOMC__) -#elif defined(__TURBOC__) -# define LZO_CC_TURBOC 1 -# define LZO_INFO_CC "Turbo C" -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__TURBOC__) -#elif defined(__ZTC__) -# define LZO_CC_ZORTECHC 1 -# define LZO_INFO_CC "Zortech C" -# if (__ZTC__ == 0x310) -# define LZO_INFO_CCVER "0x310" -# else -# define LZO_INFO_CCVER LZO_PP_MACRO_EXPAND(__ZTC__) -# endif -#else -# define LZO_CC_UNKNOWN 1 -# define LZO_INFO_CC "unknown" -# define LZO_INFO_CCVER "unknown" -#endif -#if 0 && (LZO_CC_MSC && (_MSC_VER >= 1200)) && !defined(_MSC_FULL_VER) -# error "LZO_CC_MSC: _MSC_FULL_VER is not defined" -#endif -#if !defined(__LZO_ARCH_OVERRIDE) && !(LZO_ARCH_GENERIC) && defined(_CRAY) -# if (UINT_MAX > LZO_0xffffffffL) && defined(_CRAY) -# if defined(_CRAYMPP) || defined(_CRAYT3D) || defined(_CRAYT3E) -# define LZO_ARCH_CRAY_MPP 1 -# elif defined(_CRAY1) -# define LZO_ARCH_CRAY_PVP 1 -# endif -# endif -#endif -#if !defined(__LZO_ARCH_OVERRIDE) -#if (LZO_ARCH_GENERIC) -# define LZO_INFO_ARCH "generic" -#elif (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -# define LZO_ARCH_I086 1 -# define LZO_ARCH_IA16 1 -# define LZO_INFO_ARCH "i086" -#elif defined(__alpha__) || defined(__alpha) || defined(_M_ALPHA) -# define LZO_ARCH_ALPHA 1 -# define LZO_INFO_ARCH "alpha" -#elif (LZO_ARCH_CRAY_MPP) && (defined(_CRAYT3D) || defined(_CRAYT3E)) -# define LZO_ARCH_ALPHA 1 -# define LZO_INFO_ARCH "alpha" -#elif defined(__amd64__) || defined(__x86_64__) || defined(_M_AMD64) -# define LZO_ARCH_AMD64 1 -# define LZO_INFO_ARCH "amd64" -#elif defined(__thumb__) || (defined(_M_ARM) && defined(_M_THUMB)) -# define LZO_ARCH_ARM 1 -# define LZO_ARCH_ARM_THUMB 1 -# define LZO_INFO_ARCH "arm_thumb" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCARM__) -# define LZO_ARCH_ARM 1 -# if defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 1) -# define LZO_ARCH_ARM_THUMB 1 -# define LZO_INFO_ARCH "arm_thumb" -# elif defined(__CPU_MODE__) && ((__CPU_MODE__)+0 == 2) -# define LZO_INFO_ARCH "arm" -# else -# define LZO_INFO_ARCH "arm" -# endif -#elif defined(__arm__) || defined(_M_ARM) -# define LZO_ARCH_ARM 1 -# define LZO_INFO_ARCH "arm" -#elif (UINT_MAX <= LZO_0xffffL) && defined(__AVR__) -# define LZO_ARCH_AVR 1 -# define LZO_INFO_ARCH "avr" -#elif defined(__avr32__) || defined(__AVR32__) -# define LZO_ARCH_AVR32 1 -# define LZO_INFO_ARCH "avr32" -#elif defined(__bfin__) -# define LZO_ARCH_BLACKFIN 1 -# define LZO_INFO_ARCH "blackfin" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C166__) -# define LZO_ARCH_C166 1 -# define LZO_INFO_ARCH "c166" -#elif defined(__cris__) -# define LZO_ARCH_CRIS 1 -# define LZO_INFO_ARCH "cris" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCEZ80__) -# define LZO_ARCH_EZ80 1 -# define LZO_INFO_ARCH "ez80" -#elif defined(__H8300__) || defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -# define LZO_ARCH_H8300 1 -# define LZO_INFO_ARCH "h8300" -#elif defined(__hppa__) || defined(__hppa) -# define LZO_ARCH_HPPA 1 -# define LZO_INFO_ARCH "hppa" -#elif defined(__386__) || defined(__i386__) || defined(__i386) || defined(_M_IX86) || defined(_M_I386) -# define LZO_ARCH_I386 1 -# define LZO_ARCH_IA32 1 -# define LZO_INFO_ARCH "i386" -#elif (LZO_CC_ZORTECHC && defined(__I86__)) -# define LZO_ARCH_I386 1 -# define LZO_ARCH_IA32 1 -# define LZO_INFO_ARCH "i386" -#elif (LZO_OS_DOS32 && LZO_CC_HIGHC) && defined(_I386) -# define LZO_ARCH_I386 1 -# define LZO_ARCH_IA32 1 -# define LZO_INFO_ARCH "i386" -#elif defined(__ia64__) || defined(__ia64) || defined(_M_IA64) -# define LZO_ARCH_IA64 1 -# define LZO_INFO_ARCH "ia64" -#elif (UINT_MAX == LZO_0xffffL) && defined(__m32c__) -# define LZO_ARCH_M16C 1 -# define LZO_INFO_ARCH "m16c" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICCM16C__) -# define LZO_ARCH_M16C 1 -# define LZO_INFO_ARCH "m16c" -#elif defined(__m32r__) -# define LZO_ARCH_M32R 1 -# define LZO_INFO_ARCH "m32r" -#elif (LZO_OS_TOS) || defined(__m68k__) || defined(__m68000__) || defined(__mc68000__) || defined(__mc68020__) || defined(_M_M68K) -# define LZO_ARCH_M68K 1 -# define LZO_INFO_ARCH "m68k" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C251__) -# define LZO_ARCH_MCS251 1 -# define LZO_INFO_ARCH "mcs251" -#elif (UINT_MAX == LZO_0xffffL) && defined(__C51__) -# define LZO_ARCH_MCS51 1 -# define LZO_INFO_ARCH "mcs51" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC8051__) -# define LZO_ARCH_MCS51 1 -# define LZO_INFO_ARCH "mcs51" -#elif defined(__mips__) || defined(__mips) || defined(_MIPS_ARCH) || defined(_M_MRX000) -# define LZO_ARCH_MIPS 1 -# define LZO_INFO_ARCH "mips" -#elif (UINT_MAX == LZO_0xffffL) && defined(__MSP430__) -# define LZO_ARCH_MSP430 1 -# define LZO_INFO_ARCH "msp430" -#elif defined(__IAR_SYSTEMS_ICC__) && defined(__ICC430__) -# define LZO_ARCH_MSP430 1 -# define LZO_INFO_ARCH "msp430" -#elif defined(__powerpc__) || defined(__powerpc) || defined(__ppc__) || defined(__PPC__) || defined(_M_PPC) || defined(_ARCH_PPC) || defined(_ARCH_PWR) -# define LZO_ARCH_POWERPC 1 -# define LZO_INFO_ARCH "powerpc" -#elif defined(__s390__) || defined(__s390) || defined(__s390x__) || defined(__s390x) -# define LZO_ARCH_S390 1 -# define LZO_INFO_ARCH "s390" -#elif defined(__sh__) || defined(_M_SH) -# define LZO_ARCH_SH 1 -# define LZO_INFO_ARCH "sh" -#elif defined(__sparc__) || defined(__sparc) || defined(__sparcv8) -# define LZO_ARCH_SPARC 1 -# define LZO_INFO_ARCH "sparc" -#elif defined(__SPU__) -# define LZO_ARCH_SPU 1 -# define LZO_INFO_ARCH "spu" -#elif (UINT_MAX == LZO_0xffffL) && defined(__z80) -# define LZO_ARCH_Z80 1 -# define LZO_INFO_ARCH "z80" -#elif (LZO_ARCH_CRAY_PVP) -# if defined(_CRAYSV1) -# define LZO_ARCH_CRAY_SV1 1 -# define LZO_INFO_ARCH "cray_sv1" -# elif (_ADDR64) -# define LZO_ARCH_CRAY_T90 1 -# define LZO_INFO_ARCH "cray_t90" -# elif (_ADDR32) -# define LZO_ARCH_CRAY_YMP 1 -# define LZO_INFO_ARCH "cray_ymp" -# else -# define LZO_ARCH_CRAY_XMP 1 -# define LZO_INFO_ARCH "cray_xmp" -# endif -#else -# define LZO_ARCH_UNKNOWN 1 -# define LZO_INFO_ARCH "unknown" -#endif -#endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_DOS32 || LZO_OS_OS2) -# error "FIXME - missing define for CPU architecture" -#endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN32) -# error "FIXME - missing WIN32 define for CPU architecture" -#endif -#if 1 && (LZO_ARCH_UNKNOWN) && (LZO_OS_WIN64) -# error "FIXME - missing WIN64 define for CPU architecture" -#endif -#if (LZO_OS_OS216 || LZO_OS_WIN16) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && defined(BLX286)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && defined(DOSX286)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#elif 1 && (LZO_OS_DOS16 && LZO_CC_BORLANDC && defined(__DPMI16__)) -# define LZO_ARCH_I086PM 1 -# define LZO_ARCH_IA16PM 1 -#endif -#if (LZO_ARCH_ARM_THUMB) && !(LZO_ARCH_ARM) -# error "this should not happen" -#endif -#if (LZO_ARCH_I086PM) && !(LZO_ARCH_I086) -# error "this should not happen" -#endif -#if (LZO_ARCH_I086) -# if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif -#if (LZO_ARCH_I386) -# if (UINT_MAX != LZO_0xffffL) && defined(__i386_int16__) -# error "this should not happen" -# endif -# if (UINT_MAX != LZO_0xffffffffL) && !defined(__i386_int16__) -# error "this should not happen" -# endif -# if (ULONG_MAX != LZO_0xffffffffL) -# error "this should not happen" -# endif -#endif -#if !defined(__LZO_MM_OVERRIDE) -#if (LZO_ARCH_I086) -#if (UINT_MAX != LZO_0xffffL) -# error "this should not happen" -#endif -#if defined(__TINY__) || defined(M_I86TM) || defined(_M_I86TM) -# define LZO_MM_TINY 1 -#elif defined(__HUGE__) || defined(_HUGE_) || defined(M_I86HM) || defined(_M_I86HM) -# define LZO_MM_HUGE 1 -#elif defined(__SMALL__) || defined(M_I86SM) || defined(_M_I86SM) || defined(SMALL_MODEL) -# define LZO_MM_SMALL 1 -#elif defined(__MEDIUM__) || defined(M_I86MM) || defined(_M_I86MM) -# define LZO_MM_MEDIUM 1 -#elif defined(__COMPACT__) || defined(M_I86CM) || defined(_M_I86CM) -# define LZO_MM_COMPACT 1 -#elif defined(__LARGE__) || defined(M_I86LM) || defined(_M_I86LM) || defined(LARGE_MODEL) -# define LZO_MM_LARGE 1 -#elif (LZO_CC_AZTECC) -# if defined(_LARGE_CODE) && defined(_LARGE_DATA) -# define LZO_MM_LARGE 1 -# elif defined(_LARGE_CODE) -# define LZO_MM_MEDIUM 1 -# elif defined(_LARGE_DATA) -# define LZO_MM_COMPACT 1 -# else -# define LZO_MM_SMALL 1 -# endif -#elif (LZO_CC_ZORTECHC && defined(__VCM__)) -# define LZO_MM_LARGE 1 -#else -# error "unknown memory model" -#endif -#if (LZO_OS_DOS16 || LZO_OS_OS216 || LZO_OS_WIN16) -#define LZO_HAVE_MM_HUGE_PTR 1 -#define LZO_HAVE_MM_HUGE_ARRAY 1 -#if (LZO_MM_TINY) -# undef LZO_HAVE_MM_HUGE_ARRAY -#endif -#if (LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_ZORTECHC) -# undef LZO_HAVE_MM_HUGE_PTR -# undef LZO_HAVE_MM_HUGE_ARRAY -#elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -# undef LZO_HAVE_MM_HUGE_ARRAY -#elif (LZO_CC_MSC && defined(_QC)) -# undef LZO_HAVE_MM_HUGE_ARRAY -# if (_MSC_VER < 600) -# undef LZO_HAVE_MM_HUGE_PTR -# endif -#elif (LZO_CC_TURBOC && (__TURBOC__ < 0x0295)) -# undef LZO_HAVE_MM_HUGE_ARRAY -#endif -#if (LZO_ARCH_I086PM) && !(LZO_HAVE_MM_HUGE_PTR) -# if (LZO_OS_DOS16) -# error "this should not happen" -# elif (LZO_CC_ZORTECHC) -# else -# error "this should not happen" -# endif -#endif -#ifdef __cplusplus -extern "C" { -#endif -#if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0200)) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_MSC || LZO_CC_TOPSPEEDC) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif (LZO_CC_TURBOC && (__TURBOC__ >= 0x0295)) - extern void __near __cdecl _AHSHIFT(void); -# define LZO_MM_AHSHIFT ((unsigned) _AHSHIFT) -#elif ((LZO_CC_AZTECC || LZO_CC_PACIFICC || LZO_CC_TURBOC) && LZO_OS_DOS16) -# define LZO_MM_AHSHIFT 12 -#elif (LZO_CC_WATCOMC) - extern unsigned char _HShift; -# define LZO_MM_AHSHIFT ((unsigned) _HShift) -#else -# error "FIXME - implement LZO_MM_AHSHIFT" -#endif -#ifdef __cplusplus -} -#endif -#endif -#elif (LZO_ARCH_C166) -#if !defined(__MODEL__) -# error "FIXME - C166 __MODEL__" -#elif ((__MODEL__) == 0) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 1) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - C166 __MODEL__" -#endif -#elif (LZO_ARCH_MCS251) -#if !defined(__MODEL__) -# error "FIXME - MCS251 __MODEL__" -#elif ((__MODEL__) == 0) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - MCS251 __MODEL__" -#endif -#elif (LZO_ARCH_MCS51) -#if !defined(__MODEL__) -# error "FIXME - MCS51 __MODEL__" -#elif ((__MODEL__) == 1) -# define LZO_MM_SMALL 1 -#elif ((__MODEL__) == 2) -# define LZO_MM_LARGE 1 -#elif ((__MODEL__) == 3) -# define LZO_MM_TINY 1 -#elif ((__MODEL__) == 4) -# define LZO_MM_XTINY 1 -#elif ((__MODEL__) == 5) -# define LZO_MM_XSMALL 1 -#else -# error "FIXME - MCS51 __MODEL__" -#endif -#elif (LZO_ARCH_CRAY_PVP) -# define LZO_MM_PVP 1 -#else -# define LZO_MM_FLAT 1 -#endif -#if (LZO_MM_COMPACT) -# define LZO_INFO_MM "compact" -#elif (LZO_MM_FLAT) -# define LZO_INFO_MM "flat" -#elif (LZO_MM_HUGE) -# define LZO_INFO_MM "huge" -#elif (LZO_MM_LARGE) -# define LZO_INFO_MM "large" -#elif (LZO_MM_MEDIUM) -# define LZO_INFO_MM "medium" -#elif (LZO_MM_PVP) -# define LZO_INFO_MM "pvp" -#elif (LZO_MM_SMALL) -# define LZO_INFO_MM "small" -#elif (LZO_MM_TINY) -# define LZO_INFO_MM "tiny" -#else -# error "unknown memory model" -#endif -#endif -#if defined(SIZEOF_SHORT) -# define LZO_SIZEOF_SHORT (SIZEOF_SHORT) -#endif -#if defined(SIZEOF_INT) -# define LZO_SIZEOF_INT (SIZEOF_INT) -#endif -#if defined(SIZEOF_LONG) -# define LZO_SIZEOF_LONG (SIZEOF_LONG) -#endif -#if defined(SIZEOF_LONG_LONG) -# define LZO_SIZEOF_LONG_LONG (SIZEOF_LONG_LONG) -#endif -#if defined(SIZEOF___INT16) -# define LZO_SIZEOF___INT16 (SIZEOF___INT16) -#endif -#if defined(SIZEOF___INT32) -# define LZO_SIZEOF___INT32 (SIZEOF___INT32) -#endif -#if defined(SIZEOF___INT64) -# define LZO_SIZEOF___INT64 (SIZEOF___INT64) -#endif -#if defined(SIZEOF_VOID_P) -# define LZO_SIZEOF_VOID_P (SIZEOF_VOID_P) -#endif -#if defined(SIZEOF_SIZE_T) -# define LZO_SIZEOF_SIZE_T (SIZEOF_SIZE_T) -#endif -#if defined(SIZEOF_PTRDIFF_T) -# define LZO_SIZEOF_PTRDIFF_T (SIZEOF_PTRDIFF_T) -#endif -#define __LZO_LSR(x,b) (((x)+0ul) >> (b)) -#if !defined(LZO_SIZEOF_SHORT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_SHORT 8 -# elif (USHRT_MAX == LZO_0xffffL) -# define LZO_SIZEOF_SHORT 2 -# elif (__LZO_LSR(USHRT_MAX,7) == 1) -# define LZO_SIZEOF_SHORT 1 -# elif (__LZO_LSR(USHRT_MAX,15) == 1) -# define LZO_SIZEOF_SHORT 2 -# elif (__LZO_LSR(USHRT_MAX,31) == 1) -# define LZO_SIZEOF_SHORT 4 -# elif (__LZO_LSR(USHRT_MAX,63) == 1) -# define LZO_SIZEOF_SHORT 8 -# elif (__LZO_LSR(USHRT_MAX,127) == 1) -# define LZO_SIZEOF_SHORT 16 -# else -# error "LZO_SIZEOF_SHORT" -# endif -#endif -#if !defined(LZO_SIZEOF_INT) -# if (LZO_ARCH_CRAY_PVP) -# define LZO_SIZEOF_INT 8 -# elif (UINT_MAX == LZO_0xffffL) -# define LZO_SIZEOF_INT 2 -# elif (UINT_MAX == LZO_0xffffffffL) -# define LZO_SIZEOF_INT 4 -# elif (__LZO_LSR(UINT_MAX,7) == 1) -# define LZO_SIZEOF_INT 1 -# elif (__LZO_LSR(UINT_MAX,15) == 1) -# define LZO_SIZEOF_INT 2 -# elif (__LZO_LSR(UINT_MAX,31) == 1) -# define LZO_SIZEOF_INT 4 -# elif (__LZO_LSR(UINT_MAX,63) == 1) -# define LZO_SIZEOF_INT 8 -# elif (__LZO_LSR(UINT_MAX,127) == 1) -# define LZO_SIZEOF_INT 16 -# else -# error "LZO_SIZEOF_INT" -# endif -#endif -#if !defined(LZO_SIZEOF_LONG) -# if (ULONG_MAX == LZO_0xffffffffL) -# define LZO_SIZEOF_LONG 4 -# elif (__LZO_LSR(ULONG_MAX,7) == 1) -# define LZO_SIZEOF_LONG 1 -# elif (__LZO_LSR(ULONG_MAX,15) == 1) -# define LZO_SIZEOF_LONG 2 -# elif (__LZO_LSR(ULONG_MAX,31) == 1) -# define LZO_SIZEOF_LONG 4 -# elif (__LZO_LSR(ULONG_MAX,63) == 1) -# define LZO_SIZEOF_LONG 8 -# elif (__LZO_LSR(ULONG_MAX,127) == 1) -# define LZO_SIZEOF_LONG 16 -# else -# error "LZO_SIZEOF_LONG" -# endif -#endif -#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -# if defined(__LONG_MAX__) && defined(__LONG_LONG_MAX__) -# if (LZO_CC_GNUC >= 0x030300ul) -# if ((__LONG_MAX__)+0 == (__LONG_LONG_MAX__)+0) -# define LZO_SIZEOF_LONG_LONG LZO_SIZEOF_LONG -# elif (__LZO_LSR(__LONG_LONG_MAX__,30) == 1) -# define LZO_SIZEOF_LONG_LONG 4 -# endif -# endif -# endif -#endif -#endif -#if !defined(LZO_SIZEOF_LONG_LONG) && !defined(LZO_SIZEOF___INT64) -#if (LZO_SIZEOF_LONG > 0 && LZO_SIZEOF_LONG < 8) -#if (LZO_ARCH_I086 && LZO_CC_DMC) -#elif (LZO_CC_CILLY) && defined(__GNUC__) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_SIZEOF_LONG_LONG 8 -#elif ((LZO_OS_WIN32 || LZO_OS_WIN64 || defined(_WIN32)) && LZO_CC_MSC && (_MSC_VER >= 1400)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_OS_WIN64 || defined(_WIN64)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_DMC)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_SYMANTECC && (__SC__ >= 0x700))) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_INTELC && defined(__linux__))) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_MWERKS || LZO_CC_PELLESC || LZO_CC_PGI || LZO_CC_SUNPROC)) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_ARCH_I386 && (LZO_CC_INTELC || LZO_CC_MSC)) -# define LZO_SIZEOF___INT64 8 -#elif ((LZO_OS_WIN32 || defined(_WIN32)) && (LZO_CC_MSC)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0520))) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_ARCH_I386 && (LZO_CC_WATCOMC && (__WATCOMC__ >= 1100))) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_CC_WATCOMC && defined(_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS == 64)) -# define LZO_SIZEOF___INT64 8 -#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -# define LZO_SIZEOF_LONG_LONG 8 -#elif (LZO_CC_SDCC) && (LZO_SIZEOF_INT == 2) -#elif 1 && defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define LZO_SIZEOF_LONG_LONG 8 -#endif -#endif -#endif -#if defined(__cplusplus) && (LZO_CC_GNUC) -# if (LZO_CC_GNUC < 0x020800ul) -# undef LZO_SIZEOF_LONG_LONG -# endif -#endif -#if (LZO_CFG_NO_LONG_LONG) || defined(__NO_LONG_LONG) -# undef LZO_SIZEOF_LONG_LONG -#endif -#if !defined(LZO_SIZEOF_VOID_P) -#if (LZO_ARCH_I086) -# define __LZO_WORDSIZE 2 -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM) -# define LZO_SIZEOF_VOID_P 2 -# elif (LZO_MM_COMPACT || LZO_MM_LARGE || LZO_MM_HUGE) -# define LZO_SIZEOF_VOID_P 4 -# else -# error "LZO_MM" -# endif -#elif (LZO_ARCH_AVR || LZO_ARCH_Z80) -# define __LZO_WORDSIZE 1 -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_C166 || LZO_ARCH_MCS51 || LZO_ARCH_MCS251 || LZO_ARCH_MSP430) -# define LZO_SIZEOF_VOID_P 2 -#elif (LZO_ARCH_H8300) -# if defined(__NORMAL_MODE__) -# define __LZO_WORDSIZE 4 -# define LZO_SIZEOF_VOID_P 2 -# elif defined(__H8300H__) || defined(__H8300S__) || defined(__H8300SX__) -# define __LZO_WORDSIZE 4 -# define LZO_SIZEOF_VOID_P 4 -# else -# define __LZO_WORDSIZE 2 -# define LZO_SIZEOF_VOID_P 2 -# endif -# if (LZO_CC_GNUC && (LZO_CC_GNUC < 0x040000ul)) && (LZO_SIZEOF_INT == 4) -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_INT -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_INT -# endif -#elif (LZO_ARCH_M16C) -# define __LZO_WORDSIZE 2 -# if defined(__m32c_cpu__) || defined(__m32cm_cpu__) -# define LZO_SIZEOF_VOID_P 4 -# else -# define LZO_SIZEOF_VOID_P 2 -# endif -#elif (LZO_SIZEOF_LONG == 8) && ((defined(__mips__) && defined(__R5900__)) || defined(__MIPS_PSX2__)) -# define __LZO_WORDSIZE 8 -# define LZO_SIZEOF_VOID_P 4 -#elif defined(__LLP64__) || defined(__LLP64) || defined(_LLP64) || defined(_WIN64) -# define __LZO_WORDSIZE 8 -# define LZO_SIZEOF_VOID_P 8 -#elif (LZO_OS_OS400 || defined(__OS400__)) && defined(__LLP64_IFC__) -# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (LZO_OS_OS400 || defined(__OS400__)) -# define __LZO_WORDSIZE LZO_SIZEOF_LONG -# define LZO_SIZEOF_VOID_P 16 -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (defined(__vms) || defined(__VMS)) && (__INITIAL_POINTER_SIZE+0 == 64) -# define LZO_SIZEOF_VOID_P 8 -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_LONG -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_LONG -#elif (LZO_ARCH_SPU) -# if 0 -# define __LZO_WORDSIZE 16 -# endif -# define LZO_SIZEOF_VOID_P 4 -#else -# define LZO_SIZEOF_VOID_P LZO_SIZEOF_LONG -#endif -#endif -#if !defined(LZO_WORDSIZE) -# if defined(__LZO_WORDSIZE) -# define LZO_WORDSIZE __LZO_WORDSIZE -# else -# define LZO_WORDSIZE LZO_SIZEOF_VOID_P -# endif -#endif -#if !defined(LZO_SIZEOF_SIZE_T) -#if (LZO_ARCH_I086 || LZO_ARCH_M16C) -# define LZO_SIZEOF_SIZE_T 2 -#else -# define LZO_SIZEOF_SIZE_T LZO_SIZEOF_VOID_P -#endif -#endif -#if !defined(LZO_SIZEOF_PTRDIFF_T) -#if (LZO_ARCH_I086) -# if (LZO_MM_TINY || LZO_MM_SMALL || LZO_MM_MEDIUM || LZO_MM_HUGE) -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_VOID_P -# elif (LZO_MM_COMPACT || LZO_MM_LARGE) -# if (LZO_CC_BORLANDC || LZO_CC_TURBOC) -# define LZO_SIZEOF_PTRDIFF_T 4 -# else -# define LZO_SIZEOF_PTRDIFF_T 2 -# endif -# else -# error "LZO_MM" -# endif -#else -# define LZO_SIZEOF_PTRDIFF_T LZO_SIZEOF_SIZE_T -#endif -#endif -#if (LZO_ABI_NEUTRAL_ENDIAN) -# undef LZO_ABI_BIG_ENDIAN -# undef LZO_ABI_LITTLE_ENDIAN -#elif !(LZO_ABI_BIG_ENDIAN) && !(LZO_ABI_LITTLE_ENDIAN) -#if (LZO_ARCH_ALPHA) && (LZO_ARCH_CRAY_MPP) -# define LZO_ABI_BIG_ENDIAN 1 -#elif (LZO_ARCH_IA64) && (LZO_OS_POSIX_LINUX || LZO_OS_WIN64) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif (LZO_ARCH_ALPHA || LZO_ARCH_AMD64 || LZO_ARCH_BLACKFIN || LZO_ARCH_CRIS || LZO_ARCH_I086 || LZO_ARCH_I386 || LZO_ARCH_MSP430) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif (LZO_ARCH_AVR32 || LZO_ARCH_M68K || LZO_ARCH_S390) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__IAR_SYSTEMS_ICC__) && defined(__LITTLE_ENDIAN__) -# if (__LITTLE_ENDIAN__ == 1) -# define LZO_ABI_LITTLE_ENDIAN 1 -# else -# define LZO_ABI_BIG_ENDIAN 1 -# endif -#elif 1 && defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && defined(__LITTLE_ENDIAN__) && !defined(__BIG_ENDIAN__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEB__) && !defined(__ARMEL__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_ARM) && defined(__ARMEL__) && !defined(__ARMEB__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEB__) && !defined(__MIPSEL__) -# define LZO_ABI_BIG_ENDIAN 1 -#elif 1 && (LZO_ARCH_MIPS) && defined(__MIPSEL__) && !defined(__MIPSEB__) -# define LZO_ABI_LITTLE_ENDIAN 1 -#endif -#endif -#if (LZO_ABI_BIG_ENDIAN) && (LZO_ABI_LITTLE_ENDIAN) -# error "this should not happen" -#endif -#if (LZO_ABI_BIG_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "be" -#elif (LZO_ABI_LITTLE_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "le" -#elif (LZO_ABI_NEUTRAL_ENDIAN) -# define LZO_INFO_ABI_ENDIAN "neutral" -#endif -#if (LZO_SIZEOF_INT == 1 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -# define LZO_ABI_I8LP16 1 -# define LZO_INFO_ABI_PM "i8lp16" -#elif (LZO_SIZEOF_INT == 2 && LZO_SIZEOF_LONG == 2 && LZO_SIZEOF_VOID_P == 2) -# define LZO_ABI_ILP16 1 -# define LZO_INFO_ABI_PM "ilp16" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 4) -# define LZO_ABI_ILP32 1 -# define LZO_INFO_ABI_PM "ilp32" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 4 && LZO_SIZEOF_VOID_P == 8 && LZO_SIZEOF_SIZE_T == 8) -# define LZO_ABI_LLP64 1 -# define LZO_INFO_ABI_PM "llp64" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -# define LZO_ABI_LP64 1 -# define LZO_INFO_ABI_PM "lp64" -#elif (LZO_SIZEOF_INT == 8 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 8) -# define LZO_ABI_ILP64 1 -# define LZO_INFO_ABI_PM "ilp64" -#elif (LZO_SIZEOF_INT == 4 && LZO_SIZEOF_LONG == 8 && LZO_SIZEOF_VOID_P == 4) -# define LZO_ABI_IP32L64 1 -# define LZO_INFO_ABI_PM "ip32l64" -#endif -#if !defined(__LZO_LIBC_OVERRIDE) -#if (LZO_LIBC_NAKED) -# define LZO_INFO_LIBC "naked" -#elif (LZO_LIBC_FREESTANDING) -# define LZO_INFO_LIBC "freestanding" -#elif (LZO_LIBC_MOSTLY_FREESTANDING) -# define LZO_INFO_LIBC "mfreestanding" -#elif (LZO_LIBC_ISOC90) -# define LZO_INFO_LIBC "isoc90" -#elif (LZO_LIBC_ISOC99) -# define LZO_INFO_LIBC "isoc99" -#elif defined(__dietlibc__) -# define LZO_LIBC_DIETLIBC 1 -# define LZO_INFO_LIBC "dietlibc" -#elif defined(_NEWLIB_VERSION) -# define LZO_LIBC_NEWLIB 1 -# define LZO_INFO_LIBC "newlib" -#elif defined(__UCLIBC__) && defined(__UCLIBC_MAJOR__) && defined(__UCLIBC_MINOR__) -# if defined(__UCLIBC_SUBLEVEL__) -# define LZO_LIBC_UCLIBC (__UCLIBC_MAJOR__ * 0x10000L + __UCLIBC_MINOR__ * 0x100 + __UCLIBC_SUBLEVEL__) -# else -# define LZO_LIBC_UCLIBC 0x00090bL -# endif -# define LZO_INFO_LIBC "uclibc" -#elif defined(__GLIBC__) && defined(__GLIBC_MINOR__) -# define LZO_LIBC_GLIBC (__GLIBC__ * 0x10000L + __GLIBC_MINOR__ * 0x100) -# define LZO_INFO_LIBC "glibc" -#elif (LZO_CC_MWERKS) && defined(__MSL__) -# define LZO_LIBC_MSL __MSL__ -# define LZO_INFO_LIBC "msl" -#elif 1 && defined(__IAR_SYSTEMS_ICC__) -# define LZO_LIBC_ISOC90 1 -# define LZO_INFO_LIBC "isoc90" -#else -# define LZO_LIBC_DEFAULT 1 -# define LZO_INFO_LIBC "default" -#endif -#endif -#if !defined(__lzo_gnuc_extension__) -#if (LZO_CC_GNUC >= 0x020800ul) -# define __lzo_gnuc_extension__ __extension__ -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_gnuc_extension__ __extension__ -#else -# define __lzo_gnuc_extension__ /*empty*/ -#endif -#endif -#if !defined(__lzo_ua_volatile) -# define __lzo_ua_volatile volatile -#endif -#if !defined(__lzo_alignof) -#if (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -# define __lzo_alignof(e) __alignof__(e) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 700)) -# define __lzo_alignof(e) __alignof__(e) -#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -# define __lzo_alignof(e) __alignof(e) -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_alignof(e) __alignof__(e) -#endif -#endif -#if defined(__lzo_alignof) -# define __lzo_HAVE_alignof 1 -#endif -#if !defined(__lzo_constructor) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_constructor __attribute__((__constructor__,__used__)) -#elif (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_constructor __attribute__((__constructor__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_constructor __attribute__((__constructor__)) -#endif -#endif -#if defined(__lzo_constructor) -# define __lzo_HAVE_constructor 1 -#endif -#if !defined(__lzo_destructor) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_destructor __attribute__((__destructor__,__used__)) -#elif (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_destructor __attribute__((__destructor__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_destructor __attribute__((__destructor__)) -#endif -#endif -#if defined(__lzo_destructor) -# define __lzo_HAVE_destructor 1 -#endif -#if (__lzo_HAVE_destructor) && !(__lzo_HAVE_constructor) -# error "this should not happen" -#endif -#if !defined(__lzo_inline) -#if (LZO_CC_TURBOC && (__TURBOC__ <= 0x0295)) -#elif defined(__cplusplus) -# define __lzo_inline inline -#elif (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0550)) -# define __lzo_inline __inline -#elif (LZO_CC_CILLY || LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE || LZO_CC_PGI) -# define __lzo_inline __inline__ -#elif (LZO_CC_DMC) -# define __lzo_inline __inline -#elif (LZO_CC_INTELC) -# define __lzo_inline __inline -#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x2405)) -# define __lzo_inline __inline -#elif (LZO_CC_MSC && (_MSC_VER >= 900)) -# define __lzo_inline __inline -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_inline __inline__ -#elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) -# define __lzo_inline inline -#endif -#endif -#if defined(__lzo_inline) -# define __lzo_HAVE_inline 1 -#else -# define __lzo_inline /*empty*/ -#endif -#if !defined(__lzo_forceinline) -#if (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -# define __lzo_forceinline __forceinline -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -# define __lzo_forceinline __forceinline -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_forceinline __inline__ __attribute__((__always_inline__)) -#endif -#endif -#if defined(__lzo_forceinline) -# define __lzo_HAVE_forceinline 1 -#else -# define __lzo_forceinline /*empty*/ -#endif -#if !defined(__lzo_noinline) -#if 1 && (LZO_ARCH_I386) && (LZO_CC_GNUC >= 0x040000ul) && (LZO_CC_GNUC < 0x040003ul) -# define __lzo_noinline __attribute__((__noinline__,__used__)) -#elif (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_MSC) -# define __lzo_noinline __declspec(noinline) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800) && LZO_CC_SYNTAX_GNUC) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_noinline __attribute__((__noinline__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1300)) -# define __lzo_noinline __declspec(noinline) -#elif (LZO_CC_MWERKS && (__MWERKS__ >= 0x3200) && (LZO_OS_WIN32 || LZO_OS_WIN64)) -# if defined(__cplusplus) -# else -# define __lzo_noinline __declspec(noinline) -# endif -#elif (LZO_CC_SUNPROC && (LZO_CC_SUNPROC >= 0x5100)) -# define __lzo_noinline __attribute__((__noinline__)) -#endif -#endif -#if defined(__lzo_noinline) -# define __lzo_HAVE_noinline 1 -#else -# define __lzo_noinline /*empty*/ -#endif -#if (__lzo_HAVE_forceinline || __lzo_HAVE_noinline) && !(__lzo_HAVE_inline) -# error "this should not happen" -#endif -#if !defined(__lzo_noreturn) -#if (LZO_CC_GNUC >= 0x020700ul) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) -# define __lzo_noreturn __declspec(noreturn) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_noreturn __attribute__((__noreturn__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) -# define __lzo_noreturn __declspec(noreturn) -#endif -#endif -#if defined(__lzo_noreturn) -# define __lzo_HAVE_noreturn 1 -#else -# define __lzo_noreturn /*empty*/ -#endif -#if !defined(__lzo_nothrow) -#if (LZO_CC_GNUC >= 0x030300ul) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 450) && LZO_CC_SYNTAX_MSC) && defined(__cplusplus) -# define __lzo_nothrow __declspec(nothrow) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 900) && LZO_CC_SYNTAX_GNUC) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_nothrow __attribute__((__nothrow__)) -#elif (LZO_CC_MSC && (_MSC_VER >= 1200)) && defined(__cplusplus) -# define __lzo_nothrow __declspec(nothrow) -#endif -#endif -#if defined(__lzo_nothrow) -# define __lzo_HAVE_nothrow 1 -#else -# define __lzo_nothrow /*empty*/ -#endif -#if !defined(__lzo_restrict) -#if (LZO_CC_GNUC >= 0x030400ul) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 600) && LZO_CC_SYNTAX_GNUC) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_CLANG || LZO_CC_LLVM) -# define __lzo_restrict __restrict__ -#elif (LZO_CC_MSC && (_MSC_VER >= 1400)) -# define __lzo_restrict __restrict -#endif -#endif -#if defined(__lzo_restrict) -# define __lzo_HAVE_restrict 1 -#else -# define __lzo_restrict /*empty*/ -#endif -#if !defined(__lzo_likely) && !defined(__lzo_unlikely) -#if (LZO_CC_GNUC >= 0x030200ul) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#elif (LZO_CC_INTELC && (__INTEL_COMPILER >= 800)) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#elif (LZO_CC_CLANG || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define __lzo_likely(e) (__builtin_expect(!!(e),1)) -# define __lzo_unlikely(e) (__builtin_expect(!!(e),0)) -#endif -#endif -#if defined(__lzo_likely) -# define __lzo_HAVE_likely 1 -#else -# define __lzo_likely(e) (e) -#endif -#if defined(__lzo_unlikely) -# define __lzo_HAVE_unlikely 1 -#else -# define __lzo_unlikely(e) (e) -#endif -#if !defined(LZO_UNUSED) -# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -# define LZO_UNUSED(var) ((void) &var) -# elif (LZO_CC_BORLANDC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PELLESC || LZO_CC_TURBOC) -# define LZO_UNUSED(var) if (&var) ; else -# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_UNUSED(var) ((void) var) -# elif (LZO_CC_MSC && (_MSC_VER < 900)) -# define LZO_UNUSED(var) if (&var) ; else -# elif (LZO_CC_KEILC) -# define LZO_UNUSED(var) {extern int __lzo_unused[1-2*!(sizeof(var)>0)];} -# elif (LZO_CC_PACIFICC) -# define LZO_UNUSED(var) ((void) sizeof(var)) -# elif (LZO_CC_WATCOMC) && defined(__cplusplus) -# define LZO_UNUSED(var) ((void) var) -# else -# define LZO_UNUSED(var) ((void) &var) -# endif -#endif -#if !defined(LZO_UNUSED_FUNC) -# if (LZO_CC_BORLANDC && (__BORLANDC__ >= 0x0600)) -# define LZO_UNUSED_FUNC(func) ((void) func) -# elif (LZO_CC_BORLANDC || LZO_CC_NDPC || LZO_CC_TURBOC) -# define LZO_UNUSED_FUNC(func) if (func) ; else -# elif (LZO_CC_CLANG || LZO_CC_LLVM) -# define LZO_UNUSED_FUNC(func) ((void) &func) -# elif (LZO_CC_MSC && (_MSC_VER < 900)) -# define LZO_UNUSED_FUNC(func) if (func) ; else -# elif (LZO_CC_MSC) -# define LZO_UNUSED_FUNC(func) ((void) &func) -# elif (LZO_CC_KEILC || LZO_CC_PELLESC) -# define LZO_UNUSED_FUNC(func) {extern int __lzo_unused[1-2*!(sizeof((int)func)>0)];} -# else -# define LZO_UNUSED_FUNC(func) ((void) func) -# endif -#endif -#if !defined(LZO_UNUSED_LABEL) -# if (LZO_CC_WATCOMC) && defined(__cplusplus) -# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l -# elif (LZO_CC_CLANG || LZO_CC_INTELC || LZO_CC_WATCOMC) -# define LZO_UNUSED_LABEL(l) if (0) goto l -# else -# define LZO_UNUSED_LABEL(l) switch(0) case 1:goto l -# endif -#endif -#if !defined(LZO_DEFINE_UNINITIALIZED_VAR) -# if 0 -# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var -# elif 0 && (LZO_CC_GNUC) -# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = var -# else -# define LZO_DEFINE_UNINITIALIZED_VAR(type,var,init) type var = init -# endif -#endif -#if !defined(LZO_UNCONST_CAST) -# if 0 && defined(__cplusplus) -# define LZO_UNCONST_CAST(t,e) (const_cast (e)) -# elif (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_LLVM || LZO_CC_PATHSCALE) -# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((lzo_uintptr_t) ((const void *) (e)))))) -# else -# define LZO_UNCONST_CAST(t,e) ((t) ((void *) ((char *) ((const void *) (e))))) -# endif -#endif -#if !defined(LZO_COMPILE_TIME_ASSERT_HEADER) -# if (LZO_CC_AZTECC || LZO_CC_ZORTECHC) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; -# elif (LZO_CC_DMC || LZO_CC_SYMANTECC) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1u-2*!(e)]; -# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-!(e)]; -# else -# define LZO_COMPILE_TIME_ASSERT_HEADER(e) extern int __lzo_cta[1-2*!(e)]; -# endif -#endif -#if !defined(LZO_COMPILE_TIME_ASSERT) -# if (LZO_CC_AZTECC) -# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-!(e)];} -# elif (LZO_CC_DMC || LZO_CC_PACIFICC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -# elif (LZO_CC_MSC && (_MSC_VER < 900)) -# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -# elif (LZO_CC_TURBOC && (__TURBOC__ == 0x0295)) -# define LZO_COMPILE_TIME_ASSERT(e) switch(0) case 1:case !(e):break; -# else -# define LZO_COMPILE_TIME_ASSERT(e) {typedef int __lzo_cta_t[1-2*!(e)];} -# endif -#endif -#if (LZO_ARCH_I086 || LZO_ARCH_I386) && (LZO_OS_DOS16 || LZO_OS_DOS32 || LZO_OS_OS2 || LZO_OS_OS216 || LZO_OS_WIN16 || LZO_OS_WIN32 || LZO_OS_WIN64) -# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC) -# elif (LZO_CC_DMC || LZO_CC_SYMANTECC || LZO_CC_ZORTECHC) -# define __lzo_cdecl __cdecl -# define __lzo_cdecl_atexit /*empty*/ -# define __lzo_cdecl_main __cdecl -# if (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -# define __lzo_cdecl_qsort __pascal -# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -# define __lzo_cdecl_qsort _stdcall -# else -# define __lzo_cdecl_qsort __cdecl -# endif -# elif (LZO_CC_WATCOMC) -# define __lzo_cdecl __cdecl -# else -# define __lzo_cdecl __cdecl -# define __lzo_cdecl_atexit __cdecl -# define __lzo_cdecl_main __cdecl -# define __lzo_cdecl_qsort __cdecl -# endif -# if (LZO_CC_GNUC || LZO_CC_HIGHC || LZO_CC_NDPC || LZO_CC_PACIFICC || LZO_CC_WATCOMC) -# elif (LZO_OS_OS2 && (LZO_CC_DMC || LZO_CC_SYMANTECC)) -# define __lzo_cdecl_sighandler __pascal -# elif (LZO_OS_OS2 && (LZO_CC_ZORTECHC)) -# define __lzo_cdecl_sighandler _stdcall -# elif (LZO_CC_MSC && (_MSC_VER >= 1400)) && defined(_M_CEE_PURE) -# define __lzo_cdecl_sighandler __clrcall -# elif (LZO_CC_MSC && (_MSC_VER >= 600 && _MSC_VER < 700)) -# if defined(_DLL) -# define __lzo_cdecl_sighandler _far _cdecl _loadds -# elif defined(_MT) -# define __lzo_cdecl_sighandler _far _cdecl -# else -# define __lzo_cdecl_sighandler _cdecl -# endif -# else -# define __lzo_cdecl_sighandler __cdecl -# endif -#elif (LZO_ARCH_I386) && (LZO_CC_WATCOMC) -# define __lzo_cdecl __cdecl -#elif (LZO_ARCH_M68K && LZO_OS_TOS && (LZO_CC_PUREC || LZO_CC_TURBOC)) -# define __lzo_cdecl cdecl -#endif -#if !defined(__lzo_cdecl) -# define __lzo_cdecl /*empty*/ -#endif -#if !defined(__lzo_cdecl_atexit) -# define __lzo_cdecl_atexit /*empty*/ -#endif -#if !defined(__lzo_cdecl_main) -# define __lzo_cdecl_main /*empty*/ -#endif -#if !defined(__lzo_cdecl_qsort) -# define __lzo_cdecl_qsort /*empty*/ -#endif -#if !defined(__lzo_cdecl_sighandler) -# define __lzo_cdecl_sighandler /*empty*/ -#endif -#if !defined(__lzo_cdecl_va) -# define __lzo_cdecl_va __lzo_cdecl -#endif -#if !(LZO_CFG_NO_WINDOWS_H) -#if (LZO_OS_CYGWIN || (LZO_OS_EMX && defined(__RSXNT__)) || LZO_OS_WIN32 || LZO_OS_WIN64) -# if (LZO_CC_WATCOMC && (__WATCOMC__ < 1000)) -# elif (LZO_OS_WIN32 && LZO_CC_GNUC) && defined(__PW32__) -# elif ((LZO_OS_CYGWIN || defined(__MINGW32__)) && (LZO_CC_GNUC && (LZO_CC_GNUC < 0x025f00ul))) -# else -# define LZO_HAVE_WINDOWS_H 1 -# endif -#endif -#endif -#if (LZO_ARCH_ALPHA) -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_AVOID_SHORT 1 -# define LZO_OPT_AVOID_USHORT 1 -#elif (LZO_ARCH_AMD64) -# define LZO_OPT_AVOID_INT_INDEX 1 -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# define LZO_OPT_UNALIGNED64 1 -#elif (LZO_ARCH_ARM && LZO_ARCH_ARM_THUMB) -#elif (LZO_ARCH_ARM) -# define LZO_OPT_AVOID_SHORT 1 -# define LZO_OPT_AVOID_USHORT 1 -#elif (LZO_ARCH_CRIS) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -#elif (LZO_ARCH_I386) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -#elif (LZO_ARCH_IA64) -# define LZO_OPT_AVOID_INT_INDEX 1 -# define LZO_OPT_AVOID_UINT_INDEX 1 -# define LZO_OPT_PREFER_POSTINC 1 -#elif (LZO_ARCH_M68K) -# define LZO_OPT_PREFER_POSTINC 1 -# define LZO_OPT_PREFER_PREDEC 1 -# if defined(__mc68020__) && !defined(__mcoldfire__) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# endif -#elif (LZO_ARCH_MIPS) -# define LZO_OPT_AVOID_UINT_INDEX 1 -#elif (LZO_ARCH_POWERPC) -# define LZO_OPT_PREFER_PREINC 1 -# define LZO_OPT_PREFER_PREDEC 1 -# if (LZO_ABI_BIG_ENDIAN) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# endif -#elif (LZO_ARCH_S390) -# define LZO_OPT_UNALIGNED16 1 -# define LZO_OPT_UNALIGNED32 1 -# if (LZO_SIZEOF_SIZE_T == 8) -# define LZO_OPT_UNALIGNED64 1 -# endif -#elif (LZO_ARCH_SH) -# define LZO_OPT_PREFER_POSTINC 1 -# define LZO_OPT_PREFER_PREDEC 1 -#endif -#ifndef LZO_CFG_NO_INLINE_ASM -#if (LZO_CC_LLVM) -# define LZO_CFG_NO_INLINE_ASM 1 -#endif -#endif -#ifndef LZO_CFG_NO_UNALIGNED -#if (LZO_ABI_NEUTRAL_ENDIAN) || (LZO_ARCH_GENERIC) -# define LZO_CFG_NO_UNALIGNED 1 -#endif -#endif -#if (LZO_CFG_NO_UNALIGNED) -# undef LZO_OPT_UNALIGNED16 -# undef LZO_OPT_UNALIGNED32 -# undef LZO_OPT_UNALIGNED64 -#endif -#if (LZO_CFG_NO_INLINE_ASM) -#elif (LZO_ARCH_I386 && (LZO_OS_DOS32 || LZO_OS_WIN32) && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -# define LZO_ASM_SYNTAX_MSC 1 -#elif (LZO_OS_WIN64 && (LZO_CC_DMC || LZO_CC_INTELC || LZO_CC_MSC || LZO_CC_PELLESC)) -#elif (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC == 0x011f00ul)) -#elif (LZO_ARCH_I386 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -# define LZO_ASM_SYNTAX_GNUC 1 -#elif (LZO_ARCH_AMD64 && (LZO_CC_CLANG || LZO_CC_GNUC || LZO_CC_INTELC || LZO_CC_PATHSCALE)) -# define LZO_ASM_SYNTAX_GNUC 1 -#endif -#if (LZO_ASM_SYNTAX_GNUC) -#if (LZO_ARCH_I386 && LZO_CC_GNUC && (LZO_CC_GNUC < 0x020000ul)) -# define __LZO_ASM_CLOBBER "ax" -#elif (LZO_CC_INTELC) -# define __LZO_ASM_CLOBBER "memory" -#else -# define __LZO_ASM_CLOBBER "cc", "memory" -#endif -#endif -#if defined(__LZO_INFOSTR_MM) -#elif (LZO_MM_FLAT) && (defined(__LZO_INFOSTR_PM) || defined(LZO_INFO_ABI_PM)) -# define __LZO_INFOSTR_MM "" -#elif defined(LZO_INFO_MM) -# define __LZO_INFOSTR_MM "." LZO_INFO_MM -#else -# define __LZO_INFOSTR_MM "" -#endif -#if defined(__LZO_INFOSTR_PM) -#elif defined(LZO_INFO_ABI_PM) -# define __LZO_INFOSTR_PM "." LZO_INFO_ABI_PM -#else -# define __LZO_INFOSTR_PM "" -#endif -#if defined(__LZO_INFOSTR_ENDIAN) -#elif defined(LZO_INFO_ABI_ENDIAN) -# define __LZO_INFOSTR_ENDIAN "." LZO_INFO_ABI_ENDIAN -#else -# define __LZO_INFOSTR_ENDIAN "" -#endif -#if defined(__LZO_INFOSTR_OSNAME) -#elif defined(LZO_INFO_OS_CONSOLE) -# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_CONSOLE -#elif defined(LZO_INFO_OS_POSIX) -# define __LZO_INFOSTR_OSNAME LZO_INFO_OS "." LZO_INFO_OS_POSIX -#else -# define __LZO_INFOSTR_OSNAME LZO_INFO_OS -#endif -#if defined(__LZO_INFOSTR_LIBC) -#elif defined(LZO_INFO_LIBC) -# define __LZO_INFOSTR_LIBC "." LZO_INFO_LIBC -#else -# define __LZO_INFOSTR_LIBC "" -#endif -#if defined(__LZO_INFOSTR_CCVER) -#elif defined(LZO_INFO_CCVER) -# define __LZO_INFOSTR_CCVER " " LZO_INFO_CCVER -#else -# define __LZO_INFOSTR_CCVER "" -#endif -#define LZO_INFO_STRING \ - LZO_INFO_ARCH __LZO_INFOSTR_MM __LZO_INFOSTR_PM __LZO_INFOSTR_ENDIAN \ - " " __LZO_INFOSTR_OSNAME __LZO_INFOSTR_LIBC " " LZO_INFO_CC __LZO_INFOSTR_CCVER - -#endif /* already included */ - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/lzo/lzoutil.h b/maclibs/include/lzo/lzoutil.h deleted file mode 100644 index eb741ce2..00000000 --- a/maclibs/include/lzo/lzoutil.h +++ /dev/null @@ -1,76 +0,0 @@ -/* lzoutil.h -- utilitiy functions for use by applications [DEPRECATED] - - This file is part of the LZO real-time data compression library. - - Copyright (C) 2011 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2010 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2009 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2008 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2007 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2006 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2005 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2004 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2003 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2002 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2001 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 2000 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1999 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1998 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer - Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer - All Rights Reserved. - - The LZO library is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of - the License, or (at your option) any later version. - - The LZO library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with the LZO library; see the file COPYING. - If not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - Markus F.X.J. Oberhumer - - http://www.oberhumer.com/opensource/lzo/ - */ - - -#ifndef __LZOUTIL_H_INCLUDED -#define __LZOUTIL_H_INCLUDED 1 - -#ifndef __LZOCONF_H_INCLUDED -#include "lzoconf.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - - -/*********************************************************************** -// LZO-v1 deprecated macros (which were used in the old example programs) -// DO NOT USE -************************************************************************/ - -#define lzo_alloc(a,b) (malloc((a)*(b))) -#define lzo_malloc(a) (malloc(a)) -#define lzo_free(a) (free(a)) - -#define lzo_fread(f,b,s) (fread(b,1,s,f)) -#define lzo_fwrite(f,b,s) (fwrite(b,1,s,f)) - - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* already included */ - - -/* vim:set ts=4 et: */ diff --git a/maclibs/include/ogg/config_types.h b/maclibs/include/ogg/config_types.h deleted file mode 100644 index 00962788..00000000 --- a/maclibs/include/ogg/config_types.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __CONFIG_TYPES_H__ -#define __CONFIG_TYPES_H__ - -/* these are filled in by configure */ -#define INCLUDE_INTTYPES_H 1 -#define INCLUDE_STDINT_H 1 -#define INCLUDE_SYS_TYPES_H 1 - -#if INCLUDE_INTTYPES_H -# include -#endif -#if INCLUDE_STDINT_H -# include -#endif -#if INCLUDE_SYS_TYPES_H -# include -#endif - -typedef short ogg_int16_t; -typedef unsigned short ogg_uint16_t; -typedef int ogg_int32_t; -typedef unsigned int ogg_uint32_t; -typedef long ogg_int64_t; - -#endif diff --git a/maclibs/include/ogg/ogg.h b/maclibs/include/ogg/ogg.h deleted file mode 100644 index cea4ebed..00000000 --- a/maclibs/include/ogg/ogg.h +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: toplevel libogg include - last mod: $Id: ogg.h 18044 2011-08-01 17:55:20Z gmaxwell $ - - ********************************************************************/ -#ifndef _OGG_H -#define _OGG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -typedef struct { - void *iov_base; - size_t iov_len; -} ogg_iovec_t; - -typedef struct { - long endbyte; - int endbit; - - unsigned char *buffer; - unsigned char *ptr; - long storage; -} oggpack_buffer; - -/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/ - -typedef struct { - unsigned char *header; - long header_len; - unsigned char *body; - long body_len; -} ogg_page; - -/* ogg_stream_state contains the current encode/decode state of a logical - Ogg bitstream **********************************************************/ - -typedef struct { - unsigned char *body_data; /* bytes from packet bodies */ - long body_storage; /* storage elements allocated */ - long body_fill; /* elements stored; fill mark */ - long body_returned; /* elements of fill returned */ - - - int *lacing_vals; /* The values that will go to the segment table */ - ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact - this way, but it is simple coupled to the - lacing fifo */ - long lacing_storage; - long lacing_fill; - long lacing_packet; - long lacing_returned; - - unsigned char header[282]; /* working space for header encode */ - int header_fill; - - int e_o_s; /* set when we have buffered the last packet in the - logical bitstream */ - int b_o_s; /* set after we've written the initial page - of a logical bitstream */ - long serialno; - long pageno; - ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a separate abstraction - layer) also knows about the gap */ - ogg_int64_t granulepos; - -} ogg_stream_state; - -/* ogg_packet is used to encapsulate the data and metadata belonging - to a single raw Ogg/Vorbis packet *************************************/ - -typedef struct { - unsigned char *packet; - long bytes; - long b_o_s; - long e_o_s; - - ogg_int64_t granulepos; - - ogg_int64_t packetno; /* sequence number for decode; the framing - knows where there's a hole in the data, - but we need coupling so that the codec - (which is in a separate abstraction - layer) also knows about the gap */ -} ogg_packet; - -typedef struct { - unsigned char *data; - int storage; - int fill; - int returned; - - int unsynced; - int headerbytes; - int bodybytes; -} ogg_sync_state; - -/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/ - -extern void oggpack_writeinit(oggpack_buffer *b); -extern int oggpack_writecheck(oggpack_buffer *b); -extern void oggpack_writetrunc(oggpack_buffer *b,long bits); -extern void oggpack_writealign(oggpack_buffer *b); -extern void oggpack_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpack_reset(oggpack_buffer *b); -extern void oggpack_writeclear(oggpack_buffer *b); -extern void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpack_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpack_look(oggpack_buffer *b,int bits); -extern long oggpack_look1(oggpack_buffer *b); -extern void oggpack_adv(oggpack_buffer *b,int bits); -extern void oggpack_adv1(oggpack_buffer *b); -extern long oggpack_read(oggpack_buffer *b,int bits); -extern long oggpack_read1(oggpack_buffer *b); -extern long oggpack_bytes(oggpack_buffer *b); -extern long oggpack_bits(oggpack_buffer *b); -extern unsigned char *oggpack_get_buffer(oggpack_buffer *b); - -extern void oggpackB_writeinit(oggpack_buffer *b); -extern int oggpackB_writecheck(oggpack_buffer *b); -extern void oggpackB_writetrunc(oggpack_buffer *b,long bits); -extern void oggpackB_writealign(oggpack_buffer *b); -extern void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits); -extern void oggpackB_reset(oggpack_buffer *b); -extern void oggpackB_writeclear(oggpack_buffer *b); -extern void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes); -extern void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits); -extern long oggpackB_look(oggpack_buffer *b,int bits); -extern long oggpackB_look1(oggpack_buffer *b); -extern void oggpackB_adv(oggpack_buffer *b,int bits); -extern void oggpackB_adv1(oggpack_buffer *b); -extern long oggpackB_read(oggpack_buffer *b,int bits); -extern long oggpackB_read1(oggpack_buffer *b); -extern long oggpackB_bytes(oggpack_buffer *b); -extern long oggpackB_bits(oggpack_buffer *b); -extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b); - -/* Ogg BITSTREAM PRIMITIVES: encoding **************************/ - -extern int ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op); -extern int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, - int count, long e_o_s, ogg_int64_t granulepos); -extern int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_pageout_fill(ogg_stream_state *os, ogg_page *og, int nfill); -extern int ogg_stream_flush(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_flush_fill(ogg_stream_state *os, ogg_page *og, int nfill); - -/* Ogg BITSTREAM PRIMITIVES: decoding **************************/ - -extern int ogg_sync_init(ogg_sync_state *oy); -extern int ogg_sync_clear(ogg_sync_state *oy); -extern int ogg_sync_reset(ogg_sync_state *oy); -extern int ogg_sync_destroy(ogg_sync_state *oy); -extern int ogg_sync_check(ogg_sync_state *oy); - -extern char *ogg_sync_buffer(ogg_sync_state *oy, long size); -extern int ogg_sync_wrote(ogg_sync_state *oy, long bytes); -extern long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og); -extern int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og); -extern int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og); -extern int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op); -extern int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op); - -/* Ogg BITSTREAM PRIMITIVES: general ***************************/ - -extern int ogg_stream_init(ogg_stream_state *os,int serialno); -extern int ogg_stream_clear(ogg_stream_state *os); -extern int ogg_stream_reset(ogg_stream_state *os); -extern int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno); -extern int ogg_stream_destroy(ogg_stream_state *os); -extern int ogg_stream_check(ogg_stream_state *os); -extern int ogg_stream_eos(ogg_stream_state *os); - -extern void ogg_page_checksum_set(ogg_page *og); - -extern int ogg_page_version(const ogg_page *og); -extern int ogg_page_continued(const ogg_page *og); -extern int ogg_page_bos(const ogg_page *og); -extern int ogg_page_eos(const ogg_page *og); -extern ogg_int64_t ogg_page_granulepos(const ogg_page *og); -extern int ogg_page_serialno(const ogg_page *og); -extern long ogg_page_pageno(const ogg_page *og); -extern int ogg_page_packets(const ogg_page *og); - -extern void ogg_packet_clear(ogg_packet *op); - - -#ifdef __cplusplus -} -#endif - -#endif /* _OGG_H */ diff --git a/maclibs/include/ogg/os_types.h b/maclibs/include/ogg/os_types.h deleted file mode 100644 index d6691b70..00000000 --- a/maclibs/include/ogg/os_types.h +++ /dev/null @@ -1,147 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: #ifdef jail to whip a few platforms into the UNIX ideal. - last mod: $Id: os_types.h 17712 2010-12-03 17:10:02Z xiphmont $ - - ********************************************************************/ -#ifndef _OS_TYPES_H -#define _OS_TYPES_H - -/* make it easy on the folks that want to compile the libs with a - different malloc than stdlib */ -#define _ogg_malloc malloc -#define _ogg_calloc calloc -#define _ogg_realloc realloc -#define _ogg_free free - -#if defined(_WIN32) - -# if defined(__CYGWIN__) -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - typedef uint64_t ogg_uint64_t; -# elif defined(__MINGW32__) -# include - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - typedef unsigned long long ogg_uint64_t; -# elif defined(__MWERKS__) - typedef long long ogg_int64_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; -# else - /* MSVC/Borland */ - typedef __int64 ogg_int64_t; - typedef __int32 ogg_int32_t; - typedef unsigned __int32 ogg_uint32_t; - typedef __int16 ogg_int16_t; - typedef unsigned __int16 ogg_uint16_t; -# endif - -#elif defined(__MACOS__) - -# include - typedef SInt16 ogg_int16_t; - typedef UInt16 ogg_uint16_t; - typedef SInt32 ogg_int32_t; - typedef UInt32 ogg_uint32_t; - typedef SInt64 ogg_int64_t; - -#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ - -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - -#elif defined(__HAIKU__) - - /* Haiku */ -# include - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - -#elif defined(__BEOS__) - - /* Be */ -# include - typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; - typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; - typedef int64_t ogg_int64_t; - -#elif defined (__EMX__) - - /* OS/2 GCC */ - typedef short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - -#elif defined (DJGPP) - - /* DJGPP */ - typedef short ogg_int16_t; - typedef int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long ogg_int64_t; - -#elif defined(R5900) - - /* PS2 EE */ - typedef long ogg_int64_t; - typedef int ogg_int32_t; - typedef unsigned ogg_uint32_t; - typedef short ogg_int16_t; - -#elif defined(__SYMBIAN32__) - - /* Symbian GCC */ - typedef signed short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef signed int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long int ogg_int64_t; - -#elif defined(__TMS320C6X__) - - /* TI C64x compiler */ - typedef signed short ogg_int16_t; - typedef unsigned short ogg_uint16_t; - typedef signed int ogg_int32_t; - typedef unsigned int ogg_uint32_t; - typedef long long int ogg_int64_t; - -#else - -# include - -#endif - -#endif /* _OS_TYPES_H */ diff --git a/maclibs/include/opencc/Common.hpp b/maclibs/include/opencc/Common.hpp deleted file mode 100644 index 9d8d69a0..00000000 --- a/maclibs/include/opencc/Common.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -// Microsoft Visual C++ specific -#if defined(_MSC_VER) && (_MSC_VER >= 1020) -#pragma warning(disable : 4251 4266 4350 4503 4512 4514 4710 4820) -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "Exception.hpp" -#include "Export.hpp" -#include "Optional.hpp" - -using std::list; -using std::string; -using std::vector; - -// Forward decalarations and alias -namespace opencc { -class BinaryDict; -class Config; -class Conversion; -class ConversionChain; -class Converter; -class DartsDict; -class Dict; -class DictEntry; -class DictGroup; -class Lexicon; -class MultiValueDictEntry; -class NoValueDictEntry; -class Segmentation; -class Segments; -class SerializableDict; -class SingleValueDictEntry; -class TextDict; -typedef std::shared_ptr BinaryDictPtr; -typedef std::shared_ptr ConversionPtr; -typedef std::shared_ptr ConversionChainPtr; -typedef std::shared_ptr ConverterPtr; -typedef std::shared_ptr DartsDictPtr; -typedef std::shared_ptr DictPtr; -typedef std::shared_ptr DictGroupPtr; -typedef std::shared_ptr LexiconPtr; -typedef std::shared_ptr SegmentationPtr; -typedef std::shared_ptr SegmentsPtr; -typedef std::shared_ptr SerializableDictPtr; -typedef std::shared_ptr TextDictPtr; -} - -#ifndef PKGDATADIR -const string PACKAGE_DATA_DIRECTORY = ""; -#else // ifndef PKGDATADIR -const string PACKAGE_DATA_DIRECTORY = PKGDATADIR "/"; -#endif // ifndef PKGDATADIR - -#ifndef VERSION -#define VERSION "1.0.*" -#endif // ifndef VERSION diff --git a/maclibs/include/opencc/Config.hpp b/maclibs/include/opencc/Config.hpp deleted file mode 100644 index a71a00d0..00000000 --- a/maclibs/include/opencc/Config.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" - -namespace opencc { -/** -* Configuration loader -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT Config { -public: - Config(); - - virtual ~Config(); - - ConverterPtr NewFromString(const string& json, const string& configDirectory); - - ConverterPtr NewFromFile(const string& fileName); - -private: - void* internal; -}; -} diff --git a/maclibs/include/opencc/Conversion.hpp b/maclibs/include/opencc/Conversion.hpp deleted file mode 100644 index 6bfc455f..00000000 --- a/maclibs/include/opencc/Conversion.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** -* Conversion interface -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT Conversion { -public: - Conversion(DictPtr _dict) : dict(_dict) {} - - // Convert single phrase - string Convert(const string& phrase) const; - - // Convert single phrase - string Convert(const char* phrase) const; - - // Convert segmented text - SegmentsPtr Convert(const SegmentsPtr& input) const; - - const DictPtr GetDict() const { return dict; } - -private: - const DictPtr dict; -}; -} diff --git a/maclibs/include/opencc/ConversionChain.hpp b/maclibs/include/opencc/ConversionChain.hpp deleted file mode 100644 index db9e6251..00000000 --- a/maclibs/include/opencc/ConversionChain.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "Conversion.hpp" - -namespace opencc { -/** -* Chain of conversions -* Consists of a list of conversions. Converts input in sequence. -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT ConversionChain { -public: - ConversionChain(const list _conversions); - - SegmentsPtr Convert(const SegmentsPtr& input) const; - - const list GetConversions() const { return conversions; } - -private: - const list conversions; -}; -} diff --git a/maclibs/include/opencc/Converter.hpp b/maclibs/include/opencc/Converter.hpp deleted file mode 100644 index 65cdda2a..00000000 --- a/maclibs/include/opencc/Converter.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** -* Controller of segmentation and conversion -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT Converter { -public: - Converter(const string& _name, SegmentationPtr _segmentation, - ConversionChainPtr _conversionChain) - : name(_name), segmentation(_segmentation), - conversionChain(_conversionChain) {} - - string Convert(const string& text) const; - - size_t Convert(const char* input, char* output) const; - - const SegmentationPtr GetSegmentation() const { return segmentation; } - - const ConversionChainPtr GetConversionChain() const { - return conversionChain; - } - -private: - const string name; - const SegmentationPtr segmentation; - const ConversionChainPtr conversionChain; -}; -} diff --git a/maclibs/include/opencc/Dict.hpp b/maclibs/include/opencc/Dict.hpp deleted file mode 100644 index f923f378..00000000 --- a/maclibs/include/opencc/Dict.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "DictEntry.hpp" - -namespace opencc { -/** -* Abstract class of dictionary -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT Dict { -public: - /** - * Matches a word exactly and returns the DictEntry or Optional::Null(). - */ - virtual Optional Match(const char* word) const = 0; - - /** - * Matches a word exactly and returns the DictEntry or Optional::Null(). - */ - Optional Match(const string& word) const { - return Match(word.c_str()); - } - - /** - * Matches the longest matched prefix of a word. - * For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", - * the longest prefix of "banana" matched is "bana". - */ - virtual Optional MatchPrefix(const char* word) const; - - /** - * Matches the longest matched prefix of a word. - */ - Optional MatchPrefix(const string& word) const { - return MatchPrefix(word.c_str()); - } - - /** - * Returns all matched prefixes of a word, sorted by the length (desc). - * For example given a dictionary having "a", "an", "b", "ba", "ban", "bana", - * all the matched prefixes of "banana" are "bana", "ban", "ba", "b". - */ - virtual vector MatchAllPrefixes(const char* word) const; - - /** - * Returns all matched prefixes of a word, sorted by the length (desc). - */ - vector MatchAllPrefixes(const string& word) const { - return MatchAllPrefixes(word.c_str()); - } - - /** - * Returns the length of the longest key in the dictionary. - */ - virtual size_t KeyMaxLength() const = 0; - - /** - * Returns all entries in the dictionary. - */ - virtual LexiconPtr GetLexicon() const = 0; -}; -} diff --git a/maclibs/include/opencc/DictEntry.hpp b/maclibs/include/opencc/DictEntry.hpp deleted file mode 100644 index ecef4891..00000000 --- a/maclibs/include/opencc/DictEntry.hpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "UTF8Util.hpp" -#include "Segments.hpp" - -namespace opencc { -/** -* Key-values pair entry -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT DictEntry { -public: - virtual ~DictEntry() {} - - virtual const char* Key() const = 0; - - virtual vector Values() const = 0; - - virtual const char* GetDefault() const = 0; - - virtual size_t NumValues() const = 0; - - virtual string ToString() const = 0; - - size_t KeyLength() const { return strlen(Key()); } - - bool operator<(const DictEntry& that) const { - return strcmp(Key(), that.Key()) < 0; - } - - bool operator==(const DictEntry& that) const { - return strcmp(Key(), that.Key()) == 0; - } - - static bool PtrLessThan(const DictEntry* a, const DictEntry* b) { - return *a < *b; - } -}; - -class OPENCC_EXPORT NoValueDictEntry : public DictEntry { -public: - NoValueDictEntry(const string& _key) : key(_key) {} - - virtual ~NoValueDictEntry() {} - - virtual const char* Key() const { return key.c_str(); } - - virtual vector Values() const { return vector(); } - - virtual const char* GetDefault() const { return Key(); } - - virtual size_t NumValues() const { return 0; } - - virtual string ToString() const { return key; } - -private: - string key; -}; - -class OPENCC_EXPORT SingleValueDictEntry : public DictEntry { -public: - virtual const char* Value() const = 0; - - virtual vector Values() const { - return vector{Value()}; - } - - virtual const char* GetDefault() const { return Value(); } - - virtual size_t NumValues() const { return 1; } - - virtual string ToString() const { return string(Key()) + "\t" + Value(); } -}; - -class OPENCC_EXPORT StrSingleValueDictEntry : public SingleValueDictEntry { -public: - StrSingleValueDictEntry(const string& _key, const string& _value) - : key(_key), value(_value) {} - - virtual ~StrSingleValueDictEntry() {} - - virtual const char* Key() const { return key.c_str(); } - - virtual const char* Value() const { return value.c_str(); } - -private: - string key; - string value; -}; - -class OPENCC_EXPORT MultiValueDictEntry : public DictEntry { -public: - virtual const char* GetDefault() const { - if (NumValues() > 0) { - return Values().at(0); - } else { - return Key(); - } - } - - virtual string ToString() const; -}; - -class OPENCC_EXPORT StrMultiValueDictEntry : public MultiValueDictEntry { -public: - StrMultiValueDictEntry(const string& _key, const vector& _values) - : key(_key), values(_values) {} - - StrMultiValueDictEntry(const string& _key, const vector& _values) - : key(_key) { - values.reserve(_values.size()); - for (const char* str : _values) { - values.push_back(str); - } - } - - virtual ~StrMultiValueDictEntry() {} - - virtual const char* Key() const { return key.c_str(); } - - size_t NumValues() const { return values.size(); } - - vector Values() const { - vector values; - for (const string& value : this->values) { - values.push_back(value.c_str()); - } - return values; - } - -private: - string key; - vector values; -}; - -class OPENCC_EXPORT PtrDictEntry : public MultiValueDictEntry { -public: - PtrDictEntry(const char* _key, const vector& _values) - : key(_key), values(_values) {} - - virtual ~PtrDictEntry() {} - - virtual const char* Key() const { return key; } - - size_t NumValues() const { return values.size(); } - - vector Values() const { return values; } - -private: - const char* key; - vector values; -}; - -class OPENCC_EXPORT DictEntryFactory { -public: - static DictEntry* New(const string& key) { return new NoValueDictEntry(key); } - - static DictEntry* New(const string& key, const string& value) { - return new StrSingleValueDictEntry(key, value); - } - - static DictEntry* New(const string& key, const vector& values) { - return new StrMultiValueDictEntry(key, values); - } - - static DictEntry* New(const DictEntry* entry) { - if (entry->NumValues() == 0) { - return new NoValueDictEntry(entry->Key()); - } else if (entry->NumValues() == 1) { - const auto svEntry = static_cast(entry); - return new StrSingleValueDictEntry(svEntry->Key(), svEntry->Value()); - } else { - const auto mvEntry = static_cast(entry); - return new StrMultiValueDictEntry(mvEntry->Key(), mvEntry->Values()); - } - } -}; -} diff --git a/maclibs/include/opencc/DictGroup.hpp b/maclibs/include/opencc/DictGroup.hpp deleted file mode 100644 index 8098addd..00000000 --- a/maclibs/include/opencc/DictGroup.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "Dict.hpp" - -namespace opencc { -/** -* Group of dictionaries -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT DictGroup : public Dict { -public: - DictGroup(const list& dicts); - - static DictGroupPtr NewFromDict(const Dict& dict); - - virtual ~DictGroup(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word) const; - - virtual Optional MatchPrefix(const char* word) const; - - virtual vector MatchAllPrefixes(const char* word) const; - - virtual LexiconPtr GetLexicon() const; - - const list GetDicts() const { return dicts; } - -private: - const size_t keyMaxLength; - const list dicts; -}; -} diff --git a/maclibs/include/opencc/Exception.hpp b/maclibs/include/opencc/Exception.hpp deleted file mode 100644 index a1134e85..00000000 --- a/maclibs/include/opencc/Exception.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include -#include -#include - -#include "Export.hpp" - -#ifdef _MSC_VER - -// Until Visual Studio 2013 (12.0), C++ 11 "noexcept" qualifier is not supported -#define noexcept -#endif // ifdef _MSC_VER - -namespace opencc { - -class OPENCC_EXPORT Exception : public std::exception { -public: - Exception() {} - - virtual ~Exception() throw() {} - - Exception(const std::string& _message) : message(_message) {} - - virtual const char* what() const noexcept { return message.c_str(); } - -protected: - std::string message; -}; - -class OPENCC_EXPORT FileNotFound : public Exception { -public: - FileNotFound(const std::string& fileName) - : Exception(fileName + " not found or not accessible.") {} -}; - -class OPENCC_EXPORT FileNotWritable : public Exception { -public: - FileNotWritable(const std::string& fileName) - : Exception(fileName + " not writable.") {} -}; - -class OPENCC_EXPORT InvalidFormat : public Exception { -public: - InvalidFormat(const std::string& message) - : Exception("Invalid format: " + message) {} -}; - -class OPENCC_EXPORT InvalidTextDictionary : public InvalidFormat { -public: - InvalidTextDictionary(const std::string& _message, size_t lineNum) - : InvalidFormat("") { - std::ostringstream buffer; - buffer << "Invalid text dictionary at line " << lineNum << ": " << _message; - message = buffer.str(); - } -}; - -class OPENCC_EXPORT InvalidUTF8 : public Exception { -public: - InvalidUTF8(const std::string& _message) - : Exception("Invalid UTF8: " + _message) {} -}; - -class OPENCC_EXPORT ShouldNotBeHere : public Exception { -public: - ShouldNotBeHere() : Exception("ShouldNotBeHere! This must be a bug.") {} -}; - -} // namespace opencc diff --git a/maclibs/include/opencc/Export.hpp b/maclibs/include/opencc/Export.hpp deleted file mode 100644 index e511b8a4..00000000 --- a/maclibs/include/opencc/Export.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) -#define OPENCC_EXPORT -#define OPENCC_NO_EXPORT -#else // if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) -#ifndef OPENCC_EXPORT -#ifdef libopencc_EXPORTS - -/* We are building this library */ -#define OPENCC_EXPORT __declspec(dllexport) -#else // ifdef libopencc_EXPORTS - -/* We are using this library */ -#define OPENCC_EXPORT __declspec(dllimport) -#endif // ifdef libopencc_EXPORTS -#endif // ifndef OPENCC_EXPORT - -#ifndef OPENCC_NO_EXPORT -#define OPENCC_NO_EXPORT -#endif // ifndef OPENCC_NO_EXPORT -#endif // if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) diff --git a/maclibs/include/opencc/Lexicon.hpp b/maclibs/include/opencc/Lexicon.hpp deleted file mode 100644 index 1bb6ab6a..00000000 --- a/maclibs/include/opencc/Lexicon.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "DictEntry.hpp" - -namespace opencc { -/** -* Storage of all entries -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT Lexicon { -public: - Lexicon() {} - - ~Lexicon() { - for (DictEntry* entry : entries) { - delete entry; - } - } - - void Add(DictEntry* entry) { entries.push_back(entry); } - - void Sort() { - std::sort(entries.begin(), entries.end(), DictEntry::PtrLessThan); - } - - const DictEntry* At(size_t index) const { return entries.at(index); } - - size_t Length() const { return entries.size(); } - - vector::const_iterator begin() const { return entries.begin(); } - - vector::const_iterator end() const { return entries.end(); } - -private: - vector entries; -}; -} diff --git a/maclibs/include/opencc/MaxMatchSegmentation.hpp b/maclibs/include/opencc/MaxMatchSegmentation.hpp deleted file mode 100644 index ace021e6..00000000 --- a/maclibs/include/opencc/MaxMatchSegmentation.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "DictGroup.hpp" -#include "Segmentation.hpp" - -namespace opencc { -/** -* Implementation of maximal match segmentation -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT MaxMatchSegmentation : public Segmentation { -public: - MaxMatchSegmentation(const DictPtr _dict) : dict(_dict) {} - - virtual ~MaxMatchSegmentation() {} - - virtual SegmentsPtr Segment(const string& text) const; - - const DictPtr GetDict() const { return dict; } - -private: - const DictPtr dict; -}; -} diff --git a/maclibs/include/opencc/Optional.hpp b/maclibs/include/opencc/Optional.hpp deleted file mode 100644 index 9279101b..00000000 --- a/maclibs/include/opencc/Optional.hpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -namespace opencc { -/** -* A class that wraps type T into a nullable type. -* @ingroup opencc_cpp_api -*/ -template class Optional { -public: - /** - * The constructor of Optional. - */ - Optional(T actual) : isNull(false), data(actual) {} - - /** - * Returns true if the instance is null. - */ - bool IsNull() const { return isNull; } - - /** - * Returns the containing data of the instance. - */ - const T& Get() const { return data; } - - /** - * Constructs a null instance. - */ - static Optional Null() { return Optional(); } - -private: - Optional() : isNull(true) {} - - bool isNull; - T data; -}; - -/** -* Specialization of Optional for pointers. -* -* Reduce a bool. -*/ -template class Optional { -private: - Optional() : data(nullptr) {} - - typedef T* TPtr; - TPtr data; - -public: - Optional(TPtr actual) : data(actual) {} - - bool IsNull() const { return data == nullptr; } - - const TPtr& Get() const { return data; } - - static Optional Null() { return Optional(); } -}; -} \ No newline at end of file diff --git a/maclibs/include/opencc/Segments.hpp b/maclibs/include/opencc/Segments.hpp deleted file mode 100644 index 6225e1a4..00000000 --- a/maclibs/include/opencc/Segments.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" - -namespace opencc { -/** -* Segmented text -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT Segments { -public: - Segments() {} - - Segments(std::initializer_list initList) { - for (const string& item : initList) { - AddSegment(item); - } - } - - Segments(std::initializer_list initList) { - for (const string& item : initList) { - AddSegment(item); - } - } - - void AddSegment(const char* unmanagedString) { - indexes.push_back(std::make_pair(unmanaged.size(), false)); - unmanaged.push_back(unmanagedString); - } - - void AddSegment(const string& str) { - indexes.push_back(std::make_pair(managed.size(), true)); - managed.push_back(str); - } - - class iterator : public std::iterator { - public: - iterator(const Segments* const _segments, size_t _cursor) - : segments(_segments), cursor(_cursor) {} - - iterator& operator++() { - cursor++; - return *this; - } - - bool operator==(const iterator& that) const { - return cursor == that.cursor && segments == that.segments; - } - - bool operator!=(const iterator& that) const { - return !this->operator==(that); - } - - const char* operator*() const { return segments->At(cursor); } - - private: - const Segments* const segments; - size_t cursor; - }; - - const char* At(size_t cursor) const { - const auto& index = indexes[cursor]; - if (index.second) { - return managed[index.first].c_str(); - } else { - return unmanaged[index.first]; - } - } - - size_t Length() const { return indexes.size(); } - - iterator begin() const { return iterator(this, 0); } - - iterator end() const { return iterator(this, indexes.size()); } - - string ToString() const { - // TODO implement a nested structure to reduce concatenation, - // like a purely functional differential list - std::ostringstream buffer; - for (const char* segment : *this) { - buffer << segment; - } - return buffer.str(); - } - -private: - Segments(const Segments&) {} - - vector unmanaged; - vector managed; - // index, managed - vector> indexes; -}; -} diff --git a/maclibs/include/opencc/SerializableDict.hpp b/maclibs/include/opencc/SerializableDict.hpp deleted file mode 100644 index a02e53e6..00000000 --- a/maclibs/include/opencc/SerializableDict.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Dict.hpp" - -namespace opencc { -/** -* Serializable dictionary interface -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT SerializableDict { -public: - /** - * Serializes the dictionary and writes in to a file. - */ - virtual void SerializeToFile(FILE* fp) const = 0; - - /** - * Serializes the dictionary and writes in to a file. - */ - virtual void SerializeToFile(const string& fileName) const { - FILE* fp = fopen(fileName.c_str(), "wb"); - if (fp == NULL) { - throw FileNotWritable(fileName); - } - SerializeToFile(fp); - fclose(fp); - } - - template - static bool TryLoadFromFile(const string& fileName, - std::shared_ptr* dict) { - FILE* fp = -#ifdef _MSC_VER - // well, the 'GetPlatformString' shall return a 'wstring' - _wfopen(UTF8Util::GetPlatformString(fileName).c_str(), L"rb") -#else - fopen(UTF8Util::GetPlatformString(fileName).c_str(), "rb") -#endif // _MSC_VER - ; - - if (fp == NULL) { - return false; - } - std::shared_ptr loadedDict = DICT::NewFromFile(fp); - fclose(fp); - *dict = loadedDict; - return true; - } - - template - static std::shared_ptr NewFromFile(const string& fileName) { - std::shared_ptr dict; - if (!TryLoadFromFile(fileName, &dict)) { - throw FileNotFound(fileName); - } - return dict; - } -}; -} diff --git a/maclibs/include/opencc/SimpleConverter.hpp b/maclibs/include/opencc/SimpleConverter.hpp deleted file mode 100644 index 0dabefbb..00000000 --- a/maclibs/include/opencc/SimpleConverter.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __OPENCC_SIMPLECONVERTER_HPP_ -#define __OPENCC_SIMPLECONVERTER_HPP_ - -/** -* @defgroup opencc_simple_api OpenCC C++ Simple API -* -* Simple API in C++ language -*/ - -namespace opencc { -/** -* A high level converter -* This interface does not require C++11 to compile. -* @ingroup opencc_simple_api -*/ -class OPENCC_EXPORT SimpleConverter { -public: - /** - * Constructor of SimpleConverter - * @param configFileName File name of configuration. - */ - SimpleConverter(const std::string& configFileName); - - ~SimpleConverter(); - - /** - * Converts a text - * @param input Text to be converted. - */ - std::string Convert(const std::string& input) const; - - /** - * Converts a text - * @param input A C-Style string (terminated by '\0') to be converted. - */ - std::string Convert(const char* input) const; - - /** - * Converts a text - * @param input A C-Style string limited by a given length to be converted. - * @param length Maximal length in byte of the input string. - */ - std::string Convert(const char* input, size_t length) const; - - /** - * Converts a text and writes to an allocated buffer - * Please make sure the buffer has sufficent space. - * @param input A C-Style string (terminated by '\0') to be converted. - * @param output Buffer to write the converted text. - * @return Length of converted text. - */ - size_t Convert(const char* input, char* output) const; - - /** - * Converts a text and writes to an allocated buffer - * Please make sure the buffer has sufficent space. - * @param input A C-Style string limited by a given length to be converted. - * @param length Maximal length in byte of the input string. - * @param output Buffer to write the converted text. - * @return Length of converted text. - */ - size_t Convert(const char* input, size_t length, char* output) const; - -private: - const void* internalData; -}; - -} // namespace opencc - -#endif diff --git a/maclibs/include/opencc/TextDict.hpp b/maclibs/include/opencc/TextDict.hpp deleted file mode 100644 index 5000b27c..00000000 --- a/maclibs/include/opencc/TextDict.hpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include "Common.hpp" -#include "SerializableDict.hpp" - -namespace opencc { -/** -* Text dictionary -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT TextDict : public Dict, public SerializableDict { -public: - /** - * Constructor of TextDict. - * _lexicon must be sorted. - */ - TextDict(const LexiconPtr& _lexicon); - - virtual ~TextDict(); - - virtual size_t KeyMaxLength() const; - - virtual Optional Match(const char* word) const; - - virtual LexiconPtr GetLexicon() const; - - virtual void SerializeToFile(FILE* fp) const; - - /** - * Constructs a TextDict from another dictionary. - */ - static TextDictPtr NewFromDict(const Dict& dict); - - static TextDictPtr NewFromFile(FILE* fp); - - static TextDictPtr NewFromSortedFile(FILE* fp); - -private: - const size_t maxLength; - const LexiconPtr lexicon; -}; -} diff --git a/maclibs/include/opencc/UTF8Util.hpp b/maclibs/include/opencc/UTF8Util.hpp deleted file mode 100644 index ea03dc01..00000000 --- a/maclibs/include/opencc/UTF8Util.hpp +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2013 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#ifdef _MSC_VER -#define NOMINMAX -#include -#undef NOMINMAX -#endif // _MSC_VER - -#include "Common.hpp" - -namespace opencc { -/** -* UTF8 string utilities -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT UTF8Util { -public: - /** - * Detect UTF8 BOM and skip it. - */ - static void SkipUtf8Bom(FILE* fp); - - /** - * Returns the length in byte for the next UTF8 character. - * On error returns 0. - */ - static size_t NextCharLengthNoException(const char* str) { - char ch = *str; - if ((ch & 0xF0) == 0xE0) { - return 3; - } else if ((ch & 0x80) == 0x00) { - return 1; - } else if ((ch & 0xE0) == 0xC0) { - return 2; - } else if ((ch & 0xF8) == 0xF0) { - return 4; - } else if ((ch & 0xFC) == 0xF8) { - return 5; - } else if ((ch & 0xFE) == 0xFC) { - return 6; - } - return 0; - } - - /** - * Returns the length in byte for the next UTF8 character. - */ - static size_t NextCharLength(const char* str) { - size_t length = NextCharLengthNoException(str); - if (length == 0) { - throw InvalidUTF8(str); - } - return length; - } - - /** - * Returns the length in byte for the previous UTF8 character. - */ - static size_t PrevCharLength(const char* str) { - { - const size_t length = NextCharLengthNoException(str - 3); - if (length == 3) { - return length; - } - } - { - const size_t length = NextCharLengthNoException(str - 1); - if (length == 1) { - return length; - } - } - { - const size_t length = NextCharLengthNoException(str - 2); - if (length == 2) { - return length; - } - } - for (size_t i = 4; i <= 6; i++) { - const size_t length = NextCharLengthNoException(str - i); - if (length == i) { - return length; - } - } - throw InvalidUTF8(str); - } - - /** - * Returns the char* pointer over the next UTF8 character. - */ - static const char* NextChar(const char* str) { - return str + NextCharLength(str); - } - - /** - * Move the char* pointer before the previous UTF8 character. - */ - static const char* PrevChar(const char* str) { - return str - PrevCharLength(str); - } - - /** - * Returns the UTF8 length of a valid UTF8 string. - */ - static size_t Length(const char* str) { - size_t length = 0; - while (*str != '\0') { - str = NextChar(str); - length++; - } - return length; - } - - /** - * Finds a character in the same line. - * @param str The text to be searched in. - * @param ch The character to find. - * @return The pointer that points to the found chacter in str or EOL/EOF. - */ - static const char* FindNextInline(const char* str, const char ch) { - while (!IsLineEndingOrFileEnding(*str) && *str != ch) { - str = NextChar(str); - } - return str; - } - - /** - * Returns ture if the character is a line ending or end of file. - */ - static bool IsLineEndingOrFileEnding(const char ch) { - return ch == '\0' || ch == '\n' || ch == '\r'; - } - - /** - * Copies a substring with given length to a new std::string. - */ - static string FromSubstr(const char* str, size_t length) { - string newStr; - newStr.resize(length); - strncpy(const_cast(newStr.c_str()), str, length); - return newStr; - } - - /** - * Returns true if the given string is longer or as long as the given length. - */ - static bool NotShorterThan(const char* str, size_t byteLength) { - while (byteLength > 0) { - if (*str == '\0') { - return false; - } - byteLength--; - str++; - } - return true; - } - - /** - * Truncates a string with a maximal length in byte. - * No UTF8 character will be broken. - */ - static string TruncateUTF8(const char* str, size_t maxByteLength) { - string wordTrunc; - if (NotShorterThan(str, maxByteLength)) { - size_t len = 0; - const char* pStr = str; - for (;;) { - const size_t charLength = NextCharLength(pStr); - if (len + charLength > maxByteLength) { - break; - } - pStr += charLength; - len += charLength; - } - wordTrunc = FromSubstr(str, len); - } else { - wordTrunc = str; - } - return wordTrunc; - } - - /** - * Replaces all patterns in a string in place. - */ - static void ReplaceAll(string& str, const char* from, const char* to) { - string::size_type pos = 0; - string::size_type fromLen = strlen(from); - string::size_type toLen = strlen(to); - while ((pos = str.find(from, pos)) != string::npos) { - str.replace(pos, fromLen, to); - pos += toLen; - } - } - - /** - * Joins a string vector in to a string with a separator. - */ - static string Join(const vector& strings, const string& separator) { - std::ostringstream buffer; - bool first = true; - for (const auto& str : strings) { - if (!first) { - buffer << separator; - } - buffer << str; - first = false; - } - return buffer.str(); - } - - /** - * Joins a string vector in to a string. - */ - static string Join(const vector& strings) { - std::ostringstream buffer; - for (const auto& str : strings) { - buffer << str; - } - return buffer.str(); - } - - static void GetByteMap(const char* str, const size_t utf8Length, - vector* byteMap) { - if (byteMap->size() < utf8Length) { - byteMap->resize(utf8Length); - } - const char* pstr = str; - for (size_t i = 0; i < utf8Length; i++) { - (*byteMap)[i] = pstr - str; - pstr = NextChar(pstr); - } - } - -#ifdef _MSC_VER - static std::wstring GetPlatformString(const std::string& str) { - return U8ToU16(str); - } -#else - static std::string GetPlatformString(const std::string& str) { - return str; - } -#endif // _MSC_VER - - -#ifdef _MSC_VER - static std::string U16ToU8(const std::wstring& wstr) { - std::string ret; - int convcnt = WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wstr.length(), NULL, 0, NULL, NULL); - if (convcnt > 0) { - ret.resize(convcnt); - WideCharToMultiByte(CP_UTF8, 0, wstr.c_str(), wstr.length(), &ret[0], convcnt, NULL, NULL); - } - return ret; - } - - static std::wstring U8ToU16(const std::string& str) { - std::wstring ret; - int convcnt = MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), NULL, 0); - if (convcnt > 0) { - ret.resize(convcnt); - MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), &ret[0], convcnt); - } - return ret; - } -#endif // _MSC_VER -}; -} diff --git a/maclibs/include/opencc/opencc.h b/maclibs/include/opencc/opencc.h deleted file mode 100644 index 21b90469..00000000 --- a/maclibs/include/opencc/opencc.h +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Open Chinese Convert - * - * Copyright 2010-2014 BYVoid - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __OPENCC_H_ -#define __OPENCC_H_ - -#ifdef __cplusplus - -#include -#include "Export.hpp" -#include "SimpleConverter.hpp" - -extern "C" { -#else -#include -#endif - -#ifndef OPENCC_EXPORT -#define OPENCC_EXPORT -#endif - -/** -* @defgroup opencc_c_api OpenCC C API -* -* API in C language -*/ - -/** -* Filename of default Simplified to Traditional configuration -* -* @ingroup opencc_c_api -*/ -#define OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD "s2t.json" - -/** -* Filename of default Traditional to Simplified configuration -* -* @ingroup opencc_c_api -*/ -#define OPENCC_DEFAULT_CONFIG_TRAD_TO_SIMP "t2s.json" - -/** -* Type of opencc descriptor -* -* @ingroup opencc_c_api -*/ -typedef void* opencc_t; - -/** -* Makes an instance of opencc -* -* @param configFileName Location of configuration file. If this is set to NULL, -* OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD will be loaded. -* @return A description pointer of the newly allocated instance of -* opencc. On error the return value will be (opencc_t) -1. -* @ingroup opencc_c_api -*/ -OPENCC_EXPORT opencc_t opencc_open(const char* configFileName); -#ifdef _MSC_VER -/** -* Makes an instance of opencc (wide char / Unicode) -* -* @param configFileName Location of configuration file. If this is set to NULL, -* OPENCC_DEFAULT_CONFIG_SIMP_TO_TRAD will be loaded. -* @return A description pointer of the newly allocated instance of -* opencc. On error the return value will be (opencc_t) -1. -* @ingroup opencc_c_api -*/ -OPENCC_EXPORT opencc_t opencc_open_w(const wchar_t* configFileName); -#endif /* _MSC_VER */ - -/** -* Destroys an instance of opencc -* -* @param opencc The description pointer. -* @return 0 on success or non-zero number on failure. -* @ingroup opencc_c_api -*/ -OPENCC_EXPORT int opencc_close(opencc_t opencc); - -/** -* Converts UTF-8 string -* -* @param opencc The opencc description pointer. -* @param input The UTF-8 encoded string. -* @param length The maximum length in byte to convert. If length is (size_t)-1, -* the whole string (terminated by '\0') will be converted. -* @param output The buffer to store converted text. You MUST make sure this -* buffer has sufficient space. -* -* @return The length of converted string or (size_t)-1 on error. -* -* @ingroup opencc_c_api -*/ -OPENCC_EXPORT size_t opencc_convert_utf8_to_buffer(opencc_t opencc, - const char* input, - size_t length, - char* output); - -/** -* Converts UTF-8 string -* This function returns an allocated C-Style string, which stores -* the converted string. -* You MUST call opencc_convert_utf8_free() to release allocated memory. -* -* @param opencc The opencc description pointer. -* @param input The UTF-8 encoded string. -* @param length The maximum length in byte to convert. If length is (size_t)-1, -* the whole string (terminated by '\0') will be converted. -* -* @return The newly allocated UTF-8 string that stores text converted, -* or NULL on error. -* @ingroup opencc_c_api -*/ -OPENCC_EXPORT char* opencc_convert_utf8(opencc_t opencc, - const char* input, - size_t length); - -/** -* Releases allocated buffer by opencc_convert_utf8 -* -* @param str Pointer to the allocated string buffer by opencc_convert_utf8. -* -* @ingroup opencc_c_api -*/ -OPENCC_EXPORT void opencc_convert_utf8_free(char* str); - -/** -* Returns the last error message -* -* Note that this function is the only one which is NOT thread-safe. -* -* @ingroup opencc_c_api -*/ -OPENCC_EXPORT const char* opencc_error(void); - -#ifdef __cplusplus -} // extern "C" -#endif - -/** -* @defgroup opencc_cpp_api OpenCC C++ Comprehensive API -* -* Comprehensive API in C++ language -*/ - -#endif diff --git a/maclibs/include/tiff/tiff.h b/maclibs/include/tiff/tiff.h deleted file mode 100644 index fb39634c..00000000 --- a/maclibs/include/tiff/tiff.h +++ /dev/null @@ -1,681 +0,0 @@ -/* $Id: tiff.h,v 1.70 2016-01-23 21:20:34 erouault Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFF_ -#define _TIFF_ - -#include "tiffconf.h" - -/* - * Tag Image File Format (TIFF) - * - * Based on Rev 6.0 from: - * Developer's Desk - * Aldus Corporation - * 411 First Ave. South - * Suite 200 - * Seattle, WA 98104 - * 206-622-5500 - * - * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) - * - * For BigTIFF design notes see the following links - * http://www.remotesensing.org/libtiff/bigtiffdesign.html - * http://www.awaresystems.be/imaging/tiff/bigtiff.html - */ - -#define TIFF_VERSION_CLASSIC 42 -#define TIFF_VERSION_BIG 43 - -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 -#define MDI_LITTLEENDIAN 0x5045 -#define MDI_BIGENDIAN 0x4550 - -/* - * Intrinsic data types required by the file format: - * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * 64-bit quantities int64/uint64 - * strings unsigned char* - */ - -typedef TIFF_INT8_T int8; -typedef TIFF_UINT8_T uint8; - -typedef TIFF_INT16_T int16; -typedef TIFF_UINT16_T uint16; - -typedef TIFF_INT32_T int32; -typedef TIFF_UINT32_T uint32; - -typedef TIFF_INT64_T int64; -typedef TIFF_UINT64_T uint64; - -/* - * Some types as promoted in a variable argument list - * We use uint16_vap rather then directly using int, because this way - * we document the type we actually want to pass through, conceptually, - * rather then confusing the issue by merely stating the type it gets - * promoted to - */ - -typedef int uint16_vap; - -/* - * TIFF header. - */ -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ -} TIFFHeaderCommon; -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint32 tiff_diroff; /* byte offset to first directory */ -} TIFFHeaderClassic; -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint16 tiff_offsetsize; /* size of offsets, should be 8 */ - uint16 tiff_unused; /* unused word, should be 0 */ - uint64 tiff_diroff; /* byte offset to first directory */ -} TIFFHeaderBig; - - -/* - * NB: In the comments below, - * - items marked with a + are obsoleted by revision 5.0, - * - items marked with a ! are introduced in revision 6.0. - * - items marked with a % are introduced post revision 6.0. - * - items marked with a $ are obsoleted by revision 6.0. - * - items marked with a & are introduced by Adobe DNG specification. - */ - -/* - * Tag data type information. - * - * Note: RATIONALs are the ratio of two 32-bit integer values. - */ -typedef enum { - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ - TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ - TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ - TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ - TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ -} TIFFDataType; - -/* - * TIFF Tag Definitions. - */ -#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ -#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ -#define FILETYPE_PAGE 0x2 /* one page of many */ -#define FILETYPE_MASK 0x4 /* transparency mask */ -#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ -#define OFILETYPE_IMAGE 1 /* full resolution image data */ -#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ -#define OFILETYPE_PAGE 3 /* one page of many */ -#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ -#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ -#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ -#define TIFFTAG_COMPRESSION 259 /* data compression technique */ -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ -#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ -#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ -#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ -#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ -#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ -#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ -#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ -#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ -#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ -#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ -#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ -/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT */ -#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ -#define COMPRESSION_JBIG 34661 /* ISO JBIG */ -#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ -#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ -#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ -#define COMPRESSION_LZMA 34925 /* LZMA2 */ -#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ -#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ -#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ -#define PHOTOMETRIC_RGB 2 /* RGB color model */ -#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ -#define PHOTOMETRIC_MASK 4 /* $holdout mask */ -#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ -#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ -#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ -#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ -#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ -#define PHOTOMETRIC_CFA 32803 /* color filter array */ -#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ -#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ -#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ -#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ -#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ -#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ -#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ -#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ -#define TIFFTAG_FILLORDER 266 /* data order within a byte */ -#define FILLORDER_MSB2LSB 1 /* most significant -> least */ -#define FILLORDER_LSB2MSB 2 /* least significant -> most */ -#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ -#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ -#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ -#define TIFFTAG_MODEL 272 /* scanner model name/number */ -#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ -#define TIFFTAG_ORIENTATION 274 /* +image orientation */ -#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ -#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ -#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ -#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ -#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ -#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ -#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ -#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ -#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ -#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ -#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ -#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ -#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ -#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ -#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ -#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ -#define PLANARCONFIG_CONTIG 1 /* single image plane */ -#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ -#define TIFFTAG_PAGENAME 285 /* page name image is from */ -#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ -#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ -#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ -#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ -#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ -#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ -#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ -#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ -#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ -#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ -#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ -#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ -#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ -#define RESUNIT_NONE 1 /* no meaningful units */ -#define RESUNIT_INCH 2 /* english */ -#define RESUNIT_CENTIMETER 3 /* metric */ -#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ -#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ -#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ -#define TIFFTAG_SOFTWARE 305 /* name & release */ -#define TIFFTAG_DATETIME 306 /* creation date and time */ -#define TIFFTAG_ARTIST 315 /* creator of image */ -#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ -#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ -#define PREDICTOR_NONE 1 /* no prediction scheme used */ -#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ -#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ -#define TIFFTAG_WHITEPOINT 318 /* image white point */ -#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ -#define TIFFTAG_COLORMAP 320 /* RGB map for palette image */ -#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ -#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ -#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ -#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ -#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ -#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ -#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ -#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ -#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ -#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ -#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ -#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ -#define TIFFTAG_INKSET 332 /* !inks in separated image */ -#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ -#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ -#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ -#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ -#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ -#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ -#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ -#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ -#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ -#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ -#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ -#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ -#define SAMPLEFORMAT_INT 2 /* !signed integer data */ -#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ -#define SAMPLEFORMAT_VOID 4 /* !untyped data */ -#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ -#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ -#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ -#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ -#define TIFFTAG_CLIPPATH 343 /* %ClipPath - [Adobe TIFF technote 2] */ -#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits - [Adobe TIFF technote 2] */ -#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits - [Adobe TIFF technote 2] */ -#define TIFFTAG_INDEXED 346 /* %Indexed - [Adobe TIFF Technote 3] */ -#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ -#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ -/* Tags 400-435 are from the TIFF/FX spec */ -#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ -#define TIFFTAG_PROFILETYPE 401 /* ! */ -#define PROFILETYPE_UNSPECIFIED 0 /* ! */ -#define PROFILETYPE_G3_FAX 1 /* ! */ -#define TIFFTAG_FAXPROFILE 402 /* ! */ -#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ -#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ -#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ -#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ -#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ -#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ -#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ -#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ -#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ -#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ -#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ -#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ -#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ -#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ -#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ -#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ -#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ -#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ -/* - * Tags 512-521 are obsoleted by Technical Note #2 which specifies a - * revised JPEG-in-TIFF scheme. - */ -#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ -#define JPEGPROC_BASELINE 1 /* !baseline sequential */ -#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ -#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ -#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ -#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ -#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ -#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ -#define TIFFTAG_JPEGQTABLES 519 /* !Q matrix offsets */ -#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ -#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ -#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ -#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ -#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ -#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ -#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ -#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ -#define TIFFTAG_XMLPACKET 700 /* %XML packet - [Adobe XMP Specification, - January 2004 */ -#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID - [Adobe TIFF technote] */ -/* tags 32952-32956 are private tags registered to Island Graphics */ -#define TIFFTAG_REFPTS 32953 /* image reference points */ -#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ -#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ -#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ -/* tags 32995-32999 are private tags registered to SGI */ -#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ -#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ -#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ -#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ -/* tags 33300-33309 are private tags registered to Pixar */ -/* - * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH - * are set when an image has been cropped out of a larger image. - * They reflect the size of the original uncropped image. - * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used - * to determine the position of the smaller image in the larger one. - */ -#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ -#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ - /* Tags 33302-33306 are used to identify special image modes and data - * used by Pixar's texture formats. - */ -#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ -#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ -#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ -#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 -#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 -/* tag 33405 is a private tag registered to Eastman Kodak */ -#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ -#define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */ -#define TIFFTAG_CFAPATTERN 33422 /* color filter array pattern */ -/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ -#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ -/* IPTC TAG from RichTIFF specifications */ -#define TIFFTAG_RICHTIFFIPTC 33723 -/* 34016-34029 are reserved for ANSI IT8 TIFF/IT */ -#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ -/* tag 34929 is a private tag registered to FedEx */ -#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ -#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ -/* Adobe Digital Negative (DNG) format tags */ -#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ -#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ -#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ -#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model - name */ -#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space - mapping */ -#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ -#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ -#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for - the BlackLevel tag */ -#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ -#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level - differences (columns) */ -#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level - differences (rows) */ -#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding - level */ -#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ -#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image - area */ -#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image - area */ -#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space - transformation matrix 1 */ -#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space - transformation matrix 2 */ -#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ -#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ -#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction - matrix 1 */ -#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction - matrix 2 */ -#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw - values*/ -#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in - linear reference space */ -#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in - x-y chromaticity - coordinates */ -#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero - point */ -#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ -#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of - sharpening */ -#define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of - the green pixels in the - blue/green rows track the - values of the green pixels - in the red/green rows */ -#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ -#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ -#define TIFFTAG_LENSINFO 50736 /* info about the lens */ -#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ -#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the - camera's anti-alias filter */ -#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ -#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ -#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote - tag is safe to preserve - along with the rest of the - EXIF data */ -#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ -#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ -#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ -#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for - the raw image data */ -#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original - raw file */ -#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original - raw file */ -#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels - of the sensor */ -#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates - of fully masked pixels */ -#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ -#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space - into ICC profile space */ -#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ -#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ -/* tag 65535 is an undefined tag used by Eastman Kodak */ -#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ - -/* - * The following are ``pseudo tags'' that can be used to control - * codec-specific functionality. These tags are not written to file. - * Note that these values start at 0xffff+1 so that they'll never - * collide with Aldus-assigned tags. - * - * If you want your private pseudo tags ``registered'' (i.e. added to - * this file), please post a bug report via the tracking system at - * http://www.remotesensing.org/libtiff/bugs.html with the appropriate - * C definitions to add. - */ -#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ -#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ -#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ -#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ -#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ -#define FAXMODE_WORDALIGN 0x0008 /* word align row */ -#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ -#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ -/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ -#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ -#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ -#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ -#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ -#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ -#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ -/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ -#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ -#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ -#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ -#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ -#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ -#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ -#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ -#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ -/* 65550-65556 are allocated to Oceana Matrix */ -#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ -#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ -#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ -#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ -#define DCSIMAGERFILTER_IR 0 /* infrared filter */ -#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ -#define DCSIMAGERFILTER_CFA 2 /* color filter array */ -#define DCSIMAGERFILTER_OTHER 3 /* other filter */ -#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ -#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ -#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ -#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ -#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ -#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ -#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ -#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ -/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ -#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ -#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ -/* 65559 is allocated to Oceana Matrix */ -#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ -#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ -#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ -#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ -#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ -#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ -#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ -#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ -#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ -#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ -#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ -#define PERSAMPLE_MERGED 0 /* present as a single value */ -#define PERSAMPLE_MULTI 1 /* present as multiple values */ - -/* - * EXIF tags - */ -#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ -#define EXIFTAG_FNUMBER 33437 /* F number */ -#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ -#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ -#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ -#define EXIFTAG_OECF 34856 /* Optoelectric conversion - factor */ -#define EXIFTAG_EXIFVERSION 36864 /* Exif version */ -#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original - data generation */ -#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital - data generation */ -#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ -#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ -#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ -#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ -#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ -#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ -#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ -#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ -#define EXIFTAG_METERINGMODE 37383 /* Metering mode */ -#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ -#define EXIFTAG_FLASH 37385 /* Flash */ -#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ -#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ -#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ -#define EXIFTAG_USERCOMMENT 37510 /* User comments */ -#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ -#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ -#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ -#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ -#define EXIFTAG_COLORSPACE 40961 /* Color space information */ -#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ -#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ -#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ -#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ -#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ -#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ -#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ -#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ -#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ -#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ -#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ -#define EXIFTAG_FILESOURCE 41728 /* File source */ -#define EXIFTAG_SCENETYPE 41729 /* Scene type */ -#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ -#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ -#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ -#define EXIFTAG_WHITEBALANCE 41987 /* White balance */ -#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ -#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ -#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_CONTRAST 41992 /* Contrast */ -#define EXIFTAG_SATURATION 41993 /* Saturation */ -#define EXIFTAG_SHARPNESS 41994 /* Sharpness */ -#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ -#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ - -#endif /* _TIFF_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/maclibs/include/tiff/tiffconf.h b/maclibs/include/tiff/tiffconf.h deleted file mode 100644 index f37b0b52..00000000 --- a/maclibs/include/tiff/tiffconf.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - Configuration defines for Qt. - This file maintained for backward compatibility. Do not use definitions - from this file in your programs. -*/ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ - -#include - -/* Signed 16-bit type */ -#define TIFF_INT16_T qint16 - -/* Signed 32-bit type */ -#define TIFF_INT32_T qint32 - -/* Signed 64-bit type */ -#define TIFF_INT64_T qint64 - -/* Signed 8-bit type */ -#define TIFF_INT8_T qint8 - -/* Unsigned 16-bit type */ -#define TIFF_UINT16_T quint16 - -/* Unsigned 32-bit type */ -#define TIFF_UINT32_T quint32 - -/* Unsigned 64-bit type */ -#define TIFF_UINT64_T quint64 - -/* Unsigned 8-bit type */ -#define TIFF_UINT8_T quint8 - -/* Signed size type */ -#if QT_POINTER_SIZE == 4 -#define TIFF_SSIZE_T qint32 -#else -#define TIFF_SSIZE_T qint64 -#endif - -/* Pointer difference type */ -#define TIFF_PTRDIFF_T ptrdiff_t - -/* Define to 1 if the system has the type `int16'. */ -/* #undef HAVE_INT16 */ - -/* Define to 1 if the system has the type `int32'. */ -/* #undef HAVE_INT32 */ - -/* Define to 1 if the system has the type `int8'. */ -/* #undef HAVE_INT8 */ - -/* Compatibility stuff. */ - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_LSB2MSB - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#if (Q_BYTE_ORDER == Q_BIG_ENDIAN) -#define HOST_BIGENDIAN 1 -#else -#define HOST_BIGENDIAN 0 -#endif - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Support JPEG compression (requires IJG JPEG library) */ -/* #undef JPEG_SUPPORT */ - -/* Support LogLuv high dynamic range encoding */ -#define LOGLUV_SUPPORT 1 - -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 - -/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation - fails with unpatched IJG JPEG library) */ -/* #undef OJPEG_SUPPORT */ - -/* Support Macintosh PackBits algorithm */ -#define PACKBITS_SUPPORT 1 - -/* Support Pixar log-format algorithm (requires Zlib) */ -#define PIXARLOG_SUPPORT 1 - -/* Support ThunderScan 4-bit RLE algorithm */ -#define THUNDER_SUPPORT 1 - -/* Support Deflate compression */ -#define ZIP_SUPPORT 1 - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP - -/* Enable SubIFD tag (330) support */ -#define SUBIFD_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 - -/* Support MS MDI magic number files as TIFF */ -#define MDI_SUPPORT 1 - -/* - * Feature support definitions. - * XXX: These macros are obsoleted. Don't use them in your apps! - * Macros stays here for backward compatibility and should be always defined. - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT - -#endif /* _TIFFCONF_ */ diff --git a/maclibs/include/tiff/tiffio.h b/maclibs/include/tiff/tiffio.h deleted file mode 100644 index ef61b5c0..00000000 --- a/maclibs/include/tiff/tiffio.h +++ /dev/null @@ -1,560 +0,0 @@ -/* $Id: tiffio.h,v 1.94 2017-01-11 19:02:49 erouault Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIO_ -#define _TIFFIO_ - -/* - * TIFF I/O Library Definitions. - */ -#include "tiff.h" -#include "tiffvers.h" - -/* - * TIFF is defined as an incomplete type to hide the - * library's internal data structures from clients. - */ -typedef struct tiff TIFF; - -/* - * The following typedefs define the intrinsic size of - * data types used in the *exported* interfaces. These - * definitions depend on the proper definition of types - * in tiff.h. Note also that the varargs interface used - * to pass tag types and values uses the types defined in - * tiff.h directly. - * - * NB: ttag_t is unsigned int and not unsigned short because - * ANSI C requires that the type before the ellipsis be a - * promoted type (i.e. one of int, unsigned int, pointer, - * or double) and because we defined pseudo-tags that are - * outside the range of legal Aldus-assigned tags. - * NB: tsize_t is int32 and not uint32 because some functions - * return -1. - * NB: toff_t is not off_t for many reasons; TIFFs max out at - * 32-bit file offsets, and BigTIFF maxes out at 64-bit - * offsets being the most important, and to ensure use of - * a consistently unsigned type across architectures. - * Prior to libtiff 4.0, this was an unsigned 32 bit type. - */ -/* - * this is the machine addressing size type, only it's signed, so make it - * int32 on 32bit machines, int64 on 64bit machines - */ -typedef TIFF_SSIZE_T tmsize_t; -typedef uint64 toff_t; /* file offset */ -/* the following are deprecated and should be replaced by their defining - counterparts */ -typedef uint32 ttag_t; /* directory tag */ -typedef uint16 tdir_t; /* directory index */ -typedef uint16 tsample_t; /* sample number */ -typedef uint32 tstrile_t; /* strip or tile number */ -typedef tstrile_t tstrip_t; /* strip number */ -typedef tstrile_t ttile_t; /* tile number */ -typedef tmsize_t tsize_t; /* i/o size in bytes */ -typedef void* tdata_t; /* image data ref */ - -#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) -#define __WIN32__ -#endif - -/* - * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c - * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). - * - * By default tif_unix.c is assumed. - */ - -#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) -# define AVOID_WIN32_FILEIO -# endif -#endif - -#if defined(USE_WIN32_FILEIO) -# define VC_EXTRALEAN -# include -# ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ -# else -typedef HFILE thandle_t; /* client data handle */ -# endif /* __WIN32__ */ -#else -typedef void* thandle_t; /* client data handle */ -#endif /* USE_WIN32_FILEIO */ - -/* - * Flags to pass to TIFFPrintDirectory to control - * printing of data structures that are potentially - * very large. Bit-or these flags to enable printing - * multiple items. - */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ - -/* - * Colour conversion stuff - */ - -/* reference white */ -#define D65_X0 (95.0470F) -#define D65_Y0 (100.0F) -#define D65_Z0 (108.8827F) - -#define D50_X0 (96.4250F) -#define D50_Y0 (100.0F) -#define D50_Z0 (82.4680F) - -/* Structure for holding information about a display device. */ - -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ - -typedef struct { - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ - uint32 d_Vrwg; - uint32 d_Vrwb; - float d_Y0R; /* Residual light for black pixel */ - float d_Y0G; - float d_Y0B; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; -} TIFFDisplay; - -typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; -} TIFFYCbCrToRGB; - -typedef struct { /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ -#define CIELABTORGB_TABLE_RANGE 1500 - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ - TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ -} TIFFCIELabToRGB; - -/* - * RGBA-style image support. - */ -typedef struct _TIFFRGBAImage TIFFRGBAImage; -/* - * The image reading and conversion routines invoke - * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are - * provided to convert/copy raw image data to 8-bit - * packed ABGR format rasters. Applications can supply - * alternate routines that unpack the data into a - * different format or, for example, unpack the data - * and draw the unpacked raster on the display. - */ -typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*); -typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); -/* - * RGBA-reader state. - */ -struct _TIFFRGBAImage { - TIFF* tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 req_orientation; /* requested orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap palette */ - uint16* greencmap; - uint16* bluecmap; - /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); - /* put decoded strip/tile */ - union { - void (*any)(TIFFRGBAImage*); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; - TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ - TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ - TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - - uint8* UaToAa; /* Unassociated alpha to associated alpha conversion LUT */ - uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ - - int row_offset; - int col_offset; -}; - -/* - * Macros for extracting components from the - * packed ABGR form returned by TIFFReadRGBAImage. - */ -#define TIFFGetR(abgr) ((abgr) & 0xff) -#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) -#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) -#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) - -/* - * A CODEC is a software package that implements decoding, - * encoding, or decoding+encoding of a compression algorithm. - * The library provides a collection of builtin codecs. - * More codecs may be registered through calls to the library - * and/or the builtin implementations may be overridden. - */ -typedef int (*TIFFInitMethod)(TIFF*, int); -typedef struct { - char* name; - uint16 scheme; - TIFFInitMethod init; -} TIFFCodec; - -#include -#include - -/* share internal LogLuv conversion routines? */ -#ifndef LOGLUV_PUBLIC -#define LOGLUV_PUBLIC 1 -#endif - -#if !defined(__GNUC__) && !defined(__attribute__) -# define __attribute__(x) /*nothing*/ -#endif - -#if defined(c_plusplus) || defined(__cplusplus) -extern "C" { -#endif -typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); -typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); -typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); -typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); -typedef int (*TIFFCloseProc)(thandle_t); -typedef toff_t (*TIFFSizeProc)(thandle_t); -typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); -typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); -typedef void (*TIFFExtendProc)(TIFF*); - -extern const char* TIFFGetVersion(void); - -extern const TIFFCodec* TIFFFindCODEC(uint16); -extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); -extern void TIFFUnRegisterCODEC(TIFFCodec*); -extern int TIFFIsCODECConfigured(uint16); -extern TIFFCodec* TIFFGetConfiguredCODECs(void); - -/* - * Auxiliary functions. - */ - -extern void* _TIFFmalloc(tmsize_t s); -extern void* _TIFFcalloc(tmsize_t nmemb, tmsize_t siz); -extern void* _TIFFrealloc(void* p, tmsize_t s); -extern void _TIFFmemset(void* p, int v, tmsize_t c); -extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); -extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); -extern void _TIFFfree(void* p); - -/* -** Stuff, related to tag handling and creating custom tags. -*/ -extern int TIFFGetTagListCount( TIFF * ); -extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); - -#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ -#define TIFF_VARIABLE -1 /* marker for variable length tags */ -#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ - -#define FIELD_CUSTOM 65 - -typedef struct _TIFFField TIFFField; -typedef struct _TIFFFieldArray TIFFFieldArray; - -extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); -extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); -extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); - -extern uint32 TIFFFieldTag(const TIFFField*); -extern const char* TIFFFieldName(const TIFFField*); -extern TIFFDataType TIFFFieldDataType(const TIFFField*); -extern int TIFFFieldPassCount(const TIFFField*); -extern int TIFFFieldReadCount(const TIFFField*); -extern int TIFFFieldWriteCount(const TIFFField*); - -typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); -typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); - -typedef struct { - TIFFVSetMethod vsetfield; /* tag set routine */ - TIFFVGetMethod vgetfield; /* tag get routine */ - TIFFPrintMethod printdir; /* directory print routine */ -} TIFFTagMethods; - -extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); -extern void *TIFFGetClientInfo(TIFF *, const char *); -extern void TIFFSetClientInfo(TIFF *, void *, const char *); - -extern void TIFFCleanup(TIFF* tif); -extern void TIFFClose(TIFF* tif); -extern int TIFFFlush(TIFF* tif); -extern int TIFFFlushData(TIFF* tif); -extern int TIFFGetField(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); -extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); -extern int TIFFReadDirectory(TIFF* tif); -extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); -extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); -extern uint64 TIFFScanlineSize64(TIFF* tif); -extern tmsize_t TIFFScanlineSize(TIFF* tif); -extern uint64 TIFFRasterScanlineSize64(TIFF* tif); -extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); -extern uint64 TIFFStripSize64(TIFF* tif); -extern tmsize_t TIFFStripSize(TIFF* tif); -extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); -extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); -extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); -extern uint64 TIFFTileRowSize64(TIFF* tif); -extern tmsize_t TIFFTileRowSize(TIFF* tif); -extern uint64 TIFFTileSize64(TIFF* tif); -extern tmsize_t TIFFTileSize(TIFF* tif); -extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); -extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); -extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -extern int TIFFFileno(TIFF*); -extern int TIFFSetFileno(TIFF*, int); -extern thandle_t TIFFClientdata(TIFF*); -extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); -extern int TIFFGetMode(TIFF*); -extern int TIFFSetMode(TIFF*, int); -extern int TIFFIsTiled(TIFF*); -extern int TIFFIsByteSwapped(TIFF*); -extern int TIFFIsUpSampled(TIFF*); -extern int TIFFIsMSB2LSB(TIFF*); -extern int TIFFIsBigEndian(TIFF*); -extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); -extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); -extern TIFFSeekProc TIFFGetSeekProc(TIFF*); -extern TIFFCloseProc TIFFGetCloseProc(TIFF*); -extern TIFFSizeProc TIFFGetSizeProc(TIFF*); -extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); -extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); -extern uint32 TIFFCurrentRow(TIFF*); -extern uint16 TIFFCurrentDirectory(TIFF*); -extern uint16 TIFFNumberOfDirectories(TIFF*); -extern uint64 TIFFCurrentDirOffset(TIFF*); -extern uint32 TIFFCurrentStrip(TIFF*); -extern uint32 TIFFCurrentTile(TIFF* tif); -extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); -extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); -extern int TIFFSetupStrips(TIFF *); -extern int TIFFWriteCheck(TIFF*, int, const char *); -extern void TIFFFreeDirectory(TIFF*); -extern int TIFFCreateDirectory(TIFF*); -extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); -extern int TIFFCreateEXIFDirectory(TIFF*); -extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, uint16); -extern int TIFFSetSubDirectory(TIFF*, uint64); -extern int TIFFUnlinkDirectory(TIFF*, uint16); -extern int TIFFSetField(TIFF*, uint32, ...); -extern int TIFFVSetField(TIFF*, uint32, va_list); -extern int TIFFUnsetField(TIFF*, uint32); -extern int TIFFWriteDirectory(TIFF *); -extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); -extern int TIFFCheckpointDirectory(TIFF *); -extern int TIFFRewriteDirectory(TIFF *); - -#if defined(c_plusplus) || defined(__cplusplus) -extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, - int = ORIENTATION_BOTLEFT, int = 0); -#else -extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); -#endif - -extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); -extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -extern int TIFFReadRGBAStripExt(TIFF*, uint32, uint32 *, int stop_on_error ); -extern int TIFFReadRGBATileExt(TIFF*, uint32, uint32, uint32 *, int stop_on_error ); -extern int TIFFRGBAImageOK(TIFF*, char [1024]); -extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); -extern void TIFFRGBAImageEnd(TIFFRGBAImage*); -extern TIFF* TIFFOpen(const char*, const char*); -# ifdef __WIN32__ -extern TIFF* TIFFOpenW(const wchar_t*, const char*); -# endif /* __WIN32__ */ -extern TIFF* TIFFFdOpen(int, const char*, const char*); -extern TIFF* TIFFClientOpen(const char*, const char*, - thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, - TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); -extern const char* TIFFFileName(TIFF*); -extern const char* TIFFSetFileName(TIFF*, const char *); -extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); -extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); -extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); -extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); -extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFNumberOfTiles(TIFF*); -extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); -extern uint32 TIFFNumberOfStrips(TIFF*); -extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); -extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ -extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); -extern void TIFFSwabShort(uint16*); -extern void TIFFSwabLong(uint32*); -extern void TIFFSwabLong8(uint64*); -extern void TIFFSwabFloat(float*); -extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); -extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); -extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); -extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); -extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); -extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); -extern void TIFFReverseBits(uint8* cp, tmsize_t n); -extern const unsigned char* TIFFGetBitRevTable(int); - -#ifdef LOGLUV_PUBLIC -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. -extern double LogL16toY(int); -extern double LogL10toY(int); -extern void XYZtoRGB24(float*, uint8*); -extern int uv_decode(double*, double*, int); -extern void LogLuv24toXYZ(uint32, float*); -extern void LogLuv32toXYZ(uint32, float*); -#if defined(c_plusplus) || defined(__cplusplus) -extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); -extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); -extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); -#else -extern int LogL16fromY(double, int); -extern int LogL10fromY(double, int); -extern int uv_encode(double, double, int); -extern uint32 LogLuv24fromXYZ(float*, int); -extern uint32 LogLuv32fromXYZ(float*, int); -#endif -#endif /* LOGLUV_PUBLIC */ - -extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); -extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, - float *, float *, float *); -extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, - uint32 *, uint32 *, uint32 *); - -extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); -extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, - uint32 *, uint32 *, uint32 *); - -/**************************************************************************** - * O B S O L E T E D I N T E R F A C E S - * - * Don't use this stuff in your applications, it may be removed in the future - * libtiff versions. - ****************************************************************************/ -typedef struct { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ -} TIFFFieldInfo; - -extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); - -#if defined(c_plusplus) || defined(__cplusplus) -} -#endif - -#endif /* _TIFFIO_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/maclibs/include/tiff/tiffvers.h b/maclibs/include/tiff/tiffvers.h deleted file mode 100644 index 890e433d..00000000 --- a/maclibs/include/tiff/tiffvers.h +++ /dev/null @@ -1,9 +0,0 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.8\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." -/* - * This define can be used in code that requires - * compilation-related definitions specific to a - * version or versions of the library. Runtime - * version checking should be done based on the - * string returned by TIFFGetVersion. - */ -#define TIFFLIB_VERSION 20170521 diff --git a/maclibs/include/vorbis/codec.h b/maclibs/include/vorbis/codec.h deleted file mode 100644 index 999aa335..00000000 --- a/maclibs/include/vorbis/codec.h +++ /dev/null @@ -1,243 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - - ******************************************************************** - - function: libvorbis codec headers - last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $ - - ********************************************************************/ - -#ifndef _vorbis_codec_h_ -#define _vorbis_codec_h_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include - -typedef struct vorbis_info{ - int version; - int channels; - long rate; - - /* The below bitrate declarations are *hints*. - Combinations of the three values carry the following implications: - - all three set to the same value: - implies a fixed rate bitstream - only nominal set: - implies a VBR stream that averages the nominal bitrate. No hard - upper/lower limit - upper and or lower set: - implies a VBR bitstream that obeys the bitrate limits. nominal - may also be set to give a nominal rate. - none set: - the coder does not care to speculate. - */ - - long bitrate_upper; - long bitrate_nominal; - long bitrate_lower; - long bitrate_window; - - void *codec_setup; -} vorbis_info; - -/* vorbis_dsp_state buffers the current vorbis audio - analysis/synthesis state. The DSP state belongs to a specific - logical bitstream ****************************************************/ -typedef struct vorbis_dsp_state{ - int analysisp; - vorbis_info *vi; - - float **pcm; - float **pcmret; - int pcm_storage; - int pcm_current; - int pcm_returned; - - int preextrapolate; - int eofflag; - - long lW; - long W; - long nW; - long centerW; - - ogg_int64_t granulepos; - ogg_int64_t sequence; - - ogg_int64_t glue_bits; - ogg_int64_t time_bits; - ogg_int64_t floor_bits; - ogg_int64_t res_bits; - - void *backend_state; -} vorbis_dsp_state; - -typedef struct vorbis_block{ - /* necessary stream state for linking to the framing abstraction */ - float **pcm; /* this is a pointer into local storage */ - oggpack_buffer opb; - - long lW; - long W; - long nW; - int pcmend; - int mode; - - int eofflag; - ogg_int64_t granulepos; - ogg_int64_t sequence; - vorbis_dsp_state *vd; /* For read-only access of configuration */ - - /* local storage to avoid remallocing; it's up to the mapping to - structure it */ - void *localstore; - long localtop; - long localalloc; - long totaluse; - struct alloc_chain *reap; - - /* bitmetrics for the frame */ - long glue_bits; - long time_bits; - long floor_bits; - long res_bits; - - void *internal; - -} vorbis_block; - -/* vorbis_block is a single block of data to be processed as part of -the analysis/synthesis stream; it belongs to a specific logical -bitstream, but is independent from other vorbis_blocks belonging to -that logical bitstream. *************************************************/ - -struct alloc_chain{ - void *ptr; - struct alloc_chain *next; -}; - -/* vorbis_info contains all the setup information specific to the - specific compression/decompression mode in progress (eg, - psychoacoustic settings, channel setup, options, codebook - etc). vorbis_info and substructures are in backends.h. -*********************************************************************/ - -/* the comments are not part of vorbis_info so that vorbis_info can be - static storage */ -typedef struct vorbis_comment{ - /* unlimited user comment fields. libvorbis writes 'libvorbis' - whatever vendor is set to in encode */ - char **user_comments; - int *comment_lengths; - int comments; - char *vendor; - -} vorbis_comment; - - -/* libvorbis encodes in two abstraction layers; first we perform DSP - and produce a packet (see docs/analysis.txt). The packet is then - coded into a framed OggSquish bitstream by the second layer (see - docs/framing.txt). Decode is the reverse process; we sync/frame - the bitstream and extract individual packets, then decode the - packet back into PCM audio. - - The extra framing/packetizing is used in streaming formats, such as - files. Over the net (such as with UDP), the framing and - packetization aren't necessary as they're provided by the transport - and the streaming layer is not used */ - -/* Vorbis PRIMITIVES: general ***************************************/ - -extern void vorbis_info_init(vorbis_info *vi); -extern void vorbis_info_clear(vorbis_info *vi); -extern int vorbis_info_blocksize(vorbis_info *vi,int zo); -extern void vorbis_comment_init(vorbis_comment *vc); -extern void vorbis_comment_add(vorbis_comment *vc, const char *comment); -extern void vorbis_comment_add_tag(vorbis_comment *vc, - const char *tag, const char *contents); -extern char *vorbis_comment_query(vorbis_comment *vc, const char *tag, int count); -extern int vorbis_comment_query_count(vorbis_comment *vc, const char *tag); -extern void vorbis_comment_clear(vorbis_comment *vc); - -extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb); -extern int vorbis_block_clear(vorbis_block *vb); -extern void vorbis_dsp_clear(vorbis_dsp_state *v); -extern double vorbis_granule_time(vorbis_dsp_state *v, - ogg_int64_t granulepos); - -extern const char *vorbis_version_string(void); - -/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/ - -extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi); -extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op); -extern int vorbis_analysis_headerout(vorbis_dsp_state *v, - vorbis_comment *vc, - ogg_packet *op, - ogg_packet *op_comm, - ogg_packet *op_code); -extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals); -extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals); -extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb); -extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op); - -extern int vorbis_bitrate_addblock(vorbis_block *vb); -extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd, - ogg_packet *op); - -/* Vorbis PRIMITIVES: synthesis layer *******************************/ -extern int vorbis_synthesis_idheader(ogg_packet *op); -extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc, - ogg_packet *op); - -extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi); -extern int vorbis_synthesis_restart(vorbis_dsp_state *v); -extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op); -extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op); -extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb); -extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm); -extern int vorbis_synthesis_lapout(vorbis_dsp_state *v,float ***pcm); -extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples); -extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op); - -extern int vorbis_synthesis_halfrate(vorbis_info *v,int flag); -extern int vorbis_synthesis_halfrate_p(vorbis_info *v); - -/* Vorbis ERRORS and return codes ***********************************/ - -#define OV_FALSE -1 -#define OV_EOF -2 -#define OV_HOLE -3 - -#define OV_EREAD -128 -#define OV_EFAULT -129 -#define OV_EIMPL -130 -#define OV_EINVAL -131 -#define OV_ENOTVORBIS -132 -#define OV_EBADHEADER -133 -#define OV_EVERSION -134 -#define OV_ENOTAUDIO -135 -#define OV_EBADPACKET -136 -#define OV_EBADLINK -137 -#define OV_ENOSEEK -138 - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - diff --git a/maclibs/include/vorbis/vorbisfile.h b/maclibs/include/vorbis/vorbisfile.h deleted file mode 100644 index 9271331e..00000000 --- a/maclibs/include/vorbis/vorbisfile.h +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************** - * * - * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * - * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * - * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * - * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * - * * - * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * - * * - ******************************************************************** - - function: stdio-based convenience library for opening/seeking/decoding - last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $ - - ********************************************************************/ - -#ifndef _OV_FILE_H_ -#define _OV_FILE_H_ - -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ - -#include -#include "codec.h" - -/* The function prototypes for the callbacks are basically the same as for - * the stdio functions fread, fseek, fclose, ftell. - * The one difference is that the FILE * arguments have been replaced with - * a void * - this is to be used as a pointer to whatever internal data these - * functions might need. In the stdio case, it's just a FILE * cast to a void * - * - * If you use other functions, check the docs for these functions and return - * the right values. For seek_func(), you *MUST* return -1 if the stream is - * unseekable - */ -typedef struct { - size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource); - int (*seek_func) (void *datasource, ogg_int64_t offset, int whence); - int (*close_func) (void *datasource); - long (*tell_func) (void *datasource); -} ov_callbacks; - -#ifndef OV_EXCLUDE_STATIC_CALLBACKS - -/* a few sets of convenient callbacks, especially for use under - * Windows where ov_open_callbacks() should always be used instead of - * ov_open() to avoid problems with incompatible crt.o version linking - * issues. */ - -static int _ov_header_fseek_wrap(FILE *f,ogg_int64_t off,int whence){ - if(f==NULL)return(-1); - -#ifdef __MINGW32__ - return fseeko64(f,off,whence); -#elif defined (_WIN32) - return _fseeki64(f,off,whence); -#else - return fseek(f,off,whence); -#endif -} - -/* These structs below (OV_CALLBACKS_DEFAULT etc) are defined here as - * static data. That means that every file which includes this header - * will get its own copy of these structs whether it uses them or - * not unless it #defines OV_EXCLUDE_STATIC_CALLBACKS. - * These static symbols are essential on platforms such as Windows on - * which several different versions of stdio support may be linked to - * by different DLLs, and we need to be certain we know which one - * we're using (the same one as the main application). - */ - -static ov_callbacks OV_CALLBACKS_DEFAULT = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, - (int (*)(void *)) fclose, - (long (*)(void *)) ftell -}; - -static ov_callbacks OV_CALLBACKS_NOCLOSE = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) _ov_header_fseek_wrap, - (int (*)(void *)) NULL, - (long (*)(void *)) ftell -}; - -static ov_callbacks OV_CALLBACKS_STREAMONLY = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) NULL, - (int (*)(void *)) fclose, - (long (*)(void *)) NULL -}; - -static ov_callbacks OV_CALLBACKS_STREAMONLY_NOCLOSE = { - (size_t (*)(void *, size_t, size_t, void *)) fread, - (int (*)(void *, ogg_int64_t, int)) NULL, - (int (*)(void *)) NULL, - (long (*)(void *)) NULL -}; - -#endif - -#define NOTOPEN 0 -#define PARTOPEN 1 -#define OPENED 2 -#define STREAMSET 3 -#define INITSET 4 - -typedef struct OggVorbis_File { - void *datasource; /* Pointer to a FILE *, etc. */ - int seekable; - ogg_int64_t offset; - ogg_int64_t end; - ogg_sync_state oy; - - /* If the FILE handle isn't seekable (eg, a pipe), only the current - stream appears */ - int links; - ogg_int64_t *offsets; - ogg_int64_t *dataoffsets; - long *serialnos; - ogg_int64_t *pcmlengths; /* overloaded to maintain binary - compatibility; x2 size, stores both - beginning and end values */ - vorbis_info *vi; - vorbis_comment *vc; - - /* Decoding working state local storage */ - ogg_int64_t pcm_offset; - int ready_state; - long current_serialno; - int current_link; - - double bittrack; - double samptrack; - - ogg_stream_state os; /* take physical pages, weld into a logical - stream of packets */ - vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */ - vorbis_block vb; /* local working space for packet->PCM decode */ - - ov_callbacks callbacks; - -} OggVorbis_File; - - -extern int ov_clear(OggVorbis_File *vf); -extern int ov_fopen(const char *path,OggVorbis_File *vf); -extern int ov_open(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); -extern int ov_open_callbacks(void *datasource, OggVorbis_File *vf, - const char *initial, long ibytes, ov_callbacks callbacks); - -extern int ov_test(FILE *f,OggVorbis_File *vf,const char *initial,long ibytes); -extern int ov_test_callbacks(void *datasource, OggVorbis_File *vf, - const char *initial, long ibytes, ov_callbacks callbacks); -extern int ov_test_open(OggVorbis_File *vf); - -extern long ov_bitrate(OggVorbis_File *vf,int i); -extern long ov_bitrate_instant(OggVorbis_File *vf); -extern long ov_streams(OggVorbis_File *vf); -extern long ov_seekable(OggVorbis_File *vf); -extern long ov_serialnumber(OggVorbis_File *vf,int i); - -extern ogg_int64_t ov_raw_total(OggVorbis_File *vf,int i); -extern ogg_int64_t ov_pcm_total(OggVorbis_File *vf,int i); -extern double ov_time_total(OggVorbis_File *vf,int i); - -extern int ov_raw_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_page(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_time_seek(OggVorbis_File *vf,double pos); -extern int ov_time_seek_page(OggVorbis_File *vf,double pos); - -extern int ov_raw_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_pcm_seek_page_lap(OggVorbis_File *vf,ogg_int64_t pos); -extern int ov_time_seek_lap(OggVorbis_File *vf,double pos); -extern int ov_time_seek_page_lap(OggVorbis_File *vf,double pos); - -extern ogg_int64_t ov_raw_tell(OggVorbis_File *vf); -extern ogg_int64_t ov_pcm_tell(OggVorbis_File *vf); -extern double ov_time_tell(OggVorbis_File *vf); - -extern vorbis_info *ov_info(OggVorbis_File *vf,int link); -extern vorbis_comment *ov_comment(OggVorbis_File *vf,int link); - -extern long ov_read_float(OggVorbis_File *vf,float ***pcm_channels,int samples, - int *bitstream); -extern long ov_read_filter(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream, - void (*filter)(float **pcm,long channels,long samples,void *filter_param),void *filter_param); -extern long ov_read(OggVorbis_File *vf,char *buffer,int length, - int bigendianp,int word,int sgned,int *bitstream); -extern int ov_crosslap(OggVorbis_File *vf1,OggVorbis_File *vf2); - -extern int ov_halfrate(OggVorbis_File *vf,int flag); -extern int ov_halfrate_p(OggVorbis_File *vf); - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#endif - diff --git a/maclibs/include/zstd.h b/maclibs/include/zstd.h deleted file mode 100644 index 72080ea8..00000000 --- a/maclibs/include/zstd.h +++ /dev/null @@ -1,2049 +0,0 @@ -/* - * Copyright (c) 2016-present, Yann Collet, Facebook, Inc. - * All rights reserved. - * - * This source code is licensed under both the BSD-style license (found in the - * LICENSE file in the root directory of this source tree) and the GPLv2 (found - * in the COPYING file in the root directory of this source tree). - * You may select, at your option, one of the above-listed licenses. - */ -#if defined (__cplusplus) -extern "C" { -#endif - -#ifndef ZSTD_H_235446 -#define ZSTD_H_235446 - -/* ====== Dependency ======*/ -#include /* INT_MAX */ -#include /* size_t */ - - -/* ===== ZSTDLIB_API : control library symbols visibility ===== */ -#ifndef ZSTDLIB_VISIBILITY -# if defined(__GNUC__) && (__GNUC__ >= 4) -# define ZSTDLIB_VISIBILITY __attribute__ ((visibility ("default"))) -# else -# define ZSTDLIB_VISIBILITY -# endif -#endif -#if defined(ZSTD_DLL_EXPORT) && (ZSTD_DLL_EXPORT==1) -# define ZSTDLIB_API __declspec(dllexport) ZSTDLIB_VISIBILITY -#elif defined(ZSTD_DLL_IMPORT) && (ZSTD_DLL_IMPORT==1) -# define ZSTDLIB_API __declspec(dllimport) ZSTDLIB_VISIBILITY /* It isn't required but allows to generate better code, saving a function pointer load from the IAT and an indirect jump.*/ -#else -# define ZSTDLIB_API ZSTDLIB_VISIBILITY -#endif - - -/******************************************************************************* - Introduction - - zstd, short for Zstandard, is a fast lossless compression algorithm, targeting - real-time compression scenarios at zlib-level and better compression ratios. - The zstd compression library provides in-memory compression and decompression - functions. - - The library supports regular compression levels from 1 up to ZSTD_maxCLevel(), - which is currently 22. Levels >= 20, labeled `--ultra`, should be used with - caution, as they require more memory. The library also offers negative - compression levels, which extend the range of speed vs. ratio preferences. - The lower the level, the faster the speed (at the cost of compression). - - Compression can be done in: - - a single step (described as Simple API) - - a single step, reusing a context (described as Explicit context) - - unbounded multiple steps (described as Streaming compression) - - The compression ratio achievable on small data can be highly improved using - a dictionary. Dictionary compression can be performed in: - - a single step (described as Simple dictionary API) - - a single step, reusing a dictionary (described as Bulk-processing - dictionary API) - - Advanced experimental functions can be accessed using - `#define ZSTD_STATIC_LINKING_ONLY` before including zstd.h. - - Advanced experimental APIs should never be used with a dynamically-linked - library. They are not "stable"; their definitions or signatures may change in - the future. Only static linking is allowed. -*******************************************************************************/ - -/*------ Version ------*/ -#define ZSTD_VERSION_MAJOR 1 -#define ZSTD_VERSION_MINOR 4 -#define ZSTD_VERSION_RELEASE 4 - -#define ZSTD_VERSION_NUMBER (ZSTD_VERSION_MAJOR *100*100 + ZSTD_VERSION_MINOR *100 + ZSTD_VERSION_RELEASE) -ZSTDLIB_API unsigned ZSTD_versionNumber(void); /**< to check runtime library version */ - -#define ZSTD_LIB_VERSION ZSTD_VERSION_MAJOR.ZSTD_VERSION_MINOR.ZSTD_VERSION_RELEASE -#define ZSTD_QUOTE(str) #str -#define ZSTD_EXPAND_AND_QUOTE(str) ZSTD_QUOTE(str) -#define ZSTD_VERSION_STRING ZSTD_EXPAND_AND_QUOTE(ZSTD_LIB_VERSION) -ZSTDLIB_API const char* ZSTD_versionString(void); /* requires v1.3.0+ */ - -/* ************************************* - * Default constant - ***************************************/ -#ifndef ZSTD_CLEVEL_DEFAULT -# define ZSTD_CLEVEL_DEFAULT 3 -#endif - -/* ************************************* - * Constants - ***************************************/ - -/* All magic numbers are supposed read/written to/from files/memory using little-endian convention */ -#define ZSTD_MAGICNUMBER 0xFD2FB528 /* valid since v0.8.0 */ -#define ZSTD_MAGIC_DICTIONARY 0xEC30A437 /* valid since v0.7.0 */ -#define ZSTD_MAGIC_SKIPPABLE_START 0x184D2A50 /* all 16 values, from 0x184D2A50 to 0x184D2A5F, signal the beginning of a skippable frame */ -#define ZSTD_MAGIC_SKIPPABLE_MASK 0xFFFFFFF0 - -#define ZSTD_BLOCKSIZELOG_MAX 17 -#define ZSTD_BLOCKSIZE_MAX (1<= `ZSTD_compressBound(srcSize)`. - * @return : compressed size written into `dst` (<= `dstCapacity), - * or an error code if it fails (which can be tested using ZSTD_isError()). */ -ZSTDLIB_API size_t ZSTD_compress( void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - int compressionLevel); - -/*! ZSTD_decompress() : - * `compressedSize` : must be the _exact_ size of some number of compressed and/or skippable frames. - * `dstCapacity` is an upper bound of originalSize to regenerate. - * If user cannot imply a maximum upper bound, it's better to use streaming mode to decompress data. - * @return : the number of bytes decompressed into `dst` (<= `dstCapacity`), - * or an errorCode if it fails (which can be tested using ZSTD_isError()). */ -ZSTDLIB_API size_t ZSTD_decompress( void* dst, size_t dstCapacity, - const void* src, size_t compressedSize); - -/*! ZSTD_getFrameContentSize() : requires v1.3.0+ - * `src` should point to the start of a ZSTD encoded frame. - * `srcSize` must be at least as large as the frame header. - * hint : any size >= `ZSTD_frameHeaderSize_max` is large enough. - * @return : - decompressed size of `src` frame content, if known - * - ZSTD_CONTENTSIZE_UNKNOWN if the size cannot be determined - * - ZSTD_CONTENTSIZE_ERROR if an error occurred (e.g. invalid magic number, srcSize too small) - * note 1 : a 0 return value means the frame is valid but "empty". - * note 2 : decompressed size is an optional field, it may not be present, typically in streaming mode. - * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. - * In which case, it's necessary to use streaming mode to decompress data. - * Optionally, application can rely on some implicit limit, - * as ZSTD_decompress() only needs an upper bound of decompressed size. - * (For example, data could be necessarily cut into blocks <= 16 KB). - * note 3 : decompressed size is always present when compression is completed using single-pass functions, - * such as ZSTD_compress(), ZSTD_compressCCtx() ZSTD_compress_usingDict() or ZSTD_compress_usingCDict(). - * note 4 : decompressed size can be very large (64-bits value), - * potentially larger than what local system can handle as a single memory segment. - * In which case, it's necessary to use streaming mode to decompress data. - * note 5 : If source is untrusted, decompressed size could be wrong or intentionally modified. - * Always ensure return value fits within application's authorized limits. - * Each application can set its own limits. - * note 6 : This function replaces ZSTD_getDecompressedSize() */ -#define ZSTD_CONTENTSIZE_UNKNOWN (0ULL - 1) -#define ZSTD_CONTENTSIZE_ERROR (0ULL - 2) -ZSTDLIB_API unsigned long long ZSTD_getFrameContentSize(const void *src, size_t srcSize); - -/*! ZSTD_getDecompressedSize() : - * NOTE: This function is now obsolete, in favor of ZSTD_getFrameContentSize(). - * Both functions work the same way, but ZSTD_getDecompressedSize() blends - * "empty", "unknown" and "error" results to the same return value (0), - * while ZSTD_getFrameContentSize() gives them separate return values. - * @return : decompressed size of `src` frame content _if known and not empty_, 0 otherwise. */ -ZSTDLIB_API unsigned long long ZSTD_getDecompressedSize(const void* src, size_t srcSize); - -/*! ZSTD_findFrameCompressedSize() : - * `src` should point to the start of a ZSTD frame or skippable frame. - * `srcSize` must be >= first frame size - * @return : the compressed size of the first frame starting at `src`, - * suitable to pass as `srcSize` to `ZSTD_decompress` or similar, - * or an error code if input is invalid */ -ZSTDLIB_API size_t ZSTD_findFrameCompressedSize(const void* src, size_t srcSize); - - -/*====== Helper functions ======*/ -#define ZSTD_COMPRESSBOUND(srcSize) ((srcSize) + ((srcSize)>>8) + (((srcSize) < (128<<10)) ? (((128<<10) - (srcSize)) >> 11) /* margin, from 64 to 0 */ : 0)) /* this formula ensures that bound(A) + bound(B) <= bound(A+B) as long as A and B >= 128 KB */ -ZSTDLIB_API size_t ZSTD_compressBound(size_t srcSize); /*!< maximum compressed size in worst case single-pass scenario */ -ZSTDLIB_API unsigned ZSTD_isError(size_t code); /*!< tells if a `size_t` function result is an error code */ -ZSTDLIB_API const char* ZSTD_getErrorName(size_t code); /*!< provides readable string from an error code */ -ZSTDLIB_API int ZSTD_minCLevel(void); /*!< minimum negative compression level allowed */ -ZSTDLIB_API int ZSTD_maxCLevel(void); /*!< maximum compression level available */ - - -/*************************************** -* Explicit context -***************************************/ -/*= Compression context - * When compressing many times, - * it is recommended to allocate a context just once, - * and re-use it for each successive compression operation. - * This will make workload friendlier for system's memory. - * Note : re-using context is just a speed / resource optimization. - * It doesn't change the compression ratio, which remains identical. - * Note 2 : In multi-threaded environments, - * use one different context per thread for parallel execution. - */ -typedef struct ZSTD_CCtx_s ZSTD_CCtx; -ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx(void); -ZSTDLIB_API size_t ZSTD_freeCCtx(ZSTD_CCtx* cctx); - -/*! ZSTD_compressCCtx() : - * Same as ZSTD_compress(), using an explicit ZSTD_CCtx. - * Important : in order to behave similarly to `ZSTD_compress()`, - * this function compresses at requested compression level, - * __ignoring any other parameter__ . - * If any advanced parameter was set using the advanced API, - * they will all be reset. Only `compressionLevel` remains. - */ -ZSTDLIB_API size_t ZSTD_compressCCtx(ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - int compressionLevel); - -/*= Decompression context - * When decompressing many times, - * it is recommended to allocate a context only once, - * and re-use it for each successive compression operation. - * This will make workload friendlier for system's memory. - * Use one context per thread for parallel execution. */ -typedef struct ZSTD_DCtx_s ZSTD_DCtx; -ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx(void); -ZSTDLIB_API size_t ZSTD_freeDCtx(ZSTD_DCtx* dctx); - -/*! ZSTD_decompressDCtx() : - * Same as ZSTD_decompress(), - * requires an allocated ZSTD_DCtx. - * Compatible with sticky parameters. - */ -ZSTDLIB_API size_t ZSTD_decompressDCtx(ZSTD_DCtx* dctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize); - - -/*************************************** -* Advanced compression API -***************************************/ - -/* API design : - * Parameters are pushed one by one into an existing context, - * using ZSTD_CCtx_set*() functions. - * Pushed parameters are sticky : they are valid for next compressed frame, and any subsequent frame. - * "sticky" parameters are applicable to `ZSTD_compress2()` and `ZSTD_compressStream*()` ! - * __They do not apply to "simple" one-shot variants such as ZSTD_compressCCtx()__ . - * - * It's possible to reset all parameters to "default" using ZSTD_CCtx_reset(). - * - * This API supercedes all other "advanced" API entry points in the experimental section. - * In the future, we expect to remove from experimental API entry points which are redundant with this API. - */ - - -/* Compression strategies, listed from fastest to strongest */ -typedef enum { ZSTD_fast=1, - ZSTD_dfast=2, - ZSTD_greedy=3, - ZSTD_lazy=4, - ZSTD_lazy2=5, - ZSTD_btlazy2=6, - ZSTD_btopt=7, - ZSTD_btultra=8, - ZSTD_btultra2=9 - /* note : new strategies _might_ be added in the future. - Only the order (from fast to strong) is guaranteed */ -} ZSTD_strategy; - - -typedef enum { - - /* compression parameters - * Note: When compressing with a ZSTD_CDict these parameters are superseded - * by the parameters used to construct the ZSTD_CDict. - * See ZSTD_CCtx_refCDict() for more info (superseded-by-cdict). */ - ZSTD_c_compressionLevel=100, /* Set compression parameters according to pre-defined cLevel table. - * Note that exact compression parameters are dynamically determined, - * depending on both compression level and srcSize (when known). - * Default level is ZSTD_CLEVEL_DEFAULT==3. - * Special: value 0 means default, which is controlled by ZSTD_CLEVEL_DEFAULT. - * Note 1 : it's possible to pass a negative compression level. - * Note 2 : setting a level resets all other compression parameters to default */ - /* Advanced compression parameters : - * It's possible to pin down compression parameters to some specific values. - * In which case, these values are no longer dynamically selected by the compressor */ - ZSTD_c_windowLog=101, /* Maximum allowed back-reference distance, expressed as power of 2. - * This will set a memory budget for streaming decompression, - * with larger values requiring more memory - * and typically compressing more. - * Must be clamped between ZSTD_WINDOWLOG_MIN and ZSTD_WINDOWLOG_MAX. - * Special: value 0 means "use default windowLog". - * Note: Using a windowLog greater than ZSTD_WINDOWLOG_LIMIT_DEFAULT - * requires explicitly allowing such size at streaming decompression stage. */ - ZSTD_c_hashLog=102, /* Size of the initial probe table, as a power of 2. - * Resulting memory usage is (1 << (hashLog+2)). - * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX. - * Larger tables improve compression ratio of strategies <= dFast, - * and improve speed of strategies > dFast. - * Special: value 0 means "use default hashLog". */ - ZSTD_c_chainLog=103, /* Size of the multi-probe search table, as a power of 2. - * Resulting memory usage is (1 << (chainLog+2)). - * Must be clamped between ZSTD_CHAINLOG_MIN and ZSTD_CHAINLOG_MAX. - * Larger tables result in better and slower compression. - * This parameter is useless for "fast" strategy. - * It's still useful when using "dfast" strategy, - * in which case it defines a secondary probe table. - * Special: value 0 means "use default chainLog". */ - ZSTD_c_searchLog=104, /* Number of search attempts, as a power of 2. - * More attempts result in better and slower compression. - * This parameter is useless for "fast" and "dFast" strategies. - * Special: value 0 means "use default searchLog". */ - ZSTD_c_minMatch=105, /* Minimum size of searched matches. - * Note that Zstandard can still find matches of smaller size, - * it just tweaks its search algorithm to look for this size and larger. - * Larger values increase compression and decompression speed, but decrease ratio. - * Must be clamped between ZSTD_MINMATCH_MIN and ZSTD_MINMATCH_MAX. - * Note that currently, for all strategies < btopt, effective minimum is 4. - * , for all strategies > fast, effective maximum is 6. - * Special: value 0 means "use default minMatchLength". */ - ZSTD_c_targetLength=106, /* Impact of this field depends on strategy. - * For strategies btopt, btultra & btultra2: - * Length of Match considered "good enough" to stop search. - * Larger values make compression stronger, and slower. - * For strategy fast: - * Distance between match sampling. - * Larger values make compression faster, and weaker. - * Special: value 0 means "use default targetLength". */ - ZSTD_c_strategy=107, /* See ZSTD_strategy enum definition. - * The higher the value of selected strategy, the more complex it is, - * resulting in stronger and slower compression. - * Special: value 0 means "use default strategy". */ - - /* LDM mode parameters */ - ZSTD_c_enableLongDistanceMatching=160, /* Enable long distance matching. - * This parameter is designed to improve compression ratio - * for large inputs, by finding large matches at long distance. - * It increases memory usage and window size. - * Note: enabling this parameter increases default ZSTD_c_windowLog to 128 MB - * except when expressly set to a different value. */ - ZSTD_c_ldmHashLog=161, /* Size of the table for long distance matching, as a power of 2. - * Larger values increase memory usage and compression ratio, - * but decrease compression speed. - * Must be clamped between ZSTD_HASHLOG_MIN and ZSTD_HASHLOG_MAX - * default: windowlog - 7. - * Special: value 0 means "automatically determine hashlog". */ - ZSTD_c_ldmMinMatch=162, /* Minimum match size for long distance matcher. - * Larger/too small values usually decrease compression ratio. - * Must be clamped between ZSTD_LDM_MINMATCH_MIN and ZSTD_LDM_MINMATCH_MAX. - * Special: value 0 means "use default value" (default: 64). */ - ZSTD_c_ldmBucketSizeLog=163, /* Log size of each bucket in the LDM hash table for collision resolution. - * Larger values improve collision resolution but decrease compression speed. - * The maximum value is ZSTD_LDM_BUCKETSIZELOG_MAX. - * Special: value 0 means "use default value" (default: 3). */ - ZSTD_c_ldmHashRateLog=164, /* Frequency of inserting/looking up entries into the LDM hash table. - * Must be clamped between 0 and (ZSTD_WINDOWLOG_MAX - ZSTD_HASHLOG_MIN). - * Default is MAX(0, (windowLog - ldmHashLog)), optimizing hash table usage. - * Larger values improve compression speed. - * Deviating far from default value will likely result in a compression ratio decrease. - * Special: value 0 means "automatically determine hashRateLog". */ - - /* frame parameters */ - ZSTD_c_contentSizeFlag=200, /* Content size will be written into frame header _whenever known_ (default:1) - * Content size must be known at the beginning of compression. - * This is automatically the case when using ZSTD_compress2(), - * For streaming scenarios, content size must be provided with ZSTD_CCtx_setPledgedSrcSize() */ - ZSTD_c_checksumFlag=201, /* A 32-bits checksum of content is written at end of frame (default:0) */ - ZSTD_c_dictIDFlag=202, /* When applicable, dictionary's ID is written into frame header (default:1) */ - - /* multi-threading parameters */ - /* These parameters are only useful if multi-threading is enabled (compiled with build macro ZSTD_MULTITHREAD). - * They return an error otherwise. */ - ZSTD_c_nbWorkers=400, /* Select how many threads will be spawned to compress in parallel. - * When nbWorkers >= 1, triggers asynchronous mode when used with ZSTD_compressStream*() : - * ZSTD_compressStream*() consumes input and flush output if possible, but immediately gives back control to caller, - * while compression work is performed in parallel, within worker threads. - * (note : a strong exception to this rule is when first invocation of ZSTD_compressStream2() sets ZSTD_e_end : - * in which case, ZSTD_compressStream2() delegates to ZSTD_compress2(), which is always a blocking call). - * More workers improve speed, but also increase memory usage. - * Default value is `0`, aka "single-threaded mode" : no worker is spawned, compression is performed inside Caller's thread, all invocations are blocking */ - ZSTD_c_jobSize=401, /* Size of a compression job. This value is enforced only when nbWorkers >= 1. - * Each compression job is completed in parallel, so this value can indirectly impact the nb of active threads. - * 0 means default, which is dynamically determined based on compression parameters. - * Job size must be a minimum of overlap size, or 1 MB, whichever is largest. - * The minimum size is automatically and transparently enforced. */ - ZSTD_c_overlapLog=402, /* Control the overlap size, as a fraction of window size. - * The overlap size is an amount of data reloaded from previous job at the beginning of a new job. - * It helps preserve compression ratio, while each job is compressed in parallel. - * This value is enforced only when nbWorkers >= 1. - * Larger values increase compression ratio, but decrease speed. - * Possible values range from 0 to 9 : - * - 0 means "default" : value will be determined by the library, depending on strategy - * - 1 means "no overlap" - * - 9 means "full overlap", using a full window size. - * Each intermediate rank increases/decreases load size by a factor 2 : - * 9: full window; 8: w/2; 7: w/4; 6: w/8; 5:w/16; 4: w/32; 3:w/64; 2:w/128; 1:no overlap; 0:default - * default value varies between 6 and 9, depending on strategy */ - - /* note : additional experimental parameters are also available - * within the experimental section of the API. - * At the time of this writing, they include : - * ZSTD_c_rsyncable - * ZSTD_c_format - * ZSTD_c_forceMaxWindow - * ZSTD_c_forceAttachDict - * ZSTD_c_literalCompressionMode - * ZSTD_c_targetCBlockSize - * ZSTD_c_srcSizeHint - * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them. - * note : never ever use experimentalParam? names directly; - * also, the enums values themselves are unstable and can still change. - */ - ZSTD_c_experimentalParam1=500, - ZSTD_c_experimentalParam2=10, - ZSTD_c_experimentalParam3=1000, - ZSTD_c_experimentalParam4=1001, - ZSTD_c_experimentalParam5=1002, - ZSTD_c_experimentalParam6=1003, - ZSTD_c_experimentalParam7=1004 -} ZSTD_cParameter; - -typedef struct { - size_t error; - int lowerBound; - int upperBound; -} ZSTD_bounds; - -/*! ZSTD_cParam_getBounds() : - * All parameters must belong to an interval with lower and upper bounds, - * otherwise they will either trigger an error or be automatically clamped. - * @return : a structure, ZSTD_bounds, which contains - * - an error status field, which must be tested using ZSTD_isError() - * - lower and upper bounds, both inclusive - */ -ZSTDLIB_API ZSTD_bounds ZSTD_cParam_getBounds(ZSTD_cParameter cParam); - -/*! ZSTD_CCtx_setParameter() : - * Set one compression parameter, selected by enum ZSTD_cParameter. - * All parameters have valid bounds. Bounds can be queried using ZSTD_cParam_getBounds(). - * Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). - * Setting a parameter is generally only possible during frame initialization (before starting compression). - * Exception : when using multi-threading mode (nbWorkers >= 1), - * the following parameters can be updated _during_ compression (within same frame): - * => compressionLevel, hashLog, chainLog, searchLog, minMatch, targetLength and strategy. - * new parameters will be active for next job only (after a flush()). - * @return : an error code (which can be tested using ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_CCtx_setParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int value); - -/*! ZSTD_CCtx_setPledgedSrcSize() : - * Total input data size to be compressed as a single frame. - * Value will be written in frame header, unless if explicitly forbidden using ZSTD_c_contentSizeFlag. - * This value will also be controlled at end of frame, and trigger an error if not respected. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Note 1 : pledgedSrcSize==0 actually means zero, aka an empty frame. - * In order to mean "unknown content size", pass constant ZSTD_CONTENTSIZE_UNKNOWN. - * ZSTD_CONTENTSIZE_UNKNOWN is default value for any new frame. - * Note 2 : pledgedSrcSize is only valid once, for the next frame. - * It's discarded at the end of the frame, and replaced by ZSTD_CONTENTSIZE_UNKNOWN. - * Note 3 : Whenever all input data is provided and consumed in a single round, - * for example with ZSTD_compress2(), - * or invoking immediately ZSTD_compressStream2(,,,ZSTD_e_end), - * this value is automatically overridden by srcSize instead. - */ -ZSTDLIB_API size_t ZSTD_CCtx_setPledgedSrcSize(ZSTD_CCtx* cctx, unsigned long long pledgedSrcSize); - -typedef enum { - ZSTD_reset_session_only = 1, - ZSTD_reset_parameters = 2, - ZSTD_reset_session_and_parameters = 3 -} ZSTD_ResetDirective; - -/*! ZSTD_CCtx_reset() : - * There are 2 different things that can be reset, independently or jointly : - * - The session : will stop compressing current frame, and make CCtx ready to start a new one. - * Useful after an error, or to interrupt any ongoing compression. - * Any internal data not yet flushed is cancelled. - * Compression parameters and dictionary remain unchanged. - * They will be used to compress next frame. - * Resetting session never fails. - * - The parameters : changes all parameters back to "default". - * This removes any reference to any dictionary too. - * Parameters can only be changed between 2 sessions (i.e. no compression is currently ongoing) - * otherwise the reset fails, and function returns an error value (which can be tested using ZSTD_isError()) - * - Both : similar to resetting the session, followed by resetting parameters. - */ -ZSTDLIB_API size_t ZSTD_CCtx_reset(ZSTD_CCtx* cctx, ZSTD_ResetDirective reset); - -/*! ZSTD_compress2() : - * Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API. - * ZSTD_compress2() always starts a new frame. - * Should cctx hold data from a previously unfinished frame, everything about it is forgotten. - * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() - * - The function is always blocking, returns when compression is completed. - * Hint : compression runs faster if `dstCapacity` >= `ZSTD_compressBound(srcSize)`. - * @return : compressed size written into `dst` (<= `dstCapacity), - * or an error code if it fails (which can be tested using ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_compress2( ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize); - - -/*************************************** -* Advanced decompression API -***************************************/ - -/* The advanced API pushes parameters one by one into an existing DCtx context. - * Parameters are sticky, and remain valid for all following frames - * using the same DCtx context. - * It's possible to reset parameters to default values using ZSTD_DCtx_reset(). - * Note : This API is compatible with existing ZSTD_decompressDCtx() and ZSTD_decompressStream(). - * Therefore, no new decompression function is necessary. - */ - -typedef enum { - - ZSTD_d_windowLogMax=100, /* Select a size limit (in power of 2) beyond which - * the streaming API will refuse to allocate memory buffer - * in order to protect the host from unreasonable memory requirements. - * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode. - * By default, a decompression context accepts window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT). - * Special: value 0 means "use default maximum windowLog". */ - - /* note : additional experimental parameters are also available - * within the experimental section of the API. - * At the time of this writing, they include : - * ZSTD_c_format - * Because they are not stable, it's necessary to define ZSTD_STATIC_LINKING_ONLY to access them. - * note : never ever use experimentalParam? names directly - */ - ZSTD_d_experimentalParam1=1000 - -} ZSTD_dParameter; - -/*! ZSTD_dParam_getBounds() : - * All parameters must belong to an interval with lower and upper bounds, - * otherwise they will either trigger an error or be automatically clamped. - * @return : a structure, ZSTD_bounds, which contains - * - an error status field, which must be tested using ZSTD_isError() - * - both lower and upper bounds, inclusive - */ -ZSTDLIB_API ZSTD_bounds ZSTD_dParam_getBounds(ZSTD_dParameter dParam); - -/*! ZSTD_DCtx_setParameter() : - * Set one compression parameter, selected by enum ZSTD_dParameter. - * All parameters have valid bounds. Bounds can be queried using ZSTD_dParam_getBounds(). - * Providing a value beyond bound will either clamp it, or trigger an error (depending on parameter). - * Setting a parameter is only possible during frame initialization (before starting decompression). - * @return : 0, or an error code (which can be tested using ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_DCtx_setParameter(ZSTD_DCtx* dctx, ZSTD_dParameter param, int value); - -/*! ZSTD_DCtx_reset() : - * Return a DCtx to clean state. - * Session and parameters can be reset jointly or separately. - * Parameters can only be reset when no active frame is being decompressed. - * @return : 0, or an error code, which can be tested with ZSTD_isError() - */ -ZSTDLIB_API size_t ZSTD_DCtx_reset(ZSTD_DCtx* dctx, ZSTD_ResetDirective reset); - - -/**************************** -* Streaming -****************************/ - -typedef struct ZSTD_inBuffer_s { - const void* src; /**< start of input buffer */ - size_t size; /**< size of input buffer */ - size_t pos; /**< position where reading stopped. Will be updated. Necessarily 0 <= pos <= size */ -} ZSTD_inBuffer; - -typedef struct ZSTD_outBuffer_s { - void* dst; /**< start of output buffer */ - size_t size; /**< size of output buffer */ - size_t pos; /**< position where writing stopped. Will be updated. Necessarily 0 <= pos <= size */ -} ZSTD_outBuffer; - - - -/*-*********************************************************************** -* Streaming compression - HowTo -* -* A ZSTD_CStream object is required to track streaming operation. -* Use ZSTD_createCStream() and ZSTD_freeCStream() to create/release resources. -* ZSTD_CStream objects can be reused multiple times on consecutive compression operations. -* It is recommended to re-use ZSTD_CStream since it will play nicer with system's memory, by re-using already allocated memory. -* -* For parallel execution, use one separate ZSTD_CStream per thread. -* -* note : since v1.3.0, ZSTD_CStream and ZSTD_CCtx are the same thing. -* -* Parameters are sticky : when starting a new compression on the same context, -* it will re-use the same sticky parameters as previous compression session. -* When in doubt, it's recommended to fully initialize the context before usage. -* Use ZSTD_CCtx_reset() to reset the context and ZSTD_CCtx_setParameter(), -* ZSTD_CCtx_setPledgedSrcSize(), or ZSTD_CCtx_loadDictionary() and friends to -* set more specific parameters, the pledged source size, or load a dictionary. -* -* Use ZSTD_compressStream2() with ZSTD_e_continue as many times as necessary to -* consume input stream. The function will automatically update both `pos` -* fields within `input` and `output`. -* Note that the function may not consume the entire input, for example, because -* the output buffer is already full, in which case `input.pos < input.size`. -* The caller must check if input has been entirely consumed. -* If not, the caller must make some room to receive more compressed data, -* and then present again remaining input data. -* note: ZSTD_e_continue is guaranteed to make some forward progress when called, -* but doesn't guarantee maximal forward progress. This is especially relevant -* when compressing with multiple threads. The call won't block if it can -* consume some input, but if it can't it will wait for some, but not all, -* output to be flushed. -* @return : provides a minimum amount of data remaining to be flushed from internal buffers -* or an error code, which can be tested using ZSTD_isError(). -* -* At any moment, it's possible to flush whatever data might remain stuck within internal buffer, -* using ZSTD_compressStream2() with ZSTD_e_flush. `output->pos` will be updated. -* Note that, if `output->size` is too small, a single invocation with ZSTD_e_flush might not be enough (return code > 0). -* In which case, make some room to receive more compressed data, and call again ZSTD_compressStream2() with ZSTD_e_flush. -* You must continue calling ZSTD_compressStream2() with ZSTD_e_flush until it returns 0, at which point you can change the -* operation. -* note: ZSTD_e_flush will flush as much output as possible, meaning when compressing with multiple threads, it will -* block until the flush is complete or the output buffer is full. -* @return : 0 if internal buffers are entirely flushed, -* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size), -* or an error code, which can be tested using ZSTD_isError(). -* -* Calling ZSTD_compressStream2() with ZSTD_e_end instructs to finish a frame. -* It will perform a flush and write frame epilogue. -* The epilogue is required for decoders to consider a frame completed. -* flush operation is the same, and follows same rules as calling ZSTD_compressStream2() with ZSTD_e_flush. -* You must continue calling ZSTD_compressStream2() with ZSTD_e_end until it returns 0, at which point you are free to -* start a new frame. -* note: ZSTD_e_end will flush as much output as possible, meaning when compressing with multiple threads, it will -* block until the flush is complete or the output buffer is full. -* @return : 0 if frame fully completed and fully flushed, -* >0 if some data still present within internal buffer (the value is minimal estimation of remaining size), -* or an error code, which can be tested using ZSTD_isError(). -* -* *******************************************************************/ - -typedef ZSTD_CCtx ZSTD_CStream; /**< CCtx and CStream are now effectively same object (>= v1.3.0) */ - /* Continue to distinguish them for compatibility with older versions <= v1.2.0 */ -/*===== ZSTD_CStream management functions =====*/ -ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream(void); -ZSTDLIB_API size_t ZSTD_freeCStream(ZSTD_CStream* zcs); - -/*===== Streaming compression functions =====*/ -typedef enum { - ZSTD_e_continue=0, /* collect more data, encoder decides when to output compressed result, for optimal compression ratio */ - ZSTD_e_flush=1, /* flush any data provided so far, - * it creates (at least) one new block, that can be decoded immediately on reception; - * frame will continue: any future data can still reference previously compressed data, improving compression. - * note : multithreaded compression will block to flush as much output as possible. */ - ZSTD_e_end=2 /* flush any remaining data _and_ close current frame. - * note that frame is only closed after compressed data is fully flushed (return value == 0). - * After that point, any additional data starts a new frame. - * note : each frame is independent (does not reference any content from previous frame). - : note : multithreaded compression will block to flush as much output as possible. */ -} ZSTD_EndDirective; - -/*! ZSTD_compressStream2() : - * Behaves about the same as ZSTD_compressStream, with additional control on end directive. - * - Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*() - * - Compression parameters cannot be changed once compression is started (save a list of exceptions in multi-threading mode) - * - output->pos must be <= dstCapacity, input->pos must be <= srcSize - * - output->pos and input->pos will be updated. They are guaranteed to remain below their respective limit. - * - When nbWorkers==0 (default), function is blocking : it completes its job before returning to caller. - * - When nbWorkers>=1, function is non-blocking : it just acquires a copy of input, and distributes jobs to internal worker threads, flush whatever is available, - * and then immediately returns, just indicating that there is some data remaining to be flushed. - * The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte. - * - Exception : if the first call requests a ZSTD_e_end directive and provides enough dstCapacity, the function delegates to ZSTD_compress2() which is always blocking. - * - @return provides a minimum amount of data remaining to be flushed from internal buffers - * or an error code, which can be tested using ZSTD_isError(). - * if @return != 0, flush is not fully completed, there is still some data left within internal buffers. - * This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers. - * For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed. - * - after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0), - * only ZSTD_e_end or ZSTD_e_flush operations are allowed. - * Before starting a new compression job, or changing compression parameters, - * it is required to fully flush internal buffers. - */ -ZSTDLIB_API size_t ZSTD_compressStream2( ZSTD_CCtx* cctx, - ZSTD_outBuffer* output, - ZSTD_inBuffer* input, - ZSTD_EndDirective endOp); - - -/* These buffer sizes are softly recommended. - * They are not required : ZSTD_compressStream*() happily accepts any buffer size, for both input and output. - * Respecting the recommended size just makes it a bit easier for ZSTD_compressStream*(), - * reducing the amount of memory shuffling and buffering, resulting in minor performance savings. - * - * However, note that these recommendations are from the perspective of a C caller program. - * If the streaming interface is invoked from some other language, - * especially managed ones such as Java or Go, through a foreign function interface such as jni or cgo, - * a major performance rule is to reduce crossing such interface to an absolute minimum. - * It's not rare that performance ends being spent more into the interface, rather than compression itself. - * In which cases, prefer using large buffers, as large as practical, - * for both input and output, to reduce the nb of roundtrips. - */ -ZSTDLIB_API size_t ZSTD_CStreamInSize(void); /**< recommended size for input buffer */ -ZSTDLIB_API size_t ZSTD_CStreamOutSize(void); /**< recommended size for output buffer. Guarantee to successfully flush at least one complete compressed block. */ - - -/* ***************************************************************************** - * This following is a legacy streaming API. - * It can be replaced by ZSTD_CCtx_reset() and ZSTD_compressStream2(). - * It is redundant, but remains fully supported. - * Advanced parameters and dictionary compression can only be used through the - * new API. - ******************************************************************************/ - -/*! - * Equivalent to: - * - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) - * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - */ -ZSTDLIB_API size_t ZSTD_initCStream(ZSTD_CStream* zcs, int compressionLevel); -/*! - * Alternative for ZSTD_compressStream2(zcs, output, input, ZSTD_e_continue). - * NOTE: The return value is different. ZSTD_compressStream() returns a hint for - * the next read size (if non-zero and not an error). ZSTD_compressStream2() - * returns the minimum nb of bytes left to flush (if non-zero and not an error). - */ -ZSTDLIB_API size_t ZSTD_compressStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output, ZSTD_inBuffer* input); -/*! Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_flush). */ -ZSTDLIB_API size_t ZSTD_flushStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output); -/*! Equivalent to ZSTD_compressStream2(zcs, output, &emptyInput, ZSTD_e_end). */ -ZSTDLIB_API size_t ZSTD_endStream(ZSTD_CStream* zcs, ZSTD_outBuffer* output); - - -/*-*************************************************************************** -* Streaming decompression - HowTo -* -* A ZSTD_DStream object is required to track streaming operations. -* Use ZSTD_createDStream() and ZSTD_freeDStream() to create/release resources. -* ZSTD_DStream objects can be re-used multiple times. -* -* Use ZSTD_initDStream() to start a new decompression operation. -* @return : recommended first input size -* Alternatively, use advanced API to set specific properties. -* -* Use ZSTD_decompressStream() repetitively to consume your input. -* The function will update both `pos` fields. -* If `input.pos < input.size`, some input has not been consumed. -* It's up to the caller to present again remaining data. -* The function tries to flush all data decoded immediately, respecting output buffer size. -* If `output.pos < output.size`, decoder has flushed everything it could. -* But if `output.pos == output.size`, there might be some data left within internal buffers., -* In which case, call ZSTD_decompressStream() again to flush whatever remains in the buffer. -* Note : with no additional input provided, amount of data flushed is necessarily <= ZSTD_BLOCKSIZE_MAX. -* @return : 0 when a frame is completely decoded and fully flushed, -* or an error code, which can be tested using ZSTD_isError(), -* or any other value > 0, which means there is still some decoding or flushing to do to complete current frame : -* the return value is a suggested next input size (just a hint for better latency) -* that will never request more than the remaining frame size. -* *******************************************************************************/ - -typedef ZSTD_DCtx ZSTD_DStream; /**< DCtx and DStream are now effectively same object (>= v1.3.0) */ - /* For compatibility with versions <= v1.2.0, prefer differentiating them. */ -/*===== ZSTD_DStream management functions =====*/ -ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream(void); -ZSTDLIB_API size_t ZSTD_freeDStream(ZSTD_DStream* zds); - -/*===== Streaming decompression functions =====*/ - -/* This function is redundant with the advanced API and equivalent to: - * - * ZSTD_DCtx_reset(zds); - * ZSTD_DCtx_refDDict(zds, NULL); - */ -ZSTDLIB_API size_t ZSTD_initDStream(ZSTD_DStream* zds); - -ZSTDLIB_API size_t ZSTD_decompressStream(ZSTD_DStream* zds, ZSTD_outBuffer* output, ZSTD_inBuffer* input); - -ZSTDLIB_API size_t ZSTD_DStreamInSize(void); /*!< recommended size for input buffer */ -ZSTDLIB_API size_t ZSTD_DStreamOutSize(void); /*!< recommended size for output buffer. Guarantee to successfully flush at least one complete block in all circumstances. */ - - -/************************** -* Simple dictionary API -***************************/ -/*! ZSTD_compress_usingDict() : - * Compression at an explicit compression level using a Dictionary. - * A dictionary can be any arbitrary data segment (also called a prefix), - * or a buffer with specified information (see dictBuilder/zdict.h). - * Note : This function loads the dictionary, resulting in significant startup delay. - * It's intended for a dictionary used only once. - * Note 2 : When `dict == NULL || dictSize < 8` no dictionary is used. */ -ZSTDLIB_API size_t ZSTD_compress_usingDict(ZSTD_CCtx* ctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const void* dict,size_t dictSize, - int compressionLevel); - -/*! ZSTD_decompress_usingDict() : - * Decompression using a known Dictionary. - * Dictionary must be identical to the one used during compression. - * Note : This function loads the dictionary, resulting in significant startup delay. - * It's intended for a dictionary used only once. - * Note : When `dict == NULL || dictSize < 8` no dictionary is used. */ -ZSTDLIB_API size_t ZSTD_decompress_usingDict(ZSTD_DCtx* dctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const void* dict,size_t dictSize); - - -/*********************************** - * Bulk processing dictionary API - **********************************/ -typedef struct ZSTD_CDict_s ZSTD_CDict; - -/*! ZSTD_createCDict() : - * When compressing multiple messages or blocks using the same dictionary, - * it's recommended to digest the dictionary only once, since it's a costly operation. - * ZSTD_createCDict() will create a state from digesting a dictionary. - * The resulting state can be used for future compression operations with very limited startup cost. - * ZSTD_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only. - * @dictBuffer can be released after ZSTD_CDict creation, because its content is copied within CDict. - * Note 1 : Consider experimental function `ZSTD_createCDict_byReference()` if you prefer to not duplicate @dictBuffer content. - * Note 2 : A ZSTD_CDict can be created from an empty @dictBuffer, - * in which case the only thing that it transports is the @compressionLevel. - * This can be useful in a pipeline featuring ZSTD_compress_usingCDict() exclusively, - * expecting a ZSTD_CDict parameter with any data, including those without a known dictionary. */ -ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict(const void* dictBuffer, size_t dictSize, - int compressionLevel); - -/*! ZSTD_freeCDict() : - * Function frees memory allocated by ZSTD_createCDict(). */ -ZSTDLIB_API size_t ZSTD_freeCDict(ZSTD_CDict* CDict); - -/*! ZSTD_compress_usingCDict() : - * Compression using a digested Dictionary. - * Recommended when same dictionary is used multiple times. - * Note : compression level is _decided at dictionary creation time_, - * and frame parameters are hardcoded (dictID=yes, contentSize=yes, checksum=no) */ -ZSTDLIB_API size_t ZSTD_compress_usingCDict(ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const ZSTD_CDict* cdict); - - -typedef struct ZSTD_DDict_s ZSTD_DDict; - -/*! ZSTD_createDDict() : - * Create a digested dictionary, ready to start decompression operation without startup delay. - * dictBuffer can be released after DDict creation, as its content is copied inside DDict. */ -ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict(const void* dictBuffer, size_t dictSize); - -/*! ZSTD_freeDDict() : - * Function frees memory allocated with ZSTD_createDDict() */ -ZSTDLIB_API size_t ZSTD_freeDDict(ZSTD_DDict* ddict); - -/*! ZSTD_decompress_usingDDict() : - * Decompression using a digested Dictionary. - * Recommended when same dictionary is used multiple times. */ -ZSTDLIB_API size_t ZSTD_decompress_usingDDict(ZSTD_DCtx* dctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const ZSTD_DDict* ddict); - - -/******************************** - * Dictionary helper functions - *******************************/ - -/*! ZSTD_getDictID_fromDict() : - * Provides the dictID stored within dictionary. - * if @return == 0, the dictionary is not conformant with Zstandard specification. - * It can still be loaded, but as a content-only dictionary. */ -ZSTDLIB_API unsigned ZSTD_getDictID_fromDict(const void* dict, size_t dictSize); - -/*! ZSTD_getDictID_fromDDict() : - * Provides the dictID of the dictionary loaded into `ddict`. - * If @return == 0, the dictionary is not conformant to Zstandard specification, or empty. - * Non-conformant dictionaries can still be loaded, but as content-only dictionaries. */ -ZSTDLIB_API unsigned ZSTD_getDictID_fromDDict(const ZSTD_DDict* ddict); - -/*! ZSTD_getDictID_fromFrame() : - * Provides the dictID required to decompressed the frame stored within `src`. - * If @return == 0, the dictID could not be decoded. - * This could for one of the following reasons : - * - The frame does not require a dictionary to be decoded (most common case). - * - The frame was built with dictID intentionally removed. Whatever dictionary is necessary is a hidden information. - * Note : this use case also happens when using a non-conformant dictionary. - * - `srcSize` is too small, and as a result, the frame header could not be decoded (only possible if `srcSize < ZSTD_FRAMEHEADERSIZE_MAX`). - * - This is not a Zstandard frame. - * When identifying the exact failure cause, it's possible to use ZSTD_getFrameHeader(), which will provide a more precise error code. */ -ZSTDLIB_API unsigned ZSTD_getDictID_fromFrame(const void* src, size_t srcSize); - - -/******************************************************************************* - * Advanced dictionary and prefix API - * - * This API allows dictionaries to be used with ZSTD_compress2(), - * ZSTD_compressStream2(), and ZSTD_decompress(). Dictionaries are sticky, and - * only reset with the context is reset with ZSTD_reset_parameters or - * ZSTD_reset_session_and_parameters. Prefixes are single-use. - ******************************************************************************/ - - -/*! ZSTD_CCtx_loadDictionary() : - * Create an internal CDict from `dict` buffer. - * Decompression will have to use same dictionary. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special: Loading a NULL (or 0-size) dictionary invalidates previous dictionary, - * meaning "return to no-dictionary mode". - * Note 1 : Dictionary is sticky, it will be used for all future compressed frames. - * To return to "no-dictionary" situation, load a NULL dictionary (or reset parameters). - * Note 2 : Loading a dictionary involves building tables. - * It's also a CPU consuming operation, with non-negligible impact on latency. - * Tables are dependent on compression parameters, and for this reason, - * compression parameters can no longer be changed after loading a dictionary. - * Note 3 :`dict` content will be copied internally. - * Use experimental ZSTD_CCtx_loadDictionary_byReference() to reference content instead. - * In such a case, dictionary buffer must outlive its users. - * Note 4 : Use ZSTD_CCtx_loadDictionary_advanced() - * to precisely select how dictionary content must be interpreted. */ -ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary(ZSTD_CCtx* cctx, const void* dict, size_t dictSize); - -/*! ZSTD_CCtx_refCDict() : - * Reference a prepared dictionary, to be used for all next compressed frames. - * Note that compression parameters are enforced from within CDict, - * and supersede any compression parameter previously set within CCtx. - * The parameters ignored are labled as "superseded-by-cdict" in the ZSTD_cParameter enum docs. - * The ignored parameters will be used again if the CCtx is returned to no-dictionary mode. - * The dictionary will remain valid for future compressed frames using same CCtx. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special : Referencing a NULL CDict means "return to no-dictionary mode". - * Note 1 : Currently, only one dictionary can be managed. - * Referencing a new dictionary effectively "discards" any previous one. - * Note 2 : CDict is just referenced, its lifetime must outlive its usage within CCtx. */ -ZSTDLIB_API size_t ZSTD_CCtx_refCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); - -/*! ZSTD_CCtx_refPrefix() : - * Reference a prefix (single-usage dictionary) for next compressed frame. - * A prefix is **only used once**. Tables are discarded at end of frame (ZSTD_e_end). - * Decompression will need same prefix to properly regenerate data. - * Compressing with a prefix is similar in outcome as performing a diff and compressing it, - * but performs much faster, especially during decompression (compression speed is tunable with compression level). - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary - * Note 1 : Prefix buffer is referenced. It **must** outlive compression. - * Its content must remain unmodified during compression. - * Note 2 : If the intention is to diff some large src data blob with some prior version of itself, - * ensure that the window size is large enough to contain the entire source. - * See ZSTD_c_windowLog. - * Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters. - * It's a CPU consuming operation, with non-negligible impact on latency. - * If there is a need to use the same prefix multiple times, consider loadDictionary instead. - * Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dct_rawContent). - * Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation. */ -ZSTDLIB_API size_t ZSTD_CCtx_refPrefix(ZSTD_CCtx* cctx, - const void* prefix, size_t prefixSize); - -/*! ZSTD_DCtx_loadDictionary() : - * Create an internal DDict from dict buffer, - * to be used to decompress next frames. - * The dictionary remains valid for all future frames, until explicitly invalidated. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Special : Adding a NULL (or 0-size) dictionary invalidates any previous dictionary, - * meaning "return to no-dictionary mode". - * Note 1 : Loading a dictionary involves building tables, - * which has a non-negligible impact on CPU usage and latency. - * It's recommended to "load once, use many times", to amortize the cost - * Note 2 :`dict` content will be copied internally, so `dict` can be released after loading. - * Use ZSTD_DCtx_loadDictionary_byReference() to reference dictionary content instead. - * Note 3 : Use ZSTD_DCtx_loadDictionary_advanced() to take control of - * how dictionary content is loaded and interpreted. - */ -ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); - -/*! ZSTD_DCtx_refDDict() : - * Reference a prepared dictionary, to be used to decompress next frames. - * The dictionary remains active for decompression of future frames using same DCtx. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Note 1 : Currently, only one dictionary can be managed. - * Referencing a new dictionary effectively "discards" any previous one. - * Special: referencing a NULL DDict means "return to no-dictionary mode". - * Note 2 : DDict is just referenced, its lifetime must outlive its usage from DCtx. - */ -ZSTDLIB_API size_t ZSTD_DCtx_refDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict); - -/*! ZSTD_DCtx_refPrefix() : - * Reference a prefix (single-usage dictionary) to decompress next frame. - * This is the reverse operation of ZSTD_CCtx_refPrefix(), - * and must use the same prefix as the one used during compression. - * Prefix is **only used once**. Reference is discarded at end of frame. - * End of frame is reached when ZSTD_decompressStream() returns 0. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - * Note 1 : Adding any prefix (including NULL) invalidates any previously set prefix or dictionary - * Note 2 : Prefix buffer is referenced. It **must** outlive decompression. - * Prefix buffer must remain unmodified up to the end of frame, - * reached when ZSTD_decompressStream() returns 0. - * Note 3 : By default, the prefix is treated as raw content (ZSTD_dct_rawContent). - * Use ZSTD_CCtx_refPrefix_advanced() to alter dictMode (Experimental section) - * Note 4 : Referencing a raw content prefix has almost no cpu nor memory cost. - * A full dictionary is more costly, as it requires building tables. - */ -ZSTDLIB_API size_t ZSTD_DCtx_refPrefix(ZSTD_DCtx* dctx, - const void* prefix, size_t prefixSize); - -/* === Memory management === */ - -/*! ZSTD_sizeof_*() : - * These functions give the _current_ memory usage of selected object. - * Note that object memory usage can evolve (increase or decrease) over time. */ -ZSTDLIB_API size_t ZSTD_sizeof_CCtx(const ZSTD_CCtx* cctx); -ZSTDLIB_API size_t ZSTD_sizeof_DCtx(const ZSTD_DCtx* dctx); -ZSTDLIB_API size_t ZSTD_sizeof_CStream(const ZSTD_CStream* zcs); -ZSTDLIB_API size_t ZSTD_sizeof_DStream(const ZSTD_DStream* zds); -ZSTDLIB_API size_t ZSTD_sizeof_CDict(const ZSTD_CDict* cdict); -ZSTDLIB_API size_t ZSTD_sizeof_DDict(const ZSTD_DDict* ddict); - -#endif /* ZSTD_H_235446 */ - - -/* ************************************************************************************** - * ADVANCED AND EXPERIMENTAL FUNCTIONS - **************************************************************************************** - * The definitions in the following section are considered experimental. - * They are provided for advanced scenarios. - * They should never be used with a dynamic library, as prototypes may change in the future. - * Use them only in association with static linking. - * ***************************************************************************************/ - -#if defined(ZSTD_STATIC_LINKING_ONLY) && !defined(ZSTD_H_ZSTD_STATIC_LINKING_ONLY) -#define ZSTD_H_ZSTD_STATIC_LINKING_ONLY - -/**************************************************************************************** - * experimental API (static linking only) - **************************************************************************************** - * The following symbols and constants - * are not planned to join "stable API" status in the near future. - * They can still change in future versions. - * Some of them are planned to remain in the static_only section indefinitely. - * Some of them might be removed in the future (especially when redundant with existing stable functions) - * ***************************************************************************************/ - -#define ZSTD_FRAMEHEADERSIZE_PREFIX(format) ((format) == ZSTD_f_zstd1 ? 5 : 1) /* minimum input size required to query frame header size */ -#define ZSTD_FRAMEHEADERSIZE_MIN(format) ((format) == ZSTD_f_zstd1 ? 6 : 2) -#define ZSTD_FRAMEHEADERSIZE_MAX 18 /* can be useful for static allocation */ -#define ZSTD_SKIPPABLEHEADERSIZE 8 - -/* compression parameter bounds */ -#define ZSTD_WINDOWLOG_MAX_32 30 -#define ZSTD_WINDOWLOG_MAX_64 31 -#define ZSTD_WINDOWLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_WINDOWLOG_MAX_32 : ZSTD_WINDOWLOG_MAX_64)) -#define ZSTD_WINDOWLOG_MIN 10 -#define ZSTD_HASHLOG_MAX ((ZSTD_WINDOWLOG_MAX < 30) ? ZSTD_WINDOWLOG_MAX : 30) -#define ZSTD_HASHLOG_MIN 6 -#define ZSTD_CHAINLOG_MAX_32 29 -#define ZSTD_CHAINLOG_MAX_64 30 -#define ZSTD_CHAINLOG_MAX ((int)(sizeof(size_t) == 4 ? ZSTD_CHAINLOG_MAX_32 : ZSTD_CHAINLOG_MAX_64)) -#define ZSTD_CHAINLOG_MIN ZSTD_HASHLOG_MIN -#define ZSTD_SEARCHLOG_MAX (ZSTD_WINDOWLOG_MAX-1) -#define ZSTD_SEARCHLOG_MIN 1 -#define ZSTD_MINMATCH_MAX 7 /* only for ZSTD_fast, other strategies are limited to 6 */ -#define ZSTD_MINMATCH_MIN 3 /* only for ZSTD_btopt+, faster strategies are limited to 4 */ -#define ZSTD_TARGETLENGTH_MAX ZSTD_BLOCKSIZE_MAX -#define ZSTD_TARGETLENGTH_MIN 0 /* note : comparing this constant to an unsigned results in a tautological test */ -#define ZSTD_STRATEGY_MIN ZSTD_fast -#define ZSTD_STRATEGY_MAX ZSTD_btultra2 - - -#define ZSTD_OVERLAPLOG_MIN 0 -#define ZSTD_OVERLAPLOG_MAX 9 - -#define ZSTD_WINDOWLOG_LIMIT_DEFAULT 27 /* by default, the streaming decoder will refuse any frame - * requiring larger than (1< 3, then this is seqDef.offset - 3 - * If seqDef.offset < 3, then this is the corresponding repeat offset - * But if seqDef.offset < 3 and litLength == 0, this is the - * repeat offset before the corresponding repeat offset - * And if seqDef.offset == 3 and litLength == 0, this is the - * most recent repeat offset - 1 - */ - unsigned int offset; - unsigned int litLength; /* Literal length */ - unsigned int matchLength; /* Match length */ - /* 0 when seq not rep and seqDef.offset otherwise - * when litLength == 0 this will be <= 4, otherwise <= 3 like normal - */ - unsigned int rep; -} ZSTD_Sequence; - -typedef struct { - unsigned windowLog; /**< largest match distance : larger == more compression, more memory needed during decompression */ - unsigned chainLog; /**< fully searched segment : larger == more compression, slower, more memory (useless for fast) */ - unsigned hashLog; /**< dispatch table : larger == faster, more memory */ - unsigned searchLog; /**< nb of searches : larger == more compression, slower */ - unsigned minMatch; /**< match length searched : larger == faster decompression, sometimes less compression */ - unsigned targetLength; /**< acceptable match size for optimal parser (only) : larger == more compression, slower */ - ZSTD_strategy strategy; /**< see ZSTD_strategy definition above */ -} ZSTD_compressionParameters; - -typedef struct { - int contentSizeFlag; /**< 1: content size will be in frame header (when known) */ - int checksumFlag; /**< 1: generate a 32-bits checksum using XXH64 algorithm at end of frame, for error detection */ - int noDictIDFlag; /**< 1: no dictID will be saved into frame header (dictID is only useful for dictionary compression) */ -} ZSTD_frameParameters; - -typedef struct { - ZSTD_compressionParameters cParams; - ZSTD_frameParameters fParams; -} ZSTD_parameters; - -typedef enum { - ZSTD_dct_auto = 0, /* dictionary is "full" when starting with ZSTD_MAGIC_DICTIONARY, otherwise it is "rawContent" */ - ZSTD_dct_rawContent = 1, /* ensures dictionary is always loaded as rawContent, even if it starts with ZSTD_MAGIC_DICTIONARY */ - ZSTD_dct_fullDict = 2 /* refuses to load a dictionary if it does not respect Zstandard's specification, starting with ZSTD_MAGIC_DICTIONARY */ -} ZSTD_dictContentType_e; - -typedef enum { - ZSTD_dlm_byCopy = 0, /**< Copy dictionary content internally */ - ZSTD_dlm_byRef = 1 /**< Reference dictionary content -- the dictionary buffer must outlive its users. */ -} ZSTD_dictLoadMethod_e; - -typedef enum { - ZSTD_f_zstd1 = 0, /* zstd frame format, specified in zstd_compression_format.md (default) */ - ZSTD_f_zstd1_magicless = 1 /* Variant of zstd frame format, without initial 4-bytes magic number. - * Useful to save 4 bytes per generated frame. - * Decoder cannot recognise automatically this format, requiring this instruction. */ -} ZSTD_format_e; - -typedef enum { - /* Note: this enum and the behavior it controls are effectively internal - * implementation details of the compressor. They are expected to continue - * to evolve and should be considered only in the context of extremely - * advanced performance tuning. - * - * Zstd currently supports the use of a CDict in three ways: - * - * - The contents of the CDict can be copied into the working context. This - * means that the compression can search both the dictionary and input - * while operating on a single set of internal tables. This makes - * the compression faster per-byte of input. However, the initial copy of - * the CDict's tables incurs a fixed cost at the beginning of the - * compression. For small compressions (< 8 KB), that copy can dominate - * the cost of the compression. - * - * - The CDict's tables can be used in-place. In this model, compression is - * slower per input byte, because the compressor has to search two sets of - * tables. However, this model incurs no start-up cost (as long as the - * working context's tables can be reused). For small inputs, this can be - * faster than copying the CDict's tables. - * - * - The CDict's tables are not used at all, and instead we use the working - * context alone to reload the dictionary and use params based on the source - * size. See ZSTD_compress_insertDictionary() and ZSTD_compress_usingDict(). - * This method is effective when the dictionary sizes are very small relative - * to the input size, and the input size is fairly large to begin with. - * - * Zstd has a simple internal heuristic that selects which strategy to use - * at the beginning of a compression. However, if experimentation shows that - * Zstd is making poor choices, it is possible to override that choice with - * this enum. - */ - ZSTD_dictDefaultAttach = 0, /* Use the default heuristic. */ - ZSTD_dictForceAttach = 1, /* Never copy the dictionary. */ - ZSTD_dictForceCopy = 2, /* Always copy the dictionary. */ - ZSTD_dictForceLoad = 3 /* Always reload the dictionary */ -} ZSTD_dictAttachPref_e; - -typedef enum { - ZSTD_lcm_auto = 0, /**< Automatically determine the compression mode based on the compression level. - * Negative compression levels will be uncompressed, and positive compression - * levels will be compressed. */ - ZSTD_lcm_huffman = 1, /**< Always attempt Huffman compression. Uncompressed literals will still be - * emitted if Huffman compression is not profitable. */ - ZSTD_lcm_uncompressed = 2 /**< Always emit uncompressed literals. */ -} ZSTD_literalCompressionMode_e; - - -/*************************************** -* Frame size functions -***************************************/ - -/*! ZSTD_findDecompressedSize() : - * `src` should point to the start of a series of ZSTD encoded and/or skippable frames - * `srcSize` must be the _exact_ size of this series - * (i.e. there should be a frame boundary at `src + srcSize`) - * @return : - decompressed size of all data in all successive frames - * - if the decompressed size cannot be determined: ZSTD_CONTENTSIZE_UNKNOWN - * - if an error occurred: ZSTD_CONTENTSIZE_ERROR - * - * note 1 : decompressed size is an optional field, that may not be present, especially in streaming mode. - * When `return==ZSTD_CONTENTSIZE_UNKNOWN`, data to decompress could be any size. - * In which case, it's necessary to use streaming mode to decompress data. - * note 2 : decompressed size is always present when compression is done with ZSTD_compress() - * note 3 : decompressed size can be very large (64-bits value), - * potentially larger than what local system can handle as a single memory segment. - * In which case, it's necessary to use streaming mode to decompress data. - * note 4 : If source is untrusted, decompressed size could be wrong or intentionally modified. - * Always ensure result fits within application's authorized limits. - * Each application can set its own limits. - * note 5 : ZSTD_findDecompressedSize handles multiple frames, and so it must traverse the input to - * read each contained frame header. This is fast as most of the data is skipped, - * however it does mean that all frame data must be present and valid. */ -ZSTDLIB_API unsigned long long ZSTD_findDecompressedSize(const void* src, size_t srcSize); - -/*! ZSTD_decompressBound() : - * `src` should point to the start of a series of ZSTD encoded and/or skippable frames - * `srcSize` must be the _exact_ size of this series - * (i.e. there should be a frame boundary at `src + srcSize`) - * @return : - upper-bound for the decompressed size of all data in all successive frames - * - if an error occured: ZSTD_CONTENTSIZE_ERROR - * - * note 1 : an error can occur if `src` contains an invalid or incorrectly formatted frame. - * note 2 : the upper-bound is exact when the decompressed size field is available in every ZSTD encoded frame of `src`. - * in this case, `ZSTD_findDecompressedSize` and `ZSTD_decompressBound` return the same value. - * note 3 : when the decompressed size field isn't available, the upper-bound for that frame is calculated by: - * upper-bound = # blocks * min(128 KB, Window_Size) - */ -ZSTDLIB_API unsigned long long ZSTD_decompressBound(const void* src, size_t srcSize); - -/*! ZSTD_frameHeaderSize() : - * srcSize must be >= ZSTD_FRAMEHEADERSIZE_PREFIX. - * @return : size of the Frame Header, - * or an error code (if srcSize is too small) */ -ZSTDLIB_API size_t ZSTD_frameHeaderSize(const void* src, size_t srcSize); - -/*! ZSTD_getSequences() : - * Extract sequences from the sequence store - * zc can be used to insert custom compression params. - * This function invokes ZSTD_compress2 - * @return : number of sequences extracted - */ -ZSTDLIB_API size_t ZSTD_getSequences(ZSTD_CCtx* zc, ZSTD_Sequence* outSeqs, - size_t outSeqsSize, const void* src, size_t srcSize); - - -/*************************************** -* Memory management -***************************************/ - -/*! ZSTD_estimate*() : - * These functions make it possible to estimate memory usage of a future - * {D,C}Ctx, before its creation. - * - * ZSTD_estimateCCtxSize() will provide a budget large enough for any - * compression level up to selected one. Unlike ZSTD_estimateCStreamSize*(), - * this estimate does not include space for a window buffer, so this estimate - * is guaranteed to be enough for single-shot compressions, but not streaming - * compressions. It will however assume the input may be arbitrarily large, - * which is the worst case. If srcSize is known to always be small, - * ZSTD_estimateCCtxSize_usingCParams() can provide a tighter estimation. - * ZSTD_estimateCCtxSize_usingCParams() can be used in tandem with - * ZSTD_getCParams() to create cParams from compressionLevel. - * ZSTD_estimateCCtxSize_usingCCtxParams() can be used in tandem with - * ZSTD_CCtxParams_setParameter(). - * - * Note: only single-threaded compression is supported. This function will - * return an error code if ZSTD_c_nbWorkers is >= 1. */ -ZSTDLIB_API size_t ZSTD_estimateCCtxSize(int compressionLevel); -ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCParams(ZSTD_compressionParameters cParams); -ZSTDLIB_API size_t ZSTD_estimateCCtxSize_usingCCtxParams(const ZSTD_CCtx_params* params); -ZSTDLIB_API size_t ZSTD_estimateDCtxSize(void); - -/*! ZSTD_estimateCStreamSize() : - * ZSTD_estimateCStreamSize() will provide a budget large enough for any compression level up to selected one. - * It will also consider src size to be arbitrarily "large", which is worst case. - * If srcSize is known to always be small, ZSTD_estimateCStreamSize_usingCParams() can provide a tighter estimation. - * ZSTD_estimateCStreamSize_usingCParams() can be used in tandem with ZSTD_getCParams() to create cParams from compressionLevel. - * ZSTD_estimateCStreamSize_usingCCtxParams() can be used in tandem with ZSTD_CCtxParams_setParameter(). Only single-threaded compression is supported. This function will return an error code if ZSTD_c_nbWorkers is >= 1. - * Note : CStream size estimation is only correct for single-threaded compression. - * ZSTD_DStream memory budget depends on window Size. - * This information can be passed manually, using ZSTD_estimateDStreamSize, - * or deducted from a valid frame Header, using ZSTD_estimateDStreamSize_fromFrame(); - * Note : if streaming is init with function ZSTD_init?Stream_usingDict(), - * an internal ?Dict will be created, which additional size is not estimated here. - * In this case, get total size by adding ZSTD_estimate?DictSize */ -ZSTDLIB_API size_t ZSTD_estimateCStreamSize(int compressionLevel); -ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCParams(ZSTD_compressionParameters cParams); -ZSTDLIB_API size_t ZSTD_estimateCStreamSize_usingCCtxParams(const ZSTD_CCtx_params* params); -ZSTDLIB_API size_t ZSTD_estimateDStreamSize(size_t windowSize); -ZSTDLIB_API size_t ZSTD_estimateDStreamSize_fromFrame(const void* src, size_t srcSize); - -/*! ZSTD_estimate?DictSize() : - * ZSTD_estimateCDictSize() will bet that src size is relatively "small", and content is copied, like ZSTD_createCDict(). - * ZSTD_estimateCDictSize_advanced() makes it possible to control compression parameters precisely, like ZSTD_createCDict_advanced(). - * Note : dictionaries created by reference (`ZSTD_dlm_byRef`) are logically smaller. - */ -ZSTDLIB_API size_t ZSTD_estimateCDictSize(size_t dictSize, int compressionLevel); -ZSTDLIB_API size_t ZSTD_estimateCDictSize_advanced(size_t dictSize, ZSTD_compressionParameters cParams, ZSTD_dictLoadMethod_e dictLoadMethod); -ZSTDLIB_API size_t ZSTD_estimateDDictSize(size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod); - -/*! ZSTD_initStatic*() : - * Initialize an object using a pre-allocated fixed-size buffer. - * workspace: The memory area to emplace the object into. - * Provided pointer *must be 8-bytes aligned*. - * Buffer must outlive object. - * workspaceSize: Use ZSTD_estimate*Size() to determine - * how large workspace must be to support target scenario. - * @return : pointer to object (same address as workspace, just different type), - * or NULL if error (size too small, incorrect alignment, etc.) - * Note : zstd will never resize nor malloc() when using a static buffer. - * If the object requires more memory than available, - * zstd will just error out (typically ZSTD_error_memory_allocation). - * Note 2 : there is no corresponding "free" function. - * Since workspace is allocated externally, it must be freed externally too. - * Note 3 : cParams : use ZSTD_getCParams() to convert a compression level - * into its associated cParams. - * Limitation 1 : currently not compatible with internal dictionary creation, triggered by - * ZSTD_CCtx_loadDictionary(), ZSTD_initCStream_usingDict() or ZSTD_initDStream_usingDict(). - * Limitation 2 : static cctx currently not compatible with multi-threading. - * Limitation 3 : static dctx is incompatible with legacy support. - */ -ZSTDLIB_API ZSTD_CCtx* ZSTD_initStaticCCtx(void* workspace, size_t workspaceSize); -ZSTDLIB_API ZSTD_CStream* ZSTD_initStaticCStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticCCtx() */ - -ZSTDLIB_API ZSTD_DCtx* ZSTD_initStaticDCtx(void* workspace, size_t workspaceSize); -ZSTDLIB_API ZSTD_DStream* ZSTD_initStaticDStream(void* workspace, size_t workspaceSize); /**< same as ZSTD_initStaticDCtx() */ - -ZSTDLIB_API const ZSTD_CDict* ZSTD_initStaticCDict( - void* workspace, size_t workspaceSize, - const void* dict, size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType, - ZSTD_compressionParameters cParams); - -ZSTDLIB_API const ZSTD_DDict* ZSTD_initStaticDDict( - void* workspace, size_t workspaceSize, - const void* dict, size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType); - - -/*! Custom memory allocation : - * These prototypes make it possible to pass your own allocation/free functions. - * ZSTD_customMem is provided at creation time, using ZSTD_create*_advanced() variants listed below. - * All allocation/free operations will be completed using these custom variants instead of regular ones. - */ -typedef void* (*ZSTD_allocFunction) (void* opaque, size_t size); -typedef void (*ZSTD_freeFunction) (void* opaque, void* address); -typedef struct { ZSTD_allocFunction customAlloc; ZSTD_freeFunction customFree; void* opaque; } ZSTD_customMem; -static ZSTD_customMem const ZSTD_defaultCMem = { NULL, NULL, NULL }; /**< this constant defers to stdlib's functions */ - -ZSTDLIB_API ZSTD_CCtx* ZSTD_createCCtx_advanced(ZSTD_customMem customMem); -ZSTDLIB_API ZSTD_CStream* ZSTD_createCStream_advanced(ZSTD_customMem customMem); -ZSTDLIB_API ZSTD_DCtx* ZSTD_createDCtx_advanced(ZSTD_customMem customMem); -ZSTDLIB_API ZSTD_DStream* ZSTD_createDStream_advanced(ZSTD_customMem customMem); - -ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_advanced(const void* dict, size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType, - ZSTD_compressionParameters cParams, - ZSTD_customMem customMem); - -ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_advanced(const void* dict, size_t dictSize, - ZSTD_dictLoadMethod_e dictLoadMethod, - ZSTD_dictContentType_e dictContentType, - ZSTD_customMem customMem); - - - -/*************************************** -* Advanced compression functions -***************************************/ - -/*! ZSTD_createCDict_byReference() : - * Create a digested dictionary for compression - * Dictionary content is just referenced, not duplicated. - * As a consequence, `dictBuffer` **must** outlive CDict, - * and its content must remain unmodified throughout the lifetime of CDict. - * note: equivalent to ZSTD_createCDict_advanced(), with dictLoadMethod==ZSTD_dlm_byRef */ -ZSTDLIB_API ZSTD_CDict* ZSTD_createCDict_byReference(const void* dictBuffer, size_t dictSize, int compressionLevel); - -/*! ZSTD_getCParams() : - * @return ZSTD_compressionParameters structure for a selected compression level and estimated srcSize. - * `estimatedSrcSize` value is optional, select 0 if not known */ -ZSTDLIB_API ZSTD_compressionParameters ZSTD_getCParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize); - -/*! ZSTD_getParams() : - * same as ZSTD_getCParams(), but @return a full `ZSTD_parameters` object instead of sub-component `ZSTD_compressionParameters`. - * All fields of `ZSTD_frameParameters` are set to default : contentSize=1, checksum=0, noDictID=0 */ -ZSTDLIB_API ZSTD_parameters ZSTD_getParams(int compressionLevel, unsigned long long estimatedSrcSize, size_t dictSize); - -/*! ZSTD_checkCParams() : - * Ensure param values remain within authorized range. - * @return 0 on success, or an error code (can be checked with ZSTD_isError()) */ -ZSTDLIB_API size_t ZSTD_checkCParams(ZSTD_compressionParameters params); - -/*! ZSTD_adjustCParams() : - * optimize params for a given `srcSize` and `dictSize`. - * `srcSize` can be unknown, in which case use ZSTD_CONTENTSIZE_UNKNOWN. - * `dictSize` must be `0` when there is no dictionary. - * cPar can be invalid : all parameters will be clamped within valid range in the @return struct. - * This function never fails (wide contract) */ -ZSTDLIB_API ZSTD_compressionParameters ZSTD_adjustCParams(ZSTD_compressionParameters cPar, unsigned long long srcSize, size_t dictSize); - -/*! ZSTD_compress_advanced() : - * Note : this function is now DEPRECATED. - * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_setParameter() and other parameter setters. - * This prototype will be marked as deprecated and generate compilation warning on reaching v1.5.x */ -ZSTDLIB_API size_t ZSTD_compress_advanced(ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const void* dict,size_t dictSize, - ZSTD_parameters params); - -/*! ZSTD_compress_usingCDict_advanced() : - * Note : this function is now REDUNDANT. - * It can be replaced by ZSTD_compress2(), in combination with ZSTD_CCtx_loadDictionary() and other parameter setters. - * This prototype will be marked as deprecated and generate compilation warning in some future version */ -ZSTDLIB_API size_t ZSTD_compress_usingCDict_advanced(ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, - const void* src, size_t srcSize, - const ZSTD_CDict* cdict, - ZSTD_frameParameters fParams); - - -/*! ZSTD_CCtx_loadDictionary_byReference() : - * Same as ZSTD_CCtx_loadDictionary(), but dictionary content is referenced, instead of being copied into CCtx. - * It saves some memory, but also requires that `dict` outlives its usage within `cctx` */ -ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_byReference(ZSTD_CCtx* cctx, const void* dict, size_t dictSize); - -/*! ZSTD_CCtx_loadDictionary_advanced() : - * Same as ZSTD_CCtx_loadDictionary(), but gives finer control over - * how to load the dictionary (by copy ? by reference ?) - * and how to interpret it (automatic ? force raw mode ? full mode only ?) */ -ZSTDLIB_API size_t ZSTD_CCtx_loadDictionary_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType); - -/*! ZSTD_CCtx_refPrefix_advanced() : - * Same as ZSTD_CCtx_refPrefix(), but gives finer control over - * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */ -ZSTDLIB_API size_t ZSTD_CCtx_refPrefix_advanced(ZSTD_CCtx* cctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType); - -/* === experimental parameters === */ -/* these parameters can be used with ZSTD_setParameter() - * they are not guaranteed to remain supported in the future */ - - /* Enables rsyncable mode, - * which makes compressed files more rsync friendly - * by adding periodic synchronization points to the compressed data. - * The target average block size is ZSTD_c_jobSize / 2. - * It's possible to modify the job size to increase or decrease - * the granularity of the synchronization point. - * Once the jobSize is smaller than the window size, - * it will result in compression ratio degradation. - * NOTE 1: rsyncable mode only works when multithreading is enabled. - * NOTE 2: rsyncable performs poorly in combination with long range mode, - * since it will decrease the effectiveness of synchronization points, - * though mileage may vary. - * NOTE 3: Rsyncable mode limits maximum compression speed to ~400 MB/s. - * If the selected compression level is already running significantly slower, - * the overall speed won't be significantly impacted. - */ - #define ZSTD_c_rsyncable ZSTD_c_experimentalParam1 - -/* Select a compression format. - * The value must be of type ZSTD_format_e. - * See ZSTD_format_e enum definition for details */ -#define ZSTD_c_format ZSTD_c_experimentalParam2 - -/* Force back-reference distances to remain < windowSize, - * even when referencing into Dictionary content (default:0) */ -#define ZSTD_c_forceMaxWindow ZSTD_c_experimentalParam3 - -/* Controls whether the contents of a CDict - * are used in place, or copied into the working context. - * Accepts values from the ZSTD_dictAttachPref_e enum. - * See the comments on that enum for an explanation of the feature. */ -#define ZSTD_c_forceAttachDict ZSTD_c_experimentalParam4 - -/* Controls how the literals are compressed (default is auto). - * The value must be of type ZSTD_literalCompressionMode_e. - * See ZSTD_literalCompressionMode_t enum definition for details. - */ -#define ZSTD_c_literalCompressionMode ZSTD_c_experimentalParam5 - -/* Tries to fit compressed block size to be around targetCBlockSize. - * No target when targetCBlockSize == 0. - * There is no guarantee on compressed block size (default:0) */ -#define ZSTD_c_targetCBlockSize ZSTD_c_experimentalParam6 - -/* User's best guess of source size. - * Hint is not valid when srcSizeHint == 0. - * There is no guarantee that hint is close to actual source size, - * but compression ratio may regress significantly if guess considerably underestimates */ -#define ZSTD_c_srcSizeHint ZSTD_c_experimentalParam7 - -/*! ZSTD_CCtx_getParameter() : - * Get the requested compression parameter value, selected by enum ZSTD_cParameter, - * and store it into int* value. - * @return : 0, or an error code (which can be tested with ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_CCtx_getParameter(ZSTD_CCtx* cctx, ZSTD_cParameter param, int* value); - - -/*! ZSTD_CCtx_params : - * Quick howto : - * - ZSTD_createCCtxParams() : Create a ZSTD_CCtx_params structure - * - ZSTD_CCtxParams_setParameter() : Push parameters one by one into - * an existing ZSTD_CCtx_params structure. - * This is similar to - * ZSTD_CCtx_setParameter(). - * - ZSTD_CCtx_setParametersUsingCCtxParams() : Apply parameters to - * an existing CCtx. - * These parameters will be applied to - * all subsequent frames. - * - ZSTD_compressStream2() : Do compression using the CCtx. - * - ZSTD_freeCCtxParams() : Free the memory. - * - * This can be used with ZSTD_estimateCCtxSize_advanced_usingCCtxParams() - * for static allocation of CCtx for single-threaded compression. - */ -ZSTDLIB_API ZSTD_CCtx_params* ZSTD_createCCtxParams(void); -ZSTDLIB_API size_t ZSTD_freeCCtxParams(ZSTD_CCtx_params* params); - -/*! ZSTD_CCtxParams_reset() : - * Reset params to default values. - */ -ZSTDLIB_API size_t ZSTD_CCtxParams_reset(ZSTD_CCtx_params* params); - -/*! ZSTD_CCtxParams_init() : - * Initializes the compression parameters of cctxParams according to - * compression level. All other parameters are reset to their default values. - */ -ZSTDLIB_API size_t ZSTD_CCtxParams_init(ZSTD_CCtx_params* cctxParams, int compressionLevel); - -/*! ZSTD_CCtxParams_init_advanced() : - * Initializes the compression and frame parameters of cctxParams according to - * params. All other parameters are reset to their default values. - */ -ZSTDLIB_API size_t ZSTD_CCtxParams_init_advanced(ZSTD_CCtx_params* cctxParams, ZSTD_parameters params); - -/*! ZSTD_CCtxParams_setParameter() : - * Similar to ZSTD_CCtx_setParameter. - * Set one compression parameter, selected by enum ZSTD_cParameter. - * Parameters must be applied to a ZSTD_CCtx using ZSTD_CCtx_setParametersUsingCCtxParams(). - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_CCtxParams_setParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int value); - -/*! ZSTD_CCtxParams_getParameter() : - * Similar to ZSTD_CCtx_getParameter. - * Get the requested value of one compression parameter, selected by enum ZSTD_cParameter. - * @result : 0, or an error code (which can be tested with ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_CCtxParams_getParameter(ZSTD_CCtx_params* params, ZSTD_cParameter param, int* value); - -/*! ZSTD_CCtx_setParametersUsingCCtxParams() : - * Apply a set of ZSTD_CCtx_params to the compression context. - * This can be done even after compression is started, - * if nbWorkers==0, this will have no impact until a new compression is started. - * if nbWorkers>=1, new parameters will be picked up at next job, - * with a few restrictions (windowLog, pledgedSrcSize, nbWorkers, jobSize, and overlapLog are not updated). - */ -ZSTDLIB_API size_t ZSTD_CCtx_setParametersUsingCCtxParams( - ZSTD_CCtx* cctx, const ZSTD_CCtx_params* params); - -/*! ZSTD_compressStream2_simpleArgs() : - * Same as ZSTD_compressStream2(), - * but using only integral types as arguments. - * This variant might be helpful for binders from dynamic languages - * which have troubles handling structures containing memory pointers. - */ -ZSTDLIB_API size_t ZSTD_compressStream2_simpleArgs ( - ZSTD_CCtx* cctx, - void* dst, size_t dstCapacity, size_t* dstPos, - const void* src, size_t srcSize, size_t* srcPos, - ZSTD_EndDirective endOp); - - -/*************************************** -* Advanced decompression functions -***************************************/ - -/*! ZSTD_isFrame() : - * Tells if the content of `buffer` starts with a valid Frame Identifier. - * Note : Frame Identifier is 4 bytes. If `size < 4`, @return will always be 0. - * Note 2 : Legacy Frame Identifiers are considered valid only if Legacy Support is enabled. - * Note 3 : Skippable Frame Identifiers are considered valid. */ -ZSTDLIB_API unsigned ZSTD_isFrame(const void* buffer, size_t size); - -/*! ZSTD_createDDict_byReference() : - * Create a digested dictionary, ready to start decompression operation without startup delay. - * Dictionary content is referenced, and therefore stays in dictBuffer. - * It is important that dictBuffer outlives DDict, - * it must remain read accessible throughout the lifetime of DDict */ -ZSTDLIB_API ZSTD_DDict* ZSTD_createDDict_byReference(const void* dictBuffer, size_t dictSize); - -/*! ZSTD_DCtx_loadDictionary_byReference() : - * Same as ZSTD_DCtx_loadDictionary(), - * but references `dict` content instead of copying it into `dctx`. - * This saves memory if `dict` remains around., - * However, it's imperative that `dict` remains accessible (and unmodified) while being used, so it must outlive decompression. */ -ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_byReference(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); - -/*! ZSTD_DCtx_loadDictionary_advanced() : - * Same as ZSTD_DCtx_loadDictionary(), - * but gives direct control over - * how to load the dictionary (by copy ? by reference ?) - * and how to interpret it (automatic ? force raw mode ? full mode only ?). */ -ZSTDLIB_API size_t ZSTD_DCtx_loadDictionary_advanced(ZSTD_DCtx* dctx, const void* dict, size_t dictSize, ZSTD_dictLoadMethod_e dictLoadMethod, ZSTD_dictContentType_e dictContentType); - -/*! ZSTD_DCtx_refPrefix_advanced() : - * Same as ZSTD_DCtx_refPrefix(), but gives finer control over - * how to interpret prefix content (automatic ? force raw mode (default) ? full mode only ?) */ -ZSTDLIB_API size_t ZSTD_DCtx_refPrefix_advanced(ZSTD_DCtx* dctx, const void* prefix, size_t prefixSize, ZSTD_dictContentType_e dictContentType); - -/*! ZSTD_DCtx_setMaxWindowSize() : - * Refuses allocating internal buffers for frames requiring a window size larger than provided limit. - * This protects a decoder context from reserving too much memory for itself (potential attack scenario). - * This parameter is only useful in streaming mode, since no internal buffer is allocated in single-pass mode. - * By default, a decompression context accepts all window sizes <= (1 << ZSTD_WINDOWLOG_LIMIT_DEFAULT) - * @return : 0, or an error code (which can be tested using ZSTD_isError()). - */ -ZSTDLIB_API size_t ZSTD_DCtx_setMaxWindowSize(ZSTD_DCtx* dctx, size_t maxWindowSize); - -/* ZSTD_d_format - * experimental parameter, - * allowing selection between ZSTD_format_e input compression formats - */ -#define ZSTD_d_format ZSTD_d_experimentalParam1 - -/*! ZSTD_DCtx_setFormat() : - * Instruct the decoder context about what kind of data to decode next. - * This instruction is mandatory to decode data without a fully-formed header, - * such ZSTD_f_zstd1_magicless for example. - * @return : 0, or an error code (which can be tested using ZSTD_isError()). */ -ZSTDLIB_API size_t ZSTD_DCtx_setFormat(ZSTD_DCtx* dctx, ZSTD_format_e format); - -/*! ZSTD_decompressStream_simpleArgs() : - * Same as ZSTD_decompressStream(), - * but using only integral types as arguments. - * This can be helpful for binders from dynamic languages - * which have troubles handling structures containing memory pointers. - */ -ZSTDLIB_API size_t ZSTD_decompressStream_simpleArgs ( - ZSTD_DCtx* dctx, - void* dst, size_t dstCapacity, size_t* dstPos, - const void* src, size_t srcSize, size_t* srcPos); - - -/******************************************************************** -* Advanced streaming functions -* Warning : most of these functions are now redundant with the Advanced API. -* Once Advanced API reaches "stable" status, -* redundant functions will be deprecated, and then at some point removed. -********************************************************************/ - -/*===== Advanced Streaming compression functions =====*/ -/**! ZSTD_initCStream_srcSize() : - * This function is deprecated, and equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_refCDict(zcs, NULL); // clear the dictionary (if any) - * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - * - * pledgedSrcSize must be correct. If it is not known at init time, use - * ZSTD_CONTENTSIZE_UNKNOWN. Note that, for compatibility with older programs, - * "0" also disables frame content size field. It may be enabled in the future. - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t -ZSTD_initCStream_srcSize(ZSTD_CStream* zcs, - int compressionLevel, - unsigned long long pledgedSrcSize); - -/**! ZSTD_initCStream_usingDict() : - * This function is deprecated, and is equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_setParameter(zcs, ZSTD_c_compressionLevel, compressionLevel); - * ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); - * - * Creates of an internal CDict (incompatible with static CCtx), except if - * dict == NULL or dictSize < 8, in which case no dict is used. - * Note: dict is loaded with ZSTD_dct_auto (treated as a full zstd dictionary if - * it begins with ZSTD_MAGIC_DICTIONARY, else as raw content) and ZSTD_dlm_byCopy. - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t -ZSTD_initCStream_usingDict(ZSTD_CStream* zcs, - const void* dict, size_t dictSize, - int compressionLevel); - -/**! ZSTD_initCStream_advanced() : - * This function is deprecated, and is approximately equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * // Pseudocode: Set each zstd parameter and leave the rest as-is. - * for ((param, value) : params) { - * ZSTD_CCtx_setParameter(zcs, param, value); - * } - * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - * ZSTD_CCtx_loadDictionary(zcs, dict, dictSize); - * - * dict is loaded with ZSTD_dct_auto and ZSTD_dlm_byCopy. - * pledgedSrcSize must be correct. - * If srcSize is not known at init time, use value ZSTD_CONTENTSIZE_UNKNOWN. - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t -ZSTD_initCStream_advanced(ZSTD_CStream* zcs, - const void* dict, size_t dictSize, - ZSTD_parameters params, - unsigned long long pledgedSrcSize); - -/**! ZSTD_initCStream_usingCDict() : - * This function is deprecated, and equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_refCDict(zcs, cdict); - * - * note : cdict will just be referenced, and must outlive compression session - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t ZSTD_initCStream_usingCDict(ZSTD_CStream* zcs, const ZSTD_CDict* cdict); - -/**! ZSTD_initCStream_usingCDict_advanced() : - * This function is DEPRECATED, and is approximately equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * // Pseudocode: Set each zstd frame parameter and leave the rest as-is. - * for ((fParam, value) : fParams) { - * ZSTD_CCtx_setParameter(zcs, fParam, value); - * } - * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - * ZSTD_CCtx_refCDict(zcs, cdict); - * - * same as ZSTD_initCStream_usingCDict(), with control over frame parameters. - * pledgedSrcSize must be correct. If srcSize is not known at init time, use - * value ZSTD_CONTENTSIZE_UNKNOWN. - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t -ZSTD_initCStream_usingCDict_advanced(ZSTD_CStream* zcs, - const ZSTD_CDict* cdict, - ZSTD_frameParameters fParams, - unsigned long long pledgedSrcSize); - -/*! ZSTD_resetCStream() : - * This function is deprecated, and is equivalent to: - * ZSTD_CCtx_reset(zcs, ZSTD_reset_session_only); - * ZSTD_CCtx_setPledgedSrcSize(zcs, pledgedSrcSize); - * - * start a new frame, using same parameters from previous frame. - * This is typically useful to skip dictionary loading stage, since it will re-use it in-place. - * Note that zcs must be init at least once before using ZSTD_resetCStream(). - * If pledgedSrcSize is not known at reset time, use macro ZSTD_CONTENTSIZE_UNKNOWN. - * If pledgedSrcSize > 0, its value must be correct, as it will be written in header, and controlled at the end. - * For the time being, pledgedSrcSize==0 is interpreted as "srcSize unknown" for compatibility with older programs, - * but it will change to mean "empty" in future version, so use macro ZSTD_CONTENTSIZE_UNKNOWN instead. - * @return : 0, or an error code (which can be tested using ZSTD_isError()) - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t ZSTD_resetCStream(ZSTD_CStream* zcs, unsigned long long pledgedSrcSize); - - -typedef struct { - unsigned long long ingested; /* nb input bytes read and buffered */ - unsigned long long consumed; /* nb input bytes actually compressed */ - unsigned long long produced; /* nb of compressed bytes generated and buffered */ - unsigned long long flushed; /* nb of compressed bytes flushed : not provided; can be tracked from caller side */ - unsigned currentJobID; /* MT only : latest started job nb */ - unsigned nbActiveWorkers; /* MT only : nb of workers actively compressing at probe time */ -} ZSTD_frameProgression; - -/* ZSTD_getFrameProgression() : - * tells how much data has been ingested (read from input) - * consumed (input actually compressed) and produced (output) for current frame. - * Note : (ingested - consumed) is amount of input data buffered internally, not yet compressed. - * Aggregates progression inside active worker threads. - */ -ZSTDLIB_API ZSTD_frameProgression ZSTD_getFrameProgression(const ZSTD_CCtx* cctx); - -/*! ZSTD_toFlushNow() : - * Tell how many bytes are ready to be flushed immediately. - * Useful for multithreading scenarios (nbWorkers >= 1). - * Probe the oldest active job, defined as oldest job not yet entirely flushed, - * and check its output buffer. - * @return : amount of data stored in oldest job and ready to be flushed immediately. - * if @return == 0, it means either : - * + there is no active job (could be checked with ZSTD_frameProgression()), or - * + oldest job is still actively compressing data, - * but everything it has produced has also been flushed so far, - * therefore flush speed is limited by production speed of oldest job - * irrespective of the speed of concurrent (and newer) jobs. - */ -ZSTDLIB_API size_t ZSTD_toFlushNow(ZSTD_CCtx* cctx); - - -/*===== Advanced Streaming decompression functions =====*/ -/** - * This function is deprecated, and is equivalent to: - * - * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - * ZSTD_DCtx_loadDictionary(zds, dict, dictSize); - * - * note: no dictionary will be used if dict == NULL or dictSize < 8 - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t ZSTD_initDStream_usingDict(ZSTD_DStream* zds, const void* dict, size_t dictSize); - -/** - * This function is deprecated, and is equivalent to: - * - * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - * ZSTD_DCtx_refDDict(zds, ddict); - * - * note : ddict is referenced, it must outlive decompression session - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t ZSTD_initDStream_usingDDict(ZSTD_DStream* zds, const ZSTD_DDict* ddict); - -/** - * This function is deprecated, and is equivalent to: - * - * ZSTD_DCtx_reset(zds, ZSTD_reset_session_only); - * - * re-use decompression parameters from previous init; saves dictionary loading - * Note : this prototype will be marked as deprecated and generate compilation warnings on reaching v1.5.x - */ -ZSTDLIB_API size_t ZSTD_resetDStream(ZSTD_DStream* zds); - - -/********************************************************************* -* Buffer-less and synchronous inner streaming functions -* -* This is an advanced API, giving full control over buffer management, for users which need direct control over memory. -* But it's also a complex one, with several restrictions, documented below. -* Prefer normal streaming API for an easier experience. -********************************************************************* */ - -/** - Buffer-less streaming compression (synchronous mode) - - A ZSTD_CCtx object is required to track streaming operations. - Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource. - ZSTD_CCtx object can be re-used multiple times within successive compression operations. - - Start by initializing a context. - Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression, - or ZSTD_compressBegin_advanced(), for finer parameter control. - It's also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx() - - Then, consume your input using ZSTD_compressContinue(). - There are some important considerations to keep in mind when using this advanced function : - - ZSTD_compressContinue() has no internal buffer. It uses externally provided buffers only. - - Interface is synchronous : input is consumed entirely and produces 1+ compressed blocks. - - Caller must ensure there is enough space in `dst` to store compressed data under worst case scenario. - Worst case evaluation is provided by ZSTD_compressBound(). - ZSTD_compressContinue() doesn't guarantee recover after a failed compression. - - ZSTD_compressContinue() presumes prior input ***is still accessible and unmodified*** (up to maximum distance size, see WindowLog). - It remembers all previous contiguous blocks, plus one separated memory segment (which can itself consists of multiple contiguous blocks) - - ZSTD_compressContinue() detects that prior input has been overwritten when `src` buffer overlaps. - In which case, it will "discard" the relevant memory section from its history. - - Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum. - It's possible to use srcSize==0, in which case, it will write a final empty block to end the frame. - Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders. - - `ZSTD_CCtx` object can be re-used (ZSTD_compressBegin()) to compress again. -*/ - -/*===== Buffer-less streaming compression functions =====*/ -ZSTDLIB_API size_t ZSTD_compressBegin(ZSTD_CCtx* cctx, int compressionLevel); -ZSTDLIB_API size_t ZSTD_compressBegin_usingDict(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, int compressionLevel); -ZSTDLIB_API size_t ZSTD_compressBegin_advanced(ZSTD_CCtx* cctx, const void* dict, size_t dictSize, ZSTD_parameters params, unsigned long long pledgedSrcSize); /**< pledgedSrcSize : If srcSize is not known at init time, use ZSTD_CONTENTSIZE_UNKNOWN */ -ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict(ZSTD_CCtx* cctx, const ZSTD_CDict* cdict); /**< note: fails if cdict==NULL */ -ZSTDLIB_API size_t ZSTD_compressBegin_usingCDict_advanced(ZSTD_CCtx* const cctx, const ZSTD_CDict* const cdict, ZSTD_frameParameters const fParams, unsigned long long const pledgedSrcSize); /* compression parameters are already set within cdict. pledgedSrcSize must be correct. If srcSize is not known, use macro ZSTD_CONTENTSIZE_UNKNOWN */ -ZSTDLIB_API size_t ZSTD_copyCCtx(ZSTD_CCtx* cctx, const ZSTD_CCtx* preparedCCtx, unsigned long long pledgedSrcSize); /**< note: if pledgedSrcSize is not known, use ZSTD_CONTENTSIZE_UNKNOWN */ - -ZSTDLIB_API size_t ZSTD_compressContinue(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); -ZSTDLIB_API size_t ZSTD_compressEnd(ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); - - -/*- - Buffer-less streaming decompression (synchronous mode) - - A ZSTD_DCtx object is required to track streaming operations. - Use ZSTD_createDCtx() / ZSTD_freeDCtx() to manage it. - A ZSTD_DCtx object can be re-used multiple times. - - First typical operation is to retrieve frame parameters, using ZSTD_getFrameHeader(). - Frame header is extracted from the beginning of compressed frame, so providing only the frame's beginning is enough. - Data fragment must be large enough to ensure successful decoding. - `ZSTD_frameHeaderSize_max` bytes is guaranteed to always be large enough. - @result : 0 : successful decoding, the `ZSTD_frameHeader` structure is correctly filled. - >0 : `srcSize` is too small, please provide at least @result bytes on next attempt. - errorCode, which can be tested using ZSTD_isError(). - - It fills a ZSTD_frameHeader structure with important information to correctly decode the frame, - such as the dictionary ID, content size, or maximum back-reference distance (`windowSize`). - Note that these values could be wrong, either because of data corruption, or because a 3rd party deliberately spoofs false information. - As a consequence, check that values remain within valid application range. - For example, do not allocate memory blindly, check that `windowSize` is within expectation. - Each application can set its own limits, depending on local restrictions. - For extended interoperability, it is recommended to support `windowSize` of at least 8 MB. - - ZSTD_decompressContinue() needs previous data blocks during decompression, up to `windowSize` bytes. - ZSTD_decompressContinue() is very sensitive to contiguity, - if 2 blocks don't follow each other, make sure that either the compressor breaks contiguity at the same place, - or that previous contiguous segment is large enough to properly handle maximum back-reference distance. - There are multiple ways to guarantee this condition. - - The most memory efficient way is to use a round buffer of sufficient size. - Sufficient size is determined by invoking ZSTD_decodingBufferSize_min(), - which can @return an error code if required value is too large for current system (in 32-bits mode). - In a round buffer methodology, ZSTD_decompressContinue() decompresses each block next to previous one, - up to the moment there is not enough room left in the buffer to guarantee decoding another full block, - which maximum size is provided in `ZSTD_frameHeader` structure, field `blockSizeMax`. - At which point, decoding can resume from the beginning of the buffer. - Note that already decoded data stored in the buffer should be flushed before being overwritten. - - There are alternatives possible, for example using two or more buffers of size `windowSize` each, though they consume more memory. - - Finally, if you control the compression process, you can also ignore all buffer size rules, - as long as the encoder and decoder progress in "lock-step", - aka use exactly the same buffer sizes, break contiguity at the same place, etc. - - Once buffers are setup, start decompression, with ZSTD_decompressBegin(). - If decompression requires a dictionary, use ZSTD_decompressBegin_usingDict() or ZSTD_decompressBegin_usingDDict(). - - Then use ZSTD_nextSrcSizeToDecompress() and ZSTD_decompressContinue() alternatively. - ZSTD_nextSrcSizeToDecompress() tells how many bytes to provide as 'srcSize' to ZSTD_decompressContinue(). - ZSTD_decompressContinue() requires this _exact_ amount of bytes, or it will fail. - - @result of ZSTD_decompressContinue() is the number of bytes regenerated within 'dst' (necessarily <= dstCapacity). - It can be zero : it just means ZSTD_decompressContinue() has decoded some metadata item. - It can also be an error code, which can be tested with ZSTD_isError(). - - A frame is fully decoded when ZSTD_nextSrcSizeToDecompress() returns zero. - Context can then be reset to start a new decompression. - - Note : it's possible to know if next input to present is a header or a block, using ZSTD_nextInputType(). - This information is not required to properly decode a frame. - - == Special case : skippable frames == - - Skippable frames allow integration of user-defined data into a flow of concatenated frames. - Skippable frames will be ignored (skipped) by decompressor. - The format of skippable frames is as follows : - a) Skippable frame ID - 4 Bytes, Little endian format, any value from 0x184D2A50 to 0x184D2A5F - b) Frame Size - 4 Bytes, Little endian format, unsigned 32-bits - c) Frame Content - any content (User Data) of length equal to Frame Size - For skippable frames ZSTD_getFrameHeader() returns zfhPtr->frameType==ZSTD_skippableFrame. - For skippable frames ZSTD_decompressContinue() always returns 0 : it only skips the content. -*/ - -/*===== Buffer-less streaming decompression functions =====*/ -typedef enum { ZSTD_frame, ZSTD_skippableFrame } ZSTD_frameType_e; -typedef struct { - unsigned long long frameContentSize; /* if == ZSTD_CONTENTSIZE_UNKNOWN, it means this field is not available. 0 means "empty" */ - unsigned long long windowSize; /* can be very large, up to <= frameContentSize */ - unsigned blockSizeMax; - ZSTD_frameType_e frameType; /* if == ZSTD_skippableFrame, frameContentSize is the size of skippable content */ - unsigned headerSize; - unsigned dictID; - unsigned checksumFlag; -} ZSTD_frameHeader; - -/*! ZSTD_getFrameHeader() : - * decode Frame Header, or requires larger `srcSize`. - * @return : 0, `zfhPtr` is correctly filled, - * >0, `srcSize` is too small, value is wanted `srcSize` amount, - * or an error code, which can be tested using ZSTD_isError() */ -ZSTDLIB_API size_t ZSTD_getFrameHeader(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize); /**< doesn't consume input */ -/*! ZSTD_getFrameHeader_advanced() : - * same as ZSTD_getFrameHeader(), - * with added capability to select a format (like ZSTD_f_zstd1_magicless) */ -ZSTDLIB_API size_t ZSTD_getFrameHeader_advanced(ZSTD_frameHeader* zfhPtr, const void* src, size_t srcSize, ZSTD_format_e format); -ZSTDLIB_API size_t ZSTD_decodingBufferSize_min(unsigned long long windowSize, unsigned long long frameContentSize); /**< when frame content size is not known, pass in frameContentSize == ZSTD_CONTENTSIZE_UNKNOWN */ - -ZSTDLIB_API size_t ZSTD_decompressBegin(ZSTD_DCtx* dctx); -ZSTDLIB_API size_t ZSTD_decompressBegin_usingDict(ZSTD_DCtx* dctx, const void* dict, size_t dictSize); -ZSTDLIB_API size_t ZSTD_decompressBegin_usingDDict(ZSTD_DCtx* dctx, const ZSTD_DDict* ddict); - -ZSTDLIB_API size_t ZSTD_nextSrcSizeToDecompress(ZSTD_DCtx* dctx); -ZSTDLIB_API size_t ZSTD_decompressContinue(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); - -/* misc */ -ZSTDLIB_API void ZSTD_copyDCtx(ZSTD_DCtx* dctx, const ZSTD_DCtx* preparedDCtx); -typedef enum { ZSTDnit_frameHeader, ZSTDnit_blockHeader, ZSTDnit_block, ZSTDnit_lastBlock, ZSTDnit_checksum, ZSTDnit_skippableFrame } ZSTD_nextInputType_e; -ZSTDLIB_API ZSTD_nextInputType_e ZSTD_nextInputType(ZSTD_DCtx* dctx); - - - - -/* ============================ */ -/** Block level API */ -/* ============================ */ - -/*! - Block functions produce and decode raw zstd blocks, without frame metadata. - Frame metadata cost is typically ~12 bytes, which can be non-negligible for very small blocks (< 100 bytes). - But users will have to take in charge needed metadata to regenerate data, such as compressed and content sizes. - - A few rules to respect : - - Compressing and decompressing require a context structure - + Use ZSTD_createCCtx() and ZSTD_createDCtx() - - It is necessary to init context before starting - + compression : any ZSTD_compressBegin*() variant, including with dictionary - + decompression : any ZSTD_decompressBegin*() variant, including with dictionary - + copyCCtx() and copyDCtx() can be used too - - Block size is limited, it must be <= ZSTD_getBlockSize() <= ZSTD_BLOCKSIZE_MAX == 128 KB - + If input is larger than a block size, it's necessary to split input data into multiple blocks - + For inputs larger than a single block, consider using regular ZSTD_compress() instead. - Frame metadata is not that costly, and quickly becomes negligible as source size grows larger than a block. - - When a block is considered not compressible enough, ZSTD_compressBlock() result will be 0 (zero) ! - ===> In which case, nothing is produced into `dst` ! - + User __must__ test for such outcome and deal directly with uncompressed data - + A block cannot be declared incompressible if ZSTD_compressBlock() return value was != 0. - Doing so would mess up with statistics history, leading to potential data corruption. - + ZSTD_decompressBlock() _doesn't accept uncompressed data as input_ !! - + In case of multiple successive blocks, should some of them be uncompressed, - decoder must be informed of their existence in order to follow proper history. - Use ZSTD_insertBlock() for such a case. -*/ - -/*===== Raw zstd block functions =====*/ -ZSTDLIB_API size_t ZSTD_getBlockSize (const ZSTD_CCtx* cctx); -ZSTDLIB_API size_t ZSTD_compressBlock (ZSTD_CCtx* cctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); -ZSTDLIB_API size_t ZSTD_decompressBlock(ZSTD_DCtx* dctx, void* dst, size_t dstCapacity, const void* src, size_t srcSize); -ZSTDLIB_API size_t ZSTD_insertBlock (ZSTD_DCtx* dctx, const void* blockStart, size_t blockSize); /**< insert uncompressed block into `dctx` history. Useful for multi-blocks decompression. */ - - -#endif /* ZSTD_H_ZSTD_STATIC_LINKING_ONLY */ - -#if defined (__cplusplus) -} -#endif diff --git a/maclibs/lib/ao/libmacosx.so b/maclibs/lib/ao/libmacosx.so deleted file mode 100644 index 54301fb3..00000000 Binary files a/maclibs/lib/ao/libmacosx.so and /dev/null differ diff --git a/maclibs/lib/libao.dylib b/maclibs/lib/libao.dylib deleted file mode 100644 index d8ac92d7..00000000 Binary files a/maclibs/lib/libao.dylib and /dev/null differ diff --git a/maclibs/lib/libavcodec-gd.dylib b/maclibs/lib/libavcodec-gd.dylib deleted file mode 100644 index 1d078c83..00000000 Binary files a/maclibs/lib/libavcodec-gd.dylib and /dev/null differ diff --git a/maclibs/lib/libavformat-gd.dylib b/maclibs/lib/libavformat-gd.dylib deleted file mode 100644 index 06ab2a8c..00000000 Binary files a/maclibs/lib/libavformat-gd.dylib and /dev/null differ diff --git a/maclibs/lib/libavutil-gd.dylib b/maclibs/lib/libavutil-gd.dylib deleted file mode 100644 index 0e859252..00000000 Binary files a/maclibs/lib/libavutil-gd.dylib and /dev/null differ diff --git a/maclibs/lib/libeb.dylib b/maclibs/lib/libeb.dylib deleted file mode 100644 index cc298323..00000000 Binary files a/maclibs/lib/libeb.dylib and /dev/null differ diff --git a/maclibs/lib/libhunspell-1.6.1.dylib b/maclibs/lib/libhunspell-1.6.1.dylib deleted file mode 100644 index baa1a4cb..00000000 Binary files a/maclibs/lib/libhunspell-1.6.1.dylib and /dev/null differ diff --git a/maclibs/lib/libiconv.dylib b/maclibs/lib/libiconv.dylib deleted file mode 100755 index 1c6c5461..00000000 Binary files a/maclibs/lib/libiconv.dylib and /dev/null differ diff --git a/maclibs/lib/liblzma.a b/maclibs/lib/liblzma.a deleted file mode 100644 index a589a0ae..00000000 Binary files a/maclibs/lib/liblzma.a and /dev/null differ diff --git a/maclibs/lib/liblzo2.dylib b/maclibs/lib/liblzo2.dylib deleted file mode 100644 index f6c6ebc1..00000000 Binary files a/maclibs/lib/liblzo2.dylib and /dev/null differ diff --git a/maclibs/lib/libogg.dylib b/maclibs/lib/libogg.dylib deleted file mode 100755 index e14cf265..00000000 Binary files a/maclibs/lib/libogg.dylib and /dev/null differ diff --git a/maclibs/lib/libopencc.2.dylib b/maclibs/lib/libopencc.2.dylib deleted file mode 100644 index 8cddb068..00000000 Binary files a/maclibs/lib/libopencc.2.dylib and /dev/null differ diff --git a/maclibs/lib/libswresample-gd.dylib b/maclibs/lib/libswresample-gd.dylib deleted file mode 100644 index 03be7232..00000000 Binary files a/maclibs/lib/libswresample-gd.dylib and /dev/null differ diff --git a/maclibs/lib/libtiff.dylib b/maclibs/lib/libtiff.dylib deleted file mode 100644 index a5358c1a..00000000 Binary files a/maclibs/lib/libtiff.dylib and /dev/null differ diff --git a/maclibs/lib/libvorbis.dylib b/maclibs/lib/libvorbis.dylib deleted file mode 100755 index bc03887c..00000000 Binary files a/maclibs/lib/libvorbis.dylib and /dev/null differ diff --git a/maclibs/lib/libvorbisfile.dylib b/maclibs/lib/libvorbisfile.dylib deleted file mode 100755 index c9a9ce61..00000000 Binary files a/maclibs/lib/libvorbisfile.dylib and /dev/null differ diff --git a/maclibs/lib/libzstd.a b/maclibs/lib/libzstd.a deleted file mode 100644 index 2202734c..00000000 Binary files a/maclibs/lib/libzstd.a and /dev/null differ diff --git a/maclibs/readme.txt b/maclibs/readme.txt deleted file mode 100644 index 74b5dec1..00000000 --- a/maclibs/readme.txt +++ /dev/null @@ -1,10 +0,0 @@ -This directory holds precompiled third-party libraries and their header files -used to build GoldenDict under Mac OS X. Those are supplied merely to ease -the build process. No other platform except Mac OS X uses those files, so they -can safely be removed for Linux builds etc. -Due credit goes to those created those libraries. The libraries are -copyrighted by their responsive copyright holders and distributed in -compliance to their respective licenses. No modifications were made except -those needed in order to build the libraries correctly. The source codes -aren't shipped here merely to shrink the size of the distribution, and can -be downloaded from the original libraries' websites separately. diff --git a/maclibs/scripts/libao-build.sh b/maclibs/scripts/libao-build.sh deleted file mode 100644 index 1bc7d618..00000000 --- a/maclibs/scripts/libao-build.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# $1 - GoldenDict source directory - -if [ ${OSTYPE:0:6} != "darwin" ]; then - echo "OSX Only" - exit 1 -fi - - -if [[ -n "$1" && ! -d "$1" ]]; then - echo "Invalid GoldenDict source directory" - exit 1 -fi - -./configure \ - CFLAGS="-arch i386 -arch x86_64 -DCUSTOM_AO_PLUGIN_PATH=\\\"@executable_path/../Frameworks/ao\\\"" \ - LDFLAGS="-arch i386 -arch x86_64" \ - --disable-dependency-tracking - -make clean && make - - -install_name_tool \ - -id @executable_path/../Frameworks/libao.dylib \ - src/.libs/libao.dylib - -for PLUGIN_DIR in `find src/plugins -type d -maxdepth 1`; do - PLUGIN_NAME=$(basename "$PLUGIN_DIR") - PLUGIN_PATH=$PLUGIN_DIR/.libs/lib$PLUGIN_NAME.so - if [ -f "$PLUGIN_PATH" ]; then - install_name_tool \ - -id @executable_path/../Frameworks/ao/$PLUGIN_NAME.so \ - $PLUGIN_PATH - fi -done - -if [ -n "$1" ]; then - cp src/.libs/libao.dylib $1/maclibs/lib - # Copy plugins - mkdir -p $1/maclibs/lib/ao - find src/plugins -type f -maxdepth 3 -name "*.so" -exec cp {} $1/maclibs/lib/ao \; -fi diff --git a/maclibs/scripts/libao.txt b/maclibs/scripts/libao.txt deleted file mode 100644 index e2fef536..00000000 --- a/maclibs/scripts/libao.txt +++ /dev/null @@ -1,9 +0,0 @@ -Patched libao source for OSX can be found here: -https://github.com/timonwong/libao/tree/goldendict - -You can checkout the source directly using git: - git clone -b goldendict https://github.com/timonwong/libao.git - -Then, copy libao-build.sh (along with this file) to libao source directory, and build using following commands: - chmod +x libao-build.sh - ./libao-build.sh [goldendict source directory] diff --git a/main.cc b/main.cc index 26440d6f..1adf5097 100644 --- a/main.cc +++ b/main.cc @@ -1,4 +1,4 @@ -/* This file is (c) 2008-2012 Konstantin Isakov +/* This file is (c) 2008-2012 Konstantin Isakov * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ #include @@ -90,6 +90,7 @@ void gdMessageHandler( QtMsgType type, const QMessageLogContext &context, const if( logFilePtr && logFilePtr->isOpen() ) { + message.insert( 0, QDateTime::currentDateTime().toString( "yyyy-MM-dd HH:mm:ss.zzz " ) ); message.append( "\n" ); logFilePtr->write( message.toUtf8() ); logFilePtr->flush(); @@ -328,23 +329,8 @@ int main( int argc, char ** argv ) #endif // Load translations for system locale - - QTranslator qtTranslator; - QString localeName = QLocale::system().name(); - if ( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) ) - qtTranslator.load( "qt_" + localeName, - QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ); - - app.installTranslator( &qtTranslator ); - - QTranslator translator; - - translator.load( Config::getLocDir() + "/" + localeName ); - - app.installTranslator( &translator ); - Config::Class cfg; for( ; ; ) { @@ -395,16 +381,28 @@ int main( int argc, char ** argv ) } // Reload translations for user selected locale is nesessary - + QTranslator qtTranslator; + QTranslator translator; if( !cfg.preferences.interfaceLanguage.isEmpty() && localeName != cfg.preferences.interfaceLanguage ) { localeName = cfg.preferences.interfaceLanguage; + } - if ( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) ) - qtTranslator.load( "qt_" + localeName, - QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ); + QLocale locale( localeName ); + QLocale::setDefault( locale ); + if( !qtTranslator.load( "qt_" + localeName, Config::getLocDir() ) ) + { + qtTranslator.load( "qt_" + localeName, QLibraryInfo::location( QLibraryInfo::TranslationsPath ) ); + app.installTranslator( &qtTranslator ); + } - translator.load( Config::getLocDir() + "/" + localeName ); + translator.load( Config::getEmbedLocDir() + "/" + localeName ); + app.installTranslator( &translator ); + + QTranslator webengineTs; + if( webengineTs.load( "qtwebengine_" + localeName, Config::getLocDir() ) ) + { + app.installTranslator( &webengineTs ); } // Prevent app from quitting spontaneously when it works with scan popup diff --git a/mainstatusbar.cc b/mainstatusbar.cc index fe41655b..47ea5f22 100644 --- a/mainstatusbar.cc +++ b/mainstatusbar.cc @@ -43,7 +43,7 @@ MainStatusBar::MainStatusBar( QWidget *parent ) : QWidget( parent ) bool MainStatusBar::hasImage() const { - return !picWidget->pixmap()->isNull(); + return !picWidget->pixmap().isNull(); } void MainStatusBar::clearMessage() @@ -92,7 +92,7 @@ void MainStatusBar::refresh() { adjustSize(); - if ( !picWidget->pixmap()->isNull() ) + if ( !picWidget->pixmap().isNull() ) { picWidget->setFixedSize( textWidget->height(), textWidget->height() ); } diff --git a/maintabwidget.cc b/maintabwidget.cc index fdf3ca15..0d15f9d1 100644 --- a/maintabwidget.cc +++ b/maintabwidget.cc @@ -67,7 +67,7 @@ bool MainTabWidget::eventFilter( QObject * obj, QEvent * ev ) if( obj == tabBar() && ev->type() == QEvent::MouseButtonPress ) { QMouseEvent * mev = static_cast< QMouseEvent *>( ev ); - if( mev->button() == Qt::MidButton ) + if( mev->button() == Qt::MiddleButton ) { emit tabCloseRequested( tabBar()->tabAt( mev->pos() ) ); return true; diff --git a/mainwindow.cc b/mainwindow.cc index e5208bf3..33b34b0b 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -46,7 +46,7 @@ #include "fsencoding.hh" #include "historypanewidget.hh" #include "utils.hh" -#include +#include #include "ui_authentication.h" #include "resourceschemehandler.h" @@ -59,14 +59,14 @@ #include #include "wstring.hh" #include "wstring_qt.hh" - -#define gdStoreNormalGeometryEvent ( ( QEvent::Type )( QEvent::User + 1 ) ) -#define gdApplyNormalGeometryEvent ( ( QEvent::Type )( QEvent::User + 2 ) ) - #endif #ifdef HAVE_X11 +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #include #endif @@ -156,7 +156,12 @@ MainWindow::MainWindow( Config::Class & cfg_ ): } wuri = new WebUrlRequestInterceptor(); - QWebEngineProfile::defaultProfile()->setUrlRequestInterceptor(wuri); + QWebEngineProfile::defaultProfile()->setUrlRequestInterceptor( wuri ); + connect( wuri, &WebUrlRequestInterceptor::linkClicked, this, &MainWindow::viewLinkClicked ); + + if(!cfg.preferences.hideGoldenDictHeader){ + QWebEngineProfile::defaultProfile()->setHttpUserAgent(QWebEngineProfile::defaultProfile()->httpUserAgent()+" GoldenDict/webengine"); + } qRegisterMetaType< Config::InputPhrase >(); @@ -169,8 +174,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ): articleMaker.setCollapseParameters( cfg.preferences.collapseBigArticles, cfg.preferences.articleSizeLimit ); // Set own gesture recognizers +#ifndef Q_OS_MAC Gestures::registerRecognizers(); - +#endif // use our own, custom statusbar setStatusBar(0); mainStatusBar = new MainStatusBar( this ); @@ -459,9 +465,9 @@ MainWindow::MainWindow( Config::Class & cfg_ ): switchExpandModeAction.setShortcutContext( Qt::WidgetWithChildrenShortcut ); switchExpandModeAction.setShortcuts( QList< QKeySequence >() << - QKeySequence( Qt::CTRL + Qt::Key_8 ) << - QKeySequence( Qt::CTRL + Qt::Key_Asterisk ) << - QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_8 ) ); + QKeySequence( Qt::CTRL | Qt::Key_8 ) << + QKeySequence( Qt::CTRL | Qt::Key_Asterisk ) << + QKeySequence( Qt::CTRL | Qt::SHIFT | Qt::Key_8 ) ); connect( &switchExpandModeAction, SIGNAL( triggered() ), this, SLOT(switchExpandOptionalPartsMode() ) ); @@ -676,11 +682,11 @@ MainWindow::MainWindow( Config::Class & cfg_ ): connect( ui.showReference, SIGNAL( triggered() ), this, SLOT( showGDHelp() ) ); - connect( groupListInDock, SIGNAL( currentIndexChanged( QString const & ) ), - this, SLOT( currentGroupChanged( QString const & ) ) ); + connect( groupListInDock, &GroupComboBox::currentIndexChanged, + this, &MainWindow::currentGroupChanged ); - connect( groupListInToolbar, SIGNAL( currentIndexChanged( QString const & ) ), - this, SLOT( currentGroupChanged( QString const & ) ) ); + connect( groupListInToolbar, &GroupComboBox::currentIndexChanged, + this, &MainWindow::currentGroupChanged ); connect( ui.translateLine, SIGNAL( textChanged( QString const & ) ), this, SLOT( translateInputChanged( QString const & ) ) ); @@ -741,7 +747,7 @@ MainWindow::MainWindow( Config::Class & cfg_ ): #ifdef Q_OS_WIN if( cfg.normalMainWindowGeometry.width() <= 0 ) { - QRect r = QApplication::desktop()->availableGeometry(); + QRect r = QGuiApplication::primaryScreen ()->geometry (); cfg.normalMainWindowGeometry.setRect( r.width() / 4, r.height() / 4, r.width() / 2, r.height() / 2 ); } if( cfg.maximizedMainWindowGeometry.width() > 0 ) @@ -767,7 +773,6 @@ MainWindow::MainWindow( Config::Class & cfg_ ): ui.searchPane->setVisible( cfg.preferences.searchInDock ); applyProxySettings(); - applyWebSettings(); connect( &dictNetMgr, SIGNAL( proxyAuthenticationRequired( QNetworkProxy, QAuthenticator * ) ), this, SLOT( proxyAuthentication( QNetworkProxy, QAuthenticator * ) ) ); @@ -975,7 +980,7 @@ void MainWindow::mousePressEvent( QMouseEvent *event) return; } - if (event->button() != Qt::MidButton) + if (event->button() != Qt::MiddleButton) return QMainWindow::mousePressEvent(event); // middle clicked @@ -1133,8 +1138,8 @@ void MainWindow::applyQtStyleSheet( QString const & displayStyle, QString const { // Load an additional stylesheet QFile builtInCssFile( QString( ":/qt-style-st-%1.css" ).arg( displayStyle ) ); - builtInCssFile.open( QFile::ReadOnly ); - css += builtInCssFile.readAll(); + if ( builtInCssFile.open( QFile::ReadOnly ) ) + css += builtInCssFile.readAll(); } // Try loading a style sheet if there's one @@ -1194,11 +1199,11 @@ void MainWindow::wheelEvent( QWheelEvent *ev ) { if ( ev->modifiers().testFlag( Qt::ControlModifier ) ) { - if ( ev->delta() > 0 ) + if ( ev->angleDelta().y() > 0 ) { zoomin(); } - else if ( ev->delta() < 0 ) + else if ( ev->angleDelta().y() < 0 ) { zoomout(); } @@ -1217,11 +1222,16 @@ void MainWindow::closeEvent( QCloseEvent * ev ) if( !cfg.preferences.searchInDock ) translateBox->setPopupEnabled( false ); +#ifdef Q_OS_MACOS + if (!ev->spontaneous() || !isVisible()) { + return; + } +#endif #ifdef HAVE_X11 // Don't ignore the close event, because doing so cancels session logout if // the main window is visible when the user attempts to log out. // The main window will be only hidden, because QApplication::quitOnLastWindowClosed - // property is false and Qt::WA_DeleteOnClose widget attribute is not set. + // property is false and Qt::WA_DeleteOnClose widget is not set. Q_ASSERT(!QApplication::quitOnLastWindowClosed()); Q_ASSERT(!testAttribute(Qt::WA_DeleteOnClose)); #else @@ -1295,16 +1305,6 @@ void MainWindow::applyProxySettings() QNetworkProxy::setApplicationProxy( proxy ); } -void MainWindow::applyWebSettings() -{ - QWebEngineSettings *defaultSettings = QWebEngineSettings::defaultSettings(); - defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins); - defaultSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false); - defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true ); - defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true ); - defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false); -} - void MainWindow::setupNetworkCache( int maxSize ) { // x << 20 == x * 2^20 converts mebibytes to bytes. @@ -1346,6 +1346,9 @@ void MainWindow::makeDictionaries() loadDictionaries( this, isVisible(), cfg, dictionaries, dictNetMgr, false ); + //create map + dictMap = Dictionary::dictToMap(dictionaries); + for( unsigned x = 0; x < dictionaries.size(); x++ ) { dictionaries[ x ]->setFTSParameters( cfg.preferences.fts ); @@ -1384,29 +1387,29 @@ void MainWindow::updateGroupList() // currentIndexChanged() signal is very trigger-happy. To avoid triggering // it, we disconnect it while we're clearing and filling back groups. - disconnect( groupList, SIGNAL( currentIndexChanged( QString const & ) ), - this, SLOT( currentGroupChanged( QString const & ) ) ); + disconnect( groupList, &GroupComboBox::currentIndexChanged, + this, &MainWindow::currentGroupChanged ); groupInstances.clear(); // Add dictionaryOrder first, as the 'All' group. { - Instances::Group g( cfg.dictionaryOrder, dictionaries, Config::Group() ); + Instances::Group g( cfg.dictionaryOrder, dictMap, Config::Group() ); // Add any missing entries to dictionary order Instances::complementDictionaryOrder( g, - Instances::Group( cfg.inactiveDictionaries, dictionaries, Config::Group() ), + Instances::Group( cfg.inactiveDictionaries, dictMap, Config::Group() ), dictionaries ); g.name = tr( "All" ); g.id = Instances::Group::AllGroupId; - g.icon = "folder.svg"; + g.icon = "folder.png"; groupInstances.push_back( g ); } for( int x = 0; x < cfg.groups.size(); ++x ) - groupInstances.push_back( Instances::Group( cfg.groups[ x ], dictionaries, cfg.inactiveDictionaries ) ); + groupInstances.push_back( Instances::Group( cfg.groups[ x ], dictMap, cfg.inactiveDictionaries ) ); // Update names for dictionaries that are present, so that they could be // found in case they got moved. @@ -1430,8 +1433,8 @@ void MainWindow::updateGroupList() view.reload(); } - connect( groupList, SIGNAL( currentIndexChanged( QString const & ) ), - this, SLOT( currentGroupChanged( QString const & ) ) ); + connect( groupList, &GroupComboBox::currentIndexChanged, + this, &MainWindow::currentGroupChanged ); } void MainWindow::updateDictionaryBar() @@ -1681,12 +1684,6 @@ ArticleView * MainWindow::createNewTab( bool switchToIt, connect( view, SIGNAL( zoomIn()), this, SLOT( zoomin() ) ); connect( view, SIGNAL( zoomOut()), this, SLOT( zoomout() ) ); - connect(wuri, &WebUrlRequestInterceptor::linkClicked, view, [=](QUrl url) { - ArticleView *active = getCurrentArticleView(); - if (active == view) { - view->linkClicked(url); - } - }); view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick ); @@ -2000,7 +1997,7 @@ void MainWindow::updateFoundInDictsList() QString dictId = QString::fromUtf8( dictionaries[ x ]->getId().c_str() ); QListWidgetItem * item = new QListWidgetItem( - dictionaries[ x ]->getIcon().pixmap(32).scaledToHeight( 21, Qt::SmoothTransformation ), + dictionaries[ x ]->getIcon(), dictName, ui.dictsList, QListWidgetItem::Type ); item->setData(Qt::UserRole, QVariant( dictId ) ); @@ -2037,10 +2034,14 @@ void MainWindow::updateBackForwardButtons() void MainWindow::updatePronounceAvailability() { - bool pronounceEnabled = ui.tabWidget->count() > 0 && - getCurrentArticleView()->hasSound(); - - navPronounce->setEnabled( pronounceEnabled ); + if (ui.tabWidget->count() > 0) { + getCurrentArticleView()->hasSound([this](bool has) { + navPronounce->setEnabled( has ); + }); + } + else { + navPronounce->setEnabled( false ); + } } void MainWindow::editDictionaries( unsigned editDictionaryGroup ) @@ -2050,9 +2051,6 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup ) closeHeadwordsDialog(); closeFullTextSearchDialog(); - ftsIndexing.stopIndexing(); - ftsIndexing.clearDictionaries(); - wordFinder.clear(); dictionariesUnmuted.clear(); @@ -2061,7 +2059,7 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup ) { // Limit existence of newCfg Config::Class newCfg = cfg; - EditDictionaries dicts( this, newCfg, dictionaries, groupInstances, dictNetMgr ); + EditDictionaries dicts( this, newCfg, dictionaries, dictMap, groupInstances, dictNetMgr ); connect( &dicts, SIGNAL( showDictionaryInfo( QString const & ) ), this, SLOT( showDictionaryInfo( QString const & ) ) ); @@ -2078,7 +2076,8 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup ) if ( dicts.areDictionariesChanged() || dicts.areGroupsChanged() ) { - + ftsIndexing.stopIndexing(); + ftsIndexing.clearDictionaries(); // Set muted dictionaries from old groups for( int x = 0; x < newCfg.groups.size(); x++ ) { @@ -2101,6 +2100,15 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup ) Config::save( cfg ); updateSuggestionList(); + + for( unsigned x = 0; x < dictionaries.size(); x++ ) + { + dictionaries[ x ]->setFTSParameters( cfg.preferences.fts ); + dictionaries[ x ]->setSynonymSearchEnabled( cfg.preferences.synonymSearchEnabled ); + } + + ftsIndexing.setDictionaries( dictionaries ); + ftsIndexing.doIndexing(); } } @@ -2108,14 +2116,7 @@ void MainWindow::editDictionaries( unsigned editDictionaryGroup ) makeScanPopup(); installHotKeys(); - for( unsigned x = 0; x < dictionaries.size(); x++ ) - { - dictionaries[ x ]->setFTSParameters( cfg.preferences.fts ); - dictionaries[ x ]->setSynonymSearchEnabled( cfg.preferences.synonymSearchEnabled ); - } - ftsIndexing.setDictionaries( dictionaries ); - ftsIndexing.doIndexing(); } void MainWindow::editCurrentGroup() @@ -2224,7 +2225,6 @@ void MainWindow::editPreferences() updateTrayIcon(); applyProxySettings(); - applyWebSettings(); ui.tabWidget->setHideSingleTab(cfg.preferences.hideSingleTab); @@ -2254,7 +2254,7 @@ void MainWindow::editPreferences() ftsIndexing.doIndexing(); } -void MainWindow::currentGroupChanged( QString const & ) +void MainWindow::currentGroupChanged( int ) { cfg.lastMainGroupId = groupList->getCurrentGroup(); Instances::Group const * igrp = groupInstances.findGroup( cfg.lastMainGroupId ); @@ -2469,25 +2469,6 @@ bool MainWindow::handleBackForwardMouseButtons ( QMouseEvent * event) { bool MainWindow::eventFilter( QObject * obj, QEvent * ev ) { -#ifdef Q_OS_WIN - if( obj == this && ev->type() == gdStoreNormalGeometryEvent ) - { - if( !isMaximized() && !isMinimized() && !isFullScreen() ) - cfg.normalMainWindowGeometry = normalGeometry(); - ev->accept(); - return true; - } - - if( obj == this && ev->type() == gdApplyNormalGeometryEvent ) - { - if( !isMaximized() && !isMinimized() && !isFullScreen() ) - { - setGeometry( cfg.normalMainWindowGeometry ); - } - ev->accept(); - return true; - } -#endif if ( ev->type() == QEvent::ShortcutOverride || ev->type() == QEvent::KeyPress ) { @@ -2522,13 +2503,6 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev ) // when the main window is moved or resized, hide the word list suggestions if ( obj == this && ( ev->type() == QEvent::Move || ev->type() == QEvent::Resize ) ) { -#ifdef Q_OS_WIN - if( !isMaximized() && !isMinimized() && !isFullScreen() && gdAskMessage != 0xFFFFFFFF ) - { - QEvent *ev = new QEvent( gdStoreNormalGeometryEvent ); - qApp->postEvent( this, ev ); - } -#endif if ( !cfg.preferences.searchInDock ) { translateBox->setPopupEnabled( false ); @@ -2540,14 +2514,6 @@ bool MainWindow::eventFilter( QObject * obj, QEvent * ev ) { QWindowStateChangeEvent *stev = static_cast< QWindowStateChangeEvent *>( ev ); wasMaximized = ( stev->oldState() == Qt::WindowMaximized && isMinimized() ); - -#ifdef Q_OS_WIN - if( stev->oldState() == Qt::WindowMaximized && !isMinimized() && cfg.normalMainWindowGeometry.width() > 0 ) - { - QEvent *ev = new QEvent( gdApplyNormalGeometryEvent ); - qApp->postEvent( this, ev ); - } -#endif } if ( ev->type() == QEvent::MouseButtonPress ) { @@ -2723,14 +2689,18 @@ void MainWindow::dictsListItemActivated( QListWidgetItem * item ) void MainWindow::dictsListSelectionChanged() { QList< QListWidgetItem * > selected = ui.dictsList->selectedItems(); - if ( selected.size() ) + if( selected.size() ) { - ArticleView * view = getCurrentArticleView(); - if(view){ - QString dictId = ui.dictsList->selectedItems().at(0)->data(Qt::UserRole).toString(); - view->setActiveArticleId(dictId); - } -// jumpToDictionary( selected.front() ); + ArticleView * view = getCurrentArticleView(); + if( view ) + { + QString dictId = ui.dictsList->selectedItems().at( 0 )->data( Qt::UserRole ).toString(); + view->setActiveArticleId( dictId ); + } + // selection change ,no need to jump to article ,if jump to article ,the position in webview would be changed + // when click the dictionary in the html. + + // jumpToDictionary( selected.front() ); } } @@ -2885,23 +2855,6 @@ void MainWindow::toggleMainWindow( bool onlyShow ) { show(); -#ifdef Q_OS_WIN32 - if( !!( hotkeyWrapper ) && hotkeyWrapper->handleViaDLL() ) - { - // Some dances with tambourine - HWND wId = (HWND) winId(); - DWORD pId = GetWindowThreadProcessId( wId, NULL ); - DWORD fpId = GetWindowThreadProcessId( GetForegroundWindow(), NULL ); - - //Attach Thread to get the Input - i am now allowed to set the Foreground window! - AttachThreadInput( fpId, pId, true ); - SetActiveWindow( wId ); - SetForegroundWindow( wId ); - SetFocus( wId ); - AttachThreadInput( fpId, pId, false ); - } -#endif - qApp->setActiveWindow( this ); activateWindow(); raise(); @@ -2922,22 +2875,6 @@ void MainWindow::toggleMainWindow( bool onlyShow ) if ( !isActiveWindow() ) { qApp->setActiveWindow( this ); -#ifdef Q_OS_WIN32 - if( !!( hotkeyWrapper ) && hotkeyWrapper->handleViaDLL() ) - { - // Some dances with tambourine - HWND wId = (HWND) winId(); - DWORD pId = GetWindowThreadProcessId( wId, NULL ); - DWORD fpId = GetWindowThreadProcessId( GetForegroundWindow(), NULL ); - - //Attach Thread to get the Input - i am now allowed to set the Foreground window! - AttachThreadInput( fpId, pId, true ); - SetActiveWindow( wId ); - SetForegroundWindow( wId ); - SetFocus( wId ); - AttachThreadInput( fpId, pId, false ); - } -#endif raise(); activateWindow(); shown = true; @@ -3037,11 +2974,7 @@ void MainWindow::installHotKeys() connect( hotkeyWrapper.get(), SIGNAL( hotkeyActivated( int ) ), this, SLOT( hotKeyActivated( int ) ), -#ifdef Q_OS_WIN32 - hotkeyWrapper->handleViaDLL() ? Qt::QueuedConnection : Qt::AutoConnection ); -#else Qt::AutoConnection ); -#endif } } @@ -3409,7 +3342,10 @@ void MainWindow::on_pageSetup_triggered() void MainWindow::on_printPreview_triggered() { QPrinter printer; - QPrintPreviewDialog dialog( &printer, this ); + QPrintPreviewDialog dialog( &printer, this ); + auto combox = dialog.findChild< QComboBox *>(); + int index=combox->findText( "100%" ); + combox->setCurrentIndex( index ); connect( &dialog, SIGNAL( paintRequested( QPrinter * ) ), this, SLOT( printPreviewPaintRequested( QPrinter * ) ) ); @@ -3474,23 +3410,23 @@ static void filterAndCollectResources( QString & html, QRegExp & rx, const QStri void MainWindow::on_saveArticle_triggered() { - ArticleView *view = getCurrentArticleView(); + ArticleView * view = getCurrentArticleView(); QString fileName = view->getTitle().simplified(); // Replace reserved filename characters - QRegExp rxName( "[/\\\\\\?\\*:\\|<>]" ); + QRegularExpression rxName( "[/\\\\\\?\\*:\\|<>]" ); fileName.replace( rxName, "_" ); fileName += ".html"; QString savePath; - if ( cfg.articleSavePath.isEmpty() ) + if( cfg.articleSavePath.isEmpty() ) savePath = QDir::homePath(); else { savePath = QDir::fromNativeSeparators( cfg.articleSavePath ); - if ( !QDir( savePath ).exists() ) + if( !QDir( savePath ).exists() ) savePath = QDir::homePath(); } @@ -3501,96 +3437,102 @@ void MainWindow::on_saveArticle_triggered() filters.push_back( tr( "Article, HTML Only (*.html)" ) ); fileName = savePath + "/" + fileName; - fileName = QFileDialog::getSaveFileName( this, tr( "Save Article As" ), + fileName = QFileDialog::getSaveFileName( this, + tr( "Save Article As" ), fileName, filters.join( ";;" ), - &selectedFilter, options ); + &selectedFilter, + options ); bool complete = ( selectedFilter == filters[ 0 ] ); - if ( !fileName.isEmpty() ) - { + if( fileName.isEmpty() ) + return; - QFile file( fileName ); - - if ( !file.open( QIODevice::WriteOnly ) ) + view->toHtml( + [ = ]( QString & html ) mutable { - QMessageBox::critical( this, tr( "Error" ), - tr( "Can't save article: %1" ).arg( file.errorString() ) ); - } - else - { - QString html = view->toHtml(); - QFileInfo fi( fileName ); - cfg.articleSavePath = QDir::toNativeSeparators( fi.absoluteDir().absolutePath() ); - - // Convert internal links - - QRegExp rx3( "href=\"(bword:|gdlookup://localhost/)([^\"]+)\"" ); - int pos = 0; - while ( ( pos = rx3.indexIn( html, pos ) ) != -1 ) + QFile file( fileName ); + if( !file.open( QIODevice::WriteOnly ) ) { - QString name = QUrl::fromPercentEncoding( rx3.cap( 2 ).simplified().toLatin1() ); - QString anchor; - name.replace( "?gdanchor=", "#" ); - int n = name.indexOf( '#' ); - if( n > 0 ) - { - anchor = name.mid( n ); - name.truncate( n ); - anchor.replace( QRegExp( "(g[0-9a-f]{32}_)[0-9a-f]+_" ), "\\1" ); // MDict anchors - } - name.replace( rxName, "_" ); - name = QString( "href=\"" ) + QUrl::toPercentEncoding( name ) + ".html" + anchor + "\""; - html.replace( pos, rx3.cap().length(), name ); - pos += name.length(); - } - - // MDict anchors - QRegExp anchorLinkRe( "(<\\s*a\\s+[^>]*\\b(?:name|id)\\b\\s*=\\s*[\"']*g[0-9a-f]{32}_)([0-9a-f]+_)(?=[^\"'])", Qt::CaseInsensitive ); - html.replace( anchorLinkRe, "\\1" ); - - if ( complete ) - { - QString folder = fi.absoluteDir().absolutePath() + "/" + fi.baseName() + "_files"; - QRegExp rx1( "\"((?:bres|gico|gdau|qrcx|gdvideo)://[^\"]+)\"" ); - QRegExp rx2( "'((?:bres|gico|gdau|qrcx|gdvideo)://[^']+)'" ); - set< QByteArray > resourceIncluded; - vector< pair< QUrl, QString > > downloadResources; - - filterAndCollectResources( html, rx1, "\"", folder, resourceIncluded, downloadResources ); - filterAndCollectResources( html, rx2, "'", folder, resourceIncluded, downloadResources ); - - ArticleSaveProgressDialog * progressDialog = new ArticleSaveProgressDialog( this ); - // reserve '1' for saving main html file - int maxVal = 1; - - // Pull and save resources to files - for ( vector< pair< QUrl, QString > >::const_iterator i = downloadResources.begin(); - i != downloadResources.end(); i++ ) - { - ResourceToSaveHandler * handler = view->saveResource( i->first, i->second ); - if( !handler->isEmpty() ) - { - maxVal += 1; - connect( handler, SIGNAL( done() ), progressDialog, SLOT( perform() ) ); - } - } - - progressDialog->setLabelText( tr("Saving article...") ); - progressDialog->setRange( 0, maxVal ); - progressDialog->setValue( 0 ); - progressDialog->show(); - - file.write( html.toUtf8() ); - progressDialog->setValue( 1 ); + QMessageBox::critical( this, tr( "Error" ), tr( "Can't save article: %1" ).arg( file.errorString() ) ); } else { - file.write( html.toUtf8() ); + QFileInfo fi( fileName ); + cfg.articleSavePath = QDir::toNativeSeparators( fi.absoluteDir().absolutePath() ); + + // Convert internal links + + QRegExp rx3( "href=\"(bword:|gdlookup://localhost/)([^\"]+)\"" ); + int pos = 0; + QRegularExpression anchorRx( "(g[0-9a-f]{32}_)[0-9a-f]+_" ); + while( ( pos = rx3.indexIn( html, pos ) ) != -1 ) + { + QString name = QUrl::fromPercentEncoding( rx3.cap( 2 ).simplified().toLatin1() ); + QString anchor; + name.replace( "?gdanchor=", "#" ); + int n = name.indexOf( '#' ); + if( n > 0 ) + { + anchor = name.mid( n ); + name.truncate( n ); + anchor.replace( anchorRx, "\\1" ); // MDict anchors + } + name.replace( rxName, "_" ); + name = QString( "href=\"" ) + QUrl::toPercentEncoding( name ) + ".html" + anchor + "\""; + html.replace( pos, rx3.cap().length(), name ); + pos += name.length(); + } + + // MDict anchors + QRegularExpression anchorLinkRe( + "(<\\s*a\\s+[^>]*\\b(?:name|id)\\b\\s*=\\s*[\"']*g[0-9a-f]{32}_)([0-9a-f]+_)(?=[^\"'])", + QRegularExpression::PatternOption::CaseInsensitiveOption ); + html.replace( anchorLinkRe, "\\1" ); + + if( complete ) + { + QString folder = fi.absoluteDir().absolutePath() + "/" + fi.baseName() + "_files"; + QRegExp rx1( "\"((?:bres|gico|gdau|qrcx|gdvideo)://[^\"]+)\"" ); + QRegExp rx2( "'((?:bres|gico|gdau|qrcx|gdvideo)://[^']+)'" ); + set< QByteArray > resourceIncluded; + vector< pair< QUrl, QString > > downloadResources; + + filterAndCollectResources( html, rx1, "\"", folder, resourceIncluded, downloadResources ); + filterAndCollectResources( html, rx2, "'", folder, resourceIncluded, downloadResources ); + + ArticleSaveProgressDialog * progressDialog = new ArticleSaveProgressDialog( this ); + // reserve '1' for saving main html file + int maxVal = 1; + + // Pull and save resources to files + for( vector< pair< QUrl, QString > >::const_iterator i = downloadResources.begin(); + i != downloadResources.end(); + ++i ) + { + ResourceToSaveHandler * handler = view->saveResource( i->first, i->second ); + if( !handler->isEmpty() ) + { + maxVal += 1; + connect( handler, SIGNAL( done() ), progressDialog, SLOT( perform() ) ); + } + } + + progressDialog->setLabelText( tr( "Saving article..." ) ); + progressDialog->setRange( 0, maxVal ); + progressDialog->setValue( 0 ); + progressDialog->show(); + + file.write( html.toUtf8() ); + progressDialog->perform(); + } + else + { + file.write( html.toUtf8() ); + } } - } - } + } ); } void MainWindow::on_rescanFiles_triggered() @@ -3609,6 +3551,7 @@ void MainWindow::on_rescanFiles_triggered() dictionaryBar.setDictionaries( dictionaries ); loadDictionaries( this, true, cfg, dictionaries, dictNetMgr ); + dictMap = Dictionary::dictToMap(dictionaries); for( unsigned x = 0; x < dictionaries.size(); x++ ) { @@ -3674,6 +3617,21 @@ void MainWindow::unzoom() applyZoomFactor(); } +void MainWindow::viewLinkClicked( const QUrl & url ) +{ + if( scanPopup.get() && scanPopup->isActiveWindow() ) + { + QString word = Utils::Url::getWordFromUrl( url ); + if( !word.isEmpty() ) + { + scanPopup->translateWord( word ); + return; + } + } + ArticleView * view = getCurrentArticleView(); + view->linkClicked( url ); +} + void MainWindow::applyZoomFactor() { // Always call this function synchronously to potentially disable a zoom action, @@ -3701,7 +3659,7 @@ void MainWindow::adjustCurrentZoomFactor() zoomIn->setEnabled( cfg.preferences.zoomFactor < 5 ); zoomOut->setEnabled( cfg.preferences.zoomFactor > 0.1 ); - zoomBase->setEnabled( cfg.preferences.zoomFactor != 1.0 ); + zoomBase->setEnabled( !qFuzzyCompare( cfg.preferences.zoomFactor, 1.0 ) ); } void MainWindow::scaleArticlesByCurrentZoomFactor() @@ -3790,8 +3748,8 @@ void MainWindow::applyWordsZoomLevel() if ( groupList->font().pointSize() != ps ) { - disconnect( groupList, SIGNAL( currentIndexChanged( QString const & ) ), - this, SLOT( currentGroupChanged( QString const & ) ) ); + disconnect( groupList, &GroupComboBox::currentIndexChanged, + this, &MainWindow::currentGroupChanged ); int n = groupList->currentIndex(); groupList->clear(); groupList->setFont( font ); @@ -4363,12 +4321,11 @@ void MainWindow::editDictionary( Dictionary::Class * dict ) QString headword = unescapeTabHeader( ui.tabWidget->tabText( ui.tabWidget->currentIndex() ) ); command.replace( "%GDWORD%", headword ); } - if( !QProcess::startDetached( command ) ) + if( !QProcess::startDetached( command,QStringList() ) ) QApplication::beep(); } } - void MainWindow::openDictionaryFolder( const QString & id ) { for( unsigned x = 0; x < dictionaries.size(); x++ ) @@ -4378,46 +4335,10 @@ void MainWindow::openDictionaryFolder( const QString & id ) if( dictionaries[ x ]->getDictionaryFilenames().size() > 0 ) { QString fileName = FsEncoding::decode( dictionaries[ x ]->getDictionaryFilenames()[ 0 ].c_str() ); - bool explorerLaunched = false; - // Platform-dependent way to launch a file explorer and to select a file, - // currently only on Windows. -#if defined(Q_OS_WIN) - if ( !QFileInfo( fileName ).isDir() ) - { - QString param = QLatin1String("explorer.exe ") - + QLatin1String("/select, \"") + QDir::toNativeSeparators( fileName ) + QLatin1String("\""); - - qDebug() << "Launching" << param; - - // We use CreateProcess() directly instead of QProcess::startDetached() since - // startDetached() does some evil things with quotes breaking explorer arguments. - // E.g., the following file cannot be properly selected via startDetached(), due to equals sign, - // which explorer considers as separator: - // Z:\GoldenDict\content\-=MDict=-\Test.mdx - PROCESS_INFORMATION pinfo; - STARTUPINFOW startupInfo = { sizeof( STARTUPINFO ), 0, 0, 0, - (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, - (ulong)CW_USEDEFAULT, (ulong)CW_USEDEFAULT, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - explorerLaunched = CreateProcess(0, (wchar_t*) param.utf16(), - 0, 0, FALSE, CREATE_UNICODE_ENVIRONMENT | CREATE_NEW_CONSOLE, 0, - 0, &startupInfo, &pinfo); - - if ( explorerLaunched ) { - CloseHandle( pinfo.hThread ); - CloseHandle( pinfo.hProcess ); - } - } -#endif - - if ( !explorerLaunched ) - { - QString folder = QFileInfo( fileName ).absoluteDir().absolutePath(); - if( !folder.isEmpty() ) - QDesktopServices::openUrl( QUrl::fromLocalFile( folder ) ); - } + QString folder = QFileInfo( fileName ).absoluteDir().absolutePath(); + if( !folder.isEmpty() ) + QDesktopServices::openUrl( QUrl::fromLocalFile( folder ) ); } break; } @@ -4813,23 +4734,6 @@ void MainWindow::headwordFromFavorites( QString const & headword, #ifdef Q_OS_WIN32 -bool MainWindow::handleGDMessage( MSG * message, long * result ) -{ - if( message->message != gdAskMessage ) - return false; - *result = 0; - - if( !isGoldenDictWindow( message->hwnd ) ) - return true; - - ArticleView * view = getCurrentArticleView(); - if( !view ) - return true; - - *result = 1; - return true; -} - bool MainWindow::isGoldenDictWindow( HWND hwnd ) { return hwnd == (HWND)winId() || hwnd == (HWND)ui.centralWidget->winId(); diff --git a/mainwindow.hh b/mainwindow.hh index c61f3c83..2c7c075b 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -151,6 +151,7 @@ private: History history; DictionaryBar dictionaryBar; vector< sptr< Dictionary::Class > > dictionaries; + QMap > dictMap; /// Here we store unmuted dictionaries when the dictionary bar is active vector< sptr< Dictionary::Class > > dictionariesUnmuted; Instances::Groups groupInstances; @@ -209,7 +210,6 @@ private: void closeEvent( QCloseEvent * ); void applyProxySettings(); - void applyWebSettings(); void setupNetworkCache( int maxSize ); void makeDictionaries(); void updateStatusLine(); @@ -360,6 +360,8 @@ private slots: void zoomout(); void unzoom(); + void viewLinkClicked( const QUrl & url ); + void scaleArticlesByCurrentZoomFactor(); void doWordsZoomIn(); @@ -375,7 +377,7 @@ private slots: void editCurrentGroup(); void editPreferences(); - void currentGroupChanged( QString const & ); + void currentGroupChanged( int ); void translateInputChanged( QString const & ); void translateInputFinished( bool checkModifiers = true ); @@ -511,7 +513,6 @@ signals: protected: unsigned gdAskMessage; public: - bool handleGDMessage( MSG * message, long * result ); private slots: /// Return true while scanning GoldenDict window @@ -524,7 +525,7 @@ class ArticleSaveProgressDialog : public QProgressDialog Q_OBJECT public: - explicit ArticleSaveProgressDialog( QWidget * parent = 0, Qt::WindowFlags f = 0 ): + explicit ArticleSaveProgressDialog( QWidget * parent = 0, Qt::WindowFlags f = Qt::Widget ): QProgressDialog( parent, f ) { setAutoReset( false ); diff --git a/mdictparser.cc b/mdictparser.cc index ca044e70..dee23a45 100644 --- a/mdictparser.cc +++ b/mdictparser.cc @@ -22,7 +22,6 @@ #include #include -#include #include #include @@ -33,8 +32,11 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include - +#endif #include "decompress.hh" #include "gddebug.hh" #include "ripemd.hh" @@ -165,7 +167,7 @@ bool MdictParser::readNextHeadWordIndex( MdictParser::HeadWordIndex & headWordIn return false; headWordIndex = splitHeadWordBlock( decompressed ); - headWordBlockInfosIter_++; + ++headWordBlockInfosIter_; return true; } @@ -357,7 +359,7 @@ bool MdictParser::readHeader( QDataStream & in ) if ( headerAttributes.contains( "StyleSheet" ) ) { QString styleSheets = headerAttributes.namedItem( "StyleSheet" ).toAttr().value(); - QStringList lines = styleSheets.split( QRegularExpression( "[\r\n]" ), QString::KeepEmptyParts ); + QStringList lines = styleSheets.split( QRegularExpression( "[\r\n]" ), Qt::KeepEmptyParts ); for ( int i = 0; i < lines.size() - 3; i += 3 ) { @@ -624,7 +626,7 @@ QString & MdictParser::substituteStylesheet( QString & article, MdictParser::Sty { QRegularExpressionMatch match = it.next(); int styleId = match.captured( 1 ).toInt(); - articleNewText += article.midRef( pos, match.capturedStart() - pos ); + articleNewText += article.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); StyleSheets::const_iterator iter = styleSheets.find( styleId ); @@ -645,7 +647,7 @@ QString & MdictParser::substituteStylesheet( QString & article, MdictParser::Sty } if( pos ) { - articleNewText += article.midRef( pos ); + articleNewText += article.mid( pos ); article = articleNewText; articleNewText.clear(); } diff --git a/mdx.cc b/mdx.cc index 8c8c1316..fc2941e7 100644 --- a/mdx.cc +++ b/mdx.cc @@ -191,6 +191,49 @@ public: }; +struct MdxRegex +{ + MdxRegex() : + allLinksRe( "(?:<\\s*(a(?:rea)?|img|link|script|source)(?:\\s+[^>]+|\\s*)>)", + QRegularExpression::CaseInsensitiveOption ), + wordCrossLink( "([\\s\"']href\\s*=)\\s*([\"'])entry://([^>#]*?)((?:#[^>]*?)?)\\2", + QRegularExpression::CaseInsensitiveOption ), + anchorIdRe( "([\\s\"'](?:name|id)\\s*=)\\s*([\"'])\\s*(?=\\S)", QRegularExpression::CaseInsensitiveOption ), + anchorIdRe2( "([\\s\"'](?:name|id)\\s*=)\\s*(?=[^\"'])([^\\s\">]+)", QRegularExpression::CaseInsensitiveOption ), + anchorLinkRe( "([\\s\"']href\\s*=\\s*[\"'])entry://#", QRegularExpression::CaseInsensitiveOption ), + audioRe( "([\\s\"']href\\s*=)\\s*([\"'])sound://([^\">]+)\\2", + QRegularExpression::CaseInsensitiveOption | QRegularExpression::InvertedGreedinessOption ), + stylesRe( "([\\s\"']href\\s*=)\\s*([\"'])(?!\\s*\\b(?:(?:bres|https?|ftp)://" + "|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\">]+)\\2", + QRegularExpression::CaseInsensitiveOption ), + stylesRe2( "([\\s\"']href\\s*=)\\s*(?![\\s\"']|\\b(?:(?:bres|https?|ftp)://" + "|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\\s\">]+)", + QRegularExpression::CaseInsensitiveOption ), + inlineScriptRe( "<\\s*script(?:(?=\\s)(?:(?![\\s\"']src\\s*=)[^>])+|\\s*)>", + QRegularExpression::CaseInsensitiveOption ), + closeScriptTagRe( "<\\s*/script\\s*>", QRegularExpression::CaseInsensitiveOption ), + srcRe( "([\\s\"']src\\s*=)\\s*([\"'])(?!\\s*\\b(?:(?:bres|https?|ftp)://" + "|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\">]+)\\2", + QRegularExpression::CaseInsensitiveOption ), + srcRe2( "([\\s\"']src\\s*=)\\s*(?![\\s\"']|\\b(?:(?:bres|https?|ftp)://" + "|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\\s\">]+)", + QRegularExpression::CaseInsensitiveOption ) + { + } + QRegularExpression allLinksRe; + QRegularExpression wordCrossLink; + QRegularExpression anchorIdRe; + QRegularExpression anchorIdRe2; + QRegularExpression anchorLinkRe; + QRegularExpression audioRe; + QRegularExpression stylesRe; + QRegularExpression stylesRe2; + QRegularExpression inlineScriptRe; + QRegularExpression closeScriptTagRe; + QRegularExpression srcRe; + QRegularExpression srcRe2; +}; + class MdxDictionary: public BtreeIndexing::BtreeDictionary { Mutex idxMutex; @@ -211,6 +254,8 @@ class MdxDictionary: public BtreeIndexing::BtreeDictionary string initError; QString cacheDirName; + static MdxRegex mdxRx; + public: MdxDictionary( string const & id, string const & indexFile, vector const & dictionaryFiles ); @@ -252,8 +297,8 @@ public: virtual sptr< Dictionary::DataRequest > getArticle( wstring const & word, vector< wstring > const & alts, wstring const &, - bool ignoreDiacritics ) THROW_SPEC( std::exception ); - virtual sptr< Dictionary::DataRequest > getResource( string const & name ) THROW_SPEC( std::exception ); + bool ignoreDiacritics ) ; + virtual sptr< Dictionary::DataRequest > getResource( string const & name ) ; virtual QString const & getDescription(); virtual sptr< Dictionary::DataRequest > getSearchResults( QString const & searchString, @@ -268,8 +313,8 @@ public: virtual void setFTSParameters( Config::FullTextSearch const & fts ) { - if( ensureInitDone().size() ) - return; +// if( ensureInitDone().size() ) +// return; can_FTS = fts.enabled && !fts.disabledTypes.contains( "MDICT", Qt::CaseInsensitive ) @@ -301,6 +346,8 @@ private: friend class MdxDeferredInitRunnable; }; +MdxRegex MdxDictionary::mdxRx; + MdxDictionary::MdxDictionary( string const & id, string const & indexFile, vector const & dictionaryFiles ): BtreeDictionary( id, dictionaryFiles ), @@ -725,7 +772,7 @@ void MdxArticleRequest::run() } sptr MdxDictionary::getArticle( const wstring & word, const vector & alts, - const wstring &, bool ignoreDiacritics ) THROW_SPEC( std::exception ) + const wstring &, bool ignoreDiacritics ) { return new MdxArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -848,7 +895,7 @@ void MddResourceRequest::run() catch ( File::exCantOpen & ) { for ( vector< sptr< IndexedMdd > >::const_iterator i = dict.mddResources.begin(); - i != dict.mddResources.end(); i++ ) + i != dict.mddResources.end(); ++i ) { sptr< IndexedMdd > mddResource = *i; if ( mddResource->loadFile( resourceName, data ) ) @@ -896,7 +943,7 @@ void MddResourceRequest::run() while ( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - newCSS += css.midRef( pos, match.capturedStart() - pos ); + newCSS += css.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString url = match.captured( 2 ); @@ -915,7 +962,7 @@ void MddResourceRequest::run() } if( pos ) { - newCSS += css.midRef( pos ); + newCSS += css.mid( pos ); css = newCSS; newCSS.clear(); } @@ -931,7 +978,7 @@ void MddResourceRequest::run() finish(); } -sptr MdxDictionary::getResource( const string & name ) THROW_SPEC( std::exception ) +sptr MdxDictionary::getResource( const string & name ) { return new MddResourceRequest( *this, name ); } @@ -1009,24 +1056,6 @@ void MdxDictionary::loadArticle( uint32_t offset, string & articleText, bool noF if( !noFilter ) article = filterResource( articleId, article ); - // Check for unclosed and
- - int openTags = article.count( QRegExp( "<\\s*span\\b", Qt::CaseInsensitive ) ); - int closedTags = article.count( QRegExp( "<\\s*/span\\s*>", Qt::CaseInsensitive ) ); - while( openTags > closedTags ) - { - article += ""; - closedTags += 1; - } - - openTags = article.count( QRegExp( "<\\s*div\\b", Qt::CaseInsensitive ) ); - closedTags = article.count( QRegExp( "<\\s*/div\\s*>", Qt::CaseInsensitive ) ); - while( openTags > closedTags ) - { - article += "
"; - closedTags += 1; - } - articleText = string( article.toUtf8().constData() ); } @@ -1035,35 +1064,11 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar QString id = QString::fromStdString( getId() ); QString uniquePrefix = QString::fromLatin1( "g" ) + id + "_" + articleId + "_"; - QRegularExpression allLinksRe( "(?:<\\s*(a(?:rea)?|img|link|script|source)(?:\\s+[^>]+|\\s*)>)", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression wordCrossLink( "([\\s\"']href\\s*=)\\s*([\"'])entry://([^>#]*?)((?:#[^>]*?)?)\\2", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression anchorIdRe( "([\\s\"'](?:name|id)\\s*=)\\s*([\"'])\\s*(?=\\S)", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression anchorIdRe2( "([\\s\"'](?:name|id)\\s*=)\\s*(?=[^\"'])([^\\s\">]+)", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression anchorLinkRe( "([\\s\"']href\\s*=\\s*[\"'])entry://#", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression audioRe( "([\\s\"']href\\s*=)\\s*([\"'])sound://([^\">]+)\\2", - QRegularExpression::CaseInsensitiveOption - | QRegularExpression::InvertedGreedinessOption ); - QRegularExpression stylesRe( "([\\s\"']href\\s*=)\\s*([\"'])(?!\\s*\\b(?:(?:bres|https?|ftp)://|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\">]+)\\2", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression stylesRe2( "([\\s\"']href\\s*=)\\s*(?![\\s\"']|\\b(?:(?:bres|https?|ftp)://|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\\s\">]+)", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression inlineScriptRe( "<\\s*script(?:(?=\\s)(?:(?![\\s\"']src\\s*=)[^>])+|\\s*)>", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression closeScriptTagRe( "<\\s*/script\\s*>", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression srcRe( "([\\s\"']src\\s*=)\\s*([\"'])(?!\\s*\\b(?:(?:bres|https?|ftp)://|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\">]+)\\2", - QRegularExpression::CaseInsensitiveOption ); - QRegularExpression srcRe2( "([\\s\"']src\\s*=)\\s*(?![\\s\"']|\\b(?:(?:bres|https?|ftp)://|(?:data|javascript):))(?:file://)?[\\x00-\\x1f\\x7f]*\\.*/?([^\\s\">]+)", - QRegularExpression::CaseInsensitiveOption ); + QString articleNewText; int linkPos = 0; - QRegularExpressionMatchIterator it = allLinksRe.globalMatch( article ); + QRegularExpressionMatchIterator it = mdxRx.allLinksRe.globalMatch( article ); while( it.hasNext() ) { QRegularExpressionMatch allLinksMatch = it.next(); @@ -1071,7 +1076,7 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar if( allLinksMatch.capturedEnd() < linkPos ) continue; - articleNewText += article.midRef( linkPos, allLinksMatch.capturedStart() - linkPos ); + articleNewText += article.mid( linkPos, allLinksMatch.capturedStart() - linkPos ); linkPos = allLinksMatch.capturedEnd(); QString linkTxt = allLinksMatch.captured(); @@ -1080,18 +1085,18 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar if( !linkType.isEmpty() && linkType.at( 0 ) == 'a' ) { - QRegularExpressionMatch match = anchorIdRe.match( linkTxt ); + QRegularExpressionMatch match = mdxRx.anchorIdRe.match( linkTxt ); if( match.hasMatch() ) { QString newText = match.captured( 1 ) + match.captured( 2 ) + uniquePrefix; newLink = linkTxt.replace( match.capturedStart(), match.capturedLength(), newText ); } else - newLink = linkTxt.replace( anchorIdRe2, "\\1\"" + uniquePrefix + "\\2\"" ); + newLink = linkTxt.replace( mdxRx.anchorIdRe2, "\\1\"" + uniquePrefix + "\\2\"" ); - newLink = newLink.replace( anchorLinkRe, "\\1#" + uniquePrefix ); + newLink = newLink.replace( mdxRx.anchorLinkRe, "\\1#" + uniquePrefix ); - match = audioRe.match( newLink ); + match = mdxRx.audioRe.match( newLink ); if( match.hasMatch() ) { // sounds and audio link script @@ -1102,7 +1107,7 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar + newLink.replace( match.capturedStart(), match.capturedLength(), newTxt ); } - match = wordCrossLink.match( newLink ); + match = mdxRx.wordCrossLink.match( newLink ); if( match.hasMatch() ) { QString newTxt = match.captured( 1 ) + match.captured( 2 ) @@ -1120,7 +1125,7 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar if( linkType.compare( "link" ) == 0 ) { // stylesheets - QRegularExpressionMatch match = stylesRe.match( linkTxt ); + QRegularExpressionMatch match = mdxRx.stylesRe.match( linkTxt ); if( match.hasMatch() ) { QString newText = match.captured( 1 ) + match.captured( 2 ) @@ -1129,7 +1134,7 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar newLink = linkTxt.replace( match.capturedStart(), match.capturedLength(), newText ); } else - newLink = linkTxt.replace( stylesRe2, + newLink = linkTxt.replace( mdxRx.stylesRe2, "\\1\"bres://" + id + "/\\2\"" ); } else @@ -1137,23 +1142,23 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar || linkType.compare( "source" ) == 0 ) { // javascripts and images - QRegularExpressionMatch match = inlineScriptRe.match( linkTxt ); + QRegularExpressionMatch match = mdxRx.inlineScriptRe.match( linkTxt ); if( linkType.at( 1 ) == 'c' // "script" tag && match.hasMatch() && match.capturedLength() == linkTxt.length() ) { // skip inline scripts articleNewText += linkTxt; - match = closeScriptTagRe.match( article, linkPos ); + match = mdxRx.closeScriptTagRe.match( article, linkPos ); if( match.hasMatch() ) { - articleNewText += article.midRef( linkPos, match.capturedEnd() - linkPos ); + articleNewText += article.mid( linkPos, match.capturedEnd() - linkPos ); linkPos = match.capturedEnd(); } continue; } else { - match = srcRe.match( linkTxt ); + match = mdxRx.srcRe.match( linkTxt ); if( match.hasMatch() ) { QString newText; @@ -1174,7 +1179,7 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar newLink = linkTxt.replace( match.capturedStart(), match.capturedLength(), newText ); } else - newLink = linkTxt.replace( srcRe2, + newLink = linkTxt.replace( mdxRx.srcRe2, "\\1\"bres://" + id + "/\\2\"" ); } } @@ -1187,7 +1192,7 @@ QString & MdxDictionary::filterResource( QString const & articleId, QString & ar } if( linkPos ) { - articleNewText += article.midRef( linkPos ); + articleNewText += article.mid( linkPos ); article = articleNewText; } @@ -1272,7 +1277,7 @@ QString MdxDictionary::getCachedFileName( QString filename ) catch ( File::exCantOpen & ) { for ( vector< sptr< IndexedMdd > >::const_iterator i = mddResources.begin(); - i != mddResources.end(); i++ ) + i != mddResources.end(); ++i ) { sptr< IndexedMdd > mddResource = *i; if ( mddResource->loadFile( resourceName, data ) ) @@ -1441,18 +1446,21 @@ static void findResourceFiles( string const & mdx, vector< string > & dictFiles } } -vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, +vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > & fileNames, string const & indicesDir, - Dictionary::Initializing & initializing ) THROW_SPEC( std::exception ) + Dictionary::Initializing & initializing ) { vector< sptr< Dictionary::Class > > dictionaries; - for ( vector< string >::const_iterator i = fileNames.begin(); i != fileNames.end(); i++ ) + for ( vector< string >::iterator i = fileNames.begin(); i != fileNames.end(); ) { // Skip files with the extensions different to .mdx to speed up the // scanning if ( i->size() < 4 || strcasecmp( i->c_str() + ( i->size() - 4 ), ".mdx" ) != 0 ) + { + i++; continue; + } vector< string > dictFiles( 1, *i ); findResourceFiles( *i, dictFiles ); @@ -1477,7 +1485,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f initializing.indexingDictionary( title ); for ( vector< string >::const_iterator mddIter = dictFiles.begin() + 1; - mddIter != dictFiles.end(); mddIter++ ) + mddIter != dictFiles.end(); ++mddIter ) { if ( File::exists( *mddIter ) ) { @@ -1576,7 +1584,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f idxHeader.styleSheetCount = styleSheets.size(); for ( MdictParser::StyleSheets::const_iterator iter = styleSheets.begin(); - iter != styleSheets.end(); iter++ ) + iter != styleSheets.end(); ++iter ) { string styleBegin( iter->second.first.toUtf8().constData() ); string styleEnd( iter->second.second.toUtf8().constData() ); @@ -1607,7 +1615,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f // Build index info for each mdd file vector< IndexInfo > mddIndexInfos; for ( vector< sptr< IndexedWords > >::const_iterator mddIndexIter = mddIndices.begin(); - mddIndexIter != mddIndices.end(); mddIndexIter++ ) + mddIndexIter != mddIndices.end(); ++mddIndexIter ) { IndexInfo resourceIdxInfo = BtreeIndexing::buildIndex( *( *mddIndexIter ), idx ); mddIndexInfos.push_back( resourceIdxInfo ); @@ -1639,6 +1647,8 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & f } dictionaries.push_back( new MdxDictionary( dictId, indexFile, dictFiles ) ); + + i=fileNames.erase(i); } return dictionaries; diff --git a/mdx.hh b/mdx.hh index 2b304390..4b2895cf 100644 --- a/mdx.hh +++ b/mdx.hh @@ -12,9 +12,9 @@ namespace Mdx using std::vector; using std::string; -vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, +vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > & fileNames, string const & indicesDir, - Dictionary::Initializing & ) THROW_SPEC( std::exception ); + Dictionary::Initializing & ) ; } diff --git a/mediawiki.cc b/mediawiki.cc index 8f747613..e6b3b57b 100644 --- a/mediawiki.cc +++ b/mediawiki.cc @@ -60,11 +60,10 @@ public: { return 0; } virtual sptr< WordSearchRequest > prefixMatch( wstring const &, - unsigned long maxResults ) THROW_SPEC( std::exception ); + unsigned long maxResults ) ; virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts, - wstring const &, bool ) - THROW_SPEC( std::exception ); + wstring const &, bool ); virtual quint32 getLangFrom() const { return langId; } @@ -90,16 +89,18 @@ void MediaWikiDictionary::loadIcon() throw() loadIconFromFile( fInfo.absoluteFilePath(), true ); } if( dictionaryIcon.isNull() ) - dictionaryIcon = dictionaryNativeIcon = QIcon(":/icons/icon32_wiki.png"); + { + if( url.contains( "tionary" ) ) + dictionaryIcon = dictionaryNativeIcon = QIcon( ":/icons/wiktionary.png" ); + else + dictionaryIcon = dictionaryNativeIcon = QIcon( ":/icons/icon32_wiki.png" ); + } dictionaryIconLoaded = true; } class MediaWikiWordSearchRequest: public MediaWikiWordSearchRequestSlots { sptr< QNetworkReply > netReply; - bool livedLongEnough; // Indicates that the request has lived long enough - // to be destroyed prematurely. Used to prevent excessive - // network loads when typing search terms rapidly. bool isCancelling; public: @@ -111,10 +112,6 @@ public: virtual void cancel(); -protected: - - virtual void timerEvent( QTimerEvent * ); - private: virtual void downloadFinished(); @@ -122,8 +119,8 @@ private: MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str, QString const & url, - QNetworkAccessManager & mgr ): - livedLongEnough( false ), isCancelling( false ) + QNetworkAccessManager & mgr ) : + isCancelling( false ) { GD_DPRINTF( "request begin\n" ); QUrl reqUrl( url + "/api.php?action=query&list=allpages&aplimit=40&format=xml" ); @@ -141,19 +138,6 @@ MediaWikiWordSearchRequest::MediaWikiWordSearchRequest( wstring const & str, netReply.get(), SLOT( ignoreSslErrors() ) ); #endif - - // We start a timer to postpone early destruction, so a rapid type won't make - // unnecessary network load - startTimer( 200 ); -} - -void MediaWikiWordSearchRequest::timerEvent( QTimerEvent * ev ) -{ - killTimer( ev->timerId() ); - livedLongEnough = true; - - if ( isCancelling ) - finish(); } MediaWikiWordSearchRequest::~MediaWikiWordSearchRequest() @@ -166,17 +150,12 @@ void MediaWikiWordSearchRequest::cancel() // We either finish it in place, or in the timer handler isCancelling = true; - if ( netReply.get() ) + if( netReply.get() ) netReply.reset(); - if ( livedLongEnough ) - { - finish(); - } - else - { - GD_DPRINTF("not long enough\n" ); - } + finish(); + + GD_DPRINTF( "cancel the request" ); } void MediaWikiWordSearchRequest::downloadFinished() @@ -374,7 +353,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewString += articleString.midRef( pos, match.capturedStart() - pos ); + articleNewString += articleString.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString link = match.captured( 1 ); @@ -403,7 +382,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) } if( pos ) { - articleNewString += articleString.midRef( pos ); + articleNewString += articleString.mid( pos ); articleString = articleNewString; articleNewString.clear(); } @@ -428,7 +407,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewString += articleString.midRef( pos, match.capturedStart() - pos ); + articleNewString += articleString.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString tag = match.captured(); @@ -445,7 +424,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) } if( pos ) { - articleNewString += articleString.midRef( pos ); + articleNewString += articleString.mid( pos ); articleString = articleNewString; articleNewString.clear(); } @@ -491,7 +470,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewString += articleString.midRef( pos, match.capturedStart() - pos ); + articleNewString += articleString.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString srcset = match.captured(); @@ -501,7 +480,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) } if( pos ) { - articleNewString += articleString.midRef( pos ); + articleNewString += articleString.mid( pos ); articleString = articleNewString; articleNewString.clear(); } @@ -545,7 +524,7 @@ void MediaWikiArticleRequest::requestFinished( QNetworkReply * r ) sptr< WordSearchRequest > MediaWikiDictionary::prefixMatch( wstring const & word, unsigned long maxResults ) - THROW_SPEC( std::exception ) + { (void) maxResults; if ( word.size() > 80 ) @@ -561,7 +540,7 @@ sptr< WordSearchRequest > MediaWikiDictionary::prefixMatch( wstring const & word sptr< DataRequest > MediaWikiDictionary::getArticle( wstring const & word, vector< wstring > const & alts, wstring const &, bool ) - THROW_SPEC( std::exception ) + { if ( word.size() > 80 ) { @@ -579,7 +558,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Dictionary::Initializing &, Config::MediaWikis const & wikis, QNetworkAccessManager & mgr ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > result; diff --git a/mediawiki.hh b/mediawiki.hh index e8ba98a6..54164a4a 100644 --- a/mediawiki.hh +++ b/mediawiki.hh @@ -18,7 +18,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( Dictionary::Initializing &, Config::MediaWikis const & wikis, QNetworkAccessManager & ) - THROW_SPEC( std::exception ); + ; /// Exposed here for moc class MediaWikiWordSearchRequestSlots: public Dictionary::WordSearchRequest diff --git a/mouseover.cc b/mouseover.cc deleted file mode 100644 index c18609c7..00000000 --- a/mouseover.cc +++ /dev/null @@ -1,239 +0,0 @@ -#include "mouseover.hh" -#include "utf8.hh" -#include -#include -#include - -#ifdef Q_OS_WIN32 -#undef WINVER -#define WINVER 0x0500 -#include -#include -#include -#include "wordbyauto.hh" -#include "x64.hh" -#endif - -MouseOver & MouseOver::instance() -{ - static MouseOver m; - - return m; -} - -#ifdef Q_OS_WIN32 -const UINT WM_MY_SHOW_TRANSLATION = WM_USER + 301; -static wchar_t className[] = L"GoldenDictMouseover"; -typedef BOOL ( WINAPI *ChangeWindowMessageFilterFunc )( UINT, DWORD ); - -#ifndef _MSC_VER -typedef struct tagCHANGEFILTERSTRUCT { - DWORD cbSize; - DWORD ExtStatus; -} CHANGEFILTERSTRUCT, *PCHANGEFILTERSTRUCT; -#endif - -typedef BOOL ( WINAPI *ChangeWindowMessageFilterExFunc )( HWND, UINT, DWORD, PCHANGEFILTERSTRUCT ); - -#endif // Q_OS_WIN32 - -#ifdef Q_OS_WIN32 - -#ifndef ConvertStringSecurityDescriptorToSecurityDescriptor - -extern "C" BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorW( - LPCWSTR StringSecurityDescriptor, - DWORD StringSDRevision, - PSECURITY_DESCRIPTOR *SecurityDescriptor, - PULONG SecurityDescriptorSize ); - -#endif - -static void SetLowLabelToGDSynchroObjects() -{ -// The LABEL_SECURITY_INFORMATION SDDL SACL to be set for low integrity -#define LOW_INTEGRITY_SDDL_SACL_W L"S:(ML;;NW;;;LW)" -// DWORD dwErr = ERROR_SUCCESS; - PSECURITY_DESCRIPTOR pSD = NULL; - - PACL pSacl = NULL; // not allocated - BOOL fSaclPresent = FALSE; - BOOL fSaclDefaulted = FALSE; -#ifdef Q_OS_WIN64 - LPCWSTR pwszMapFileName64 = L"GoldenDictTextOutHookSharedMem64"; -#endif - LPCWSTR pwszMapFileName = L"GoldenDictTextOutHookSharedMem"; - LPCWSTR pwszSpyMutexName = L"GoldenDictTextOutSpyMutex"; - - if( ConvertStringSecurityDescriptorToSecurityDescriptorW( LOW_INTEGRITY_SDDL_SACL_W, 1 /* SDDL_REVISION_1 */, &pSD, NULL ) ) - { - if( GetSecurityDescriptorSacl(pSD, &fSaclPresent, &pSacl, &fSaclDefaulted)) - { -// Note that psidOwner, psidGroup, and pDacl are -// all NULL and set the new LABEL_SECURITY_INFORMATION - -#ifdef Q_OS_WIN64 - /* dwErr = */ SetNamedSecurityInfoW( (LPWSTR)pwszMapFileName64, - SE_KERNEL_OBJECT, LABEL_SECURITY_INFORMATION, NULL, NULL, NULL, pSacl); -#endif - /* dwErr = */ SetNamedSecurityInfoW( (LPWSTR)pwszMapFileName, - SE_KERNEL_OBJECT, LABEL_SECURITY_INFORMATION, NULL, NULL, NULL, pSacl); - - /* dwErr = */ SetNamedSecurityInfoW( (LPWSTR)pwszSpyMutexName, - SE_KERNEL_OBJECT, LABEL_SECURITY_INFORMATION, NULL, NULL, NULL, pSacl); - - } - LocalFree(pSD); - } -} - -#endif // Q_OS_WIN32 - -MouseOver::MouseOver() : - pPref(NULL) -{ - -} - -void MouseOver::enableMouseOver() -{ -#ifdef Q_OS_WIN32 - if ( !mouseOverEnabled && activateSpyFn ) - { - activateSpyFn( true ); - installx64Hooks(); - mouseOverEnabled = true; - } -#endif -} - -void MouseOver::disableMouseOver() -{ -#ifdef Q_OS_WIN32 - if ( mouseOverEnabled && activateSpyFn ) - { - activateSpyFn( false ); - removex64Hooks(); - mouseOverEnabled = false; - } -#endif -} - -#ifdef Q_OS_WIN32 - -LRESULT MouseOver::makeScanBitMask() -{ -LRESULT res = 0; - if( pPref == NULL ) - return 0; - - return res; -} - -LRESULT CALLBACK MouseOver::eventHandler( HWND hwnd_, UINT msg, - WPARAM wparam, LPARAM lparam ) -{ - if ( msg == WM_MY_SHOW_TRANSLATION ) - { - LRESULT res = instance().makeScanBitMask(); - - if( res == 0 ) - return 0; // Don't handle word without necessity - - if( wparam != 0) //Ask for methods of word retrieving - return res; - - int wordSeqPos = 0; - QString wordSeq; - - // Now locate the word inside the sequence - - QString word; - - if ( wordSeq[ wordSeqPos ].isSpace() ) - { - // Currently we ignore such cases - return 0; - } - else - if ( !wordSeq[ wordSeqPos ].isLetterOrNumber() ) - { - // Special case: the cursor points to something which doesn't look like a - // middle of the word -- assume that it's something that joins two words - // together. - - int begin = wordSeqPos; - - for( ; begin; --begin ) - if ( !wordSeq[ begin - 1 ].isLetterOrNumber() ) - break; - - int end = wordSeqPos; - - while( ++end < wordSeq.size() ) - if ( !wordSeq[ end ].isLetterOrNumber() ) - break; - - if ( end - begin == 1 ) - { - // Well, turns out it was just a single non-letter char, discard it - return 0; - } - - word = wordSeq.mid( begin, end - begin ); - } - else - { - // Cursor points to a letter -- cut the word it points to - - int begin = wordSeqPos; - - for( ; begin; --begin ) - if ( !wordSeq[ begin - 1 ].isLetterOrNumber() ) - break; - - int end = wordSeqPos; - - while( ++end < wordSeq.size() ) - { - if ( !wordSeq[ end ].isLetterOrNumber() ) - break; - } - word = wordSeq.mid( begin, end - begin ); - } - - // See if we have an RTL char. Reverse the whole string if we do. - - if( lparam == 0 ) - { - for( int x = 0; x < word.size(); ++x ) - { - QChar::Direction d = word[ x ].direction(); - - if ( d == QChar::DirR || d == QChar::DirAL || - d == QChar::DirRLE || d == QChar::DirRLO ) - { - std::reverse( word.begin(), word.end() ); - break; - } - } - } - - bool forcePopup = false; - emit instance().hovered( word, forcePopup ); - return 0; - } - - return DefWindowProc( hwnd_, msg, wparam, lparam ); -} - -#endif - -MouseOver::~MouseOver() -{ -#ifdef Q_OS_WIN32 - - -#endif -} - diff --git a/mouseover.hh b/mouseover.hh deleted file mode 100644 index 995b47c9..00000000 --- a/mouseover.hh +++ /dev/null @@ -1,71 +0,0 @@ -#ifndef __MOUSEOVER_HH_INCLUDED__ -#define __MOUSEOVER_HH_INCLUDED__ - -#include -#include "config.hh" -#include "keyboardstate.hh" - -#ifdef Q_OS_WIN32 -#include -#endif - -/// This is a mouseover feature interface, where you can point your mouse at -/// any word in any window and wait a little, and it would provide that word -/// for the translation. -/// This interface always exists, even on platforms that don't support that -/// feature -- it just remains dormant on them. -/// -/// The Windows platform is the only one supported; it works with the help of -/// two external .dll files, -class MouseOver: public QObject, public KeyboardState -{ - Q_OBJECT - -public: - - /// The class is a singleton. - static MouseOver & instance(); - - /// Enables mouseover. The mouseover is initially disabled. - void enableMouseOver(); - /// Disables mouseover. - void disableMouseOver(); - - /// Set pointer to program configuration - void setPreferencesPtr( Config::Preferences const *ppref ) { pPref = ppref; }; - -signals: - - /// Emitted when there was some text under cursor which was hovered over. - void hovered( QString const &, bool forcePopup ); - -#ifdef Q_OS_WIN32 - /// Ask for source window is GoldenDict window - bool isGoldenDictWindow( HWND hwnd ); -#endif - -private: - - MouseOver(); - ~MouseOver(); - - Config::Preferences const *pPref; - -#ifdef Q_OS_WIN32 - - static LRESULT CALLBACK eventHandler( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ); - - typedef void ( *ActivateSpyFn )( bool ); - ActivateSpyFn activateSpyFn; - HINSTANCE spyDll; - bool mouseOverEnabled; - - /// Create mask for scan methods - LRESULT makeScanBitMask(); - -#endif - -}; - -#endif - diff --git a/multimediaaudioplayer.cc b/multimediaaudioplayer.cc index f4f10990..de325cab 100644 --- a/multimediaaudioplayer.cc +++ b/multimediaaudioplayer.cc @@ -4,15 +4,26 @@ #ifdef MAKE_QTMULTIMEDIA_PLAYER #include +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) #include +#endif #include "multimediaaudioplayer.hh" -MultimediaAudioPlayer::MultimediaAudioPlayer() : - player( 0, QMediaPlayer::StreamPlayback ) +MultimediaAudioPlayer::MultimediaAudioPlayer() +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) + : player( 0, QMediaPlayer::StreamPlayback ) +#endif { typedef void( QMediaPlayer::* ErrorSignal )( QMediaPlayer::Error ); +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) connect( &player, static_cast< ErrorSignal >( &QMediaPlayer::error ), this, &MultimediaAudioPlayer::onMediaPlayerError ); +#else + player.setAudioOutput(&audioOutput); + + connect( &player, &QMediaPlayer::errorChanged , + this, &MultimediaAudioPlayer::onMediaPlayerError ); +#endif } QString MultimediaAudioPlayer::play( const char * data, int size ) @@ -22,15 +33,20 @@ QString MultimediaAudioPlayer::play( const char * data, int size ) audioBuffer.setData( data, size ); if( !audioBuffer.open( QIODevice::ReadOnly ) ) return tr( "Couldn't open audio buffer for reading." ); - +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + player.setSourceDevice (&audioBuffer ); +#else player.setMedia( QMediaContent(), &audioBuffer ); +#endif player.play(); return QString(); } void MultimediaAudioPlayer::stop() { +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) player.setMedia( QMediaContent() ); // Forget about audioBuffer. +#endif audioBuffer.close(); audioBuffer.setData( QByteArray() ); // Free memory. } diff --git a/multimediaaudioplayer.hh b/multimediaaudioplayer.hh index 873af412..472fe3c1 100644 --- a/multimediaaudioplayer.hh +++ b/multimediaaudioplayer.hh @@ -9,6 +9,9 @@ #include #include #include "audioplayerinterface.hh" +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif class MultimediaAudioPlayer : public AudioPlayerInterface { @@ -25,6 +28,9 @@ private slots: private: QBuffer audioBuffer; QMediaPlayer player; ///< Depends on audioBuffer. +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + QAudioOutput audioOutput; +#endif }; #endif // MAKE_QTMULTIMEDIA_PLAYER diff --git a/mutex.hh b/mutex.hh index 8df8d1b7..5a6ce6a1 100644 --- a/mutex.hh +++ b/mutex.hh @@ -4,16 +4,16 @@ #ifndef __MUTEX_HH_INCLUDED__ #define __MUTEX_HH_INCLUDED__ -#include +#include /// This provides a mutex class. As you can see, it's just a Qt one, but it /// does provide the Lock class which doesn't seem to exist in Qt, and it does /// provide some abstraction for dictionaries in case they are to be ported /// away from Qt. -class Mutex: public QMutex +class Mutex : public QRecursiveMutex { public: - Mutex() : QMutex( Recursive ) + Mutex() : QRecursiveMutex() {} ~Mutex() {} diff --git a/opencc/HKVariants.ocd b/opencc/HKVariants.ocd deleted file mode 100644 index 582c22c0..00000000 Binary files a/opencc/HKVariants.ocd and /dev/null differ diff --git a/opencc/HKVariants.ocd2 b/opencc/HKVariants.ocd2 new file mode 100644 index 00000000..d87866dd Binary files /dev/null and b/opencc/HKVariants.ocd2 differ diff --git a/opencc/HKVariantsPhrases.ocd b/opencc/HKVariantsPhrases.ocd deleted file mode 100644 index 4206c343..00000000 Binary files a/opencc/HKVariantsPhrases.ocd and /dev/null differ diff --git a/opencc/HKVariantsPhrases.ocd2 b/opencc/HKVariantsPhrases.ocd2 new file mode 100644 index 00000000..8fc40ae3 Binary files /dev/null and b/opencc/HKVariantsPhrases.ocd2 differ diff --git a/opencc/HKVariantsRev.ocd2 b/opencc/HKVariantsRev.ocd2 new file mode 100644 index 00000000..25107df2 Binary files /dev/null and b/opencc/HKVariantsRev.ocd2 differ diff --git a/opencc/HKVariantsRevPhrases.ocd2 b/opencc/HKVariantsRevPhrases.ocd2 new file mode 100644 index 00000000..fe817dc6 Binary files /dev/null and b/opencc/HKVariantsRevPhrases.ocd2 differ diff --git a/opencc/JPShinjitaiCharacters.ocd2 b/opencc/JPShinjitaiCharacters.ocd2 new file mode 100644 index 00000000..23e59125 Binary files /dev/null and b/opencc/JPShinjitaiCharacters.ocd2 differ diff --git a/opencc/JPShinjitaiPhrases.ocd2 b/opencc/JPShinjitaiPhrases.ocd2 new file mode 100644 index 00000000..e4c823f1 Binary files /dev/null and b/opencc/JPShinjitaiPhrases.ocd2 differ diff --git a/opencc/JPVariants.ocd2 b/opencc/JPVariants.ocd2 new file mode 100644 index 00000000..68b9e5b1 Binary files /dev/null and b/opencc/JPVariants.ocd2 differ diff --git a/opencc/JPVariantsRev.ocd2 b/opencc/JPVariantsRev.ocd2 new file mode 100644 index 00000000..bcca7d36 Binary files /dev/null and b/opencc/JPVariantsRev.ocd2 differ diff --git a/opencc/STCharacters.ocd b/opencc/STCharacters.ocd deleted file mode 100644 index 6297f1d1..00000000 Binary files a/opencc/STCharacters.ocd and /dev/null differ diff --git a/opencc/STCharacters.ocd2 b/opencc/STCharacters.ocd2 new file mode 100644 index 00000000..7e917758 Binary files /dev/null and b/opencc/STCharacters.ocd2 differ diff --git a/opencc/STPhrases.ocd b/opencc/STPhrases.ocd deleted file mode 100644 index 1c68361e..00000000 Binary files a/opencc/STPhrases.ocd and /dev/null differ diff --git a/opencc/STPhrases.ocd2 b/opencc/STPhrases.ocd2 new file mode 100644 index 00000000..9eace34a Binary files /dev/null and b/opencc/STPhrases.ocd2 differ diff --git a/opencc/TSCharacters.ocd b/opencc/TSCharacters.ocd deleted file mode 100644 index de18b687..00000000 Binary files a/opencc/TSCharacters.ocd and /dev/null differ diff --git a/opencc/TSCharacters.ocd2 b/opencc/TSCharacters.ocd2 new file mode 100644 index 00000000..79e3bdcf Binary files /dev/null and b/opencc/TSCharacters.ocd2 differ diff --git a/opencc/TSPhrases.ocd b/opencc/TSPhrases.ocd deleted file mode 100644 index 59223349..00000000 Binary files a/opencc/TSPhrases.ocd and /dev/null differ diff --git a/opencc/TSPhrases.ocd2 b/opencc/TSPhrases.ocd2 new file mode 100644 index 00000000..dc1d1a97 Binary files /dev/null and b/opencc/TSPhrases.ocd2 differ diff --git a/opencc/TWPhrases.ocd2 b/opencc/TWPhrases.ocd2 new file mode 100644 index 00000000..c3a02eff Binary files /dev/null and b/opencc/TWPhrases.ocd2 differ diff --git a/opencc/TWPhrasesRev.ocd2 b/opencc/TWPhrasesRev.ocd2 new file mode 100644 index 00000000..447c8e6b Binary files /dev/null and b/opencc/TWPhrasesRev.ocd2 differ diff --git a/opencc/TWVariants.ocd b/opencc/TWVariants.ocd deleted file mode 100644 index 0cd2d890..00000000 Binary files a/opencc/TWVariants.ocd and /dev/null differ diff --git a/opencc/TWVariants.ocd2 b/opencc/TWVariants.ocd2 new file mode 100644 index 00000000..80553c44 Binary files /dev/null and b/opencc/TWVariants.ocd2 differ diff --git a/opencc/TWVariantsRev.ocd2 b/opencc/TWVariantsRev.ocd2 new file mode 100644 index 00000000..5f3e266f Binary files /dev/null and b/opencc/TWVariantsRev.ocd2 differ diff --git a/opencc/TWVariantsRevPhrases.ocd2 b/opencc/TWVariantsRevPhrases.ocd2 new file mode 100644 index 00000000..cd23619e Binary files /dev/null and b/opencc/TWVariantsRevPhrases.ocd2 differ diff --git a/opencc/copyright b/opencc/copyright new file mode 100644 index 00000000..9f7a310e --- /dev/null +++ b/opencc/copyright @@ -0,0 +1,56 @@ +Apache License +Version 2.0, January 2004 +http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + +"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. + +"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. + +"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. + +"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. + +"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. + +"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). + +"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. + +"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." + +"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: + + 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating that You changed the files; and + + 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and + + 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. + +You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + diff --git a/opencc/hk2s.json b/opencc/hk2s.json new file mode 100644 index 00000000..7e5da1da --- /dev/null +++ b/opencc/hk2s.json @@ -0,0 +1,33 @@ +{ + "name": "Traditional Chinese (Hong Kong standard) to Simplified Chinese", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "TSPhrases.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "HKVariantsRevPhrases.ocd2" + }, { + "type": "ocd2", + "file": "HKVariantsRev.ocd2" + }] + } + }, { + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "TSPhrases.ocd2" + }, { + "type": "ocd2", + "file": "TSCharacters.ocd2" + }] + } + }] +} diff --git a/opencc/jp2t.json b/opencc/jp2t.json new file mode 100644 index 00000000..025d8919 --- /dev/null +++ b/opencc/jp2t.json @@ -0,0 +1,25 @@ +{ + "name": "New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai)", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "JPShinjitaiPhrases.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "JPShinjitaiPhrases.ocd2" + }, { + "type": "ocd2", + "file": "JPShinjitaiCharacters.ocd2" + }, { + "type": "ocd2", + "file": "JPVariantsRev.ocd2" + }] + } + }] +} diff --git a/opencc/s2hk.json b/opencc/s2hk.json index 94854409..38638a8b 100644 --- a/opencc/s2hk.json +++ b/opencc/s2hk.json @@ -3,30 +3,30 @@ "segmentation": { "type": "mmseg", "dict": { - "type": "ocd", - "file": "STPhrases.ocd" + "type": "ocd2", + "file": "STPhrases.ocd2" } }, "conversion_chain": [{ "dict": { "type": "group", "dicts": [{ - "type": "ocd", - "file": "STPhrases.ocd" + "type": "ocd2", + "file": "STPhrases.ocd2" }, { - "type": "ocd", - "file": "STCharacters.ocd" + "type": "ocd2", + "file": "STCharacters.ocd2" }] } }, { "dict": { "type": "group", "dicts": [{ - "type": "ocd", - "file": "HKVariantsPhrases.ocd" + "type": "ocd2", + "file": "HKVariantsPhrases.ocd2" }, { - "type": "ocd", - "file": "HKVariants.ocd" + "type": "ocd2", + "file": "HKVariants.ocd2" }] } }] diff --git a/opencc/s2t.json b/opencc/s2t.json new file mode 100644 index 00000000..87516acb --- /dev/null +++ b/opencc/s2t.json @@ -0,0 +1,22 @@ +{ + "name": "Simplified Chinese to Traditional Chinese", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "STPhrases.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "STPhrases.ocd2" + }, { + "type": "ocd2", + "file": "STCharacters.ocd2" + }] + } + }] +} diff --git a/opencc/s2tw.json b/opencc/s2tw.json index 5fc6afe1..2a3d7656 100644 --- a/opencc/s2tw.json +++ b/opencc/s2tw.json @@ -3,25 +3,25 @@ "segmentation": { "type": "mmseg", "dict": { - "type": "ocd", - "file": "STPhrases.ocd" + "type": "ocd2", + "file": "STPhrases.ocd2" } }, "conversion_chain": [{ "dict": { "type": "group", "dicts": [{ - "type": "ocd", - "file": "STPhrases.ocd" + "type": "ocd2", + "file": "STPhrases.ocd2" }, { - "type": "ocd", - "file": "STCharacters.ocd" + "type": "ocd2", + "file": "STCharacters.ocd2" }] } }, { "dict": { - "type": "ocd", - "file": "TWVariants.ocd" + "type": "ocd2", + "file": "TWVariants.ocd2" } }] } diff --git a/opencc/s2twp.json b/opencc/s2twp.json new file mode 100644 index 00000000..2f36e935 --- /dev/null +++ b/opencc/s2twp.json @@ -0,0 +1,32 @@ +{ + "name": "Simplified Chinese to Traditional Chinese (Taiwan standard, with phrases)", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "STPhrases.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "STPhrases.ocd2" + }, { + "type": "ocd2", + "file": "STCharacters.ocd2" + }] + } + }, { + "dict": { + "type": "ocd2", + "file": "TWPhrases.ocd2" + } + }, { + "dict": { + "type": "ocd2", + "file": "TWVariants.ocd2" + } + }] +} diff --git a/opencc/t2hk.json b/opencc/t2hk.json new file mode 100644 index 00000000..32f70aa3 --- /dev/null +++ b/opencc/t2hk.json @@ -0,0 +1,22 @@ +{ + "name": "Traditional Chinese to Traditional Chinese (Hong Kong standard)", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "HKVariantsPhrases.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "HKVariantsPhrases.ocd2" + }, { + "type": "ocd2", + "file": "HKVariants.ocd2" + }] + } + }] +} diff --git a/opencc/t2jp.json b/opencc/t2jp.json new file mode 100644 index 00000000..7a43217f --- /dev/null +++ b/opencc/t2jp.json @@ -0,0 +1,16 @@ +{ + "name": "Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai)", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "JPVariants.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "ocd2", + "file": "JPVariants.ocd2" + } + }] +} diff --git a/opencc/t2s.json b/opencc/t2s.json index 21ba6e40..06cf5f58 100644 --- a/opencc/t2s.json +++ b/opencc/t2s.json @@ -3,19 +3,19 @@ "segmentation": { "type": "mmseg", "dict": { - "type": "ocd", - "file": "TSPhrases.ocd" + "type": "ocd2", + "file": "TSPhrases.ocd2" } }, "conversion_chain": [{ "dict": { "type": "group", "dicts": [{ - "type": "ocd", - "file": "TSPhrases.ocd" + "type": "ocd2", + "file": "TSPhrases.ocd2" }, { - "type": "ocd", - "file": "TSCharacters.ocd" + "type": "ocd2", + "file": "TSCharacters.ocd2" }] } }] diff --git a/opencc/t2tw.json b/opencc/t2tw.json new file mode 100644 index 00000000..0394f600 --- /dev/null +++ b/opencc/t2tw.json @@ -0,0 +1,16 @@ +{ + "name": "Traditional Chinese to Traditional Chinese (Taiwan standard)", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "TWVariants.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "ocd2", + "file": "TWVariants.ocd2" + } + }] +} diff --git a/opencc/tw2s.json b/opencc/tw2s.json new file mode 100644 index 00000000..4f554393 --- /dev/null +++ b/opencc/tw2s.json @@ -0,0 +1,33 @@ +{ + "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "TSPhrases.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "TWVariantsRevPhrases.ocd2" + }, { + "type": "ocd2", + "file": "TWVariantsRev.ocd2" + }] + } + }, { + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "TSPhrases.ocd2" + }, { + "type": "ocd2", + "file": "TSCharacters.ocd2" + }] + } + }] +} diff --git a/opencc/tw2sp.json b/opencc/tw2sp.json new file mode 100644 index 00000000..64eb9d97 --- /dev/null +++ b/opencc/tw2sp.json @@ -0,0 +1,36 @@ +{ + "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese (with phrases)", + "segmentation": { + "type": "mmseg", + "dict": { + "type": "ocd2", + "file": "TSPhrases.ocd2" + } + }, + "conversion_chain": [{ + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "TWPhrasesRev.ocd2" + }, { + "type": "ocd2", + "file": "TWVariantsRevPhrases.ocd2" + }, { + "type": "ocd2", + "file": "TWVariantsRev.ocd2" + }] + } + }, { + "dict": { + "type": "group", + "dicts": [{ + "type": "ocd2", + "file": "TSPhrases.ocd2" + }, { + "type": "ocd2", + "file": "TSCharacters.ocd2" + }] + } + }] +} diff --git a/opencc/vcpkg_abi_info.txt b/opencc/vcpkg_abi_info.txt new file mode 100644 index 00000000..0ff71abd --- /dev/null +++ b/opencc/vcpkg_abi_info.txt @@ -0,0 +1,18 @@ +cmake 3.21.1 +features core +portfile.cmake 9863613dceb7a5268bbb2d767d9098c35400b8a881a0815bfe7dbe36e793868f +ports.cmake e01bcbe535b11a2fbda56cffd590218ddeb18cb899c00afb2ac22a2301df2b09 +post_build_checks 2 +powershell 7.2.1 +triplet x64-windows-rel +triplet_abi 4970dad5b87bdaa6176cb4f981bb32f09d8957ff9babdaf321bdb98198621b56-b569c9954a47274946415ff01b1a344c8549f3fc19cb931d50bc09d1e5630c1d-cc5606e89ff68c454d07a2425977151c05eb9158 +vcpkg.json d7125dc7d159ce1190e81cbc30003b28a55e53e7d88a455903040003606a0976 +vcpkg_add_to_path 5d7b62ed9fa23a49d3d842206e95e4211ab25b41321e30b6ddd9208febed9d18 +vcpkg_configure_cmake 0b91a87ccb0659953d3be8d9b5b82dc9bf680b7b84b50eba8f8790c6d27b03d3 +vcpkg_copy_pdbs 59e4c0d2321697848a899ba9537394cdee81725b11965c6d1341df53a6850380 +vcpkg_copy_tool_dependencies 4655cdf0d283d2e6bce5e2aee3745ab0bfd7e4fb048c532274de53ef56389ea9 +vcpkg_find_acquire_program a1240f46d8e1cb7eaacb8ac882ce597e5370be9b387d8a048d178d3b842b3520 +vcpkg_fixup_pkgconfig ff54f8b06c83b54a1af5e35286a6c36ea9e69376bed1d11b5521c254987c123f +vcpkg_from_git 05d446731ca8f6cefe0e4dc04c17776e54b39d4f2bfeeec7952ced1cfe8bf89f +vcpkg_from_github 1929b9ee1417dbf59f8a25ac321ef9ca792b6d67aee38bda69ee3700ea256b73 +vcpkg_install_cmake 6430f4795e65c4c44c545c590d431fe1a68d7444255d0da58362a267bbf6408d diff --git a/opencc/x64/HKVariants.ocd b/opencc/x64/HKVariants.ocd deleted file mode 100644 index 7c2e24c2..00000000 Binary files a/opencc/x64/HKVariants.ocd and /dev/null differ diff --git a/opencc/x64/HKVariantsPhrases.ocd b/opencc/x64/HKVariantsPhrases.ocd deleted file mode 100644 index 7cdc3aaa..00000000 Binary files a/opencc/x64/HKVariantsPhrases.ocd and /dev/null differ diff --git a/opencc/x64/STCharacters.ocd b/opencc/x64/STCharacters.ocd deleted file mode 100644 index 417c8315..00000000 Binary files a/opencc/x64/STCharacters.ocd and /dev/null differ diff --git a/opencc/x64/STPhrases.ocd b/opencc/x64/STPhrases.ocd deleted file mode 100644 index 17b946b6..00000000 Binary files a/opencc/x64/STPhrases.ocd and /dev/null differ diff --git a/opencc/x64/TSCharacters.ocd b/opencc/x64/TSCharacters.ocd deleted file mode 100644 index 471d7f38..00000000 Binary files a/opencc/x64/TSCharacters.ocd and /dev/null differ diff --git a/opencc/x64/TSPhrases.ocd b/opencc/x64/TSPhrases.ocd deleted file mode 100644 index 4c6d7050..00000000 Binary files a/opencc/x64/TSPhrases.ocd and /dev/null differ diff --git a/opencc/x64/TWVariants.ocd b/opencc/x64/TWVariants.ocd deleted file mode 100644 index 94b708a2..00000000 Binary files a/opencc/x64/TWVariants.ocd and /dev/null differ diff --git a/opencc/x64/s2hk.json b/opencc/x64/s2hk.json deleted file mode 100644 index 94854409..00000000 --- a/opencc/x64/s2hk.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "Simplified Chinese to Traditional Chinese (Hong Kong standard)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd", - "file": "STPhrases.ocd" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd", - "file": "STPhrases.ocd" - }, { - "type": "ocd", - "file": "STCharacters.ocd" - }] - } - }, { - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd", - "file": "HKVariantsPhrases.ocd" - }, { - "type": "ocd", - "file": "HKVariants.ocd" - }] - } - }] -} diff --git a/opencc/x64/s2tw.json b/opencc/x64/s2tw.json deleted file mode 100644 index 5fc6afe1..00000000 --- a/opencc/x64/s2tw.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "name": "Simplified Chinese to Traditional Chinese (Taiwan standard)", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd", - "file": "STPhrases.ocd" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd", - "file": "STPhrases.ocd" - }, { - "type": "ocd", - "file": "STCharacters.ocd" - }] - } - }, { - "dict": { - "type": "ocd", - "file": "TWVariants.ocd" - } - }] -} diff --git a/opencc/x64/t2s.json b/opencc/x64/t2s.json deleted file mode 100644 index 21ba6e40..00000000 --- a/opencc/x64/t2s.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "name": "Traditional Chinese to Simplified Chinese", - "segmentation": { - "type": "mmseg", - "dict": { - "type": "ocd", - "file": "TSPhrases.ocd" - } - }, - "conversion_chain": [{ - "dict": { - "type": "group", - "dicts": [{ - "type": "ocd", - "file": "TSPhrases.ocd" - }, { - "type": "ocd", - "file": "TSCharacters.ocd" - }] - } - }] -} diff --git a/orderandprops.cc b/orderandprops.cc index 322e4f8d..863d596c 100644 --- a/orderandprops.cc +++ b/orderandprops.cc @@ -86,13 +86,14 @@ OrderAndProps::OrderAndProps( QWidget * parent, Config::Group const & dictionaryOrder, Config::Group const & inactiveDictionaries, std::vector< sptr< Dictionary::Class > > const & - allDictionaries ): + allDictionaries , + QMap > const & dictMap): QWidget( parent ) { ui.setupUi( this ); - Instances::Group order( dictionaryOrder, allDictionaries, Config::Group() ); - Instances::Group inactive( inactiveDictionaries, allDictionaries, Config::Group() ); + Instances::Group order( dictionaryOrder, dictMap, Config::Group() ); + Instances::Group inactive( inactiveDictionaries, dictMap, Config::Group() ); Instances::complementDictionaryOrder( order, inactive, allDictionaries ); diff --git a/orderandprops.hh b/orderandprops.hh index 79c49877..61be3ff2 100644 --- a/orderandprops.hh +++ b/orderandprops.hh @@ -16,7 +16,8 @@ public: OrderAndProps( QWidget * parent, Config::Group const & dictionaryOrder, Config::Group const & inactiveDictionaries, - std::vector< sptr< Dictionary::Class > > const & allDictionaries ); + std::vector< sptr< Dictionary::Class > > const & allDictionaries , + QMap > const & dictMap); Config::Group getCurrentDictionaryOrder() const; Config::Group getCurrentInactiveDictionaries() const; diff --git a/preferences.cc b/preferences.cc index 6be59a98..8ec85622 100644 --- a/preferences.cc +++ b/preferences.cc @@ -63,11 +63,11 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): // See which other translations do we have - QStringList availLocs = QDir( Config::getLocDir() ).entryList( QStringList( "*.qm" ), + QStringList availLocs = QDir( Config::getEmbedLocDir() ).entryList( QStringList( "*.qm" ), QDir::Files ); // We need to sort by language name -- otherwise list looks really weird - QMap< QString, QPair< QIcon, QString > > sortedLocs; + QMultiMap< QString, QPair< QIcon, QString > > sortedLocs; for( QStringList::iterator i = availLocs.begin(); i != availLocs.end(); ++i ) { @@ -77,15 +77,14 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): if ( lang == "qt" ) continue; // We skip qt's own localizations - sortedLocs.insertMulti( + sortedLocs.insert( Language::localizedNameForId( LangCoder::code2toInt( lang.toLatin1().data() ) ), QPair< QIcon, QString >( QIcon( QString( ":/flags/%1.png" ).arg( i->mid( 3, 2 ).toLower() ) ), i->mid( 0, i->size() - 3 ) ) ); } - for( QMap< QString, QPair< QIcon, QString > >::iterator i = sortedLocs.begin(); - i != sortedLocs.end(); ++i ) + for( QMultiMap< QString, QPair< QIcon, QString > >::iterator i = sortedLocs.begin(); i != sortedLocs.end(); ++i ) ui.interfaceLanguage->addItem( i.value().first, i.key(), i.value().second ); for( int x = 0; x < ui.interfaceLanguage->count(); ++x ) @@ -105,7 +104,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): QStringList availHelps = QDir( Config::getHelpDir() ).entryList( QStringList( "*.qch" ), QDir::Files ); - QMap< QString, QPair< QIcon, QString > > sortedHelps; + QMultiMap< QString, QPair< QIcon, QString > > sortedHelps; for( QStringList::iterator i = availHelps.begin(); i != availHelps.end(); ++i ) { @@ -122,14 +121,13 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): reg = lang.toUpper(); } - sortedHelps.insertMulti( + sortedHelps.insert( Language::localizedNameForId( LangCoder::code2toInt( lang.toLatin1().data() ) ), QPair< QIcon, QString >( QIcon( QString( ":/flags/%1.png" ).arg( reg.toLower() ) ), lang + "_" + reg ) ); } - for( QMap< QString, QPair< QIcon, QString > >::iterator i = sortedHelps.begin(); - i != sortedHelps.end(); ++i ) + for( QMultiMap< QString, QPair< QIcon, QString > >::iterator i = sortedHelps.begin(); i != sortedHelps.end(); ++i ) ui.helpLanguage->addItem( i.value().first, i.key(), i.value().second ); for( int x = 0; x < ui.helpLanguage->count(); ++x ) @@ -169,6 +167,7 @@ Preferences::Preferences( QWidget * parent, Config::Class & cfg_ ): ui.cbAutostart->setChecked( p.autoStart ); ui.doubleClickTranslates->setChecked( p.doubleClickTranslates ); ui.selectBySingleClick->setChecked( p.selectWordBySingleClick); + ui.autoScrollToTargetArticle->setChecked( p.autoScrollToTargetArticle ); ui.escKeyHidesMainWindow->setChecked( p.escKeyHidesMainWindow ); ui.enableMainWindowHotkey->setChecked( p.enableMainWindowHotkey ); @@ -379,6 +378,7 @@ Config::Preferences Preferences::getPreferences() p.autoStart = ui.cbAutostart->isChecked(); p.doubleClickTranslates = ui.doubleClickTranslates->isChecked(); p.selectWordBySingleClick = ui.selectBySingleClick->isChecked(); + p.autoScrollToTargetArticle = ui.autoScrollToTargetArticle->isChecked(); p.escKeyHidesMainWindow = ui.escKeyHidesMainWindow->isChecked(); p.enableMainWindowHotkey = ui.enableMainWindowHotkey->isChecked(); diff --git a/preferences.ui b/preferences.ui index 54ebee0b..392f6a5a 100644 --- a/preferences.ui +++ b/preferences.ui @@ -6,8 +6,8 @@ 0 0 - 636 - 447 + 721 + 506 @@ -24,7 +24,7 @@ - 6 + 0 @@ -47,129 +47,11 @@ &Interface - - - - Startup - - - - - - Automatically starts GoldenDict after operation system bootup. - - - Start with system - - - - - - - - - - - - Add-on style: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - When enabled, an icon appears in the system tray area which can be used -to open main window and perform other tasks. - - - Enable system tray icon - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - false - - - true - - - false - - - - - - With this on, the application starts directly to system tray without showing -its main window. - - - Start to system tray - - - - - - - With this on, an attempt to close main window would hide it instead of closing -the application. - - - Close to system tray - - - - - - - - - - Double-click translates the word clicked - - - - - - - Normally, pressing ESC key moves focus to the translation line. -With this on however, it will hide the main window. - - - ESC key hides main window - - - - - - - Turn this option on if you want to select words by single mouse click - - - Select word by single click - - - - - + + 9 + + + Qt::Vertical @@ -181,7 +63,14 @@ With this on however, it will hide the main window.
- + + + + Double-click translates the word clicked + + + + Tabbed browsing @@ -231,7 +120,17 @@ be the last ones.
- + + + + Turn this option on if you want to select words by single mouse click + + + Select word by single click + + + + @@ -307,20 +206,127 @@ be the last ones.
- - - - Qt::Vertical + + + + When enabled, an icon appears in the system tray area which can be used +to open main window and perform other tasks. - - - 20 - 40 - + + Enable system tray icon - + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + false + + + true + + + false + + + + + + With this on, the application starts directly to system tray without showing +its main window. + + + Start to system tray + + + + + + + With this on, an attempt to close main window would hide it instead of closing +the application. + + + Close to system tray + + + + + + + + + + + + Add-on style: + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Normally, clicking on a link, double-clicking on a word or looking up +selection in an article loads the translation and almost immediately +scrolls to the article from the same dictionary. With this option off, +however, the article from the topmost dictionary is shown. + + + Automatically scroll to target article + + + true + + + + + + + Startup + + + + + + Automatically starts GoldenDict after operation system bootup. + + + Start with system + + + + + + + + + + Normally, pressing ESC key moves focus to the translation line. +With this on however, it will hide the main window. + + + ESC key hides main window + + + + @@ -380,19 +386,6 @@ be the last ones.
&Scan Popup - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -726,19 +719,6 @@ seconds, which is specified here.
Hotkeys - - - - Qt::Vertical - - - - 20 - 19 - - - - @@ -871,19 +851,6 @@ p, li { white-space: pre-wrap; } &Audio - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -977,19 +944,6 @@ p, li { white-space: pre-wrap; } &Network - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -1259,19 +1213,6 @@ download page.
Full-text search - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -1437,78 +1378,64 @@ download page.
- - - - - ScanPopup unpinned window flags + + + ScanPopup unpinned window flags + + + + + 10 + 25 + 191 + 22 + + + + + 0 + 0 + + + + Experiment with non-default flags if the unpinned scan popup window misbehaves + + + + <default> - - - - - Experiment with non-default flags if the unpinned scan popup window misbehaves - - - - <default> - - - - - Popup - - - - - Tool - - - - - - - - false - - - This hint can be combined with non-default window flags - - - Bypass window manager hint - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - Qt::Horizontal + + + + Popup - - - 40 - 20 - + + + + Tool - - - + + + + + false + + + + 10 + 53 + 193 + 20 + + + + This hint can be combined with non-default window flags + + + Bypass window manager hint + + + diff --git a/processwrapper.cc b/processwrapper.cc index 9d525830..0359e963 100644 --- a/processwrapper.cc +++ b/processwrapper.cc @@ -112,7 +112,7 @@ unsigned int ProcessWrapper::findProcess(const char *name, unsigned int pid_skip QDir pd("/proc"); QFileInfoList list = pd.entryInfoList(QDir::Dirs | QDir::NoSymLinks | QDir::NoDotAndDotDot); QFileInfoList::iterator it, it_end = list.end(); - for (it = list.begin(); it != it_end; it++) + for (it = list.begin(); it != it_end; ++it) { const QFileInfo &fi = *it; if (fi.baseName().at(0).isDigit()) { diff --git a/programs.cc b/programs.cc index 2078b86e..cd2b07df 100644 --- a/programs.cc +++ b/programs.cc @@ -44,12 +44,12 @@ public: virtual sptr< WordSearchRequest > prefixMatch( wstring const & word, unsigned long maxResults ) - THROW_SPEC( std::exception ); + ; virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ) - THROW_SPEC( std::exception ); + ; protected: @@ -58,7 +58,7 @@ protected: sptr< WordSearchRequest > ProgramsDictionary::prefixMatch( wstring const & word, unsigned long /*maxResults*/ ) - THROW_SPEC( std::exception ) + { if ( prg.type == Config::Program::PrefixMatch ) return new ProgramWordSearchRequest( gd::toQString( word ), prg ); @@ -74,7 +74,7 @@ sptr< WordSearchRequest > ProgramsDictionary::prefixMatch( wstring const & word, sptr< Dictionary::DataRequest > ProgramsDictionary::getArticle( wstring const & word, vector< wstring > const &, wstring const &, bool ) - THROW_SPEC( std::exception ) + { switch( prg.type ) { @@ -372,7 +372,7 @@ void ProgramWordSearchRequest::cancel() vector< sptr< Dictionary::Class > > makeDictionaries( Config::Programs const & programs ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > result; diff --git a/programs.hh b/programs.hh index 6c11a665..2e53a186 100644 --- a/programs.hh +++ b/programs.hh @@ -17,7 +17,7 @@ using std::string; using gd::wstring; vector< sptr< Dictionary::Class > > makeDictionaries( Config::Programs const & ) - THROW_SPEC( std::exception ); + ; class RunInstance: public QObject { diff --git a/resources.qrc b/resources.qrc index f8b68306..a421a9e4 100644 --- a/resources.qrc +++ b/resources.qrc @@ -18,6 +18,7 @@ icons/icon32_dictd.png icons/icon32_hunspell.png icons/icon32_wiki.png + icons/wiktionary.png qt-style-st-lingvo.css article-style-st-lingvo.css icons/icon_dsl_native.png diff --git a/resources/gd-builtin.js b/resources/gd-builtin.js index b553cbf2..41cbc9b4 100644 --- a/resources/gd-builtin.js +++ b/resources/gd-builtin.js @@ -1,110 +1,122 @@ // seperate from cpp code. -var gdAudioLinks = { first: null, current: null }; +var gdAudioLinks = { + "first": null, + "current": null +}; -function gdMakeArticleActive(newId) { - var gdCurrentArticle=$_$(".gdactivearticle").attr("id"); +function gdMakeArticleActive(newId,noEvent) { + var gdCurrentArticle = $_$(".gdactivearticle").attr("id") if (gdCurrentArticle !== 'gdfrom-' + newId) { - $_$(".gdactivearticle").removeClass("gdactivearticle"); - var newFormId='gdfrom-' + newId; - $_$("#"+newFormId).addClass("gdactivearticle"); - gdCurrentArticle = 'gdfrom-' + newId; - gdAudioLinks.current = newId; - articleview.onJsActiveArticleChanged(gdCurrentArticle); + $_$(".gdactivearticle").removeClass("gdactivearticle") + var newFormId = 'gdfrom-' + newId + $_$("#" + newFormId).addClass("gdactivearticle") + gdCurrentArticle = 'gdfrom-' + newId + gdAudioLinks.current = newId + if(!noEvent) + articleview.onJsActiveArticleChanged('gdfrom-' + newId); } } + var overIframeId = null; function gdSelectArticle(id) { - var selection = window.getSelection(); - var range = document.createRange(); - range.selectNodeContents(document.getElementById('gdfrom-' + id)); - selection.removeAllRanges(); - selection.addRange(range); + var selection = window.getSelection() + var range = document.createRange() + range.selectNodeContents(document.getElementById('gdfrom-' + id)) + selection.removeAllRanges() + selection.addRange(range) } function processIframeMouseOut() { - overIframeId = null; - top.focus(); + overIframeId = null + top.focus() } -function processIframeMouseOver(newId) { overIframeId = newId; } +function processIframeMouseOver(newId) { + overIframeId = newId +} function processIframeClick() { if (overIframeId != null) { - overIframeId = overIframeId.replace('gdexpandframe-', ''); + overIframeId = overIframeId.replace('gdexpandframe-', '') gdMakeArticleActive(overIframeId) } } -function init() { window.addEventListener('blur', processIframeClick, false); } -window.addEventListener('load', init, false); +function init() { + window.addEventListener('blur', processIframeClick, false) +} +window.addEventListener('load', init, false) function gdExpandOptPart(expanderId, optionalId) { - var d1 = document.getElementById(expanderId); - var i = 0; + var d1 = document.getElementById(expanderId) + var i = 0 if (d1.alt == '[+]') { - d1.alt = '[-]'; - d1.src = 'qrcx://localhost/icons/collapse_opt.png'; + d1.alt = '[-]' + d1.src = 'qrcx://localhost/icons/collapse_opt.png' for (i = 0; i < 1000; i++) { - var d2 = document.getElementById(optionalId + i); - if (!d2) break; - d2.style.display = 'inline'; + var d2 = document.getElementById(optionalId + i) + if (!d2) + break + d2.style.display = 'inline' } } else { - d1.alt = '[+]'; - d1.src = 'qrcx://localhost/icons/expand_opt.png'; + d1.alt = '[+]' + d1.src = 'qrcx://localhost/icons/expand_opt.png' for (i = 0; i < 1000; i++) { - var d2 = document.getElementById(optionalId + i); - if (!d2) break; - d2.style.display = 'none'; + var d2 = document.getElementById(optionalId + i) + if (!d2) + break + d2.style.display = 'none' } } -}; +} -function emitClickedEvent(){ - try{ - articleview.linkClickedInHtml(""); - }catch(error) - { - console.error(error); +function emitClickedEvent(link) { + try { + articleview.linkClickedInHtml(link) + } catch (error) { + console.error(error) } - } function gdExpandArticle(id) { - emitClickedEvent(); - elem = document.getElementById('gdarticlefrom-' + id); - ico = document.getElementById('expandicon-' + id); - art = document.getElementById('gdfrom-' + id); - ev = window.event; - t = null; - if (ev) t = ev.target || ev.srcElement; - if (elem.style.display == 'inline' ) { - elem.style.display = 'none'; - ico.className = 'gdexpandicon'; - art.className = art.className + ' gdcollapsedarticle'; - nm = document.getElementById('gddictname-' + id); - nm.style.cursor = 'pointer'; - if (ev) ev.stopPropagation(); - ico.title = tr("Expand article"); - nm.title = ''; + emitClickedEvent() + elem = document.getElementById('gdarticlefrom-' + id) + ico = document.getElementById('expandicon-' + id) + art = document.getElementById('gdfrom-' + id) + ev = window.event + t = null + if (ev) + t = ev.target || ev.srcElement + if (elem.style.display == 'inline') { + elem.style.display = 'none' + ico.className = 'gdexpandicon' + art.className = art.className + ' gdcollapsedarticle' + nm = document.getElementById('gddictname-' + id) + nm.style.cursor = 'pointer' + if (ev) + ev.stopPropagation() + ico.title = tr("Expand article") + nm.title = '' } else if (elem.style.display == 'none') { - elem.style.display = 'inline'; - ico.className = 'gdcollapseicon'; - art.className = art.className.replace(' gdcollapsedarticle', ''); - nm = document.getElementById('gddictname-' + id); - nm.style.cursor = 'default'; - nm.title = ''; - ico.title = tr("Collapse article"); + elem.style.display = 'inline' + ico.className = 'gdcollapseicon' + art.className = art.className.replace(' gdcollapsedarticle', '') + nm = document.getElementById('gddictname-' + id) + nm.style.cursor = 'default' + nm.title = '' + ico.title = tr("Collapse article") } } function gdCheckArticlesNumber() { - elems = document.getElementsByClassName('gddictname'); + elems = document.getElementsByClassName('gddictname') if (elems.length == 1) { - el = elems.item(0); - s = el.id.replace('gddictname-', ''); - el = document.getElementById('gdfrom-' + s); - if (el && el.className.search('gdcollapsedarticle') > 0) gdExpandArticle(s); + el = elems.item(0) + s = el.id.replace('gddictname-', '') + el = document.getElementById('gdfrom-' + s) + if (el && el.className.search('gdcollapsedarticle') > 0) + gdExpandArticle(s) } } diff --git a/resources/gd-custom.js b/resources/gd-custom.js index f2eab157..ae5bba3b 100644 --- a/resources/gd-custom.js +++ b/resources/gd-custom.js @@ -1,12 +1,16 @@ //document ready (function($){ $(function() { - $("a").click(function(event) { + $(document).on("click","a",function(event) { var link = $(this).attr("href"); - emitClickedEvent(link); - if(link.indexOf(":")>=0){ + if ('string' != typeof(link)) { return; } + if(link.indexOf(":")>=0){ + emitClickedEvent(link); + return false; + } + emitClickedEvent(""); var newLink; var href = window.location.href; @@ -23,12 +27,17 @@ $(function() { } } else { index = href.indexOf("?"); - if(index>-1) - { - newLink = href.substring(0, index) + "?word=" + link; + + if (link.indexOf("?gdanchor") > -1) { + newLink = "gdlookup://localhost/" + link; } - else{ - newLink=href+"?word=" + link; + else { + if (index > -1) { + newLink = href.substring(0, index) + "?word=" + link; + } + else { + newLink = href + "?word=" + link; + } } } $(this).attr("href", newLink); @@ -43,14 +52,16 @@ function playSound(sound) { a.play(); } -function emitClickedEvent(link) { - try { - articleview.linkClickedInHtml(link); - } catch (error) { - console.error(error); - } -} - function resizeIframe(obj) { - obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px'; + setInterval(function(){ + //in some cases ,the website in iframe will load result after document has been loaded. the height will continue to change. + if(obj.contentWindow.document.documentElement.scrollHeight <1000) + { + obj.style.height = obj.contentWindow.document.documentElement.scrollHeight + 'px'; + } + else{ + obj.style.height ='1000px' + obj.scrolling="yes"; + } + },500); } diff --git a/resourceschemehandler.cpp b/resourceschemehandler.cpp index 933811cd..d32ea11d 100644 --- a/resourceschemehandler.cpp +++ b/resourceschemehandler.cpp @@ -25,4 +25,5 @@ void ResourceSchemeHandler::requestStarted(QWebEngineUrlRequestJob *requestJob) // Reply segment requestJob->reply(contentType.toLatin1(), reply); }); + connect(requestJob, &QObject::destroyed, reply, &QObject::deleteLater); } diff --git a/ripemd.hh b/ripemd.hh index 53db34bf..fe801763 100644 --- a/ripemd.hh +++ b/ripemd.hh @@ -22,11 +22,7 @@ #include #include -#if defined( _MSC_VER ) && _MSC_VER < 1800 // VS2012 and older -#include -#else #include -#endif class RIPEMD128 { diff --git a/romaji.cc b/romaji.cc index 748bb2e2..10ebc4ea 100644 --- a/romaji.cc +++ b/romaji.cc @@ -92,7 +92,7 @@ HepburnKatakana::HepburnKatakana() } vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & r ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > result; diff --git a/romaji.hh b/romaji.hh index 581435db..58d08669 100644 --- a/romaji.hh +++ b/romaji.hh @@ -13,7 +13,7 @@ namespace Romaji { using std::vector; vector< sptr< Dictionary::Class > > makeDictionaries( Config::Romaji const & ) - THROW_SPEC( std::exception ); + ; } diff --git a/russiantranslit.cc b/russiantranslit.cc index 29787b15..56f44d95 100644 --- a/russiantranslit.cc +++ b/russiantranslit.cc @@ -99,7 +99,7 @@ RussianTable::RussianTable() ins( "Ya", "Я" ); } -sptr< Dictionary::Class > makeDictionary() THROW_SPEC( std::exception ) +sptr< Dictionary::Class > makeDictionary() { static RussianTable t; diff --git a/russiantranslit.hh b/russiantranslit.hh index e5b889f6..63dffdf1 100644 --- a/russiantranslit.hh +++ b/russiantranslit.hh @@ -9,7 +9,7 @@ // Support for Russian transliteration namespace RussianTranslit { -sptr< Dictionary::Class > makeDictionary() THROW_SPEC( std::exception ); +sptr< Dictionary::Class > makeDictionary() ; } diff --git a/scanflag.cc b/scanflag.cc index 346f45ce..99d0459b 100644 --- a/scanflag.cc +++ b/scanflag.cc @@ -1,8 +1,8 @@ #include -#include #include "scanflag.hh" #include "ui_scanflag.h" +#include static Qt::WindowFlags popupWindowFlags = @@ -53,7 +53,7 @@ void ScanFlag::showScanFlag() QPoint currentPos = QCursor::pos(); - QRect desktop = QApplication::desktop()->screenGeometry(); + QRect desktop = QGuiApplication::primaryScreen()->geometry(); QSize windowSize = geometry().size(); diff --git a/scanpopup.cc b/scanpopup.cc index e61fd4f9..4a7199dd 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -8,15 +8,15 @@ #include #include #include +#if (QT_VERSION < QT_VERSION_CHECK(6,0,0)) #include +#endif #include "gddebug.hh" #include "gestures.hh" #ifdef Q_OS_MAC #include "macmouseover.hh" #define MouseOver MacMouseOver -#else -#include "mouseover.hh" #endif using std::wstring; @@ -244,16 +244,16 @@ ScanPopup::ScanPopup( QWidget * parent, connect( focusArticleViewAction, SIGNAL( triggered() ), definition, SLOT( focus() ) ); switchExpandModeAction.setShortcuts( QList< QKeySequence >() << - QKeySequence( Qt::CTRL + Qt::Key_8 ) << - QKeySequence( Qt::CTRL + Qt::Key_Asterisk ) << - QKeySequence( Qt::CTRL + Qt::SHIFT + Qt::Key_8 ) ); + QKeySequence( Qt::CTRL | Qt::Key_8 ) << + QKeySequence( Qt::CTRL | Qt::Key_Asterisk ) << + QKeySequence( Qt::CTRL | Qt::SHIFT | Qt::Key_8 ) ); addAction( &switchExpandModeAction ); connect( &switchExpandModeAction, SIGNAL( triggered() ), this, SLOT(switchExpandOptionalPartsMode() ) ); - connect( ui.groupList, SIGNAL( currentIndexChanged( QString const & ) ), - this, SLOT( currentGroupChanged( QString const & ) ) ); + connect( ui.groupList, &QComboBox::currentIndexChanged, + this, &ScanPopup::currentGroupChanged); connect( &wordFinder, SIGNAL( finished() ), this, SLOT( prefixMatchFinished() ) ); @@ -279,9 +279,10 @@ ScanPopup::ScanPopup( QWidget * parent, this, SLOT( clipboardChanged( QClipboard::Mode ) ) ); #endif +#ifdef Q_OS_MAC connect( &MouseOver::instance(), SIGNAL( hovered( QString const &, bool ) ), this, SLOT( mouseHovered( QString const &, bool ) ) ); - +#endif hideTimer.setSingleShot( true ); hideTimer.setInterval( 400 ); @@ -305,9 +306,9 @@ ScanPopup::ScanPopup( QWidget * parent, mouseGrabPollTimer.setInterval( 10 ); connect( &mouseGrabPollTimer, SIGNAL( timeout() ), this, SLOT(mouseGrabPoll()) ); - +#ifdef Q_OS_MAC MouseOver::instance().setPreferencesPtr( &( cfg.preferences ) ); - +#endif ui.goBackButton->setEnabled( false ); ui.goForwardButton->setEnabled( false ); @@ -361,7 +362,6 @@ void ScanPopup::enableScanning() if ( !isScanningEnabled ) { isScanningEnabled = true; - MouseOver::instance().enableMouseOver(); } } @@ -369,7 +369,6 @@ void ScanPopup::disableScanning() { if ( isScanningEnabled ) { - MouseOver::instance().disableMouseOver(); isScanningEnabled = false; } } @@ -625,7 +624,7 @@ void ScanPopup::engagePopup( bool forcePopup, bool giveFocus ) QPoint currentPos = QCursor::pos(); - QRect desktop = QApplication::desktop()->screenGeometry(); + QRect desktop = QGuiApplication::primaryScreen()->geometry(); QSize windowSize = geometry().size(); @@ -716,8 +715,7 @@ QString ScanPopup::elideInputWord() QString const & inputWord = inputPhrase.phrase; return inputWord.size() > 32 ? inputWord.mid( 0, 32 ) + "..." : inputWord; } - -void ScanPopup::currentGroupChanged( QString const & ) +void ScanPopup::currentGroupChanged( int ) { cfg.lastPopupGroupId = ui.groupList->getCurrentGroup(); Instances::Group const * igrp = groups.findGroup( cfg.lastPopupGroupId ); @@ -1004,7 +1002,11 @@ void ScanPopup::leaveEvent( QEvent * event ) } } +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +void ScanPopup::enterEvent( QEnterEvent * event ) +#else void ScanPopup::enterEvent( QEvent * event ) +#endif { QMainWindow::enterEvent( event ); @@ -1139,7 +1141,11 @@ void ScanPopup::altModePoll() void ScanPopup::pageLoaded( ArticleView * ) { - ui.pronounceButton->setVisible( definition->hasSound() ); + + + definition->hasSound([this](bool has){ + ui.pronounceButton->setVisible( has ); + }); updateBackForwardButtons(); diff --git a/scanpopup.hh b/scanpopup.hh index 5ebb1bf4..e081ae0a 100644 --- a/scanpopup.hh +++ b/scanpopup.hh @@ -53,7 +53,6 @@ public: void setDictionaryIconSize(); void saveConfigData(); - signals: /// Forwarded from the dictionary bar, so that main window could act on this. @@ -176,7 +175,11 @@ private: virtual void mouseMoveEvent( QMouseEvent * ); virtual void mouseReleaseEvent( QMouseEvent * ); virtual void leaveEvent( QEvent * event ); +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) + virtual void enterEvent( QEnterEvent * event ); +#else virtual void enterEvent( QEvent * event ); +#endif virtual void showEvent( QShowEvent * ); /// Returns inputWord, chopped with appended ... if it's too long/ @@ -188,12 +191,10 @@ private: void updateSuggestionList(); void updateSuggestionList( QString const & text ); - private slots: - void clipboardChanged( QClipboard::Mode ); void mouseHovered( QString const & , bool forcePopup); - void currentGroupChanged( QString const & ); + void currentGroupChanged( int ); void prefixMatchFinished(); void on_pronounceButton_clicked(); void pinButtonClicked( bool checked ); diff --git a/sdict.cc b/sdict.cc index bbec14c5..0b1cb8a5 100644 --- a/sdict.cc +++ b/sdict.cc @@ -28,7 +28,9 @@ #include #include #include - +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif #include #include "ufile.hh" @@ -163,7 +165,7 @@ class SdictDictionary: public BtreeIndexing::BtreeDictionary vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual QString const & getDescription(); @@ -322,8 +324,8 @@ string SdictDictionary::convert( string const & in ) int n = 0; for( ; ; ) { - QRegExp start_link_tag( "<\\s*r\\s*>", Qt::CaseInsensitive ); - QRegExp end_link_tag( "<\\s*/r\\s*>", Qt::CaseInsensitive ); + QRegularExpression start_link_tag( "<\\s*r\\s*>", QRegularExpression::CaseInsensitiveOption ); + QRegularExpression end_link_tag( "<\\s*/r\\s*>", QRegularExpression::CaseInsensitiveOption ); n = result.indexOf( start_link_tag, n ); if( n < 0 ) @@ -333,10 +335,12 @@ string SdictDictionary::convert( string const & in ) if( end < 0 ) break; - int tag_len = start_link_tag.cap().length(); + QRegularExpressionMatch m= start_link_tag.match( result, 0, QRegularExpression::PartialPreferFirstMatch ); + int tag_len = m.captured ().length(); QString link_text = result.mid( n + tag_len, end - n - tag_len ); - result.replace( end, end_link_tag.cap().length(), "" ); + m= end_link_tag.match( result, 0, QRegularExpression::PartialPreferFirstMatch ); + result.replace( end, m.captured ().length(), "" ); result.replace( n, tag_len, QString( ""); } @@ -663,7 +667,7 @@ sptr< Dictionary::DataRequest > SdictDictionary::getArticle( wstring const & wor vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new SdictArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -742,7 +746,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/sdict.hh b/sdict.hh index ef979c02..81de56c0 100644 --- a/sdict.hh +++ b/sdict.hh @@ -16,7 +16,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; } diff --git a/slob.cc b/slob.cc index 8420f642..16c88c6b 100644 --- a/slob.cc +++ b/slob.cc @@ -31,6 +31,9 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif #include #include #include @@ -606,10 +609,10 @@ class SlobDictionary: public BtreeIndexing::BtreeDictionary vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; virtual QString const& getDescription(); @@ -835,7 +838,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) { QRegularExpressionMatch match = it.next(); - newText += text.midRef( pos, match.capturedStart() - pos ); + newText += text.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QStringList list = match.capturedTexts(); @@ -854,8 +857,8 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) else anchor.clear(); - tag.remove( QRegExp(".*/") ). - remove( QRegExp( "\\.(s|)htm(l|)$", Qt::CaseInsensitive ) ). + tag.remove( QRegularExpression(".*/") ). + remove( QRegularExpression( "\\.(s|)htm(l|)$", QRegularExpression::PatternOption::CaseInsensitiveOption ) ). replace( "_", "%20" ). prepend( "" ); @@ -864,7 +867,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) } if( pos ) { - newText += text.midRef( pos ); + newText += text.mid( pos ); text = newText; } newText.clear(); @@ -878,7 +881,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) QRegularExpression regFrac( "\\\\[dt]frac" ); QRegularExpression regSpaces( "\\s+([\\{\\(\\[\\}\\)\\]])" ); - QRegExp multReg = QRegExp( "\\*\\{(\\d+)\\}([^\\{]|\\{([^\\}]+)\\})", Qt::CaseSensitive, QRegExp::RegExp2 ); + QRegExp multReg( "\\*\\{(\\d+)\\}([^\\{]|\\{([^\\}]+)\\})", Qt::CaseSensitive, QRegExp::RegExp2 ); QString arrayDesc( "\\begin{array}{" ); pos = 0; @@ -891,7 +894,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) { QRegularExpressionMatch match = it.next(); - newText += text.midRef( pos, match.capturedStart() - pos ); + newText += text.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QStringList list = match.capturedTexts(); @@ -902,7 +905,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) || list[ 1 ].endsWith( " tex" ) ) { QString name; - name.sprintf( "%04X%04X%04X.gif", entry.itemIndex, entry.binIndex, texCount ); + name.asprintf( "%04X%04X%04X.gif", entry.itemIndex, entry.binIndex, texCount ); imgName = texCachePath + "/" + name; if( !QFileInfo( imgName ).exists() ) @@ -985,7 +988,7 @@ string SlobDictionary::convert( const string & in, RefEntry const & entry ) QString command = texCgiPath + " -e " + imgName + " \"" + tex + "\""; - QProcess::execute( command ); + QProcess::execute( command,QStringList() ); } QString tag = QString( " SlobDictionary::getArticle( wstring const & word vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new SlobArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -1634,7 +1637,7 @@ void SlobResourceRequest::run() } sptr< Dictionary::DataRequest > SlobDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { return new SlobResourceRequest( *this, name ); } @@ -1645,7 +1648,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing & initializing, unsigned maxHeadwordsToExpand ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/slob.hh b/slob.hh index 3be13df2..a095e3d6 100644 --- a/slob.hh +++ b/slob.hh @@ -16,7 +16,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing &, unsigned maxHeadwordsToExpand ) - THROW_SPEC( std::exception ); + ; } diff --git a/sounddir.cc b/sounddir.cc index da56cdc6..46b58749 100644 --- a/sounddir.cc +++ b/sounddir.cc @@ -95,10 +95,10 @@ public: vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; protected: @@ -128,7 +128,7 @@ sptr< Dictionary::DataRequest > SoundDirDictionary::getArticle( wstring const & vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { vector< WordArticleLink > chain = findArticles( word, ignoreDiacritics ); @@ -306,7 +306,7 @@ void SoundDirDictionary::loadIcon() throw() } sptr< Dictionary::DataRequest > SoundDirDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { bool isNumber = false; @@ -408,7 +408,7 @@ void addDir( QDir const & baseDir, QDir const & dir, IndexedWords & indexedWords vector< sptr< Dictionary::Class > > makeDictionaries( Config::SoundDirs const & soundDirs, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/sounddir.hh b/sounddir.hh index 1b11cd17..1c3f2eb0 100644 --- a/sounddir.hh +++ b/sounddir.hh @@ -16,7 +16,7 @@ using std::string; vector< sptr< Dictionary::Class > > makeDictionaries( Config::SoundDirs const &, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; } diff --git a/sources.cc b/sources.cc index 60558408..a90e2042 100644 --- a/sources.cc +++ b/sources.cc @@ -74,7 +74,7 @@ Sources::Sources( QWidget * parent, Config::Class const & cfg): ui.programs->resizeColumnToContents( 0 ); // Make sure this thing will be large enough ui.programs->setColumnWidth( 1, - QFontMetrics( QFont() ).width( + QFontMetrics( QFont() ).horizontalAdvance( ProgramTypeEditor::getNameForType( Config::Program::PrefixMatch ) ) + 16 ); ui.programs->resizeColumnToContents( 2 ); ui.programs->resizeColumnToContents( 3 ); diff --git a/sources.ui b/sources.ui index d303f057..1464e82d 100644 --- a/sources.ui +++ b/sources.ui @@ -6,7 +6,7 @@ 0 0 - 811 + 929 336 @@ -493,19 +493,6 @@ of the appropriate groups to use them.
true - - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -556,21 +543,21 @@ in the future, or register on the site to get your own key.
- + Language codes (comma-separated): - + List of language codes you would like to have. Example: "en, ru". - + Qt::Horizontal @@ -586,7 +573,7 @@ in the future, or register on the site to get your own key.
- + Full list of language codes is available <a href="http://www.forvo.com/languages-codes/">here</a>. @@ -596,19 +583,6 @@ in the future, or register on the site to get your own key.
- - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -638,32 +612,11 @@ in the future, or register on the site to get your own key.
Transliteration - - - - Qt::Vertical - - - - 20 - 40 - - - - + + 6 + - - - - Russian transliteration - - - - :/flags/ru.png:/flags/ru.png - - - @@ -675,20 +628,18 @@ in the future, or register on the site to get your own key.
- - - - Qt::Vertical + + + + Russian transliteration - - - 20 - 40 - + + + :/flags/ru.png:/flags/ru.png - + - + German transliteration @@ -699,7 +650,7 @@ in the future, or register on the site to get your own key.
- + Belarusian transliteration @@ -712,19 +663,6 @@ in the future, or register on the site to get your own key.
- - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -820,19 +758,6 @@ Not implemented yet in GoldenDict.
- - - - Qt::Vertical - - - - 20 - 40 - - - - @@ -864,8 +789,8 @@ Not implemented yet in GoldenDict.
paths - + diff --git a/splitfile.cc b/splitfile.cc index 9308f77e..0f7cdfc3 100644 --- a/splitfile.cc +++ b/splitfile.cc @@ -42,7 +42,7 @@ void SplitFile::close() void SplitFile::getFilenames( vector< string > &names ) const { - for( QVector< QFile const * >::const_iterator i = files.begin(); i != files.end(); ++i ) + for( QVector< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i ) names.push_back( FsEncoding::encode( (*i)->fileName() ) ); } diff --git a/stardict.cc b/stardict.cc index e9fb2c3d..3e1d1a15 100644 --- a/stardict.cc +++ b/stardict.cc @@ -39,7 +39,11 @@ #include #include #include +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#else #include +#endif #include #include #include @@ -170,16 +174,16 @@ public: { return idxHeader.langTo; } virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; virtual QString const& getDescription(); @@ -472,7 +476,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewText += articleText.midRef( pos, match.capturedStart() - pos ); + articleNewText += articleText.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString link = match.captured( 3 ); @@ -507,7 +511,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz } if( pos ) { - articleNewText += articleText.midRef( pos ); + articleNewText += articleText.mid( pos ); articleText = articleNewText; articleNewText.clear(); } @@ -527,7 +531,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewText += articleText.midRef( pos, match.capturedStart() - pos ); + articleNewText += articleText.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString src = match.captured( 2 ); @@ -551,7 +555,7 @@ string StardictDictionary::handleResource( char type, char const * resource, siz } if( pos ) { - articleNewText += articleText.midRef( pos ); + articleNewText += articleText.mid( pos ); articleText = articleNewText; articleNewText.clear(); } @@ -1310,7 +1314,7 @@ void StardictHeadwordsRequest::run() sptr< Dictionary::WordSearchRequest > StardictDictionary::findHeadwordsForSynonym( wstring const & word ) - THROW_SPEC( std::exception ) + { return synonymSearchEnabled ? new StardictHeadwordsRequest( word, *this ) : Class::findHeadwordsForSynonym( word ); @@ -1514,7 +1518,7 @@ sptr< Dictionary::DataRequest > StardictDictionary::getArticle( wstring const & vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new StardictArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -1775,7 +1779,7 @@ void StardictResourceRequest::run() while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - newCSS += css.midRef( pos, match.capturedStart() - pos ); + newCSS += css.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString url = match.captured( 2 ); @@ -1793,7 +1797,7 @@ void StardictResourceRequest::run() } if( pos ) { - newCSS += css.midRef( pos ); + newCSS += css.mid( pos ); css = newCSS; newCSS.clear(); } @@ -1821,7 +1825,7 @@ void StardictResourceRequest::run() } sptr< Dictionary::DataRequest > StardictDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { return new StardictResourceRequest( *this, name ); } @@ -2004,7 +2008,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing & initializing, unsigned maxHeadwordsToExpand ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/stardict.hh b/stardict.hh index 7cc53055..bfe82a23 100644 --- a/stardict.hh +++ b/stardict.hh @@ -17,7 +17,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing &, unsigned maxHeadwordsToExpand ) - THROW_SPEC( std::exception ); + ; } diff --git a/termination.cc b/termination.cc index d45cd538..3ace17a6 100644 --- a/termination.cc +++ b/termination.cc @@ -1,164 +1,21 @@ + /* This file is (c) 2008-2012 Konstantin Isakov * Part of GoldenDict. Licensed under GPLv3 or later, see the LICENSE file */ #include "termination.hh" #include -#include - -#ifndef _MSC_VER -#include -#endif - -#include - -#ifndef __WIN32 -#include -#endif - -#include -#include - -#include - #include -using std::string; static void termHandler() { + QString message( "GoldenDict has crashed with an unexpected exception\n\n" ); + qDebug() << message; + if( logFilePtr && logFilePtr->isOpen() ) logFilePtr->close(); - std::string message( "GoldenDict has crashed with an unexpected exception\n\n" ); - - int status; - char * function = 0; - size_t functionLength = 0; - -#ifdef _MSC_VER - std::type_info * ti = 0; -#else - std::type_info * ti = __cxxabiv1::__cxa_current_exception_type(); -#endif - - if ( ti ) - { - char const * name = ti->name(); - -#ifdef _MSC_VER - char * ret = 0; - // avoid 'unused' warnings - (void) status; - (void) functionLength; -#else - char * ret = abi::__cxa_demangle( name, function, &functionLength, &status ); -#endif - - if ( ret ) - { - function = ret; - name = function; - } - - message += "Exception: "; - message += name; - message += '\n'; - - try - { - throw; - } - catch( std::exception & e ) - { - message += "Message: "; - - message += e.what(); - - message += '\n'; - } - catch( ... ) - { - } - } - else - { - message += "terminate() called without active exception\n"; - } - -#ifndef __WIN32 - - message += "\nBacktrace:\n"; - - const size_t maxDepth = 200; - size_t stackDepth; - void * stackAddrs[ maxDepth ]; - char ** stackStrings; - - stackDepth = backtrace( stackAddrs, maxDepth ); - stackStrings = backtrace_symbols( stackAddrs, stackDepth ); - - for (size_t i = 1; i < stackDepth; i++) - { - char * begin = 0, * end = 0; - - for (char *j = stackStrings[i]; *j; ++j) - { - if (*j == '(') - begin = j + 1; - else if ( begin && ( *j == '+' || *j == ')' ) ) - { - end = j; - break; - } - } - - string line; - - if ( end ) - { - char endSymbol = *end; - - *end = 0; - - char * ret = abi::__cxa_demangle( begin, function, &functionLength, &status ); - - *end = endSymbol; - - if ( ret ) - { - function = ret; - - line = string( stackStrings[ i ], begin ); - line += function; - line += string( end ); - } - } - - message += " "; - message += line.size() ? line.c_str() : stackStrings[ i ]; - message += '\n'; - } - -#endif - - QTemporaryFile file; - - if ( file.open() ) - { - file.setAutoRemove( false ); - file.write( message.data(), message.size() ); - - QStringList args; - - args << "--show-error-file"; - args << file.fileName(); - - file.close(); - - QProcess::execute( QCoreApplication::applicationFilePath(), args ); - - abort(); - } + abort(); } void installTerminationHandler() diff --git a/texttospeechsource.ui b/texttospeechsource.ui index 9af0daea..09a4874a 100644 --- a/texttospeechsource.ui +++ b/texttospeechsource.ui @@ -14,19 +14,6 @@ Form - - - - Qt::Vertical - - - - 20 - 17 - - - - @@ -230,19 +217,6 @@ - - - - Qt::Vertical - - - - 20 - 10 - - - - diff --git a/qtsingleapplication/INSTALL.TXT b/thirdparty/qtsingleapplication/INSTALL.TXT similarity index 100% rename from qtsingleapplication/INSTALL.TXT rename to thirdparty/qtsingleapplication/INSTALL.TXT diff --git a/qtsingleapplication/README.TXT b/thirdparty/qtsingleapplication/README.TXT similarity index 100% rename from qtsingleapplication/README.TXT rename to thirdparty/qtsingleapplication/README.TXT diff --git a/qtsingleapplication/source.txt b/thirdparty/qtsingleapplication/source.txt similarity index 100% rename from qtsingleapplication/source.txt rename to thirdparty/qtsingleapplication/source.txt diff --git a/qtsingleapplication/src/QtLockedFile b/thirdparty/qtsingleapplication/src/QtLockedFile similarity index 100% rename from qtsingleapplication/src/QtLockedFile rename to thirdparty/qtsingleapplication/src/QtLockedFile diff --git a/qtsingleapplication/src/QtSingleApplication b/thirdparty/qtsingleapplication/src/QtSingleApplication similarity index 100% rename from qtsingleapplication/src/QtSingleApplication rename to thirdparty/qtsingleapplication/src/QtSingleApplication diff --git a/qtsingleapplication/src/qtlocalpeer.cpp b/thirdparty/qtsingleapplication/src/qtlocalpeer.cpp similarity index 98% rename from qtsingleapplication/src/qtlocalpeer.cpp rename to thirdparty/qtsingleapplication/src/qtlocalpeer.cpp index 8c277fb7..5633bfed 100644 --- a/qtsingleapplication/src/qtlocalpeer.cpp +++ b/thirdparty/qtsingleapplication/src/qtlocalpeer.cpp @@ -56,6 +56,8 @@ static PProcessIdToSessionId pProcessIdToSessionId = 0; #include #endif +#include + namespace QtLP_Private { #include "qtlockedfile.cpp" #if defined(Q_OS_WIN) @@ -78,7 +80,7 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) #endif prefix = id.section(QLatin1Char('/'), -1); } - prefix.remove(QRegExp("[^a-zA-Z]")); + prefix.remove(QRegularExpression("[^a-zA-Z]")); prefix.truncate(6); QByteArray idc = id.toUtf8(); @@ -108,8 +110,6 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId) lockFile.open(QIODevice::ReadWrite); } - - bool QtLocalPeer::isClient() { if (lockFile.isLocked()) @@ -132,7 +132,6 @@ bool QtLocalPeer::isClient() return false; } - bool QtLocalPeer::sendMessage(const QString &message, int timeout) { if (!isClient()) @@ -169,7 +168,6 @@ bool QtLocalPeer::sendMessage(const QString &message, int timeout) return res; } - void QtLocalPeer::receiveConnection() { QLocalSocket* socket = server->nextPendingConnection(); diff --git a/qtsingleapplication/src/qtlocalpeer.h b/thirdparty/qtsingleapplication/src/qtlocalpeer.h similarity index 100% rename from qtsingleapplication/src/qtlocalpeer.h rename to thirdparty/qtsingleapplication/src/qtlocalpeer.h diff --git a/qtsingleapplication/src/qtlockedfile.cpp b/thirdparty/qtsingleapplication/src/qtlockedfile.cpp similarity index 100% rename from qtsingleapplication/src/qtlockedfile.cpp rename to thirdparty/qtsingleapplication/src/qtlockedfile.cpp diff --git a/qtsingleapplication/src/qtlockedfile.h b/thirdparty/qtsingleapplication/src/qtlockedfile.h similarity index 100% rename from qtsingleapplication/src/qtlockedfile.h rename to thirdparty/qtsingleapplication/src/qtlockedfile.h diff --git a/qtsingleapplication/src/qtlockedfile_unix.cpp b/thirdparty/qtsingleapplication/src/qtlockedfile_unix.cpp similarity index 100% rename from qtsingleapplication/src/qtlockedfile_unix.cpp rename to thirdparty/qtsingleapplication/src/qtlockedfile_unix.cpp diff --git a/qtsingleapplication/src/qtlockedfile_win.cpp b/thirdparty/qtsingleapplication/src/qtlockedfile_win.cpp similarity index 100% rename from qtsingleapplication/src/qtlockedfile_win.cpp rename to thirdparty/qtsingleapplication/src/qtlockedfile_win.cpp diff --git a/qtsingleapplication/src/qtsingleapplication.cpp b/thirdparty/qtsingleapplication/src/qtsingleapplication.cpp similarity index 100% rename from qtsingleapplication/src/qtsingleapplication.cpp rename to thirdparty/qtsingleapplication/src/qtsingleapplication.cpp diff --git a/qtsingleapplication/src/qtsingleapplication.h b/thirdparty/qtsingleapplication/src/qtsingleapplication.h similarity index 100% rename from qtsingleapplication/src/qtsingleapplication.h rename to thirdparty/qtsingleapplication/src/qtsingleapplication.h diff --git a/qtsingleapplication/src/qtsingleapplication.pri b/thirdparty/qtsingleapplication/src/qtsingleapplication.pri similarity index 100% rename from qtsingleapplication/src/qtsingleapplication.pri rename to thirdparty/qtsingleapplication/src/qtsingleapplication.pri diff --git a/qtsingleapplication/src/qtsinglecoreapplication.cpp b/thirdparty/qtsingleapplication/src/qtsinglecoreapplication.cpp similarity index 100% rename from qtsingleapplication/src/qtsinglecoreapplication.cpp rename to thirdparty/qtsingleapplication/src/qtsinglecoreapplication.cpp diff --git a/qtsingleapplication/src/qtsinglecoreapplication.h b/thirdparty/qtsingleapplication/src/qtsinglecoreapplication.h similarity index 100% rename from qtsingleapplication/src/qtsinglecoreapplication.h rename to thirdparty/qtsingleapplication/src/qtsinglecoreapplication.h diff --git a/qtsingleapplication/src/qtsinglecoreapplication.pri b/thirdparty/qtsingleapplication/src/qtsinglecoreapplication.pri similarity index 100% rename from qtsingleapplication/src/qtsinglecoreapplication.pri rename to thirdparty/qtsingleapplication/src/qtsinglecoreapplication.pri diff --git a/thirdparty/qwebengine_ts/README.md b/thirdparty/qwebengine_ts/README.md new file mode 100644 index 00000000..fcd9b261 --- /dev/null +++ b/thirdparty/qwebengine_ts/README.md @@ -0,0 +1,7 @@ +qt webengine lacks the translation of chinese . +this file is a compilation of this qwebengine_zh_CN.ts +(https://codereview.qt-project.org/c/qt/qttranslations/+/399180) . + +provided as a temporarily way to support zh_CN. + + diff --git a/thirdparty/qwebengine_ts/qtwebengine_zh_CN.qm b/thirdparty/qwebengine_ts/qtwebengine_zh_CN.qm new file mode 100644 index 00000000..bb2eadc9 Binary files /dev/null and b/thirdparty/qwebengine_ts/qtwebengine_zh_CN.qm differ diff --git a/thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts b/thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts new file mode 100644 index 00000000..dd149bd5 --- /dev/null +++ b/thirdparty/qwebengine_ts/qtwebengine_zh_CN.ts @@ -0,0 +1,467 @@ + + + + + DownloadInterruptReason + + Unknown reason or not interrupted + 未知原因或非中断 + + + General file operation failure + 文件操作失败 + + + The file cannot be written locally, due to access restrictions + 由于访问限制,该文件无法在本地写入 + + + Insufficient space on the target drive + 目标驱动器上的空间不足 + + + The directory or file name is too long + 目录或文件名太长 + + + The file size exceeds the file system limitation + 文件大小超过文件系统限制 + + + The file is infected with a virus + 该文件感染了病毒 + + + Temporary problem (for example file in use, or too many open files) + 临时问题(例如文件正在使用或打开的文件太多) + + + The file was blocked due to local policy + 由于本地政策,该文件被阻止 + + + Checking the safety of the download failed due to unexpected reasons + 由于意外原因,检查下载的安全性失败 + + + File seek past the end of a file (resuming previously interrupted download) + 文件搜索超过文件末尾(恢复先前中断的下载) + + + The partial file did not match the expected hash + 部分文件与预期的哈希不匹配 + + + General network failure + 一般网络故障 + + + The network operation has timed out + 网络操作超时 + + + The network connection has been terminated + 网络连接已终止 + + + The server has gone down + 服务器宕机了 + + + The network request was invalid (for example, the URL or scheme is invalid) + 网络请求无效(例如,URL或scheme无效) + + + General server failure + 一般服务器故障 + + + The server does not have the requested data + 服务器没有请求的数据 + + + The server did not authorize access to the resource + 服务器未授权访问资源 + + + A problem with the server certificate occurred + 服务器证书出现问题 + + + Access forbidden by the server + 服务器禁止访问 + + + Unexpected server response + 意外的服务器响应 + + + Download canceled by the user + 下载被用户取消 + + + + QQuickPdfDocument + + no error + 无错误 + + + data not yet available + 数据不可用 + + + file not found + 文件未找到 + + + invalid file format + 无效文件格式 + + + incorrect password + 密码错误 + + + unsupported security scheme + 不支持的安全方案 + + + unknown error + 未知错误 + + + + QQuickWebEngineView + + Stop + 停止 + + + Reload and Bypass Cache + 重新加载和绕过缓存 + + + Open link in this window + 在当前窗口中打开链接 + + + Toggle Play/Pause + 播放/暂停 + + + Toggle Mute + 静音 + + + Close Page + 关闭页面 + + + Unselect + 取消选择 + + + &Bold + 加粗(&B) + + + &Italic + 斜体(&I) + + + &Underline + 下划线(&U) + + + &Strikethrough + 删除线(&S) + + + Align &Left + 左对齐(&L) + + + Align &Center + 居中(&C) + + + Align &Right + 右对齐(&R) + + + Align &Justified + 对齐(&J) + + + &Indent + 缩进(&I) + + + &Outdent + 突出(&O) + + + Insert &Ordered List + 插入有序列表(&O) + + + Insert &Unordered List + 插入无序列表(&U) + + + + QWebEnginePage + + Stop + 停止 + + + Reload and Bypass Cache + 重新加载和绕过缓存 + + + Toggle Play/Pause + 播放/暂停 + + + Toggle Mute + 静音 + + + Close Page + 关闭页面 + + + Unselect + 取消选择 + + + Are you sure you want to leave this page? Changes that you made may not be saved. + 您确定要离开此页面吗? 您所做的更改不会被保存。 + + + Open link in this window + 在当前窗口中打开链接 + + + Open link in new background tab + 在新的后台选项卡中打开链接 + + + &Bold + 加粗(&B) + + + &Italic + 斜体(&I) + + + &Underline + 下划线(&U) + + + &Strikethrough + 删除线(&S) + + + Align &Left + 左对齐(&L) + + + Align &Center + 居中(&C) + + + Align &Right + 右对齐(&R) + + + Align &Justified + 对齐(&J) + + + &Indent + 缩进(&I) + + + &Outdent + 突出(&O) + + + Insert &Ordered List + 插入有序列表(&O) + + + Insert &Unordered List + 插入无序列表(&U) + + + Select folder to upload + 选择要上传的文件夹 + + + + QtWebEnginePlugin + + Cannot create separate instance of WebEngineNewViewRequest + 无法创建 WebEngineNewViewRequest 的单独实例 + + + Cannot create separate instance of %1 + 无法创建 %1 的单独实例 + + + + QtWebEngineTestSupportPlugin + + Cannot create a separate instance of WebEngineErrorPage + 无法创建 WebEngineErrorPage 的单独实例 + + + Cannot create a separate instance of WebEngineTestEvent + 无法创建单独的 WebEngineTestEvent 实例 + + + + RenderViewContextMenuQt + + Back + 后退 + + + Forward + 前进 + + + Reload + 重载 + + + Cut + 剪切 + + + Copy + 复制 + + + Paste + 粘贴 + + + Undo + 撤销 + + + Redo + 恢复 + + + Select all + 全选 + + + Paste and match style + 粘贴并匹配样式 + + + Open link in new window + 在新窗口中打开链接 + + + Open link in new tab + 在新页签中打开链接 + + + Copy link address + 复制链接地址 + + + Save link + 保存链接 + + + Copy image + 复制图片 + + + Copy image address + 复制图片地址 + + + Save image + 保存图片 + + + Copy media address + 复制媒体链接 + + + Show controls + 显示控制 + + + Loop + 循环 + + + Save media + 保存媒体 + + + Inspect + 审核 + + + Exit full screen + 退出全屏 + + + Save page + 保存页面 + + + View page source + 查看页面源代码 + + + + UIDelegatesManager + + Javascript Alert - %1 + Javascript-警告 - %1 + + + Javascript Confirm - %1 + Javascript-确认 - %1 + + + Javascript Prompt - %1 + Javascript-提醒 - %1 + + + Are you sure you want to leave this page? + 您确定要离开当前页面吗? + + + Changes that you made may not be saved. + 您所做的更改不会被保存。 + + + Connect to proxy "%1" using: + 使用以下命令连接到代理“%1”: + + + Enter username and password for "%1" at %2://%3 + 在 %2://%3 输入“%1”的用户名和密码 + + + + WebContentsAdapter + + HTTP-POST data can only be sent over HTTP(S) protocol + HTTP-POST 数据只能通过 HTTP(S) 协议发送 + + + diff --git a/tiff.cc b/tiff.cc index e3cb8bf5..95dd812f 100644 --- a/tiff.cc +++ b/tiff.cc @@ -5,7 +5,7 @@ #include "tiff.hh" -#if defined (Q_OS_MAC) || defined (Q_OS_WIN) +#if defined (Q_OS_WIN) #include "tiff/tiff.h" #include "tiff/tiffio.h" #else diff --git a/generators/CaseFolding.txt b/tools/generators/CaseFolding.txt similarity index 100% rename from generators/CaseFolding.txt rename to tools/generators/CaseFolding.txt diff --git a/generators/DiacriticFolding.txt b/tools/generators/DiacriticFolding.txt similarity index 100% rename from generators/DiacriticFolding.txt rename to tools/generators/DiacriticFolding.txt diff --git a/generators/generate.cc b/tools/generators/generate.cc similarity index 100% rename from generators/generate.cc rename to tools/generators/generate.cc diff --git a/generators/make_flags_qrc.sh b/tools/generators/make_flags_qrc.sh similarity index 100% rename from generators/make_flags_qrc.sh rename to tools/generators/make_flags_qrc.sh diff --git a/generators/readme.txt b/tools/generators/readme.txt similarity index 100% rename from generators/readme.txt rename to tools/generators/readme.txt diff --git a/nsis/GoldenDict-EnRuEn.nsi b/tools/nsis/GoldenDict-EnRuEn.nsi similarity index 100% rename from nsis/GoldenDict-EnRuEn.nsi rename to tools/nsis/GoldenDict-EnRuEn.nsi diff --git a/nsis/GoldenDict.nsi b/tools/nsis/GoldenDict.nsi similarity index 100% rename from nsis/GoldenDict.nsi rename to tools/nsis/GoldenDict.nsi diff --git a/nsis/gen_uninstall/gen_uninstall.cc b/tools/nsis/gen_uninstall/gen_uninstall.cc similarity index 100% rename from nsis/gen_uninstall/gen_uninstall.cc rename to tools/nsis/gen_uninstall/gen_uninstall.cc diff --git a/nsis/gen_uninstall/gen_uninstall.exe.manifest b/tools/nsis/gen_uninstall/gen_uninstall.exe.manifest similarity index 100% rename from nsis/gen_uninstall/gen_uninstall.exe.manifest rename to tools/nsis/gen_uninstall/gen_uninstall.exe.manifest diff --git a/nsis/gen_uninstall/gen_uninstall.pro b/tools/nsis/gen_uninstall/gen_uninstall.pro similarity index 100% rename from nsis/gen_uninstall/gen_uninstall.pro rename to tools/nsis/gen_uninstall/gen_uninstall.pro diff --git a/nsis/gen_uninstall/gen_uninstall.rc b/tools/nsis/gen_uninstall/gen_uninstall.rc similarity index 100% rename from nsis/gen_uninstall/gen_uninstall.rc rename to tools/nsis/gen_uninstall/gen_uninstall.rc diff --git a/nsis/makensis.sh b/tools/nsis/makensis.sh similarity index 100% rename from nsis/makensis.sh rename to tools/nsis/makensis.sh diff --git a/translatebox.cc b/translatebox.cc index 67944754..531fb8d6 100644 --- a/translatebox.cc +++ b/translatebox.cc @@ -51,7 +51,13 @@ bool CompletionList::eventFilter( QObject * obj, QEvent * ev ) int CompletionList::preferredHeight() const { - const QSize itemSizeHint = itemDelegate()->sizeHint(viewOptions(), model()->index( 0, 0 ) ); +#if( QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 ) ) + const QSize itemSizeHint = itemDelegate()->sizeHint( viewOptions(), model()->index( 0, 0 ) ); +#else + QStyleOptionViewItem option; + initViewItemOption( &option ); + const QSize itemSizeHint = itemDelegate()->sizeHint(option, model()->index( 0, 0 ) ); +#endif int rows = qMin( count(), MAX_POPUP_ROWS ); int scrollBarHeight = 0; @@ -107,7 +113,7 @@ TranslateBox::TranslateBox(QWidget *parent) : QWidget(parent), QHBoxLayout *layout = new QHBoxLayout(this); setLayout(layout); - layout->setMargin(0); + layout->setContentsMargins(0,0,0,0); layout->addWidget(translate_line); QPixmap image(":/icons/system-search.svg"); diff --git a/transliteration.cc b/transliteration.cc index cee4a230..aefc13fd 100644 --- a/transliteration.cc +++ b/transliteration.cc @@ -35,17 +35,17 @@ unsigned long BaseTransliterationDictionary::getWordCount() throw() { return 0; } sptr< Dictionary::WordSearchRequest > BaseTransliterationDictionary::prefixMatch( wstring const &, - unsigned long ) THROW_SPEC( std::exception ) + unsigned long ) { return new Dictionary::WordSearchRequestInstant(); } sptr< Dictionary::DataRequest > BaseTransliterationDictionary::getArticle( wstring const &, vector< wstring > const &, wstring const &, bool ) - THROW_SPEC( std::exception ) + { return new Dictionary::DataRequestInstant( false ); } sptr< Dictionary::WordSearchRequest > BaseTransliterationDictionary::findHeadwordsForSynonym( wstring const & str ) - THROW_SPEC( std::exception ) + { sptr< Dictionary::WordSearchRequestInstant > result = new Dictionary::WordSearchRequestInstant(); diff --git a/transliteration.hh b/transliteration.hh index e2ff40cf..d6d96198 100644 --- a/transliteration.hh +++ b/transliteration.hh @@ -40,15 +40,15 @@ public: throw() = 0; virtual sptr< Dictionary::WordSearchRequest > findHeadwordsForSynonym( wstring const & ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::WordSearchRequest > prefixMatch( wstring const &, - unsigned long ) THROW_SPEC( std::exception ); + unsigned long ) ; virtual sptr< Dictionary::DataRequest > getArticle( wstring const &, vector< wstring > const &, wstring const &, bool ) - THROW_SPEC( std::exception ); + ; }; diff --git a/utf8.cc b/utf8.cc index ee5dd1f6..91618f92 100644 --- a/utf8.cc +++ b/utf8.cc @@ -143,7 +143,7 @@ string encode( wstring const & in ) throw() encode( in.data(), in.size(), &buffer.front() ) ); } -wstring decode( string const & in ) THROW_SPEC( exCantDecode ) +wstring decode( string const & in ) { if ( in.size() == 0 ) diff --git a/utf8.hh b/utf8.hh index ef1bc08f..ce636276 100644 --- a/utf8.hh +++ b/utf8.hh @@ -5,7 +5,6 @@ #include #include -#include "cpp_features.hh" #include "ex.hh" #include "wstring.hh" @@ -46,7 +45,7 @@ long decode( char const * in, size_t inSize, wchar * out ); /// Versions for non time-critical code. string encode( wstring const & ) throw(); -wstring decode( string const & ) THROW_SPEC( exCantDecode ); +wstring decode( string const & ) ; /// Since the standard isspace() is locale-specific, we need something /// that would never mess up our utf8 input. The stock one worked fine under diff --git a/utils.hh b/utils.hh index b577746a..54bb4d00 100644 --- a/utils.hh +++ b/utils.hh @@ -60,7 +60,6 @@ inline int loadAcquire( QAtomicInt const & ref ) namespace Url { - // This wrapper is created due to behavior change of the setPath() method // See: https://bugreports.qt-project.org/browse/QTBUG-27728 // https://codereview.qt-project.org/#change,38257 @@ -123,6 +122,28 @@ inline QString fragment( const QUrl & url ) return url.fragment( QUrl::FullyDecoded ); } +// extract query word from url +inline QString getWordFromUrl( const QUrl & url ) +{ + QString word; + if( url.scheme().compare( "bword" ) == 0 ) + { + word = url.path(); + } + else if( url.scheme() == "gdlookup" ) // Plain html links inherit gdlookup scheme + { + if( hasQueryItem( url, "word" ) ) + { + word = queryItemValue( url, "word" ); + } + else + { + word = url.path().mid( 1 ); + } + } + + return word; +} } namespace Dom diff --git a/voiceengines.cc b/voiceengines.cc index 49dfbaea..6367a177 100644 --- a/voiceengines.cc +++ b/voiceengines.cc @@ -58,12 +58,12 @@ public: virtual sptr< WordSearchRequest > prefixMatch( wstring const & word, unsigned long maxResults ) - THROW_SPEC( std::exception ); + ; virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const &, bool ) - THROW_SPEC( std::exception ); + ; protected: @@ -72,7 +72,7 @@ protected: sptr< WordSearchRequest > VoiceEnginesDictionary::prefixMatch( wstring const & /*word*/, unsigned long /*maxResults*/ ) - THROW_SPEC( std::exception ) + { WordSearchRequestInstant * sr = new WordSearchRequestInstant(); sr->setUncertain( true ); @@ -81,7 +81,7 @@ sptr< WordSearchRequest > VoiceEnginesDictionary::prefixMatch( wstring const & / sptr< Dictionary::DataRequest > VoiceEnginesDictionary::getArticle( wstring const & word, vector< wstring > const &, wstring const &, bool ) - THROW_SPEC( std::exception ) + { string result; string wordUtf8( Utf8::encode( word ) ); @@ -128,7 +128,7 @@ void VoiceEnginesDictionary::loadIcon() throw() vector< sptr< Dictionary::Class > > makeDictionaries( Config::VoiceEngines const & voiceEngines ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > result; diff --git a/voiceengines.hh b/voiceengines.hh index 85dadb37..e3d94acb 100644 --- a/voiceengines.hh +++ b/voiceengines.hh @@ -18,7 +18,7 @@ using std::string; using gd::wstring; vector< sptr< Dictionary::Class > > makeDictionaries(Config::VoiceEngines const & voiceEngines) - THROW_SPEC( std::exception ); + ; } diff --git a/website.cc b/website.cc index 5167c55f..0a766969 100644 --- a/website.cc +++ b/website.cc @@ -56,14 +56,14 @@ public: { return 0; } virtual sptr< WordSearchRequest > prefixMatch( wstring const & word, - unsigned long ) THROW_SPEC( std::exception ); + unsigned long ) ; virtual sptr< DataRequest > getArticle( wstring const &, vector< wstring > const & alts, wstring const & context, bool ) - THROW_SPEC( std::exception ); + ; - virtual sptr< Dictionary::DataRequest > getResource( string const & name ) THROW_SPEC( std::exception ); + virtual sptr< Dictionary::DataRequest > getResource( string const & name ) ; void isolateWebCSS( QString & css ); @@ -73,7 +73,7 @@ protected: }; sptr< WordSearchRequest > WebSiteDictionary::prefixMatch( wstring const & /*word*/, - unsigned long ) THROW_SPEC( std::exception ) + unsigned long ) { sptr< WordSearchRequestInstant > sr = new WordSearchRequestInstant; @@ -195,7 +195,7 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r ) while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewString += articleString.midRef( pos, match.capturedStart() - pos ); + articleNewString += articleString.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString tag = match.captured(); @@ -233,7 +233,7 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r ) } if( pos ) { - articleNewString += articleString.midRef( pos ); + articleNewString += articleString.mid( pos ); articleString = articleNewString; articleNewString.clear(); } @@ -245,10 +245,11 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r ) QRegularExpression::CaseInsensitiveOption ); pos = 0; it = linkTags.globalMatch( articleString ); + while( it.hasNext() ) { QRegularExpressionMatch match = it.next(); - articleNewString += articleString.midRef( pos, match.capturedStart() - pos ); + articleNewString += articleString.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QString newTag = match.captured( 1 ) + prefix + match.captured( 2 ) @@ -257,29 +258,11 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r ) } if( pos ) { - articleNewString += articleString.midRef( pos ); + articleNewString += articleString.mid( pos ); articleString = articleNewString; articleNewString.clear(); } - // Check for unclosed and
- - int openTags = articleString.count( QRegExp( "<\\s*span\\b", Qt::CaseInsensitive ) ); - int closedTags = articleString.count( QRegExp( "<\\s*/span\\s*>", Qt::CaseInsensitive ) ); - while( openTags > closedTags ) - { - articleString += ""; - closedTags += 1; - } - - openTags = articleString.count( QRegExp( "<\\s*div\\b", Qt::CaseInsensitive ) ); - closedTags = articleString.count( QRegExp( "<\\s*/div\\s*>", Qt::CaseInsensitive ) ); - while( openTags > closedTags ) - { - articleString += "
"; - closedTags += 1; - } - // See Issue #271: A mechanism to clean-up invalid HTML cards. // leave the invalid tags at the mercy of modern browsers.(webengine chrome) // https://html.spec.whatwg.org/#an-introduction-to-error-handling-and-strange-cases-in-the-parser @@ -328,7 +311,7 @@ void WebSiteArticleRequest::requestFinished( QNetworkReply * r ) sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str, vector< wstring > const &, wstring const & context, bool ) - THROW_SPEC( std::exception ) + { QByteArray urlString; @@ -369,7 +352,7 @@ sptr< DataRequest > WebSiteDictionary::getArticle( wstring const & str, { codec = QTextCodec::codecForName( QString( "ISO 8859-%1" ).arg( x ).toLatin1() ); if( codec ) - urlString.replace( QString( "%25GDISO%1%25" ).arg( x ), codec->fromUnicode( inputWord ).toPercentEncoding() ); + urlString.replace( QString( "%25GDISO%1%25" ).arg( x ).toUtf8(), codec->fromUnicode( inputWord ).toPercentEncoding() ); if ( x == 10 ) x = 12; // Skip encodings 11..12, they don't exist @@ -507,7 +490,7 @@ void WebSiteResourceRequest::requestFinished( QNetworkReply * r ) finish(); } -sptr< Dictionary::DataRequest > WebSiteDictionary::getResource( string const & name ) THROW_SPEC( std::exception ) +sptr< Dictionary::DataRequest > WebSiteDictionary::getResource( string const & name ) { QString link = QString::fromUtf8( name.c_str() ); int pos = link.indexOf( '/' ); @@ -536,7 +519,7 @@ void WebSiteDictionary::loadIcon() throw() vector< sptr< Dictionary::Class > > makeDictionaries( Config::WebSites const & ws, QNetworkAccessManager & mgr ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > result; diff --git a/website.hh b/website.hh index 43bf7885..9fb570e0 100644 --- a/website.hh +++ b/website.hh @@ -17,7 +17,7 @@ using std::string; vector< sptr< Dictionary::Class > > makeDictionaries( Config::WebSites const &, QNetworkAccessManager & ) - THROW_SPEC( std::exception ); + ; /// Exposed here for moc class WebSiteDataRequestSlots: public Dictionary::DataRequest diff --git a/winlibs/include/iconv.h b/winlibs/include/iconv.h deleted file mode 100644 index fa3b9f2a..00000000 --- a/winlibs/include/iconv.h +++ /dev/null @@ -1,247 +0,0 @@ -/* Copyright (C) 1999-2003, 2005-2006, 2008-2011 Free Software Foundation, Inc. - This file is part of the GNU LIBICONV Library. - - The GNU LIBICONV Library is free software; you can redistribute it - and/or modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - The GNU LIBICONV Library is distributed in the hope that it will be - useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the GNU LIBICONV Library; see the file COPYING.LIB. - If not, see . */ - -/* When installed, this file is called "iconv.h". */ - -#ifndef _LIBICONV_H -#define _LIBICONV_H - -#define _LIBICONV_VERSION 0x010F /* version number: (major<<8) + minor */ - -#if 1 && BUILDING_LIBICONV -#define LIBICONV_DLL_EXPORTED __attribute__((__visibility__("default"))) -#else -#define LIBICONV_DLL_EXPORTED -#endif -extern LIBICONV_DLL_EXPORTED __declspec (dllimport) int _libiconv_version; /* Likewise */ - -/* We would like to #include any system header file which could define - iconv_t, 1. in order to eliminate the risk that the user gets compilation - errors because some other system header file includes /usr/include/iconv.h - which defines iconv_t or declares iconv after this file, 2. when compiling - for LIBICONV_PLUG, we need the proper iconv_t type in order to produce - binary compatible code. - But gcc's #include_next is not portable. Thus, once libiconv's iconv.h - has been installed in /usr/local/include, there is no way any more to - include the original /usr/include/iconv.h. We simply have to get away - without it. - Ad 1. The risk that a system header file does - #include "iconv.h" or #include_next "iconv.h" - is small. They all do #include . - Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It - has to be a scalar type because (iconv_t)(-1) is a possible return value - from iconv_open().) */ - -/* Define iconv_t ourselves. */ -#undef iconv_t -#define iconv_t libiconv_t -typedef void* iconv_t; - -/* Get size_t declaration. - Get wchar_t declaration if it exists. */ -#include - -/* Get errno declaration and values. */ -#include -/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS, - have EILSEQ in a different header. On these systems, define EILSEQ - ourselves. */ -#ifndef EILSEQ -#define EILSEQ -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - - -/* Allocates descriptor for code conversion from encoding ‘fromcode’ to - encoding ‘tocode’. */ -#ifndef LIBICONV_PLUG -#define iconv_open libiconv_open -#endif -extern LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode); - -/* Converts, using conversion descriptor ‘cd’, at most ‘*inbytesleft’ bytes - starting at ‘*inbuf’, writing at most ‘*outbytesleft’ bytes starting at - ‘*outbuf’. - Decrements ‘*inbytesleft’ and increments ‘*inbuf’ by the same amount. - Decrements ‘*outbytesleft’ and increments ‘*outbuf’ by the same amount. */ -#ifndef LIBICONV_PLUG -#define iconv libiconv -#endif -extern LIBICONV_DLL_EXPORTED size_t iconv (iconv_t cd, char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft); - -/* Frees resources allocated for conversion descriptor ‘cd’. */ -#ifndef LIBICONV_PLUG -#define iconv_close libiconv_close -#endif -extern LIBICONV_DLL_EXPORTED int iconv_close (iconv_t cd); - - -#ifdef __cplusplus -} -#endif - - -#ifndef LIBICONV_PLUG - -/* Nonstandard extensions. */ - -#if 1 -#if 0 -/* Tru64 with Desktop Toolkit C has a bug: must be included before - . - BSD/OS 4.0.1 has a bug: , and must be - included before . */ -#include -#include -#include -#endif -#include -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* A type that holds all memory needed by a conversion descriptor. - A pointer to such an object can be used as an iconv_t. */ -typedef struct { - void* dummy1[28]; -#if 1 - mbstate_t dummy2; -#endif -} iconv_allocation_t; - -/* Allocates descriptor for code conversion from encoding ‘fromcode’ to - encoding ‘tocode’ into preallocated memory. Returns an error indicator - (0 or -1 with errno set). */ -#define iconv_open_into libiconv_open_into -extern LIBICONV_DLL_EXPORTED int iconv_open_into (const char* tocode, const char* fromcode, - iconv_allocation_t* resultp); - -/* Control of attributes. */ -#define iconvctl libiconvctl -extern LIBICONV_DLL_EXPORTED int iconvctl (iconv_t cd, int request, void* argument); - -/* Hook performed after every successful conversion of a Unicode character. */ -typedef void (*iconv_unicode_char_hook) (unsigned int uc, void* data); -/* Hook performed after every successful conversion of a wide character. */ -typedef void (*iconv_wide_char_hook) (wchar_t wc, void* data); -/* Set of hooks. */ -struct iconv_hooks { - iconv_unicode_char_hook uc_hook; - iconv_wide_char_hook wc_hook; - void* data; -}; - -/* Fallback function. Invoked when a small number of bytes could not be - converted to a Unicode character. This function should process all - bytes from inbuf and may produce replacement Unicode characters by calling - the write_replacement callback repeatedly. */ -typedef void (*iconv_unicode_mb_to_uc_fallback) - (const char* inbuf, size_t inbufsize, - void (*write_replacement) (const unsigned int *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -/* Fallback function. Invoked when a Unicode character could not be converted - to the target encoding. This function should process the character and - may produce replacement bytes (in the target encoding) by calling the - write_replacement callback repeatedly. */ -typedef void (*iconv_unicode_uc_to_mb_fallback) - (unsigned int code, - void (*write_replacement) (const char *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -#if 1 -/* Fallback function. Invoked when a number of bytes could not be converted to - a wide character. This function should process all bytes from inbuf and may - produce replacement wide characters by calling the write_replacement - callback repeatedly. */ -typedef void (*iconv_wchar_mb_to_wc_fallback) - (const char* inbuf, size_t inbufsize, - void (*write_replacement) (const wchar_t *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -/* Fallback function. Invoked when a wide character could not be converted to - the target encoding. This function should process the character and may - produce replacement bytes (in the target encoding) by calling the - write_replacement callback repeatedly. */ -typedef void (*iconv_wchar_wc_to_mb_fallback) - (wchar_t code, - void (*write_replacement) (const char *buf, size_t buflen, - void* callback_arg), - void* callback_arg, - void* data); -#else -/* If the wchar_t type does not exist, these two fallback functions are never - invoked. Their argument list therefore does not matter. */ -typedef void (*iconv_wchar_mb_to_wc_fallback) (); -typedef void (*iconv_wchar_wc_to_mb_fallback) (); -#endif -/* Set of fallbacks. */ -struct iconv_fallbacks { - iconv_unicode_mb_to_uc_fallback mb_to_uc_fallback; - iconv_unicode_uc_to_mb_fallback uc_to_mb_fallback; - iconv_wchar_mb_to_wc_fallback mb_to_wc_fallback; - iconv_wchar_wc_to_mb_fallback wc_to_mb_fallback; - void* data; -}; - -/* Requests for iconvctl. */ -#define ICONV_TRIVIALP 0 /* int *argument */ -#define ICONV_GET_TRANSLITERATE 1 /* int *argument */ -#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */ -#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */ -#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */ -#define ICONV_SET_HOOKS 5 /* const struct iconv_hooks *argument */ -#define ICONV_SET_FALLBACKS 6 /* const struct iconv_fallbacks *argument */ - -/* Listing of locale independent encodings. */ -#define iconvlist libiconvlist -extern LIBICONV_DLL_EXPORTED void iconvlist (int (*do_one) (unsigned int namescount, - const char * const * names, - void* data), - void* data); - -/* Canonicalize an encoding name. - The result is either a canonical encoding name, or name itself. */ -extern LIBICONV_DLL_EXPORTED const char * iconv_canonicalize (const char * name); - -/* Support for relocatable packages. */ - -/* Sets the original and the current installation prefix of the package. - Relocation simply replaces a pathname starting with the original prefix - by the corresponding pathname with the current prefix instead. Both - prefixes should be directory names without trailing slash (i.e. use "" - instead of "/"). */ -extern LIBICONV_DLL_EXPORTED void libiconv_set_relocation_prefix (const char *orig_prefix, - const char *curr_prefix); - -#ifdef __cplusplus -} -#endif - -#endif - - -#endif /* _LIBICONV_H */ diff --git a/maclibs/include/libavutil/macros.h b/winlibs/include/libavcodec/ac3_parser.h similarity index 62% rename from maclibs/include/libavutil/macros.h rename to winlibs/include/libavcodec/ac3_parser.h index 2007ee56..ff8cc4cf 100644 --- a/maclibs/include/libavutil/macros.h +++ b/winlibs/include/libavcodec/ac3_parser.h @@ -1,4 +1,8 @@ /* + * AC-3 parser prototypes + * Copyright (c) 2003 Fabrice Bellard + * Copyright (c) 2003 Michael Niedermayer + * * This file is part of FFmpeg. * * FFmpeg is free software; you can redistribute it and/or @@ -16,35 +20,17 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/** - * @file - * @ingroup lavu - * Utility Preprocessor macros - */ +#ifndef AVCODEC_AC3_PARSER_H +#define AVCODEC_AC3_PARSER_H -#ifndef AVUTIL_MACROS_H -#define AVUTIL_MACROS_H +#include +#include /** - * @addtogroup preproc_misc Preprocessor String Macros - * - * String manipulation macros - * - * @{ + * Extract the bitstream ID and the frame size from AC-3 data. */ +int av_ac3_parse_header(const uint8_t *buf, size_t size, + uint8_t *bitstream_id, uint16_t *frame_size); -#define AV_STRINGIFY(s) AV_TOSTRING(s) -#define AV_TOSTRING(s) #s -#define AV_GLUE(a, b) a ## b -#define AV_JOIN(a, b) AV_GLUE(a, b) - -/** - * @} - */ - -#define AV_PRAGMA(s) _Pragma(#s) - -#define FFALIGN(x, a) (((x)+(a)-1)&~((a)-1)) - -#endif /* AVUTIL_MACROS_H */ +#endif /* AVCODEC_AC3_PARSER_H */ diff --git a/winlibs/include/libavcodec/adts_parser.h b/winlibs/include/libavcodec/adts_parser.h new file mode 100644 index 00000000..f85becd1 --- /dev/null +++ b/winlibs/include/libavcodec/adts_parser.h @@ -0,0 +1,37 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_ADTS_PARSER_H +#define AVCODEC_ADTS_PARSER_H + +#include +#include + +#define AV_AAC_ADTS_HEADER_SIZE 7 + +/** + * Extract the number of samples and frames from AAC data. + * @param[in] buf pointer to AAC data buffer + * @param[out] samples Pointer to where number of samples is written + * @param[out] frames Pointer to where number of frames is written + * @return Returns 0 on success, error code on failure. + */ +int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, + uint8_t *frames); + +#endif /* AVCODEC_ADTS_PARSER_H */ diff --git a/winlibs/include/libavcodec/avcodec.h b/winlibs/include/libavcodec/avcodec.h index d234271c..8a71c042 100644 --- a/winlibs/include/libavcodec/avcodec.h +++ b/winlibs/include/libavcodec/avcodec.h @@ -41,6 +41,12 @@ #include "libavutil/pixfmt.h" #include "libavutil/rational.h" +#include "bsf.h" +#include "codec.h" +#include "codec_desc.h" +#include "codec_par.h" +#include "codec_id.h" +#include "packet.h" #include "version.h" /** @@ -92,6 +98,7 @@ * compressed data in an AVPacket. * - For encoding, call avcodec_send_frame() to give the encoder an AVFrame * containing uncompressed audio or video. + * * In both cases, it is recommended that AVPackets and AVFrames are * refcounted, or libavcodec might have to copy the input data. (libavformat * always returns refcounted AVPackets, and av_frame_get_buffer() allocates @@ -102,6 +109,7 @@ * an AVFrame containing uncompressed audio or video data. * - For encoding, call avcodec_receive_packet(). On success, it will return * an AVPacket with a compressed frame. + * * Repeat this call until it returns AVERROR(EAGAIN) or an error. The * AVERROR(EAGAIN) return value means that new input data is required to * return new output. In this case, continue with sending input. For each @@ -196,589 +204,6 @@ * @{ */ - -/** - * Identify the syntax and semantics of the bitstream. - * The principle is roughly: - * Two decoders with the same ID can decode the same streams. - * Two encoders with the same ID can encode compatible streams. - * There may be slight deviations from the principle due to implementation - * details. - * - * If you add a codec ID to this list, add it so that - * 1. no value of an existing codec ID changes (that would break ABI), - * 2. it is as close as possible to similar codecs - * - * After adding new codec IDs, do not forget to add an entry to the codec - * descriptor list and bump libavcodec minor version. - */ -enum AVCodecID { - AV_CODEC_ID_NONE, - - /* video codecs */ - AV_CODEC_ID_MPEG1VIDEO, - AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding - AV_CODEC_ID_H261, - AV_CODEC_ID_H263, - AV_CODEC_ID_RV10, - AV_CODEC_ID_RV20, - AV_CODEC_ID_MJPEG, - AV_CODEC_ID_MJPEGB, - AV_CODEC_ID_LJPEG, - AV_CODEC_ID_SP5X, - AV_CODEC_ID_JPEGLS, - AV_CODEC_ID_MPEG4, - AV_CODEC_ID_RAWVIDEO, - AV_CODEC_ID_MSMPEG4V1, - AV_CODEC_ID_MSMPEG4V2, - AV_CODEC_ID_MSMPEG4V3, - AV_CODEC_ID_WMV1, - AV_CODEC_ID_WMV2, - AV_CODEC_ID_H263P, - AV_CODEC_ID_H263I, - AV_CODEC_ID_FLV1, - AV_CODEC_ID_SVQ1, - AV_CODEC_ID_SVQ3, - AV_CODEC_ID_DVVIDEO, - AV_CODEC_ID_HUFFYUV, - AV_CODEC_ID_CYUV, - AV_CODEC_ID_H264, - AV_CODEC_ID_INDEO3, - AV_CODEC_ID_VP3, - AV_CODEC_ID_THEORA, - AV_CODEC_ID_ASV1, - AV_CODEC_ID_ASV2, - AV_CODEC_ID_FFV1, - AV_CODEC_ID_4XM, - AV_CODEC_ID_VCR1, - AV_CODEC_ID_CLJR, - AV_CODEC_ID_MDEC, - AV_CODEC_ID_ROQ, - AV_CODEC_ID_INTERPLAY_VIDEO, - AV_CODEC_ID_XAN_WC3, - AV_CODEC_ID_XAN_WC4, - AV_CODEC_ID_RPZA, - AV_CODEC_ID_CINEPAK, - AV_CODEC_ID_WS_VQA, - AV_CODEC_ID_MSRLE, - AV_CODEC_ID_MSVIDEO1, - AV_CODEC_ID_IDCIN, - AV_CODEC_ID_8BPS, - AV_CODEC_ID_SMC, - AV_CODEC_ID_FLIC, - AV_CODEC_ID_TRUEMOTION1, - AV_CODEC_ID_VMDVIDEO, - AV_CODEC_ID_MSZH, - AV_CODEC_ID_ZLIB, - AV_CODEC_ID_QTRLE, - AV_CODEC_ID_TSCC, - AV_CODEC_ID_ULTI, - AV_CODEC_ID_QDRAW, - AV_CODEC_ID_VIXL, - AV_CODEC_ID_QPEG, - AV_CODEC_ID_PNG, - AV_CODEC_ID_PPM, - AV_CODEC_ID_PBM, - AV_CODEC_ID_PGM, - AV_CODEC_ID_PGMYUV, - AV_CODEC_ID_PAM, - AV_CODEC_ID_FFVHUFF, - AV_CODEC_ID_RV30, - AV_CODEC_ID_RV40, - AV_CODEC_ID_VC1, - AV_CODEC_ID_WMV3, - AV_CODEC_ID_LOCO, - AV_CODEC_ID_WNV1, - AV_CODEC_ID_AASC, - AV_CODEC_ID_INDEO2, - AV_CODEC_ID_FRAPS, - AV_CODEC_ID_TRUEMOTION2, - AV_CODEC_ID_BMP, - AV_CODEC_ID_CSCD, - AV_CODEC_ID_MMVIDEO, - AV_CODEC_ID_ZMBV, - AV_CODEC_ID_AVS, - AV_CODEC_ID_SMACKVIDEO, - AV_CODEC_ID_NUV, - AV_CODEC_ID_KMVC, - AV_CODEC_ID_FLASHSV, - AV_CODEC_ID_CAVS, - AV_CODEC_ID_JPEG2000, - AV_CODEC_ID_VMNC, - AV_CODEC_ID_VP5, - AV_CODEC_ID_VP6, - AV_CODEC_ID_VP6F, - AV_CODEC_ID_TARGA, - AV_CODEC_ID_DSICINVIDEO, - AV_CODEC_ID_TIERTEXSEQVIDEO, - AV_CODEC_ID_TIFF, - AV_CODEC_ID_GIF, - AV_CODEC_ID_DXA, - AV_CODEC_ID_DNXHD, - AV_CODEC_ID_THP, - AV_CODEC_ID_SGI, - AV_CODEC_ID_C93, - AV_CODEC_ID_BETHSOFTVID, - AV_CODEC_ID_PTX, - AV_CODEC_ID_TXD, - AV_CODEC_ID_VP6A, - AV_CODEC_ID_AMV, - AV_CODEC_ID_VB, - AV_CODEC_ID_PCX, - AV_CODEC_ID_SUNRAST, - AV_CODEC_ID_INDEO4, - AV_CODEC_ID_INDEO5, - AV_CODEC_ID_MIMIC, - AV_CODEC_ID_RL2, - AV_CODEC_ID_ESCAPE124, - AV_CODEC_ID_DIRAC, - AV_CODEC_ID_BFI, - AV_CODEC_ID_CMV, - AV_CODEC_ID_MOTIONPIXELS, - AV_CODEC_ID_TGV, - AV_CODEC_ID_TGQ, - AV_CODEC_ID_TQI, - AV_CODEC_ID_AURA, - AV_CODEC_ID_AURA2, - AV_CODEC_ID_V210X, - AV_CODEC_ID_TMV, - AV_CODEC_ID_V210, - AV_CODEC_ID_DPX, - AV_CODEC_ID_MAD, - AV_CODEC_ID_FRWU, - AV_CODEC_ID_FLASHSV2, - AV_CODEC_ID_CDGRAPHICS, - AV_CODEC_ID_R210, - AV_CODEC_ID_ANM, - AV_CODEC_ID_BINKVIDEO, - AV_CODEC_ID_IFF_ILBM, -#define AV_CODEC_ID_IFF_BYTERUN1 AV_CODEC_ID_IFF_ILBM - AV_CODEC_ID_KGV1, - AV_CODEC_ID_YOP, - AV_CODEC_ID_VP8, - AV_CODEC_ID_PICTOR, - AV_CODEC_ID_ANSI, - AV_CODEC_ID_A64_MULTI, - AV_CODEC_ID_A64_MULTI5, - AV_CODEC_ID_R10K, - AV_CODEC_ID_MXPEG, - AV_CODEC_ID_LAGARITH, - AV_CODEC_ID_PRORES, - AV_CODEC_ID_JV, - AV_CODEC_ID_DFA, - AV_CODEC_ID_WMV3IMAGE, - AV_CODEC_ID_VC1IMAGE, - AV_CODEC_ID_UTVIDEO, - AV_CODEC_ID_BMV_VIDEO, - AV_CODEC_ID_VBLE, - AV_CODEC_ID_DXTORY, - AV_CODEC_ID_V410, - AV_CODEC_ID_XWD, - AV_CODEC_ID_CDXL, - AV_CODEC_ID_XBM, - AV_CODEC_ID_ZEROCODEC, - AV_CODEC_ID_MSS1, - AV_CODEC_ID_MSA1, - AV_CODEC_ID_TSCC2, - AV_CODEC_ID_MTS2, - AV_CODEC_ID_CLLC, - AV_CODEC_ID_MSS2, - AV_CODEC_ID_VP9, - AV_CODEC_ID_AIC, - AV_CODEC_ID_ESCAPE130, - AV_CODEC_ID_G2M, - AV_CODEC_ID_WEBP, - AV_CODEC_ID_HNM4_VIDEO, - AV_CODEC_ID_HEVC, -#define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC - AV_CODEC_ID_FIC, - AV_CODEC_ID_ALIAS_PIX, - AV_CODEC_ID_BRENDER_PIX, - AV_CODEC_ID_PAF_VIDEO, - AV_CODEC_ID_EXR, - AV_CODEC_ID_VP7, - AV_CODEC_ID_SANM, - AV_CODEC_ID_SGIRLE, - AV_CODEC_ID_MVC1, - AV_CODEC_ID_MVC2, - AV_CODEC_ID_HQX, - AV_CODEC_ID_TDSC, - AV_CODEC_ID_HQ_HQA, - AV_CODEC_ID_HAP, - AV_CODEC_ID_DDS, - AV_CODEC_ID_DXV, - AV_CODEC_ID_SCREENPRESSO, - AV_CODEC_ID_RSCC, - AV_CODEC_ID_AVS2, - - AV_CODEC_ID_Y41P = 0x8000, - AV_CODEC_ID_AVRP, - AV_CODEC_ID_012V, - AV_CODEC_ID_AVUI, - AV_CODEC_ID_AYUV, - AV_CODEC_ID_TARGA_Y216, - AV_CODEC_ID_V308, - AV_CODEC_ID_V408, - AV_CODEC_ID_YUV4, - AV_CODEC_ID_AVRN, - AV_CODEC_ID_CPIA, - AV_CODEC_ID_XFACE, - AV_CODEC_ID_SNOW, - AV_CODEC_ID_SMVJPEG, - AV_CODEC_ID_APNG, - AV_CODEC_ID_DAALA, - AV_CODEC_ID_CFHD, - AV_CODEC_ID_TRUEMOTION2RT, - AV_CODEC_ID_M101, - AV_CODEC_ID_MAGICYUV, - AV_CODEC_ID_SHEERVIDEO, - AV_CODEC_ID_YLC, - AV_CODEC_ID_PSD, - AV_CODEC_ID_PIXLET, - AV_CODEC_ID_SPEEDHQ, - AV_CODEC_ID_FMVC, - AV_CODEC_ID_SCPR, - AV_CODEC_ID_CLEARVIDEO, - AV_CODEC_ID_XPM, - AV_CODEC_ID_AV1, - AV_CODEC_ID_BITPACKED, - AV_CODEC_ID_MSCC, - AV_CODEC_ID_SRGC, - AV_CODEC_ID_SVG, - AV_CODEC_ID_GDV, - AV_CODEC_ID_FITS, - AV_CODEC_ID_IMM4, - AV_CODEC_ID_PROSUMER, - AV_CODEC_ID_MWSC, - AV_CODEC_ID_WCMV, - AV_CODEC_ID_RASC, - AV_CODEC_ID_HYMT, - AV_CODEC_ID_ARBC, - AV_CODEC_ID_AGM, - AV_CODEC_ID_LSCR, - AV_CODEC_ID_VP4, - - /* various PCM "codecs" */ - AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs - AV_CODEC_ID_PCM_S16LE = 0x10000, - AV_CODEC_ID_PCM_S16BE, - AV_CODEC_ID_PCM_U16LE, - AV_CODEC_ID_PCM_U16BE, - AV_CODEC_ID_PCM_S8, - AV_CODEC_ID_PCM_U8, - AV_CODEC_ID_PCM_MULAW, - AV_CODEC_ID_PCM_ALAW, - AV_CODEC_ID_PCM_S32LE, - AV_CODEC_ID_PCM_S32BE, - AV_CODEC_ID_PCM_U32LE, - AV_CODEC_ID_PCM_U32BE, - AV_CODEC_ID_PCM_S24LE, - AV_CODEC_ID_PCM_S24BE, - AV_CODEC_ID_PCM_U24LE, - AV_CODEC_ID_PCM_U24BE, - AV_CODEC_ID_PCM_S24DAUD, - AV_CODEC_ID_PCM_ZORK, - AV_CODEC_ID_PCM_S16LE_PLANAR, - AV_CODEC_ID_PCM_DVD, - AV_CODEC_ID_PCM_F32BE, - AV_CODEC_ID_PCM_F32LE, - AV_CODEC_ID_PCM_F64BE, - AV_CODEC_ID_PCM_F64LE, - AV_CODEC_ID_PCM_BLURAY, - AV_CODEC_ID_PCM_LXF, - AV_CODEC_ID_S302M, - AV_CODEC_ID_PCM_S8_PLANAR, - AV_CODEC_ID_PCM_S24LE_PLANAR, - AV_CODEC_ID_PCM_S32LE_PLANAR, - AV_CODEC_ID_PCM_S16BE_PLANAR, - - AV_CODEC_ID_PCM_S64LE = 0x10800, - AV_CODEC_ID_PCM_S64BE, - AV_CODEC_ID_PCM_F16LE, - AV_CODEC_ID_PCM_F24LE, - AV_CODEC_ID_PCM_VIDC, - - /* various ADPCM codecs */ - AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, - AV_CODEC_ID_ADPCM_IMA_WAV, - AV_CODEC_ID_ADPCM_IMA_DK3, - AV_CODEC_ID_ADPCM_IMA_DK4, - AV_CODEC_ID_ADPCM_IMA_WS, - AV_CODEC_ID_ADPCM_IMA_SMJPEG, - AV_CODEC_ID_ADPCM_MS, - AV_CODEC_ID_ADPCM_4XM, - AV_CODEC_ID_ADPCM_XA, - AV_CODEC_ID_ADPCM_ADX, - AV_CODEC_ID_ADPCM_EA, - AV_CODEC_ID_ADPCM_G726, - AV_CODEC_ID_ADPCM_CT, - AV_CODEC_ID_ADPCM_SWF, - AV_CODEC_ID_ADPCM_YAMAHA, - AV_CODEC_ID_ADPCM_SBPRO_4, - AV_CODEC_ID_ADPCM_SBPRO_3, - AV_CODEC_ID_ADPCM_SBPRO_2, - AV_CODEC_ID_ADPCM_THP, - AV_CODEC_ID_ADPCM_IMA_AMV, - AV_CODEC_ID_ADPCM_EA_R1, - AV_CODEC_ID_ADPCM_EA_R3, - AV_CODEC_ID_ADPCM_EA_R2, - AV_CODEC_ID_ADPCM_IMA_EA_SEAD, - AV_CODEC_ID_ADPCM_IMA_EA_EACS, - AV_CODEC_ID_ADPCM_EA_XAS, - AV_CODEC_ID_ADPCM_EA_MAXIS_XA, - AV_CODEC_ID_ADPCM_IMA_ISS, - AV_CODEC_ID_ADPCM_G722, - AV_CODEC_ID_ADPCM_IMA_APC, - AV_CODEC_ID_ADPCM_VIMA, - - AV_CODEC_ID_ADPCM_AFC = 0x11800, - AV_CODEC_ID_ADPCM_IMA_OKI, - AV_CODEC_ID_ADPCM_DTK, - AV_CODEC_ID_ADPCM_IMA_RAD, - AV_CODEC_ID_ADPCM_G726LE, - AV_CODEC_ID_ADPCM_THP_LE, - AV_CODEC_ID_ADPCM_PSX, - AV_CODEC_ID_ADPCM_AICA, - AV_CODEC_ID_ADPCM_IMA_DAT4, - AV_CODEC_ID_ADPCM_MTAF, - AV_CODEC_ID_ADPCM_AGM, - - /* AMR */ - AV_CODEC_ID_AMR_NB = 0x12000, - AV_CODEC_ID_AMR_WB, - - /* RealAudio codecs*/ - AV_CODEC_ID_RA_144 = 0x13000, - AV_CODEC_ID_RA_288, - - /* various DPCM codecs */ - AV_CODEC_ID_ROQ_DPCM = 0x14000, - AV_CODEC_ID_INTERPLAY_DPCM, - AV_CODEC_ID_XAN_DPCM, - AV_CODEC_ID_SOL_DPCM, - - AV_CODEC_ID_SDX2_DPCM = 0x14800, - AV_CODEC_ID_GREMLIN_DPCM, - - /* audio codecs */ - AV_CODEC_ID_MP2 = 0x15000, - AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 - AV_CODEC_ID_AAC, - AV_CODEC_ID_AC3, - AV_CODEC_ID_DTS, - AV_CODEC_ID_VORBIS, - AV_CODEC_ID_DVAUDIO, - AV_CODEC_ID_WMAV1, - AV_CODEC_ID_WMAV2, - AV_CODEC_ID_MACE3, - AV_CODEC_ID_MACE6, - AV_CODEC_ID_VMDAUDIO, - AV_CODEC_ID_FLAC, - AV_CODEC_ID_MP3ADU, - AV_CODEC_ID_MP3ON4, - AV_CODEC_ID_SHORTEN, - AV_CODEC_ID_ALAC, - AV_CODEC_ID_WESTWOOD_SND1, - AV_CODEC_ID_GSM, ///< as in Berlin toast format - AV_CODEC_ID_QDM2, - AV_CODEC_ID_COOK, - AV_CODEC_ID_TRUESPEECH, - AV_CODEC_ID_TTA, - AV_CODEC_ID_SMACKAUDIO, - AV_CODEC_ID_QCELP, - AV_CODEC_ID_WAVPACK, - AV_CODEC_ID_DSICINAUDIO, - AV_CODEC_ID_IMC, - AV_CODEC_ID_MUSEPACK7, - AV_CODEC_ID_MLP, - AV_CODEC_ID_GSM_MS, /* as found in WAV */ - AV_CODEC_ID_ATRAC3, - AV_CODEC_ID_APE, - AV_CODEC_ID_NELLYMOSER, - AV_CODEC_ID_MUSEPACK8, - AV_CODEC_ID_SPEEX, - AV_CODEC_ID_WMAVOICE, - AV_CODEC_ID_WMAPRO, - AV_CODEC_ID_WMALOSSLESS, - AV_CODEC_ID_ATRAC3P, - AV_CODEC_ID_EAC3, - AV_CODEC_ID_SIPR, - AV_CODEC_ID_MP1, - AV_CODEC_ID_TWINVQ, - AV_CODEC_ID_TRUEHD, - AV_CODEC_ID_MP4ALS, - AV_CODEC_ID_ATRAC1, - AV_CODEC_ID_BINKAUDIO_RDFT, - AV_CODEC_ID_BINKAUDIO_DCT, - AV_CODEC_ID_AAC_LATM, - AV_CODEC_ID_QDMC, - AV_CODEC_ID_CELT, - AV_CODEC_ID_G723_1, - AV_CODEC_ID_G729, - AV_CODEC_ID_8SVX_EXP, - AV_CODEC_ID_8SVX_FIB, - AV_CODEC_ID_BMV_AUDIO, - AV_CODEC_ID_RALF, - AV_CODEC_ID_IAC, - AV_CODEC_ID_ILBC, - AV_CODEC_ID_OPUS, - AV_CODEC_ID_COMFORT_NOISE, - AV_CODEC_ID_TAK, - AV_CODEC_ID_METASOUND, - AV_CODEC_ID_PAF_AUDIO, - AV_CODEC_ID_ON2AVC, - AV_CODEC_ID_DSS_SP, - AV_CODEC_ID_CODEC2, - - AV_CODEC_ID_FFWAVESYNTH = 0x15800, - AV_CODEC_ID_SONIC, - AV_CODEC_ID_SONIC_LS, - AV_CODEC_ID_EVRC, - AV_CODEC_ID_SMV, - AV_CODEC_ID_DSD_LSBF, - AV_CODEC_ID_DSD_MSBF, - AV_CODEC_ID_DSD_LSBF_PLANAR, - AV_CODEC_ID_DSD_MSBF_PLANAR, - AV_CODEC_ID_4GV, - AV_CODEC_ID_INTERPLAY_ACM, - AV_CODEC_ID_XMA1, - AV_CODEC_ID_XMA2, - AV_CODEC_ID_DST, - AV_CODEC_ID_ATRAC3AL, - AV_CODEC_ID_ATRAC3PAL, - AV_CODEC_ID_DOLBY_E, - AV_CODEC_ID_APTX, - AV_CODEC_ID_APTX_HD, - AV_CODEC_ID_SBC, - AV_CODEC_ID_ATRAC9, - AV_CODEC_ID_HCOM, - - /* subtitle codecs */ - AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. - AV_CODEC_ID_DVD_SUBTITLE = 0x17000, - AV_CODEC_ID_DVB_SUBTITLE, - AV_CODEC_ID_TEXT, ///< raw UTF-8 text - AV_CODEC_ID_XSUB, - AV_CODEC_ID_SSA, - AV_CODEC_ID_MOV_TEXT, - AV_CODEC_ID_HDMV_PGS_SUBTITLE, - AV_CODEC_ID_DVB_TELETEXT, - AV_CODEC_ID_SRT, - - AV_CODEC_ID_MICRODVD = 0x17800, - AV_CODEC_ID_EIA_608, - AV_CODEC_ID_JACOSUB, - AV_CODEC_ID_SAMI, - AV_CODEC_ID_REALTEXT, - AV_CODEC_ID_STL, - AV_CODEC_ID_SUBVIEWER1, - AV_CODEC_ID_SUBVIEWER, - AV_CODEC_ID_SUBRIP, - AV_CODEC_ID_WEBVTT, - AV_CODEC_ID_MPL2, - AV_CODEC_ID_VPLAYER, - AV_CODEC_ID_PJS, - AV_CODEC_ID_ASS, - AV_CODEC_ID_HDMV_TEXT_SUBTITLE, - AV_CODEC_ID_TTML, - AV_CODEC_ID_ARIB_CAPTION, - - /* other specific kind of codecs (generally used for attachments) */ - AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. - AV_CODEC_ID_TTF = 0x18000, - - AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of program stream. - AV_CODEC_ID_BINTEXT = 0x18800, - AV_CODEC_ID_XBIN, - AV_CODEC_ID_IDF, - AV_CODEC_ID_OTF, - AV_CODEC_ID_SMPTE_KLV, - AV_CODEC_ID_DVD_NAV, - AV_CODEC_ID_TIMED_ID3, - AV_CODEC_ID_BIN_DATA, - - - AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it - - AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS - * stream (only used by libavformat) */ - AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems - * stream (only used by libavformat) */ - AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. - AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket -}; - -/** - * This struct describes the properties of a single codec described by an - * AVCodecID. - * @see avcodec_descriptor_get() - */ -typedef struct AVCodecDescriptor { - enum AVCodecID id; - enum AVMediaType type; - /** - * Name of the codec described by this descriptor. It is non-empty and - * unique for each codec descriptor. It should contain alphanumeric - * characters and '_' only. - */ - const char *name; - /** - * A more descriptive name for this codec. May be NULL. - */ - const char *long_name; - /** - * Codec properties, a combination of AV_CODEC_PROP_* flags. - */ - int props; - /** - * MIME type(s) associated with the codec. - * May be NULL; if not, a NULL-terminated array of MIME types. - * The first item is always non-NULL and is the preferred MIME type. - */ - const char *const *mime_types; - /** - * If non-NULL, an array of profiles recognized for this codec. - * Terminated with FF_PROFILE_UNKNOWN. - */ - const struct AVProfile *profiles; -} AVCodecDescriptor; - -/** - * Codec uses only intra compression. - * Video and audio codecs only. - */ -#define AV_CODEC_PROP_INTRA_ONLY (1 << 0) -/** - * Codec supports lossy compression. Audio and video codecs only. - * @note a codec may support both lossy and lossless - * compression modes - */ -#define AV_CODEC_PROP_LOSSY (1 << 1) -/** - * Codec supports lossless compression. Audio and video codecs only. - */ -#define AV_CODEC_PROP_LOSSLESS (1 << 2) -/** - * Codec supports frame reordering. That is, the coded order (the order in which - * the encoded packets are output by the encoders / stored / input to the - * decoders) may be different from the presentation order of the corresponding - * frames. - * - * For codecs that do not have this property set, PTS and DTS should always be - * equal. - */ -#define AV_CODEC_PROP_REORDER (1 << 3) -/** - * Subtitle codec is bitmap based - * Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field. - */ -#define AV_CODEC_PROP_BITMAP_SUB (1 << 16) -/** - * Subtitle codec is text based. - * Decoded AVSubtitle data can be read from the AVSubtitleRect->ass field. - */ -#define AV_CODEC_PROP_TEXT_SUB (1 << 17) - /** * @ingroup lavc_decoding * Required number of additionally allocated bytes at the end of the input bitstream for decoding. @@ -969,127 +394,27 @@ typedef struct RcOverride{ /* /Fx */ /* codec capabilities */ +/* Exported side data. + These flags can be passed in AVCodecContext.export_side_data before initialization. +*/ /** - * Decoder can use draw_horiz_band callback. + * Export motion vectors through frame side data */ -#define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0) +#define AV_CODEC_EXPORT_DATA_MVS (1 << 0) /** - * Codec uses get_buffer() for allocating buffers and supports custom allocators. - * If not set, it might not use get_buffer() at all or use operations that - * assume the buffer was allocated by avcodec_default_get_buffer. + * Export encoder Producer Reference Time through packet side data */ -#define AV_CODEC_CAP_DR1 (1 << 1) -#define AV_CODEC_CAP_TRUNCATED (1 << 3) +#define AV_CODEC_EXPORT_DATA_PRFT (1 << 1) /** - * Encoder or decoder requires flushing with NULL input at the end in order to - * give the complete and correct output. - * - * NOTE: If this flag is not set, the codec is guaranteed to never be fed with - * with NULL data. The user can still send NULL data to the public encode - * or decode function, but libavcodec will not pass it along to the codec - * unless this flag is set. - * - * Decoders: - * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL, - * avpkt->size=0 at the end to get the delayed data until the decoder no longer - * returns frames. - * - * Encoders: - * The encoder needs to be fed with NULL data at the end of encoding until the - * encoder no longer returns data. - * - * NOTE: For encoders implementing the AVCodec.encode2() function, setting this - * flag also means that the encoder must set the pts and duration for - * each output packet. If this flag is not set, the pts and duration will - * be determined by libavcodec from the input frame. + * Decoding only. + * Export the AVVideoEncParams structure through frame side data. */ -#define AV_CODEC_CAP_DELAY (1 << 5) +#define AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS (1 << 2) /** - * Codec can be fed a final frame with a smaller size. - * This can be used to prevent truncation of the last audio samples. + * Decoding only. + * Do not apply film grain, export it instead. */ -#define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6) - -/** - * Codec can output multiple frames per AVPacket - * Normally demuxers return one frame at a time, demuxers which do not do - * are connected to a parser to split what they return into proper frames. - * This flag is reserved to the very rare category of codecs which have a - * bitstream that cannot be split into frames without timeconsuming - * operations like full decoding. Demuxers carrying such bitstreams thus - * may return multiple frames in a packet. This has many disadvantages like - * prohibiting stream copy in many cases thus it should only be considered - * as a last resort. - */ -#define AV_CODEC_CAP_SUBFRAMES (1 << 8) -/** - * Codec is experimental and is thus avoided in favor of non experimental - * encoders - */ -#define AV_CODEC_CAP_EXPERIMENTAL (1 << 9) -/** - * Codec should fill in channel configuration and samplerate instead of container - */ -#define AV_CODEC_CAP_CHANNEL_CONF (1 << 10) -/** - * Codec supports frame-level multithreading. - */ -#define AV_CODEC_CAP_FRAME_THREADS (1 << 12) -/** - * Codec supports slice-based (or partition-based) multithreading. - */ -#define AV_CODEC_CAP_SLICE_THREADS (1 << 13) -/** - * Codec supports changed parameters at any point. - */ -#define AV_CODEC_CAP_PARAM_CHANGE (1 << 14) -/** - * Codec supports avctx->thread_count == 0 (auto). - */ -#define AV_CODEC_CAP_AUTO_THREADS (1 << 15) -/** - * Audio encoder supports receiving a different number of samples in each call. - */ -#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16) -/** - * Decoder is not a preferred choice for probing. - * This indicates that the decoder is not a good choice for probing. - * It could for example be an expensive to spin up hardware decoder, - * or it could simply not provide a lot of useful information about - * the stream. - * A decoder marked with this flag should only be used as last resort - * choice for probing. - */ -#define AV_CODEC_CAP_AVOID_PROBING (1 << 17) -/** - * Codec is intra only. - */ -#define AV_CODEC_CAP_INTRA_ONLY 0x40000000 -/** - * Codec is lossless. - */ -#define AV_CODEC_CAP_LOSSLESS 0x80000000 - -/** - * Codec is backed by a hardware implementation. Typically used to - * identify a non-hwaccel hardware decoder. For information about hwaccels, use - * avcodec_get_hw_config() instead. - */ -#define AV_CODEC_CAP_HARDWARE (1 << 18) - -/** - * Codec is potentially backed by a hardware implementation, but not - * necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the - * implementation provides some sort of internal fallback. - */ -#define AV_CODEC_CAP_HYBRID (1 << 19) - -/** - * This codec takes the reordered_opaque field from input AVFrames - * and returns it in the corresponding field in AVCodecContext after - * encoding. - */ -#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20) +#define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3) /** * Pan Scan area. @@ -1170,385 +495,31 @@ typedef struct AVCPBProperties { uint64_t vbv_delay; } AVCPBProperties; +/** + * This structure supplies correlation between a packet timestamp and a wall clock + * production time. The definition follows the Producer Reference Time ('prft') + * as defined in ISO/IEC 14496-12 + */ +typedef struct AVProducerReferenceTime { + /** + * A UTC timestamp, in microseconds, since Unix epoch (e.g, av_gettime()). + */ + int64_t wallclock; + int flags; +} AVProducerReferenceTime; + /** * The decoder will keep a reference to the frame and may reuse it later. */ #define AV_GET_BUFFER_FLAG_REF (1 << 0) /** - * @defgroup lavc_packet AVPacket - * - * Types and functions for working with AVPacket. - * @{ - */ -enum AVPacketSideDataType { - /** - * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE - * bytes worth of palette. This side data signals that a new palette is - * present. - */ - AV_PKT_DATA_PALETTE, - - /** - * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format - * that the extradata buffer was changed and the receiving side should - * act upon it appropriately. The new extradata is embedded in the side - * data buffer and should be immediately used for processing the current - * frame or packet. - */ - AV_PKT_DATA_NEW_EXTRADATA, - - /** - * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: - * @code - * u32le param_flags - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) - * s32le channel_count - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) - * u64le channel_layout - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) - * s32le sample_rate - * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) - * s32le width - * s32le height - * @endcode - */ - AV_PKT_DATA_PARAM_CHANGE, - - /** - * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of - * structures with info about macroblocks relevant to splitting the - * packet into smaller packets on macroblock edges (e.g. as for RFC 2190). - * That is, it does not necessarily contain info about all macroblocks, - * as long as the distance between macroblocks in the info is smaller - * than the target payload size. - * Each MB info structure is 12 bytes, and is laid out as follows: - * @code - * u32le bit offset from the start of the packet - * u8 current quantizer at the start of the macroblock - * u8 GOB number - * u16le macroblock address within the GOB - * u8 horizontal MV predictor - * u8 vertical MV predictor - * u8 horizontal MV predictor for block number 3 - * u8 vertical MV predictor for block number 3 - * @endcode - */ - AV_PKT_DATA_H263_MB_INFO, - - /** - * This side data should be associated with an audio stream and contains - * ReplayGain information in form of the AVReplayGain struct. - */ - AV_PKT_DATA_REPLAYGAIN, - - /** - * This side data contains a 3x3 transformation matrix describing an affine - * transformation that needs to be applied to the decoded video frames for - * correct presentation. - * - * See libavutil/display.h for a detailed description of the data. - */ - AV_PKT_DATA_DISPLAYMATRIX, - - /** - * This side data should be associated with a video stream and contains - * Stereoscopic 3D information in form of the AVStereo3D struct. - */ - AV_PKT_DATA_STEREO3D, - - /** - * This side data should be associated with an audio stream and corresponds - * to enum AVAudioServiceType. - */ - AV_PKT_DATA_AUDIO_SERVICE_TYPE, - - /** - * This side data contains quality related information from the encoder. - * @code - * u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad). - * u8 picture type - * u8 error count - * u16 reserved - * u64le[error count] sum of squared differences between encoder in and output - * @endcode - */ - AV_PKT_DATA_QUALITY_STATS, - - /** - * This side data contains an integer value representing the stream index - * of a "fallback" track. A fallback track indicates an alternate - * track to use when the current track can not be decoded for some reason. - * e.g. no decoder available for codec. - */ - AV_PKT_DATA_FALLBACK_TRACK, - - /** - * This side data corresponds to the AVCPBProperties struct. - */ - AV_PKT_DATA_CPB_PROPERTIES, - - /** - * Recommmends skipping the specified number of samples - * @code - * u32le number of samples to skip from start of this packet - * u32le number of samples to skip from end of this packet - * u8 reason for start skip - * u8 reason for end skip (0=padding silence, 1=convergence) - * @endcode - */ - AV_PKT_DATA_SKIP_SAMPLES, - - /** - * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that - * the packet may contain "dual mono" audio specific to Japanese DTV - * and if it is true, recommends only the selected channel to be used. - * @code - * u8 selected channels (0=mail/left, 1=sub/right, 2=both) - * @endcode - */ - AV_PKT_DATA_JP_DUALMONO, - - /** - * A list of zero terminated key/value strings. There is no end marker for - * the list, so it is required to rely on the side data size to stop. - */ - AV_PKT_DATA_STRINGS_METADATA, - - /** - * Subtitle event position - * @code - * u32le x1 - * u32le y1 - * u32le x2 - * u32le y2 - * @endcode - */ - AV_PKT_DATA_SUBTITLE_POSITION, - - /** - * Data found in BlockAdditional element of matroska container. There is - * no end marker for the data, so it is required to rely on the side data - * size to recognize the end. 8 byte id (as found in BlockAddId) followed - * by data. - */ - AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, - - /** - * The optional first identifier line of a WebVTT cue. - */ - AV_PKT_DATA_WEBVTT_IDENTIFIER, - - /** - * The optional settings (rendering instructions) that immediately - * follow the timestamp specifier of a WebVTT cue. - */ - AV_PKT_DATA_WEBVTT_SETTINGS, - - /** - * A list of zero terminated key/value strings. There is no end marker for - * the list, so it is required to rely on the side data size to stop. This - * side data includes updated metadata which appeared in the stream. - */ - AV_PKT_DATA_METADATA_UPDATE, - - /** - * MPEGTS stream ID as uint8_t, this is required to pass the stream ID - * information from the demuxer to the corresponding muxer. - */ - AV_PKT_DATA_MPEGTS_STREAM_ID, - - /** - * Mastering display metadata (based on SMPTE-2086:2014). This metadata - * should be associated with a video stream and contains data in the form - * of the AVMasteringDisplayMetadata struct. - */ - AV_PKT_DATA_MASTERING_DISPLAY_METADATA, - - /** - * This side data should be associated with a video stream and corresponds - * to the AVSphericalMapping structure. - */ - AV_PKT_DATA_SPHERICAL, - - /** - * Content light level (based on CTA-861.3). This metadata should be - * associated with a video stream and contains data in the form of the - * AVContentLightMetadata struct. - */ - AV_PKT_DATA_CONTENT_LIGHT_LEVEL, - - /** - * ATSC A53 Part 4 Closed Captions. This metadata should be associated with - * a video stream. A53 CC bitstream is stored as uint8_t in AVPacketSideData.data. - * The number of bytes of CC data is AVPacketSideData.size. - */ - AV_PKT_DATA_A53_CC, - - /** - * This side data is encryption initialization data. - * The format is not part of ABI, use av_encryption_init_info_* methods to - * access. - */ - AV_PKT_DATA_ENCRYPTION_INIT_INFO, - - /** - * This side data contains encryption info for how to decrypt the packet. - * The format is not part of ABI, use av_encryption_info_* methods to access. - */ - AV_PKT_DATA_ENCRYPTION_INFO, - - /** - * Active Format Description data consisting of a single byte as specified - * in ETSI TS 101 154 using AVActiveFormatDescription enum. - */ - AV_PKT_DATA_AFD, - - /** - * The number of side data types. - * This is not part of the public API/ABI in the sense that it may - * change when new side data types are added. - * This must stay the last enum value. - * If its value becomes huge, some code using it - * needs to be updated as it assumes it to be smaller than other limits. - */ - AV_PKT_DATA_NB -}; - -#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED - -typedef struct AVPacketSideData { - uint8_t *data; - int size; - enum AVPacketSideDataType type; -} AVPacketSideData; - -/** - * This structure stores compressed data. It is typically exported by demuxers - * and then passed as input to decoders, or received as output from encoders and - * then passed to muxers. - * - * For video, it should typically contain one compressed frame. For audio it may - * contain several compressed frames. Encoders are allowed to output empty - * packets, with no compressed data, containing only side data - * (e.g. to update some stream parameters at the end of encoding). - * - * AVPacket is one of the few structs in FFmpeg, whose size is a part of public - * ABI. Thus it may be allocated on stack and no new fields can be added to it - * without libavcodec and libavformat major bump. - * - * The semantics of data ownership depends on the buf field. - * If it is set, the packet data is dynamically allocated and is - * valid indefinitely until a call to av_packet_unref() reduces the - * reference count to 0. - * - * If the buf field is not set av_packet_ref() would make a copy instead - * of increasing the reference count. - * - * The side data is always allocated with av_malloc(), copied by - * av_packet_ref() and freed by av_packet_unref(). - * - * @see av_packet_ref - * @see av_packet_unref - */ -typedef struct AVPacket { - /** - * A reference to the reference-counted buffer where the packet data is - * stored. - * May be NULL, then the packet data is not reference-counted. - */ - AVBufferRef *buf; - /** - * Presentation timestamp in AVStream->time_base units; the time at which - * the decompressed packet will be presented to the user. - * Can be AV_NOPTS_VALUE if it is not stored in the file. - * pts MUST be larger or equal to dts as presentation cannot happen before - * decompression, unless one wants to view hex dumps. Some formats misuse - * the terms dts and pts/cts to mean something different. Such timestamps - * must be converted to true pts/dts before they are stored in AVPacket. - */ - int64_t pts; - /** - * Decompression timestamp in AVStream->time_base units; the time at which - * the packet is decompressed. - * Can be AV_NOPTS_VALUE if it is not stored in the file. - */ - int64_t dts; - uint8_t *data; - int size; - int stream_index; - /** - * A combination of AV_PKT_FLAG values - */ - int flags; - /** - * Additional packet data that can be provided by the container. - * Packet can contain several types of side information. - */ - AVPacketSideData *side_data; - int side_data_elems; - - /** - * Duration of this packet in AVStream->time_base units, 0 if unknown. - * Equals next_pts - this_pts in presentation order. - */ - int64_t duration; - - int64_t pos; ///< byte position in stream, -1 if unknown - -#if FF_API_CONVERGENCE_DURATION - /** - * @deprecated Same as the duration field, but as int64_t. This was required - * for Matroska subtitles, whose duration values could overflow when the - * duration field was still an int. - */ - attribute_deprecated - int64_t convergence_duration; -#endif -} AVPacket; -#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe -#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted -/** - * Flag is used to discard packets which are required to maintain valid - * decoder state but are not required for output and should be dropped - * after decoding. - **/ -#define AV_PKT_FLAG_DISCARD 0x0004 -/** - * The packet comes from a trusted source. - * - * Otherwise-unsafe constructs such as arbitrary pointers to data - * outside the packet may be followed. - */ -#define AV_PKT_FLAG_TRUSTED 0x0008 -/** - * Flag is used to indicate packets that contain frames that can - * be discarded by the decoder. I.e. Non-reference frames. - */ -#define AV_PKT_FLAG_DISPOSABLE 0x0010 - - -enum AVSideDataParamChangeFlags { - AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, - AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, - AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, - AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, -}; -/** - * @} + * The encoder will keep a reference to the packet and may reuse it later. */ +#define AV_GET_ENCODE_BUFFER_FLAG_REF (1 << 0) struct AVCodecInternal; -enum AVFieldOrder { - AV_FIELD_UNKNOWN, - AV_FIELD_PROGRESSIVE, - AV_FIELD_TT, //< Top coded_first, top displayed first - AV_FIELD_BB, //< Bottom coded first, bottom displayed first - AV_FIELD_TB, //< Top coded first, bottom displayed first - AV_FIELD_BT, //< Bottom coded first, top displayed first -}; - /** * main external API structure. * New fields can be added to the end with minor version bumps. @@ -2353,9 +1324,9 @@ typedef struct AVCodecContext { * * Some decoders do not support linesizes changing between frames. * - * If frame multithreading is used and thread_safe_callbacks is set, - * this callback may be called from a different thread, but not from more - * than one at once. Does not need to be reentrant. + * If frame multithreading is used, this callback may be called from a + * different thread, but not from more than one at once. Does not need to be + * reentrant. * * @see avcodec_align_dimensions2() * @@ -2379,6 +1350,7 @@ typedef struct AVCodecContext { */ int (*get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags); +#if FF_API_OLD_ENCDEC /** * If non-zero, the decoded audio and video frames returned from * avcodec_decode_video2() and avcodec_decode_audio4() are reference-counted @@ -2394,6 +1366,7 @@ typedef struct AVCodecContext { */ attribute_deprecated int refcounted_frames; +#endif /* - encoding parameters */ float qcompress; ///< amount of qscale change between easy & hard scenes (0.0-1.0) @@ -2653,42 +1626,20 @@ typedef struct AVCodecContext { #define FF_DEBUG_BITSTREAM 4 #define FF_DEBUG_MB_TYPE 8 #define FF_DEBUG_QP 16 -#if FF_API_DEBUG_MV -/** - * @deprecated this option does nothing - */ -#define FF_DEBUG_MV 32 -#endif #define FF_DEBUG_DCT_COEFF 0x00000040 #define FF_DEBUG_SKIP 0x00000080 #define FF_DEBUG_STARTCODE 0x00000100 #define FF_DEBUG_ER 0x00000400 #define FF_DEBUG_MMCO 0x00000800 #define FF_DEBUG_BUGS 0x00001000 -#if FF_API_DEBUG_MV -#define FF_DEBUG_VIS_QP 0x00002000 -#define FF_DEBUG_VIS_MB_TYPE 0x00004000 -#endif #define FF_DEBUG_BUFFERS 0x00008000 #define FF_DEBUG_THREADS 0x00010000 #define FF_DEBUG_GREEN_MD 0x00800000 #define FF_DEBUG_NOMC 0x01000000 -#if FF_API_DEBUG_MV - /** - * debug - * - encoding: Set by user. - * - decoding: Set by user. - */ - int debug_mv; -#define FF_DEBUG_VIS_MV_P_FOR 0x00000001 // visualize forward predicted MVs of P-frames -#define FF_DEBUG_VIS_MV_B_FOR 0x00000002 // visualize forward predicted MVs of B-frames -#define FF_DEBUG_VIS_MV_B_BACK 0x00000004 // visualize backward predicted MVs of B-frames -#endif - /** * Error recognition; may misdetect some more or less valid parts as errors. - * - encoding: unused + * - encoding: Set by user. * - decoding: Set by user. */ int err_recognition; @@ -2795,14 +1746,12 @@ typedef struct AVCodecContext { */ int bits_per_raw_sample; -#if FF_API_LOWRES /** * low resolution decoding, 1-> 1/2 size, 2->1/4 size * - encoding: unused * - decoding: Set by user. */ int lowres; -#endif #if FF_API_CODED_FRAME /** @@ -2842,6 +1791,7 @@ typedef struct AVCodecContext { */ int active_thread_type; +#if FF_API_THREAD_SAFE_CALLBACKS /** * Set by the client if its custom get_buffer() callback can be called * synchronously from another thread, which allows faster multithreaded decoding. @@ -2849,8 +1799,18 @@ typedef struct AVCodecContext { * Ignored if the default get_buffer() is used. * - encoding: Set by user. * - decoding: Set by user. + * + * @deprecated the custom get_buffer2() callback should always be + * thread-safe. Thread-unsafe get_buffer2() implementations will be + * invalid starting with LIBAVCODEC_VERSION_MAJOR=60; in other words, + * libavcodec will behave as if this field was always set to 1. + * Callers that want to be forward compatible with future libavcodec + * versions should wrap access to this field in + * #if LIBAVCODEC_VERSION_MAJOR < 60 */ + attribute_deprecated int thread_safe_callbacks; +#endif /** * The codec may call this to execute several independent things. @@ -2988,6 +1948,9 @@ typedef struct AVCodecContext { #define FF_PROFILE_HEVC_MAIN_STILL_PICTURE 3 #define FF_PROFILE_HEVC_REXT 4 +#define FF_PROFILE_VVC_MAIN_10 1 +#define FF_PROFILE_VVC_MAIN_10_444 33 + #define FF_PROFILE_AV1_MAIN 0 #define FF_PROFILE_AV1_HIGH 1 #define FF_PROFILE_AV1_PROFESSIONAL 2 @@ -3010,6 +1973,9 @@ typedef struct AVCodecContext { #define FF_PROFILE_ARIB_PROFILE_A 0 #define FF_PROFILE_ARIB_PROFILE_C 1 +#define FF_PROFILE_KLVA_SYNC 0 +#define FF_PROFILE_KLVA_ASYNC 1 + /** * level * - encoding: Set by user. @@ -3125,15 +2091,6 @@ typedef struct AVCodecContext { */ const AVCodecDescriptor *codec_descriptor; -#if !FF_API_LOWRES - /** - * low resolution decoding, 1-> 1/2 size, 2->1/4 size - * - encoding: unused - * - decoding: Set by user. - */ - int lowres; -#endif - /** * Current statistics for PTS correction. * - decoding: maintained and used by libavcodec, not intended to be used by user apps @@ -3184,12 +2141,11 @@ typedef struct AVCodecContext { */ int seek_preroll; -#if !FF_API_DEBUG_MV +#if FF_API_DEBUG_MV /** - * debug motion vectors - * - encoding: Set by user. - * - decoding: Set by user. + * @deprecated unused */ + attribute_deprecated int debug_mv; #define FF_DEBUG_VIS_MV_P_FOR 0x00000001 //visualize forward predicted MVs of P frames #define FF_DEBUG_VIS_MV_B_FOR 0x00000002 //visualize forward predicted MVs of B frames @@ -3370,6 +2326,62 @@ typedef struct AVCodecContext { * - encoding: unused */ int discard_damaged_percentage; + + /** + * The number of samples per frame to maximally accept. + * + * - decoding: set by user + * - encoding: set by user + */ + int64_t max_samples; + + /** + * Bit set of AV_CODEC_EXPORT_DATA_* flags, which affects the kind of + * metadata exported in frame, packet, or coded stream side data by + * decoders and encoders. + * + * - decoding: set by user + * - encoding: set by user + */ + int export_side_data; + + /** + * This callback is called at the beginning of each packet to get a data + * buffer for it. + * + * The following field will be set in the packet before this callback is + * called: + * - size + * This callback must use the above value to calculate the required buffer size, + * which must padded by at least AV_INPUT_BUFFER_PADDING_SIZE bytes. + * + * This callback must fill the following fields in the packet: + * - data: alignment requirements for AVPacket apply, if any. Some architectures and + * encoders may benefit from having aligned data. + * - buf: must contain a pointer to an AVBufferRef structure. The packet's + * data pointer must be contained in it. See: av_buffer_create(), av_buffer_alloc(), + * and av_buffer_ref(). + * + * If AV_CODEC_CAP_DR1 is not set then get_encode_buffer() must call + * avcodec_default_get_encode_buffer() instead of providing a buffer allocated by + * some other means. + * + * The flags field may contain a combination of AV_GET_ENCODE_BUFFER_FLAG_ flags. + * They may be used for example to hint what use the buffer may get after being + * created. + * Implementations of this callback may ignore flags they don't understand. + * If AV_GET_ENCODE_BUFFER_FLAG_REF is set in flags then the packet may be reused + * (read and/or written to if it is writable) later by libavcodec. + * + * This callback must be thread-safe, as when frame threading is used, it may + * be called from multiple threads simultaneously. + * + * @see avcodec_default_get_encode_buffer() + * + * - encoding: Set by libavcodec, user can override. + * - decoding: unused + */ + int (*get_encode_buffer)(struct AVCodecContext *s, AVPacket *pkt, int flags); } AVCodecContext; #if FF_API_CODEC_GET_SET @@ -3390,12 +2402,10 @@ void av_codec_set_codec_descriptor(AVCodecContext *avctx, co attribute_deprecated unsigned av_codec_get_codec_properties(const AVCodecContext *avctx); -#if FF_API_LOWRES attribute_deprecated int av_codec_get_lowres(const AVCodecContext *avctx); attribute_deprecated void av_codec_set_lowres(AVCodecContext *avctx, int val); -#endif attribute_deprecated int av_codec_get_seek_preroll(const AVCodecContext *avctx); @@ -3408,220 +2418,8 @@ attribute_deprecated void av_codec_set_chroma_intra_matrix(AVCodecContext *avctx, uint16_t *val); #endif -/** - * AVProfile. - */ -typedef struct AVProfile { - int profile; - const char *name; ///< short name for the profile -} AVProfile; - -enum { - /** - * The codec supports this format via the hw_device_ctx interface. - * - * When selecting this format, AVCodecContext.hw_device_ctx should - * have been set to a device of the specified type before calling - * avcodec_open2(). - */ - AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01, - /** - * The codec supports this format via the hw_frames_ctx interface. - * - * When selecting this format for a decoder, - * AVCodecContext.hw_frames_ctx should be set to a suitable frames - * context inside the get_format() callback. The frames context - * must have been created on a device of the specified type. - */ - AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02, - /** - * The codec supports this format by some internal method. - * - * This format can be selected without any additional configuration - - * no device or frames context is required. - */ - AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04, - /** - * The codec supports this format by some ad-hoc method. - * - * Additional settings and/or function calls are required. See the - * codec-specific documentation for details. (Methods requiring - * this sort of configuration are deprecated and others should be - * used in preference.) - */ - AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08, -}; - -typedef struct AVCodecHWConfig { - /** - * A hardware pixel format which the codec can use. - */ - enum AVPixelFormat pix_fmt; - /** - * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible - * setup methods which can be used with this configuration. - */ - int methods; - /** - * The device type associated with the configuration. - * - * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and - * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused. - */ - enum AVHWDeviceType device_type; -} AVCodecHWConfig; - -typedef struct AVCodecDefault AVCodecDefault; - struct AVSubtitle; -/** - * AVCodec. - */ -typedef struct AVCodec { - /** - * Name of the codec implementation. - * The name is globally unique among encoders and among decoders (but an - * encoder and a decoder can share the same name). - * This is the primary way to find a codec from the user perspective. - */ - const char *name; - /** - * Descriptive name for the codec, meant to be more human readable than name. - * You should use the NULL_IF_CONFIG_SMALL() macro to define it. - */ - const char *long_name; - enum AVMediaType type; - enum AVCodecID id; - /** - * Codec capabilities. - * see AV_CODEC_CAP_* - */ - int capabilities; - const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} - const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 - const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 - const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 - const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 - uint8_t max_lowres; ///< maximum value for lowres supported by the decoder - const AVClass *priv_class; ///< AVClass for the private context - const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} - - /** - * Group name of the codec implementation. - * This is a short symbolic name of the wrapper backing this codec. A - * wrapper uses some kind of external implementation for the codec, such - * as an external library, or a codec implementation provided by the OS or - * the hardware. - * If this field is NULL, this is a builtin, libavcodec native codec. - * If non-NULL, this will be the suffix in AVCodec.name in most cases - * (usually AVCodec.name will be of the form "_"). - */ - const char *wrapper_name; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - int priv_data_size; - struct AVCodec *next; - /** - * @name Frame-level threading support functions - * @{ - */ - /** - * If defined, called on thread contexts when they are created. - * If the codec allocates writable tables in init(), re-allocate them here. - * priv_data will be set to a copy of the original. - */ - int (*init_thread_copy)(AVCodecContext *); - /** - * Copy necessary context variables from a previous thread context to the current one. - * If not defined, the next thread will start automatically; otherwise, the codec - * must call ff_thread_finish_setup(). - * - * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. - */ - int (*update_thread_context)(AVCodecContext *dst, const AVCodecContext *src); - /** @} */ - - /** - * Private codec-specific defaults. - */ - const AVCodecDefault *defaults; - - /** - * Initialize codec static data, called from avcodec_register(). - * - * This is not intended for time consuming operations as it is - * run for every codec regardless of that codec being used. - */ - void (*init_static_data)(struct AVCodec *codec); - - int (*init)(AVCodecContext *); - int (*encode_sub)(AVCodecContext *, uint8_t *buf, int buf_size, - const struct AVSubtitle *sub); - /** - * Encode data to an AVPacket. - * - * @param avctx codec context - * @param avpkt output AVPacket (may contain a user-provided buffer) - * @param[in] frame AVFrame containing the raw data to be encoded - * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a - * non-empty packet was returned in avpkt. - * @return 0 on success, negative error code on failure - */ - int (*encode2)(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, - int *got_packet_ptr); - int (*decode)(AVCodecContext *, void *outdata, int *outdata_size, AVPacket *avpkt); - int (*close)(AVCodecContext *); - /** - * Encode API with decoupled packet/frame dataflow. The API is the - * same as the avcodec_ prefixed APIs (avcodec_send_frame() etc.), except - * that: - * - never called if the codec is closed or the wrong type, - * - if AV_CODEC_CAP_DELAY is not set, drain frames are never sent, - * - only one drain frame is ever passed down, - */ - int (*send_frame)(AVCodecContext *avctx, const AVFrame *frame); - int (*receive_packet)(AVCodecContext *avctx, AVPacket *avpkt); - - /** - * Decode API with decoupled packet/frame dataflow. This function is called - * to get one output frame. It should call ff_decode_get_packet() to obtain - * input data. - */ - int (*receive_frame)(AVCodecContext *avctx, AVFrame *frame); - /** - * Flush buffers. - * Will be called when seeking - */ - void (*flush)(AVCodecContext *); - /** - * Internal codec capabilities. - * See FF_CODEC_CAP_* in internal.h - */ - int caps_internal; - - /** - * Decoding only, a comma-separated list of bitstream filters to apply to - * packets before decoding. - */ - const char *bsfs; - - /** - * Array of pointers to hardware configurations supported by the codec, - * or NULL if no hardware supported. The array is terminated by a NULL - * pointer. - * - * The user can only access this field via avcodec_get_hw_config(). - */ - const struct AVCodecHWConfigInternal **hw_configs; -} AVCodec; - #if FF_API_CODEC_GET_SET attribute_deprecated int av_codec_get_max_lowres(const AVCodec *codec); @@ -3629,15 +2427,6 @@ int av_codec_get_max_lowres(const AVCodec *codec); struct MpegEncContext; -/** - * Retrieve supported hardware configurations for a codec. - * - * Values of index from zero to some maximum return the indexed configuration - * descriptor; all other values return NULL. If the codec does not support - * any hardware configurations then it will always return NULL. - */ -const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index); - /** * @defgroup lavc_hwaccel AVHWAccel * @@ -3939,175 +2728,6 @@ typedef struct AVSubtitle { int64_t pts; ///< Same as packet pts, in AV_TIME_BASE } AVSubtitle; -/** - * This struct describes the properties of an encoded stream. - * - * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must - * be allocated with avcodec_parameters_alloc() and freed with - * avcodec_parameters_free(). - */ -typedef struct AVCodecParameters { - /** - * General type of the encoded data. - */ - enum AVMediaType codec_type; - /** - * Specific type of the encoded data (the codec used). - */ - enum AVCodecID codec_id; - /** - * Additional information about the codec (corresponds to the AVI FOURCC). - */ - uint32_t codec_tag; - - /** - * Extra binary data needed for initializing the decoder, codec-dependent. - * - * Must be allocated with av_malloc() and will be freed by - * avcodec_parameters_free(). The allocated size of extradata must be at - * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding - * bytes zeroed. - */ - uint8_t *extradata; - /** - * Size of the extradata content in bytes. - */ - int extradata_size; - - /** - * - video: the pixel format, the value corresponds to enum AVPixelFormat. - * - audio: the sample format, the value corresponds to enum AVSampleFormat. - */ - int format; - - /** - * The average bitrate of the encoded data (in bits per second). - */ - int64_t bit_rate; - - /** - * The number of bits per sample in the codedwords. - * - * This is basically the bitrate per sample. It is mandatory for a bunch of - * formats to actually decode them. It's the number of bits for one sample in - * the actual coded bitstream. - * - * This could be for example 4 for ADPCM - * For PCM formats this matches bits_per_raw_sample - * Can be 0 - */ - int bits_per_coded_sample; - - /** - * This is the number of valid bits in each output sample. If the - * sample format has more bits, the least significant bits are additional - * padding bits, which are always 0. Use right shifts to reduce the sample - * to its actual size. For example, audio formats with 24 bit samples will - * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32. - * To get the original sample use "(int32_t)sample >> 8"." - * - * For ADPCM this might be 12 or 16 or similar - * Can be 0 - */ - int bits_per_raw_sample; - - /** - * Codec-specific bitstream restrictions that the stream conforms to. - */ - int profile; - int level; - - /** - * Video only. The dimensions of the video frame in pixels. - */ - int width; - int height; - - /** - * Video only. The aspect ratio (width / height) which a single pixel - * should have when displayed. - * - * When the aspect ratio is unknown / undefined, the numerator should be - * set to 0 (the denominator may have any value). - */ - AVRational sample_aspect_ratio; - - /** - * Video only. The order of the fields in interlaced video. - */ - enum AVFieldOrder field_order; - - /** - * Video only. Additional colorspace characteristics. - */ - enum AVColorRange color_range; - enum AVColorPrimaries color_primaries; - enum AVColorTransferCharacteristic color_trc; - enum AVColorSpace color_space; - enum AVChromaLocation chroma_location; - - /** - * Video only. Number of delayed frames. - */ - int video_delay; - - /** - * Audio only. The channel layout bitmask. May be 0 if the channel layout is - * unknown or unspecified, otherwise the number of bits set must be equal to - * the channels field. - */ - uint64_t channel_layout; - /** - * Audio only. The number of audio channels. - */ - int channels; - /** - * Audio only. The number of audio samples per second. - */ - int sample_rate; - /** - * Audio only. The number of bytes per coded audio frame, required by some - * formats. - * - * Corresponds to nBlockAlign in WAVEFORMATEX. - */ - int block_align; - /** - * Audio only. Audio frame size, if known. Required by some formats to be static. - */ - int frame_size; - - /** - * Audio only. The amount of padding (in samples) inserted by the encoder at - * the beginning of the audio. I.e. this number of leading decoded samples - * must be discarded by the caller to get the original audio without leading - * padding. - */ - int initial_padding; - /** - * Audio only. The amount of padding (in samples) appended by the encoder to - * the end of the audio. I.e. this number of decoded samples must be - * discarded by the caller from the end of the stream to get the original - * audio without any trailing padding. - */ - int trailing_padding; - /** - * Audio only. Number of samples to skip after a discontinuity. - */ - int seek_preroll; -} AVCodecParameters; - -/** - * Iterate over all registered codecs. - * - * @param opaque a pointer where libavcodec will store the iteration state. Must - * point to NULL to start the iteration. - * - * @return the next registered codec or NULL when the iteration is - * finished - */ -const AVCodec *av_codec_iterate(void **opaque); - #if FF_API_NEXT /** * If c is NULL, returns the first registered codec, @@ -4135,25 +2755,13 @@ const char *avcodec_license(void); #if FF_API_NEXT /** - * Register the codec codec and initialize libavcodec. - * - * @warning either this function or avcodec_register_all() must be called - * before any other libavcodec functions. - * - * @see avcodec_register_all() + * @deprecated Calling this function is unnecessary. */ attribute_deprecated void avcodec_register(AVCodec *codec); /** - * Register all the codecs, parsers and bitstream filters which were enabled at - * configuration time. If you do not call this function you can select exactly - * which formats you want to support, by using the individual registration - * functions. - * - * @see avcodec_register - * @see av_register_codec_parser - * @see av_register_bitstream_filter + * @deprecated Calling this function is unnecessary. */ attribute_deprecated void avcodec_register_all(void); @@ -4197,14 +2805,13 @@ int avcodec_get_context_defaults3(AVCodecContext *s, const AVCodec *codec); */ const AVClass *avcodec_get_class(void); -#if FF_API_COPY_CONTEXT +#if FF_API_GET_FRAME_CLASS /** - * Get the AVClass for AVFrame. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). + * @deprecated This function should not be used. */ +attribute_deprecated const AVClass *avcodec_get_frame_class(void); +#endif /** * Get the AVClass for AVSubtitleRect. It can be used in combination with @@ -4214,6 +2821,7 @@ const AVClass *avcodec_get_frame_class(void); */ const AVClass *avcodec_get_subtitle_rect_class(void); +#if FF_API_COPY_CONTEXT /** * Copy the settings of the source AVCodecContext into the destination * AVCodecContext. The resulting destination codec context will be @@ -4235,27 +2843,6 @@ attribute_deprecated int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src); #endif -/** - * Allocate a new AVCodecParameters and set its fields to default values - * (unknown/invalid/0). The returned struct must be freed with - * avcodec_parameters_free(). - */ -AVCodecParameters *avcodec_parameters_alloc(void); - -/** - * Free an AVCodecParameters instance and everything associated with it and - * write NULL to the supplied pointer. - */ -void avcodec_parameters_free(AVCodecParameters **par); - -/** - * Copy the contents of src to dst. Any allocated fields in dst are freed and - * replaced with newly allocated duplicates of the corresponding fields in src. - * - * @return >= 0 on success, a negative AVERROR code on failure. - */ -int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src); - /** * Fill the parameters struct based on the values from the supplied codec * context. Any allocated fields in par are freed and replaced with duplicates @@ -4291,7 +2878,6 @@ int avcodec_parameters_to_context(AVCodecContext *codec, * @ref avcodec_receive_frame()). * * @code - * avcodec_register_all(); * av_dict_set(&opts, "b", "2.5M", 0); * codec = avcodec_find_decoder(AV_CODEC_ID_H264); * if (!codec) @@ -4339,316 +2925,6 @@ int avcodec_close(AVCodecContext *avctx); */ void avsubtitle_free(AVSubtitle *sub); -/** - * @} - */ - -/** - * @addtogroup lavc_packet - * @{ - */ - -/** - * Allocate an AVPacket and set its fields to default values. The resulting - * struct must be freed using av_packet_free(). - * - * @return An AVPacket filled with default values or NULL on failure. - * - * @note this only allocates the AVPacket itself, not the data buffers. Those - * must be allocated through other means such as av_new_packet. - * - * @see av_new_packet - */ -AVPacket *av_packet_alloc(void); - -/** - * Create a new packet that references the same data as src. - * - * This is a shortcut for av_packet_alloc()+av_packet_ref(). - * - * @return newly created AVPacket on success, NULL on error. - * - * @see av_packet_alloc - * @see av_packet_ref - */ -AVPacket *av_packet_clone(const AVPacket *src); - -/** - * Free the packet, if the packet is reference counted, it will be - * unreferenced first. - * - * @param pkt packet to be freed. The pointer will be set to NULL. - * @note passing NULL is a no-op. - */ -void av_packet_free(AVPacket **pkt); - -/** - * Initialize optional fields of a packet with default values. - * - * Note, this does not touch the data and size members, which have to be - * initialized separately. - * - * @param pkt packet - */ -void av_init_packet(AVPacket *pkt); - -/** - * Allocate the payload of a packet and initialize its fields with - * default values. - * - * @param pkt packet - * @param size wanted payload size - * @return 0 if OK, AVERROR_xxx otherwise - */ -int av_new_packet(AVPacket *pkt, int size); - -/** - * Reduce packet size, correctly zeroing padding - * - * @param pkt packet - * @param size new size - */ -void av_shrink_packet(AVPacket *pkt, int size); - -/** - * Increase packet size, correctly zeroing padding - * - * @param pkt packet - * @param grow_by number of bytes by which to increase the size of the packet - */ -int av_grow_packet(AVPacket *pkt, int grow_by); - -/** - * Initialize a reference-counted packet from av_malloc()ed data. - * - * @param pkt packet to be initialized. This function will set the data, size, - * and buf fields, all others are left untouched. - * @param data Data allocated by av_malloc() to be used as packet data. If this - * function returns successfully, the data is owned by the underlying AVBuffer. - * The caller may not access the data through other means. - * @param size size of data in bytes, without the padding. I.e. the full buffer - * size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE. - * - * @return 0 on success, a negative AVERROR on error - */ -int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size); - -#if FF_API_AVPACKET_OLD_API -/** - * @warning This is a hack - the packet memory allocation stuff is broken. The - * packet is allocated if it was not really allocated. - * - * @deprecated Use av_packet_ref or av_packet_make_refcounted - */ -attribute_deprecated -int av_dup_packet(AVPacket *pkt); -/** - * Copy packet, including contents - * - * @return 0 on success, negative AVERROR on fail - * - * @deprecated Use av_packet_ref - */ -attribute_deprecated -int av_copy_packet(AVPacket *dst, const AVPacket *src); - -/** - * Copy packet side data - * - * @return 0 on success, negative AVERROR on fail - * - * @deprecated Use av_packet_copy_props - */ -attribute_deprecated -int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src); - -/** - * Free a packet. - * - * @deprecated Use av_packet_unref - * - * @param pkt packet to free - */ -attribute_deprecated -void av_free_packet(AVPacket *pkt); -#endif -/** - * Allocate new information of a packet. - * - * @param pkt packet - * @param type side information type - * @param size side information size - * @return pointer to fresh allocated data or NULL otherwise - */ -uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, - int size); - -/** - * Wrap an existing array as a packet side data. - * - * @param pkt packet - * @param type side information type - * @param data the side data array. It must be allocated with the av_malloc() - * family of functions. The ownership of the data is transferred to - * pkt. - * @param size side information size - * @return a non-negative number on success, a negative AVERROR code on - * failure. On failure, the packet is unchanged and the data remains - * owned by the caller. - */ -int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, - uint8_t *data, size_t size); - -/** - * Shrink the already allocated side data buffer - * - * @param pkt packet - * @param type side information type - * @param size new side information size - * @return 0 on success, < 0 on failure - */ -int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, - int size); - -/** - * Get side information from packet. - * - * @param pkt packet - * @param type desired side information type - * @param size pointer for side information size to store (optional) - * @return pointer to data if present or NULL otherwise - */ -uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, - int *size); - -#if FF_API_MERGE_SD_API -attribute_deprecated -int av_packet_merge_side_data(AVPacket *pkt); - -attribute_deprecated -int av_packet_split_side_data(AVPacket *pkt); -#endif - -const char *av_packet_side_data_name(enum AVPacketSideDataType type); - -/** - * Pack a dictionary for use in side_data. - * - * @param dict The dictionary to pack. - * @param size pointer to store the size of the returned data - * @return pointer to data if successful, NULL otherwise - */ -uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size); -/** - * Unpack a dictionary from side_data. - * - * @param data data from side_data - * @param size size of the data - * @param dict the metadata storage dictionary - * @return 0 on success, < 0 on failure - */ -int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict); - - -/** - * Convenience function to free all the side data stored. - * All the other fields stay untouched. - * - * @param pkt packet - */ -void av_packet_free_side_data(AVPacket *pkt); - -/** - * Setup a new reference to the data described by a given packet - * - * If src is reference-counted, setup dst as a new reference to the - * buffer in src. Otherwise allocate a new buffer in dst and copy the - * data from src into it. - * - * All the other fields are copied from src. - * - * @see av_packet_unref - * - * @param dst Destination packet - * @param src Source packet - * - * @return 0 on success, a negative AVERROR on error. - */ -int av_packet_ref(AVPacket *dst, const AVPacket *src); - -/** - * Wipe the packet. - * - * Unreference the buffer referenced by the packet and reset the - * remaining packet fields to their default values. - * - * @param pkt The packet to be unreferenced. - */ -void av_packet_unref(AVPacket *pkt); - -/** - * Move every field in src to dst and reset src. - * - * @see av_packet_unref - * - * @param src Source packet, will be reset - * @param dst Destination packet - */ -void av_packet_move_ref(AVPacket *dst, AVPacket *src); - -/** - * Copy only "properties" fields from src to dst. - * - * Properties for the purpose of this function are all the fields - * beside those related to the packet data (buf, data, size) - * - * @param dst Destination packet - * @param src Source packet - * - * @return 0 on success AVERROR on failure. - */ -int av_packet_copy_props(AVPacket *dst, const AVPacket *src); - -/** - * Ensure the data described by a given packet is reference counted. - * - * @note This function does not ensure that the reference will be writable. - * Use av_packet_make_writable instead for that purpose. - * - * @see av_packet_ref - * @see av_packet_make_writable - * - * @param pkt packet whose data should be made reference counted. - * - * @return 0 on success, a negative AVERROR on error. On failure, the - * packet is unchanged. - */ -int av_packet_make_refcounted(AVPacket *pkt); - -/** - * Create a writable reference for the data described by a given packet, - * avoiding data copy if possible. - * - * @param pkt Packet whose data should be made writable. - * - * @return 0 on success, a negative AVERROR on failure. On failure, the - * packet is unchanged. - */ -int av_packet_make_writable(AVPacket *pkt); - -/** - * Convert valid timing fields (timestamps / durations) in a packet from one - * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be - * ignored. - * - * @param pkt packet on which the conversion will be performed - * @param tb_src source timebase, in which the timing fields in pkt are - * expressed - * @param tb_dst destination timebase, to which the timing fields will be - * converted - */ -void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); - /** * @} */ @@ -4658,22 +2934,6 @@ void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); * @{ */ -/** - * Find a registered decoder with a matching codec ID. - * - * @param id AVCodecID of the requested decoder - * @return A decoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_decoder(enum AVCodecID id); - -/** - * Find a registered decoder with the specified name. - * - * @param name name of the requested decoder - * @return A decoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_decoder_by_name(const char *name); - /** * The default callback for AVCodecContext.get_buffer2(). It is made public so * it can be called by custom get_buffer2() implementations for decoders without @@ -4681,6 +2941,13 @@ AVCodec *avcodec_find_decoder_by_name(const char *name); */ int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags); +/** + * The default callback for AVCodecContext.get_encode_buffer(). It is made public so + * it can be called by custom get_encode_buffer() implementations for encoders without + * AV_CODEC_CAP_DR1 set. + */ +int avcodec_default_get_encode_buffer(AVCodecContext *s, AVPacket *pkt, int flags); + /** * Modify width and height values so that they will result in a memory * buffer that is acceptable for the codec if you do not use any horizontal @@ -4722,6 +2989,7 @@ int avcodec_enum_to_chroma_pos(int *xpos, int *ypos, enum AVChromaLocation pos); */ enum AVChromaLocation avcodec_chroma_pos_to_enum(int xpos, int ypos); +#if FF_API_OLD_ENCDEC /** * Decode the audio frame of size avpkt->size from avpkt->data into frame. * @@ -4828,6 +3096,7 @@ attribute_deprecated int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, int *got_picture_ptr, const AVPacket *avpkt); +#endif /** * Decode a subtitle message. @@ -4835,7 +3104,7 @@ int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, * If no subtitle could be decompressed, got_sub_ptr is zero. * Otherwise, the subtitle is stored in *sub. * Note that AV_CODEC_CAP_DR1 is not available for subtitle codecs. This is for - * simplicity, because the performance difference is expect to be negligible + * simplicity, because the performance difference is expected to be negligible * and reusing a get_buffer written for video codecs would probably perform badly * due to a potentially very different allocation pattern. * @@ -4851,7 +3120,7 @@ int avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture, * before packets may be fed to the decoder. * * @param avctx the codec context - * @param[out] sub The Preallocated AVSubtitle in which the decoded subtitle will be stored, + * @param[out] sub The preallocated AVSubtitle in which the decoded subtitle will be stored, * must be freed with avsubtitle_free if *got_sub_ptr is set. * @param[in,out] got_sub_ptr Zero if no subtitle could be decompressed, otherwise, it is nonzero. * @param[in] avpkt The input AVPacket containing the input buffer. @@ -4968,7 +3237,7 @@ int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame); * AVERROR(EINVAL): codec not opened, refcounted_frames not set, it is a * decoder, or requires flush * AVERROR(ENOMEM): failed to add packet to internal queue, or similar - * other errors: legitimate decoding errors + * other errors: legitimate encoding errors */ int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); @@ -4978,14 +3247,14 @@ int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame); * @param avctx codec context * @param avpkt This will be set to a reference-counted packet allocated by the * encoder. Note that the function will always call - * av_frame_unref(frame) before doing anything else. + * av_packet_unref(avpkt) before doing anything else. * @return 0 on success, otherwise negative error code: * AVERROR(EAGAIN): output is not available in the current state - user * must try to send input * AVERROR_EOF: the encoder has been fully flushed, and there will be * no more output packets - * AVERROR(EINVAL): codec not opened, or it is an encoder - * other errors: legitimate decoding errors + * AVERROR(EINVAL): codec not opened, or it is a decoder + * other errors: legitimate encoding errors */ int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt); @@ -5284,7 +3553,10 @@ typedef struct AVCodecParser { const uint8_t *buf, int buf_size); void (*parser_close)(AVCodecParserContext *s); int (*split)(AVCodecContext *avctx, const uint8_t *buf, int buf_size); +#if FF_API_NEXT + attribute_deprecated struct AVCodecParser *next; +#endif } AVCodecParser; /** @@ -5298,11 +3570,13 @@ typedef struct AVCodecParser { */ const AVCodecParser *av_parser_iterate(void **opaque); +#if FF_API_NEXT attribute_deprecated AVCodecParser *av_parser_next(const AVCodecParser *c); attribute_deprecated void av_register_codec_parser(AVCodecParser *parser); +#endif AVCodecParserContext *av_parser_init(int codec_id); /** @@ -5343,14 +3617,18 @@ int av_parser_parse2(AVCodecParserContext *s, int64_t pts, int64_t dts, int64_t pos); +#if FF_API_PARSER_CHANGE /** * @return 0 if the output buffer is a subset of the input, 1 if it is allocated and must be freed - * @deprecated use AVBitStreamFilter + * @deprecated Use dump_extradata, remove_extra or extract_extradata + * bitstream filters instead. */ +attribute_deprecated int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx, uint8_t **poutbuf, int *poutbuf_size, const uint8_t *buf, int buf_size, int keyframe); +#endif void av_parser_close(AVCodecParserContext *s); /** @@ -5363,22 +3641,7 @@ void av_parser_close(AVCodecParserContext *s); * @{ */ -/** - * Find a registered encoder with a matching codec ID. - * - * @param id AVCodecID of the requested encoder - * @return An encoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_encoder(enum AVCodecID id); - -/** - * Find a registered encoder with the specified name. - * - * @param name name of the requested encoder - * @return An encoder if one was found, NULL otherwise. - */ -AVCodec *avcodec_find_encoder_by_name(const char *name); - +#if FF_API_OLD_ENCDEC /** * Encode a frame of audio. * @@ -5417,7 +3680,9 @@ AVCodec *avcodec_find_encoder_by_name(const char *name); * not be used. * @return 0 on success, negative error code on failure * - * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead + * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead. + * If allowed and required, set AVCodecContext.get_encode_buffer to + * a custom function to pass user supplied output buffers. */ attribute_deprecated int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, @@ -5456,11 +3721,14 @@ int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, * not be used. * @return 0 on success, negative error code on failure * - * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead + * @deprecated use avcodec_send_frame()/avcodec_receive_packet() instead. + * If allowed and required, set AVCodecContext.get_encode_buffer to + * a custom function to pass user supplied output buffers. */ attribute_deprecated int avcodec_encode_video2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr); +#endif int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub); @@ -5567,12 +3835,6 @@ void avcodec_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int */ unsigned int avcodec_pix_fmt_to_codec_tag(enum AVPixelFormat pix_fmt); -/** - * @deprecated see av_get_pix_fmt_loss() - */ -int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, - int has_alpha); - /** * Find the best pixel format to convert to given a certain source pixel * format. When converting from one pixel format to another, information loss @@ -5594,15 +3856,24 @@ enum AVPixelFormat avcodec_find_best_pix_fmt_of_list(const enum AVPixelFormat *p enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); +#if FF_API_AVCODEC_PIX_FMT +/** + * @deprecated see av_get_pix_fmt_loss() + */ +attribute_deprecated +int avcodec_get_pix_fmt_loss(enum AVPixelFormat dst_pix_fmt, enum AVPixelFormat src_pix_fmt, + int has_alpha); /** * @deprecated see av_find_best_pix_fmt_of_2() */ +attribute_deprecated enum AVPixelFormat avcodec_find_best_pix_fmt_of_2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); attribute_deprecated enum AVPixelFormat avcodec_find_best_pix_fmt2(enum AVPixelFormat dst_pix_fmt1, enum AVPixelFormat dst_pix_fmt2, enum AVPixelFormat src_pix_fmt, int has_alpha, int *loss_ptr); +#endif enum AVPixelFormat avcodec_default_get_format(struct AVCodecContext *s, const enum AVPixelFormat * fmt); @@ -5682,13 +3953,21 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels, int buf_size, int align); /** - * Reset the internal decoder state / flush internal buffers. Should be called + * Reset the internal codec state / flush internal buffers. Should be called * e.g. when seeking or when switching to a different stream. * - * @note when refcounted frames are not used (i.e. avctx->refcounted_frames is 0), - * this invalidates the frames previously returned from the decoder. When - * refcounted frames are used, the decoder just releases any references it might - * keep internally, but the caller's reference remains valid. + * @note for decoders, when refcounted frames are not used + * (i.e. avctx->refcounted_frames is 0), this invalidates the frames previously + * returned from the decoder. When refcounted frames are used, the decoder just + * releases any references it might keep internally, but the caller's reference + * remains valid. + * + * @note for encoders, this function will only do something if the encoder + * declares support for AV_CODEC_CAP_ENCODER_FLUSH. When called, the encoder + * will drain any remaining packets, and can then be re-used for a different + * stream (as opposed to sending a null frame which will leave the encoder + * in a permanent EOF state after draining). This can be desirable if the + * cost of tearing down and replacing the encoder instance is high. */ void avcodec_flush_buffers(AVCodecContext *avctx); @@ -5746,106 +4025,7 @@ typedef struct AVBitStreamFilterContext { */ char *args; } AVBitStreamFilterContext; -#endif -typedef struct AVBSFInternal AVBSFInternal; - -/** - * The bitstream filter state. - * - * This struct must be allocated with av_bsf_alloc() and freed with - * av_bsf_free(). - * - * The fields in the struct will only be changed (by the caller or by the - * filter) as described in their documentation, and are to be considered - * immutable otherwise. - */ -typedef struct AVBSFContext { - /** - * A class for logging and AVOptions - */ - const AVClass *av_class; - - /** - * The bitstream filter this context is an instance of. - */ - const struct AVBitStreamFilter *filter; - - /** - * Opaque libavcodec internal data. Must not be touched by the caller in any - * way. - */ - AVBSFInternal *internal; - - /** - * Opaque filter-specific private data. If filter->priv_class is non-NULL, - * this is an AVOptions-enabled struct. - */ - void *priv_data; - - /** - * Parameters of the input stream. This field is allocated in - * av_bsf_alloc(), it needs to be filled by the caller before - * av_bsf_init(). - */ - AVCodecParameters *par_in; - - /** - * Parameters of the output stream. This field is allocated in - * av_bsf_alloc(), it is set by the filter in av_bsf_init(). - */ - AVCodecParameters *par_out; - - /** - * The timebase used for the timestamps of the input packets. Set by the - * caller before av_bsf_init(). - */ - AVRational time_base_in; - - /** - * The timebase used for the timestamps of the output packets. Set by the - * filter in av_bsf_init(). - */ - AVRational time_base_out; -} AVBSFContext; - -typedef struct AVBitStreamFilter { - const char *name; - - /** - * A list of codec ids supported by the filter, terminated by - * AV_CODEC_ID_NONE. - * May be NULL, in that case the bitstream filter works with any codec id. - */ - const enum AVCodecID *codec_ids; - - /** - * A class for the private data, used to declare bitstream filter private - * AVOptions. This field is NULL for bitstream filters that do not declare - * any options. - * - * If this field is non-NULL, the first member of the filter private data - * must be a pointer to AVClass, which will be set by libavcodec generic - * code to this class. - */ - const AVClass *priv_class; - - /***************************************************************** - * No fields below this line are part of the public API. They - * may not be used outside of libavcodec and can be changed and - * removed at will. - * New public fields should be added right above. - ***************************************************************** - */ - - int priv_data_size; - int (*init)(AVBSFContext *ctx); - int (*filter)(AVBSFContext *ctx, AVPacket *pkt); - void (*close)(AVBSFContext *ctx); - void (*flush)(AVBSFContext *ctx); -} AVBitStreamFilter; - -#if FF_API_OLD_BSF /** * @deprecated the old bitstream filtering API (using AVBitStreamFilterContext) * is deprecated. Use the new bitstream filtering API (using AVBSFContext). @@ -5885,194 +4065,11 @@ attribute_deprecated const AVBitStreamFilter *av_bitstream_filter_next(const AVBitStreamFilter *f); #endif -/** - * @return a bitstream filter with the specified name or NULL if no such - * bitstream filter exists. - */ -const AVBitStreamFilter *av_bsf_get_by_name(const char *name); - -/** - * Iterate over all registered bitstream filters. - * - * @param opaque a pointer where libavcodec will store the iteration state. Must - * point to NULL to start the iteration. - * - * @return the next registered bitstream filter or NULL when the iteration is - * finished - */ -const AVBitStreamFilter *av_bsf_iterate(void **opaque); #if FF_API_NEXT attribute_deprecated const AVBitStreamFilter *av_bsf_next(void **opaque); #endif -/** - * Allocate a context for a given bitstream filter. The caller must fill in the - * context parameters as described in the documentation and then call - * av_bsf_init() before sending any data to the filter. - * - * @param filter the filter for which to allocate an instance. - * @param ctx a pointer into which the pointer to the newly-allocated context - * will be written. It must be freed with av_bsf_free() after the - * filtering is done. - * - * @return 0 on success, a negative AVERROR code on failure - */ -int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx); - -/** - * Prepare the filter for use, after all the parameters and options have been - * set. - */ -int av_bsf_init(AVBSFContext *ctx); - -/** - * Submit a packet for filtering. - * - * After sending each packet, the filter must be completely drained by calling - * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or - * AVERROR_EOF. - * - * @param pkt the packet to filter. The bitstream filter will take ownership of - * the packet and reset the contents of pkt. pkt is not touched if an error occurs. - * This parameter may be NULL, which signals the end of the stream (i.e. no more - * packets will be sent). That will cause the filter to output any packets it - * may have buffered internally. - * - * @return 0 on success, a negative AVERROR on error. - */ -int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); - -/** - * Retrieve a filtered packet. - * - * @param[out] pkt this struct will be filled with the contents of the filtered - * packet. It is owned by the caller and must be freed using - * av_packet_unref() when it is no longer needed. - * This parameter should be "clean" (i.e. freshly allocated - * with av_packet_alloc() or unreffed with av_packet_unref()) - * when this function is called. If this function returns - * successfully, the contents of pkt will be completely - * overwritten by the returned data. On failure, pkt is not - * touched. - * - * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the - * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there - * will be no further output from the filter. Another negative AVERROR value if - * an error occurs. - * - * @note one input packet may result in several output packets, so after sending - * a packet with av_bsf_send_packet(), this function needs to be called - * repeatedly until it stops returning 0. It is also possible for a filter to - * output fewer packets than were sent to it, so this function may return - * AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call. - */ -int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt); - -/** - * Reset the internal bitstream filter state / flush internal buffers. - */ -void av_bsf_flush(AVBSFContext *ctx); - -/** - * Free a bitstream filter context and everything associated with it; write NULL - * into the supplied pointer. - */ -void av_bsf_free(AVBSFContext **ctx); - -/** - * Get the AVClass for AVBSFContext. It can be used in combination with - * AV_OPT_SEARCH_FAKE_OBJ for examining options. - * - * @see av_opt_find(). - */ -const AVClass *av_bsf_get_class(void); - -/** - * Structure for chain/list of bitstream filters. - * Empty list can be allocated by av_bsf_list_alloc(). - */ -typedef struct AVBSFList AVBSFList; - -/** - * Allocate empty list of bitstream filters. - * The list must be later freed by av_bsf_list_free() - * or finalized by av_bsf_list_finalize(). - * - * @return Pointer to @ref AVBSFList on success, NULL in case of failure - */ -AVBSFList *av_bsf_list_alloc(void); - -/** - * Free list of bitstream filters. - * - * @param lst Pointer to pointer returned by av_bsf_list_alloc() - */ -void av_bsf_list_free(AVBSFList **lst); - -/** - * Append bitstream filter to the list of bitstream filters. - * - * @param lst List to append to - * @param bsf Filter context to be appended - * - * @return >=0 on success, negative AVERROR in case of failure - */ -int av_bsf_list_append(AVBSFList *lst, AVBSFContext *bsf); - -/** - * Construct new bitstream filter context given it's name and options - * and append it to the list of bitstream filters. - * - * @param lst List to append to - * @param bsf_name Name of the bitstream filter - * @param options Options for the bitstream filter, can be set to NULL - * - * @return >=0 on success, negative AVERROR in case of failure - */ -int av_bsf_list_append2(AVBSFList *lst, const char * bsf_name, AVDictionary **options); -/** - * Finalize list of bitstream filters. - * - * This function will transform @ref AVBSFList to single @ref AVBSFContext, - * so the whole chain of bitstream filters can be treated as single filter - * freshly allocated by av_bsf_alloc(). - * If the call is successful, @ref AVBSFList structure is freed and lst - * will be set to NULL. In case of failure, caller is responsible for - * freeing the structure by av_bsf_list_free() - * - * @param lst Filter list structure to be transformed - * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure - * representing the chain of bitstream filters - * - * @return >=0 on success, negative AVERROR in case of failure - */ -int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf); - -/** - * Parse string describing list of bitstream filters and create single - * @ref AVBSFContext describing the whole chain of bitstream filters. - * Resulting @ref AVBSFContext can be treated as any other @ref AVBSFContext freshly - * allocated by av_bsf_alloc(). - * - * @param str String describing chain of bitstream filters in format - * `bsf1[=opt1=val1:opt2=val2][,bsf2]` - * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure - * representing the chain of bitstream filters - * - * @return >=0 on success, negative AVERROR in case of failure - */ -int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf); - -/** - * Get null/pass-through bitstream filter. - * - * @param[out] bsf Pointer to be set to new instance of pass-through bitstream filter - * - * @return - */ -int av_bsf_get_null_filter(AVBSFContext **bsf); - /* memory */ /** @@ -6163,53 +4160,12 @@ attribute_deprecated int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)); #endif -/** - * Get the type of the given codec. - */ -enum AVMediaType avcodec_get_type(enum AVCodecID codec_id); - -/** - * Get the name of a codec. - * @return a static string identifying the codec; never NULL - */ -const char *avcodec_get_name(enum AVCodecID id); - /** * @return a positive value if s is open (i.e. avcodec_open2() was called on it * with no corresponding avcodec_close()), 0 otherwise. */ int avcodec_is_open(AVCodecContext *s); -/** - * @return a non-zero number if codec is an encoder, zero otherwise - */ -int av_codec_is_encoder(const AVCodec *codec); - -/** - * @return a non-zero number if codec is a decoder, zero otherwise - */ -int av_codec_is_decoder(const AVCodec *codec); - -/** - * @return descriptor for given codec ID or NULL if no descriptor exists. - */ -const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id); - -/** - * Iterate over all codec descriptors known to libavcodec. - * - * @param prev previous descriptor. NULL to get the first descriptor. - * - * @return next descriptor or NULL after the last descriptor - */ -const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev); - -/** - * @return codec descriptor with the given name or NULL if no such descriptor - * exists. - */ -const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name); - /** * Allocate a CPB properties structure and initialize its fields to default * values. diff --git a/winlibs/include/libavcodec/avdct.h b/winlibs/include/libavcodec/avdct.h new file mode 100644 index 00000000..6411fab6 --- /dev/null +++ b/winlibs/include/libavcodec/avdct.h @@ -0,0 +1,88 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_AVDCT_H +#define AVCODEC_AVDCT_H + +#include "libavutil/opt.h" + +/** + * AVDCT context. + * @note function pointers can be NULL if the specific features have been + * disabled at build time. + */ +typedef struct AVDCT { + const AVClass *av_class; + + void (*idct)(int16_t *block /* align 16 */); + + /** + * IDCT input permutation. + * Several optimized IDCTs need a permutated input (relative to the + * normal order of the reference IDCT). + * This permutation must be performed before the idct_put/add. + * Note, normally this can be merged with the zigzag/alternate scan
+ * An example to avoid confusion: + * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...) + * - (x -> reference DCT -> reference IDCT -> x) + * - (x -> reference DCT -> simple_mmx_perm = idct_permutation + * -> simple_idct_mmx -> x) + * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant + * -> simple_idct_mmx -> ...) + */ + uint8_t idct_permutation[64]; + + void (*fdct)(int16_t *block /* align 16 */); + + + /** + * DCT algorithm. + * must use AVOptions to set this field. + */ + int dct_algo; + + /** + * IDCT algorithm. + * must use AVOptions to set this field. + */ + int idct_algo; + + void (*get_pixels)(int16_t *block /* align 16 */, + const uint8_t *pixels /* align 8 */, + ptrdiff_t line_size); + + int bits_per_sample; + + void (*get_pixels_unaligned)(int16_t *block /* align 16 */, + const uint8_t *pixels, + ptrdiff_t line_size); +} AVDCT; + +/** + * Allocates a AVDCT context. + * This needs to be initialized with avcodec_dct_init() after optionally + * configuring it with AVOptions. + * + * To free it use av_free() + */ +AVDCT *avcodec_dct_alloc(void); +int avcodec_dct_init(AVDCT *); + +const AVClass *avcodec_dct_get_class(void); + +#endif /* AVCODEC_AVDCT_H */ diff --git a/winlibs/include/libavcodec/bsf.h b/winlibs/include/libavcodec/bsf.h new file mode 100644 index 00000000..3b5faa85 --- /dev/null +++ b/winlibs/include/libavcodec/bsf.h @@ -0,0 +1,325 @@ +/* + * Bitstream filters public API + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_BSF_H +#define AVCODEC_BSF_H + +#include "libavutil/dict.h" +#include "libavutil/log.h" +#include "libavutil/rational.h" + +#include "codec_id.h" +#include "codec_par.h" +#include "packet.h" + +/** + * @addtogroup lavc_core + * @{ + */ + +typedef struct AVBSFInternal AVBSFInternal; + +/** + * The bitstream filter state. + * + * This struct must be allocated with av_bsf_alloc() and freed with + * av_bsf_free(). + * + * The fields in the struct will only be changed (by the caller or by the + * filter) as described in their documentation, and are to be considered + * immutable otherwise. + */ +typedef struct AVBSFContext { + /** + * A class for logging and AVOptions + */ + const AVClass *av_class; + + /** + * The bitstream filter this context is an instance of. + */ + const struct AVBitStreamFilter *filter; + + /** + * Opaque libavcodec internal data. Must not be touched by the caller in any + * way. + */ + AVBSFInternal *internal; + + /** + * Opaque filter-specific private data. If filter->priv_class is non-NULL, + * this is an AVOptions-enabled struct. + */ + void *priv_data; + + /** + * Parameters of the input stream. This field is allocated in + * av_bsf_alloc(), it needs to be filled by the caller before + * av_bsf_init(). + */ + AVCodecParameters *par_in; + + /** + * Parameters of the output stream. This field is allocated in + * av_bsf_alloc(), it is set by the filter in av_bsf_init(). + */ + AVCodecParameters *par_out; + + /** + * The timebase used for the timestamps of the input packets. Set by the + * caller before av_bsf_init(). + */ + AVRational time_base_in; + + /** + * The timebase used for the timestamps of the output packets. Set by the + * filter in av_bsf_init(). + */ + AVRational time_base_out; +} AVBSFContext; + +typedef struct AVBitStreamFilter { + const char *name; + + /** + * A list of codec ids supported by the filter, terminated by + * AV_CODEC_ID_NONE. + * May be NULL, in that case the bitstream filter works with any codec id. + */ + const enum AVCodecID *codec_ids; + + /** + * A class for the private data, used to declare bitstream filter private + * AVOptions. This field is NULL for bitstream filters that do not declare + * any options. + * + * If this field is non-NULL, the first member of the filter private data + * must be a pointer to AVClass, which will be set by libavcodec generic + * code to this class. + */ + const AVClass *priv_class; + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavcodec and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + + int priv_data_size; + int (*init)(AVBSFContext *ctx); + int (*filter)(AVBSFContext *ctx, AVPacket *pkt); + void (*close)(AVBSFContext *ctx); + void (*flush)(AVBSFContext *ctx); +} AVBitStreamFilter; + +/** + * @return a bitstream filter with the specified name or NULL if no such + * bitstream filter exists. + */ +const AVBitStreamFilter *av_bsf_get_by_name(const char *name); + +/** + * Iterate over all registered bitstream filters. + * + * @param opaque a pointer where libavcodec will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the next registered bitstream filter or NULL when the iteration is + * finished + */ +const AVBitStreamFilter *av_bsf_iterate(void **opaque); + +/** + * Allocate a context for a given bitstream filter. The caller must fill in the + * context parameters as described in the documentation and then call + * av_bsf_init() before sending any data to the filter. + * + * @param filter the filter for which to allocate an instance. + * @param ctx a pointer into which the pointer to the newly-allocated context + * will be written. It must be freed with av_bsf_free() after the + * filtering is done. + * + * @return 0 on success, a negative AVERROR code on failure + */ +int av_bsf_alloc(const AVBitStreamFilter *filter, AVBSFContext **ctx); + +/** + * Prepare the filter for use, after all the parameters and options have been + * set. + */ +int av_bsf_init(AVBSFContext *ctx); + +/** + * Submit a packet for filtering. + * + * After sending each packet, the filter must be completely drained by calling + * av_bsf_receive_packet() repeatedly until it returns AVERROR(EAGAIN) or + * AVERROR_EOF. + * + * @param pkt the packet to filter. The bitstream filter will take ownership of + * the packet and reset the contents of pkt. pkt is not touched if an error occurs. + * If pkt is empty (i.e. NULL, or pkt->data is NULL and pkt->side_data_elems zero), + * it signals the end of the stream (i.e. no more non-empty packets will be sent; + * sending more empty packets does nothing) and will cause the filter to output + * any packets it may have buffered internally. + * + * @return 0 on success. AVERROR(EAGAIN) if packets need to be retrieved from the + * filter (using av_bsf_receive_packet()) before new input can be consumed. Another + * negative AVERROR value if an error occurs. + */ +int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt); + +/** + * Retrieve a filtered packet. + * + * @param[out] pkt this struct will be filled with the contents of the filtered + * packet. It is owned by the caller and must be freed using + * av_packet_unref() when it is no longer needed. + * This parameter should be "clean" (i.e. freshly allocated + * with av_packet_alloc() or unreffed with av_packet_unref()) + * when this function is called. If this function returns + * successfully, the contents of pkt will be completely + * overwritten by the returned data. On failure, pkt is not + * touched. + * + * @return 0 on success. AVERROR(EAGAIN) if more packets need to be sent to the + * filter (using av_bsf_send_packet()) to get more output. AVERROR_EOF if there + * will be no further output from the filter. Another negative AVERROR value if + * an error occurs. + * + * @note one input packet may result in several output packets, so after sending + * a packet with av_bsf_send_packet(), this function needs to be called + * repeatedly until it stops returning 0. It is also possible for a filter to + * output fewer packets than were sent to it, so this function may return + * AVERROR(EAGAIN) immediately after a successful av_bsf_send_packet() call. + */ +int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt); + +/** + * Reset the internal bitstream filter state. Should be called e.g. when seeking. + */ +void av_bsf_flush(AVBSFContext *ctx); + +/** + * Free a bitstream filter context and everything associated with it; write NULL + * into the supplied pointer. + */ +void av_bsf_free(AVBSFContext **ctx); + +/** + * Get the AVClass for AVBSFContext. It can be used in combination with + * AV_OPT_SEARCH_FAKE_OBJ for examining options. + * + * @see av_opt_find(). + */ +const AVClass *av_bsf_get_class(void); + +/** + * Structure for chain/list of bitstream filters. + * Empty list can be allocated by av_bsf_list_alloc(). + */ +typedef struct AVBSFList AVBSFList; + +/** + * Allocate empty list of bitstream filters. + * The list must be later freed by av_bsf_list_free() + * or finalized by av_bsf_list_finalize(). + * + * @return Pointer to @ref AVBSFList on success, NULL in case of failure + */ +AVBSFList *av_bsf_list_alloc(void); + +/** + * Free list of bitstream filters. + * + * @param lst Pointer to pointer returned by av_bsf_list_alloc() + */ +void av_bsf_list_free(AVBSFList **lst); + +/** + * Append bitstream filter to the list of bitstream filters. + * + * @param lst List to append to + * @param bsf Filter context to be appended + * + * @return >=0 on success, negative AVERROR in case of failure + */ +int av_bsf_list_append(AVBSFList *lst, AVBSFContext *bsf); + +/** + * Construct new bitstream filter context given it's name and options + * and append it to the list of bitstream filters. + * + * @param lst List to append to + * @param bsf_name Name of the bitstream filter + * @param options Options for the bitstream filter, can be set to NULL + * + * @return >=0 on success, negative AVERROR in case of failure + */ +int av_bsf_list_append2(AVBSFList *lst, const char * bsf_name, AVDictionary **options); +/** + * Finalize list of bitstream filters. + * + * This function will transform @ref AVBSFList to single @ref AVBSFContext, + * so the whole chain of bitstream filters can be treated as single filter + * freshly allocated by av_bsf_alloc(). + * If the call is successful, @ref AVBSFList structure is freed and lst + * will be set to NULL. In case of failure, caller is responsible for + * freeing the structure by av_bsf_list_free() + * + * @param lst Filter list structure to be transformed + * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure + * representing the chain of bitstream filters + * + * @return >=0 on success, negative AVERROR in case of failure + */ +int av_bsf_list_finalize(AVBSFList **lst, AVBSFContext **bsf); + +/** + * Parse string describing list of bitstream filters and create single + * @ref AVBSFContext describing the whole chain of bitstream filters. + * Resulting @ref AVBSFContext can be treated as any other @ref AVBSFContext freshly + * allocated by av_bsf_alloc(). + * + * @param str String describing chain of bitstream filters in format + * `bsf1[=opt1=val1:opt2=val2][,bsf2]` + * @param[out] bsf Pointer to be set to newly created @ref AVBSFContext structure + * representing the chain of bitstream filters + * + * @return >=0 on success, negative AVERROR in case of failure + */ +int av_bsf_list_parse_str(const char *str, AVBSFContext **bsf); + +/** + * Get null/pass-through bitstream filter. + * + * @param[out] bsf Pointer to be set to new instance of pass-through bitstream filter + * + * @return + */ +int av_bsf_get_null_filter(AVBSFContext **bsf); + +/** + * @} + */ + +#endif // AVCODEC_BSF_H diff --git a/winlibs/include/libavcodec/codec.h b/winlibs/include/libavcodec/codec.h new file mode 100644 index 00000000..50a22f6e --- /dev/null +++ b/winlibs/include/libavcodec/codec.h @@ -0,0 +1,480 @@ +/* + * AVCodec public API + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_CODEC_H +#define AVCODEC_CODEC_H + +#include + +#include "libavutil/avutil.h" +#include "libavutil/hwcontext.h" +#include "libavutil/log.h" +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" +#include "libavutil/samplefmt.h" + +#include "libavcodec/codec_id.h" +#include "libavcodec/version.h" + +/** + * @addtogroup lavc_core + * @{ + */ + +/** + * Decoder can use draw_horiz_band callback. + */ +#define AV_CODEC_CAP_DRAW_HORIZ_BAND (1 << 0) +/** + * Codec uses get_buffer() or get_encode_buffer() for allocating buffers and + * supports custom allocators. + * If not set, it might not use get_buffer() or get_encode_buffer() at all, or + * use operations that assume the buffer was allocated by + * avcodec_default_get_buffer2 or avcodec_default_get_encode_buffer. + */ +#define AV_CODEC_CAP_DR1 (1 << 1) +#define AV_CODEC_CAP_TRUNCATED (1 << 3) +/** + * Encoder or decoder requires flushing with NULL input at the end in order to + * give the complete and correct output. + * + * NOTE: If this flag is not set, the codec is guaranteed to never be fed with + * with NULL data. The user can still send NULL data to the public encode + * or decode function, but libavcodec will not pass it along to the codec + * unless this flag is set. + * + * Decoders: + * The decoder has a non-zero delay and needs to be fed with avpkt->data=NULL, + * avpkt->size=0 at the end to get the delayed data until the decoder no longer + * returns frames. + * + * Encoders: + * The encoder needs to be fed with NULL data at the end of encoding until the + * encoder no longer returns data. + * + * NOTE: For encoders implementing the AVCodec.encode2() function, setting this + * flag also means that the encoder must set the pts and duration for + * each output packet. If this flag is not set, the pts and duration will + * be determined by libavcodec from the input frame. + */ +#define AV_CODEC_CAP_DELAY (1 << 5) +/** + * Codec can be fed a final frame with a smaller size. + * This can be used to prevent truncation of the last audio samples. + */ +#define AV_CODEC_CAP_SMALL_LAST_FRAME (1 << 6) + +/** + * Codec can output multiple frames per AVPacket + * Normally demuxers return one frame at a time, demuxers which do not do + * are connected to a parser to split what they return into proper frames. + * This flag is reserved to the very rare category of codecs which have a + * bitstream that cannot be split into frames without timeconsuming + * operations like full decoding. Demuxers carrying such bitstreams thus + * may return multiple frames in a packet. This has many disadvantages like + * prohibiting stream copy in many cases thus it should only be considered + * as a last resort. + */ +#define AV_CODEC_CAP_SUBFRAMES (1 << 8) +/** + * Codec is experimental and is thus avoided in favor of non experimental + * encoders + */ +#define AV_CODEC_CAP_EXPERIMENTAL (1 << 9) +/** + * Codec should fill in channel configuration and samplerate instead of container + */ +#define AV_CODEC_CAP_CHANNEL_CONF (1 << 10) +/** + * Codec supports frame-level multithreading. + */ +#define AV_CODEC_CAP_FRAME_THREADS (1 << 12) +/** + * Codec supports slice-based (or partition-based) multithreading. + */ +#define AV_CODEC_CAP_SLICE_THREADS (1 << 13) +/** + * Codec supports changed parameters at any point. + */ +#define AV_CODEC_CAP_PARAM_CHANGE (1 << 14) +/** + * Codec supports multithreading through a method other than slice- or + * frame-level multithreading. Typically this marks wrappers around + * multithreading-capable external libraries. + */ +#define AV_CODEC_CAP_OTHER_THREADS (1 << 15) +#if FF_API_AUTO_THREADS +#define AV_CODEC_CAP_AUTO_THREADS AV_CODEC_CAP_OTHER_THREADS +#endif +/** + * Audio encoder supports receiving a different number of samples in each call. + */ +#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE (1 << 16) +/** + * Decoder is not a preferred choice for probing. + * This indicates that the decoder is not a good choice for probing. + * It could for example be an expensive to spin up hardware decoder, + * or it could simply not provide a lot of useful information about + * the stream. + * A decoder marked with this flag should only be used as last resort + * choice for probing. + */ +#define AV_CODEC_CAP_AVOID_PROBING (1 << 17) + +#if FF_API_UNUSED_CODEC_CAPS +/** + * Deprecated and unused. Use AVCodecDescriptor.props instead + */ +#define AV_CODEC_CAP_INTRA_ONLY 0x40000000 +/** + * Deprecated and unused. Use AVCodecDescriptor.props instead + */ +#define AV_CODEC_CAP_LOSSLESS 0x80000000 +#endif + +/** + * Codec is backed by a hardware implementation. Typically used to + * identify a non-hwaccel hardware decoder. For information about hwaccels, use + * avcodec_get_hw_config() instead. + */ +#define AV_CODEC_CAP_HARDWARE (1 << 18) + +/** + * Codec is potentially backed by a hardware implementation, but not + * necessarily. This is used instead of AV_CODEC_CAP_HARDWARE, if the + * implementation provides some sort of internal fallback. + */ +#define AV_CODEC_CAP_HYBRID (1 << 19) + +/** + * This codec takes the reordered_opaque field from input AVFrames + * and returns it in the corresponding field in AVCodecContext after + * encoding. + */ +#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE (1 << 20) + +/** + * This encoder can be flushed using avcodec_flush_buffers(). If this flag is + * not set, the encoder must be closed and reopened to ensure that no frames + * remain pending. + */ +#define AV_CODEC_CAP_ENCODER_FLUSH (1 << 21) + +/** + * AVProfile. + */ +typedef struct AVProfile { + int profile; + const char *name; ///< short name for the profile +} AVProfile; + +typedef struct AVCodecDefault AVCodecDefault; + +struct AVCodecContext; +struct AVSubtitle; +struct AVPacket; + +/** + * AVCodec. + */ +typedef struct AVCodec { + /** + * Name of the codec implementation. + * The name is globally unique among encoders and among decoders (but an + * encoder and a decoder can share the same name). + * This is the primary way to find a codec from the user perspective. + */ + const char *name; + /** + * Descriptive name for the codec, meant to be more human readable than name. + * You should use the NULL_IF_CONFIG_SMALL() macro to define it. + */ + const char *long_name; + enum AVMediaType type; + enum AVCodecID id; + /** + * Codec capabilities. + * see AV_CODEC_CAP_* + */ + int capabilities; + const AVRational *supported_framerates; ///< array of supported framerates, or NULL if any, array is terminated by {0,0} + const enum AVPixelFormat *pix_fmts; ///< array of supported pixel formats, or NULL if unknown, array is terminated by -1 + const int *supported_samplerates; ///< array of supported audio samplerates, or NULL if unknown, array is terminated by 0 + const enum AVSampleFormat *sample_fmts; ///< array of supported sample formats, or NULL if unknown, array is terminated by -1 + const uint64_t *channel_layouts; ///< array of support channel layouts, or NULL if unknown. array is terminated by 0 + uint8_t max_lowres; ///< maximum value for lowres supported by the decoder + const AVClass *priv_class; ///< AVClass for the private context + const AVProfile *profiles; ///< array of recognized profiles, or NULL if unknown, array is terminated by {FF_PROFILE_UNKNOWN} + + /** + * Group name of the codec implementation. + * This is a short symbolic name of the wrapper backing this codec. A + * wrapper uses some kind of external implementation for the codec, such + * as an external library, or a codec implementation provided by the OS or + * the hardware. + * If this field is NULL, this is a builtin, libavcodec native codec. + * If non-NULL, this will be the suffix in AVCodec.name in most cases + * (usually AVCodec.name will be of the form "_"). + */ + const char *wrapper_name; + + /***************************************************************** + * No fields below this line are part of the public API. They + * may not be used outside of libavcodec and can be changed and + * removed at will. + * New public fields should be added right above. + ***************************************************************** + */ + int priv_data_size; +#if FF_API_NEXT + struct AVCodec *next; +#endif + /** + * @name Frame-level threading support functions + * @{ + */ + /** + * Copy necessary context variables from a previous thread context to the current one. + * If not defined, the next thread will start automatically; otherwise, the codec + * must call ff_thread_finish_setup(). + * + * dst and src will (rarely) point to the same context, in which case memcpy should be skipped. + */ + int (*update_thread_context)(struct AVCodecContext *dst, const struct AVCodecContext *src); + /** @} */ + + /** + * Private codec-specific defaults. + */ + const AVCodecDefault *defaults; + + /** + * Initialize codec static data, called from av_codec_iterate(). + * + * This is not intended for time consuming operations as it is + * run for every codec regardless of that codec being used. + */ + void (*init_static_data)(struct AVCodec *codec); + + int (*init)(struct AVCodecContext *); + int (*encode_sub)(struct AVCodecContext *, uint8_t *buf, int buf_size, + const struct AVSubtitle *sub); + /** + * Encode data to an AVPacket. + * + * @param avctx codec context + * @param avpkt output AVPacket + * @param[in] frame AVFrame containing the raw data to be encoded + * @param[out] got_packet_ptr encoder sets to 0 or 1 to indicate that a + * non-empty packet was returned in avpkt. + * @return 0 on success, negative error code on failure + */ + int (*encode2)(struct AVCodecContext *avctx, struct AVPacket *avpkt, + const struct AVFrame *frame, int *got_packet_ptr); + /** + * Decode picture or subtitle data. + * + * @param avctx codec context + * @param outdata codec type dependent output struct + * @param[out] got_frame_ptr decoder sets to 0 or 1 to indicate that a + * non-empty frame or subtitle was returned in + * outdata. + * @param[in] avpkt AVPacket containing the data to be decoded + * @return amount of bytes read from the packet on success, negative error + * code on failure + */ + int (*decode)(struct AVCodecContext *avctx, void *outdata, + int *got_frame_ptr, struct AVPacket *avpkt); + int (*close)(struct AVCodecContext *); + /** + * Encode API with decoupled frame/packet dataflow. This function is called + * to get one output packet. It should call ff_encode_get_frame() to obtain + * input data. + */ + int (*receive_packet)(struct AVCodecContext *avctx, struct AVPacket *avpkt); + + /** + * Decode API with decoupled packet/frame dataflow. This function is called + * to get one output frame. It should call ff_decode_get_packet() to obtain + * input data. + */ + int (*receive_frame)(struct AVCodecContext *avctx, struct AVFrame *frame); + /** + * Flush buffers. + * Will be called when seeking + */ + void (*flush)(struct AVCodecContext *); + /** + * Internal codec capabilities. + * See FF_CODEC_CAP_* in internal.h + */ + int caps_internal; + + /** + * Decoding only, a comma-separated list of bitstream filters to apply to + * packets before decoding. + */ + const char *bsfs; + + /** + * Array of pointers to hardware configurations supported by the codec, + * or NULL if no hardware supported. The array is terminated by a NULL + * pointer. + * + * The user can only access this field via avcodec_get_hw_config(). + */ + const struct AVCodecHWConfigInternal *const *hw_configs; + + /** + * List of supported codec_tags, terminated by FF_CODEC_TAGS_END. + */ + const uint32_t *codec_tags; +} AVCodec; + +/** + * Iterate over all registered codecs. + * + * @param opaque a pointer where libavcodec will store the iteration state. Must + * point to NULL to start the iteration. + * + * @return the next registered codec or NULL when the iteration is + * finished + */ +const AVCodec *av_codec_iterate(void **opaque); + +/** + * Find a registered decoder with a matching codec ID. + * + * @param id AVCodecID of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder(enum AVCodecID id); + +/** + * Find a registered decoder with the specified name. + * + * @param name name of the requested decoder + * @return A decoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_decoder_by_name(const char *name); + +/** + * Find a registered encoder with a matching codec ID. + * + * @param id AVCodecID of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder(enum AVCodecID id); + +/** + * Find a registered encoder with the specified name. + * + * @param name name of the requested encoder + * @return An encoder if one was found, NULL otherwise. + */ +AVCodec *avcodec_find_encoder_by_name(const char *name); +/** + * @return a non-zero number if codec is an encoder, zero otherwise + */ +int av_codec_is_encoder(const AVCodec *codec); + +/** + * @return a non-zero number if codec is a decoder, zero otherwise + */ +int av_codec_is_decoder(const AVCodec *codec); + +enum { + /** + * The codec supports this format via the hw_device_ctx interface. + * + * When selecting this format, AVCodecContext.hw_device_ctx should + * have been set to a device of the specified type before calling + * avcodec_open2(). + */ + AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = 0x01, + /** + * The codec supports this format via the hw_frames_ctx interface. + * + * When selecting this format for a decoder, + * AVCodecContext.hw_frames_ctx should be set to a suitable frames + * context inside the get_format() callback. The frames context + * must have been created on a device of the specified type. + * + * When selecting this format for an encoder, + * AVCodecContext.hw_frames_ctx should be set to the context which + * will be used for the input frames before calling avcodec_open2(). + */ + AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = 0x02, + /** + * The codec supports this format by some internal method. + * + * This format can be selected without any additional configuration - + * no device or frames context is required. + */ + AV_CODEC_HW_CONFIG_METHOD_INTERNAL = 0x04, + /** + * The codec supports this format by some ad-hoc method. + * + * Additional settings and/or function calls are required. See the + * codec-specific documentation for details. (Methods requiring + * this sort of configuration are deprecated and others should be + * used in preference.) + */ + AV_CODEC_HW_CONFIG_METHOD_AD_HOC = 0x08, +}; + +typedef struct AVCodecHWConfig { + /** + * For decoders, a hardware pixel format which that decoder may be + * able to decode to if suitable hardware is available. + * + * For encoders, a pixel format which the encoder may be able to + * accept. If set to AV_PIX_FMT_NONE, this applies to all pixel + * formats supported by the codec. + */ + enum AVPixelFormat pix_fmt; + /** + * Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible + * setup methods which can be used with this configuration. + */ + int methods; + /** + * The device type associated with the configuration. + * + * Must be set for AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX and + * AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX, otherwise unused. + */ + enum AVHWDeviceType device_type; +} AVCodecHWConfig; + +/** + * Retrieve supported hardware configurations for a codec. + * + * Values of index from zero to some maximum return the indexed configuration + * descriptor; all other values return NULL. If the codec does not support + * any hardware configurations then it will always return NULL. + */ +const AVCodecHWConfig *avcodec_get_hw_config(const AVCodec *codec, int index); + +/** + * @} + */ + +#endif /* AVCODEC_CODEC_H */ diff --git a/winlibs/include/libavcodec/codec_desc.h b/winlibs/include/libavcodec/codec_desc.h new file mode 100644 index 00000000..126b52df --- /dev/null +++ b/winlibs/include/libavcodec/codec_desc.h @@ -0,0 +1,128 @@ +/* + * Codec descriptors public API + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_CODEC_DESC_H +#define AVCODEC_CODEC_DESC_H + +#include "libavutil/avutil.h" + +#include "codec_id.h" + +/** + * @addtogroup lavc_core + * @{ + */ + +/** + * This struct describes the properties of a single codec described by an + * AVCodecID. + * @see avcodec_descriptor_get() + */ +typedef struct AVCodecDescriptor { + enum AVCodecID id; + enum AVMediaType type; + /** + * Name of the codec described by this descriptor. It is non-empty and + * unique for each codec descriptor. It should contain alphanumeric + * characters and '_' only. + */ + const char *name; + /** + * A more descriptive name for this codec. May be NULL. + */ + const char *long_name; + /** + * Codec properties, a combination of AV_CODEC_PROP_* flags. + */ + int props; + /** + * MIME type(s) associated with the codec. + * May be NULL; if not, a NULL-terminated array of MIME types. + * The first item is always non-NULL and is the preferred MIME type. + */ + const char *const *mime_types; + /** + * If non-NULL, an array of profiles recognized for this codec. + * Terminated with FF_PROFILE_UNKNOWN. + */ + const struct AVProfile *profiles; +} AVCodecDescriptor; + +/** + * Codec uses only intra compression. + * Video and audio codecs only. + */ +#define AV_CODEC_PROP_INTRA_ONLY (1 << 0) +/** + * Codec supports lossy compression. Audio and video codecs only. + * @note a codec may support both lossy and lossless + * compression modes + */ +#define AV_CODEC_PROP_LOSSY (1 << 1) +/** + * Codec supports lossless compression. Audio and video codecs only. + */ +#define AV_CODEC_PROP_LOSSLESS (1 << 2) +/** + * Codec supports frame reordering. That is, the coded order (the order in which + * the encoded packets are output by the encoders / stored / input to the + * decoders) may be different from the presentation order of the corresponding + * frames. + * + * For codecs that do not have this property set, PTS and DTS should always be + * equal. + */ +#define AV_CODEC_PROP_REORDER (1 << 3) +/** + * Subtitle codec is bitmap based + * Decoded AVSubtitle data can be read from the AVSubtitleRect->pict field. + */ +#define AV_CODEC_PROP_BITMAP_SUB (1 << 16) +/** + * Subtitle codec is text based. + * Decoded AVSubtitle data can be read from the AVSubtitleRect->ass field. + */ +#define AV_CODEC_PROP_TEXT_SUB (1 << 17) + +/** + * @return descriptor for given codec ID or NULL if no descriptor exists. + */ +const AVCodecDescriptor *avcodec_descriptor_get(enum AVCodecID id); + +/** + * Iterate over all codec descriptors known to libavcodec. + * + * @param prev previous descriptor. NULL to get the first descriptor. + * + * @return next descriptor or NULL after the last descriptor + */ +const AVCodecDescriptor *avcodec_descriptor_next(const AVCodecDescriptor *prev); + +/** + * @return codec descriptor with the given name or NULL if no such descriptor + * exists. + */ +const AVCodecDescriptor *avcodec_descriptor_get_by_name(const char *name); + +/** + * @} + */ + +#endif // AVCODEC_CODEC_DESC_H diff --git a/winlibs/include/libavcodec/codec_id.h b/winlibs/include/libavcodec/codec_id.h new file mode 100644 index 00000000..ab7bc68e --- /dev/null +++ b/winlibs/include/libavcodec/codec_id.h @@ -0,0 +1,592 @@ +/* + * Codec IDs + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_CODEC_ID_H +#define AVCODEC_CODEC_ID_H + +#include "libavutil/avutil.h" + +/** + * @addtogroup lavc_core + * @{ + */ + +/** + * Identify the syntax and semantics of the bitstream. + * The principle is roughly: + * Two decoders with the same ID can decode the same streams. + * Two encoders with the same ID can encode compatible streams. + * There may be slight deviations from the principle due to implementation + * details. + * + * If you add a codec ID to this list, add it so that + * 1. no value of an existing codec ID changes (that would break ABI), + * 2. it is as close as possible to similar codecs + * + * After adding new codec IDs, do not forget to add an entry to the codec + * descriptor list and bump libavcodec minor version. + */ +enum AVCodecID { + AV_CODEC_ID_NONE, + + /* video codecs */ + AV_CODEC_ID_MPEG1VIDEO, + AV_CODEC_ID_MPEG2VIDEO, ///< preferred ID for MPEG-1/2 video decoding + AV_CODEC_ID_H261, + AV_CODEC_ID_H263, + AV_CODEC_ID_RV10, + AV_CODEC_ID_RV20, + AV_CODEC_ID_MJPEG, + AV_CODEC_ID_MJPEGB, + AV_CODEC_ID_LJPEG, + AV_CODEC_ID_SP5X, + AV_CODEC_ID_JPEGLS, + AV_CODEC_ID_MPEG4, + AV_CODEC_ID_RAWVIDEO, + AV_CODEC_ID_MSMPEG4V1, + AV_CODEC_ID_MSMPEG4V2, + AV_CODEC_ID_MSMPEG4V3, + AV_CODEC_ID_WMV1, + AV_CODEC_ID_WMV2, + AV_CODEC_ID_H263P, + AV_CODEC_ID_H263I, + AV_CODEC_ID_FLV1, + AV_CODEC_ID_SVQ1, + AV_CODEC_ID_SVQ3, + AV_CODEC_ID_DVVIDEO, + AV_CODEC_ID_HUFFYUV, + AV_CODEC_ID_CYUV, + AV_CODEC_ID_H264, + AV_CODEC_ID_INDEO3, + AV_CODEC_ID_VP3, + AV_CODEC_ID_THEORA, + AV_CODEC_ID_ASV1, + AV_CODEC_ID_ASV2, + AV_CODEC_ID_FFV1, + AV_CODEC_ID_4XM, + AV_CODEC_ID_VCR1, + AV_CODEC_ID_CLJR, + AV_CODEC_ID_MDEC, + AV_CODEC_ID_ROQ, + AV_CODEC_ID_INTERPLAY_VIDEO, + AV_CODEC_ID_XAN_WC3, + AV_CODEC_ID_XAN_WC4, + AV_CODEC_ID_RPZA, + AV_CODEC_ID_CINEPAK, + AV_CODEC_ID_WS_VQA, + AV_CODEC_ID_MSRLE, + AV_CODEC_ID_MSVIDEO1, + AV_CODEC_ID_IDCIN, + AV_CODEC_ID_8BPS, + AV_CODEC_ID_SMC, + AV_CODEC_ID_FLIC, + AV_CODEC_ID_TRUEMOTION1, + AV_CODEC_ID_VMDVIDEO, + AV_CODEC_ID_MSZH, + AV_CODEC_ID_ZLIB, + AV_CODEC_ID_QTRLE, + AV_CODEC_ID_TSCC, + AV_CODEC_ID_ULTI, + AV_CODEC_ID_QDRAW, + AV_CODEC_ID_VIXL, + AV_CODEC_ID_QPEG, + AV_CODEC_ID_PNG, + AV_CODEC_ID_PPM, + AV_CODEC_ID_PBM, + AV_CODEC_ID_PGM, + AV_CODEC_ID_PGMYUV, + AV_CODEC_ID_PAM, + AV_CODEC_ID_FFVHUFF, + AV_CODEC_ID_RV30, + AV_CODEC_ID_RV40, + AV_CODEC_ID_VC1, + AV_CODEC_ID_WMV3, + AV_CODEC_ID_LOCO, + AV_CODEC_ID_WNV1, + AV_CODEC_ID_AASC, + AV_CODEC_ID_INDEO2, + AV_CODEC_ID_FRAPS, + AV_CODEC_ID_TRUEMOTION2, + AV_CODEC_ID_BMP, + AV_CODEC_ID_CSCD, + AV_CODEC_ID_MMVIDEO, + AV_CODEC_ID_ZMBV, + AV_CODEC_ID_AVS, + AV_CODEC_ID_SMACKVIDEO, + AV_CODEC_ID_NUV, + AV_CODEC_ID_KMVC, + AV_CODEC_ID_FLASHSV, + AV_CODEC_ID_CAVS, + AV_CODEC_ID_JPEG2000, + AV_CODEC_ID_VMNC, + AV_CODEC_ID_VP5, + AV_CODEC_ID_VP6, + AV_CODEC_ID_VP6F, + AV_CODEC_ID_TARGA, + AV_CODEC_ID_DSICINVIDEO, + AV_CODEC_ID_TIERTEXSEQVIDEO, + AV_CODEC_ID_TIFF, + AV_CODEC_ID_GIF, + AV_CODEC_ID_DXA, + AV_CODEC_ID_DNXHD, + AV_CODEC_ID_THP, + AV_CODEC_ID_SGI, + AV_CODEC_ID_C93, + AV_CODEC_ID_BETHSOFTVID, + AV_CODEC_ID_PTX, + AV_CODEC_ID_TXD, + AV_CODEC_ID_VP6A, + AV_CODEC_ID_AMV, + AV_CODEC_ID_VB, + AV_CODEC_ID_PCX, + AV_CODEC_ID_SUNRAST, + AV_CODEC_ID_INDEO4, + AV_CODEC_ID_INDEO5, + AV_CODEC_ID_MIMIC, + AV_CODEC_ID_RL2, + AV_CODEC_ID_ESCAPE124, + AV_CODEC_ID_DIRAC, + AV_CODEC_ID_BFI, + AV_CODEC_ID_CMV, + AV_CODEC_ID_MOTIONPIXELS, + AV_CODEC_ID_TGV, + AV_CODEC_ID_TGQ, + AV_CODEC_ID_TQI, + AV_CODEC_ID_AURA, + AV_CODEC_ID_AURA2, + AV_CODEC_ID_V210X, + AV_CODEC_ID_TMV, + AV_CODEC_ID_V210, + AV_CODEC_ID_DPX, + AV_CODEC_ID_MAD, + AV_CODEC_ID_FRWU, + AV_CODEC_ID_FLASHSV2, + AV_CODEC_ID_CDGRAPHICS, + AV_CODEC_ID_R210, + AV_CODEC_ID_ANM, + AV_CODEC_ID_BINKVIDEO, + AV_CODEC_ID_IFF_ILBM, +#define AV_CODEC_ID_IFF_BYTERUN1 AV_CODEC_ID_IFF_ILBM + AV_CODEC_ID_KGV1, + AV_CODEC_ID_YOP, + AV_CODEC_ID_VP8, + AV_CODEC_ID_PICTOR, + AV_CODEC_ID_ANSI, + AV_CODEC_ID_A64_MULTI, + AV_CODEC_ID_A64_MULTI5, + AV_CODEC_ID_R10K, + AV_CODEC_ID_MXPEG, + AV_CODEC_ID_LAGARITH, + AV_CODEC_ID_PRORES, + AV_CODEC_ID_JV, + AV_CODEC_ID_DFA, + AV_CODEC_ID_WMV3IMAGE, + AV_CODEC_ID_VC1IMAGE, + AV_CODEC_ID_UTVIDEO, + AV_CODEC_ID_BMV_VIDEO, + AV_CODEC_ID_VBLE, + AV_CODEC_ID_DXTORY, + AV_CODEC_ID_V410, + AV_CODEC_ID_XWD, + AV_CODEC_ID_CDXL, + AV_CODEC_ID_XBM, + AV_CODEC_ID_ZEROCODEC, + AV_CODEC_ID_MSS1, + AV_CODEC_ID_MSA1, + AV_CODEC_ID_TSCC2, + AV_CODEC_ID_MTS2, + AV_CODEC_ID_CLLC, + AV_CODEC_ID_MSS2, + AV_CODEC_ID_VP9, + AV_CODEC_ID_AIC, + AV_CODEC_ID_ESCAPE130, + AV_CODEC_ID_G2M, + AV_CODEC_ID_WEBP, + AV_CODEC_ID_HNM4_VIDEO, + AV_CODEC_ID_HEVC, +#define AV_CODEC_ID_H265 AV_CODEC_ID_HEVC + AV_CODEC_ID_FIC, + AV_CODEC_ID_ALIAS_PIX, + AV_CODEC_ID_BRENDER_PIX, + AV_CODEC_ID_PAF_VIDEO, + AV_CODEC_ID_EXR, + AV_CODEC_ID_VP7, + AV_CODEC_ID_SANM, + AV_CODEC_ID_SGIRLE, + AV_CODEC_ID_MVC1, + AV_CODEC_ID_MVC2, + AV_CODEC_ID_HQX, + AV_CODEC_ID_TDSC, + AV_CODEC_ID_HQ_HQA, + AV_CODEC_ID_HAP, + AV_CODEC_ID_DDS, + AV_CODEC_ID_DXV, + AV_CODEC_ID_SCREENPRESSO, + AV_CODEC_ID_RSCC, + AV_CODEC_ID_AVS2, + AV_CODEC_ID_PGX, + AV_CODEC_ID_AVS3, + AV_CODEC_ID_MSP2, + AV_CODEC_ID_VVC, +#define AV_CODEC_ID_H266 AV_CODEC_ID_VVC + + AV_CODEC_ID_Y41P = 0x8000, + AV_CODEC_ID_AVRP, + AV_CODEC_ID_012V, + AV_CODEC_ID_AVUI, + AV_CODEC_ID_AYUV, + AV_CODEC_ID_TARGA_Y216, + AV_CODEC_ID_V308, + AV_CODEC_ID_V408, + AV_CODEC_ID_YUV4, + AV_CODEC_ID_AVRN, + AV_CODEC_ID_CPIA, + AV_CODEC_ID_XFACE, + AV_CODEC_ID_SNOW, + AV_CODEC_ID_SMVJPEG, + AV_CODEC_ID_APNG, + AV_CODEC_ID_DAALA, + AV_CODEC_ID_CFHD, + AV_CODEC_ID_TRUEMOTION2RT, + AV_CODEC_ID_M101, + AV_CODEC_ID_MAGICYUV, + AV_CODEC_ID_SHEERVIDEO, + AV_CODEC_ID_YLC, + AV_CODEC_ID_PSD, + AV_CODEC_ID_PIXLET, + AV_CODEC_ID_SPEEDHQ, + AV_CODEC_ID_FMVC, + AV_CODEC_ID_SCPR, + AV_CODEC_ID_CLEARVIDEO, + AV_CODEC_ID_XPM, + AV_CODEC_ID_AV1, + AV_CODEC_ID_BITPACKED, + AV_CODEC_ID_MSCC, + AV_CODEC_ID_SRGC, + AV_CODEC_ID_SVG, + AV_CODEC_ID_GDV, + AV_CODEC_ID_FITS, + AV_CODEC_ID_IMM4, + AV_CODEC_ID_PROSUMER, + AV_CODEC_ID_MWSC, + AV_CODEC_ID_WCMV, + AV_CODEC_ID_RASC, + AV_CODEC_ID_HYMT, + AV_CODEC_ID_ARBC, + AV_CODEC_ID_AGM, + AV_CODEC_ID_LSCR, + AV_CODEC_ID_VP4, + AV_CODEC_ID_IMM5, + AV_CODEC_ID_MVDV, + AV_CODEC_ID_MVHA, + AV_CODEC_ID_CDTOONS, + AV_CODEC_ID_MV30, + AV_CODEC_ID_NOTCHLC, + AV_CODEC_ID_PFM, + AV_CODEC_ID_MOBICLIP, + AV_CODEC_ID_PHOTOCD, + AV_CODEC_ID_IPU, + AV_CODEC_ID_ARGO, + AV_CODEC_ID_CRI, + AV_CODEC_ID_SIMBIOSIS_IMX, + AV_CODEC_ID_SGA_VIDEO, + + /* various PCM "codecs" */ + AV_CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs + AV_CODEC_ID_PCM_S16LE = 0x10000, + AV_CODEC_ID_PCM_S16BE, + AV_CODEC_ID_PCM_U16LE, + AV_CODEC_ID_PCM_U16BE, + AV_CODEC_ID_PCM_S8, + AV_CODEC_ID_PCM_U8, + AV_CODEC_ID_PCM_MULAW, + AV_CODEC_ID_PCM_ALAW, + AV_CODEC_ID_PCM_S32LE, + AV_CODEC_ID_PCM_S32BE, + AV_CODEC_ID_PCM_U32LE, + AV_CODEC_ID_PCM_U32BE, + AV_CODEC_ID_PCM_S24LE, + AV_CODEC_ID_PCM_S24BE, + AV_CODEC_ID_PCM_U24LE, + AV_CODEC_ID_PCM_U24BE, + AV_CODEC_ID_PCM_S24DAUD, + AV_CODEC_ID_PCM_ZORK, + AV_CODEC_ID_PCM_S16LE_PLANAR, + AV_CODEC_ID_PCM_DVD, + AV_CODEC_ID_PCM_F32BE, + AV_CODEC_ID_PCM_F32LE, + AV_CODEC_ID_PCM_F64BE, + AV_CODEC_ID_PCM_F64LE, + AV_CODEC_ID_PCM_BLURAY, + AV_CODEC_ID_PCM_LXF, + AV_CODEC_ID_S302M, + AV_CODEC_ID_PCM_S8_PLANAR, + AV_CODEC_ID_PCM_S24LE_PLANAR, + AV_CODEC_ID_PCM_S32LE_PLANAR, + AV_CODEC_ID_PCM_S16BE_PLANAR, + + AV_CODEC_ID_PCM_S64LE = 0x10800, + AV_CODEC_ID_PCM_S64BE, + AV_CODEC_ID_PCM_F16LE, + AV_CODEC_ID_PCM_F24LE, + AV_CODEC_ID_PCM_VIDC, + AV_CODEC_ID_PCM_SGA, + + /* various ADPCM codecs */ + AV_CODEC_ID_ADPCM_IMA_QT = 0x11000, + AV_CODEC_ID_ADPCM_IMA_WAV, + AV_CODEC_ID_ADPCM_IMA_DK3, + AV_CODEC_ID_ADPCM_IMA_DK4, + AV_CODEC_ID_ADPCM_IMA_WS, + AV_CODEC_ID_ADPCM_IMA_SMJPEG, + AV_CODEC_ID_ADPCM_MS, + AV_CODEC_ID_ADPCM_4XM, + AV_CODEC_ID_ADPCM_XA, + AV_CODEC_ID_ADPCM_ADX, + AV_CODEC_ID_ADPCM_EA, + AV_CODEC_ID_ADPCM_G726, + AV_CODEC_ID_ADPCM_CT, + AV_CODEC_ID_ADPCM_SWF, + AV_CODEC_ID_ADPCM_YAMAHA, + AV_CODEC_ID_ADPCM_SBPRO_4, + AV_CODEC_ID_ADPCM_SBPRO_3, + AV_CODEC_ID_ADPCM_SBPRO_2, + AV_CODEC_ID_ADPCM_THP, + AV_CODEC_ID_ADPCM_IMA_AMV, + AV_CODEC_ID_ADPCM_EA_R1, + AV_CODEC_ID_ADPCM_EA_R3, + AV_CODEC_ID_ADPCM_EA_R2, + AV_CODEC_ID_ADPCM_IMA_EA_SEAD, + AV_CODEC_ID_ADPCM_IMA_EA_EACS, + AV_CODEC_ID_ADPCM_EA_XAS, + AV_CODEC_ID_ADPCM_EA_MAXIS_XA, + AV_CODEC_ID_ADPCM_IMA_ISS, + AV_CODEC_ID_ADPCM_G722, + AV_CODEC_ID_ADPCM_IMA_APC, + AV_CODEC_ID_ADPCM_VIMA, + + AV_CODEC_ID_ADPCM_AFC = 0x11800, + AV_CODEC_ID_ADPCM_IMA_OKI, + AV_CODEC_ID_ADPCM_DTK, + AV_CODEC_ID_ADPCM_IMA_RAD, + AV_CODEC_ID_ADPCM_G726LE, + AV_CODEC_ID_ADPCM_THP_LE, + AV_CODEC_ID_ADPCM_PSX, + AV_CODEC_ID_ADPCM_AICA, + AV_CODEC_ID_ADPCM_IMA_DAT4, + AV_CODEC_ID_ADPCM_MTAF, + AV_CODEC_ID_ADPCM_AGM, + AV_CODEC_ID_ADPCM_ARGO, + AV_CODEC_ID_ADPCM_IMA_SSI, + AV_CODEC_ID_ADPCM_ZORK, + AV_CODEC_ID_ADPCM_IMA_APM, + AV_CODEC_ID_ADPCM_IMA_ALP, + AV_CODEC_ID_ADPCM_IMA_MTF, + AV_CODEC_ID_ADPCM_IMA_CUNNING, + AV_CODEC_ID_ADPCM_IMA_MOFLEX, + + /* AMR */ + AV_CODEC_ID_AMR_NB = 0x12000, + AV_CODEC_ID_AMR_WB, + + /* RealAudio codecs*/ + AV_CODEC_ID_RA_144 = 0x13000, + AV_CODEC_ID_RA_288, + + /* various DPCM codecs */ + AV_CODEC_ID_ROQ_DPCM = 0x14000, + AV_CODEC_ID_INTERPLAY_DPCM, + AV_CODEC_ID_XAN_DPCM, + AV_CODEC_ID_SOL_DPCM, + + AV_CODEC_ID_SDX2_DPCM = 0x14800, + AV_CODEC_ID_GREMLIN_DPCM, + AV_CODEC_ID_DERF_DPCM, + + /* audio codecs */ + AV_CODEC_ID_MP2 = 0x15000, + AV_CODEC_ID_MP3, ///< preferred ID for decoding MPEG audio layer 1, 2 or 3 + AV_CODEC_ID_AAC, + AV_CODEC_ID_AC3, + AV_CODEC_ID_DTS, + AV_CODEC_ID_VORBIS, + AV_CODEC_ID_DVAUDIO, + AV_CODEC_ID_WMAV1, + AV_CODEC_ID_WMAV2, + AV_CODEC_ID_MACE3, + AV_CODEC_ID_MACE6, + AV_CODEC_ID_VMDAUDIO, + AV_CODEC_ID_FLAC, + AV_CODEC_ID_MP3ADU, + AV_CODEC_ID_MP3ON4, + AV_CODEC_ID_SHORTEN, + AV_CODEC_ID_ALAC, + AV_CODEC_ID_WESTWOOD_SND1, + AV_CODEC_ID_GSM, ///< as in Berlin toast format + AV_CODEC_ID_QDM2, + AV_CODEC_ID_COOK, + AV_CODEC_ID_TRUESPEECH, + AV_CODEC_ID_TTA, + AV_CODEC_ID_SMACKAUDIO, + AV_CODEC_ID_QCELP, + AV_CODEC_ID_WAVPACK, + AV_CODEC_ID_DSICINAUDIO, + AV_CODEC_ID_IMC, + AV_CODEC_ID_MUSEPACK7, + AV_CODEC_ID_MLP, + AV_CODEC_ID_GSM_MS, /* as found in WAV */ + AV_CODEC_ID_ATRAC3, + AV_CODEC_ID_APE, + AV_CODEC_ID_NELLYMOSER, + AV_CODEC_ID_MUSEPACK8, + AV_CODEC_ID_SPEEX, + AV_CODEC_ID_WMAVOICE, + AV_CODEC_ID_WMAPRO, + AV_CODEC_ID_WMALOSSLESS, + AV_CODEC_ID_ATRAC3P, + AV_CODEC_ID_EAC3, + AV_CODEC_ID_SIPR, + AV_CODEC_ID_MP1, + AV_CODEC_ID_TWINVQ, + AV_CODEC_ID_TRUEHD, + AV_CODEC_ID_MP4ALS, + AV_CODEC_ID_ATRAC1, + AV_CODEC_ID_BINKAUDIO_RDFT, + AV_CODEC_ID_BINKAUDIO_DCT, + AV_CODEC_ID_AAC_LATM, + AV_CODEC_ID_QDMC, + AV_CODEC_ID_CELT, + AV_CODEC_ID_G723_1, + AV_CODEC_ID_G729, + AV_CODEC_ID_8SVX_EXP, + AV_CODEC_ID_8SVX_FIB, + AV_CODEC_ID_BMV_AUDIO, + AV_CODEC_ID_RALF, + AV_CODEC_ID_IAC, + AV_CODEC_ID_ILBC, + AV_CODEC_ID_OPUS, + AV_CODEC_ID_COMFORT_NOISE, + AV_CODEC_ID_TAK, + AV_CODEC_ID_METASOUND, + AV_CODEC_ID_PAF_AUDIO, + AV_CODEC_ID_ON2AVC, + AV_CODEC_ID_DSS_SP, + AV_CODEC_ID_CODEC2, + + AV_CODEC_ID_FFWAVESYNTH = 0x15800, + AV_CODEC_ID_SONIC, + AV_CODEC_ID_SONIC_LS, + AV_CODEC_ID_EVRC, + AV_CODEC_ID_SMV, + AV_CODEC_ID_DSD_LSBF, + AV_CODEC_ID_DSD_MSBF, + AV_CODEC_ID_DSD_LSBF_PLANAR, + AV_CODEC_ID_DSD_MSBF_PLANAR, + AV_CODEC_ID_4GV, + AV_CODEC_ID_INTERPLAY_ACM, + AV_CODEC_ID_XMA1, + AV_CODEC_ID_XMA2, + AV_CODEC_ID_DST, + AV_CODEC_ID_ATRAC3AL, + AV_CODEC_ID_ATRAC3PAL, + AV_CODEC_ID_DOLBY_E, + AV_CODEC_ID_APTX, + AV_CODEC_ID_APTX_HD, + AV_CODEC_ID_SBC, + AV_CODEC_ID_ATRAC9, + AV_CODEC_ID_HCOM, + AV_CODEC_ID_ACELP_KELVIN, + AV_CODEC_ID_MPEGH_3D_AUDIO, + AV_CODEC_ID_SIREN, + AV_CODEC_ID_HCA, + AV_CODEC_ID_FASTAUDIO, + + /* subtitle codecs */ + AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. + AV_CODEC_ID_DVD_SUBTITLE = 0x17000, + AV_CODEC_ID_DVB_SUBTITLE, + AV_CODEC_ID_TEXT, ///< raw UTF-8 text + AV_CODEC_ID_XSUB, + AV_CODEC_ID_SSA, + AV_CODEC_ID_MOV_TEXT, + AV_CODEC_ID_HDMV_PGS_SUBTITLE, + AV_CODEC_ID_DVB_TELETEXT, + AV_CODEC_ID_SRT, + + AV_CODEC_ID_MICRODVD = 0x17800, + AV_CODEC_ID_EIA_608, + AV_CODEC_ID_JACOSUB, + AV_CODEC_ID_SAMI, + AV_CODEC_ID_REALTEXT, + AV_CODEC_ID_STL, + AV_CODEC_ID_SUBVIEWER1, + AV_CODEC_ID_SUBVIEWER, + AV_CODEC_ID_SUBRIP, + AV_CODEC_ID_WEBVTT, + AV_CODEC_ID_MPL2, + AV_CODEC_ID_VPLAYER, + AV_CODEC_ID_PJS, + AV_CODEC_ID_ASS, + AV_CODEC_ID_HDMV_TEXT_SUBTITLE, + AV_CODEC_ID_TTML, + AV_CODEC_ID_ARIB_CAPTION, + + /* other specific kind of codecs (generally used for attachments) */ + AV_CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs. + AV_CODEC_ID_TTF = 0x18000, + + AV_CODEC_ID_SCTE_35, ///< Contain timestamp estimated through PCR of program stream. + AV_CODEC_ID_EPG, + AV_CODEC_ID_BINTEXT = 0x18800, + AV_CODEC_ID_XBIN, + AV_CODEC_ID_IDF, + AV_CODEC_ID_OTF, + AV_CODEC_ID_SMPTE_KLV, + AV_CODEC_ID_DVD_NAV, + AV_CODEC_ID_TIMED_ID3, + AV_CODEC_ID_BIN_DATA, + + + AV_CODEC_ID_PROBE = 0x19000, ///< codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it + + AV_CODEC_ID_MPEG2TS = 0x20000, /**< _FAKE_ codec to indicate a raw MPEG-2 TS + * stream (only used by libavformat) */ + AV_CODEC_ID_MPEG4SYSTEMS = 0x20001, /**< _FAKE_ codec to indicate a MPEG-4 Systems + * stream (only used by libavformat) */ + AV_CODEC_ID_FFMETADATA = 0x21000, ///< Dummy codec for streams containing only metadata information. + AV_CODEC_ID_WRAPPED_AVFRAME = 0x21001, ///< Passthrough codec, AVFrames wrapped in AVPacket +}; + +/** + * Get the type of the given codec. + */ +enum AVMediaType avcodec_get_type(enum AVCodecID codec_id); + +/** + * Get the name of a codec. + * @return a static string identifying the codec; never NULL + */ +const char *avcodec_get_name(enum AVCodecID id); + +/** + * @} + */ + +#endif // AVCODEC_CODEC_ID_H diff --git a/winlibs/include/libavcodec/codec_par.h b/winlibs/include/libavcodec/codec_par.h new file mode 100644 index 00000000..948758e2 --- /dev/null +++ b/winlibs/include/libavcodec/codec_par.h @@ -0,0 +1,229 @@ +/* + * Codec parameters public API + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_CODEC_PAR_H +#define AVCODEC_CODEC_PAR_H + +#include + +#include "libavutil/avutil.h" +#include "libavutil/rational.h" +#include "libavutil/pixfmt.h" + +#include "codec_id.h" + +/** + * @addtogroup lavc_core + */ + +enum AVFieldOrder { + AV_FIELD_UNKNOWN, + AV_FIELD_PROGRESSIVE, + AV_FIELD_TT, //< Top coded_first, top displayed first + AV_FIELD_BB, //< Bottom coded first, bottom displayed first + AV_FIELD_TB, //< Top coded first, bottom displayed first + AV_FIELD_BT, //< Bottom coded first, top displayed first +}; + +/** + * This struct describes the properties of an encoded stream. + * + * sizeof(AVCodecParameters) is not a part of the public ABI, this struct must + * be allocated with avcodec_parameters_alloc() and freed with + * avcodec_parameters_free(). + */ +typedef struct AVCodecParameters { + /** + * General type of the encoded data. + */ + enum AVMediaType codec_type; + /** + * Specific type of the encoded data (the codec used). + */ + enum AVCodecID codec_id; + /** + * Additional information about the codec (corresponds to the AVI FOURCC). + */ + uint32_t codec_tag; + + /** + * Extra binary data needed for initializing the decoder, codec-dependent. + * + * Must be allocated with av_malloc() and will be freed by + * avcodec_parameters_free(). The allocated size of extradata must be at + * least extradata_size + AV_INPUT_BUFFER_PADDING_SIZE, with the padding + * bytes zeroed. + */ + uint8_t *extradata; + /** + * Size of the extradata content in bytes. + */ + int extradata_size; + + /** + * - video: the pixel format, the value corresponds to enum AVPixelFormat. + * - audio: the sample format, the value corresponds to enum AVSampleFormat. + */ + int format; + + /** + * The average bitrate of the encoded data (in bits per second). + */ + int64_t bit_rate; + + /** + * The number of bits per sample in the codedwords. + * + * This is basically the bitrate per sample. It is mandatory for a bunch of + * formats to actually decode them. It's the number of bits for one sample in + * the actual coded bitstream. + * + * This could be for example 4 for ADPCM + * For PCM formats this matches bits_per_raw_sample + * Can be 0 + */ + int bits_per_coded_sample; + + /** + * This is the number of valid bits in each output sample. If the + * sample format has more bits, the least significant bits are additional + * padding bits, which are always 0. Use right shifts to reduce the sample + * to its actual size. For example, audio formats with 24 bit samples will + * have bits_per_raw_sample set to 24, and format set to AV_SAMPLE_FMT_S32. + * To get the original sample use "(int32_t)sample >> 8"." + * + * For ADPCM this might be 12 or 16 or similar + * Can be 0 + */ + int bits_per_raw_sample; + + /** + * Codec-specific bitstream restrictions that the stream conforms to. + */ + int profile; + int level; + + /** + * Video only. The dimensions of the video frame in pixels. + */ + int width; + int height; + + /** + * Video only. The aspect ratio (width / height) which a single pixel + * should have when displayed. + * + * When the aspect ratio is unknown / undefined, the numerator should be + * set to 0 (the denominator may have any value). + */ + AVRational sample_aspect_ratio; + + /** + * Video only. The order of the fields in interlaced video. + */ + enum AVFieldOrder field_order; + + /** + * Video only. Additional colorspace characteristics. + */ + enum AVColorRange color_range; + enum AVColorPrimaries color_primaries; + enum AVColorTransferCharacteristic color_trc; + enum AVColorSpace color_space; + enum AVChromaLocation chroma_location; + + /** + * Video only. Number of delayed frames. + */ + int video_delay; + + /** + * Audio only. The channel layout bitmask. May be 0 if the channel layout is + * unknown or unspecified, otherwise the number of bits set must be equal to + * the channels field. + */ + uint64_t channel_layout; + /** + * Audio only. The number of audio channels. + */ + int channels; + /** + * Audio only. The number of audio samples per second. + */ + int sample_rate; + /** + * Audio only. The number of bytes per coded audio frame, required by some + * formats. + * + * Corresponds to nBlockAlign in WAVEFORMATEX. + */ + int block_align; + /** + * Audio only. Audio frame size, if known. Required by some formats to be static. + */ + int frame_size; + + /** + * Audio only. The amount of padding (in samples) inserted by the encoder at + * the beginning of the audio. I.e. this number of leading decoded samples + * must be discarded by the caller to get the original audio without leading + * padding. + */ + int initial_padding; + /** + * Audio only. The amount of padding (in samples) appended by the encoder to + * the end of the audio. I.e. this number of decoded samples must be + * discarded by the caller from the end of the stream to get the original + * audio without any trailing padding. + */ + int trailing_padding; + /** + * Audio only. Number of samples to skip after a discontinuity. + */ + int seek_preroll; +} AVCodecParameters; + +/** + * Allocate a new AVCodecParameters and set its fields to default values + * (unknown/invalid/0). The returned struct must be freed with + * avcodec_parameters_free(). + */ +AVCodecParameters *avcodec_parameters_alloc(void); + +/** + * Free an AVCodecParameters instance and everything associated with it and + * write NULL to the supplied pointer. + */ +void avcodec_parameters_free(AVCodecParameters **par); + +/** + * Copy the contents of src to dst. Any allocated fields in dst are freed and + * replaced with newly allocated duplicates of the corresponding fields in src. + * + * @return >= 0 on success, a negative AVERROR code on failure. + */ +int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src); + + +/** + * @} + */ + +#endif // AVCODEC_CODEC_PAR_H diff --git a/maclibs/include/libavcodec/dxva2.h b/winlibs/include/libavcodec/d3d11va.h similarity index 60% rename from maclibs/include/libavcodec/dxva2.h rename to winlibs/include/libavcodec/d3d11va.h index 22c93992..6816b6c1 100644 --- a/maclibs/include/libavcodec/dxva2.h +++ b/winlibs/include/libavcodec/d3d11va.h @@ -1,7 +1,8 @@ /* - * DXVA2 HW acceleration + * Direct3D11 HW acceleration * * copyright (c) 2009 Laurent Aimar + * copyright (c) 2015 Steve Lhomme * * This file is part of FFmpeg. * @@ -20,13 +21,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVCODEC_DXVA2_H -#define AVCODEC_DXVA2_H +#ifndef AVCODEC_D3D11VA_H +#define AVCODEC_D3D11VA_H /** * @file - * @ingroup lavc_codec_hwaccel_dxva2 - * Public libavcodec DXVA2 header. + * @ingroup lavc_codec_hwaccel_d3d11va + * Public libavcodec D3D11VA header. */ #if !defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0602 @@ -35,35 +36,41 @@ #endif #include -#include -#include +#include /** - * @defgroup lavc_codec_hwaccel_dxva2 DXVA2 + * @defgroup lavc_codec_hwaccel_d3d11va Direct3D11 * @ingroup lavc_codec_hwaccel * * @{ */ -#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for DXVA2 and old UVD/UVD+ ATI video cards -#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for DXVA2 and old Intel GPUs with ClearVideo interface +#define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1 ///< Work around for Direct3D11 and old UVD/UVD+ ATI video cards +#define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2 ///< Work around for Direct3D11 and old Intel GPUs with ClearVideo interface /** * This structure is used to provides the necessary configurations and data - * to the DXVA2 FFmpeg HWAccel implementation. + * to the Direct3D11 FFmpeg HWAccel implementation. * * The application must make it available as AVCodecContext.hwaccel_context. + * + * Use av_d3d11va_alloc_context() exclusively to allocate an AVD3D11VAContext. */ -struct dxva_context { +typedef struct AVD3D11VAContext { /** - * DXVA2 decoder object + * D3D11 decoder object */ - IDirectXVideoDecoder *decoder; + ID3D11VideoDecoder *decoder; /** - * DXVA2 configuration used to create the decoder + * D3D11 VideoContext + */ + ID3D11VideoContext *video_context; + + /** + * D3D11 configuration used to create the decoder */ - const DXVA2_ConfigPictureDecode *cfg; + D3D11_VIDEO_DECODER_CONFIG *cfg; /** * The number of surface in the surface array @@ -73,7 +80,7 @@ struct dxva_context { /** * The array of Direct3D surfaces used to create the decoder */ - LPDIRECT3DSURFACE9 *surface; + ID3D11VideoDecoderOutputView **surface; /** * A bit field configuring the workarounds needed for using the decoder @@ -84,10 +91,22 @@ struct dxva_context { * Private to the FFmpeg AVHWAccel implementation */ unsigned report_id; -}; + + /** + * Mutex to access video_context + */ + HANDLE context_mutex; +} AVD3D11VAContext; + +/** + * Allocate an AVD3D11VAContext. + * + * @return Newly-allocated AVD3D11VAContext or NULL on failure. + */ +AVD3D11VAContext *av_d3d11va_alloc_context(void); /** * @} */ -#endif /* AVCODEC_DXVA2_H */ +#endif /* AVCODEC_D3D11VA_H */ diff --git a/winlibs/include/libavcodec/dirac.h b/winlibs/include/libavcodec/dirac.h new file mode 100644 index 00000000..e6d9d346 --- /dev/null +++ b/winlibs/include/libavcodec/dirac.h @@ -0,0 +1,131 @@ +/* + * Copyright (C) 2007 Marco Gerards + * Copyright (C) 2009 David Conrad + * Copyright (C) 2011 Jordi Ortiz + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_DIRAC_H +#define AVCODEC_DIRAC_H + +/** + * @file + * Interface to Dirac Decoder/Encoder + * @author Marco Gerards + * @author David Conrad + * @author Jordi Ortiz + */ + +#include "avcodec.h" + +/** + * The spec limits the number of wavelet decompositions to 4 for both + * level 1 (VC-2) and 128 (long-gop default). + * 5 decompositions is the maximum before >16-bit buffers are needed. + * Schroedinger allows this for DD 9,7 and 13,7 wavelets only, limiting + * the others to 4 decompositions (or 3 for the fidelity filter). + * + * We use this instead of MAX_DECOMPOSITIONS to save some memory. + */ +#define MAX_DWT_LEVELS 5 + +/** + * Parse code values: + * + * Dirac Specification -> + * 9.6.1 Table 9.1 + * + * VC-2 Specification -> + * 10.4.1 Table 10.1 + */ + +enum DiracParseCodes { + DIRAC_PCODE_SEQ_HEADER = 0x00, + DIRAC_PCODE_END_SEQ = 0x10, + DIRAC_PCODE_AUX = 0x20, + DIRAC_PCODE_PAD = 0x30, + DIRAC_PCODE_PICTURE_CODED = 0x08, + DIRAC_PCODE_PICTURE_RAW = 0x48, + DIRAC_PCODE_PICTURE_LOW_DEL = 0xC8, + DIRAC_PCODE_PICTURE_HQ = 0xE8, + DIRAC_PCODE_INTER_NOREF_CO1 = 0x0A, + DIRAC_PCODE_INTER_NOREF_CO2 = 0x09, + DIRAC_PCODE_INTER_REF_CO1 = 0x0D, + DIRAC_PCODE_INTER_REF_CO2 = 0x0E, + DIRAC_PCODE_INTRA_REF_CO = 0x0C, + DIRAC_PCODE_INTRA_REF_RAW = 0x4C, + DIRAC_PCODE_INTRA_REF_PICT = 0xCC, + DIRAC_PCODE_MAGIC = 0x42424344, +}; + +typedef struct DiracVersionInfo { + int major; + int minor; +} DiracVersionInfo; + +typedef struct AVDiracSeqHeader { + unsigned width; + unsigned height; + uint8_t chroma_format; ///< 0: 444 1: 422 2: 420 + + uint8_t interlaced; + uint8_t top_field_first; + + uint8_t frame_rate_index; ///< index into dirac_frame_rate[] + uint8_t aspect_ratio_index; ///< index into dirac_aspect_ratio[] + + uint16_t clean_width; + uint16_t clean_height; + uint16_t clean_left_offset; + uint16_t clean_right_offset; + + uint8_t pixel_range_index; ///< index into dirac_pixel_range_presets[] + uint8_t color_spec_index; ///< index into dirac_color_spec_presets[] + + int profile; + int level; + + AVRational framerate; + AVRational sample_aspect_ratio; + + enum AVPixelFormat pix_fmt; + enum AVColorRange color_range; + enum AVColorPrimaries color_primaries; + enum AVColorTransferCharacteristic color_trc; + enum AVColorSpace colorspace; + + DiracVersionInfo version; + int bit_depth; +} AVDiracSeqHeader; + +/** + * Parse a Dirac sequence header. + * + * @param dsh this function will allocate and fill an AVDiracSeqHeader struct + * and write it into this pointer. The caller must free it with + * av_free(). + * @param buf the data buffer + * @param buf_size the size of the data buffer in bytes + * @param log_ctx if non-NULL, this function will log errors here + * @return 0 on success, a negative AVERROR code on failure + */ +int av_dirac_parse_sequence_header(AVDiracSeqHeader **dsh, + const uint8_t *buf, size_t buf_size, + void *log_ctx); + +#endif /* AVCODEC_DIRAC_H */ diff --git a/winlibs/include/libavcodec/dv_profile.h b/winlibs/include/libavcodec/dv_profile.h new file mode 100644 index 00000000..9380a66f --- /dev/null +++ b/winlibs/include/libavcodec/dv_profile.h @@ -0,0 +1,83 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_DV_PROFILE_H +#define AVCODEC_DV_PROFILE_H + +#include + +#include "libavutil/pixfmt.h" +#include "libavutil/rational.h" +#include "avcodec.h" + +/* minimum number of bytes to read from a DV stream in order to + * determine the profile */ +#define DV_PROFILE_BYTES (6 * 80) /* 6 DIF blocks */ + + +/* + * AVDVProfile is used to express the differences between various + * DV flavors. For now it's primarily used for differentiating + * 525/60 and 625/50, but the plans are to use it for various + * DV specs as well (e.g. SMPTE314M vs. IEC 61834). + */ +typedef struct AVDVProfile { + int dsf; /* value of the dsf in the DV header */ + int video_stype; /* stype for VAUX source pack */ + int frame_size; /* total size of one frame in bytes */ + int difseg_size; /* number of DIF segments per DIF channel */ + int n_difchan; /* number of DIF channels per frame */ + AVRational time_base; /* 1/framerate */ + int ltc_divisor; /* FPS from the LTS standpoint */ + int height; /* picture height in pixels */ + int width; /* picture width in pixels */ + AVRational sar[2]; /* sample aspect ratios for 4:3 and 16:9 */ + enum AVPixelFormat pix_fmt; /* picture pixel format */ + int bpm; /* blocks per macroblock */ + const uint8_t *block_sizes; /* AC block sizes, in bits */ + int audio_stride; /* size of audio_shuffle table */ + int audio_min_samples[3]; /* min amount of audio samples */ + /* for 48kHz, 44.1kHz and 32kHz */ + int audio_samples_dist[5]; /* how many samples are supposed to be */ + /* in each frame in a 5 frames window */ + const uint8_t (*audio_shuffle)[9]; /* PCM shuffling table */ +} AVDVProfile; + +/** + * Get a DV profile for the provided compressed frame. + * + * @param sys the profile used for the previous frame, may be NULL + * @param frame the compressed data buffer + * @param buf_size size of the buffer in bytes + * @return the DV profile for the supplied data or NULL on failure + */ +const AVDVProfile *av_dv_frame_profile(const AVDVProfile *sys, + const uint8_t *frame, unsigned buf_size); + +/** + * Get a DV profile for the provided stream parameters. + */ +const AVDVProfile *av_dv_codec_profile(int width, int height, enum AVPixelFormat pix_fmt); + +/** + * Get a DV profile for the provided stream parameters. + * The frame rate is used as a best-effort parameter. + */ +const AVDVProfile *av_dv_codec_profile2(int width, int height, enum AVPixelFormat pix_fmt, AVRational frame_rate); + +#endif /* AVCODEC_DV_PROFILE_H */ diff --git a/winlibs/include/libavcodec/jni.h b/winlibs/include/libavcodec/jni.h new file mode 100644 index 00000000..dd99e926 --- /dev/null +++ b/winlibs/include/libavcodec/jni.h @@ -0,0 +1,46 @@ +/* + * JNI public API functions + * + * Copyright (c) 2015-2016 Matthieu Bouron + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_JNI_H +#define AVCODEC_JNI_H + +/* + * Manually set a Java virtual machine which will be used to retrieve the JNI + * environment. Once a Java VM is set it cannot be changed afterwards, meaning + * you can call multiple times av_jni_set_java_vm with the same Java VM pointer + * however it will error out if you try to set a different Java VM. + * + * @param vm Java virtual machine + * @param log_ctx context used for logging, can be NULL + * @return 0 on success, < 0 otherwise + */ +int av_jni_set_java_vm(void *vm, void *log_ctx); + +/* + * Get the Java virtual machine which has been set with av_jni_set_java_vm. + * + * @param vm Java virtual machine + * @return a pointer to the Java virtual machine + */ +void *av_jni_get_java_vm(void *log_ctx); + +#endif /* AVCODEC_JNI_H */ diff --git a/winlibs/include/libavcodec/mediacodec.h b/winlibs/include/libavcodec/mediacodec.h new file mode 100644 index 00000000..4c8545df --- /dev/null +++ b/winlibs/include/libavcodec/mediacodec.h @@ -0,0 +1,101 @@ +/* + * Android MediaCodec public API + * + * Copyright (c) 2016 Matthieu Bouron + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MEDIACODEC_H +#define AVCODEC_MEDIACODEC_H + +#include "libavcodec/avcodec.h" + +/** + * This structure holds a reference to a android/view/Surface object that will + * be used as output by the decoder. + * + */ +typedef struct AVMediaCodecContext { + + /** + * android/view/Surface object reference. + */ + void *surface; + +} AVMediaCodecContext; + +/** + * Allocate and initialize a MediaCodec context. + * + * When decoding with MediaCodec is finished, the caller must free the + * MediaCodec context with av_mediacodec_default_free. + * + * @return a pointer to a newly allocated AVMediaCodecContext on success, NULL otherwise + */ +AVMediaCodecContext *av_mediacodec_alloc_context(void); + +/** + * Convenience function that sets up the MediaCodec context. + * + * @param avctx codec context + * @param ctx MediaCodec context to initialize + * @param surface reference to an android/view/Surface + * @return 0 on success, < 0 otherwise + */ +int av_mediacodec_default_init(AVCodecContext *avctx, AVMediaCodecContext *ctx, void *surface); + +/** + * This function must be called to free the MediaCodec context initialized with + * av_mediacodec_default_init(). + * + * @param avctx codec context + */ +void av_mediacodec_default_free(AVCodecContext *avctx); + +/** + * Opaque structure representing a MediaCodec buffer to render. + */ +typedef struct MediaCodecBuffer AVMediaCodecBuffer; + +/** + * Release a MediaCodec buffer and render it to the surface that is associated + * with the decoder. This function should only be called once on a given + * buffer, once released the underlying buffer returns to the codec, thus + * subsequent calls to this function will have no effect. + * + * @param buffer the buffer to render + * @param render 1 to release and render the buffer to the surface or 0 to + * discard the buffer + * @return 0 on success, < 0 otherwise + */ +int av_mediacodec_release_buffer(AVMediaCodecBuffer *buffer, int render); + +/** + * Release a MediaCodec buffer and render it at the given time to the surface + * that is associated with the decoder. The timestamp must be within one second + * of the current java/lang/System#nanoTime() (which is implemented using + * CLOCK_MONOTONIC on Android). See the Android MediaCodec documentation + * of android/media/MediaCodec#releaseOutputBuffer(int,long) for more details. + * + * @param buffer the buffer to render + * @param time timestamp in nanoseconds of when to render the buffer + * @return 0 on success, < 0 otherwise + */ +int av_mediacodec_render_buffer_at_time(AVMediaCodecBuffer *buffer, int64_t time); + +#endif /* AVCODEC_MEDIACODEC_H */ diff --git a/winlibs/include/libavcodec/packet.h b/winlibs/include/libavcodec/packet.h new file mode 100644 index 00000000..ca18ae63 --- /dev/null +++ b/winlibs/include/libavcodec/packet.h @@ -0,0 +1,774 @@ +/* + * AVPacket public API + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_PACKET_H +#define AVCODEC_PACKET_H + +#include +#include + +#include "libavutil/attributes.h" +#include "libavutil/buffer.h" +#include "libavutil/dict.h" +#include "libavutil/rational.h" + +#include "libavcodec/version.h" + +/** + * @defgroup lavc_packet AVPacket + * + * Types and functions for working with AVPacket. + * @{ + */ +enum AVPacketSideDataType { + /** + * An AV_PKT_DATA_PALETTE side data packet contains exactly AVPALETTE_SIZE + * bytes worth of palette. This side data signals that a new palette is + * present. + */ + AV_PKT_DATA_PALETTE, + + /** + * The AV_PKT_DATA_NEW_EXTRADATA is used to notify the codec or the format + * that the extradata buffer was changed and the receiving side should + * act upon it appropriately. The new extradata is embedded in the side + * data buffer and should be immediately used for processing the current + * frame or packet. + */ + AV_PKT_DATA_NEW_EXTRADATA, + + /** + * An AV_PKT_DATA_PARAM_CHANGE side data packet is laid out as follows: + * @code + * u32le param_flags + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT) + * s32le channel_count + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT) + * u64le channel_layout + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE) + * s32le sample_rate + * if (param_flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS) + * s32le width + * s32le height + * @endcode + */ + AV_PKT_DATA_PARAM_CHANGE, + + /** + * An AV_PKT_DATA_H263_MB_INFO side data packet contains a number of + * structures with info about macroblocks relevant to splitting the + * packet into smaller packets on macroblock edges (e.g. as for RFC 2190). + * That is, it does not necessarily contain info about all macroblocks, + * as long as the distance between macroblocks in the info is smaller + * than the target payload size. + * Each MB info structure is 12 bytes, and is laid out as follows: + * @code + * u32le bit offset from the start of the packet + * u8 current quantizer at the start of the macroblock + * u8 GOB number + * u16le macroblock address within the GOB + * u8 horizontal MV predictor + * u8 vertical MV predictor + * u8 horizontal MV predictor for block number 3 + * u8 vertical MV predictor for block number 3 + * @endcode + */ + AV_PKT_DATA_H263_MB_INFO, + + /** + * This side data should be associated with an audio stream and contains + * ReplayGain information in form of the AVReplayGain struct. + */ + AV_PKT_DATA_REPLAYGAIN, + + /** + * This side data contains a 3x3 transformation matrix describing an affine + * transformation that needs to be applied to the decoded video frames for + * correct presentation. + * + * See libavutil/display.h for a detailed description of the data. + */ + AV_PKT_DATA_DISPLAYMATRIX, + + /** + * This side data should be associated with a video stream and contains + * Stereoscopic 3D information in form of the AVStereo3D struct. + */ + AV_PKT_DATA_STEREO3D, + + /** + * This side data should be associated with an audio stream and corresponds + * to enum AVAudioServiceType. + */ + AV_PKT_DATA_AUDIO_SERVICE_TYPE, + + /** + * This side data contains quality related information from the encoder. + * @code + * u32le quality factor of the compressed frame. Allowed range is between 1 (good) and FF_LAMBDA_MAX (bad). + * u8 picture type + * u8 error count + * u16 reserved + * u64le[error count] sum of squared differences between encoder in and output + * @endcode + */ + AV_PKT_DATA_QUALITY_STATS, + + /** + * This side data contains an integer value representing the stream index + * of a "fallback" track. A fallback track indicates an alternate + * track to use when the current track can not be decoded for some reason. + * e.g. no decoder available for codec. + */ + AV_PKT_DATA_FALLBACK_TRACK, + + /** + * This side data corresponds to the AVCPBProperties struct. + */ + AV_PKT_DATA_CPB_PROPERTIES, + + /** + * Recommmends skipping the specified number of samples + * @code + * u32le number of samples to skip from start of this packet + * u32le number of samples to skip from end of this packet + * u8 reason for start skip + * u8 reason for end skip (0=padding silence, 1=convergence) + * @endcode + */ + AV_PKT_DATA_SKIP_SAMPLES, + + /** + * An AV_PKT_DATA_JP_DUALMONO side data packet indicates that + * the packet may contain "dual mono" audio specific to Japanese DTV + * and if it is true, recommends only the selected channel to be used. + * @code + * u8 selected channels (0=mail/left, 1=sub/right, 2=both) + * @endcode + */ + AV_PKT_DATA_JP_DUALMONO, + + /** + * A list of zero terminated key/value strings. There is no end marker for + * the list, so it is required to rely on the side data size to stop. + */ + AV_PKT_DATA_STRINGS_METADATA, + + /** + * Subtitle event position + * @code + * u32le x1 + * u32le y1 + * u32le x2 + * u32le y2 + * @endcode + */ + AV_PKT_DATA_SUBTITLE_POSITION, + + /** + * Data found in BlockAdditional element of matroska container. There is + * no end marker for the data, so it is required to rely on the side data + * size to recognize the end. 8 byte id (as found in BlockAddId) followed + * by data. + */ + AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL, + + /** + * The optional first identifier line of a WebVTT cue. + */ + AV_PKT_DATA_WEBVTT_IDENTIFIER, + + /** + * The optional settings (rendering instructions) that immediately + * follow the timestamp specifier of a WebVTT cue. + */ + AV_PKT_DATA_WEBVTT_SETTINGS, + + /** + * A list of zero terminated key/value strings. There is no end marker for + * the list, so it is required to rely on the side data size to stop. This + * side data includes updated metadata which appeared in the stream. + */ + AV_PKT_DATA_METADATA_UPDATE, + + /** + * MPEGTS stream ID as uint8_t, this is required to pass the stream ID + * information from the demuxer to the corresponding muxer. + */ + AV_PKT_DATA_MPEGTS_STREAM_ID, + + /** + * Mastering display metadata (based on SMPTE-2086:2014). This metadata + * should be associated with a video stream and contains data in the form + * of the AVMasteringDisplayMetadata struct. + */ + AV_PKT_DATA_MASTERING_DISPLAY_METADATA, + + /** + * This side data should be associated with a video stream and corresponds + * to the AVSphericalMapping structure. + */ + AV_PKT_DATA_SPHERICAL, + + /** + * Content light level (based on CTA-861.3). This metadata should be + * associated with a video stream and contains data in the form of the + * AVContentLightMetadata struct. + */ + AV_PKT_DATA_CONTENT_LIGHT_LEVEL, + + /** + * ATSC A53 Part 4 Closed Captions. This metadata should be associated with + * a video stream. A53 CC bitstream is stored as uint8_t in AVPacketSideData.data. + * The number of bytes of CC data is AVPacketSideData.size. + */ + AV_PKT_DATA_A53_CC, + + /** + * This side data is encryption initialization data. + * The format is not part of ABI, use av_encryption_init_info_* methods to + * access. + */ + AV_PKT_DATA_ENCRYPTION_INIT_INFO, + + /** + * This side data contains encryption info for how to decrypt the packet. + * The format is not part of ABI, use av_encryption_info_* methods to access. + */ + AV_PKT_DATA_ENCRYPTION_INFO, + + /** + * Active Format Description data consisting of a single byte as specified + * in ETSI TS 101 154 using AVActiveFormatDescription enum. + */ + AV_PKT_DATA_AFD, + + /** + * Producer Reference Time data corresponding to the AVProducerReferenceTime struct, + * usually exported by some encoders (on demand through the prft flag set in the + * AVCodecContext export_side_data field). + */ + AV_PKT_DATA_PRFT, + + /** + * ICC profile data consisting of an opaque octet buffer following the + * format described by ISO 15076-1. + */ + AV_PKT_DATA_ICC_PROFILE, + + /** + * DOVI configuration + * ref: + * dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.1.2, section 2.2 + * dolby-vision-bitstreams-in-mpeg-2-transport-stream-multiplex-v1.2, section 3.3 + * Tags are stored in struct AVDOVIDecoderConfigurationRecord. + */ + AV_PKT_DATA_DOVI_CONF, + + /** + * Timecode which conforms to SMPTE ST 12-1:2014. The data is an array of 4 uint32_t + * where the first uint32_t describes how many (1-3) of the other timecodes are used. + * The timecode format is described in the documentation of av_timecode_get_smpte_from_framenum() + * function in libavutil/timecode.h. + */ + AV_PKT_DATA_S12M_TIMECODE, + + /** + * The number of side data types. + * This is not part of the public API/ABI in the sense that it may + * change when new side data types are added. + * This must stay the last enum value. + * If its value becomes huge, some code using it + * needs to be updated as it assumes it to be smaller than other limits. + */ + AV_PKT_DATA_NB +}; + +#define AV_PKT_DATA_QUALITY_FACTOR AV_PKT_DATA_QUALITY_STATS //DEPRECATED + +typedef struct AVPacketSideData { + uint8_t *data; +#if FF_API_BUFFER_SIZE_T + int size; +#else + size_t size; +#endif + enum AVPacketSideDataType type; +} AVPacketSideData; + +/** + * This structure stores compressed data. It is typically exported by demuxers + * and then passed as input to decoders, or received as output from encoders and + * then passed to muxers. + * + * For video, it should typically contain one compressed frame. For audio it may + * contain several compressed frames. Encoders are allowed to output empty + * packets, with no compressed data, containing only side data + * (e.g. to update some stream parameters at the end of encoding). + * + * The semantics of data ownership depends on the buf field. + * If it is set, the packet data is dynamically allocated and is + * valid indefinitely until a call to av_packet_unref() reduces the + * reference count to 0. + * + * If the buf field is not set av_packet_ref() would make a copy instead + * of increasing the reference count. + * + * The side data is always allocated with av_malloc(), copied by + * av_packet_ref() and freed by av_packet_unref(). + * + * sizeof(AVPacket) being a part of the public ABI is deprecated. once + * av_init_packet() is removed, new packets will only be able to be allocated + * with av_packet_alloc(), and new fields may be added to the end of the struct + * with a minor bump. + * + * @see av_packet_alloc + * @see av_packet_ref + * @see av_packet_unref + */ +typedef struct AVPacket { + /** + * A reference to the reference-counted buffer where the packet data is + * stored. + * May be NULL, then the packet data is not reference-counted. + */ + AVBufferRef *buf; + /** + * Presentation timestamp in AVStream->time_base units; the time at which + * the decompressed packet will be presented to the user. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + * pts MUST be larger or equal to dts as presentation cannot happen before + * decompression, unless one wants to view hex dumps. Some formats misuse + * the terms dts and pts/cts to mean something different. Such timestamps + * must be converted to true pts/dts before they are stored in AVPacket. + */ + int64_t pts; + /** + * Decompression timestamp in AVStream->time_base units; the time at which + * the packet is decompressed. + * Can be AV_NOPTS_VALUE if it is not stored in the file. + */ + int64_t dts; + uint8_t *data; + int size; + int stream_index; + /** + * A combination of AV_PKT_FLAG values + */ + int flags; + /** + * Additional packet data that can be provided by the container. + * Packet can contain several types of side information. + */ + AVPacketSideData *side_data; + int side_data_elems; + + /** + * Duration of this packet in AVStream->time_base units, 0 if unknown. + * Equals next_pts - this_pts in presentation order. + */ + int64_t duration; + + int64_t pos; ///< byte position in stream, -1 if unknown + +#if FF_API_CONVERGENCE_DURATION + /** + * @deprecated Same as the duration field, but as int64_t. This was required + * for Matroska subtitles, whose duration values could overflow when the + * duration field was still an int. + */ + attribute_deprecated + int64_t convergence_duration; +#endif +} AVPacket; + +#if FF_API_INIT_PACKET +attribute_deprecated +typedef struct AVPacketList { + AVPacket pkt; + struct AVPacketList *next; +} AVPacketList; +#endif + +#define AV_PKT_FLAG_KEY 0x0001 ///< The packet contains a keyframe +#define AV_PKT_FLAG_CORRUPT 0x0002 ///< The packet content is corrupted +/** + * Flag is used to discard packets which are required to maintain valid + * decoder state but are not required for output and should be dropped + * after decoding. + **/ +#define AV_PKT_FLAG_DISCARD 0x0004 +/** + * The packet comes from a trusted source. + * + * Otherwise-unsafe constructs such as arbitrary pointers to data + * outside the packet may be followed. + */ +#define AV_PKT_FLAG_TRUSTED 0x0008 +/** + * Flag is used to indicate packets that contain frames that can + * be discarded by the decoder. I.e. Non-reference frames. + */ +#define AV_PKT_FLAG_DISPOSABLE 0x0010 + +enum AVSideDataParamChangeFlags { + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = 0x0001, + AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = 0x0002, + AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = 0x0004, + AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = 0x0008, +}; + +/** + * Allocate an AVPacket and set its fields to default values. The resulting + * struct must be freed using av_packet_free(). + * + * @return An AVPacket filled with default values or NULL on failure. + * + * @note this only allocates the AVPacket itself, not the data buffers. Those + * must be allocated through other means such as av_new_packet. + * + * @see av_new_packet + */ +AVPacket *av_packet_alloc(void); + +/** + * Create a new packet that references the same data as src. + * + * This is a shortcut for av_packet_alloc()+av_packet_ref(). + * + * @return newly created AVPacket on success, NULL on error. + * + * @see av_packet_alloc + * @see av_packet_ref + */ +AVPacket *av_packet_clone(const AVPacket *src); + +/** + * Free the packet, if the packet is reference counted, it will be + * unreferenced first. + * + * @param pkt packet to be freed. The pointer will be set to NULL. + * @note passing NULL is a no-op. + */ +void av_packet_free(AVPacket **pkt); + +#if FF_API_INIT_PACKET +/** + * Initialize optional fields of a packet with default values. + * + * Note, this does not touch the data and size members, which have to be + * initialized separately. + * + * @param pkt packet + * + * @see av_packet_alloc + * @see av_packet_unref + * + * @deprecated This function is deprecated. Once it's removed, + sizeof(AVPacket) will not be a part of the ABI anymore. + */ +attribute_deprecated +void av_init_packet(AVPacket *pkt); +#endif + +/** + * Allocate the payload of a packet and initialize its fields with + * default values. + * + * @param pkt packet + * @param size wanted payload size + * @return 0 if OK, AVERROR_xxx otherwise + */ +int av_new_packet(AVPacket *pkt, int size); + +/** + * Reduce packet size, correctly zeroing padding + * + * @param pkt packet + * @param size new size + */ +void av_shrink_packet(AVPacket *pkt, int size); + +/** + * Increase packet size, correctly zeroing padding + * + * @param pkt packet + * @param grow_by number of bytes by which to increase the size of the packet + */ +int av_grow_packet(AVPacket *pkt, int grow_by); + +/** + * Initialize a reference-counted packet from av_malloc()ed data. + * + * @param pkt packet to be initialized. This function will set the data, size, + * and buf fields, all others are left untouched. + * @param data Data allocated by av_malloc() to be used as packet data. If this + * function returns successfully, the data is owned by the underlying AVBuffer. + * The caller may not access the data through other means. + * @param size size of data in bytes, without the padding. I.e. the full buffer + * size is assumed to be size + AV_INPUT_BUFFER_PADDING_SIZE. + * + * @return 0 on success, a negative AVERROR on error + */ +int av_packet_from_data(AVPacket *pkt, uint8_t *data, int size); + +#if FF_API_AVPACKET_OLD_API +/** + * @warning This is a hack - the packet memory allocation stuff is broken. The + * packet is allocated if it was not really allocated. + * + * @deprecated Use av_packet_ref or av_packet_make_refcounted + */ +attribute_deprecated +int av_dup_packet(AVPacket *pkt); +/** + * Copy packet, including contents + * + * @return 0 on success, negative AVERROR on fail + * + * @deprecated Use av_packet_ref + */ +attribute_deprecated +int av_copy_packet(AVPacket *dst, const AVPacket *src); + +/** + * Copy packet side data + * + * @return 0 on success, negative AVERROR on fail + * + * @deprecated Use av_packet_copy_props + */ +attribute_deprecated +int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src); + +/** + * Free a packet. + * + * @deprecated Use av_packet_unref + * + * @param pkt packet to free + */ +attribute_deprecated +void av_free_packet(AVPacket *pkt); +#endif +/** + * Allocate new information of a packet. + * + * @param pkt packet + * @param type side information type + * @param size side information size + * @return pointer to fresh allocated data or NULL otherwise + */ +uint8_t* av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, +#if FF_API_BUFFER_SIZE_T + int size); +#else + size_t size); +#endif + +/** + * Wrap an existing array as a packet side data. + * + * @param pkt packet + * @param type side information type + * @param data the side data array. It must be allocated with the av_malloc() + * family of functions. The ownership of the data is transferred to + * pkt. + * @param size side information size + * @return a non-negative number on success, a negative AVERROR code on + * failure. On failure, the packet is unchanged and the data remains + * owned by the caller. + */ +int av_packet_add_side_data(AVPacket *pkt, enum AVPacketSideDataType type, + uint8_t *data, size_t size); + +/** + * Shrink the already allocated side data buffer + * + * @param pkt packet + * @param type side information type + * @param size new side information size + * @return 0 on success, < 0 on failure + */ +int av_packet_shrink_side_data(AVPacket *pkt, enum AVPacketSideDataType type, +#if FF_API_BUFFER_SIZE_T + int size); +#else + size_t size); +#endif + +/** + * Get side information from packet. + * + * @param pkt packet + * @param type desired side information type + * @param size If supplied, *size will be set to the size of the side data + * or to zero if the desired side data is not present. + * @return pointer to data if present or NULL otherwise + */ +uint8_t* av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, +#if FF_API_BUFFER_SIZE_T + int *size); +#else + size_t *size); +#endif + +#if FF_API_MERGE_SD_API +attribute_deprecated +int av_packet_merge_side_data(AVPacket *pkt); + +attribute_deprecated +int av_packet_split_side_data(AVPacket *pkt); +#endif + +const char *av_packet_side_data_name(enum AVPacketSideDataType type); + +/** + * Pack a dictionary for use in side_data. + * + * @param dict The dictionary to pack. + * @param size pointer to store the size of the returned data + * @return pointer to data if successful, NULL otherwise + */ +#if FF_API_BUFFER_SIZE_T +uint8_t *av_packet_pack_dictionary(AVDictionary *dict, int *size); +#else +uint8_t *av_packet_pack_dictionary(AVDictionary *dict, size_t *size); +#endif +/** + * Unpack a dictionary from side_data. + * + * @param data data from side_data + * @param size size of the data + * @param dict the metadata storage dictionary + * @return 0 on success, < 0 on failure + */ +#if FF_API_BUFFER_SIZE_T +int av_packet_unpack_dictionary(const uint8_t *data, int size, AVDictionary **dict); +#else +int av_packet_unpack_dictionary(const uint8_t *data, size_t size, + AVDictionary **dict); +#endif + +/** + * Convenience function to free all the side data stored. + * All the other fields stay untouched. + * + * @param pkt packet + */ +void av_packet_free_side_data(AVPacket *pkt); + +/** + * Setup a new reference to the data described by a given packet + * + * If src is reference-counted, setup dst as a new reference to the + * buffer in src. Otherwise allocate a new buffer in dst and copy the + * data from src into it. + * + * All the other fields are copied from src. + * + * @see av_packet_unref + * + * @param dst Destination packet. Will be completely overwritten. + * @param src Source packet + * + * @return 0 on success, a negative AVERROR on error. On error, dst + * will be blank (as if returned by av_packet_alloc()). + */ +int av_packet_ref(AVPacket *dst, const AVPacket *src); + +/** + * Wipe the packet. + * + * Unreference the buffer referenced by the packet and reset the + * remaining packet fields to their default values. + * + * @param pkt The packet to be unreferenced. + */ +void av_packet_unref(AVPacket *pkt); + +/** + * Move every field in src to dst and reset src. + * + * @see av_packet_unref + * + * @param src Source packet, will be reset + * @param dst Destination packet + */ +void av_packet_move_ref(AVPacket *dst, AVPacket *src); + +/** + * Copy only "properties" fields from src to dst. + * + * Properties for the purpose of this function are all the fields + * beside those related to the packet data (buf, data, size) + * + * @param dst Destination packet + * @param src Source packet + * + * @return 0 on success AVERROR on failure. + */ +int av_packet_copy_props(AVPacket *dst, const AVPacket *src); + +/** + * Ensure the data described by a given packet is reference counted. + * + * @note This function does not ensure that the reference will be writable. + * Use av_packet_make_writable instead for that purpose. + * + * @see av_packet_ref + * @see av_packet_make_writable + * + * @param pkt packet whose data should be made reference counted. + * + * @return 0 on success, a negative AVERROR on error. On failure, the + * packet is unchanged. + */ +int av_packet_make_refcounted(AVPacket *pkt); + +/** + * Create a writable reference for the data described by a given packet, + * avoiding data copy if possible. + * + * @param pkt Packet whose data should be made writable. + * + * @return 0 on success, a negative AVERROR on failure. On failure, the + * packet is unchanged. + */ +int av_packet_make_writable(AVPacket *pkt); + +/** + * Convert valid timing fields (timestamps / durations) in a packet from one + * timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be + * ignored. + * + * @param pkt packet on which the conversion will be performed + * @param tb_src source timebase, in which the timing fields in pkt are + * expressed + * @param tb_dst destination timebase, to which the timing fields will be + * converted + */ +void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst); + +/** + * @} + */ + +#endif // AVCODEC_PACKET_H diff --git a/winlibs/include/libavcodec/qsv.h b/winlibs/include/libavcodec/qsv.h new file mode 100644 index 00000000..b77158ec --- /dev/null +++ b/winlibs/include/libavcodec/qsv.h @@ -0,0 +1,107 @@ +/* + * Intel MediaSDK QSV public API + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_QSV_H +#define AVCODEC_QSV_H + +#include + +#include "libavutil/buffer.h" + +/** + * This struct is used for communicating QSV parameters between libavcodec and + * the caller. It is managed by the caller and must be assigned to + * AVCodecContext.hwaccel_context. + * - decoding: hwaccel_context must be set on return from the get_format() + * callback + * - encoding: hwaccel_context must be set before avcodec_open2() + */ +typedef struct AVQSVContext { + /** + * If non-NULL, the session to use for encoding or decoding. + * Otherwise, libavcodec will try to create an internal session. + */ + mfxSession session; + + /** + * The IO pattern to use. + */ + int iopattern; + + /** + * Extra buffers to pass to encoder or decoder initialization. + */ + mfxExtBuffer **ext_buffers; + int nb_ext_buffers; + + /** + * Encoding only. If this field is set to non-zero by the caller, libavcodec + * will create an mfxExtOpaqueSurfaceAlloc extended buffer and pass it to + * the encoder initialization. This only makes sense if iopattern is also + * set to MFX_IOPATTERN_IN_OPAQUE_MEMORY. + * + * The number of allocated opaque surfaces will be the sum of the number + * required by the encoder and the user-provided value nb_opaque_surfaces. + * The array of the opaque surfaces will be exported to the caller through + * the opaque_surfaces field. + */ + int opaque_alloc; + + /** + * Encoding only, and only if opaque_alloc is set to non-zero. Before + * calling avcodec_open2(), the caller should set this field to the number + * of extra opaque surfaces to allocate beyond what is required by the + * encoder. + * + * On return from avcodec_open2(), this field will be set by libavcodec to + * the total number of allocated opaque surfaces. + */ + int nb_opaque_surfaces; + + /** + * Encoding only, and only if opaque_alloc is set to non-zero. On return + * from avcodec_open2(), this field will be used by libavcodec to export the + * array of the allocated opaque surfaces to the caller, so they can be + * passed to other parts of the pipeline. + * + * The buffer reference exported here is owned and managed by libavcodec, + * the callers should make their own reference with av_buffer_ref() and free + * it with av_buffer_unref() when it is no longer needed. + * + * The buffer data is an nb_opaque_surfaces-sized array of mfxFrameSurface1. + */ + AVBufferRef *opaque_surfaces; + + /** + * Encoding only, and only if opaque_alloc is set to non-zero. On return + * from avcodec_open2(), this field will be set to the surface type used in + * the opaque allocation request. + */ + int opaque_alloc_type; +} AVQSVContext; + +/** + * Allocate a new context. + * + * It must be freed by the caller with av_free(). + */ +AVQSVContext *av_qsv_alloc_context(void); + +#endif /* AVCODEC_QSV_H */ diff --git a/winlibs/include/libavcodec/version.h b/winlibs/include/libavcodec/version.h index 3331d473..cfdde469 100644 --- a/winlibs/include/libavcodec/version.h +++ b/winlibs/include/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 58 -#define LIBAVCODEC_VERSION_MINOR 54 +#define LIBAVCODEC_VERSION_MINOR 134 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ @@ -51,12 +51,6 @@ * at once through the bump. This improves the git bisect-ability of the change. */ -#ifndef FF_API_LOWRES -#define FF_API_LOWRES (LIBAVCODEC_VERSION_MAJOR < 59) -#endif -#ifndef FF_API_DEBUG_MV -#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 58) -#endif #ifndef FF_API_AVCTX_TIMEBASE #define FF_API_AVCTX_TIMEBASE (LIBAVCODEC_VERSION_MAJOR < 59) #endif @@ -135,6 +129,44 @@ #ifndef FF_API_UNSANITIZED_BITRATES #define FF_API_UNSANITIZED_BITRATES (LIBAVCODEC_VERSION_MAJOR < 59) #endif - +#ifndef FF_API_OPENH264_SLICE_MODE +#define FF_API_OPENH264_SLICE_MODE (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_OPENH264_CABAC +#define FF_API_OPENH264_CABAC (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_UNUSED_CODEC_CAPS +#define FF_API_UNUSED_CODEC_CAPS (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_AVPRIV_PUT_BITS +#define FF_API_AVPRIV_PUT_BITS (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_OLD_ENCDEC +#define FF_API_OLD_ENCDEC (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_AVCODEC_PIX_FMT +#define FF_API_AVCODEC_PIX_FMT (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_MPV_RC_STRATEGY +#define FF_API_MPV_RC_STRATEGY (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_PARSER_CHANGE +#define FF_API_PARSER_CHANGE (LIBAVCODEC_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_THREAD_SAFE_CALLBACKS +#define FF_API_THREAD_SAFE_CALLBACKS (LIBAVCODEC_VERSION_MAJOR < 60) +#endif +#ifndef FF_API_DEBUG_MV +#define FF_API_DEBUG_MV (LIBAVCODEC_VERSION_MAJOR < 60) +#endif +#ifndef FF_API_GET_FRAME_CLASS +#define FF_API_GET_FRAME_CLASS (LIBAVCODEC_VERSION_MAJOR < 60) +#endif +#ifndef FF_API_AUTO_THREADS +#define FF_API_AUTO_THREADS (LIBAVCODEC_VERSION_MAJOR < 60) +#endif +#ifndef FF_API_INIT_PACKET +#define FF_API_INIT_PACKET (LIBAVCODEC_VERSION_MAJOR < 60) +#endif #endif /* AVCODEC_VERSION_H */ diff --git a/winlibs/include/libavcodec/videotoolbox.h b/winlibs/include/libavcodec/videotoolbox.h new file mode 100644 index 00000000..af2db0d5 --- /dev/null +++ b/winlibs/include/libavcodec/videotoolbox.h @@ -0,0 +1,127 @@ +/* + * Videotoolbox hardware acceleration + * + * copyright (c) 2012 Sebastien Zwickert + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_VIDEOTOOLBOX_H +#define AVCODEC_VIDEOTOOLBOX_H + +/** + * @file + * @ingroup lavc_codec_hwaccel_videotoolbox + * Public libavcodec Videotoolbox header. + */ + +#include + +#define Picture QuickdrawPicture +#include +#undef Picture + +#include "libavcodec/avcodec.h" + +/** + * This struct holds all the information that needs to be passed + * between the caller and libavcodec for initializing Videotoolbox decoding. + * Its size is not a part of the public ABI, it must be allocated with + * av_videotoolbox_alloc_context() and freed with av_free(). + */ +typedef struct AVVideotoolboxContext { + /** + * Videotoolbox decompression session object. + * Created and freed the caller. + */ + VTDecompressionSessionRef session; + + /** + * The output callback that must be passed to the session. + * Set by av_videottoolbox_default_init() + */ + VTDecompressionOutputCallback output_callback; + + /** + * CVPixelBuffer Format Type that Videotoolbox will use for decoded frames. + * set by the caller. If this is set to 0, then no specific format is + * requested from the decoder, and its native format is output. + */ + OSType cv_pix_fmt_type; + + /** + * CoreMedia Format Description that Videotoolbox will use to create the decompression session. + * Set by the caller. + */ + CMVideoFormatDescriptionRef cm_fmt_desc; + + /** + * CoreMedia codec type that Videotoolbox will use to create the decompression session. + * Set by the caller. + */ + int cm_codec_type; +} AVVideotoolboxContext; + +/** + * Allocate and initialize a Videotoolbox context. + * + * This function should be called from the get_format() callback when the caller + * selects the AV_PIX_FMT_VIDETOOLBOX format. The caller must then create + * the decoder object (using the output callback provided by libavcodec) that + * will be used for Videotoolbox-accelerated decoding. + * + * When decoding with Videotoolbox is finished, the caller must destroy the decoder + * object and free the Videotoolbox context using av_free(). + * + * @return the newly allocated context or NULL on failure + */ +AVVideotoolboxContext *av_videotoolbox_alloc_context(void); + +/** + * This is a convenience function that creates and sets up the Videotoolbox context using + * an internal implementation. + * + * @param avctx the corresponding codec context + * + * @return >= 0 on success, a negative AVERROR code on failure + */ +int av_videotoolbox_default_init(AVCodecContext *avctx); + +/** + * This is a convenience function that creates and sets up the Videotoolbox context using + * an internal implementation. + * + * @param avctx the corresponding codec context + * @param vtctx the Videotoolbox context to use + * + * @return >= 0 on success, a negative AVERROR code on failure + */ +int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx); + +/** + * This function must be called to free the Videotoolbox context initialized with + * av_videotoolbox_default_init(). + * + * @param avctx the corresponding codec context + */ +void av_videotoolbox_default_free(AVCodecContext *avctx); + +/** + * @} + */ + +#endif /* AVCODEC_VIDEOTOOLBOX_H */ diff --git a/winlibs/include/libavcodec/vorbis_parser.h b/winlibs/include/libavcodec/vorbis_parser.h new file mode 100644 index 00000000..789932ac --- /dev/null +++ b/winlibs/include/libavcodec/vorbis_parser.h @@ -0,0 +1,74 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * A public API for Vorbis parsing + * + * Determines the duration for each packet. + */ + +#ifndef AVCODEC_VORBIS_PARSER_H +#define AVCODEC_VORBIS_PARSER_H + +#include + +typedef struct AVVorbisParseContext AVVorbisParseContext; + +/** + * Allocate and initialize the Vorbis parser using headers in the extradata. + */ +AVVorbisParseContext *av_vorbis_parse_init(const uint8_t *extradata, + int extradata_size); + +/** + * Free the parser and everything associated with it. + */ +void av_vorbis_parse_free(AVVorbisParseContext **s); + +#define VORBIS_FLAG_HEADER 0x00000001 +#define VORBIS_FLAG_COMMENT 0x00000002 +#define VORBIS_FLAG_SETUP 0x00000004 + +/** + * Get the duration for a Vorbis packet. + * + * If @p flags is @c NULL, + * special frames are considered invalid. + * + * @param s Vorbis parser context + * @param buf buffer containing a Vorbis frame + * @param buf_size size of the buffer + * @param flags flags for special frames + */ +int av_vorbis_parse_frame_flags(AVVorbisParseContext *s, const uint8_t *buf, + int buf_size, int *flags); + +/** + * Get the duration for a Vorbis packet. + * + * @param s Vorbis parser context + * @param buf buffer containing a Vorbis frame + * @param buf_size size of the buffer + */ +int av_vorbis_parse_frame(AVVorbisParseContext *s, const uint8_t *buf, + int buf_size); + +void av_vorbis_parse_reset(AVVorbisParseContext *s); + +#endif /* AVCODEC_VORBIS_PARSER_H */ diff --git a/winlibs/include/libavformat/avformat.h b/winlibs/include/libavformat/avformat.h index 6eb329f1..56708c02 100644 --- a/winlibs/include/libavformat/avformat.h +++ b/winlibs/include/libavformat/avformat.h @@ -170,14 +170,9 @@ * information will be in AVStream.time_base units, i.e. it has to be * multiplied by the timebase to convert them to seconds. * - * If AVPacket.buf is set on the returned packet, then the packet is - * allocated dynamically and the user may keep it indefinitely. - * Otherwise, if AVPacket.buf is NULL, the packet data is backed by a - * static storage somewhere inside the demuxer and the packet is only valid - * until the next av_read_frame() call or closing the file. If the caller - * requires a longer lifetime, av_packet_make_refcounted() will ensure that - * the data is reference counted, copying the data if necessary. - * In both cases, the packet must be freed with av_packet_unref() when it is no + * A packet returned by av_read_frame() is always reference-counted, + * i.e. AVPacket.buf is set and the user may keep it indefinitely. + * The packet must be freed with av_packet_unref() when it is no * longer needed. * * @section lavf_decoding_seek Seeking @@ -361,7 +356,7 @@ struct AVDeviceCapabilitiesQuery; * sorting will have '-sort' appended. E.g. artist="The Beatles", * artist-sort="Beatles, The". * - Some protocols and demuxers support metadata updates. After a successful - * call to av_read_packet(), AVFormatContext.event_flags or AVStream.event_flags + * call to av_read_frame(), AVFormatContext.event_flags or AVStream.event_flags * will be updated to indicate if metadata changed. In order to detect metadata * changes on a stream, you need to loop through all streams in the AVFormatContext * and check their individual event_flags. @@ -539,7 +534,9 @@ typedef struct AVOutputFormat { #else #define ff_const59 const #endif +#if FF_API_NEXT ff_const59 struct AVOutputFormat *next; +#endif /** * size of private data so that it can be allocated in the wrapper */ @@ -556,7 +553,8 @@ typedef struct AVOutputFormat { int (*write_packet)(struct AVFormatContext *, AVPacket *pkt); int (*write_trailer)(struct AVFormatContext *); /** - * Currently only used to set pixel format if not YUV420P. + * A format-specific function for interleavement. + * If unset, packets will be interleaved by dts. */ int (*interleave_packet)(struct AVFormatContext *, AVPacket *out, AVPacket *in, int flush); @@ -592,6 +590,7 @@ typedef struct AVOutputFormat { * @see avdevice_list_devices() for more details. */ int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list); +#if LIBAVFORMAT_VERSION_MAJOR < 59 /** * Initialize device capabilities submodule. * @see avdevice_capabilities_create() for more details. @@ -602,6 +601,7 @@ typedef struct AVOutputFormat { * @see avdevice_capabilities_free() for more details. */ int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); +#endif enum AVCodecID data_codec; /**< default data codec */ /** * Initialize format. May allocate data here, and set any AVFormatContext or @@ -683,7 +683,9 @@ typedef struct AVInputFormat { * New public fields should be added right above. ***************************************************************** */ +#if FF_API_NEXT ff_const59 struct AVInputFormat *next; +#endif /** * Raw demuxers store their codec ID here. @@ -715,8 +717,7 @@ typedef struct AVInputFormat { * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a * background thread). * @return 0 on success, < 0 on error. - * When returning an error, pkt must not have been allocated - * or must be freed before returning + * Upon returning an error, pkt must be unreferenced by the caller. */ int (*read_packet)(struct AVFormatContext *, AVPacket *pkt); @@ -770,6 +771,7 @@ typedef struct AVInputFormat { */ int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list); +#if LIBAVFORMAT_VERSION_MAJOR < 59 /** * Initialize device capabilities submodule. * @see avdevice_capabilities_create() for more details. @@ -781,6 +783,7 @@ typedef struct AVInputFormat { * @see avdevice_capabilities_free() for more details. */ int (*free_device_capabilities)(struct AVFormatContext *s, struct AVDeviceCapabilitiesQuery *caps); +#endif } AVInputFormat; /** * @} @@ -978,12 +981,30 @@ typedef struct AVStream { int nb_side_data; /** - * Flags for the user to detect events happening on the stream. Flags must - * be cleared by the user once the event has been handled. - * A combination of AVSTREAM_EVENT_FLAG_*. + * Flags indicating events happening on the stream, a combination of + * AVSTREAM_EVENT_FLAG_*. + * + * - demuxing: may be set by the demuxer in avformat_open_input(), + * avformat_find_stream_info() and av_read_frame(). Flags must be cleared + * by the user once the event has been handled. + * - muxing: may be set by the user after avformat_write_header(). to + * indicate a user-triggered event. The muxer will clear the flags for + * events it has handled in av_[interleaved]_write_frame(). */ int event_flags; -#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata. +/** + * - demuxing: the demuxer read new metadata from the file and updated + * AVStream.metadata accordingly + * - muxing: the user updated AVStream.metadata and wishes the muxer to write + * it into the file + */ +#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001 +/** + * - demuxing: new packets for this stream were read from the file. This + * event is informational only and does not guarantee that new packets + * for this stream will necessarily be returned from av_read_frame(). + */ +#define AVSTREAM_EVENT_FLAG_NEW_PACKETS (1 << 1) /** * Real base framerate of the stream. @@ -1028,38 +1049,10 @@ typedef struct AVStream { ***************************************************************** */ -#define MAX_STD_TIMEBASES (30*12+30+3+6) - /** - * Stream information used internally by avformat_find_stream_info() - */ - struct { - int64_t last_dts; - int64_t duration_gcd; - int duration_count; - int64_t rfps_duration_sum; - double (*duration_error)[2][MAX_STD_TIMEBASES]; - int64_t codec_info_duration; - int64_t codec_info_duration_fields; - int frame_delay_evidence; - - /** - * 0 -> decoder has not been searched for yet. - * >0 -> decoder found - * <0 -> decoder with codec_id == -found_decoder has not been found - */ - int found_decoder; - - int64_t last_duration; - - /** - * Those are used for average framerate estimation. - */ - int64_t fps_first_dts; - int fps_first_dts_idx; - int64_t fps_last_dts; - int fps_last_dts_idx; - - } *info; +#if LIBAVFORMAT_VERSION_MAJOR < 59 + // kept for ABI compatibility only, do not access in any way + void *unused; +#endif int pts_wrap_bits; /**< number of bits in pts (used for wrapping control) */ @@ -1090,14 +1083,12 @@ typedef struct AVStream { enum AVStreamParseType need_parsing; struct AVCodecParserContext *parser; - /** - * last packet in packet_buffer for this stream when muxing. - */ - struct AVPacketList *last_in_packet_buffer; - AVProbeData probe_data; -#define MAX_REORDER_DELAY 16 - int64_t pts_buffer[MAX_REORDER_DELAY+1]; - +#if LIBAVFORMAT_VERSION_MAJOR < 59 + // kept for ABI compatibility only, do not access in any way + void *unused7; + AVProbeData unused6; + int64_t unused5[16+1]; +#endif AVIndexEntry *index_entries; /**< Only used if the format does not support seeking natively. */ int nb_index_entries; @@ -1110,117 +1101,12 @@ typedef struct AVStream { */ int stream_identifier; - /** - * Details of the MPEG-TS program which created this stream. - */ - int program_num; - int pmt_version; - int pmt_stream_idx; - - int64_t interleaver_chunk_size; - int64_t interleaver_chunk_duration; - - /** - * stream probing state - * -1 -> probing finished - * 0 -> no probing requested - * rest -> perform probing with request_probe being the minimum score to accept. - * NOT PART OF PUBLIC API - */ - int request_probe; - /** - * Indicates that everything up to the next keyframe - * should be discarded. - */ - int skip_to_keyframe; - - /** - * Number of samples to skip at the start of the frame decoded from the next packet. - */ - int skip_samples; - - /** - * If not 0, the number of samples that should be skipped from the start of - * the stream (the samples are removed from packets with pts==0, which also - * assumes negative timestamps do not happen). - * Intended for use with formats such as mp3 with ad-hoc gapless audio - * support. - */ - int64_t start_skip_samples; - - /** - * If not 0, the first audio sample that should be discarded from the stream. - * This is broken by design (needs global sample count), but can't be - * avoided for broken by design formats such as mp3 with ad-hoc gapless - * audio support. - */ - int64_t first_discard_sample; - - /** - * The sample after last sample that is intended to be discarded after - * first_discard_sample. Works on frame boundaries only. Used to prevent - * early EOF if the gapless info is broken (considered concatenated mp3s). - */ - int64_t last_discard_sample; - - /** - * Number of internally decoded frames, used internally in libavformat, do not access - * its lifetime differs from info which is why it is not in that structure. - */ - int nb_decoded_frames; - - /** - * Timestamp offset added to timestamps before muxing - * NOT PART OF PUBLIC API - */ - int64_t mux_ts_offset; - - /** - * Internal data to check for wrapping of the time stamp - */ - int64_t pts_wrap_reference; - - /** - * Options for behavior, when a wrap is detected. - * - * Defined by AV_PTS_WRAP_ values. - * - * If correction is enabled, there are two possibilities: - * If the first time stamp is near the wrap point, the wrap offset - * will be subtracted, which will create negative time stamps. - * Otherwise the offset will be added. - */ - int pts_wrap_behavior; - - /** - * Internal data to prevent doing update_initial_durations() twice - */ - int update_initial_durations_done; - - /** - * Internal data to generate dts from pts - */ - int64_t pts_reorder_error[MAX_REORDER_DELAY+1]; - uint8_t pts_reorder_error_count[MAX_REORDER_DELAY+1]; - - /** - * Internal data to analyze DTS and detect faulty mpeg streams - */ - int64_t last_dts_for_order_check; - uint8_t dts_ordered; - uint8_t dts_misordered; - - /** - * Internal data to inject global side data - */ - int inject_global_side_data; - - /** - * display aspect ratio (0 if unknown) - * - encoding: unused - * - decoding: Set by libavformat to calculate sample_aspect_ratio internally - */ - AVRational display_aspect_ratio; +#if LIBAVFORMAT_VERSION_MAJOR < 59 + // kept for ABI compatibility only, do not access in any way + int unused8; + int unused9; + int unused10; +#endif /** * An opaque field for libavformat internal usage. @@ -1299,7 +1185,11 @@ typedef struct AVProgram { change dynamically at runtime. */ typedef struct AVChapter { +#if FF_API_CHAPTER_ID_INT int id; ///< unique ID to identify the chapter +#else + int64_t id; ///< unique ID to identify the chapter +#endif AVRational time_base; ///< time base in which the start/end timestamps are specified int64_t start, end; ///< chapter start/end time in time_base units AVDictionary *metadata; @@ -1494,7 +1384,9 @@ typedef struct AVFormatContext { #define AVFMT_FLAG_MP4A_LATM 0x8000 ///< Deprecated, does nothing. #endif #define AVFMT_FLAG_SORT_DTS 0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down) -#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (this could be made default once all code is converted) +#if FF_API_LAVF_PRIV_OPT +#define AVFMT_FLAG_PRIV_OPT 0x20000 ///< Enable use of private options by delaying codec open (deprecated, will do nothing once av_demuxer_open() is removed) +#endif #if FF_API_LAVF_KEEPSIDE_FLAG #define AVFMT_FLAG_KEEP_SIDE_DATA 0x40000 ///< Deprecated, does nothing. #endif @@ -1652,12 +1544,24 @@ typedef struct AVFormatContext { int strict_std_compliance; /** - * Flags for the user to detect events happening on the file. Flags must - * be cleared by the user once the event has been handled. - * A combination of AVFMT_EVENT_FLAG_*. + * Flags indicating events happening on the file, a combination of + * AVFMT_EVENT_FLAG_*. + * + * - demuxing: may be set by the demuxer in avformat_open_input(), + * avformat_find_stream_info() and av_read_frame(). Flags must be cleared + * by the user once the event has been handled. + * - muxing: may be set by the user after avformat_write_header() to + * indicate a user-triggered event. The muxer will clear the flags for + * events it has handled in av_[interleaved]_write_frame(). */ int event_flags; -#define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001 ///< The call resulted in updated metadata. +/** + * - demuxing: the demuxer read new metadata from the file and updated + * AVFormatContext.metadata accordingly + * - muxing: the user updated AVFormatContext.metadata and wishes the muxer to + * write it into the file + */ +#define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001 /** * Maximum number of packets to read while waiting for the first timestamp. @@ -1951,6 +1855,13 @@ typedef struct AVFormatContext { * - decoding: set by user */ int skip_estimate_duration_from_pts; + + /** + * Maximum number of packets that can be probed + * - encoding: unused + * - decoding: set by user + */ + int max_probe_packets; } AVFormatContext; #if FF_API_FORMAT_GET_SET @@ -2007,12 +1918,6 @@ void av_format_inject_global_side_data(AVFormatContext *s); */ enum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx); -typedef struct AVPacketList { - AVPacket pkt; - struct AVPacketList *next; -} AVPacketList; - - /** * @defgroup lavf_core Core functions * @ingroup libavf @@ -2183,17 +2088,26 @@ int av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type, * @return pointer to fresh allocated data or NULL otherwise */ uint8_t *av_stream_new_side_data(AVStream *stream, +#if FF_API_BUFFER_SIZE_T enum AVPacketSideDataType type, int size); +#else + enum AVPacketSideDataType type, size_t size); +#endif /** * Get side information from stream. * * @param stream stream * @param type desired side information type - * @param size pointer for side information size to store (optional) + * @param size If supplied, *size will be set to the size of the side data + * or to zero if the desired side data is not present. * @return pointer to data if present or NULL otherwise */ uint8_t *av_stream_get_side_data(const AVStream *stream, +#if FF_API_BUFFER_SIZE_T enum AVPacketSideDataType type, int *size); +#else + enum AVPacketSideDataType type, size_t *size); +#endif AVProgram *av_new_program(AVFormatContext *s, int id); @@ -2311,8 +2225,13 @@ int av_probe_input_buffer(AVIOContext *pb, ff_const59 AVInputFormat **fmt, */ int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options); +#if FF_API_DEMUXER_OPEN +/** + * @deprecated Use an AVDictionary to pass options to a demuxer. + */ attribute_deprecated int av_demuxer_open(AVFormatContext *ic); +#endif /** * Read packets of a media file to get stream information. This @@ -2390,13 +2309,12 @@ int av_find_best_stream(AVFormatContext *ic, * omit invalid data between valid frames so as to give the decoder the maximum * information possible for decoding. * - * If pkt->buf is NULL, then the packet is valid until the next - * av_read_frame() or until avformat_close_input(). Otherwise the packet - * is valid indefinitely. In both cases the packet must be freed with - * av_packet_unref when it is no longer needed. For video, the packet contains - * exactly one frame. For audio, it contains an integer number of frames if each - * frame has a known fixed size (e.g. PCM or ADPCM data). If the audio frames - * have a variable size (e.g. MPEG audio), then it contains one frame. + * On success, the returned packet is reference-counted (pkt->buf is set) and + * valid indefinitely. The packet must be freed with av_packet_unref() when + * it is no longer needed. For video, the packet contains exactly one frame. + * For audio, it contains an integer number of frames if each frame has + * a known fixed size (e.g. PCM or ADPCM data). If the audio frames have + * a variable size (e.g. MPEG audio), then it contains one frame. * * pkt->pts, pkt->dts and pkt->duration are always set to correct * values in AVStream.time_base units (and guessed if the format cannot @@ -2404,7 +2322,11 @@ int av_find_best_stream(AVFormatContext *ic, * has B-frames, so it is better to rely on pkt->dts if you do not * decompress the payload. * - * @return 0 if OK, < 0 on error or end of file + * @return 0 if OK, < 0 on error or end of file. On error, pkt will be blank + * (as if it came from av_packet_alloc()). + * + * @note pkt will be initialized, so it may be uninitialized, but it must not + * contain data that needs to be freed. */ int av_read_frame(AVFormatContext *s, AVPacket *pkt); @@ -2449,8 +2371,6 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, * @return >=0 on success, error code otherwise * * @note This is part of the new seek API which is still under construction. - * Thus do not use this yet. It may change at any time, do not expect - * ABI compatibility yet! */ int avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags); @@ -2637,9 +2557,9 @@ int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt); * Write an uncoded frame to an output media file. * * The frame must be correctly interleaved according to the container - * specification; if not, then av_interleaved_write_frame() must be used. + * specification; if not, av_interleaved_write_uncoded_frame() must be used. * - * See av_interleaved_write_frame() for details. + * See av_interleaved_write_uncoded_frame() for details. */ int av_write_uncoded_frame(AVFormatContext *s, int stream_index, AVFrame *frame); diff --git a/winlibs/include/libavformat/avio.h b/winlibs/include/libavformat/avio.h index dcb8dcdf..d022820a 100644 --- a/winlibs/include/libavformat/avio.h +++ b/winlibs/include/libavformat/avio.h @@ -571,9 +571,29 @@ int64_t avio_size(AVIOContext *s); */ int avio_feof(AVIOContext *s); -/** @warning Writes up to 4 KiB per call */ +/** + * Writes a formatted string to the context. + * @return number of bytes written, < 0 on error. + */ int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3); +/** + * Write a NULL terminated array of strings to the context. + * Usually you don't need to use this function directly but its macro wrapper, + * avio_print. + */ +void avio_print_string_array(AVIOContext *s, const char *strings[]); + +/** + * Write strings (const char *) to the context. + * This is a convenience macro around avio_print_string_array and it + * automatically creates the string array from the variable argument list. + * For simple string concatenations this function is more performant than using + * avio_printf since it does not need a temporary buffer. + */ +#define avio_print(s, ...) \ + avio_print_string_array(s, (const char*[]){__VA_ARGS__, NULL}) + /** * Force flushing of buffered data. * @@ -787,6 +807,13 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); */ const char *avio_enum_protocols(void **opaque, int output); +/** + * Get AVClass by names of available protocols. + * + * @return A AVClass of input protocol name or NULL + */ +const AVClass *avio_protocol_get_class(const char *name); + /** * Pause and resume playing - only meaningful if using a network streaming * protocol (e.g. MMS). diff --git a/winlibs/include/libavformat/version.h b/winlibs/include/libavformat/version.h index 22ed534b..46dc51a2 100644 --- a/winlibs/include/libavformat/version.h +++ b/winlibs/include/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 58 -#define LIBAVFORMAT_VERSION_MINOR 29 +#define LIBAVFORMAT_VERSION_MINOR 76 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ @@ -106,6 +106,15 @@ #ifndef FF_API_AVIOFORMAT #define FF_API_AVIOFORMAT (LIBAVFORMAT_VERSION_MAJOR < 59) #endif +#ifndef FF_API_DEMUXER_OPEN +#define FF_API_DEMUXER_OPEN (LIBAVFORMAT_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_CHAPTER_ID_INT +#define FF_API_CHAPTER_ID_INT (LIBAVFORMAT_VERSION_MAJOR < 59) +#endif +#ifndef FF_API_LAVF_PRIV_OPT +#define FF_API_LAVF_PRIV_OPT (LIBAVFORMAT_VERSION_MAJOR < 60) +#endif #ifndef FF_API_R_FRAME_RATE diff --git a/maclibs/include/libavutil/adler32.h b/winlibs/include/libavutil/adler32.h similarity index 82% rename from maclibs/include/libavutil/adler32.h rename to winlibs/include/libavutil/adler32.h index a1f035b7..e7a8f837 100644 --- a/maclibs/include/libavutil/adler32.h +++ b/winlibs/include/libavutil/adler32.h @@ -27,8 +27,10 @@ #ifndef AVUTIL_ADLER32_H #define AVUTIL_ADLER32_H +#include #include #include "attributes.h" +#include "version.h" /** * @defgroup lavu_adler32 Adler-32 @@ -38,6 +40,12 @@ * @{ */ +#if FF_API_CRYPTO_SIZE_T +typedef unsigned long AVAdler; +#else +typedef uint32_t AVAdler; +#endif + /** * Calculate the Adler32 checksum of a buffer. * @@ -50,8 +58,12 @@ * @param len size of input buffer * @return updated checksum */ -unsigned long av_adler32_update(unsigned long adler, const uint8_t *buf, - unsigned int len) av_pure; +AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, +#if FF_API_CRYPTO_SIZE_T + unsigned int len) av_pure; +#else + size_t len) av_pure; +#endif /** * @} diff --git a/maclibs/include/libavutil/aes.h b/winlibs/include/libavutil/aes.h similarity index 100% rename from maclibs/include/libavutil/aes.h rename to winlibs/include/libavutil/aes.h diff --git a/winlibs/include/libavutil/aes_ctr.h b/winlibs/include/libavutil/aes_ctr.h new file mode 100644 index 00000000..e4aae126 --- /dev/null +++ b/winlibs/include/libavutil/aes_ctr.h @@ -0,0 +1,88 @@ +/* + * AES-CTR cipher + * Copyright (c) 2015 Eran Kornblau + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_AES_CTR_H +#define AVUTIL_AES_CTR_H + +#include + +#include "attributes.h" +#include "version.h" + +#define AES_CTR_KEY_SIZE (16) +#define AES_CTR_IV_SIZE (8) + +struct AVAESCTR; + +/** + * Allocate an AVAESCTR context. + */ +struct AVAESCTR *av_aes_ctr_alloc(void); + +/** + * Initialize an AVAESCTR context. + * @param key encryption key, must have a length of AES_CTR_KEY_SIZE + */ +int av_aes_ctr_init(struct AVAESCTR *a, const uint8_t *key); + +/** + * Release an AVAESCTR context. + */ +void av_aes_ctr_free(struct AVAESCTR *a); + +/** + * Process a buffer using a previously initialized context. + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param size the size of src and dst + */ +void av_aes_ctr_crypt(struct AVAESCTR *a, uint8_t *dst, const uint8_t *src, int size); + +/** + * Get the current iv + */ +const uint8_t* av_aes_ctr_get_iv(struct AVAESCTR *a); + +/** + * Generate a random iv + */ +void av_aes_ctr_set_random_iv(struct AVAESCTR *a); + +/** + * Forcefully change the 8-byte iv + */ +void av_aes_ctr_set_iv(struct AVAESCTR *a, const uint8_t* iv); + +/** + * Forcefully change the "full" 16-byte iv, including the counter + */ +void av_aes_ctr_set_full_iv(struct AVAESCTR *a, const uint8_t* iv); + +/** + * Increment the top 64 bit of the iv (performed after each frame) + */ +void av_aes_ctr_increment_iv(struct AVAESCTR *a); + +/** + * @} + */ + +#endif /* AVUTIL_AES_CTR_H */ diff --git a/winlibs/include/libavutil/attributes.h b/winlibs/include/libavutil/attributes.h index ced108aa..5cb9fe34 100644 --- a/winlibs/include/libavutil/attributes.h +++ b/winlibs/include/libavutil/attributes.h @@ -34,6 +34,12 @@ # define AV_GCC_VERSION_AT_MOST(x,y) 0 #endif +#ifdef __has_builtin +# define AV_HAS_BUILTIN(x) __has_builtin(x) +#else +# define AV_HAS_BUILTIN(x) 0 +#endif + #ifndef av_always_inline #if AV_GCC_VERSION_AT_LEAST(3,1) # define av_always_inline __attribute__((always_inline)) inline diff --git a/maclibs/include/libavutil/audio_fifo.h b/winlibs/include/libavutil/audio_fifo.h similarity index 100% rename from maclibs/include/libavutil/audio_fifo.h rename to winlibs/include/libavutil/audio_fifo.h diff --git a/maclibs/include/libavutil/avassert.h b/winlibs/include/libavutil/avassert.h similarity index 100% rename from maclibs/include/libavutil/avassert.h rename to winlibs/include/libavutil/avassert.h diff --git a/maclibs/include/libavutil/avstring.h b/winlibs/include/libavutil/avstring.h similarity index 92% rename from maclibs/include/libavutil/avstring.h rename to winlibs/include/libavutil/avstring.h index 37dd4e2d..fae446c3 100644 --- a/maclibs/include/libavutil/avstring.h +++ b/winlibs/include/libavutil/avstring.h @@ -24,6 +24,7 @@ #include #include #include "attributes.h" +#include "version.h" /** * @addtogroup lavu_string @@ -155,10 +156,14 @@ static inline size_t av_strnlen(const char *s, size_t len) */ char *av_asprintf(const char *fmt, ...) av_printf_format(1, 2); +#if FF_API_D2STR /** * Convert a number to an av_malloced string. + * @deprecated use av_asprintf() with "%f" or a more specific format */ +attribute_deprecated char *av_d2str(double d); +#endif /** * Unescape the given string until a non escaped terminating char, @@ -274,16 +279,21 @@ char *av_strireplace(const char *str, const char *from, const char *to); /** * Thread safe basename. - * @param path the path, on DOS both \ and / are considered separators. + * @param path the string to parse, on DOS both \ and / are considered separators. * @return pointer to the basename substring. + * If path does not contain a slash, the function returns a copy of path. + * If path is a NULL pointer or points to an empty string, a pointer + * to a string "." is returned. */ const char *av_basename(const char *path); /** * Thread safe dirname. - * @param path the path, on DOS both \ and / are considered separators. - * @return the path with the separator replaced by the string terminator or ".". - * @note the function may change the input string. + * @param path the string to parse, on DOS both \ and / are considered separators. + * @return A pointer to a string that's the parent directory of path. + * If path is a NULL pointer or points to an empty string, a pointer + * to a string "." is returned. + * @note the function may modify the contents of the path, so copies should be passed. */ const char *av_dirname(char *path); @@ -314,6 +324,7 @@ enum AVEscapeMode { AV_ESCAPE_MODE_AUTO, ///< Use auto-selected escaping mode. AV_ESCAPE_MODE_BACKSLASH, ///< Use backslash escaping. AV_ESCAPE_MODE_QUOTE, ///< Use single-quote escaping. + AV_ESCAPE_MODE_XML, ///< Use XML non-markup character data escaping. }; /** @@ -333,6 +344,19 @@ enum AVEscapeMode { */ #define AV_ESCAPE_FLAG_STRICT (1 << 1) +/** + * Within AV_ESCAPE_MODE_XML, additionally escape single quotes for single + * quoted attributes. + */ +#define AV_ESCAPE_FLAG_XML_SINGLE_QUOTES (1 << 2) + +/** + * Within AV_ESCAPE_MODE_XML, additionally escape double quotes for double + * quoted attributes. + */ +#define AV_ESCAPE_FLAG_XML_DOUBLE_QUOTES (1 << 3) + + /** * Escape string in src, and put the escaped string in an allocated * string in *dst, which must be freed with av_free(). diff --git a/maclibs/include/libavutil/base64.h b/winlibs/include/libavutil/base64.h similarity index 100% rename from maclibs/include/libavutil/base64.h rename to winlibs/include/libavutil/base64.h diff --git a/maclibs/include/libavutil/blowfish.h b/winlibs/include/libavutil/blowfish.h similarity index 100% rename from maclibs/include/libavutil/blowfish.h rename to winlibs/include/libavutil/blowfish.h diff --git a/maclibs/include/libavutil/bprint.h b/winlibs/include/libavutil/bprint.h similarity index 100% rename from maclibs/include/libavutil/bprint.h rename to winlibs/include/libavutil/bprint.h diff --git a/maclibs/include/libavutil/bswap.h b/winlibs/include/libavutil/bswap.h similarity index 100% rename from maclibs/include/libavutil/bswap.h rename to winlibs/include/libavutil/bswap.h diff --git a/winlibs/include/libavutil/buffer.h b/winlibs/include/libavutil/buffer.h index 73b6bd0b..241a80ed 100644 --- a/winlibs/include/libavutil/buffer.h +++ b/winlibs/include/libavutil/buffer.h @@ -25,8 +25,11 @@ #ifndef AVUTIL_BUFFER_H #define AVUTIL_BUFFER_H +#include #include +#include "version.h" + /** * @defgroup lavu_buffer AVBuffer * @ingroup lavu_data @@ -90,7 +93,11 @@ typedef struct AVBufferRef { /** * Size of data in bytes. */ +#if FF_API_BUFFER_SIZE_T int size; +#else + size_t size; +#endif } AVBufferRef; /** @@ -98,13 +105,21 @@ typedef struct AVBufferRef { * * @return an AVBufferRef of given size or NULL when out of memory */ +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_alloc(int size); +#else +AVBufferRef *av_buffer_alloc(size_t size); +#endif /** * Same as av_buffer_alloc(), except the returned buffer will be initialized * to zero. */ +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_allocz(int size); +#else +AVBufferRef *av_buffer_allocz(size_t size); +#endif /** * Always treat the buffer as read-only, even when it has only one @@ -127,7 +142,11 @@ AVBufferRef *av_buffer_allocz(int size); * * @return an AVBufferRef referring to data on success, NULL on failure. */ +#if FF_API_BUFFER_SIZE_T AVBufferRef *av_buffer_create(uint8_t *data, int size, +#else +AVBufferRef *av_buffer_create(uint8_t *data, size_t size, +#endif void (*free)(void *opaque, uint8_t *data), void *opaque, int flags); @@ -195,7 +214,27 @@ int av_buffer_make_writable(AVBufferRef **buf); * reference to it (i.e. the one passed to this function). In all other cases * a new buffer is allocated and the data is copied. */ +#if FF_API_BUFFER_SIZE_T int av_buffer_realloc(AVBufferRef **buf, int size); +#else +int av_buffer_realloc(AVBufferRef **buf, size_t size); +#endif + +/** + * Ensure dst refers to the same data as src. + * + * When *dst is already equivalent to src, do nothing. Otherwise unreference dst + * and replace it with a new reference to src. + * + * @param dst Pointer to either a valid buffer reference or NULL. On success, + * this will point to a buffer reference equivalent to src. On + * failure, dst will be left untouched. + * @param src A buffer reference to replace dst with. May be NULL, then this + * function is equivalent to av_buffer_unref(dst). + * @return 0 on success + * AVERROR(ENOMEM) on memory allocation failure. + */ +int av_buffer_replace(AVBufferRef **dst, AVBufferRef *src); /** * @} @@ -246,7 +285,11 @@ typedef struct AVBufferPool AVBufferPool; * (av_buffer_alloc()). * @return newly created buffer pool on success, NULL on error. */ +#if FF_API_BUFFER_SIZE_T AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); +#else +AVBufferPool *av_buffer_pool_init(size_t size, AVBufferRef* (*alloc)(size_t size)); +#endif /** * Allocate and initialize a buffer pool with a more complex allocator. @@ -254,16 +297,22 @@ AVBufferPool *av_buffer_pool_init(int size, AVBufferRef* (*alloc)(int size)); * @param size size of each buffer in this pool * @param opaque arbitrary user data used by the allocator * @param alloc a function that will be used to allocate new buffers when the - * pool is empty. + * pool is empty. May be NULL, then the default allocator will be + * used (av_buffer_alloc()). * @param pool_free a function that will be called immediately before the pool * is freed. I.e. after av_buffer_pool_uninit() is called * by the caller and all the frames are returned to the pool * and freed. It is intended to uninitialize the user opaque - * data. + * data. May be NULL. * @return newly created buffer pool on success, NULL on error. */ +#if FF_API_BUFFER_SIZE_T AVBufferPool *av_buffer_pool_init2(int size, void *opaque, AVBufferRef* (*alloc)(void *opaque, int size), +#else +AVBufferPool *av_buffer_pool_init2(size_t size, void *opaque, + AVBufferRef* (*alloc)(void *opaque, size_t size), +#endif void (*pool_free)(void *opaque)); /** @@ -284,6 +333,19 @@ void av_buffer_pool_uninit(AVBufferPool **pool); */ AVBufferRef *av_buffer_pool_get(AVBufferPool *pool); +/** + * Query the original opaque parameter of an allocated buffer in the pool. + * + * @param ref a buffer reference to a buffer returned by av_buffer_pool_get. + * @return the opaque parameter set by the buffer allocator function of the + * buffer pool. + * + * @note the opaque parameter of ref is used by the buffer pool implementation, + * therefore you have to use this function to access the original opaque + * parameter of an allocated buffer. + */ +void *av_buffer_pool_buffer_get_opaque(AVBufferRef *ref); + /** * @} */ diff --git a/winlibs/include/libavutil/camellia.h b/winlibs/include/libavutil/camellia.h new file mode 100644 index 00000000..e674c9b9 --- /dev/null +++ b/winlibs/include/libavutil/camellia.h @@ -0,0 +1,70 @@ +/* + * An implementation of the CAMELLIA algorithm as mentioned in RFC3713 + * Copyright (c) 2014 Supraja Meedinti + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_CAMELLIA_H +#define AVUTIL_CAMELLIA_H + +#include + + +/** + * @file + * @brief Public header for libavutil CAMELLIA algorithm + * @defgroup lavu_camellia CAMELLIA + * @ingroup lavu_crypto + * @{ + */ + +extern const int av_camellia_size; + +struct AVCAMELLIA; + +/** + * Allocate an AVCAMELLIA context + * To free the struct: av_free(ptr) + */ +struct AVCAMELLIA *av_camellia_alloc(void); + +/** + * Initialize an AVCAMELLIA context. + * + * @param ctx an AVCAMELLIA context + * @param key a key of 16, 24, 32 bytes used for encryption/decryption + * @param key_bits number of keybits: possible are 128, 192, 256 + */ +int av_camellia_init(struct AVCAMELLIA *ctx, const uint8_t *key, int key_bits); + +/** + * Encrypt or decrypt a buffer using a previously initialized context + * + * @param ctx an AVCAMELLIA context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 16 byte blocks + * @paran iv initialization vector for CBC mode, NULL for ECB mode + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_camellia_crypt(struct AVCAMELLIA *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt); + +/** + * @} + */ +#endif /* AVUTIL_CAMELLIA_H */ diff --git a/winlibs/include/libavutil/cast5.h b/winlibs/include/libavutil/cast5.h new file mode 100644 index 00000000..ad5b347e --- /dev/null +++ b/winlibs/include/libavutil/cast5.h @@ -0,0 +1,80 @@ +/* + * An implementation of the CAST128 algorithm as mentioned in RFC2144 + * Copyright (c) 2014 Supraja Meedinti + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_CAST5_H +#define AVUTIL_CAST5_H + +#include + + +/** + * @file + * @brief Public header for libavutil CAST5 algorithm + * @defgroup lavu_cast5 CAST5 + * @ingroup lavu_crypto + * @{ + */ + +extern const int av_cast5_size; + +struct AVCAST5; + +/** + * Allocate an AVCAST5 context + * To free the struct: av_free(ptr) + */ +struct AVCAST5 *av_cast5_alloc(void); +/** + * Initialize an AVCAST5 context. + * + * @param ctx an AVCAST5 context + * @param key a key of 5,6,...16 bytes used for encryption/decryption + * @param key_bits number of keybits: possible are 40,48,...,128 + * @return 0 on success, less than 0 on failure + */ +int av_cast5_init(struct AVCAST5 *ctx, const uint8_t *key, int key_bits); + +/** + * Encrypt or decrypt a buffer using a previously initialized context, ECB mode only + * + * @param ctx an AVCAST5 context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 8 byte blocks + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_cast5_crypt(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, int decrypt); + +/** + * Encrypt or decrypt a buffer using a previously initialized context + * + * @param ctx an AVCAST5 context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 8 byte blocks + * @param iv initialization vector for CBC mode, NULL for ECB mode + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_cast5_crypt2(struct AVCAST5 *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); +/** + * @} + */ +#endif /* AVUTIL_CAST5_H */ diff --git a/winlibs/include/libavutil/channel_layout.h b/winlibs/include/libavutil/channel_layout.h index 50bb8f03..d39ae117 100644 --- a/winlibs/include/libavutil/channel_layout.h +++ b/winlibs/include/libavutil/channel_layout.h @@ -71,6 +71,11 @@ #define AV_CH_SURROUND_DIRECT_LEFT 0x0000000200000000ULL #define AV_CH_SURROUND_DIRECT_RIGHT 0x0000000400000000ULL #define AV_CH_LOW_FREQUENCY_2 0x0000000800000000ULL +#define AV_CH_TOP_SIDE_LEFT 0x0000001000000000ULL +#define AV_CH_TOP_SIDE_RIGHT 0x0000002000000000ULL +#define AV_CH_BOTTOM_FRONT_CENTER 0x0000004000000000ULL +#define AV_CH_BOTTOM_FRONT_LEFT 0x0000008000000000ULL +#define AV_CH_BOTTOM_FRONT_RIGHT 0x0000010000000000ULL /** Channel mask value used for AVCodecContext.request_channel_layout to indicate that the user requests the channel order of the decoder output @@ -110,6 +115,7 @@ #define AV_CH_LAYOUT_OCTAGONAL (AV_CH_LAYOUT_5POINT0|AV_CH_BACK_LEFT|AV_CH_BACK_CENTER|AV_CH_BACK_RIGHT) #define AV_CH_LAYOUT_HEXADECAGONAL (AV_CH_LAYOUT_OCTAGONAL|AV_CH_WIDE_LEFT|AV_CH_WIDE_RIGHT|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT) #define AV_CH_LAYOUT_STEREO_DOWNMIX (AV_CH_STEREO_LEFT|AV_CH_STEREO_RIGHT) +#define AV_CH_LAYOUT_22POINT2 (AV_CH_LAYOUT_5POINT1_BACK|AV_CH_FRONT_LEFT_OF_CENTER|AV_CH_FRONT_RIGHT_OF_CENTER|AV_CH_BACK_CENTER|AV_CH_LOW_FREQUENCY_2|AV_CH_SIDE_LEFT|AV_CH_SIDE_RIGHT|AV_CH_TOP_FRONT_LEFT|AV_CH_TOP_FRONT_RIGHT|AV_CH_TOP_FRONT_CENTER|AV_CH_TOP_CENTER|AV_CH_TOP_BACK_LEFT|AV_CH_TOP_BACK_RIGHT|AV_CH_TOP_SIDE_LEFT|AV_CH_TOP_SIDE_RIGHT|AV_CH_TOP_BACK_CENTER|AV_CH_BOTTOM_FRONT_CENTER|AV_CH_BOTTOM_FRONT_LEFT|AV_CH_BOTTOM_FRONT_RIGHT) enum AVMatrixEncoding { AV_MATRIX_ENCODING_NONE, diff --git a/winlibs/include/libavutil/common.h b/winlibs/include/libavutil/common.h index 8db02911..aee353d3 100644 --- a/winlibs/include/libavutil/common.h +++ b/winlibs/include/libavutil/common.h @@ -53,7 +53,7 @@ //rounded division & shift #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b)) /* assume b>0 */ -#define ROUNDED_DIV(a,b) (((a)>0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) +#define ROUNDED_DIV(a,b) (((a)>=0 ? (a) + ((b)>>1) : (a) - ((b)>>1))/(b)) /* Fast a/(1<=0 and b>=0 */ #define AV_CEIL_RSHIFT(a,b) (!av_builtin_constant_p(b) ? -((-(a)) >> (b)) \ : ((a) + (1<<(b)) - 1) >> (b)) @@ -80,6 +80,15 @@ */ #define FFNABS(a) ((a) <= 0 ? (a) : (-(a))) +/** + * Unsigned Absolute value. + * This takes the absolute value of a signed int and returns it as a unsigned. + * This also works with INT_MIN which would otherwise not be representable + * As with many macros, this evaluates its argument twice. + */ +#define FFABSU(a) ((a) <= 0 ? -(unsigned)(a) : (unsigned)(a)) +#define FFABS64U(a) ((a) <= 0 ? -(uint64_t)(a) : (uint64_t)(a)) + /** * Comparator. * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0 @@ -106,8 +115,72 @@ # include "intmath.h" #endif -/* Pull in unguarded fallback defines at the end of this file. */ -#include "common.h" +#ifndef av_ceil_log2 +# define av_ceil_log2 av_ceil_log2_c +#endif +#ifndef av_clip +# define av_clip av_clip_c +#endif +#ifndef av_clip64 +# define av_clip64 av_clip64_c +#endif +#ifndef av_clip_uint8 +# define av_clip_uint8 av_clip_uint8_c +#endif +#ifndef av_clip_int8 +# define av_clip_int8 av_clip_int8_c +#endif +#ifndef av_clip_uint16 +# define av_clip_uint16 av_clip_uint16_c +#endif +#ifndef av_clip_int16 +# define av_clip_int16 av_clip_int16_c +#endif +#ifndef av_clipl_int32 +# define av_clipl_int32 av_clipl_int32_c +#endif +#ifndef av_clip_intp2 +# define av_clip_intp2 av_clip_intp2_c +#endif +#ifndef av_clip_uintp2 +# define av_clip_uintp2 av_clip_uintp2_c +#endif +#ifndef av_mod_uintp2 +# define av_mod_uintp2 av_mod_uintp2_c +#endif +#ifndef av_sat_add32 +# define av_sat_add32 av_sat_add32_c +#endif +#ifndef av_sat_dadd32 +# define av_sat_dadd32 av_sat_dadd32_c +#endif +#ifndef av_sat_sub32 +# define av_sat_sub32 av_sat_sub32_c +#endif +#ifndef av_sat_dsub32 +# define av_sat_dsub32 av_sat_dsub32_c +#endif +#ifndef av_sat_add64 +# define av_sat_add64 av_sat_add64_c +#endif +#ifndef av_sat_sub64 +# define av_sat_sub64 av_sat_sub64_c +#endif +#ifndef av_clipf +# define av_clipf av_clipf_c +#endif +#ifndef av_clipd +# define av_clipd av_clipd_c +#endif +#ifndef av_popcount +# define av_popcount av_popcount_c +#endif +#ifndef av_popcount64 +# define av_popcount64 av_popcount64_c +#endif +#ifndef av_parity +# define av_parity av_parity_c +#endif #ifndef av_log2 av_const int av_log2(unsigned v); @@ -240,7 +313,7 @@ static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p) */ static av_always_inline av_const unsigned av_mod_uintp2_c(unsigned a, unsigned p) { - return a & ((1 << p) - 1); + return a & ((1U << p) - 1); } /** @@ -291,6 +364,45 @@ static av_always_inline int av_sat_dsub32_c(int a, int b) return av_sat_sub32(a, av_sat_add32(b, b)); } +/** + * Add two signed 64-bit values with saturation. + * + * @param a one value + * @param b another value + * @return sum with signed saturation + */ +static av_always_inline int64_t av_sat_add64_c(int64_t a, int64_t b) { +#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_add_overflow) + int64_t tmp; + return !__builtin_add_overflow(a, b, &tmp) ? tmp : (tmp < 0 ? INT64_MAX : INT64_MIN); +#else + int64_t s = a+(uint64_t)b; + if ((int64_t)(a^b | ~s^b) >= 0) + return INT64_MAX ^ (b >> 63); + return s; +#endif +} + +/** + * Subtract two signed 64-bit values with saturation. + * + * @param a one value + * @param b another value + * @return difference with signed saturation + */ +static av_always_inline int64_t av_sat_sub64_c(int64_t a, int64_t b) { +#if (!defined(__INTEL_COMPILER) && AV_GCC_VERSION_AT_LEAST(5,1)) || AV_HAS_BUILTIN(__builtin_sub_overflow) + int64_t tmp; + return !__builtin_sub_overflow(a, b, &tmp) ? tmp : (tmp < 0 ? INT64_MAX : INT64_MIN); +#else + if (b <= 0 && a >= INT64_MAX + b) + return INT64_MAX; + if (b >= 0 && a <= INT64_MIN + b) + return INT64_MIN; + return a - b; +#endif +} + /** * Clip a float value into the amin-amax range. * @param a value to clip @@ -331,7 +443,7 @@ static av_always_inline av_const double av_clipd_c(double a, double amin, double */ static av_always_inline av_const int av_ceil_log2_c(int x) { - return av_log2((x - 1) << 1); + return av_log2((x - 1U) << 1); } /** @@ -373,7 +485,9 @@ static av_always_inline av_const int av_parity_c(uint32_t v) * @param GET_BYTE Expression reading one byte from the input. * Evaluated up to 7 times (4 for the currently * assigned Unicode range). With a memory buffer - * input, this could be *ptr++. + * input, this could be *ptr++, or if you want to make sure + * that *ptr stops at the end of a NULL terminated string then + * *ptr ? *ptr++ : 0 * @param ERROR Expression to be evaluated on invalid input, * typically a goto statement. * @@ -387,11 +501,11 @@ static av_always_inline av_const int av_parity_c(uint32_t v) {\ uint32_t top = (val & 128) >> 1;\ if ((val & 0xc0) == 0x80 || val >= 0xFE)\ - ERROR\ + {ERROR}\ while (val & top) {\ - int tmp= (GET_BYTE) - 128;\ + unsigned int tmp = (GET_BYTE) - 128;\ if(tmp>>6)\ - ERROR\ + {ERROR}\ val= (val<<6) + tmp;\ top <<= 5;\ }\ @@ -408,13 +522,13 @@ static av_always_inline av_const int av_parity_c(uint32_t v) * typically a goto statement. */ #define GET_UTF16(val, GET_16BIT, ERROR)\ - val = GET_16BIT;\ + val = (GET_16BIT);\ {\ unsigned int hi = val - 0xD800;\ if (hi < 0x800) {\ - val = GET_16BIT - 0xDC00;\ + val = (GET_16BIT) - 0xDC00;\ if (val > 0x3FFU || hi > 0x3FFU)\ - ERROR\ + {ERROR}\ val += (hi<<10) + 0x10000;\ }\ }\ @@ -492,69 +606,3 @@ static av_always_inline av_const int av_parity_c(uint32_t v) #endif /* HAVE_AV_CONFIG_H */ #endif /* AVUTIL_COMMON_H */ - -/* - * The following definitions are outside the multiple inclusion guard - * to ensure they are immediately available in intmath.h. - */ - -#ifndef av_ceil_log2 -# define av_ceil_log2 av_ceil_log2_c -#endif -#ifndef av_clip -# define av_clip av_clip_c -#endif -#ifndef av_clip64 -# define av_clip64 av_clip64_c -#endif -#ifndef av_clip_uint8 -# define av_clip_uint8 av_clip_uint8_c -#endif -#ifndef av_clip_int8 -# define av_clip_int8 av_clip_int8_c -#endif -#ifndef av_clip_uint16 -# define av_clip_uint16 av_clip_uint16_c -#endif -#ifndef av_clip_int16 -# define av_clip_int16 av_clip_int16_c -#endif -#ifndef av_clipl_int32 -# define av_clipl_int32 av_clipl_int32_c -#endif -#ifndef av_clip_intp2 -# define av_clip_intp2 av_clip_intp2_c -#endif -#ifndef av_clip_uintp2 -# define av_clip_uintp2 av_clip_uintp2_c -#endif -#ifndef av_mod_uintp2 -# define av_mod_uintp2 av_mod_uintp2_c -#endif -#ifndef av_sat_add32 -# define av_sat_add32 av_sat_add32_c -#endif -#ifndef av_sat_dadd32 -# define av_sat_dadd32 av_sat_dadd32_c -#endif -#ifndef av_sat_sub32 -# define av_sat_sub32 av_sat_sub32_c -#endif -#ifndef av_sat_dsub32 -# define av_sat_dsub32 av_sat_dsub32_c -#endif -#ifndef av_clipf -# define av_clipf av_clipf_c -#endif -#ifndef av_clipd -# define av_clipd av_clipd_c -#endif -#ifndef av_popcount -# define av_popcount av_popcount_c -#endif -#ifndef av_popcount64 -# define av_popcount64 av_popcount64_c -#endif -#ifndef av_parity -# define av_parity av_parity_c -#endif diff --git a/winlibs/include/libavutil/cpu.h b/winlibs/include/libavutil/cpu.h index 8bb9eb60..83099dd9 100644 --- a/winlibs/include/libavutil/cpu.h +++ b/winlibs/include/libavutil/cpu.h @@ -71,6 +71,9 @@ #define AV_CPU_FLAG_VFP_VM (1 << 7) ///< VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations #define AV_CPU_FLAG_SETEND (1 <<16) +#define AV_CPU_FLAG_MMI (1 << 0) +#define AV_CPU_FLAG_MSA (1 << 1) + /** * Return the flags which specify extensions supported by the CPU. * The returned value is affected by av_force_cpu_flags() if that was used diff --git a/maclibs/include/libavutil/crc.h b/winlibs/include/libavutil/crc.h similarity index 100% rename from maclibs/include/libavutil/crc.h rename to winlibs/include/libavutil/crc.h diff --git a/winlibs/include/libavutil/des.h b/winlibs/include/libavutil/des.h new file mode 100644 index 00000000..4cf11f5b --- /dev/null +++ b/winlibs/include/libavutil/des.h @@ -0,0 +1,77 @@ +/* + * DES encryption/decryption + * Copyright (c) 2007 Reimar Doeffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_DES_H +#define AVUTIL_DES_H + +#include + +/** + * @defgroup lavu_des DES + * @ingroup lavu_crypto + * @{ + */ + +typedef struct AVDES { + uint64_t round_keys[3][16]; + int triple_des; +} AVDES; + +/** + * Allocate an AVDES context. + */ +AVDES *av_des_alloc(void); + +/** + * @brief Initializes an AVDES context. + * + * @param key_bits must be 64 or 192 + * @param decrypt 0 for encryption/CBC-MAC, 1 for decryption + * @return zero on success, negative value otherwise + */ +int av_des_init(struct AVDES *d, const uint8_t *key, int key_bits, int decrypt); + +/** + * @brief Encrypts / decrypts using the DES algorithm. + * + * @param count number of 8 byte blocks + * @param dst destination array, can be equal to src, must be 8-byte aligned + * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL + * @param iv initialization vector for CBC mode, if NULL then ECB will be used, + * must be 8-byte aligned + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_des_crypt(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); + +/** + * @brief Calculates CBC-MAC using the DES algorithm. + * + * @param count number of 8 byte blocks + * @param dst destination array, can be equal to src, must be 8-byte aligned + * @param src source array, can be equal to dst, must be 8-byte aligned, may be NULL + */ +void av_des_mac(struct AVDES *d, uint8_t *dst, const uint8_t *src, int count); + +/** + * @} + */ + +#endif /* AVUTIL_DES_H */ diff --git a/winlibs/include/libavutil/display.h b/winlibs/include/libavutil/display.h new file mode 100644 index 00000000..515adad7 --- /dev/null +++ b/winlibs/include/libavutil/display.h @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2014 Vittorio Giovara + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Display matrix + */ + +#ifndef AVUTIL_DISPLAY_H +#define AVUTIL_DISPLAY_H + +#include +#include "common.h" + +/** + * @addtogroup lavu_video + * @{ + * + * @defgroup lavu_video_display Display transformation matrix functions + * @{ + */ + +/** + * @addtogroup lavu_video_display + * The display transformation matrix specifies an affine transformation that + * should be applied to video frames for correct presentation. It is compatible + * with the matrices stored in the ISO/IEC 14496-12 container format. + * + * The data is a 3x3 matrix represented as a 9-element array: + * + * @code{.unparsed} + * | a b u | + * (a, b, u, c, d, v, x, y, w) -> | c d v | + * | x y w | + * @endcode + * + * All numbers are stored in native endianness, as 16.16 fixed-point values, + * except for u, v and w, which are stored as 2.30 fixed-point values. + * + * The transformation maps a point (p, q) in the source (pre-transformation) + * frame to the point (p', q') in the destination (post-transformation) frame as + * follows: + * + * @code{.unparsed} + * | a b u | + * (p, q, 1) . | c d v | = z * (p', q', 1) + * | x y w | + * @endcode + * + * The transformation can also be more explicitly written in components as + * follows: + * + * @code{.unparsed} + * p' = (a * p + c * q + x) / z; + * q' = (b * p + d * q + y) / z; + * z = u * p + v * q + w + * @endcode + */ + +/** + * Extract the rotation component of the transformation matrix. + * + * @param matrix the transformation matrix + * @return the angle (in degrees) by which the transformation rotates the frame + * counterclockwise. The angle will be in range [-180.0, 180.0], + * or NaN if the matrix is singular. + * + * @note floating point numbers are inherently inexact, so callers are + * recommended to round the return value to nearest integer before use. + */ +double av_display_rotation_get(const int32_t matrix[9]); + +/** + * Initialize a transformation matrix describing a pure counterclockwise + * rotation by the specified angle (in degrees). + * + * @param matrix an allocated transformation matrix (will be fully overwritten + * by this function) + * @param angle rotation angle in degrees. + */ +void av_display_rotation_set(int32_t matrix[9], double angle); + +/** + * Flip the input matrix horizontally and/or vertically. + * + * @param matrix an allocated transformation matrix + * @param hflip whether the matrix should be flipped horizontally + * @param vflip whether the matrix should be flipped vertically + */ +void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip); + +/** + * @} + * @} + */ + +#endif /* AVUTIL_DISPLAY_H */ diff --git a/winlibs/include/libavutil/dovi_meta.h b/winlibs/include/libavutil/dovi_meta.h new file mode 100644 index 00000000..299911d4 --- /dev/null +++ b/winlibs/include/libavutil/dovi_meta.h @@ -0,0 +1,70 @@ +/* + * Copyright (c) 2020 Vacing Fang + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * DOVI configuration + */ + + +#ifndef AVUTIL_DOVI_META_H +#define AVUTIL_DOVI_META_H + +#include +#include + +/* + * DOVI configuration + * ref: dolby-vision-bitstreams-within-the-iso-base-media-file-format-v2.1.2 + dolby-vision-bitstreams-in-mpeg-2-transport-stream-multiplex-v1.2 + * @code + * uint8_t dv_version_major, the major version number that the stream complies with + * uint8_t dv_version_minor, the minor version number that the stream complies with + * uint8_t dv_profile, the Dolby Vision profile + * uint8_t dv_level, the Dolby Vision level + * uint8_t rpu_present_flag + * uint8_t el_present_flag + * uint8_t bl_present_flag + * uint8_t dv_bl_signal_compatibility_id + * @endcode + * + * @note The struct must be allocated with av_dovi_alloc() and + * its size is not a part of the public ABI. + */ +typedef struct AVDOVIDecoderConfigurationRecord { + uint8_t dv_version_major; + uint8_t dv_version_minor; + uint8_t dv_profile; + uint8_t dv_level; + uint8_t rpu_present_flag; + uint8_t el_present_flag; + uint8_t bl_present_flag; + uint8_t dv_bl_signal_compatibility_id; +} AVDOVIDecoderConfigurationRecord; + +/** + * Allocate a AVDOVIDecoderConfigurationRecord structure and initialize its + * fields to default values. + * + * @return the newly allocated struct or NULL on failure + */ +AVDOVIDecoderConfigurationRecord *av_dovi_alloc(size_t *size); + +#endif /* AVUTIL_DOVI_META_H */ diff --git a/winlibs/include/libavutil/downmix_info.h b/winlibs/include/libavutil/downmix_info.h new file mode 100644 index 00000000..221cf5bf --- /dev/null +++ b/winlibs/include/libavutil/downmix_info.h @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2014 Tim Walker + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_DOWNMIX_INFO_H +#define AVUTIL_DOWNMIX_INFO_H + +#include "frame.h" + +/** + * @file + * audio downmix medatata + */ + +/** + * @addtogroup lavu_audio + * @{ + */ + +/** + * @defgroup downmix_info Audio downmix metadata + * @{ + */ + +/** + * Possible downmix types. + */ +enum AVDownmixType { + AV_DOWNMIX_TYPE_UNKNOWN, /**< Not indicated. */ + AV_DOWNMIX_TYPE_LORO, /**< Lo/Ro 2-channel downmix (Stereo). */ + AV_DOWNMIX_TYPE_LTRT, /**< Lt/Rt 2-channel downmix, Dolby Surround compatible. */ + AV_DOWNMIX_TYPE_DPLII, /**< Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible. */ + AV_DOWNMIX_TYPE_NB /**< Number of downmix types. Not part of ABI. */ +}; + +/** + * This structure describes optional metadata relevant to a downmix procedure. + * + * All fields are set by the decoder to the value indicated in the audio + * bitstream (if present), or to a "sane" default otherwise. + */ +typedef struct AVDownmixInfo { + /** + * Type of downmix preferred by the mastering engineer. + */ + enum AVDownmixType preferred_downmix_type; + + /** + * Absolute scale factor representing the nominal level of the center + * channel during a regular downmix. + */ + double center_mix_level; + + /** + * Absolute scale factor representing the nominal level of the center + * channel during an Lt/Rt compatible downmix. + */ + double center_mix_level_ltrt; + + /** + * Absolute scale factor representing the nominal level of the surround + * channels during a regular downmix. + */ + double surround_mix_level; + + /** + * Absolute scale factor representing the nominal level of the surround + * channels during an Lt/Rt compatible downmix. + */ + double surround_mix_level_ltrt; + + /** + * Absolute scale factor representing the level at which the LFE data is + * mixed into L/R channels during downmixing. + */ + double lfe_mix_level; +} AVDownmixInfo; + +/** + * Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing. + * + * If the side data is absent, it is created and added to the frame. + * + * @param frame the frame for which the side data is to be obtained or created + * + * @return the AVDownmixInfo structure to be edited by the caller, or NULL if + * the structure cannot be allocated. + */ +AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame); + +/** + * @} + */ + +/** + * @} + */ + +#endif /* AVUTIL_DOWNMIX_INFO_H */ diff --git a/winlibs/include/libavutil/encryption_info.h b/winlibs/include/libavutil/encryption_info.h new file mode 100644 index 00000000..8fe7ebfe --- /dev/null +++ b/winlibs/include/libavutil/encryption_info.h @@ -0,0 +1,205 @@ +/** + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_ENCRYPTION_INFO_H +#define AVUTIL_ENCRYPTION_INFO_H + +#include +#include + +typedef struct AVSubsampleEncryptionInfo { + /** The number of bytes that are clear. */ + unsigned int bytes_of_clear_data; + + /** + * The number of bytes that are protected. If using pattern encryption, + * the pattern applies to only the protected bytes; if not using pattern + * encryption, all these bytes are encrypted. + */ + unsigned int bytes_of_protected_data; +} AVSubsampleEncryptionInfo; + +/** + * This describes encryption info for a packet. This contains frame-specific + * info for how to decrypt the packet before passing it to the decoder. + * + * The size of this struct is not part of the public ABI. + */ +typedef struct AVEncryptionInfo { + /** The fourcc encryption scheme, in big-endian byte order. */ + uint32_t scheme; + + /** + * Only used for pattern encryption. This is the number of 16-byte blocks + * that are encrypted. + */ + uint32_t crypt_byte_block; + + /** + * Only used for pattern encryption. This is the number of 16-byte blocks + * that are clear. + */ + uint32_t skip_byte_block; + + /** + * The ID of the key used to encrypt the packet. This should always be + * 16 bytes long, but may be changed in the future. + */ + uint8_t *key_id; + uint32_t key_id_size; + + /** + * The initialization vector. This may have been zero-filled to be the + * correct block size. This should always be 16 bytes long, but may be + * changed in the future. + */ + uint8_t *iv; + uint32_t iv_size; + + /** + * An array of subsample encryption info specifying how parts of the sample + * are encrypted. If there are no subsamples, then the whole sample is + * encrypted. + */ + AVSubsampleEncryptionInfo *subsamples; + uint32_t subsample_count; +} AVEncryptionInfo; + +/** + * This describes info used to initialize an encryption key system. + * + * The size of this struct is not part of the public ABI. + */ +typedef struct AVEncryptionInitInfo { + /** + * A unique identifier for the key system this is for, can be NULL if it + * is not known. This should always be 16 bytes, but may change in the + * future. + */ + uint8_t* system_id; + uint32_t system_id_size; + + /** + * An array of key IDs this initialization data is for. All IDs are the + * same length. Can be NULL if there are no known key IDs. + */ + uint8_t** key_ids; + /** The number of key IDs. */ + uint32_t num_key_ids; + /** + * The number of bytes in each key ID. This should always be 16, but may + * change in the future. + */ + uint32_t key_id_size; + + /** + * Key-system specific initialization data. This data is copied directly + * from the file and the format depends on the specific key system. This + * can be NULL if there is no initialization data; in that case, there + * will be at least one key ID. + */ + uint8_t* data; + uint32_t data_size; + + /** + * An optional pointer to the next initialization info in the list. + */ + struct AVEncryptionInitInfo *next; +} AVEncryptionInitInfo; + +/** + * Allocates an AVEncryptionInfo structure and sub-pointers to hold the given + * number of subsamples. This will allocate pointers for the key ID, IV, + * and subsample entries, set the size members, and zero-initialize the rest. + * + * @param subsample_count The number of subsamples. + * @param key_id_size The number of bytes in the key ID, should be 16. + * @param iv_size The number of bytes in the IV, should be 16. + * + * @return The new AVEncryptionInfo structure, or NULL on error. + */ +AVEncryptionInfo *av_encryption_info_alloc(uint32_t subsample_count, uint32_t key_id_size, uint32_t iv_size); + +/** + * Allocates an AVEncryptionInfo structure with a copy of the given data. + * @return The new AVEncryptionInfo structure, or NULL on error. + */ +AVEncryptionInfo *av_encryption_info_clone(const AVEncryptionInfo *info); + +/** + * Frees the given encryption info object. This MUST NOT be used to free the + * side-data data pointer, that should use normal side-data methods. + */ +void av_encryption_info_free(AVEncryptionInfo *info); + +/** + * Creates a copy of the AVEncryptionInfo that is contained in the given side + * data. The resulting object should be passed to av_encryption_info_free() + * when done. + * + * @return The new AVEncryptionInfo structure, or NULL on error. + */ +AVEncryptionInfo *av_encryption_info_get_side_data(const uint8_t *side_data, size_t side_data_size); + +/** + * Allocates and initializes side data that holds a copy of the given encryption + * info. The resulting pointer should be either freed using av_free or given + * to av_packet_add_side_data(). + * + * @return The new side-data pointer, or NULL. + */ +uint8_t *av_encryption_info_add_side_data( + const AVEncryptionInfo *info, size_t *side_data_size); + + +/** + * Allocates an AVEncryptionInitInfo structure and sub-pointers to hold the + * given sizes. This will allocate pointers and set all the fields. + * + * @return The new AVEncryptionInitInfo structure, or NULL on error. + */ +AVEncryptionInitInfo *av_encryption_init_info_alloc( + uint32_t system_id_size, uint32_t num_key_ids, uint32_t key_id_size, uint32_t data_size); + +/** + * Frees the given encryption init info object. This MUST NOT be used to free + * the side-data data pointer, that should use normal side-data methods. + */ +void av_encryption_init_info_free(AVEncryptionInitInfo* info); + +/** + * Creates a copy of the AVEncryptionInitInfo that is contained in the given + * side data. The resulting object should be passed to + * av_encryption_init_info_free() when done. + * + * @return The new AVEncryptionInitInfo structure, or NULL on error. + */ +AVEncryptionInitInfo *av_encryption_init_info_get_side_data( + const uint8_t* side_data, size_t side_data_size); + +/** + * Allocates and initializes side data that holds a copy of the given encryption + * init info. The resulting pointer should be either freed using av_free or + * given to av_packet_add_side_data(). + * + * @return The new side-data pointer, or NULL. + */ +uint8_t *av_encryption_init_info_add_side_data( + const AVEncryptionInitInfo *info, size_t *side_data_size); + +#endif /* AVUTIL_ENCRYPTION_INFO_H */ diff --git a/maclibs/include/libavutil/eval.h b/winlibs/include/libavutil/eval.h similarity index 83% rename from maclibs/include/libavutil/eval.h rename to winlibs/include/libavutil/eval.h index dacd22b9..068c62cd 100644 --- a/maclibs/include/libavutil/eval.h +++ b/winlibs/include/libavutil/eval.h @@ -86,6 +86,30 @@ int av_expr_parse(AVExpr **expr, const char *s, */ double av_expr_eval(AVExpr *e, const double *const_values, void *opaque); +/** + * Track the presence of variables and their number of occurrences in a parsed expression + * + * @param counter a zero-initialized array where the count of each variable will be stored + * @param size size of array + * @return 0 on success, a negative value indicates that no expression or array was passed + * or size was zero + */ +int av_expr_count_vars(AVExpr *e, unsigned *counter, int size); + +/** + * Track the presence of user provided functions and their number of occurrences + * in a parsed expression. + * + * @param counter a zero-initialized array where the count of each function will be stored + * if you passed 5 functions with 2 arguments to av_expr_parse() + * then for arg=2 this will use upto 5 entries. + * @param size size of array + * @param arg number of arguments the counted functions have + * @return 0 on success, a negative value indicates that no expression or array was passed + * or size was zero + */ +int av_expr_count_func(AVExpr *e, unsigned *counter, int size, int arg); + /** * Free a parsed expression previously created with av_expr_parse(). */ diff --git a/winlibs/include/libavutil/ffversion.h b/winlibs/include/libavutil/ffversion.h index 46908846..8c0f7ccd 100644 --- a/winlibs/include/libavutil/ffversion.h +++ b/winlibs/include/libavutil/ffversion.h @@ -1,5 +1,5 @@ /* Automatically generated by version.sh, do not manually edit! */ #ifndef AVUTIL_FFVERSION_H #define AVUTIL_FFVERSION_H -#define FFMPEG_VERSION "4.2.1" +#define FFMPEG_VERSION "4.4.1" #endif /* AVUTIL_FFVERSION_H */ diff --git a/maclibs/include/libavutil/fifo.h b/winlibs/include/libavutil/fifo.h similarity index 100% rename from maclibs/include/libavutil/fifo.h rename to winlibs/include/libavutil/fifo.h diff --git a/maclibs/include/libavutil/file.h b/winlibs/include/libavutil/file.h similarity index 100% rename from maclibs/include/libavutil/file.h rename to winlibs/include/libavutil/file.h diff --git a/winlibs/include/libavutil/film_grain_params.h b/winlibs/include/libavutil/film_grain_params.h new file mode 100644 index 00000000..7629e3a0 --- /dev/null +++ b/winlibs/include/libavutil/film_grain_params.h @@ -0,0 +1,168 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_FILM_GRAIN_PARAMS_H +#define AVUTIL_FILM_GRAIN_PARAMS_H + +#include "frame.h" + +enum AVFilmGrainParamsType { + AV_FILM_GRAIN_PARAMS_NONE = 0, + + /** + * The union is valid when interpreted as AVFilmGrainAOMParams (codec.aom) + */ + AV_FILM_GRAIN_PARAMS_AV1, +}; + +/** + * This structure describes how to handle film grain synthesis for AOM codecs. + * + * @note The struct must be allocated as part of AVFilmGrainParams using + * av_film_grain_params_alloc(). Its size is not a part of the public ABI. + */ +typedef struct AVFilmGrainAOMParams { + /** + * Number of points, and the scale and value for each point of the + * piecewise linear scaling function for the uma plane. + */ + int num_y_points; + uint8_t y_points[14][2 /* value, scaling */]; + + /** + * Signals whether to derive the chroma scaling function from the luma. + * Not equivalent to copying the luma values and scales. + */ + int chroma_scaling_from_luma; + + /** + * If chroma_scaling_from_luma is set to 0, signals the chroma scaling + * function parameters. + */ + int num_uv_points[2 /* cb, cr */]; + uint8_t uv_points[2 /* cb, cr */][10][2 /* value, scaling */]; + + /** + * Specifies the shift applied to the chroma components. For AV1, its within + * [8; 11] and determines the range and quantization of the film grain. + */ + int scaling_shift; + + /** + * Specifies the auto-regression lag. + */ + int ar_coeff_lag; + + /** + * Luma auto-regression coefficients. The number of coefficients is given by + * 2 * ar_coeff_lag * (ar_coeff_lag + 1). + */ + int8_t ar_coeffs_y[24]; + + /** + * Chroma auto-regression coefficients. The number of coefficients is given by + * 2 * ar_coeff_lag * (ar_coeff_lag + 1) + !!num_y_points. + */ + int8_t ar_coeffs_uv[2 /* cb, cr */][25]; + + /** + * Specifies the range of the auto-regressive coefficients. Values of 6, + * 7, 8 and so on represent a range of [-2, 2), [-1, 1), [-0.5, 0.5) and + * so on. For AV1 must be between 6 and 9. + */ + int ar_coeff_shift; + + /** + * Signals the down shift applied to the generated gaussian numbers during + * synthesis. + */ + int grain_scale_shift; + + /** + * Specifies the luma/chroma multipliers for the index to the component + * scaling function. + */ + int uv_mult[2 /* cb, cr */]; + int uv_mult_luma[2 /* cb, cr */]; + + /** + * Offset used for component scaling function. For AV1 its a 9-bit value + * with a range [-256, 255] + */ + int uv_offset[2 /* cb, cr */]; + + /** + * Signals whether to overlap film grain blocks. + */ + int overlap_flag; + + /** + * Signals to clip to limited color levels after film grain application. + */ + int limit_output_range; +} AVFilmGrainAOMParams; + +/** + * This structure describes how to handle film grain synthesis in video + * for specific codecs. Must be present on every frame where film grain is + * meant to be synthesised for correct presentation. + * + * @note The struct must be allocated with av_film_grain_params_alloc() and + * its size is not a part of the public ABI. + */ +typedef struct AVFilmGrainParams { + /** + * Specifies the codec for which this structure is valid. + */ + enum AVFilmGrainParamsType type; + + /** + * Seed to use for the synthesis process, if the codec allows for it. + */ + uint64_t seed; + + /** + * Additional fields may be added both here and in any structure included. + * If a codec's film grain structure differs slightly over another + * codec's, fields within may change meaning depending on the type. + */ + union { + AVFilmGrainAOMParams aom; + } codec; +} AVFilmGrainParams; + +/** + * Allocate an AVFilmGrainParams structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * If size is not NULL it will be set to the number of bytes allocated. + * + * @return An AVFilmGrainParams filled with default values or NULL + * on failure. + */ +AVFilmGrainParams *av_film_grain_params_alloc(size_t *size); + +/** + * Allocate a complete AVFilmGrainParams and add it to the frame. + * + * @param frame The frame which side data is added to. + * + * @return The AVFilmGrainParams structure to be filled by caller. + */ +AVFilmGrainParams *av_film_grain_params_create_side_data(AVFrame *frame); + +#endif /* AVUTIL_FILM_GRAIN_PARAMS_H */ diff --git a/winlibs/include/libavutil/frame.h b/winlibs/include/libavutil/frame.h index 5d3231e7..7d1f8e29 100644 --- a/winlibs/include/libavutil/frame.h +++ b/winlibs/include/libavutil/frame.h @@ -162,8 +162,8 @@ enum AVFrameSideDataType { /** * Timecode which conforms to SMPTE ST 12-1. The data is an array of 4 uint32_t * where the first uint32_t describes how many (1-3) of the other timecodes are used. - * The timecode format is described in the av_timecode_get_smpte_from_framenum() - * function in libavutil/timecode.c. + * The timecode format is described in the documentation of av_timecode_get_smpte_from_framenum() + * function in libavutil/timecode.h. */ AV_FRAME_DATA_S12M_TIMECODE, @@ -179,6 +179,25 @@ enum AVFrameSideDataType { * array element is implied by AVFrameSideData.size / AVRegionOfInterest.self_size. */ AV_FRAME_DATA_REGIONS_OF_INTEREST, + + /** + * Encoding parameters for a video frame, as described by AVVideoEncParams. + */ + AV_FRAME_DATA_VIDEO_ENC_PARAMS, + + /** + * User data unregistered metadata associated with a video frame. + * This is the H.26[45] UDU SEI message, and shouldn't be used for any other purpose + * The data is stored as uint8_t in AVFrameSideData.data which is 16 bytes of + * uuid_iso_iec_11578 followed by AVFrameSideData.size - 16 bytes of user_data_payload_byte. + */ + AV_FRAME_DATA_SEI_UNREGISTERED, + + /** + * Film grain parameters for a frame, described by AVFilmGrainParams. + * Must be present for every frame which should have film grain applied. + */ + AV_FRAME_DATA_FILM_GRAIN_PARAMS, }; enum AVActiveFormatDescription { @@ -201,7 +220,11 @@ enum AVActiveFormatDescription { typedef struct AVFrameSideData { enum AVFrameSideDataType type; uint8_t *data; +#if FF_API_BUFFER_SIZE_T int size; +#else + size_t size; +#endif AVDictionary *metadata; AVBufferRef *buf; } AVFrameSideData; @@ -894,7 +917,11 @@ AVBufferRef *av_frame_get_plane_buffer(AVFrame *frame, int plane); */ AVFrameSideData *av_frame_new_side_data(AVFrame *frame, enum AVFrameSideDataType type, +#if FF_API_BUFFER_SIZE_T int size); +#else + size_t size); +#endif /** * Add a new side data to a frame from an existing AVBufferRef @@ -920,8 +947,7 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type); /** - * If side data of the supplied type exists in the frame, free it and remove it - * from the frame. + * Remove and free all side data instances of the given type. */ void av_frame_remove_side_data(AVFrame *frame, enum AVFrameSideDataType type); diff --git a/winlibs/include/libavutil/hash.h b/winlibs/include/libavutil/hash.h new file mode 100644 index 00000000..af4719e4 --- /dev/null +++ b/winlibs/include/libavutil/hash.h @@ -0,0 +1,270 @@ +/* + * Copyright (C) 2013 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @ingroup lavu_hash_generic + * Generic hashing API + */ + +#ifndef AVUTIL_HASH_H +#define AVUTIL_HASH_H + +#include +#include + +#include "version.h" + +/** + * @defgroup lavu_hash Hash Functions + * @ingroup lavu_crypto + * Hash functions useful in multimedia. + * + * Hash functions are widely used in multimedia, from error checking and + * concealment to internal regression testing. libavutil has efficient + * implementations of a variety of hash functions that may be useful for + * FFmpeg and other multimedia applications. + * + * @{ + * + * @defgroup lavu_hash_generic Generic Hashing API + * An abstraction layer for all hash functions supported by libavutil. + * + * If your application needs to support a wide range of different hash + * functions, then the Generic Hashing API is for you. It provides a generic, + * reusable API for @ref lavu_hash "all hash functions" implemented in libavutil. + * If you just need to use one particular hash function, use the @ref lavu_hash + * "individual hash" directly. + * + * @section Sample Code + * + * A basic template for using the Generic Hashing API follows: + * + * @code + * struct AVHashContext *ctx = NULL; + * const char *hash_name = NULL; + * uint8_t *output_buf = NULL; + * + * // Select from a string returned by av_hash_names() + * hash_name = ...; + * + * // Allocate a hash context + * ret = av_hash_alloc(&ctx, hash_name); + * if (ret < 0) + * return ret; + * + * // Initialize the hash context + * av_hash_init(ctx); + * + * // Update the hash context with data + * while (data_left) { + * av_hash_update(ctx, data, size); + * } + * + * // Now we have no more data, so it is time to finalize the hash and get the + * // output. But we need to first allocate an output buffer. Note that you can + * // use any memory allocation function, including malloc(), not just + * // av_malloc(). + * output_buf = av_malloc(av_hash_get_size(ctx)); + * if (!output_buf) + * return AVERROR(ENOMEM); + * + * // Finalize the hash context. + * // You can use any of the av_hash_final*() functions provided, for other + * // output formats. If you do so, be sure to adjust the memory allocation + * // above. See the function documentation below for the exact amount of extra + * // memory needed. + * av_hash_final(ctx, output_buffer); + * + * // Free the context + * av_hash_freep(&ctx); + * @endcode + * + * @section Hash Function-Specific Information + * If the CRC32 hash is selected, the #AV_CRC_32_IEEE polynomial will be + * used. + * + * If the Murmur3 hash is selected, the default seed will be used. See @ref + * lavu_murmur3_seedinfo "Murmur3" for more information. + * + * @{ + */ + +/** + * @example ffhash.c + * This example is a simple command line application that takes one or more + * arguments. It demonstrates a typical use of the hashing API with allocation, + * initialization, updating, and finalizing. + */ + +struct AVHashContext; + +/** + * Allocate a hash context for the algorithm specified by name. + * + * @return >= 0 for success, a negative error code for failure + * + * @note The context is not initialized after a call to this function; you must + * call av_hash_init() to do so. + */ +int av_hash_alloc(struct AVHashContext **ctx, const char *name); + +/** + * Get the names of available hash algorithms. + * + * This function can be used to enumerate the algorithms. + * + * @param[in] i Index of the hash algorithm, starting from 0 + * @return Pointer to a static string or `NULL` if `i` is out of range + */ +const char *av_hash_names(int i); + +/** + * Get the name of the algorithm corresponding to the given hash context. + */ +const char *av_hash_get_name(const struct AVHashContext *ctx); + +/** + * Maximum value that av_hash_get_size() will currently return. + * + * You can use this if you absolutely want or need to use static allocation for + * the output buffer and are fine with not supporting hashes newly added to + * libavutil without recompilation. + * + * @warning + * Adding new hashes with larger sizes, and increasing the macro while doing + * so, will not be considered an ABI change. To prevent your code from + * overflowing a buffer, either dynamically allocate the output buffer with + * av_hash_get_size(), or limit your use of the Hashing API to hashes that are + * already in FFmpeg during the time of compilation. + */ +#define AV_HASH_MAX_SIZE 64 + +/** + * Get the size of the resulting hash value in bytes. + * + * The maximum value this function will currently return is available as macro + * #AV_HASH_MAX_SIZE. + * + * @param[in] ctx Hash context + * @return Size of the hash value in bytes + */ +int av_hash_get_size(const struct AVHashContext *ctx); + +/** + * Initialize or reset a hash context. + * + * @param[in,out] ctx Hash context + */ +void av_hash_init(struct AVHashContext *ctx); + +/** + * Update a hash context with additional data. + * + * @param[in,out] ctx Hash context + * @param[in] src Data to be added to the hash context + * @param[in] len Size of the additional data + */ +#if FF_API_CRYPTO_SIZE_T +void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, int len); +#else +void av_hash_update(struct AVHashContext *ctx, const uint8_t *src, size_t len); +#endif + +/** + * Finalize a hash context and compute the actual hash value. + * + * The minimum size of `dst` buffer is given by av_hash_get_size() or + * #AV_HASH_MAX_SIZE. The use of the latter macro is discouraged. + * + * It is not safe to update or finalize a hash context again, if it has already + * been finalized. + * + * @param[in,out] ctx Hash context + * @param[out] dst Where the final hash value will be stored + * + * @see av_hash_final_bin() provides an alternative API + */ +void av_hash_final(struct AVHashContext *ctx, uint8_t *dst); + +/** + * Finalize a hash context and store the actual hash value in a buffer. + * + * It is not safe to update or finalize a hash context again, if it has already + * been finalized. + * + * If `size` is smaller than the hash size (given by av_hash_get_size()), the + * hash is truncated; if size is larger, the buffer is padded with 0. + * + * @param[in,out] ctx Hash context + * @param[out] dst Where the final hash value will be stored + * @param[in] size Number of bytes to write to `dst` + */ +void av_hash_final_bin(struct AVHashContext *ctx, uint8_t *dst, int size); + +/** + * Finalize a hash context and store the hexadecimal representation of the + * actual hash value as a string. + * + * It is not safe to update or finalize a hash context again, if it has already + * been finalized. + * + * The string is always 0-terminated. + * + * If `size` is smaller than `2 * hash_size + 1`, where `hash_size` is the + * value returned by av_hash_get_size(), the string will be truncated. + * + * @param[in,out] ctx Hash context + * @param[out] dst Where the string will be stored + * @param[in] size Maximum number of bytes to write to `dst` + */ +void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size); + +/** + * Finalize a hash context and store the Base64 representation of the + * actual hash value as a string. + * + * It is not safe to update or finalize a hash context again, if it has already + * been finalized. + * + * The string is always 0-terminated. + * + * If `size` is smaller than AV_BASE64_SIZE(hash_size), where `hash_size` is + * the value returned by av_hash_get_size(), the string will be truncated. + * + * @param[in,out] ctx Hash context + * @param[out] dst Where the final hash value will be stored + * @param[in] size Maximum number of bytes to write to `dst` + */ +void av_hash_final_b64(struct AVHashContext *ctx, uint8_t *dst, int size); + +/** + * Free hash context and set hash context pointer to `NULL`. + * + * @param[in,out] ctx Pointer to hash context + */ +void av_hash_freep(struct AVHashContext **ctx); + +/** + * @} + * @} + */ + +#endif /* AVUTIL_HASH_H */ diff --git a/winlibs/include/libavutil/hdr_dynamic_metadata.h b/winlibs/include/libavutil/hdr_dynamic_metadata.h new file mode 100644 index 00000000..2d72de56 --- /dev/null +++ b/winlibs/include/libavutil/hdr_dynamic_metadata.h @@ -0,0 +1,343 @@ +/* + * Copyright (c) 2018 Mohammad Izadi + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HDR_DYNAMIC_METADATA_H +#define AVUTIL_HDR_DYNAMIC_METADATA_H + +#include "frame.h" +#include "rational.h" + +/** + * Option for overlapping elliptical pixel selectors in an image. + */ +enum AVHDRPlusOverlapProcessOption { + AV_HDR_PLUS_OVERLAP_PROCESS_WEIGHTED_AVERAGING = 0, + AV_HDR_PLUS_OVERLAP_PROCESS_LAYERING = 1, +}; + +/** + * Represents the percentile at a specific percentage in + * a distribution. + */ +typedef struct AVHDRPlusPercentile { + /** + * The percentage value corresponding to a specific percentile linearized + * RGB value in the processing window in the scene. The value shall be in + * the range of 0 to100, inclusive. + */ + uint8_t percentage; + + /** + * The linearized maxRGB value at a specific percentile in the processing + * window in the scene. The value shall be in the range of 0 to 1, inclusive + * and in multiples of 0.00001. + */ + AVRational percentile; +} AVHDRPlusPercentile; + +/** + * Color transform parameters at a processing window in a dynamic metadata for + * SMPTE 2094-40. + */ +typedef struct AVHDRPlusColorTransformParams { + /** + * The relative x coordinate of the top left pixel of the processing + * window. The value shall be in the range of 0 and 1, inclusive and + * in multiples of 1/(width of Picture - 1). The value 1 corresponds + * to the absolute coordinate of width of Picture - 1. The value for + * first processing window shall be 0. + */ + AVRational window_upper_left_corner_x; + + /** + * The relative y coordinate of the top left pixel of the processing + * window. The value shall be in the range of 0 and 1, inclusive and + * in multiples of 1/(height of Picture - 1). The value 1 corresponds + * to the absolute coordinate of height of Picture - 1. The value for + * first processing window shall be 0. + */ + AVRational window_upper_left_corner_y; + + /** + * The relative x coordinate of the bottom right pixel of the processing + * window. The value shall be in the range of 0 and 1, inclusive and + * in multiples of 1/(width of Picture - 1). The value 1 corresponds + * to the absolute coordinate of width of Picture - 1. The value for + * first processing window shall be 1. + */ + AVRational window_lower_right_corner_x; + + /** + * The relative y coordinate of the bottom right pixel of the processing + * window. The value shall be in the range of 0 and 1, inclusive and + * in multiples of 1/(height of Picture - 1). The value 1 corresponds + * to the absolute coordinate of height of Picture - 1. The value for + * first processing window shall be 1. + */ + AVRational window_lower_right_corner_y; + + /** + * The x coordinate of the center position of the concentric internal and + * external ellipses of the elliptical pixel selector in the processing + * window. The value shall be in the range of 0 to (width of Picture - 1), + * inclusive and in multiples of 1 pixel. + */ + uint16_t center_of_ellipse_x; + + /** + * The y coordinate of the center position of the concentric internal and + * external ellipses of the elliptical pixel selector in the processing + * window. The value shall be in the range of 0 to (height of Picture - 1), + * inclusive and in multiples of 1 pixel. + */ + uint16_t center_of_ellipse_y; + + /** + * The clockwise rotation angle in degree of arc with respect to the + * positive direction of the x-axis of the concentric internal and external + * ellipses of the elliptical pixel selector in the processing window. The + * value shall be in the range of 0 to 180, inclusive and in multiples of 1. + */ + uint8_t rotation_angle; + + /** + * The semi-major axis value of the internal ellipse of the elliptical pixel + * selector in amount of pixels in the processing window. The value shall be + * in the range of 1 to 65535, inclusive and in multiples of 1 pixel. + */ + uint16_t semimajor_axis_internal_ellipse; + + /** + * The semi-major axis value of the external ellipse of the elliptical pixel + * selector in amount of pixels in the processing window. The value + * shall not be less than semimajor_axis_internal_ellipse of the current + * processing window. The value shall be in the range of 1 to 65535, + * inclusive and in multiples of 1 pixel. + */ + uint16_t semimajor_axis_external_ellipse; + + /** + * The semi-minor axis value of the external ellipse of the elliptical pixel + * selector in amount of pixels in the processing window. The value shall be + * in the range of 1 to 65535, inclusive and in multiples of 1 pixel. + */ + uint16_t semiminor_axis_external_ellipse; + + /** + * Overlap process option indicates one of the two methods of combining + * rendered pixels in the processing window in an image with at least one + * elliptical pixel selector. For overlapping elliptical pixel selectors + * in an image, overlap_process_option shall have the same value. + */ + enum AVHDRPlusOverlapProcessOption overlap_process_option; + + /** + * The maximum of the color components of linearized RGB values in the + * processing window in the scene. The values should be in the range of 0 to + * 1, inclusive and in multiples of 0.00001. maxscl[ 0 ], maxscl[ 1 ], and + * maxscl[ 2 ] are corresponding to R, G, B color components respectively. + */ + AVRational maxscl[3]; + + /** + * The average of linearized maxRGB values in the processing window in the + * scene. The value should be in the range of 0 to 1, inclusive and in + * multiples of 0.00001. + */ + AVRational average_maxrgb; + + /** + * The number of linearized maxRGB values at given percentiles in the + * processing window in the scene. The maximum value shall be 15. + */ + uint8_t num_distribution_maxrgb_percentiles; + + /** + * The linearized maxRGB values at given percentiles in the + * processing window in the scene. + */ + AVHDRPlusPercentile distribution_maxrgb[15]; + + /** + * The fraction of selected pixels in the image that contains the brightest + * pixel in the scene. The value shall be in the range of 0 to 1, inclusive + * and in multiples of 0.001. + */ + AVRational fraction_bright_pixels; + + /** + * This flag indicates that the metadata for the tone mapping function in + * the processing window is present (for value of 1). + */ + uint8_t tone_mapping_flag; + + /** + * The x coordinate of the separation point between the linear part and the + * curved part of the tone mapping function. The value shall be in the range + * of 0 to 1, excluding 0 and in multiples of 1/4095. + */ + AVRational knee_point_x; + + /** + * The y coordinate of the separation point between the linear part and the + * curved part of the tone mapping function. The value shall be in the range + * of 0 to 1, excluding 0 and in multiples of 1/4095. + */ + AVRational knee_point_y; + + /** + * The number of the intermediate anchor parameters of the tone mapping + * function in the processing window. The maximum value shall be 15. + */ + uint8_t num_bezier_curve_anchors; + + /** + * The intermediate anchor parameters of the tone mapping function in the + * processing window in the scene. The values should be in the range of 0 + * to 1, inclusive and in multiples of 1/1023. + */ + AVRational bezier_curve_anchors[15]; + + /** + * This flag shall be equal to 0 in bitstreams conforming to this version of + * this Specification. Other values are reserved for future use. + */ + uint8_t color_saturation_mapping_flag; + + /** + * The color saturation gain in the processing window in the scene. The + * value shall be in the range of 0 to 63/8, inclusive and in multiples of + * 1/8. The default value shall be 1. + */ + AVRational color_saturation_weight; +} AVHDRPlusColorTransformParams; + +/** + * This struct represents dynamic metadata for color volume transform - + * application 4 of SMPTE 2094-40:2016 standard. + * + * To be used as payload of a AVFrameSideData or AVPacketSideData with the + * appropriate type. + * + * @note The struct should be allocated with + * av_dynamic_hdr_plus_alloc() and its size is not a part of + * the public ABI. + */ +typedef struct AVDynamicHDRPlus { + /** + * Country code by Rec. ITU-T T.35 Annex A. The value shall be 0xB5. + */ + uint8_t itu_t_t35_country_code; + + /** + * Application version in the application defining document in ST-2094 + * suite. The value shall be set to 0. + */ + uint8_t application_version; + + /** + * The number of processing windows. The value shall be in the range + * of 1 to 3, inclusive. + */ + uint8_t num_windows; + + /** + * The color transform parameters for every processing window. + */ + AVHDRPlusColorTransformParams params[3]; + + /** + * The nominal maximum display luminance of the targeted system display, + * in units of 0.0001 candelas per square metre. The value shall be in + * the range of 0 to 10000, inclusive. + */ + AVRational targeted_system_display_maximum_luminance; + + /** + * This flag shall be equal to 0 in bit streams conforming to this version + * of this Specification. The value 1 is reserved for future use. + */ + uint8_t targeted_system_display_actual_peak_luminance_flag; + + /** + * The number of rows in the targeted system_display_actual_peak_luminance + * array. The value shall be in the range of 2 to 25, inclusive. + */ + uint8_t num_rows_targeted_system_display_actual_peak_luminance; + + /** + * The number of columns in the + * targeted_system_display_actual_peak_luminance array. The value shall be + * in the range of 2 to 25, inclusive. + */ + uint8_t num_cols_targeted_system_display_actual_peak_luminance; + + /** + * The normalized actual peak luminance of the targeted system display. The + * values should be in the range of 0 to 1, inclusive and in multiples of + * 1/15. + */ + AVRational targeted_system_display_actual_peak_luminance[25][25]; + + /** + * This flag shall be equal to 0 in bitstreams conforming to this version of + * this Specification. The value 1 is reserved for future use. + */ + uint8_t mastering_display_actual_peak_luminance_flag; + + /** + * The number of rows in the mastering_display_actual_peak_luminance array. + * The value shall be in the range of 2 to 25, inclusive. + */ + uint8_t num_rows_mastering_display_actual_peak_luminance; + + /** + * The number of columns in the mastering_display_actual_peak_luminance + * array. The value shall be in the range of 2 to 25, inclusive. + */ + uint8_t num_cols_mastering_display_actual_peak_luminance; + + /** + * The normalized actual peak luminance of the mastering display used for + * mastering the image essence. The values should be in the range of 0 to 1, + * inclusive and in multiples of 1/15. + */ + AVRational mastering_display_actual_peak_luminance[25][25]; +} AVDynamicHDRPlus; + +/** + * Allocate an AVDynamicHDRPlus structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVDynamicHDRPlus filled with default values or NULL + * on failure. + */ +AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size); + +/** + * Allocate a complete AVDynamicHDRPlus and add it to the frame. + * @param frame The frame which side data is added to. + * + * @return The AVDynamicHDRPlus structure to be filled by caller or NULL + * on failure. + */ +AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame); + +#endif /* AVUTIL_HDR_DYNAMIC_METADATA_H */ diff --git a/maclibs/include/libavutil/hmac.h b/winlibs/include/libavutil/hmac.h similarity index 100% rename from maclibs/include/libavutil/hmac.h rename to winlibs/include/libavutil/hmac.h diff --git a/winlibs/include/libavutil/hwcontext.h b/winlibs/include/libavutil/hwcontext.h index f5a4b623..04d19d89 100644 --- a/winlibs/include/libavutil/hwcontext.h +++ b/winlibs/include/libavutil/hwcontext.h @@ -36,6 +36,7 @@ enum AVHWDeviceType { AV_HWDEVICE_TYPE_DRM, AV_HWDEVICE_TYPE_OPENCL, AV_HWDEVICE_TYPE_MEDIACODEC, + AV_HWDEVICE_TYPE_VULKAN, }; typedef struct AVHWDeviceInternal AVHWDeviceInternal; @@ -327,6 +328,26 @@ int av_hwdevice_ctx_create_derived(AVBufferRef **dst_ctx, enum AVHWDeviceType type, AVBufferRef *src_ctx, int flags); +/** + * Create a new device of the specified type from an existing device. + * + * This function performs the same action as av_hwdevice_ctx_create_derived, + * however, it is able to set options for the new device to be derived. + * + * @param dst_ctx On success, a reference to the newly-created + * AVHWDeviceContext. + * @param type The type of the new device to create. + * @param src_ctx A reference to an existing AVHWDeviceContext which will be + * used to create the new device. + * @param options Options for the new device to create, same format as in + * av_hwdevice_ctx_create. + * @param flags Currently unused; should be set to zero. + * @return Zero on success, a negative AVERROR code on failure. + */ +int av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ctx, + enum AVHWDeviceType type, + AVBufferRef *src_ctx, + AVDictionary *options, int flags); /** * Allocate an AVHWFramesContext tied to a given device context. diff --git a/winlibs/include/libavutil/hwcontext_cuda.h b/winlibs/include/libavutil/hwcontext_cuda.h new file mode 100644 index 00000000..cefbe0ce --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_cuda.h @@ -0,0 +1,69 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef AVUTIL_HWCONTEXT_CUDA_H +#define AVUTIL_HWCONTEXT_CUDA_H + +#ifndef CUDA_VERSION +#include +#endif + +#include "pixfmt.h" + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_CUDA. + * + * This API supports dynamic frame pools. AVHWFramesContext.pool must return + * AVBufferRefs whose data pointer is a CUdeviceptr. + */ + +typedef struct AVCUDADeviceContextInternal AVCUDADeviceContextInternal; + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVCUDADeviceContext { + CUcontext cuda_ctx; + CUstream stream; + AVCUDADeviceContextInternal *internal; +} AVCUDADeviceContext; + +/** + * AVHWFramesContext.hwctx is currently not used + */ + +/** + * @defgroup hwcontext_cuda Device context creation flags + * + * Flags for av_hwdevice_ctx_create. + * + * @{ + */ + +/** + * Use primary device context instead of creating a new one. + */ +#define AV_CUDA_USE_PRIMARY_CONTEXT (1 << 0) + +/** + * @} + */ + +#endif /* AVUTIL_HWCONTEXT_CUDA_H */ diff --git a/winlibs/include/libavutil/hwcontext_d3d11va.h b/winlibs/include/libavutil/hwcontext_d3d11va.h new file mode 100644 index 00000000..9f91e9b1 --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_d3d11va.h @@ -0,0 +1,169 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_D3D11VA_H +#define AVUTIL_HWCONTEXT_D3D11VA_H + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_D3D11VA. + * + * The default pool implementation will be fixed-size if initial_pool_size is + * set (and allocate elements from an array texture). Otherwise it will allocate + * individual textures. Be aware that decoding requires a single array texture. + * + * Using sw_format==AV_PIX_FMT_YUV420P has special semantics, and maps to + * DXGI_FORMAT_420_OPAQUE. av_hwframe_transfer_data() is not supported for + * this format. Refer to MSDN for details. + * + * av_hwdevice_ctx_create() for this device type supports a key named "debug" + * for the AVDictionary entry. If this is set to any value, the device creation + * code will try to load various supported D3D debugging layers. + */ + +#include +#include + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVD3D11VADeviceContext { + /** + * Device used for texture creation and access. This can also be used to + * set the libavcodec decoding device. + * + * Must be set by the user. This is the only mandatory field - the other + * device context fields are set from this and are available for convenience. + * + * Deallocating the AVHWDeviceContext will always release this interface, + * and it does not matter whether it was user-allocated. + */ + ID3D11Device *device; + + /** + * If unset, this will be set from the device field on init. + * + * Deallocating the AVHWDeviceContext will always release this interface, + * and it does not matter whether it was user-allocated. + */ + ID3D11DeviceContext *device_context; + + /** + * If unset, this will be set from the device field on init. + * + * Deallocating the AVHWDeviceContext will always release this interface, + * and it does not matter whether it was user-allocated. + */ + ID3D11VideoDevice *video_device; + + /** + * If unset, this will be set from the device_context field on init. + * + * Deallocating the AVHWDeviceContext will always release this interface, + * and it does not matter whether it was user-allocated. + */ + ID3D11VideoContext *video_context; + + /** + * Callbacks for locking. They protect accesses to device_context and + * video_context calls. They also protect access to the internal staging + * texture (for av_hwframe_transfer_data() calls). They do NOT protect + * access to hwcontext or decoder state in general. + * + * If unset on init, the hwcontext implementation will set them to use an + * internal mutex. + * + * The underlying lock must be recursive. lock_ctx is for free use by the + * locking implementation. + */ + void (*lock)(void *lock_ctx); + void (*unlock)(void *lock_ctx); + void *lock_ctx; +} AVD3D11VADeviceContext; + +/** + * D3D11 frame descriptor for pool allocation. + * + * In user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs + * with the data pointer pointing at an object of this type describing the + * planes of the frame. + * + * This has no use outside of custom allocation, and AVFrame AVBufferRef do not + * necessarily point to an instance of this struct. + */ +typedef struct AVD3D11FrameDescriptor { + /** + * The texture in which the frame is located. The reference count is + * managed by the AVBufferRef, and destroying the reference will release + * the interface. + * + * Normally stored in AVFrame.data[0]. + */ + ID3D11Texture2D *texture; + + /** + * The index into the array texture element representing the frame, or 0 + * if the texture is not an array texture. + * + * Normally stored in AVFrame.data[1] (cast from intptr_t). + */ + intptr_t index; +} AVD3D11FrameDescriptor; + +/** + * This struct is allocated as AVHWFramesContext.hwctx + */ +typedef struct AVD3D11VAFramesContext { + /** + * The canonical texture used for pool allocation. If this is set to NULL + * on init, the hwframes implementation will allocate and set an array + * texture if initial_pool_size > 0. + * + * The only situation when the API user should set this is: + * - the user wants to do manual pool allocation (setting + * AVHWFramesContext.pool), instead of letting AVHWFramesContext + * allocate the pool + * - of an array texture + * - and wants it to use it for decoding + * - this has to be done before calling av_hwframe_ctx_init() + * + * Deallocating the AVHWFramesContext will always release this interface, + * and it does not matter whether it was user-allocated. + * + * This is in particular used by the libavcodec D3D11VA hwaccel, which + * requires a single array texture. It will create ID3D11VideoDecoderOutputView + * objects for each array texture element on decoder initialization. + */ + ID3D11Texture2D *texture; + + /** + * D3D11_TEXTURE2D_DESC.BindFlags used for texture creation. The user must + * at least set D3D11_BIND_DECODER if the frames context is to be used for + * video decoding. + * This field is ignored/invalid if a user-allocated texture is provided. + */ + UINT BindFlags; + + /** + * D3D11_TEXTURE2D_DESC.MiscFlags used for texture creation. + * This field is ignored/invalid if a user-allocated texture is provided. + */ + UINT MiscFlags; +} AVD3D11VAFramesContext; + +#endif /* AVUTIL_HWCONTEXT_D3D11VA_H */ diff --git a/winlibs/include/libavutil/hwcontext_drm.h b/winlibs/include/libavutil/hwcontext_drm.h new file mode 100644 index 00000000..42709f21 --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_drm.h @@ -0,0 +1,169 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_DRM_H +#define AVUTIL_HWCONTEXT_DRM_H + +#include +#include + +/** + * @file + * API-specific header for AV_HWDEVICE_TYPE_DRM. + * + * Internal frame allocation is not currently supported - all frames + * must be allocated by the user. Thus AVHWFramesContext is always + * NULL, though this may change if support for frame allocation is + * added in future. + */ + +enum { + /** + * The maximum number of layers/planes in a DRM frame. + */ + AV_DRM_MAX_PLANES = 4 +}; + +/** + * DRM object descriptor. + * + * Describes a single DRM object, addressing it as a PRIME file + * descriptor. + */ +typedef struct AVDRMObjectDescriptor { + /** + * DRM PRIME fd for the object. + */ + int fd; + /** + * Total size of the object. + * + * (This includes any parts not which do not contain image data.) + */ + size_t size; + /** + * Format modifier applied to the object (DRM_FORMAT_MOD_*). + * + * If the format modifier is unknown then this should be set to + * DRM_FORMAT_MOD_INVALID. + */ + uint64_t format_modifier; +} AVDRMObjectDescriptor; + +/** + * DRM plane descriptor. + * + * Describes a single plane of a layer, which is contained within + * a single object. + */ +typedef struct AVDRMPlaneDescriptor { + /** + * Index of the object containing this plane in the objects + * array of the enclosing frame descriptor. + */ + int object_index; + /** + * Offset within that object of this plane. + */ + ptrdiff_t offset; + /** + * Pitch (linesize) of this plane. + */ + ptrdiff_t pitch; +} AVDRMPlaneDescriptor; + +/** + * DRM layer descriptor. + * + * Describes a single layer within a frame. This has the structure + * defined by its format, and will contain one or more planes. + */ +typedef struct AVDRMLayerDescriptor { + /** + * Format of the layer (DRM_FORMAT_*). + */ + uint32_t format; + /** + * Number of planes in the layer. + * + * This must match the number of planes required by format. + */ + int nb_planes; + /** + * Array of planes in this layer. + */ + AVDRMPlaneDescriptor planes[AV_DRM_MAX_PLANES]; +} AVDRMLayerDescriptor; + +/** + * DRM frame descriptor. + * + * This is used as the data pointer for AV_PIX_FMT_DRM_PRIME frames. + * It is also used by user-allocated frame pools - allocating in + * AVHWFramesContext.pool must return AVBufferRefs which contain + * an object of this type. + * + * The fields of this structure should be set such it can be + * imported directly by EGL using the EGL_EXT_image_dma_buf_import + * and EGL_EXT_image_dma_buf_import_modifiers extensions. + * (Note that the exact layout of a particular format may vary between + * platforms - we only specify that the same platform should be able + * to import it.) + * + * The total number of planes must not exceed AV_DRM_MAX_PLANES, and + * the order of the planes by increasing layer index followed by + * increasing plane index must be the same as the order which would + * be used for the data pointers in the equivalent software format. + */ +typedef struct AVDRMFrameDescriptor { + /** + * Number of DRM objects making up this frame. + */ + int nb_objects; + /** + * Array of objects making up the frame. + */ + AVDRMObjectDescriptor objects[AV_DRM_MAX_PLANES]; + /** + * Number of layers in the frame. + */ + int nb_layers; + /** + * Array of layers in the frame. + */ + AVDRMLayerDescriptor layers[AV_DRM_MAX_PLANES]; +} AVDRMFrameDescriptor; + +/** + * DRM device. + * + * Allocated as AVHWDeviceContext.hwctx. + */ +typedef struct AVDRMDeviceContext { + /** + * File descriptor of DRM device. + * + * This is used as the device to create frames on, and may also be + * used in some derivation and mapping operations. + * + * If no device is required, set to -1. + */ + int fd; +} AVDRMDeviceContext; + +#endif /* AVUTIL_HWCONTEXT_DRM_H */ diff --git a/winlibs/include/libavutil/hwcontext_dxva2.h b/winlibs/include/libavutil/hwcontext_dxva2.h new file mode 100644 index 00000000..e1b79bc0 --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_dxva2.h @@ -0,0 +1,75 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef AVUTIL_HWCONTEXT_DXVA2_H +#define AVUTIL_HWCONTEXT_DXVA2_H + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_DXVA2. + * + * Only fixed-size pools are supported. + * + * For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs + * with the data pointer set to a pointer to IDirect3DSurface9. + */ + +#include +#include + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVDXVA2DeviceContext { + IDirect3DDeviceManager9 *devmgr; +} AVDXVA2DeviceContext; + +/** + * This struct is allocated as AVHWFramesContext.hwctx + */ +typedef struct AVDXVA2FramesContext { + /** + * The surface type (e.g. DXVA2_VideoProcessorRenderTarget or + * DXVA2_VideoDecoderRenderTarget). Must be set by the caller. + */ + DWORD surface_type; + + /** + * The surface pool. When an external pool is not provided by the caller, + * this will be managed (allocated and filled on init, freed on uninit) by + * libavutil. + */ + IDirect3DSurface9 **surfaces; + int nb_surfaces; + + /** + * Certain drivers require the decoder to be destroyed before the surfaces. + * To allow internally managed pools to work properly in such cases, this + * field is provided. + * + * If it is non-NULL, libavutil will call IDirectXVideoDecoder_Release() on + * it just before the internal surface pool is freed. + * + * This is for convenience only. Some code uses other methods to manage the + * decoder reference. + */ + IDirectXVideoDecoder *decoder_to_release; +} AVDXVA2FramesContext; + +#endif /* AVUTIL_HWCONTEXT_DXVA2_H */ diff --git a/winlibs/include/libavutil/hwcontext_mediacodec.h b/winlibs/include/libavutil/hwcontext_mediacodec.h new file mode 100644 index 00000000..101a9806 --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_mediacodec.h @@ -0,0 +1,36 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_MEDIACODEC_H +#define AVUTIL_HWCONTEXT_MEDIACODEC_H + +/** + * MediaCodec details. + * + * Allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVMediaCodecDeviceContext { + /** + * android/view/Surface handle, to be filled by the user. + * + * This is the default surface used by decoders on this device. + */ + void *surface; +} AVMediaCodecDeviceContext; + +#endif /* AVUTIL_HWCONTEXT_MEDIACODEC_H */ diff --git a/winlibs/include/libavutil/hwcontext_opencl.h b/winlibs/include/libavutil/hwcontext_opencl.h new file mode 100644 index 00000000..ef54486c --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_opencl.h @@ -0,0 +1,100 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_OPENCL_H +#define AVUTIL_HWCONTEXT_OPENCL_H + +#ifdef __APPLE__ +#include +#else +#include +#endif + +#include "frame.h" + +/** + * @file + * API-specific header for AV_HWDEVICE_TYPE_OPENCL. + * + * Pools allocated internally are always dynamic, and are primarily intended + * to be used in OpenCL-only cases. If interoperation is required, it is + * typically required to allocate frames in the other API and then map the + * frames context to OpenCL with av_hwframe_ctx_create_derived(). + */ + +/** + * OpenCL frame descriptor for pool allocation. + * + * In user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs + * with the data pointer pointing at an object of this type describing the + * planes of the frame. + */ +typedef struct AVOpenCLFrameDescriptor { + /** + * Number of planes in the frame. + */ + int nb_planes; + /** + * OpenCL image2d objects for each plane of the frame. + */ + cl_mem planes[AV_NUM_DATA_POINTERS]; +} AVOpenCLFrameDescriptor; + +/** + * OpenCL device details. + * + * Allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVOpenCLDeviceContext { + /** + * The primary device ID of the device. If multiple OpenCL devices + * are associated with the context then this is the one which will + * be used for all operations internal to FFmpeg. + */ + cl_device_id device_id; + /** + * The OpenCL context which will contain all operations and frames on + * this device. + */ + cl_context context; + /** + * The default command queue for this device, which will be used by all + * frames contexts which do not have their own command queue. If not + * intialised by the user, a default queue will be created on the + * primary device. + */ + cl_command_queue command_queue; +} AVOpenCLDeviceContext; + +/** + * OpenCL-specific data associated with a frame pool. + * + * Allocated as AVHWFramesContext.hwctx. + */ +typedef struct AVOpenCLFramesContext { + /** + * The command queue used for internal asynchronous operations on this + * device (av_hwframe_transfer_data(), av_hwframe_map()). + * + * If this is not set, the command queue from the associated device is + * used instead. + */ + cl_command_queue command_queue; +} AVOpenCLFramesContext; + +#endif /* AVUTIL_HWCONTEXT_OPENCL_H */ diff --git a/winlibs/include/libavutil/hwcontext_qsv.h b/winlibs/include/libavutil/hwcontext_qsv.h new file mode 100644 index 00000000..b98d611c --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_qsv.h @@ -0,0 +1,53 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_QSV_H +#define AVUTIL_HWCONTEXT_QSV_H + +#include + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_QSV. + * + * This API does not support dynamic frame pools. AVHWFramesContext.pool must + * contain AVBufferRefs whose data pointer points to an mfxFrameSurface1 struct. + */ + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVQSVDeviceContext { + mfxSession session; +} AVQSVDeviceContext; + +/** + * This struct is allocated as AVHWFramesContext.hwctx + */ +typedef struct AVQSVFramesContext { + mfxFrameSurface1 *surfaces; + int nb_surfaces; + + /** + * A combination of MFX_MEMTYPE_* describing the frame pool. + */ + int frame_type; +} AVQSVFramesContext; + +#endif /* AVUTIL_HWCONTEXT_QSV_H */ + diff --git a/winlibs/include/libavutil/hwcontext_vaapi.h b/winlibs/include/libavutil/hwcontext_vaapi.h new file mode 100644 index 00000000..0b2e071c --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_vaapi.h @@ -0,0 +1,117 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_VAAPI_H +#define AVUTIL_HWCONTEXT_VAAPI_H + +#include + +/** + * @file + * API-specific header for AV_HWDEVICE_TYPE_VAAPI. + * + * Dynamic frame pools are supported, but note that any pool used as a render + * target is required to be of fixed size in order to be be usable as an + * argument to vaCreateContext(). + * + * For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs + * with the data pointer set to a VASurfaceID. + */ + +enum { + /** + * The quirks field has been set by the user and should not be detected + * automatically by av_hwdevice_ctx_init(). + */ + AV_VAAPI_DRIVER_QUIRK_USER_SET = (1 << 0), + /** + * The driver does not destroy parameter buffers when they are used by + * vaRenderPicture(). Additional code will be required to destroy them + * separately afterwards. + */ + AV_VAAPI_DRIVER_QUIRK_RENDER_PARAM_BUFFERS = (1 << 1), + + /** + * The driver does not support the VASurfaceAttribMemoryType attribute, + * so the surface allocation code will not try to use it. + */ + AV_VAAPI_DRIVER_QUIRK_ATTRIB_MEMTYPE = (1 << 2), + + /** + * The driver does not support surface attributes at all. + * The surface allocation code will never pass them to surface allocation, + * and the results of the vaQuerySurfaceAttributes() call will be faked. + */ + AV_VAAPI_DRIVER_QUIRK_SURFACE_ATTRIBUTES = (1 << 3), +}; + +/** + * VAAPI connection details. + * + * Allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVVAAPIDeviceContext { + /** + * The VADisplay handle, to be filled by the user. + */ + VADisplay display; + /** + * Driver quirks to apply - this is filled by av_hwdevice_ctx_init(), + * with reference to a table of known drivers, unless the + * AV_VAAPI_DRIVER_QUIRK_USER_SET bit is already present. The user + * may need to refer to this field when performing any later + * operations using VAAPI with the same VADisplay. + */ + unsigned int driver_quirks; +} AVVAAPIDeviceContext; + +/** + * VAAPI-specific data associated with a frame pool. + * + * Allocated as AVHWFramesContext.hwctx. + */ +typedef struct AVVAAPIFramesContext { + /** + * Set by the user to apply surface attributes to all surfaces in + * the frame pool. If null, default settings are used. + */ + VASurfaceAttrib *attributes; + int nb_attributes; + /** + * The surfaces IDs of all surfaces in the pool after creation. + * Only valid if AVHWFramesContext.initial_pool_size was positive. + * These are intended to be used as the render_targets arguments to + * vaCreateContext(). + */ + VASurfaceID *surface_ids; + int nb_surfaces; +} AVVAAPIFramesContext; + +/** + * VAAPI hardware pipeline configuration details. + * + * Allocated with av_hwdevice_hwconfig_alloc(). + */ +typedef struct AVVAAPIHWConfig { + /** + * ID of a VAAPI pipeline configuration. + */ + VAConfigID config_id; +} AVVAAPIHWConfig; + +#endif /* AVUTIL_HWCONTEXT_VAAPI_H */ diff --git a/winlibs/include/libavutil/hwcontext_vdpau.h b/winlibs/include/libavutil/hwcontext_vdpau.h new file mode 100644 index 00000000..1b7ea1e4 --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_vdpau.h @@ -0,0 +1,44 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_VDPAU_H +#define AVUTIL_HWCONTEXT_VDPAU_H + +#include + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_VDPAU. + * + * This API supports dynamic frame pools. AVHWFramesContext.pool must return + * AVBufferRefs whose data pointer is a VdpVideoSurface. + */ + +/** + * This struct is allocated as AVHWDeviceContext.hwctx + */ +typedef struct AVVDPAUDeviceContext { + VdpDevice device; + VdpGetProcAddress *get_proc_address; +} AVVDPAUDeviceContext; + +/** + * AVHWFramesContext.hwctx is currently not used + */ + +#endif /* AVUTIL_HWCONTEXT_VDPAU_H */ diff --git a/winlibs/include/libavutil/hwcontext_videotoolbox.h b/winlibs/include/libavutil/hwcontext_videotoolbox.h new file mode 100644 index 00000000..5074d79e --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_videotoolbox.h @@ -0,0 +1,60 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H +#define AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H + +#include + +#include + +#include "pixfmt.h" + +/** + * @file + * An API-specific header for AV_HWDEVICE_TYPE_VIDEOTOOLBOX. + * + * This API currently does not support frame allocation, as the raw VideoToolbox + * API does allocation, and FFmpeg itself never has the need to allocate frames. + * + * If the API user sets a custom pool, AVHWFramesContext.pool must return + * AVBufferRefs whose data pointer is a CVImageBufferRef or CVPixelBufferRef. + * + * Currently AVHWDeviceContext.hwctx and AVHWFramesContext.hwctx are always + * NULL. + */ + +/** + * Convert a VideoToolbox (actually CoreVideo) format to AVPixelFormat. + * Returns AV_PIX_FMT_NONE if no known equivalent was found. + */ +enum AVPixelFormat av_map_videotoolbox_format_to_pixfmt(uint32_t cv_fmt); + +/** + * Convert an AVPixelFormat to a VideoToolbox (actually CoreVideo) format. + * Returns 0 if no known equivalent was found. + */ +uint32_t av_map_videotoolbox_format_from_pixfmt(enum AVPixelFormat pix_fmt); + +/** + * Same as av_map_videotoolbox_format_from_pixfmt function, but can map and + * return full range pixel formats via a flag. + */ +uint32_t av_map_videotoolbox_format_from_pixfmt2(enum AVPixelFormat pix_fmt, bool full_range); + +#endif /* AVUTIL_HWCONTEXT_VIDEOTOOLBOX_H */ diff --git a/winlibs/include/libavutil/hwcontext_vulkan.h b/winlibs/include/libavutil/hwcontext_vulkan.h new file mode 100644 index 00000000..5cbeb8e7 --- /dev/null +++ b/winlibs/include/libavutil/hwcontext_vulkan.h @@ -0,0 +1,204 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_HWCONTEXT_VULKAN_H +#define AVUTIL_HWCONTEXT_VULKAN_H + +#include + +#include "pixfmt.h" +#include "frame.h" + +/** + * @file + * API-specific header for AV_HWDEVICE_TYPE_VULKAN. + * + * For user-allocated pools, AVHWFramesContext.pool must return AVBufferRefs + * with the data pointer set to an AVVkFrame. + */ + +/** + * Main Vulkan context, allocated as AVHWDeviceContext.hwctx. + * All of these can be set before init to change what the context uses + */ +typedef struct AVVulkanDeviceContext { + /** + * Custom memory allocator, else NULL + */ + const VkAllocationCallbacks *alloc; + /** + * Vulkan instance. Must be at least version 1.1. + */ + VkInstance inst; + /** + * Physical device + */ + VkPhysicalDevice phys_dev; + /** + * Active device + */ + VkDevice act_dev; + /** + * Queue family index for graphics + * @note av_hwdevice_create() will set all 3 queue indices if unset + * If there is no dedicated queue for compute or transfer operations, + * they will be set to the graphics queue index which can handle both. + * nb_graphics_queues indicates how many queues were enabled for the + * graphics queue (must be at least 1) + */ + int queue_family_index; + int nb_graphics_queues; + /** + * Queue family index to use for transfer operations, and the amount of queues + * enabled. In case there is no dedicated transfer queue, nb_tx_queues + * must be 0 and queue_family_tx_index must be the same as either the graphics + * queue or the compute queue, if available. + */ + int queue_family_tx_index; + int nb_tx_queues; + /** + * Queue family index for compute ops, and the amount of queues enabled. + * In case there are no dedicated compute queues, nb_comp_queues must be + * 0 and its queue family index must be set to the graphics queue. + */ + int queue_family_comp_index; + int nb_comp_queues; + /** + * Enabled instance extensions. + * If supplying your own device context, set this to an array of strings, with + * each entry containing the specified Vulkan extension string to enable. + * Duplicates are possible and accepted. + * If no extensions are enabled, set these fields to NULL, and 0 respectively. + */ + const char * const *enabled_inst_extensions; + int nb_enabled_inst_extensions; + /** + * Enabled device extensions. By default, VK_KHR_external_memory_fd, + * VK_EXT_external_memory_dma_buf, VK_EXT_image_drm_format_modifier, + * VK_KHR_external_semaphore_fd and VK_EXT_external_memory_host are enabled if found. + * If supplying your own device context, these fields takes the same format as + * the above fields, with the same conditions that duplicates are possible + * and accepted, and that NULL and 0 respectively means no extensions are enabled. + */ + const char * const *enabled_dev_extensions; + int nb_enabled_dev_extensions; + /** + * This structure should be set to the set of features that present and enabled + * during device creation. When a device is created by FFmpeg, it will default to + * enabling all that are present of the shaderImageGatherExtended, + * fragmentStoresAndAtomics, shaderInt64 and vertexPipelineStoresAndAtomics features. + */ + VkPhysicalDeviceFeatures2 device_features; +} AVVulkanDeviceContext; + +/** + * Allocated as AVHWFramesContext.hwctx, used to set pool-specific options + */ +typedef struct AVVulkanFramesContext { + /** + * Controls the tiling of allocated frames. + */ + VkImageTiling tiling; + /** + * Defines extra usage of output frames. If left as 0, the following bits + * are set: TRANSFER_SRC, TRANSFER_DST. SAMPLED and STORAGE. + */ + VkImageUsageFlagBits usage; + /** + * Extension data for image creation. + */ + void *create_pnext; + /** + * Extension data for memory allocation. Must have as many entries as + * the number of planes of the sw_format. + * This will be chained to VkExportMemoryAllocateInfo, which is used + * to make all pool images exportable to other APIs if the necessary + * extensions are present in enabled_dev_extensions. + */ + void *alloc_pnext[AV_NUM_DATA_POINTERS]; +} AVVulkanFramesContext; + +/* + * Frame structure, the VkFormat of the image will always match + * the pool's sw_format. + * All frames, imported or allocated, will be created with the + * VK_IMAGE_CREATE_ALIAS_BIT flag set, so the memory may be aliased if needed. + * + * If all three queue family indices in the device context are the same, + * images will be created with the EXCLUSIVE sharing mode. Otherwise, all images + * will be created using the CONCURRENT sharing mode. + * + * @note the size of this structure is not part of the ABI, to allocate + * you must use @av_vk_frame_alloc(). + */ +typedef struct AVVkFrame { + /** + * Vulkan images to which the memory is bound to. + */ + VkImage img[AV_NUM_DATA_POINTERS]; + + /** + * The same tiling must be used for all images in the frame. + */ + VkImageTiling tiling; + + /** + * Memory backing the images. Could be less than the amount of images + * if importing from a DRM or VAAPI frame. + */ + VkDeviceMemory mem[AV_NUM_DATA_POINTERS]; + size_t size[AV_NUM_DATA_POINTERS]; + + /** + * OR'd flags for all memory allocated + */ + VkMemoryPropertyFlagBits flags; + + /** + * Updated after every barrier + */ + VkAccessFlagBits access[AV_NUM_DATA_POINTERS]; + VkImageLayout layout[AV_NUM_DATA_POINTERS]; + + /** + * Synchronization semaphores. Must not be freed manually. Must be waited on + * and signalled at every queue submission. + * Could be less than the amount of images: either one per VkDeviceMemory + * or one for the entire frame. All others will be set to VK_NULL_HANDLE. + */ + VkSemaphore sem[AV_NUM_DATA_POINTERS]; + + /** + * Internal data. + */ + struct AVVkFrameInternal *internal; +} AVVkFrame; + +/** + * Allocates a single AVVkFrame and initializes everything as 0. + * @note Must be freed via av_free() + */ +AVVkFrame *av_vk_frame_alloc(void); + +/** + * Returns the format of each image up to the number of planes for a given sw_format. + * Returns NULL on unsupported formats. + */ +const VkFormat *av_vkfmt_from_pixfmt(enum AVPixelFormat p); + +#endif /* AVUTIL_HWCONTEXT_VULKAN_H */ diff --git a/maclibs/include/libavutil/imgutils.h b/winlibs/include/libavutil/imgutils.h similarity index 94% rename from maclibs/include/libavutil/imgutils.h rename to winlibs/include/libavutil/imgutils.h index 5b790ecf..5eccbf0b 100644 --- a/maclibs/include/libavutil/imgutils.h +++ b/winlibs/include/libavutil/imgutils.h @@ -67,6 +67,20 @@ int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane); */ int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width); +/** + * Fill plane sizes for an image with pixel format pix_fmt and height height. + * + * @param size the array to be filled with the size of each image plane + * @param linesizes the array containing the linesize for each + * plane, should be filled by av_image_fill_linesizes() + * @return >= 0 in case of success, a negative error code otherwise + * + * @note The linesize parameters have the type ptrdiff_t here, while they are + * int for av_image_fill_linesizes(). + */ +int av_image_fill_plane_sizes(size_t size[4], enum AVPixelFormat pix_fmt, + int height, const ptrdiff_t linesizes[4]); + /** * Fill plane data pointers for an image with pixel format pix_fmt and * height height. diff --git a/maclibs/include/libavutil/intreadwrite.h b/winlibs/include/libavutil/intreadwrite.h similarity index 100% rename from maclibs/include/libavutil/intreadwrite.h rename to winlibs/include/libavutil/intreadwrite.h diff --git a/maclibs/include/libavutil/lfg.h b/winlibs/include/libavutil/lfg.h similarity index 81% rename from maclibs/include/libavutil/lfg.h rename to winlibs/include/libavutil/lfg.h index 03f779ad..2b669205 100644 --- a/maclibs/include/libavutil/lfg.h +++ b/winlibs/include/libavutil/lfg.h @@ -24,6 +24,12 @@ #include +/** + * Context structure for the Lagged Fibonacci PRNG. + * The exact layout, types and content of this struct may change and should + * not be accessed directly. Only its sizeof() is guranteed to stay the same + * to allow easy instanciation. + */ typedef struct AVLFG { unsigned int state[64]; int index; @@ -45,8 +51,9 @@ int av_lfg_init_from_data(AVLFG *c, const uint8_t *data, unsigned int length); * it may be good enough and faster for your specific use case. */ static inline unsigned int av_lfg_get(AVLFG *c){ - c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63]; - return c->state[c->index++ & 63]; + unsigned a = c->state[c->index & 63] = c->state[(c->index-24) & 63] + c->state[(c->index-55) & 63]; + c->index += 1U; + return a; } /** @@ -57,7 +64,9 @@ static inline unsigned int av_lfg_get(AVLFG *c){ static inline unsigned int av_mlfg_get(AVLFG *c){ unsigned int a= c->state[(c->index-55) & 63]; unsigned int b= c->state[(c->index-24) & 63]; - return c->state[c->index++ & 63] = 2*a*b+a+b; + a = c->state[c->index & 63] = 2*a*b+a+b; + c->index += 1U; + return a; } /** diff --git a/winlibs/include/libavutil/log.h b/winlibs/include/libavutil/log.h index d9554e60..8edd6bbf 100644 --- a/winlibs/include/libavutil/log.h +++ b/winlibs/include/libavutil/log.h @@ -112,6 +112,7 @@ typedef struct AVClass { */ void* (*child_next)(void *obj, void *prev); +#if FF_API_CHILD_CLASS_NEXT /** * Return an AVClass corresponding to the next potential * AVOptions-enabled child. @@ -120,7 +121,9 @@ typedef struct AVClass { * child_next iterates over _already existing_ objects, while * child_class_next iterates over _all possible_ children. */ + attribute_deprecated const struct AVClass* (*child_class_next)(const struct AVClass *prev); +#endif /** * Category used for visualization (like color) @@ -140,6 +143,21 @@ typedef struct AVClass { * available since version (52.12) */ int (*query_ranges)(struct AVOptionRanges **, void *obj, const char *key, int flags); + + /** + * Iterate over the AVClasses corresponding to potential AVOptions-enabled + * children. + * + * @param iter pointer to opaque iteration state. The caller must initialize + * *iter to NULL before the first call. + * @return AVClass for the next AVOptions-enabled child or NULL if there are + * no more such children. + * + * @note The difference between child_next and this is that child_next + * iterates over _already existing_ objects, while child_class_iterate + * iterates over _all possible_ children. + */ + const struct AVClass* (*child_class_iterate)(void **iter); } AVClass; /** @@ -233,6 +251,27 @@ typedef struct AVClass { */ void av_log(void *avcl, int level, const char *fmt, ...) av_printf_format(3, 4); +/** + * Send the specified message to the log once with the initial_level and then with + * the subsequent_level. By default, all logging messages are sent to + * stderr. This behavior can be altered by setting a different logging callback + * function. + * @see av_log + * + * @param avcl A pointer to an arbitrary struct of which the first field is a + * pointer to an AVClass struct or NULL if general log. + * @param initial_level importance level of the message expressed using a @ref + * lavu_log_constants "Logging Constant" for the first occurance. + * @param subsequent_level importance level of the message expressed using a @ref + * lavu_log_constants "Logging Constant" after the first occurance. + * @param fmt The format string (printf-compatible) that specifies how + * subsequent arguments are converted to output. + * @param state a variable to keep trak of if a message has already been printed + * this must be initialized to 0 before the first use. The same state + * must not be accessed by 2 Threads simultaneously. + */ +void av_log_once(void* avcl, int initial_level, int subsequent_level, int *state, const char *fmt, ...) av_printf_format(5, 6); + /** * Send the specified message to the log if the level is less than or equal diff --git a/maclibs/include/libavutil/lzo.h b/winlibs/include/libavutil/lzo.h similarity index 100% rename from maclibs/include/libavutil/lzo.h rename to winlibs/include/libavutil/lzo.h diff --git a/winlibs/include/libavutil/mastering_display_metadata.h b/winlibs/include/libavutil/mastering_display_metadata.h new file mode 100644 index 00000000..c23b07c3 --- /dev/null +++ b/winlibs/include/libavutil/mastering_display_metadata.h @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2016 Neil Birkbeck + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_MASTERING_DISPLAY_METADATA_H +#define AVUTIL_MASTERING_DISPLAY_METADATA_H + +#include "frame.h" +#include "rational.h" + + +/** + * Mastering display metadata capable of representing the color volume of + * the display used to master the content (SMPTE 2086:2014). + * + * To be used as payload of a AVFrameSideData or AVPacketSideData with the + * appropriate type. + * + * @note The struct should be allocated with av_mastering_display_metadata_alloc() + * and its size is not a part of the public ABI. + */ +typedef struct AVMasteringDisplayMetadata { + /** + * CIE 1931 xy chromaticity coords of color primaries (r, g, b order). + */ + AVRational display_primaries[3][2]; + + /** + * CIE 1931 xy chromaticity coords of white point. + */ + AVRational white_point[2]; + + /** + * Min luminance of mastering display (cd/m^2). + */ + AVRational min_luminance; + + /** + * Max luminance of mastering display (cd/m^2). + */ + AVRational max_luminance; + + /** + * Flag indicating whether the display primaries (and white point) are set. + */ + int has_primaries; + + /** + * Flag indicating whether the luminance (min_ and max_) have been set. + */ + int has_luminance; + +} AVMasteringDisplayMetadata; + +/** + * Allocate an AVMasteringDisplayMetadata structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVMasteringDisplayMetadata filled with default values or NULL + * on failure. + */ +AVMasteringDisplayMetadata *av_mastering_display_metadata_alloc(void); + +/** + * Allocate a complete AVMasteringDisplayMetadata and add it to the frame. + * + * @param frame The frame which side data is added to. + * + * @return The AVMasteringDisplayMetadata structure to be filled by caller. + */ +AVMasteringDisplayMetadata *av_mastering_display_metadata_create_side_data(AVFrame *frame); + +/** + * Content light level needed by to transmit HDR over HDMI (CTA-861.3). + * + * To be used as payload of a AVFrameSideData or AVPacketSideData with the + * appropriate type. + * + * @note The struct should be allocated with av_content_light_metadata_alloc() + * and its size is not a part of the public ABI. + */ +typedef struct AVContentLightMetadata { + /** + * Max content light level (cd/m^2). + */ + unsigned MaxCLL; + + /** + * Max average light level per frame (cd/m^2). + */ + unsigned MaxFALL; +} AVContentLightMetadata; + +/** + * Allocate an AVContentLightMetadata structure and set its fields to + * default values. The resulting struct can be freed using av_freep(). + * + * @return An AVContentLightMetadata filled with default values or NULL + * on failure. + */ +AVContentLightMetadata *av_content_light_metadata_alloc(size_t *size); + +/** + * Allocate a complete AVContentLightMetadata and add it to the frame. + * + * @param frame The frame which side data is added to. + * + * @return The AVContentLightMetadata structure to be filled by caller. + */ +AVContentLightMetadata *av_content_light_metadata_create_side_data(AVFrame *frame); + +#endif /* AVUTIL_MASTERING_DISPLAY_METADATA_H */ diff --git a/winlibs/include/libavutil/mathematics.h b/winlibs/include/libavutil/mathematics.h index 54901800..64d4137a 100644 --- a/winlibs/include/libavutil/mathematics.h +++ b/winlibs/include/libavutil/mathematics.h @@ -134,6 +134,7 @@ int64_t av_rescale(int64_t a, int64_t b, int64_t c) av_const; * * The operation is mathematically equivalent to `a * b / c`, but writing that * directly can overflow, and does not support different rounding methods. + * If the result is not representable then INT64_MIN is returned. * * @see av_rescale(), av_rescale_q(), av_rescale_q_rnd() */ diff --git a/maclibs/include/libavutil/md5.h b/winlibs/include/libavutil/md5.h similarity index 100% rename from maclibs/include/libavutil/md5.h rename to winlibs/include/libavutil/md5.h diff --git a/winlibs/include/libavutil/mem.h b/winlibs/include/libavutil/mem.h index 5fb1a02d..e21a1fea 100644 --- a/winlibs/include/libavutil/mem.h +++ b/winlibs/include/libavutil/mem.h @@ -33,6 +33,7 @@ #include "attributes.h" #include "error.h" #include "avutil.h" +#include "version.h" /** * @addtogroup lavu_mem @@ -49,6 +50,10 @@ * dealing with memory consistently possible on all platforms. * * @{ + */ + +#if FF_API_DECLARE_ALIGNED +/** * * @defgroup lavu_mem_macros Alignment Macros * Helper macros for declaring aligned variables. @@ -125,6 +130,7 @@ /** * @} */ +#endif /** * @defgroup lavu_mem_attrs Function Attributes diff --git a/winlibs/include/libavutil/motion_vector.h b/winlibs/include/libavutil/motion_vector.h new file mode 100644 index 00000000..ec295563 --- /dev/null +++ b/winlibs/include/libavutil/motion_vector.h @@ -0,0 +1,57 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_MOTION_VECTOR_H +#define AVUTIL_MOTION_VECTOR_H + +#include + +typedef struct AVMotionVector { + /** + * Where the current macroblock comes from; negative value when it comes + * from the past, positive value when it comes from the future. + * XXX: set exact relative ref frame reference instead of a +/- 1 "direction". + */ + int32_t source; + /** + * Width and height of the block. + */ + uint8_t w, h; + /** + * Absolute source position. Can be outside the frame area. + */ + int16_t src_x, src_y; + /** + * Absolute destination position. Can be outside the frame area. + */ + int16_t dst_x, dst_y; + /** + * Extra flag information. + * Currently unused. + */ + uint64_t flags; + /** + * Motion vector + * src_x = dst_x + motion_x / motion_scale + * src_y = dst_y + motion_y / motion_scale + */ + int32_t motion_x, motion_y; + uint16_t motion_scale; +} AVMotionVector; + +#endif /* AVUTIL_MOTION_VECTOR_H */ diff --git a/winlibs/include/libavutil/murmur3.h b/winlibs/include/libavutil/murmur3.h new file mode 100644 index 00000000..b3b3a07d --- /dev/null +++ b/winlibs/include/libavutil/murmur3.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2013 Reimar Döffinger + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @ingroup lavu_murmur3 + * Public header for MurmurHash3 hash function implementation. + */ + +#ifndef AVUTIL_MURMUR3_H +#define AVUTIL_MURMUR3_H + +#include +#include + +#include "version.h" + +/** + * @defgroup lavu_murmur3 Murmur3 + * @ingroup lavu_hash + * MurmurHash3 hash function implementation. + * + * MurmurHash3 is a non-cryptographic hash function, of which three + * incompatible versions were created by its inventor Austin Appleby: + * + * - 32-bit output + * - 128-bit output for 32-bit platforms + * - 128-bit output for 64-bit platforms + * + * FFmpeg only implements the last variant: 128-bit output designed for 64-bit + * platforms. Even though the hash function was designed for 64-bit platforms, + * the function in reality works on 32-bit systems too, only with reduced + * performance. + * + * @anchor lavu_murmur3_seedinfo + * By design, MurmurHash3 requires a seed to operate. In response to this, + * libavutil provides two functions for hash initiation, one that requires a + * seed (av_murmur3_init_seeded()) and one that uses a fixed arbitrary integer + * as the seed, and therefore does not (av_murmur3_init()). + * + * To make hashes comparable, you should provide the same seed for all calls to + * this hash function -- if you are supplying one yourself, that is. + * + * @{ + */ + +/** + * Allocate an AVMurMur3 hash context. + * + * @return Uninitialized hash context or `NULL` in case of error + */ +struct AVMurMur3 *av_murmur3_alloc(void); + +/** + * Initialize or reinitialize an AVMurMur3 hash context with a seed. + * + * @param[out] c Hash context + * @param[in] seed Random seed + * + * @see av_murmur3_init() + * @see @ref lavu_murmur3_seedinfo "Detailed description" on a discussion of + * seeds for MurmurHash3. + */ +void av_murmur3_init_seeded(struct AVMurMur3 *c, uint64_t seed); + +/** + * Initialize or reinitialize an AVMurMur3 hash context. + * + * Equivalent to av_murmur3_init_seeded() with a built-in seed. + * + * @param[out] c Hash context + * + * @see av_murmur3_init_seeded() + * @see @ref lavu_murmur3_seedinfo "Detailed description" on a discussion of + * seeds for MurmurHash3. + */ +void av_murmur3_init(struct AVMurMur3 *c); + +/** + * Update hash context with new data. + * + * @param[out] c Hash context + * @param[in] src Input data to update hash with + * @param[in] len Number of bytes to read from `src` + */ +#if FF_API_CRYPTO_SIZE_T +void av_murmur3_update(struct AVMurMur3 *c, const uint8_t *src, int len); +#else +void av_murmur3_update(struct AVMurMur3 *c, const uint8_t *src, size_t len); +#endif + +/** + * Finish hashing and output digest value. + * + * @param[in,out] c Hash context + * @param[out] dst Buffer where output digest value is stored + */ +void av_murmur3_final(struct AVMurMur3 *c, uint8_t dst[16]); + +/** + * @} + */ + +#endif /* AVUTIL_MURMUR3_H */ diff --git a/winlibs/include/libavutil/opt.h b/winlibs/include/libavutil/opt.h index 39f4a8dd..8dc020a8 100644 --- a/winlibs/include/libavutil/opt.h +++ b/winlibs/include/libavutil/opt.h @@ -114,7 +114,7 @@ * libavcodec exports generic options, while its priv_data field exports * codec-specific options). In such a case, it is possible to set up the * parent struct to export a child's options. To do that, simply - * implement AVClass.child_next() and AVClass.child_class_next() in the + * implement AVClass.child_next() and AVClass.child_class_iterate() in the * parent struct's AVClass. * Assuming that the test_struct from above now also contains a * child_struct field: @@ -143,23 +143,25 @@ * return t->child_struct; * return NULL * } - * const AVClass child_class_next(const AVClass *prev) + * const AVClass child_class_iterate(void **iter) * { - * return prev ? NULL : &child_class; + * const AVClass *c = *iter ? NULL : &child_class; + * *iter = (void*)(uintptr_t)c; + * return c; * } * @endcode - * Putting child_next() and child_class_next() as defined above into + * Putting child_next() and child_class_iterate() as defined above into * test_class will now make child_struct's options accessible through * test_struct (again, proper setup as described above needs to be done on * child_struct right after it is created). * * From the above example it might not be clear why both child_next() - * and child_class_next() are needed. The distinction is that child_next() - * iterates over actually existing objects, while child_class_next() + * and child_class_iterate() are needed. The distinction is that child_next() + * iterates over actually existing objects, while child_class_iterate() * iterates over all possible child classes. E.g. if an AVCodecContext * was initialized to use a codec which has private options, then its * child_next() will return AVCodecContext.priv_data and finish - * iterating. OTOH child_class_next() on AVCodecContext.av_class will + * iterating. OTOH child_class_iterate() on AVCodecContext.av_class will * iterate over all available codecs with private options. * * @subsection avoptions_implement_named_constants Named constants @@ -194,7 +196,7 @@ * For enumerating there are basically two cases. The first is when you want to * get all options that may potentially exist on the struct and its children * (e.g. when constructing documentation). In that case you should call - * av_opt_child_class_next() recursively on the parent struct's AVClass. The + * av_opt_child_class_iterate() recursively on the parent struct's AVClass. The * second case is when you have an already initialized struct with all its * children and you want to get all options that can be actually written or read * from it. In that case you should call av_opt_child_next() recursively (and @@ -288,8 +290,10 @@ typedef struct AVOption { */ #define AV_OPT_FLAG_READONLY 128 #define AV_OPT_FLAG_BSF_PARAM (1<<8) ///< a generic parameter which can be set by the user for bit stream filtering +#define AV_OPT_FLAG_RUNTIME_PARAM (1<<15) ///< a generic parameter which can be set by the user at runtime #define AV_OPT_FLAG_FILTERING_PARAM (1<<16) ///< a generic parameter which can be set by the user for filtering #define AV_OPT_FLAG_DEPRECATED (1<<17) ///< set if option is deprecated, users should refer to AVOption.help text for more information +#define AV_OPT_FLAG_CHILD_CONSTS (1<<18) ///< set if option constants can also reside in child objects //FIXME think about enc-audio, ... style flags /** @@ -644,13 +648,26 @@ const AVOption *av_opt_next(const void *obj, const AVOption *prev); */ void *av_opt_child_next(void *obj, void *prev); +#if FF_API_CHILD_CLASS_NEXT /** * Iterate over potential AVOptions-enabled children of parent. * * @param prev result of a previous call to this function or NULL * @return AVClass corresponding to next potential child or NULL + * + * @deprecated use av_opt_child_class_iterate */ +attribute_deprecated const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *prev); +#endif + +/** + * Iterate over potential AVOptions-enabled children of parent. + * + * @param iter a pointer where iteration state is stored. + * @return AVClass corresponding to next potential child or NULL + */ +const AVClass *av_opt_child_class_iterate(const AVClass *parent, void **iter); /** * @defgroup opt_set_funcs Option setting functions @@ -669,6 +686,9 @@ const AVClass *av_opt_child_class_next(const AVClass *parent, const AVClass *pre * scalars or named flags separated by '+' or '-'. Prefixing a flag * with '+' causes it to be set without affecting the other flags; * similarly, '-' unsets a flag. + * If the field is of a dictionary type, it has to be a ':' separated list of + * key=value parameters. Values containing ':' special characters must be + * escaped. * @param search_flags flags passed to av_opt_find2. I.e. if AV_OPT_SEARCH_CHILDREN * is passed here, then the option may be set on a child of obj. * @@ -729,9 +749,10 @@ int av_opt_set_dict_val(void *obj, const char *name, const AVDictionary *val, in /** * @note the returned string will be av_malloc()ed and must be av_free()ed by the caller * - * @note if AV_OPT_ALLOW_NULL is set in search_flags in av_opt_get, and the option has - * AV_OPT_TYPE_STRING or AV_OPT_TYPE_BINARY and is set to NULL, *out_val will be set - * to NULL instead of an allocated empty string. + * @note if AV_OPT_ALLOW_NULL is set in search_flags in av_opt_get, and the + * option is of type AV_OPT_TYPE_STRING, AV_OPT_TYPE_BINARY or AV_OPT_TYPE_DICT + * and is set to NULL, *out_val will be set to NULL instead of an allocated + * empty string. */ int av_opt_get (void *obj, const char *name, int search_flags, uint8_t **out_val); int av_opt_get_int (void *obj, const char *name, int search_flags, int64_t *out_val); diff --git a/maclibs/include/libavutil/parseutils.h b/winlibs/include/libavutil/parseutils.h similarity index 100% rename from maclibs/include/libavutil/parseutils.h rename to winlibs/include/libavutil/parseutils.h diff --git a/maclibs/include/libavutil/pixdesc.h b/winlibs/include/libavutil/pixdesc.h similarity index 99% rename from maclibs/include/libavutil/pixdesc.h rename to winlibs/include/libavutil/pixdesc.h index c055810a..9b9d386a 100644 --- a/maclibs/include/libavutil/pixdesc.h +++ b/winlibs/include/libavutil/pixdesc.h @@ -147,6 +147,7 @@ typedef struct AVPixFmtDescriptor { */ #define AV_PIX_FMT_FLAG_RGB (1 << 5) +#if FF_API_PSEUDOPAL /** * The pixel format is "pseudo-paletted". This means that it contains a * fixed palette in the 2nd plane but the palette is fixed/constant for each @@ -164,6 +165,7 @@ typedef struct AVPixFmtDescriptor { * before the deprecation, though). */ #define AV_PIX_FMT_FLAG_PSEUDOPAL (1 << 6) +#endif /** * The pixel format has an alpha channel. This is set on all formats that diff --git a/winlibs/include/libavutil/pixelutils.h b/winlibs/include/libavutil/pixelutils.h new file mode 100644 index 00000000..a8dbc157 --- /dev/null +++ b/winlibs/include/libavutil/pixelutils.h @@ -0,0 +1,52 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_PIXELUTILS_H +#define AVUTIL_PIXELUTILS_H + +#include +#include +#include "common.h" + +/** + * Sum of abs(src1[x] - src2[x]) + */ +typedef int (*av_pixelutils_sad_fn)(const uint8_t *src1, ptrdiff_t stride1, + const uint8_t *src2, ptrdiff_t stride2); + +/** + * Get a potentially optimized pointer to a Sum-of-absolute-differences + * function (see the av_pixelutils_sad_fn prototype). + * + * @param w_bits 1< + +/** + * @defgroup lavu_rc4 RC4 + * @ingroup lavu_crypto + * @{ + */ + +typedef struct AVRC4 { + uint8_t state[256]; + int x, y; +} AVRC4; + +/** + * Allocate an AVRC4 context. + */ +AVRC4 *av_rc4_alloc(void); + +/** + * @brief Initializes an AVRC4 context. + * + * @param key_bits must be a multiple of 8 + * @param decrypt 0 for encryption, 1 for decryption, currently has no effect + * @return zero on success, negative value otherwise + */ +int av_rc4_init(struct AVRC4 *d, const uint8_t *key, int key_bits, int decrypt); + +/** + * @brief Encrypts / decrypts using the RC4 algorithm. + * + * @param count number of bytes + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst, may be NULL + * @param iv not (yet) used for RC4, should be NULL + * @param decrypt 0 for encryption, 1 for decryption, not (yet) used + */ +void av_rc4_crypt(struct AVRC4 *d, uint8_t *dst, const uint8_t *src, int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_RC4_H */ diff --git a/winlibs/include/libavutil/replaygain.h b/winlibs/include/libavutil/replaygain.h new file mode 100644 index 00000000..b49bf1a3 --- /dev/null +++ b/winlibs/include/libavutil/replaygain.h @@ -0,0 +1,50 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_REPLAYGAIN_H +#define AVUTIL_REPLAYGAIN_H + +#include + +/** + * ReplayGain information (see + * http://wiki.hydrogenaudio.org/index.php?title=ReplayGain_1.0_specification). + * The size of this struct is a part of the public ABI. + */ +typedef struct AVReplayGain { + /** + * Track replay gain in microbels (divide by 100000 to get the value in dB). + * Should be set to INT32_MIN when unknown. + */ + int32_t track_gain; + /** + * Peak track amplitude, with 100000 representing full scale (but values + * may overflow). 0 when unknown. + */ + uint32_t track_peak; + /** + * Same as track_gain, but for the whole album. + */ + int32_t album_gain; + /** + * Same as track_peak, but for the whole album, + */ + uint32_t album_peak; +} AVReplayGain; + +#endif /* AVUTIL_REPLAYGAIN_H */ diff --git a/winlibs/include/libavutil/ripemd.h b/winlibs/include/libavutil/ripemd.h new file mode 100644 index 00000000..921aa666 --- /dev/null +++ b/winlibs/include/libavutil/ripemd.h @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2007 Michael Niedermayer + * Copyright (C) 2013 James Almer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @ingroup lavu_ripemd + * Public header for RIPEMD hash function implementation. + */ + +#ifndef AVUTIL_RIPEMD_H +#define AVUTIL_RIPEMD_H + +#include +#include + +#include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_ripemd RIPEMD + * @ingroup lavu_hash + * RIPEMD hash function implementation. + * + * @{ + */ + +extern const int av_ripemd_size; + +struct AVRIPEMD; + +/** + * Allocate an AVRIPEMD context. + */ +struct AVRIPEMD *av_ripemd_alloc(void); + +/** + * Initialize RIPEMD hashing. + * + * @param context pointer to the function context (of size av_ripemd_size) + * @param bits number of bits in digest (128, 160, 256 or 320 bits) + * @return zero if initialization succeeded, -1 otherwise + */ +int av_ripemd_init(struct AVRIPEMD* context, int bits); + +/** + * Update hash value. + * + * @param context hash function context + * @param data input data to update hash with + * @param len input data length + */ +#if FF_API_CRYPTO_SIZE_T +void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, unsigned int len); +#else +void av_ripemd_update(struct AVRIPEMD* context, const uint8_t* data, size_t len); +#endif + +/** + * Finish hashing and output digest value. + * + * @param context hash function context + * @param digest buffer where output digest value is stored + */ +void av_ripemd_final(struct AVRIPEMD* context, uint8_t *digest); + +/** + * @} + */ + +#endif /* AVUTIL_RIPEMD_H */ diff --git a/maclibs/include/libavutil/sha.h b/winlibs/include/libavutil/sha.h similarity index 100% rename from maclibs/include/libavutil/sha.h rename to winlibs/include/libavutil/sha.h diff --git a/winlibs/include/libavutil/sha512.h b/winlibs/include/libavutil/sha512.h new file mode 100644 index 00000000..bef714b4 --- /dev/null +++ b/winlibs/include/libavutil/sha512.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2007 Michael Niedermayer + * Copyright (C) 2013 James Almer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * @ingroup lavu_sha512 + * Public header for SHA-512 implementation. + */ + +#ifndef AVUTIL_SHA512_H +#define AVUTIL_SHA512_H + +#include +#include + +#include "attributes.h" +#include "version.h" + +/** + * @defgroup lavu_sha512 SHA-512 + * @ingroup lavu_hash + * SHA-512 (Secure Hash Algorithm) hash function implementations. + * + * This module supports the following SHA-2 hash functions: + * + * - SHA-512/224: 224 bits + * - SHA-512/256: 256 bits + * - SHA-384: 384 bits + * - SHA-512: 512 bits + * + * @see For SHA-1, SHA-256, and variants thereof, see @ref lavu_sha. + * + * @{ + */ + +extern const int av_sha512_size; + +struct AVSHA512; + +/** + * Allocate an AVSHA512 context. + */ +struct AVSHA512 *av_sha512_alloc(void); + +/** + * Initialize SHA-2 512 hashing. + * + * @param context pointer to the function context (of size av_sha512_size) + * @param bits number of bits in digest (224, 256, 384 or 512 bits) + * @return zero if initialization succeeded, -1 otherwise + */ +int av_sha512_init(struct AVSHA512* context, int bits); + +/** + * Update hash value. + * + * @param context hash function context + * @param data input data to update hash with + * @param len input data length + */ +#if FF_API_CRYPTO_SIZE_T +void av_sha512_update(struct AVSHA512* context, const uint8_t* data, unsigned int len); +#else +void av_sha512_update(struct AVSHA512* context, const uint8_t* data, size_t len); +#endif + +/** + * Finish hashing and output digest value. + * + * @param context hash function context + * @param digest buffer where output digest value is stored + */ +void av_sha512_final(struct AVSHA512* context, uint8_t *digest); + +/** + * @} + */ + +#endif /* AVUTIL_SHA512_H */ diff --git a/winlibs/include/libavutil/spherical.h b/winlibs/include/libavutil/spherical.h new file mode 100644 index 00000000..cef759cf --- /dev/null +++ b/winlibs/include/libavutil/spherical.h @@ -0,0 +1,232 @@ +/* + * Copyright (c) 2016 Vittorio Giovara + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Spherical video + */ + +#ifndef AVUTIL_SPHERICAL_H +#define AVUTIL_SPHERICAL_H + +#include +#include + +/** + * @addtogroup lavu_video + * @{ + * + * @defgroup lavu_video_spherical Spherical video mapping + * @{ + */ + +/** + * @addtogroup lavu_video_spherical + * A spherical video file contains surfaces that need to be mapped onto a + * sphere. Depending on how the frame was converted, a different distortion + * transformation or surface recomposition function needs to be applied before + * the video should be mapped and displayed. + */ + +/** + * Projection of the video surface(s) on a sphere. + */ +enum AVSphericalProjection { + /** + * Video represents a sphere mapped on a flat surface using + * equirectangular projection. + */ + AV_SPHERICAL_EQUIRECTANGULAR, + + /** + * Video frame is split into 6 faces of a cube, and arranged on a + * 3x2 layout. Faces are oriented upwards for the front, left, right, + * and back faces. The up face is oriented so the top of the face is + * forwards and the down face is oriented so the top of the face is + * to the back. + */ + AV_SPHERICAL_CUBEMAP, + + /** + * Video represents a portion of a sphere mapped on a flat surface + * using equirectangular projection. The @ref bounding fields indicate + * the position of the current video in a larger surface. + */ + AV_SPHERICAL_EQUIRECTANGULAR_TILE, +}; + +/** + * This structure describes how to handle spherical videos, outlining + * information about projection, initial layout, and any other view modifier. + * + * @note The struct must be allocated with av_spherical_alloc() and + * its size is not a part of the public ABI. + */ +typedef struct AVSphericalMapping { + /** + * Projection type. + */ + enum AVSphericalProjection projection; + + /** + * @name Initial orientation + * @{ + * There fields describe additional rotations applied to the sphere after + * the video frame is mapped onto it. The sphere is rotated around the + * viewer, who remains stationary. The order of transformation is always + * yaw, followed by pitch, and finally by roll. + * + * The coordinate system matches the one defined in OpenGL, where the + * forward vector (z) is coming out of screen, and it is equivalent to + * a rotation matrix of R = r_y(yaw) * r_x(pitch) * r_z(roll). + * + * A positive yaw rotates the portion of the sphere in front of the viewer + * toward their right. A positive pitch rotates the portion of the sphere + * in front of the viewer upwards. A positive roll tilts the portion of + * the sphere in front of the viewer to the viewer's right. + * + * These values are exported as 16.16 fixed point. + * + * See this equirectangular projection as example: + * + * @code{.unparsed} + * Yaw + * -180 0 180 + * 90 +-------------+-------------+ 180 + * | | | up + * P | | | y| forward + * i | ^ | | /z + * t 0 +-------------X-------------+ 0 Roll | / + * c | | | | / + * h | | | 0|/_____right + * | | | x + * -90 +-------------+-------------+ -180 + * + * X - the default camera center + * ^ - the default up vector + * @endcode + */ + int32_t yaw; ///< Rotation around the up vector [-180, 180]. + int32_t pitch; ///< Rotation around the right vector [-90, 90]. + int32_t roll; ///< Rotation around the forward vector [-180, 180]. + /** + * @} + */ + + /** + * @name Bounding rectangle + * @anchor bounding + * @{ + * These fields indicate the location of the current tile, and where + * it should be mapped relative to the original surface. They are + * exported as 0.32 fixed point, and can be converted to classic + * pixel values with av_spherical_bounds(). + * + * @code{.unparsed} + * +----------------+----------+ + * | |bound_top | + * | +--------+ | + * | bound_left |tile | | + * +<---------->| |<--->+bound_right + * | +--------+ | + * | | | + * | bound_bottom| | + * +----------------+----------+ + * @endcode + * + * If needed, the original video surface dimensions can be derived + * by adding the current stream or frame size to the related bounds, + * like in the following example: + * + * @code{c} + * original_width = tile->width + bound_left + bound_right; + * original_height = tile->height + bound_top + bound_bottom; + * @endcode + * + * @note These values are valid only for the tiled equirectangular + * projection type (@ref AV_SPHERICAL_EQUIRECTANGULAR_TILE), + * and should be ignored in all other cases. + */ + uint32_t bound_left; ///< Distance from the left edge + uint32_t bound_top; ///< Distance from the top edge + uint32_t bound_right; ///< Distance from the right edge + uint32_t bound_bottom; ///< Distance from the bottom edge + /** + * @} + */ + + /** + * Number of pixels to pad from the edge of each cube face. + * + * @note This value is valid for only for the cubemap projection type + * (@ref AV_SPHERICAL_CUBEMAP), and should be ignored in all other + * cases. + */ + uint32_t padding; +} AVSphericalMapping; + +/** + * Allocate a AVSphericalVideo structure and initialize its fields to default + * values. + * + * @return the newly allocated struct or NULL on failure + */ +AVSphericalMapping *av_spherical_alloc(size_t *size); + +/** + * Convert the @ref bounding fields from an AVSphericalVideo + * from 0.32 fixed point to pixels. + * + * @param map The AVSphericalVideo map to read bound values from. + * @param width Width of the current frame or stream. + * @param height Height of the current frame or stream. + * @param left Pixels from the left edge. + * @param top Pixels from the top edge. + * @param right Pixels from the right edge. + * @param bottom Pixels from the bottom edge. + */ +void av_spherical_tile_bounds(const AVSphericalMapping *map, + size_t width, size_t height, + size_t *left, size_t *top, + size_t *right, size_t *bottom); + +/** + * Provide a human-readable name of a given AVSphericalProjection. + * + * @param projection The input AVSphericalProjection. + * + * @return The name of the AVSphericalProjection, or "unknown". + */ +const char *av_spherical_projection_name(enum AVSphericalProjection projection); + +/** + * Get the AVSphericalProjection form a human-readable name. + * + * @param name The input string. + * + * @return The AVSphericalProjection value, or -1 if not found. + */ +int av_spherical_from_name(const char *name); +/** + * @} + * @} + */ + +#endif /* AVUTIL_SPHERICAL_H */ diff --git a/winlibs/include/libavutil/stereo3d.h b/winlibs/include/libavutil/stereo3d.h new file mode 100644 index 00000000..d421aac2 --- /dev/null +++ b/winlibs/include/libavutil/stereo3d.h @@ -0,0 +1,233 @@ +/* + * Copyright (c) 2013 Vittorio Giovara + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * Stereoscopic video + */ + +#ifndef AVUTIL_STEREO3D_H +#define AVUTIL_STEREO3D_H + +#include + +#include "frame.h" + +/** + * @addtogroup lavu_video + * @{ + * + * @defgroup lavu_video_stereo3d Stereo3D types and functions + * @{ + */ + +/** + * @addtogroup lavu_video_stereo3d + * A stereoscopic video file consists in multiple views embedded in a single + * frame, usually describing two views of a scene. This file describes all + * possible codec-independent view arrangements. + * */ + +/** + * List of possible 3D Types + */ +enum AVStereo3DType { + /** + * Video is not stereoscopic (and metadata has to be there). + */ + AV_STEREO3D_2D, + + /** + * Views are next to each other. + * + * @code{.unparsed} + * LLLLRRRR + * LLLLRRRR + * LLLLRRRR + * ... + * @endcode + */ + AV_STEREO3D_SIDEBYSIDE, + + /** + * Views are on top of each other. + * + * @code{.unparsed} + * LLLLLLLL + * LLLLLLLL + * RRRRRRRR + * RRRRRRRR + * @endcode + */ + AV_STEREO3D_TOPBOTTOM, + + /** + * Views are alternated temporally. + * + * @code{.unparsed} + * frame0 frame1 frame2 ... + * LLLLLLLL RRRRRRRR LLLLLLLL + * LLLLLLLL RRRRRRRR LLLLLLLL + * LLLLLLLL RRRRRRRR LLLLLLLL + * ... ... ... + * @endcode + */ + AV_STEREO3D_FRAMESEQUENCE, + + /** + * Views are packed in a checkerboard-like structure per pixel. + * + * @code{.unparsed} + * LRLRLRLR + * RLRLRLRL + * LRLRLRLR + * ... + * @endcode + */ + AV_STEREO3D_CHECKERBOARD, + + /** + * Views are next to each other, but when upscaling + * apply a checkerboard pattern. + * + * @code{.unparsed} + * LLLLRRRR L L L L R R R R + * LLLLRRRR => L L L L R R R R + * LLLLRRRR L L L L R R R R + * LLLLRRRR L L L L R R R R + * @endcode + */ + AV_STEREO3D_SIDEBYSIDE_QUINCUNX, + + /** + * Views are packed per line, as if interlaced. + * + * @code{.unparsed} + * LLLLLLLL + * RRRRRRRR + * LLLLLLLL + * ... + * @endcode + */ + AV_STEREO3D_LINES, + + /** + * Views are packed per column. + * + * @code{.unparsed} + * LRLRLRLR + * LRLRLRLR + * LRLRLRLR + * ... + * @endcode + */ + AV_STEREO3D_COLUMNS, +}; + +/** + * List of possible view types. + */ +enum AVStereo3DView { + /** + * Frame contains two packed views. + */ + AV_STEREO3D_VIEW_PACKED, + + /** + * Frame contains only the left view. + */ + AV_STEREO3D_VIEW_LEFT, + + /** + * Frame contains only the right view. + */ + AV_STEREO3D_VIEW_RIGHT, +}; + +/** + * Inverted views, Right/Bottom represents the left view. + */ +#define AV_STEREO3D_FLAG_INVERT (1 << 0) + +/** + * Stereo 3D type: this structure describes how two videos are packed + * within a single video surface, with additional information as needed. + * + * @note The struct must be allocated with av_stereo3d_alloc() and + * its size is not a part of the public ABI. + */ +typedef struct AVStereo3D { + /** + * How views are packed within the video. + */ + enum AVStereo3DType type; + + /** + * Additional information about the frame packing. + */ + int flags; + + /** + * Determines which views are packed. + */ + enum AVStereo3DView view; +} AVStereo3D; + +/** + * Allocate an AVStereo3D structure and set its fields to default values. + * The resulting struct can be freed using av_freep(). + * + * @return An AVStereo3D filled with default values or NULL on failure. + */ +AVStereo3D *av_stereo3d_alloc(void); + +/** + * Allocate a complete AVFrameSideData and add it to the frame. + * + * @param frame The frame which side data is added to. + * + * @return The AVStereo3D structure to be filled by caller. + */ +AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame); + +/** + * Provide a human-readable name of a given stereo3d type. + * + * @param type The input stereo3d type value. + * + * @return The name of the stereo3d value, or "unknown". + */ +const char *av_stereo3d_type_name(unsigned int type); + +/** + * Get the AVStereo3DType form a human-readable name. + * + * @param name The input string. + * + * @return The AVStereo3DType value, or -1 if not found. + */ +int av_stereo3d_from_name(const char *name); + +/** + * @} + * @} + */ + +#endif /* AVUTIL_STEREO3D_H */ diff --git a/winlibs/include/libavutil/tea.h b/winlibs/include/libavutil/tea.h new file mode 100644 index 00000000..dd929bda --- /dev/null +++ b/winlibs/include/libavutil/tea.h @@ -0,0 +1,71 @@ +/* + * A 32-bit implementation of the TEA algorithm + * Copyright (c) 2015 Vesselin Bontchev + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_TEA_H +#define AVUTIL_TEA_H + +#include + +/** + * @file + * @brief Public header for libavutil TEA algorithm + * @defgroup lavu_tea TEA + * @ingroup lavu_crypto + * @{ + */ + +extern const int av_tea_size; + +struct AVTEA; + +/** + * Allocate an AVTEA context + * To free the struct: av_free(ptr) + */ +struct AVTEA *av_tea_alloc(void); + +/** + * Initialize an AVTEA context. + * + * @param ctx an AVTEA context + * @param key a key of 16 bytes used for encryption/decryption + * @param rounds the number of rounds in TEA (64 is the "standard") + */ +void av_tea_init(struct AVTEA *ctx, const uint8_t key[16], int rounds); + +/** + * Encrypt or decrypt a buffer using a previously initialized context. + * + * @param ctx an AVTEA context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 8 byte blocks + * @param iv initialization vector for CBC mode, if NULL then ECB will be used + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_tea_crypt(struct AVTEA *ctx, uint8_t *dst, const uint8_t *src, + int count, uint8_t *iv, int decrypt); + +/** + * @} + */ + +#endif /* AVUTIL_TEA_H */ diff --git a/winlibs/include/libavutil/threadmessage.h b/winlibs/include/libavutil/threadmessage.h new file mode 100644 index 00000000..42ce655f --- /dev/null +++ b/winlibs/include/libavutil/threadmessage.h @@ -0,0 +1,115 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public License + * as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_THREADMESSAGE_H +#define AVUTIL_THREADMESSAGE_H + +typedef struct AVThreadMessageQueue AVThreadMessageQueue; + +typedef enum AVThreadMessageFlags { + + /** + * Perform non-blocking operation. + * If this flag is set, send and recv operations are non-blocking and + * return AVERROR(EAGAIN) immediately if they can not proceed. + */ + AV_THREAD_MESSAGE_NONBLOCK = 1, + +} AVThreadMessageFlags; + +/** + * Allocate a new message queue. + * + * @param mq pointer to the message queue + * @param nelem maximum number of elements in the queue + * @param elsize size of each element in the queue + * @return >=0 for success; <0 for error, in particular AVERROR(ENOSYS) if + * lavu was built without thread support + */ +int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, + unsigned nelem, + unsigned elsize); + +/** + * Free a message queue. + * + * The message queue must no longer be in use by another thread. + */ +void av_thread_message_queue_free(AVThreadMessageQueue **mq); + +/** + * Send a message on the queue. + */ +int av_thread_message_queue_send(AVThreadMessageQueue *mq, + void *msg, + unsigned flags); + +/** + * Receive a message from the queue. + */ +int av_thread_message_queue_recv(AVThreadMessageQueue *mq, + void *msg, + unsigned flags); + +/** + * Set the sending error code. + * + * If the error code is set to non-zero, av_thread_message_queue_send() will + * return it immediately. Conventional values, such as AVERROR_EOF or + * AVERROR(EAGAIN), can be used to cause the sending thread to stop or + * suspend its operation. + */ +void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, + int err); + +/** + * Set the receiving error code. + * + * If the error code is set to non-zero, av_thread_message_queue_recv() will + * return it immediately when there are no longer available messages. + * Conventional values, such as AVERROR_EOF or AVERROR(EAGAIN), can be used + * to cause the receiving thread to stop or suspend its operation. + */ +void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, + int err); + +/** + * Set the optional free message callback function which will be called if an + * operation is removing messages from the queue. + */ +void av_thread_message_queue_set_free_func(AVThreadMessageQueue *mq, + void (*free_func)(void *msg)); + +/** + * Return the current number of messages in the queue. + * + * @return the current number of messages or AVERROR(ENOSYS) if lavu was built + * without thread support + */ +int av_thread_message_queue_nb_elems(AVThreadMessageQueue *mq); + +/** + * Flush the message queue + * + * This function is mostly equivalent to reading and free-ing every message + * except that it will be done in a single operation (no lock/unlock between + * reads). + */ +void av_thread_message_flush(AVThreadMessageQueue *mq); + +#endif /* AVUTIL_THREADMESSAGE_H */ diff --git a/maclibs/include/libavutil/time.h b/winlibs/include/libavutil/time.h similarity index 100% rename from maclibs/include/libavutil/time.h rename to winlibs/include/libavutil/time.h diff --git a/maclibs/include/libavutil/timecode.h b/winlibs/include/libavutil/timecode.h similarity index 64% rename from maclibs/include/libavutil/timecode.h rename to winlibs/include/libavutil/timecode.h index 37c1361b..060574a1 100644 --- a/maclibs/include/libavutil/timecode.h +++ b/winlibs/include/libavutil/timecode.h @@ -49,9 +49,9 @@ typedef struct { * Adjust frame number for NTSC drop frame time code. * * @param framenum frame number to adjust - * @param fps frame per second, 30 or 60 + * @param fps frame per second, multiples of 30 * @return adjusted frame number - * @warning adjustment is only valid in NTSC 29.97 and 59.94 + * @warning adjustment is only valid for multiples of NTSC 29.97 */ int av_timecode_adjust_ntsc_framenum2(int framenum, int fps); @@ -62,14 +62,39 @@ int av_timecode_adjust_ntsc_framenum2(int framenum, int fps); * @param framenum frame number * @return the SMPTE binary representation * + * See SMPTE ST 314M-2005 Sec 4.4.2.2.1 "Time code pack (TC)" + * the format description as follows: + * bits 0-5: hours, in BCD(6bits) + * bits 6: BGF1 + * bits 7: BGF2 (NTSC) or FIELD (PAL) + * bits 8-14: minutes, in BCD(7bits) + * bits 15: BGF0 (NTSC) or BGF2 (PAL) + * bits 16-22: seconds, in BCD(7bits) + * bits 23: FIELD (NTSC) or BGF0 (PAL) + * bits 24-29: frames, in BCD(6bits) + * bits 30: drop frame flag (0: non drop, 1: drop) + * bits 31: color frame flag (0: unsync mode, 1: sync mode) + * @note BCD numbers (6 or 7 bits): 4 or 5 lower bits for units, 2 higher bits for tens. * @note Frame number adjustment is automatically done in case of drop timecode, * you do NOT have to call av_timecode_adjust_ntsc_framenum2(). * @note The frame number is relative to tc->start. - * @note Color frame (CF), binary group flags (BGF) and biphase mark polarity - * correction (PC) bits are set to zero. + * @note Color frame (CF) and binary group flags (BGF) bits are set to zero. */ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum); +/** + * Convert sei info to SMPTE 12M binary representation. + * + * @param rate frame rate in rational form + * @param drop drop flag + * @param hh hour + * @param mm minute + * @param ss second + * @param ff frame number + * @return the SMPTE binary representation + */ +uint32_t av_timecode_get_smpte(AVRational rate, int drop, int hh, int mm, int ss, int ff); + /** * Load timecode string in buf. * @@ -84,6 +109,23 @@ uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum) */ char *av_timecode_make_string(const AVTimecode *tc, char *buf, int framenum); +/** + * Get the timecode string from the SMPTE timecode format. + * + * In contrast to av_timecode_make_smpte_tc_string this function supports 50/60 + * fps timecodes by using the field bit. + * + * @param buf destination buffer, must be at least AV_TIMECODE_STR_SIZE long + * @param rate frame rate of the timecode + * @param tcsmpte the 32-bit SMPTE timecode + * @param prevent_df prevent the use of a drop flag when it is known the DF bit + * is arbitrary + * @param skip_field prevent the use of a field flag when it is known the field + * bit is arbitrary (e.g. because it is used as PC flag) + * @return the buf parameter + */ +char *av_timecode_make_smpte_tc_string2(char *buf, AVRational rate, uint32_t tcsmpte, int prevent_df, int skip_field); + /** * Get the timecode string from the SMPTE timecode format. * @@ -118,6 +160,23 @@ char *av_timecode_make_mpeg_tc_string(char *buf, uint32_t tc25bit); */ int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx); +/** + * Init a timecode struct from the passed timecode components. + * + * @param log_ctx a pointer to an arbitrary struct of which the first field + * is a pointer to an AVClass struct (used for av_log) + * @param tc pointer to an allocated AVTimecode + * @param rate frame rate in rational form + * @param flags miscellaneous flags such as drop frame, +24 hours, ... + * (see AVTimecodeFlag) + * @param hh hours + * @param mm minutes + * @param ss seconds + * @param ff frames + * @return 0 on success, AVERROR otherwise + */ +int av_timecode_init_from_components(AVTimecode *tc, AVRational rate, int flags, int hh, int mm, int ss, int ff, void *log_ctx); + /** * Parse timecode representation (hh:mm:ss[:;.]ff). * diff --git a/maclibs/include/libavutil/timestamp.h b/winlibs/include/libavutil/timestamp.h similarity index 100% rename from maclibs/include/libavutil/timestamp.h rename to winlibs/include/libavutil/timestamp.h diff --git a/winlibs/include/libavutil/tree.h b/winlibs/include/libavutil/tree.h new file mode 100644 index 00000000..d5e0aebf --- /dev/null +++ b/winlibs/include/libavutil/tree.h @@ -0,0 +1,138 @@ +/* + * copyright (c) 2006 Michael Niedermayer + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/** + * @file + * A tree container. + * @author Michael Niedermayer + */ + +#ifndef AVUTIL_TREE_H +#define AVUTIL_TREE_H + +#include "attributes.h" +#include "version.h" + +/** + * @addtogroup lavu_tree AVTree + * @ingroup lavu_data + * + * Low-complexity tree container + * + * Insertion, removal, finding equal, largest which is smaller than and + * smallest which is larger than, all have O(log n) worst-case complexity. + * @{ + */ + + +struct AVTreeNode; +extern const int av_tree_node_size; + +/** + * Allocate an AVTreeNode. + */ +struct AVTreeNode *av_tree_node_alloc(void); + +/** + * Find an element. + * @param root a pointer to the root node of the tree + * @param next If next is not NULL, then next[0] will contain the previous + * element and next[1] the next element. If either does not exist, + * then the corresponding entry in next is unchanged. + * @param cmp compare function used to compare elements in the tree, + * API identical to that of Standard C's qsort + * It is guaranteed that the first and only the first argument to cmp() + * will be the key parameter to av_tree_find(), thus it could if the + * user wants, be a different type (like an opaque context). + * @return An element with cmp(key, elem) == 0 or NULL if no such element + * exists in the tree. + */ +void *av_tree_find(const struct AVTreeNode *root, void *key, + int (*cmp)(const void *key, const void *b), void *next[2]); + +/** + * Insert or remove an element. + * + * If *next is NULL, then the supplied element will be removed if it exists. + * If *next is non-NULL, then the supplied element will be inserted, unless + * it already exists in the tree. + * + * @param rootp A pointer to a pointer to the root node of the tree; note that + * the root node can change during insertions, this is required + * to keep the tree balanced. + * @param key pointer to the element key to insert in the tree + * @param next Used to allocate and free AVTreeNodes. For insertion the user + * must set it to an allocated and zeroed object of at least + * av_tree_node_size bytes size. av_tree_insert() will set it to + * NULL if it has been consumed. + * For deleting elements *next is set to NULL by the user and + * av_tree_insert() will set it to the AVTreeNode which was + * used for the removed element. + * This allows the use of flat arrays, which have + * lower overhead compared to many malloced elements. + * You might want to define a function like: + * @code + * void *tree_insert(struct AVTreeNode **rootp, void *key, + * int (*cmp)(void *key, const void *b), + * AVTreeNode **next) + * { + * if (!*next) + * *next = av_mallocz(av_tree_node_size); + * return av_tree_insert(rootp, key, cmp, next); + * } + * void *tree_remove(struct AVTreeNode **rootp, void *key, + * int (*cmp)(void *key, const void *b, AVTreeNode **next)) + * { + * av_freep(next); + * return av_tree_insert(rootp, key, cmp, next); + * } + * @endcode + * @param cmp compare function used to compare elements in the tree, API identical + * to that of Standard C's qsort + * @return If no insertion happened, the found element; if an insertion or + * removal happened, then either key or NULL will be returned. + * Which one it is depends on the tree state and the implementation. You + * should make no assumptions that it's one or the other in the code. + */ +void *av_tree_insert(struct AVTreeNode **rootp, void *key, + int (*cmp)(const void *key, const void *b), + struct AVTreeNode **next); + +void av_tree_destroy(struct AVTreeNode *t); + +/** + * Apply enu(opaque, &elem) to all the elements in the tree in a given range. + * + * @param cmp a comparison function that returns < 0 for an element below the + * range, > 0 for an element above the range and == 0 for an + * element inside the range + * + * @note The cmp function should use the same ordering used to construct the + * tree. + */ +void av_tree_enumerate(struct AVTreeNode *t, void *opaque, + int (*cmp)(void *opaque, void *elem), + int (*enu)(void *opaque, void *elem)); + +/** + * @} + */ + +#endif /* AVUTIL_TREE_H */ diff --git a/winlibs/include/libavutil/twofish.h b/winlibs/include/libavutil/twofish.h new file mode 100644 index 00000000..813cfecd --- /dev/null +++ b/winlibs/include/libavutil/twofish.h @@ -0,0 +1,70 @@ +/* + * An implementation of the TwoFish algorithm + * Copyright (c) 2015 Supraja Meedinti + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_TWOFISH_H +#define AVUTIL_TWOFISH_H + +#include + + +/** + * @file + * @brief Public header for libavutil TWOFISH algorithm + * @defgroup lavu_twofish TWOFISH + * @ingroup lavu_crypto + * @{ + */ + +extern const int av_twofish_size; + +struct AVTWOFISH; + +/** + * Allocate an AVTWOFISH context + * To free the struct: av_free(ptr) + */ +struct AVTWOFISH *av_twofish_alloc(void); + +/** + * Initialize an AVTWOFISH context. + * + * @param ctx an AVTWOFISH context + * @param key a key of size ranging from 1 to 32 bytes used for encryption/decryption + * @param key_bits number of keybits: 128, 192, 256 If less than the required, padded with zeroes to nearest valid value; return value is 0 if key_bits is 128/192/256, -1 if less than 0, 1 otherwise + */ +int av_twofish_init(struct AVTWOFISH *ctx, const uint8_t *key, int key_bits); + +/** + * Encrypt or decrypt a buffer using a previously initialized context + * + * @param ctx an AVTWOFISH context + * @param dst destination array, can be equal to src + * @param src source array, can be equal to dst + * @param count number of 16 byte blocks + * @paran iv initialization vector for CBC mode, NULL for ECB mode + * @param decrypt 0 for encryption, 1 for decryption + */ +void av_twofish_crypt(struct AVTWOFISH *ctx, uint8_t *dst, const uint8_t *src, int count, uint8_t* iv, int decrypt); + +/** + * @} + */ +#endif /* AVUTIL_TWOFISH_H */ diff --git a/winlibs/include/libavutil/tx.h b/winlibs/include/libavutil/tx.h new file mode 100644 index 00000000..bfc0c7f2 --- /dev/null +++ b/winlibs/include/libavutil/tx.h @@ -0,0 +1,135 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_TX_H +#define AVUTIL_TX_H + +#include +#include + +typedef struct AVTXContext AVTXContext; + +typedef struct AVComplexFloat { + float re, im; +} AVComplexFloat; + +typedef struct AVComplexDouble { + double re, im; +} AVComplexDouble; + +typedef struct AVComplexInt32 { + int32_t re, im; +} AVComplexInt32; + +enum AVTXType { + /** + * Standard complex to complex FFT with sample data type AVComplexFloat. + * Output is not 1/len normalized. Scaling currently unsupported. + * The stride parameter is ignored. + */ + AV_TX_FLOAT_FFT = 0, + + /** + * Standard MDCT with sample data type of float and a scale type of + * float. Length is the frame size, not the window size (which is 2x frame) + * For forward transforms, the stride specifies the spacing between each + * sample in the output array in bytes. The input must be a flat array. + * For inverse transforms, the stride specifies the spacing between each + * sample in the input array in bytes. The output will be a flat array. + * Stride must be a non-zero multiple of sizeof(float). + * NOTE: the inverse transform is half-length, meaning the output will not + * contain redundant data. This is what most codecs work with. + */ + AV_TX_FLOAT_MDCT = 1, + + /** + * Same as AV_TX_FLOAT_FFT with a data type of AVComplexDouble. + */ + AV_TX_DOUBLE_FFT = 2, + + /** + * Same as AV_TX_FLOAT_MDCT with data and scale type of double. + * Stride must be a non-zero multiple of sizeof(double). + */ + AV_TX_DOUBLE_MDCT = 3, + + /** + * Same as AV_TX_FLOAT_FFT with a data type of AVComplexInt32. + */ + AV_TX_INT32_FFT = 4, + + /** + * Same as AV_TX_FLOAT_MDCT with data type of int32_t and scale type of float. + * Only scale values less than or equal to 1.0 are supported. + * Stride must be a non-zero multiple of sizeof(int32_t). + */ + AV_TX_INT32_MDCT = 5, +}; + +/** + * Function pointer to a function to perform the transform. + * + * @note Using a different context than the one allocated during av_tx_init() + * is not allowed. + * + * @param s the transform context + * @param out the output array + * @param in the input array + * @param stride the input or output stride in bytes + * + * The out and in arrays must be aligned to the maximum required by the CPU + * architecture. + * The stride must follow the constraints the transform type has specified. + */ +typedef void (*av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride); + +/** + * Flags for av_tx_init() + */ +enum AVTXFlags { + /** + * Performs an in-place transformation on the input. The output argument + * of av_tn_fn() MUST match the input. May be unsupported or slower for some + * transform types. + */ + AV_TX_INPLACE = 1ULL << 0, +}; + +/** + * Initialize a transform context with the given configuration + * (i)MDCTs with an odd length are currently not supported. + * + * @param ctx the context to allocate, will be NULL on error + * @param tx pointer to the transform function pointer to set + * @param type type the type of transform + * @param inv whether to do an inverse or a forward transform + * @param len the size of the transform in samples + * @param scale pointer to the value to scale the output if supported by type + * @param flags a bitmask of AVTXFlags or 0 + * + * @return 0 on success, negative error code on failure + */ +int av_tx_init(AVTXContext **ctx, av_tx_fn *tx, enum AVTXType type, + int inv, int len, const void *scale, uint64_t flags); + +/** + * Frees a context and sets ctx to NULL, does nothing when ctx == NULL + */ +void av_tx_uninit(AVTXContext **ctx); + +#endif /* AVUTIL_TX_H */ diff --git a/winlibs/include/libavutil/version.h b/winlibs/include/libavutil/version.h index 24ca8ab7..f888dbb2 100644 --- a/winlibs/include/libavutil/version.h +++ b/winlibs/include/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 56 -#define LIBAVUTIL_VERSION_MINOR 31 +#define LIBAVUTIL_VERSION_MINOR 70 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -129,7 +129,18 @@ #ifndef FF_API_PSEUDOPAL #define FF_API_PSEUDOPAL (LIBAVUTIL_VERSION_MAJOR < 57) #endif - +#ifndef FF_API_CHILD_CLASS_NEXT +#define FF_API_CHILD_CLASS_NEXT (LIBAVUTIL_VERSION_MAJOR < 57) +#endif +#ifndef FF_API_BUFFER_SIZE_T +#define FF_API_BUFFER_SIZE_T (LIBAVUTIL_VERSION_MAJOR < 57) +#endif +#ifndef FF_API_D2STR +#define FF_API_D2STR (LIBAVUTIL_VERSION_MAJOR < 58) +#endif +#ifndef FF_API_DECLARE_ALIGNED +#define FF_API_DECLARE_ALIGNED (LIBAVUTIL_VERSION_MAJOR < 58) +#endif /** * @} diff --git a/winlibs/include/libavutil/video_enc_params.h b/winlibs/include/libavutil/video_enc_params.h new file mode 100644 index 00000000..fc0c3bc1 --- /dev/null +++ b/winlibs/include/libavutil/video_enc_params.h @@ -0,0 +1,171 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVUTIL_VIDEO_ENC_PARAMS_H +#define AVUTIL_VIDEO_ENC_PARAMS_H + +#include +#include + +#include "libavutil/avassert.h" +#include "libavutil/frame.h" + +enum AVVideoEncParamsType { + AV_VIDEO_ENC_PARAMS_NONE = -1, + /** + * VP9 stores: + * - per-frame base (luma AC) quantizer index, exported as AVVideoEncParams.qp + * - deltas for luma DC, chroma AC and chroma DC, exported in the + * corresponding entries in AVVideoEncParams.delta_qp + * - per-segment delta, exported as for each block as AVVideoBlockParams.delta_qp + * + * To compute the resulting quantizer index for a block: + * - for luma AC, add the base qp and the per-block delta_qp, saturating to + * unsigned 8-bit. + * - for luma DC and chroma AC/DC, add the corresponding + * AVVideoBlockParams.delta_qp to the luma AC index, again saturating to + * unsigned 8-bit. + */ + AV_VIDEO_ENC_PARAMS_VP9, + + /** + * H.264 stores: + * - in PPS (per-picture): + * * initial QP_Y (luma) value, exported as AVVideoEncParams.qp + * * delta(s) for chroma QP values (same for both, or each separately), + * exported as in the corresponding entries in AVVideoEncParams.delta_qp + * - per-slice QP delta, not exported directly, added to the per-MB value + * - per-MB delta; not exported directly; the final per-MB quantizer + * parameter - QP_Y - minus the value in AVVideoEncParams.qp is exported + * as AVVideoBlockParams.qp_delta. + */ + AV_VIDEO_ENC_PARAMS_H264, + + /* + * MPEG-2-compatible quantizer. + * + * Summing the frame-level qp with the per-block delta_qp gives the + * resulting quantizer for the block. + */ + AV_VIDEO_ENC_PARAMS_MPEG2, +}; + +/** + * Video encoding parameters for a given frame. This struct is allocated along + * with an optional array of per-block AVVideoBlockParams descriptors. + * Must be allocated with av_video_enc_params_alloc(). + */ +typedef struct AVVideoEncParams { + /** + * Number of blocks in the array. + * + * May be 0, in which case no per-block information is present. In this case + * the values of blocks_offset / block_size are unspecified and should not + * be accessed. + */ + unsigned int nb_blocks; + /** + * Offset in bytes from the beginning of this structure at which the array + * of blocks starts. + */ + size_t blocks_offset; + /* + * Size of each block in bytes. May not match sizeof(AVVideoBlockParams). + */ + size_t block_size; + + /** + * Type of the parameters (the codec they are used with). + */ + enum AVVideoEncParamsType type; + + /** + * Base quantisation parameter for the frame. The final quantiser for a + * given block in a given plane is obtained from this value, possibly + * combined with {@code delta_qp} and the per-block delta in a manner + * documented for each type. + */ + int32_t qp; + + /** + * Quantisation parameter offset from the base (per-frame) qp for a given + * plane (first index) and AC/DC coefficients (second index). + */ + int32_t delta_qp[4][2]; +} AVVideoEncParams; + +/** + * Data structure for storing block-level encoding information. + * It is allocated as a part of AVVideoEncParams and should be retrieved with + * av_video_enc_params_block(). + * + * sizeof(AVVideoBlockParams) is not a part of the ABI and new fields may be + * added to it. + */ +typedef struct AVVideoBlockParams { + /** + * Distance in luma pixels from the top-left corner of the visible frame + * to the top-left corner of the block. + * Can be negative if top/right padding is present on the coded frame. + */ + int src_x, src_y; + /** + * Width and height of the block in luma pixels. + */ + int w, h; + + /** + * Difference between this block's final quantization parameter and the + * corresponding per-frame value. + */ + int32_t delta_qp; +} AVVideoBlockParams; + +/* + * Get the block at the specified {@code idx}. Must be between 0 and nb_blocks. + */ +static av_always_inline AVVideoBlockParams* +av_video_enc_params_block(AVVideoEncParams *par, unsigned int idx) +{ + av_assert0(idx < par->nb_blocks); + return (AVVideoBlockParams *)((uint8_t *)par + par->blocks_offset + + idx * par->block_size); +} + +/** + * Allocates memory for AVVideoEncParams of the given type, plus an array of + * {@code nb_blocks} AVVideoBlockParams and initializes the variables. Can be + * freed with a normal av_free() call. + * + * @param out_size if non-NULL, the size in bytes of the resulting data array is + * written here. + */ +AVVideoEncParams *av_video_enc_params_alloc(enum AVVideoEncParamsType type, + unsigned int nb_blocks, size_t *out_size); + +/** + * Allocates memory for AVEncodeInfoFrame plus an array of + * {@code nb_blocks} AVEncodeInfoBlock in the given AVFrame {@code frame} + * as AVFrameSideData of type AV_FRAME_DATA_VIDEO_ENC_PARAMS + * and initializes the variables. + */ +AVVideoEncParams* +av_video_enc_params_create_side_data(AVFrame *frame, enum AVVideoEncParamsType type, + unsigned int nb_blocks); + +#endif /* AVUTIL_VIDEO_ENC_PARAMS_H */ diff --git a/maclibs/include/libavutil/xtea.h b/winlibs/include/libavutil/xtea.h similarity index 100% rename from maclibs/include/libavutil/xtea.h rename to winlibs/include/libavutil/xtea.h diff --git a/winlibs/include/libswresample/version.h b/winlibs/include/libswresample/version.h index a0b361bc..0a99e0f1 100644 --- a/winlibs/include/libswresample/version.h +++ b/winlibs/include/libswresample/version.h @@ -29,7 +29,7 @@ #include "libavutil/avutil.h" #define LIBSWRESAMPLE_VERSION_MAJOR 3 -#define LIBSWRESAMPLE_VERSION_MINOR 5 +#define LIBSWRESAMPLE_VERSION_MINOR 9 #define LIBSWRESAMPLE_VERSION_MICRO 100 #define LIBSWRESAMPLE_VERSION_INT AV_VERSION_INT(LIBSWRESAMPLE_VERSION_MAJOR, \ diff --git a/winlibs/include/ogg/config_types.h b/winlibs/include/ogg/config_types.h index 1e7d4909..1a87df64 100644 --- a/winlibs/include/ogg/config_types.h +++ b/winlibs/include/ogg/config_types.h @@ -1,7 +1,7 @@ #ifndef __CONFIG_TYPES_H__ #define __CONFIG_TYPES_H__ -/* these are filled in by configure */ +/* these are filled in by configure or cmake*/ #define INCLUDE_INTTYPES_H 1 #define INCLUDE_STDINT_H 1 #define INCLUDE_SYS_TYPES_H 1 @@ -16,10 +16,11 @@ # include #endif -typedef short ogg_int16_t; -typedef unsigned short ogg_uint16_t; -typedef int ogg_int32_t; -typedef unsigned int ogg_uint32_t; -typedef long long ogg_int64_t; +typedef int16_t ogg_int16_t; +typedef uint16_t ogg_uint16_t; +typedef int32_t ogg_int32_t; +typedef uint32_t ogg_uint32_t; +typedef int64_t ogg_int64_t; +typedef uint64_t ogg_uint64_t; #endif diff --git a/winlibs/include/ogg/ogg.h b/winlibs/include/ogg/ogg.h index cea4ebed..c4325aa7 100644 --- a/winlibs/include/ogg/ogg.h +++ b/winlibs/include/ogg/ogg.h @@ -11,7 +11,6 @@ ******************************************************************** function: toplevel libogg include - last mod: $Id: ogg.h 18044 2011-08-01 17:55:20Z gmaxwell $ ********************************************************************/ #ifndef _OGG_H diff --git a/winlibs/include/ogg/os_types.h b/winlibs/include/ogg/os_types.h index d6691b70..e655a1d6 100644 --- a/winlibs/include/ogg/os_types.h +++ b/winlibs/include/ogg/os_types.h @@ -10,8 +10,7 @@ * * ******************************************************************** - function: #ifdef jail to whip a few platforms into the UNIX ideal. - last mod: $Id: os_types.h 17712 2010-12-03 17:10:02Z xiphmont $ + function: Define a consistent set of types on each platform. ********************************************************************/ #ifndef _OS_TYPES_H @@ -24,7 +23,7 @@ #define _ogg_realloc realloc #define _ogg_free free -#if defined(_WIN32) +#if defined(_WIN32) # if defined(__CYGWIN__) # include @@ -44,36 +43,40 @@ typedef unsigned long long ogg_uint64_t; # elif defined(__MWERKS__) typedef long long ogg_int64_t; + typedef unsigned long long ogg_uint64_t; typedef int ogg_int32_t; typedef unsigned int ogg_uint32_t; typedef short ogg_int16_t; typedef unsigned short ogg_uint16_t; # else - /* MSVC/Borland */ - typedef __int64 ogg_int64_t; - typedef __int32 ogg_int32_t; - typedef unsigned __int32 ogg_uint32_t; - typedef __int16 ogg_int16_t; - typedef unsigned __int16 ogg_uint16_t; +# if defined(_MSC_VER) && (_MSC_VER >= 1800) /* MSVC 2013 and newer */ +# include + typedef int16_t ogg_int16_t; + typedef uint16_t ogg_uint16_t; + typedef int32_t ogg_int32_t; + typedef uint32_t ogg_uint32_t; + typedef int64_t ogg_int64_t; + typedef uint64_t ogg_uint64_t; +# else + /* MSVC/Borland */ + typedef __int64 ogg_int64_t; + typedef __int32 ogg_int32_t; + typedef unsigned __int32 ogg_uint32_t; + typedef unsigned __int64 ogg_uint64_t; + typedef __int16 ogg_int16_t; + typedef unsigned __int16 ogg_uint16_t; +# endif # endif -#elif defined(__MACOS__) - -# include - typedef SInt16 ogg_int16_t; - typedef UInt16 ogg_uint16_t; - typedef SInt32 ogg_int32_t; - typedef UInt32 ogg_uint32_t; - typedef SInt64 ogg_int64_t; - #elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */ -# include +# include typedef int16_t ogg_int16_t; - typedef uint16_t ogg_uint16_t; + typedef u_int16_t ogg_uint16_t; typedef int32_t ogg_int32_t; - typedef uint32_t ogg_uint32_t; + typedef u_int32_t ogg_uint32_t; typedef int64_t ogg_int64_t; + typedef u_int64_t ogg_uint64_t; #elif defined(__HAIKU__) @@ -84,6 +87,7 @@ typedef int ogg_int32_t; typedef unsigned int ogg_uint32_t; typedef long long ogg_int64_t; + typedef unsigned long long ogg_uint64_t; #elif defined(__BEOS__) @@ -94,6 +98,7 @@ typedef int32_t ogg_int32_t; typedef uint32_t ogg_uint32_t; typedef int64_t ogg_int64_t; + typedef uint64_t ogg_uint64_t; #elif defined (__EMX__) @@ -103,6 +108,8 @@ typedef int ogg_int32_t; typedef unsigned int ogg_uint32_t; typedef long long ogg_int64_t; + typedef unsigned long long ogg_uint64_t; + #elif defined (DJGPP) @@ -111,11 +118,13 @@ typedef int ogg_int32_t; typedef unsigned int ogg_uint32_t; typedef long long ogg_int64_t; + typedef unsigned long long ogg_uint64_t; #elif defined(R5900) /* PS2 EE */ typedef long ogg_int64_t; + typedef unsigned long ogg_uint64_t; typedef int ogg_int32_t; typedef unsigned ogg_uint32_t; typedef short ogg_int16_t; @@ -128,6 +137,7 @@ typedef signed int ogg_int32_t; typedef unsigned int ogg_uint32_t; typedef long long int ogg_int64_t; + typedef unsigned long long int ogg_uint64_t; #elif defined(__TMS320C6X__) @@ -137,6 +147,7 @@ typedef signed int ogg_int32_t; typedef unsigned int ogg_uint32_t; typedef long long int ogg_int64_t; + typedef unsigned long long int ogg_uint64_t; #else diff --git a/winlibs/include/opencc/Common.hpp b/winlibs/include/opencc/Common.hpp index 9d8d69a0..2315fae9 100644 --- a/winlibs/include/opencc/Common.hpp +++ b/winlibs/include/opencc/Common.hpp @@ -50,16 +50,15 @@ using std::vector; // Forward decalarations and alias namespace opencc { -class BinaryDict; class Config; class Conversion; class ConversionChain; class Converter; -class DartsDict; class Dict; class DictEntry; class DictGroup; class Lexicon; +class MarisaDict; class MultiValueDictEntry; class NoValueDictEntry; class Segmentation; @@ -67,26 +66,36 @@ class Segments; class SerializableDict; class SingleValueDictEntry; class TextDict; -typedef std::shared_ptr BinaryDictPtr; typedef std::shared_ptr ConversionPtr; typedef std::shared_ptr ConversionChainPtr; typedef std::shared_ptr ConverterPtr; -typedef std::shared_ptr DartsDictPtr; typedef std::shared_ptr DictPtr; typedef std::shared_ptr DictGroupPtr; typedef std::shared_ptr LexiconPtr; +typedef std::shared_ptr MarisaDictPtr; typedef std::shared_ptr SegmentationPtr; typedef std::shared_ptr SegmentsPtr; typedef std::shared_ptr SerializableDictPtr; typedef std::shared_ptr TextDictPtr; -} + +#ifdef ENABLE_DARTS +class BinaryDict; +class DartsDict; +typedef std::shared_ptr BinaryDictPtr; +typedef std::shared_ptr DartsDictPtr; +#endif + +} // namespace opencc #ifndef PKGDATADIR const string PACKAGE_DATA_DIRECTORY = ""; -#else // ifndef PKGDATADIR +#else // ifndef PKGDATADIR const string PACKAGE_DATA_DIRECTORY = PKGDATADIR "/"; #endif // ifndef PKGDATADIR #ifndef VERSION #define VERSION "1.0.*" #endif // ifndef VERSION + +// The following definitions are provided by CMake +// #define ENABLE_DARTS diff --git a/maclibs/include/opencc/Segmentation.hpp b/winlibs/include/opencc/DictConverter.hpp similarity index 72% rename from maclibs/include/opencc/Segmentation.hpp rename to winlibs/include/opencc/DictConverter.hpp index 84e7f216..7d392a1e 100644 --- a/maclibs/include/opencc/Segmentation.hpp +++ b/winlibs/include/opencc/DictConverter.hpp @@ -1,7 +1,7 @@ /* * Open Chinese Convert * - * Copyright 2010-2014 BYVoid + * Copyright 2010-2017 BYVoid * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,11 +22,9 @@ namespace opencc { /** -* Abstract segmentation +* Converts a dictionary from a format to another. * @ingroup opencc_cpp_api */ -class OPENCC_EXPORT Segmentation { -public: - virtual SegmentsPtr Segment(const string& text) const = 0; -}; +OPENCC_EXPORT void ConvertDictionary(const string inputFileName, const string outputFileName, + const string formatFrom, const string formatTo); } diff --git a/winlibs/include/opencc/DictEntry.hpp b/winlibs/include/opencc/DictEntry.hpp index 0a840a68..4370200e 100644 --- a/winlibs/include/opencc/DictEntry.hpp +++ b/winlibs/include/opencc/DictEntry.hpp @@ -1,7 +1,7 @@ /* * Open Chinese Convert * - * Copyright 2010-2014 BYVoid + * Copyright 2010-2020 BYVoid * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,39 +19,36 @@ #pragma once #include "Common.hpp" -#include "UTF8Util.hpp" #include "Segments.hpp" +#include "UTF8Util.hpp" namespace opencc { /** -* Key-values pair entry -* @ingroup opencc_cpp_api -*/ + * Key-values pair entry + * @ingroup opencc_cpp_api + */ class OPENCC_EXPORT DictEntry { public: virtual ~DictEntry() {} - virtual const char* Key() const = 0; + virtual std::string Key() const = 0; - virtual vector Values() const = 0; + virtual vector Values() const = 0; - virtual const char* GetDefault() const = 0; + virtual std::string GetDefault() const = 0; virtual size_t NumValues() const = 0; virtual string ToString() const = 0; - size_t KeyLength() const { return strlen(Key()); } + size_t KeyLength() const { return Key().length(); } - bool operator<(const DictEntry& that) const { - return strcmp(Key(), that.Key()) < 0; - } + bool operator<(const DictEntry& that) const { return Key() < that.Key(); } - bool operator==(const DictEntry& that) const { - return strcmp(Key(), that.Key()) == 0; - } + bool operator==(const DictEntry& that) const { return Key() == that.Key(); } - static bool PtrLessThan(const DictEntry* a, const DictEntry* b) { + static bool UPtrLessThan(const std::unique_ptr& a, + const std::unique_ptr& b) { return *a < *b; } }; @@ -62,11 +59,11 @@ public: virtual ~NoValueDictEntry() {} - virtual const char* Key() const { return key.c_str(); } + virtual std::string Key() const { return key; } - virtual vector Values() const { return vector(); } + virtual vector Values() const { return vector(); } - virtual const char* GetDefault() const { return Key(); } + virtual std::string GetDefault() const { return key; } virtual size_t NumValues() const { return 0; } @@ -78,13 +75,13 @@ private: class OPENCC_EXPORT SingleValueDictEntry : public DictEntry { public: - virtual const char* Value() const = 0; + virtual std::string Value() const = 0; - virtual vector Values() const { - return vector{Value()}; + virtual vector Values() const { + return vector{Value()}; } - virtual const char* GetDefault() const { return Value(); } + virtual std::string GetDefault() const { return Value(); } virtual size_t NumValues() const { return 1; } @@ -98,9 +95,9 @@ public: virtual ~StrSingleValueDictEntry() {} - virtual const char* Key() const { return key.c_str(); } + virtual std::string Key() const { return key; } - virtual const char* Value() const { return value.c_str(); } + virtual std::string Value() const { return value; } private: string key; @@ -109,7 +106,7 @@ private: class OPENCC_EXPORT MultiValueDictEntry : public DictEntry { public: - virtual const char* GetDefault() const { + virtual std::string GetDefault() const { if (NumValues() > 0) { return Values().at(0); } else { @@ -122,54 +119,22 @@ public: class OPENCC_EXPORT StrMultiValueDictEntry : public MultiValueDictEntry { public: - StrMultiValueDictEntry(const string& _key, const vector& _values) + StrMultiValueDictEntry(const string& _key, const vector& _values) : key(_key), values(_values) {} - StrMultiValueDictEntry(const string& _key, const vector& _values) - : key(_key) { - values.reserve(_values.size()); - for (const char* str : _values) { - values.push_back(str); - } - } - virtual ~StrMultiValueDictEntry() {} - virtual const char* Key() const { return key.c_str(); } + virtual std::string Key() const { return key; } size_t NumValues() const { return values.size(); } - vector Values() const { - vector retsult; - for (const string& value : this->values) { - retsult.push_back(value.c_str()); - } - return retsult; - } + vector Values() const { return values; } private: string key; vector values; }; -class OPENCC_EXPORT PtrDictEntry : public MultiValueDictEntry { -public: - PtrDictEntry(const char* _key, const vector& _values) - : key(_key), values(_values) {} - - virtual ~PtrDictEntry() {} - - virtual const char* Key() const { return key; } - - size_t NumValues() const { return values.size(); } - - vector Values() const { return values; } - -private: - const char* key; - vector values; -}; - class OPENCC_EXPORT DictEntryFactory { public: static DictEntry* New(const string& key) { return new NoValueDictEntry(key); } @@ -179,6 +144,11 @@ public: } static DictEntry* New(const string& key, const vector& values) { + if (values.size() == 0) { + return New(key); + } else if (values.size() == 1) { + return New(key, values.front()); + } return new StrMultiValueDictEntry(key, values); } @@ -194,4 +164,4 @@ public: } } }; -} +} // namespace opencc diff --git a/winlibs/include/opencc/Exception.hpp b/winlibs/include/opencc/Exception.hpp index 33cb5d9d..98ebb605 100644 --- a/winlibs/include/opencc/Exception.hpp +++ b/winlibs/include/opencc/Exception.hpp @@ -24,9 +24,8 @@ #include "Export.hpp" -#ifdef _MSC_VER - -// Until Visual Studio 2013 (12.0), C++ 11 "noexcept" qualifier is not supported +#if defined(_MSC_VER) && _MSC_VER < 1900 +// Before Visual Studio 2015 (14.0), C++ 11 "noexcept" qualifier is not supported #define noexcept #endif // ifdef _MSC_VER diff --git a/winlibs/include/opencc/Lexicon.hpp b/winlibs/include/opencc/Lexicon.hpp index 1bb6ab6a..e54f2f92 100644 --- a/winlibs/include/opencc/Lexicon.hpp +++ b/winlibs/include/opencc/Lexicon.hpp @@ -23,34 +23,46 @@ namespace opencc { /** -* Storage of all entries -* @ingroup opencc_cpp_api -*/ + * Storage of all entries + * @ingroup opencc_cpp_api + */ class OPENCC_EXPORT Lexicon { public: Lexicon() {} + Lexicon(vector> entries_) + : entries(std::move(entries_)) {} + Lexicon(const Lexicon&) = delete; + Lexicon& operator=(const Lexicon&) = delete; - ~Lexicon() { - for (DictEntry* entry : entries) { - delete entry; - } + // Lexicon will take the ownership of the entry. + void Add(DictEntry* entry) { entries.emplace_back(entry); } + + void Add(std::unique_ptr entry) { + entries.push_back(std::move(entry)); } - void Add(DictEntry* entry) { entries.push_back(entry); } - void Sort() { - std::sort(entries.begin(), entries.end(), DictEntry::PtrLessThan); + std::sort(entries.begin(), entries.end(), DictEntry::UPtrLessThan); } - const DictEntry* At(size_t index) const { return entries.at(index); } + bool IsSorted() { + return std::is_sorted(entries.begin(), entries.end(), + DictEntry::UPtrLessThan); + } + + const DictEntry* At(size_t index) const { return entries.at(index).get(); } size_t Length() const { return entries.size(); } - vector::const_iterator begin() const { return entries.begin(); } + vector>::const_iterator begin() const { + return entries.begin(); + } - vector::const_iterator end() const { return entries.end(); } + vector>::const_iterator end() const { + return entries.end(); + } private: - vector entries; + vector> entries; }; -} +} // namespace opencc diff --git a/maclibs/include/opencc/DartsDict.hpp b/winlibs/include/opencc/MarisaDict.hpp similarity index 65% rename from maclibs/include/opencc/DartsDict.hpp rename to winlibs/include/opencc/MarisaDict.hpp index 609486db..ef20121b 100644 --- a/maclibs/include/opencc/DartsDict.hpp +++ b/winlibs/include/opencc/MarisaDict.hpp @@ -1,7 +1,7 @@ /* * Open Chinese Convert * - * Copyright 2010-2014 BYVoid + * Copyright 2020 BYVoid * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,12 +23,12 @@ namespace opencc { /** -* Darts dictionary -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT DartsDict : public Dict, public SerializableDict { + * Darts dictionary + * @ingroup opencc_cpp_api + */ +class OPENCC_EXPORT MarisaDict : public Dict, public SerializableDict { public: - virtual ~DartsDict(); + virtual ~MarisaDict(); virtual size_t KeyMaxLength() const; @@ -36,24 +36,26 @@ public: virtual Optional MatchPrefix(const char* word) const; + virtual vector MatchAllPrefixes(const char* word) const; + virtual LexiconPtr GetLexicon() const; virtual void SerializeToFile(FILE* fp) const; /** - * Constructs a DartsDict from another dictionary. - */ - static DartsDictPtr NewFromDict(const Dict& thatDict); + * Constructs a MarisaDict from another dictionary. + */ + static MarisaDictPtr NewFromDict(const Dict& thatDict); - static DartsDictPtr NewFromFile(FILE* fp); + static MarisaDictPtr NewFromFile(FILE* fp); private: - DartsDict(); + MarisaDict(); size_t maxLength; LexiconPtr lexicon; - class DartsInternal; - DartsInternal* internal; + class MarisaInternal; + std::unique_ptr internal; }; -} +} // namespace opencc diff --git a/winlibs/include/opencc/PhraseExtract.hpp b/winlibs/include/opencc/PhraseExtract.hpp new file mode 100644 index 00000000..5397c863 --- /dev/null +++ b/winlibs/include/opencc/PhraseExtract.hpp @@ -0,0 +1,191 @@ +/* + * Open Chinese Convert + * + * Copyright 2015 BYVoid + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include + +#include "Common.hpp" +#include "UTF8StringSlice.hpp" + +namespace opencc { + +class OPENCC_EXPORT PhraseExtract { +public: + typedef UTF8StringSlice::LengthType LengthType; + + typedef UTF8StringSliceBase UTF8StringSlice8Bit; + + PhraseExtract(); + + virtual ~PhraseExtract(); + + void Extract(const string& text) { + SetFullText(text); + ExtractSuffixes(); + CalculateFrequency(); + CalculateSuffixEntropy(); + ReleaseSuffixes(); + ExtractPrefixes(); + CalculatePrefixEntropy(); + ReleasePrefixes(); + ExtractWordCandidates(); + CalculateCohesions(); + SelectWords(); + } + + void SetFullText(const string& fullText) { + utf8FullText = UTF8StringSlice(fullText.c_str()); + } + + void SetFullText(const char* fullText) { + utf8FullText = UTF8StringSlice(fullText); + } + + void SetFullText(const UTF8StringSlice& fullText) { utf8FullText = fullText; } + + void SetWordMinLength(const LengthType _wordMinLength) { + wordMinLength = _wordMinLength; + } + + void SetWordMaxLength(const LengthType _wordMaxLength) { + wordMaxLength = _wordMaxLength; + } + + void SetPrefixSetLength(const LengthType _prefixSetLength) { + prefixSetLength = _prefixSetLength; + } + + void SetSuffixSetLength(const LengthType _suffixSetLength) { + suffixSetLength = _suffixSetLength; + } + + // PreCalculationFilter is called after frequencies statistics. + void SetPreCalculationFilter(const std::function< + bool(const PhraseExtract&, const UTF8StringSlice8Bit&)>& filter) { + preCalculationFilter = filter; + } + + void SetPostCalculationFilter(const std::function< + bool(const PhraseExtract&, const UTF8StringSlice8Bit&)>& filter) { + postCalculationFilter = filter; + } + + void ReleaseSuffixes() { vector().swap(suffixes); } + + void ReleasePrefixes() { vector().swap(prefixes); } + + const vector& Words() const { return words; } + + const vector& WordCandidates() const { + return wordCandidates; + } + + struct Signals { + size_t frequency; + double cohesion; + double suffixEntropy; + double prefixEntropy; + }; + + const Signals& Signal(const UTF8StringSlice8Bit& wordCandidate) const; + + double Cohesion(const UTF8StringSlice8Bit& wordCandidate) const; + + double Entropy(const UTF8StringSlice8Bit& wordCandidate) const; + + double SuffixEntropy(const UTF8StringSlice8Bit& wordCandidate) const; + + double PrefixEntropy(const UTF8StringSlice8Bit& wordCandidate) const; + + size_t Frequency(const UTF8StringSlice8Bit& word) const; + + double Probability(const UTF8StringSlice8Bit& word) const; + + double LogProbability(const UTF8StringSlice8Bit& word) const; + + void Reset(); + + void ExtractSuffixes(); + + void ExtractPrefixes(); + + void ExtractWordCandidates(); + + void CalculateFrequency(); + + void CalculateCohesions(); + + void CalculateSuffixEntropy(); + + void CalculatePrefixEntropy(); + + void SelectWords(); + + static bool + DefaultPreCalculationFilter(const PhraseExtract&, + const PhraseExtract::UTF8StringSlice8Bit&); + + static bool + DefaultPostCalculationFilter(const PhraseExtract&, + const PhraseExtract::UTF8StringSlice8Bit&); + +private: + class DictType; + + // Pointwise Mutual Information + double PMI(const UTF8StringSlice8Bit& wordCandidate, + const UTF8StringSlice8Bit& part1, + const UTF8StringSlice8Bit& part2) const; + + double CalculateCohesion(const UTF8StringSlice8Bit& wordCandidate) const; + + double CalculateEntropy(const std::unordered_map< + UTF8StringSlice8Bit, size_t, UTF8StringSlice8Bit::Hasher>& choices) const; + + LengthType wordMinLength; + LengthType wordMaxLength; + LengthType prefixSetLength; + LengthType suffixSetLength; + std::function + preCalculationFilter; + std::function + postCalculationFilter; + + bool prefixesExtracted; + bool suffixesExtracted; + bool frequenciesCalculated; + bool wordCandidatesExtracted; + bool cohesionsCalculated; + bool prefixEntropiesCalculated; + bool suffixEntropiesCalculated; + bool wordsSelected; + + UTF8StringSlice utf8FullText; + size_t totalOccurrence; + double logTotalOccurrence; + vector prefixes; + vector suffixes; + vector wordCandidates; + vector words; + DictType* signals; + + friend class PhraseExtractTest; +}; + +} // namespace opencc diff --git a/maclibs/include/opencc/BinaryDict.hpp b/winlibs/include/opencc/SerializedValues.hpp similarity index 58% rename from maclibs/include/opencc/BinaryDict.hpp rename to winlibs/include/opencc/SerializedValues.hpp index 9d900ced..c75b488f 100644 --- a/maclibs/include/opencc/BinaryDict.hpp +++ b/winlibs/include/opencc/SerializedValues.hpp @@ -1,7 +1,7 @@ /* * Open Chinese Convert * - * Copyright 2010-2014 BYVoid + * Copyright 2020 BYVoid * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,18 +23,18 @@ namespace opencc { /** -* Binary dictionary for faster deserialization -* @ingroup opencc_cpp_api -*/ -class OPENCC_EXPORT BinaryDict : public SerializableDict { + * Binary format for dictionary values serialization. + * @ingroup opencc_cpp_api + */ +class OPENCC_EXPORT SerializedValues : public SerializableDict { public: - BinaryDict(const LexiconPtr& _lexicon) : lexicon(_lexicon) {} + SerializedValues(const LexiconPtr& _lexicon) : lexicon(_lexicon) {} - virtual ~BinaryDict() {} + virtual ~SerializedValues() {} virtual void SerializeToFile(FILE* fp) const; - static BinaryDictPtr NewFromFile(FILE* fp); + static std::shared_ptr NewFromFile(FILE* fp); const LexiconPtr& GetLexicon() const { return lexicon; } @@ -42,12 +42,8 @@ public: private: LexiconPtr lexicon; - string keyBuffer; - string valueBuffer; - void ConstructBuffer(string& keyBuffer, vector& keyOffset, - size_t& keyTotalLength, string& valueBuffer, - vector& valueOffset, - size_t& valueTotalLength) const; + void ConstructBuffer(string* valueBuffer, vector* valueBytes, + uint32_t* valueTotalLength) const; }; -} +} // namespace opencc diff --git a/winlibs/include/opencc/UTF8StringSlice.hpp b/winlibs/include/opencc/UTF8StringSlice.hpp new file mode 100644 index 00000000..96006313 --- /dev/null +++ b/winlibs/include/opencc/UTF8StringSlice.hpp @@ -0,0 +1,244 @@ +/* + * Open Chinese Convert + * + * Copyright 2015 BYVoid + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "Common.hpp" +#include "UTF8Util.hpp" + +namespace opencc { + +namespace internal { + +inline size_t FNVHash(const char* text, const size_t byteLength, + const size_t FNV_prime, const size_t FNV_offset_basis) { + size_t hash = FNV_offset_basis; + for (const char* pstr = text; pstr < text + byteLength; pstr++) { + hash ^= *pstr; + hash *= FNV_prime; + } + return hash; +} + +template size_t FNVHash(const char* text, const size_t byteLength); + +template <> +inline size_t FNVHash<4>(const char* text, const size_t byteLength) { + return FNVHash(text, byteLength, 16777619UL, 2166136261UL); +} + +#if SIZE_MAX == 0xffffffffffffffff +template <> +inline size_t FNVHash<8>(const char* text, const size_t byteLength) { + return FNVHash(text, byteLength, 1099511628211UL, 14695981039346656037UL); +} +#endif + +} // namespace internal + +template class UTF8StringSliceBase { +public: + typedef LENGTH_TYPE LengthType; + + UTF8StringSliceBase(const char* _str) + : str(_str), utf8Length(static_cast(UTF8Util::Length(_str))), + byteLength(static_cast(strlen(_str))) {} + + UTF8StringSliceBase(const char* _str, const LengthType _utf8Length) + : str(_str), utf8Length(_utf8Length) { + CalculateByteLength(); + } + + UTF8StringSliceBase(const char* _str, const LengthType _utf8Length, + const LengthType _byteLength) + : str(_str), utf8Length(_utf8Length), byteLength(_byteLength) { + CalculateByteLength(); + } + + LengthType UTF8Length() const { return utf8Length; } + + LengthType ByteLength() const { return byteLength; } + + UTF8StringSliceBase Left(const LengthType numberOfCharacters) const { + if (numberOfCharacters == UTF8Length()) { + return *this; + } else { + return UTF8StringSliceBase(str, numberOfCharacters); + } + } + + UTF8StringSliceBase Right(const LengthType numberOfCharacters) const { + if (numberOfCharacters == UTF8Length()) { + return *this; + } else { + const char* pstr = str + byteLength; + for (size_t i = 0; i < numberOfCharacters; i++) { + pstr = UTF8Util::PrevChar(pstr); + } + return UTF8StringSliceBase(pstr, numberOfCharacters); + } + } + + UTF8StringSliceBase SubString(const LengthType offset, + const LengthType numberOfCharacters) const { + if (offset == 0) { + return Left(numberOfCharacters); + } else { + const char* pstr = str; + for (size_t i = 0; i < offset; i++) { + pstr = UTF8Util::NextChar(pstr); + } + return UTF8StringSliceBase(pstr, numberOfCharacters); + } + } + + string ToString() const { return string(str, str + byteLength); } + + const char* CString() const { return str; } + + LengthType CommonPrefixLength(const UTF8StringSliceBase& that) const { + if (str == that.str) { + return std::min(utf8Length, that.utf8Length); + } else { + const char* pstr1 = str; + const char* pstr2 = that.str; + for (size_t length = 0; length < utf8Length && length < that.utf8Length; + length++) { + size_t charLen1 = UTF8Util::NextCharLength(pstr1); + size_t charLen2 = UTF8Util::NextCharLength(pstr2); + if (charLen1 != charLen2 || strncmp(pstr1, pstr2, charLen1) != 0) { + return length; + } + pstr1 += charLen1; + pstr2 += charLen2; + } + return 0; + } + } + + void MoveRight() { + if (utf8Length > 0) { + const size_t charLen = UTF8Util::NextCharLength(str); + str += charLen; + utf8Length--; + byteLength -= charLen; + } + } + + void MoveLeft() { + if (utf8Length > 0) { + const size_t charLen = UTF8Util::PrevCharLength(str + byteLength); + utf8Length--; + byteLength -= charLen; + } + } + + int ReverseCompare(const UTF8StringSliceBase& that) const { + const char* pstr1 = str + byteLength; + const char* pstr2 = that.str + that.byteLength; + const size_t length = std::min(utf8Length, that.utf8Length); + for (size_t i = 0; i < length; i++) { + const size_t charLen1 = UTF8Util::PrevCharLength(pstr1); + const size_t charLen2 = UTF8Util::PrevCharLength(pstr2); + pstr1 -= charLen1; + pstr2 -= charLen2; + const int cmp = strncmp(pstr1, pstr2, std::min(charLen1, charLen2)); + if (cmp < 0) { + return -1; + } else if (cmp > 0) { + return 1; + } else if (charLen1 < charLen2) { + return -1; + } else if (charLen1 > charLen2) { + return 1; + } + } + if (utf8Length < that.utf8Length) { + return -1; + } else if (utf8Length > that.utf8Length) { + return 1; + } else { + return 0; + } + } + + LengthType FindBytePosition(const UTF8StringSliceBase& pattern) const { + return static_cast( + ToString().find(pattern.str, 0, pattern.byteLength)); + } + + bool operator<(const UTF8StringSliceBase& that) const { + return Compare(that) < 0; + } + + bool operator>(const UTF8StringSliceBase& that) const { + return Compare(that) > 0; + } + + bool operator==(const UTF8StringSliceBase& that) const { + return (str == that.str && utf8Length == that.utf8Length) || + Compare(that) == 0; + } + + bool operator!=(const UTF8StringSliceBase& that) const { + return !this->operator==(that); + } + + class Hasher { + public: + size_t operator()(const UTF8StringSliceBase& text) const { + return internal::FNVHash(text.CString(), + text.ByteLength()); + } + }; + +private: + inline int Compare(const UTF8StringSliceBase& that) const { + int cmp = strncmp(str, that.str, std::min(byteLength, that.byteLength)); + if (cmp == 0) { + if (utf8Length < that.utf8Length) { + cmp = -1; + } else if (utf8Length > that.utf8Length) { + cmp = 1; + } else { + cmp = 0; + } + } + return cmp; + } + + void CalculateByteLength() { + const char* pstr = str; + for (size_t i = 0; i < utf8Length; i++) { + pstr = UTF8Util::NextChar(pstr); + } + byteLength = static_cast(pstr - str); + } + + const char* str; + LengthType utf8Length; + LengthType byteLength; +}; + +typedef UTF8StringSliceBase UTF8StringSlice; + +template +std::ostream& operator<<(::std::ostream& os, + const UTF8StringSliceBase& str) { + return os << str.ToString(); +} + +} // namespace opencc diff --git a/winlibs/include/stdint_msvc.h b/winlibs/include/stdint_msvc.h deleted file mode 100644 index e89d9687..00000000 --- a/winlibs/include/stdint_msvc.h +++ /dev/null @@ -1,232 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#if (_MSC_VER < 1300) && defined(__cplusplus) - extern "C++" { -#endif -# include -#if (_MSC_VER < 1300) && defined(__cplusplus) - } -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types -typedef __int8 int8_t; -typedef __int16 int16_t; -typedef __int32 int32_t; -typedef __int64 int64_t; -typedef unsigned __int8 uint8_t; -typedef unsigned __int16 uint16_t; -typedef unsigned __int32 uint32_t; -typedef unsigned __int64 uint64_t; - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] \ No newline at end of file diff --git a/winlibs/include/vorbis/codec.h b/winlibs/include/vorbis/codec.h index 999aa335..f8a912bc 100644 --- a/winlibs/include/vorbis/codec.h +++ b/winlibs/include/vorbis/codec.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * ******************************************************************** function: libvorbis codec headers - last mod: $Id: codec.h 17021 2010-03-24 09:29:41Z xiphmont $ ********************************************************************/ diff --git a/winlibs/include/vorbis/vorbisenc.h b/winlibs/include/vorbis/vorbisenc.h new file mode 100644 index 00000000..085b15e6 --- /dev/null +++ b/winlibs/include/vorbis/vorbisenc.h @@ -0,0 +1,435 @@ +/******************************************************************** + * * + * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. * + * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS * + * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE * + * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * + * * + * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 * + * by the Xiph.Org Foundation https://xiph.org/ * + * * + ******************************************************************** + + function: vorbis encode-engine setup + + ********************************************************************/ + +/** \file + * Libvorbisenc is a convenient API for setting up an encoding + * environment using libvorbis. Libvorbisenc encapsulates the + * actions needed to set up the encoder properly. + */ + +#ifndef _OV_ENC_H_ +#define _OV_ENC_H_ + +#ifdef __cplusplus +extern "C" +{ +#endif /* __cplusplus */ + +#include "codec.h" + +/** + * This is the primary function within libvorbisenc for setting up managed + * bitrate modes. + * + * Before this function is called, the \ref vorbis_info + * struct should be initialized by using vorbis_info_init() from the libvorbis + * API. After encoding, vorbis_info_clear() should be called. + * + * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set + * constraints for the encoded file. This function uses these settings to + * select the appropriate encoding mode and set it up. + * + * \param vi Pointer to an initialized \ref vorbis_info struct. + * \param channels The number of channels to be encoded. + * \param rate The sampling rate of the source audio. + * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. + * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. + * \param min_bitrate Desired minimum bitrate. -1 indicates unset. + * + * \return Zero for success, and negative values for failure. + * + * \retval 0 Success. + * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. + * \retval OV_EINVAL Invalid setup request, eg, out of range argument. + * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. + */ +extern int vorbis_encode_init(vorbis_info *vi, + long channels, + long rate, + + long max_bitrate, + long nominal_bitrate, + long min_bitrate); + +/** + * This function performs step-one of a three-step bitrate-managed encode + * setup. It functions similarly to the one-step setup performed by \ref + * vorbis_encode_init but allows an application to make further encode setup + * tweaks using \ref vorbis_encode_ctl before finally calling \ref + * vorbis_encode_setup_init to complete the setup process. + * + * Before this function is called, the \ref vorbis_info struct should be + * initialized by using vorbis_info_init() from the libvorbis API. After + * encoding, vorbis_info_clear() should be called. + * + * The max_bitrate, nominal_bitrate, and min_bitrate settings are used to set + * constraints for the encoded file. This function uses these settings to + * select the appropriate encoding mode and set it up. + * + * \param vi Pointer to an initialized vorbis_info struct. + * \param channels The number of channels to be encoded. + * \param rate The sampling rate of the source audio. + * \param max_bitrate Desired maximum bitrate (limit). -1 indicates unset. + * \param nominal_bitrate Desired average, or central, bitrate. -1 indicates unset. + * \param min_bitrate Desired minimum bitrate. -1 indicates unset. + * + * \return Zero for success, and negative for failure. + * + * \retval 0 Success + * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. + * \retval OV_EINVAL Invalid setup request, eg, out of range argument. + * \retval OV_EIMPL Unimplemented mode; unable to comply with bitrate request. + */ +extern int vorbis_encode_setup_managed(vorbis_info *vi, + long channels, + long rate, + + long max_bitrate, + long nominal_bitrate, + long min_bitrate); + +/** + * This function performs step-one of a three-step variable bitrate + * (quality-based) encode setup. It functions similarly to the one-step setup + * performed by \ref vorbis_encode_init_vbr() but allows an application to + * make further encode setup tweaks using \ref vorbis_encode_ctl() before + * finally calling \ref vorbis_encode_setup_init to complete the setup + * process. + * + * Before this function is called, the \ref vorbis_info struct should be + * initialized by using \ref vorbis_info_init() from the libvorbis API. After + * encoding, vorbis_info_clear() should be called. + * + * \param vi Pointer to an initialized vorbis_info struct. + * \param channels The number of channels to be encoded. + * \param rate The sampling rate of the source audio. + * \param quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). + * + * \return Zero for success, and negative values for failure. + * + * \retval 0 Success + * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. + * \retval OV_EINVAL Invalid setup request, eg, out of range argument. + * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. + */ +extern int vorbis_encode_setup_vbr(vorbis_info *vi, + long channels, + long rate, + + float quality + ); + +/** + * This is the primary function within libvorbisenc for setting up variable + * bitrate ("quality" based) modes. + * + * + * Before this function is called, the vorbis_info struct should be + * initialized by using vorbis_info_init() from the libvorbis API. After + * encoding, vorbis_info_clear() should be called. + * + * \param vi Pointer to an initialized vorbis_info struct. + * \param channels The number of channels to be encoded. + * \param rate The sampling rate of the source audio. + * \param base_quality Desired quality level, currently from -0.1 to 1.0 (lo to hi). + * + * + * \return Zero for success, or a negative number for failure. + * + * \retval 0 Success + * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. + * \retval OV_EINVAL Invalid setup request, eg, out of range argument. + * \retval OV_EIMPL Unimplemented mode; unable to comply with quality level request. + */ +extern int vorbis_encode_init_vbr(vorbis_info *vi, + long channels, + long rate, + + float base_quality + ); + +/** + * This function performs the last stage of three-step encoding setup, as + * described in the API overview under managed bitrate modes. + * + * Before this function is called, the \ref vorbis_info struct should be + * initialized by using vorbis_info_init() from the libvorbis API, one of + * \ref vorbis_encode_setup_managed() or \ref vorbis_encode_setup_vbr() called to + * initialize the high-level encoding setup, and \ref vorbis_encode_ctl() + * called if necessary to make encoding setup changes. + * vorbis_encode_setup_init() finalizes the highlevel encoding structure into + * a complete encoding setup after which the application may make no further + * setup changes. + * + * After encoding, vorbis_info_clear() should be called. + * + * \param vi Pointer to an initialized \ref vorbis_info struct. + * + * \return Zero for success, and negative values for failure. + * + * \retval 0 Success. + * \retval OV_EFAULT Internal logic fault; indicates a bug or heap/stack corruption. + * + * \retval OV_EINVAL Attempt to use vorbis_encode_setup_init() without first + * calling one of vorbis_encode_setup_managed() or vorbis_encode_setup_vbr() to + * initialize the high-level encoding setup + * + */ +extern int vorbis_encode_setup_init(vorbis_info *vi); + +/** + * This function implements a generic interface to miscellaneous encoder + * settings similar to the classic UNIX 'ioctl()' system call. Applications + * may use vorbis_encode_ctl() to query or set bitrate management or quality + * mode details by using one of several \e request arguments detailed below. + * vorbis_encode_ctl() must be called after one of + * vorbis_encode_setup_managed() or vorbis_encode_setup_vbr(). When used + * to modify settings, \ref vorbis_encode_ctl() must be called before \ref + * vorbis_encode_setup_init(). + * + * \param vi Pointer to an initialized vorbis_info struct. + * + * \param number Specifies the desired action; See \ref encctlcodes "the list + * of available requests". + * + * \param arg void * pointing to a data structure matching the request + * argument. + * + * \retval 0 Success. Any further return information (such as the result of a + * query) is placed into the storage pointed to by *arg. + * + * \retval OV_EINVAL Invalid argument, or an attempt to modify a setting after + * calling vorbis_encode_setup_init(). + * + * \retval OV_EIMPL Unimplemented or unknown request + */ +extern int vorbis_encode_ctl(vorbis_info *vi,int number,void *arg); + +/** + * \deprecated This is a deprecated interface. Please use vorbis_encode_ctl() + * with the \ref ovectl_ratemanage2_arg struct and \ref + * OV_ECTL_RATEMANAGE2_GET and \ref OV_ECTL_RATEMANAGE2_SET calls in new code. + * + * The \ref ovectl_ratemanage_arg structure is used with vorbis_encode_ctl() + * and the \ref OV_ECTL_RATEMANAGE_GET, \ref OV_ECTL_RATEMANAGE_SET, \ref + * OV_ECTL_RATEMANAGE_AVG, \ref OV_ECTL_RATEMANAGE_HARD calls in order to + * query and modify specifics of the encoder's bitrate management + * configuration. +*/ +struct ovectl_ratemanage_arg { + int management_active; /**< nonzero if bitrate management is active*/ +/** hard lower limit (in kilobits per second) below which the stream bitrate + will never be allowed for any given bitrate_hard_window seconds of time.*/ + long bitrate_hard_min; +/** hard upper limit (in kilobits per second) above which the stream bitrate + will never be allowed for any given bitrate_hard_window seconds of time.*/ + long bitrate_hard_max; +/** the window period (in seconds) used to regulate the hard bitrate minimum + and maximum*/ + double bitrate_hard_window; +/** soft lower limit (in kilobits per second) below which the average bitrate + tracker will start nudging the bitrate higher.*/ + long bitrate_av_lo; +/** soft upper limit (in kilobits per second) above which the average bitrate + tracker will start nudging the bitrate lower.*/ + long bitrate_av_hi; +/** the window period (in seconds) used to regulate the average bitrate + minimum and maximum.*/ + double bitrate_av_window; +/** Regulates the relative centering of the average and hard windows; in + libvorbis 1.0 and 1.0.1, the hard window regulation overlapped but + followed the average window regulation. In libvorbis 1.1 a bit-reservoir + interface replaces the old windowing interface; the older windowing + interface is simulated and this field has no effect.*/ + double bitrate_av_window_center; +}; + +/** + * \name struct ovectl_ratemanage2_arg + * + * The ovectl_ratemanage2_arg structure is used with vorbis_encode_ctl() and + * the OV_ECTL_RATEMANAGE2_GET and OV_ECTL_RATEMANAGE2_SET calls in order to + * query and modify specifics of the encoder's bitrate management + * configuration. + * +*/ +struct ovectl_ratemanage2_arg { + int management_active; /**< nonzero if bitrate management is active */ +/** Lower allowed bitrate limit in kilobits per second */ + long bitrate_limit_min_kbps; +/** Upper allowed bitrate limit in kilobits per second */ + long bitrate_limit_max_kbps; + long bitrate_limit_reservoir_bits; /**struct ovectl_ratemanage2_arg * + * + * Used to query the current encoder bitrate management setting. Also used to + * initialize fields of an ovectl_ratemanage2_arg structure for use with + * \ref OV_ECTL_RATEMANAGE2_SET. + */ +#define OV_ECTL_RATEMANAGE2_GET 0x14 + +/** + * Set the current encoder bitrate management settings. + * + * Argument: struct ovectl_ratemanage2_arg * + * + * Used to set the current encoder bitrate management settings to the values + * listed in the ovectl_ratemanage2_arg. Passing a NULL pointer will disable + * bitrate management. +*/ +#define OV_ECTL_RATEMANAGE2_SET 0x15 + +/** + * Returns the current encoder hard-lowpass setting (kHz) in the double + * pointed to by arg. + * + * Argument: double * +*/ +#define OV_ECTL_LOWPASS_GET 0x20 + +/** + * Sets the encoder hard-lowpass to the value (kHz) pointed to by arg. Valid + * lowpass settings range from 2 to 99. + * + * Argument: double * +*/ +#define OV_ECTL_LOWPASS_SET 0x21 + +/** + * Returns the current encoder impulse block setting in the double pointed + * to by arg. + * + * Argument: double * +*/ +#define OV_ECTL_IBLOCK_GET 0x30 + +/** + * Sets the impulse block bias to the the value pointed to by arg. + * + * Argument: double * + * + * Valid range is -15.0 to 0.0 [default]. A negative impulse block bias will + * direct to encoder to use more bits when incoding short blocks that contain + * strong impulses, thus improving the accuracy of impulse encoding. + */ +#define OV_ECTL_IBLOCK_SET 0x31 + +/** + * Returns the current encoder coupling setting in the int pointed + * to by arg. + * + * Argument: int * +*/ +#define OV_ECTL_COUPLING_GET 0x40 + +/** + * Enables/disables channel coupling in multichannel encoding according to arg. + * + * Argument: int * + * + * Zero disables channel coupling for multichannel inputs, nonzer enables + * channel coupling. Setting has no effect on monophonic encoding or + * multichannel counts that do not offer coupling. At present, coupling is + * available for stereo and 5.1 encoding. + */ +#define OV_ECTL_COUPLING_SET 0x41 + + /* deprecated rate management supported only for compatibility */ + +/** + * Old interface to querying bitrate management settings. + * + * Deprecated after move to bit-reservoir style management in 1.1 rendered + * this interface partially obsolete. + + * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_GET instead. + * + * Argument: struct ovectl_ratemanage_arg * + */ +#define OV_ECTL_RATEMANAGE_GET 0x10 +/** + * Old interface to modifying bitrate management settings. + * + * deprecated after move to bit-reservoir style management in 1.1 rendered + * this interface partially obsolete. + * + * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. + * + * Argument: struct ovectl_ratemanage_arg * + */ +#define OV_ECTL_RATEMANAGE_SET 0x11 +/** + * Old interface to setting average-bitrate encoding mode. + * + * Deprecated after move to bit-reservoir style management in 1.1 rendered + * this interface partially obsolete. + * + * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. + * + * Argument: struct ovectl_ratemanage_arg * + */ +#define OV_ECTL_RATEMANAGE_AVG 0x12 +/** + * Old interface to setting bounded-bitrate encoding modes. + * + * deprecated after move to bit-reservoir style management in 1.1 rendered + * this interface partially obsolete. + * + * \deprecated Please use \ref OV_ECTL_RATEMANAGE2_SET instead. + * + * Argument: struct ovectl_ratemanage_arg * + */ +#define OV_ECTL_RATEMANAGE_HARD 0x13 + +/*@}*/ + + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif diff --git a/winlibs/include/vorbis/vorbisfile.h b/winlibs/include/vorbis/vorbisfile.h index 9271331e..3d65393f 100644 --- a/winlibs/include/vorbis/vorbisfile.h +++ b/winlibs/include/vorbis/vorbisfile.h @@ -6,12 +6,11 @@ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. * * * * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007 * - * by the Xiph.Org Foundation http://www.xiph.org/ * + * by the Xiph.Org Foundation https://xiph.org/ * * * ******************************************************************** function: stdio-based convenience library for opening/seeking/decoding - last mod: $Id: vorbisfile.h 17182 2010-04-29 03:48:32Z xiphmont $ ********************************************************************/ diff --git a/winlibs/lib/msvc/SDL2.dll b/winlibs/lib/msvc/SDL2.dll new file mode 100644 index 00000000..4654cd7a Binary files /dev/null and b/winlibs/lib/msvc/SDL2.dll differ diff --git a/winlibs/lib/msvc/SDL2.lib b/winlibs/lib/msvc/SDL2.lib new file mode 100644 index 00000000..b22ffb7c Binary files /dev/null and b/winlibs/lib/msvc/SDL2.lib differ diff --git a/winlibs/lib/msvc/ao-4.dll b/winlibs/lib/msvc/ao-4.dll new file mode 100644 index 00000000..fc079e68 Binary files /dev/null and b/winlibs/lib/msvc/ao-4.dll differ diff --git a/winlibs/lib/msvc/ao.lib b/winlibs/lib/msvc/ao.lib index b8594ac7..7334d167 100644 Binary files a/winlibs/lib/msvc/ao.lib and b/winlibs/lib/msvc/ao.lib differ diff --git a/winlibs/lib/msvc/avcodec-58.dll b/winlibs/lib/msvc/avcodec-58.dll index 44f4ade2..39b33dc9 100644 Binary files a/winlibs/lib/msvc/avcodec-58.dll and b/winlibs/lib/msvc/avcodec-58.dll differ diff --git a/winlibs/lib/msvc/avcodec.lib b/winlibs/lib/msvc/avcodec.lib index e5dc2ddd..e6adbf19 100644 Binary files a/winlibs/lib/msvc/avcodec.lib and b/winlibs/lib/msvc/avcodec.lib differ diff --git a/winlibs/lib/msvc/avdevice-58.dll b/winlibs/lib/msvc/avdevice-58.dll index 0346dcb8..31503293 100644 Binary files a/winlibs/lib/msvc/avdevice-58.dll and b/winlibs/lib/msvc/avdevice-58.dll differ diff --git a/winlibs/lib/msvc/avdevice.lib b/winlibs/lib/msvc/avdevice.lib index e32fbe74..bda1d2a2 100644 Binary files a/winlibs/lib/msvc/avdevice.lib and b/winlibs/lib/msvc/avdevice.lib differ diff --git a/winlibs/lib/msvc/avfilter-7.dll b/winlibs/lib/msvc/avfilter-7.dll index c813aa7c..db0db99c 100644 Binary files a/winlibs/lib/msvc/avfilter-7.dll and b/winlibs/lib/msvc/avfilter-7.dll differ diff --git a/winlibs/lib/msvc/avfilter.lib b/winlibs/lib/msvc/avfilter.lib index 6245840a..66c86d45 100644 Binary files a/winlibs/lib/msvc/avfilter.lib and b/winlibs/lib/msvc/avfilter.lib differ diff --git a/winlibs/lib/msvc/avformat-58.dll b/winlibs/lib/msvc/avformat-58.dll index 0d581a5c..4fcba8ad 100644 Binary files a/winlibs/lib/msvc/avformat-58.dll and b/winlibs/lib/msvc/avformat-58.dll differ diff --git a/winlibs/lib/msvc/avformat.lib b/winlibs/lib/msvc/avformat.lib index e30d7abe..a6fcc047 100644 Binary files a/winlibs/lib/msvc/avformat.lib and b/winlibs/lib/msvc/avformat.lib differ diff --git a/winlibs/lib/msvc/avresample-4.dll b/winlibs/lib/msvc/avresample-4.dll new file mode 100644 index 00000000..fc280ede Binary files /dev/null and b/winlibs/lib/msvc/avresample-4.dll differ diff --git a/winlibs/lib/msvc/avresample.lib b/winlibs/lib/msvc/avresample.lib new file mode 100644 index 00000000..13ffb0b0 Binary files /dev/null and b/winlibs/lib/msvc/avresample.lib differ diff --git a/winlibs/lib/msvc/avutil-56.dll b/winlibs/lib/msvc/avutil-56.dll index 5ab15d89..4173591a 100644 Binary files a/winlibs/lib/msvc/avutil-56.dll and b/winlibs/lib/msvc/avutil-56.dll differ diff --git a/winlibs/lib/msvc/avutil.lib b/winlibs/lib/msvc/avutil.lib index ae5b6656..223f0ea0 100644 Binary files a/winlibs/lib/msvc/avutil.lib and b/winlibs/lib/msvc/avutil.lib differ diff --git a/winlibs/lib/msvc/iconv.lib b/winlibs/lib/msvc/iconv.lib deleted file mode 100644 index 93af5fc0..00000000 Binary files a/winlibs/lib/msvc/iconv.lib and /dev/null differ diff --git a/winlibs/lib/msvc/libao-4.dll b/winlibs/lib/msvc/libao-4.dll deleted file mode 100644 index 40a2db32..00000000 Binary files a/winlibs/lib/msvc/libao-4.dll and /dev/null differ diff --git a/winlibs/lib/msvc/libiconv-2.dll b/winlibs/lib/msvc/libiconv-2.dll deleted file mode 100644 index 66ca6fce..00000000 Binary files a/winlibs/lib/msvc/libiconv-2.dll and /dev/null differ diff --git a/winlibs/lib/msvc/libmp3lame.dll b/winlibs/lib/msvc/libmp3lame.dll new file mode 100644 index 00000000..19e8e126 Binary files /dev/null and b/winlibs/lib/msvc/libmp3lame.dll differ diff --git a/winlibs/lib/msvc/libmp3lame.lib b/winlibs/lib/msvc/libmp3lame.lib new file mode 100644 index 00000000..9a3be4dc Binary files /dev/null and b/winlibs/lib/msvc/libmp3lame.lib differ diff --git a/winlibs/lib/msvc/libspeex.dll b/winlibs/lib/msvc/libspeex.dll new file mode 100644 index 00000000..ee2305d4 Binary files /dev/null and b/winlibs/lib/msvc/libspeex.dll differ diff --git a/winlibs/lib/msvc/libspeex.lib b/winlibs/lib/msvc/libspeex.lib new file mode 100644 index 00000000..b5a81b17 Binary files /dev/null and b/winlibs/lib/msvc/libspeex.lib differ diff --git a/winlibs/lib/msvc/libz.a b/winlibs/lib/msvc/libz.a deleted file mode 100644 index 77a348d5..00000000 Binary files a/winlibs/lib/msvc/libz.a and /dev/null differ diff --git a/winlibs/lib/msvc/libz.dll.a b/winlibs/lib/msvc/libz.dll.a deleted file mode 100644 index 0d7516e4..00000000 Binary files a/winlibs/lib/msvc/libz.dll.a and /dev/null differ diff --git a/winlibs/lib/msvc/msys-iconv-2.dll b/winlibs/lib/msvc/msys-iconv-2.dll deleted file mode 100644 index 074485c8..00000000 Binary files a/winlibs/lib/msvc/msys-iconv-2.dll and /dev/null differ diff --git a/winlibs/lib/msvc/ogg.dll b/winlibs/lib/msvc/ogg.dll new file mode 100644 index 00000000..7d9056be Binary files /dev/null and b/winlibs/lib/msvc/ogg.dll differ diff --git a/winlibs/lib/msvc/ogg.lib b/winlibs/lib/msvc/ogg.lib index 1f15cf05..01b10b2c 100644 Binary files a/winlibs/lib/msvc/ogg.lib and b/winlibs/lib/msvc/ogg.lib differ diff --git a/winlibs/lib/msvc/opencc.dll b/winlibs/lib/msvc/opencc.dll index 11f76e25..4bba4f19 100644 Binary files a/winlibs/lib/msvc/opencc.dll and b/winlibs/lib/msvc/opencc.dll differ diff --git a/winlibs/lib/msvc/opencc.lib b/winlibs/lib/msvc/opencc.lib index 4e9c5afa..cc81da44 100644 Binary files a/winlibs/lib/msvc/opencc.lib and b/winlibs/lib/msvc/opencc.lib differ diff --git a/winlibs/lib/msvc/opus.dll b/winlibs/lib/msvc/opus.dll new file mode 100644 index 00000000..e4f0b8bd Binary files /dev/null and b/winlibs/lib/msvc/opus.dll differ diff --git a/winlibs/lib/msvc/opus.lib b/winlibs/lib/msvc/opus.lib index 8ad9a9fa..ad5e7105 100644 Binary files a/winlibs/lib/msvc/opus.lib and b/winlibs/lib/msvc/opus.lib differ diff --git a/winlibs/lib/msvc/postproc-55.dll b/winlibs/lib/msvc/postproc-55.dll index b01b115d..b1615058 100644 Binary files a/winlibs/lib/msvc/postproc-55.dll and b/winlibs/lib/msvc/postproc-55.dll differ diff --git a/winlibs/lib/msvc/postproc.lib b/winlibs/lib/msvc/postproc.lib index 0e2c8fd8..c2f387ef 100644 Binary files a/winlibs/lib/msvc/postproc.lib and b/winlibs/lib/msvc/postproc.lib differ diff --git a/winlibs/lib/msvc/swresample-3.dll b/winlibs/lib/msvc/swresample-3.dll index 908c20c0..4b17088e 100644 Binary files a/winlibs/lib/msvc/swresample-3.dll and b/winlibs/lib/msvc/swresample-3.dll differ diff --git a/winlibs/lib/msvc/swresample.lib b/winlibs/lib/msvc/swresample.lib index 94758b34..80ba71f3 100644 Binary files a/winlibs/lib/msvc/swresample.lib and b/winlibs/lib/msvc/swresample.lib differ diff --git a/winlibs/lib/msvc/swscale-5.dll b/winlibs/lib/msvc/swscale-5.dll index f3da32fb..9b11ffc9 100644 Binary files a/winlibs/lib/msvc/swscale-5.dll and b/winlibs/lib/msvc/swscale-5.dll differ diff --git a/winlibs/lib/msvc/swscale.lib b/winlibs/lib/msvc/swscale.lib index d4562745..53d8a2bc 100644 Binary files a/winlibs/lib/msvc/swscale.lib and b/winlibs/lib/msvc/swscale.lib differ diff --git a/winlibs/lib/msvc/vorbis.dll b/winlibs/lib/msvc/vorbis.dll new file mode 100644 index 00000000..761eead9 Binary files /dev/null and b/winlibs/lib/msvc/vorbis.dll differ diff --git a/winlibs/lib/msvc/vorbis.lib b/winlibs/lib/msvc/vorbis.lib index e3e32a41..f9949e55 100644 Binary files a/winlibs/lib/msvc/vorbis.lib and b/winlibs/lib/msvc/vorbis.lib differ diff --git a/winlibs/lib/msvc/vorbisenc.dll b/winlibs/lib/msvc/vorbisenc.dll new file mode 100644 index 00000000..9c9d9d7a Binary files /dev/null and b/winlibs/lib/msvc/vorbisenc.dll differ diff --git a/winlibs/lib/msvc/vorbisenc.lib b/winlibs/lib/msvc/vorbisenc.lib index 6a1e0c88..c51959b2 100644 Binary files a/winlibs/lib/msvc/vorbisenc.lib and b/winlibs/lib/msvc/vorbisenc.lib differ diff --git a/winlibs/lib/msvc/vorbisfile.dll b/winlibs/lib/msvc/vorbisfile.dll new file mode 100644 index 00000000..34226025 Binary files /dev/null and b/winlibs/lib/msvc/vorbisfile.dll differ diff --git a/winlibs/lib/msvc/vorbisfile.lib b/winlibs/lib/msvc/vorbisfile.lib index f2e8e5d1..102b5cb7 100644 Binary files a/winlibs/lib/msvc/vorbisfile.lib and b/winlibs/lib/msvc/vorbisfile.lib differ diff --git a/winlibs/scripts/ffmpeg-configure-mingw32-vs.sh b/winlibs/scripts/ffmpeg-configure-mingw32-vs.sh new file mode 100644 index 00000000..2ca25046 --- /dev/null +++ b/winlibs/scripts/ffmpeg-configure-mingw32-vs.sh @@ -0,0 +1,190 @@ +#!/bin/sh + +./configure \ + --toolchain=msvc \ + --arch=x86_64 \ + --enable-yasm \ + --enable-asm\ + --prefix=$PREFIX \ + --enable-runtime-cpudetect \ + --enable-shared \ + --disable-static \ + --disable-debug \ + --disable-programs \ + --disable-network \ + --disable-avdevice \ + --disable-avfilter \ + --disable-swscale \ + --disable-network \ + --disable-muxers \ + --disable-demuxers \ + --enable-rdft \ + --enable-demuxer=aac \ + --enable-demuxer=ac3 \ + --enable-demuxer=aiff \ + --enable-demuxer=ape \ + --enable-demuxer=asf \ + --enable-demuxer=flac \ + --enable-demuxer=matroska \ + --enable-demuxer=mp3 \ + --enable-demuxer=mpc \ + --enable-demuxer=mov \ + --enable-demuxer=mpc8 \ + --enable-demuxer=ogg \ + --enable-demuxer=tta \ + --enable-demuxer=wav \ + --enable-demuxer=wv \ + --disable-bsfs \ + --disable-filters \ + --disable-parsers \ + --enable-parser=aac \ + --enable-parser=ac3 \ + --enable-parser=mpegaudio \ + --disable-protocols \ + --disable-indevs \ + --disable-outdevs \ + --disable-encoders \ + --disable-decoders \ + --enable-decoder=eightsvx_exp \ + --enable-decoder=eightsvx_fib \ + --enable-decoder=aac \ + --enable-decoder=aac_latm \ + --enable-decoder=ac3 \ + --enable-decoder=adpcm_4xm \ + --enable-decoder=adpcm_adx \ + --enable-decoder=adpcm_afc \ + --enable-decoder=adpcm_ct \ + --enable-decoder=adpcm_ea \ + --enable-decoder=adpcm_ea_maxis_xa \ + --enable-decoder=adpcm_ea_r1 \ + --enable-decoder=adpcm_ea_r2 \ + --enable-decoder=adpcm_ea_r3 \ + --enable-decoder=adpcm_ea_xas \ + --enable-decoder=adpcm_g722 \ + --enable-decoder=adpcm_g726 \ + --enable-decoder=adpcm_ima_amv \ + --enable-decoder=adpcm_ima_apc \ + --enable-decoder=adpcm_ima_dk3 \ + --enable-decoder=adpcm_ima_dk4 \ + --enable-decoder=adpcm_ima_ea_eacs \ + --enable-decoder=adpcm_ima_ea_sead \ + --enable-decoder=adpcm_ima_iss \ + --enable-decoder=adpcm_ima_oki \ + --enable-decoder=adpcm_ima_qt \ + --enable-decoder=adpcm_ima_smjpeg \ + --enable-decoder=adpcm_ima_wav \ + --enable-decoder=adpcm_ima_ws \ + --enable-decoder=adpcm_ms \ + --enable-decoder=adpcm_sbpro_2 \ + --enable-decoder=adpcm_sbpro_3 \ + --enable-decoder=adpcm_sbpro_4 \ + --enable-decoder=adpcm_swf \ + --enable-decoder=adpcm_thp \ + --enable-decoder=adpcm_xa \ + --enable-decoder=adpcm_yamaha \ + --enable-decoder=alac \ + --enable-decoder=amrnb \ + --enable-decoder=libopencore_amrnb \ + --enable-decoder=amrwb \ + --enable-decoder=libopencore_amrwb \ + --enable-decoder=ape \ + --enable-decoder=atrac1 \ + --enable-decoder=atrac3 \ + --enable-decoder=binkaudio_dct \ + --enable-decoder=binkaudio_rdft \ + --enable-decoder=bmv_audio \ + --enable-decoder=comfortnoise \ + --enable-decoder=cook \ + --enable-decoder=dsicinaudio \ + --enable-decoder=dca \ + --enable-decoder=eac3 \ + --enable-decoder=flac \ + --enable-decoder=g723_1 \ + --enable-decoder=g729 \ + --enable-decoder=gsm \ + --enable-decoder=libgsm \ + --enable-decoder=gsm_ms \ + --enable-decoder=libgsm_ms \ + --enable-decoder=iac \ + --enable-decoder=imc \ + --enable-decoder=interplay_dpcm \ + --enable-decoder=mace3 \ + --enable-decoder=mace6 \ + --enable-decoder=mlp \ + --enable-decoder=mp1 \ + --enable-decoder=mp1float \ + --enable-decoder=mp2 \ + --enable-decoder=mp2float \ + --enable-decoder=mp3 \ + --enable-decoder=mp3float \ + --enable-decoder=mp3adu \ + --enable-decoder=mp3adufloat \ + --enable-decoder=mp3on4 \ + --enable-decoder=mp3on4float \ + --enable-decoder=als \ + --enable-decoder=mpc7 \ + --enable-decoder=mpc8 \ + --enable-decoder=nellymoser \ + --enable-decoder=libopus \ + --enable-decoder=paf_audio \ + --enable-decoder=pcm_alaw \ + --enable-decoder=pcm_bluray \ + --enable-decoder=pcm_dvd \ + --enable-decoder=pcm_f32be \ + --enable-decoder=pcm_f32le \ + --enable-decoder=pcm_f64be \ + --enable-decoder=pcm_f64le \ + --enable-decoder=pcm_lxf \ + --enable-decoder=pcm_mulaw \ + --enable-decoder=pcm_s16be \ + --enable-decoder=pcm_s16be_planar \ + --enable-decoder=pcm_s16le \ + --enable-decoder=pcm_s16le_planar \ + --enable-decoder=pcm_s24be \ + --enable-decoder=pcm_s24daud \ + --enable-decoder=pcm_s24le \ + --enable-decoder=pcm_s24le_planar \ + --enable-decoder=pcm_s32be \ + --enable-decoder=pcm_s32le \ + --enable-decoder=pcm_s32le_planar \ + --enable-decoder=pcm_s8 \ + --enable-decoder=pcm_s8_planar \ + --enable-decoder=pcm_u16be \ + --enable-decoder=pcm_u16le \ + --enable-decoder=pcm_u24be \ + --enable-decoder=pcm_u24le \ + --enable-decoder=pcm_u32be \ + --enable-decoder=pcm_u32le \ + --enable-decoder=pcm_u8 \ + --enable-decoder=pcm_zork \ + --enable-decoder=qcelp \ + --enable-decoder=qdm2 \ + --enable-decoder=ra_144 \ + --enable-decoder=ra_288 \ + --enable-decoder=ralf \ + --enable-decoder=roq_dpcm \ + --enable-decoder=s302m \ + --enable-decoder=shorten \ + --enable-decoder=sipr \ + --enable-decoder=smackaud \ + --enable-decoder=sol_dpcm \ + --enable-decoder=sonic \ + --enable-decoder=libspeex \ + --enable-decoder=tak \ + --enable-decoder=truehd \ + --enable-decoder=truespeech \ + --enable-decoder=tta \ + --enable-decoder=twinvq \ + --enable-decoder=vima \ + --enable-decoder=vmdaudio \ + --enable-decoder=vorbis \ + --enable-decoder=ffwavesynth \ + --enable-decoder=wavpack \ + --enable-decoder=ws_snd1 \ + --enable-decoder=wmalossless \ + --enable-decoder=wmapro \ + --enable-decoder=wmav1 \ + --enable-decoder=wmav2 \ + --enable-decoder=wmavoice \ + --enable-decoder=xan_dpcm \ + --enable-libspeex diff --git a/winlibs/scripts/ffmpeg-configure-mingw32.sh b/winlibs/scripts/ffmpeg-configure-mingw32.sh index 55d1cfe5..7e351866 100644 --- a/winlibs/scripts/ffmpeg-configure-mingw32.sh +++ b/winlibs/scripts/ffmpeg-configure-mingw32.sh @@ -2,8 +2,6 @@ ./configure \ --prefix=$PREFIX \ - --build-suffix=-gd \ - --enable-memalign-hack \ --enable-runtime-cpudetect \ --enable-shared \ --disable-static \ @@ -185,4 +183,4 @@ --enable-decoder=wmav2 \ --enable-decoder=wmavoice \ --enable-decoder=xan_dpcm \ - --enable-libspeex + --enable-libspeex diff --git a/wstring.cc b/wstring.cc deleted file mode 100644 index d823b343..00000000 --- a/wstring.cc +++ /dev/null @@ -1,19 +0,0 @@ -#ifdef __WIN32 - -#include "wstring.hh" -#include "iconv.hh" -#include -#include - -namespace gd -{ - wstring __nativeToWs( wchar_t const * str ) - { - QString qStr=QString::fromWCharArray(str); - return qStr.toStdU32String(); - //return Iconv::toWstring( "WCHAR_T", str, wcslen( str ) * sizeof( wchar_t ) ); - } -} - -#endif - diff --git a/wstring.hh b/wstring.hh index 9741b522..d47d2e6f 100644 --- a/wstring.hh +++ b/wstring.hh @@ -13,12 +13,12 @@ /// all Unicode chars were 2 bytes long. After the Unicode got expanded past /// two-byte representation, the guys at Microsoft had probably decided that /// the least painful way to go is to just switch to UTF-16. Or so's the theory. -/// +/// /// Now, the UTF family is an encoding, made for transit purposes -- is not a /// representation. While it's good for passthrough, it's not directly /// applicable for manipulation on Unicode symbols. It must be decoded first to /// a normal UCS. Think like this: UTF to UCS is something like Base64 to ASCII. -/// +/// /// The distinction between Microsoft platform and all other ones is that while /// the latters are stuck in an 8-bit era and use UTF-8 to pass unicode around /// through its venerable interfaces, the former one is stuck in a 16-bit era, @@ -27,7 +27,7 @@ /// solution is even more ugly than the 8-bit one, because it doesn't have a /// benefit of ASCII compatibility, having a much more useless UCS-2 /// compatibility instead. It's stuck in the middle of nowhere, really. -/// +/// /// The question is, what are we going to do with all this? When we do Unicode /// processing in GoldenDict, we want to use real Unicode characters, not some /// UTF-16 encoded ones. To that end, we have two options under Windows: first, @@ -40,23 +40,14 @@ /// introduce our own gd::wstring and gd::wchar types here. On all systems but /// Windows, they are equivalent to std::wstring and wchar_t. On Windows, they /// are basic_string< unsigned int > and unsigned int. +/// +/// +/// Now we have a better built-in type as char32_t and std::u32string namespace gd { - - #ifdef __WIN32 typedef char32_t wchar; typedef std::u32string wstring; - // GD_NATIVE_TO_WS is used to convert L"" strings to a const pointer to - // wchar. - wstring __nativeToWs( wchar_t const * ); - #define GD_NATIVE_TO_WS( str ) ( gd::__nativeToWs( ( str ) ).c_str() ) - - #else - typedef wchar_t wchar; - typedef std::basic_string wstring; - #define GD_NATIVE_TO_WS( str ) ( str ) - #endif } #endif diff --git a/wstring_qt.cc b/wstring_qt.cc index c7ff8b8d..aa9d9f6a 100644 --- a/wstring_qt.cc +++ b/wstring_qt.cc @@ -3,15 +3,9 @@ namespace gd { - - QString toQString( wstring const & in ) { -#ifdef __WIN32 - return QString::fromUcs4( in.c_str() ); -#else - return QString::fromStdWString(in); -#endif + return QString::fromStdU32String( in ); } wstring toWString( QString const & in ) @@ -34,4 +28,9 @@ namespace gd return gd::toWString( gd::toQString( str ).normalized( QString::NormalizationForm_C ) ); } + std::string toStdString(const QString& str) + { + return str.toStdString(); + } + } diff --git a/wstring_qt.hh b/wstring_qt.hh index 96b6160d..2a46ed9a 100644 --- a/wstring_qt.hh +++ b/wstring_qt.hh @@ -15,6 +15,7 @@ namespace gd QString toQString( wstring const & ); wstring toWString( QString const & ); wstring normalize( wstring const & ); + std::string toStdString(const QString& ); } #endif diff --git a/x64.cc b/x64.cc deleted file mode 100644 index f0f9d7e4..00000000 --- a/x64.cc +++ /dev/null @@ -1,73 +0,0 @@ -#include -#include - -#ifndef _UNICODE -#define _UNICODE -#endif - -#include "x64.hh" -#include -#include - -typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL); -PROCESS_INFORMATION pInfo; - -#ifndef Q_OS_WIN64 -bool isWow64() -{ - static LPFN_ISWOW64PROCESS fnIsWow64Process; - BOOL bIsWow64 = FALSE; - - if( NULL == fnIsWow64Process ) - fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress( GetModuleHandle( _T("kernel32") ), "IsWow64Process" ); - if( NULL != fnIsWow64Process ) - { - if ( !fnIsWow64Process( GetCurrentProcess(), &bIsWow64 ) ) - return false; - } - return bIsWow64; -} -#endif - -bool installx64Hooks() -{ -STARTUPINFO startup; -#ifndef Q_OS_WIN64 - if( !isWow64() ) - return false; -#endif - if( pInfo.hProcess != NULL ) - removex64Hooks(); - QDir dir = QCoreApplication::applicationDirPath(); -#ifdef Q_OS_WIN64 - if( !dir.cd("x86") ) - return false; - QString starterProc = QDir::toNativeSeparators( dir.filePath( "x86helper.exe" ) ); -#else - if( !dir.cd("x64") ) - return false; - QString starterProc = QDir::toNativeSeparators( dir.filePath( "x64helper.exe" ) ); -#endif - - memset( &startup, 0, sizeof(startup) ); - startup.cb = sizeof(startup); - - BOOL b = CreateProcess( starterProc.toStdWString().c_str(), NULL, NULL, NULL, FALSE, CREATE_NO_WINDOW | DETACHED_PROCESS, NULL, NULL, &startup, &pInfo ); - if( !b ) - pInfo.hProcess = NULL; - - return b; -} - -void removex64Hooks() -{ - if( pInfo.hProcess == NULL ) - return; - PostThreadMessage( pInfo.dwThreadId, WM_QUIT, 0, 0 ); - DWORD res = WaitForSingleObject( pInfo.hProcess, 3000 ); - if( res == WAIT_TIMEOUT ) - TerminateProcess( pInfo.hProcess, 1 ); - CloseHandle( pInfo.hProcess ); - CloseHandle( pInfo.hThread ); - pInfo.hProcess = NULL; -} diff --git a/x64.hh b/x64.hh deleted file mode 100644 index f8c223aa..00000000 --- a/x64.hh +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef __X64_HH_INCLUDED__ -#define __X64_HH_INCLUDED__ - -bool isWow64(); -bool installx64Hooks(); -void removex64Hooks(); - -#endif // __X64_HH_INCLUDED__ diff --git a/xdxf.cc b/xdxf.cc index a4cb5ed0..d96720ea 100644 --- a/xdxf.cc +++ b/xdxf.cc @@ -39,7 +39,9 @@ #include #include #include - +#if (QT_VERSION >= QT_VERSION_CHECK(6,0,0)) +#include +#endif #include #include #include @@ -167,10 +169,10 @@ public: vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; virtual QString const& getDescription(); @@ -622,7 +624,7 @@ sptr< Dictionary::DataRequest > XdxfDictionary::getArticle( wstring const & word vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new XdxfArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -686,7 +688,7 @@ class GzippedFile: public QIODevice public: - GzippedFile( char const * fileName ) THROW_SPEC( exCantReadFile ); + GzippedFile( char const * fileName ) ; ~GzippedFile(); @@ -717,7 +719,7 @@ protected: { return -1; } }; -GzippedFile::GzippedFile( char const * fileName ) THROW_SPEC( exCantReadFile ) +GzippedFile::GzippedFile( char const * fileName ) { gz = gd_gzopen( fileName ); if ( !gz ) @@ -839,8 +841,8 @@ QString readElementText( QXmlStreamReader & stream ) void addAllKeyTags( QXmlStreamReader & stream, list< QString > & words ) { - // todo implement support for tag , that overrides the article sorting order - if ( stream.name() == "k" ) + // todo implement support for tag , that overrides the article sorting order + if ( stream.name() == u"k" ) { words.push_back( readElementText( stream ) ); return; @@ -887,12 +889,12 @@ void indexArticle( GzippedFile & gzFile, { ArticleFormat format( Default ); - QStringRef formatValue = stream.attributes().value( "f" ); + QStringView formatValue = stream.attributes().value( "f" ); - if ( formatValue == "v" ) + if ( formatValue == u"v" ) format = Visual; else - if ( formatValue == "l" ) + if ( formatValue == u"l" ) format = Logical; if( format == Default ) format = defaultFormat; @@ -1134,7 +1136,7 @@ void XdxfResourceRequest::run() } sptr< Dictionary::DataRequest > XdxfDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { return new XdxfResourceRequest( *this, name ); } @@ -1146,7 +1148,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; @@ -1225,7 +1227,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( if ( stream.isStartElement() ) { - if ( stream.name() != "xdxf" ) + if ( stream.name() != u"xdxf" ) throw exNotXdxfFile( dictFiles[ 0 ] ); else { @@ -1245,7 +1247,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( idxHeader.langTo = LangCoder::findIdForLanguageCode3( str.c_str() ); - bool isLogical = ( stream.attributes().value( "format" ) == "logical" ); + bool isLogical = ( stream.attributes().value( "format" ) == u"logical" ); QRegExp regNum( "\\d+" ); regNum.indexIn( stream.attributes().value( "revision" ).toString() ); @@ -1262,7 +1264,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( if ( stream.isStartElement() ) { // todo implement using short for denoting the dictionary in settings or dict list toolbar - if ( stream.name() == "full_name" || stream.name() == "full_title" ) + if ( stream.name() == u"full_name" || stream.name() == u"full_title" ) { // That's our name @@ -1288,7 +1290,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } } else - if ( stream.name() == "description" ) + if ( stream.name() == u"description" ) { // todo implement adding other information to the description like <publisher>, <authors>, <file_ver>, <creation_date>, <last_edited_date>, <dict_edition>, <publishing_date>, <dict_src_url> QString desc = readXhtmlData( stream ); @@ -1310,26 +1312,26 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } } else - if ( stream.name() == "abbreviations" ) + if ( stream.name() == u"abbreviations" ) { QString s; string value; list < wstring > keys; - while( !( stream.isEndElement() && stream.name() == "abbreviations" ) && !stream.atEnd() ) + while( !( stream.isEndElement() && stream.name() == u"abbreviations" ) && !stream.atEnd() ) { if( !stream.readNextStartElement() ) break; // abbreviations tag set switch at format revision = 30 if( idxHeader.revisionNumber >= 30 ) { - while ( !( stream.isEndElement() && stream.name() == "abbr_def" ) || !stream.atEnd() ) + while ( !( stream.isEndElement() && stream.name() == u"abbr_def" ) || !stream.atEnd() ) { - if ( stream.isStartElement() && stream.name() == "abbr_k" ) + if ( stream.isStartElement() && stream.name() == u"abbr_k" ) { s = readElementText( stream ); keys.push_back( gd::toWString( s ) ); } - else if ( stream.isStartElement() && stream.name() == "abbr_v" ) + else if ( stream.isStartElement() && stream.name() == u"abbr_v" ) { s = readElementText( stream ); value = Utf8::encode( Folding::trimWhitespace( gd::toWString( s ) ) ); @@ -1339,21 +1341,21 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } keys.clear(); } - else if ( stream.isEndElement() && stream.name() == "abbreviations" ) + else if ( stream.isEndElement() && stream.name() == u"abbreviations" ) break; stream.readNext(); } } else { - while ( !( stream.isEndElement() && stream.name() == "abr_def" ) || !stream.atEnd() ) + while ( !( stream.isEndElement() && stream.name() == u"abr_def" ) || !stream.atEnd() ) { - if ( stream.isStartElement() && stream.name() == "k" ) + if ( stream.isStartElement() && stream.name() == u"k" ) { s = readElementText( stream ); keys.push_back( gd::toWString( s ) ); } - else if ( stream.isStartElement() && stream.name() == "v" ) + else if ( stream.isStartElement() && stream.name() == u"v" ) { s = readElementText( stream ); value = Utf8::encode( Folding::trimWhitespace( gd::toWString( s ) ) ); @@ -1363,7 +1365,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } keys.clear(); } - else if ( stream.isEndElement() && stream.name() == "abbreviations" ) + else if ( stream.isEndElement() && stream.name() == u"abbreviations" ) break; stream.readNext(); } @@ -1371,7 +1373,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( } } else - if ( stream.name() == "ar" ) + if ( stream.name() == u"ar" ) { indexArticle( gzFile, stream, indexedWords, chunks, articleCount, wordCount, isLogical ? Logical : Visual ); diff --git a/xdxf.hh b/xdxf.hh index 880b2b50..c562a56a 100644 --- a/xdxf.hh +++ b/xdxf.hh @@ -16,7 +16,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; } diff --git a/zim.cc b/zim.cc index b1c5d233..e8c07b7c 100644 --- a/zim.cc +++ b/zim.cc @@ -584,10 +584,10 @@ class ZimDictionary: public BtreeIndexing::BtreeDictionary vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; virtual QString const& getDescription(); @@ -758,7 +758,7 @@ string ZimDictionary::convert( const string & in ) { QRegularExpressionMatch match = it.next(); - newText += text.midRef( pos, match.capturedStart() - pos ); + newText += text.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QStringList list = match.capturedTexts(); @@ -775,7 +775,8 @@ string ZimDictionary::convert( const string & in ) if( linksType == UNKNOWN && tag.indexOf( '/' ) >= 0 ) { QString word = QUrl::fromPercentEncoding( tag.toLatin1() ); - word.remove( QRegExp( "\\.(s|)htm(l|)$", Qt::CaseInsensitive ) ). + QRegularExpression htmlRx( "\\.(s|)htm(l|)$", QRegularExpression::CaseInsensitiveOption ); + word.remove( htmlRx ). replace( "_", " " ); vector< WordArticleLink > links; @@ -787,7 +788,7 @@ string ZimDictionary::convert( const string & in ) } else { - word.remove( QRegExp(".*/") ); + word.remove( QRegularExpression(".*/") ); links = findArticles( gd::toWString( word ) ); if( !links.empty() ) { @@ -799,15 +800,15 @@ string ZimDictionary::convert( const string & in ) if( linksType == SLASH || linksType == UNKNOWN ) { - tag.remove( QRegExp( "\\.(s|)htm(l|)$", Qt::CaseInsensitive ) ). + tag.remove( QRegularExpression( "\\.(s|)htm(l|)$", QRegularExpression::PatternOption::CaseInsensitiveOption ) ). replace( "_", "%20" ). prepend( "<a href=\"gdlookup://localhost/" ). append( "\" " + list[4] + ">" ); } else { - tag.remove( QRegExp(".*/") ). - remove( QRegExp( "\\.(s|)htm(l|)$", Qt::CaseInsensitive ) ). + tag.remove( QRegularExpression(".*/") ). + remove( QRegularExpression( "\\.(s|)htm(l|)$", QRegularExpression::PatternOption::CaseInsensitiveOption ) ). replace( "_", "%20" ). prepend( "<a href=\"gdlookup://localhost/" ). append( "\" " + list[4] + ">" ); @@ -817,7 +818,7 @@ string ZimDictionary::convert( const string & in ) } if( pos ) { - newText += text.midRef( pos ); + newText += text.mid( pos ); text = newText; } newText.clear(); @@ -833,7 +834,7 @@ string ZimDictionary::convert( const string & in ) { QRegularExpressionMatch match = it.next(); - newText += text.midRef( pos, match.capturedStart() - pos ); + newText += text.mid( pos, match.capturedStart() - pos ); pos = match.capturedEnd(); QStringList list = match.capturedTexts(); @@ -842,7 +843,7 @@ string ZimDictionary::convert( const string & in ) list.append( QString() ); QString tag = list[2]; - tag.replace( QRegExp( "<br( |)(\\\\|/|)>", Qt::CaseInsensitive ) , "<br/>" ). + tag.replace( QRegularExpression( "<br( |)(\\\\|/|)>", QRegularExpression::PatternOption::CaseInsensitiveOption ) , "<br/>" ). prepend( list[1] ). append( "</a>" ); @@ -850,7 +851,7 @@ string ZimDictionary::convert( const string & in ) } if( pos ) { - newText += text.midRef( pos ); + newText += text.mid( pos ); text = newText; } newText.clear(); @@ -1329,7 +1330,7 @@ sptr< Dictionary::DataRequest > ZimDictionary::getArticle( wstring const & word, vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { return new ZimArticleRequest( word, alts, *this, ignoreDiacritics ); } @@ -1475,7 +1476,7 @@ void ZimResourceRequest::run() } sptr< Dictionary::DataRequest > ZimDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { return new ZimResourceRequest( *this, name ); } @@ -1487,7 +1488,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing & initializing, unsigned maxHeadwordsToExpand ) - THROW_SPEC( std::exception ) + { vector< sptr< Dictionary::Class > > dictionaries; diff --git a/zim.hh b/zim.hh index 4f3b0d6c..93848f6c 100644 --- a/zim.hh +++ b/zim.hh @@ -16,7 +16,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( string const & indicesDir, Dictionary::Initializing &, unsigned maxHeadwordsToExpand ) - THROW_SPEC( std::exception ); + ; } diff --git a/zipfile.cc b/zipfile.cc index 837eb497..04a43b0c 100644 --- a/zipfile.cc +++ b/zipfile.cc @@ -242,11 +242,11 @@ QDateTime SplitZipFile::lastModified() const unsigned long ts = 0; for( QVector< QFile * >::const_iterator i = files.begin(); i != files.end(); ++i ) { - unsigned long t = QFileInfo( (*i)->fileName() ).lastModified().toTime_t(); + unsigned long t = QFileInfo( (*i)->fileName() ).lastModified().toSecsSinceEpoch(); if( t > ts ) ts = t; } - return QDateTime::fromTime_t( ts ); + return QDateTime::fromSecsSinceEpoch( ts ); } qint64 SplitZipFile::calcAbsoluteOffset( qint64 offset, quint16 partNo ) diff --git a/zipsounds.cc b/zipsounds.cc index 11f0b9b2..6448cff1 100644 --- a/zipsounds.cc +++ b/zipsounds.cc @@ -129,10 +129,10 @@ public: vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ); + ; virtual sptr< Dictionary::DataRequest > getResource( string const & name ) - THROW_SPEC( std::exception ); + ; protected: @@ -178,7 +178,7 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getArticle( wstring const & vector< wstring > const & alts, wstring const &, bool ignoreDiacritics ) - THROW_SPEC( std::exception ) + { vector< WordArticleLink > chain = findArticles( word, ignoreDiacritics ); @@ -343,7 +343,7 @@ sptr< Dictionary::DataRequest > ZipSoundsDictionary::getArticle( wstring const & } sptr< Dictionary::DataRequest > ZipSoundsDictionary::getResource( string const & name ) - THROW_SPEC( std::exception ) + { // Remove extension for sound files (like in sound dirs) @@ -410,7 +410,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & initializing ) - THROW_SPEC( std::exception ) + { (void) initializing; vector< sptr< Dictionary::Class > > dictionaries; diff --git a/zipsounds.hh b/zipsounds.hh index bb392a66..d24555f6 100644 --- a/zipsounds.hh +++ b/zipsounds.hh @@ -15,7 +15,7 @@ vector< sptr< Dictionary::Class > > makeDictionaries( vector< string > const & fileNames, string const & indicesDir, Dictionary::Initializing & ) - THROW_SPEC( std::exception ); + ; }