Remove believed unnecessary audio channel layout stuff for resampler.
authorCarl Hetherington <cth@carlh.net>
Wed, 10 Apr 2013 19:45:07 +0000 (20:45 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 10 Apr 2013 19:45:07 +0000 (20:45 +0100)
src/lib/audio_content.h
src/lib/encoder.cc
src/lib/ffmpeg_content.cc
src/lib/ffmpeg_content.h
src/lib/ffmpeg_decoder.cc
src/lib/film.cc
src/lib/film.h
src/lib/imagemagick_decoder.h
src/lib/playlist.cc
src/lib/playlist.h
src/lib/sndfile_content.h

index d5dbf266bb6c5db616cb561220c59a0a830ac421..dbd55943d096430c482ff2a3e75e88376c613315 100644 (file)
@@ -45,8 +45,6 @@ public:
         virtual int audio_channels () const = 0;
         virtual ContentAudioFrame audio_length () const = 0;
         virtual int audio_frame_rate () const = 0;
-        virtual int64_t audio_channel_layout () const = 0;
-       
 };
 
 #endif
index 46d11c55640e2fbf92a0789748f9f9a284c1d0b8..b897c8a314f5b6c439d9ba389077545e4f9742bc 100644 (file)
@@ -86,13 +86,20 @@ Encoder::process_begin ()
                s << String::compose (N_("Will resample audio from %1 to %2"), _film->audio_frame_rate(), _film->target_audio_sample_rate());
                _film->log()->log (s.str ());
 
-               /* We will be using planar float data when we call the resampler */
+               /* We will be using planar float data when we call the
+                  resampler.  As far as I can see, the audio channel
+                  layout is not necessary for our purposes; it seems
+                  only to be used get the number of channels and
+                  decide if rematrixing is needed.  It won't be, since
+                  input and output layouts are the same.
+               */
+                  
                _swr_context = swr_alloc_set_opts (
                        0,
-                       _film->audio_channel_layout(),
+                       av_get_default_channel_layout (_film->audio_channels ()),
                        AV_SAMPLE_FMT_FLTP,
                        _film->target_audio_sample_rate(),
-                       _film->audio_channel_layout(),
+                       av_get_default_channel_layout (_film->audio_channels ()),
                        AV_SAMPLE_FMT_FLTP,
                        _film->audio_frame_rate(),
                        0, 0
index 0424fbc33dfbe77de1738c4ed20c3ebce8531ec3..577dbd14d084ba6fe8a19db0c8870935a7d7d9dd 100644 (file)
@@ -216,7 +216,7 @@ FFmpegContent::audio_channels () const
                 return 0;
         }
 
-        return _audio_stream->channels ();
+        return _audio_stream->channels;
 }
 
 int
@@ -229,16 +229,6 @@ FFmpegContent::audio_frame_rate () const
         return _audio_stream->frame_rate;
 }
 
-int64_t
-FFmpegContent::audio_channel_layout () const
-{
-        if (!_audio_stream) {
-                return 0;
-        }
-
-        return _audio_stream->channel_layout;
-}
-       
 bool
 operator== (FFmpegSubtitleStream const & a, FFmpegSubtitleStream const & b)
 {
@@ -256,7 +246,7 @@ FFmpegAudioStream::FFmpegAudioStream (shared_ptr<const cxml::Node> node)
        name = node->string_child ("Name");
        id = node->number_child<int> ("Id");
        frame_rate = node->number_child<int> ("FrameRate");
-       channel_layout = node->number_child<int64_t> ("ChannelLayout");
+       channels = node->number_child<int64_t> ("Channels");
 }
 
 void
@@ -265,7 +255,7 @@ FFmpegAudioStream::as_xml (xmlpp::Node* root) const
        root->add_child("Name")->add_child_text (name);
        root->add_child("Id")->add_child_text (lexical_cast<string> (id));
        root->add_child("FrameRate")->add_child_text (lexical_cast<string> (frame_rate));
-       root->add_child("ChannelLayout")->add_child_text (lexical_cast<string> (channel_layout));
+       root->add_child("Channels")->add_child_text (lexical_cast<string> (channels));
 }
 
 /** Construct a SubtitleStream from a value returned from to_string().
index cc603e680d692855948c3f1bbfa3b6e88b5a6a8f..b49e5790ef130f7ece609d4aece91ef6179b7b35 100644 (file)
 class FFmpegAudioStream
 {
 public:
-        FFmpegAudioStream (std::string n, int i, int f, int64_t c)
+        FFmpegAudioStream (std::string n, int i, int f, int c)
                 : name (n)
                 , id (i)
                 , frame_rate (f)
-                , channel_layout (c)
+               , channels (c)
         {}
 
        FFmpegAudioStream (boost::shared_ptr<const cxml::Node>);
 
        void as_xml (xmlpp::Node *) const;
        
-        int channels () const {
-                return av_get_channel_layout_nb_channels (channel_layout);
-        }
-        
         std::string name;
         int id;
         int frame_rate;
-        int64_t channel_layout;
+       int channels;
 };
 
 extern bool operator== (FFmpegAudioStream const & a, FFmpegAudioStream const & b);
@@ -98,7 +94,6 @@ public:
         int audio_channels () const;
         ContentAudioFrame audio_length () const;
         int audio_frame_rate () const;
-        int64_t audio_channel_layout () const;
        
         std::vector<FFmpegSubtitleStream> subtitle_streams () const {
                 boost::mutex::scoped_lock lm (_mutex);
index d0b1de748c0e2960dc4bc3ed9aeade1c8db2ab00..eac1d91aea3c93db48178ed6fd7775e9b830c7af 100644 (file)
@@ -143,7 +143,7 @@ FFmpegDecoder::setup_general ()
                        }
                        
                        _audio_streams.push_back (
-                               FFmpegAudioStream (stream_name (s), i, s->codec->sample_rate, s->codec->channel_layout)
+                               FFmpegAudioStream (stream_name (s), i, s->codec->sample_rate, s->codec->channels)
                                );
                        
                } else if (s->codec->codec_type == AVMEDIA_TYPE_SUBTITLE) {
index 35a07b399e3432716f61f64e7d892abf98f056de..5f1b89d0c9b505f7fa2fc8fde495dd83c8cfc6b9 100644 (file)
@@ -1131,12 +1131,6 @@ Film::audio_frame_rate () const
        return _playlist->audio_frame_rate ();
 }
 
-int64_t
-Film::audio_channel_layout () const
-{
-       return _playlist->audio_channel_layout ();
-}
-
 bool
 Film::has_audio () const
 {
index 532d32bdcc5477c3ee863231743101cb714416c6..4d994996e86333e8a18b2be13dcdc6cf0012e162 100644 (file)
@@ -106,7 +106,6 @@ public:
        ContentAudioFrame audio_length () const;
        int audio_channels () const;
        int audio_frame_rate () const;
-       int64_t audio_channel_layout () const;
        bool has_audio () const;
        
        float video_frame_rate () const;
index 52c7bec186495cdbe4026e7bce1d325d3d6a8211..40a89bb1594007ad65eb798fab7fdb7eb9be43c1 100644 (file)
@@ -37,18 +37,6 @@ public:
        libdcp::Size native_size () const;
        ContentVideoFrame video_length () const;
 
-       int audio_channels () const {
-               return 0;
-       }
-
-       int audio_sample_rate () const {
-               return 0;
-       }
-
-       int64_t audio_channel_layout () const {
-               return 0;
-       }
-
        bool seek (double);
        bool pass ();
 
index 717c1daceacbc7c2945c35eedb7c14b06f3cb142..f346cb6e03d0377eb9403d0d29cbc0a4f1835434 100644 (file)
@@ -143,28 +143,6 @@ Playlist::audio_frame_rate () const
        return 0;
 }
 
-int64_t
-Playlist::audio_channel_layout () const
-{
-       /* XXX: assuming that all content has the same layout */
-
-       switch (_audio_from) {
-       case AUDIO_FFMPEG:
-       {
-               shared_ptr<const FFmpegContent> fc = first_ffmpeg ();
-               if (fc) {
-                       return fc->audio_channel_layout ();
-               }
-               break;
-       }
-       case AUDIO_SNDFILE:
-               /* XXX */
-               return 0;
-       }
-
-       return 0;
-}
-
 float
 Playlist::video_frame_rate () const
 {
index 4dd27f67538a6c2f38c7b6621184b397b66bfb37..6384dce1c5d7d78ca6491150a87ebf8d6797fd94 100644 (file)
@@ -47,7 +47,6 @@ public:
        ContentAudioFrame audio_length () const;
        int audio_channels () const;
        int audio_frame_rate () const;
-       int64_t audio_channel_layout () const;
        bool has_audio () const;
        
        float video_frame_rate () const;
index 27c5f3615bde9c5477e79f02ebe2906ed7b16cc8..e8e86b60386bc505f7db64e8295181f9f9bca34c 100644 (file)
@@ -58,10 +58,6 @@ public:
                return _audio_frame_rate;
        }
        
-        int64_t audio_channel_layout () const {
-               return av_get_default_channel_layout (audio_channels ());
-       }
-
        static bool valid_file (boost::filesystem::path);
 
 private: