Return first frame in FramesData
on OOB access (#4830)
This commit is contained in:
parent
b37f545391
commit
e39726dbf7
@ -16,6 +16,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
#include <functional>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <glib/gstdio.h>
|
#include <glib/gstdio.h>
|
||||||
#include <tiff.h>
|
#include <tiff.h>
|
||||||
@ -43,6 +44,22 @@ Glib::ustring to_utf8 (const std::string& str)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
T getFromFrame(
|
||||||
|
const std::vector<std::unique_ptr<FrameData>>& frames,
|
||||||
|
std::size_t frame,
|
||||||
|
const std::function<T (const FrameData&)>& function
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (frame < frames.size()) {
|
||||||
|
return function(*frames[frame]);
|
||||||
|
}
|
||||||
|
if (!frames.empty()) {
|
||||||
|
return function(*frames[0]);
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FramesMetaData* FramesMetaData::fromFile (const Glib::ustring& fname, std::unique_ptr<RawMetaDataLocation> rml, bool firstFrameOnly)
|
FramesMetaData* FramesMetaData::fromFile (const Glib::ustring& fname, std::unique_ptr<RawMetaDataLocation> rml, bool firstFrameOnly)
|
||||||
@ -900,74 +917,196 @@ procparams::IPTCPairs FramesData::getIPTCData (unsigned int frame) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FramesData::hasExif (unsigned int frame) const
|
bool FramesData::hasExif(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? false : frames.at(frame)->hasExif ();
|
return getFromFrame<bool>(
|
||||||
}
|
frames,
|
||||||
bool FramesData::hasIPTC (unsigned int frame) const
|
frame,
|
||||||
{
|
[](const FrameData& frame_data)
|
||||||
return frames.empty() || frame >= frames.size() ? false : frames.at(frame)->hasIPTC ();
|
{
|
||||||
|
return frame_data.hasExif();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
tm FramesData::getDateTime (unsigned int frame) const
|
bool FramesData::hasIPTC(unsigned int frame) const
|
||||||
{
|
{
|
||||||
if (frames.empty() || frame >= frames.size() ) {
|
return getFromFrame<bool>(
|
||||||
return {};
|
frames,
|
||||||
} else {
|
frame,
|
||||||
return frames.at(frame)->getDateTime ();
|
[](const FrameData& frame_data)
|
||||||
}
|
{
|
||||||
|
return frame_data.hasIPTC();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tm FramesData::getDateTime(unsigned int frame) const
|
||||||
|
{
|
||||||
|
return getFromFrame<tm>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getDateTime();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
time_t FramesData::getDateTimeAsTS(unsigned int frame) const
|
time_t FramesData::getDateTimeAsTS(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? 0 : frames.at(frame)->getDateTimeAsTS ();
|
return getFromFrame<time_t>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getDateTimeAsTS();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
int FramesData::getISOSpeed (unsigned int frame) const
|
|
||||||
|
int FramesData::getISOSpeed(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? 0 : frames.at(frame)->getISOSpeed ();
|
return getFromFrame<int>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getISOSpeed();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
double FramesData::getFNumber (unsigned int frame) const
|
|
||||||
|
double FramesData::getFNumber(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFNumber ();
|
return getFromFrame<double>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getFNumber();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
double FramesData::getFocalLen (unsigned int frame) const
|
|
||||||
|
double FramesData::getFocalLen(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFocalLen ();
|
return getFromFrame<double>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getFocalLen();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
double FramesData::getFocalLen35mm (unsigned int frame) const
|
|
||||||
|
double FramesData::getFocalLen35mm(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getFocalLen35mm ();
|
return getFromFrame<double>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getFocalLen35mm();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
float FramesData::getFocusDist (unsigned int frame) const
|
|
||||||
|
float FramesData::getFocusDist(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? 0.f : frames.at(frame)->getFocusDist ();
|
return getFromFrame<float>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getFocusDist();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
double FramesData::getShutterSpeed (unsigned int frame) const
|
|
||||||
|
double FramesData::getShutterSpeed(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getShutterSpeed ();
|
return getFromFrame<double>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getShutterSpeed();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
double FramesData::getExpComp (unsigned int frame) const
|
|
||||||
|
double FramesData::getExpComp(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? 0. : frames.at(frame)->getExpComp ();
|
return getFromFrame<double>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getExpComp();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
std::string FramesData::getMake (unsigned int frame) const
|
|
||||||
|
std::string FramesData::getMake(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getMake ();
|
return getFromFrame<std::string>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getMake();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
std::string FramesData::getModel (unsigned int frame) const
|
|
||||||
|
std::string FramesData::getModel(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getModel ();
|
return getFromFrame<std::string>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getModel();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
std::string FramesData::getLens (unsigned int frame) const
|
|
||||||
|
std::string FramesData::getLens(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getLens ();
|
return getFromFrame<std::string>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getLens();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
std::string FramesData::getSerialNumber (unsigned int frame) const
|
|
||||||
|
std::string FramesData::getSerialNumber(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getSerialNumber ();
|
return getFromFrame<std::string>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getSerialNumber();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
std::string FramesData::getOrientation (unsigned int frame) const
|
|
||||||
|
std::string FramesData::getOrientation(unsigned int frame) const
|
||||||
{
|
{
|
||||||
return frames.empty() || frame >= frames.size() ? std::string() : frames.at(frame)->getOrientation ();
|
return getFromFrame<std::string>(
|
||||||
|
frames,
|
||||||
|
frame,
|
||||||
|
[](const FrameData& frame_data)
|
||||||
|
{
|
||||||
|
return frame_data.getOrientation();
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -499,7 +499,6 @@ void Imagefloat::ExecCMSTransform(cmsHTRANSFORM hTransform)
|
|||||||
*(p++) = *(pR++);
|
*(p++) = *(pR++);
|
||||||
*(p++) = *(pG++);
|
*(p++) = *(pG++);
|
||||||
*(p++) = *(pB++);
|
*(p++) = *(pB++);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cmsDoTransform (hTransform, pBuf.data, pBuf.data, width);
|
cmsDoTransform (hTransform, pBuf.data, pBuf.data, width);
|
||||||
|
@ -488,8 +488,8 @@ template<typename T = std::uint32_t>
|
|||||||
class ChoiceInterpreter : public Interpreter
|
class ChoiceInterpreter : public Interpreter
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
using Choices = std::map<T, std::string>;
|
using Choices = std::map<T, std::string>;
|
||||||
using ChoicesIterator = typename Choices::const_iterator;
|
using ChoicesIterator = typename Choices::const_iterator;
|
||||||
Choices choices;
|
Choices choices;
|
||||||
public:
|
public:
|
||||||
ChoiceInterpreter () {};
|
ChoiceInterpreter () {};
|
||||||
|
@ -134,13 +134,13 @@ enum {
|
|||||||
ADDSET_FATTAL_ANCHOR,
|
ADDSET_FATTAL_ANCHOR,
|
||||||
ADDSET_SHARPENMICRO_CONTRAST,
|
ADDSET_SHARPENMICRO_CONTRAST,
|
||||||
ADDSET_SHARP_CONTRAST,
|
ADDSET_SHARP_CONTRAST,
|
||||||
ADDSET_BAYER_FALSE_COLOR_SUPPRESSION,
|
ADDSET_BAYER_FALSE_COLOR_SUPPRESSION,
|
||||||
ADDSET_BAYER_ITER,
|
ADDSET_BAYER_ITER,
|
||||||
ADDSET_BAYER_PS_SMOOTH,
|
ADDSET_BAYER_PS_SMOOTH,
|
||||||
ADDSET_BAYER_PS_EPERISO,
|
ADDSET_BAYER_PS_EPERISO,
|
||||||
ADDSET_BAYER_PS_SIGMA,
|
ADDSET_BAYER_PS_SIGMA,
|
||||||
ADDSET_BAYER_DUALDEMOZCONTRAST,
|
ADDSET_BAYER_DUALDEMOZCONTRAST,
|
||||||
ADDSET_XTRANS_FALSE_COLOR_SUPPRESSION,
|
ADDSET_XTRANS_FALSE_COLOR_SUPPRESSION,
|
||||||
ADDSET_SOFTLIGHT_STRENGTH,
|
ADDSET_SOFTLIGHT_STRENGTH,
|
||||||
ADDSET_DEHAZE_STRENGTH,
|
ADDSET_DEHAZE_STRENGTH,
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt,
|
|||||||
|
|
||||||
customCurve = Gtk::manage (new MyDiagonalCurve ());
|
customCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||||
customCurve->setType (DCT_Spline);
|
customCurve->setType (DCT_Spline);
|
||||||
|
|
||||||
Gtk::Grid* customCurveBox= Gtk::manage (new Gtk::Grid ());
|
Gtk::Grid* customCurveBox= Gtk::manage (new Gtk::Grid ());
|
||||||
customCurveBox->get_style_context()->add_class("curve-curvebox");
|
customCurveBox->get_style_context()->add_class("curve-curvebox");
|
||||||
customCurveBox->add(*customCurve);
|
customCurveBox->add(*customCurve);
|
||||||
@ -148,7 +148,7 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt,
|
|||||||
|
|
||||||
NURBSCurve = Gtk::manage (new MyDiagonalCurve ());
|
NURBSCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||||
NURBSCurve->setType (DCT_NURBS);
|
NURBSCurve->setType (DCT_NURBS);
|
||||||
|
|
||||||
Gtk::Grid* NURBSCurveBox= Gtk::manage (new Gtk::Grid ());
|
Gtk::Grid* NURBSCurveBox= Gtk::manage (new Gtk::Grid ());
|
||||||
NURBSCurveBox->get_style_context()->add_class("curve-curvebox");
|
NURBSCurveBox->get_style_context()->add_class("curve-curvebox");
|
||||||
NURBSCurveBox->add(*NURBSCurve);
|
NURBSCurveBox->add(*NURBSCurve);
|
||||||
@ -240,7 +240,7 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt,
|
|||||||
|
|
||||||
paramCurve = Gtk::manage (new MyDiagonalCurve ());
|
paramCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||||
paramCurve->setType (DCT_Parametric);
|
paramCurve->setType (DCT_Parametric);
|
||||||
|
|
||||||
Gtk::Grid* paramCurveBox= Gtk::manage (new Gtk::Grid ());
|
Gtk::Grid* paramCurveBox= Gtk::manage (new Gtk::Grid ());
|
||||||
paramCurveBox->get_style_context()->add_class("curve-curvebox");
|
paramCurveBox->get_style_context()->add_class("curve-curvebox");
|
||||||
paramCurveBox->add(*paramCurve);
|
paramCurveBox->add(*paramCurve);
|
||||||
@ -669,9 +669,7 @@ void DiagonalCurveEditorSubGroup::switchGUI()
|
|||||||
} else {
|
} else {
|
||||||
// dCurve ave a ColorProvider or a background gradient defined, so we create/update the object
|
// dCurve ave a ColorProvider or a background gradient defined, so we create/update the object
|
||||||
if (!leftBar) {
|
if (!leftBar) {
|
||||||
leftBar = new ColoredBar(RTO_Bottom2Top);
|
leftBar = new ColoredBar(RTO_Bottom2Top);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (barColorProvider) {
|
if (barColorProvider) {
|
||||||
@ -1197,7 +1195,7 @@ bool DiagonalCurveEditorSubGroup::curveReset(CurveEditor *ce)
|
|||||||
customCurve->reset (dce->customResetCurve, dce->getIdentityValue());
|
customCurve->reset (dce->customResetCurve, dce->getIdentityValue());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case (DCT_CatumullRom) :
|
case (DCT_CatumullRom) :
|
||||||
customCurve->reset (dce->catmullRomResetCurve, dce->getIdentityValue());
|
customCurve->reset (dce->catmullRomResetCurve, dce->getIdentityValue());
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -647,7 +647,7 @@ bool HistogramRGBArea::on_button_press_event (GdkEventButton* event)
|
|||||||
|
|
||||||
void HistogramRGBArea::factorChanged (double newFactor)
|
void HistogramRGBArea::factorChanged (double newFactor)
|
||||||
{
|
{
|
||||||
factor = newFactor;
|
factor = newFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
x
Reference in New Issue
Block a user