-
Notifications
You must be signed in to change notification settings - Fork 468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encode: do not perform rate control for single-tile lossless #1009
Comments
Correct solution is to simply include all passes in a single layer for single-layer lossless |
Do you have examples where that occurs ? |
No, I can't remember the exact case, but I saw this happening when I removed the limit of 10 resolution levels. Also, if you look at the logic in the code, you can see how this might happen. But, even without a test image, there is no reason to perform rate control on single layer lossless image. |
Actually I don't see how that could happen. Lossless encoding implies cp->m_specific_param.m_enc.m_disto_alloc == 1 and tcd_tcp->rates[0] == 0. Which implies in opj_tcd_rateallocate() that goodthresh = min; which is the minimum of dd / dr for all passes of all code blocks ( openjpeg/src/lib/openjp2/tcd.c Line 616 in a55c024
openjpeg/src/lib/openjp2/tcd.c Lines 291 to 292 in a55c024
|
hmmmm. Well, I guess that was a false alarm then :) |
How about lossless with multiple layers ? Could the final layer be missing some passes ? If so, that would be a problem. |
The same logic will apply for multiple layers. For lossless encoding, the last layer should have tcd_tcp->rates[layno] == 0, in which case all remaining coding passes will be selected. I just committed a fix for opj_compress help which indicated 1 instead of 0 for this lossless terminating layer |
For So, looks like everything is correct then. Closing. |
Actually that doesn't match my experiments. You really need to set 0 to get all the remaining coding passes in the final layer. 1 gets you almost to lossless, but not completely |
Well, what I would do is keep the 1 for compression ratio flag, and then convert to 0 in the code. Compression ratio of 0 is a bit counter-intuitive. You could let the user know that 1 == final lossless layer. |
i.e. set |
Also sanity check that ratios are decreasing and >= 1 |
…alue to get lossless for -r. In opj_j2k_setup_encoder(), make sure that ll rates[] <= 1.0 are set to 0. Document 0 as being lossless for -q / tcp_distoratio (#1009)
So, I think the key logic to look at is how distortion delta So, that's why there should be no rate control at all on final layer, if it is a lossless one. Just include everything and do not look at |
…g or tcp_distoratio are not increasing (#1009)
…yer (#1009) And save a useless loop, which should be a tiny faster.
OK, b428b8c should really make sure to include all passes for a lossless layer |
Looks good. |
Yes, 7aa071a will warn about that |
Cool. |
Currently, for single tile lossless, rate control is performed, although it is not needed.
This can lead to lossy encoding if there are code passes at the end of a code block that do not
contribute to a rate increase. The rate control algorithm will remove these code passes,
leading to potential lossy encode.
The text was updated successfully, but these errors were encountered: