From 47265d30f383d239c6c7246b110d821997d4c825 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Milo=C5=A1=20Komar=C4=8Devi=C4=87?= Date: Thu, 2 Nov 2023 16:13:35 +0100 Subject: [PATCH 1/2] Use standard name for JPEG 2000 --- examples/heif_convert.cc | 2 +- examples/heif_enc.cc | 6 +++--- libheif/context.cc | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/heif_convert.cc b/examples/heif_convert.cc index f474901798..0e3cb4d2de 100644 --- a/examples/heif_convert.cc +++ b/examples/heif_convert.cc @@ -171,7 +171,7 @@ void list_all_decoders() std::cout << "JPEG decoders:\n"; list_decoders(heif_compression_JPEG); - std::cout << "JPEG-2000 decoders:\n"; + std::cout << "JPEG 2000 decoders:\n"; list_decoders(heif_compression_JPEG2000); #if WITH_UNCOMPRESSED_CODEC diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc index 308b32ce37..754f566379 100644 --- a/examples/heif_enc.cc +++ b/examples/heif_enc.cc @@ -160,7 +160,7 @@ void show_help(const char* argv0) << " -p set encoder parameter (NAME=VALUE)\n" << " -A, --avif encode as AVIF (not needed if output filename with .avif suffix is provided)\n" << " --jpeg encode as JPEG\n" - << " --jpeg2000 encode as JPEG-2000 (experimental)\n" + << " --jpeg2000 encode as JPEG 2000 (experimental)\n" #if WITH_UNCOMPRESSED_CODEC << " -U, --uncompressed encode as uncompressed image (according to ISO 23001-17) (EXPERIMENTAL)\n" #endif @@ -362,7 +362,7 @@ static const char* get_compression_format_name(heif_compression_format format) return "JPEG"; break; case heif_compression_JPEG2000: - return "JPEG-2000"; + return "JPEG 2000"; break; case heif_compression_uncompressed: return "Uncompressed"; @@ -392,7 +392,7 @@ static void show_list_of_all_encoders() std::cout << "JPEG"; break; case heif_compression_JPEG2000: - std::cout << "JPEG-2000"; + std::cout << "JPEG 2000"; break; case heif_compression_uncompressed: std::cout << "Uncompressed"; diff --git a/libheif/context.cc b/libheif/context.cc index 392eac1b80..cdb5dbc28f 100644 --- a/libheif/context.cc +++ b/libheif/context.cc @@ -1193,7 +1193,7 @@ Error HeifContext::Image::get_preferred_decoding_colorspace(heif_colorspace* out return err; } - // TODO: this should be codec specific. JPEG-2000, for example, can use RGB internally. + // TODO: this should be codec specific. JPEG 2000, for example, can use RGB internally. *out_colorspace = heif_colorspace_YCbCr; *out_chroma = heif_chroma_undefined; From e29fcc74a47865d8703a87364d4425678343ef07 Mon Sep 17 00:00:00 2001 From: Dirk Farin Date: Thu, 2 Nov 2023 17:57:10 +0100 Subject: [PATCH 2/2] fix returning version number parts (#1023) --- libheif/heif.cc | 11 +++-------- libheif/heif.h | 11 +++++------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/libheif/heif.cc b/libheif/heif.cc index 6f7f614989..373fd9971a 100644 --- a/libheif/heif.cc +++ b/libheif/heif.cc @@ -83,24 +83,19 @@ uint32_t heif_get_version_number(void) return (LIBHEIF_NUMERIC_VERSION); } -static uint8_t bcd2dec(uint8_t v) -{ - return uint8_t((v >> 4) * 10 + (v & 0x0F)); -} - int heif_get_version_number_major(void) { - return bcd2dec(((LIBHEIF_NUMERIC_VERSION) >> 24) & 0xFF); + return ((LIBHEIF_NUMERIC_VERSION) >> 24) & 0xFF; } int heif_get_version_number_minor(void) { - return bcd2dec(((LIBHEIF_NUMERIC_VERSION) >> 16) & 0xFF); + return ((LIBHEIF_NUMERIC_VERSION) >> 16) & 0xFF; } int heif_get_version_number_maintenance(void) { - return bcd2dec(((LIBHEIF_NUMERIC_VERSION) >> 8) & 0xFF); + return ((LIBHEIF_NUMERIC_VERSION) >> 8) & 0xFF; } diff --git a/libheif/heif.h b/libheif/heif.h index 0c25f5eada..71c325644f 100644 --- a/libheif/heif.h +++ b/libheif/heif.h @@ -77,19 +77,18 @@ extern "C" { // Version string of linked libheif library. LIBHEIF_API const char* heif_get_version(void); -// Numeric version of linked libheif library, encoded as BCD 0xHHMMLL00 = HH.MM.LL. -// For example: 0x02143000 is version 2.14.30 +// Numeric version of linked libheif library, encoded as 0xHHMMLL00 = hh.mm.ll, where hh, mm, ll is the decimal representation of HH, MM, LL. +// For example: 0x02150300 is version 2.21.3 LIBHEIF_API uint32_t heif_get_version_number(void); -// Numeric part "HH" from above. Returned as a decimal number (not BCD). +// Numeric part "HH" from above. Returned as a decimal number. LIBHEIF_API int heif_get_version_number_major(void); -// Numeric part "MM" from above. Returned as a decimal number (not BCD). +// Numeric part "MM" from above. Returned as a decimal number. LIBHEIF_API int heif_get_version_number_minor(void); -// Numeric part "LL" from above. Returned as a decimal number (not BCD). +// Numeric part "LL" from above. Returned as a decimal number. LIBHEIF_API int heif_get_version_number_maintenance(void); // Helper macros to check for given versions of libheif at compile time. -// Note: h, m, l should be 2-digit BCD numbers. I.e., decimal 17 = 0x17 (BCD) #define LIBHEIF_MAKE_VERSION(h, m, l) ((h) << 24 | (m) << 16 | (l) << 8) #define LIBHEIF_HAVE_VERSION(h, m, l) (LIBHEIF_NUMERIC_VERSION >= LIBHEIF_MAKE_VERSION(h, m, l))