Reduce IDE JPEG quality.

This commit is contained in:
iabdalkader 2016-08-15 01:10:39 +02:00
parent 34ffa826dd
commit d9c8b1535d
2 changed files with 18 additions and 5 deletions

View File

@ -540,11 +540,11 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
jpeg_subsample_t jpeg_subsample; jpeg_subsample_t jpeg_subsample;
if (quality > 70) { if (quality > 60) {
jpeg_subsample = JPEG_SUBSAMPLE_1x1; jpeg_subsample = JPEG_SUBSAMPLE_1x1;
} else if (quality > 50) { } else if (quality > 35) {
jpeg_subsample = JPEG_SUBSAMPLE_2x1; jpeg_subsample = JPEG_SUBSAMPLE_2x1;
} else { // <= 50 } else { // <= 35
jpeg_subsample = JPEG_SUBSAMPLE_2x2; jpeg_subsample = JPEG_SUBSAMPLE_2x2;
} }
@ -572,6 +572,9 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
} }
DCY = jpeg_processDU(&jpeg_buf, YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT); DCY = jpeg_processDU(&jpeg_buf, YDU, fdtbl_Y, DCY, YDC_HT, YAC_HT);
} }
if (jpeg_buf.overflow) {
goto jpeg_overflow;
}
} }
} else if (src->bpp == 2) {// TODO assuming RGB565 } else if (src->bpp == 2) {// TODO assuming RGB565
switch (jpeg_subsample) { switch (jpeg_subsample) {
@ -620,6 +623,9 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
DCU = jpeg_processDU(&jpeg_buf, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCU = jpeg_processDU(&jpeg_buf, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
DCV = jpeg_processDU(&jpeg_buf, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); DCV = jpeg_processDU(&jpeg_buf, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
} }
if (jpeg_buf.overflow) {
goto jpeg_overflow;
}
} }
break; break;
} }
@ -674,6 +680,9 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
DCU = jpeg_processDU(&jpeg_buf, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCU = jpeg_processDU(&jpeg_buf, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
DCV = jpeg_processDU(&jpeg_buf, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); DCV = jpeg_processDU(&jpeg_buf, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
} }
if (jpeg_buf.overflow) {
goto jpeg_overflow;
}
} }
break; break;
} }
@ -750,6 +759,9 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
DCU = jpeg_processDU(&jpeg_buf, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT); DCU = jpeg_processDU(&jpeg_buf, UDU, fdtbl_UV, DCU, UVDC_HT, UVAC_HT);
DCV = jpeg_processDU(&jpeg_buf, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT); DCV = jpeg_processDU(&jpeg_buf, VDU, fdtbl_UV, DCV, UVDC_HT, UVAC_HT);
} }
if (jpeg_buf.overflow) {
goto jpeg_overflow;
}
} }
break; break;
} }
@ -771,6 +783,7 @@ bool jpeg_compress(image_t *src, image_t *dst, int quality, bool realloc)
printf("time: %lums\n", HAL_GetTick() - start); printf("time: %lums\n", HAL_GetTick() - start);
#endif #endif
jpeg_overflow:
return jpeg_buf.overflow; return jpeg_buf.overflow;
} }

View File

@ -170,7 +170,7 @@ void sensor_init0()
memset(JPEG_FB(), 0, sizeof(*JPEG_FB())); memset(JPEG_FB(), 0, sizeof(*JPEG_FB()));
// Set default quality // Set default quality
JPEG_FB()->quality = 50; JPEG_FB()->quality = 35;
// Set fb_enabled // Set fb_enabled
JPEG_FB()->enabled = fb_enabled; JPEG_FB()->enabled = fb_enabled;
@ -636,7 +636,7 @@ int sensor_snapshot(image_t *image, line_filter_t line_filter_func, void *line_f
} }
// No buffer overflow, increase quality up to max quality based on frame size // No buffer overflow, increase quality up to max quality based on frame size
if (overflow_count == 0 && if (overflow_count == 0 &&
JPEG_FB()->quality < ((MAIN_FB_SIZE() > JPEG_QUALITY_THRESH) ? 50:75)) { JPEG_FB()->quality < ((MAIN_FB_SIZE() > JPEG_QUALITY_THRESH) ? 35:60)) {
JPEG_FB()->quality++; JPEG_FB()->quality++;
} }
// Set FB from JPEG image // Set FB from JPEG image