summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: bb6acb6)
raw | patch | inline | side by side (parent: bb6acb6)
author | Frank Livingston <frank-livingston@ti.com> | |
Mon, 17 Jul 2017 16:57:16 +0000 (11:57 -0500) | ||
committer | Frank Livingston <frank-livingston@ti.com> | |
Mon, 17 Jul 2017 16:57:16 +0000 (11:57 -0500) |
index 4e18afa79bd58c8590c4cb00ed8ecc79b70550eb..f67bd67f6fb833d513c4e8145dce1640d2d61371 100644 (file)
#define CB_OP_COUNT_MAX 10000
#endif
+// CB control
+#define ASP_DECODE_CB_GATE_NAME ( "AspDecOpCbGate" ) // name of GateMP used for circular buffer shared memory protection
+#define ASP_DECODE_CB_GATE_REGION_ID ( 0 ) // IPC shared region ID used for CB gate allocation
+
// error return codes
#define ASP_DECOP_CB_SOK ( 0 ) // ok
#define ASP_DECOP_CB_CTL_INIT_INV_GATE ( ASP_DECOP_CB_SOK-1 ) // error: invalid gate handle
#define ASP_DECOP_CB_INIT_WRTIDX_THD ( 0 )
#define ASP_DECOP_CB_INIT_RDIDX_THD ( 0 )
//#define ASP_DECOP_CB_INIT_LAG_THD ( 5 ) // 5*20ms = 100 ms, For the worst case of 100 ms
-#define ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD ( 3504 ) //( 2224 ) // THD target Nominal Delay in number of samples, fs=48 kHz
-#define ASP_DECOP_CB_TARGET_ND_SAMPS_96kTHD ( ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD ) // THD target Nominal Delay in number of samples, fs=96 kHz
+#define ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD ( 3600 ) //( 3504 ) //( 2224 ) // THD target Nominal Delay in number of samples, fs=48 kHz
+#define ASP_DECOP_CB_TARGET_ND_SAMPS_96kTHD ( 7200 ) // THD target Nominal Delay in number of samples, fs=96 kHz
#define ASP_DECOP_CB_TARGET_ND_SAMPS_192kTHD ( ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD ) // THD target Nominal Delay in number of samples, fs=192 kHz
-#define ASP_DECODE_CB_GATE_NAME ( "AspDecOpCbGate" ) // name of GateMP used for circular buffer shared memory protection
-#define ASP_DECODE_CB_GATE_REGION_ID ( 0 ) // IPC shared region ID used for CB gate allocation
+//#define DEF_SOURCE_SEL ( PAF_SOURCE_PCM ) // default source select
+//#define DEF_DEC_OP_FRAME_LEN ( PAF_SYS_FRAMELENGTH ) // default decoder output frame length
+//#define DEF_STR_FRAME_LEN ( PAF_SYS_FRAMELENGTH ) // default stream frame length
-#define DEF_SOURCE_SEL ( PAF_SOURCE_PCM ) // default source select
-#define DEF_DEC_OP_FRAME_LEN ( PAF_SYS_FRAMELENGTH ) // default decoder output frame length
-#define DEF_STR_FRAME_LEN ( PAF_SYS_FRAMELENGTH ) // default stream frame length
// Decoder output circular buffer
typedef struct PAF_AST_DecOpCircBuf
diff --git a/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c b/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c
index d864671b1ddce913d41d917f9a0a8a8d8b38d9fb..7965102f01f3edd9bfc49ea0e97afd9c7818a058 100644 (file)
#endif
// debug
-//Int8 gCbInitSourceSelCnt=0;
-//Int8 gCbInitSourceSelThdCnt=0;
+//Int8 gCbInitDecWriteCnt=0;
+//Int8 gCbInitDecWriteThdCnt=0;
-// Initialize circular buffer based on selected source
-Int cbInitSourceSel(
+/// Initialize circular buffer for Decoder writes
+Int cbInitDecWrite(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
Int8 cbIdx, // decoder output circular buffer index
Int8 sourceSelect, // source select (PCM, DDP, etc.)
Int16 decOpFrameLen, // decoder output frame length (PCM samples)
- Int16 strFrameLen, // stream frame length (PCM samples)
Int8 resetRwFlags, // whether to reset reader, writer, and drain flags
PAF_AudioFrame *pDecInitAf // pointer to Dec output audio frame used for CB initialization
)
Int8 n;
Int8 i;
- //gCbInitSourceSelCnt++; // debug
+ //gCbInitDecWriteCnt++; // debug
// Get gate handle
gateHandle = pCbCtl->gateHandle;
Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
- //Log_info1("cbInitSourceSel:afCb=0x%04x", (IArg)pCb->afCb); // debug
+ //Log_info1("cbInitDecWrite:afCb=0x%04x", (IArg)pCb->afCb); // debug
// Set source select
pCb->sourceSel = sourceSelect;
// Set input frame length
pCb->decOpFrameLen = decOpFrameLen;
- // Set output frame length
- pCb->strFrameLen = strFrameLen;
-
//pCb->afInitialLag = 0; // default No lag
//pCb->afLagIdx = 0;
// Initialize CB primed flag
// Calculate number of output frames to block reader.
// This is sample count reader waits before allowed to actually read samples from the CB.
- pCb->deltaSamps = (pCb->targetNDSamps - pAfWrt->sampleCount + (pCb->strFrameLen-1)) / pCb->strFrameLen * pCb->strFrameLen;
+ //pCb->deltaSamps = (pCb->targetNDSamps - pAfWrt->sampleCount + (pCb->strFrameLen-1)) / pCb->strFrameLen * pCb->strFrameLen;
+ // FL: CB read decrements by strFrameLen and tests for >0, so rounding to strFrameLen is unnecessary
+ pCb->deltaSamps = pCb->targetNDSamps - pAfWrt->sampleCount;
// debug
//gSampleCountBuf[gPrimedFlagCnt] = pAfWrt->sampleCount;
}
Cache_wait();
+#if 0 // (***) FL: shows timing of CB write
+ // debug
{
static Uint8 toggleState = 0;
if (toggleState == 0)
GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
toggleState = ~(toggleState);
}
+#endif
+
Log_info3("wrote %d samples into AF %d sourceSel: %d", pAfCb->sampleCount, pCb->afWrtIdx, pCb->sourceSel);
Log_info4("CBWMETA num=%d size=%d offset=%d chrequest=0x%04x", pAfCb->numPrivateMetadata, pAfCb->pafPrivateMetadata[0].size, pAfCb->pafPrivateMetadata[0].offset, pAfCb->channelConfigurationRequest.full);
}
diff --git a/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h b/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h
index c632bb96a13444eca0f95040041ac3494d4723bf..f7db4322b2c344a5b88ea7e5f36ba31abee6412a 100644 (file)
#define ASP_DECOP_CB_INIT_INV_SOURCE_SEL ( ASP_DECOP_CB_ERR_START-1 ) // error: invalid source selection on init
#define ASP_DECOP_CB_WRITE_OVERFLOW ( ASP_DECOP_CB_ERR_START-2 ) // error: write overflow
-// Initialize circular buffer for selected source
-Int cbInitSourceSel(
+#define DEF_DEC_OP_FRAME_LEN ( PAF_SYS_FRAMELENGTH ) // default decoder output frame length
+
+// Initialize circular buffer for Decoder writes
+Int cbInitDecWrite(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
Int8 cbIdx, // decoder output circular buffer index
Int8 sourceSelect, // source select (PCM, DDP, etc.)
Int16 decOpFrameLen, // decoder output frame length (PCM samples)
- Int16 strFrameLen, // stream frame length (PCM samples)
Int8 resetRwFlags, // whether to reset reader, writer, and drain flags
PAF_AudioFrame *pDecInitAf // pointer to Dec output audio frame used for CB initialization
);
- // Start writes to circular buffer
+// Start writes to circular buffer
Int cbWriteStart(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
Int8 cbIdx // decoder output circular buffer index
diff --git a/pasdk/test_arm/framework/audioStreamDecodeProc.c b/pasdk/test_arm/framework/audioStreamDecodeProc.c
index 388cdbc6781aec8964e636b634b6312c788b27d5..fbb796030825ebf16da5eb781670a6cc3df5567b 100644 (file)
// FL: cbInitSourceSel() moved from DSP:ASIT:INIT:decodeInit()
// frameLength: changed to decodeControl.frameLength.
// Written by ASIT:decodeInit:getFrameLengthSourceSel().
- // FRAMELENGTH: pP->frameLength.
- // Formerly ASIT, now ASDT but same value (PAF_SYS_FRAMELENGTH).
- //
- // Initialize decoder output circular buffer for selected source
- errno = cbInitSourceSel(pCbCtl, z, sourceSelect,
+ // Initialize decoder output circular buffer
+ errno = cbInitDecWrite(pCbCtl, z, sourceSelect,
pAstCfg->xDec[z].decodeControl.frameLength,
- FRAMELENGTH, 0, pAfWrt);
+ 0, pAfWrt);
if (errno)
{
SW_BREAKPOINT; // debug
//pCb = &pAstCfg->xDecOpCb[z];
//TRACE_TERSE1("Dec:pCb=0x%04x", (IArg)pCb);
- //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107); // debug
+ //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_99); // debug
cbErrno = cbWriteAf(pCbCtl, z, pAfWrt);
+ //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_99);
if ((cbErrno < 0) && (cbErrno != ASP_DECOP_CB_WRITE_OVERFLOW))
{
gCbWrtAfErrCnt++;
diff --git a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c
index e7349d0546d6fe6027b56aff8cdae955e109d3eb..e19652d08f52e03ae5a471177fc5d443bf6d6e0c 100644 (file)
return ASP_DECOP_CB_SOK;
}
-
#if 0 // FL: moved to ARM
// debug
//Int8 gCbInitSourceSelCnt=0;
}
#endif
+// Initialize circular buffer for Stream reads
+Int cbInitStreamRead(
+ PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
+ Int8 cbIdx, // decoder output circular buffer index
+ Int16 strFrameLen // stream frame length (PCM samples)
+)
+{
+ IArg key;
+ GateMP_Handle gateHandle;
+ PAF_AST_DecOpCircBuf *pCb;
+
+ // Get gate handle
+ gateHandle = pCbCtl->gateHandle;
+ // Enter gate
+ key = GateMP_enter(gateHandle);
+
+ // Get circular buffer base pointer
+ pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]);
+
+ // Invalidate circular buffer configuration
+ Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
+
+ // Set output frame length
+ pCb->strFrameLen = strFrameLen;
+
+ // Write back circular buffer configuration
+ Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
+ Cache_wait();
+
+ // Leave the gate
+ GateMP_leave(gateHandle, key);
+
+ //return ret;
+ return ASP_DECOP_CB_SOK;
+}
+
// Start reads from circular buffer
Int cbReadStart(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
cbReadMuteWithLastAfInfo(pCb, pAfRd);
//SW_BREAKPOINT; // FL: debug
+#if 0 // (***) FL: shows timing of CB underflow
// debug
{
static Uint8 toggleState = 0;
GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
toggleState = ~(toggleState);
}
+#endif
#ifdef CB_RW_OP_CAP_PP // debug
if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
// FL: this update of Last AF is handled above
//memcpy (&pCb->lastAf, pAfRd, sizeof(PAF_AudioFrame));
+#if 0 // (***) FL: shows timing of successful CB read
{
static Uint8 toggleState = 0;
if (toggleState == 0)
GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
toggleState = ~(toggleState);
}
+#endif
}
if (pCb->drainFlag == 1)
diff --git a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h
index 56d15396aa465b5ea229270e2d53b07d9072ccfb..1cc7906270f52074edd4497325cb5d93aa66cf2f 100644 (file)
);
#endif
+// Initialize circular buffer for Stream reads
+Int cbInitStreamRead(
+ PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
+ Int8 cbIdx, // decoder output circular buffer index
+ Int16 strFrameLen // stream frame length (PCM samples)
+);
+
// Start reads from circular buffer
Int cbReadStart(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.c b/pasdk/test_dsp/framework/audioStreamOutProc.c
index 3eb5658f6f564e15cd8d74399320ca5ca1955136..480edc03b841f22c1e9fc2633d156ed2b3af0239 100644 (file)
for (z=DECODE1; z < DECODEN; z++)
{
+ // FRAMELENGTH: pP->frameLength.
+ // Formerly ASIT, now ASOT but same value (PAF_SYS_FRAMELENGTH).
+ //
+
+ // Initialize decoder output circular buffer for stream reads
+ errno = cbInitStreamRead(pCbCtl, z, FRAMELENGTH);
+ if (errno)
+ {
+ TRACE_TERSE1("PAF_ASOT_decodeInit:cbInitStreamRead() error=%d", errno);
+ SW_BREAKPOINT; // debug
+ return errno;
+ }
+
// Start decoder output circular buffer reads
errno = cbReadStart(pCbCtl, z);
if (errno)
SW_BREAKPOINT; // debug
return errno;
}
+
gCbReadAfErr=0; // reset read circular buffer error count
gDecOpCbRdAfUnd=0; // reset decoder output circular buffer underflow count
gMaxDecOpCbRdAfUnd=0; // reset max decoder output circular buffer underflow count
// Read decoder output circular buffer
//
pAfRd = pAstCfg->xStr[zS].pAudioFrame;
- //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106);
+ //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106); // debug
cbErrno = cbReadAf(pCbCtl, z, pAfRd);
+ //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
if ((cbErrno < 0) && (cbErrno != ASP_DECOP_CB_READ_UNDERFLOW))
{
gCbReadAfErr++;
pAstCfg->xOut[z].outBufConfig.lengthofFrame =
pAstCfg->xEnc[zE].encodeInStruct.pAudioFrame->sampleCount;
TRACE_GEN2("PAF_ASOT_decodeEncode: AS%d: processing block %d -- idle", as+zS, block);
+ //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
errno = SIO_reclaim(pAstCfg->xOut[z].hTxSio,(Ptr *) &pAstCfg->xOut[z].pOutBuf, NULL);
+ //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106); // debug
if (errno < 0)
{
SIO_idle(pAstCfg->xOut[z].hTxSio);
if (pAstCfg->xOut[z].hTxSio)
{
TRACE_GEN2("PAF_ASOT_decodeEncode: AS%d: processing block %d -- output", as+zS, block);
+ GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_106); // debug
errno = SIO_issue(pAstCfg->xOut[z].hTxSio,
&pAstCfg->xOut[z].outBufConfig, sizeof (pAstCfg->xOut[z].outBufConfig), 0);
+ GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106);
if (errno)
{
SIO_idle(pAstCfg->xOut[z].hTxSio);
return errno;
} //PAF_ASOT_stopOutput
+UInt32 gNumRateXCalc1=0;
+UInt32 gNumRateXCalc2=0;
+UInt32 gNumDobErrRateChange=0;
+Int gCheck[100];
+float gRateI[100];
+float gRateO[100];
+float gRateX[100];
+
// -----------------------------------------------------------------------------
// ASOT Decoding Function Helper - SIO Driver Change
//{
// return errno;
//}
- outIsCpyAf(pDecInfo1Af, pStrAf);
+ // Hack to set ASOT output frame length.
+ // THD sets this to 256 (hard-coded in Dec Info)
+ // DDP sets this to 0 (audio frame passthrough, 0 from ASDT AF frame length)
+ // PCM sets this to 256 (decodeControl.frameLength)
+ pDecInfo1Af->sampleCount = 256; // !!!! Revisit !!!!
+
+ outIsCpyAf(pDecInfo1Af, pStrAf);
+
+ // Hack to set ASOT output frame length
+ // THD sets this to 256 (hard-coded in Dec Info)
+ // DDP sets this to 0 (audio frame passthrough, 0 from ASDT AF frame length)
+ // PCM sets this to 256 (decodeControl.frameLength)
+ //pStrAf->sampleCount = 256; // !!!! Revisit !!!!
+
// outputInfo1():
// - ASP chain reset,
// - Enc Info
zMD = pAsotCfg->pAstCfg->masterDec; // get master Dec index
// Check circular buffer drain state
+ //GPIOSetOutput(GPIO_PORT_0, GPIO_PIN_107);
errno = cbCheckDrainState(pCbCtl, zMD, &drainedFlag);
+ //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_107);
if (errno < 0)
{
return errno;