本文整理汇总了C++中DecoderState函数的典型用法代码示例。如果您正苦于以下问题:C++ DecoderState函数的具体用法?C++ DecoderState怎么用?C++ DecoderState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DecoderState函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TIFFInitLZW
int
TIFFInitLZW(TIFF* tif, int scheme)
{
assert(scheme == COMPRESSION_LZW);
/*
* Allocate state block so tag methods have storage to record values.
*/
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWCodecState));
if (tif->tif_data == NULL)
goto bad;
DecoderState(tif)->dec_codetab = NULL;
DecoderState(tif)->dec_decode = NULL;
EncoderState(tif)->enc_hashtab = NULL;
LZWState(tif)->rw_mode = tif->tif_mode;
/*
* Install codec methods.
*/
tif->tif_setupdecode = LZWSetupDecode;
tif->tif_predecode = LZWPreDecode;
tif->tif_decoderow = LZWDecode;
tif->tif_decodestrip = LZWDecode;
tif->tif_decodetile = LZWDecode;
tif->tif_setupencode = LZWSetupEncode;
tif->tif_preencode = LZWPreEncode;
tif->tif_postencode = LZWPostEncode;
tif->tif_encoderow = LZWEncode;
tif->tif_encodestrip = LZWEncode;
tif->tif_encodetile = LZWEncode;
tif->tif_cleanup = LZWCleanup;
/*
* Setup predictor setup.
*/
(void) TIFFPredictorInit(tif);
return (1);
bad:
TIFFErrorExt(tif->tif_clientdata, "TIFFInitLZW",
"No space for LZW state block");
return (0);
}
示例2: ZIPSetupDecode
static int
ZIPSetupDecode(TIFF* tif)
{
ZIPState* sp = DecoderState(tif);
static char module[] = "ZIPSetupDecode";
assert(sp != NULL);
if (inflateInit2(&sp->stream, -DEF_WBITS) != Z_OK) {
TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg);
return (0);
} else
return (1);
}
示例3: TWebPSetupDecode
static int
TWebPSetupDecode(TIFF* tif)
{
static const char module[] = "WebPSetupDecode";
uint16 nBitsPerSample = tif->tif_dir.td_bitspersample;
uint16 sampleFormat = tif->tif_dir.td_sampleformat;
WebPState* sp = DecoderState(tif);
assert(sp != NULL);
sp->nSamples = tif->tif_dir.td_samplesperpixel;
/* check band count */
if ( sp->nSamples != 3
#if WEBP_ENCODER_ABI_VERSION >= 0x0100
&& sp->nSamples != 4
#endif
)
{
TIFFErrorExt(tif->tif_clientdata, module,
"WEBP driver doesn't support %d bands. Must be 3 (RGB) "
#if WEBP_ENCODER_ABI_VERSION >= 0x0100
"or 4 (RGBA) "
#endif
"bands.",
sp->nSamples );
return 0;
}
/* check bits per sample and data type */
if ((nBitsPerSample != 8) && (sampleFormat != 1)) {
TIFFErrorExt(tif->tif_clientdata, module,
"WEBP driver requires 8 bit unsigned data");
return 0;
}
/* if we were last encoding, terminate this mode */
if (sp->state & LSTATE_INIT_ENCODE) {
WebPPictureFree(&sp->sPicture);
if (sp->pBuffer != NULL) {
_TIFFfree(sp->pBuffer);
sp->pBuffer = NULL;
}
sp->buffer_offset = 0;
sp->state = 0;
}
sp->state |= LSTATE_INIT_DECODE;
return 1;
}
示例4: TIFFInitLZW
int
TIFFInitLZW(TIFF* tif, int scheme)
{
assert(scheme == COMPRESSION_LZW);
/*
* Allocate state block so tag methods have storage to record values.
*/
tif->tif_data = (tidata_t) _TIFFmalloc(sizeof (LZWDecodeState));
if (tif->tif_data == NULL)
goto bad;
if (tif->tif_mode == O_RDONLY) {
DecoderState(tif)->dec_codetab = NULL;
DecoderState(tif)->dec_decode = NULL;
}
/*
* Install codec methods.
*/
tif->tif_setupdecode = LZWSetupDecode;
tif->tif_predecode = LZWPreDecode;
tif->tif_decoderow = LZWDecode;
tif->tif_decodestrip = LZWDecode;
tif->tif_decodetile = LZWDecode;
tif->tif_setupencode = _LZWtrue;
tif->tif_preencode = _TIFFNoPreCode;
tif->tif_postencode = _LZWtrue;
tif->tif_encoderow = _TIFFNoRowEncode;
tif->tif_encodestrip = _TIFFNoStripEncode;
tif->tif_encodetile = _TIFFNoTileEncode;
tif->tif_cleanup = LZWCleanup;
/*
* Setup predictor setup.
*/
(void) TIFFPredictorInit(tif);
return (1);
bad:
TIFFError("TIFFInitLZW", "No space for LZW state block");
return (0);
}
示例5: ZIPSetupDecode
static int
ZIPSetupDecode(TIFF* tif) {
ZIPState* sp = DecoderState(tif);
static const char module[] = "ZIPSetupDecode";
assert(sp != NULL);
if (inflateInit(&sp->stream) != Z_OK) {
TIFFError(module, "%s: %s", tif->tif_name, sp->stream.msg);
return (0);
} else {
sp->state |= ZSTATE_INIT;
return (1);
}
}
示例6: LogLuvDecode24
/*
* Decode a string of 24-bit pixels.
*/
static int
LogLuvDecode24(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
{
static const char module[] = "LogLuvDecode24";
LogLuvState* sp = DecoderState(tif);
tmsize_t cc;
tmsize_t i;
tmsize_t npixels;
unsigned char* bp;
uint32* tp;
assert(s == 0);
assert(sp != NULL);
npixels = occ / sp->pixel_size;
if (sp->user_datafmt == SGILOGDATAFMT_RAW)
tp = (uint32 *)op;
else {
assert(sp->tbuflen >= npixels);
tp = (uint32 *) sp->tbuf;
}
/* copy to array of uint32 */
bp = (unsigned char*) tif->tif_rawcp;
cc = tif->tif_rawcc;
for (i = 0; i < npixels && cc > 0; i++) {
tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2];
bp += 3;
cc -= 3;
}
tif->tif_rawcp = (uint8*) bp;
tif->tif_rawcc = cc;
if (i != npixels) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data at row %lu (short %I64d pixels)",
(unsigned long) tif->tif_row,
(unsigned __int64) (npixels - i));
#else
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data at row %lu (short %llu pixels)",
(unsigned long) tif->tif_row,
(unsigned long long) (npixels - i));
#endif
return (0);
}
(*sp->tfunc)(sp, op, npixels);
return (1);
}
示例7: ZIPPreDecode
/*
* Setup state for decoding a strip.
*/
static int
ZIPPreDecode(TIFF* tif, tsample_t s)
{
ZIPState* sp = DecoderState(tif);
(void) s;
assert(sp != NULL);
if( (sp->state & ZSTATE_INIT_DECODE) == 0 )
tif->tif_setupdecode( tif );
sp->stream.next_in = tif->tif_rawdata;
sp->stream.avail_in = tif->tif_rawcc;
return (inflateReset(&sp->stream) == Z_OK);
}
示例8: LERCSetupDecode
static int
LERCSetupDecode(TIFF* tif)
{
LERCState* sp = DecoderState(tif);
assert(sp != NULL);
/* if we were last encoding, terminate this mode */
if (sp->state & LSTATE_INIT_ENCODE) {
sp->state = 0;
}
sp->state |= LSTATE_INIT_DECODE;
return 1;
}
示例9: ZIPDecode
static int
ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
{
static const char module[] = "ZIPDecode";
ZIPState* sp = DecoderState(tif);
(void) s;
assert(sp != NULL);
assert(sp->state == ZSTATE_INIT_DECODE);
sp->stream.next_out = op;
assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised,
we need to simplify this code to reflect a ZLib that is likely updated
to deal with 8byte memory sizes, though this code will respond
apropriately even before we simplify it */
sp->stream.avail_out = (uInt) occ;
if ((tmsize_t)sp->stream.avail_out != occ)
{
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
return (0);
}
do {
int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
if (state == Z_STREAM_END)
break;
if (state == Z_DATA_ERROR) {
TIFFErrorExt(tif->tif_clientdata, module,
"Decoding error at scanline %lu, %s",
(unsigned long) tif->tif_row, sp->stream.msg);
if (inflateSync(&sp->stream) != Z_OK)
return (0);
continue;
}
if (state != Z_OK) {
TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
sp->stream.msg);
return (0);
}
} while (sp->stream.avail_out > 0);
if (sp->stream.avail_out != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data at scanline %lu (short %llu bytes)",
(unsigned long) tif->tif_row, (unsigned long long) sp->stream.avail_out);
return (0);
}
return (1);
}
示例10: ZIPSetupDecode
static int
ZIPSetupDecode(TIFF* tif)
{
ZIPState* sp = DecoderState(tif);
static const char module[] = "ZIPSetupDecode";
assert(sp != NULL);
/* if we were last encoding, terminate this mode */
if (sp->state & ZSTATE_INIT_ENCODE) {
deflateEnd(&sp->stream);
sp->state = 0;
}
if (inflateInit(&sp->stream) != Z_OK) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: %s", tif->tif_name, sp->stream.msg);
return (0);
} else {
sp->state |= ZSTATE_INIT_DECODE;
return (1);
}
}
示例11: LogLuvDecode24
/*
* Decode a string of 24-bit pixels.
*/
static int
LogLuvDecode24(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
{
LogLuvState* sp = DecoderState(tif);
int cc, i, npixels;
u_char* bp;
uint32* tp;
assert(s == 0);
assert(sp != NULL);
npixels = occ / sp->pixel_size;
if (sp->user_datafmt == SGILOGDATAFMT_RAW)
tp = (uint32 *)op;
else {
assert(sp->tbuflen >= npixels);
tp = (uint32 *) sp->tbuf;
}
_TIFFmemset((tdata_t) tp, 0, npixels*sizeof (tp[0]));
/* copy to array of uint32 */
bp = (u_char*) tif->tif_rawcp;
cc = tif->tif_rawcc;
for (i = 0; i < npixels && cc > 0; i++) {
tp[i] = bp[0] << 16 | bp[1] << 8 | bp[2];
bp += 3;
cc -= 3;
}
tif->tif_rawcp = (tidata_t) bp;
tif->tif_rawcc = cc;
if (i != npixels) {
TIFFError(tif->tif_name,
"LogLuvDecode24: Not enough data at row %d (short %d pixels)",
tif->tif_row, npixels - i);
return (0);
}
(*sp->tfunc)(sp, op, npixels);
return (1);
}
示例12: ZIPDecode
static int
ZIPDecode(TIFF* tif, tidata_t op, tsize_t occ, tsample_t s)
{
ZIPState* sp = DecoderState(tif);
static const char module[] = "ZIPDecode";
(void) s;
assert(sp != NULL);
assert(sp->state == ZSTATE_INIT_DECODE);
sp->stream.next_out = op;
sp->stream.avail_out = occ;
do {
int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
if (state == Z_STREAM_END)
break;
if (state == Z_DATA_ERROR) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Decoding error at scanline %d, %s",
tif->tif_name, tif->tif_row, sp->stream.msg);
if (inflateSync(&sp->stream) != Z_OK)
return (0);
continue;
}
if (state != Z_OK) {
TIFFErrorExt(tif->tif_clientdata, module, "%s: zlib error: %s",
tif->tif_name, sp->stream.msg);
return (0);
}
} while (sp->stream.avail_out > 0);
if (sp->stream.avail_out != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"%s: Not enough data at scanline %d (short %d bytes)",
tif->tif_name, tif->tif_row, sp->stream.avail_out);
return (0);
}
return (1);
}
示例13: LogLuvDecode32
/*
* Decode a string of 32-bit pixels.
*/
static int
LogLuvDecode32(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
{
static const char module[] = "LogLuvDecode32";
LogLuvState* sp;
int shft;
tmsize_t i;
tmsize_t npixels;
unsigned char* bp;
uint32* tp;
uint32 b;
tmsize_t cc;
int rc;
assert(s == 0);
sp = DecoderState(tif);
assert(sp != NULL);
npixels = occ / sp->pixel_size;
if (sp->user_datafmt == SGILOGDATAFMT_RAW)
tp = (uint32*) op;
else {
assert(sp->tbuflen >= npixels);
tp = (uint32*) sp->tbuf;
}
_TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0]));
bp = (unsigned char*) tif->tif_rawcp;
cc = tif->tif_rawcc;
/* get each byte string */
for (shft = 4*8; (shft -= 8) >= 0; ) {
for (i = 0; i < npixels && cc > 0; )
if (*bp >= 128) { /* run */
rc = *bp++ + (2-128);
b = (uint32)*bp++ << shft;
cc -= 2; /* TODO: potential input buffer overrun when decoding corrupt or truncated data */
while (rc-- && i < npixels)
tp[i++] |= b;
} else { /* non-run */
rc = *bp++; /* nul is noop */
while (--cc && rc-- && i < npixels)
tp[i++] |= (uint32)*bp++ << shft;
}
if (i != npixels) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data at row %lu (short %I64d pixels)",
(unsigned long) tif->tif_row,
(unsigned __int64) (npixels - i));
#else
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data at row %lu (short %llu pixels)",
(unsigned long) tif->tif_row,
(unsigned long long) (npixels - i));
#endif
tif->tif_rawcp = (uint8*) bp;
tif->tif_rawcc = cc;
return (0);
}
}
(*sp->tfunc)(sp, op, npixels);
tif->tif_rawcp = (uint8*) bp;
tif->tif_rawcc = cc;
return (1);
}
示例14: LogL16Decode
/*
* Decode a string of 16-bit gray pixels.
*/
static int
LogL16Decode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
{
static const char module[] = "LogL16Decode";
LogLuvState* sp = DecoderState(tif);
int shft;
tmsize_t i;
tmsize_t npixels;
unsigned char* bp;
int16* tp;
int16 b;
tmsize_t cc;
int rc;
assert(s == 0);
assert(sp != NULL);
npixels = occ / sp->pixel_size;
if (sp->user_datafmt == SGILOGDATAFMT_16BIT)
tp = (int16*) op;
else {
if(sp->tbuflen < npixels) {
TIFFErrorExt(tif->tif_clientdata, module,
"Translation buffer too short");
return (0);
}
tp = (int16*) sp->tbuf;
}
_TIFFmemset((void*) tp, 0, npixels*sizeof (tp[0]));
bp = (unsigned char*) tif->tif_rawcp;
cc = tif->tif_rawcc;
/* get each byte string */
for (shft = 2*8; (shft -= 8) >= 0; ) {
for (i = 0; i < npixels && cc > 0; ) {
if (*bp >= 128) { /* run */
if( cc < 2 )
break;
rc = *bp++ + (2-128);
b = (int16)(*bp++ << shft);
cc -= 2;
while (rc-- && i < npixels)
tp[i++] |= b;
} else { /* non-run */
rc = *bp++; /* nul is noop */
while (--cc && rc-- && i < npixels)
tp[i++] |= (int16)*bp++ << shft;
}
}
if (i != npixels) {
#if defined(__WIN32__) && (defined(_MSC_VER) || defined(__MINGW32__))
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data at row %lu (short %I64d pixels)",
(unsigned long) tif->tif_row,
(unsigned __int64) (npixels - i));
#else
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data at row %lu (short %llu pixels)",
(unsigned long) tif->tif_row,
(unsigned long long) (npixels - i));
#endif
tif->tif_rawcp = (uint8*) bp;
tif->tif_rawcc = cc;
return (0);
}
}
(*sp->tfunc)(sp, op, npixels);
tif->tif_rawcp = (uint8*) bp;
tif->tif_rawcc = cc;
return (1);
}
示例15: ZIPDecode
static int
ZIPDecode(TIFF* tif, uint8* op, tmsize_t occ, uint16 s)
{
static const char module[] = "ZIPDecode";
ZIPState* sp = DecoderState(tif);
(void) s;
assert(sp != NULL);
assert(sp->state == ZSTATE_INIT_DECODE);
sp->stream.next_in = tif->tif_rawcp;
sp->stream.avail_in = (uInt) tif->tif_rawcc;
sp->stream.next_out = op;
assert(sizeof(sp->stream.avail_out)==4); /* if this assert gets raised,
we need to simplify this code to reflect a ZLib that is likely updated
to deal with 8byte memory sizes, though this code will respond
apropriately even before we simplify it */
sp->stream.avail_out = (uInt) occ;
if ((tmsize_t)sp->stream.avail_out != occ)
{
TIFFErrorExt(tif->tif_clientdata, module, "ZLib cannot deal with buffers this size");
return (0);
}
#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */
# pragma ivdep
# pragma swp
# pragma unroll
# pragma prefetch
# if 0
# pragma simd noassert
# endif
#endif /* VDM auto patch */
do {
int state = inflate(&sp->stream, Z_PARTIAL_FLUSH);
if (state == Z_STREAM_END)
break;
if (state == Z_DATA_ERROR) {
TIFFErrorExt(tif->tif_clientdata, module,
"Decoding error at scanline %lu, %s",
(unsigned long) tif->tif_row, sp->stream.msg);
if (inflateSync(&sp->stream) != Z_OK)
return (0);
continue;
}
if (state != Z_OK) {
TIFFErrorExt(tif->tif_clientdata, module, "ZLib error: %s",
sp->stream.msg);
return (0);
}
} while (sp->stream.avail_out > 0);
if (sp->stream.avail_out != 0) {
TIFFErrorExt(tif->tif_clientdata, module,
"Not enough data at scanline %lu (short " TIFF_UINT64_FORMAT " bytes)",
(unsigned long) tif->tif_row, (TIFF_UINT64_T) sp->stream.avail_out);
return (0);
}
tif->tif_rawcp = sp->stream.next_in;
tif->tif_rawcc = sp->stream.avail_in;
return (1);
}