fixed memory leaks in cvtyuv tests

This commit is contained in:
Ilya Lavrenov 2015-08-15 10:06:09 +03:00
parent 7719da9552
commit b2489d31d6

View File

@ -548,7 +548,7 @@ void referenceRGB2YUV(const Mat& rgb, Mat& yuv, RGBreader* rgbReader, YUVwriter*
struct ConversionYUV
{
ConversionYUV( const int code )
explicit ConversionYUV( const int code )
{
yuvReader_ = YUVreader :: getReader(code);
yuvWriter_ = YUVwriter :: getWriter(code);
@ -557,6 +557,24 @@ struct ConversionYUV
grayWriter_ = GRAYwriter:: getWriter(code);
}
~ConversionYUV()
{
if (yuvReader_)
delete yuvReader_;
if (yuvWriter_)
delete yuvWriter_;
if (rgbReader_)
delete rgbReader_;
if (rgbReader_)
delete rgbReader_;
if (grayWriter_)
delete grayWriter_;
}
int getDcn()
{
return (rgbWriter_ != 0) ? rgbWriter_->channels() : ((grayWriter_ != 0) ? grayWriter_->channels() : yuvWriter_->channels());