Skip to content

Commit 7fc5699

Browse files
committed
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)
1 parent 905e32a commit 7fc5699

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

contrib/packjpg/precomp_jpg.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Motion JPEG DHT header
22
// JPEG DHT Segment for YCrCb omitted from MJPEG data
33

4+
#define JPG_MAX_MEMORY_SIZE 512 * 1024 * 1024
5+
46
#define MJPGDHT_LEN 420
57
unsigned char MJPGDHT[MJPGDHT_LEN] = {
68
0xFF,0xC4,0x01,0xA2,

contrib/packmp3/precomp_mp3.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "pmp3tbl.h"
44
#undef PRECOMP_MP3
55

6-
#define MP3_MAX_MEMORY_SIZE 64 * 1024 * 1024
6+
#define MP3_MAX_MEMORY_SIZE 512 * 1024 * 1024
77

88
// function to convert MP3 to PMP and vice versa, file to file
99
bool pmplib_convert_file2file( char* in, char* out, char* msg );

precomp.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4857,7 +4857,7 @@ while (fin_pos < fin_length) {
48574857
unsigned char* jpg_mem_in = NULL;
48584858
unsigned char* jpg_mem_out = NULL;
48594859
unsigned int jpg_mem_out_size = -1;
4860-
bool in_memory = (recompressed_data_length <= MAX_IO_BUFFER_SIZE);
4860+
bool in_memory = (recompressed_data_length <= JPG_MAX_MEMORY_SIZE);
48614861
bool recompress_success = false;
48624862

48634863
if (in_memory) {
@@ -6587,7 +6587,7 @@ void try_decompression_jpg (long long jpg_length, bool progressive_jpg) {
65876587
unsigned char* jpg_mem_in = NULL;
65886588
unsigned char* jpg_mem_out = NULL;
65896589
unsigned int jpg_mem_out_size = -1;
6590-
bool in_memory = ((jpg_length + MJPGDHT_LEN) <= MAX_IO_BUFFER_SIZE);
6590+
bool in_memory = ((jpg_length + MJPGDHT_LEN) <= JPG_MAX_MEMORY_SIZE);
65916591

65926592
if (in_memory) { // small stream => do everything in memory
65936593
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) {
66776677
brotli_used = false;
66786678
}
66796679
} else { // large stream => use temporary files
6680-
// try to decompress at current position
6680+
if (DEBUG_MODE) {
6681+
printf("JPG too large for brunsli, using packJPG fallback...\n");
6682+
}
6683+
// try to decompress at current position
66816684
fjpg = tryOpen(tempfile0,"wb");
66826685
seek_64(fin, input_file_pos);
66836686
fast_copy(fin, fjpg, jpg_length);

0 commit comments

Comments
 (0)