Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Fixes:
- ``FilterContext.link_to`` raises ``ValueError`` when linking filters from different graphs instead of aborting the process.
- Filters added or linked after ``Graph.configure()`` are now configured on the next push or pull instead of segfaulting.
- ``SubtitleCodecContext.decode(None)`` flushes the decoder instead of raising ``RuntimeError``, so delayed decoders such as EIA-608 closed captions return their final subtitle.
- ``AudioFrame.planes`` no longer counts one plane too many for 8-channel planar audio (e.g. ``fltp`` with ``7.1``), which made ``planes``, ``to_ndarray()``, and ``from_ndarray()`` raise ``ValueError``, and no longer reads past the end of ``extended_data`` for more channels. By :gh-user:`ChandraChaan` in (:pr:`2502`).

v19.0.2
-------
Expand Down
3 changes: 2 additions & 1 deletion av/audio/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ def planes(self):

:type: tuple
"""
nb_planes: cython.int = self.layout.nb_channels if self.format.is_planar else 1
plane_count: cython.int = 0
while self.ptr.extended_data[plane_count]:
while plane_count < nb_planes and self.ptr.extended_data[plane_count]:
plane_count += 1

return tuple([AudioPlane(self, i) for i in range(plane_count)])
Expand Down
11 changes: 11 additions & 0 deletions tests/test_audioframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ def test_manual_fltp_stereo_constructor() -> None:
assert frame.samples == 160


def test_manual_fltp_7_1_constructor() -> None:
# With 8 planes, extended_data points at the frame's data[8] array, which
# is not NULL-terminated: the next field is linesize[0].
frame = AudioFrame(format="fltp", layout="7.1", samples=160)
assert len(frame.planes) == 8

array = np.arange(8 * 160, dtype="f4").reshape(8, 160)
frame = AudioFrame.from_ndarray(array, format="fltp", layout="7.1")
assertNdarraysEqual(frame.to_ndarray(), array)


def test_manual_s16_mono_constructor() -> None:
frame = AudioFrame(format="s16", layout="mono", samples=160)
assert frame.format.name == "s16"
Expand Down
Loading