Skip to content

Refactor audio sample calculation for EAC3#3276

Open
minlinbroadcom wants to merge 1 commit into
androidx:releasefrom
minlinbroadcom:patch-1
Open

Refactor audio sample calculation for EAC3#3276
minlinbroadcom wants to merge 1 commit into
androidx:releasefrom
minlinbroadcom:patch-1

Conversation

@minlinbroadcom

Copy link
Copy Markdown

Calculate the number of audio samples based on frame size and number of frames for EAC3.

Calculate the number of audio samples based on frame size and number of frames for EAC3.
@google-cla

google-cla Bot commented Jun 16, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@FongMi

FongMi commented Jun 21, 2026

Copy link
Copy Markdown

For #3276, the sample count calculation can overcount when an EC-3 sample contains multiple syncframes for different substreams.

In Ac3Util.java, the new code derives numFrames from buffer.remaining() / firstFrameBytes and returns numFrames * samplesPerFrame. However, in ISO BMFF, an E-AC-3 sample may contain multiple syncframes for different substreams or shorter block frames, and those syncframes do not necessarily represent consecutive presentation time. Per ETSI TS 102 366 Annex F, the EC-3 sample duration is still six audio blocks, i.e. 1536 PCM samples.

For example, a sample with two substreams and three audio blocks per syncframe may contain four syncframes. This implementation would return 4 * 768 = 3072, but the correct sample duration is still 1536. I think this should either be reverted or implemented as MP4/EC-3-specific logic, rather than changing a utility method whose contract is to parse one syncframe and relying on buffer.remaining().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants