summaryrefslogtreecommitdiffstats
path: root/media/libeffects/downmix/EffectDownmix.h
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2012-03-02 10:59:56 -0800
committerJean-Michel Trivi <jmtrivi@google.com>2012-03-07 10:17:19 -0800
commit04c1e531b5913c09aa9b2e59e2b8ed9b4d8a4cba (patch)
tree643a1bd10a8e4d0e9a208a3987d41459d6db49d1 /media/libeffects/downmix/EffectDownmix.h
parenteb7de4504bdb3a0182021ca6f022cccca01dbf1e (diff)
downloadframeworks_av-04c1e531b5913c09aa9b2e59e2b8ed9b4d8a4cba.zip
frameworks_av-04c1e531b5913c09aa9b2e59e2b8ed9b4d8a4cba.tar.gz
frameworks_av-04c1e531b5913c09aa9b2e59e2b8ed9b4d8a4cba.tar.bz2
Effect for multichannel PCM downmix to stereo
First pass at implementing an audio effect whose role is to downmix multichannel PCM buffers to stereo. The effect is not handling volume changes. The effect code here handles quad, 4.0, 5.1 and 7.1 input configurations, to optimize the most commom configurations, and does not yet handle generic multichanel configurations. Change-Id: I74d04bd961348f3f0e4ae7714b70e620808a0829
Diffstat (limited to 'media/libeffects/downmix/EffectDownmix.h')
-rw-r--r--media/libeffects/downmix/EffectDownmix.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/media/libeffects/downmix/EffectDownmix.h b/media/libeffects/downmix/EffectDownmix.h
new file mode 100644
index 0000000..4176b5a
--- /dev/null
+++ b/media/libeffects/downmix/EffectDownmix.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ANDROID_EFFECTDOWNMIX_H_
+#define ANDROID_EFFECTDOWNMIX_H_
+
+#include <audio_effects/effect_downmix.h>
+#include <audio_utils/primitives.h>
+#include <system/audio.h>
+
+/*------------------------------------
+ * definitions
+ *------------------------------------
+*/
+
+#define DOWNMIX_OUTPUT_CHANNELS AUDIO_CHANNEL_OUT_STEREO
+
+typedef enum {
+ DOWNMIX_STATE_UNINITIALIZED,
+ DOWNMIX_STATE_INITIALIZED,
+ DOWNMIX_STATE_ACTIVE,
+} downmix_state_t;
+
+/* parameters for each downmixer */
+typedef struct {
+ downmix_state_t state;
+ downmix_type_t type;
+ bool apply_volume_correction;
+ uint8_t input_channel_count;
+} downmix_object_t;
+
+
+typedef struct downmix_module_s {
+ const struct effect_interface_s *itfe;
+ effect_config_t config;
+ downmix_object_t context;
+} downmix_module_t;
+
+
+/*------------------------------------
+ * Effect API
+ *------------------------------------
+*/
+int32_t DownmixLib_QueryNumberEffects(uint32_t *pNumEffects);
+int32_t DownmixLib_QueryEffect(uint32_t index,
+ effect_descriptor_t *pDescriptor);
+int32_t DownmixLib_Create(const effect_uuid_t *uuid,
+ int32_t sessionId,
+ int32_t ioId,
+ effect_handle_t *pHandle);
+int32_t DownmixLib_Release(effect_handle_t handle);
+int32_t DownmixLib_GetDescriptor(const effect_uuid_t *uuid,
+ effect_descriptor_t *pDescriptor);
+
+static int Downmix_Process(effect_handle_t self,
+ audio_buffer_t *inBuffer,
+ audio_buffer_t *outBuffer);
+static int Downmix_Command(effect_handle_t self,
+ uint32_t cmdCode,
+ uint32_t cmdSize,
+ void *pCmdData,
+ uint32_t *replySize,
+ void *pReplyData);
+static int Downmix_GetDescriptor(effect_handle_t self,
+ effect_descriptor_t *pDescriptor);
+
+
+/*------------------------------------
+ * internal functions
+ *------------------------------------
+*/
+int Downmix_Init(downmix_module_t *pDwmModule);
+int Downmix_Configure(downmix_module_t *pDwmModule, effect_config_t *pConfig, bool init);
+int Downmix_Reset(downmix_object_t *pDownmixer, bool init);
+int Downmix_setParameter(downmix_object_t *pDownmixer, int32_t param, size_t size, void *pValue);
+int Downmix_getParameter(downmix_object_t *pDownmixer, int32_t param, size_t *pSize, void *pValue);
+
+void Downmix_foldFromQuad(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate);
+void Downmix_foldFromSurround(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate);
+void Downmix_foldFrom5Point1(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate);
+void Downmix_foldFrom7Point1(int16_t *pSrc, int16_t*pDst, size_t numFrames, bool accumulate);
+
+#endif /*ANDROID_EFFECTDOWNMIX_H_*/