2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
15 #include "g722_enc_dec.h"
16 #include "g722_interface.h"
17 #include "webrtc/typedefs.h"
19 int16_t WebRtcG722_CreateEncoder(G722EncInst **G722enc_inst)
21 *G722enc_inst=(G722EncInst*)malloc(sizeof(g722_encode_state_t));
22 if (*G722enc_inst!=NULL) {
29 int16_t WebRtcG722_EncoderInit(G722EncInst *G722enc_inst)
31 // Create and/or reset the G.722 encoder
32 // Bitrate 64 kbps and wideband mode (2)
33 G722enc_inst = (G722EncInst *) WebRtc_g722_encode_init(
34 (g722_encode_state_t*) G722enc_inst, 64000, 2);
35 if (G722enc_inst == NULL) {
42 int16_t WebRtcG722_FreeEncoder(G722EncInst *G722enc_inst)
44 // Free encoder memory
45 return WebRtc_g722_encode_release((g722_encode_state_t*) G722enc_inst);
48 int16_t WebRtcG722_Encode(G722EncInst *G722enc_inst,
53 unsigned char *codechar = (unsigned char*) encoded;
54 // Encode the input speech vector
55 return WebRtc_g722_encode((g722_encode_state_t*) G722enc_inst,
56 codechar, speechIn, len);
59 int16_t WebRtcG722_CreateDecoder(G722DecInst **G722dec_inst)
61 *G722dec_inst=(G722DecInst*)malloc(sizeof(g722_decode_state_t));
62 if (*G722dec_inst!=NULL) {
69 int16_t WebRtcG722_DecoderInit(G722DecInst *G722dec_inst)
71 // Create and/or reset the G.722 decoder
72 // Bitrate 64 kbps and wideband mode (2)
73 G722dec_inst = (G722DecInst *) WebRtc_g722_decode_init(
74 (g722_decode_state_t*) G722dec_inst, 64000, 2);
75 if (G722dec_inst == NULL) {
82 int16_t WebRtcG722_FreeDecoder(G722DecInst *G722dec_inst)
84 // Free encoder memory
85 return WebRtc_g722_decode_release((g722_decode_state_t*) G722dec_inst);
88 int16_t WebRtcG722_Decode(G722DecInst *G722dec_inst,
94 // Decode the G.722 encoder stream
95 *speechType=G722_WEBRTC_SPEECH;
96 return WebRtc_g722_decode((g722_decode_state_t*) G722dec_inst,
97 decoded, (uint8_t*) encoded, len);
100 int16_t WebRtcG722_Version(char *versionStr, short len)
102 // Get version string
103 char version[30] = "2.0.0\n";
104 if (strlen(version) < (unsigned int)len)
106 strcpy(versionStr, version);