Skip to content

fix: picture size from the decoder's crop rectangle (#166) - #167

Merged
compot-dev merged 4 commits into
v2from
fix/visible-size-166
Oct 14, 2026
Merged

compot-dev merged 4 commits into
v2from
fix/visible-size-166

Conversation

@compot-dev

@compot-dev compot-dev commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

The output format's KEY_WIDTH / KEY_HEIGHT are the decoder's buffer, padded to its alignment: every 1080p stream showed as 1920×1088, and on the reporter's device an H.265 1920×1080 stream as 2304×1088. The single view also fits the picture to that size, so its aspect ratio was off (2.12:1 instead of 16:9).

Now the size comes from the crop-left/top/right/bottom keys when the decoder sets them (the buffer size otherwise; a crop larger than the buffer is ignored). Used for /stats.json size, the cell text, and the single view's fit. Unit test: VisibleSizeTest.

Version 2.04 (after #163 took 2.03).

Refs #166 (the second part of the report, a higher resolution not starting, needs details from the reporter).

…uffer (#166)

KEY_WIDTH / KEY_HEIGHT of the output format are the buffer, padded to the
decoder's alignment: 1080 became 1088 everywhere, and one H.265 decoder
reported a 1920x1080 stream as 2304x1088, which also skewed the aspect
ratio the single view fits the picture to. The crop-* keys give the
picture; the buffer size stays when a decoder sets none.
@compot-dev
compot-dev force-pushed the fix/visible-size-166 branch from 89bec88 to 63eabbe Compare October 14, 2026 16:03
@compot-dev

Copy link
Copy Markdown
Collaborator Author

/review

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Bad crop data distorts video layout ✓ Resolved
Description
visibleSize accepts a crop whenever its right edge exceeds its left edge, without checking whether
either edge lies within the buffer. If a decoder reports a 1920-pixel-wide buffer with crop edges at
3000 and 3100, the resulting width is 101 pixels; that value reaches the single-view fit and the
multi-view load estimate.
Code

android/app/src/main/java/com/openipc/decoder/MediaCodecManager.java[R513-516]

+        if (left >= 0 && right > left) w = right - left + 1;
+        if (top >= 0 && bottom > top) h = bottom - top + 1;
+        // A crop larger than the buffer is not believed
+        if (w > width && width > 0) w = width;
Evidence
The new calculation checks crop ordering and caps only a computed size larger than the buffer, so an
out-of-bounds rectangle that is narrower than the buffer survives. The result is published on an
output-format change, and downstream consumers use it for layout and load estimation.

android/app/src/main/java/com/openipc/decoder/MediaCodecManager.java[510-518]
android/app/src/main/java/com/openipc/decoder/MediaCodecManager.java[525-532]
android/app/src/main/java/com/openipc/decoder/Decoder.java[1747-1773]
android/app/src/main/java/com/openipc/decoder/QuadCell.java[393-407]
android/app/src/main/java/com/openipc/decoder/QuadCell.java[532-535]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A crop rectangle wholly outside the decoder buffer can produce a plausible but incorrect picture size.
## Fix Focus Areas
- android/app/src/main/java/com/openipc/decoder/MediaCodecManager.java[510-518]
- android/app/src/test/java/com/openipc/decoder/VisibleSizeTest.java[36-40]
## Recommended Fix
Validate each crop axis against the corresponding positive buffer dimension before using it; retain the buffer dimension when its crop coordinates are invalid. Add a test with an offset crop wholly outside the buffer.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Tip of the day
💡 Did you know, you can switch off images and animations for a plain-text comment

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread android/app/src/main/java/com/openipc/decoder/MediaCodecManager.java Outdated
@compot-dev
compot-dev force-pushed the fix/visible-size-166 branch from 63eabbe to 03966ee Compare October 14, 2026 16:13
@compot-dev
compot-dev merged commit 766d697 into v2 Oct 14, 2026
4 checks passed
@compot-dev
compot-dev deleted the fix/visible-size-166 branch October 14, 2026 16:17
compot-dev added a commit that referenced this pull request Oct 15, 2026
compot-dev added a commit that referenced this pull request Oct 15, 2026
fix: picture size from the decoder's crop rectangle (#166)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant