|
37 | 37 | #define AVIF_MAX_TILE_SIZE 3072 |
38 | 38 | #define AVIF_DEFAULT_TILE_SIZE AVIF_MIN_TILE_SIZE * 2 |
39 | 39 |
|
40 | | -DT_MODULE(1) |
| 40 | +DT_MODULE(2) |
41 | 41 |
|
42 | 42 | enum avif_compression_type_e |
43 | 43 | { |
@@ -724,6 +724,48 @@ size_t params_size(dt_imageio_module_format_t *self) |
724 | 724 | return sizeof(dt_imageio_avif_t); |
725 | 725 | } |
726 | 726 |
|
| 727 | +void *legacy_params(dt_imageio_module_format_t *self, |
| 728 | + const void *const old_params, |
| 729 | + const size_t old_params_size, |
| 730 | + const int old_version, |
| 731 | + int *new_version, |
| 732 | + size_t *new_size) |
| 733 | +{ |
| 734 | + if(old_version == 1) |
| 735 | + { |
| 736 | + typedef struct dt_imageio_avif_v1_t |
| 737 | + { |
| 738 | + dt_imageio_module_data_t global; |
| 739 | + uint32_t bit_depth; |
| 740 | + uint32_t color_mode; |
| 741 | + uint32_t compression_type; |
| 742 | + uint32_t quality; |
| 743 | + uint32_t tiling; |
| 744 | + } dt_imageio_avif_v1_t; |
| 745 | + |
| 746 | + if(old_params_size != sizeof(dt_imageio_avif_v1_t)) return NULL; |
| 747 | + |
| 748 | + const dt_imageio_avif_v1_t *o = (dt_imageio_avif_v1_t *)old_params; |
| 749 | + dt_imageio_avif_t *n = (dt_imageio_avif_t *)malloc(sizeof(dt_imageio_avif_t)); |
| 750 | + |
| 751 | + if(!n) return NULL; |
| 752 | + |
| 753 | + n->global = o->global; |
| 754 | + n->bit_depth = o->bit_depth; |
| 755 | + n->color_mode = o->color_mode; |
| 756 | + n->compression_type = o->compression_type; |
| 757 | + n->quality = o->quality; |
| 758 | + n->tiling = o->tiling; |
| 759 | + n->subsample = AVIF_SUBSAMPLE_AUTO; // Default to auto mode for old presets |
| 760 | + |
| 761 | + *new_version = 2; |
| 762 | + *new_size = sizeof(dt_imageio_avif_t); |
| 763 | + return n; |
| 764 | + } |
| 765 | + |
| 766 | + return NULL; |
| 767 | +} |
| 768 | + |
727 | 769 | void *get_params(dt_imageio_module_format_t *self) |
728 | 770 | { |
729 | 771 | dt_imageio_avif_t *d = calloc(1, sizeof(dt_imageio_avif_t)); |
|
0 commit comments