From eed1a3c239d78edf978af9433001cbc823242cda Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 22 Jun 2015 14:28:23 +0200 Subject: decoder/ffmpeg: move code to pcm/Interleave.cxx --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) (limited to 'src/decoder/plugins') diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 88352bbb0..9493fee69 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -31,6 +31,7 @@ #include "../DecoderAPI.hxx" #include "FfmpegMetaData.hxx" #include "FfmpegIo.hxx" +#include "pcm/Interleave.hxx" #include "tag/TagBuilder.hxx" #include "tag/TagHandler.hxx" #include "tag/ReplayGain.hxx" @@ -103,20 +104,6 @@ start_time_fallback(const AVStream &stream) return FfmpegTimestampFallback(stream.start_time, 0); } -static void -copy_interleave_frame2(uint8_t *dest, uint8_t **src, - unsigned nframes, unsigned nchannels, - unsigned sample_size) -{ - for (unsigned frame = 0; frame < nframes; ++frame) { - for (unsigned channel = 0; channel < nchannels; ++channel) { - memcpy(dest, src[channel] + frame * sample_size, - sample_size); - dest += sample_size; - } - } -} - /** * Copy PCM data from a non-empty AVFrame to an interleaved buffer. */ @@ -150,11 +137,11 @@ copy_interleave_frame(const AVCodecContext &codec_context, return 0; } - 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)); + PcmInterleave(output_buffer, + ConstBuffer((const void *const*)frame.extended_data, + codec_context.channels), + frame.nb_samples, + av_get_bytes_per_sample(codec_context.sample_fmt)); } else { output_buffer = frame.extended_data[0]; } -- cgit v1.2.3