Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 43 additions & 1 deletion src/imageio/format/avif.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#define AVIF_MAX_TILE_SIZE 3072
#define AVIF_DEFAULT_TILE_SIZE AVIF_MIN_TILE_SIZE * 2

DT_MODULE(1)
DT_MODULE(2)

enum avif_compression_type_e
{
Expand Down Expand Up @@ -724,6 +724,48 @@ size_t params_size(dt_imageio_module_format_t *self)
return sizeof(dt_imageio_avif_t);
}

void *legacy_params(dt_imageio_module_format_t *self,
const void *const old_params,
const size_t old_params_size,
const int old_version,
int *new_version,
size_t *new_size)
{
if(old_version == 1)
{
typedef struct dt_imageio_avif_v1_t
{
dt_imageio_module_data_t global;
uint32_t bit_depth;
uint32_t color_mode;
uint32_t compression_type;
uint32_t quality;
uint32_t tiling;
} dt_imageio_avif_v1_t;

if(old_params_size != sizeof(dt_imageio_avif_v1_t)) return NULL;

const dt_imageio_avif_v1_t *o = (dt_imageio_avif_v1_t *)old_params;
dt_imageio_avif_t *n = (dt_imageio_avif_t *)malloc(sizeof(dt_imageio_avif_t));

if(!n) return NULL;

n->global = o->global;
n->bit_depth = o->bit_depth;
n->color_mode = o->color_mode;
n->compression_type = o->compression_type;
n->quality = o->quality;
n->tiling = o->tiling;
n->subsample = AVIF_SUBSAMPLE_AUTO; // Default to auto mode for old presets

*new_version = 2;
*new_size = sizeof(dt_imageio_avif_t);
return n;
}

return NULL;
}

void *get_params(dt_imageio_module_format_t *self)
{
dt_imageio_avif_t *d = calloc(1, sizeof(dt_imageio_avif_t));
Expand Down
Loading