Commit a0b06a0
Implement full AC-3 audio decoder for ATSC broadcasts with WebCodecs (#225)
* Initial plan
* Implement AC-3 audio decoder with comprehensive features
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
* Add comprehensive AC-3 decoder documentation
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
* Implement AC-3 audio decoder for ATSC broadcasts
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
* Implement full AC-3 decoding with WebCodecs AudioDecoder
- Add WebCodecs AudioDecoder integration for native AC-3 decoding
- Implement ITU-R BS.775 compliant multi-channel downmixing (5.1/5.0/3.0 → stereo)
- Add automatic codec detection (tries ac-3, mp4a.a5, mp4a.A5)
- Convert planar audio to interleaved stereo format
- Graceful fallback to placeholder audio when WebCodecs unavailable
- Update tests with WebCodecs mocks (35 tests passing)
- Update documentation with WebCodecs implementation details
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
* Fix PR review comments: code quality improvements
- Fix duplicate await keywords in tests (lines 110, 128, 137)
- Remove unused audioDataQueue field
- Replace dead LFE code with TODO comment
- Add constants for magic numbers (CENTER_SURROUND_GAIN = Math.SQRT1_2)
- Fix error message to remove redundant "Close first"
- Add memory leak protection for partialFrame buffer (64KB limit)
- Add warning to setLanguage method (not yet implemented)
- Fix AudioData copyTo to properly handle multi-channel planar audio
- Fix missing closing backtick in documentation
- Update test count to 35 in documentation
- Remove derived test count from memory file
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
* Update src/decoders/AC3Decoder.ts
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Refactor: extract shared decoder types to separate file
- Create src/decoders/types.ts with shared types (PESHeader, DecoderState, DecoderErrorCallback)
- Update AC3Decoder to import shared types instead of duplicating
- Update ATSCVideoDecoder to import shared types instead of duplicating
- Update index.ts to export shared types from types.ts
- Remove orphaned JSDoc comment about channel configuration constants
- Follow DRY principle and prevent type incompatibility issues
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
* Address PR review feedback: improve logging, error handling, and robustness
- Change console.warn to console.info for informational messages (WebCodecs availability)
- Fix missing await in test for decoder initialization
- Add Math.floor for PTS conversions to make rounding explicit and consistent
- Add defensive checks for divide-by-zero in averageDecodeTime calculations
- Use finally block to ensure AudioData cleanup on all code paths
- Fix comment formatting in types.ts (90 kHz with space)
- Enhance error handling for DOMException to preserve error name/message
- Allow reinitialization from error state
- Improve error message for partial frame buffer overflow (console.error)
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
* Add comprehensive AC-3 decoder unit tests (57 total tests)
- Add WebCodecs fallback tests (unavailable, unsupported codec)
- Add tests for different channel configurations (mono, 3-ch, 4-ch, 5-ch)
- Add tests for different sample rates (32kHz, 44.1kHz, 48kHz)
- Add audio presentation and queueing tests
- Add error condition tests (closed state, invalid PES, corrupted frames)
- Add buffer management tests (overflow protection, partial frame accumulation)
- Add metrics reporting tests (decode time, buffer health)
- Add downmix functionality tests (DRC, zero samples)
- Add state transition tests (flush, reset)
Total: 57 tests passing (previously 35)
Coverage improved but AC3Decoder still has complex untested paths (WebCodecs decode path requires more sophisticated mocks)
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
* Fix PR review comments: documentation accuracy and rounding consistency
- Remove derived test count from documentation (best practice to avoid stale data)
- Update PTS parsing example to use BigInt (match actual implementation)
- Update memory file to reflect WebCodecs implementation (not just parser framework)
- Add Math.floor to duration calculation for consistent integer microsecond values
- Add Math.floor to adjustedPTS calculations (2 locations) for integer 90kHz timestamps
- Remove unused initialState variable in test
- Fix invalid presentAudio test calls (method is private and takes no args)
All 57 tests passing, TypeScript clean, ESLint clean, Prettier formatted, self-review clean
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: alexthemitchell <5687158+alexthemitchell@users.noreply.github.com>
Co-authored-by: Alex Mitchell <alex@alexmitchelltech.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>1 parent 6724e64 commit a0b06a0
File tree
7 files changed
+2616
-30
lines changed- .serena/memories
- docs/reference
- src/decoders
- __tests__
7 files changed
+2616
-30
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
0 commit comments