}
/* XXX: is this right? Especially for more than 5.1? */
- vector<double> channel_corrections(film->audio_channels(), 1);
+ vector<double> channel_corrections(static_cast<size_t>(film->audio_channels()), 1);
add_if_required (channel_corrections, 4, -3); // Ls
add_if_required (channel_corrections, 5, -3); // Rs
add_if_required (channel_corrections, 6, -144); // HI
channel_corrections,
850, // suggested by leqm_nrt CLI source
64, // suggested by leqm_nrt CLI source
- boost::thread::hardware_concurrency()
+ static_cast<int>(boost::thread::hardware_concurrency())
));
}
}
#endif
- int const frames = b->frames ();
- int const channels = b->channels ();
- vector<double> interleaved(frames * channels);
+ DCPOMATIC_ASSERT (b->frames());
+ DCPOMATIC_ASSERT (b->channels());
- for (int j = 0; j < channels; ++j) {
+ vector<double> interleaved(static_cast<size_t>(b->frames() * b->channels()));
+
+ for (int j = 0; j < b->channels(); ++j) {
float* data = b->data(j);
- for (int i = 0; i < frames; ++i) {
- float s = data[i];
+ for (Frame i = 0; i < b->frames(); ++i) {
+ float s = data[static_cast<size_t>(i)];
- interleaved[i * channels + j] = s;
+ interleaved[static_cast<size_t>(i * b->channels() + j)] = s;
float as = fabsf (s);
if (as < 10e-7) {
_leqm->add(interleaved);
- _done += frames;
+ _done += b->frames();
DCPTime const length = _playlist->length (_film);
set_progress ((time.seconds() - _start.seconds()) / (length.seconds() - _start.seconds()));
dcpomatic::DCPTime _start;
bool _from_zero;
- int64_t _done;
- int64_t _samples_per_point;
+ Frame _done;
+ Frame _samples_per_point;
AudioPoint* _current;
float* _sample_peak;
_frames = frames;
_allocated_frames = frames;
- _data = static_cast<float**> (malloc (_channels * sizeof (float *)));
+ _data = static_cast<float**>(malloc(static_cast<size_t>(_channels) * sizeof(float *)));
if (!_data) {
throw bad_alloc ();
}
for (int i = 0; i < _channels; ++i) {
- _data[i] = static_cast<float*> (malloc (frames * sizeof (float)));
+ _data[i] = static_cast<float*>(malloc(static_cast<size_t>(frames) * sizeof(float)));
if (!_data[i]) {
throw bad_alloc ();
}
/* This isn't really allowed, as all-bits-0 is not guaranteed to mean a 0 float,
but it seems that we can get away with it.
*/
- memset (_data[c], 0, _frames * sizeof(float));
+ DCPOMATIC_ASSERT (_frames >= 0);
+ memset (_data[c], 0, static_cast<size_t>(_frames) * sizeof(float));
}
/** Make some frames.
AudioBuffers::make_silent (int32_t from, int32_t frames)
{
DCPOMATIC_ASSERT ((from + frames) <= _allocated_frames);
+ DCPOMATIC_ASSERT (frames >= 0);
for (int c = 0; c < _channels; ++c) {
/* This isn't really allowed, as all-bits-0 is not guaranteed to mean a 0 float,
but it seems that we can get away with it.
*/
- memset (_data[c] + from, 0, frames * sizeof(float));
+ memset (_data[c] + from, 0, static_cast<size_t>(frames) * sizeof(float));
}
}
DCPOMATIC_ASSERT (from);
DCPOMATIC_ASSERT (read_offset >= 0 && (read_offset + frames_to_copy) <= from->_allocated_frames);
DCPOMATIC_ASSERT (write_offset >= 0 && (write_offset + frames_to_copy) <= _allocated_frames);
+ DCPOMATIC_ASSERT (frames_to_copy > 0);
for (int i = 0; i < _channels; ++i) {
- memcpy (_data[i] + write_offset, from->_data[i] + read_offset, frames_to_copy * sizeof(float));
+ memcpy (_data[i] + write_offset, from->_data[i] + read_offset, static_cast<size_t>(frames_to_copy) * sizeof(float));
}
}
DCPOMATIC_ASSERT ((to + frames) <= _allocated_frames);
for (int i = 0; i < _channels; ++i) {
- memmove (_data[i] + to, _data[i] + from, frames * sizeof(float));
+ memmove (_data[i] + to, _data[i] + from, static_cast<size_t>(frames) * sizeof(float));
}
}
void
AudioBuffers::ensure_size (int32_t frames)
{
+ DCPOMATIC_ASSERT (frames >= 0);
+
if (_allocated_frames >= frames) {
return;
}
frames++;
for (int i = 0; i < _channels; ++i) {
- _data[i] = static_cast<float*> (realloc (_data[i], frames * sizeof (float)));
+ _data[i] = static_cast<float*>(realloc(_data[i], static_cast<size_t>(frames) * sizeof (float)));
if (!_data[i]) {
throw bad_alloc ();
}
AudioBuffers::copy_channel_from (AudioBuffers const * from, int from_channel, int to_channel)
{
DCPOMATIC_ASSERT (from->frames() == frames());
- memcpy (data(to_channel), from->data(from_channel), frames() * sizeof (float));
+ DCPOMATIC_ASSERT (frames() >= 0);
+ memcpy (data(to_channel), from->data(from_channel), static_cast<size_t>(frames()) * sizeof(float));
}
/** Make a copy of these AudioBuffers */
void
AudioMapping::setup (int input_channels, int output_channels)
{
+ DCPOMATIC_ASSERT (input_channels >= 0);
+ DCPOMATIC_ASSERT (output_channels >= 0);
+
_input_channels = input_channels;
_output_channels = output_channels;
- _gain.resize (_input_channels);
+ _gain.resize (static_cast<size_t>(_input_channels));
for (int i = 0; i < _input_channels; ++i) {
- _gain[i].resize (_output_channels);
+ _gain[i].resize (static_cast<size_t>(_output_channels));
}
make_zero ();
void
AudioMapping::set (int input_channel, int output_channel, float g)
{
- DCPOMATIC_ASSERT (input_channel < int(_gain.size()));
- DCPOMATIC_ASSERT (output_channel < int(_gain[0].size()));
- _gain[input_channel][output_channel] = g;
+ DCPOMATIC_ASSERT (input_channel >= 0 && input_channel < int(_gain.size()));
+ DCPOMATIC_ASSERT (output_channel >= 0 && output_channel < int(_gain[0].size()));
+ _gain[static_cast<size_t>(input_channel)][static_cast<size_t>(output_channel)] = g;
}
float
AudioMapping::get (int input_channel, int output_channel) const
{
- DCPOMATIC_ASSERT (input_channel < int (_gain.size()));
- DCPOMATIC_ASSERT (output_channel < int (_gain[0].size()));
- return _gain[input_channel][output_channel];
+ DCPOMATIC_ASSERT (input_channel >= 0 && input_channel < int(_gain.size()));
+ DCPOMATIC_ASSERT (output_channel >= 0 && output_channel < int(_gain[0].size()));
+ return _gain[static_cast<size_t>(input_channel)][static_cast<size_t>(output_channel)];
}
void
Digester digester;
digester.add (_input_channels);
digester.add (_output_channels);
- for (int i = 0; i < _input_channels; ++i) {
- for (int j = 0; j < _output_channels; ++j) {
+ for (size_t i = 0; i < static_cast<size_t>(_input_channels); ++i) {
+ for (int j = 0; j < static_cast<size_t>(_output_channels); ++j) {
digester.add (_gain[i][j]);
}
}
CinemaSoundProcessor const *
CinemaSoundProcessor::from_index (int i)
{
- DCPOMATIC_ASSERT (i <= int(_cinema_sound_processors.size ()));
- return _cinema_sound_processors[i];
+ DCPOMATIC_ASSERT (i >= 0 && i < int(_cinema_sound_processors.size()));
+ return _cinema_sound_processors[static_cast<size_t>(i)];
}
float
/* Read in old <Matrix> nodes and convert them to chromaticities */
boost::numeric::ublas::matrix<double> C (3, 3);
for (list<cxml::NodePtr>::iterator i = m.begin(); i != m.end(); ++i) {
- int const ti = (*i)->number_attribute<int> ("i");
- int const tj = (*i)->number_attribute<int> ("j");
+ size_t const ti = (*i)->number_attribute<size_t>("i");
+ size_t const tj = (*i)->number_attribute<size_t>("j");
C(ti, tj) = raw_convert<double> ((*i)->content ());
}
// save string
output.push_back(fmt.substr(b, i - b));
- int n = 1; // number of digits
+ std::string::size_type n = 1; // number of digits
int spec_no = 0;
do {
#include "cross.h"
#include "compose.hpp"
+#include "dcpomatic_assert.h"
#include "log.h"
#include "dcpomatic_log.h"
#include "config.h"
void
dcpomatic_sleep_seconds (int s)
{
- sleep (s);
+ DCPOMATIC_ASSERT (s >= 0);
+ sleep (static_cast<unsigned int>(s));
}
void
dcpomatic_sleep_milliseconds (int ms)
{
- usleep (ms * 1000);
+ DCPOMATIC_ASSERT (ms >= 0);
+ usleep (static_cast<unsigned int>(ms) * 1000);
}
/** @return A string of CPU information (model name etc.) */
* @param size Number of bytes to write.
*/
void
-Socket::write (uint8_t const * data, int size)
+Socket::write (uint8_t const * data, size_t size)
{
_deadline.expires_from_now (boost::posix_time::seconds (_timeout));
boost::system::error_code ec = boost::asio::error::would_block;
* @param size Number of bytes to read.
*/
void
-Socket::read (uint8_t* data, int size)
+Socket::read (uint8_t* data, size_t size)
{
_deadline.expires_from_now (boost::posix_time::seconds (_timeout));
boost::system::error_code ec = boost::asio::error::would_block;
Socket::check_read_digest ()
{
DCPOMATIC_ASSERT (_read_digester);
- int const size = _read_digester->size ();
+ size_t const size = _read_digester->size ();
uint8_t ref[size];
_read_digester->get (ref);
Socket::finish_write_digest ()
{
DCPOMATIC_ASSERT (_write_digester);
- int const size = _write_digester->size();
+ size_t const size = _write_digester->size();
uint8_t buffer[size];
_write_digester->get (buffer);
void connect (boost::asio::ip::tcp::endpoint);
void write (uint32_t n);
- void write (uint8_t const * data, int size);
+ void write (uint8_t const * data, size_t size);
- void read (uint8_t* data, int size);
+ void read (uint8_t* data, size_t size);
uint32_t read_uint32 ();
class ReadDigestScope
}
-int
+size_t
Digester::size () const
{
return MD5_DIGEST_SIZE;
void get (uint8_t* buffer) const;
- int size () const;
+ size_t size () const;
private:
mutable md5_ctx _context;
mon.manufacturer_product_code = (edid[11] << 8) | edid[10];
- mon.serial_number = (edid[15] << 24) | (edid[14] << 16) | (edid[13] << 8) | edid[12];
+ mon.serial_number = (static_cast<uint32_t>(edid[15]) << 24) |
+ (static_cast<uint32_t>(edid[14]) << 16) |
+ (static_cast<uint32_t>(edid[13]) << 8) |
+ static_cast<uint32_t>(edid[12]);
+
mon.week_of_manufacture = edid[16];
mon.year_of_manufacture = edid[17];
monitors.push_back (mon);
*/
AVPacket copy_packet = _packet;
- int const stream_index = copy_packet.stream_index;
+ DCPOMATIC_ASSERT (copy_packet.stream_index >= 0);
+ size_t const stream_index = static_cast<size_t>(copy_packet.stream_index);
/* XXX: inefficient */
vector<shared_ptr<FFmpegAudioStream> > streams = ffmpeg_content()->ffmpeg_audio_streams ();
chosen by the user; created a `mapped' palette from those settings.
*/
map<RGBA, RGBA> colour_map = ffmpeg_content()->subtitle_stream()->colours ();
- vector<RGBA> mapped_palette (rect->nb_colors);
- for (int i = 0; i < rect->nb_colors; ++i) {
+ DCPOMATIC_ASSERT (rect->nb_colors);
+ size_t const colors = static_cast<size_t>(rect->nb_colors);
+ vector<RGBA> mapped_palette (colors);
+ for (size_t i = 0; i < colors; ++i) {
RGBA c (palette[2], palette[1], palette[0], palette[3]);
map<RGBA, RGBA>::const_iterator j = colour_map.find (c);
if (j != colour_map.end ()) {
int
FFmpegImageProxy::avio_read (uint8_t* buffer, int const amount)
{
- int const to_do = min(int64_t(amount), _data.size() - _pos);
+ size_t const to_do = min(static_cast<size_t>(amount), _data.size() - _pos);
if (to_do == 0) {
return AVERROR_EOF;
}
{
switch (whence) {
case AVSEEK_SIZE:
- return _data.size();
+ return static_cast<int64_t>(_data.size());
case SEEK_CUR:
- _pos += pos;
+ DCPOMATIC_ASSERT ((static_cast<int_64_t>(_pos) + pos) >= 0);
+ _pos = static_cast<size_t>(_pos + pos);
break;
case SEEK_SET:
- _pos = pos;
+ DCPOMATIC_ASSERT (pos >= 0);
+ _pos = static_cast<size_t>(pos);
break;
case SEEK_END:
- _pos = _data.size() - pos;
+ DCPOMATIC_ASSERT ((static_cast<int64_t>(_data.size()) - pos) >= 0);
+ _pos = static_cast<size_t>(_data.size() - pos);
break;
}
+ DCPOMATIC_ASSERT (_pos >= 0);
return _pos;
}
private:
dcp::Data _data;
- mutable int64_t _pos;
+ mutable size_t _pos;
/** Path of a file that this image came from, if applicable; stored so that
failed-decode errors can give more detail.
*/
/** @return The approximate disk space required to encode a DCP of this film with the
* current settings, in bytes.
*/
-uint64_t
+size_t
Film::required_disk_space () const
{
return _playlist->required_disk_space (shared_from_this(), j2k_bandwidth(), audio_channels(), audio_frame_rate());
}
/* Prepare input data pointers with crop */
- uint8_t* scale_in_data[planes()];
+ DCPOMATIC_ASSERT (planes() > 0);
+ uint8_t* scale_in_data[static_cast<size_t>(planes())];
for (int c = 0; c < planes(); ++c) {
/* To work out the crop in bytes, start by multiplying
the crop by the (average) bytes per pixel. Then
throw PixelFormatError ("crop_scale_window()", out_format);
}
- uint8_t* scale_out_data[out->planes()];
+ uint8_t* scale_out_data[static_cast<size_t>(out->planes())];
for (int c = 0; c < out->planes(); ++c) {
/* See the note in the crop loop above */
int const x = lrintf (out->bytes_per_pixel(c) * corner.x) & ~ ((int) out_desc->log2_chroma_w);
void
Image::yuv_16_black (uint16_t v, bool alpha)
{
- memset (data()[0], 0, sample_size(0).height * stride()[0]);
+ memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
for (int i = 1; i < 3; ++i) {
- int16_t* p = reinterpret_cast<int16_t*> (data()[i]);
+ uint16_t* p = reinterpret_cast<uint16_t*> (data()[i]);
int const lines = sample_size(i).height;
for (int y = 0; y < lines; ++y) {
/* We divide by 2 here because we are writing 2 bytes at a time */
}
if (alpha) {
- memset (data()[3], 0, sample_size(3).height * stride()[3]);
+ memset (data()[3], 0, static_cast<size_t>(sample_size(3).height * stride()[3]));
}
}
int const s = stride()[0];
uint8_t* p = data()[0];
for (int y = 0; y < h; y++) {
- memset (p + x * bpp, 0, w * bpp);
+ memset (p + x * bpp, 0, static_cast<size_t>(w * bpp));
p += s;
}
break;
case AV_PIX_FMT_YUV422P:
case AV_PIX_FMT_YUV444P:
case AV_PIX_FMT_YUV411P:
- memset (data()[0], 0, sample_size(0).height * stride()[0]);
- memset (data()[1], eight_bit_uv, sample_size(1).height * stride()[1]);
- memset (data()[2], eight_bit_uv, sample_size(2).height * stride()[2]);
+ memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
+ memset (data()[1], eight_bit_uv, static_cast<size_t>(sample_size(1).height * stride()[1]));
+ memset (data()[2], eight_bit_uv, static_cast<size_t>(sample_size(2).height * stride()[2]));
break;
case AV_PIX_FMT_YUVJ420P:
case AV_PIX_FMT_YUVJ422P:
case AV_PIX_FMT_YUVJ444P:
- memset (data()[0], 0, sample_size(0).height * stride()[0]);
- memset (data()[1], eight_bit_uv + 1, sample_size(1).height * stride()[1]);
- memset (data()[2], eight_bit_uv + 1, sample_size(2).height * stride()[2]);
+ memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
+ memset (data()[1], eight_bit_uv + 1, static_cast<size_t>(sample_size(1).height * stride()[1]));
+ memset (data()[2], eight_bit_uv + 1, static_cast<size_t>(sample_size(2).height * stride()[2]));
break;
case AV_PIX_FMT_YUV422P9LE:
case AV_PIX_FMT_RGB48LE:
case AV_PIX_FMT_RGB48BE:
case AV_PIX_FMT_XYZ12LE:
- memset (data()[0], 0, sample_size(0).height * stride()[0]);
+ memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
break;
case AV_PIX_FMT_UYVY422:
throw PixelFormatError ("make_transparent()", _pixel_format);
}
- memset (data()[0], 0, sample_size(0).height * stride()[0]);
+ memset (data()[0], 0, static_cast<size_t>(sample_size(0).height * stride()[0]));
}
void
for (int ty = position.y, oy = 0; ty < size().height && oy < other->size().height; ++ty, ++oy) {
uint8_t * const tp = data()[0] + ty * stride()[0] + position.x * 3;
uint8_t * const op = other->data()[0] + oy * other->stride()[0];
- memcpy (tp, op, N * 3);
+ memcpy (tp, op, static_cast<size_t>(N * 3));
}
}
uint8_t* p = data()[i];
int const lines = sample_size(i).height;
for (int y = 0; y < lines; ++y) {
- socket->read (p, line_size()[i]);
+ socket->read (p, static_cast<size_t>(line_size()[i]));
p += stride()[i];
}
}
uint8_t* p = data()[i];
int const lines = sample_size(i).height;
for (int y = 0; y < lines; ++y) {
- socket->write (p, line_size()[i]);
+ socket->write (p, static_cast<size_t>(line_size()[i]));
p += stride()[i];
}
}
|XXXwrittenXXX|<------line-size------------->|XXXwrittenXXXXXXwrittenXXX
^^^^ out of bounds
*/
- _data[i] = (uint8_t *) wrapped_av_malloc (_stride[i] * (sample_size(i).height + 1) + 32);
+ _data[i] = (uint8_t *) wrapped_av_malloc (static_cast<size_t>(_stride[i] * (sample_size(i).height + 1) + 32));
#if HAVE_VALGRIND_MEMCHECK_H
/* The data between the end of the line size and the stride is undefined but processed by
libswscale, causing lots of valgrind errors. Mark it all defined to quell these errors.
uint8_t* q = other._data[i];
int const lines = sample_size(i).height;
for (int j = 0; j < lines; ++j) {
- memcpy (p, q, _line_size[i]);
+ memcpy (p, q, static_cast<size_t>(_line_size[i]));
p += stride()[i];
q += other.stride()[i];
}
uint8_t* q = frame->data[i];
int const lines = sample_size(i).height;
for (int j = 0; j < lines; ++j) {
- memcpy (p, q, _line_size[i]);
+ memcpy (p, q, static_cast<size_t>(_line_size[i]));
p += stride()[i];
/* AVFrame's linesize is what we call `stride' */
q += frame->linesize[i];
uint8_t* q = other->data()[i];
int const lines = sample_size(i).height;
for (int j = 0; j < lines; ++j) {
- memcpy (p, q, line_size()[i]);
+ memcpy (p, q, static_cast<size_t>(line_size()[i]));
p += stride()[i];
q += other->stride()[i];
}
uint8_t* q = b.data()[c];
int const lines = a.sample_size(c).height;
for (int y = 0; y < lines; ++y) {
- if (memcmp (p, q, a.line_size()[c]) != 0) {
+ if (memcmp(p, q, static_cast<size_t>(a.line_size()[c])) != 0) {
return false;
}
{
size_t m = 0;
for (int i = 0; i < planes(); ++i) {
- m += _stride[i] * sample_size(i).height;
+ m += static_cast<size_t>(_stride[i] * sample_size(i).height);
}
return m;
}
throw EncodeError (N_("could not create PNG info struct"));
}
- png_set_IHDR (png_ptr, info_ptr, size().width, size().height, 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
+ png_set_IHDR (
+ png_ptr, info_ptr,
+ static_cast<png_uint_32>(size().width), static_cast<png_uint_32>(size().height),
+ 8, PNG_COLOR_TYPE_RGBA, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT
+ );
- png_byte ** row_pointers = reinterpret_cast<png_byte **>(png_malloc(png_ptr, size().height * sizeof(png_byte *)));
+ png_byte ** row_pointers = reinterpret_cast<png_byte **>(png_malloc(png_ptr, static_cast<size_t>(size().height) * sizeof(png_byte *)));
for (int i = 0; i < size().height; ++i) {
row_pointers[i] = (png_byte *) (data()[0] + i * stride()[0]);
}
if (!_image_content->still() || !_image) {
/* Either we need an image or we are using moving images, so load one */
- boost::filesystem::path path = _image_content->path (_image_content->still() ? 0 : _frame_video_position);
+ DCPOMATIC_ASSERT (_frame_video_position >= 0);
+ boost::filesystem::path path = _image_content->path (_image_content->still() ? 0 : static_cast<size_t>(_frame_video_position));
if (valid_j2k_file (path)) {
AVPixelFormat pf;
if (_image_content->video->colour_conversion()) {
if (content->still ()) {
_video_length = Config::instance()->default_still_length() * video_frame_rate().get_value_or (film->video_frame_rate ());
} else {
- _video_length = _image_content->number_of_paths ();
+ _video_length = static_cast<Frame>(_image_content->number_of_paths());
}
}
string an = extract_numbers (a);
string bn = extract_numbers (b);
- int const anl = an.length ();
- int const bnl = bn.length ();
+ size_t const anl = an.length ();
+ size_t const bnl = bn.length ();
if (anl > bnl) {
bn = string(anl - bnl, '0') + bn;
char buffer[4096];
while (true) {
int const N = zip_fread (file_in_zip, buffer, sizeof (buffer));
- checked_fwrite (buffer, N, f, temp_cert.file());
+ if (N == -1) {
+ zip_fclose (file_in_zip);
+ zip_close (zip);
+ return optional<string>(_("Could not read from ZIP file"));
+ }
+ checked_fwrite (buffer, static_cast<size_t>(N), f, temp_cert.file());
if (N < int (sizeof (buffer))) {
break;
}
if (xml->optional_number_child<int> ("Eye")) {
_eye = static_cast<dcp::Eye> (xml->number_child<int> ("Eye"));
}
- _data = Data (xml->number_child<int> ("Size"));
+ _data = Data (xml->number_child<size_t>("Size"));
/* This only matters when we are using J2KImageProxy for the preview, which
will never use this constructor (which is only used for passing data to
encode servers). So we can put anything in here. It's a bit of a hack.
size_t m = _data.size();
if (_image) {
/* 3 components, 16-bits per pixel */
- m += 3 * 2 * _image->size().width * _image->size().height;
+ m += static_cast<size_t>(3 * 2 * _image->size().width * _image->size().height);
}
return m;
}
function<bool (boost::filesystem::path)> confirm_overwrite
)
{
- int written = 0;
+ size_t written = 0;
BOOST_FOREACH (list<KDMWithMetadataPtr> const & i, kdms) {
boost::filesystem::path path = directory;
written += i.size();
}
- return written;
+ return static_cast<int>(written);
}
function<bool (boost::filesystem::path)> confirm_overwrite
)
{
- int written = 0;
+ size_t written = 0;
BOOST_FOREACH (list<KDMWithMetadataPtr> const & i, kdms) {
boost::filesystem::path path = directory;
}
}
- return written;
+ return static_cast<size_t>(written);
}
c->set_position (film, c->position() + next_c->length_after_trim(film));
}
-int64_t
+size_t
Playlist::required_disk_space (shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const
{
- int64_t video = uint64_t (j2k_bandwidth / 8) * length(film).seconds();
- int64_t audio = uint64_t (audio_channels * audio_frame_rate * 3) * length(film).seconds();
+ size_t video = static_cast<size_t>(j2k_bandwidth / 8) * length(film).seconds();
+ size_t audio = static_cast<size_t>(audio_channels * audio_frame_rate * 3) * length(film).seconds();
BOOST_FOREACH (shared_ptr<Content> i, content()) {
shared_ptr<DCPContent> d = dynamic_pointer_cast<DCPContent> (i);
if (d) {
+ DCPTime const len = d->length_after_trim(film);
+ DCPOMATIC_ASSERT (len.get() >= 0);
if (d->reference_video()) {
- video -= uint64_t (j2k_bandwidth / 8) * d->length_after_trim(film).seconds();
+ video -= static_cast<size_t>(j2k_bandwidth / 8) * len.seconds();
}
if (d->reference_audio()) {
- audio -= uint64_t (audio_channels * audio_frame_rate * 3) * d->length_after_trim(film).seconds();
+ audio -= static_cast<size_t>(audio_channels * audio_frame_rate * 3) * len.seconds();
}
}
}
dcpomatic::DCPTime length (boost::shared_ptr<const Film> film) const;
boost::optional<dcpomatic::DCPTime> start () const;
- int64_t required_disk_space (boost::shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const;
+ size_t required_disk_space (boost::shared_ptr<const Film> film, int j2k_bandwidth, int audio_channels, int audio_frame_rate) const;
int best_video_frame_rate () const;
dcpomatic::DCPTime video_end (boost::shared_ptr<const Film> film) const;
bool ok = true;
/* Read the data from the asset and hash it */
- dcpomatic_fseek (asset_file, info.offset, SEEK_SET);
+ dcpomatic_fseek (asset_file, static_cast<int64_t>(info.offset), SEEK_SET);
Data data (info.size);
size_t const read = fread (data.data().get(), 1, data.size(), asset_file);
LOG_GENERAL ("Read %1 bytes of asset data; wanted %2", read, info.size);
#include "cross.h"
#include "font.h"
#include "dcpomatic_assert.h"
+#include "warnings.h"
#include <dcp/raw_convert.h>
#include <fontconfig/fontconfig.h>
+DCPOMATIC_DISABLE_WARNINGS
#include <cairomm/cairomm.h>
#include <pangomm.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <pango/pangocairo.h>
#ifndef DCPOMATIC_HAVE_SHOW_IN_CAIRO_CONTEXT
#include <pango/pangocairo.h>
VideoRingBuffers::size () const
{
boost::mutex::scoped_lock lm (_mutex);
- return _data.size ();
+ return static_cast<Frame>(_data.size());
}
bool
--- /dev/null
+/*
+ Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+
+ This file is part of DCP-o-matic.
+
+ DCP-o-matic 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 2 of the License, or
+ (at your option) any later version.
+
+ DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
+
+*/
+
+#define DCPOMATIC_DISABLE_WARNINGS \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wsign-conversion\"")
+ _Pragma("GCC diagnostic ignored \"-Wcast-function-type\"")
+
+#define DCPOMATIC_ENABLE_WARNINGS \
+ _Pragma("GCC diagnostic pop")
void file_history (wxCommandEvent& event)
{
+ if (event.GetId() < ID_file_history) {
+ return;
+ }
+ size_t const n = event.GetId() - ID_file_history;
vector<boost::filesystem::path> history = Config::instance()->history ();
- int n = event.GetId() - ID_file_history;
- if (n >= 0 && n < static_cast<int> (history.size ()) && maybe_save_then_delete_film<FilmChangedClosingDialog>()) {
+ if (n < history.size() && maybe_save_then_delete_film<FilmChangedClosingDialog>()) {
load_film (history[n]);
}
}
delete _history_separator;
_history_separator = 0;
- int pos = _history_position;
+ unsigned int pos = _history_position;
/* Clear out non-existant history items before we re-build the menu */
Config::instance()->clean_history ();
wxMenu* _file_menu;
shared_ptr<Film> _film;
int _history_items;
- int _history_position;
+ unsigned int _history_position;
wxMenuItem* _history_separator;
boost::signals2::scoped_connection _config_changed_connection;
boost::signals2::scoped_connection _analytics_message_connection;
*
*/
-#include <boost/signals2.hpp>
-#include <wx/wx.h>
#include "lib/audio_mapping.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
+#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
+#include <boost/signals2.hpp>
/** @class AudioMappingView
* @brief This class displays the mapping of one set of audio channels to another,
#include "lib/dcpomatic_time.h"
#include "lib/player.h"
#include "lib/text_ring_buffers.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
class Butler;
class FilmViewer;
#include "lib/string_text_file_content.h"
#include "lib/string_text_file.h"
#include "lib/dcpomatic_log.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <wx/notebook.h>
#include <wx/listctrl.h>
#include <wx/display.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <iostream>
_no_check_selection = true;
ContentList content = _film->content ();
- for (size_t i = 0; i < content.size(); ++i) {
+ for (long int i = 0; i < static_cast<long int>(content.size()); ++i) {
if (find(cl.begin(), cl.end(), content[i]) != cl.end()) {
_content->SetItemState (i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
} else {
#ifndef DCPOMATIC_CONTENT_SUB_PANEL_H
#define DCPOMATIC_CONTENT_SUB_PANEL_H
-#include <boost/shared_ptr.hpp>
-#include <wx/wx.h>
-#include "lib/film.h"
#include "lib/config.h"
+#include "lib/film.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
+#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
+#include <boost/shared_ptr.hpp>
class ContentPanel;
class Content;
*/
#include "lib/content_store.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/listctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <vector>
#include "lib/dcpomatic_time.h"
#include "lib/types.h"
#include "lib/film.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
#include "custom_scale_dialog.h"
#include "wx_util.h"
#include "lib/util.h"
+#include "lib/warnings.h"
#include <dcp/raw_convert.h>
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <wx/propgrid/property.h>
#include <wx/propgrid/props.h>
+DCPOMATIC_ENABLE_WARNINGS
using boost::optional;
#include "table_dialog.h"
#include <dcp/types.h>
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <wx/spinctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
class CustomScaleDialog : public TableDialog
*/
+#include "lib/warnings.h"
#include <dcp/certificate.h>
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <wx/notebook.h>
+DCPOMATIC_ENABLE_WARNINGS
class DownloadCertificatePanel;
#ifndef DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H
#define DCPOMATIC_DOWNLOAD_CERTIFICATE_PANEL_H
+#include "lib/warnings.h"
#include <dcp/certificate.h>
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/optional.hpp>
class DownloadCertificateDialog;
#include "wx_util.h"
#include "dcpomatic_button.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <wx/listctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/function.hpp>
#include <vector>
*/
#include "lib/film.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
class wxNotebook;
total += i;
}
- return total / _latency_history.size();
+ return total / static_cast<Frame>(_latency_history.size());
}
void
#include "lib/player_text.h"
#include "lib/timer.h"
#include "lib/signaller.h"
+#include "lib/warnings.h"
#include <RtAudio.h>
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
class wxToggleButton;
class FFmpegPlayer;
dcp::Size _out_size;
RtAudio _audio;
- int _audio_channels;
+ unsigned int _audio_channels;
unsigned int _audio_block_size;
bool _playing;
int _suspended;
* @brief A dialog to select FFmpeg filters.
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
class Film;
*/
#include "focus_manager.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/textctrl.h>
+DCPOMATIC_ENABLE_WARNINGS
FocusManager* FocusManager::_instance;
#include "video_view.h"
#include "lib/signaller.h"
#include "lib/position.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <wx/glcanvas.h>
#include <dcp/util.h>
#include <boost/atomic.hpp>
#ifndef DCPOMATIC_I18N_HOOK_H
#define DCPOMATIC_I18N_HOOK_H
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <map>
class I18NHook
* @brief Class which is a wxPanel for showing the progress of jobs.
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/shared_ptr.hpp>
#include <list>
}
void
-JobView::insert (int pos)
+JobView::insert (size_t pos)
{
_table->Insert (pos, _gauge_message, 1, wxEXPAND | wxLEFT | wxRIGHT);
_table->Insert (pos + 1, _controls, 1, wxALIGN_CENTER_VERTICAL | wxALL, 3);
void setup ();
void maybe_pulse ();
- void insert (int pos);
+ void insert (size_t pos);
void detach ();
boost::shared_ptr<Job> job () const {
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <list>
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
#include <boost/filesystem.hpp>
bool
PlaylistControls::can_do_next ()
{
- return _selected_playlist && (_selected_playlist_position + 1) < int(_playlists[*_selected_playlist].get().size());
+ return _selected_playlist && (_selected_playlist_position + 1) < _playlists[*_selected_playlist].get().size();
}
void
void
PlaylistControls::spl_selection_changed ()
{
- long int selected = _spl_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+ size_t const selected = _spl_view->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
if (selected == -1) {
_current_spl_view->DeleteAllItems ();
_selected_playlist = boost::none;
}
void
-PlaylistControls::select_playlist (int selected, int position)
+PlaylistControls::select_playlist (size_t selected, size_t position)
{
log (wxString::Format("load-playlist %s", std_to_wx(_playlists[selected].name()).data()));
BOOST_FOREACH (SPLEntry const & i, _playlists[selected].get()) {
dialog.Pulse ();
- shared_ptr<DCPContent> dcp = dynamic_pointer_cast<DCPContent> (i.content);
+ shared_ptr<DCPContent> dcp = dynamic_ponter_cast<DCPContent> (i.content);
if (dcp && dcp->needs_kdm()) {
optional<dcp::EncryptedKDM> kdm;
kdm = get_kdm_from_directory (dcp);
}
_selected_playlist_position++;
- if (_selected_playlist_position < int(_playlists[*_selected_playlist].get().size())) {
+ if (_selected_playlist_position < _playlists[*_selected_playlist].get().size()) {
/* Next piece of content on the SPL */
update_current_content ();
_viewer->start ();
void update_content_directory ();
void update_playlist_directory ();
void spl_selection_changed ();
- void select_playlist (int selected, int position);
+ void select_playlist (size_t selected, size_t position);
void started ();
void stopped ();
void setup_sensitivity ();
std::vector<SPL> _playlists;
boost::optional<int> _selected_playlist;
- int _selected_playlist_position;
+ size_t _selected_playlist_position;
};
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
class QuestionDialog : public wxDialog
{
*/
+#include "table_dialog.h"
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <wx/spinctrl.h>
-#include "table_dialog.h"
+DCPOMATIC_ENABLE_WARNINGS
class RepeatDialog : public TableDialog
{
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
#include <wx/srchctrl.h>
#include <wx/treectrl.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/shared_ptr.hpp>
#include <boost/signals2.hpp>
#include <list>
* one of those fonts.
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/filesystem.hpp>
#include <boost/optional.hpp>
#include <vector>
#ifndef DCPOMATIC_TABLE_DIALOG_H
#define DCPOMATIC_TABLE_DIALOG_H
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
class TableDialog : public wxDialog
{
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
class wxSpinCtrl;
#define DCPOMATIC_TIMELINE_CONTENT_VIEW_H
#include "lib/types.h"
+#include "lib/warnings.h"
#include "timeline_view.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/signals2.hpp>
class Content;
*/
+#include "lib/warnings.h"
#include <dcp/verify.h>
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <list>
class wxRichTextCtrl;
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/shared_ptr.hpp>
#include <boost/weak_ptr.hpp>
#include <boost/signals2.hpp>
#ifndef DCPOMATIC_WX_UTIL_H
#define DCPOMATIC_WX_UTIL_H
+#include "lib/warnings.h"
#include "lib/dcpomatic_time.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <wx/wx.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <wx/gbsizer.h>
#include <boost/function.hpp>
#include <boost/thread.hpp>
{
using namespace MagickCore;
- Magick::Image m (image->size().width, image->size().height, format.c_str(), pixel_type, (void *) image->data()[0]);
+ Magick::Image m (static_cast<size_t>(image->size().width), static_cast<size_t>(image->size().height), format.c_str(), pixel_type, reinterpret_cast<void *>(image->data()[0]));
m.write (file.string ());
}
*/
+#include "lib/warnings.h"
+DCPOMATIC_DISABLE_WARNINGS
#include <Magick++.h>
+DCPOMATIC_ENABLE_WARNINGS
#include <boost/filesystem.hpp>
#include <boost/shared_ptr.hpp>
opt.add_option('--variant', help='build variant (swaroop-studio, swaroop-theater)', choices=['swaroop-studio', 'swaroop-theater'])
opt.add_option('--use-lld', action='store_true', default=False, help='use lld linker')
opt.add_option('--enable-disk', action='store_true', default=False, help='build dcpomatic2_disk tool; requires Boost process, lwext4 and nanomsg libraries')
+ opt.add_option('--warnings-are-errors', action='store_true', default=False, help='build with -Werror')
def configure(conf):
conf.load('compiler_cxx')
'-Wno-parentheses',
'-D_FILE_OFFSET_BITS=64'])
+ if conf.options.warnings_are_errors:
+ conf.env.append_value('CXXFLAGS', '-Werror')
+
if conf.options.force_cpp11:
conf.env.append_value('CXXFLAGS', ['-std=c++11', '-DBOOST_NO_CXX11_SCOPED_ENUMS'])
conf.check_cc(fragment="""
#include <libssh/libssh.h>\n
int main () {\n
- ssh_session s = ssh_new ();\n
+ ssh_new ();\n
return 0;\n
}
""",