forgot a few backports - release

This commit is contained in:
philippe44
2020-02-26 23:48:18 -08:00
parent 1ae8f80e53
commit c00f513be7
4 changed files with 8 additions and 52 deletions

View File

@@ -90,10 +90,13 @@ static uint16_t* DecodeJPEG(uint8_t *Source, int *Width, int *Height, float Scal
Decoder.scale = Scale;
if (Res == JDR_OK && !SizeOnly) {
// ready to decode
// find the scaling factor
Context.OutData = malloc(Decoder.width * Decoder.height * sizeof(uint16_t));
uint8_t N = 0, iScale = 1.0 / Scale;
while (iScale >>= 1) N++;
uint8_t N = 0, ScaleInt = ceil(1.0 / Scale);
ScaleInt--; ScaleInt |= ScaleInt >> 1; ScaleInt |= ScaleInt >> 2; ScaleInt++;
while (ScaleInt >>= 1) N++;
// ready to decode
if (Context.OutData) {
Context.Width = Decoder.width / (1 << N);
Context.Height = Decoder.height / (1 << N);