Skip to content

Set premultiplied alpha and pixel aspect ratio in ffmpeg decoder - #1860

Closed
torusrxxx wants to merge 1 commit into
strukturag:masterfrom
torusrxxx:patch-5
Closed

torusrxxx wants to merge 1 commit into
strukturag:masterfrom
torusrxxx:patch-5

Conversation

@torusrxxx

Copy link
Copy Markdown
Contributor

No description provided.

@farindk

farindk commented Sep 1, 2026

Copy link
Copy Markdown
Member

As far as I know, the alpha mode field is only set by ffmpeg for the JPEG-XL codec, not for anything we use. If we set it like proposed in the PR, there could even be a mismatch between the value coming from ffmpeg and the property in the HEIF layer.

For aspect ratio, this may be set for H.265, but not for AV1. And we will also have potential conflicts with the HEIF layer.

I would prefer not to read these fields from ffmpeg.

@farindk

farindk commented Sep 1, 2026

Copy link
Copy Markdown
Member

alpha_mode also needs FFMPEG 8.0, which would break some builds.

@farindk

farindk commented Sep 1, 2026

Copy link
Copy Markdown
Member

For aspect ratio, the code would have to check at least for the undefined case (num > 0 && den > 0).

@farindk

farindk commented Sep 1, 2026 •

Copy link
Copy Markdown
Member

BTW: If we read the SAR from H.265, we should also write it in encoders.

See: a26561d

farindk added a commit that referenced this pull request Sep 1, 2026
…1860)

Write the image's pixel aspect ratio into the codec-level signalling where the
format supports it, so that the bitstream agrees with the pasp property:
- x265, kvazaar (HEVC), x264 (AVC), uvg266, vvenc (VVC): Extended_SAR in the SPS VUI
- JPEG: JFIF APP0 density fields with unit 0 (Xdensity:Ydensity = hSpacing:vSpacing)

Only ratios that fit the u(16) VUI fields are written, 1:1 is omitted, and
auxiliary images (alpha, depth) are excluded. AV1 and raw JPEG 2000 codestreams
have no aspect ratio signalling and rely on the pasp property alone.
@torusrxxx

Copy link
Copy Markdown
Contributor Author

I think it's always necessary to encode and decode metadata in the bitstream by codec plugins whenever it is possible, let the HEIF core decide what to do with it. I'm closing this one, it seems this isn't necessary anymore.

@torusrxxx torusrxxx closed this Sep 2, 2026
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