google / guetzli

Perceptual JPEG encoder
Apache License 2.0
12.9k stars 976 forks source link

Is this code neccessary if the input jpeg is already grayscale? #255

Open ppoocde opened 5 years ago

ppoocde commented 5 years ago

Dear All,

I am trying to understand processor.cc, specially the function bool Processor::ProcessJpegData(). I see an if statement to check if the input has cbcr colorspace HasYCbCrColorSpace(). And, before the function try to optimize the quantization table, I found the following code: { JPEGData jpg = jpg_in; RemoveOriginalQuantization(&jpg, qin); OutputImage img(jpg.width, jpg.height); img.CopyFromJpegData(jpg); comparator->Compare(img); } MaybeOutput(encoded_jpg);

My question is, if the above code neccessary if my input is always have ycbcr (non grayscale) and always yuv420? Because I also try to optimize the code for our own usage.

https://github.com/google/guetzli/blob/0b78c7cc8b1b6cbaaf3d08b1facb599bcec1d101/guetzli/processor.cc#L839

Thanks,

Sunny

koboltzz commented 5 years ago

Glad someone is still interested in this software (like I am! Don't expect any answer from anyone here). I only have one hint if you want to optimize the process: Try to further optimize the already optimized version at https://github.com/ianhuang-777/guetzli-cuda-opencl instead this one. I have to say the added '--c' command reduce processing time by ~30% which is great. The cuda and opencl optimization works only till 6 MP big pictures. Anything bigger will abort the process so it's not usable.

Please let me know if you have any success in further optimizing guetzli.

ppoocde commented 5 years ago

thanks @koboltzz I intend to optimize the code so that it can be easier for hardware engineer to translate the implementation into one of the hardware description language such as Verilog. Do you know any active Guetzli forum or website that I can post any question ?

koboltzz commented 5 years ago

No since for the most people guetzli is too heavy to RAM and CPU, it's kinda dead. The only people that could help you are Google employees and they don't work on guetzli anymore.

ppoocde commented 5 years ago

thanks again I may have to spend more time to understand the code then. Refer to my original question, assume we don't modify any parameter. By default, params_.force420 and params.try_420 are set to false, theforefore, the following for loop are always executed: for (int downsample = force_420; downsample <= try_420; ++downsample) {

Therefore, the above code can be treated as redundant if we don't modify the parameter.