diff --git a/examples/heif_dec.cc b/examples/heif_dec.cc index 0353dcc905..c74fa1826e 100644 --- a/examples/heif_dec.cc +++ b/examples/heif_dec.cc @@ -188,11 +188,8 @@ void list_all_decoders() std::cout << "JPEG 2000 (HT) decoders:\n"; list_decoders(heif_compression_HTJ2K); -#if WITH_UNCOMPRESSED_CODEC - std::cout << "uncompressed: yes\n"; -#else - std::cout << "uncompressed: no\n"; -#endif + std::cout << "uncompressed:\n"; + list_decoders(heif_compression_uncompressed); std::cout << "VVIC decoders:\n"; list_decoders(heif_compression_VVC); diff --git a/libheif/api/libheif/heif.cc b/libheif/api/libheif/heif.cc index 798fd5c4e4..3a328223e6 100644 --- a/libheif/api/libheif/heif.cc +++ b/libheif/api/libheif/heif.cc @@ -2832,13 +2832,6 @@ struct heif_error heif_context_get_encoder(struct heif_context* context, int heif_have_decoder_for_format(enum heif_compression_format format) { - if (format == heif_compression_uncompressed) { -#if WITH_UNCOMPRESSED_CODEC - return true; -#else - return false; -#endif - } auto plugin = get_decoder(format, nullptr); return plugin != nullptr; } diff --git a/libheif/plugin_registry.cc b/libheif/plugin_registry.cc index 9bc196f467..3c3b59e980 100644 --- a/libheif/plugin_registry.cc +++ b/libheif/plugin_registry.cc @@ -76,6 +76,7 @@ #if WITH_UNCOMPRESSED_CODEC #include "plugins/encoder_uncompressed.h" +#include "plugins/decoder_uncompressed.h" #endif #if HAVE_JPEG_DECODER @@ -213,9 +214,10 @@ void register_default_plugins() #if WITH_UNCOMPRESSED_CODEC register_encoder(get_encoder_plugin_uncompressed()); + register_decoder(get_decoder_plugin_uncompressed()); #endif -register_encoder(get_encoder_plugin_mask()); + register_encoder(get_encoder_plugin_mask()); } diff --git a/libheif/plugins/CMakeLists.txt b/libheif/plugins/CMakeLists.txt index 18e4bdb158..1444e20417 100644 --- a/libheif/plugins/CMakeLists.txt +++ b/libheif/plugins/CMakeLists.txt @@ -121,5 +121,7 @@ target_sources(heif PRIVATE if (WITH_UNCOMPRESSED_CODEC) target_sources(heif PRIVATE encoder_uncompressed.h - encoder_uncompressed.cc) + encoder_uncompressed.cc + decoder_uncompressed.h + decoder_uncompressed.cc) endif () diff --git a/libheif/plugins/decoder_uncompressed.cc b/libheif/plugins/decoder_uncompressed.cc new file mode 100644 index 0000000000..cce9ad7085 --- /dev/null +++ b/libheif/plugins/decoder_uncompressed.cc @@ -0,0 +1,72 @@ +/* + * JPEG codec. + * Copyright (c) 2023 Dirk Farin + * + * This file is part of libheif. + * + * libheif is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * libheif is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libheif. If not, see . + */ + +#include "libheif/heif.h" +#include "libheif/heif_plugin.h" +#include "decoder_uncompressed.h" + +struct uncompressed_decoder +{ +}; + +static const char kSuccess[] = "Success"; + +static const int UNCOMPRESSED_PLUGIN_PRIORITY = 100; + + +static const char* uncompressed_plugin_name() +{ + return "builtin"; +} + + +static int uncompressed_does_support_format(enum heif_compression_format format) +{ + if (format == heif_compression_uncompressed) { + return UNCOMPRESSED_PLUGIN_PRIORITY; + } + else { + return 0; + } +} + + + + +static const struct heif_decoder_plugin decoder_uncompressed + { + 3, + uncompressed_plugin_name, + nullptr, + nullptr, + uncompressed_does_support_format, + nullptr, + nullptr, + nullptr, + nullptr, + nullptr, + "uncompressed" + }; + + +const struct heif_decoder_plugin* get_decoder_plugin_uncompressed() +{ + return &decoder_uncompressed; +} diff --git a/libheif/plugins/decoder_uncompressed.h b/libheif/plugins/decoder_uncompressed.h new file mode 100644 index 0000000000..d20a6dd9aa --- /dev/null +++ b/libheif/plugins/decoder_uncompressed.h @@ -0,0 +1,28 @@ +/* + * Dummy decoder plugin for the 'uncompressed' codec. + * Copyright (c) 2023 Dirk Farin + * + * This file is part of libheif. + * + * libheif is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. + * + * libheif is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with libheif. If not, see . + */ + +#ifndef LIBHEIF_DECODER_UNCOMPRESSED_H +#define LIBHEIF_DECODER_UNCOMPRESSED_H + +#include "common_utils.h" + +const struct heif_decoder_plugin* get_decoder_plugin_uncompressed(); + +#endif