summaryrefslogtreecommitdiff
path: root/core/fxcodec/codec
diff options
context:
space:
mode:
Diffstat (limited to 'core/fxcodec/codec')
-rw-r--r--core/fxcodec/codec/codec_int.h1
-rw-r--r--core/fxcodec/codec/fx_codec_flate.cpp6
-rw-r--r--core/fxcodec/codec/fx_codec_jpx_opj.cpp16
-rw-r--r--core/fxcodec/codec/fx_codec_tiff.cpp6
4 files changed, 16 insertions, 13 deletions
diff --git a/core/fxcodec/codec/codec_int.h b/core/fxcodec/codec/codec_int.h
index d2f44dd674..d19a694222 100644
--- a/core/fxcodec/codec/codec_int.h
+++ b/core/fxcodec/codec/codec_int.h
@@ -47,7 +47,6 @@ class CCodec_ScanlineDecoder : public ICodec_ScanlineDecoder {
~CCodec_ScanlineDecoder() override;
// ICodec_ScanlineDecoder
- FX_DWORD GetSrcOffset() override { return -1; }
void DownScale(int dest_width, int dest_height) override;
const uint8_t* GetScanline(int line) override;
FX_BOOL SkipToScanline(int line, IFX_Pause* pPause) override;
diff --git a/core/fxcodec/codec/fx_codec_flate.cpp b/core/fxcodec/codec/fx_codec_flate.cpp
index 49a4f34166..27416f1c67 100644
--- a/core/fxcodec/codec/fx_codec_flate.cpp
+++ b/core/fxcodec/codec/fx_codec_flate.cpp
@@ -147,7 +147,7 @@ int CLZWDecoder::Decode(uint8_t* dest_buf,
m_Early = bEarlyChange ? 1 : 0;
m_nCodes = 0;
FX_DWORD old_code = (FX_DWORD)-1;
- uint8_t last_char;
+ uint8_t last_char = 0;
while (1) {
if (m_InPos + m_CodeLen > src_size * 8) {
break;
@@ -942,7 +942,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW,
offset = src_size;
int err = decoder->Decode(NULL, dest_size, src_buf, offset, bEarlyChange);
if (err || dest_size == 0 || dest_size + 1 < dest_size) {
- return -1;
+ return static_cast<FX_DWORD>(-1);
}
}
{
@@ -965,7 +965,7 @@ FX_DWORD CCodec_FlateModule::FlateOrLZWDecode(FX_BOOL bLZW,
ret =
TIFF_Predictor(dest_buf, dest_size, Colors, BitsPerComponent, Columns);
}
- return ret ? offset : -1;
+ return ret ? offset : static_cast<FX_DWORD>(-1);
}
FX_BOOL CCodec_FlateModule::Encode(const uint8_t* src_buf,
FX_DWORD src_size,
diff --git a/core/fxcodec/codec/fx_codec_jpx_opj.cpp b/core/fxcodec/codec/fx_codec_jpx_opj.cpp
index aaa89388b8..a57b93df22 100644
--- a/core/fxcodec/codec/fx_codec_jpx_opj.cpp
+++ b/core/fxcodec/codec/fx_codec_jpx_opj.cpp
@@ -24,16 +24,17 @@ static void fx_warning_callback(const char* msg, void* client_data) {
static void fx_info_callback(const char* msg, void* client_data) {
(void)client_data;
}
+
OPJ_SIZE_T opj_read_from_memory(void* p_buffer,
OPJ_SIZE_T nb_bytes,
void* p_user_data) {
DecodeData* srcData = static_cast<DecodeData*>(p_user_data);
if (!srcData || !srcData->src_data || srcData->src_size == 0) {
- return -1;
+ return static_cast<OPJ_SIZE_T>(-1);
}
// Reads at EOF return an error code.
if (srcData->offset >= srcData->src_size) {
- return -1;
+ return static_cast<OPJ_SIZE_T>(-1);
}
OPJ_SIZE_T bufferLength = srcData->src_size - srcData->offset;
OPJ_SIZE_T readlength = nb_bytes < bufferLength ? nb_bytes : bufferLength;
@@ -41,16 +42,17 @@ OPJ_SIZE_T opj_read_from_memory(void* p_buffer,
srcData->offset += readlength;
return readlength;
}
+
OPJ_SIZE_T opj_write_from_memory(void* p_buffer,
OPJ_SIZE_T nb_bytes,
void* p_user_data) {
DecodeData* srcData = static_cast<DecodeData*>(p_user_data);
if (!srcData || !srcData->src_data || srcData->src_size == 0) {
- return -1;
+ return static_cast<OPJ_SIZE_T>(-1);
}
// Writes at EOF return an error code.
if (srcData->offset >= srcData->src_size) {
- return -1;
+ return static_cast<OPJ_SIZE_T>(-1);
}
OPJ_SIZE_T bufferLength = srcData->src_size - srcData->offset;
OPJ_SIZE_T writeLength = nb_bytes < bufferLength ? nb_bytes : bufferLength;
@@ -58,17 +60,18 @@ OPJ_SIZE_T opj_write_from_memory(void* p_buffer,
srcData->offset += writeLength;
return writeLength;
}
+
OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data) {
DecodeData* srcData = static_cast<DecodeData*>(p_user_data);
if (!srcData || !srcData->src_data || srcData->src_size == 0) {
- return -1;
+ return static_cast<OPJ_OFF_T>(-1);
}
// Offsets are signed and may indicate a negative skip. Do not support this
// because of the strange return convention where either bytes skipped or
// -1 is returned. Following that convention, a successful relative seek of
// -1 bytes would be required to to give the same result as the error case.
if (nb_bytes < 0) {
- return -1;
+ return static_cast<OPJ_OFF_T>(-1);
}
// FIXME: use std::make_unsigned<OPJ_OFF_T>::type once c++11 lib is OK'd.
uint64_t unsignedNbBytes = static_cast<uint64_t>(nb_bytes);
@@ -89,6 +92,7 @@ OPJ_OFF_T opj_skip_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data) {
}
return nb_bytes;
}
+
OPJ_BOOL opj_seek_from_memory(OPJ_OFF_T nb_bytes, void* p_user_data) {
DecodeData* srcData = static_cast<DecodeData*>(p_user_data);
if (!srcData || !srcData->src_data || srcData->src_size == 0) {
diff --git a/core/fxcodec/codec/fx_codec_tiff.cpp b/core/fxcodec/codec/fx_codec_tiff.cpp
index 2af92f2f12..0312622fb4 100644
--- a/core/fxcodec/codec/fx_codec_tiff.cpp
+++ b/core/fxcodec/codec/fx_codec_tiff.cpp
@@ -122,20 +122,20 @@ static toff_t _tiff_seek(thandle_t context, toff_t offset, int whence) {
case 2:
if (pTiffContext->isDecoder) {
if (pTiffContext->io.in->GetSize() < (FX_FILESIZE)offset) {
- return -1;
+ return static_cast<toff_t>(-1);
}
pTiffContext->offset =
(FX_DWORD)(pTiffContext->io.in->GetSize() - offset);
} else {
if (pTiffContext->io.out->GetSize() < (FX_FILESIZE)offset) {
- return -1;
+ return static_cast<toff_t>(-1);
}
pTiffContext->offset =
(FX_DWORD)(pTiffContext->io.out->GetSize() - offset);
}
break;
default:
- return -1;
+ return static_cast<toff_t>(-1);
}
ASSERT(pTiffContext->isDecoder ? (pTiffContext->offset <=
(FX_DWORD)pTiffContext->io.in->GetSize())