summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2016-05-16 23:46:51 +0100
committerCarl Hetherington <cth@carlh.net>2016-05-18 11:50:29 +0100
commitd60b9d006fee94fab80ee86fe1149de7f2e76750 (patch)
treee7821dc323ec6e3b53bf25266350e355c4de0fc0 /src/lib
parent3ce77bc8f0f047725f40a5f1725833fce5f8db63 (diff)
Remove Sndfile code and use FFmpeg instead.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/content_factory.cc27
-rw-r--r--src/lib/ffmpeg_audio_stream.h5
-rw-r--r--src/lib/player.cc32
-rw-r--r--src/lib/playlist.cc2
-rw-r--r--src/lib/sndfile_base.cc54
-rw-r--r--src/lib/sndfile_base.h40
-rw-r--r--src/lib/sndfile_content.h48
-rw-r--r--src/lib/sndfile_decoder.cc103
-rw-r--r--src/lib/sndfile_decoder.h38
-rw-r--r--src/lib/sndfile_examiner.cc46
-rw-r--r--src/lib/sndfile_examiner.h31
-rw-r--r--src/lib/wscript6
12 files changed, 30 insertions, 402 deletions
diff --git a/src/lib/content_factory.cc b/src/lib/content_factory.cc
index c3278e30e..e21a4c0d0 100644
--- a/src/lib/content_factory.cc
+++ b/src/lib/content_factory.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -22,12 +22,13 @@
*/
#include "ffmpeg_content.h"
+#include "audio_content.h"
#include "image_content.h"
-#include "sndfile_content.h"
#include "text_subtitle_content.h"
#include "dcp_content.h"
#include "dcp_subtitle_content.h"
#include "util.h"
+#include "ffmpeg_audio_stream.h"
#include "film.h"
#include "log_entry.h"
#include "log.h"
@@ -57,11 +58,29 @@ content_factory (shared_ptr<const Film> film, cxml::NodePtr node, int version, l
boost::shared_ptr<Content> content;
if (type == "FFmpeg") {
+ /* SndfileContent is now handled by the FFmpeg code rather than by
+ separate libsndfile-based code.
+ */
content.reset (new FFmpegContent (film, node, version, notes));
} else if (type == "Image") {
content.reset (new ImageContent (film, node, version));
} else if (type == "Sndfile") {
- content.reset (new SndfileContent (film, node, version));
+ /* SndfileContent is now handled by the FFmpeg code rather than by
+ separate libsndfile-based code.
+ */
+ content.reset (new FFmpegContent (film, node, version, notes));
+
+ content->audio->set_stream (
+ AudioStreamPtr (
+ new FFmpegAudioStream (
+ "Stream", 0,
+ node->number_child<int> ("AudioFrameRate"),
+ node->number_child<Frame> ("AudioLength"),
+ AudioMapping (node->node_child ("AudioMapping"), version)
+ )
+ )
+ );
+
} else if (type == "SubRip" || type == "TextSubtitle") {
content.reset (new TextSubtitleContent (film, node, version));
} else if (type == "DCP") {
@@ -137,8 +156,6 @@ content_factory (shared_ptr<const Film> film, boost::filesystem::path path)
if (valid_image_file (path)) {
content.reset (new ImageContent (film, path));
- } else if (SndfileContent::valid_file (path)) {
- content.reset (new SndfileContent (film, path));
} else if (ext == ".srt" || ext == ".ssa") {
content.reset (new TextSubtitleContent (film, path));
} else if (ext == ".xml") {
diff --git a/src/lib/ffmpeg_audio_stream.h b/src/lib/ffmpeg_audio_stream.h
index 8de43c632..984d8ccad 100644
--- a/src/lib/ffmpeg_audio_stream.h
+++ b/src/lib/ffmpeg_audio_stream.h
@@ -31,6 +31,11 @@ public:
, AudioStream (frame_rate, length, channels)
{}
+ FFmpegAudioStream (std::string name, int id, int frame_rate, Frame length, AudioMapping mapping)
+ : FFmpegStream (name, id)
+ , AudioStream (frame_rate, length, mapping)
+ {}
+
FFmpegAudioStream (cxml::ConstNodePtr, int);
void as_xml (xmlpp::Node *) const;
diff --git a/src/lib/player.cc b/src/lib/player.cc
index 801e145af..cd841d1ce 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -21,13 +21,13 @@
#include "film.h"
#include "ffmpeg_decoder.h"
#include "video_decoder.h"
+#include "audio_decoder.h"
#include "audio_buffers.h"
#include "audio_content.h"
#include "ffmpeg_content.h"
#include "image_decoder.h"
+#include "content_audio.h"
#include "image_content.h"
-#include "sndfile_decoder.h"
-#include "sndfile_content.h"
#include "subtitle_content.h"
#include "text_subtitle_decoder.h"
#include "text_subtitle_content.h"
@@ -160,34 +160,6 @@ Player::setup_pieces ()
frc = FrameRateChange (ic->active_video_frame_rate(), _film->video_frame_rate());
}
- /* SndfileContent */
- shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (i);
- if (sc) {
- decoder.reset (new SndfileDecoder (sc, _fast, _film->log()));
-
- /* Work out a FrameRateChange for the best overlap video for this content */
- DCPTime best_overlap_t;
- shared_ptr<Content> best_overlap;
- BOOST_FOREACH (shared_ptr<Content> j, _playlist->content ()) {
- if (!j->video) {
- continue;
- }
-
- DCPTime const overlap = min (j->end(), i->end()) - max (j->position(), i->position());
- if (overlap > best_overlap_t) {
- best_overlap = j;
- best_overlap_t = overlap;
- }
- }
-
- if (best_overlap) {
- frc = FrameRateChange (best_overlap->active_video_frame_rate(), _film->video_frame_rate ());
- } else {
- /* No video overlap; e.g. if the DCP is just audio */
- frc = FrameRateChange (_film->video_frame_rate(), _film->video_frame_rate ());
- }
- }
-
/* It's questionable whether subtitle content should have a video frame rate; perhaps
it should be assumed that any subtitle content has been prepared at the same rate
as simultaneous video content (like we do with audio).
diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc
index bd6abc31d..41ce862b5 100644
--- a/src/lib/playlist.cc
+++ b/src/lib/playlist.cc
@@ -18,8 +18,6 @@
*/
#include "playlist.h"
-#include "sndfile_content.h"
-#include "sndfile_decoder.h"
#include "video_content.h"
#include "subtitle_content.h"
#include "ffmpeg_decoder.h"
diff --git a/src/lib/sndfile_base.cc b/src/lib/sndfile_base.cc
deleted file mode 100644
index 712df7bda..000000000
--- a/src/lib/sndfile_base.cc
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifdef DCPOMATIC_WINDOWS
-#include <windows.h>
-#define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
-#endif
-#include <sndfile.h>
-
-#include "sndfile_base.h"
-#include "sndfile_content.h"
-#include "exceptions.h"
-
-#include "i18n.h"
-
-using boost::shared_ptr;
-
-Sndfile::Sndfile (shared_ptr<const SndfileContent> c)
- : _sndfile_content (c)
-{
- _info.format = 0;
-
- /* Here be monsters. See fopen_boost for similar shenanigans */
-#ifdef DCPOMATIC_WINDOWS
- _sndfile = sf_wchar_open (_sndfile_content->path(0).c_str(), SFM_READ, &_info);
-#else
- _sndfile = sf_open (_sndfile_content->path(0).string().c_str(), SFM_READ, &_info);
-#endif
-
- if (!_sndfile) {
- throw DecodeError (_("could not open audio file for reading"));
- }
-}
-
-Sndfile::~Sndfile ()
-{
- sf_close (_sndfile);
-}
diff --git a/src/lib/sndfile_base.h b/src/lib/sndfile_base.h
deleted file mode 100644
index 4b7a50fc7..000000000
--- a/src/lib/sndfile_base.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef DCPOMATIC_SNDFILE_BASE_H
-#define DCPOMATIC_SNDFILE_BASE_H
-
-#include <sndfile.h>
-#include <boost/shared_ptr.hpp>
-
-class SndfileContent;
-
-class Sndfile
-{
-public:
- Sndfile (boost::shared_ptr<const SndfileContent> content);
- virtual ~Sndfile ();
-
-protected:
- boost::shared_ptr<const SndfileContent> _sndfile_content;
- SNDFILE* _sndfile;
- SF_INFO _info;
-};
-
-#endif
diff --git a/src/lib/sndfile_content.h b/src/lib/sndfile_content.h
deleted file mode 100644
index cdb842c04..000000000
--- a/src/lib/sndfile_content.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#ifndef DCPOMATIC_SNDFILE_CONTENT_H
-#define DCPOMATIC_SNDFILE_CONTENT_H
-
-#include "content.h"
-
-class AudioExaminer;
-
-class SndfileContent : public Content
-{
-public:
- SndfileContent (boost::shared_ptr<const Film>, boost::filesystem::path);
- SndfileContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
-
- boost::shared_ptr<SndfileContent> shared_from_this () {
- return boost::dynamic_pointer_cast<SndfileContent> (Content::shared_from_this ());
- }
-
- DCPTime full_length () const;
-
- void examine (boost::shared_ptr<Job>);
- std::string summary () const;
- std::string technical_summary () const;
- std::string information () const;
- void as_xml (xmlpp::Node *) const;
-
- static bool valid_file (boost::filesystem::path);
-};
-
-#endif
diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc
deleted file mode 100644
index 2a2b3fe4a..000000000
--- a/src/lib/sndfile_decoder.cc
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include <iostream>
-#include <sndfile.h>
-#include "audio_content.h"
-#include "sndfile_content.h"
-#include "sndfile_decoder.h"
-#include "exceptions.h"
-#include "audio_buffers.h"
-
-#include "i18n.h"
-
-using std::vector;
-using std::string;
-using std::min;
-using std::cout;
-using boost::shared_ptr;
-
-SndfileDecoder::SndfileDecoder (shared_ptr<const SndfileContent> c, bool fast, shared_ptr<Log> log)
- : Sndfile (c)
- , _done (0)
- , _remaining (_info.frames)
- , _deinterleave_buffer (0)
-{
- audio.reset (new AudioDecoder (this, c->audio, fast, log));
-}
-
-SndfileDecoder::~SndfileDecoder ()
-{
- delete[] _deinterleave_buffer;
-}
-
-bool
-SndfileDecoder::pass (PassReason, bool)
-{
- if (_remaining == 0) {
- return true;
- }
-
- /* Do things in half second blocks as I think there may be limits
- to what FFmpeg (and in particular the resampler) can cope with.
- */
- sf_count_t const block = _sndfile_content->audio->stream()->frame_rate() / 2;
- sf_count_t const this_time = min (block, _remaining);
-
- int const channels = _sndfile_content->audio->stream()->channels ();
-
- shared_ptr<AudioBuffers> data (new AudioBuffers (channels, this_time));
-
- if (_sndfile_content->audio->stream()->channels() == 1) {
- /* No de-interleaving required */
- sf_read_float (_sndfile, data->data(0), this_time);
- } else {
- /* Deinterleave */
- if (!_deinterleave_buffer) {
- _deinterleave_buffer = new float[block * channels];
- }
- sf_readf_float (_sndfile, _deinterleave_buffer, this_time);
- vector<float*> out_ptr (channels);
- for (int i = 0; i < channels; ++i) {
- out_ptr[i] = data->data(i);
- }
- float* in_ptr = _deinterleave_buffer;
- for (int i = 0; i < this_time; ++i) {
- for (int j = 0; j < channels; ++j) {
- *out_ptr[j]++ = *in_ptr++;
- }
- }
- }
-
- data->set_frames (this_time);
- audio->give (_sndfile_content->audio->stream (), data, ContentTime::from_frames (_done, _info.samplerate));
- _done += this_time;
- _remaining -= this_time;
-
- return _remaining == 0;
-}
-
-void
-SndfileDecoder::seek (ContentTime t, bool accurate)
-{
- audio->seek (t, accurate);
-
- _done = t.frames_round (_info.samplerate);
- _remaining = _info.frames - _done;
-}
diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h
deleted file mode 100644
index d3f9342b3..000000000
--- a/src/lib/sndfile_decoder.h
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "audio_decoder.h"
-#include "sndfile_base.h"
-
-class SndfileContent;
-
-class SndfileDecoder : public Sndfile, public Decoder
-{
-public:
- SndfileDecoder (boost::shared_ptr<const SndfileContent> c, bool fast, boost::shared_ptr<Log> log);
- ~SndfileDecoder ();
-
-private:
- bool pass (PassReason, bool);
- void seek (ContentTime, bool);
-
- int64_t _done;
- int64_t _remaining;
- float* _deinterleave_buffer;
-};
diff --git a/src/lib/sndfile_examiner.cc b/src/lib/sndfile_examiner.cc
deleted file mode 100644
index 5f2338ab8..000000000
--- a/src/lib/sndfile_examiner.cc
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "sndfile_examiner.h"
-
-using boost::shared_ptr;
-
-SndfileExaminer::SndfileExaminer (shared_ptr<const SndfileContent> content)
- : Sndfile (content)
-{
-
-}
-
-int
-SndfileExaminer::audio_channels () const
-{
- return _info.channels;
-}
-
-Frame
-SndfileExaminer::audio_length () const
-{
- return _info.frames;
-}
-
-int
-SndfileExaminer::audio_frame_rate () const
-{
- return _info.samplerate;
-}
diff --git a/src/lib/sndfile_examiner.h b/src/lib/sndfile_examiner.h
deleted file mode 100644
index c64ceae6e..000000000
--- a/src/lib/sndfile_examiner.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
-
- This program 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.
-
- This program 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 this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-*/
-
-#include "sndfile_base.h"
-#include "audio_examiner.h"
-
-class SndfileExaminer : public Sndfile, public AudioExaminer
-{
-public:
- SndfileExaminer (boost::shared_ptr<const SndfileContent> content);
-
- int audio_channels () const;
- Frame audio_length () const;
- int audio_frame_rate () const;
-};
diff --git a/src/lib/wscript b/src/lib/wscript
index 4b6754b2e..fe4eac114 100644
--- a/src/lib/wscript
+++ b/src/lib/wscript
@@ -114,10 +114,6 @@ sources = """
send_kdm_email_job.cc
send_problem_report_job.cc
server.cc
- sndfile_base.cc
- sndfile_content.cc
- sndfile_decoder.cc
- sndfile_examiner.cc
string_log_entry.cc
text_subtitle.cc
text_subtitle_content.cc
@@ -153,7 +149,7 @@ def build(bld):
obj.uselib = """
AVCODEC AVUTIL AVFORMAT AVFILTER SWSCALE
BOOST_FILESYSTEM BOOST_THREAD BOOST_DATETIME BOOST_SIGNALS2 BOOST_REGEX
- SNDFILE SAMPLERATE POSTPROC TIFF MAGICK SSH DCP CXML GLIB LZMA XML++
+ SAMPLERATE POSTPROC TIFF MAGICK SSH DCP CXML GLIB LZMA XML++
CURL ZIP FONTCONFIG PANGOMM CAIROMM XMLSEC SUB ICU
"""