summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-07-27 01:52:07 +0100
committerCarl Hetherington <cth@carlh.net>2012-07-27 01:52:07 +0100
commitf0488edf2b3bc2874deb077879523becba7d0d10 (patch)
treececcd80049ce4cd309e6ba1518cf202314dd82f9 /src
parentb15e972e14ba5ad2863cb878fa02409eb87a41f8 (diff)
Clean up channels coming from ffmpeg wrt those thought to be the case.
Diffstat (limited to 'src')
-rw-r--r--src/lib/decoder.cc10
-rw-r--r--src/lib/decoder.h2
-rw-r--r--src/lib/ffmpeg_decoder.cc3
3 files changed, 8 insertions, 7 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index a4eec02cb..6bebe800c 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -220,10 +220,10 @@ Decoder::pass ()
/** Called by subclasses to tell the world that some audio data is ready */
void
-Decoder::process_audio (uint8_t* data, int channels, int size)
+Decoder::process_audio (uint8_t* data, int size)
{
int const samples = size / _fs->bytes_per_sample();
- int const frames = samples / channels;
+ int const frames = samples / _fs->audio_channels;
if (_fs->audio_gain != 0) {
float const linear_gain = pow (10, _fs->audio_gain / 20);
@@ -256,7 +256,7 @@ Decoder::process_audio (uint8_t* data, int channels, int size)
};
int const out_buffer_size_frames = ceil (frames * float (dcp_audio_sample_rate (_fs->audio_sample_rate)) / _fs->audio_sample_rate) + 32;
- int const out_buffer_size_bytes = out_buffer_size_frames * channels * _fs->bytes_per_sample();
+ int const out_buffer_size_bytes = out_buffer_size_frames * _fs->audio_channels * _fs->bytes_per_sample();
out_buffer = new uint8_t[out_buffer_size_bytes];
uint8_t* out[2] = {
@@ -270,11 +270,11 @@ Decoder::process_audio (uint8_t* data, int channels, int size)
}
data = out_buffer;
- size = out_frames * channels * _fs->bytes_per_sample();
+ size = out_frames * _fs->audio_channels * _fs->bytes_per_sample();
}
/* Update the number of audio frames we've pushed to the encoder */
- _audio_frames_processed += size / (channels * _fs->bytes_per_sample ());
+ _audio_frames_processed += size / (_fs->audio_channels * _fs->bytes_per_sample ());
int available = _delay_line->feed (data, size);
Audio (data, available);
diff --git a/src/lib/decoder.h b/src/lib/decoder.h
index 198dfb8dc..5c69e12d0 100644
--- a/src/lib/decoder.h
+++ b/src/lib/decoder.h
@@ -104,7 +104,7 @@ protected:
virtual int sample_aspect_ratio_denominator () const = 0;
void process_video (AVFrame *);
- void process_audio (uint8_t *, int, int);
+ void process_audio (uint8_t *, int);
/** our FilmState */
boost::shared_ptr<const FilmState> _fs;
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index df7434ff8..d2a10be1f 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -172,7 +172,8 @@ FFmpegDecoder::do_pass ()
0, _audio_codec_context->channels, _frame->nb_samples, audio_sample_format (), 1
);
- process_audio (_frame->data[0], _audio_codec_context->channels, data_size);
+ assert (_audio_codec_context->channels == _fs->audio_channels);
+ process_audio (_frame->data[0], data_size);
}
}