Skip to content

Fix 14-bit DTS frame size calculation#3330

Open
Tolriq wants to merge 1 commit into
androidx:mainfrom
Tolriq:fix/14-bit-dts-frame-size
Open

Fix 14-bit DTS frame size calculation#3330
Tolriq wants to merge 1 commit into
androidx:mainfrom
Tolriq:fix/14-bit-dts-frame-size

Conversation

@Tolriq

@Tolriq Tolriq commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

ETSI TS 102 114 V1.2.1 section 5.3 defines 14-bit DTS storage as one 14-bit payload word in the least significant bits of each 16-bit word. Convert FSIZE+1 to a whole number of 14-bit words before mapping those words to physical bytes.

The previous fsize * 16 / 14 calculation could produce an impossible odd physical size. For common DTS-CD headers with FSIZE+1 equal to 3585 it returned 4097 bytes, although consecutive sync words are 4096 bytes apart. DtsReader then consumed the first byte of the next sync word and failed to recognize subsequent frames.

Add direct coverage for little- and big-endian 14-bit headers and for an already-exact conversion.

Test: ./gradlew :lib-extractor:testDebugUnitTest --tests androidx.media3.extractor.DtsUtilTest

ETSI TS 102 114 V1.2.1 section 5.3 defines 14-bit DTS storage as one 14-bit payload word in the least significant bits of each 16-bit word. Convert FSIZE+1 to a whole number of 14-bit words before mapping those words to physical bytes.

The previous fsize * 16 / 14 calculation could produce an impossible odd physical size. For common DTS-CD headers with FSIZE+1 equal to 3585 it returned 4097 bytes, although consecutive sync words are 4096 bytes apart. DtsReader then consumed the first byte of the next sync word and failed to recognize subsequent frames.

Add direct coverage for little- and big-endian 14-bit headers and for an already-exact conversion.

Test: ./gradlew :lib-extractor:testDebugUnitTest --tests androidx.media3.extractor.DtsUtilTest
@osscv

osscv commented Jul 11, 2026

Copy link
Copy Markdown

Hi, do u have any test stream?

@Tolriq

Tolriq commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

Not directly usable here as they are dts in wav that is not supported by the current extractors. But since those dtsutils and reader are reusable I supposed the fix still have it's place upstream.

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.

2 participants