summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-07-03 22:35:30 +0200
committerCarl Hetherington <cth@carlh.net>2021-07-03 22:35:30 +0200
commit2d4e8c5f69cc694625ad95dcee554499605f823b (patch)
treedb816ca461a0b45d6be27a1ce37b8a03dac16f3f /src
parent16e560c3815b52609de103b45c1d5d2cbf155b97 (diff)
C++11 tidying.
Diffstat (limited to 'src')
-rw-r--r--src/lib/audio_filter.cc23
-rw-r--r--src/lib/audio_filter.h10
-rw-r--r--src/lib/encoder.cc6
-rw-r--r--src/lib/encoder.h11
-rw-r--r--src/lib/filter_graph.cc17
-rw-r--r--src/lib/filter_graph.h20
-rw-r--r--src/lib/user_property.h6
7 files changed, 55 insertions, 38 deletions
diff --git a/src/lib/audio_filter.cc b/src/lib/audio_filter.cc
index 24aa244f2..281ac9668 100644
--- a/src/lib/audio_filter.cc
+++ b/src/lib/audio_filter.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,14 +18,18 @@
*/
+
#include "audio_filter.h"
#include "audio_buffers.h"
#include "util.h"
#include <cmath>
+
+using std::make_shared;
using std::min;
using std::shared_ptr;
+
/** @return array of floats which the caller must destroy with delete[] */
float *
AudioFilter::sinc_blackman (float cutoff, bool invert) const
@@ -68,15 +72,17 @@ AudioFilter::sinc_blackman (float cutoff, bool invert) const
return ir;
}
+
AudioFilter::~AudioFilter ()
{
delete[] _ir;
}
+
shared_ptr<AudioBuffers>
AudioFilter::run (shared_ptr<const AudioBuffers> in)
{
- shared_ptr<AudioBuffers> out (new AudioBuffers (in->channels(), in->frames()));
+ auto out = make_shared<AudioBuffers>(in->channels(), in->frames());
if (!_tail) {
_tail.reset (new AudioBuffers (in->channels(), _M + 1));
@@ -87,9 +93,9 @@ AudioFilter::run (shared_ptr<const AudioBuffers> in)
int const frames = in->frames ();
for (int i = 0; i < channels; ++i) {
- float* tail_p = _tail->data (i);
- float* in_p = in->data (i);
- float* out_p = out->data (i);
+ auto tail_p = _tail->data (i);
+ auto in_p = in->data (i);
+ auto out_p = out->data (i);
for (int j = 0; j < frames; ++j) {
float s = 0;
for (int k = 0; k <= _M; ++k) {
@@ -113,12 +119,14 @@ AudioFilter::run (shared_ptr<const AudioBuffers> in)
return out;
}
+
void
AudioFilter::flush ()
{
_tail.reset ();
}
+
LowPassAudioFilter::LowPassAudioFilter (float transition_bandwidth, float cutoff)
: AudioFilter (transition_bandwidth)
{
@@ -132,11 +140,12 @@ HighPassAudioFilter::HighPassAudioFilter (float transition_bandwidth, float cuto
_ir = sinc_blackman (cutoff, true);
}
+
BandPassAudioFilter::BandPassAudioFilter (float transition_bandwidth, float lower, float higher)
: AudioFilter (transition_bandwidth)
{
- float* lpf = sinc_blackman (lower, false);
- float* hpf = sinc_blackman (higher, true);
+ auto lpf = sinc_blackman (lower, false);
+ auto hpf = sinc_blackman (higher, true);
delete[] _ir;
_ir = new float[_M + 1];
diff --git a/src/lib/audio_filter.h b/src/lib/audio_filter.h
index 500cfa6e2..922cc5fdb 100644
--- a/src/lib/audio_filter.h
+++ b/src/lib/audio_filter.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -28,6 +28,7 @@
class AudioBuffers;
struct audio_filter_impulse_input_test;
+
/** An audio filter which can take AudioBuffers and apply some filtering operation,
* returning filtered samples
*/
@@ -35,7 +36,6 @@ class AudioFilter
{
public:
explicit AudioFilter (float transition_bandwidth)
- : _ir (0)
{
_M = 4 / transition_bandwidth;
if (_M % 2) {
@@ -55,11 +55,12 @@ protected:
float* sinc_blackman (float cutoff, bool invert) const;
- float* _ir;
+ float* _ir = nullptr;
int _M;
std::shared_ptr<AudioBuffers> _tail;
};
+
class LowPassAudioFilter : public AudioFilter
{
public:
@@ -70,6 +71,7 @@ public:
LowPassAudioFilter (float transition_bandwidth, float cutoff);
};
+
class HighPassAudioFilter : public AudioFilter
{
public:
@@ -80,6 +82,7 @@ public:
HighPassAudioFilter (float transition_bandwidth, float cutoff);
};
+
class BandPassAudioFilter : public AudioFilter
{
public:
@@ -91,4 +94,5 @@ public:
BandPassAudioFilter (float transition_bandwidth, float lower, float higher);
};
+
#endif
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index fd826deb6..fe27cb7dd 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -18,6 +18,7 @@
*/
+
/** @file src/encoder.cc
* @brief A class which takes a Film and some Options, then uses those to encode the film
* into some output format.
@@ -26,19 +27,18 @@
* as a parameter to the constructor.
*/
+
#include "encoder.h"
#include "player.h"
#include "i18n.h"
-using std::weak_ptr;
-using std::shared_ptr;
/** Construct an encoder.
* @param film Film that we are encoding.
* @param job Job that this encoder is being used in.
*/
-Encoder::Encoder (shared_ptr<const Film> film, weak_ptr<Job> job)
+Encoder::Encoder (std::shared_ptr<const Film> film, std::weak_ptr<Job> job)
: _film (film)
, _job (job)
, _player (new Player(film))
diff --git a/src/lib/encoder.h b/src/lib/encoder.h
index 1403e75b2..19c1120b3 100644
--- a/src/lib/encoder.h
+++ b/src/lib/encoder.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,13 +18,16 @@
*/
+
#ifndef DCPOMATIC_ENCODER_H
#define DCPOMATIC_ENCODER_H
-#include "types.h"
+
#include "player_text.h"
+#include "types.h"
#include <boost/signals2.hpp>
+
class Film;
class Encoder;
class Player;
@@ -32,6 +35,7 @@ class Job;
class PlayerVideo;
class AudioBuffers;
+
/** @class Encoder
* @brief Parent class for something that can encode a film into some format
*/
@@ -48,7 +52,7 @@ public:
/** @return the current frame rate over the last short while */
virtual boost::optional<float> current_rate () const {
- return boost::optional<float>();
+ return {};
}
/** @return the number of frames that are done */
@@ -61,4 +65,5 @@ protected:
std::shared_ptr<Player> _player;
};
+
#endif
diff --git a/src/lib/filter_graph.cc b/src/lib/filter_graph.cc
index ba0e01ed5..fc6b9033a 100644
--- a/src/lib/filter_graph.cc
+++ b/src/lib/filter_graph.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -50,22 +50,11 @@ using std::weak_ptr;
using dcp::Size;
-/** Construct a FilterGraph for the settings in a piece of content */
-FilterGraph::FilterGraph ()
- : _graph (0)
- , _copy (false)
- , _buffer_src_context (0)
- , _buffer_sink_context (0)
- , _frame (0)
-{
-
-}
-
void
FilterGraph::setup (vector<Filter const *> filters)
{
- string const filters_string = Filter::ffmpeg_string (filters);
- if (filters.empty ()) {
+ auto const filters_string = Filter::ffmpeg_string (filters);
+ if (filters.empty()) {
_copy = true;
return;
}
diff --git a/src/lib/filter_graph.h b/src/lib/filter_graph.h
index d5a2da7a2..9ee628d4c 100644
--- a/src/lib/filter_graph.h
+++ b/src/lib/filter_graph.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,13 +18,16 @@
*/
+
/** @file src/lib/filter_graph.h
* @brief A graph of FFmpeg filters.
*/
+
#ifndef DCPOMATIC_FILTER_GRAPH_H
#define DCPOMATIC_FILTER_GRAPH_H
+
#include "util.h"
#include "warnings.h"
DCPOMATIC_DISABLE_WARNINGS
@@ -33,18 +36,20 @@ extern "C" {
}
DCPOMATIC_ENABLE_WARNINGS
+
struct AVFilterContext;
struct AVFrame;
class Image;
class Filter;
+
/** @class FilterGraph
* @brief A graph of FFmpeg filters.
*/
class FilterGraph
{
public:
- FilterGraph ();
+ FilterGraph() = default;
virtual ~FilterGraph ();
FilterGraph (FilterGraph const&) = delete;
@@ -59,12 +64,13 @@ protected:
virtual void set_parameters (AVFilterContext* context) const = 0;
virtual std::string sink_name () const = 0;
- AVFilterGraph* _graph;
+ AVFilterGraph* _graph = nullptr;
/** true if this graph has no filters in, so it just copies stuff straight through */
- bool _copy;
- AVFilterContext* _buffer_src_context;
- AVFilterContext* _buffer_sink_context;
- AVFrame* _frame;
+ bool _copy = false;
+ AVFilterContext* _buffer_src_context = nullptr;
+ AVFilterContext* _buffer_sink_context = nullptr;
+ AVFrame* _frame = nullptr;
};
+
#endif
diff --git a/src/lib/user_property.h b/src/lib/user_property.h
index ffbb99a5f..fb597eeb6 100644
--- a/src/lib/user_property.h
+++ b/src/lib/user_property.h
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,11 +18,14 @@
*/
+
#ifndef DCPOMATIC_USER_PROPERTY_H
#define DCPOMATIC_USER_PROPERTY_H
+
#include <dcp/locale_convert.h>
+
class UserProperty
{
public:
@@ -47,4 +50,5 @@ public:
std::string unit;
};
+
#endif