lavc/pgssub: implement composition object cropping #21109
No reviewers
Labels
No labels
avcodec
avdevice
avfilter
avformat
avutil
backport/release/4.3
backport/release/4.4
backport/release/5.0
backport/release/5.1
backport/release/6.0
backport/release/6.1
backport/release/7.0
backport/release/7.1
backport/release/8.0
backport/release/8.1
backport/release/9.0
backport/release/9.1
CLI
doc
Forgejo Fairy
swresample
swscale
vulkan
API
API major
bug
enhancement
fix/bug
fix/regression
GSoC
GSoC-Qualification
help wanted
important
LGTM
meta
needs backport
needs docs
needs fate test
needs info
needs sample
needs testing
new
question
regression
repro
flaky
repro
no
repro
no(env)
repro
yes
resolution
duplicate
resolution
external
resolution
fixed
resolution
invalid
resolution
wontfix
security
small
No milestone
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
FFmpeg/FFmpeg!21109
Loading…
Reference in a new issue
No description provided.
Delete branch "cubicibo/FFmpeg:MR/pgssub"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This commit brings the lavc PGS decoder to a comparable level to reference implementations.
Test file:
libavcodec/pgssubdec.c:550: transfering ==> transferring to pass lint
858e3426048c420e065e@ -41,0 +39,4 @@#define MAX_EPOCH_OBJECTS 64 // Max 64 allowed per PGS epoch#define MAX_OBJECT_REFS 2 // Max objects per display set#define MAX_OBJECT_WH 4096 // Max object width/heightcosmetic changes should be separate from functional. (2+ commits)
to elaborate here a bit, ideally all indention changes and variable renamings should be in a separet patch from functional changes that makes the changes easier to read
I agree, my sincere apologies. I will not squash everything the next time.
@ -264,0 +299,4 @@/* Decode rle bitmap length, stored size includes width/height data */rle_bitmap_len = bytestream_get_be24(&buf) - 2*2;if (buf_size > rle_bitmap_len) {integer overflow
rle_bitmap_len = 0 - 2*2 becomes a very large number and then the following if() will not detect it as error
I see now this was there before. But probably better if you add a patch fixing this because if i fix it it will just conflict with your patch
8c420e065eb6d93b0659b6d93b0659a947667ebca947667ebcbad7594c4cLLM — combined review of
bad7594c4c.The separation between decoded objects and the displayed plane supports the intended behavior: the supplied signaling sample retains its displayed bitmap during the palette update and changes it on the subsequent redraw. The implementation nevertheless introduces two memory-safety problems that need correction before merging.
Findings
Major — Rejected crop values still reach the cropped copy (
bad7594c4c, libavcodec/pgssubdec.c:672).The invalid-crop branch returns only with
AV_EF_EXPLODE. Otherwise, the rectangle retains the full object dimensions for allocation, while the later copy at line 724 still uses the rejected crop dimensions and offsets. Neither the picture-bounds check nor the bitmap-validity check validates those copy bounds. This permits out-of-bounds reads and writes. Both drafts report ASan confirmation; the allocation and copy paths independently establish the mismatch.Skip the invalid rectangle after the diagnostic in normal mode, preserving the strict-mode error. The correction branch below implements that bounded recovery. — GPT-6-ASTRA code and design reviews.
Major — Cached bitmap validity can outlive its dimensions or a failed decode (
bad7594c4c, libavcodec/pgssubdec.c:199, :329 and :710).Accepting replacement dimensions does not invalidate
bitmap_size. RLE completion and the last-fragment indication are separate conditions, so display can accept an older bitmap size without decoding the replacement. The destination allocation then uses the new dimensions while the full-image copy uses the old size, permitting a heap overwrite when the replacement is smaller.The same validity marker is also set before RLE decoding succeeds. Normal error recovery can therefore export partially decoded pixels mixed with retained pixels. The parent instead makes a failed decode's rectangle empty. Both drafts report sanitizer confirmation of the size mismatch and runtime confirmation of stale-pixel output.
Invalidate
bitmap_sizewhen accepting a replacement and before decoding; publish the current size only after successful decoding. The correction branch implements both changes. — GPT-6-ASTRA code and design reviews.Moderate — Forced-only filtering consults pending references instead of the displayed plane (
bad7594c4c, libavcodec/pgssubdec.c:750).A preparation-only presentation can replace
presentation.objects[]without replacing the displayed bitmap. A subsequent palette update then filters that retained bitmap using unrelated pending flags. I independently confirmed that a retained forced rectangle keepsAV_SUBTITLE_FLAG_FORCEDbut receives a transparent palette after a non-forced preparation; the correction preserves its visible palette. The code-review draft also reports the reverse case exposing a non-forced rectangle.Use
gp_rect->flags & AV_SUBTITLE_FLAG_FORCEDin the palette-export condition, as the correction does. — GPT-6-ASTRA code and design reviews.Moderate — Repeated END packets can lose the previous plane allocation (
bad7594c4c, libavcodec/pgssubdec.c:637 and :716).Rendering leaves
plane.writableset. The duplicate-END guard applies only within one decode call, so a later END packet can render again and overwritegp_rect->data[0]without releasing its allocation. Repetition accumulates leaked bitmaps. Both drafts report LeakSanitizer confirmation.The drafts propose slightly different remedies: releasing the old bitmap before replacement, or consuming the pending redraw. The retained correction uses the latter, taking a local copy of
writableand clearing the stored flag before rendering. This also prevents an export failure from leaving the redraw pending. — GPT-6-ASTRA code and design reviews.Moderate — The additional bitmap copies cause a substantial measured slowdown on the existing sample (
bad7594c4c, libavcodec/pgssubdec.c:199, :716 and :755).The new path stores the decoded object, copies it into the plane, then copies the plane into the independently owned output rectangle. My five interleaved, CPU-pinned arm64 Clang release measurements over 10,000 decodes of
sub/pgs_sub.supgave median process CPU times of 1.029 seconds for the parent and 2.464 seconds for the head, approximately 2.39×, with matching inspected output. Input reading was outside the timing; context/packet allocation and teardown were included.This corroborates the design draft's approximately 2.4× result. That draft additionally reports parent/head times of 0.0553/0.1565 seconds for its solid-object workload and 0.0415/0.0468 seconds for its palette-update workload; I did not independently repeat those two workloads. These are workload-specific costs, not universal playback slowdowns.
Please investigate avoiding the intermediate full-image copy. Immutable reference-counted storage retained by the plane is one option, but merely aliasing the mutable object buffer would undo the signaling fix. The correction branch does not implement this optimization. — GPT-6-ASTRA design review.
Moderate — The single commit still mixes the feature with representation/refactoring changes (
bad7594c4c, libavcodec/pgssubdec.c:52).The history still contains one commit, including changes to existing ID/count field types alongside the functional redesign. Michael's separation request therefore remains applicable. Please separate independently reviewable mechanical changes from the feature. This is not a blanket objection to indentation: the current policy explicitly permits whitespace changes that can be ignored by the diff viewer. — GPT-6-ASTRA code and design reviews.
Minor — Palette-allocation failure leaks an unregistered rectangle (
bad7594c4c, libavcodec/pgssubdec.c:739).av_memdup()allocates the rectangle before palette allocation, but registration insub->rectshappens afterward. If palette allocation fails, the caller'savsubtitle_free()cannot reach that rectangle. Both drafts report allocation-failure testing that confirms the leak.Free the detached structure with
av_free(rect)before returning. Its shallow-copied bitmap still belongs to the plane and must not be freed there. The correction implements this cleanup. — GPT-6-ASTRA code and design reviews.Minor — The binary literal unnecessarily depends on a compiler extension (
bad7594c4c, libavcodec/pgssubdec.c:484).The project specifies C11 and requires compatibility without compiler-specific extensions. Clang rejects this line with
-std=c11 -Werror=gnu-binary-literal; replacing0b10with2passes that check. This confirms the portability concern, but does not establish a failure in a supported default build configuration or explain the historical CI failures. The correction uses the standard integer constant. — GPT-6-ASTRA design review.Minor — The commit message omits the rationale for the new display model (
bad7594c4c, commit message).The message contains only its subject. Please carry the rationale from the PR description into the body: why decoded objects and displayed pixels need separate lifetimes, and how WDS-controlled redraws and palette-only updates resolve the incorrect output. — GPT-6-ASTRA code and design reviews.
Minor — Decode-side regression coverage is missing (
bad7594c4c, tests/fate/subtitles.mak:61).The patch adds no tests, and the inspected PGS-specific FATE entries exercise remuxing rather than these decoder paths. Please add coverage for valid cropping and preparation → palette update → redraw, including forced-only behavior. Expected output belongs under
tests/ref/. New non-security samples can be submitted to[email protected]; this is a coverage request, not a request to publish security reproducers. The existing-decoder change does not trigger the checklist's mandatory coverage rule for new modules. — GPT-6-ASTRA code and design reviews.Proposed corrections: I verified and retained fairy/pr21109-review-fixes, commit a3f53c8cdb09. It addresses findings 1–4, 7 and 8 and is intended to be folded into the revised functional patch. It is a targeted correction, not a complete replacement series: performance, commit organization/rationale and FATE coverage remain outstanding.
Pre-existing issues
Minor — An already-empty plane still emits a subtitle for a no-update display set (
bad7594c4c, libavcodec/pgssubdec.c:607).The empty-plane return precedes the new no-update test. I independently observed empty subtitles at both timestamps for an empty epoch start followed by a preparation-only set. The parent emits the same two outputs, so this is a remaining limitation rather than an introduced regression. Under the supplied rule that partially fixing a bug is not itself an issue, it does not independently block this improvement. A follow-up could track a pending clear separately from plane occupancy; simply swapping the checks would suppress an epoch-start clear without WDS. — GPT-6-ASTRA design review.
Unverified matters
Unverified — The historical CI failure causes cannot be identified from the available logs (
bad7594c4c, CI jobs).Autolabel / Labeler reports “Failing after 12m16s”; Lint / Pre-Commit reports “Failing after 12m12s”. Both supplied log fetches returned HTTP 404 because the logs were cleaned up. There is no evidence supporting a specific cause. Please rerun the jobs to obtain actionable logs. The code-review draft reports that all applicable configured pre-commit file checks passed locally; the design draft reports passing whitespace and configured codespell checks. Those results do not establish why the historical jobs failed. — GPT-6-ASTRA code and design reviews.
Resolved issues
Resolved — The encoded RLE-length subtraction is now guarded (
bad7594c4c, libavcodec/pgssubdec.c:302).The code rejects lengths below four before subtracting the dimension fields, addressing Michael's earlier underflow report. — GPT-6-ASTRA code and design reviews.
Verification
Independent build and functional checks passed for the exercised cases (
bad7594c4cand a3f53c8cdb09).The minimal arm64 decoder build completed. The parent and corrected decoder variants also compiled. The existing PGS sample produced matching inspected subtitle records, dimensions, flags, bitmap hashes and palette-entry summaries across all three variants. The supplied
graphicplane_test.supproduced matching records between the head and correction, including the retained bitmap during palette update and changed bitmap on redraw. The forced-only correction was independently exercised. Both diffs passedgit diff --check. This was not a full FATE run.The drafts report additional sanitizer and sample checks (
bad7594c4cand their proposed corrections).Both report ASan/LSan and allocation-failure checks covering the identified safety and ownership problems, with their corrections passing the targeted cases. The code-review draft additionally reports unchanged cropping-sample dimensions, flags, bitmap checksums and palette summaries after its corrective diff. These are attributed draft results, not additional sanitizer runs by the combiner.
The related cache-retention objection does not apply to this patch (
bad7594c4c, libavcodec/pgssubdec.c:479).This PR retains
flush_cache()for nonzero composition states. The current #23851 discussion confirms that its former cache-retention proposal was replaced with missing-palette recovery. That earlier objection is not a reason to change this PR's cache-flush policy. The staged-plane rationale is useful; the drafts' external implementation/specification comparisons do not establish every normative signaling constraint.Classification
major_issues — The current patch introduces unsafe memory accesses and should not merge unchanged.
Findings 1 and 2 meet the supplied Additional Major issues: “Out of array access” rule and make the decoder worse if merged. They also conflict with the Development Policy requirement that arbitrary input must never cause unsafe behavior. The forced-only regression, measured speed regression and mixed refactoring independently match the supplied moderate criteria. The remaining empty-plane behavior is treated as a pre-existing limitation, and unknown CI causes are not used as evidence of a build failure. The author's previous revisions and the useful signaling improvement are recognized, but the new memory-safety defects still require correction.
bad7594c4c82052957e9lavc/pgssub: Support cropping and display update signalingto lavc/pgssub: implement composition object cropping82052957e9105210b73fSplit the changes in two commits (types, cropping support). Removed the update signaling part as it was the least worthwile change to land and came with unecessary complexity.
The fairy's report was addressed.
LLM — combined follow-up review of
db8e63f3e8and105210b73f.Replies
Reply — The reduced scope and commit split address the earlier organization request (cubicibo, scope clarification).
The type changes are separated in
db8e63f3e8, and105210b73fexplains the cropping change. The displayed-plane state machine is gone. The earlier review should not be read as requiring that removed feature to return. — GPT-6.1-SOL code/design, GLM-5.3 and GROK-4.7 design.Findings
Moderate — Larger source objects bypass the caller’s pixel limit (
105210b73f, libavcodec/pgssubdec.c:305).The fixed 4096-per-side check replaces the presentation-dimension bound without independently checking
avctx->max_pixels. Presentation dimensions still pass throughff_set_dimensions(), but the decoded source can now be larger. This conflicts with the documented maximum accepted pixels per image.I independently reproduced an 8×4 presentation with
max_pixels=32accepting and expanding a 4096×4096 source, then exporting a 1×1 crop. The source bitmap contains 16,777,216 pixels; the ancestor rejects it.Please include
libavutil/imgutils.hand insert this after the existing dimension check, before accepting replacement dimensions:This follows the existing DVB subtitle decoder’s use of the helper. I compiled and exercised it: the low limit prevents source expansion, raising the limit to 16,777,216 permits the crop, and ordinary crops plus the supplied cropping sample retain their inspected output. Strict mode propagates the error; normal recovery leaves an empty rectangle. This is an FFmpeg resource-limit bugfix, not an external workaround. — GPT-6.1-SOL code and design.
Moderate — Eager bitmap caching expands and retains objects that are never displayed (
105210b73f, libavcodec/pgssubdec.c:335).Every completed ODS is decoded immediately, and its bitmap remains alongside compressed RLE until replacement or cache flush. I reproduced 64 completed 1920×1080 objects with a zero-object presentation: the head retained 126.56 MiB of bitmap pixels, with peak RSS about 140,316 KiB, versus 9,704 KiB for the ancestor. This is a resource stress case; its conformance has not been established. The code’s 64 slots and 4096×4096 cap permit 1 GiB of bitmap pixels, before allocator growth and RLE storage. A per-image
max_pixelscheck does not bound this aggregate.The same eager work explains a confirmed performance cost: five alternating, CPU-pinned arm64 runs of 10,000 complete
pgs_sub.supreplays gave median process CPU times of 0.972 s for the ancestor and 1.553 s for the head. That file includes a completed object in an unfinished trailing display set. For only its complete first display set, my medians were 0.964 s and 0.896 s, so I did not reproduce the drafts’ ordinary-display slowdown in this build.Please consider a decoded-cache budget or decoding on demand while retaining reuse benefits. Eviction would need to preserve compressed RLE and arrange re-decoding: simply freeing pixels would make the current
bitmap_sizegate suppress later displays. The drafts’ large animation speedups are a reason to preserve useful caching, not to restore decoding on every display. The immediate pixel-limit correction above can remain small while maintainers decide the cache policy. — GPT-6.1-SOL design; GROK-4.7 design raised the related decode/copy cost.Minor — The PR description still promises the removed signaling changes (#21109, description).
Please remove the claims that display updates now follow bitstream signaling and that mismatched-palette updates are fixed. The title, functional commit message and latest author comment already describe the reduced cropping scope.
graphicplane_test.supremains useful as a fragmented-object compatibility test. — GPT-6.1-SOL code/design and GROK-4.7 design.Pre-existing issues
Minor — Optional crop fields lack a segment-length check (
105210b73f, libavcodec/pgssubdec.c:496).The unchanged parser checks the eight-byte object header, then reads eight optional crop bytes without checking their presence. I reproduced a truncated PCS followed by END in the same packet: the END marker becomes
crop_x=32768. The current bounds checks reject that crop before copying. Targeted ASan/UBSan checks were clean; the demonstrated read stays within following packet data or required input padding, so this is not a demonstrated allocation overread.A small follow-up can insert the following immediately inside the crop-flag branch, before reading
crop_x:I tested this guard: normal mode drops the incomplete reference and emits the usual clearing subtitle when none remain; strict mode returns an error. The supplied cropping output is unchanged. This is pre-existing parser hardening, not a new memory-safety blocker. — GLM-5.3 and GROK-4.7 design.
Unverified or conditional matters
Minor, conditional — Requiring the final-fragment flag changes incomplete-sequence recovery (
105210b73f, libavcodec/pgssubdec.c:335).I confirmed that a complete RLE payload marked
0x80without a subsequent0x40fragment produces an empty rectangle, whereas the ancestor displays it. The code now waits for the explicit last-fragment indication. The drafts report matching libbluray behavior, but a normative requirement was not established here. Is this stricter completion rule intentional? It is not treated as a blocking regression without evidence that a valid or commonly encountered stream requires the former recovery. — GLM-5.3 and GROK-4.7 design.Minor, conditional — The 4096 ceiling and stricter picture bounds need a compatibility basis (
105210b73f, libavcodec/pgssubdec.c:305 and :631).The code rejects larger source dimensions and blanks rectangles crossing the picture boundary, where the ancestor could retain a crossing rectangle or relocate an outside origin. The changes are clear, but the drafts did not establish a conforming counterexample or a normative maximum object dimension. A reference supporting the 4096 ceiling would resolve that uncertainty. Detected malformed-input recovery is an implementation choice under the Development Policy; these observations alone do not establish an avoidable valid-stream regression. — GROK-4.7 design.
Resolved issues
Resolved — The previous unsafe-copy and plane-ownership findings no longer apply (
105210b73f, libavcodec/pgssubdec.c:310, :620 and :647).Invalid crops leave before copying; accepted replacements invalidate bitmap size, which is published only after successful decoding. Removing the graphic plane removes its forced-flag mismatch, repeated-END allocation loss and detached-rectangle failure path. Output rectangles are registered before palette allocation. The RLE-length subtraction remains guarded, binary literals are gone, and the functional commit now explains its purpose. — GPT-6.1-SOL code/design, GLM-5.3 and GROK-4.7 design.
The obsolete
fairy/pr21109-review-fixesbranch, a3f53c8cdb09, is marked for deletion: its corrections are incorporated or unnecessary after this rewrite.Dropped claims
Dropped — “There is no decode-side PGS FATE coverage” (GLM-5.3 and GROK-4.7 design, tests/fate/ffmpeg.mak:81).
fate-sub2video_time_limitedexplicitly enables the PGS decoder and exercises decoded output. It andfate-sub-pgs-remuxpassed independently here, corroborating GPT-6.1-SOL design. The remaining gap is cropping-specific coverage. The existing sub2video/framecrc path is a suitable starting point; use a trimmed SUP sample and references undertests/ref/. New samples can be submitted to[email protected].Dropped — Removing the graphic plane eliminates the performance concern (GLM-5.3,
105210b73f).The short process timings do not resolve the disagreement with the longer repeated benchmarks. Independent measurements confirm extra work for the full existing sample, but do not reproduce a slowdown for its complete first display set. GPT-6.1-SOL design reports approximately 1.64× for that first set; GROK-4.7 design reports approximately 2.16× for the full sample. These are build- and workload-specific results, not universal playback slowdowns. The confirmed eager-work cost is retained above.
Dropped — Nonzero stride on an empty rectangle is itself a bug (GLM-5.3, libavcodec/pgssubdec.c:597).
This pattern is pre-existing, and no violated API requirement or affected consumer was demonstrated. Resetting it would be optional cleanup, not a substantive review finding.
Verification
Verified — Cropping matches an independent reconstruction (
105210b73f, supplied00019.m2ts).My reconstruction matched geometry and bitmap hashes for all 650 rendered rectangles. There are 240 crop-flagged references, of which 238 change the full-object window, reconciling the drafts’ different counts. The pixel-limit and crop-length guards preserve this output. Existing
pgs_sub.supand suppliedgraphicplane_test.supalso matched the ancestor’s inspected geometry and bitmap hashes. This does not claim restored display-signaling functionality.Verified — Targeted builds and tests passed; broader draft tests remain attributed (
105210b73f).The arm64 build, two named FATE tests and
git diff --checkpassed. Targeted decoder/harness ASan/UBSan checks covered the suggested guards and malformed crop case. GPT-6.1-SOL code additionally reports standalone sanitizer builds of both commits and 400 generated crop-oracle cases; GLM-5.3 reports 20,000 mutation iterations and forced-only/palette comparisons. Those broader results were not independently repeated. No full FATE run was performed.Verified — CI failed during sample synchronization, not compilation or a FATE comparison (linux-amd64 shared job).
The job reports “Failing after 8m41s”. Its log shows successful linking, followed by
@ERROR: max connections (30) reached -- try again laterandfate-rsyncerror 5. Please rerun when the sample server has capacity; this log provides no evidence of a decoder build or test-result failure. — All four drafts.Classification
moderate_issues — Cropping is verified, but the caller’s resource limit needs enforcement.
The documented pixel-limit bypass and eager-cache resource cost support the supplied Additional Moderate issues: moderate design issues criterion; the measured eager-work cost is also relevant to its speed-regression criterion. They do not establish a new unsafe access, supported-build failure or significant real-world correctness regression warranting Major. The earlier blockers are resolved, and the author’s substantial simplification supports keeping the next correction focused. Pre-existing parsing behavior, uncertain format constraints and missing crop-specific coverage are non-blocking under the supplied rules on pre-existing issues, partial improvements and repeated revisions, consistent with the Development Policy’s robustness and adequate-testing guidance.
105210b73f6095087856Nonsense. The whole point of the cropping feature is to overlay pieces of objects that are larger than the display size to realise, for example, a scrolling banner. Furthermore, the ancestor implementation was broken and incomplete. Moot point.
BDAV specifications. Maybe you prefer the "ancestor" which could yeet 2 * 65535 * 65535 bytes at the user's face within a single display set?
––––––––
I stand against FFmpeg usage of xAI products. Volunteers submitting patches should have the right to opt-out from AI reviews, or at least from certain AI vendors whose ethics have been shown to be non-existent.
LLM — combined follow-up review of
db8e63f3e8and6095087856.Replies
Reply — Larger-than-presentation objects are necessary for cropping; the caller’s pixel budget is a separate constraint (cubicibo, latest technical reply).
Agreed about scrolling banners. The earlier explanation should have distinguished presentation dimensions from the caller’s independently configured
max_pixels. Supporting a larger source is correct; the remaining resource-limit point below does not propose restoring the ancestor’s presentation-size restriction. Comparisons with that ancestor establish behavior and cost, not format conformance. — GPT-6.1-SOL code/design, GLM-5.3 and GROK-4.7 design.Reply — The ancestor already rejected a 65535×65535 presentation (cubicibo, same reply).
Its
ff_set_dimensions()callsav_image_check_size2(), and its object check rejects dimensions exceeding that presentation. I inspected both ancestor helpers and confirmed that the corresponding size check returnsAVERROR(EINVAL)for 65535×65535. Thus two bitmaps of that size are not an allocation the ancestor accepts through this path. The new explicit limits still provide a useful tighter bound. — GROK-4.7 design.Findings
Minor, non-blocking — The decoded source bitmap still bypasses a lower caller-selected pixel limit (
6095087856, libavcodec/pgssubdec.c:178).The API documents
max_pixelsas the maximum accepted pixels per image, and the option includes subtitle decoding. The new 4 MiB ceiling does not enforce a smaller caller limit.I independently confirmed that
max_pixels=921600accepts a 1280×720 presentation, expands a 1920×1080 source containing 2,073,600 pixels, and exports its 640×360 crop. A focused correction is to includelibavutil/imgutils.h, addint retto the locals indecode_object_rle(), and insert this before bitmap allocation:I compiled and exercised this placement. The lower limit produces an empty rectangle in normal mode and an error with
AV_EF_EXPLODE; raising it to 2,073,600 permits the same crop with the same pixel hash. The existing PGS sample and all 650 supplied-sample rectangles retain their inspected output. Checking here follows the new lazy allocation policy; checking during object parsing, as the other drafts suggest, would additionally reject objects that are never displayed. This is an FFmpeg resource-limit correction, not an external-project workaround. — GPT-6.1-SOL code/design, GLM-5.3 and GROK-4.7 design.Minor, non-blocking — Caching trades additional first-use work and retained memory for substantial reuse savings (
6095087856, libavcodec/pgssubdec.c:653–681).An uncropped object is decoded into the cache and then copied into a separately allocated output bitmap. Five interleaved, CPU-pinned arm64 runs independently gave these median process CPU times, with input preloaded and decoding/context teardown included:
pgs_sub.supThis confirms a first-use cost, about 57% in this build, alongside a large reuse benefit. GPT-6.1-SOL design reports the same tradeoff with different absolute timings. GROK-4.7’s shorter full-sample timings do not refute the isolated first-use result; these are different workloads, not universal playback slowdowns.
Avoiding the extra first-use allocation/copy is a worthwhile follow-up if it preserves reuse and output ownership. The cache also retains previously displayed objects: its pixel payload can reach 256 MiB, excluding allocator overhead and compressed RLE. GLM-5.3 reports approximately 279 MiB resident for its 64-displayed-object stress case. That is a visible design cost, not evidence that normal epochs consume that amount. — GPT-6.1-SOL design; GLM-5.3 for retained-memory measurements; GROK-4.7 design for comparative timings.
Minor, non-blocking — The outstanding cropping test now has a verified small sample candidate (
6095087856, tests/fate/ffmpeg.mak:83).I verified GPT-6.1-SOL design’s extraction command:
It produces 13,185 bytes and eight presentations with widths decreasing from 501 to 471 pixels, without decoder diagnostics. This gives the earlier coverage request a concrete starting point: submit the sample to
[email protected]and use the existing sub2video/framecrc approach with expected output undertests/ref/fate/. Unlike the draft’s estimate of “well under 10 KB,” this verified extraction is slightly larger; it is already trimmed. — GPT-6.1-SOL design, GLM-5.3 and GROK-4.7 design.Unverified or conditional matters
Minor, conditional — The new area ceiling excludes some synthetic UHD-sized objects, but a valid-stream regression is unverified (
6095087856, libavcodec/pgssubdec.c:309).The check necessarily rejects 3840×1200 and 3840×2160 objects because their areas exceed 4,194,304 pixels. GLM-5.3 reports confirming the rejection against ancestor rendering. Neither an affected real stream nor a normative requirement permitting these objects was established. The available Blu-ray Disc Format: 2.B Audio Visual Application Format Specifications for BD-ROM white paper describes the object buffer and crop transform, but does not supply the numerical limits. This uncertainty does not establish a blocking compatibility defect. — GLM-5.3 and GROK-4.7 design.
Minor, conditional — Edge-crossing rectangles remain a format-compatibility question, not a confirmed regression (
6095087856, libavcodec/pgssubdec.c:637–650).The code blanks a rectangle crossing the presentation boundary. GROK-4.7 reports a synthetic ancestor/head difference; GLM-5.3 considers the graphics-plane model supportive of the new check. Neither establishes the normative rule for such a composition. The earlier conditional concern therefore remains unverified and adds no blocking request. — GROK-4.7 design and GLM-5.3.
Resolved issues
Resolved — Lazy decoding and parser hardening address the previous round’s eager-work and crop-field findings (
6095087856, libavcodec/pgssubdec.c:486 and :653).Bitmap expansion now occurs only for a displayed, validated reference. The optional crop fields have a length check, and display no longer requires the final-fragment flag once the declared RLE payload is complete. The description matches the reduced cropping scope. The earlier guarded length subtraction, replacement invalidation, safe crop rejection and removal of graphic-plane ownership problems remain in place. The drafts report targeted checks of these paths; source inspection confirms the relevant changes. — All four drafts.
Dropped claims
Dropped — A UHD graphics plane necessarily requires an object buffer large enough for one full-frame object (GLM-5.3, discussion of libavcodec/pgssubdec.c:309).
That implication does not follow: a graphics plane can contain smaller objects without requiring a single full-frame object. The inspected white paper supplies no UHD buffer requirement. Consequently, the suggested larger constant or presentation-area floor is not a verified necessary fix; recommending either would increase the storage ceiling without an established compatibility requirement. — GLM-5.3.
Dropped — Identity on
pgs_sub.supestablishes that uncropped streams are unaffected (GLM-5.3, sample comparison).It establishes identity for that sample. The inspected bounds changes and independently measured first-use cost prevent extending that result to every uncropped stream or workload. — GLM-5.3.
Verification
Verified — Supplied-sample cropping and the proposed pixel-limit correction preserve the expected pixels (
6095087856).An independent RLE/crop reconstruction matched geometry and bitmap hashes for all 650 rendered rectangles: 240 references carry the crop flag, and 238 change the full-object window. This reconciles the drafts’ counts. The corrected decoder matches the head on all those rectangles, and ancestor/head/correction match on the inspected existing PGS sample.
Verified — Targeted build, FATE and current CI checks pass (
6095087856).The arm64 build,
fate-sub2video_time_limited,fate-sub-pgs-remuxandgit diff --checkpassed independently. The current commit status reports all 11 checks successful, confirming GPT-6.1-SOL design’s report; the earlier sample-synchronization rerun request is resolved.Attributed verification — Broader sanitizer and generated-case results were not independently repeated.
GPT-6.1-SOL code/design report targeted ASan/UBSan/LSan checks; the design draft additionally reports 400 generated crop cases. GLM-5.3 reports 8000 ASan/LSan mutation iterations and targeted malformed-input checks. These supplement the independent functional checks above; they are not a full sanitizer or FATE run by the combiner.
Classification
minor_issues_approve — The cropping improvement is verified, with focused non-blocking follow-ups.
The pixel-budget gap and measured first-use cost would ordinarily engage the supplied Additional Moderate issues criteria for design and speed regressions. Here I apply the explicit instruction to lean toward minor and approve after several rounds of fixes when the PR overall improves things: the earlier unsafe-copy and ownership blockers are resolved, lazy decoding removes the demonstrated eager-work problem, storage has an explicit ceiling, and reuse provides a substantial benefit. No confirmed unsafe access, supported-build failure or significant valid-stream regression remains in these drafts. Cropping-specific coverage and the small resource-limit correction remain worthwhile follow-ups, consistent with the Development Policy’s robustness guidance.
The fate sample file (
00019.m2ts) is 2.3MiB and is completely synthetic. Can you reduce the file size as small as practical or < 100KiB.@pross Sure, here is the raw SUP stream with only the cropping effect.
6095087856d97262798dLLM — combined follow-up review of
87ab7830a5andd97262798d.Replies
Reply — The trimmed attachment satisfies the requested size threshold (cubicibo, sample attachment).
cropping.supis 21,621 bytes, below Peter’s requested 100 KiB threshold. It decodes without diagnostics. My independent RLE-and-crop reconstruction matched placement, dimensions and every bitmap byte for all 119 rectangles, confirming the drafts’ results. — GPT-6.1-SOL code/design and GROK-4.7 design.Findings
Minor, non-blocking — The existing cropping-coverage follow-up now has a verified FATE commit (
d97262798d, tests/fate/ffmpeg.mak:92).I verified and retained fairy/pr21109-cropping-fate, commit 66102f20c8fc, on top of this PR. It adds
fate-sub2video_pgs_cropusing sub2video/framecrc, with expected output undertests/ref/fate/and no sample binary in Git.The test passes on arm64 with the PR decoder and fails with the decoder from the type-only parent,
87ab7830a5: the parent keeps rendering the full object instead of the changing crop. Restoring the PR decoder makes it pass again. The design draft additionally reports the same reference passing on x86-64.For integration, submit the attachment unchanged to
[email protected]assub/pgs-cropping.sup. Its availability as an attachment is sufficient for review; absence from the public sample suite is not a blocker. This fixture covers the horizontal wipe and repeated object reuse, but does not independently cover nonzero crop offsets or changing crop height. — GPT-6.1-SOL code/design.Verification
Verified — Incremental RLE storage preserves the required padding and ownership (
d97262798d, libavcodec/pgssubdec.c:320 and :334).The first-fragment allocation helper clears padding at the logical end even when reusing a larger allocation. Continuations check the remaining declared length, preserve the old pointer on allocation failure, and explicitly clear padding after the appended payload. Accepted replacements invalidate the decoded bitmap; successful decoding publishes its size. Crop and picture checks precede allocation and copying. These source checks support the drafts’ conclusions about the revised fragment handling. — GPT-6.1-SOL code/design and GROK-4.7 design.
Verified — The targeted build, FATE tests and CI checks pass (
d97262798dwith test helper 66102f20c8fc).Independently passed on arm64:
fate-sub2video_pgs_crop,fate-sub2video_time_limitedandfate-sub-pgs-remux. Both the PR diff and helper diff passgit diff --check. The commit status reports all 11 checks successful.The drafts additionally report targeted sanitizer checks covering fragmentation, incomplete data, crop bounds, replacement and cache reuse. Those results remain attributed to their respective drafts; I did not independently repeat sanitizer testing or run the full FATE suite.
Attributed verification — The new sample demonstrates the previously discussed cache tradeoff (
d97262798d, libavcodec/pgssubdec.c:653).GPT-6.1-SOL design reports median process CPU times from five alternating, CPU-pinned arm64 pairs, with input preloaded and context creation/cleanup included: 0.930 s ancestor versus 1.468 s head for 10,000 replays of
pgs_sub.sup, and 3.571 s versus 0.143 s for 1,000 replays of the attached cropping animation. This supports retaining the earlier interpretation: additional first-use work accompanies substantial reuse savings. The attachment’s ancestor/head outputs intentionally differ because the ancestor ignores cropping, so these are workload-specific implementation timings, not equivalent-output or universal playback comparisons. I did not independently repeat these benchmarks. — GPT-6.1-SOL design.Classification
minor_issues_approve — The cropping improvement remains suitable to merge, with a concrete non-blocking test follow-up.
This round establishes no new blocking defect, and the attachment and targeted tests corroborate the intended rendering. The verdict follows the supplied definition permitting approval with non-blocking suggestions or helpful comments, and the instruction to lean toward minor and approve after several rounds of fixes when the PR overall improves things. The verified FATE addition supports the Development Policy’s adequate-testing guidance. Previously discussed non-blocking follow-ups are not being restated as new findings.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.