summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-02-05 14:52:23 +0000
committerCarl Hetherington <cth@carlh.net>2014-02-05 14:52:23 +0000
commitd8a2e55855b50eda28ec7d394449274f5e085bd6 (patch)
tree9d3110b4c306a80800259b6fd4b9045531e17064 /src
parentebe451c248c3accd1a564bcad5eabf9d32a971f3 (diff)
Fix some coverity-reported stuff.
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_analysis.cc11
-rw-r--r--src/lib/config.h12
-rw-r--r--src/lib/ffmpeg.cc3
-rw-r--r--src/lib/ffmpeg_content.h2
-rw-r--r--src/lib/player.cc2
-rw-r--r--src/lib/scp_dcp_job.cc6
-rw-r--r--src/lib/writer.cc4
-rw-r--r--src/tools/dcpomatic_create.cc52
-rw-r--r--src/tools/server_test.cc14
-rw-r--r--src/wx/audio_plot.cc4
-rw-r--r--src/wx/timeline.cc2
11 files changed, 65 insertions, 47 deletions
diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc
index 1488f89fc..98d092726 100644
--- a/src/lib/audio_analysis.cc
+++ b/src/lib/audio_analysis.cc
@@ -93,10 +93,21 @@ AudioAnalysis::AudioAnalysis (boost::filesystem::path filename)
for (int i = 0; i < channels; ++i) {
int points;
fscanf (f, "%d", &points);
+ if (feof (f)) {
+ fclose (f);
+ return;
+ }
+
for (int j = 0; j < points; ++j) {
_data[i].push_back (AudioPoint (f));
+ if (feof (f)) {
+ fclose (f);
+ return;
+ }
}
}
+
+ fclose (f);
}
void
diff --git a/src/lib/config.h b/src/lib/config.h
index 791e41e8f..d77969b3e 100644
--- a/src/lib/config.h
+++ b/src/lib/config.h
@@ -193,14 +193,6 @@ public:
_server_port_base = p;
}
- void set_reference_scaler (Scaler const * s) {
- _reference_scaler = s;
- }
-
- void set_reference_filters (std::vector<Filter const *> const & f) {
- _reference_filters = f;
- }
-
/** @param i IP address of a TMS that we can copy DCPs to */
void set_tms_ip (std::string i) {
_tms_ip = i;
@@ -326,10 +318,6 @@ private:
bool _use_any_servers;
/** J2K encoding servers that should definitely be used */
std::vector<std::string> _servers;
- /** Scaler to use for the "A" part of A/B comparisons */
- Scaler const * _reference_scaler;
- /** Filters to use for the "A" part of A/B comparisons */
- std::vector<Filter const *> _reference_filters;
/** The IP address of a TMS that we can copy DCPs to */
std::string _tms_ip;
/** The path on a TMS that we should write DCPs to */
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc
index d3653e311..b7ae04b06 100644
--- a/src/lib/ffmpeg.cc
+++ b/src/lib/ffmpeg.cc
@@ -146,7 +146,8 @@ void
FFmpeg::setup_video ()
{
boost::mutex::scoped_lock lm (_mutex);
-
+
+ assert (_video_stream >= 0);
AVCodecContext* context = _format_context->streams[_video_stream]->codec;
AVCodec* codec = avcodec_find_decoder (context->codec_id);
diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h
index 7ff159b85..b1f2abcea 100644
--- a/src/lib/ffmpeg_content.h
+++ b/src/lib/ffmpeg_content.h
@@ -86,6 +86,8 @@ private:
/* Constructor for tests */
FFmpegAudioStream ()
: FFmpegStream ("", 0)
+ , frame_rate (0)
+ , channels (0)
, mapping (1)
{}
};
diff --git a/src/lib/player.cc b/src/lib/player.cc
index e661a7b36..42551889b 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -62,6 +62,8 @@ public:
, decoder (d)
, video_position (c->position ())
, audio_position (c->position ())
+ , repeat_to_do (0)
+ , repeat_done (0)
{}
/** Set this piece to repeat a video frame a given number of times */
diff --git a/src/lib/scp_dcp_job.cc b/src/lib/scp_dcp_job.cc
index 310303c09..22715978a 100644
--- a/src/lib/scp_dcp_job.cc
+++ b/src/lib/scp_dcp_job.cc
@@ -191,8 +191,10 @@ SCPDCPJob::run ()
}
to_do -= t;
bytes_transferred += t;
-
- set_progress ((double) bytes_transferred / bytes_to_transfer);
+
+ if (bytes_to_transfer > 0) {
+ set_progress ((double) bytes_transferred / bytes_to_transfer);
+ }
}
fclose (f);
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index c2a6c981b..42187dc6e 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -541,7 +541,9 @@ Writer::check_existing_picture_mxf ()
shared_ptr<Job> job = _job.lock ();
assert (job);
- job->set_progress (float (_first_nonexistant_frame) / N);
+ if (N > 0) {
+ job->set_progress (float (_first_nonexistant_frame) / N);
+ }
if (_film->three_d ()) {
if (!check_existing_picture_mxf_frame (mxf, _first_nonexistant_frame, EYES_LEFT)) {
diff --git a/src/tools/dcpomatic_create.cc b/src/tools/dcpomatic_create.cc
index 8be468b30..8dc4de50e 100644
--- a/src/tools/dcpomatic_create.cc
+++ b/src/tools/dcpomatic_create.cc
@@ -20,6 +20,7 @@
#include <string>
#include <iostream>
#include <cstdlib>
+#include <stdexcept>
#include <getopt.h>
#include <boost/filesystem.hpp>
#include "lib/version.h"
@@ -34,6 +35,7 @@ using std::string;
using std::cout;
using std::cerr;
using std::list;
+using std::exception;
using boost::shared_ptr;
static void
@@ -98,31 +100,37 @@ main (int argc, char* argv[])
dcpomatic_setup ();
ui_signaller = new UISignaller ();
- shared_ptr<Film> film (new Film (output));
- if (!name.empty ()) {
- film->set_name (name);
- }
-
- for (int i = optind; i < argc; ++i) {
- film->examine_and_add_content (content_factory (film, argv[i]));
- }
-
- JobManager* jm = JobManager::instance ();
- while (jm->work_to_do ()) {
- ui_signaller->ui_idle ();
- }
-
- if (jm->errors ()) {
- list<shared_ptr<Job> > jobs = jm->get ();
- for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) {
- if ((*i)->finished_in_error ()) {
- cerr << (*i)->error_summary () << "\n"
- << (*i)->error_details () << "\n";
+ try {
+ shared_ptr<Film> film (new Film (output));
+ if (!name.empty ()) {
+ film->set_name (name);
+ }
+
+ for (int i = optind; i < argc; ++i) {
+ film->examine_and_add_content (content_factory (film, argv[i]));
+ }
+
+ JobManager* jm = JobManager::instance ();
+ while (jm->work_to_do ()) {
+ ui_signaller->ui_idle ();
+ }
+
+ if (jm->errors ()) {
+ list<shared_ptr<Job> > jobs = jm->get ();
+ for (list<shared_ptr<Job> >::iterator i = jobs.begin(); i != jobs.end(); ++i) {
+ if ((*i)->finished_in_error ()) {
+ cerr << (*i)->error_summary () << "\n"
+ << (*i)->error_details () << "\n";
+ }
}
+ exit (EXIT_FAILURE);
}
+
+ film->write_metadata ();
+ } catch (exception& e) {
+ cerr << argv[0] << ": " << e.what() << "\n";
exit (EXIT_FAILURE);
}
-
- film->write_metadata ();
+
return 0;
}
diff --git a/src/tools/server_test.cc b/src/tools/server_test.cc
index b2c5e784b..039088862 100644
--- a/src/tools/server_test.cc
+++ b/src/tools/server_test.cc
@@ -137,14 +137,14 @@ main (int argc, char* argv[])
dcpomatic_setup ();
- server = new ServerDescription (server_host, 1);
- film.reset (new Film (film_dir));
- film->read_metadata ();
-
- shared_ptr<Player> player = film->make_player ();
- player->disable_audio ();
-
try {
+ server = new ServerDescription (server_host, 1);
+ film.reset (new Film (film_dir));
+ film->read_metadata ();
+
+ shared_ptr<Player> player = film->make_player ();
+ player->disable_audio ();
+
player->Video.connect (boost::bind (process_video, _1, _2, _3, _5));
bool done = false;
while (!done) {
diff --git a/src/wx/audio_plot.cc b/src/wx/audio_plot.cc
index f78885772..fd2619255 100644
--- a/src/wx/audio_plot.cc
+++ b/src/wx/audio_plot.cc
@@ -259,7 +259,9 @@ AudioPlot::plot_rms (wxGraphicsPath& path, int channel) const
p += pow (*j, 2);
}
- p = sqrt (p / smoothing.size ());
+ if (smoothing.size() > 0) {
+ p = sqrt (p / smoothing.size ());
+ }
path.AddLineToPoint (_db_label_width + i * _x_scale, y_for_linear (p));
}
diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc
index 6cc1f79d9..4e306c499 100644
--- a/src/wx/timeline.cc
+++ b/src/wx/timeline.cc
@@ -474,7 +474,7 @@ void
Timeline::setup_pixels_per_time_unit ()
{
shared_ptr<const Film> film = _film.lock ();
- if (!film) {
+ if (!film || film->length() == 0) {
return;
}