-
-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
openjph: HT-J2K encoder #1072
openjph: HT-J2K encoder #1072
Conversation
libheif/context.cc
Outdated
@@ -2304,6 +2304,15 @@ Error HeifContext::encode_image(const std::shared_ptr<HeifPixelImage>& pixel_ima | |||
} | |||
break; | |||
|
|||
case heif_compression_HTJ2K: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor thing: maybe this case
can be simply combined with the heif_compression_JPEG2000
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will see if we need to add something extra for the HT case, and combine if not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have combined it.
Thank you, this is a great addition. |
It would help to not have to parse the |
Another reason to have a separate Second option: we would put the burden on the user when the codec is selected. He has to know that "-e OpenJPEG" is ordinary J2K und "-e OpenJPH" is HTJ2K. Third option: we require that all JPEG2000 plugins have an ht2k parameter option and if it is set to a value not supported by the plugin, it fails with an error. Sounds like a silly idea, but we can have similar cases for other codecs, e.g. a h265 codec that cannot encode monochrome images. (Currently we handle this by the plugin encoding dummy color planes.) Fourth option: when selecting the encoder, we pass a compression-format specific options struct to libheif. For Jpeg2000, this would include the HTJ2K flag and would be used for plugin selection. However, this may contradict the explicit user choice through "-e". My subjective summary: option 1 sounds like the easy solution. Maybe in the future, when all encoders support everything, the two enums can be synonyms. |
Maybe this is worth deeper consideration. I did some investigation into hardware based encoding and decoding (e.g. with NVIDIA GPUs). There are quite a few dimensions to whether the hardware can handle the task, beyond just the codec. NVIDIA documentation for the decoder and encoder shows differences in:
Running the tests code shows additional variation in MB count, minimum size and output surface format. This is a tricky tradeoff, because we'd like to use the fastest codec that supports the configuration the user has, but that isn't really exposed in the plugin API. |
4e34df9
to
d525dbf
Compare
I have cleaned up the code, and think it is now ready for review. The one thing that doesn't work yet is the quality setting. That is still to be implemented in OpenJPH. Also, there is no OpenJPH decoder implementation yet. I do plan to do that, no schedule at this stage. |
Thank you. |
This is an early-exposure draft of an OpenJPH based High Throughput JPEG-2000 encoder.
Thanks to @aous72 for OpenJPH and for debugging assistance. Also thanks to @Jamaika1 for suggesting this at #420.
An OpenJPH-based decoder is practical, but is not yet written. In the meantime, the OpenJPEG decoder will work.
I'm not sure about the additional codec type (
heif_compression_HTJ2K
). It seems like the JPEG community think that HT-J2K is really (a variation of) JPEG 2000, but if we want to pick a working encoder for the user, it seems like it would be better to have a different value.All input appreciated.
Note: This will likely have merge conflicts with #1071, which I'll resolve after that gets merged.