Avif image loader: add another check to verify that libavif has been built with an AV1 decoder

Summary: libavif can be built without a AV1 decoder. Check this in the image loader

Test Plan: entice

Reviewers: raster

Subscribers: cedric, #reviewers, #committers

Tags: #efl

Differential Revision: https://phab.enlightenment.org/D12252
This commit is contained in:
Vincent Torri 2021-03-28 21:56:54 +01:00 committed by Carsten Haitzler (Rasterman)
parent a2f672455c
commit e52391c585
1 changed files with 24 additions and 0 deletions

View File

@ -44,6 +44,7 @@ evas_image_load_file_head_avif_internal(Evas_Loader_Internal *loader,
{ {
Evas_Image_Animated *animated; Evas_Image_Animated *animated;
avifDecoder *decoder; avifDecoder *decoder;
const char *codec_name;
avifResult res; avifResult res;
Eina_Bool ret; Eina_Bool ret;
@ -61,6 +62,16 @@ evas_image_load_file_head_avif_internal(Evas_Loader_Internal *loader,
return ret; return ret;
} }
codec_name = avifCodecName(decoder->codecChoice, AVIF_CODEC_FLAG_CAN_DECODE);
if (!codec_name)
{
ERR("AV1 codec not available");
*error = EVAS_LOAD_ERROR_GENERIC;
goto destroy_decoder;
}
INF("AV1 codec name (decode): %s", codec_name);
avifDecoderSetIOMemory(decoder, (const uint8_t *)map, length); avifDecoderSetIOMemory(decoder, (const uint8_t *)map, length);
res = avifDecoderParse(decoder); res = avifDecoderParse(decoder);
if (res != AVIF_RESULT_OK) if (res != AVIF_RESULT_OK)
@ -138,6 +149,8 @@ evas_image_load_file_data_avif_internal(Evas_Loader_Internal *loader,
decoder = loader->decoder; decoder = loader->decoder;
if (!decoder) if (!decoder)
{ {
const char *codec_name;
decoder = avifDecoderCreate(); decoder = avifDecoderCreate();
if (!decoder) if (!decoder)
{ {
@ -145,6 +158,17 @@ evas_image_load_file_data_avif_internal(Evas_Loader_Internal *loader,
return EINA_FALSE; return EINA_FALSE;
} }
codec_name = avifCodecName(decoder->codecChoice,
AVIF_CODEC_FLAG_CAN_DECODE);
if (!codec_name)
{
ERR("AV1 codec not available");
*error = EVAS_LOAD_ERROR_GENERIC;
goto on_error;
}
INF("AV1 codec name (decode): %s", codec_name);
avifDecoderSetIOMemory(decoder, (const uint8_t *)map, length); avifDecoderSetIOMemory(decoder, (const uint8_t *)map, length);
res = avifDecoderParse(decoder); res = avifDecoderParse(decoder);
if (res != AVIF_RESULT_OK) if (res != AVIF_RESULT_OK)