| 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 |
| (...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 917 * DecoderInitLb(...) - internal function for initialization of | 917 * DecoderInitLb(...) - internal function for initialization of |
| 918 * Lower Band | 918 * Lower Band |
| 919 * DecoderInitUb(...) - internal function for initialization of | 919 * DecoderInitUb(...) - internal function for initialization of |
| 920 * Upper Band | 920 * Upper Band |
| 921 * WebRtcIsac_DecoderInit(...) - API function | 921 * WebRtcIsac_DecoderInit(...) - API function |
| 922 * | 922 * |
| 923 * This function initializes a ISAC instance prior to the decoder calls. | 923 * This function initializes a ISAC instance prior to the decoder calls. |
| 924 * | 924 * |
| 925 * Input: | 925 * Input: |
| 926 * - ISAC_main_inst : ISAC instance. | 926 * - ISAC_main_inst : ISAC instance. |
| 927 * | |
| 928 * Return value | |
| 929 * : 0 - Ok | |
| 930 * -1 - Error | |
| 931 */ | 927 */ |
| 932 static int16_t DecoderInitLb(ISACLBStruct* instISAC) { | 928 static void DecoderInitLb(ISACLBStruct* instISAC) { |
| 933 int i; | 929 int i; |
| 934 /* Initialize stream vector to zero. */ | 930 /* Initialize stream vector to zero. */ |
| 935 for (i = 0; i < STREAM_SIZE_MAX_60; i++) { | 931 for (i = 0; i < STREAM_SIZE_MAX_60; i++) { |
| 936 instISAC->ISACdecLB_obj.bitstr_obj.stream[i] = 0; | 932 instISAC->ISACdecLB_obj.bitstr_obj.stream[i] = 0; |
| 937 } | 933 } |
| 938 | 934 |
| 939 WebRtcIsac_InitMasking(&instISAC->ISACdecLB_obj.maskfiltstr_obj); | 935 WebRtcIsac_InitMasking(&instISAC->ISACdecLB_obj.maskfiltstr_obj); |
| 940 WebRtcIsac_InitPostFilterbank( | 936 WebRtcIsac_InitPostFilterbank( |
| 941 &instISAC->ISACdecLB_obj.postfiltbankstr_obj); | 937 &instISAC->ISACdecLB_obj.postfiltbankstr_obj); |
| 942 WebRtcIsac_InitPitchFilter(&instISAC->ISACdecLB_obj.pitchfiltstr_obj); | 938 WebRtcIsac_InitPitchFilter(&instISAC->ISACdecLB_obj.pitchfiltstr_obj); |
| 943 return 0; | |
| 944 } | 939 } |
| 945 | 940 |
| 946 static int16_t DecoderInitUb(ISACUBStruct* instISAC) { | 941 static void DecoderInitUb(ISACUBStruct* instISAC) { |
| 947 int i; | 942 int i; |
| 948 /* Init stream vector to zero */ | 943 /* Init stream vector to zero */ |
| 949 for (i = 0; i < STREAM_SIZE_MAX_60; i++) { | 944 for (i = 0; i < STREAM_SIZE_MAX_60; i++) { |
| 950 instISAC->ISACdecUB_obj.bitstr_obj.stream[i] = 0; | 945 instISAC->ISACdecUB_obj.bitstr_obj.stream[i] = 0; |
| 951 } | 946 } |
| 952 | 947 |
| 953 WebRtcIsac_InitMasking(&instISAC->ISACdecUB_obj.maskfiltstr_obj); | 948 WebRtcIsac_InitMasking(&instISAC->ISACdecUB_obj.maskfiltstr_obj); |
| 954 WebRtcIsac_InitPostFilterbank( | 949 WebRtcIsac_InitPostFilterbank( |
| 955 &instISAC->ISACdecUB_obj.postfiltbankstr_obj); | 950 &instISAC->ISACdecUB_obj.postfiltbankstr_obj); |
| 956 return (0); | |
| 957 } | 951 } |
| 958 | 952 |
| 959 int16_t WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst) { | 953 void WebRtcIsac_DecoderInit(ISACStruct* ISAC_main_inst) { |
| 960 ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; | 954 ISACMainStruct* instISAC = (ISACMainStruct*)ISAC_main_inst; |
| 961 | 955 |
| 962 if (DecoderInitLb(&instISAC->instLB) < 0) { | 956 DecoderInitLb(&instISAC->instLB); |
| 963 return -1; | |
| 964 } | |
| 965 if (instISAC->decoderSamplingRateKHz == kIsacSuperWideband) { | 957 if (instISAC->decoderSamplingRateKHz == kIsacSuperWideband) { |
| 966 memset(instISAC->synthesisFBState1, 0, | 958 memset(instISAC->synthesisFBState1, 0, |
| 967 FB_STATE_SIZE_WORD32 * sizeof(int32_t)); | 959 FB_STATE_SIZE_WORD32 * sizeof(int32_t)); |
| 968 memset(instISAC->synthesisFBState2, 0, | 960 memset(instISAC->synthesisFBState2, 0, |
| 969 FB_STATE_SIZE_WORD32 * sizeof(int32_t)); | 961 FB_STATE_SIZE_WORD32 * sizeof(int32_t)); |
| 970 | 962 DecoderInitUb(&(instISAC->instUB)); |
| 971 if (DecoderInitUb(&(instISAC->instUB)) < 0) { | |
| 972 return -1; | |
| 973 } | |
| 974 } | 963 } |
| 975 if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != BIT_MASK_ENC_INIT) { | 964 if ((instISAC->initFlag & BIT_MASK_ENC_INIT) != BIT_MASK_ENC_INIT) { |
| 976 WebRtcIsac_InitBandwidthEstimator(&instISAC->bwestimator_obj, | 965 WebRtcIsac_InitBandwidthEstimator(&instISAC->bwestimator_obj, |
| 977 instISAC->encoderSamplingRateKHz, | 966 instISAC->encoderSamplingRateKHz, |
| 978 instISAC->decoderSamplingRateKHz); | 967 instISAC->decoderSamplingRateKHz); |
| 979 } | 968 } |
| 980 instISAC->initFlag |= BIT_MASK_DEC_INIT; | 969 instISAC->initFlag |= BIT_MASK_DEC_INIT; |
| 981 instISAC->resetFlag_8kHz = 0; | 970 instISAC->resetFlag_8kHz = 0; |
| 982 return 0; | |
| 983 } | 971 } |
| 984 | 972 |
| 985 | 973 |
| 986 /**************************************************************************** | 974 /**************************************************************************** |
| 987 * WebRtcIsac_UpdateBwEstimate(...) | 975 * WebRtcIsac_UpdateBwEstimate(...) |
| 988 * | 976 * |
| 989 * This function updates the estimate of the bandwidth. | 977 * This function updates the estimate of the bandwidth. |
| 990 * | 978 * |
| 991 * NOTE: | 979 * NOTE: |
| 992 * The estimates of bandwidth is not valid if the sample rate of the far-end | 980 * The estimates of bandwidth is not valid if the sample rate of the far-end |
| (...skipping 1353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2346 | 2334 |
| 2347 if ((instISAC->decoderSamplingRateKHz == kIsacWideband) && | 2335 if ((instISAC->decoderSamplingRateKHz == kIsacWideband) && |
| 2348 (decoder_operational_rate == kIsacSuperWideband)) { | 2336 (decoder_operational_rate == kIsacSuperWideband)) { |
| 2349 /* Switching from wideband to super-wideband at the decoder | 2337 /* Switching from wideband to super-wideband at the decoder |
| 2350 * we need to reset the filter-bank and initialize upper-band decoder. */ | 2338 * we need to reset the filter-bank and initialize upper-band decoder. */ |
| 2351 memset(instISAC->synthesisFBState1, 0, | 2339 memset(instISAC->synthesisFBState1, 0, |
| 2352 FB_STATE_SIZE_WORD32 * sizeof(int32_t)); | 2340 FB_STATE_SIZE_WORD32 * sizeof(int32_t)); |
| 2353 memset(instISAC->synthesisFBState2, 0, | 2341 memset(instISAC->synthesisFBState2, 0, |
| 2354 FB_STATE_SIZE_WORD32 * sizeof(int32_t)); | 2342 FB_STATE_SIZE_WORD32 * sizeof(int32_t)); |
| 2355 | 2343 |
| 2356 if (DecoderInitUb(&(instISAC->instUB)) < 0) { | 2344 DecoderInitUb(&instISAC->instUB); |
| 2357 return -1; | |
| 2358 } | |
| 2359 } | 2345 } |
| 2360 instISAC->decoderSamplingRateKHz = decoder_operational_rate; | 2346 instISAC->decoderSamplingRateKHz = decoder_operational_rate; |
| 2361 return 0; | 2347 return 0; |
| 2362 } | 2348 } |
| 2363 | 2349 |
| 2364 | 2350 |
| 2365 /****************************************************************************** | 2351 /****************************************************************************** |
| 2366 * WebRtcIsac_EncSampRate() | 2352 * WebRtcIsac_EncSampRate() |
| 2367 * | 2353 * |
| 2368 * Input: | 2354 * Input: |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2410 } | 2396 } |
| 2411 | 2397 |
| 2412 void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst, | 2398 void WebRtcIsac_SetEncSampRateInDecoder(ISACStruct* inst, |
| 2413 int sample_rate_hz) { | 2399 int sample_rate_hz) { |
| 2414 ISACMainStruct* instISAC = (ISACMainStruct*)inst; | 2400 ISACMainStruct* instISAC = (ISACMainStruct*)inst; |
| 2415 assert(instISAC->initFlag & BIT_MASK_DEC_INIT); | 2401 assert(instISAC->initFlag & BIT_MASK_DEC_INIT); |
| 2416 assert(!(instISAC->initFlag & BIT_MASK_ENC_INIT)); | 2402 assert(!(instISAC->initFlag & BIT_MASK_ENC_INIT)); |
| 2417 assert(sample_rate_hz == 16000 || sample_rate_hz == 32000); | 2403 assert(sample_rate_hz == 16000 || sample_rate_hz == 32000); |
| 2418 instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000; | 2404 instISAC->encoderSamplingRateKHz = sample_rate_hz / 1000; |
| 2419 } | 2405 } |
| OLD | NEW |