From 276e403db6b456399b7049582f9724e6bcd435c1 Mon Sep 17 00:00:00 2001 From: wyapx Date: Tue, 26 Apr 2022 23:51:52 +0800 Subject: [PATCH] Merge to master (#9) * Update python-build-test.yml * Update python-publish.yml * fix: time measure * Update utils.py * Update codec.cpp --- .github/workflows/python-build-test.yml | 3 +-- .github/workflows/python-publish.yml | 5 +++-- src/pysilk/__main__.py | 2 +- src/pysilk/utils.py | 5 ++++- src/silk/codec.cpp | 11 ++++++++--- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.github/workflows/python-build-test.yml b/.github/workflows/python-build-test.yml index 99b0666..cc1fd43 100644 --- a/.github/workflows/python-build-test.yml +++ b/.github/workflows/python-build-test.yml @@ -7,11 +7,10 @@ on: push: branches: [ master ] pull_request: - branches: [ master ] + branches: [ master, dev ] jobs: build: - runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 96a424b..e745aca 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -6,7 +6,7 @@ # separate terms of service, privacy policy, and support # documentation. -name: Upload Python Package +name: Publish to pypi on: release: @@ -17,7 +17,7 @@ jobs: name: Build wheels on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: - fail-fast: false + fail-fast: true matrix: os: [ubuntu-latest, windows-latest, macos-latest] @@ -39,6 +39,7 @@ jobs: with: fetch-depth: 0 # Optional, use if you use setuptools_scm submodules: true # Optional, use if you have submodules + - name: Build SDist run: pipx run build --sdist diff --git a/src/pysilk/__main__.py b/src/pysilk/__main__.py index 0656657..f72e9b9 100644 --- a/src/pysilk/__main__.py +++ b/src/pysilk/__main__.py @@ -48,4 +48,4 @@ def log(*content_args): f.write(decode_file(source, to_wav=args.output == "wav")) else: print("Unknown operation:", i_suffix, "to", o_suffix) - log(f"done, {round(time.time() - st, 2)}ms used") + log(f"done, {round((time.time() - st) * 1000, 2)}ms used") diff --git a/src/pysilk/utils.py b/src/pysilk/utils.py index be23ff6..acdc761 100644 --- a/src/pysilk/utils.py +++ b/src/pysilk/utils.py @@ -4,7 +4,10 @@ def is_silk_data(raw: bytes) -> bool: if len(raw) > 10: - if raw[:10] == b"\x02#!SILK_V3": + offset = 0 + if raw[0] == 2: + offset = 1 + if raw[offset:10] == b"#!SILK_V3": return True return False diff --git a/src/silk/codec.cpp b/src/silk/codec.cpp index 52670bf..e65f483 100644 --- a/src/silk/codec.cpp +++ b/src/silk/codec.cpp @@ -137,8 +137,13 @@ silkDecode(unsigned char *silkData, int dataLen, SKP_SILK_SDK_DecControlStruct DecControl; /* Check Silk header */ - if (strncmp((char *) psRead, "\x02#!SILK_V3", 0x0A) != 0) - goto failed; + if (psRead[0] == 0x02) { + if (strncmp((char *) psRead, "\x02#!SILK_V3", 0x0A) != 0) + goto failed; + } else { + if (strncmp((char *) psRead, "#!SILK_V3", 0x09) != 0) + goto failed; + } psRead += 0x0A; @@ -286,4 +291,4 @@ 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. -***********************************************************************/ \ No newline at end of file +***********************************************************************/