Skip to content

Commit

Permalink
use dummy decoder plugin for 'uncompressed' (#1347)
Browse files Browse the repository at this point in the history
  • Loading branch information
farindk committed Oct 20, 2024
1 parent da90cc9 commit 996f6dd
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 14 deletions.
7 changes: 2 additions & 5 deletions examples/heif_dec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions libheif/api/libheif/heif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 3 additions & 1 deletion libheif/plugin_registry.cc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

#if WITH_UNCOMPRESSED_CODEC
#include "plugins/encoder_uncompressed.h"
#include "plugins/decoder_uncompressed.h"
#endif

#if HAVE_JPEG_DECODER
Expand Down Expand Up @@ -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());
}


Expand Down
4 changes: 3 additions & 1 deletion libheif/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
72 changes: 72 additions & 0 deletions libheif/plugins/decoder_uncompressed.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* JPEG codec.
* Copyright (c) 2023 Dirk Farin <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/

#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;
}
28 changes: 28 additions & 0 deletions libheif/plugins/decoder_uncompressed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Dummy decoder plugin for the 'uncompressed' codec.
* Copyright (c) 2023 Dirk Farin <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/

#ifndef LIBHEIF_DECODER_UNCOMPRESSED_H
#define LIBHEIF_DECODER_UNCOMPRESSED_H

#include "common_utils.h"

const struct heif_decoder_plugin* get_decoder_plugin_uncompressed();

#endif

0 comments on commit 996f6dd

Please sign in to comment.