audiobargraph_a: fix counter wrapping
[vlc/gmpfix.git] / modules / arm_neon / volume.c
blob3497387032b286632562135c3e90152afa296d42
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 *****************************************************************************/
21 #ifdef HAVE_CONFIG_H
22 # include "config.h"
23 #endif
25 #include <assert.h>
27 #include <vlc_common.h>
28 #include <vlc_plugin.h>
29 #include <vlc_cpu.h>
30 #include <vlc_aout.h>
31 #include <vlc_aout_volume.h>
33 static int Probe(vlc_object_t *);
35 vlc_module_begin()
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)
41 vlc_module_end()
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())
50 return VLC_EGENERIC;
51 if (volume->format == VLC_CODEC_FL32)
52 volume->amplify = AmplifyFloat;
53 else
54 return VLC_EGENERIC;
55 return VLC_SUCCESS;
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;
65 if (amp == 1.0)
66 return;
68 /* Unaligned header */
69 assert(((uintptr_t)buf & 3) == 0);
70 while (unlikely((uintptr_t)buf & 12))
72 *(buf++) *= amp;
73 length -= 4;
75 /* Unaligned footer */
76 assert((length & 3) == 0);
77 while (unlikely(length & 12))
79 length -= 4;
80 buf[length / 4] *= amp;
83 amplify_float_arm_neon(buf, buf, length, amp);
84 (void) volume;