where are chrominance and luminance parameters?

12 views
Skip to first unread message

Xavier Brochard

unread,
Sep 6, 2022, 12:33:10 PM9/6/22
to libjpeg-turbo User Discussion/Support
Hi
I am looking for the chrominance and luminance quality parameters in the code. I've read some files and the 2 available APIs but didn't find them. Note that I am not a C programmer, only a modest sysadmin who try to understand some pieces of code.
Can someone could point me to the related files?
Also, I would like to know if they are in the API?
Any help welcome
Regards

DRC

unread,
Sep 6, 2022, 1:49:06 PM9/6/22
to libjpeg-t...@googlegroups.com
If you are referring to the ability to set the JPEG quality
independently for chrominance and luminance components, that is only
available in the libjpeg API at the moment.

This code:

https://github.com/libjpeg-turbo/libjpeg-turbo/blob/c5db99e1aafe302598708c02a8bb9b7dcd5344a4/rdswitch.c#L80-L82
https://github.com/libjpeg-turbo/libjpeg-turbo/blob/c5db99e1aafe302598708c02a8bb9b7dcd5344a4/rdswitch.c#L282-L358

shows how cjpeg accomplishes it.

DRC

Xavier Brochard

unread,
Sep 12, 2022, 11:41:57 AM9/12/22
to libjpeg-turbo User Discussion/Support
Thanks a lot.
So, if I have well understood, you don't use jpeg_set_quality at all, but rather jpeg_add_quant_table ?

DRC

unread,
Sep 12, 2022, 11:54:36 AM9/12/22
to libjpeg-t...@googlegroups.com

Yes.  jpeg_set_quality(cinfo, quality, force_baseline) is just a wrapper for

  jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, jpeg_quality_scaling(quality), force_baseline);
  jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, jpeg_quality_scaling(quality), force_baseline);

You can simply copy those two tables (which are directly from the JPEG spec: https://www.w3.org/Graphics/JPEG/itu-t81.pdf, Annex K) into your own code and call:

  jpeg_add_quant_table(cinfo, 0, std_luminance_quant_tbl, jpeg_quality_scaling(luminance_quality), force_baseline);
  jpeg_add_quant_table(cinfo, 1, std_chrominance_quant_tbl, jpeg_quality_scaling(chrominance_quality), force_baseline);

(force_baseline is documented in libjpeg.txt.)

DRC

--
You received this message because you are subscribed to the Google Groups "libjpeg-turbo User Discussion/Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libjpeg-turbo-u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/libjpeg-turbo-users/6002067d-0f25-453a-8449-2e905bd02190n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages