xiph / opus-tools

A set of tools to encode, inspect, and decode audio in the Opus format.
https://opus-codec.org/
Other
218 stars 79 forks source link

[bug] `opusenc` resampler is 3-4x slower in >= opus-tools-0.2 compared to opus-tools-0.1.10 (big degradation in encoding 8khz audio) #87

Open vadimkantorov opened 10 months ago

vadimkantorov commented 10 months ago

cc @mark4o

Essentially, this is a repro follow-up for:

It first downloads a test.opus file from the part-files attached to this issue, then it prepares a 8khz-sampled test.8000.wav.

Then it runs three versions of opusenc:

  1. stock ubuntu20.04 version opusenc stats: Encoded: 2 hours, 58 minutes, and 10.04 seconds Runtime: 38 seconds (281.3x realtime)
  2. manually built 0.1.10 version (matches the opusenc shipped in ubuntu20.04). Encoded: 2 hours, 58 minutes, and 10.04 seconds Runtime: 38 seconds (281.3x realtime)
  3. manually built 0.2 version along with libopusenc-0.2.1 (other dependencies are used from stock ubuntu20.04 packages, including libopus-1.3.1). opusenc stats: Encoded: 2 hours, 58 minutes, and 10.04 seconds Runtime: 2 minutes and 47 seconds (64.01x realtime)
  4. the old opus-tools-0.1.6: Encoded: 2 hours, 58 minutes, and 10.04 seconds Runtime: 1 minute and 12 seconds (148.5x realtime). This disproves https://github.com/xiph/opus-tools/issues/85, and shows that the problem is opus-tools-0.2 version (and probably same cause in master version), and opus-tools-0.1.10 is faster than opus-tools-0.1.6

The measurements:

name: buildopusenc0.1.10_0.2
on: workflow_dispatch
jobs:
  buildopusenc0.1.10_0.2:
    runs-on: ubuntu-20.04
    steps:
      - name: Build
        run: |
          sudo apt-get update && sudo apt-get install -y git autoconf gcc libtool make xz-utils zip libpcap-dev opus-tools libogg-dev libopus-dev libopusfile-dev libflac-dev
          wget --quiet https://github.com/xiph/opus-tools/files/13588219/test.opus.00.bogus.zip https://github.com/xiph/opus-tools/files/13588222/test.opus.01.bogus.zip https://github.com/xiph/opus-tools/files/13588228/test.opus.02.bogus.zip https://github.com/xiph/opus-tools/files/13588233/test.opus.03.bogus.zip https://github.com/xiph/opus-tools/files/13588240/test.opus.04.bogus.zip https://github.com/xiph/opus-tools/files/13588243/test.opus.05.bogus.zip
          cat *.bogus.zip | opusdec --quiet --rate 8000 - test.8000.wav
          wget --quiet https://archive.mozilla.org/pub/opus/libopusenc-0.2.1.tar.gz https://downloads.xiph.org/releases/opus/opus-tools-0.1.10.tar.gz https://downloads.xiph.org/releases/opus/opus-tools-0.2.tar.gz 
          tar -xf libopusenc-0.2.1.tar.gz
          tar -xf opus-tools-0.1.10.tar.gz
          tar -xf opus-tools-0.2.tar.gz
          cd opus-tools-0.1.10
          bash ./configure --prefix="$PWD/../build0.1.10"
          make install
          cd ../libopusenc-0.2.1
          bash ./configure --prefix="$PWD/../build0.2"
          make install
          cd ../opus-tools-0.2
          LIBOPUSENC_LIBS="-L$PWD/../build0.2/lib -lopusenc" LIBOPUSENC_CFLAGS="-I$PWD/../build0.2/include/opus" bash ./configure --prefix="$PWD/../build0.2"
          make install
          cd ..
          opusenc test.8000.wav test.8000.opus
          rm test.8000.opus && ./build0.1.10/bin/opusenc test.8000.wav test.8000.opus
          rm test.8000.opus && LD_LIBRARY_PATH=./build0.2/lib ./build0.2/bin/opusenc test.8000.wav test.8000.opus
name: buildopusenc0.1.6
on: workflow_dispatch
jobs:
  buildopusenc0.1.6:
    runs-on: ubuntu-20.04
    container: centos:7
    steps:
      - name: Build
        run: |
          yum install -y wget
          wget https://rpmfind.net/linux/epel/7/x86_64/Packages/o/opus-tools-0.1.6-1.el7.x86_64.rpm
          yum localinstall -y opus-tools-0.1.6-1.el7.x86_64.rpm
          wget --quiet https://github.com/xiph/opus-tools/files/13588219/test.opus.00.bogus.zip https://github.com/xiph/opus-tools/files/13588222/test.opus.01.bogus.zip https://github.com/xiph/opus-tools/files/13588228/test.opus.02.bogus.zip https://github.com/xiph/opus-tools/files/13588233/test.opus.03.bogus.zip https://github.com/xiph/opus-tools/files/13588240/test.opus.04.bogus.zip https://github.com/xiph/opus-tools/files/13588243/test.opus.05.bogus.zip
          cat *.bogus.zip | opusdec --quiet --rate 8000 - test.8000.wav
          opusenc test.8000.wav test.8000.opus

test.opus.00.bogus.zip test.opus.01.bogus.zip test.opus.02.bogus.zip test.opus.03.bogus.zip test.opus.04.bogus.zip test.opus.05.bogus.zip