1 /*****************************************************************************
2 * volume.c : ARM NEON audio volume
3 *****************************************************************************
4 * Copyright (C) 2012 RĂ©mi Denis-Courmont
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
27 #include <vlc_common.h>
28 #include <vlc_plugin.h>
31 #include <vlc_aout_volume.h>
33 static int Probe(vlc_object_t
*);
36 set_category(CAT_AUDIO
)
37 set_subcategory(SUBCAT_AUDIO_MISC
)
38 set_description(N_("ARM NEON audio volume"))
39 set_capability("audio volume", 10)
40 set_callbacks(Probe
, NULL
)
43 static void AmplifyFloat(audio_volume_t
*, block_t
*, float);
45 static int Probe(vlc_object_t
*obj
)
47 audio_volume_t
*volume
= (audio_volume_t
*)obj
;
49 if (!vlc_CPU_ARM_NEON())
51 if (volume
->format
== VLC_CODEC_FL32
)
52 volume
->amplify
= AmplifyFloat
;
58 void amplify_float_arm_neon(float *, const float *, size_t, float) asm("amplify_float_arm_neon");
60 static void AmplifyFloat(audio_volume_t
*volume
, block_t
*block
, float amp
)
62 float *buf
= (float *)block
->p_buffer
;
63 size_t length
= block
->i_buffer
;
68 /* Unaligned header */
69 assert(((uintptr_t)buf
& 3) == 0);
70 while (unlikely((uintptr_t)buf
& 12))
75 /* Unaligned footer */
76 assert((length
& 3) == 0);
77 while (unlikely(length
& 12))
80 buf
[length
/ 4] *= amp
;
83 amplify_float_arm_neon(buf
, buf
, length
, amp
);