@@ -442,14 +442,19 @@ static bool configure_with(struct state_video_compress_j2k *s, struct video_desc
442442
443443 CHECK_OK (cmpto_j2k_enc_cfg_create (s->context , &s->enc_settings ),
444444 " Creating context configuration:" , return false );
445- CHECK_OK (cmpto_j2k_enc_cfg_set_quantization (
445+
446+ if (s->lossless ) {
447+ MSG (INFO, " Lossless compression selected. Ignoring quality parameter.\n " );
448+ CHECK_OK (cmpto_j2k_enc_cfg_set_lossless (
449+ s->enc_settings , s->lossless ),
450+ " Setting lossless mode" , NOOP);
451+ } else {
452+ CHECK_OK (cmpto_j2k_enc_cfg_set_quantization (
446453 s->enc_settings ,
447454 s->quality /* 0.0 = poor quality, 1.0 = full quality */
448455 ),
449456 " Setting quantization" , NOOP);
450- CHECK_OK (cmpto_j2k_enc_cfg_set_lossless (
451- s->enc_settings , s->lossless ),
452- " Setting lossless mode" , NOOP);
457+ }
453458
454459 CHECK_OK (cmpto_j2k_enc_cfg_set_resolutions (s->enc_settings , 6 ),
455460 " Setting DWT levels" , NOOP);
@@ -772,10 +777,12 @@ static struct module * j2k_compress_init(struct module *parent, const char *c_cf
772777 }
773778 }
774779
775- if (s->quality < 0.0 || s->quality > 1.0 ) {
776- LOG (LOG_LEVEL_ERROR) << " [J2K] Quality should be in interval [0-1]!\n " ;
777- j2k_compress_done ((struct module *) s);
778- return nullptr ;
780+ if (!s->lossless ) {
781+ if (s->quality < 0.0 || s->quality > 1.0 ) {
782+ LOG (LOG_LEVEL_ERROR) << " [J2K] Quality should be in interval [0-1]!\n " ;
783+ j2k_compress_done ((struct module *) s);
784+ return nullptr ;
785+ }
779786 }
780787
781788 s->tech = get_supported_technology (req_technology);
0 commit comments