MCPcopy Create free account
hub / github.com/audeering/opensmile / getMatrix

Method getMatrix

src/core/dataMemoryLevel.cpp:1651–1738  ·  view source on GitHub ↗

TODO: add an optimized 'simple' level for high performance and low overhead wave handling no tmeta, very simple access functions etc. tmeta if accessed will be emulated?

Source from the content-addressed store, hash-verified

1649// no tmeta, very simple access functions etc.
1650// tmeta if accessed will be emulated?
1651cMatrix * cDataMemoryLevel::getMatrix(long vIdx, long vIdxEnd, int special, int rdId, int *result)
1652{
1653 if (!lcfg.finalised) { COMP_ERR("cannot get matrix from non-finalised level! call finalise() first!"); }
1654
1655 long vIdxold=vIdx;
1656// long vIdxEndO = vIdxEnd;
1657 if (vIdx < 0) vIdx = 0;
1658 int padEnd = 0; // will be filled with the number of samples at the end of the matrix to be padded
1659
1660//****** acquire read lock.... *******
1661 smileMutexLock(RWstatMtx);
1662 // check for urgent write request:
1663 while (writeReqFlag) { // wait until write request has been served!
1664 smileMutexUnlock(RWstatMtx);
1665 smileYield();
1666 smileMutexLock(RWstatMtx);
1667 }
1668 if (nCurRdr == 0) {
1669 smileMutexLock(RWmtx); // no other readers, so lock mutex to exclude writes...
1670 }
1671 nCurRdr++;
1672 smileMutexUnlock(RWstatMtx);
1673//****************
1674
1675 smileMutexLock(RWptrMtx);
1676 // TODO : if EOI state, then allow vIdxEnd out of range! pad frame...
1677 long rIdx = validateIdxRangeR(vIdxold, &vIdx, vIdxEnd, special, rdId, 0, &padEnd);
1678 smileMutexUnlock(RWptrMtx);
1679
1680 cMatrix *mat=NULL;
1681 if (rIdx>=0) {
1682 if (vIdxold < 0) mat = new cMatrix(lcfg.N,vIdxEnd-vIdxold);
1683 else mat = new cMatrix(lcfg.N,vIdxEnd-vIdx);
1684 SMILE_DBG(4,"creating new data matrix (%s) vIdxold=%i , vIdx=%i, vIdxEnd=%i, lcfg.N=%i",this->getName(),vIdxold,vIdx,vIdxEnd,lcfg.N)
1685 if (mat == NULL) OUT_OF_MEMORY;
1686 long i,j;
1687 if (vIdxold < 0) {
1688 long i0 = 0-vIdxold;
1689 for (i=0; i<i0; i++) {
1690 if (special == DMEM_PAD_ZERO) for (j=0; j<mat->N; j++) mat->data[i*lcfg.N+j] = 0.0; // pad with value
1691 else frameRd((rIdx)%lcfg.nT, mat->data + (i*lcfg.N)); // fill with first frame
1692 getTimeMeta((rIdx)%lcfg.nT, vIdx + i, mat->tmeta + i);
1693 }
1694 for (i=0; i<vIdxEnd; i++) {
1695 frameRd((rIdx+i)%lcfg.nT, mat->data + (i+i0)*lcfg.N);
1696 getTimeMeta((rIdx+i)%lcfg.nT, vIdx + i + i0, mat->tmeta + i +i0);
1697 }
1698 } else if (padEnd>0) {
1699 for (i=0; i<(vIdxEnd-vIdx)-padEnd; i++) {
1700 frameRd((rIdx+i)%lcfg.nT, mat->data + (i*lcfg.N));
1701 getTimeMeta((rIdx+i)%lcfg.nT, vIdx + i, mat->tmeta + i);
1702 }
1703 long i0 = i-1;
1704 for (; i<(vIdxEnd-vIdx); i++) {
1705 if (special == DMEM_PAD_ZERO) for (j=0; j<mat->N; j++) mat->data[i*lcfg.N+j] = 0.0; // pad with value
1706 else frameRd((rIdx+i0)%lcfg.nT, mat->data + (i*lcfg.N)); // fill with last frame
1707 getTimeMeta((rIdx+i0)%lcfg.nT, vIdx + i, mat->tmeta + i);
1708 }

Callers

nothing calls this directly

Calls 4

getNameMethod · 0.95
smileMutexLockFunction · 0.85
smileMutexUnlockFunction · 0.85
smileYieldFunction · 0.85

Tested by

no test coverage detected