From e547b740b16e50aa9a03b450206fb53c97297fce Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Tue, 31 Oct 2023 19:55:08 +0100 Subject: [PATCH] show correct compression format name (not just AV1/HEVC) --- examples/heif_enc.cc | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc index 8627dce062..791fa48ab7 100644 --- a/examples/heif_enc.cc +++ b/examples/heif_enc.cc @@ -349,6 +349,29 @@ static void show_list_of_encoders(const heif_encoder_descriptor* const* encoder_ } +static const char* get_compression_format_name(heif_compression_format format) +{ + switch (format) { + case heif_compression_AV1: + return "AV1"; + break; + case heif_compression_HEVC: + return "HEVC"; + break; + case heif_compression_JPEG: + return "JPEG"; + break; + case heif_compression_JPEG2000: + return "JPEG-2000"; + break; + case heif_compression_uncompressed: + return "Uncompressed"; + break; + default: + assert(false); + } +} + static void show_list_of_all_encoders() { for (auto compression_format : {heif_compression_HEVC, heif_compression_AV1, heif_compression_JPEG, heif_compression_JPEG2000 @@ -687,7 +710,7 @@ int main(int argc, char** argv) active_encoder_descriptor = encoder_descriptors[idx]; } else { - std::cerr << "No " << (compressionFormat == heif_compression_AV1 ? "AV1" : "HEVC") << " encoder available.\n"; + std::cerr << "No " << get_compression_format_name(compressionFormat) << " encoder available.\n"; return 5; }