filter/ffmpeg: interleave the output AVFrame

If the FFmpeg filter outputs planar data, interleave it, just like the
FFmpeg decoder plugin does.
This commit is contained in:
Max Kellermann 2020-11-04 20:08:48 +01:00
parent 2d606fa989
commit 226eb26300
3 changed files with 6 additions and 1 deletions

1
NEWS
View File

@ -3,6 +3,7 @@ ver 0.22.3 (not yet released)
- add option "as_directory", making CUE file expansion optional - add option "as_directory", making CUE file expansion optional
* filter * filter
- fix garbage after "Audio format not supported by filter" message - fix garbage after "Audio format not supported by filter" message
- ffmpeg: support planar output
ver 0.22.2 (2020/10/28) ver 0.22.2 (2020/10/28)
* database * database

View File

@ -18,6 +18,7 @@
*/ */
#include "FfmpegFilter.hxx" #include "FfmpegFilter.hxx"
#include "lib/ffmpeg/Interleave.hxx"
#include "lib/ffmpeg/SampleFormat.hxx" #include "lib/ffmpeg/SampleFormat.hxx"
#include "util/ConstBuffer.hxx" #include "util/ConstBuffer.hxx"
@ -79,5 +80,5 @@ FfmpegFilter::FilterPCM(ConstBuffer<void> src)
/* TODO: call av_buffersink_get_frame() repeatedly? Not /* TODO: call av_buffersink_get_frame() repeatedly? Not
possible with MPD's current Filter API */ possible with MPD's current Filter API */
return {frame.GetData(0), frame->nb_samples * GetOutAudioFormat().GetFrameSize()}; return Ffmpeg::InterleaveFrame(*frame, interleave_buffer);
} }

View File

@ -21,6 +21,7 @@
#define MPD_FFMPEG_FILTER__HXX #define MPD_FFMPEG_FILTER__HXX
#include "filter/Filter.hxx" #include "filter/Filter.hxx"
#include "lib/ffmpeg/Buffer.hxx"
#include "lib/ffmpeg/Filter.hxx" #include "lib/ffmpeg/Filter.hxx"
#include "lib/ffmpeg/Frame.hxx" #include "lib/ffmpeg/Frame.hxx"
@ -32,6 +33,8 @@ class FfmpegFilter final : public Filter {
Ffmpeg::FilterContext buffer_src, buffer_sink; Ffmpeg::FilterContext buffer_src, buffer_sink;
Ffmpeg::Frame frame; Ffmpeg::Frame frame;
FfmpegBuffer interleave_buffer;
const int in_format, in_sample_rate, in_channels; const int in_format, in_sample_rate, in_channels;
const size_t in_audio_frame_size; const size_t in_audio_frame_size;