Skip to content

Update Decode() for ImageDecoder API 3.1.0 - #91

Merged
garbear merged 3 commits into
xbmc:Piersfrom
cinema-ONE:imagedecoder-api-3.1.0
Aug 30, 2026
Merged

Update Decode() for ImageDecoder API 3.1.0#91
garbear merged 3 commits into
xbmc:Piersfrom
cinema-ONE:imagedecoder-api-3.1.0

Conversation

@cinema-ONE

Copy link
Copy Markdown
Contributor

Readies the add-on for ImageDecoder API 3.1.0 (xbmc/xbmc#29068), which added size_t pixelBufferSize to the C++ Decode() signature.

This is a source break rather than a rebuild: the old five-argument Decode(...) override no longer matches the base virtual, so it fails to compile against the new dev-kit.

Two commits, separable. The first is the signature alone and unblocks the build. The second uses the argument for a bounds check and can be dropped if you would rather not take it now.

The check is worth having here because the loop writes 3 bytes per pixel, or 4 for ADDON_IMG_FMT_A8R8G8B8, so its reach depends on the requested format as well as the geometry.

Verified by building against a Kodi tree carrying the merged API: configure and build clean, .so produced. The generated addon.xml picks up minversion="3.1.0" version="3.1.0" from the dev-kit on its own, so nothing needs hardcoding in addon.xml.in.


Written by my AI co-author (Claude Code); posted from my account.

cinema-ONE and others added 2 commits August 30, 2026 07:23
xbmc/xbmc#29068 added size_t pixelBufferSize to the C++ Decode() signature.
The old five-argument override no longer matches the base virtual, so this
does not compile against the new dev-kit rather than merely warning.

Signature only; the argument is used in the next commit.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Use the pixelBufferSize argument added in the previous commit: work out what
the copy loop actually reaches and return false rather than write past the
end.

The loop's dimensions are not always the ones Kodi passed, which is what
makes the check worth having.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

The PR updates HeifPicture::Decode to implement ImageDecoder API 3.1.0 and uses the new buffer-size argument to reject output buffers that cannot contain the decoder’s writes.

  • Adds pixelBufferSize to the declaration and implementation of the Decode override.
  • Calculates the output extent from geometry, pitch, and the write path’s bytes per pixel.
  • Rejects zero-sized images and undersized output buffers before decoding.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete changed-code-triggered failure established.

The updated declaration and implementation remain consistent, and the new buffer check accounts for the exact final write extent of the existing decoding loop.

Important Files Changed

Filename Overview
src/HeifPicture.cpp Updates the Decode implementation for API 3.1.0 and adds a bounds check matching the existing pixel-writing loop.
src/HeifPicture.h Adds the API 3.1.0 pixel-buffer-size parameter to the Decode override declaration.

Reviews (1): Last reviewed commit: "Refuse a decode that would not fit the o..." | Re-trigger Greptile

The copy loop writes B,G,R and fills the fourth byte only for A8R8G8B8, so
that is the only format actually produced. Every other value fell through to
that same loop and returned true with output that does not match the request.

ADDON_IMG_FMT_A8 was the worst of them: one byte per pixel is asked for and
three are written. The previous commit's bounds check now refuses that, but
it should not be reached at all.

Latent today only because CTexture::LoadIImage() asks for A8R8G8B8.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@garbear
garbear merged commit 64e69ea into xbmc:Piers Aug 30, 2026
8 checks passed
@garbear

garbear commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants