g711_codec.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. // 刘斌修改 start - G711编解码实现
  2. // 内存优化:使用动态分配查找表
  3. // 支持μ-law和A-law编解码
  4. #include "luat_base.h"
  5. #include "luat_multimedia_codec.h"
  6. #include "luat_mem.h"
  7. #include <stdbool.h>
  8. #define LUAT_LOG_TAG "g711"
  9. #include "luat_log.h"
  10. // G711编解码器结构体 - 包含动态分配的查找表
  11. typedef struct {
  12. uint8_t type; // ULAW or ALAW
  13. uint8_t is_encoder; // 是否为编码器
  14. uint32_t sample_rate; // 采样率
  15. uint32_t frame_count; // 处理的帧数统计
  16. // 动态分配的查找表
  17. uint8_t* linear_to_alaw; // A-law编码表
  18. uint8_t* linear_to_ulaw; // μ-law编码表
  19. int16_t* ulaw_decode_table; // μ-law解码表
  20. int16_t* alaw_decode_table; // A-law解码表
  21. bool tables_initialized; // 查找表是否已初始化
  22. } g711_codec_t;
  23. // μ-law编码函数 - 用于生成查找表
  24. static int ulaw2linear(unsigned char u_val)
  25. {
  26. int t;
  27. u_val = ~u_val;
  28. t = ((u_val & 0x0F) << 3) + 0x84;
  29. t <<= ((unsigned)u_val & 0x70) >> 4;
  30. return (u_val & 0x80) ? (0x84 - t) : (t - 0x84);
  31. }
  32. // A-law编码函数 - 用于生成查找表
  33. static int alaw2linear(unsigned char a_val)
  34. {
  35. int t;
  36. int seg;
  37. a_val ^= 0x55;
  38. t = a_val & 0x0F;
  39. seg = ((unsigned)a_val & 0x70) >> 4;
  40. if(seg)
  41. t = (t + t + 1 + 32) << (seg + 2);
  42. else
  43. t = (t + t + 1) << 3;
  44. return (a_val & 0x80) ? t : -t;
  45. }
  46. // 生成μ-law编码查找表
  47. static void build_ulaw_table(uint8_t* linear_to_ulaw)
  48. {
  49. int i, j, v, v1, v2;
  50. j = 1;
  51. linear_to_ulaw[8192] = 0xFF;
  52. for(i = 0; i < 127; i++) {
  53. v1 = ulaw2linear(i ^ 0xFF);
  54. v2 = ulaw2linear((i + 1) ^ 0xFF);
  55. v = (v1 + v2 + 4) >> 3;
  56. for(; j < v; j += 1) {
  57. linear_to_ulaw[8192 - j] = (i ^ (0xFF ^ 0x80));
  58. linear_to_ulaw[8192 + j] = (i ^ 0xFF);
  59. }
  60. }
  61. for(; j < 8192; j++) {
  62. linear_to_ulaw[8192 - j] = (127 ^ (0xFF ^ 0x80));
  63. linear_to_ulaw[8192 + j] = (127 ^ 0xFF);
  64. }
  65. linear_to_ulaw[0] = linear_to_ulaw[1];
  66. }
  67. // 生成A-law编码查找表
  68. static void build_alaw_table(uint8_t* linear_to_alaw)
  69. {
  70. int i, j, v, v1, v2;
  71. j = 1;
  72. linear_to_alaw[8192] = 0xD5;
  73. for(i = 0; i < 127; i++) {
  74. v1 = alaw2linear(i ^ 0xD5);
  75. v2 = alaw2linear((i + 1) ^ 0xD5);
  76. v = (v1 + v2 + 4) >> 3;
  77. for(; j < v; j += 1) {
  78. linear_to_alaw[8192 - j] = (i ^ (0xD5 ^ 0x80));
  79. linear_to_alaw[8192 + j] = (i ^ 0xD5);
  80. }
  81. }
  82. for(; j < 8192; j++) {
  83. linear_to_alaw[8192 - j] = (127 ^ (0xD5 ^ 0x80));
  84. linear_to_alaw[8192 + j] = (127 ^ 0xD5);
  85. }
  86. linear_to_alaw[0] = linear_to_alaw[1];
  87. }
  88. // 初始化μ-law解码查找表
  89. static void build_ulaw_decode_table(int16_t* ulaw_decode_table)
  90. {
  91. // 标准的μ-law解码表数据
  92. const int16_t ulaw_data[256] = {
  93. -32124, -31100, -30076, -29052, -28028, -27004, -25980, -24956,
  94. -23932, -22908, -21884, -20860, -19836, -18812, -17788, -16764,
  95. -15996, -15484, -14972, -14460, -13948, -13436, -12924, -12412,
  96. -11900, -11388, -10876, -10364, -9852, -9340, -8828, -8316,
  97. -7932, -7676, -7420, -7164, -6908, -6652, -6396, -6140,
  98. -5884, -5628, -5372, -5116, -4860, -4604, -4348, -4092,
  99. -3900, -3772, -3644, -3516, -3388, -3260, -3132, -3004,
  100. -2876, -2748, -2620, -2492, -2364, -2236, -2108, -1980,
  101. -1884, -1820, -1756, -1692, -1628, -1564, -1500, -1436,
  102. -1372, -1308, -1244, -1180, -1116, -1052, -988, -924,
  103. -876, -844, -812, -780, -748, -716, -684, -652,
  104. -620, -588, -556, -524, -492, -460, -428, -396,
  105. -372, -356, -340, -324, -308, -292, -276, -260,
  106. -244, -228, -212, -196, -180, -164, -148, -132,
  107. -120, -112, -104, -96, -88, -80, -72, -64,
  108. -56, -48, -40, -32, -24, -16, -8, 0,
  109. 32124, 31100, 30076, 29052, 28028, 27004, 25980, 24956,
  110. 23932, 22908, 21884, 20860, 19836, 18812, 17788, 16764,
  111. 15996, 15484, 14972, 14460, 13948, 13436, 12924, 12412,
  112. 11900, 11388, 10876, 10364, 9852, 9340, 8828, 8316,
  113. 7932, 7676, 7420, 7164, 6908, 6652, 6396, 6140,
  114. 5884, 5628, 5372, 5116, 4860, 4604, 4348, 4092,
  115. 3900, 3772, 3644, 3516, 3388, 3260, 3132, 3004,
  116. 2876, 2748, 2620, 2492, 2364, 2236, 2108, 1980,
  117. 1884, 1820, 1756, 1692, 1628, 1564, 1500, 1436,
  118. 1372, 1308, 1244, 1180, 1116, 1052, 988, 924,
  119. 876, 844, 812, 780, 748, 716, 684, 652,
  120. 620, 588, 556, 524, 492, 460, 428, 396,
  121. 372, 356, 340, 324, 308, 292, 276, 260,
  122. 244, 228, 212, 196, 180, 164, 148, 132,
  123. 120, 112, 104, 96, 88, 80, 72, 64,
  124. 56, 48, 40, 32, 24, 16, 8, 0
  125. };
  126. // 复制数据到动态分配的表
  127. for(int i = 0; i < 256; i++) {
  128. ulaw_decode_table[i] = ulaw_data[i];
  129. }
  130. }
  131. // 初始化A-law解码查找表
  132. static void build_alaw_decode_table(int16_t* alaw_decode_table)
  133. {
  134. // 标准的A-law解码表数据
  135. const int16_t alaw_data[256] = {
  136. -5504, -5248, -6016, -5760, -4480, -4224, -4992, -4736,
  137. -7552, -7296, -8064, -7808, -6528, -6272, -7040, -6784,
  138. -2752, -2624, -3008, -2880, -2240, -2112, -2496, -2368,
  139. -3776, -3648, -4032, -3904, -3264, -3136, -3520, -3392,
  140. -22016, -20992, -24064, -23040, -17920, -16896, -19968, -18944,
  141. -30208, -29184, -32256, -31232, -26112, -25088, -28160, -27136,
  142. -11008, -10496, -12032, -11520, -8960, -8448, -9984, -9472,
  143. -15104, -14592, -16128, -15616, -13056, -12544, -14080, -13568,
  144. -344, -328, -376, -360, -280, -264, -312, -296,
  145. -472, -456, -504, -488, -408, -392, -440, -424,
  146. -88, -72, -120, -104, -24, -8, -56, -40,
  147. -216, -200, -248, -232, -152, -136, -184, -168,
  148. -1376, -1312, -1504, -1440, -1120, -1056, -1248, -1184,
  149. -1888, -1824, -2016, -1952, -1632, -1568, -1760, -1696,
  150. -688, -656, -752, -720, -560, -528, -624, -592,
  151. -944, -912, -1008, -976, -816, -784, -880, -848,
  152. 5504, 5248, 6016, 5760, 4480, 4224, 4992, 4736,
  153. 7552, 7296, 8064, 7808, 6528, 6272, 7040, 6784,
  154. 2752, 2624, 3008, 2880, 2240, 2112, 2496, 2368,
  155. 3776, 3648, 4032, 3904, 3264, 3136, 3520, 3392,
  156. 22016, 20992, 24064, 23040, 17920, 16896, 19968, 18944,
  157. 30208, 29184, 32256, 31232, 26112, 25088, 28160, 27136,
  158. 11008, 10496, 12032, 11520, 8960, 8448, 9984, 9472,
  159. 15104, 14592, 16128, 15616, 13056, 12544, 14080, 13568,
  160. 344, 328, 376, 360, 280, 264, 312, 296,
  161. 472, 456, 504, 488, 408, 392, 440, 424,
  162. 88, 72, 120, 104, 24, 8, 56, 40,
  163. 216, 200, 248, 232, 152, 136, 184, 168,
  164. 1376, 1312, 1504, 1440, 1120, 1056, 1248, 1184,
  165. 1888, 1824, 2016, 1952, 1632, 1568, 1760, 1696,
  166. 688, 656, 752, 720, 560, 528, 624, 592,
  167. 944, 912, 1008, 976, 816, 784, 880, 848
  168. };
  169. // 复制数据到动态分配的表
  170. for(int i = 0; i < 256; i++) {
  171. alaw_decode_table[i] = alaw_data[i];
  172. }
  173. }
  174. // 初始化所有查找表
  175. static int g711_tables_init(g711_codec_t* codec)
  176. {
  177. if (!codec || codec->tables_initialized) {
  178. return 0;
  179. }
  180. // 分配编码查找表内存
  181. codec->linear_to_alaw = (uint8_t*)luat_heap_malloc(16384);
  182. codec->linear_to_ulaw = (uint8_t*)luat_heap_malloc(16384);
  183. // 分配解码查找表内存
  184. codec->ulaw_decode_table = (int16_t*)luat_heap_malloc(256 * sizeof(int16_t));
  185. codec->alaw_decode_table = (int16_t*)luat_heap_malloc(256 * sizeof(int16_t));
  186. // 检查内存分配是否成功
  187. if (!codec->linear_to_alaw || !codec->linear_to_ulaw ||
  188. !codec->ulaw_decode_table || !codec->alaw_decode_table) {
  189. // 内存分配失败,清理已分配的内存
  190. if (codec->linear_to_alaw) luat_heap_free(codec->linear_to_alaw);
  191. if (codec->linear_to_ulaw) luat_heap_free(codec->linear_to_ulaw);
  192. if (codec->ulaw_decode_table) luat_heap_free(codec->ulaw_decode_table);
  193. if (codec->alaw_decode_table) luat_heap_free(codec->alaw_decode_table);
  194. codec->linear_to_alaw = NULL;
  195. codec->linear_to_ulaw = NULL;
  196. codec->ulaw_decode_table = NULL;
  197. codec->alaw_decode_table = NULL;
  198. LLOGE("G711 tables memory allocation failed");
  199. return -1;
  200. }
  201. // 生成查找表
  202. build_ulaw_table(codec->linear_to_ulaw);
  203. build_alaw_table(codec->linear_to_alaw);
  204. build_ulaw_decode_table(codec->ulaw_decode_table);
  205. build_alaw_decode_table(codec->alaw_decode_table);
  206. codec->tables_initialized = true;
  207. return 0;
  208. }
  209. // 释放查找表内存
  210. static void g711_tables_cleanup(g711_codec_t* codec)
  211. {
  212. if (codec) {
  213. if (codec->linear_to_alaw) {
  214. luat_heap_free(codec->linear_to_alaw);
  215. codec->linear_to_alaw = NULL;
  216. }
  217. if (codec->linear_to_ulaw) {
  218. luat_heap_free(codec->linear_to_ulaw);
  219. codec->linear_to_ulaw = NULL;
  220. }
  221. if (codec->ulaw_decode_table) {
  222. luat_heap_free(codec->ulaw_decode_table);
  223. codec->ulaw_decode_table = NULL;
  224. }
  225. if (codec->alaw_decode_table) {
  226. luat_heap_free(codec->alaw_decode_table);
  227. codec->alaw_decode_table = NULL;
  228. }
  229. codec->tables_initialized = false;
  230. }
  231. }
  232. // 优化的G711 μ-law编码函数 - 使用动态查找表
  233. static inline uint8_t g711_ulaw_encode_optimized(g711_codec_t* codec, int16_t pcm_sample)
  234. {
  235. int index = (pcm_sample + 32768) >> 2;
  236. if(index < 0) index = 0;
  237. if(index >= 16384) index = 16383;
  238. return codec->linear_to_ulaw[index];
  239. }
  240. // 优化的G711 A-law编码函数 - 使用动态查找表
  241. static inline uint8_t g711_alaw_encode_optimized(g711_codec_t* codec, int16_t pcm_sample)
  242. {
  243. int index = (pcm_sample + 32768) >> 2;
  244. if(index < 0) index = 0;
  245. if(index >= 16384) index = 16383;
  246. return codec->linear_to_alaw[index];
  247. }
  248. // 标准G711 μ-law解码函数 - 使用动态查找表
  249. static inline int16_t g711_ulaw_decode_optimized(g711_codec_t* codec, uint8_t ulaw_byte) {
  250. return codec->ulaw_decode_table[ulaw_byte];
  251. }
  252. // 标准G711 A-law解码函数 - 使用动态查找表
  253. static inline int16_t g711_alaw_decode_optimized(g711_codec_t* codec, uint8_t alaw_byte) {
  254. return codec->alaw_decode_table[alaw_byte];
  255. }
  256. // 批量μ-law编码 - 使用循环展开优化
  257. static void g711_ulaw_encode_batch(g711_codec_t* codec, const int16_t* pcm, uint8_t* output, uint32_t len) {
  258. uint32_t i;
  259. // 循环展开优化,每次处理4个样本
  260. for (i = 0; i < len - 3; i += 4) {
  261. output[i] = g711_ulaw_encode_optimized(codec, pcm[i]);
  262. output[i+1] = g711_ulaw_encode_optimized(codec, pcm[i+1]);
  263. output[i+2] = g711_ulaw_encode_optimized(codec, pcm[i+2]);
  264. output[i+3] = g711_ulaw_encode_optimized(codec, pcm[i+3]);
  265. }
  266. // 处理剩余样本
  267. for (; i < len; i++) {
  268. output[i] = g711_ulaw_encode_optimized(codec, pcm[i]);
  269. }
  270. }
  271. // 批量A-law编码 - 使用循环展开优化
  272. static void g711_alaw_encode_batch(g711_codec_t* codec, const int16_t* pcm, uint8_t* output, uint32_t len) {
  273. uint32_t i;
  274. // 循环展开优化,每次处理4个样本
  275. for (i = 0; i < len - 3; i += 4) {
  276. output[i] = g711_alaw_encode_optimized(codec, pcm[i]);
  277. output[i+1] = g711_alaw_encode_optimized(codec, pcm[i+1]);
  278. output[i+2] = g711_alaw_encode_optimized(codec, pcm[i+2]);
  279. output[i+3] = g711_alaw_encode_optimized(codec, pcm[i+3]);
  280. }
  281. // 处理剩余样本
  282. for (; i < len; i++) {
  283. output[i] = g711_alaw_encode_optimized(codec, pcm[i]);
  284. }
  285. }
  286. // 批量μ-law解码 - 使用循环展开优化
  287. static void g711_ulaw_decode_batch(g711_codec_t* codec, const uint8_t* input, int16_t* pcm, uint32_t len) {
  288. uint32_t i;
  289. // 循环展开优化,每次处理4个样本
  290. for (i = 0; i < len - 3; i += 4) {
  291. pcm[i] = g711_ulaw_decode_optimized(codec, input[i]);
  292. pcm[i+1] = g711_ulaw_decode_optimized(codec, input[i+1]);
  293. pcm[i+2] = g711_ulaw_decode_optimized(codec, input[i+2]);
  294. pcm[i+3] = g711_ulaw_decode_optimized(codec, input[i+3]);
  295. }
  296. // 处理剩余样本
  297. for (; i < len; i++) {
  298. pcm[i] = g711_ulaw_decode_optimized(codec, input[i]);
  299. }
  300. }
  301. // 批量A-law解码 - 使用循环展开优化
  302. static void g711_alaw_decode_batch(g711_codec_t* codec, const uint8_t* input, int16_t* pcm, uint32_t len) {
  303. uint32_t i;
  304. // 循环展开优化,每次处理4个样本
  305. for (i = 0; i < len - 3; i += 4) {
  306. pcm[i] = g711_alaw_decode_optimized(codec, input[i]);
  307. pcm[i+1] = g711_alaw_decode_optimized(codec, input[i+1]);
  308. pcm[i+2] = g711_alaw_decode_optimized(codec, input[i+2]);
  309. pcm[i+3] = g711_alaw_decode_optimized(codec, input[i+3]);
  310. }
  311. // 处理剩余样本
  312. for (; i < len; i++) {
  313. pcm[i] = g711_alaw_decode_optimized(codec, input[i]);
  314. }
  315. }
  316. // 创建G711解码器 - 优化内存分配
  317. void* g711_decoder_create(uint8_t type) {
  318. // 验证类型
  319. if (type != LUAT_MULTIMEDIA_DATA_TYPE_ULAW && type != LUAT_MULTIMEDIA_DATA_TYPE_ALAW) {
  320. return NULL;
  321. }
  322. g711_codec_t* decoder = (g711_codec_t*)luat_heap_malloc(sizeof(g711_codec_t));
  323. if (decoder) {
  324. // 初始化结构体
  325. decoder->type = type;
  326. decoder->is_encoder = 0;
  327. decoder->sample_rate = 8000; // 默认采样率
  328. decoder->frame_count = 0;
  329. decoder->linear_to_alaw = NULL;
  330. decoder->linear_to_ulaw = NULL;
  331. decoder->ulaw_decode_table = NULL;
  332. decoder->alaw_decode_table = NULL;
  333. decoder->tables_initialized = false;
  334. // 初始化查找表
  335. if (g711_tables_init(decoder) != 0) {
  336. luat_heap_free(decoder);
  337. return NULL;
  338. }
  339. } else {
  340. LLOGE("G711 decoder memory allocation failed");
  341. }
  342. return decoder;
  343. }
  344. // 销毁G711解码器 - 安全释放内存
  345. void g711_decoder_destroy(void* decoder) {
  346. if (decoder) {
  347. g711_codec_t* g711 = (g711_codec_t*)decoder;
  348. g711_tables_cleanup(g711);
  349. luat_heap_free(decoder);
  350. }
  351. }
  352. // G711解码数据 - 批量处理提高效率
  353. int g711_decoder_get_data(void* decoder, const uint8_t* input, uint32_t len,
  354. int16_t* pcm, uint32_t* out_len, uint32_t* used) {
  355. g711_codec_t* g711 = (g711_codec_t*)decoder;
  356. // 参数验证
  357. if (!g711 || !input || !pcm || !out_len || !used) {
  358. LLOGE("G711 decoder invalid parameters");
  359. return -1;
  360. }
  361. if (len == 0) {
  362. *out_len = 0;
  363. *used = 0;
  364. return 0;
  365. }
  366. *out_len = 0;
  367. *used = len;
  368. // 批量解码G711数据为PCM
  369. if (g711->type == LUAT_MULTIMEDIA_DATA_TYPE_ULAW) {
  370. g711_ulaw_decode_batch(g711, input, pcm, len);
  371. } else if (g711->type == LUAT_MULTIMEDIA_DATA_TYPE_ALAW) {
  372. g711_alaw_decode_batch(g711, input, pcm, len);
  373. } else {
  374. return -1;
  375. }
  376. *out_len = len * 2; // 16位PCM,每样本2字节
  377. return 1;
  378. }
  379. // 创建G711编码器 - 优化内存分配
  380. void* g711_encoder_create(uint8_t type) {
  381. // 验证类型
  382. if (type != LUAT_MULTIMEDIA_DATA_TYPE_ULAW && type != LUAT_MULTIMEDIA_DATA_TYPE_ALAW) {
  383. return NULL;
  384. }
  385. g711_codec_t* encoder = (g711_codec_t*)luat_heap_malloc(sizeof(g711_codec_t));
  386. if (encoder) {
  387. // 初始化结构体
  388. encoder->type = type;
  389. encoder->is_encoder = 1;
  390. encoder->sample_rate = 8000; // 默认采样率
  391. encoder->frame_count = 0;
  392. encoder->linear_to_alaw = NULL;
  393. encoder->linear_to_ulaw = NULL;
  394. encoder->ulaw_decode_table = NULL;
  395. encoder->alaw_decode_table = NULL;
  396. encoder->tables_initialized = false;
  397. // 初始化查找表
  398. if (g711_tables_init(encoder) != 0) {
  399. luat_heap_free(encoder);
  400. return NULL;
  401. }
  402. } else {
  403. LLOGE("G711 encoder memory allocation failed");
  404. }
  405. return encoder;
  406. }
  407. // 销毁G711编码器 - 安全释放内存
  408. void g711_encoder_destroy(void* encoder) {
  409. if (encoder) {
  410. g711_codec_t* g711 = (g711_codec_t*)encoder;
  411. g711_tables_cleanup(g711);
  412. luat_heap_free(encoder);
  413. }
  414. }
  415. // G711编码数据 - 批量处理提高效率,仅支持16位PCM输入
  416. int g711_encoder_get_data(void* encoder, const int16_t* pcm, uint32_t len,
  417. uint8_t* output, uint32_t* out_len) {
  418. g711_codec_t* g711 = (g711_codec_t*)encoder;
  419. // 参数验证
  420. if (!g711 || !pcm || !output || !out_len) {
  421. return -1;
  422. }
  423. if (len == 0) {
  424. *out_len = 0;
  425. return 0;
  426. }
  427. *out_len = 0;
  428. // 批量编码PCM数据为G711
  429. if (g711->type == LUAT_MULTIMEDIA_DATA_TYPE_ULAW) {
  430. g711_ulaw_encode_batch(g711, pcm, output, len);
  431. } else if (g711->type == LUAT_MULTIMEDIA_DATA_TYPE_ALAW) {
  432. g711_alaw_encode_batch(g711, pcm, output, len);
  433. } else {
  434. return -1;
  435. }
  436. *out_len = len; // 8位G711,每样本1字节
  437. return 1;
  438. }
  439. // 性能统计函数
  440. void g711_get_stats(void* codec, uint32_t* sample_rate, uint32_t* frame_count) {
  441. g711_codec_t* g711 = (g711_codec_t*)codec;
  442. if (g711) {
  443. if (sample_rate) *sample_rate = g711->sample_rate;
  444. if (frame_count) *frame_count = g711->frame_count;
  445. }
  446. }
  447. // 重置统计信息
  448. void g711_reset_stats(void* codec) {
  449. g711_codec_t* g711 = (g711_codec_t*)codec;
  450. if (g711) {
  451. g711->frame_count = 0;
  452. }
  453. }
  454. // 设置采样率
  455. void g711_set_sample_rate(void* codec, uint32_t sample_rate) {
  456. g711_codec_t* g711 = (g711_codec_t*)codec;
  457. if (g711) {
  458. g711->sample_rate = sample_rate;
  459. }
  460. }
  461. // 刘斌修改 end