fixed
This commit is contained in:
parent
507ea95265
commit
12279e2631
@ -2894,21 +2894,20 @@ class DctIPPLoop_Invoker : public ParallelLoopBody
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
DctIPPLoop_Invoker(const Mat& _src, Mat& _dst, const Dct& _ippidct, bool _inv, bool *_ok) :
|
DctIPPLoop_Invoker(const Mat& _src, Mat& _dst, const Dct* _ippidct, bool _inv, bool *_ok) :
|
||||||
ParallelLoopBody(), src(_src), dst(_dst), ippidct(_ippidct), inv(_inv), ok(_ok)
|
ParallelLoopBody(), src(&_src), dst(&_dst), ippidct(_ippidct), inv(_inv), ok(_ok)
|
||||||
{
|
{
|
||||||
*ok = true;
|
*ok = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void operator()(const Range& range) const
|
virtual void operator()(const Range& range) const
|
||||||
{
|
{
|
||||||
IppStatus status;
|
|
||||||
void* pDCTSpec;
|
void* pDCTSpec;
|
||||||
AutoBuffer<uchar> buf;
|
AutoBuffer<uchar> buf;
|
||||||
uchar* pBuffer = 0;
|
uchar* pBuffer = 0;
|
||||||
int bufSize=0;
|
int bufSize=0;
|
||||||
|
|
||||||
IppiSize srcRoiSize = {src.cols, 1};
|
IppiSize srcRoiSize = {src->cols, 1};
|
||||||
|
|
||||||
CV_SUPPRESS_DEPRECATED_START
|
CV_SUPPRESS_DEPRECATED_START
|
||||||
|
|
||||||
@ -2916,51 +2915,37 @@ public:
|
|||||||
ippiDCTFree ippFree = inv ? (ippiDCTFree)ippiDCTInvFree_32f : (ippiDCTFree)ippiDCTFwdFree_32f;
|
ippiDCTFree ippFree = inv ? (ippiDCTFree)ippiDCTInvFree_32f : (ippiDCTFree)ippiDCTFwdFree_32f;
|
||||||
ippiDCTGetBufSize ippGetBufSize = inv ? (ippiDCTGetBufSize)ippiDCTInvGetBufSize_32f : (ippiDCTGetBufSize)ippiDCTFwdGetBufSize_32f;
|
ippiDCTGetBufSize ippGetBufSize = inv ? (ippiDCTGetBufSize)ippiDCTInvGetBufSize_32f : (ippiDCTGetBufSize)ippiDCTFwdGetBufSize_32f;
|
||||||
|
|
||||||
status = ippInitAlloc(&pDCTSpec, srcRoiSize, ippAlgHintNone);
|
if (ippInitAlloc(&pDCTSpec, srcRoiSize, ippAlgHintNone)>=0 && ippGetBufSize(pDCTSpec, &bufSize)>=0)
|
||||||
|
|
||||||
if ( status < 0 )
|
|
||||||
{
|
{
|
||||||
ippFree(pDCTSpec);
|
buf.allocate( bufSize );
|
||||||
*ok = false;
|
pBuffer = (uchar*)buf;
|
||||||
return;
|
|
||||||
|
for( int i = range.start; i < range.end; ++i)
|
||||||
|
if(!(*ippidct)((float*)(src->data+i*src->step), (int)src->step,(float*)(dst->data+i*dst->step), (int)dst->step, pDCTSpec, (Ipp8u*)pBuffer))
|
||||||
|
*ok = false;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
status = ippGetBufSize(pDCTSpec, &bufSize);
|
|
||||||
if ( status < 0 )
|
|
||||||
{
|
|
||||||
ippFree(pDCTSpec);
|
|
||||||
*ok = false;
|
*ok = false;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.allocate( bufSize );
|
if (pDCTSpec)
|
||||||
pBuffer = (uchar*)buf;
|
ippFree(pDCTSpec);
|
||||||
|
|
||||||
for( int i = range.start; i < range.end; ++i)
|
|
||||||
if(!ippidct((float*)(src.data+i*src.step), (int)src.step,(float*)(dst.data+i*dst.step), (int)dst.step, pDCTSpec, (Ipp8u*)pBuffer))
|
|
||||||
{
|
|
||||||
*ok = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ippFree( pDCTSpec);
|
|
||||||
CV_SUPPRESS_DEPRECATED_END
|
CV_SUPPRESS_DEPRECATED_END
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Mat& src;
|
const Mat* src;
|
||||||
Mat& dst;
|
Mat* dst;
|
||||||
const Dct& ippidct;
|
const Dct* ippidct;
|
||||||
bool inv;
|
bool inv;
|
||||||
bool *ok;
|
bool *ok;
|
||||||
|
|
||||||
const DctIPPLoop_Invoker& operator= (const DctIPPLoop_Invoker&);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Dct>
|
template <typename Dct>
|
||||||
bool DctIPPLoop(const Mat& src, Mat& dst, const Dct& ippidct, bool inv)
|
bool DctIPPLoop(const Mat& src, Mat& dst, const Dct& ippidct, bool inv)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
parallel_for_(Range(0, src.rows), DctIPPLoop_Invoker<Dct>(src, dst, ippidct, inv, &ok), src.rows/(double)(1<<4) );
|
parallel_for_(Range(0, src.rows), DctIPPLoop_Invoker<Dct>(src, dst, &ippidct, inv, &ok), src.rows/(double)(1<<4) );
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2981,10 +2966,7 @@ static bool ippi_DCT_32f(const Mat& src, Mat& dst, bool inv, bool row)
|
|||||||
ippiDCTFunc ippFunc = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R ;
|
ippiDCTFunc ippFunc = inv ? (ippiDCTFunc)ippiDCTInv_32f_C1R : (ippiDCTFunc)ippiDCTFwd_32f_C1R ;
|
||||||
|
|
||||||
if (row)
|
if (row)
|
||||||
if(DctIPPLoop(src,dst,IPPDCTFunctor(ippFunc),inv))
|
return(DctIPPLoop(src,dst,IPPDCTFunctor(ippFunc),inv));
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IppStatus status;
|
IppStatus status;
|
||||||
@ -3001,27 +2983,19 @@ static bool ippi_DCT_32f(const Mat& src, Mat& dst, bool inv, bool row)
|
|||||||
ippiDCTFree ippFree = inv ? (ippiDCTFree)ippiDCTInvFree_32f : (ippiDCTFree)ippiDCTFwdFree_32f;
|
ippiDCTFree ippFree = inv ? (ippiDCTFree)ippiDCTInvFree_32f : (ippiDCTFree)ippiDCTFwdFree_32f;
|
||||||
ippiDCTGetBufSize ippGetBufSize = inv ? (ippiDCTGetBufSize)ippiDCTInvGetBufSize_32f : (ippiDCTGetBufSize)ippiDCTFwdGetBufSize_32f;
|
ippiDCTGetBufSize ippGetBufSize = inv ? (ippiDCTGetBufSize)ippiDCTInvGetBufSize_32f : (ippiDCTGetBufSize)ippiDCTFwdGetBufSize_32f;
|
||||||
|
|
||||||
status = ippInitAlloc(&pDCTSpec, srcRoiSize, ippAlgHintNone);
|
status = ippStsErr;
|
||||||
|
|
||||||
if ( status < 0 )
|
if (ippInitAlloc(&pDCTSpec, srcRoiSize, ippAlgHintNone)>=0 && ippGetBufSize(pDCTSpec, &bufSize)>=0)
|
||||||
{
|
{
|
||||||
ippFree(pDCTSpec);
|
buf.allocate( bufSize );
|
||||||
return false;
|
pBuffer = (uchar*)buf;
|
||||||
|
|
||||||
|
status = ippFunc((float*)src.data, (int)src.step, (float*)dst.data, (int)dst.step, pDCTSpec, (Ipp8u*)pBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ippGetBufSize(pDCTSpec, &bufSize);
|
if (pDCTSpec)
|
||||||
if ( status < 0 )
|
|
||||||
{
|
|
||||||
ippFree(pDCTSpec);
|
ippFree(pDCTSpec);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
buf.allocate( bufSize );
|
|
||||||
pBuffer = (uchar*)buf;
|
|
||||||
|
|
||||||
status = ippFunc((float*)src.data, (int)src.step, (float*)dst.data, (int)dst.step, pDCTSpec, (Ipp8u*)pBuffer);
|
|
||||||
|
|
||||||
ippFree(pDCTSpec);
|
|
||||||
CV_SUPPRESS_DEPRECATED_END
|
CV_SUPPRESS_DEPRECATED_END
|
||||||
|
|
||||||
return status >= 0;
|
return status >= 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user