Skip to content

Add backward compatibility for AVIF chroma subsampling feature - #19698

Merged
TurboGit merged 2 commits into
darktable-org:masterfrom
kadykov:avif-subsample-backward-compatibility
Nov 9, 2025
Merged

Add backward compatibility for AVIF chroma subsampling feature#19698
TurboGit merged 2 commits into
darktable-org:masterfrom
kadykov:avif-subsample-backward-compatibility

Conversation

@kadykov

@kadykov kadykov commented Nov 8, 2025

Copy link
Copy Markdown
Contributor

This PR adds the missing backward compatibility handling for the AVIF chroma subsampling feature that was recently merged in #19595. Thanks to @victoryforce for noticing this.

Problem

The previous PR added a new subsample field to the dt_imageio_avif_t structure but did not include:

  1. Module version increment
  2. Legacy parameter migration function

This could cause issues for users upgrading from older versions who have saved AVIF export presets.

Solution

This PR implements the required backward compatibility mechanisms:

  1. Incremented module version from DT_MODULE(1) to DT_MODULE(2)
  2. Added legacy_params() function to handle migration from version 1 (without subsample) to version 2 (with subsample)

Old export presets are automatically migrated with subsample set to AVIF_SUBSAMPLE_AUTO, which preserves the original quality-based chroma subsampling behavior.

Testing

Tested the migration path as follows:

  1. Built and tested version 1 (parent commit c7b5d6f, before chroma subsampling feature 6cd1733):

  2. Built and tested version 2 (current commit with backward compatibility):

    • Cleaned build artifacts
    • Built AppImage with devcontainer
    • Launched with config directory from version 1
    • Verified: Chroma subsampling combobox appears in UI and defaults to "auto"
    • Verified: Export still works correctly with migrated settings
    • Verified: No errors or crashes during migration

Changes

  • src/imageio/format/avif.c:
    • Module version: DT_MODULE(1)DT_MODULE(2)
    • Added legacy_params() function to migrate v1 parameters to v2
    • Default value for migrated presets: AVIF_SUBSAMPLE_AUTO

Related

Follow-up to the AVIF chroma subsampling feature PR #19595 that was recently merged.

Increment module version to 2 and add legacy_params function to
handle migration from version 1 (without subsample field) to
version 2 (with subsample field).

This ensures that existing AVIF export presets created before the
chroma subsampling feature continue to work after upgrade. Old
presets are automatically migrated with subsample set to AUTO,
preserving the original quality-based behavior.

Changes:
- Increment DT_MODULE from 1 to 2
- Add legacy_params() function to migrate v1 parameters to v2
- Old presets default to AVIF_SUBSAMPLE_AUTO for backward compatibility
Copilot AI review requested due to automatic review settings November 8, 2025 23:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds versioning support to the AVIF image format module to handle backwards compatibility when loading presets created with older versions. The module version is incremented from 1 to 2, and a new legacy_params function is introduced to migrate version 1 parameters to version 2.

  • Module version incremented from 1 to 2
  • Added legacy_params function to migrate old presets to new format
  • New subsample field initialized with default value for legacy presets

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/imageio/format/avif.c
Comment thread src/imageio/format/avif.c
Add safety checks to prevent crashes in the legacy_params function for AVIF export backward compatibility. The changes include verifying the old_params_size matches the expected struct size and checking for malloc failure.
@TurboGit TurboGit added this to the 5.4 milestone Nov 9, 2025
@TurboGit TurboGit added bugfix pull request fixing a bug priority: high core features are broken and not usable at all, software crashes labels Nov 9, 2025
@TurboGit

TurboGit commented Nov 9, 2025

Copy link
Copy Markdown
Member

Stupid me :( Completely forgot about this during my review. Sorry !

@TurboGit TurboGit left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@TurboGit
TurboGit merged commit 59d00e5 into darktable-org:master Nov 9, 2025
5 checks passed
piratenpanda pushed a commit to piratenpanda/darktable that referenced this pull request Aug 23, 2026
…able-org#19698)

* AVIF export: add legacy_params for backward compatibility

Increment module version to 2 and add legacy_params function to
handle migration from version 1 (without subsample field) to
version 2 (with subsample field).

This ensures that existing AVIF export presets created before the
chroma subsampling feature continue to work after upgrade. Old
presets are automatically migrated with subsample set to AUTO,
preserving the original quality-based behavior.

Changes:
- Increment DT_MODULE from 1 to 2
- Add legacy_params() function to migrate v1 parameters to v2
- Old presets default to AVIF_SUBSAMPLE_AUTO for backward compatibility
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix pull request fixing a bug priority: high core features are broken and not usable at all, software crashes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants