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

Side by Side Diff: webrtc/modules/audio_coding/codecs/ilbc/get_sync_seq.c

Issue 1305983003: Convert some more things to size_t. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Fix comment Created 5 years, 3 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) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 /****************************************************************** 11 /******************************************************************
12 12
13 iLBC Speech Coder ANSI-C Source Code 13 iLBC Speech Coder ANSI-C Source Code
14 14
15 WebRtcIlbcfix_GetSyncSeq.c 15 WebRtcIlbcfix_GetSyncSeq.c
16 16
17 ******************************************************************/ 17 ******************************************************************/
18 18
19 #include "defines.h" 19 #include "defines.h"
20 #include "constants.h" 20 #include "constants.h"
21 #include "refiner.h" 21 #include "refiner.h"
22 #include "nearest_neighbor.h" 22 #include "nearest_neighbor.h"
23 23
24 /*----------------------------------------------------------------* 24 /*----------------------------------------------------------------*
25 * get the pitch-synchronous sample sequence 25 * get the pitch-synchronous sample sequence
26 *---------------------------------------------------------------*/ 26 *---------------------------------------------------------------*/
27 27
28 void WebRtcIlbcfix_GetSyncSeq( 28 void WebRtcIlbcfix_GetSyncSeq(
29 int16_t *idata, /* (i) original data */ 29 int16_t *idata, /* (i) original data */
30 int16_t idatal, /* (i) dimension of data */ 30 size_t idatal, /* (i) dimension of data */
31 int16_t centerStartPos, /* (i) where current block starts */ 31 size_t centerStartPos, /* (i) where current block starts */
32 int16_t *period, /* (i) rough-pitch-period array (Q-2) */ 32 size_t *period, /* (i) rough-pitch-period array (Q-2) */
33 int16_t *plocs, /* (i) where periods of period array are taken (Q-2) */ 33 const size_t *plocs, /* (i) where periods of period array are taken (Q-2) */
34 size_t periodl, /* (i) dimension period array */ 34 size_t periodl, /* (i) dimension period array */
35 int16_t hl, /* (i) 2*hl+1 is the number of sequences */ 35 size_t hl, /* (i) 2*hl+1 is the number of sequences */
36 int16_t *surround /* (i/o) The contribution from this sequence 36 int16_t *surround /* (i/o) The contribution from this sequence
37 summed with earlier contributions */ 37 summed with earlier contributions */
38 ){ 38 ){
39 size_t i; 39 size_t i, centerEndPos, q;
40 int16_t centerEndPos,q;
41 /* Stack based */ 40 /* Stack based */
42 int16_t lagBlock[2*ENH_HL+1]; 41 size_t lagBlock[2 * ENH_HL + 1];
43 int16_t blockStartPos[2*ENH_HL+1]; /* Defines the position to search around (Q 2) */ 42 size_t blockStartPos[2 * ENH_HL + 1]; /* The position to search around (Q2) */
44 int16_t plocs2[ENH_PLOCSL]; 43 size_t plocs2[ENH_PLOCSL];
45 44
46 centerEndPos=centerStartPos+ENH_BLOCKL-1; 45 centerEndPos = centerStartPos + ENH_BLOCKL - 1;
47 46
48 /* present (find predicted lag from this position) */ 47 /* present (find predicted lag from this position) */
49 48
50 WebRtcIlbcfix_NearestNeighbor(lagBlock + hl, 49 WebRtcIlbcfix_NearestNeighbor(lagBlock + hl,
51 plocs, 50 plocs,
52 (int16_t)(2 * (centerStartPos + centerEndPos)), 51 2 * (centerStartPos + centerEndPos),
53 periodl); 52 periodl);
54 53
55 blockStartPos[hl] = (int16_t)(4 * centerStartPos); 54 blockStartPos[hl] = 4 * centerStartPos;
56 55
57 /* past (find predicted position and perform a refined 56 /* past (find predicted position and perform a refined
58 search to find the best sequence) */ 57 search to find the best sequence) */
59 58
60 for(q=hl-1;q>=0;q--) { 59 for (q = hl; q > 0; q--) {
61 blockStartPos[q]=blockStartPos[q+1]-period[lagBlock[q+1]]; 60 size_t qq = q - 1;
61 size_t period_q = period[lagBlock[q]];
62 /* Stop if this sequence would be outside the buffer; that means all
63 further-past sequences would also be outside the buffer. */
Peter Kasting 2015/08/27 00:39:02 Because |period| contains only non-negative number
64 if (blockStartPos[q] < period_q + (4 * ENH_OVERHANG))
65 break;
66 blockStartPos[qq] = blockStartPos[q] - period_q;
62 67
63 WebRtcIlbcfix_NearestNeighbor( 68 size_t value = blockStartPos[qq] + 4 * ENH_BLOCKL_HALF;
64 lagBlock + q, 69 value = (value > period_q) ? (value - period_q) : 0;
Peter Kasting 2015/08/27 00:39:02 Previously |value| was just inlined directly into
65 plocs, 70 WebRtcIlbcfix_NearestNeighbor(lagBlock + qq, plocs, value, periodl);
66 (int16_t)(blockStartPos[q] + 4 * ENH_BLOCKL_HALF -
67 period[lagBlock[q + 1]]),
68 periodl);
69 71
70 if (blockStartPos[q] - 4 * ENH_OVERHANG >= 0) { 72 /* Find the best possible sequence in the 4 times upsampled
71 73 domain around blockStartPos+q */
72 /* Find the best possible sequence in the 4 times upsampled 74 WebRtcIlbcfix_Refiner(blockStartPos + qq, idata, idatal, centerStartPos,
73 domain around blockStartPos+q */ 75 blockStartPos[qq], surround,
74 WebRtcIlbcfix_Refiner(blockStartPos+q,idata,idatal, 76 WebRtcIlbcfix_kEnhWt[qq]);
75 centerStartPos,blockStartPos[q],surround,WebRtcIlbcf ix_kEnhWt[q]);
76
77 } else {
78 /* Don't add anything since this sequence would
79 be outside the buffer */
80 }
81 } 77 }
82 78
83 /* future (find predicted position and perform a refined 79 /* future (find predicted position and perform a refined
84 search to find the best sequence) */ 80 search to find the best sequence) */
85 81
86 for(i=0;i<periodl;i++) { 82 for (i = 0; i < periodl; i++) {
87 plocs2[i]=(plocs[i]-period[i]); 83 plocs2[i] = plocs[i] - period[i];
88 } 84 }
89 85
90 for (q = hl + 1; q <= (int16_t)(2 * hl); q++) { 86 for (q = hl + 1; q <= (2 * hl); q++) {
91 87
92 WebRtcIlbcfix_NearestNeighbor( 88 WebRtcIlbcfix_NearestNeighbor(
93 lagBlock + q, 89 lagBlock + q,
94 plocs2, 90 plocs2,
95 (int16_t)(blockStartPos[q - 1] + 4 * ENH_BLOCKL_HALF), 91 blockStartPos[q - 1] + 4 * ENH_BLOCKL_HALF,
96 periodl); 92 periodl);
97 93
98 blockStartPos[q]=blockStartPos[q-1]+period[lagBlock[q]]; 94 blockStartPos[q]=blockStartPos[q-1]+period[lagBlock[q]];
99 95
100 if (blockStartPos[q] + 4 * (ENH_BLOCKL + ENH_OVERHANG) < 4 * idatal) { 96 if (blockStartPos[q] + 4 * (ENH_BLOCKL + ENH_OVERHANG) < 4 * idatal) {
101 97
102 /* Find the best possible sequence in the 4 times upsampled 98 /* Find the best possible sequence in the 4 times upsampled
103 domain around blockStartPos+q */ 99 domain around blockStartPos+q */
104 WebRtcIlbcfix_Refiner(blockStartPos+q, idata, idatal, 100 WebRtcIlbcfix_Refiner(blockStartPos + q, idata, idatal, centerStartPos,
105 centerStartPos,blockStartPos[q],surround,WebRtcIlbcf ix_kEnhWt[2*hl-q]); 101 blockStartPos[q], surround,
102 WebRtcIlbcfix_kEnhWt[2 * hl - q]);
106 103
107 } 104 } else {
108 else {
109 /* Don't add anything since this sequence would 105 /* Don't add anything since this sequence would
110 be outside the buffer */ 106 be outside the buffer */
111 } 107 }
112 } 108 }
113 } 109 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698