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
|
||||
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <functional>
|
||||
#include <strings.h>
|
||||
#include <glib/gstdio.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)
|
||||
@ -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 ();
|
||||
}
|
||||
bool FramesData::hasIPTC (unsigned int frame) const
|
||||
{
|
||||
return frames.empty() || frame >= frames.size() ? false : frames.at(frame)->hasIPTC ();
|
||||
return getFromFrame<bool>(
|
||||
frames,
|
||||
frame,
|
||||
[](const FrameData& frame_data)
|
||||
{
|
||||
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 {};
|
||||
} else {
|
||||
return frames.at(frame)->getDateTime ();
|
||||
}
|
||||
return getFromFrame<bool>(
|
||||
frames,
|
||||
frame,
|
||||
[](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
|
||||
{
|
||||
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++) = *(pG++);
|
||||
*(p++) = *(pB++);
|
||||
|
||||
}
|
||||
|
||||
cmsDoTransform (hTransform, pBuf.data, pBuf.data, width);
|
||||
|
@ -488,8 +488,8 @@ template<typename T = std::uint32_t>
|
||||
class ChoiceInterpreter : public Interpreter
|
||||
{
|
||||
protected:
|
||||
using Choices = std::map<T, std::string>;
|
||||
using ChoicesIterator = typename Choices::const_iterator;
|
||||
using Choices = std::map<T, std::string>;
|
||||
using ChoicesIterator = typename Choices::const_iterator;
|
||||
Choices choices;
|
||||
public:
|
||||
ChoiceInterpreter () {};
|
||||
|
@ -134,13 +134,13 @@ enum {
|
||||
ADDSET_FATTAL_ANCHOR,
|
||||
ADDSET_SHARPENMICRO_CONTRAST,
|
||||
ADDSET_SHARP_CONTRAST,
|
||||
ADDSET_BAYER_FALSE_COLOR_SUPPRESSION,
|
||||
ADDSET_BAYER_ITER,
|
||||
ADDSET_BAYER_PS_SMOOTH,
|
||||
ADDSET_BAYER_PS_EPERISO,
|
||||
ADDSET_BAYER_PS_SIGMA,
|
||||
ADDSET_BAYER_DUALDEMOZCONTRAST,
|
||||
ADDSET_XTRANS_FALSE_COLOR_SUPPRESSION,
|
||||
ADDSET_BAYER_FALSE_COLOR_SUPPRESSION,
|
||||
ADDSET_BAYER_ITER,
|
||||
ADDSET_BAYER_PS_SMOOTH,
|
||||
ADDSET_BAYER_PS_EPERISO,
|
||||
ADDSET_BAYER_PS_SIGMA,
|
||||
ADDSET_BAYER_DUALDEMOZCONTRAST,
|
||||
ADDSET_XTRANS_FALSE_COLOR_SUPPRESSION,
|
||||
ADDSET_SOFTLIGHT_STRENGTH,
|
||||
ADDSET_DEHAZE_STRENGTH,
|
||||
|
||||
|
@ -56,7 +56,7 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt,
|
||||
|
||||
customCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||
customCurve->setType (DCT_Spline);
|
||||
|
||||
|
||||
Gtk::Grid* customCurveBox= Gtk::manage (new Gtk::Grid ());
|
||||
customCurveBox->get_style_context()->add_class("curve-curvebox");
|
||||
customCurveBox->add(*customCurve);
|
||||
@ -148,7 +148,7 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt,
|
||||
|
||||
NURBSCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||
NURBSCurve->setType (DCT_NURBS);
|
||||
|
||||
|
||||
Gtk::Grid* NURBSCurveBox= Gtk::manage (new Gtk::Grid ());
|
||||
NURBSCurveBox->get_style_context()->add_class("curve-curvebox");
|
||||
NURBSCurveBox->add(*NURBSCurve);
|
||||
@ -240,7 +240,7 @@ DiagonalCurveEditorSubGroup::DiagonalCurveEditorSubGroup (CurveEditorGroup* prt,
|
||||
|
||||
paramCurve = Gtk::manage (new MyDiagonalCurve ());
|
||||
paramCurve->setType (DCT_Parametric);
|
||||
|
||||
|
||||
Gtk::Grid* paramCurveBox= Gtk::manage (new Gtk::Grid ());
|
||||
paramCurveBox->get_style_context()->add_class("curve-curvebox");
|
||||
paramCurveBox->add(*paramCurve);
|
||||
@ -669,9 +669,7 @@ void DiagonalCurveEditorSubGroup::switchGUI()
|
||||
} else {
|
||||
// dCurve ave a ColorProvider or a background gradient defined, so we create/update the object
|
||||
if (!leftBar) {
|
||||
leftBar = new ColoredBar(RTO_Bottom2Top);
|
||||
|
||||
|
||||
leftBar = new ColoredBar(RTO_Bottom2Top);
|
||||
}
|
||||
|
||||
if (barColorProvider) {
|
||||
@ -1197,7 +1195,7 @@ bool DiagonalCurveEditorSubGroup::curveReset(CurveEditor *ce)
|
||||
customCurve->reset (dce->customResetCurve, dce->getIdentityValue());
|
||||
return true;
|
||||
|
||||
case (DCT_CatumullRom) :
|
||||
case (DCT_CatumullRom) :
|
||||
customCurve->reset (dce->catmullRomResetCurve, dce->getIdentityValue());
|
||||
return true;
|
||||
|
||||
|
@ -647,7 +647,7 @@ bool HistogramRGBArea::on_button_press_event (GdkEventButton* event)
|
||||
|
||||
void HistogramRGBArea::factorChanged (double newFactor)
|
||||
{
|
||||
factor = newFactor;
|
||||
factor = newFactor;
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
x
Reference in New Issue
Block a user