diff options
author | Max Kellermann <max@duempel.org> | 2012-10-05 16:29:40 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2012-10-05 16:37:07 +0200 |
commit | 230a3eb4005702ef00040eb3cdda11ba7d19ac3e (patch) | |
tree | 64d86ccb093af30be93fb1ae70cb752f920a9c73 /src | |
parent | e39382dedd224a97a896034c43772fa3da924b15 (diff) | |
download | mpd-230a3eb4005702ef00040eb3cdda11ba7d19ac3e.tar.gz mpd-230a3eb4005702ef00040eb3cdda11ba7d19ac3e.tar.xz mpd-230a3eb4005702ef00040eb3cdda11ba7d19ac3e.zip |
decoder/ffmpeg: move code to copy_interleave_frame2()
Diffstat (limited to '')
-rw-r--r-- | src/decoder/ffmpeg_decoder_plugin.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c index 64227b85a..54a574b40 100644 --- a/src/decoder/ffmpeg_decoder_plugin.c +++ b/src/decoder/ffmpeg_decoder_plugin.c @@ -234,6 +234,17 @@ time_to_ffmpeg(double t, const AVRational time_base) } #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(53,25,0) + +static void +copy_interleave_frame2(uint8_t *dest, const uint8_t *const*src, + unsigned nchannels, size_t plane_size) +{ + for (unsigned channel = 0; channel < nchannels; ++channel) { + memcpy(dest, src[channel], plane_size); + dest += plane_size; + } +} + /** * Copy PCM data from a AVFrame to an interleaved buffer. */ @@ -254,11 +265,9 @@ copy_interleave_frame(const AVCodecContext *codec_context, if (av_sample_fmt_is_planar(codec_context->sample_fmt) && codec_context->channels > 1) { - for (int i = 0, channels = codec_context->channels; - i < channels; i++) { - memcpy(buffer, frame->extended_data[i], plane_size); - buffer += plane_size; - } + copy_interleave_frame2(buffer, + (const uint8_t *const*)frame->extended_data, + codec_context->channels, plane_size); } else { memcpy(buffer, frame->extended_data[0], data_size); } |