summaryrefslogtreecommitdiff
path: root/libtiff/tif_lzma.c
diff options
context:
space:
mode:
authorAndrey Kiselev <dron@ak4719.spb.edu>2010-12-23 13:07:38 +0000
committerAndrey Kiselev <dron@ak4719.spb.edu>2010-12-23 13:07:38 +0000
commit73ca7bd1a5e4982cf1aa6711ce4fcc6697459d3e (patch)
treee563518d1bd2d1b9890dd959d6f7f9f6530e1cb3 /libtiff/tif_lzma.c
parent9f29be434f795332e5737ea5b98340fe5b758afb (diff)
downloadlibtiff-git-73ca7bd1a5e4982cf1aa6711ce4fcc6697459d3e.tar.gz
Properly set the LZMA2 compression level (preset) in LZMAVSetField().
Diffstat (limited to 'libtiff/tif_lzma.c')
-rw-r--r--libtiff/tif_lzma.c22
1 files changed, 17 insertions, 5 deletions
diff --git a/libtiff/tif_lzma.c b/libtiff/tif_lzma.c
index f54016e0..3b4b5ab5 100644
--- a/libtiff/tif_lzma.c
+++ b/libtiff/tif_lzma.c
@@ -1,4 +1,4 @@
-/* $Id: tif_lzma.c,v 1.1 2010-12-14 12:53:00 dron Exp $ */
+/* $Id: tif_lzma.c,v 1.2 2010-12-23 13:07:38 dron Exp $ */
/*
* Copyright (c) 2010, Andrey Kiselev <dron@ak4719.spb.edu>
@@ -342,8 +342,10 @@ LZMACleanup(TIFF* tif)
tif->tif_tagmethods.vgetfield = sp->vgetparent;
tif->tif_tagmethods.vsetfield = sp->vsetparent;
- lzma_end(&sp->stream);
- sp->state = 0;
+ if (sp->state) {
+ lzma_end(&sp->stream);
+ sp->state = 0;
+ }
_TIFFfree(sp);
tif->tif_data = NULL;
@@ -353,13 +355,23 @@ LZMACleanup(TIFF* tif)
static int
LZMAVSetField(TIFF* tif, uint32 tag, va_list ap)
{
+ static const char module[] = "LZMAVSetField";
LZMAState* sp = LState(tif);
switch (tag) {
case TIFFTAG_LZMAPRESET:
sp->preset = (int) va_arg(ap, int);
- if ( sp->state & LSTATE_INIT_ENCODE )
- lzma_lzma_preset(&sp->opt_lzma, sp->preset);
+ lzma_lzma_preset(&sp->opt_lzma, sp->preset);
+ if (sp->state & LSTATE_INIT_ENCODE) {
+ lzma_ret ret = lzma_stream_encoder(&sp->stream,
+ sp->filters,
+ sp->check);
+ if (ret != LZMA_OK) {
+ TIFFErrorExt(tif->tif_clientdata, module,
+ "Liblzma error: %s",
+ LZMAStrerror(ret));
+ }
+ }
return 1;
default:
return (*sp->vsetparent)(tif, tag, ap);