Commit 3bc7b608 authored by Nabiullin, Oleg's avatar Nabiullin, Oleg Committed by Dmitry Ermilov

JPEGe/JPEGd code cleanup

1) Explicitly delete unused ctors/assignment operators.
2) Remove unused CJPEGEncoder::SelectScanScripts(). Current implementation
of CJPEGEncoder::SelectScanScripts() is broken, and the function is not
called currently.
3) Check for NULL before dereference of pointers.

Issue: MDP-52543
(cherry picked from commit 6542fb71)
parent e0e5434f
......@@ -48,6 +48,11 @@ public:
CJPEGDecoderHuffmanTable(void);
virtual ~CJPEGDecoderHuffmanTable(void);
CJPEGDecoderHuffmanTable(const CJPEGDecoderHuffmanTable&) = delete;
CJPEGDecoderHuffmanTable(CJPEGDecoderHuffmanTable&&) = delete;
CJPEGDecoderHuffmanTable& operator=(const CJPEGDecoderHuffmanTable&) = delete;
CJPEGDecoderHuffmanTable& operator=(CJPEGDecoderHuffmanTable&&) = delete;
JERRCODE Create(void);
JERRCODE Destroy(void);
......@@ -76,6 +81,11 @@ public:
CJPEGDecoderHuffmanState(void);
virtual ~CJPEGDecoderHuffmanState(void);
CJPEGDecoderHuffmanState(const CJPEGDecoderHuffmanState&) = delete;
CJPEGDecoderHuffmanState(CJPEGDecoderHuffmanState&&) = delete;
CJPEGDecoderHuffmanState& operator=(const CJPEGDecoderHuffmanState&) = delete;
CJPEGDecoderHuffmanState& operator=(CJPEGDecoderHuffmanState&&) = delete;
JERRCODE Create(void);
JERRCODE Destroy(void);
......
......@@ -2886,6 +2886,12 @@ JERRCODE CJPEGDecoder::ReconstructMCURowBL8x8To1x1(int16_t* pMCUBuf,
{
curr_comp = &m_ccomp[c];
qtbl = m_qntbl[curr_comp->m_q_selector];
if(!qtbl)
{
LOG1("Error: in CJPEGDecoder::ReconstructMCURowBL8x8To1x1() m_qntbl[] is empty for ",
curr_comp->m_q_selector);
return JPEG_ERR_INTERNAL;
}
for(k = 0; k < curr_comp->m_vsampling; k++)
{
......@@ -2899,7 +2905,7 @@ JERRCODE CJPEGDecoder::ReconstructMCURowBL8x8To1x1(int16_t* pMCUBuf,
{
dst += (l == 0) ? 0 : 1;
DCT_QUANT_INV8x8To1x1LS(pMCUBuf, dst, qtbl);
DCT_QUANT_INV8x8To1x1LS(pMCUBuf, dst, qtbl);
pMCUBuf += DCTSIZE2;
} // for m_hsampling
......
......@@ -59,7 +59,12 @@ public:
CJPEGEncoder(void);
virtual ~CJPEGEncoder(void);
JERRCODE SetSource(
CJPEGEncoder(const CJPEGEncoder&) = delete;
CJPEGEncoder(CJPEGEncoder&&) = delete;
CJPEGEncoder& operator=(const CJPEGEncoder&) = delete;
CJPEGEncoder& operator=(CJPEGEncoder&&) = delete;
JERRCODE SetSource(
uint8_t* pSrc,
int srcStep,
mfxSize srcSize,
......@@ -265,7 +270,6 @@ protected:
JERRCODE EncodeScanProgressive(void);
JERRCODE EncodeScan(int ncomp,int id[MAX_COMPS_PER_SCAN],int Ss,int Se,int Ah,int Al);
JERRCODE SelectScanScripts(void);
JERRCODE GenerateHuffmanTables(int ncomp,int id[MAX_COMPS_PER_SCAN],int Ss,int Se,int Ah,int Al);
JERRCODE GenerateHuffmanTables(void);
JERRCODE GenerateHuffmanTablesEX(void);
......
......@@ -1954,289 +1954,6 @@ JERRCODE CJPEGEncoder::WriteSOS(
} // CJPEGEncoder::WriteSOS()
JERRCODE CJPEGEncoder::SelectScanScripts(void)
{
if(0 != m_scan_script)
{
delete[] m_scan_script;
m_scan_script = 0;
}
switch(m_jpeg_ncomp)
{
case 1:
//m_scan_count = 6;
//m_scan_script = new JPEG_SCAN [m_scan_count];
// 1 DC scan, def
m_scan_script[0].ncomp = 1;
m_scan_script[0].id[0] = 0;
m_scan_script[0].Ss = 0;
m_scan_script[0].Se = 0;
m_scan_script[0].Ah = 0;
m_scan_script[0].Al = 1;
// 2 AC scan, def(luma)
m_scan_script[1].ncomp = 1;
m_scan_script[1].id[0] = 0;
m_scan_script[1].Ss = 1;
m_scan_script[1].Se = 5;
m_scan_script[1].Ah = 0;
m_scan_script[1].Al = 2;
// 3 AC scan, def(luma)
m_scan_script[2].ncomp = 1;
m_scan_script[2].id[0] = 0;
m_scan_script[2].Ss = 6;
m_scan_script[2].Se = 63;
m_scan_script[2].Ah = 0;
m_scan_script[2].Al = 2;
// 4 AC scan, ref(luma)
m_scan_script[3].ncomp = 1;
m_scan_script[3].id[0] = 0;
m_scan_script[3].Ss = 1;
m_scan_script[3].Se = 63;
m_scan_script[3].Ah = 2;
m_scan_script[3].Al = 1;
// 5 DC scan, ref
m_scan_script[4].ncomp = 1;
m_scan_script[4].id[0] = 0;
m_scan_script[4].Ss = 0;
m_scan_script[4].Se = 0;
m_scan_script[4].Ah = 1;
m_scan_script[4].Al = 0;
// 6 AC scan, ref(luma)
m_scan_script[5].ncomp = 1;
m_scan_script[5].id[0] = 0;
m_scan_script[5].Ss = 1;
m_scan_script[5].Se = 63;
m_scan_script[5].Ah = 1;
m_scan_script[5].Al = 0;
break;
case 3:
//m_scan_count = 10;
//m_scan_script = new JPEG_SCAN [m_scan_count];
// 1 DC scan, def
m_scan_script[0].ncomp = 3;
m_scan_script[0].id[0] = 0;
m_scan_script[0].id[1] = 1;
m_scan_script[0].id[2] = 2;
m_scan_script[0].Ss = 0;
m_scan_script[0].Se = 0;
m_scan_script[0].Ah = 0;
m_scan_script[0].Al = 1;
// 2 AC scan, def(luma)
m_scan_script[1].ncomp = 1;
m_scan_script[1].id[0] = 0;
m_scan_script[1].Ss = 1;
m_scan_script[1].Se = 5;
m_scan_script[1].Ah = 0;
m_scan_script[1].Al = 2;
// 3 AC scan, def(cr)
m_scan_script[2].ncomp = 1;
m_scan_script[2].id[0] = 2;
m_scan_script[2].Ss = 1;
m_scan_script[2].Se = 63;
m_scan_script[2].Ah = 0;
m_scan_script[2].Al = 1;
// 4 AC scan, def(cb)
m_scan_script[3].ncomp = 1;
m_scan_script[3].id[0] = 1;
m_scan_script[3].Ss = 1;
m_scan_script[3].Se = 63;
m_scan_script[3].Ah = 0;
m_scan_script[3].Al = 1;
// 5 AC scan, def(luma)
m_scan_script[4].ncomp = 1;
m_scan_script[4].id[0] = 0;
m_scan_script[4].Ss = 6;
m_scan_script[4].Se = 63;
m_scan_script[4].Ah = 0;
m_scan_script[4].Al = 2;
// 7 AC scan, ref(luma)
m_scan_script[5].ncomp = 1;
m_scan_script[5].id[0] = 0;
m_scan_script[5].Ss = 1;
m_scan_script[5].Se = 63;
m_scan_script[5].Ah = 2;
m_scan_script[5].Al = 1;
// 6 DC scan, ref
m_scan_script[6].ncomp = 3;
m_scan_script[6].id[0] = 0;
m_scan_script[6].id[1] = 1;
m_scan_script[6].id[2] = 2;
m_scan_script[6].Ss = 0;
m_scan_script[6].Se = 0;
m_scan_script[6].Ah = 1;
m_scan_script[6].Al = 0;
// 8 AC scan, ref(cr)
m_scan_script[7].ncomp = 1;
m_scan_script[7].id[0] = 2;
m_scan_script[7].Ss = 1;
m_scan_script[7].Se = 63;
m_scan_script[7].Ah = 1;
m_scan_script[7].Al = 0;
// 9 AC scan, ref(cb)
m_scan_script[8].ncomp = 1;
m_scan_script[8].id[0] = 1;
m_scan_script[8].Ss = 1;
m_scan_script[8].Se = 63;
m_scan_script[8].Ah = 1;
m_scan_script[8].Al = 0;
// 10 AC scan, ref(luma)
m_scan_script[9].ncomp = 1;
m_scan_script[9].id[0] = 0;
m_scan_script[9].Ss = 1;
m_scan_script[9].Se = 63;
m_scan_script[9].Ah = 1;
m_scan_script[9].Al = 0;
break;
case 4:
//m_scan_count = 18;
//m_scan_script = new JPEG_SCAN [m_scan_count];
// 1 DC scan, def
m_scan_script[0].ncomp = 4;
m_scan_script[0].id[0] = 0;
m_scan_script[0].id[1] = 1;
m_scan_script[0].id[2] = 2;
m_scan_script[0].id[3] = 3;
m_scan_script[0].Ss = 0;
m_scan_script[0].Se = 0;
m_scan_script[0].Ah = 0;
m_scan_script[0].Al = 1;
// 2 AC scan, def(0)
m_scan_script[1].ncomp = 1;
m_scan_script[1].id[0] = 0;
m_scan_script[1].Ss = 1;
m_scan_script[1].Se = 5;
m_scan_script[1].Ah = 0;
m_scan_script[1].Al = 2;
// 3 AC scan, def(1)
m_scan_script[2].ncomp = 1;
m_scan_script[2].id[0] = 1;
m_scan_script[2].Ss = 1;
m_scan_script[2].Se = 5;
m_scan_script[2].Ah = 0;
m_scan_script[2].Al = 2;
// 4 AC scan, def(2)
m_scan_script[3].ncomp = 1;
m_scan_script[3].id[0] = 2;
m_scan_script[3].Ss = 1;
m_scan_script[3].Se = 5;
m_scan_script[3].Ah = 0;
m_scan_script[3].Al = 2;
// 5 AC scan, def(3)
m_scan_script[4].ncomp = 1;
m_scan_script[4].id[0] = 3;
m_scan_script[4].Ss = 1;
m_scan_script[4].Se = 5;
m_scan_script[4].Ah = 0;
m_scan_script[4].Al = 2;
// 6 AC scan, def(0)
m_scan_script[5].ncomp = 1;
m_scan_script[5].id[0] = 0;
m_scan_script[5].Ss = 6;
m_scan_script[5].Se = 63;
m_scan_script[5].Ah = 0;
m_scan_script[5].Al = 2;
// 7 AC scan, def(1)
m_scan_script[6].ncomp = 1;
m_scan_script[6].id[0] = 1;
m_scan_script[6].Ss = 6;
m_scan_script[6].Se = 63;
m_scan_script[6].Ah = 0;
m_scan_script[6].Al = 2;
// 8 AC scan, def(2)
m_scan_script[7].ncomp = 1;
m_scan_script[7].id[0] = 2;
m_scan_script[7].Ss = 6;
m_scan_script[7].Se = 63;
m_scan_script[7].Ah = 0;
m_scan_script[7].Al = 2;
// 9 AC scan, def(3)
m_scan_script[8].ncomp = 1;
m_scan_script[8].id[0] = 3;
m_scan_script[8].Ss = 6;
m_scan_script[8].Se = 63;
m_scan_script[8].Ah = 0;
m_scan_script[8].Al = 2;
// 10 AC scan, ref(0)
m_scan_script[9].ncomp = 1;
m_scan_script[9].id[0] = 0;
m_scan_script[9].Ss = 1;
m_scan_script[9].Se = 63;
m_scan_script[9].Ah = 2;
m_scan_script[9].Al = 1;
// 11 AC scan, ref(1)
m_scan_script[10].ncomp = 1;
m_scan_script[10].id[0] = 1;
m_scan_script[10].Ss = 1;
m_scan_script[10].Se = 63;
m_scan_script[10].Ah = 2;
m_scan_script[10].Al = 1;
// 12 AC scan, ref(2)
m_scan_script[11].ncomp = 1;
m_scan_script[11].id[0] = 2;
m_scan_script[11].Ss = 1;
m_scan_script[11].Se = 63;
m_scan_script[11].Ah = 2;
m_scan_script[11].Al = 1;
// 13 AC scan, ref(3)
m_scan_script[12].ncomp = 1;
m_scan_script[12].id[0] = 3;
m_scan_script[12].Ss = 1;
m_scan_script[12].Se = 63;
m_scan_script[12].Ah = 2;
m_scan_script[12].Al = 1;
// 14 DC scan, ref
m_scan_script[13].ncomp = 4;
m_scan_script[13].id[0] = 0;
m_scan_script[13].id[1] = 1;
m_scan_script[13].id[2] = 2;
m_scan_script[13].id[3] = 3;
m_scan_script[13].Ss = 0;
m_scan_script[13].Se = 0;
m_scan_script[13].Ah = 1;
m_scan_script[13].Al = 0;
// 15 AC scan, ref(0)
m_scan_script[14].ncomp = 1;
m_scan_script[14].id[0] = 0;
m_scan_script[14].Ss = 1;
m_scan_script[14].Se = 63;
m_scan_script[14].Ah = 1;
m_scan_script[14].Al = 0;
// 16 AC scan, ref(1)
m_scan_script[15].ncomp = 1;
m_scan_script[15].id[0] = 1;
m_scan_script[15].Ss = 1;
m_scan_script[15].Se = 63;
m_scan_script[15].Ah = 1;
m_scan_script[15].Al = 0;
// 17 AC scan, ref(2)
m_scan_script[16].ncomp = 1;
m_scan_script[16].id[0] = 2;
m_scan_script[16].Ss = 1;
m_scan_script[16].Se = 63;
m_scan_script[16].Ah = 1;
m_scan_script[16].Al = 0;
// 18 AC scan, ref(3)
m_scan_script[17].ncomp = 1;
m_scan_script[17].id[0] = 3;
m_scan_script[17].Ss = 1;
m_scan_script[17].Se = 63;
m_scan_script[17].Ah = 1;
m_scan_script[17].Al = 0;
break;
default:
return JPEG_NOT_IMPLEMENTED;
}
return JPEG_OK;
} // CJPEGEncoder::SelectScanScripts()
JERRCODE CJPEGEncoder::Init(void)
{
......@@ -2349,7 +2066,8 @@ JERRCODE CJPEGEncoder::Init(void)
if(JPEG_PROGRESSIVE == m_jpeg_mode)
{
SelectScanScripts();
LOG0("Error: JPEG_PROGRESSIVE is not supported in CJPEGEncoder::Init()");
return JPEG_NOT_IMPLEMENTED;
}
if(m_num_scans != 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment