From 4dbc6ef917aeceb906b1ef1caf6911033e7e2c54 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 20 Dec 2014 23:37:57 +0000 Subject: [PATCH] Hand-apply d849d411cff28ef5453085791d0b4d7cd73bd070 from master; replace all assert()s with thrown exceptions. --- TO_PORT | 2 -- src/lib/audio_analysis.cc | 7 +++-- src/lib/audio_buffers.cc | 49 ++++++++++++++++--------------- src/lib/audio_content.cc | 6 ++-- src/lib/audio_decoder.cc | 2 +- src/lib/cinema_sound_processor.cc | 3 +- src/lib/content.cc | 2 +- src/lib/content_subtitle.cc | 2 +- src/lib/dcp_content.cc | 2 +- src/lib/dcp_content_type.cc | 3 +- src/lib/dcp_decoder.cc | 2 +- src/lib/dcp_video.h | 1 + src/lib/dcpomatic_time.h | 5 ++-- src/lib/exceptions.cc | 6 ++++ src/lib/exceptions.h | 6 ++++ src/lib/ffmpeg_content.cc | 6 ++-- src/lib/ffmpeg_decoder.cc | 6 ++-- src/lib/ffmpeg_stream.cc | 9 +++--- src/lib/film.cc | 4 +-- src/lib/film.h | 1 + src/lib/image.cc | 22 +++++++------- src/lib/image_content.cc | 4 +-- src/lib/image_proxy.cc | 5 ++-- src/lib/player.cc | 8 ++--- src/lib/player_video.cc | 2 +- src/lib/playlist.cc | 4 +-- src/lib/ratio.cc | 3 +- src/lib/scaler.cc | 9 +++--- src/lib/sndfile_content.cc | 2 +- src/lib/subrip_content.cc | 4 +-- src/lib/subtitle_content.cc | 2 +- src/lib/types.cc | 4 +-- src/lib/util.cc | 6 ++-- src/lib/util.h | 5 ++-- src/lib/video_content.cc | 16 +++++----- src/lib/video_content.h | 2 -- src/lib/video_content_scale.cc | 1 + src/lib/video_decoder.cc | 2 +- src/lib/writer.cc | 10 +++---- src/wx/audio_dialog.cc | 4 +-- src/wx/content_menu.cc | 12 ++++---- src/wx/dcp_panel.cc | 2 +- src/wx/editable_list.h | 4 +-- src/wx/hints_dialog.cc | 5 ++-- src/wx/kdm_dialog.cc | 2 +- src/wx/subtitle_panel.cc | 4 +-- src/wx/timeline.cc | 6 ++-- src/wx/video_panel.cc | 6 ++-- 48 files changed, 151 insertions(+), 129 deletions(-) diff --git a/TO_PORT b/TO_PORT index 494945e96..e69de29bb 100644 --- a/TO_PORT +++ b/TO_PORT @@ -1,2 +0,0 @@ -0ee1e8c65e2977638375a8f96dbea201210aac98 -f2851b7066d0e12102b0f3aabc2b827a261206a9 diff --git a/src/lib/audio_analysis.cc b/src/lib/audio_analysis.cc index 681917fcf..597c04a22 100644 --- a/src/lib/audio_analysis.cc +++ b/src/lib/audio_analysis.cc @@ -18,6 +18,7 @@ */ #include "audio_analysis.h" +#include "dcpomatic_assert.h" #include "cross.h" #include #include @@ -117,14 +118,14 @@ AudioAnalysis::AudioAnalysis (boost::filesystem::path filename) void AudioAnalysis::add_point (int c, AudioPoint const & p) { - assert (c < channels ()); + DCPOMATIC_ASSERT (c < channels ()); _data[c].push_back (p); } AudioPoint AudioAnalysis::get_point (int c, int p) const { - assert (p < points (c)); + DCPOMATIC_ASSERT (p < points (c)); return _data[c][p]; } @@ -137,7 +138,7 @@ AudioAnalysis::channels () const int AudioAnalysis::points (int c) const { - assert (c < channels ()); + DCPOMATIC_ASSERT (c < channels ()); return _data[c].size (); } diff --git a/src/lib/audio_buffers.cc b/src/lib/audio_buffers.cc index d1003cc8c..71422944d 100644 --- a/src/lib/audio_buffers.cc +++ b/src/lib/audio_buffers.cc @@ -18,6 +18,7 @@ */ #include "audio_buffers.h" +#include "dcpomatic_assert.h" #include #include #include @@ -73,8 +74,8 @@ AudioBuffers::~AudioBuffers () void AudioBuffers::allocate (int channels, int frames) { - assert (frames >= 0); - assert (channels >= 0); + DCPOMATIC_ASSERT (frames >= 0); + DCPOMATIC_ASSERT (channels >= 0); _channels = channels; _frames = frames; @@ -109,7 +110,7 @@ AudioBuffers::deallocate () float* AudioBuffers::data (int c) const { - assert (c >= 0 && c < _channels); + DCPOMATIC_ASSERT (c >= 0 && c < _channels); return _data[c]; } @@ -121,7 +122,7 @@ AudioBuffers::data (int c) const void AudioBuffers::set_frames (int f) { - assert (f <= _allocated_frames); + DCPOMATIC_ASSERT (f <= _allocated_frames); for (int c = 0; c < _channels; ++c) { for (int i = f; i < _frames; ++i) { @@ -147,7 +148,7 @@ AudioBuffers::make_silent () void AudioBuffers::make_silent (int c) { - assert (c >= 0 && c < _channels); + DCPOMATIC_ASSERT (c >= 0 && c < _channels); for (int i = 0; i < _frames; ++i) { _data[c][i] = 0; @@ -157,7 +158,7 @@ AudioBuffers::make_silent (int c) void AudioBuffers::make_silent (int from, int frames) { - assert ((from + frames) <= _allocated_frames); + DCPOMATIC_ASSERT ((from + frames) <= _allocated_frames); for (int c = 0; c < _channels; ++c) { for (int i = from; i < (from + frames); ++i) { @@ -180,11 +181,11 @@ AudioBuffers::copy_from (AudioBuffers const * from, int frames_to_copy, int read return; } - assert (from->channels() == channels()); + DCPOMATIC_ASSERT (from->channels() == channels()); - assert (from); - assert (read_offset >= 0 && (read_offset + frames_to_copy) <= from->_allocated_frames); - assert (write_offset >= 0 && (write_offset + frames_to_copy) <= _allocated_frames); + 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); for (int i = 0; i < _channels; ++i) { memcpy (_data[i] + write_offset, from->_data[i] + read_offset, frames_to_copy * sizeof(float)); @@ -204,14 +205,14 @@ AudioBuffers::move (int from, int to, int frames) return; } - assert (from >= 0); - assert (from < _frames); - assert (to >= 0); - assert (to < _frames); - assert (frames > 0); - assert (frames <= _frames); - assert ((from + frames) <= _frames); - assert ((to + frames) <= _allocated_frames); + DCPOMATIC_ASSERT (from >= 0); + DCPOMATIC_ASSERT (from < _frames); + DCPOMATIC_ASSERT (to >= 0); + DCPOMATIC_ASSERT (to < _frames); + DCPOMATIC_ASSERT (frames > 0); + DCPOMATIC_ASSERT (frames <= _frames); + DCPOMATIC_ASSERT ((from + frames) <= _frames); + DCPOMATIC_ASSERT ((to + frames) <= _allocated_frames); for (int i = 0; i < _channels; ++i) { memmove (_data[i] + to, _data[i] + from, frames * sizeof(float)); @@ -225,8 +226,8 @@ void AudioBuffers::accumulate_channel (AudioBuffers const * from, int from_channel, int to_channel, float gain) { int const N = frames (); - assert (from->frames() == N); - assert (to_channel <= _channels); + DCPOMATIC_ASSERT (from->frames() == N); + DCPOMATIC_ASSERT (to_channel <= _channels); float* s = from->data (from_channel); float* d = _data[to_channel]; @@ -262,9 +263,9 @@ AudioBuffers::ensure_size (int frames) void AudioBuffers::accumulate_frames (AudioBuffers const * from, int read_offset, int write_offset, int frames) { - assert (_channels == from->channels ()); - assert (read_offset >= 0); - assert (write_offset >= 0); + DCPOMATIC_ASSERT (_channels == from->channels ()); + DCPOMATIC_ASSERT (read_offset >= 0); + DCPOMATIC_ASSERT (write_offset >= 0); for (int i = 0; i < _channels; ++i) { for (int j = 0; j < frames; ++j) { @@ -300,7 +301,7 @@ AudioBuffers::channel (int c) const void AudioBuffers::copy_channel_from (AudioBuffers const * from, int from_channel, int to_channel) { - assert (from->frames() == frames()); + DCPOMATIC_ASSERT (from->frames() == frames()); memcpy (data(to_channel), from->data(from_channel), frames() * sizeof (float)); } diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc index c0e99b24c..61357c60f 100644 --- a/src/lib/audio_content.cc +++ b/src/lib/audio_content.cc @@ -90,7 +90,7 @@ AudioContent::AudioContent (shared_ptr f, vector : Content (f, c) { shared_ptr ref = dynamic_pointer_cast (c[0]); - assert (ref); + DCPOMATIC_ASSERT (ref); for (size_t i = 0; i < c.size(); ++i) { shared_ptr ac = dynamic_pointer_cast (c[i]); @@ -163,7 +163,7 @@ boost::signals2::connection AudioContent::analyse_audio (boost::function finished) { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); shared_ptr job (new AnalyseAudioJob (film, dynamic_pointer_cast (shared_from_this()))); boost::signals2::connection c = job->Finished.connect (finished); @@ -210,7 +210,7 @@ int AudioContent::resampled_audio_frame_rate () const { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); /* Resample to a DCI-approved sample rate */ double t = dcp_audio_frame_rate (audio_frame_rate ()); diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index 31dcf2ef9..0c47b9f51 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -166,7 +166,7 @@ AudioDecoder::audio (shared_ptr data, ContentTime time) _audio_position = time.frames (frame_rate); } - assert (_audio_position.get() >= (_decoded_audio.frame + _decoded_audio.audio->frames())); + DCPOMATIC_ASSERT (_audio_position.get() >= (_decoded_audio.frame + _decoded_audio.audio->frames())); add (data); } diff --git a/src/lib/cinema_sound_processor.cc b/src/lib/cinema_sound_processor.cc index 485af3fd6..367cea81e 100644 --- a/src/lib/cinema_sound_processor.cc +++ b/src/lib/cinema_sound_processor.cc @@ -23,6 +23,7 @@ #include "cinema_sound_processor.h" #include "dolby_cp750.h" +#include "dcpomatic_assert.h" #include #include @@ -98,6 +99,6 @@ CinemaSoundProcessor::as_index (CinemaSoundProcessor const * s) CinemaSoundProcessor const * CinemaSoundProcessor::from_index (int i) { - assert (i <= int(_cinema_sound_processors.size ())); + DCPOMATIC_ASSERT (i <= int(_cinema_sound_processors.size ())); return _cinema_sound_processors[i]; } diff --git a/src/lib/content.cc b/src/lib/content.cc index ba83e2627..a8d058cc1 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -270,7 +270,7 @@ Content::path_summary () const { /* XXX: should handle multiple paths more gracefully */ - assert (number_of_paths ()); + DCPOMATIC_ASSERT (number_of_paths ()); string s = path(0).filename().string (); if (number_of_paths() > 1) { diff --git a/src/lib/content_subtitle.cc b/src/lib/content_subtitle.cc index 93e0677bb..39becf943 100644 --- a/src/lib/content_subtitle.cc +++ b/src/lib/content_subtitle.cc @@ -23,7 +23,7 @@ ContentTimePeriod ContentTextSubtitle::period () const { /* XXX: assuming we have some subs and they are all at the same time */ - assert (!subs.empty ()); + DCPOMATIC_ASSERT (!subs.empty ()); return ContentTimePeriod ( ContentTime::from_seconds (double (subs.front().in().to_ticks()) / 250), ContentTime::from_seconds (double (subs.front().out().to_ticks()) / 250) diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index cd82ee6e9..2bf14dcff 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -139,7 +139,7 @@ DCPTime DCPContent::full_length () const { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); return DCPTime (video_length (), FrameRateChange (video_frame_rate (), film->video_frame_rate ())); } diff --git a/src/lib/dcp_content_type.cc b/src/lib/dcp_content_type.cc index e659a9b88..b7bf8d81a 100644 --- a/src/lib/dcp_content_type.cc +++ b/src/lib/dcp_content_type.cc @@ -22,6 +22,7 @@ */ #include "dcp_content_type.h" +#include "dcpomatic_assert.h" #include #include "i18n.h" @@ -80,7 +81,7 @@ DCPContentType::from_isdcf_name (string n) DCPContentType const * DCPContentType::from_index (int n) { - assert (n >= 0 && n < int (_dcp_content_types.size ())); + DCPOMATIC_ASSERT (n >= 0 && n < int (_dcp_content_types.size ())); return _dcp_content_types[n]; } diff --git a/src/lib/dcp_decoder.cc b/src/lib/dcp_decoder.cc index 74affe857..f6d632f92 100644 --- a/src/lib/dcp_decoder.cc +++ b/src/lib/dcp_decoder.cc @@ -49,7 +49,7 @@ DCPDecoder::DCPDecoder (shared_ptr c) if (c->kdm ()) { dcp.add (dcp::DecryptedKDM (c->kdm().get (), Config::instance()->decryption_private_key ())); } - assert (dcp.cpls().size() == 1); + DCPOMATIC_ASSERT (dcp.cpls().size() == 1); _reels = dcp.cpls().front()->reels (); _reel = _reels.begin (); } diff --git a/src/lib/dcp_video.h b/src/lib/dcp_video.h index 051333c45..9a6ae8d91 100644 --- a/src/lib/dcp_video.h +++ b/src/lib/dcp_video.h @@ -20,6 +20,7 @@ #include "util.h" #include +#include /** @file src/dcp_video_frame.h * @brief A single frame of video destined for a DCP. diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index 2408bff81..6afce554f 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -22,6 +22,7 @@ #include "frame_rate_change.h" #include "safe_stringstream.h" +#include "dcpomatic_assert.h" #include #include #include @@ -177,7 +178,7 @@ public: template static ContentTime from_frames (int64_t f, T r) { - assert (r > 0); + DCPOMATIC_ASSERT (r > 0); return ContentTime (f * HZ / r); } @@ -281,7 +282,7 @@ public: template static DCPTime from_frames (int64_t f, T r) { - assert (r > 0); + DCPOMATIC_ASSERT (r > 0); return DCPTime (f * HZ / r); } diff --git a/src/lib/exceptions.cc b/src/lib/exceptions.cc index 95d4c8cce..c4c3d0815 100644 --- a/src/lib/exceptions.cc +++ b/src/lib/exceptions.cc @@ -73,3 +73,9 @@ InvalidSignerError::InvalidSignerError () { } + +ProgrammingError::ProgrammingError (string file, int line) + : StringError (String::compose (_("Programming error at %1:%2"), file, line)) +{ + +} diff --git a/src/lib/exceptions.h b/src/lib/exceptions.h index 05c66df3a..950c2f381 100644 --- a/src/lib/exceptions.h +++ b/src/lib/exceptions.h @@ -259,6 +259,12 @@ public: InvalidSignerError (); }; +class ProgrammingError : public StringError +{ +public: + ProgrammingError (std::string file, int line); +}; + /** @class ExceptionStore * @brief A parent class for classes which have a need to catch and * re-throw exceptions. diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index e09e71041..740efdc29 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -106,7 +106,7 @@ FFmpegContent::FFmpegContent (shared_ptr f, vector ref = dynamic_pointer_cast (c[0]); - assert (ref); + DCPOMATIC_ASSERT (ref); for (size_t i = 0; i < c.size(); ++i) { shared_ptr fc = dynamic_pointer_cast (c[i]); @@ -173,7 +173,7 @@ FFmpegContent::examine (shared_ptr job, bool calculate_digest) take_from_video_examiner (examiner); shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); { boost::mutex::scoped_lock lm (_mutex); @@ -315,7 +315,7 @@ DCPTime FFmpegContent::full_length () const { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); return DCPTime (video_length_after_3d_combine(), FrameRateChange (video_frame_rate (), film->video_frame_rate ())); } diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 62a3a78c3..a16799e74 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -168,12 +168,12 @@ FFmpegDecoder::pass () shared_ptr FFmpegDecoder::deinterleave_audio (uint8_t** data, int size) { - assert (_ffmpeg_content->audio_channels()); - assert (bytes_per_audio_sample()); + DCPOMATIC_ASSERT (_ffmpeg_content->audio_channels()); + DCPOMATIC_ASSERT (bytes_per_audio_sample()); /* Deinterleave and convert to float */ - assert ((size % (bytes_per_audio_sample() * _ffmpeg_content->audio_channels())) == 0); + DCPOMATIC_ASSERT ((size % (bytes_per_audio_sample() * _ffmpeg_content->audio_channels())) == 0); int const total_samples = size / bytes_per_audio_sample(); int const frames = total_samples / _ffmpeg_content->audio_channels(); diff --git a/src/lib/ffmpeg_stream.cc b/src/lib/ffmpeg_stream.cc index 3fac33327..ad99defee 100644 --- a/src/lib/ffmpeg_stream.cc +++ b/src/lib/ffmpeg_stream.cc @@ -17,12 +17,13 @@ */ +#include "ffmpeg_stream.h" +#include "dcpomatic_assert.h" +#include +#include extern "C" { #include } -#include -#include -#include "ffmpeg_stream.h" using std::string; using dcp::raw_convert; @@ -66,6 +67,6 @@ FFmpegStream::stream (AVFormatContext const * fc) const ++i; } - assert (false); + DCPOMATIC_ASSERT (false); return 0; } diff --git a/src/lib/film.cc b/src/lib/film.cc index d7620be8d..18e992478 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -164,7 +164,7 @@ Film::Film (boost::filesystem::path dir, bool log) string Film::video_identifier () const { - assert (container ()); + DCPOMATIC_ASSERT (container ()); SafeStringStream s; s.imbue (std::locale::classic ()); @@ -1069,7 +1069,7 @@ Film::full_frame () const return dcp::Size (4096, 2160); } - assert (false); + DCPOMATIC_ASSERT (false); return dcp::Size (); } diff --git a/src/lib/film.h b/src/lib/film.h index 0227f26c9..43f7bae78 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -29,6 +29,7 @@ #include "types.h" #include "isdcf_metadata.h" #include "frame_rate_change.h" +#include "ratio.h" #include #include #include diff --git a/src/lib/image.cc b/src/lib/image.cc index 3c6769068..847ad1046 100644 --- a/src/lib/image.cc +++ b/src/lib/image.cc @@ -88,14 +88,14 @@ Image::components () const shared_ptr Image::crop_scale_window (Crop crop, dcp::Size inter_size, dcp::Size out_size, Scaler const * scaler, AVPixelFormat out_format, bool out_aligned) const { - assert (scaler); + DCPOMATIC_ASSERT (scaler); /* Empirical testing suggests that sws_scale() will crash if the input image is not aligned. */ - assert (aligned ()); + DCPOMATIC_ASSERT (aligned ()); - assert (out_size.width >= inter_size.width); - assert (out_size.height >= inter_size.height); + DCPOMATIC_ASSERT (out_size.width >= inter_size.width); + DCPOMATIC_ASSERT (out_size.height >= inter_size.height); /* Here's an image of out_size */ shared_ptr out (new Image (out_format, out_size, out_aligned)); @@ -144,11 +144,11 @@ Image::crop_scale_window (Crop crop, dcp::Size inter_size, dcp::Size out_size, S shared_ptr Image::scale (dcp::Size out_size, Scaler const * scaler, AVPixelFormat out_format, bool out_aligned) const { - assert (scaler); + DCPOMATIC_ASSERT (scaler); /* Empirical testing suggests that sws_scale() will crash if the input image is not aligned. */ - assert (aligned ()); + DCPOMATIC_ASSERT (aligned ()); shared_ptr scaled (new Image (out_format, out_size, out_aligned)); @@ -361,7 +361,7 @@ Image::make_transparent () void Image::alpha_blend (shared_ptr other, Position position) { - assert (other->pixel_format() == PIX_FMT_RGBA); + DCPOMATIC_ASSERT (other->pixel_format() == PIX_FMT_RGBA); int const other_bpp = 4; int start_tx = position.x; @@ -439,7 +439,7 @@ Image::alpha_blend (shared_ptr other, Position position) break; } default: - assert (false); + DCPOMATIC_ASSERT (false); } } @@ -447,8 +447,8 @@ void Image::copy (shared_ptr other, Position position) { /* Only implemented for RGB24 onto RGB24 so far */ - assert (_pixel_format == PIX_FMT_RGB24 && other->pixel_format() == PIX_FMT_RGB24); - assert (position.x >= 0 && position.y >= 0); + DCPOMATIC_ASSERT (_pixel_format == PIX_FMT_RGB24 && other->pixel_format() == PIX_FMT_RGB24); + DCPOMATIC_ASSERT (position.x >= 0 && position.y >= 0); int const N = min (position.x + other->size().width, size().width) - position.x; for (int ty = position.y, oy = 0; ty < size().height && oy < other->size().height; ++ty, ++oy) { @@ -609,7 +609,7 @@ Image::Image (shared_ptr other, bool aligned) allocate (); for (int i = 0; i < components(); ++i) { - assert(line_size()[i] == other->line_size()[i]); + DCPOMATIC_ASSERT (line_size()[i] == other->line_size()[i]); uint8_t* p = _data[i]; uint8_t* q = other->data()[i]; for (int j = 0; j < lines(i); ++j) { diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 132b26144..b8d2a6921 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -105,7 +105,7 @@ ImageContent::examine (shared_ptr job, bool calculate_digest) Content::examine (job, calculate_digest); shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); shared_ptr examiner (new ImageExaminer (film, shared_from_this(), job)); take_from_video_examiner (examiner); @@ -126,7 +126,7 @@ DCPTime ImageContent::full_length () const { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); return DCPTime (video_length_after_3d_combine(), FrameRateChange (video_frame_rate(), film->video_frame_rate())); } diff --git a/src/lib/image_proxy.cc b/src/lib/image_proxy.cc index 7013a69c9..f72a6c3e4 100644 --- a/src/lib/image_proxy.cc +++ b/src/lib/image_proxy.cc @@ -17,8 +17,6 @@ */ -#include -#include #include "image_proxy.h" #include "raw_image_proxy.h" #include "magick_image_proxy.h" @@ -26,6 +24,9 @@ #include "image.h" #include "exceptions.h" #include "cross.h" +#include +#include +#include #include "i18n.h" diff --git a/src/lib/player.cc b/src/lib/player.cc index 695ce00ce..36b13d105 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -337,9 +337,9 @@ Player::get_video (DCPTime time, bool accurate) shared_ptr piece = ov.back (); shared_ptr decoder = dynamic_pointer_cast (piece->decoder); - assert (decoder); + DCPOMATIC_ASSERT (decoder); shared_ptr content = dynamic_pointer_cast (piece->content); - assert (content); + DCPOMATIC_ASSERT (content); list content_video = decoder->get_video (dcp_to_content_video (piece, time), accurate); if (content_video.empty ()) { @@ -415,9 +415,9 @@ Player::get_audio (DCPTime time, DCPTime length, bool accurate) for (list >::iterator i = ov.begin(); i != ov.end(); ++i) { shared_ptr content = dynamic_pointer_cast ((*i)->content); - assert (content); + DCPOMATIC_ASSERT (content); shared_ptr decoder = dynamic_pointer_cast ((*i)->decoder); - assert (decoder); + DCPOMATIC_ASSERT (decoder); if (content->audio_frame_rate() == 0) { /* This AudioContent has no audio (e.g. if it is an FFmpegContent with no diff --git a/src/lib/player_video.cc b/src/lib/player_video.cc index b7a8f8669..fae66bf62 100644 --- a/src/lib/player_video.cc +++ b/src/lib/player_video.cc @@ -179,7 +179,7 @@ shared_ptr PlayerVideo::j2k () const { shared_ptr j2k = dynamic_pointer_cast (_in); - assert (j2k); + DCPOMATIC_ASSERT (j2k); return j2k->j2k (); } diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index 4580e54d4..1698da99e 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -367,7 +367,7 @@ Playlist::move_earlier (shared_ptr c) ++i; } - assert (i != _content.end ()); + DCPOMATIC_ASSERT (i != _content.end ()); if (previous == _content.end ()) { return; } @@ -389,7 +389,7 @@ Playlist::move_later (shared_ptr c) ++i; } - assert (i != _content.end ()); + DCPOMATIC_ASSERT (i != _content.end ()); ContentList::iterator next = i; ++next; diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index bc83ae87c..29c22c78d 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -17,9 +17,10 @@ */ -#include #include "ratio.h" #include "util.h" +#include +#include #include "i18n.h" diff --git a/src/lib/scaler.cc b/src/lib/scaler.cc index 40a0f05b9..43c1ac81c 100644 --- a/src/lib/scaler.cc +++ b/src/lib/scaler.cc @@ -21,12 +21,13 @@ * @brief A class to describe one of FFmpeg's software scalers. */ -#include -#include +#include "dcpomatic_assert.h" +#include "scaler.h" extern "C" { #include } -#include "scaler.h" +#include +#include #include "i18n.h" @@ -112,6 +113,6 @@ Scaler::as_index (Scaler const * s) Scaler const * Scaler::from_index (int i) { - assert (i <= int(_scalers.size ())); + DCPOMATIC_ASSERT (i <= int(_scalers.size ())); return _scalers[i]; } diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index cdc9734bf..3c377d644 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -113,7 +113,7 @@ DCPTime SndfileContent::full_length () const { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); return DCPTime (audio_length(), film->active_frame_rate_change (position ())); } diff --git a/src/lib/subrip_content.cc b/src/lib/subrip_content.cc index 992947a2d..f4dd427f3 100644 --- a/src/lib/subrip_content.cc +++ b/src/lib/subrip_content.cc @@ -56,7 +56,7 @@ SubRipContent::examine (boost::shared_ptr job, bool calculate_digest) SubRip s (shared_from_this ()); shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); DCPTime len (s.length (), film->active_frame_rate_change (position ())); @@ -80,7 +80,7 @@ SubRipContent::technical_summary () const string SubRipContent::information () const { - + } void diff --git a/src/lib/subtitle_content.cc b/src/lib/subtitle_content.cc index 6f9bdf3a4..2bed5413c 100644 --- a/src/lib/subtitle_content.cc +++ b/src/lib/subtitle_content.cc @@ -105,7 +105,7 @@ SubtitleContent::SubtitleContent (shared_ptr f, vector ref = dynamic_pointer_cast (c[0]); - assert (ref); + DCPOMATIC_ASSERT (ref); list > ref_fonts = ref->fonts (); for (size_t i = 0; i < c.size(); ++i) { diff --git a/src/lib/types.cc b/src/lib/types.cc index d052b2a9a..54a8cb492 100644 --- a/src/lib/types.cc +++ b/src/lib/types.cc @@ -51,7 +51,7 @@ resolution_to_string (Resolution r) return "4K"; } - assert (false); + DCPOMATIC_ASSERT (false); return ""; } @@ -67,7 +67,7 @@ string_to_resolution (string s) return RESOLUTION_4K; } - assert (false); + DCPOMATIC_ASSERT (false); return RESOLUTION_2K; } diff --git a/src/lib/util.cc b/src/lib/util.cc index 502393094..0cdfe0b0c 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -708,7 +708,7 @@ stride_round_up (int c, int const * stride, int t) int round_to (float n, int r) { - assert (r == 1 || r == 2 || r == 4); + DCPOMATIC_ASSERT (r == 1 || r == 2 || r == 4); return int (n + float(r) / 2) &~ (r - 1); } @@ -813,13 +813,13 @@ get_optional_int (multimap const & kv, string k) void ensure_ui_thread () { - assert (boost::this_thread::get_id() == ui_thread); + DCPOMATIC_ASSERT (boost::this_thread::get_id() == ui_thread); } string audio_channel_name (int c) { - assert (MAX_DCP_AUDIO_CHANNELS == 12); + DCPOMATIC_ASSERT (MAX_DCP_AUDIO_CHANNELS == 12); /// TRANSLATORS: these are the names of audio channels; Lfe (sub) is the low-frequency /// enhancement channel (sub-woofer). HI is the hearing-impaired audio track and diff --git a/src/lib/util.h b/src/lib/util.h index f5d0b3aca..1c122b70c 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -27,7 +27,8 @@ #include "compose.hpp" #include "types.h" -#include "video_content.h" +#include "exceptions.h" +#include "dcpomatic_time.h" #include extern "C" { #include @@ -125,7 +126,7 @@ private: int _timeout; }; -extern int64_t video_frames_to_audio_frames (VideoContent::Frame v, float audio_sample_rate, float frames_per_second); +extern int64_t video_frames_to_audio_frames (VideoFrame v, float audio_sample_rate, float frames_per_second); /** @class ScopedTemporary * @brief A temporary file which is deleted when the ScopedTemporary object goes out of scope. diff --git a/src/lib/video_content.cc b/src/lib/video_content.cc index 1da5d87c1..c50d466a1 100644 --- a/src/lib/video_content.cc +++ b/src/lib/video_content.cc @@ -136,7 +136,7 @@ VideoContent::VideoContent (shared_ptr f, vector , _video_length (0) { shared_ptr ref = dynamic_pointer_cast (c[0]); - assert (ref); + DCPOMATIC_ASSERT (ref); for (size_t i = 0; i < c.size(); ++i) { shared_ptr vc = dynamic_pointer_cast (c[i]); @@ -240,7 +240,7 @@ VideoContent::take_from_video_examiner (shared_ptr d) } shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); LOG_GENERAL ("Video length obtained from header as %1 frames", _video_length.frames (_video_frame_rate)); signal_changed (VideoContentProperty::VIDEO_SIZE); @@ -413,7 +413,7 @@ VideoContent::video_size_after_3d_split () const return dcp::Size (s.width, s.height / 2); } - assert (false); + DCPOMATIC_ASSERT (false); } void @@ -474,7 +474,7 @@ ContentTime VideoContent::dcp_time_to_content_time (DCPTime t) const { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); return ContentTime (t, FrameRateChange (video_frame_rate(), film->video_frame_rate())); } @@ -482,7 +482,7 @@ void VideoContent::scale_and_crop_to_fit_width () { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); set_scale (VideoContentScale (film->container ())); @@ -495,7 +495,7 @@ void VideoContent::scale_and_crop_to_fit_height () { shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); set_scale (VideoContentScale (film->container ())); @@ -522,7 +522,7 @@ VideoContent::set_video_frame_rate (float r) optional VideoContent::fade (VideoFrame f) const { - assert (f >= 0); + DCPOMATIC_ASSERT (f >= 0); if (f < fade_in().frames (video_frame_rate ())) { return float (f) / _fade_in.frames (video_frame_rate ()); @@ -563,7 +563,7 @@ VideoContent::processing_description () const } shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); dcp::Size const container_size = film->frame_size (); dcp::Size const scaled = scale().size (dynamic_pointer_cast (shared_from_this ()), container_size, container_size, 1); diff --git a/src/lib/video_content.h b/src/lib/video_content.h index 30dcac231..9e5c1362f 100644 --- a/src/lib/video_content.h +++ b/src/lib/video_content.h @@ -43,8 +43,6 @@ public: class VideoContent : public virtual Content { public: - typedef int Frame; - VideoContent (boost::shared_ptr); VideoContent (boost::shared_ptr, DCPTime, ContentTime); VideoContent (boost::shared_ptr, boost::filesystem::path); diff --git a/src/lib/video_content_scale.cc b/src/lib/video_content_scale.cc index 9bb35189e..aebafc8e5 100644 --- a/src/lib/video_content_scale.cc +++ b/src/lib/video_content_scale.cc @@ -18,6 +18,7 @@ */ #include "video_content_scale.h" +#include "video_content.h" #include "ratio.h" #include "safe_stringstream.h" #include "util.h" diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index cab1a979f..b861f49e5 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -261,7 +261,7 @@ VideoDecoder::video (shared_ptr image, VideoFrame frame) to_push.push_back (ContentVideo (image, EYES_RIGHT, PART_WHOLE, frame)); break; default: - assert (false); + DCPOMATIC_ASSERT (false); } /* Now VideoDecoder is required never to have gaps in the frames that it presents diff --git a/src/lib/writer.cc b/src/lib/writer.cc index 07b637d46..512973f46 100644 --- a/src/lib/writer.cc +++ b/src/lib/writer.cc @@ -87,7 +87,7 @@ Writer::Writer (shared_ptr f, weak_ptr j) boost::filesystem::remove_all (_film->dir (_film->dcp_name ())); shared_ptr job = _job.lock (); - assert (job); + DCPOMATIC_ASSERT (job); job->sub (_("Checking existing image data")); check_existing_picture_mxf (); @@ -308,7 +308,7 @@ try _last_written_eyes = qi.eyes; shared_ptr job = _job.lock (); - assert (job); + DCPOMATIC_ASSERT (job); int64_t total = _film->length().frames (_film->video_frame_rate ()); if (_film->three_d ()) { /* _full_written and so on are incremented for each eye, so we need to double the total @@ -333,7 +333,7 @@ try ++i; } - assert (i != _queue.rend()); + DCPOMATIC_ASSERT (i != _queue.rend()); QueueItem qi = *i; ++_pushed_to_disk; @@ -483,7 +483,7 @@ Writer::finish () cpl->add (reel); shared_ptr job = _job.lock (); - assert (job); + DCPOMATIC_ASSERT (job); job->sub (_("Computing image digest")); _picture_mxf->hash (boost::bind (&Job::set_progress, job.get(), _1, false)); @@ -571,7 +571,7 @@ Writer::check_existing_picture_mxf () while (true) { shared_ptr job = _job.lock (); - assert (job); + DCPOMATIC_ASSERT (job); if (N > 0) { job->set_progress (float (_first_nonexistant_frame) / N); diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index 1f882e61f..1d41fc185 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -163,7 +163,7 @@ AudioDialog::channel_clicked (wxCommandEvent& ev) ++c; } - assert (c < MAX_DCP_AUDIO_CHANNELS); + DCPOMATIC_ASSERT (c < MAX_DCP_AUDIO_CHANNELS); _plot->set_channel_visible (c, _channel_checkbox[c]->GetValue ()); } @@ -186,7 +186,7 @@ AudioDialog::type_clicked (wxCommandEvent& ev) ++t; } - assert (t < AudioPoint::COUNT); + DCPOMATIC_ASSERT (t < AudioPoint::COUNT); _plot->set_type_visible (t, _type_checkbox[t]->GetValue ()); } diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index c528447ac..15a234184 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -136,7 +136,7 @@ ContentMenu::join () } } - assert (fc.size() > 1); + DCPOMATIC_ASSERT (fc.size() > 1); shared_ptr film = _film.lock (); if (!film) { @@ -245,8 +245,8 @@ ContentMenu::maybe_found_missing (weak_ptr j, weak_ptr oc, weak_pt shared_ptr old_content = oc.lock (); shared_ptr new_content = nc.lock (); - assert (old_content); - assert (new_content); + DCPOMATIC_ASSERT (old_content); + DCPOMATIC_ASSERT (new_content); if (new_content->digest() != old_content->digest()) { error_dialog (0, _("The content file(s) you specified are not the same as those that are missing. Either try again with the correct content file or remove the missing content.")); @@ -259,16 +259,16 @@ ContentMenu::maybe_found_missing (weak_ptr j, weak_ptr oc, weak_pt void ContentMenu::kdm () { - assert (!_content.empty ()); + DCPOMATIC_ASSERT (!_content.empty ()); shared_ptr dcp = dynamic_pointer_cast (_content.front ()); - assert (dcp); + DCPOMATIC_ASSERT (dcp); wxFileDialog* d = new wxFileDialog (_parent, _("Select KDM")); if (d->ShowModal() == wxID_OK) { dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ())))); shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); film->examine_content (dcp, true); } diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 18ba4ccfd..5b2d18f23 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -361,7 +361,7 @@ DCPPanel::container_changed () int const n = _container->GetSelection (); if (n >= 0) { vector ratios = Ratio::all (); - assert (n < int (ratios.size())); + DCPOMATIC_ASSERT (n < int (ratios.size())); _film->set_container (ratios[n]); } } diff --git a/src/wx/editable_list.h b/src/wx/editable_list.h index 481a14741..4119b889e 100644 --- a/src/wx/editable_list.h +++ b/src/wx/editable_list.h @@ -132,7 +132,7 @@ private: } std::vector all = _get (); - assert (item >= 0 && item < int (all.size ())); + DCPOMATIC_ASSERT (item >= 0 && item < int (all.size ())); T copy (all[item]); add_to_control (copy); @@ -149,7 +149,7 @@ private: } std::vector all = _get (); - assert (item >= 0 && item < int (all.size ())); + DCPOMATIC_ASSERT (item >= 0 && item < int (all.size ())); S* dialog = new S (this); dialog->set (all[item]); diff --git a/src/wx/hints_dialog.cc b/src/wx/hints_dialog.cc index 9f8956948..b5d5c6971 100644 --- a/src/wx/hints_dialog.cc +++ b/src/wx/hints_dialog.cc @@ -17,11 +17,12 @@ */ -#include -#include #include "lib/film.h" #include "lib/ratio.h" +#include "lib/video_content.h" #include "hints_dialog.h" +#include +#include using boost::shared_ptr; using boost::dynamic_pointer_cast; diff --git a/src/wx/kdm_dialog.cc b/src/wx/kdm_dialog.cc index 6a1f8051f..9b1d6bc98 100644 --- a/src/wx/kdm_dialog.cc +++ b/src/wx/kdm_dialog.cc @@ -472,7 +472,7 @@ boost::filesystem::path KDMDialog::cpl () const { int const item = _cpl->GetSelection (); - assert (item >= 0); + DCPOMATIC_ASSERT (item >= 0); return _cpls[item].cpl_file; } diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index 07b987a67..1e137f233 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -308,7 +308,7 @@ SubtitlePanel::subtitle_view_clicked () } SubtitleContentList c = _parent->selected_subtitle (); - assert (c.size() == 1); + DCPOMATIC_ASSERT (c.size() == 1); shared_ptr decoder; @@ -337,7 +337,7 @@ SubtitlePanel::fonts_dialog_clicked () } SubtitleContentList c = _parent->selected_subtitle (); - assert (c.size() == 1); + DCPOMATIC_ASSERT (c.size() == 1); _fonts_dialog = new FontsDialog (this, c.front ()); _fonts_dialog->Show (); diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 556e6f1b3..6bce881a4 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -96,7 +96,7 @@ public: dcpomatic::Rect bbox () const { - assert (_track); + DCPOMATIC_ASSERT (_track); shared_ptr film = _timeline.film (); shared_ptr content = _content.lock (); @@ -145,7 +145,7 @@ private: void do_paint (wxGraphicsContext* gc) { - assert (_track); + DCPOMATIC_ASSERT (_track); shared_ptr film = _timeline.film (); shared_ptr cont = content (); @@ -749,7 +749,7 @@ Timeline::set_position_from_event (wxMouseEvent& ev) _down_view->content()->set_position (new_position); shared_ptr film = _film.lock (); - assert (film); + DCPOMATIC_ASSERT (film); film->set_sequence_video (false); } diff --git a/src/wx/video_panel.cc b/src/wx/video_panel.cc index 716c29dda..cdd2eb5de 100644 --- a/src/wx/video_panel.cc +++ b/src/wx/video_panel.cc @@ -48,8 +48,8 @@ static VideoContentScale index_to_scale (int n) { vector scales = VideoContentScale::all (); - assert (n >= 0); - assert (n < int (scales.size ())); + DCPOMATIC_ASSERT (n >= 0); + DCPOMATIC_ASSERT (n < int (scales.size ())); return scales[n]; } @@ -63,7 +63,7 @@ scale_to_index (VideoContentScale scale) } } - assert (false); + DCPOMATIC_ASSERT (false); } VideoPanel::VideoPanel (ContentPanel* p) -- 2.30.2