diff options
author | Max Kellermann <max@duempel.org> | 2014-12-18 23:41:08 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-18 23:44:56 +0100 |
commit | 5c3afd020a2194ca96182c52a2cb1a70543871ee (patch) | |
tree | 543f4e17b20fedcfee656118a8d49a716be4c87b /src/decoder/plugins | |
parent | 190cdfc3263f5cfa6dfca98b0e4f2e8b5886c2b9 (diff) | |
download | mpd-5c3afd020a2194ca96182c52a2cb1a70543871ee.tar.gz mpd-5c3afd020a2194ca96182c52a2cb1a70543871ee.tar.xz mpd-5c3afd020a2194ca96182c52a2cb1a70543871ee.zip |
decoder/ffmpeg: copy_interleave_frame() returns ConstBuffer
Diffstat (limited to 'src/decoder/plugins')
-rw-r--r-- | src/decoder/plugins/FfmpegDecoderPlugin.cxx | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 7d2532371..d73c2ebea 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -34,6 +34,7 @@ #include "tag/MixRamp.hxx" #include "input/InputStream.hxx" #include "CheckAudioFormat.hxx" +#include "util/ConstBuffer.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" #include "LogV.hxx" @@ -273,10 +274,9 @@ copy_interleave_frame2(uint8_t *dest, uint8_t **src, /** * Copy PCM data from a AVFrame to an interleaved buffer. */ -static size_t +static ConstBuffer<void> copy_interleave_frame(const AVCodecContext &codec_context, const AVFrame &frame, - uint8_t **output_buffer, FfmpegBuffer &global_buffer, Error &error) { @@ -294,24 +294,26 @@ copy_interleave_frame(const AVCodecContext &codec_context, return 0; } + void *output_buffer; if (av_sample_fmt_is_planar(codec_context.sample_fmt) && codec_context.channels > 1) { - *output_buffer = global_buffer.GetT<uint8_t>(data_size); - if (*output_buffer == nullptr) { + output_buffer = global_buffer.GetT<uint8_t>(data_size); + if (output_buffer == nullptr) { /* Not enough memory - shouldn't happen */ error.SetErrno(ENOMEM); return 0; } - copy_interleave_frame2(*output_buffer, frame.extended_data, + copy_interleave_frame2((uint8_t *)output_buffer, + frame.extended_data, frame.nb_samples, codec_context.channels, av_get_bytes_per_sample(codec_context.sample_fmt)); } else { - *output_buffer = frame.extended_data[0]; + output_buffer = frame.extended_data[0]; } - return data_size; + return { output_buffer, (size_t)data_size }; } static DecoderCommand @@ -350,12 +352,10 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is, if (!got_frame || frame.nb_samples <= 0) continue; - uint8_t *output_buffer = nullptr; - size_t audio_size = + auto output_buffer = copy_interleave_frame(codec_context, frame, - &output_buffer, buffer, error); - if (audio_size == 0) { + if (output_buffer.IsNull()) { /* this must be a serious error, e.g. OOM */ LogError(error); @@ -363,7 +363,7 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is, } cmd = decoder_data(decoder, is, - output_buffer, audio_size, + output_buffer.data, output_buffer.size, codec_context.bit_rate / 1000); } return cmd; |