Increase JPG/MP3 in-memory threshold

- maximum size 512 MB instead of 64 MB
- verbose output if JPGs are too large for in-memory (and packJPG is used as fallback)
This commit is contained in:
Christian Schneider 2019-11-07 00:14:21 +01:00
parent 905e32a127
commit 7fc569949e
3 changed files with 9 additions and 4 deletions

View file

@ -1,6 +1,8 @@
// Motion JPEG DHT header
// JPEG DHT Segment for YCrCb omitted from MJPEG data
#define JPG_MAX_MEMORY_SIZE 512 * 1024 * 1024
#define MJPGDHT_LEN 420
unsigned char MJPGDHT[MJPGDHT_LEN] = {
0xFF,0xC4,0x01,0xA2,

View file

@ -3,7 +3,7 @@
#include "pmp3tbl.h"
#undef PRECOMP_MP3
#define MP3_MAX_MEMORY_SIZE 64 * 1024 * 1024
#define MP3_MAX_MEMORY_SIZE 512 * 1024 * 1024
// function to convert MP3 to PMP and vice versa, file to file
bool pmplib_convert_file2file( char* in, char* out, char* msg );

View file

@ -4857,7 +4857,7 @@ while (fin_pos < fin_length) {
unsigned char* jpg_mem_in = NULL;
unsigned char* jpg_mem_out = NULL;
unsigned int jpg_mem_out_size = -1;
bool in_memory = (recompressed_data_length <= MAX_IO_BUFFER_SIZE);
bool in_memory = (recompressed_data_length <= JPG_MAX_MEMORY_SIZE);
bool recompress_success = false;
if (in_memory) {
@ -6587,7 +6587,7 @@ void try_decompression_jpg (long long jpg_length, bool progressive_jpg) {
unsigned char* jpg_mem_in = NULL;
unsigned char* jpg_mem_out = NULL;
unsigned int jpg_mem_out_size = -1;
bool in_memory = ((jpg_length + MJPGDHT_LEN) <= MAX_IO_BUFFER_SIZE);
bool in_memory = ((jpg_length + MJPGDHT_LEN) <= JPG_MAX_MEMORY_SIZE);
if (in_memory) { // small stream => do everything in memory
jpg_mem_in = new unsigned char[jpg_length + MJPGDHT_LEN];
@ -6677,7 +6677,10 @@ void try_decompression_jpg (long long jpg_length, bool progressive_jpg) {
brotli_used = false;
}
} else { // large stream => use temporary files
// try to decompress at current position
if (DEBUG_MODE) {
printf("JPG too large for brunsli, using packJPG fallback...\n");
}
// try to decompress at current position
fjpg = tryOpen(tempfile0,"wb");
seek_64(fin, input_file_pos);
fast_copy(fin, fjpg, jpg_length);