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

Side by Side Diff: third_party/opus/src/silk/NLSF_stabilize.c

Issue 2214813002: Opus: Ensure that NLSF cannot be negative when computing a min distance between them (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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) 2006-2011, Skype Limited. All rights reserved. 2 Copyright (c) 2006-2011, Skype Limited. All rights reserved.
3 Redistribution and use in source and binary forms, with or without 3 Redistribution and use in source and binary forms, with or without
4 modification, are permitted provided that the following conditions 4 modification, are permitted provided that the following conditions
5 are met: 5 are met:
6 - Redistributions of source code must retain the above copyright notice, 6 - Redistributions of source code must retain the above copyright notice,
7 this list of conditions and the following disclaimer. 7 this list of conditions and the following disclaimer.
8 - Redistributions in binary form must reproduce the above copyright 8 - Redistributions in binary form must reproduce the above copyright
9 notice, this list of conditions and the following disclaimer in the 9 notice, this list of conditions and the following disclaimer in the
10 documentation and/or other materials provided with the distribution. 10 documentation and/or other materials provided with the distribution.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 /* Insertion sort (fast for already almost sorted arrays): */ 123 /* Insertion sort (fast for already almost sorted arrays): */
124 /* Best case: O(n) for an already sorted array */ 124 /* Best case: O(n) for an already sorted array */
125 /* Worst case: O(n^2) for an inversely sorted array */ 125 /* Worst case: O(n^2) for an inversely sorted array */
126 silk_insertion_sort_increasing_all_values_int16( &NLSF_Q15[0], L ); 126 silk_insertion_sort_increasing_all_values_int16( &NLSF_Q15[0], L );
127 127
128 /* First NLSF should be no less than NDeltaMin[0] */ 128 /* First NLSF should be no less than NDeltaMin[0] */
129 NLSF_Q15[0] = silk_max_int( NLSF_Q15[0], NDeltaMin_Q15[0] ); 129 NLSF_Q15[0] = silk_max_int( NLSF_Q15[0], NDeltaMin_Q15[0] );
130 130
131 /* Keep delta_min distance between the NLSFs */ 131 /* Keep delta_min distance between the NLSFs */
132 for( i = 1; i < L; i++ ) 132 for( i = 1; i < L; i++ )
133 NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], NLSF_Q15[i-1] + NDeltaMin_Q 15[i] ); 133 NLSF_Q15[i] = silk_max_int( NLSF_Q15[i], silk_ADD_SAT16( NLSF_Q15[i- 1], NDeltaMin_Q15[i] ) );
134 134
135 /* Last NLSF should be no higher than 1 - NDeltaMin[L] */ 135 /* Last NLSF should be no higher than 1 - NDeltaMin[L] */
136 NLSF_Q15[L-1] = silk_min_int( NLSF_Q15[L-1], (1<<15) - NDeltaMin_Q15[L] ); 136 NLSF_Q15[L-1] = silk_min_int( NLSF_Q15[L-1], (1<<15) - NDeltaMin_Q15[L] );
137 137
138 /* Keep NDeltaMin distance between the NLSFs */ 138 /* Keep NDeltaMin distance between the NLSFs */
139 for( i = L-2; i >= 0; i-- ) 139 for( i = L-2; i >= 0; i-- )
140 NLSF_Q15[i] = silk_min_int( NLSF_Q15[i], NLSF_Q15[i+1] - NDeltaMin_Q 15[i+1] ); 140 NLSF_Q15[i] = silk_min_int( NLSF_Q15[i], NLSF_Q15[i+1] - NDeltaMin_Q 15[i+1] );
141 } 141 }
142 } 142 }
OLDNEW
« third_party/opus/README.chromium ('K') | « third_party/opus/README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698