No, JPEG loss shouldn't affect average brightness.  My first suspicion
would be how you are converting the YUV 4:2:2 image to RGB.  Did you use
tjDecodeYUV() to perform that conversion?  If not, which conversion
formulae did you use?

The TurboJPEG API allows you to separate the color conversion portion of
the JPEG pipeline.  It should be the case (and you can confirm this by
running tjbench with and without the -yuv argument) that compressing an
RGB image with tjCompress2() produces mathematically identical results
to converting the same RGB image to YUV with tjEncodeYUV3() or
tjEncodeYUVPlanes() and then compressing the resulting YUV image with
tjCompressFromYUV().  On the decompression side, the same mathematical
equivalency also exists for tjDecompress2() and tjDecompressToYUV2() +
tjDecodeYUV()/tjDecodeYUVPlanes() if you are decompressing a grayscale
or 4:4:4 image.  For 4:2:0 and 4:2:2 images, the same mathematical
equivalency exists if you are using fast/non-fancy upsampling (passing
-fastupsample to tjbench or setting TJFLAG_FASTUPSAMPLE in the flags.)
Fancy upsampling needs context rows, so that algorithm isn't supported
in tjDecodeYUV()/tjDecodeYUVPlanes().

On 1/14/21 9:20 AM, Jerry wrote:
> Hi DRC,
> 
> Sorry i must be confused by myself... i 'm sorry for this simple mistake.
> 
> Actually i'm using libjpeg-turbo these days, and i found a difference
> result when i did the following things:
> 1. I have a yuv422 image, use *tjCompressFromYUV* and i got a JPEG image.
> 2. On the other hand, i converted this yuv422 image to rgb and use
> *tjCompress2* to get a JPEG image.
> 
> After i compared the 2 jpeg images with the original yuv422 image, i
> found that the jpeg(input yuv422) is a little bit *brighter* than
> another one(input rgb).
> Here is how i compare:
> 1. I save the original yuv422 image to BMP, then i compute this BMP and
> 2 JPEG images' histogram, and i found rgb input's histogram is almost
> like the BMP's.        But the yuv422 input's histogram is more
> "brighter" than the BMP's.
> 2. By my eyes, it's obvious that input yuv422 one is brighter than input
> rgb one.
> 
> Is there anything i missed? or is this just something like loss? (i
> don't really know JPEG theory), please give me some advice.
> Thanks!!!
> 
> DRC 在 2021年1月14日 星期四下午10:04:50 [UTC+8] 的信中寫道:
> 
>     I can’t explain it any better than the API documentation already does.
> 
>     
> https://cdn.rawgit.com/libjpeg-turbo/libjpeg-turbo/master/doc/html/group___turbo_j_p_e_g.html#gafbdce0112fd78fd38efae841443a9bcf
> 
>>     On Jan 14, 2021, at 7:00 AM, Jerry <jerry...@gmail.com> wrote:
>>
>>     Hi all,
>>
>>     my version: libjpeg-turbo 2.0.3
>>
>>     If i read a rgb color space image into buffer.
>>     Then use*tjCompress2 *to compress to JPEG.
>>
>>     I know it will be converted to yuv then compressed to JPEG, but
>>     what kind of yuv it is?
>>     yuv444? yuv422? yuv420? or can i set the format somewhere?
>>
>>     Please tell me if you have any idea.
>>     Thanks in advanced.
>>
>>     Jerry
>>
>>
>>     -- 
>>     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/de689de0-e00b-4f8e-a020-626359bc89d5n%40googlegroups.com
>>     
>> <https://groups.google.com/d/msgid/libjpeg-turbo-users/de689de0-e00b-4f8e-a020-626359bc89d5n%40googlegroups.com?utm_medium=email&utm_source=footer>.
> 
> -- 
> 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-users+unsubscr...@googlegroups.com
> <mailto:libjpeg-turbo-users+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/libjpeg-turbo-users/024aa6be-89d8-4a2a-8b06-21b5e36e24a6n%40googlegroups.com
> <https://groups.google.com/d/msgid/libjpeg-turbo-users/024aa6be-89d8-4a2a-8b06-21b5e36e24a6n%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/libjpeg-turbo-users/aace151d-11de-7417-1c65-80cd33c12a08%40virtualgl.org.

Reply via email to