summaryrefslogtreecommitdiff
path: root/core/src/fxcodec/codec
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2015-10-30 13:33:35 -0700
committerTom Sepez <tsepez@chromium.org>2015-10-30 13:33:35 -0700
commit3d59bd9d66d01eb39c30742bce67fa0376cb4ea8 (patch)
tree7e68785f0a1316afa573870dac473d830e12ce94 /core/src/fxcodec/codec
parent71c5a4c83ba4a3bdb322a19a24dba1ac57655199 (diff)
downloadpdfium-3d59bd9d66d01eb39c30742bce67fa0376cb4ea8.tar.xz
Remove external jpeg provider interface.
It is unused in PDFium. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1407903005 .
Diffstat (limited to 'core/src/fxcodec/codec')
-rw-r--r--core/src/fxcodec/codec/codec_int.h28
-rw-r--r--core/src/fxcodec/codec/fx_codec_jpeg.cpp67
2 files changed, 16 insertions, 79 deletions
diff --git a/core/src/fxcodec/codec/codec_int.h b/core/src/fxcodec/codec/codec_int.h
index 9f408dd9a2..1fd228996d 100644
--- a/core/src/fxcodec/codec/codec_int.h
+++ b/core/src/fxcodec/codec/codec_int.h
@@ -158,14 +158,13 @@ class CCodec_FlateModule : public ICodec_FlateModule {
class CCodec_JpegModule : public ICodec_JpegModule {
public:
- CCodec_JpegModule() : m_pExtProvider(NULL) {}
- void SetPovider(IFX_JpegProvider* pJP) { m_pExtProvider = pJP; }
+ CCodec_JpegModule() {}
ICodec_ScanlineDecoder* CreateDecoder(const uint8_t* src_buf,
FX_DWORD src_size,
int width,
int height,
int nComps,
- FX_BOOL ColorTransform);
+ FX_BOOL ColorTransform) override;
FX_BOOL LoadInfo(const uint8_t* src_buf,
FX_DWORD src_size,
int& width,
@@ -174,23 +173,22 @@ class CCodec_JpegModule : public ICodec_JpegModule {
int& bits_per_components,
FX_BOOL& color_transform,
uint8_t** icc_buf_ptr,
- FX_DWORD* icc_length);
+ FX_DWORD* icc_length) override;
FX_BOOL Encode(const CFX_DIBSource* pSource,
uint8_t*& dest_buf,
FX_STRSIZE& dest_size,
int quality,
const uint8_t* icc_buf,
- FX_DWORD icc_length);
- virtual void* Start();
- virtual void Finish(void* pContext);
- virtual void Input(void* pContext, const uint8_t* src_buf, FX_DWORD src_size);
- virtual int ReadHeader(void* pContext, int* width, int* height, int* nComps);
- virtual int StartScanline(void* pContext, int down_scale);
- virtual FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf);
- virtual FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr);
-
- protected:
- IFX_JpegProvider* m_pExtProvider;
+ FX_DWORD icc_length) override;
+ void* Start() override;
+ void Finish(void* pContext) override;
+ void Input(void* pContext,
+ const uint8_t* src_buf,
+ FX_DWORD src_size) override;
+ int ReadHeader(void* pContext, int* width, int* height, int* nComps) override;
+ int StartScanline(void* pContext, int down_scale) override;
+ FX_BOOL ReadScanline(void* pContext, uint8_t* dest_buf) override;
+ FX_DWORD GetAvailInput(void* pContext, uint8_t** avail_buf_ptr) override;
};
class CCodec_IccModule : public ICodec_IccModule {
public:
diff --git a/core/src/fxcodec/codec/fx_codec_jpeg.cpp b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
index 4fdbb8ed29..544a6d14cf 100644
--- a/core/src/fxcodec/codec/fx_codec_jpeg.cpp
+++ b/core/src/fxcodec/codec/fx_codec_jpeg.cpp
@@ -296,8 +296,7 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder {
int width,
int height,
int nComps,
- FX_BOOL ColorTransform,
- IFX_JpegProvider* pJP);
+ FX_BOOL ColorTransform);
void Destroy() { delete this; }
// CCodec_ScanlineDecoder
@@ -321,8 +320,6 @@ class CCodec_JpegDecoder : public CCodec_ScanlineDecoder {
FX_BOOL m_bJpegTransform;
protected:
- IFX_JpegProvider* m_pExtProvider;
- void* m_pExtContext;
FX_DWORD m_nDefaultScaleDenom;
};
@@ -331,18 +328,12 @@ CCodec_JpegDecoder::CCodec_JpegDecoder() {
m_DownScale = 1;
m_bStarted = FALSE;
m_bInited = FALSE;
- m_pExtProvider = NULL;
- m_pExtContext = NULL;
FXSYS_memset(&cinfo, 0, sizeof(cinfo));
FXSYS_memset(&jerr, 0, sizeof(jerr));
FXSYS_memset(&src, 0, sizeof(src));
m_nDefaultScaleDenom = 1;
}
CCodec_JpegDecoder::~CCodec_JpegDecoder() {
- if (m_pExtProvider) {
- m_pExtProvider->DestroyDecoder(m_pExtContext);
- return;
- }
FX_Free(m_pScanlineBuf);
if (m_bInited) {
jpeg_destroy_decompress(&cinfo);
@@ -388,14 +379,7 @@ FX_BOOL CCodec_JpegDecoder::Create(const uint8_t* src_buf,
int width,
int height,
int nComps,
- FX_BOOL ColorTransform,
- IFX_JpegProvider* pJP) {
- if (pJP) {
- m_pExtProvider = pJP;
- m_pExtContext = m_pExtProvider->CreateDecoder(
- src_buf, src_size, width, height, nComps, ColorTransform);
- return m_pExtContext != NULL;
- }
+ FX_BOOL ColorTransform) {
_JpegScanSOI(src_buf, src_size);
m_SrcBuf = src_buf;
m_SrcSize = src_size;
@@ -455,10 +439,6 @@ int32_t FX_GetDownsampleRatio(int32_t originWidth,
}
}
void CCodec_JpegDecoder::v_DownScale(int dest_width, int dest_height) {
- if (m_pExtProvider) {
- m_pExtProvider->DownScale(m_pExtContext, dest_width, dest_height);
- return;
- }
int old_scale = m_DownScale;
m_DownScale =
FX_GetDownsampleRatio(m_OrigWidth, m_OrigHeight, dest_width, dest_height);
@@ -470,9 +450,6 @@ void CCodec_JpegDecoder::v_DownScale(int dest_width, int dest_height) {
}
}
FX_BOOL CCodec_JpegDecoder::v_Rewind() {
- if (m_pExtProvider) {
- return m_pExtProvider->Rewind(m_pExtContext);
- }
if (m_bStarted) {
jpeg_destroy_decompress(&cinfo);
if (!InitDecode()) {
@@ -497,9 +474,6 @@ FX_BOOL CCodec_JpegDecoder::v_Rewind() {
return TRUE;
}
uint8_t* CCodec_JpegDecoder::v_GetNextLine() {
- if (m_pExtProvider) {
- return m_pExtProvider->GetNextLine(m_pExtContext);
- }
int nlines = jpeg_read_scanlines(&cinfo, &m_pScanlineBuf, 1);
if (nlines < 1) {
return NULL;
@@ -507,9 +481,6 @@ uint8_t* CCodec_JpegDecoder::v_GetNextLine() {
return m_pScanlineBuf;
}
FX_DWORD CCodec_JpegDecoder::GetSrcOffset() {
- if (m_pExtProvider) {
- return m_pExtProvider->GetSrcOffset(m_pExtContext);
- }
return (FX_DWORD)(m_SrcSize - src.bytes_in_buffer);
}
ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
@@ -524,7 +495,7 @@ ICodec_ScanlineDecoder* CCodec_JpegModule::CreateDecoder(
}
CCodec_JpegDecoder* pDecoder = new CCodec_JpegDecoder;
if (!pDecoder->Create(src_buf, src_size, width, height, nComps,
- ColorTransform, m_pExtProvider)) {
+ ColorTransform)) {
delete pDecoder;
return NULL;
}
@@ -539,11 +510,6 @@ FX_BOOL CCodec_JpegModule::LoadInfo(const uint8_t* src_buf,
FX_BOOL& color_transform,
uint8_t** icc_buf_ptr,
FX_DWORD* icc_length) {
- if (m_pExtProvider) {
- return m_pExtProvider->LoadInfo(src_buf, src_size, width, height,
- num_components, bits_per_components,
- color_transform, icc_buf_ptr, icc_length);
- }
return _JpegLoadInfo(src_buf, src_size, width, height, num_components,
bits_per_components, color_transform, icc_buf_ptr,
icc_length);
@@ -554,10 +520,6 @@ FX_BOOL CCodec_JpegModule::Encode(const CFX_DIBSource* pSource,
int quality,
const uint8_t* icc_buf,
FX_DWORD icc_length) {
- if (m_pExtProvider) {
- return m_pExtProvider->Encode(pSource, dest_buf, dest_size, quality,
- icc_buf, icc_length);
- }
if (pSource->GetBPP() < 8 || pSource->GetPalette() != NULL) {
ASSERT(pSource->GetBPP() >= 8 && pSource->GetPalette() == NULL);
return FALSE;
@@ -598,9 +560,6 @@ static void jpeg_free_func(void* p) {
FX_Free(p);
}
void* CCodec_JpegModule::Start() {
- if (m_pExtProvider) {
- return m_pExtProvider->Start();
- }
FXJPEG_Context* p = FX_Alloc(FXJPEG_Context, 1);
p->m_AllocFunc = jpeg_alloc_func;
p->m_FreeFunc = jpeg_free_func;
@@ -625,10 +584,6 @@ void* CCodec_JpegModule::Start() {
return p;
}
void CCodec_JpegModule::Finish(void* pContext) {
- if (m_pExtProvider) {
- m_pExtProvider->Finish(pContext);
- return;
- }
FXJPEG_Context* p = (FXJPEG_Context*)pContext;
jpeg_destroy_decompress(&p->m_Info);
p->m_FreeFunc(p);
@@ -636,10 +591,6 @@ void CCodec_JpegModule::Finish(void* pContext) {
void CCodec_JpegModule::Input(void* pContext,
const unsigned char* src_buf,
FX_DWORD src_size) {
- if (m_pExtProvider) {
- m_pExtProvider->Input(pContext, src_buf, src_size);
- return;
- }
FXJPEG_Context* p = (FXJPEG_Context*)pContext;
if (p->m_SkipSize) {
if (p->m_SkipSize > src_size) {
@@ -658,9 +609,6 @@ int CCodec_JpegModule::ReadHeader(void* pContext,
int* width,
int* height,
int* nComps) {
- if (m_pExtProvider) {
- return m_pExtProvider->ReadHeader(pContext, width, height, nComps);
- }
FXJPEG_Context* p = (FXJPEG_Context*)pContext;
if (setjmp(p->m_JumpMark) == -1) {
return 1;
@@ -678,9 +626,6 @@ int CCodec_JpegModule::ReadHeader(void* pContext,
return 0;
}
int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) {
- if (m_pExtProvider) {
- return m_pExtProvider->StartScanline(pContext, down_scale);
- }
FXJPEG_Context* p = (FXJPEG_Context*)pContext;
if (setjmp(p->m_JumpMark) == -1) {
return 0;
@@ -690,9 +635,6 @@ int CCodec_JpegModule::StartScanline(void* pContext, int down_scale) {
}
FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext,
unsigned char* dest_buf) {
- if (m_pExtProvider) {
- return m_pExtProvider->ReadScanline(pContext, dest_buf);
- }
FXJPEG_Context* p = (FXJPEG_Context*)pContext;
if (setjmp(p->m_JumpMark) == -1) {
return FALSE;
@@ -702,9 +644,6 @@ FX_BOOL CCodec_JpegModule::ReadScanline(void* pContext,
}
FX_DWORD CCodec_JpegModule::GetAvailInput(void* pContext,
uint8_t** avail_buf_ptr) {
- if (m_pExtProvider) {
- return m_pExtProvider->GetAvailInput(pContext, avail_buf_ptr);
- }
if (avail_buf_ptr != NULL) {
*avail_buf_ptr = NULL;
if (((FXJPEG_Context*)pContext)->m_SrcMgr.bytes_in_buffer > 0) {