Added version comments

Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
Andrew Murray 2025-03-19 19:29:28 +11:00 committed by Andrew Murray
parent 79f7339b18
commit 46f4508650

View File

@ -20,7 +20,7 @@ typedef struct {
static PyTypeObject AvifDecoder_Type; static PyTypeObject AvifDecoder_Type;
#if AVIF_VERSION < 1000000 #if AVIF_VERSION < 1000000 // 1.0.0
static int static int
normalize_quantize_value(int qvalue) { normalize_quantize_value(int qvalue) {
if (qvalue < AVIF_QUANTIZER_BEST_QUALITY) { if (qvalue < AVIF_QUANTIZER_BEST_QUALITY) {
@ -182,7 +182,7 @@ _encoder_codec_available(PyObject *self, PyObject *args) {
return PyBool_FromLong(is_available); return PyBool_FromLong(is_available);
} }
#if AVIF_VERSION >= 80200 #if AVIF_VERSION >= 80200 // 0.8.2
static int static int
_add_codec_specific_options(avifEncoder *encoder, PyObject *opts) { _add_codec_specific_options(avifEncoder *encoder, PyObject *opts) {
Py_ssize_t i, size; Py_ssize_t i, size;
@ -318,7 +318,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
image->height = height; image->height = height;
image->depth = 8; image->depth = 8;
#if AVIF_VERSION >= 90000 #if AVIF_VERSION >= 90000 // 0.9.0
image->alphaPremultiplied = alpha_premultiplied ? AVIF_TRUE : AVIF_FALSE; image->alphaPremultiplied = alpha_premultiplied ? AVIF_TRUE : AVIF_FALSE;
#endif #endif
@ -334,7 +334,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
_codec_available("aom", AVIF_CODEC_FLAG_CAN_ENCODE)); _codec_available("aom", AVIF_CODEC_FLAG_CAN_ENCODE));
encoder->maxThreads = is_aom_encode && max_threads > 64 ? 64 : max_threads; encoder->maxThreads = is_aom_encode && max_threads > 64 ? 64 : max_threads;
#if AVIF_VERSION >= 1000000 #if AVIF_VERSION >= 1000000 // 1.0.0
encoder->quality = quality; encoder->quality = quality;
#else #else
encoder->minQuantizer = normalize_quantize_value(64 - quality); encoder->minQuantizer = normalize_quantize_value(64 - quality);
@ -354,7 +354,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
encoder->speed = speed; encoder->speed = speed;
encoder->timescale = (uint64_t)1000; encoder->timescale = (uint64_t)1000;
#if AVIF_VERSION >= 110000 #if AVIF_VERSION >= 110000 // 0.11.0
encoder->autoTiling = autotiling ? AVIF_TRUE : AVIF_FALSE; encoder->autoTiling = autotiling ? AVIF_TRUE : AVIF_FALSE;
if (!autotiling) { if (!autotiling) {
encoder->tileRowsLog2 = normalize_tiles_log2(tile_rows_log2); encoder->tileRowsLog2 = normalize_tiles_log2(tile_rows_log2);
@ -366,7 +366,7 @@ AvifEncoderNew(PyObject *self_, PyObject *args) {
#endif #endif
if (advanced != Py_None) { if (advanced != Py_None) {
#if AVIF_VERSION >= 80200 #if AVIF_VERSION >= 80200 // 0.8.2
if (_add_codec_specific_options(encoder, advanced)) { if (_add_codec_specific_options(encoder, advanced)) {
error = 1; error = 1;
goto end; goto end;
@ -537,7 +537,7 @@ _encoder_add(AvifEncoderObject *self, PyObject *args) {
frame->yuvRange = image->yuvRange; frame->yuvRange = image->yuvRange;
frame->yuvFormat = image->yuvFormat; frame->yuvFormat = image->yuvFormat;
frame->depth = image->depth; frame->depth = image->depth;
#if AVIF_VERSION >= 90000 #if AVIF_VERSION >= 90000 // 0.9.0
frame->alphaPremultiplied = image->alphaPremultiplied; frame->alphaPremultiplied = image->alphaPremultiplied;
#endif #endif
} }
@ -689,10 +689,10 @@ AvifDecoderNew(PyObject *self_, PyObject *args) {
PyObject_Del(self); PyObject_Del(self);
return NULL; return NULL;
} }
#if AVIF_VERSION >= 80400 #if AVIF_VERSION >= 80400 // 0.8.4
decoder->maxThreads = max_threads; decoder->maxThreads = max_threads;
#endif #endif
#if AVIF_VERSION >= 90200 #if AVIF_VERSION >= 90200 // 0.9.2
// Turn off libavif's 'clap' (clean aperture) property validation. // Turn off libavif's 'clap' (clean aperture) property validation.
decoder->strictFlags &= ~AVIF_STRICT_CLAP_VALID; decoder->strictFlags &= ~AVIF_STRICT_CLAP_VALID;
// Allow the PixelInformationProperty ('pixi') to be missing in AV1 image // Allow the PixelInformationProperty ('pixi') to be missing in AV1 image