[FFmpeg-devel] [PATCH 06/10] dca: factorize scaling in inverse ADPCM

Michael Niedermayer michaelni at gmx.at
Sat Feb 15 19:39:03 CET 2014


On Fri, Feb 14, 2014 at 04:00:50PM +0000, Christophe Gisquet wrote:
> The codeblock affected accounted for around 4% of the runtime on x86_64
> (measured using oprofile on a Penryn).
> Timings for Arrandale (gcc 4.6.1 tdm64-1 for windows):
> win32: 341 -> 331
> win64: 321 -> 120
> 
> The compiled loops are completely unrolled, so only unrolling the
> initialization causes an improvement.
> ---
>  libavcodec/dcadec.c | 20 +++++++++++++-------
>  1 file changed, 13 insertions(+), 7 deletions(-)
> 
> diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
> index 880df81..7ad6c0c 100644
> --- a/libavcodec/dcadec.c
> +++ b/libavcodec/dcadec.c
> @@ -1354,15 +1354,21 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
>              if (s->prediction_mode[k][l]) {
>                  int n;
>                  for (m = 0; m < 8; m++) {
> -                    for (n = 1; n <= 4; n++)
> +                    float sum;
> +                    if (m >= 1)
> +                        sum = adpcm_vb[s->prediction_vq[k][l]][1 - 1] *
> +                              subband_samples[k][l][m - 1];
> +                    else if (s->predictor_history)
> +                        sum = adpcm_vb[s->prediction_vq[k][l]][1 - 1] *
> +                              s->subband_samples_hist[k][l][m - 1 + 4];
> +                    for (n = 2; n <= 4; n++)
>                          if (m >= n)
> -                            subband_samples[k][l][m] +=
> -                                (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
> -                                 subband_samples[k][l][m - n] / 8192);
> +                            sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
> +                                   subband_samples[k][l][m - n];
>                          else if (s->predictor_history)
> -                            subband_samples[k][l][m] +=
> -                                (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
> -                                 s->subband_samples_hist[k][l][m - n + 4] / 8192);
> +                            sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
> +                                   s->subband_samples_hist[k][l][m - n + 4];

> +                    subband_samples[k][l][m] += sum * 1.0f/ 8192;

the 1.0f/ 8192; needs a ()
otherwise the compiler would see (sum * 1.0f) / 8192;

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

I have never wished to cater to the crowd; for what I know they do not
approve, and what they approve I do not know. -- Epicurus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140215/76974538/attachment.asc>


More information about the ffmpeg-devel mailing list