Changeset 2192
- Timestamp:
- Aug 4, 2008 4:03:28 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/test/mips_test.c
r2102 r2192 423 423 p = buf+c; 424 424 for (i=0; i<PJ_ARRAY_SIZE(ref_signal); ++i) { 425 *p = ref_signal[i] * pct_level / 100;425 *p = (pj_int16_t)(ref_signal[i] * pct_level / 100); 426 426 p += channel_count; 427 427 } … … 533 533 { 534 534 return init_conf_port(1, pool, clock_rate, channel_count, 535 samples_per_frame, 0, te);535 samples_per_frame, flags, te); 536 536 } 537 537 … … 547 547 { 548 548 return init_conf_port(2, pool, clock_rate, channel_count, 549 samples_per_frame, 0, te);549 samples_per_frame, flags, te); 550 550 } 551 551 … … 560 560 { 561 561 return init_conf_port(4, pool, clock_rate, channel_count, 562 samples_per_frame, 0, te);562 samples_per_frame, flags, te); 563 563 } 564 564 … … 573 573 { 574 574 return init_conf_port(8, pool, clock_rate, channel_count, 575 samples_per_frame, 0, te);575 samples_per_frame, flags, te); 576 576 } 577 577 … … 585 585 struct test_entry *te) 586 586 { 587 PJ_UNUSED_ARG(flags); 587 588 return init_conf_port(16, pool, clock_rate, channel_count, 588 samples_per_frame, 0, te);589 samples_per_frame, flags, te); 589 590 } 590 591 … … 603 604 unsigned opt = 0; 604 605 pj_status_t status; 606 607 PJ_UNUSED_ARG(flags); 608 PJ_UNUSED_ARG(te); 605 609 606 610 if (!high_quality) … … 736 740 pj_status_t status; 737 741 742 PJ_UNUSED_ARG(flags); 743 PJ_UNUSED_ARG(te); 744 738 745 codec_id = pj_str((char*)codec); 739 746 cp = PJ_POOL_ZALLOC_T(pool, struct codec_port); … … 959 966 unsigned opt = 0; 960 967 pj_status_t status; 968 969 PJ_UNUSED_ARG(flags); 970 PJ_UNUSED_ARG(te); 961 971 962 972 wp = PJ_POOL_ZALLOC_T(pool, struct wsola_plc_port); … … 1131 1141 pj_status_t status; 1132 1142 1143 PJ_UNUSED_ARG(flags); 1144 PJ_UNUSED_ARG(te); 1145 1133 1146 wp = PJ_POOL_ZALLOC_T(pool, struct wsola_discard_port); 1134 1147 wp->discard_pct = discard_pct; … … 1250 1263 pjmedia_port *gen_port, *ec_port; 1251 1264 pj_status_t status; 1265 1266 PJ_UNUSED_ARG(flags); 1267 PJ_UNUSED_ARG(te); 1252 1268 1253 1269 gen_port = create_gen_port(pool, clock_rate, channel_count, … … 1389 1405 pj_status_t status; 1390 1406 1407 PJ_UNUSED_ARG(flags); 1408 PJ_UNUSED_ARG(te); 1409 1391 1410 status = pjmedia_tonegen_create(pool, clock_rate, channel_count, 1392 1411 samples_per_frame, 16, … … 1396 1415 1397 1416 pj_bzero(tones, sizeof(tones)); 1398 tones[0].freq1 = freq1;1399 tones[0].freq2 = freq2;1417 tones[0].freq1 = (short)freq1; 1418 tones[0].freq2 = (short)freq2; 1400 1419 tones[0].on_msec = 400; 1401 1420 tones[0].off_msec = 0; 1402 tones[1].freq1 = freq1;1403 tones[1].freq2 = freq2;1421 tones[1].freq1 = (short)freq1; 1422 tones[1].freq2 = (short)freq2; 1404 1423 tones[1].on_msec = 400; 1405 1424 tones[1].off_msec = 100; … … 1484 1503 pjmedia_stream_info si; 1485 1504 pj_status_t status; 1505 1506 PJ_UNUSED_ARG(flags); 1486 1507 1487 1508 codec_id = pj_str((char*)codec); … … 1749 1770 clock_rate, channel_count, 1750 1771 samples_per_frame, flags, te); 1772 } 1773 1774 1775 /***************************************************************************/ 1776 /* Delay buffer */ 1777 enum {DELAY_BUF_MAX_DELAY = 80}; 1778 struct delaybuf_port 1779 { 1780 pjmedia_port base; 1781 pjmedia_delay_buf *delaybuf; 1782 pjmedia_port *gen_port; 1783 int drift_pct; 1784 }; 1785 1786 1787 static pj_status_t delaybuf_get_frame(struct pjmedia_port *this_port, 1788 pjmedia_frame *frame) 1789 { 1790 struct delaybuf_port *dp = (struct delaybuf_port*)this_port; 1791 pj_status_t status; 1792 1793 status = pjmedia_delay_buf_get(dp->delaybuf, (pj_int16_t*)frame->buf); 1794 pj_assert(status == PJ_SUCCESS); 1795 1796 /* Additional GET when drift_pct is negative */ 1797 if (dp->drift_pct < 0) { 1798 int rnd; 1799 rnd = pj_rand() % 100; 1800 1801 if (rnd < -dp->drift_pct) { 1802 status = pjmedia_delay_buf_get(dp->delaybuf, (pj_int16_t*)frame->buf); 1803 pj_assert(status == PJ_SUCCESS); 1804 } 1805 } 1806 1807 return PJ_SUCCESS; 1808 } 1809 1810 static pj_status_t delaybuf_put_frame(struct pjmedia_port *this_port, 1811 const pjmedia_frame *frame) 1812 { 1813 struct delaybuf_port *dp = (struct delaybuf_port*)this_port; 1814 pj_status_t status; 1815 pjmedia_frame f = *frame; 1816 1817 status = pjmedia_port_get_frame(dp->gen_port, &f); 1818 pj_assert(status == PJ_SUCCESS); 1819 status = pjmedia_delay_buf_put(dp->delaybuf, (pj_int16_t*)f.buf); 1820 pj_assert(status == PJ_SUCCESS); 1821 1822 /* Additional PUT when drift_pct is possitive */ 1823 if (dp->drift_pct > 0) { 1824 int rnd; 1825 rnd = pj_rand() % 100; 1826 1827 if (rnd < dp->drift_pct) { 1828 status = pjmedia_port_get_frame(dp->gen_port, &f); 1829 pj_assert(status == PJ_SUCCESS); 1830 status = pjmedia_delay_buf_put(dp->delaybuf, (pj_int16_t*)f.buf); 1831 pj_assert(status == PJ_SUCCESS); 1832 } 1833 } 1834 1835 return PJ_SUCCESS; 1836 } 1837 1838 static pj_status_t delaybuf_on_destroy(struct pjmedia_port *this_port) 1839 { 1840 struct delaybuf_port *dp = (struct delaybuf_port*)this_port; 1841 pjmedia_port_destroy(dp->gen_port); 1842 pjmedia_delay_buf_destroy(dp->delaybuf); 1843 return PJ_SUCCESS; 1844 } 1845 1846 static pjmedia_port* create_delaybuf(int drift_pct, 1847 pj_pool_t *pool, 1848 unsigned clock_rate, 1849 unsigned channel_count, 1850 unsigned samples_per_frame, 1851 unsigned flags, 1852 struct test_entry *te) 1853 { 1854 struct delaybuf_port *dp; 1855 pj_str_t name = pj_str("delaybuf"); 1856 unsigned opt = 0; 1857 pj_status_t status; 1858 1859 PJ_UNUSED_ARG(flags); 1860 PJ_UNUSED_ARG(te); 1861 1862 dp = PJ_POOL_ZALLOC_T(pool, struct delaybuf_port); 1863 dp->drift_pct = drift_pct; 1864 dp->base.get_frame = &delaybuf_get_frame; 1865 dp->base.put_frame = &delaybuf_put_frame; 1866 dp->base.on_destroy = &delaybuf_on_destroy; 1867 pjmedia_port_info_init(&dp->base.info, &name, 0x5678, clock_rate, 1868 channel_count, 16, samples_per_frame); 1869 1870 status = pjmedia_delay_buf_create(pool, "mips_test", clock_rate, 1871 samples_per_frame, channel_count, 1872 DELAY_BUF_MAX_DELAY, 1873 opt, &dp->delaybuf); 1874 if (status != PJ_SUCCESS) 1875 return NULL; 1876 1877 dp->gen_port = create_gen_port(pool, clock_rate, channel_count, 1878 samples_per_frame, 100); 1879 if (dp->gen_port == NULL) 1880 return NULL; 1881 1882 return &dp->base; 1883 } 1884 1885 1886 /* Delay buffer without drift */ 1887 static pjmedia_port* delaybuf_0( pj_pool_t *pool, 1888 unsigned clock_rate, 1889 unsigned channel_count, 1890 unsigned samples_per_frame, 1891 unsigned flags, 1892 struct test_entry *te) 1893 { 1894 return create_delaybuf(0, pool, clock_rate, channel_count, 1895 samples_per_frame, flags, te); 1896 } 1897 1898 1899 /* Delay buffer with 2% drift */ 1900 static pjmedia_port* delaybuf_p2( pj_pool_t *pool, 1901 unsigned clock_rate, 1902 unsigned channel_count, 1903 unsigned samples_per_frame, 1904 unsigned flags, 1905 struct test_entry *te) 1906 { 1907 return create_delaybuf(2, pool, clock_rate, channel_count, 1908 samples_per_frame, flags, te); 1909 } 1910 1911 /* Delay buffer with 5% drift */ 1912 static pjmedia_port* delaybuf_p5( pj_pool_t *pool, 1913 unsigned clock_rate, 1914 unsigned channel_count, 1915 unsigned samples_per_frame, 1916 unsigned flags, 1917 struct test_entry *te) 1918 { 1919 return create_delaybuf(5, pool, clock_rate, channel_count, 1920 samples_per_frame, flags, te); 1921 } 1922 1923 /* Delay buffer with 10% drift */ 1924 static pjmedia_port* delaybuf_p10(pj_pool_t *pool, 1925 unsigned clock_rate, 1926 unsigned channel_count, 1927 unsigned samples_per_frame, 1928 unsigned flags, 1929 struct test_entry *te) 1930 { 1931 return create_delaybuf(10, pool, clock_rate, channel_count, 1932 samples_per_frame, flags, te); 1933 } 1934 1935 /* Delay buffer with 20% drift */ 1936 static pjmedia_port* delaybuf_p20(pj_pool_t *pool, 1937 unsigned clock_rate, 1938 unsigned channel_count, 1939 unsigned samples_per_frame, 1940 unsigned flags, 1941 struct test_entry *te) 1942 { 1943 return create_delaybuf(20, pool, clock_rate, channel_count, 1944 samples_per_frame, flags, te); 1945 } 1946 1947 /* Delay buffer with -2% drift */ 1948 static pjmedia_port* delaybuf_n2( pj_pool_t *pool, 1949 unsigned clock_rate, 1950 unsigned channel_count, 1951 unsigned samples_per_frame, 1952 unsigned flags, 1953 struct test_entry *te) 1954 { 1955 return create_delaybuf(-2, pool, clock_rate, channel_count, 1956 samples_per_frame, flags, te); 1957 } 1958 1959 /* Delay buffer with -5% drift */ 1960 static pjmedia_port* delaybuf_n5( pj_pool_t *pool, 1961 unsigned clock_rate, 1962 unsigned channel_count, 1963 unsigned samples_per_frame, 1964 unsigned flags, 1965 struct test_entry *te) 1966 { 1967 return create_delaybuf(-5, pool, clock_rate, channel_count, 1968 samples_per_frame, flags, te); 1969 } 1970 1971 /* Delay buffer with -10% drift */ 1972 static pjmedia_port* delaybuf_n10(pj_pool_t *pool, 1973 unsigned clock_rate, 1974 unsigned channel_count, 1975 unsigned samples_per_frame, 1976 unsigned flags, 1977 struct test_entry *te) 1978 { 1979 return create_delaybuf(-10, pool, clock_rate, channel_count, 1980 samples_per_frame, flags, te); 1981 } 1982 1983 /* Delay buffer with -20% drift */ 1984 static pjmedia_port* delaybuf_n20(pj_pool_t *pool, 1985 unsigned clock_rate, 1986 unsigned channel_count, 1987 unsigned samples_per_frame, 1988 unsigned flags, 1989 struct test_entry *te) 1990 { 1991 return create_delaybuf(-20, pool, clock_rate, channel_count, 1992 samples_per_frame, flags, te); 1751 1993 } 1752 1994 … … 1869 2111 { "WSOLA discard 20% excess", OP_GET, K8|K16, &wsola_discard_20}, 1870 2112 { "WSOLA discard 50% excess", OP_GET, K8|K16, &wsola_discard_50}, 2113 { "Delay buffer", OP_GET_PUT, K8|K16, &delaybuf_0}, 2114 { "Delay buffer - drift -2%", OP_GET_PUT, K8|K16, &delaybuf_n2}, 2115 { "Delay buffer - drift -5%", OP_GET_PUT, K8|K16, &delaybuf_n5}, 2116 { "Delay buffer - drift -10%", OP_GET_PUT, K8|K16, &delaybuf_n10}, 2117 { "Delay buffer - drift -20%", OP_GET_PUT, K8|K16, &delaybuf_n20}, 2118 { "Delay buffer - drift +2%", OP_GET_PUT, K8|K16, &delaybuf_p2}, 2119 { "Delay buffer - drift +5%", OP_GET_PUT, K8|K16, &delaybuf_p5}, 2120 { "Delay buffer - drift +10%", OP_GET_PUT, K8|K16, &delaybuf_p10}, 2121 { "Delay buffer - drift +20%", OP_GET_PUT, K8|K16, &delaybuf_p20}, 1871 2122 { "echo canceller 100ms tail len", OP_GET_PUT, K8|K16, &ec_create_100}, 1872 2123 { "echo canceller 128ms tail len", OP_GET_PUT, K8|K16, &ec_create_128},
Note: See TracChangeset
for help on using the changeset viewer.