1language: c
2cache: ccache
3os:
4  - linux
5  - osx
6dist: bionic
7osx_image: xcode11
8compiler:
9  - clang
10  - gcc
11addons:
12  apt:
13    packages:
14      - cmake
15      - yasm
16      - valgrind
17      - libgstreamer-plugins-base1.0-dev
18      - libgstreamer1.0-dev
19      - llvm
20      - clang
21  homebrew:
22    packages:
23      - ccache
24      - yasm
25notifications:
26  webhooks:
27    - https://coveralls.io/webhook
28env:
29  global: build_type=release
30  matrix:
31    - CMAKE_EFLAGS="-DBUILD_SHARED_LIBS=ON"
32    - CMAKE_EFLAGS="-DBUILD_SHARED_LIBS=OFF"
33stages:
34  - name: style
35  - name: test
36  - name: Coveralls And Valgrind
37    if: type != pull_request
38before_install:
39  - |
40    if [ "$(uname -s)" == "Darwin" ]; then
41      sysctl -n machdep.cpu.brand_string
42      sysctl machdep.cpu.features
43      sysctl machdep.cpu.leaf7_features
44    elif [ -f "/proc/cpuinfo" ]; then
45      grep -Ei " sse*| ssse*| avx|model name" /proc/cpuinfo  | sort -u
46    fi
47  - "sudo chown -R travis: $HOME/.ccache"
48  - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig PATH="/usr/local/opt/ccache/libexec:$PATH"
49  - wget -nc https://raw.githubusercontent.com/OpenVisualCloud/SVT-AV1-Resources/master/video.tar.gz || wget -nc http://randomderp.com/video.tar.gz
50  - tar xf video.tar.gz
51  - mkdir -p $TRAVIS_BUILD_DIR/Build/linux/$build_type
52install:
53  - pip install --user cpp-coveralls
54  - export PATH=/Users/travis/Library/Python/2.7/bin:${PATH}
55  - if [ $TRAVIS_OS_NAME = osx ]; then ulimit -n 512; fi
56  #- if [ $TRAVIS_OS_NAME = osx ]; then brew install --HEAD valgrind; fi
57script:
58  - &base_script |
59    cd $TRAVIS_BUILD_DIR/Build/linux/$build_type
60    cmake $TRAVIS_BUILD_DIR -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=$build_type ${CMAKE_EFLAGS[@]}
61    cmake -j $(if [ $TRAVIS_OS_NAME = osx ]; then sysctl -n hw.ncpu; else nproc; fi) --build . &&
62    sudo cmake --build . --target install && cd $TRAVIS_BUILD_DIR
63  - SvtHevcEncApp -encMode 9 -i akiyo_cif.y4m -b test1.h265 $(if [ "$(uname -s)" == "Darwin" ]; then echo "-asm 0"; fi)
64before_cache:
65  - "sudo chown -R travis: $HOME/.ccache"
66matrix:
67  fast_finish: true
68  allow_failures:
69    - name: Style check
70    - name: Binary Identical?
71    - os: osx
72    - name: Valgrind
73    - env: COVERALLS_PARALLEL=true build_type=debug CMAKE_EFLAGS="-DCOVERAGE=ON"
74  exclude:
75    - os: osx
76      compiler: gcc # gcc = clang in macOS, unecessary duplicate
77  include:
78    # valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./SvtHevcEncApp -help
79    # Coding style check
80    - name: Style check
81      stage: style
82      addons: skip
83      before_install: skip
84      install: skip
85      script:
86        - git grep -InP --heading "\t|\r| $" -- .  && IS_FAIL=true || true
87        - git grep -I -l -z "" -- . | while IFS= read -r -d '' i; do
88          if [ -n "$(tail -c 1 "$i")" ]; then
89          echo "No newline at end of $i";
90          IS_FAIL=true;
91          fi;
92          done
93        - git remote rm upstream 2> /dev/null || true
94        - git remote add upstream https://github.com/OpenVisualCloud/SVT-HEVC.git
95        - git fetch -q upstream master
96        - for i in $(git rev-list HEAD ^upstream/master); do
97          echo "Checking commit message of $i";
98          msg="$(git log --format=%B -n 1 $i)";
99          if [ -n "$(echo "$msg" | awk "NR==2")" ]; then
100          echo "Malformed commit message in $i, second line must be empty";
101          IS_FAIL=true;
102          fi;
103          if echo "$msg" | head -1 | grep -q '\.$'; then
104          echo "Malformed commit message in $i, trailing period in subject line";
105          IS_FAIL=true;
106          fi;
107          done
108        - test -z "$IS_FAIL"
109    # FFmpeg interation build
110    - name: FFmpeg patch
111      stage: test
112      compiler: gcc
113      env: build_type=release
114      script:
115        # Build and install SVT-HEVC
116        - *base_script
117        # Apply SVT-HEVC plugin and enable libsvthevc to FFmpeg
118        - git clone https://github.com/FFmpeg/FFmpeg --branch release/4.4 --depth=1 ffmpeg && cd ffmpeg
119        - git am $TRAVIS_BUILD_DIR/ffmpeg_plugin/n4.4-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch
120        # Patch 2 is doc only
121        #- git am $TRAVIS_BUILD_DIR/ffmpeg_plugin/0002-doc-Add-libsvt_hevc-encoder-docs.patch
122        - export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig
123        - "sudo chown -R travis: $HOME/.ccache"
124        - ./configure --enable-libsvthevc || tail ffbuild/config.log
125        - make --quiet -j$(nproc) && sudo make install
126    # GStreamer interation build
127    - name: GStreamer patch
128      stage: test
129      compiler: gcc
130      env: build_type=release
131      script:
132        # Build and install SVT-HEVC
133        - *base_script
134        # Build GST-SVT-HEVC plugin
135        - cd $TRAVIS_BUILD_DIR/gstreamer-plugin
136        - "sudo chown -R travis: $HOME/.ccache"
137        - cmake .
138        - make --quiet -j$(nproc)
139        - sudo make install
140    # Tests if .h265 files are identical on binary level
141    - name: Binary Identical?
142      stage: test
143      script:
144        - mv -t $HOME akiyo_cif.y4m
145        - *base_script
146        - cd $HOME
147        - travis_wait SvtHevcEncApp -encMode 9 -i akiyo_cif.y4m -n 120 -b test-pr-m9.h265
148        - travis_wait SvtHevcEncApp -encMode 0 -i akiyo_cif.y4m -n 3 -b test-pr-m0.h265
149        - rm -rf $TRAVIS_BUILD_DIR
150        - git clone --depth 1 https://github.com/OpenVisualCloud/SVT-HEVC.git $TRAVIS_BUILD_DIR && cd $TRAVIS_BUILD_DIR
151        - *base_script
152        - mkdir -p $TRAVIS_BUILD_DIR/Build/linux/$build_type
153        - cd $HOME
154        - travis_wait SvtHevcEncApp -encMode 9 -i akiyo_cif.y4m -n 120 -b test-master-m9.h265
155        - travis_wait SvtHevcEncApp -encMode 0 -i akiyo_cif.y4m -n 3 -b test-master-m0.h265
156        - diff test-pr-m9.h265 test-master-m9.h265
157        - diff test-pr-m0.h265 test-master-m0.h265
158    - name: Coveralls Linux+gcc
159      stage: Coveralls And Valgrind
160      os: linux
161      compiler: gcc
162      env: COVERALLS_PARALLEL=true build_type=debug CMAKE_EFLAGS="-DCOVERAGE=ON"
163      script:
164        - *base_script
165        - &coveralls_script |
166          travis_wait SvtHevcEncApp -encMode 9 -i akiyo_cif.y4m -b test1.h265
167          git clone https://github.com/FFmpeg/FFmpeg ffmpeg --depth=1 --branch release/4.4
168          cd ffmpeg
169          git am $TRAVIS_BUILD_DIR/ffmpeg_plugin/n4.4-0001-lavc-svt_hevc-add-libsvt-hevc-encoder-wrapper.patch &&
170          git am $TRAVIS_BUILD_DIR/ffmpeg_plugin/0002-doc-Add-libsvt_hevc-encoder-docs.patch
171          sudo chown -R travis: $HOME/.ccache
172          ./configure --enable-libsvthevc || cat ffbuild/config.log
173          make -s -j$(if [ $TRAVIS_OS_NAME = osx ]; then sysctl -n hw.ncpu; else nproc; fi) >/dev/null &&
174          sudo make install
175          cd $TRAVIS_BUILD_DIR
176          ffmpeg -i akiyo_cif.y4m -c:v libsvt_hevc test.h265
177          travis_wait SvtHevcEncApp -i stdin -w 352 -h 288 -fps 30 -n 150 -b test2.h265 < akiyo_cif.y4m
178      after_script: &after_coveralls_script |
179        if [ $CC = "clang" ] && [ $TRAVIS_OS_NAME = linux ]; then
180          GCOV_FILE=llvm-cov GCOV_OPTIONS='gcov -pl'
181        else
182          GCOV_FILE=gcov GCOV_OPTIONS='\-lp'
183        fi
184        coveralls --root $TRAVIS_BUILD_DIR -i Source -E ".*CMakeFiles.*" -E ".*ffmpeg.*" --gcov $GCOV_FILE --gcov-options "$GCOV_OPTIONS"
185    - name: Coveralls osx+clang
186      stage: Coveralls And Valgrind
187      os: osx
188      compiler: clang
189      env: COVERALLS_PARALLEL=true build_type=debug CMAKE_EFLAGS="-DCOVERAGE=ON"
190      script:
191        - *base_script
192        - *coveralls_script
193      after_script: *after_coveralls_script
194    - name: Valgrind
195      stage: Coveralls And Valgrind
196      compiler: gcc
197      os: linux
198      env: build_type=debug
199      script:
200        - *base_script
201        - travis_wait valgrind -- SvtHevcEncApp -encMode 9 -i akiyo_cif.y4m -n 150 -b test1.h265
202