2014-02-05 Carl Hetherington <cth@carlh.net>
+ * A variety of fixes to small problems found by Coverity.
+
* Updates to it_IT translation from William Fanelli.
2014-02-02 Carl Hetherington <cth@carlh.net>
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
_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;
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 */
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);
/* Constructor for tests */
FFmpegAudioStream ()
: FFmpegStream ("", 0)
+ , frame_rate (0)
+ , channels (0)
, mapping (1)
{}
};
, 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 */
}
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);
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)) {
#include <string>
#include <iostream>
#include <cstdlib>
+#include <stdexcept>
#include <getopt.h>
#include <boost/filesystem.hpp>
#include "lib/version.h"
using std::cout;
using std::cerr;
using std::list;
+using std::exception;
using boost::shared_ptr;
static void
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;
}
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) {
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));
}
Timeline::setup_pixels_per_time_unit ()
{
shared_ptr<const Film> film = _film.lock ();
- if (!film) {
+ if (!film || film->length() == 0) {
return;
}
int total_out = 0;
/* 3 hours */
- int64_t const N = from * 60 * 60 * 3;
+ int64_t const N = int64_t (from) * 60 * 60 * 3;
for (int64_t i = 0; i < N; i += 1000) {
shared_ptr<AudioBuffers> a (new AudioBuffers (1, 1000));