From 9fd3c4d3f86cfc7608c3c6d8557eb2e74f0b76f2 Mon Sep 17 00:00:00 2001 From: Frank Livingston Date: Fri, 21 Jul 2017 21:40:09 -0500 Subject: [PATCH] PASDK-218:Update CB for THD HSR streams - Add PCM over/underflow detection - Increase size of CB PCM buffer using THD HSR "fudge factor". Need to investigate proper worst case sizing of buffer. --- pasdk/common/aspDecOpCircBuf_common.c | 33 ++++++--- pasdk/common/aspDecOpCircBuf_common.h | 31 +++++--- .../framework/aspDecOpCircBuf_slave.c | 72 +++++++++++++------ .../framework/aspDecOpCircBuf_slave.h | 3 +- .../framework/audioStreamDecodeProc.c | 7 +- .../framework/aspDecOpCircBuf_master.c | 17 ++--- .../framework/aspDecOpCircBuf_master.h | 5 +- pasdk/test_dsp/framework/audioStreamInpProc.c | 6 +- pasdk/test_dsp/framework/audioStreamOutProc.c | 30 ++++---- pasdk/test_dsp/framework/itopo/patchs.c | 14 ++-- 10 files changed, 139 insertions(+), 79 deletions(-) diff --git a/pasdk/common/aspDecOpCircBuf_common.c b/pasdk/common/aspDecOpCircBuf_common.c index 50ab1b1f..e0192d0e 100644 --- a/pasdk/common/aspDecOpCircBuf_common.c +++ b/pasdk/common/aspDecOpCircBuf_common.c @@ -137,23 +137,32 @@ Int cbReset( { pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_PCM; pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_PCM; - pCb->pcmRdIdx = 0; - pCb->prvMdRdIdx = 0; } else if (pCb->sourceSel == PAF_SOURCE_DDP) { pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_DDP; pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_DDP; - pCb->pcmRdIdx = 0; - pCb->prvMdRdIdx = 0; } else if (pCb->sourceSel == PAF_SOURCE_THD) { pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_THD; pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_THD; - pCb->pcmRdIdx = 0; - pCb->prvMdRdIdx = 0; } + else + { + // + // Currently unsupported source select + // + return ASP_DECOP_CB_RESET_INV_SOURCE_SEL; + } + + // Reset circular buffer: + // - PCM read index + // - Private metadata read index + // - number of PCM samples in CB + pCb->pcmRdIdx = 0; + pCb->prvMdRdIdx = 0; + pCb->numPcmSampsPerCh = 0; // initialize circular buffer current number of frames pCb->numAfCb = pCb->afWrtIdx - pCb->afRdIdx; @@ -186,8 +195,10 @@ Int cbReset( pCb->readAfNdCnt = 0; pCb->wrtAfReaderInactiveCnt = 0; pCb->wrtAfZeroSampsCnt = 0; - pCb->errUndCnt = 0; - pCb->errOvrCnt = 0; + pCb->errAfUndCnt = 0; + pCb->errAfOvrCnt = 0; + pCb->errPcmUndCnt = 0; + pCb->errPcmOvrCnt = 0; // Write back circular buffer configuration Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); @@ -239,8 +250,10 @@ Int cbGetStats( pCbStats->readAfNdCnt = pCb->readAfNdCnt; pCbStats->wrtAfReaderInactiveCnt = pCb->wrtAfReaderInactiveCnt; pCbStats->wrtAfZeroSampsCnt = pCb->wrtAfZeroSampsCnt; - pCbStats->errUndCnt = pCb->errUndCnt; - pCbStats->errOvrCnt = pCb->errOvrCnt; + pCbStats->errAfUndCnt = pCb->errAfUndCnt; + pCbStats->errAfOvrCnt = pCb->errAfOvrCnt; + pCbStats->errPcmUndCnt = pCb->errPcmUndCnt; + pCbStats->errPcmOvrCnt = pCb->errPcmOvrCnt; // Leave the gate GateMP_leave(gateHandle, key); diff --git a/pasdk/common/aspDecOpCircBuf_common.h b/pasdk/common/aspDecOpCircBuf_common.h index 19b8a6c4..a17aeff6 100644 --- a/pasdk/common/aspDecOpCircBuf_common.h +++ b/pasdk/common/aspDecOpCircBuf_common.h @@ -56,9 +56,10 @@ All rights reserved. #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_ERR_START ( ASP_DECOP_CB_CTL_INIT_INV_GATE ) // start error return ID for master & slave error return definitions +#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_RESET_INV_SOURCE_SEL ( ASP_DECOP_CB_CTL_INIT_INV_GATE - 1 ) // error: invalid source selection on init +#define ASP_DECOP_CB_ERR_START ( ASP_DECOP_CB_RESET_INV_SOURCE_SEL ) // start error return ID for master & slave error return definitions #define ASP_DECOP_CB_MAX_NUM_AF ( 30 ) // decoder output circular buffer maximum number audio frames @@ -72,8 +73,14 @@ All rights reserved. #define ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT ( 32 ) // decoder output circular buffer maximum number audio PCM channels for MAT #define ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT ( 4*256 ) // decoder output circular buffer maximum PCM frame length at 48kHz sampling rate -#define ASP_DECOP_CB_PCM_BUF_SZ ( ASP_DECOP_CB_MAX_NUM_PCM_CH * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN ) -#define ASP_DECOP_CB_PCM_BUF_SZ_32CH48kMAT ( ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT ) +// (***) !!! REVISIT!!! FL: THD 192 kHz "fudge factor" for CB PCM buffer size. +// Using this factor in PCM buffer size definition, buffer large enough to execute 96/192 kHz w/o CB OVR/UND. +// Need to define CB size in different terms than existing macros, e.g. eliminate usage of ASP_DECOP_CB_MAX_NUM_PCM_FRAMES, +// increase size of ASP_DECOP_CB_MAX_PCM_FRAME_LEN for worst case THD decoder output frame size in 20 msec. +#define THD_HSR_FUDGE_FACTOR ( 2 ) +#define ASP_DECOP_CB_PCM_BUF_SZ ( THD_HSR_FUDGE_FACTOR * ASP_DECOP_CB_MAX_NUM_PCM_CH * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN ) +// FL: unused +//#define ASP_DECOP_CB_PCM_BUF_SZ_32CH48kMAT ( ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT * ASP_DECOP_CB_MAX_NUM_PCM_FRAMES * ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT ) #define ASP_DECOP_CB_MAX_NUM_AF_PCM ( 4 ) #if (ASP_DECOP_CB_MAX_NUM_AF_PCM > ASP_DECOP_CB_MAX_NUM_AF) @@ -127,6 +134,8 @@ typedef struct PAF_AST_DecOpCircBuf Int8 prvMdRdIdx; // private metadata read index Int8 numAfCb; // current number frames in CB Int8 maxNumAfCb; // maximum number of audio frames in CB + Int32 numPcmSampsPerCh; // current number of PCM samples per channel in CB + Int32 maxNumPcmSampsPerCh; // max number of PCM samples per channel in CB Int16 decOpFrameLen; // selected decoder output frame length (input transaction size) Int16 strFrameLen; // stream frame length (output transaction size) Int8 writerActiveFlag; // flag indicates whether CB writer is active: FALSE - writer not active, TRUE - writer active @@ -136,8 +145,10 @@ typedef struct PAF_AST_DecOpCircBuf Int32 readAfNdCnt; // count of read audio frames for nominal delay Int32 wrtAfReaderInactiveCnt; // count of write audio frames with inactive reader Int32 wrtAfZeroSampsCnt; // count of write audio frames with zero samples - Int32 errUndCnt; // read error underflow count - Int32 errOvrCnt; // write error overflow count + Int32 errAfUndCnt; // read error AF underflow count + Int32 errAfOvrCnt; // write error AF overflow count + Int32 errPcmUndCnt; // read error PCM underflow count + Int32 errPcmOvrCnt; // write error PCM overflow count PAF_AudioData *pcmBufEnd; // PCM buffer, contains PCM data associated with audio frames end UInt8 *metaBufEnd; // metadata buffer, contains metadata associated with audio frames end Int8 maxAFChanNum; // maximum number of audio data channels in audio frame @@ -160,8 +171,10 @@ typedef struct PAF_AST_DecOpCircBufStats Int32 readAfNdCnt; // count of read audio frames for nominal delay Int32 wrtAfReaderInactiveCnt; // count of write audio frames with inactive reader Int32 wrtAfZeroSampsCnt; // count of write audio frames with zero samples - Int32 errUndCnt; // read error underflow count - Int32 errOvrCnt; // write error overflow count + Int32 errAfUndCnt; // read error AF underflow count + Int32 errAfOvrCnt; // write error AF overflow count + Int32 errPcmUndCnt; // read error PCM underflow count + Int32 errPcmOvrCnt; // write error PCM overflow count } PAF_AST_DecOpCircBufStats; // Decoder output circular buffer control diff --git a/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c b/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c index 7a80156f..e32daef6 100644 --- a/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c +++ b/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c @@ -141,6 +141,7 @@ Int cbInitDecWrite( // - target nominal delay // - AF write, read indices // - maximum AF channel and sample counts + // - maximum number of PCM samples per channel if (sourceSelect == PAF_SOURCE_PCM) { pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_PCM; @@ -150,11 +151,11 @@ Int cbInitDecWrite( pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_PCM; pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_PCM; - pCb->pcmRdIdx = 0; - pCb->prvMdRdIdx = 0; pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH; - pCb->maxAFSampCount = DEF_DEC_OP_FRAME_LEN; + pCb->maxAFSampCount = DEF_DEC_OP_FRAME_LEN; + + pCb->maxNumPcmSampsPerCh = (Int32)(pCb->pcmBufEnd - pCb->pcmBuf)/pCb->maxAFChanNum; } else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3)) { @@ -165,11 +166,11 @@ Int cbInitDecWrite( pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_DDP; pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_DDP; - pCb->pcmRdIdx = 0; - pCb->prvMdRdIdx = 0; pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_DDP; pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDDP; + + pCb->maxNumPcmSampsPerCh = (Int32)(pCb->pcmBufEnd - pCb->pcmBuf)/pCb->maxAFChanNum; } else if (sourceSelect == PAF_SOURCE_THD) { @@ -200,11 +201,11 @@ Int cbInitDecWrite( pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_THD; pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_THD; - pCb->pcmRdIdx = 0; - pCb->prvMdRdIdx = 0; pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT; pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT; + + pCb->maxNumPcmSampsPerCh = (Int32)(pCb->pcmBufEnd - pCb->pcmBuf)/pCb->maxAFChanNum; } else { @@ -219,7 +220,15 @@ Int cbInitDecWrite( return ASP_DECOP_CB_INIT_INV_SOURCE_SEL; } - + + // Initialize circular buffer: + // - PCM read index + // - Private metadata read index + // - number of PCM samples in CB + pCb->pcmRdIdx = 0; + pCb->prvMdRdIdx = 0; + pCb->numPcmSampsPerCh = 0; + // Initialize audio frames for (n = 0; n < pCb->maxNumAfCb; n++) { @@ -290,8 +299,10 @@ Int cbInitDecWrite( pCb->readAfNdCnt = 0; pCb->wrtAfReaderInactiveCnt = 0; pCb->wrtAfZeroSampsCnt = 0; - pCb->errUndCnt = 0; - pCb->errOvrCnt = 0; + pCb->errAfUndCnt = 0; + pCb->errAfOvrCnt = 0; + pCb->errPcmUndCnt = 0; + pCb->errPcmOvrCnt = 0; // Write back circular buffer configuration Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); @@ -431,7 +442,7 @@ Int cbWriteAf( Int8 i; Int16 j; PAF_AudioData *pPcmBuf;UInt8 *pMetaBuf; int nextWrtIdx;PAF_AudioFrame *pAfCbNextAf; - + // Get gate handle gateHandle = pCbCtl->gateHandle; // Enter gate @@ -461,14 +472,13 @@ Int cbWriteAf( { //Log_info2("cbWriteAf:pCb->numAfCb=%d, pCb->maxNumAfCb=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->maxNumAfCb); // debug - // check overflow - //while (pCb->numAfCb >= pCb->maxNumAfCb); // debug + // check AF overflow if (pCb->numAfCb >= pCb->maxNumAfCb) { - pCb->errOvrCnt++; + pCb->errAfOvrCnt++; //SW_BREAKPOINT; - Log_info1("cbWriteAf: ERROR: overflow, numAfCb=%d", pCb->numAfCb); + Log_info1("cbWriteAf: ERROR: AF CB overflow, numAfCb=%d", pCb->numAfCb); // Write back circular buffer configuration Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0); @@ -479,9 +489,27 @@ Int cbWriteAf( //Log_info2("cbWriteAf:gate leave, gateHandle=0x%04x, key=%d", (IArg)gateHandle, (IArg)key); // debug - return ASP_DECOP_CB_WRITE_OVERFLOW; + return ASP_DECOP_CB_AF_WRITE_OVERFLOW; } + + // check PCM overflow + if ((pCb->numPcmSampsPerCh + pAfWrt->sampleCount) > pCb->maxNumPcmSampsPerCh) + { + pCb->errPcmOvrCnt++; + Log_info3("cbWriteAf: ERROR: PCM CB overflow, sampleCount=%d, numPcmSampsPerCh=%d, maxNumPcmSampsPerCh=%d", + pCb->numPcmSampsPerCh, pAfWrt->sampleCount, pCb->maxNumPcmSampsPerCh); + + // 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 ASP_DECOP_CB_PCM_WRITE_OVERFLOW; + } + pAfCb = &pCb->afCb[pCb->afWrtIdx]; pPcmBuf = pAfCb->data.sample[0]; pMetaBuf = pAfCb->pafPrivateMetadata[0].pMdBuf; @@ -489,7 +517,7 @@ Int cbWriteAf( { pPcmBuf = pCb->pcmBuf; } - + for (i=0; imaxAFChanNum; i++) { pAfCb->data.sample[i] = pPcmBuf; @@ -499,8 +527,7 @@ Int cbWriteAf( Cache_inv(pAfCb->data.sample, pCb->maxAFChanNum*sizeof(PAF_AudioData *), Cache_Type_ALLD, 0); // FL: this is write back and invalidate?? Cache_wait(); - //for (i=0; imaxAFChanNum; i++){ - //} + // FL: brute force reset of all metadata in CB AF? for (i=0; ipafPrivateMetadata[i].offset = 0; @@ -510,7 +537,7 @@ Int cbWriteAf( } nextWrtIdx = 0; - if ((pCb->afWrtIdx +1) >= pCb->maxNumAfCb) + if ((pCb->afWrtIdx + 1) >= pCb->maxNumAfCb) { //Log_info0("cbWriteAf: AF Wrap around **** "); // next audio frame will be audio frame 0 @@ -551,7 +578,10 @@ Int cbWriteAf( pAfCb->data.samsiz[i] = pAfWrt->data.samsiz[i]; } } - + + // Update PCM samples per channel + pCb->numPcmSampsPerCh += pAfWrt->sampleCount; + #ifdef CB_RW_OP_CAP_PP // debug if (pCb->cb_opCnt < CB_OP_COUNT_MAX) { diff --git a/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h b/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h index f7db4322..57883a43 100644 --- a/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h +++ b/pasdk/test_arm/framework/aspDecOpCircBuf_slave.h @@ -41,7 +41,8 @@ All rights reserved. #include "aspDecOpCircBuf_common.h" #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 +#define ASP_DECOP_CB_AF_WRITE_OVERFLOW ( ASP_DECOP_CB_ERR_START-2 ) // error: write audio frame overflow +#define ASP_DECOP_CB_PCM_WRITE_OVERFLOW ( ASP_DECOP_CB_ERR_START-3 ) // error: write PCM overflow #define DEF_DEC_OP_FRAME_LEN ( PAF_SYS_FRAMELENGTH ) // default decoder output frame length diff --git a/pasdk/test_arm/framework/audioStreamDecodeProc.c b/pasdk/test_arm/framework/audioStreamDecodeProc.c index 66c3af63..1c71f193 100644 --- a/pasdk/test_arm/framework/audioStreamDecodeProc.c +++ b/pasdk/test_arm/framework/audioStreamDecodeProc.c @@ -834,14 +834,17 @@ Void taskAsdpFxn( //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)) + if ((cbErrno < 0) && + (cbErrno != ASP_DECOP_CB_AF_WRITE_OVERFLOW) && + (cbErrno != ASP_DECOP_CB_PCM_WRITE_OVERFLOW)) { gCbWrtAfErrCnt++; //SW_BREAKPOINT; // debug } // Handle circular buffer overflows - if (cbErrno == ASP_DECOP_CB_WRITE_OVERFLOW) + if ((cbErrno == ASP_DECOP_CB_AF_WRITE_OVERFLOW) || + (cbErrno == ASP_DECOP_CB_PCM_WRITE_OVERFLOW)) { gDecOpCbWrtAfOvr++; // increment circular buffer overflow count if (gDecOpCbWrtAfOvr >= DEC_OP_CB_WRTAF_OVR_THR) diff --git a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c index af544e00..25224c14 100644 --- a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c +++ b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c @@ -780,7 +780,7 @@ Int cbReadAf( // // Increment underflow count // - pCb->errUndCnt++; + pCb->errAfUndCnt++; // Mute output on underflow //cbReadAfMute(pAfRd, pCb->strFrameLen); @@ -823,7 +823,7 @@ Int cbReadAf( // Leave the gate GateMP_leave(gateHandle, key); - return ASP_DECOP_CB_READ_UNDERFLOW; + return ASP_DECOP_CB_AF_READ_UNDERFLOW; } } @@ -854,13 +854,6 @@ Int cbReadAf( // interpolation change in in bit-stream metadata type, or CC stream? // - // debug - //gCbReadAfCnt++; - //if (gCbReadAfCnt == 1404) - //{ - // Log_info1("cbReadAf: gCbReadAfCnt=%d", gCbReadAfCnt); // debug - //} - // Get pointer to current CB Audio Frame pAfCb = &pCb->afCb[pCb->afRdIdx]; @@ -1031,6 +1024,8 @@ Int cbReadAf( pAfRd->sampleCount = totNumSampsRd; // write Read AF sample count pAfRd->numPrivateMetadata = prvMdWrtIdx; // write Read AF number of metadata + + pCb->numPcmSampsPerCh -= totNumSampsRd; // update PCM samples per channel if (totNumSampsRd < pCb->strFrameLen) { @@ -1053,7 +1048,7 @@ Int cbReadAf( // // Increment underflow count // - pCb->errUndCnt++; + pCb->errPcmUndCnt++; // Mute output on underflow cbReadMuteWithLastAfInfo(pCb, pAfRd); @@ -1094,7 +1089,7 @@ Int cbReadAf( // Leave the gate GateMP_leave(gateHandle, key); - return ASP_DECOP_CB_READ_UNDERFLOW; + return ASP_DECOP_CB_PCM_READ_UNDERFLOW; } } diff --git a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h index e74dbf08..b3c5e79f 100644 --- a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h +++ b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h @@ -40,8 +40,9 @@ All rights reserved. #include "paftyp.h" #include "aspDecOpCircBuf_common.h" -#define ASP_DECOP_CB_READ_UNDERFLOW ( ASP_DECOP_CB_ERR_START-1 ) // error: read underflow -#define ASP_DECOP_CB_READ_INVSTATE ( ASP_DECOP_CB_ERR_START-2 ) // error: circular buffer invalid state on read +#define ASP_DECOP_CB_AF_READ_UNDERFLOW ( ASP_DECOP_CB_ERR_START-1 ) // error: read AF underflow +#define ASP_DECOP_CB_PCM_READ_UNDERFLOW ( ASP_DECOP_CB_ERR_START-2 ) // error: read PCM underflow +#define ASP_DECOP_CB_READ_INVSTATE ( ASP_DECOP_CB_ERR_START-3 ) // error: circular buffer invalid state on read #define ASP_DECOP_CHECK_DRAINSTATE_ALL ( -1 ) // check circular buffer combined drain state diff --git a/pasdk/test_dsp/framework/audioStreamInpProc.c b/pasdk/test_dsp/framework/audioStreamInpProc.c index dabd0ed8..7a30dfed 100644 --- a/pasdk/test_dsp/framework/audioStreamInpProc.c +++ b/pasdk/test_dsp/framework/audioStreamInpProc.c @@ -3028,9 +3028,9 @@ PAF_ASIT_decodeInfo( return ASPERR_RECLAIM; } - // FL: debug, capture input buffer - capIb(pAstCfg->xInp[zMI].pInpBuf); - gCapIb_cnt++; + //// FL: debug, capture input buffer + //capIb(pAstCfg->xInp[zMI].pInpBuf); + //gCapIb_cnt++; #if 0 // (***) FL: shows timing of Input Rx SIO reclaim after decoding has started (autodet complete) // (***) debug // B5 diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.c b/pasdk/test_dsp/framework/audioStreamOutProc.c index 43784ca5..0aa46a6f 100644 --- a/pasdk/test_dsp/framework/audioStreamOutProc.c +++ b/pasdk/test_dsp/framework/audioStreamOutProc.c @@ -67,6 +67,7 @@ Int32 gNumPfpAsot1=0; // debug // FL: debug #include "evmc66x_gpio_dbg.h" +#include "dbgCapAf.h" #define TRACE_TIME(a) @@ -2325,23 +2326,22 @@ PAF_ASOT_decodeStream( //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)) + if ((cbErrno < 0) && + (cbErrno != ASP_DECOP_CB_AF_READ_UNDERFLOW) && + (cbErrno != ASP_DECOP_CB_PCM_READ_UNDERFLOW)) { gCbReadAfErr++; TRACE_TERSE1("PAF_ASOT_decodeStream:cbReadAf() error=%d", cbErrno); - //SW_BREAKPOINT; // FL: debug + //SW_BREAKPOINT; // debug return cbErrno; } // Handle underflows - if (cbErrno == ASP_DECOP_CB_READ_UNDERFLOW) + if ((cbErrno == ASP_DECOP_CB_AF_READ_UNDERFLOW) || + (cbErrno == ASP_DECOP_CB_PCM_READ_UNDERFLOW)) { - // FL: some number of underflows alway occur on start of stream when ASOT only depends on configured Output. - // DDP: ~2 underflows - // MAT-THD: ~16 underflows - // Need to check behavior of cbReset(). + // (***) FL: Need to check behavior of cbReset(). // Need to check behavior on exit/re-entry into Output processing. - gDecOpCbRdAfUnd++; // increment circular buffer underflow count if (gDecOpCbRdAfUnd >= DEC_OP_CB_RDAF_UND_THR) { @@ -2395,9 +2395,9 @@ PAF_ASOT_decodeStream( //cbGetStats(pCbCtl, z, &cbStats); cbGetStats(pCbCtl, z, &gCbStats); - // FL: debug + // debug cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeStream:cbReadAf"); - //if (capAfWrite(pAfRd, 0) != CAP_AF_SOK) + //if (capAfWrite(pAfRd, PAF_LEFT) != CAP_AF_SOK) //{ // Log_info0("capAfWrite() error"); //} @@ -2599,10 +2599,10 @@ PAF_ASOT_decodeEncode( 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 + //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); + //GPIOClearOutput(GPIO_PORT_0, GPIO_PIN_106); if (errno) { SIO_idle(pAstCfg->xOut[z].hTxSio); @@ -3429,6 +3429,9 @@ static Int PAF_ASOT_outputReset( return ASOP_SOK; } +// FL: debug, allow modification of output frame length via JTAG +Int16 gOutFrameLen=DEF_STR_FRAME_LEN; // stream frame length (PCM samples) + // Purpose: Init-Sync Dec Info1 state function. // Performes Dec Info1 Init-Sync. static Int PAF_ASOT_initSyncDecInfo1( @@ -3480,7 +3483,8 @@ static Int PAF_ASOT_initSyncDecInfo1( // 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; // !!!! GJ: Revisit !!!! + //pDecInfo1Af->sampleCount = 256; // !!!! GJ: Revisit !!!! + pDecInfo1Af->sampleCount = gOutFrameLen; outIsCpyAf(pDecInfo1Af, pStrAf); diff --git a/pasdk/test_dsp/framework/itopo/patchs.c b/pasdk/test_dsp/framework/itopo/patchs.c index d540eb21..4887b32b 100644 --- a/pasdk/test_dsp/framework/itopo/patchs.c +++ b/pasdk/test_dsp/framework/itopo/patchs.c @@ -53,13 +53,13 @@ All rights reserved. // NOT performing PCM high-sampling rate + SRC + CAR benchmarking // -//#define _AE0_ -//#define _SRC4_ -#define _CAR_ -#define _OAR_ -//#define _DAP_ -#define _BMDA_ -//#define _ML0_ +////#define _AE0_ +#define _SRC4_ +//#define _CAR_ +//#define _OAR_ +////#define _DAP_ +//#define _BMDA_ +////#define _ML0_ #else // _ENABLE_BENCHMARK_PCMHSR_SRC_CAR_ // -- 2.39.2