mirror of
https://github.com/Xevion/easy7zip.git
synced 2025-12-11 23:09:54 -06:00
@@ -51,7 +51,7 @@ struct writelist {
|
|||||||
|
|
||||||
struct LZ4MT_CCtx_s {
|
struct LZ4MT_CCtx_s {
|
||||||
|
|
||||||
/* level: 1..22 */
|
/* level: 1..LZ4MT_LEVEL_MAX */
|
||||||
int level;
|
int level;
|
||||||
|
|
||||||
/* threads: 1..LZ4MT_THREAD_MAX */
|
/* threads: 1..LZ4MT_THREAD_MAX */
|
||||||
@@ -111,7 +111,9 @@ LZ4MT_CCtx *LZ4MT_createCCtx(int threads, int level, int inputsize)
|
|||||||
if (inputsize)
|
if (inputsize)
|
||||||
ctx->inputsize = inputsize;
|
ctx->inputsize = inputsize;
|
||||||
else
|
else
|
||||||
ctx->inputsize = 1024 * 64;
|
ctx->inputsize = 1024 * 1024 * 4;
|
||||||
|
|
||||||
|
/* printf("XX level=%d threads=%d inputsize=%d\n", level, threads, inputsize); */
|
||||||
|
|
||||||
/* setup ctx */
|
/* setup ctx */
|
||||||
ctx->level = level;
|
ctx->level = level;
|
||||||
@@ -277,26 +279,48 @@ static void *pt_compress(void *arg)
|
|||||||
pthread_mutex_unlock(&ctx->read_mutex);
|
pthread_mutex_unlock(&ctx->read_mutex);
|
||||||
|
|
||||||
/* compress whole frame */
|
/* compress whole frame */
|
||||||
|
if (ctx->threads != 1) {
|
||||||
|
/* with SKIPPABLE frame info */
|
||||||
result =
|
result =
|
||||||
LZ4F_compressFrame((unsigned char *)wl->out.buf + 12,
|
LZ4F_compressFrame((unsigned char *)wl->out.buf +
|
||||||
wl->out.size - 12, in.buf, in.size,
|
12, wl->out.size - 12, in.buf,
|
||||||
&w->zpref);
|
in.size, &w->zpref);
|
||||||
|
|
||||||
if (LZ4F_isError(result)) {
|
if (LZ4F_isError(result)) {
|
||||||
pthread_mutex_lock(&ctx->write_mutex);
|
pthread_mutex_lock(&ctx->write_mutex);
|
||||||
list_move(&wl->node, &ctx->writelist_free);
|
list_move(&wl->node, &ctx->writelist_free);
|
||||||
pthread_mutex_unlock(&ctx->write_mutex);
|
pthread_mutex_unlock(&ctx->write_mutex);
|
||||||
|
|
||||||
/* user can lookup that code */
|
/* user can lookup that code */
|
||||||
lz4mt_errcode = result;
|
lz4mt_errcode = result;
|
||||||
return (void *)ERROR(compression_library);
|
return (void *)ERROR(compression_library);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write skippable frame */
|
/* write skippable frame */
|
||||||
if (ctx->threads > 1) {
|
|
||||||
MEM_writeLE32((unsigned char *)wl->out.buf + 0,
|
MEM_writeLE32((unsigned char *)wl->out.buf + 0,
|
||||||
LZ4FMT_MAGIC_SKIPPABLE);
|
LZ4FMT_MAGIC_SKIPPABLE);
|
||||||
MEM_writeLE32((unsigned char *)wl->out.buf + 4, 4);
|
MEM_writeLE32((unsigned char *)wl->out.buf + 4, 4);
|
||||||
MEM_writeLE32((unsigned char *)wl->out.buf + 8, (U32) result);
|
MEM_writeLE32((unsigned char *)wl->out.buf + 8,
|
||||||
|
(U32) result);
|
||||||
wl->out.size = result + 12;
|
wl->out.size = result + 12;
|
||||||
|
} else {
|
||||||
|
/* WITHOUT SKIPPABLE frame info */
|
||||||
|
result =
|
||||||
|
LZ4F_compressFrame((unsigned char *)wl->out.buf,
|
||||||
|
wl->out.size, in.buf, in.size,
|
||||||
|
&w->zpref);
|
||||||
|
|
||||||
|
if (LZ4F_isError(result)) {
|
||||||
|
pthread_mutex_lock(&ctx->write_mutex);
|
||||||
|
list_move(&wl->node, &ctx->writelist_free);
|
||||||
|
pthread_mutex_unlock(&ctx->write_mutex);
|
||||||
|
|
||||||
|
/* user can lookup that code */
|
||||||
|
lz4mt_errcode = result;
|
||||||
|
return (void *)ERROR(compression_library);
|
||||||
|
}
|
||||||
|
|
||||||
|
wl->out.size = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* write result */
|
/* write result */
|
||||||
|
|||||||
Reference in New Issue
Block a user