aboutsummaryrefslogtreecommitdiffhomepage
path: root/audio/decode
diff options
context:
space:
mode:
authorGravatar wm4 <wm4@nowhere>2012-12-21 18:13:16 +0100
committerGravatar wm4 <wm4@nowhere>2012-12-28 13:43:55 +0100
commit97ed31fd8ed7241dade2e579488146e8fa3473f7 (patch)
tree2e2739caccdce9beaf29f85546e116d671961133 /audio/decode
parentb32f2ef0d344e224a24ed72bf7abf394675ea58f (diff)
audio: make de-planarization faster
Uses the same trick as the planarization code to turn per-sample memcpy calls into mov instructions. Makes decoding a ~25min 48000Hz 2ch floatle audio file faster from 3.8s to 2.7s.
Diffstat (limited to 'audio/decode')
-rw-r--r--audio/decode/ad_lavc.c17
1 files changed, 4 insertions, 13 deletions
diff --git a/audio/decode/ad_lavc.c b/audio/decode/ad_lavc.c
index e0e39e1e7d..9bcbde33cf 100644
--- a/audio/decode/ad_lavc.c
+++ b/audio/decode/ad_lavc.c
@@ -52,8 +52,8 @@ LIBAD_EXTERN(ffmpeg)
struct priv {
AVCodecContext *avctx;
AVFrame *avframe;
- char *output;
- char *output_packed; // used by deplanarize to store packed audio samples
+ uint8_t *output;
+ uint8_t *output_packed; // used by deplanarize to store packed audio samples
int output_left;
int unitsize;
int previous_data_left; // input demuxer packet data
@@ -363,6 +363,7 @@ static av_always_inline void deplanarize(struct sh_audio *sh)
{
struct priv *priv = sh->context;
+ uint8_t **planes = priv->avframe->extended_data;
size_t bps = av_get_bytes_per_sample(priv->avctx->sample_fmt);
size_t nb_samples = priv->avframe->nb_samples;
size_t channels = priv->avctx->channels;
@@ -372,17 +373,7 @@ static av_always_inline void deplanarize(struct sh_audio *sh)
priv->output_packed =
talloc_realloc_size(priv, priv->output_packed, size);
- size_t offset = 0;
- unsigned char *output_ptr = priv->output_packed;
- unsigned char **src = priv->avframe->data;
-
- for (size_t s = 0; s < nb_samples; s++) {
- for (size_t c = 0; c < channels; c++) {
- memcpy(output_ptr, src[c] + offset, bps);
- output_ptr += bps;
- }
- offset += bps;
- }
+ reorder_to_packed(priv->output_packed, planes, bps, channels, nb_samples);
priv->output = priv->output_packed;
}