| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_OPUS_INTERFACE_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_OPUS_INTERFACE_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_OPUS_INTERFACE_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_OPUS_INTERFACE_H_ |
| 13 | 13 |
| 14 #include <stddef.h> |
| 15 |
| 14 #include "webrtc/typedefs.h" | 16 #include "webrtc/typedefs.h" |
| 15 | 17 |
| 16 #ifdef __cplusplus | 18 #ifdef __cplusplus |
| 17 extern "C" { | 19 extern "C" { |
| 18 #endif | 20 #endif |
| 19 | 21 |
| 20 // Opaque wrapper types for the codec state. | 22 // Opaque wrapper types for the codec state. |
| 21 typedef struct WebRtcOpusEncInst OpusEncInst; | 23 typedef struct WebRtcOpusEncInst OpusEncInst; |
| 22 typedef struct WebRtcOpusDecInst OpusDecInst; | 24 typedef struct WebRtcOpusDecInst OpusDecInst; |
| 23 | 25 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 * - length_encoded_buffer : Output buffer size | 61 * - length_encoded_buffer : Output buffer size |
| 60 * | 62 * |
| 61 * Output: | 63 * Output: |
| 62 * - encoded : Output compressed data buffer | 64 * - encoded : Output compressed data buffer |
| 63 * | 65 * |
| 64 * Return value : >=0 - Length (in bytes) of coded data | 66 * Return value : >=0 - Length (in bytes) of coded data |
| 65 * -1 - Error | 67 * -1 - Error |
| 66 */ | 68 */ |
| 67 int WebRtcOpus_Encode(OpusEncInst* inst, | 69 int WebRtcOpus_Encode(OpusEncInst* inst, |
| 68 const int16_t* audio_in, | 70 const int16_t* audio_in, |
| 69 int16_t samples, | 71 size_t samples, |
| 70 int16_t length_encoded_buffer, | 72 size_t length_encoded_buffer, |
| 71 uint8_t* encoded); | 73 uint8_t* encoded); |
| 72 | 74 |
| 73 /**************************************************************************** | 75 /**************************************************************************** |
| 74 * WebRtcOpus_SetBitRate(...) | 76 * WebRtcOpus_SetBitRate(...) |
| 75 * | 77 * |
| 76 * This function adjusts the target bitrate of the encoder. | 78 * This function adjusts the target bitrate of the encoder. |
| 77 * | 79 * |
| 78 * Input: | 80 * Input: |
| 79 * - inst : Encoder context | 81 * - inst : Encoder context |
| 80 * - rate : New target bitrate | 82 * - rate : New target bitrate |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 * Output: | 232 * Output: |
| 231 * - decoded : The decoded vector | 233 * - decoded : The decoded vector |
| 232 * - audio_type : 1 normal, 2 CNG (for Opus it should | 234 * - audio_type : 1 normal, 2 CNG (for Opus it should |
| 233 * always return 1 since we're not using Opus's | 235 * always return 1 since we're not using Opus's |
| 234 * built-in DTX/CNG scheme) | 236 * built-in DTX/CNG scheme) |
| 235 * | 237 * |
| 236 * Return value : >0 - Samples per channel in decoded vector | 238 * Return value : >0 - Samples per channel in decoded vector |
| 237 * -1 - Error | 239 * -1 - Error |
| 238 */ | 240 */ |
| 239 int WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded, | 241 int WebRtcOpus_Decode(OpusDecInst* inst, const uint8_t* encoded, |
| 240 int16_t encoded_bytes, int16_t* decoded, | 242 size_t encoded_bytes, int16_t* decoded, |
| 241 int16_t* audio_type); | 243 int16_t* audio_type); |
| 242 | 244 |
| 243 /**************************************************************************** | 245 /**************************************************************************** |
| 244 * WebRtcOpus_DecodePlc(...) | 246 * WebRtcOpus_DecodePlc(...) |
| 245 * | 247 * |
| 246 * This function processes PLC for opus frame(s). | 248 * This function processes PLC for opus frame(s). |
| 247 * Input: | 249 * Input: |
| 248 * - inst : Decoder context | 250 * - inst : Decoder context |
| 249 * - number_of_lost_frames : Number of PLC frames to produce | 251 * - number_of_lost_frames : Number of PLC frames to produce |
| 250 * | 252 * |
| (...skipping 18 matching lines...) Expand all Loading... |
| 269 * - encoded_bytes : Bytes in encoded vector | 271 * - encoded_bytes : Bytes in encoded vector |
| 270 * | 272 * |
| 271 * Output: | 273 * Output: |
| 272 * - decoded : The decoded vector (previous frame) | 274 * - decoded : The decoded vector (previous frame) |
| 273 * | 275 * |
| 274 * Return value : >0 - Samples per channel in decoded vector | 276 * Return value : >0 - Samples per channel in decoded vector |
| 275 * 0 - No FEC data in the packet | 277 * 0 - No FEC data in the packet |
| 276 * -1 - Error | 278 * -1 - Error |
| 277 */ | 279 */ |
| 278 int WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded, | 280 int WebRtcOpus_DecodeFec(OpusDecInst* inst, const uint8_t* encoded, |
| 279 int16_t encoded_bytes, int16_t* decoded, | 281 size_t encoded_bytes, int16_t* decoded, |
| 280 int16_t* audio_type); | 282 int16_t* audio_type); |
| 281 | 283 |
| 282 /**************************************************************************** | 284 /**************************************************************************** |
| 283 * WebRtcOpus_DurationEst(...) | 285 * WebRtcOpus_DurationEst(...) |
| 284 * | 286 * |
| 285 * This function calculates the duration of an opus packet. | 287 * This function calculates the duration of an opus packet. |
| 286 * Input: | 288 * Input: |
| 287 * - inst : Decoder context | 289 * - inst : Decoder context |
| 288 * - payload : Encoded data pointer | 290 * - payload : Encoded data pointer |
| 289 * - payload_length_bytes : Bytes of encoded data | 291 * - payload_length_bytes : Bytes of encoded data |
| 290 * | 292 * |
| 291 * Return value : The duration of the packet, in samples per | 293 * Return value : The duration of the packet, in samples per |
| 292 * channel. | 294 * channel. |
| 293 */ | 295 */ |
| 294 int WebRtcOpus_DurationEst(OpusDecInst* inst, | 296 int WebRtcOpus_DurationEst(OpusDecInst* inst, |
| 295 const uint8_t* payload, | 297 const uint8_t* payload, |
| 296 int payload_length_bytes); | 298 size_t payload_length_bytes); |
| 297 | 299 |
| 298 /* TODO(minyue): Check whether it is needed to add a decoder context to the | 300 /* TODO(minyue): Check whether it is needed to add a decoder context to the |
| 299 * arguments, like WebRtcOpus_DurationEst(...). In fact, the packet itself tells | 301 * arguments, like WebRtcOpus_DurationEst(...). In fact, the packet itself tells |
| 300 * the duration. The decoder context in WebRtcOpus_DurationEst(...) is not used. | 302 * the duration. The decoder context in WebRtcOpus_DurationEst(...) is not used. |
| 301 * So it may be advisable to remove it from WebRtcOpus_DurationEst(...). */ | 303 * So it may be advisable to remove it from WebRtcOpus_DurationEst(...). */ |
| 302 | 304 |
| 303 /**************************************************************************** | 305 /**************************************************************************** |
| 304 * WebRtcOpus_FecDurationEst(...) | 306 * WebRtcOpus_FecDurationEst(...) |
| 305 * | 307 * |
| 306 * This function calculates the duration of the FEC data within an opus packet. | 308 * This function calculates the duration of the FEC data within an opus packet. |
| 307 * Input: | 309 * Input: |
| 308 * - payload : Encoded data pointer | 310 * - payload : Encoded data pointer |
| 309 * - payload_length_bytes : Bytes of encoded data | 311 * - payload_length_bytes : Bytes of encoded data |
| 310 * | 312 * |
| 311 * Return value : >0 - The duration of the FEC data in the | 313 * Return value : >0 - The duration of the FEC data in the |
| 312 * packet in samples per channel. | 314 * packet in samples per channel. |
| 313 * 0 - No FEC data in the packet. | 315 * 0 - No FEC data in the packet. |
| 314 */ | 316 */ |
| 315 int WebRtcOpus_FecDurationEst(const uint8_t* payload, | 317 int WebRtcOpus_FecDurationEst(const uint8_t* payload, |
| 316 int payload_length_bytes); | 318 size_t payload_length_bytes); |
| 317 | 319 |
| 318 /**************************************************************************** | 320 /**************************************************************************** |
| 319 * WebRtcOpus_PacketHasFec(...) | 321 * WebRtcOpus_PacketHasFec(...) |
| 320 * | 322 * |
| 321 * This function detects if an opus packet has FEC. | 323 * This function detects if an opus packet has FEC. |
| 322 * Input: | 324 * Input: |
| 323 * - payload : Encoded data pointer | 325 * - payload : Encoded data pointer |
| 324 * - payload_length_bytes : Bytes of encoded data | 326 * - payload_length_bytes : Bytes of encoded data |
| 325 * | 327 * |
| 326 * Return value : 0 - the packet does NOT contain FEC. | 328 * Return value : 0 - the packet does NOT contain FEC. |
| 327 * 1 - the packet contains FEC. | 329 * 1 - the packet contains FEC. |
| 328 */ | 330 */ |
| 329 int WebRtcOpus_PacketHasFec(const uint8_t* payload, | 331 int WebRtcOpus_PacketHasFec(const uint8_t* payload, |
| 330 int payload_length_bytes); | 332 size_t payload_length_bytes); |
| 331 | 333 |
| 332 #ifdef __cplusplus | 334 #ifdef __cplusplus |
| 333 } // extern "C" | 335 } // extern "C" |
| 334 #endif | 336 #endif |
| 335 | 337 |
| 336 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_OPUS_INTERFACE_H_ | 338 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_INTERFACE_OPUS_INTERFACE_H_ |
| OLD | NEW |