| 1 | /*************************************************************************** |
|---|
| 2 | * (c)2004-2011 Broadcom Corporation |
|---|
| 3 | * |
|---|
| 4 | * This program is the proprietary software of Broadcom Corporation and/or its licensors, |
|---|
| 5 | * and may only be used, duplicated, modified or distributed pursuant to the terms and |
|---|
| 6 | * conditions of a separate, written license agreement executed between you and Broadcom |
|---|
| 7 | * (an "Authorized License"). Except as set forth in an Authorized License, Broadcom grants |
|---|
| 8 | * no license (express or implied), right to use, or waiver of any kind with respect to the |
|---|
| 9 | * Software, and Broadcom expressly reserves all rights in and to the Software and all |
|---|
| 10 | * intellectual property rights therein. IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU |
|---|
| 11 | * HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY |
|---|
| 12 | * NOTIFY BROADCOM AND DISCONTINUE ALL USE OF THE SOFTWARE. |
|---|
| 13 | * |
|---|
| 14 | * Except as expressly set forth in the Authorized License, |
|---|
| 15 | * |
|---|
| 16 | * 1. This program, including its structure, sequence and organization, constitutes the valuable trade |
|---|
| 17 | * secrets of Broadcom, and you shall use all reasonable efforts to protect the confidentiality thereof, |
|---|
| 18 | * and to use this information only in connection with your use of Broadcom integrated circuit products. |
|---|
| 19 | * |
|---|
| 20 | * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS" |
|---|
| 21 | * AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES, REPRESENTATIONS OR |
|---|
| 22 | * WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH RESPECT TO |
|---|
| 23 | * THE SOFTWARE. BROADCOM SPECIFICALLY DISCLAIMS ANY AND ALL IMPLIED WARRANTIES |
|---|
| 24 | * OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, |
|---|
| 25 | * LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION |
|---|
| 26 | * OR CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT OF |
|---|
| 27 | * USE OR PERFORMANCE OF THE SOFTWARE. |
|---|
| 28 | * |
|---|
| 29 | * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR ITS |
|---|
| 30 | * LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR |
|---|
| 31 | * EXEMPLARY DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO YOUR |
|---|
| 32 | * USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF |
|---|
| 33 | * THE POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT |
|---|
| 34 | * ACTUALLY PAID FOR THE SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE |
|---|
| 35 | * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF ESSENTIAL PURPOSE OF |
|---|
| 36 | * ANY LIMITED REMEDY. |
|---|
| 37 | * |
|---|
| 38 | * $brcm_Workfile: nexus_audio_encoder.h $ |
|---|
| 39 | * $brcm_Revision: 7 $ |
|---|
| 40 | * $brcm_Date: 12/20/11 4:13p $ |
|---|
| 41 | * |
|---|
| 42 | * Revision History: |
|---|
| 43 | * |
|---|
| 44 | * $brcm_Log: /nexus/modules/audio/7400/include/nexus_audio_encoder.h $ |
|---|
| 45 | * |
|---|
| 46 | * 7 12/20/11 4:13p jgarrett |
|---|
| 47 | * SW7425-1018: Adding initial A/85 implementation |
|---|
| 48 | * |
|---|
| 49 | * 6 12/9/11 11:18a jgarrett |
|---|
| 50 | * SW7425-1478: Adding WMA encoding |
|---|
| 51 | * |
|---|
| 52 | * 5 6/20/11 12:48p jgarrett |
|---|
| 53 | * SW7425-741: Including nexus_audio_decoder_types.h for MP3 types |
|---|
| 54 | * |
|---|
| 55 | * 4 6/16/11 5:26p jgarrett |
|---|
| 56 | * SW7425-741: Adding MP3 encoder |
|---|
| 57 | * |
|---|
| 58 | * 3 4/22/11 10:43a erickson |
|---|
| 59 | * SW7420-1148: remove attr{shutdown=NEXUS_AudioInput_Shutdown} |
|---|
| 60 | * |
|---|
| 61 | * 2 2/18/11 6:51p jgarrett |
|---|
| 62 | * SW7425-94: Merge to main branch |
|---|
| 63 | * |
|---|
| 64 | * NEXUS_AACENC_INTEGRATION/2 2/16/11 6:05p jgarrett |
|---|
| 65 | * SW7425-94: Adding updates for AAC-LC and ADTS/LOAS |
|---|
| 66 | * |
|---|
| 67 | * NEXUS_AACENC_INTEGRATION/1 2/15/11 7:33p jgarrett |
|---|
| 68 | * SW7425-94: Adding initial mux output files for AAC encode |
|---|
| 69 | * |
|---|
| 70 | * 1 12/17/10 4:45p jgarrett |
|---|
| 71 | * SW7425-41: Adding initial encoder/mux APIs |
|---|
| 72 | * |
|---|
| 73 | ***************************************************************************/ |
|---|
| 74 | |
|---|
| 75 | #ifndef NEXUS_AUDIO_ENCODER_H__ |
|---|
| 76 | #define NEXUS_AUDIO_ENCODER_H__ |
|---|
| 77 | |
|---|
| 78 | #include "nexus_types.h" |
|---|
| 79 | #include "nexus_audio_types.h" |
|---|
| 80 | #include "nexus_audio_decoder_types.h" |
|---|
| 81 | #include "nexus_ac3_encode.h" |
|---|
| 82 | #include "nexus_dts_encode.h" |
|---|
| 83 | |
|---|
| 84 | #ifdef __cplusplus |
|---|
| 85 | extern "C" { |
|---|
| 86 | #endif |
|---|
| 87 | |
|---|
| 88 | /** |
|---|
| 89 | Internal development notes: |
|---|
| 90 | |
|---|
| 91 | Previously, nexus supported separate interfaces per encodable codec type: NEXUS_Ac3Encode, NEXUS_DtsEncode. |
|---|
| 92 | Now we will support a generic API w/ a codec enum. |
|---|
| 93 | |
|---|
| 94 | There is no Start/Stop. Instead, the whole pipeline must be stopped at the source (e.g. NEXUS_AudioDecoder_Stop), then |
|---|
| 95 | the app can make changes to the filter graph including AudioEncoder, then the whole pipeline is started at the source (e.g. NEXUS_AudioDecoder_Start). |
|---|
| 96 | **/ |
|---|
| 97 | |
|---|
| 98 | /** |
|---|
| 99 | Summary: |
|---|
| 100 | Handle for Audio Encoder stage |
|---|
| 101 | **/ |
|---|
| 102 | typedef struct NEXUS_AudioEncoder *NEXUS_AudioEncoderHandle; |
|---|
| 103 | |
|---|
| 104 | /*************************************************************************** |
|---|
| 105 | Summary: |
|---|
| 106 | Audio Encoder Settings |
|---|
| 107 | |
|---|
| 108 | Description: |
|---|
| 109 | Delay mode is set in AudioDecoder |
|---|
| 110 | ***************************************************************************/ |
|---|
| 111 | typedef struct NEXUS_AudioEncoderSettings |
|---|
| 112 | { |
|---|
| 113 | NEXUS_AudioCodec codec; /* The codec into which audio is currently being encoded. |
|---|
| 114 | Can only be changed while the data flow is stopped. */ |
|---|
| 115 | |
|---|
| 116 | bool loudnessEquivalenceEnabled; /* If true, loudness equivalence will be enabled based on the mode specified |
|---|
| 117 | in NEXUS_AudioModuleSettings.loudnessMode. Ignored if NEXUS_AudioModuleSettings.loudnessMode |
|---|
| 118 | is set to NEXUS_AudioLoudnessEquivalenceMode_eNone. Default is true. */ |
|---|
| 119 | } NEXUS_AudioEncoderSettings; |
|---|
| 120 | |
|---|
| 121 | /*************************************************************************** |
|---|
| 122 | Summary: |
|---|
| 123 | Get default settings for an Audio Encoder stage |
|---|
| 124 | ***************************************************************************/ |
|---|
| 125 | void NEXUS_AudioEncoder_GetDefaultSettings( |
|---|
| 126 | NEXUS_AudioEncoderSettings *pSettings /* [out] default settings */ |
|---|
| 127 | ); |
|---|
| 128 | |
|---|
| 129 | /*************************************************************************** |
|---|
| 130 | Summary: |
|---|
| 131 | Open an Audio Encoder stage |
|---|
| 132 | ***************************************************************************/ |
|---|
| 133 | NEXUS_AudioEncoderHandle NEXUS_AudioEncoder_Open( /* attr{destructor=NEXUS_AudioEncoder_Close} */ |
|---|
| 134 | const NEXUS_AudioEncoderSettings *pSettings |
|---|
| 135 | ); |
|---|
| 136 | |
|---|
| 137 | /*************************************************************************** |
|---|
| 138 | Summary: |
|---|
| 139 | Close an Audio Encoder stage |
|---|
| 140 | |
|---|
| 141 | Description: |
|---|
| 142 | Input to the stage must be removed prior to closing. |
|---|
| 143 | ***************************************************************************/ |
|---|
| 144 | void NEXUS_AudioEncoder_Close( |
|---|
| 145 | NEXUS_AudioEncoderHandle handle |
|---|
| 146 | ); |
|---|
| 147 | |
|---|
| 148 | /*************************************************************************** |
|---|
| 149 | Summary: |
|---|
| 150 | Get Settings for an Audio Encoder stage |
|---|
| 151 | ***************************************************************************/ |
|---|
| 152 | void NEXUS_AudioEncoder_GetSettings( |
|---|
| 153 | NEXUS_AudioEncoderHandle handle, |
|---|
| 154 | NEXUS_AudioEncoderSettings *pSettings /* [out] Settings */ |
|---|
| 155 | ); |
|---|
| 156 | |
|---|
| 157 | /*************************************************************************** |
|---|
| 158 | Summary: |
|---|
| 159 | Set Settings for an Audio Encoder stage |
|---|
| 160 | ***************************************************************************/ |
|---|
| 161 | NEXUS_Error NEXUS_AudioEncoder_SetSettings( |
|---|
| 162 | NEXUS_AudioEncoderHandle handle, |
|---|
| 163 | const NEXUS_AudioEncoderSettings *pSettings |
|---|
| 164 | ); |
|---|
| 165 | |
|---|
| 166 | /*************************************************************************** |
|---|
| 167 | Summary: |
|---|
| 168 | AAC Encode Output Mode |
|---|
| 169 | ***************************************************************************/ |
|---|
| 170 | typedef enum NEXUS_AacEncodeOutputMode |
|---|
| 171 | { |
|---|
| 172 | NEXUS_AacEncodeOutputMode_e2_0, /* Stereo */ |
|---|
| 173 | NEXUS_AacEncodeOutputMode_e1_0, /* Mono */ |
|---|
| 174 | NEXUS_AacEncodeOutputMode_eMax |
|---|
| 175 | } NEXUS_AacEncodeOutputMode; |
|---|
| 176 | |
|---|
| 177 | /*************************************************************************** |
|---|
| 178 | Summary: |
|---|
| 179 | AAC Encode Parameters |
|---|
| 180 | ***************************************************************************/ |
|---|
| 181 | typedef struct NEXUS_AacEncodeSettings |
|---|
| 182 | { |
|---|
| 183 | NEXUS_AacEncodeOutputMode outputMode; /* Output channel mode */ |
|---|
| 184 | unsigned bitRate; /* Bitrate in bps */ |
|---|
| 185 | } NEXUS_AacEncodeSettings; |
|---|
| 186 | |
|---|
| 187 | /*************************************************************************** |
|---|
| 188 | Summary: |
|---|
| 189 | MPEG audio encode parameters |
|---|
| 190 | ***************************************************************************/ |
|---|
| 191 | typedef struct NEXUS_AudioMpegEncodeSettings |
|---|
| 192 | { |
|---|
| 193 | unsigned bitRate; /* Output bitrate of the encoder in bps. Ranges from 32000 to 320000. */ |
|---|
| 194 | |
|---|
| 195 | bool privateBit; /* If true, the private bit will be asserted in the header */ |
|---|
| 196 | bool copyrightBit; /* If true, the copyright bit will be asserted in the header */ |
|---|
| 197 | bool originalBit; /* If true, the original bit will be asserted in the header */ |
|---|
| 198 | NEXUS_AudioMpegEmphasis emphasis; /* De-Emphasis mode */ |
|---|
| 199 | }NEXUS_AudioMpegEncodeSettings; |
|---|
| 200 | |
|---|
| 201 | /*************************************************************************** |
|---|
| 202 | Summary: |
|---|
| 203 | WMA Standard audio encode parameters |
|---|
| 204 | ***************************************************************************/ |
|---|
| 205 | typedef struct NEXUS_AudioWmaStdEncodeSettings |
|---|
| 206 | { |
|---|
| 207 | unsigned bitRate; /* Output bitrate of the encoder in bps. Default is 192000. Lower rates can |
|---|
| 208 | cause very high DSP usage. */ |
|---|
| 209 | bool monoEncoding; /* If true, encode as mono. If false (default), encode as stereo. */ |
|---|
| 210 | }NEXUS_AudioWmaStdEncodeSettings; |
|---|
| 211 | |
|---|
| 212 | /*************************************************************************** |
|---|
| 213 | Summary: |
|---|
| 214 | Codec-Specific Settings for an audio encoder |
|---|
| 215 | ***************************************************************************/ |
|---|
| 216 | typedef struct NEXUS_AudioEncoderCodecSettings |
|---|
| 217 | { |
|---|
| 218 | NEXUS_AudioCodec codec; /* this is used for the codecSettings lookup */ |
|---|
| 219 | union |
|---|
| 220 | { |
|---|
| 221 | NEXUS_Ac3EncodeSettings ac3; |
|---|
| 222 | NEXUS_DtsEncodeSettings dts; |
|---|
| 223 | NEXUS_AacEncodeSettings aac; |
|---|
| 224 | NEXUS_AacEncodeSettings aacPlus; |
|---|
| 225 | NEXUS_AudioMpegEncodeSettings mp3; |
|---|
| 226 | NEXUS_AudioWmaStdEncodeSettings wmaStd; |
|---|
| 227 | } codecSettings; |
|---|
| 228 | } NEXUS_AudioEncoderCodecSettings; |
|---|
| 229 | |
|---|
| 230 | /*************************************************************************** |
|---|
| 231 | Summary: |
|---|
| 232 | Get Codec-Specific Settings for an Audio Encoder stage |
|---|
| 233 | ***************************************************************************/ |
|---|
| 234 | void NEXUS_AudioEncoder_GetCodecSettings( |
|---|
| 235 | NEXUS_AudioEncoderHandle handle, |
|---|
| 236 | NEXUS_AudioCodec codec, /* the codec for which you are retrieving settings. */ |
|---|
| 237 | NEXUS_AudioEncoderCodecSettings *pSettings /* [out] Settings */ |
|---|
| 238 | ); |
|---|
| 239 | |
|---|
| 240 | /*************************************************************************** |
|---|
| 241 | Summary: |
|---|
| 242 | Set Codec-Specific Settings for an Audio Encoder stage |
|---|
| 243 | ***************************************************************************/ |
|---|
| 244 | NEXUS_Error NEXUS_AudioEncoder_SetCodecSettings( |
|---|
| 245 | NEXUS_AudioEncoderHandle handle, |
|---|
| 246 | const NEXUS_AudioEncoderCodecSettings *pSettings |
|---|
| 247 | ); |
|---|
| 248 | |
|---|
| 249 | /*************************************************************************** |
|---|
| 250 | Summary: |
|---|
| 251 | Get the audio connector for an Audio Encoder stage |
|---|
| 252 | |
|---|
| 253 | Description: |
|---|
| 254 | This is used for a direct connection to SPDIF, as follows: |
|---|
| 255 | |
|---|
| 256 | NEXUS_AudioOutput_AddInput(NEXUS_SpdifOutput_GetConnector(spdif), NEXUS_AudioEncoder_GetConnector(audioEncoder)); |
|---|
| 257 | |
|---|
| 258 | ***************************************************************************/ |
|---|
| 259 | NEXUS_AudioInput NEXUS_AudioEncoder_GetConnector( |
|---|
| 260 | NEXUS_AudioEncoderHandle handle |
|---|
| 261 | ); |
|---|
| 262 | |
|---|
| 263 | /*************************************************************************** |
|---|
| 264 | Summary: |
|---|
| 265 | Add an input to this processing stage |
|---|
| 266 | |
|---|
| 267 | Description: |
|---|
| 268 | This is used to connect to the audio decoder as follows: |
|---|
| 269 | |
|---|
| 270 | NEXUS_AudioEncoder_AddInput(audioEncoder, NEXUS_AudioDecoder_GetConnector(audioDecoder)); |
|---|
| 271 | |
|---|
| 272 | ***************************************************************************/ |
|---|
| 273 | NEXUS_Error NEXUS_AudioEncoder_AddInput( |
|---|
| 274 | NEXUS_AudioEncoderHandle handle, |
|---|
| 275 | NEXUS_AudioInput input |
|---|
| 276 | ); |
|---|
| 277 | |
|---|
| 278 | /*************************************************************************** |
|---|
| 279 | Summary: |
|---|
| 280 | Remove an input from this processing stage |
|---|
| 281 | ***************************************************************************/ |
|---|
| 282 | NEXUS_Error NEXUS_AudioEncoder_RemoveInput( |
|---|
| 283 | NEXUS_AudioEncoderHandle handle, |
|---|
| 284 | NEXUS_AudioInput input |
|---|
| 285 | ); |
|---|
| 286 | |
|---|
| 287 | /*************************************************************************** |
|---|
| 288 | Summary: |
|---|
| 289 | Remove all inputs from this processing stage |
|---|
| 290 | ***************************************************************************/ |
|---|
| 291 | NEXUS_Error NEXUS_AudioEncoder_RemoveAllInputs( |
|---|
| 292 | NEXUS_AudioEncoderHandle handle |
|---|
| 293 | ); |
|---|
| 294 | |
|---|
| 295 | #ifdef __cplusplus |
|---|
| 296 | } |
|---|
| 297 | #endif |
|---|
| 298 | |
|---|
| 299 | #endif /* #ifndef NEXUS_AUDIO_ENCODER_H__ */ |
|---|
| 300 | |
|---|