Move resampling back into AudioDecoder and fix various screw-ups with audio in the...
[dcpomatic.git] / src / lib / ffmpeg_decoder.cc
index 11cea8fb140dbcde881c23740a76bb2c3a41a72a..d8319723a3538f03cdb6bb94fe3ec41cb1082287 100644 (file)
@@ -59,8 +59,8 @@ using libdcp::Size;
 
 FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio)
        : Decoder (f)
-       , VideoDecoder (f)
-       , AudioDecoder (f)
+       , VideoDecoder (f, c)
+       , AudioDecoder (f, c)
        , SubtitleDecoder (f)
        , FFmpeg (c)
        , _subtitle_codec_context (0)
@@ -383,7 +383,13 @@ FFmpegDecoder::decode_audio_packet ()
                                                audio (silence, _audio_position);
                                        }
                                }
-                                       
+
+                               int const data_size = av_samples_get_buffer_size (
+                                       0, audio_codec_context()->channels, _frame->nb_samples, audio_sample_format (), 1
+                                       );
+
+                               audio (deinterleave_audio (_frame->data, data_size), _audio_position);
+                               
                                copy_packet.data += decode_result;
                                copy_packet.size -= decode_result;
                        }