rawTherapee/rtengine/imagedata.h
George Hilliard ec814dbf05 FramesData: Don't leak allocated frames, and remove unused functions
Valgrind report:

```
14,960 (11,544 direct, 3,416 indirect) bytes in 37 blocks are definitely lost in loss record 20,483 of 20,540
   at 0x4837DEF: operator new(unsigned long) (vg_replace_malloc.c:334)
   by 0xC06963: rtengine::FramesData::FramesData(Glib::ustring const&, std::unique_ptr<rtengine::RawMetaDataLocation, std::default_delete<rtengine::RawMetaDataLocation> >, bool) (imagedata.cc:1121)
   by 0xBD774F: rtengine::DFManager::addFileInfo(Glib::ustring const&, bool) (dfmanager.cc:380)
   by 0xBD6E90: rtengine::DFManager::init(Glib::ustring) (dfmanager.cc:303)
   by 0xC3EC5D: rtengine::init(rtengine::Settings const*, Glib::ustring, Glib::ustring, bool) [clone ._omp_fn.0] (init.cc:93)
   by 0x897CABD: gomp_thread_start (team.c:120)
   by 0x89B7A9C: start_thread (in /usr/lib/libpthread-2.28.so)
   by 0x8ACCB22: clone (in /usr/lib/libc-2.28.so)
```
2018-11-02 03:07:07 -05:00

135 lines
4.5 KiB
C++

/*
* This file is part of RawTherapee.
*
* Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
*
* RawTherapee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* RawTherapee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __IMAGEDATA_H__
#define __IMAGEDATA_H__
#include <cstdio>
#include <memory>
#include "rawimage.h"
#include <string>
#include <glibmm.h>
#include "../rtexif/rtexif.h"
#include "procparams.h"
#include <libiptcdata/iptc-data.h>
#include "rtengine.h"
namespace rtengine
{
class FrameData
{
protected:
rtexif::TagDirectory* frameRootDir;
IptcData* iptc;
struct tm time;
time_t timeStamp;
int iso_speed;
double aperture;
double focal_len, focal_len35mm;
float focus_dist; // dist: 0=unknown, 10000=infinity
double shutter;
double expcomp;
std::string make, model, serial;
std::string orientation;
std::string lens;
IIOSampleFormat sampleFormat;
// each frame has the knowledge of "being an"
// or "being part of an" HDR or PS image
bool isPixelShift;
bool isHDR;
public:
FrameData (rtexif::TagDirectory* frameRootDir, rtexif::TagDirectory* rootDir, rtexif::TagDirectory* firstRootDir);
virtual ~FrameData ();
bool getPixelShift () const;
bool getHDR () const;
std::string getImageType () const;
IIOSampleFormat getSampleFormat () const;
rtexif::TagDirectory* getExifData () const;
procparams::IPTCPairs getIPTCData () const;
static procparams::IPTCPairs getIPTCData (IptcData* iptc_);
bool hasExif () const;
bool hasIPTC () const;
tm getDateTime () const;
time_t getDateTimeAsTS () const;
int getISOSpeed () const;
double getFNumber () const;
double getFocalLen () const;
double getFocalLen35mm () const;
float getFocusDist () const;
double getShutterSpeed () const;
double getExpComp () const;
std::string getMake () const;
std::string getModel () const;
std::string getLens () const;
std::string getSerialNumber () const;
std::string getOrientation () const;
};
class FramesData : public FramesMetaData {
private:
// frame's root IFD, can be a file root IFD or a SUB-IFD
std::vector<std::unique_ptr<FrameData>> frames;
// root IFD in the file
std::vector<rtexif::TagDirectory*> roots;
IptcData* iptc;
unsigned int dcrawFrameCount;
public:
FramesData (const Glib::ustring& fname, std::unique_ptr<RawMetaDataLocation> rml = nullptr, bool firstFrameOnly = false);
~FramesData ();
void setDCRawFrameCount (unsigned int frameCount);
unsigned int getRootCount () const;
unsigned int getFrameCount () const;
bool getPixelShift () const;
bool getHDR (unsigned int frame = 0) const;
std::string getImageType (unsigned int frame) const;
IIOSampleFormat getSampleFormat (unsigned int frame = 0) const;
rtexif::TagDirectory* getFrameExifData (unsigned int frame = 0) const;
rtexif::TagDirectory* getRootExifData (unsigned int root = 0) const;
rtexif::TagDirectory* getBestExifData (ImageSource *imgSource, procparams::RAWParams *rawParams) const;
procparams::IPTCPairs getIPTCData (unsigned int frame = 0) const;
bool hasExif (unsigned int frame = 0) const;
bool hasIPTC (unsigned int frame = 0) const;
tm getDateTime (unsigned int frame = 0) const;
time_t getDateTimeAsTS (unsigned int frame = 0) const;
int getISOSpeed (unsigned int frame = 0) const;
double getFNumber (unsigned int frame = 0) const;
double getFocalLen (unsigned int frame = 0) const;
double getFocalLen35mm (unsigned int frame = 0) const;
float getFocusDist (unsigned int frame = 0) const;
double getShutterSpeed (unsigned int frame = 0) const;
double getExpComp (unsigned int frame = 0) const;
std::string getMake (unsigned int frame = 0) const;
std::string getModel (unsigned int frame = 0) const;
std::string getLens (unsigned int frame = 0) const;
std::string getSerialNumber (unsigned int frame = 0) const;
std::string getOrientation (unsigned int frame = 0) const;
};
}
#endif