summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-01-06 14:31:12 +0000
committerCarl Hetherington <cth@carlh.net>2013-01-06 14:31:12 +0000
commit7e25d487cba3c23d847aedee84a8e5143f4a209c (patch)
tree1fa33dc4ec81e27dc3f2b8b49c93a1f6a5707b30 /src/lib
parentb681612ff9f1cdb06d9aa5b246dc294442a31ddb (diff)
parente9fa6f47c5cd52f0b56f277fdeaf6a4f636ddf01 (diff)
Merge branch 'master' of /home/carl/git/dvdomatic
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/encoder.cc20
-rw-r--r--src/lib/image.cc20
-rw-r--r--src/lib/image.h1
-rw-r--r--src/lib/make_dcp_job.cc2
-rw-r--r--src/lib/util.cc14
-rw-r--r--src/lib/util.h1
6 files changed, 33 insertions, 25 deletions
diff --git a/src/lib/encoder.cc b/src/lib/encoder.cc
index 07ce8f3bc..4a829bafd 100644
--- a/src/lib/encoder.cc
+++ b/src/lib/encoder.cc
@@ -65,7 +65,7 @@ Encoder::Encoder (shared_ptr<const Film> f, shared_ptr<const EncodeOptions> o)
/* Create sound output files with .tmp suffixes; we will rename
them if and when we complete.
*/
- for (int i = 0; i < _film->audio_channels(); ++i) {
+ for (int i = 0; i < dcp_audio_channels (_film->audio_channels()); ++i) {
SF_INFO sf_info;
sf_info.samplerate = dcp_audio_sample_rate (_film->audio_stream()->sample_rate());
/* We write mono files */
@@ -163,7 +163,7 @@ Encoder::process_end ()
close_sound_files ();
/* Rename .wav.tmp files to .wav */
- for (int i = 0; i < _film->audio_channels(); ++i) {
+ for (int i = 0; i < dcp_audio_channels (_film->audio_channels()); ++i) {
if (boost::filesystem::exists (_opt->multichannel_audio_out_path (i, false))) {
boost::filesystem::remove (_opt->multichannel_audio_out_path (i, false));
}
@@ -380,6 +380,20 @@ Encoder::process_audio (shared_ptr<AudioBuffers> data)
}
#endif
+ if (_film->audio_channels() == 1) {
+ /* We need to switch things around so that the mono channel is on
+ the centre channel of a 5.1 set (with other channels silent).
+ */
+
+ shared_ptr<AudioBuffers> b (new AudioBuffers (6, data->frames ()));
+ b->make_silent (libdcp::LEFT);
+ b->make_silent (libdcp::RIGHT);
+ memcpy (b->data()[libdcp::CENTRE], data->data()[0], data->frames() * sizeof(float));
+ b->make_silent (libdcp::LFE);
+ b->make_silent (libdcp::LS);
+ b->make_silent (libdcp::RS);
+ }
+
write_audio (data);
_audio_frame += data->frames ();
@@ -388,7 +402,7 @@ Encoder::process_audio (shared_ptr<AudioBuffers> data)
void
Encoder::write_audio (shared_ptr<const AudioBuffers> audio)
{
- for (int i = 0; i < _film->audio_channels(); ++i) {
+ for (int i = 0; i < audio->channels(); ++i) {
sf_write_float (_sound_files[i], audio->data(i), audio->frames());
}
diff --git a/src/lib/image.cc b/src/lib/image.cc
index e136a8469..f774f476f 100644
--- a/src/lib/image.cc
+++ b/src/lib/image.cc
@@ -448,26 +448,6 @@ SimpleImage::~SimpleImage ()
av_free (_stride);
}
-SimpleImage::SimpleImage (shared_ptr<const Image> im, bool aligned)
- : Image (im->pixel_format())
-{
- assert (components() == im->components());
-
- for (int c = 0; c < components(); ++c) {
-
- assert (line_size()[c] == im->line_size()[c]);
-
- uint8_t* t = data()[c];
- uint8_t* o = im->data()[c];
-
- for (int y = 0; y < lines(c); ++y) {
- memcpy (t, o, line_size()[c]);
- t += stride()[c];
- o += im->stride()[c];
- }
- }
-}
-
uint8_t **
SimpleImage::data () const
{
diff --git a/src/lib/image.h b/src/lib/image.h
index 13b92d72f..95e0de9dc 100644
--- a/src/lib/image.h
+++ b/src/lib/image.h
@@ -124,7 +124,6 @@ public:
SimpleImage (AVPixelFormat, Size, bool);
SimpleImage (SimpleImage const &);
SimpleImage& operator= (SimpleImage const &);
- SimpleImage (boost::shared_ptr<const Image>, bool aligned);
~SimpleImage ();
uint8_t ** data () const;
diff --git a/src/lib/make_dcp_job.cc b/src/lib/make_dcp_job.cc
index 4605d1724..5272d6bad 100644
--- a/src/lib/make_dcp_job.cc
+++ b/src/lib/make_dcp_job.cc
@@ -131,7 +131,7 @@ MakeDCPJob::run ()
&dcp.Progress,
dfr.frames_per_second,
frames,
- _film->audio_channels()
+ dcp_audio_channels (_film->audio_channels())
)
);
ascend ();
diff --git a/src/lib/util.cc b/src/lib/util.cc
index 45965385c..395c53e31 100644
--- a/src/lib/util.cc
+++ b/src/lib/util.cc
@@ -364,6 +364,20 @@ dcp_audio_sample_rate (int fs)
return 96000;
}
+int
+dcp_audio_channels (int f)
+{
+ if (f) {
+ /* The source is mono, so to put the mono channel into
+ the centre we need to generate a 5.1 soundtrack.
+ */
+ return 6;
+ }
+
+ return f;
+}
+
+
bool operator== (Size const & a, Size const & b)
{
return (a.width == b.width && a.height == b.height);
diff --git a/src/lib/util.h b/src/lib/util.h
index 3832cc579..0744d9c09 100644
--- a/src/lib/util.h
+++ b/src/lib/util.h
@@ -184,6 +184,7 @@ struct Rect
extern std::string crop_string (Position, Size);
extern int dcp_audio_sample_rate (int);
extern DCPFrameRate dcp_frame_rate (float);
+extern int dcp_audio_channels (int);
extern std::string colour_lut_index_to_name (int index);
extern int stride_round_up (int, int const *, int);
extern int stride_lookup (int c, int const * stride);