Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/main/source/encode.c

Issue 1177993003: iSAC: Move global trig tables into the codec instance (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 return 0; 170 return 0;
171 } 171 }
172 172
173 173
174 void WebRtcIsac_ResetBitstream(Bitstr* bit_stream) { 174 void WebRtcIsac_ResetBitstream(Bitstr* bit_stream) {
175 bit_stream->W_upper = 0xFFFFFFFF; 175 bit_stream->W_upper = 0xFFFFFFFF;
176 bit_stream->stream_index = 0; 176 bit_stream->stream_index = 0;
177 bit_stream->streamval = 0; 177 bit_stream->streamval = 0;
178 } 178 }
179 179
180 int WebRtcIsac_EncodeLb(float* in, ISACLBEncStruct* ISACencLB_obj, 180 int WebRtcIsac_EncodeLb(const TransformTables* transform_tables,
181 float* in, ISACLBEncStruct* ISACencLB_obj,
181 int16_t codingMode, 182 int16_t codingMode,
182 int16_t bottleneckIndex) { 183 int16_t bottleneckIndex) {
183 int stream_length = 0; 184 int stream_length = 0;
184 int err; 185 int err;
185 int k; 186 int k;
186 int iterCntr; 187 int iterCntr;
187 188
188 double lofilt_coef[(ORDERLO + 1)*SUBFRAMES]; 189 double lofilt_coef[(ORDERLO + 1)*SUBFRAMES];
189 double hifilt_coef[(ORDERHI + 1)*SUBFRAMES]; 190 double hifilt_coef[(ORDERHI + 1)*SUBFRAMES];
190 float LP[FRAMESAMPLES_HALF]; 191 float LP[FRAMESAMPLES_HALF];
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 LP, lofilt_coef, LPw); 376 LP, lofilt_coef, LPw);
376 /* High-band filtering. */ 377 /* High-band filtering. */
377 WebRtcIsac_NormLatticeFilterMa(ORDERHI, 378 WebRtcIsac_NormLatticeFilterMa(ORDERHI,
378 ISACencLB_obj->maskfiltstr_obj.PreStateHiF, 379 ISACencLB_obj->maskfiltstr_obj.PreStateHiF,
379 ISACencLB_obj->maskfiltstr_obj.PreStateHiG, 380 ISACencLB_obj->maskfiltstr_obj.PreStateHiG,
380 HP, hifilt_coef, HPw); 381 HP, hifilt_coef, HPw);
381 /* Pitch filter. */ 382 /* Pitch filter. */
382 WebRtcIsac_PitchfilterPre(LPw, LPw_pf, &ISACencLB_obj->pitchfiltstr_obj, 383 WebRtcIsac_PitchfilterPre(LPw, LPw_pf, &ISACencLB_obj->pitchfiltstr_obj,
383 PitchLags, PitchGains); 384 PitchLags, PitchGains);
384 /* Transform */ 385 /* Transform */
385 WebRtcIsac_Time2Spec(LPw_pf, HPw, fre, fim, &ISACencLB_obj->fftstr_obj); 386 WebRtcIsac_Time2Spec(transform_tables,
387 LPw_pf, HPw, fre, fim, &ISACencLB_obj->fftstr_obj);
386 388
387 /* Save data for multiple packets memory. */ 389 /* Save data for multiple packets memory. */
388 my_index = ISACencLB_obj->SaveEnc_obj.startIdx * FRAMESAMPLES_HALF; 390 my_index = ISACencLB_obj->SaveEnc_obj.startIdx * FRAMESAMPLES_HALF;
389 memcpy(&ISACencLB_obj->SaveEnc_obj.fre[my_index], fre, sizeof(fre)); 391 memcpy(&ISACencLB_obj->SaveEnc_obj.fre[my_index], fre, sizeof(fre));
390 memcpy(&ISACencLB_obj->SaveEnc_obj.fim[my_index], fim, sizeof(fim)); 392 memcpy(&ISACencLB_obj->SaveEnc_obj.fim[my_index], fim, sizeof(fim));
391 393
392 ISACencLB_obj->SaveEnc_obj.AvgPitchGain[ISACencLB_obj->SaveEnc_obj.startIdx] = 394 ISACencLB_obj->SaveEnc_obj.AvgPitchGain[ISACencLB_obj->SaveEnc_obj.startIdx] =
393 AvgPitchGain_Q12; 395 AvgPitchGain_Q12;
394 396
395 /* Quantization and loss-less coding. */ 397 /* Quantization and loss-less coding. */
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
634 /* There has been an error but it was not too large payload 636 /* There has been an error but it was not too large payload
635 (we can cure too large payload). */ 637 (we can cure too large payload). */
636 return status; 638 return status;
637 } 639 }
638 iterCntr++; 640 iterCntr++;
639 } while ((ISACencUB_obj->bitstr_obj.stream_index > payloadLimitBytes) || 641 } while ((ISACencUB_obj->bitstr_obj.stream_index > payloadLimitBytes) ||
640 (status == -ISAC_DISALLOWED_BITSTREAM_LENGTH)); 642 (status == -ISAC_DISALLOWED_BITSTREAM_LENGTH));
641 return 0; 643 return 0;
642 } 644 }
643 645
644 int WebRtcIsac_EncodeUb16(float* in, ISACUBEncStruct* ISACencUB_obj, 646 int WebRtcIsac_EncodeUb16(const TransformTables* transform_tables,
647 float* in, ISACUBEncStruct* ISACencUB_obj,
645 int32_t jitterInfo) { 648 int32_t jitterInfo) {
646 int err; 649 int err;
647 int k; 650 int k;
648 651
649 double lpcVecs[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME]; 652 double lpcVecs[UB_LPC_ORDER * UB16_LPC_VEC_PER_FRAME];
650 double percepFilterParams[(1 + UB_LPC_ORDER) * (SUBFRAMES << 1) + 653 double percepFilterParams[(1 + UB_LPC_ORDER) * (SUBFRAMES << 1) +
651 (1 + UB_LPC_ORDER)]; 654 (1 + UB_LPC_ORDER)];
652 655
653 double LP_lookahead[FRAMESAMPLES]; 656 double LP_lookahead[FRAMESAMPLES];
654 int16_t fre[FRAMESAMPLES_HALF]; /* Q7 */ 657 int16_t fre[FRAMESAMPLES_HALF]; /* Q7 */
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 &LP_lookahead[0]); 778 &LP_lookahead[0]);
776 779
777 /* Second half-frame filtering. */ 780 /* Second half-frame filtering. */
778 WebRtcIsac_NormLatticeFilterMa( 781 WebRtcIsac_NormLatticeFilterMa(
779 UB_LPC_ORDER, ISACencUB_obj->maskfiltstr_obj.PreStateLoF, 782 UB_LPC_ORDER, ISACencUB_obj->maskfiltstr_obj.PreStateLoF,
780 ISACencUB_obj->maskfiltstr_obj.PreStateLoG, 783 ISACencUB_obj->maskfiltstr_obj.PreStateLoG,
781 &ISACencUB_obj->data_buffer_float[FRAMESAMPLES_HALF], 784 &ISACencUB_obj->data_buffer_float[FRAMESAMPLES_HALF],
782 &percepFilterParams[(UB_LPC_ORDER + 1) + SUBFRAMES * (UB_LPC_ORDER + 1)], 785 &percepFilterParams[(UB_LPC_ORDER + 1) + SUBFRAMES * (UB_LPC_ORDER + 1)],
783 &LP_lookahead[FRAMESAMPLES_HALF]); 786 &LP_lookahead[FRAMESAMPLES_HALF]);
784 787
785 WebRtcIsac_Time2Spec(&LP_lookahead[0], &LP_lookahead[FRAMESAMPLES_HALF], 788 WebRtcIsac_Time2Spec(transform_tables,
789 &LP_lookahead[0], &LP_lookahead[FRAMESAMPLES_HALF],
786 fre, fim, &ISACencUB_obj->fftstr_obj); 790 fre, fim, &ISACencUB_obj->fftstr_obj);
787 791
788 /* Store FFT coefficients for multiple encoding. */ 792 /* Store FFT coefficients for multiple encoding. */
789 memcpy(ISACencUB_obj->SaveEnc_obj.realFFT, fre, sizeof(fre)); 793 memcpy(ISACencUB_obj->SaveEnc_obj.realFFT, fre, sizeof(fre));
790 memcpy(ISACencUB_obj->SaveEnc_obj.imagFFT, fim, sizeof(fim)); 794 memcpy(ISACencUB_obj->SaveEnc_obj.imagFFT, fim, sizeof(fim));
791 795
792 /* Prepare the audio buffer for the next packet 796 /* Prepare the audio buffer for the next packet
793 * move the last 3 ms to the beginning of the buffer. */ 797 * move the last 3 ms to the beginning of the buffer. */
794 memcpy(ISACencUB_obj->data_buffer_float, 798 memcpy(ISACencUB_obj->data_buffer_float,
795 &ISACencUB_obj->data_buffer_float[FRAMESAMPLES], 799 &ISACencUB_obj->data_buffer_float[FRAMESAMPLES],
(...skipping 23 matching lines...) Expand all
819 kIsacUpperBand16, err); 823 kIsacUpperBand16, err);
820 } 824 }
821 if (err < 0) { 825 if (err < 0) {
822 return err; 826 return err;
823 } 827 }
824 /* Complete arithmetic coding. */ 828 /* Complete arithmetic coding. */
825 return WebRtcIsac_EncTerminate(&ISACencUB_obj->bitstr_obj); 829 return WebRtcIsac_EncTerminate(&ISACencUB_obj->bitstr_obj);
826 } 830 }
827 831
828 832
829 int WebRtcIsac_EncodeUb12(float* in, ISACUBEncStruct* ISACencUB_obj, 833 int WebRtcIsac_EncodeUb12(const TransformTables* transform_tables,
834 float* in, ISACUBEncStruct* ISACencUB_obj,
830 int32_t jitterInfo) { 835 int32_t jitterInfo) {
831 int err; 836 int err;
832 int k; 837 int k;
833 838
834 double lpcVecs[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME]; 839 double lpcVecs[UB_LPC_ORDER * UB_LPC_VEC_PER_FRAME];
835 840
836 double percepFilterParams[(1 + UB_LPC_ORDER) * SUBFRAMES]; 841 double percepFilterParams[(1 + UB_LPC_ORDER) * SUBFRAMES];
837 float LP[FRAMESAMPLES_HALF]; 842 float LP[FRAMESAMPLES_HALF];
838 float HP[FRAMESAMPLES_HALF]; 843 float HP[FRAMESAMPLES_HALF];
839 844
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 of bytes left for coding the spectrum. It is a 30ms frame Subract 3 955 of bytes left for coding the spectrum. It is a 30ms frame Subract 3
951 because termination process may add 3 bytes */ 956 because termination process may add 3 bytes */
952 payloadLimitBytes = ISACencUB_obj->maxPayloadSizeBytes - 957 payloadLimitBytes = ISACencUB_obj->maxPayloadSizeBytes -
953 ISACencUB_obj->numBytesUsed - 3; 958 ISACencUB_obj->numBytesUsed - 3;
954 bytesLeftSpecCoding = payloadLimitBytes - 959 bytesLeftSpecCoding = payloadLimitBytes -
955 ISACencUB_obj->bitstr_obj.stream_index; 960 ISACencUB_obj->bitstr_obj.stream_index;
956 961
957 memset(HPw, 0, sizeof(HPw)); 962 memset(HPw, 0, sizeof(HPw));
958 963
959 /* Transform */ 964 /* Transform */
960 WebRtcIsac_Time2Spec(LPw, HPw, fre, fim, &ISACencUB_obj->fftstr_obj); 965 WebRtcIsac_Time2Spec(transform_tables,
966 LPw, HPw, fre, fim, &ISACencUB_obj->fftstr_obj);
961 967
962 /* Store FFT coefficients for multiple encoding. */ 968 /* Store FFT coefficients for multiple encoding. */
963 memcpy(ISACencUB_obj->SaveEnc_obj.realFFT, fre, 969 memcpy(ISACencUB_obj->SaveEnc_obj.realFFT, fre,
964 sizeof(ISACencUB_obj->SaveEnc_obj.realFFT)); 970 sizeof(ISACencUB_obj->SaveEnc_obj.realFFT));
965 memcpy(ISACencUB_obj->SaveEnc_obj.imagFFT, fim, 971 memcpy(ISACencUB_obj->SaveEnc_obj.imagFFT, fim,
966 sizeof(ISACencUB_obj->SaveEnc_obj.imagFFT)); 972 sizeof(ISACencUB_obj->SaveEnc_obj.imagFFT));
967 973
968 /* Save the bit-stream object at this point for FEC. */ 974 /* Save the bit-stream object at this point for FEC. */
969 memcpy(&ISACencUB_obj->SaveEnc_obj.bitStreamObj, 975 memcpy(&ISACencUB_obj->SaveEnc_obj.bitStreamObj,
970 &ISACencUB_obj->bitstr_obj, sizeof(Bitstr)); 976 &ISACencUB_obj->bitstr_obj, sizeof(Bitstr));
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 band = (bandwidth == isac12kHz) ? kIsacUpperBand12 : kIsacUpperBand16; 1249 band = (bandwidth == isac12kHz) ? kIsacUpperBand12 : kIsacUpperBand16;
1244 status = WebRtcIsac_EncodeSpec(realFFT, imagFFT, kAveragePitchGain, band, 1250 status = WebRtcIsac_EncodeSpec(realFFT, imagFFT, kAveragePitchGain, band,
1245 bitStreamObj); 1251 bitStreamObj);
1246 if (status < 0) { 1252 if (status < 0) {
1247 return status; 1253 return status;
1248 } else { 1254 } else {
1249 /* Terminate entropy coding */ 1255 /* Terminate entropy coding */
1250 return WebRtcIsac_EncTerminate(bitStreamObj); 1256 return WebRtcIsac_EncTerminate(bitStreamObj);
1251 } 1257 }
1252 } 1258 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698