Repository navigation
Fix planar audio conversion; release 0.5.6 - #1
Conversation
Restores the packaging published as @kixelated/libavjs-webcodecs-polyfill@0.5.5, which was never pushed: an ES module build with declarations under dist/. Building this commit reproduces the published dist/ byte for byte. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An interleaved resource is a single plane, but copyTo offset it by planeIndex * numberOfFrames before also stepping to the channel, so every channel after the first read past its frames. Stereo Opus lost its right channel. The same path refused an explicit frameCount equal to the frames left, accepted negative or fractional indices, and threw on a destination view that is not aligned to the sample size. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AudioDecoder concatenated the planes of a planar libav frame but labeled the result with the interleaved format, so AAC's planar float read back as interleaved samples. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Points the package metadata at this fork, where its source lives. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4cb77130f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "files": ["dist"], | ||
| "scripts": { | ||
| "build": "tsc && rollup -c", | ||
| "build": "tsc", |
There was a problem hiding this comment.
Publish a browser-loadable bundle
Changing the build to plain tsc stops producing dist/libavjs-webcodecs-polyfill.js and .min.js, although the checked-in Makefile:1-4, samples/worker-util.js:36, and multiple sample HTML files still load those exact artifacts as classic scripts. After a clean build those URLs therefore 404, and dist/main.js is not a drop-in replacement because it contains ESM imports rather than defining the expected LibAVWebCodecs global; retain the Rollup bundle or update every documented browser-loading flow.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Declining: this fork exists only to publish @kixelated/libavjs-webcodecs-polyfill as an ESM package for @moq/hang, and the published 0.5.5 was already built with plain tsc, so this PR changes nothing for that flow. The UMD Makefile, rollup.config.mjs and samples/ are untouched upstream files that the fork's packaging has never built; they stay as-is to keep the diff from upstream small.
(Written by Claude Opus 5.5)
| "types": "./src/main.ts" | ||
| ".": { | ||
| "types": "./dist/main.d.ts", | ||
| "import": "./dist/main.js" |
There was a problem hiding this comment.
Emit resolvable specifiers in the ESM entry point
For consumers importing this package directly in Node or a native browser module, tsc preserves extensionless source specifiers such as ./encoded-audio-chunk in dist/main.js; standard ESM resolution does not append .js, so loading the exported entry fails on its first relative dependency unless a bundler rewrites it. Publish a bundled ESM file or emit .js-suffixed imports so the declared export is executable without bundler-specific resolution.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in aa38559: relative imports now carry .js and the package declares "type": "module". Confirmed the published 0.5.5 failed import() under Node with ERR_MODULE_NOT_FOUND; the rebuilt dist/main.js now loads under Node and Bun, and moq's js/hang/src/util/libav.test.ts passes against it.
(Written by Claude Opus 5.5)
tsc keeps extensionless relative specifiers, which Node's ESM resolver
refuses, so `import("@kixelated/libavjs-webcodecs-polyfill")` failed
with ERR_MODULE_NOT_FOUND outside Bun or a bundler. Suffix relative
imports with .js and declare "type": "module".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aa38559a78
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "types": "./src/main.ts" | ||
| ".": { | ||
| "types": "./dist/main.d.ts", | ||
| "import": "./dist/main.js" |
There was a problem hiding this comment.
Bundle the remaining bare browser dependency
When dist/main.js is served directly as a native browser module, loading still fails because the emitted graph preserves import '@ungap/global-this' from src/main.ts:37 (and other modules), and browsers cannot resolve that bare package specifier without a consumer-supplied import map. The new .js suffixes fix the relative imports, but this fresh remaining specifier means the advertised unbundled ESM entry is still not browser-loadable; bundle this dependency or publish browser-resolvable imports.
Useful? React with 👍 / 👎.
Fixes the polyfill's planar audio for moq-dev/moq, whose
@moq/hangpatches around both bugs today.@kixelated/libavjs-webcodecs-polyfill. The packaging published as 0.5.5 was never pushed here. Building that commit reproduces the publisheddist/byte for byte.AudioData.copyTofrom interleaved tof32-planar. An interleaved resource is a single plane, butcopyTooffset it byplaneIndex * numberOfFramesbefore stepping to the channel, so every channel after the first read past its frames (NaN). Stereo Opus lost its right channel. The same path refused an explicitframeCountequal to the frames left, accepted negative or fractional indices, and threw on a destination view not aligned to the sample size.AudioDecoderconcatenated a planar libav frame's planes but labeled the resultf32(interleaved), so AAC read back garbled.Testing
The regression tests live in moq (moq-dev/moq#6492,
js/hang/src/util/libav.test.ts): stereo AAC decoded through the polyfill, pluscopyTofromf32ands16interleaved into every plane, frame ranges, an unaligned view, and invalid indices. Both tests fail on 0.5.5 with the moq workarounds removed and pass on this branch's build.To release
After merging:
npm run build && npm publishfrommaster(needs an npm login with publish rights to@kixelated).(Written by Claude Opus 5.5)