lavc/pgssub: implement composition object cropping #21109

Open
cubicibo wants to merge 2 commits from cubicibo/FFmpeg:MR/pgssub into master
First-time contributor

This commit brings the lavc PGS decoder to a comparable level to reference implementations.

  • The cropping feature is now supported.

Test file:

This commit brings the lavc PGS decoder to a comparable level to reference implementations. - The cropping feature is now supported. Test file: - Cropping (generated via authoring software): [[m2ts]](https://streams.videolan.org/ffmpeg/incoming/00019.m2ts), [[brief]](https://streams.videolan.org/ffmpeg/incoming/00019.m2ts.txt)
Contributor

libavcodec/pgssubdec.c:550: transfering ==> transferring to pass lint

libavcodec/pgssubdec.c:550: transfering ==> transferring to pass lint
cubicibo force-pushed MR/pgssub from 858e342604
Some checks failed
/ pr_labeler (pull_request_target) Successful in 10s
/ lint (pull_request) Failing after 30s
/ run_fate (64, linux-aarch64, static) (pull_request) Successful in 11m37s
/ compile_only (ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest) (pull_request) Successful in 10m50s
/ run_fate (64, linux-amd64, shared) (pull_request) Successful in 11m33s
/ run_fate (32, linux-amd64, static) (pull_request) Successful in 17m5s
to 8c420e065e
All checks were successful
/ pr_labeler (pull_request_target) Successful in 9s
/ lint (pull_request) Successful in 32s
/ run_fate (64, linux-aarch64, static) (pull_request) Successful in 12m12s
/ compile_only (ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest) (pull_request) Successful in 10m48s
/ run_fate (64, linux-amd64, shared) (pull_request) Successful in 16m20s
/ run_fate (32, linux-amd64, static) (pull_request) Successful in 23m39s
2025-12-06 20:41:53 +00:00
Compare
@ -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/height
Owner

cosmetic 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

cosmetic 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
Author
First-time contributor

I agree, my sincere apologies. I will not squash everything the next time.

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) {
Owner

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

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
cubicibo force-pushed MR/pgssub from 8c420e065e
All checks were successful
/ pr_labeler (pull_request_target) Successful in 9s
/ lint (pull_request) Successful in 32s
/ run_fate (64, linux-aarch64, static) (pull_request) Successful in 12m12s
/ compile_only (ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest) (pull_request) Successful in 10m48s
/ run_fate (64, linux-amd64, shared) (pull_request) Successful in 16m20s
/ run_fate (32, linux-amd64, static) (pull_request) Successful in 23m39s
to b6d93b0659
All checks were successful
/ pr_labeler (pull_request_target) Successful in 7s
/ lint (pull_request) Successful in 32s
/ run_fate (64, linux-aarch64, static) (pull_request) Successful in 11m33s
/ compile_only (ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest) (pull_request) Successful in 10m0s
/ run_fate (64, linux-amd64, shared) (pull_request) Successful in 15m51s
/ run_fate (32, linux-amd64, static) (pull_request) Successful in 21m23s
2025-12-08 20:31:30 +00:00
Compare
cubicibo force-pushed MR/pgssub from b6d93b0659
All checks were successful
/ pr_labeler (pull_request_target) Successful in 7s
/ lint (pull_request) Successful in 32s
/ run_fate (64, linux-aarch64, static) (pull_request) Successful in 11m33s
/ compile_only (ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest) (pull_request) Successful in 10m0s
/ run_fate (64, linux-amd64, shared) (pull_request) Successful in 15m51s
/ run_fate (32, linux-amd64, static) (pull_request) Successful in 21m23s
to a947667ebc
All checks were successful
/ pr_labeler (pull_request_target) Successful in 10s
/ lint (pull_request) Successful in 41s
/ run_fate (64, linux-aarch64, static) (pull_request) Successful in 11m29s
/ run_fate (64, linux-amd64, shared) (pull_request) Successful in 16m19s
/ run_fate (32, linux-amd64, static) (pull_request) Successful in 21m53s
/ run_fate_full (ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest, wine) (pull_request) Successful in 24m47s
2025-12-28 21:33:56 +00:00
Compare
cubicibo force-pushed MR/pgssub from a947667ebc
All checks were successful
/ pr_labeler (pull_request_target) Successful in 10s
/ lint (pull_request) Successful in 41s
/ run_fate (64, linux-aarch64, static) (pull_request) Successful in 11m29s
/ run_fate (64, linux-amd64, shared) (pull_request) Successful in 16m19s
/ run_fate (32, linux-amd64, static) (pull_request) Successful in 21m53s
/ run_fate_full (ghcr.io/btbn/ffmpeg-builds/win64-gpl:latest, wine) (pull_request) Successful in 24m47s
to bad7594c4c
Some checks failed
Test / Fate (Full, Linux, aarch64) (pull_request) Successful in 9m22s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Successful in 12m8s
Lint / Pre-Commit (pull_request) Failing after 12m12s
Test / Fate (Qemu, Linux, mips64) (pull_request) Successful in 13m29s
Test / Fate (Qemu, Linux, ppc64) (pull_request) Successful in 15m56s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Successful in 19m1s
Test / Fate (Qemu, Linux, riscv64) (pull_request) Successful in 19m6s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Successful in 20m43s
Test / Fate (Full, Wine, win64) (pull_request) Successful in 29m13s
Backport / PR (pull_request_target) Has been skipped
Autolabel / Labeler (pull_request_target) Successful in 9s
2026-08-25 14:10:03 +00:00
Compare
Member

LLM — 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

  1. 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.

  2. 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_size when 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.

  3. 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 keeps AV_SUBTITLE_FLAG_FORCED but 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_FORCED in the palette-export condition, as the correction does. — GPT-6-ASTRA code and design reviews.

  4. Moderate — Repeated END packets can lose the previous plane allocation (bad7594c4c, libavcodec/pgssubdec.c:637 and :716).

    Rendering leaves plane.writable set. The duplicate-END guard applies only within one decode call, so a later END packet can render again and overwrite gp_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 writable and clearing the stored flag before rendering. This also prevents an export failure from leaving the redraw pending. — GPT-6-ASTRA code and design reviews.

  5. 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.sup gave 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.

  6. 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.

  7. Minor — Palette-allocation failure leaks an unregistered rectangle (bad7594c4c, libavcodec/pgssubdec.c:739).

    av_memdup() allocates the rectangle before palette allocation, but registration in sub->rects happens afterward. If palette allocation fails, the caller's avsubtitle_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.

  8. 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; replacing 0b10 with 2 passes 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.

  9. 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.

  10. 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

  1. 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

  1. 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

  1. 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

  1. Independent build and functional checks passed for the exercised cases (bad7594c4c and 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.sup produced 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 passed git diff --check. This was not a full FATE run.

  2. The drafts report additional sanitizer and sample checks (bad7594c4c and 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.

  3. 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.

LLM<!-- -GPT-6-ASTRA --> — combined review of bad7594c4c8a. <!-- Scope GPT-6-ASTRA code review: Reviewed the sole commit and every changed hunk, supplied discussion and complete related #23851 discussion; decoder dispatch, subtitle cleanup, allocation helpers, development rules and the BD-ROM graphics-model white paper. Reported arm64 ASan/LSan builds, synthetic cases, both supplied samples, the existing PGS sample, parent comparisons, a corrective diff and configured pre-commit checks; not a full FATE run or complete normative grammar review. Scope GPT-6-ASTRA design review: Reviewed the sole commit and every changed hunk, both discussions, dispatch, cleanup, allocation helpers, PGS FATE definitions and developer rules. Reported arm64 parent/head sanitizer testing, allocation-failure tests, supplied and existing samples, CPU-pinned release benchmarks, relevant Blu-ray graphics documents and libbluray code; no Windows, macOS, BSD or full FATE execution, and no claim to establish every normative signaling constraint. Scope combiner: Checked the exact head and parent, all supplied discussion and the related #23851 discussion, allocation/cleanup contracts, project policy, FATE definitions, CI configuration and the saved correction. Built the head and compiled parent/corrected decoder variants on arm64; independently checked the existing PGS sample, supplied display-signaling sample, forced-only and empty-plane behavior, CPU-pinned performance and binary-literal portability. Memory-safety findings were verified through source and ownership analysis; sanitizer reproduction results below are attributed to the drafts. --> 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 1. <details><summary><b>Major — Rejected crop values still reach the cropped copy (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L672">libavcodec/pgssubdec.c:672</a>).</b></summary> 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. </details> 2. <details><summary><b>Major — Cached bitmap validity can outlive its dimensions or a failed decode (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L199">libavcodec/pgssubdec.c:199</a>, :329 and :710).</b></summary> 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_size` when 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. </details> 3. <details><summary><b>Moderate — Forced-only filtering consults pending references instead of the displayed plane (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L750">libavcodec/pgssubdec.c:750</a>).</b></summary> 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 keeps `AV_SUBTITLE_FLAG_FORCED` but 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_FORCED` in the palette-export condition, as the correction does. — GPT-6-ASTRA code and design reviews. </details> 4. <details><summary><b>Moderate — Repeated END packets can lose the previous plane allocation (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L637">libavcodec/pgssubdec.c:637</a> and :716).</b></summary> Rendering leaves `plane.writable` set. The duplicate-END guard applies only within one decode call, so a later END packet can render again and overwrite `gp_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 `writable` and clearing the stored flag before rendering. This also prevents an export failure from leaving the redraw pending. — GPT-6-ASTRA code and design reviews. </details> 5. <details><summary><b>Moderate — The additional bitmap copies cause a substantial measured slowdown on the existing sample (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L199">libavcodec/pgssubdec.c:199</a>, :716 and :755).</b></summary> 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.sup` gave 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. </details> 6. <details><summary><b>Moderate — The single commit still mixes the feature with representation/refactoring changes (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L52">libavcodec/pgssubdec.c:52</a>).</b></summary> The history still contains one commit, including changes to existing ID/count field types alongside the functional redesign. [Michael's separation request](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21109#issuecomment-18064) 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](https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a561e5af087c96382ceef7402e315/doc/developer.texi#L502-L515). — GPT-6-ASTRA code and design reviews. </details> 7. <details><summary><b>Minor — Palette-allocation failure leaks an unregistered rectangle (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L739">libavcodec/pgssubdec.c:739</a>).</b></summary> `av_memdup()` allocates the rectangle before palette allocation, but registration in `sub->rects` happens afterward. If palette allocation fails, the caller's `avsubtitle_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. </details> 8. <details><summary><b>Minor — The binary literal unnecessarily depends on a compiler extension (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L484">libavcodec/pgssubdec.c:484</a>).</b></summary> The project specifies C11 and requires compatibility without compiler-specific extensions. Clang rejects this line with `-std=c11 -Werror=gnu-binary-literal`; replacing `0b10` with `2` passes 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. </details> 9. <details><summary><b>Minor — The commit message omits the rationale for the new display model (bad7594c4c8a, commit message).</b></summary> 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. </details> 10. <details><summary><b>Minor — Decode-side regression coverage is missing (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/tests/fate/subtitles.mak#L61">tests/fate/subtitles.mak:61</a>).</b></summary> 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. </details> **Proposed corrections:** I verified and retained [fairy/pr21109-review-fixes](https://code.ffmpeg.org/Forgejo_Fairy/FFmpeg/src/branch/fairy/pr21109-review-fixes), commit [a3f53c8cdb09](https://code.ffmpeg.org/Forgejo_Fairy/FFmpeg/commit/a3f53c8cdb093af703c67f33bd49c79a46ca0798). 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 1. <details><summary><b>Minor — An already-empty plane still emits a subtitle for a no-update display set (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L607">libavcodec/pgssubdec.c:607</a>).</b></summary> 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. </details> ### Unverified matters 1. <details><summary><b>Unverified — The historical CI failure causes cannot be identified from the available logs (bad7594c4c8a, CI jobs).</b></summary> [Autolabel / Labeler](https://code.ffmpeg.org/FFmpeg/FFmpeg/actions/runs/78426/jobs/0) reports “Failing after 12m16s”; [Lint / Pre-Commit](https://code.ffmpeg.org/FFmpeg/FFmpeg/actions/runs/78427/jobs/0) 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. </details> ### Resolved issues 1. <details><summary><b>Resolved — The encoded RLE-length subtraction is now guarded (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L302">libavcodec/pgssubdec.c:302</a>).</b></summary> The code rejects lengths below four before subtracting the dimension fields, addressing [Michael's earlier underflow report](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21109#issuecomment-18065). — GPT-6-ASTRA code and design reviews. </details> <details><summary><h3>Verification</h3></summary> 1. <details><summary><b>Independent build and functional checks passed for the exercised cases (bad7594c4c8a and <a href="https://code.ffmpeg.org/Forgejo_Fairy/FFmpeg/commit/a3f53c8cdb093af703c67f33bd49c79a46ca0798">a3f53c8cdb09</a>).</b></summary> 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.sup` produced 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 passed `git diff --check`. This was not a full FATE run. </details> 2. <details><summary><b>The drafts report additional sanitizer and sample checks (bad7594c4c8a and their proposed corrections).</b></summary> 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. </details> 3. <details><summary><b>The related cache-retention objection does not apply to this patch (bad7594c4c8a, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a/libavcodec/pgssubdec.c#L479">libavcodec/pgssubdec.c:479</a>).</b></summary> This PR retains `flush_cache()` for nonzero composition states. The current [#23851 discussion](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23851#issuecomment-55725) 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. </details> </details> ### Classification - <details><summary><b>major_issues — The current patch introduces unsafe memory accesses and should not merge unchanged.</b></summary> 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](https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/bad7594c4c8a561e5af087c96382ceef7402e315/doc/developer.texi#L412-L422). 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. </details>
cubicibo force-pushed MR/pgssub from bad7594c4c
Some checks failed
Test / Fate (Full, Linux, aarch64) (pull_request) Successful in 9m22s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Successful in 12m8s
Lint / Pre-Commit (pull_request) Failing after 12m12s
Test / Fate (Qemu, Linux, mips64) (pull_request) Successful in 13m29s
Test / Fate (Qemu, Linux, ppc64) (pull_request) Successful in 15m56s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Successful in 19m1s
Test / Fate (Qemu, Linux, riscv64) (pull_request) Successful in 19m6s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Successful in 20m43s
Test / Fate (Full, Wine, win64) (pull_request) Successful in 29m13s
Backport / PR (pull_request_target) Has been skipped
Autolabel / Labeler (pull_request_target) Successful in 9s
to 82052957e9
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 46s
Autolabel / Labeler (pull_request_target) Successful in 9s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Has been cancelled
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Has been cancelled
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Has been cancelled
Test / Fate (linux-loongarch64, static, 64 bit) (pull_request) Has been cancelled
Test / Fate (Qemu, Linux, mips64) (pull_request) Has been cancelled
Test / Fate (Qemu, Linux, ppc64) (pull_request) Has been cancelled
Test / Fate (Qemu, Linux, riscv64) (pull_request) Has been cancelled
Test / Fate (Full, Linux, aarch64) (pull_request) Has been cancelled
Test / Fate (Full, Wine, win64) (pull_request) Has been cancelled
2026-11-07 14:09:04 +00:00
Compare
cubicibo changed title from lavc/pgssub: Support cropping and display update signaling to lavc/pgssub: implement composition object cropping 2026-11-07 14:18:13 +00:00
cubicibo force-pushed MR/pgssub from 82052957e9
Some checks failed
Lint / Pre-Commit (pull_request) Successful in 46s
Autolabel / Labeler (pull_request_target) Successful in 9s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Has been cancelled
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Has been cancelled
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Has been cancelled
Test / Fate (linux-loongarch64, static, 64 bit) (pull_request) Has been cancelled
Test / Fate (Qemu, Linux, mips64) (pull_request) Has been cancelled
Test / Fate (Qemu, Linux, ppc64) (pull_request) Has been cancelled
Test / Fate (Qemu, Linux, riscv64) (pull_request) Has been cancelled
Test / Fate (Full, Linux, aarch64) (pull_request) Has been cancelled
Test / Fate (Full, Wine, win64) (pull_request) Has been cancelled
to 105210b73f
Some checks failed
Autolabel / Labeler (pull_request_target) Successful in 10s
Lint / Pre-Commit (pull_request) Successful in 33s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 8m41s
Test / Fate (Full, Linux, aarch64) (pull_request) Successful in 10m14s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Successful in 12m23s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Successful in 13m58s
Test / Fate (Qemu, Linux, mips64) (pull_request) Successful in 21m31s
Test / Fate (Qemu, Linux, ppc64) (pull_request) Successful in 23m39s
Test / Fate (Qemu, Linux, riscv64) (pull_request) Successful in 28m30s
Test / Fate (linux-loongarch64, static, 64 bit) (pull_request) Successful in 19m2s
Test / Fate (Full, Wine, win64) (pull_request) Successful in 47m55s
2026-11-07 14:19:36 +00:00
Compare
Author
First-time contributor

Split 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.

Split 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.
Member

LLM — combined follow-up review of db8e63f3e8 and 105210b73f.

Replies

  1. Reply — The reduced scope and commit split address the earlier organization request (cubicibo, scope clarification).

    The type changes are separated in db8e63f3e8, and 105210b73f explains 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

  1. 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 through ff_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=32 accepting 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.h and insert this after the existing dimension check, before accepting replacement dimensions:

    ret = av_image_check_size2(width, height, avctx->max_pixels,
                               AV_PIX_FMT_PAL8, 0, avctx);
    if (ret < 0)
        return ret;
    

    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.

  2. 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_pixels check 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.sup replays 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_size gate 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.

  3. 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.sup remains useful as a fragmented-object compatibility test. — GPT-6.1-SOL code/design and GROK-4.7 design.

Pre-existing issues

  1. 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:

    if (buf_end - buf < 8) {
        av_log(avctx, AV_LOG_ERROR,
               "Insufficient data for composition object crop\n");
        ctx->presentation.object_count = i;
        return AVERROR_INVALIDDATA;
    }
    

    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

  1. Minor, conditional — Requiring the final-fragment flag changes incomplete-sequence recovery (105210b73f, libavcodec/pgssubdec.c:335).

    I confirmed that a complete RLE payload marked 0x80 without a subsequent 0x40 fragment 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.

  2. 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

  1. 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-fixes branch, a3f53c8cdb09, is marked for deletion: its corrections are incorporated or unnecessary after this rewrite.

Dropped claims

  1. 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_limited explicitly enables the PGS decoder and exercises decoded output. It and fate-sub-pgs-remux passed 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 under tests/ref/. New samples can be submitted to [email protected].

  2. 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.

  3. 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

  1. Verified — Cropping matches an independent reconstruction (105210b73f, supplied 00019.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.sup and supplied graphicplane_test.sup also matched the ancestor’s inspected geometry and bitmap hashes. This does not claim restored display-signaling functionality.

  2. Verified — Targeted builds and tests passed; broader draft tests remain attributed (105210b73f).

    The arm64 build, two named FATE tests and git diff --check passed. 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.

  3. 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 later and fate-rsync error 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.

LLM<!-- -GPT-6-ASTRA --> — combined follow-up review of db8e63f3e887 and 105210b73fc1. <!-- Scope GPT-6.1-SOL [code review]: Reviewed both commits and every changed hunk, supplied discussion, #23851, developer policy/checklists and the BD-ROM graphics-model white paper; deeply inspected parsing, fragment completion, bitmap validity, crop arithmetic, allocation limits, ownership, cleanup and forced-only output. Reported arm64 ASan/UBSan/LSan builds of the ancestor, type-only commit, head and correction; supplied/existing samples and synthetic tests, including 400 crop-oracle cases. No full FATE run, release benchmark or other-platform execution. Scope GPT-6.1-SOL [design review]: Reviewed both commits and every changed hunk, both discussions, parsing, caching, allocation, cleanup, developer rules and PGS FATE paths; consulted Blu-ray graphics documents and libbluray. Reported arm64 Clang builds, independent crop reconstruction, CPU-pinned benchmarks and two FATE tests; sanitizer instrumentation covered the decoder translation unit linked against normal libraries. No full FATE run, complete normative grammar audit or other-platform execution. Scope GLM-5.3 [code review]: Reported exhaustive review of both commits, discussion and prior review; standalone builds, ancestor comparisons on existing/supplied samples, crop-field and pixel comparisons, ten malformed cases, 20,000 ASan mutation iterations, interleaved timings and comparison with libbluray crop semantics. No full FATE run or verification of removed signaling functionality beyond output identity. Scope GROK-4.7 [design review]: Reported exhaustive reading of both commits and the decoder, #21109 discussion and the #23851 note; arm64 optimized build, existing/supplied/synthetic sample comparisons and CPU-pinned benchmarks. No full FATE run or Windows/macOS/BSD builds. Scope combiner: Inspected both commits against their ancestor, supplied discussion, relevant #23851 follow-up, allocation/cleanup contracts, developer policy, FATE definitions, local Blu-ray white paper and the obsolete correction branch. Built the head on arm64; independently tested ancestor/head/correction decoder variants, pixel limits, undisplayed-cache growth, fragment completion and truncated crop parsing; reconstructed all supplied-sample crop outputs; ran interleaved CPU-pinned benchmarks and two FATE tests. Targeted ASan/UBSan checks instrumented the decoder and harness, linked against normal libraries. No full FATE run or complete normative grammar audit. --> ### Replies 1. <details><summary><b>Reply — The reduced scope and commit split address the earlier organization request (cubicibo, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21109#issuecomment-82115">scope clarification</a>).</b></summary> The type changes are separated in db8e63f3e887, and 105210b73fc1 explains 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. </details> ### Findings 1. <details><summary><b>Moderate — Larger source objects bypass the caller’s pixel limit (105210b73fc1, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/105210b73fc1/libavcodec/pgssubdec.c#L305">libavcodec/pgssubdec.c:305</a>).</b></summary> The fixed 4096-per-side check replaces the presentation-dimension bound without independently checking `avctx->max_pixels`. Presentation dimensions still pass through `ff_set_dimensions()`, but the decoded source can now be larger. This conflicts with the documented [maximum accepted pixels per image](https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/105210b73fc1/libavcodec/avcodec.h#L1788). I independently reproduced an 8×4 presentation with `max_pixels=32` accepting 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.h` and insert this after the existing dimension check, before accepting replacement dimensions: ret = av_image_check_size2(width, height, avctx->max_pixels, AV_PIX_FMT_PAL8, 0, avctx); if (ret < 0) return ret; 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. </details> 2. <details><summary><b>Moderate — Eager bitmap caching expands and retains objects that are never displayed (105210b73fc1, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/105210b73fc1/libavcodec/pgssubdec.c#L335">libavcodec/pgssubdec.c:335</a>).</b></summary> 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_pixels` check 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.sup` replays 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_size` gate 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. </details> 3. <details><summary><b>Minor — The PR description still promises the removed signaling changes (#21109, description).</b></summary> 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.sup` remains useful as a fragmented-object compatibility test. — GPT-6.1-SOL code/design and GROK-4.7 design. </details> ### Pre-existing issues 1. <details><summary><b>Minor — Optional crop fields lack a segment-length check (105210b73fc1, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/105210b73fc1/libavcodec/pgssubdec.c#L496">libavcodec/pgssubdec.c:496</a>).</b></summary> 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`: if (buf_end - buf < 8) { av_log(avctx, AV_LOG_ERROR, "Insufficient data for composition object crop\n"); ctx->presentation.object_count = i; return AVERROR_INVALIDDATA; } 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. </details> ### Unverified or conditional matters 1. <details><summary><b>Minor, conditional — Requiring the final-fragment flag changes incomplete-sequence recovery (105210b73fc1, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/105210b73fc1/libavcodec/pgssubdec.c#L335">libavcodec/pgssubdec.c:335</a>).</b></summary> I confirmed that a complete RLE payload marked `0x80` without a subsequent `0x40` fragment 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. </details> 2. <details><summary><b>Minor, conditional — The 4096 ceiling and stricter picture bounds need a compatibility basis (105210b73fc1, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/105210b73fc1/libavcodec/pgssubdec.c#L305">libavcodec/pgssubdec.c:305</a> and :631).</b></summary> 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. </details> ### Resolved issues 1. <details><summary><b>Resolved — The previous unsafe-copy and plane-ownership findings no longer apply (105210b73fc1, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/105210b73fc1/libavcodec/pgssubdec.c#L310">libavcodec/pgssubdec.c:310</a>, :620 and :647).</b></summary> 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-fixes` branch, a3f53c8cdb09, is marked for deletion: its corrections are incorporated or unnecessary after this rewrite. </details> <details><summary><h3>Dropped claims</h3></summary> 1. <details><summary><b>Dropped — “There is no decode-side PGS FATE coverage” (GLM-5.3 and GROK-4.7 design, tests/fate/ffmpeg.mak:81).</b></summary> `fate-sub2video_time_limited` explicitly enables the PGS decoder and exercises decoded output. It and `fate-sub-pgs-remux` passed 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 under `tests/ref/`. New samples can be submitted to `[email protected]`. </details> 2. <details><summary><b>Dropped — Removing the graphic plane eliminates the performance concern (GLM-5.3, 105210b73fc1).</b></summary> 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. </details> 3. <details><summary><b>Dropped — Nonzero stride on an empty rectangle is itself a bug (GLM-5.3, libavcodec/pgssubdec.c:597).</b></summary> 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. </details> </details> <details><summary><h3>Verification</h3></summary> 1. <details><summary><b>Verified — Cropping matches an independent reconstruction (105210b73fc1, supplied <code>00019.m2ts</code>).</b></summary> 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.sup` and supplied `graphicplane_test.sup` also matched the ancestor’s inspected geometry and bitmap hashes. This does not claim restored display-signaling functionality. </details> 2. <details><summary><b>Verified — Targeted builds and tests passed; broader draft tests remain attributed (105210b73fc1).</b></summary> The arm64 build, two named FATE tests and `git diff --check` passed. 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. </details> 3. <details><summary><b>Verified — CI failed during sample synchronization, not compilation or a FATE comparison (<a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/actions/runs/115587/jobs/2">linux-amd64 shared job</a>).</b></summary> The job reports “Failing after 8m41s”. Its log shows successful linking, followed by `@ERROR: max connections (30) reached -- try again later` and `fate-rsync` error 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. </details> </details> ### Classification - <details><summary><b>moderate_issues — Cropping is verified, but the caller’s resource limit needs enforcement.</b></summary> 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](https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/105210b73fc1/doc/developer.texi#L412). </details>
cubicibo force-pushed MR/pgssub from 105210b73f
Some checks failed
Autolabel / Labeler (pull_request_target) Successful in 10s
Lint / Pre-Commit (pull_request) Successful in 33s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Failing after 8m41s
Test / Fate (Full, Linux, aarch64) (pull_request) Successful in 10m14s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Successful in 12m23s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Successful in 13m58s
Test / Fate (Qemu, Linux, mips64) (pull_request) Successful in 21m31s
Test / Fate (Qemu, Linux, ppc64) (pull_request) Successful in 23m39s
Test / Fate (Qemu, Linux, riscv64) (pull_request) Successful in 28m30s
Test / Fate (linux-loongarch64, static, 64 bit) (pull_request) Successful in 19m2s
Test / Fate (Full, Wine, win64) (pull_request) Successful in 47m55s
to 6095087856
All checks were successful
Lint / Pre-Commit (pull_request) Successful in 40s
Test / Fate (linux-loongarch64, static, 64 bit) (pull_request) Successful in 4m55s
Autolabel / Labeler (pull_request_target) Successful in 9s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Successful in 12m20s
Test / Fate (Full, Linux, aarch64) (pull_request) Successful in 11m5s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Successful in 16m33s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Successful in 17m7s
Test / Fate (Qemu, Linux, mips64) (pull_request) Successful in 21m25s
Test / Fate (Qemu, Linux, ppc64) (pull_request) Successful in 23m16s
Test / Fate (Qemu, Linux, riscv64) (pull_request) Successful in 28m36s
Test / Fate (Full, Wine, win64) (pull_request) Successful in 29m24s
2026-11-08 19:52:30 +00:00
Compare
Author
First-time contributor

Moderate — Larger source objects bypass the caller’s pixel limit (105210b73f, libavcodec/pgssubdec.c:305).

Nonsense. 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.

Minor, conditional — The 4096 ceiling and stricter picture bounds need a compatibility basis (105210b73f, libavcodec/pgssubdec.c:305 and :631).

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.

> Moderate — Larger source objects bypass the caller’s pixel limit (105210b73f, libavcodec/pgssubdec.c:305). Nonsense. 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. > Minor, conditional — The 4096 ceiling and stricter picture bounds need a compatibility basis (105210b73f, libavcodec/pgssubdec.c:305 and :631). 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.
Forgejo_Fairy approved these changes 2026-11-09 03:03:37 +00:00
Dismissed
Forgejo_Fairy left a comment

LLM — combined follow-up review of db8e63f3e8 and 6095087856.

Replies

  1. 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.

  2. Reply — The ancestor already rejected a 65535×65535 presentation (cubicibo, same reply).

    Its ff_set_dimensions() calls av_image_check_size2(), and its object check rejects dimensions exceeding that presentation. I inspected both ancestor helpers and confirmed that the corresponding size check returns AVERROR(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

  1. Minor, non-blocking — The decoded source bitmap still bypasses a lower caller-selected pixel limit (6095087856, libavcodec/pgssubdec.c:178).

    The API documents max_pixels as 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=921600 accepts 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 include libavutil/imgutils.h, add int ret to the locals in decode_object_rle(), and insert this before bitmap allocation:

    ret = av_image_check_size2(object->w, object->h, avctx->max_pixels,
                              AV_PIX_FMT_PAL8, 0, avctx);
    if (ret < 0)
        return ret;
    

    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.

  2. 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:

    Workload Ancestor Head
    10,000 replays of the complete first display set from pgs_sub.sup 0.973 s 1.532 s
    1,000 replays extended to 100 presentations reusing those objects 8.801 s 0.420 s

    This 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.

  3. 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:

    ffmpeg -i 00019.m2ts -ss 9 -t 1.3 -map 0:s:0 -c:s copy pgs-crop.sup
    

    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 under tests/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

  1. 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.

  2. 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

  1. 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

  1. 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.

  2. Dropped — Identity on pgs_sub.sup establishes 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

  1. 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.

  2. Verified — Targeted build, FATE and current CI checks pass (6095087856).

    The arm64 build, fate-sub2video_time_limited, fate-sub-pgs-remux and git diff --check passed 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.

  3. 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.

LLM<!-- -GPT-6-ASTRA --> — combined follow-up review of db8e63f3e887 and 6095087856b6. <!-- Scope GPT-6.1-SOL [code review]: Reviewed both commits and every changed hunk, supplied discussion and #23851, parsing, fragment assembly, bitmap validity, crop arithmetic, allocation/cleanup, forced-only output, max_pixels contracts, developer rules and the Blu-ray graphics white paper. Reported arm64 builds of head/ancestor/type-only/corrected variants, sample comparisons, reconstruction of 650 rectangles, targeted lifecycle/resource tests, two FATE tests and decoder/harness ASan/UBSan/LSan checks linked against normal libraries. No full FATE run, other-platform execution or complete normative grammar audit. Scope GPT-6.1-SOL [design review]: Reviewed both commits and every changed hunk, discussions, developer policy, parsing, completion, bounds, ownership and caching; consulted the local Blu-ray white paper and libbluray. Reported arm64 builds, ancestor/type-only/head comparisons, reconstruction of 650 rectangles, 400 generated crop cases, lifecycle/error tests, two FATE tests and five-run CPU-pinned GCC 13 benchmarks. Sanitizers covered the decoder and harness linked against normal libraries; no full FATE run, other-platform execution or complete normative grammar audit. Scope GLM-5.3 [code review]: Reported exhaustive review of both commits against the merge-base, discussion and previous-head delta; arm64 head/ancestor/type-only builds, supplied-sample geometry/CRC oracle, existing sample and synthetic crop, fragment, pixel-limit and cache tests, plus 8000 ASan/LSan mutation iterations. No full FATE run, other-platform execution or normative BD-ROM Part 3 access. Scope GROK-4.7 [design review]: Reviewed both commits against their ancestor, previous-head delta, latest author comment, local Blu-ray white paper and libbluray behavior. Reported arm64 builds, supplied-sample pixel comparisons, existing-sample identity, synthetic pixel-limit/overhang/area tests and CPU-pinned timings. No full FATE run, other-platform execution or normative BDAV text access. Scope combiner: Inspected both commits against their ancestor, all supplied discussion and the related #23851 follow-up, max_pixels documentation/options and helper implementation, crop bounds, cache validity/lifetime, developer policy and FATE definitions. Built the exact head on arm64; compiled ancestor/head/corrected decoder harnesses; exercised caller limits and normal/strict recovery, independently reconstructed 650 supplied-sample rectangles, verified the proposed trimmed sample, ran five interleaved CPU-pinned benchmark pairs per workload and two FATE tests, and checked current CI status. No independent sanitizer run, full FATE run or normative BDAV/UHD conformance audit. --> ### Replies 1. <details><summary><b>Reply — Larger-than-presentation objects are necessary for cropping; the caller’s pixel budget is a separate constraint (cubicibo, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21109#issuecomment-82751">latest technical reply</a>).</b></summary> 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. </details> 2. <details><summary><b>Reply — The ancestor already rejected a 65535×65535 presentation (cubicibo, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21109#issuecomment-82751">same reply</a>).</b></summary> Its `ff_set_dimensions()` calls `av_image_check_size2()`, and its object check rejects dimensions exceeding that presentation. I inspected both ancestor helpers and confirmed that the corresponding size check returns `AVERROR(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. </details> ### Findings 1. <details><summary><b>Minor, non-blocking — The decoded source bitmap still bypasses a lower caller-selected pixel limit (6095087856b6, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/libavcodec/pgssubdec.c#L178">libavcodec/pgssubdec.c:178</a>).</b></summary> The [API documents `max_pixels` as the maximum accepted pixels per image](https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/libavcodec/avcodec.h#L1791), and [the option includes subtitle decoding](https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/libavcodec/options_table.h#L409). The new 4 MiB ceiling does not enforce a smaller caller limit. I independently confirmed that `max_pixels=921600` accepts 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 include `libavutil/imgutils.h`, add `int ret` to the locals in `decode_object_rle()`, and insert this before bitmap allocation: ret = av_image_check_size2(object->w, object->h, avctx->max_pixels, AV_PIX_FMT_PAL8, 0, avctx); if (ret < 0) return ret; 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. </details> 2. <details><summary><b>Minor, non-blocking — Caching trades additional first-use work and retained memory for substantial reuse savings (6095087856b6, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/libavcodec/pgssubdec.c#L653">libavcodec/pgssubdec.c:653</a>–681).</b></summary> 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: | Workload | Ancestor | Head | | --- | ---: | ---: | | 10,000 replays of the complete first display set from `pgs_sub.sup` | 0.973 s | 1.532 s | | 1,000 replays extended to 100 presentations reusing those objects | 8.801 s | 0.420 s | This 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. </details> 3. <details><summary><b>Minor, non-blocking — The outstanding cropping test now has a verified small sample candidate (6095087856b6, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/tests/fate/ffmpeg.mak#L83">tests/fate/ffmpeg.mak:83</a>).</b></summary> I verified GPT-6.1-SOL design’s extraction command: ffmpeg -i 00019.m2ts -ss 9 -t 1.3 -map 0:s:0 -c:s copy pgs-crop.sup 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 under `tests/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. </details> ### Unverified or conditional matters 1. <details><summary><b>Minor, conditional — The new area ceiling excludes some synthetic UHD-sized objects, but a valid-stream regression is unverified (6095087856b6, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/libavcodec/pgssubdec.c#L309">libavcodec/pgssubdec.c:309</a>).</b></summary> 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. </details> 2. <details><summary><b>Minor, conditional — Edge-crossing rectangles remain a format-compatibility question, not a confirmed regression (6095087856b6, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/libavcodec/pgssubdec.c#L637">libavcodec/pgssubdec.c:637</a>–650).</b></summary> 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. </details> ### Resolved issues 1. <details><summary><b>Resolved — Lazy decoding and parser hardening address the previous round’s eager-work and crop-field findings (6095087856b6, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/libavcodec/pgssubdec.c#L486">libavcodec/pgssubdec.c:486</a> and :653).</b></summary> 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. </details> <details><summary><h3>Dropped claims</h3></summary> 1. <details><summary><b>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).</b></summary> 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. </details> 2. <details><summary><b>Dropped — Identity on <code>pgs_sub.sup</code> establishes that uncropped streams are unaffected (GLM-5.3, sample comparison).</b></summary> 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. </details> </details> <details><summary><h3>Verification</h3></summary> 1. <details><summary><b>Verified — Supplied-sample cropping and the proposed pixel-limit correction preserve the expected pixels (6095087856b6).</b></summary> 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. </details> 2. <details><summary><b>Verified — Targeted build, FATE and current CI checks pass (6095087856b6).</b></summary> The arm64 build, `fate-sub2video_time_limited`, `fate-sub-pgs-remux` and `git diff --check` passed independently. The [current commit status](https://code.ffmpeg.org/api/v1/repos/FFmpeg/FFmpeg/commits/6095087856b61db7e8adfd87f7f0cae4c131bb12/status) reports all 11 checks successful, confirming GPT-6.1-SOL design’s report; the earlier sample-synchronization rerun request is resolved. </details> 3. <details><summary><b>Attributed verification — Broader sanitizer and generated-case results were not independently repeated.</b></summary> 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. </details> </details> ### Classification - <details><summary><b>minor_issues_approve — The cropping improvement is verified, with focused non-blocking follow-ups.</b></summary> 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](https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/6095087856b6/doc/developer.texi#L412). </details>
Member

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.

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.
Author
First-time contributor

@pross Sure, here is the raw SUP stream with only the cropping effect.

@pross Sure, here is the raw SUP stream with only the cropping effect.
cubicibo force-pushed MR/pgssub from 6095087856
All checks were successful
Lint / Pre-Commit (pull_request) Successful in 40s
Test / Fate (linux-loongarch64, static, 64 bit) (pull_request) Successful in 4m55s
Autolabel / Labeler (pull_request_target) Successful in 9s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Successful in 12m20s
Test / Fate (Full, Linux, aarch64) (pull_request) Successful in 11m5s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Successful in 16m33s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Successful in 17m7s
Test / Fate (Qemu, Linux, mips64) (pull_request) Successful in 21m25s
Test / Fate (Qemu, Linux, ppc64) (pull_request) Successful in 23m16s
Test / Fate (Qemu, Linux, riscv64) (pull_request) Successful in 28m36s
Test / Fate (Full, Wine, win64) (pull_request) Successful in 29m24s
to d97262798d
All checks were successful
Autolabel / Labeler (pull_request_target) Successful in 11s
Lint / Pre-Commit (pull_request) Successful in 33s
Test / Fate (linux-loongarch64, static, 64 bit) (pull_request) Successful in 4m46s
Test / Fate (Full, Wine, win64) (pull_request) Successful in 9m15s
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Successful in 9m30s
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Successful in 12m33s
Test / Fate (Full, Linux, aarch64) (pull_request) Successful in 10m43s
Test / Fate (Qemu, Linux, ppc64) (pull_request) Successful in 14m35s
Test / Fate (Qemu, Linux, mips64) (pull_request) Successful in 21m22s
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Successful in 20m27s
Test / Fate (Qemu, Linux, riscv64) (pull_request) Successful in 36m56s
2026-11-19 22:38:25 +00:00
Compare
Forgejo_Fairy left a comment

LLM — combined follow-up review of 87ab7830a5 and d97262798d.

Replies

  1. Reply — The trimmed attachment satisfies the requested size threshold (cubicibo, sample attachment).

    cropping.sup is 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

  1. 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_crop using sub2video/framecrc, with expected output under tests/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] as sub/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

  1. 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.

  2. Verified — The targeted build, FATE tests and CI checks pass (d97262798d with test helper 66102f20c8fc).

    Independently passed on arm64: fate-sub2video_pgs_crop, fate-sub2video_time_limited and fate-sub-pgs-remux. Both the PR diff and helper diff pass git 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.

  3. 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.

LLM<!-- -GPT-6-ASTRA --> — combined follow-up review of 87ab7830a564 and d97262798de7. <!-- Scope GPT-6.1-SOL [code review]: Reviewed both commits and every changed hunk, supplied #21109 discussion and relevant #23851 discussion; deeply checked incremental RLE allocation, fragment accounting, padding, bitmap validity, crop/copy bounds and cleanup. Consulted developer policy and the Blu-ray graphics white paper. Reported an exact-head arm64 build, independent sample reconstruction, targeted decoder/harness ASan/UBSan checks linked against normal libraries, three FATE tests and a type-only-parent negative control. No full FATE run, other-platform execution or complete normative BDAV audit. Scope GPT-6.1-SOL [design review]: Reviewed both commits and every changed hunk, discussions, dispatch, fragment assembly, bounds, cache lifetime, allocation/cleanup, developer policy, FATE paths, the Blu-ray graphics white paper and libbluray's composition parser. Concentrated on the attachment and regression coverage. Reported arm64/x86-64 builds, sample reconstruction and ancestor comparisons, targeted decoder/harness ASan/UBSan/LSan checks linked against normal libraries, three FATE tests, a negative control and five interleaved CPU-pinned benchmark pairs per workload. No full FATE run, complete normative BDAV audit or Windows/macOS/BSD execution. Scope GROK-4.7 [design review]: Read both commits and the resulting decoder, focusing on incremental RLE allocation and the allocation helpers. Reported arm64 ASan/UBSan/LSan checks of fragment, crop, bounds, replacement, padding-reuse and post-flush cases; independent attachment reconstruction and comparison of the existing PGS sample with the pre-change decoder. No full FATE run or Windows/macOS/BSD build. Scope combiner: Checked the supplied commits and discussion, RLE allocation helpers, fragment accounting, crop/copy bounds, cache invalidation, relevant developer testing guidance and the published FATE helper commit. Built the PR decoder plus the test-only helper on arm64, independently reconstructed and compared all attachment rectangles, ran three targeted FATE tests and a type-only-parent negative control, checked whitespace and current CI status, and retained the verified helper branch. No independent sanitizer run, benchmark, other-platform execution or normative BDAV audit. --> ### Replies 1. <details><summary><b>Reply — The trimmed attachment satisfies the requested size threshold (cubicibo, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21109#issuecomment-85130">sample attachment</a>).</b></summary> `cropping.sup` is **21,621 bytes**, below [Peter’s requested 100 KiB threshold](https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/21109#issuecomment-83406). 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. </details> ### Findings 1. <details><summary><b>Minor, non-blocking — The existing cropping-coverage follow-up now has a verified FATE commit (d97262798de7, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/d97262798de7/tests/fate/ffmpeg.mak#L92">tests/fate/ffmpeg.mak:92</a>).</b></summary> I verified and retained **[fairy/pr21109-cropping-fate](https://code.ffmpeg.org/Forgejo_Fairy/FFmpeg/src/branch/fairy/pr21109-cropping-fate)**, commit [66102f20c8fc](https://code.ffmpeg.org/Forgejo_Fairy/FFmpeg/commit/66102f20c8fc89215ad60b3f8b32d394f8ce470f), on top of this PR. It adds `fate-sub2video_pgs_crop` using sub2video/framecrc, with expected output under `tests/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, 87ab7830a564: 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]` as `sub/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. </details> <details><summary><h3>Verification</h3></summary> 1. <details><summary><b>Verified — Incremental RLE storage preserves the required padding and ownership (d97262798de7, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/d97262798de7/libavcodec/pgssubdec.c#L320">libavcodec/pgssubdec.c:320</a> and :334).</b></summary> 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. </details> 2. <details><summary><b>Verified — The targeted build, FATE tests and CI checks pass (d97262798de7 with test helper <a href="https://code.ffmpeg.org/Forgejo_Fairy/FFmpeg/commit/66102f20c8fc89215ad60b3f8b32d394f8ce470f">66102f20c8fc</a>).</b></summary> Independently passed on arm64: `fate-sub2video_pgs_crop`, `fate-sub2video_time_limited` and `fate-sub-pgs-remux`. Both the PR diff and helper diff pass `git diff --check`. The [commit status](https://code.ffmpeg.org/api/v1/repos/FFmpeg/FFmpeg/commits/d97262798de756e9ac417cdde7d54f66c42ee2f4/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. </details> 3. <details><summary><b>Attributed verification — The new sample demonstrates the previously discussed cache tradeoff (d97262798de7, <a href="https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/d97262798de7/libavcodec/pgssubdec.c#L653">libavcodec/pgssubdec.c:653</a>).</b></summary> 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. </details> </details> ### Classification - <details><summary><b>minor_issues_approve — The cropping improvement remains suitable to merge, with a concrete non-blocking test follow-up.</b></summary> 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](https://code.ffmpeg.org/FFmpeg/FFmpeg/src/commit/d97262798de7/doc/developer.texi#L548). Previously discussed non-blocking follow-ups are not being restated as new findings. </details>
All checks were successful
Autolabel / Labeler (pull_request_target) Successful in 11s
Lint / Pre-Commit (pull_request) Successful in 33s
Required
Details
Test / Fate (linux-loongarch64, static, 64 bit) (pull_request) Successful in 4m46s
Required
Details
Test / Fate (Full, Wine, win64) (pull_request) Successful in 9m15s
Required
Details
Test / Fate (linux-amd64, shared, 64 bit) (pull_request) Successful in 9m30s
Required
Details
Test / Fate (linux-aarch64, static, 64 bit) (pull_request) Successful in 12m33s
Required
Details
Test / Fate (Full, Linux, aarch64) (pull_request) Successful in 10m43s
Required
Details
Test / Fate (Qemu, Linux, ppc64) (pull_request) Successful in 14m35s
Required
Details
Test / Fate (Qemu, Linux, mips64) (pull_request) Successful in 21m22s
Required
Details
Test / Fate (linux-amd64, static, 32 bit) (pull_request) Successful in 20m27s
Required
Details
Test / Fate (Qemu, Linux, riscv64) (pull_request) Successful in 36m56s
Required
Details
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u 'MR/pgssub:cubicibo-MR/pgssub'
git switch 'cubicibo-MR/pgssub'
Sign in to join this conversation.
No reviewers
No milestone
No assignees
5 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
FFmpeg/FFmpeg!21109
No description provided.