Clean up channels coming from ffmpeg wrt those thought to be the case.
authorCarl Hetherington <cth@carlh.net>
Fri, 27 Jul 2012 00:52:07 +0000 (01:52 +0100)
committerCarl Hetherington <cth@carlh.net>
Fri, 27 Jul 2012 00:52:07 +0000 (01:52 +0100)
TODO
src/lib/decoder.cc
src/lib/decoder.h
src/lib/ffmpeg_decoder.cc

diff --git a/TODO b/TODO
index 0f5b4d1ab5b3702810d057a02e49b56531b7bfc8..956e114e105d01ecea600a97155cfdad2cb8821c 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,4 @@
 upload of (youtube) fails and of normal from windows
-sort out audio channel count mess, assert what we get is what we expect early on.
 
 Write still j2ks straight to a MXF.
 Seem to be problems when waiting for (failing) server threads at the end of an encode;
index a4eec02cbda8d3539ed67d7884899aabd4145cef..6bebe800c753b615e4a486769746979b4031fa69 100644 (file)
@@ -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);
index 198dfb8dcb6d1ccd0cb2f52fc5119aa6d785e981..5c69e12d06ed5a62133fc4427ee3668aec458bd8 100644 (file)
@@ -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;
index df7434ff8c3072b9c8f2f867c140da23b2f0a265..d2a10be1f28ecd0fab35ea2514e43c2269e7e41a 100644 (file)
@@ -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);
                }
        }