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

Side by Side Diff: webrtc/modules/audio_coding/codecs/isac/fix/source/entropy_coding.c

Issue 1172163004: Reformat existing code. There should be no functional effects. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Resync 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) 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
(...skipping 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 int16_t index[PITCH_SUBFRAMES]; 1668 int16_t index[PITCH_SUBFRAMES];
1669 const int16_t *mean_val2Q10, *mean_val4Q10; 1669 const int16_t *mean_val2Q10, *mean_val4Q10;
1670 1670
1671 const int16_t *lower_limit; 1671 const int16_t *lower_limit;
1672 const uint16_t *init_index; 1672 const uint16_t *init_index;
1673 const uint16_t *cdf_size; 1673 const uint16_t *cdf_size;
1674 const uint16_t **cdf; 1674 const uint16_t **cdf;
1675 1675
1676 int32_t meangainQ12; 1676 int32_t meangainQ12;
1677 int32_t CQ11, CQ10,tmp32a,tmp32b; 1677 int32_t CQ11, CQ10,tmp32a,tmp32b;
1678 int16_t shft,tmp16a,tmp16c; 1678 int16_t shft;
1679 1679
1680 meangainQ12=0; 1680 meangainQ12=0;
1681 for (k = 0; k < 4; k++) 1681 for (k = 0; k < 4; k++)
1682 meangainQ12 += PitchGain_Q12[k]; 1682 meangainQ12 += PitchGain_Q12[k];
1683 1683
1684 meangainQ12 >>= 2; // Get average. 1684 meangainQ12 >>= 2; // Get average.
1685 1685
1686 /* voicing classificiation */ 1686 /* voicing classificiation */
1687 if (meangainQ12 <= 819) { // mean_gain < 0.2 1687 if (meangainQ12 <= 819) { // mean_gain < 0.2
1688 shft = -1; // StepSize=2.0; 1688 shft = -1; // StepSize=2.0;
(...skipping 29 matching lines...) Expand all
1718 err = WebRtcIsacfix_DecHistOneStepMulti(index+1, streamdata, cdf+1, init_index , 3); 1718 err = WebRtcIsacfix_DecHistOneStepMulti(index+1, streamdata, cdf+1, init_index , 3);
1719 if (err<0) // error check 1719 if (err<0) // error check
1720 return -ISAC_RANGE_ERROR_DECODE_PITCH_LAG; 1720 return -ISAC_RANGE_ERROR_DECODE_PITCH_LAG;
1721 1721
1722 1722
1723 /* unquantize back to transform coefficients and do the inverse transform: S = T'*C */ 1723 /* unquantize back to transform coefficients and do the inverse transform: S = T'*C */
1724 CQ11 = ((int32_t)index[0] + lower_limit[0]); // Q0 1724 CQ11 = ((int32_t)index[0] + lower_limit[0]); // Q0
1725 CQ11 = WEBRTC_SPL_SHIFT_W32(CQ11,11-shft); // Scale with StepSize, Q11 1725 CQ11 = WEBRTC_SPL_SHIFT_W32(CQ11,11-shft); // Scale with StepSize, Q11
1726 for (k=0; k<PITCH_SUBFRAMES; k++) { 1726 for (k=0; k<PITCH_SUBFRAMES; k++) {
1727 tmp32a = WEBRTC_SPL_MUL_16_32_RSFT11(WebRtcIsacfix_kTransform[0][k], CQ11); 1727 tmp32a = WEBRTC_SPL_MUL_16_32_RSFT11(WebRtcIsacfix_kTransform[0][k], CQ11);
1728 tmp16a = (int16_t)(tmp32a >> 5); 1728 PitchLags_Q7[k] = (int16_t)(tmp32a >> 5);
1729 PitchLags_Q7[k] = tmp16a;
1730 } 1729 }
1731 1730
1732 CQ10 = mean_val2Q10[index[1]]; 1731 CQ10 = mean_val2Q10[index[1]];
1733 for (k=0; k<PITCH_SUBFRAMES; k++) { 1732 for (k=0; k<PITCH_SUBFRAMES; k++) {
1734 tmp32b = WebRtcIsacfix_kTransform[1][k] * (int16_t)CQ10 >> 10; 1733 tmp32b = WebRtcIsacfix_kTransform[1][k] * (int16_t)CQ10 >> 10;
1735 tmp16c = (int16_t)(tmp32b >> 5); 1734 PitchLags_Q7[k] += (int16_t)(tmp32b >> 5);
1736 PitchLags_Q7[k] += tmp16c;
1737 } 1735 }
1738 1736
1739 CQ10 = mean_val4Q10[index[3]]; 1737 CQ10 = mean_val4Q10[index[3]];
1740 for (k=0; k<PITCH_SUBFRAMES; k++) { 1738 for (k=0; k<PITCH_SUBFRAMES; k++) {
1741 tmp32b = WebRtcIsacfix_kTransform[3][k] * (int16_t)CQ10 >> 10; 1739 tmp32b = WebRtcIsacfix_kTransform[3][k] * (int16_t)CQ10 >> 10;
1742 tmp16c = (int16_t)(tmp32b >> 5); 1740 PitchLags_Q7[k] += (int16_t)(tmp32b >> 5);
1743 PitchLags_Q7[k] += tmp16c;
1744 } 1741 }
1745 1742
1746 return 0; 1743 return 0;
1747 } 1744 }
1748 1745
1749 1746
1750 1747
1751 /* quantize & code Pitch Lags */ 1748 /* quantize & code Pitch Lags */
1752 int WebRtcIsacfix_EncodePitchLag(int16_t* PitchLagsQ7, 1749 int WebRtcIsacfix_EncodePitchLag(int16_t* PitchLagsQ7,
1753 int16_t* PitchGain_Q12, 1750 int16_t* PitchGain_Q12,
1754 Bitstr_enc* streamdata, 1751 Bitstr_enc* streamdata,
1755 IsacSaveEncoderData* encData) { 1752 IsacSaveEncoderData* encData) {
1756 int k, j; 1753 int k, j;
1757 int16_t index[PITCH_SUBFRAMES]; 1754 int16_t index[PITCH_SUBFRAMES];
1758 int32_t meangainQ12, CQ17; 1755 int32_t meangainQ12, CQ17;
1759 int32_t CQ11, CQ10,tmp32a; 1756 int32_t CQ11, CQ10,tmp32a;
1760 1757
1761 const int16_t *mean_val2Q10,*mean_val4Q10; 1758 const int16_t *mean_val2Q10,*mean_val4Q10;
1762 const int16_t *lower_limit, *upper_limit; 1759 const int16_t *lower_limit, *upper_limit;
1763 const uint16_t **cdf; 1760 const uint16_t **cdf;
1764 int16_t shft, tmp16a, tmp16b, tmp16c; 1761 int16_t shft, tmp16b;
1765 int32_t tmp32b; 1762 int32_t tmp32b;
1766 int status = 0; 1763 int status = 0;
1767 1764
1768 /* compute mean pitch gain */ 1765 /* compute mean pitch gain */
1769 meangainQ12=0; 1766 meangainQ12=0;
1770 for (k = 0; k < 4; k++) 1767 for (k = 0; k < 4; k++)
1771 meangainQ12 += PitchGain_Q12[k]; 1768 meangainQ12 += PitchGain_Q12[k];
1772 1769
1773 meangainQ12 >>= 2; 1770 meangainQ12 >>= 2;
1774 1771
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1825 encData->pitchIndex[PITCH_SUBFRAMES*encData->startIdx + k] = index[k]; 1822 encData->pitchIndex[PITCH_SUBFRAMES*encData->startIdx + k] = index[k];
1826 } 1823 }
1827 } 1824 }
1828 1825
1829 /* unquantize back to transform coefficients and do the inverse transform: S = T'*C */ 1826 /* unquantize back to transform coefficients and do the inverse transform: S = T'*C */
1830 CQ11 = (index[0] + lower_limit[0]); // Q0 1827 CQ11 = (index[0] + lower_limit[0]); // Q0
1831 CQ11 = WEBRTC_SPL_SHIFT_W32(CQ11,11-shft); // Scale with StepSize, Q11 1828 CQ11 = WEBRTC_SPL_SHIFT_W32(CQ11,11-shft); // Scale with StepSize, Q11
1832 1829
1833 for (k=0; k<PITCH_SUBFRAMES; k++) { 1830 for (k=0; k<PITCH_SUBFRAMES; k++) {
1834 tmp32a = WEBRTC_SPL_MUL_16_32_RSFT11(WebRtcIsacfix_kTransform[0][k], CQ11); // Q12 1831 tmp32a = WEBRTC_SPL_MUL_16_32_RSFT11(WebRtcIsacfix_kTransform[0][k], CQ11); // Q12
1835 tmp16a = (int16_t)(tmp32a >> 5); // Q7. 1832 PitchLagsQ7[k] = (int16_t)(tmp32a >> 5); // Q7.
1836 PitchLagsQ7[k] = tmp16a;
1837 } 1833 }
1838 1834
1839 CQ10 = mean_val2Q10[index[1]]; 1835 CQ10 = mean_val2Q10[index[1]];
1840 for (k=0; k<PITCH_SUBFRAMES; k++) { 1836 for (k=0; k<PITCH_SUBFRAMES; k++) {
1841 tmp32b = WebRtcIsacfix_kTransform[1][k] * (int16_t)CQ10 >> 10; 1837 tmp32b = WebRtcIsacfix_kTransform[1][k] * (int16_t)CQ10 >> 10;
1842 tmp16c = (int16_t)(tmp32b >> 5); // Q7. 1838 PitchLagsQ7[k] += (int16_t)(tmp32b >> 5); // Q7.
1843 PitchLagsQ7[k] += tmp16c;
1844 } 1839 }
1845 1840
1846 CQ10 = mean_val4Q10[index[3]]; 1841 CQ10 = mean_val4Q10[index[3]];
1847 for (k=0; k<PITCH_SUBFRAMES; k++) { 1842 for (k=0; k<PITCH_SUBFRAMES; k++) {
1848 tmp32b = WebRtcIsacfix_kTransform[3][k] * (int16_t)CQ10 >> 10; 1843 tmp32b = WebRtcIsacfix_kTransform[3][k] * (int16_t)CQ10 >> 10;
1849 tmp16c = (int16_t)(tmp32b >> 5); // Q7. 1844 PitchLagsQ7[k] += (int16_t)(tmp32b >> 5); // Q7.
1850 PitchLagsQ7[k] += tmp16c;
1851 } 1845 }
1852 1846
1853 /* entropy coding of quantization pitch lags */ 1847 /* entropy coding of quantization pitch lags */
1854 status = WebRtcIsacfix_EncHistMulti(streamdata, index, cdf, PITCH_SUBFRAMES); 1848 status = WebRtcIsacfix_EncHistMulti(streamdata, index, cdf, PITCH_SUBFRAMES);
1855 1849
1856 /* If error in WebRtcIsacfix_EncHistMulti(), status will be negative, otherwis e 0 */ 1850 /* If error in WebRtcIsacfix_EncHistMulti(), status will be negative, otherwis e 0 */
1857 return status; 1851 return status;
1858 } 1852 }
1859 1853
1860 1854
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
2031 2025
2032 index_gQQ[k] = pos2QQ + WebRtcIsacfix_kQuantMinGain[k]; //ATTN: ok? 2026 index_gQQ[k] = pos2QQ + WebRtcIsacfix_kQuantMinGain[k]; //ATTN: ok?
2033 if (index_gQQ[k] < 0) { 2027 if (index_gQQ[k] < 0) {
2034 index_gQQ[k] = 0; 2028 index_gQQ[k] = 0;
2035 } 2029 }
2036 else if (index_gQQ[k] > WebRtcIsacfix_kMaxIndGain[k]) { 2030 else if (index_gQQ[k] > WebRtcIsacfix_kMaxIndGain[k]) {
2037 index_gQQ[k] = WebRtcIsacfix_kMaxIndGain[k]; 2031 index_gQQ[k] = WebRtcIsacfix_kMaxIndGain[k];
2038 } 2032 }
2039 } 2033 }
2040 } 2034 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698