Skip to content

Conversation

@kadykov
Copy link
Contributor

@kadykov kadykov commented Nov 8, 2025

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
Copy link

Copilot AI left a comment

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.

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