team-charls/charls

jpegls_encoder: component_count = 1 vs charls::interleave_mode::Sample

malaterre opened this issue · 1 comments

I believe it would be nice to either document the following behavior, or (better) throw an exception in jpegls_encoder, when doing:

#include <charls/charls.h>
#include <vector>
#include <iostream>

int main()
{
  std::vector<uint8_t> source;
  source.resize(512*512);

  charls::frame_info frame_info{ .width = 512, .height = 512, .bits_per_sample = 8, .component_count = 1};
  auto interleave_mode = charls::interleave_mode::Sample;
  std::vector<uint8_t> destination =
      charls::jpegls_encoder::encode(source, frame_info, interleave_mode);

  std::vector<uint8_t> destination2;
  try {
    charls::jpegls_decoder::decode(destination, destination2);
  } catch( std::exception &ex ) {
    std::cerr << "Cannot re-read own JPEG-LS stream" << std::endl;
    return 1;
  }

  return 0;
}

Validation of interleave mode against component count = 1 has been implemented with 04b08b7