Skip to content

[mpegts] Enlarge H.264 SPS/PPS raw_data buffers to 256 bytes - backport#2087

Merged
CastagnaIT merged 1 commit into
xbmc:Omegafrom
wmdebrito:fix/mpegts-h264-sps-extradata-increase-buffer-backport
Jul 1, 2026
Merged

[mpegts] Enlarge H.264 SPS/PPS raw_data buffers to 256 bytes - backport#2087
CastagnaIT merged 1 commit into
xbmc:Omegafrom
wmdebrito:fix/mpegts-h264-sps-extradata-increase-buffer-backport

Conversation

@wmdebrito

Copy link
Copy Markdown
Contributor

Description

The per-NAL raw_data buffers used to build the codec extra data were only 64 bytes. Some SPS with full VUI/HRD parameters can exceed that (e.g. Wowza-originated HLS), so the SPS was silently dropped (raw_data_size reset to 0) and the H.264 extra data ended up empty.

Kodi then rejects the video stream with "Codec id 27 require extradata" and disables it, leaving an audio-only stream that immediately hits EOF.

Increase the SPS/PPS raw_data buffers to 256 bytes so that for some large SPS extra data is built correctly.

Also extra_data was increase from 512 to 1024 to accommodate rare situations.
NAL buffers are now 256 bytes each, so a single legitimate SPS+PPS can be up to 4+255+4+255 = 518 bytes. With only 512, the guard I added would correctly refuse to overflow — but it would then drop a valid PPS, silently reintroducing a decode failure. 1024 ensures the destination can hold whatever the 256-byte NAL buffers can legitimately produce. The guard prevents the crash; the 1024 prevents truncation.

Motivation and context

Fix some streams that are not playing due to small buffer size.

How has this been tested?

Tested on Kodi 21 with a custom IA build. The falling stream was now able to be played. No regression on other streams

Screenshots (if appropriate):

Stream: https://streamtv.novotempo.com/CDN-TV-PT/smil:tvnovotempo.smil/playlist.m3u8
12:07:59.315 CDVDDemuxClient::RequestStream(): added/updated stream 1001 with codec_id 27
12:07:59.315 CDVDDemuxClient::RequestStream(): added/updated stream 1002 with codec_id 86018
12:07:59.316 Opening stream: 1001 source: 256
12:07:59.932 [WHITELIST] Searching the whitelist for: width: 1280, height: 720, fps: 29.970, 3D: false
12:07:59.979 error: OpenStream: Codec id 27 require extradata.
12:07:59.979 warning: OpenStream - Unsupported stream 1001. Stream disabled.
12:07:59.979 Opening stream: 1002 source: 256
12:08:00.004 CDVDAudioCodecFFmpeg::Open() Successful opened audio decoder aac
12:08:00.034 Process - eof reading from demuxer

Types of change

  • Bug fix (non-breaking change which fixes an issue)
  • Clean up (non-breaking change which removes non-working, unmaintained functionality)
  • Improvement (non-breaking change which improves existing functionality)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that will cause existing functionality to change)
  • Cosmetic change (non-breaking change that doesn't touch code)
  • None of the above (please explain below)

Checklist:

  • I have read the Contributing document
  • My code follows the Code Guidelines of this project
  • My change requires a change to the Wiki documentation
  • I have updated the documentation accordingly

The per-NAL raw_data buffers used to build the codec extra data were only
64 bytes. Some SPS with full VUI/HRD parameters can exceed
that (e.g. Wowza-originated HLS), so the SPS was silently dropped
(raw_data_size reset to 0) and the H.264 extra data ended up empty.

Kodi then rejects the video stream with "Codec id 27 require extradata"
and disables it, leaving an audio-only stream that immediately hits EOF.

Increase the SPS/PPS raw_data buffers to 256 bytes so that for some
large SPS extra data is built correctly.
@kodiai

kodiai Bot commented Jun 30, 2026

Copy link
Copy Markdown

Decision: APPROVE

Issues: none

Evidence:

  • Review prompt covered 3 changed files.
Review Details
  • Review plan: ready hash=e0e0118c5438 route=standard task=review.full files=3 lines=36(local-diff) budget=na/759s gates=3/3 publish=canonical-visible-surface graph=skipped candidates=preferred doctrine=disabled/0/0/0 reasons=disabled

  • Review reducer: ready input=2 kept=2 suppressed=0 rewritten=0 deprioritized=0 lowConfidence=0 auditEvents=0 severityDemoted=0 graphValidated=0 graphUncertain=0 doctrine=disabled/0/0/0 reasons=disabled

  • Review candidates: shadow recorded=2 rejected=0 errors=0 artifact=present repo=xbmc-inputstream.adaptive pr=2087 key=kodiai-review-output:v1:inst-109141824:xbmc-inputstream.adaptive:pr-2087:action- delivery=6a195590-74d4-11f1-8c24-722362dad0bf

  • Review candidate publication: mode=blocked approved=2 rewritten=0 publishable=0 nonPublishable=2 fixBlocked=2 published=0 directFallback=0 reasons=fix-eligibility-blocked movedToDetails=0 detailsOmitted=0 buckets=blocked:2:fix-eligibility-blocked+missing-replacement

  • M072 candidate publication bridge: status=denied; bridgeVersion=candidate-publication-bridge.v1; bridgeId=candidate-publication-record:ff31aff153d7357638917add25790d5d; recordKey=candidate-publication-record:ff31aff153d7357638917add25790d5d; correlationKey=candidate-publication-bridge:866420da7789d43d4a94a2673d3079f6; source=review-handler-publication; candidateRef=candidate-publication-summary-4cf8332d; verification=none; counts=candidateCount:0,evidenceCount:0,verifiedCount:0,partiallyVerifiedCount:0,unverifiedCount:0,disprovenCount:0,publicationEligibleCount:0,malformedRecordCount:0,unsafeInputFieldCount:0; reasons=no-evidence,publication-ineligible; malformed=none; presence=deliveryId:y,reviewOutputKey:y,upstreamCorrelationKey:y,policyCorrelationKey:y; handoffOwner=available; redaction=privateOnly:y,rawPayloads:n,publicationFields:n,evidencePayloads:n,githubCommentBody:n,reducerRawPayload:n,discardedRawPayload:n,discardedPublicationFields:n,discardedEvidencePayloads:n

  • Review finding lifecycle: status=normalized; counts=input:2,recorded:2,rejected:0,unsafeInputFields:0; correlation=repo:y,pull:y,reviewOutputKey:y,deliveryId:y,commit:y; statuses=detected:2,open:2,suggested:0,validated:0,revalidated:0,resolved:0,blocked:0,degraded:0; severity=critical:0,major:1,medium:1,minor:0; actionability=actionable:0,needs-human-review:2,needs-reproduction:0,blocked:0,not-actionable:0; reasons=automatic-detected,automatic-open,automatic-review; rejected=none; redaction=privateOnly:y,rawPrompts:n,rawModelOutput:n,candidateBodies:n,toolPayloads:n,secretLike:n,diffs:n,unboundedArrays:n,unsafeFields:0

  • Review validation truth: status=normalized; counts=detected:2,suggested:0,validated:0,revalidated:0,resolved:0,blocked:0,degraded:0,open:2,uncertain:0,inputFindings:2,unsafeInputFields:0; evidence=fresh:0,stale:0,missingValidation:2,missingRevalidation:2; reasons=validation-missing:2; refs=rfl-c7e9972ade078e46:open:validation-missing:fix:n:validation:n:revalidation:n,rfl-0d5835cb9f3885a8:open:validation-missing:fix:n:validation:n:revalidation:n; correlation=reviewOutputKey:y,deliveryId:y; redaction=privateOnly:y,rawPrompts:n,rawModelOutput:n,candidateBodies:n,replacementText:n,toolPayloads:n,secretLike:n,diffs:n,unboundedArrays:n,unsafeFields:0

  • Files reviewed: 3

  • Findings: 0 critical, 0 major, 0 medium, 0 minor

  • Lines changed: +24 -12

  • Profile: strict (auto, lines changed: 36)

  • Contributor experience: coarse-fallback (using coarse fallback signals only)

  • Shadow specialist: lane=docs-config-truth status=skipped reason=no-operator-truth-paths candidateCount=0 decisionCount=0 decisionCounts=candidate:0,duplicate:0,disagreement:0,dismissed:0,unclassifiable:0 duplicateCount=0 disagreementCount=0 dismissedCount=0 unclassifiableCount=0 truncatedCandidateCount=0 metricAvailability=token:n,cost:n,latency:n visiblePublicationDenied=true approvalPublicationDenied=true privateOnly=true shadowOnly=true redacted=raw:n,publication:n,approval:n,unsafe:0 correlationKey=e58bea72d3b5fabf deliveryId=6a195590-74d4-11f1-8c24-722362d… reviewOutputKey=kodiai-review-output:v1:inst-10…

  • Review completed: 2026-06-30T22:44:47.507Z

  • Total wall-clock: 6m 18s

  • Phase timings:

    • queue wait: 1ms
    • workspace preparation: 914ms
    • retrieval/context assembly: 4.2s
    • executor handoff: 42s
    • remote runtime: 5m 26s
    • publication: 2.5s
  • Tokens: 112 in / 14,788 out | 0.4366

  • Keyword parsing: No keywords detected

  • Budget behavior: complete (within-budget).

  • Prompt budget: 5 sections, 0 trimmed, 0 bypassed, 0 trimmed tokens.

  • Cache behavior: 2 observations, 1 hits, 1 misses, 0 degraded, 0 bypassed.

  • Continuation behavior: 0 observations, 0 compacted, 0 fallback, 0 degraded, 0 bypassed.

@CastagnaIT CastagnaIT added Type: Fix non-breaking change which fixes an issue Type: Backport v21 Omega labels Jul 1, 2026
@CastagnaIT CastagnaIT merged commit 2e6e39e into xbmc:Omega Jul 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Backport Type: Fix non-breaking change which fixes an issue v21 Omega

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants