/*
- 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.
*/
+
#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
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));
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) {
return out;
}
+
void
AudioFilter::flush ()
{
_tail.reset ();
}
+
LowPassAudioFilter::LowPassAudioFilter (float transition_bandwidth, float cutoff)
: AudioFilter (transition_bandwidth)
{
_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];
/*
- 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.
class AudioBuffers;
struct audio_filter_impulse_input_test;
+
/** An audio filter which can take AudioBuffers and apply some filtering operation,
* returning filtered samples
*/
{
public:
explicit AudioFilter (float transition_bandwidth)
- : _ir (0)
{
_M = 4 / transition_bandwidth;
if (_M % 2) {
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:
LowPassAudioFilter (float transition_bandwidth, float cutoff);
};
+
class HighPassAudioFilter : public AudioFilter
{
public:
HighPassAudioFilter (float transition_bandwidth, float cutoff);
};
+
class BandPassAudioFilter : public AudioFilter
{
public:
BandPassAudioFilter (float transition_bandwidth, float lower, float higher);
};
+
#endif
*/
+
/** @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.
* 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))
/*
- 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.
*/
+
#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;
class PlayerVideo;
class AudioBuffers;
+
/** @class Encoder
* @brief Parent class for something that can encode a film into some format
*/
/** @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 */
std::shared_ptr<Player> _player;
};
+
#endif
/*
- 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.
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;
}
/*
- 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.
*/
+
/** @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
}
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;
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
/*
- 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.
*/
+
#ifndef DCPOMATIC_USER_PROPERTY_H
#define DCPOMATIC_USER_PROPERTY_H
+
#include <dcp/locale_convert.h>
+
class UserProperty
{
public:
std::string unit;
};
+
#endif