summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 93fb949)
raw | patch | inline | side by side (parent: 93fb949)
author | Frank Livingston <frank-livingston@ti.com> | |
Fri, 2 Jun 2017 00:15:44 +0000 (19:15 -0500) | ||
committer | Frank Livingston <frank-livingston@ti.com> | |
Fri, 2 Jun 2017 00:15:44 +0000 (19:15 -0500) |
index 85ab8a73a5e4f0ad67c121b5f0ede61fa427d576..9f289379a4bd92d68fe4a6d5ed28e614e2e7fed1 100644 (file)
#include "paftyp.h"
#include "pafdec.h"
-//#define CB_RW_OP_CAP_PP
-
+#define CB_RW_OP_CAP_PP // debug
#ifdef CB_RW_OP_CAP_PP
#define CB_OP_NONE 0
#define CB_OP_W 1 // ARM write
#define CB_OP_COUNT_MAX 10000
#endif
-#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 )
-#define ASP_DECOP_CB_MAX_NUM_AF ( 15 ) // decoder output circular buffer maximum number audio frames
-#define ASP_DECOP_CB_MAX_NUM_PCM_CH ( 16 ) // decoder output circular buffer maximum number audio PCM channels
-#define ASP_DECOP_CB_MAX_NUM_PCM_FRAMES ( 15 ) // decoder output circular buffer maximum number PCM frames //Qin - Increased to prevent cb overflow for ddp.
-#define ASP_DECOP_CB_MAX_PCM_FRAME_LEN ( 6*256 ) // decoder output circular buffer maximum PCM frame length
+// 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_MAX_NUM_AF ( 15 ) // decoder output circular buffer maximum number audio frames
+#define ASP_DECOP_CB_MAX_NUM_PCM_CH ( 16 ) // decoder output circular buffer maximum number audio PCM channels
+#define ASP_DECOP_CB_MAX_NUM_PCM_FRAMES ( 15 ) // decoder output circular buffer maximum number PCM frames //Qin - Increased to prevent cb overflow for ddp.
+#define ASP_DECOP_CB_MAX_PCM_FRAME_LEN ( 6*256 ) // decoder output circular buffer maximum PCM frame length
+
+#define ASP_DECOP_CB_MAX_NUM_PCM_CH_DDP ( 16 ) // decoder output circular buffer maximum number audio PCM channels for DDP
+#define ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDDP ( 6*256 ) // decoder output circular buffer maximum PCM frame length at 48kHz sampling rate
-#define ASP_DECOP_CB_MAX_NUM_PCM_CH_DDP ( 16 ) // decoder output circular buffer maximum number audio PCM channels for DDP
-#define ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDDP ( 6*256 ) // decoder output circular buffer maximum PCM frame length at 48kHz sampling rate
+#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_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 )
-#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 )
+#define ASP_DECOP_CB_MAX_NUM_AF_PCM ( 4 )
+#define ASP_DECOP_CB_INIT_WRTIDX_PCM ( 0 )
+#define ASP_DECOP_CB_INIT_RDIDX_PCM ( 0 )
+#define ASP_DECOP_CB_INIT_LAG_PCM ( 2 )
+#define ASP_DECOP_CB_TARGET_ND_SAMPS_48kPCM ( ASP_DECOP_CB_INIT_LAG_PCM * 256 ) // PCM target Nominal Delay in number of samples, fs=48 kHz
-#define ASP_DECOP_CB_MAX_NUM_AF_PCM ( 4 )
-#define ASP_DECOP_CB_INIT_LAG_PCM ( 2 ) // 1...3
-#define ASP_DECOP_CB_INIT_WRTIDX_PCM ( 0 )
-#define ASP_DECOP_CB_INIT_RDIDX_PCM ( 0 )
+#define ASP_DECOP_CB_MAX_NUM_AF_DDP ( 2 )
+#define ASP_DECOP_CB_INIT_WRTIDX_DDP ( 0 )
+#define ASP_DECOP_CB_INIT_RDIDX_DDP ( 0 )
+#define ASP_DECOP_CB_INIT_LAG_DDP ( 1 )
+#define ASP_DECOP_CB_TARGET_ND_SAMPS_48kDDP ( ASP_DECOP_CB_INIT_LAG_DDP * 1536 ) // DDP target Nominal Delay in number of samples, fs=48 kHz
-#define ASP_DECOP_CB_MAX_NUM_AF_DDP ( 2 )
-#define ASP_DECOP_CB_INIT_LAG_DDP ( 1 ) // 0...5
-#define ASP_DECOP_CB_INIT_WRTIDX_DDP ( 0 )
-#define ASP_DECOP_CB_INIT_RDIDX_DDP ( 0 )
+#define ASP_DECOP_CB_MAX_NUM_AF_THD ( 15 )
+#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 ( 2224 ) // THD target Nominal Delay in number of samples, fs=48 kHz
-#define ASP_DECOP_CB_MAX_NUM_AF_THD ( 15 )
-#define ASP_DECOP_CB_INIT_LAG_THD ( 5 ) // 5*20ms = 100 ms, For the worst case of 100 ms
-#define ASP_DECOP_CB_INIT_WRTIDX_THD ( 0 ) //ASP_DECOP_CB_INIT_LAG_THD )
-#define ASP_DECOP_CB_INIT_RDIDX_THD ( 0 )
-#define ASP_DECODE_CB_GATE_NAME ( "AspDecOpCbGate" )
-#define ASP_DECODE_CB_GATE_REGION_ID ( 0 )
+#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
// Decoder output circular buffer
PAF_AudioData *pcmBuf; // PCM buffer, contains PCM data associated with audio frames
UInt8 *metaBuf; // metadata buffer, contains metadata associated with audio frames
Int8 sourceSel; // selected source
+ Int8 primedFlag; // flag indicated whether CB is primed: FALSE - CB not primed, TRUE - CB primed
+ Int16 targetNDSamps; // target CB Nominal Delay number of samples
+ Int16 deltaSamps; // number of 256 (N) sample output frames to block reader
Int8 afRdIdx; // audio frame CB read index
Int8 afWrtIdx; // audio frame CB write index
- Int8 afLagIdx; // audio frame CB Lag idx,
- Int8 afInitialLag; // Initial delay/lag between CB write and read
+ //Int8 afLagIdx; // audio frame CB Lag idx,
+ //Int8 afInitialLag; // Initial delay/lag between CB write and read
Int16 pcmRdIdx; // pcm buffer read index
Int8 numAfCb; // current number frames in CB
Int8 maxNumAfCb; // maximum number of audio frames 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
- Int8 readerActiveFlag; // flag indicates whether CB reader is active
- Int8 emptyFlag; // flag indicates whether reader should empty (drain) remaining frames in CB
+ Int8 writerActiveFlag; // flag indicates whether CB writer is active: FALSE - writer not active, TRUE - writer active
+ Int8 readerActiveFlag; // flag indicates whether CB reader is active: FALSE - reader not active, TRUE - reader active
+ Int8 emptyFlag; // flag indicates whether reader should empty (drain) remaining frames in CB: FALSE - reader should not drain, TRUE - reader should drain
Int8 errUndCnt; // underflow count
Int8 errOvrCnt; // overflow count
PAF_AudioData *pcmBufEnd; // PCM buffer, contains PCM data associated with audio frames end
Int8 maxAFChanNum; // maximum number of audio data channels in audio frame
Int16 maxAFSampCount; // maximum number of sample counts in audio frame
PAF_AudioFrame lastAf; // used to store the last valid read out audio frame info to generate mute frame
- #ifdef CB_RW_OP_CAP_PP
+ #ifdef CB_RW_OP_CAP_PP // debug
UInt32 *cb_samples_op; // should be in shared memory, preferred NON cache
UInt8 *cb_op_owner; // should be in shared memory, preferred NON cache
UInt8 *cb_afRdIdx; // should be in shared memory, preferred NON cache
diff --git a/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c b/pasdk/test_arm/framework/aspDecOpCircBuf_slave.c
index 8ea3696703fd05a6decb2c16b6c1c9514559642e..6a3bc915072fefdd40faec894d75d8887d2dd5d2 100644 (file)
//#include "pafsp.h"
#include "aspDecOpCircBuf_slave.h"
+#include "evmc66x_gpio_dbg.h" // Debug
+
// Initialize circular buffer control
Int cbCtlInit(
PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
// Get circular buffer base pointer
pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]);
- // (***) FL: revisit
// Invalidate circular buffer configuration.
// NOTE: Probably only a subset of this information needs to be updated.
Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
- //Log_info1("cbWriteStart:afCb=0x%04x", (IArg)pCb->afCb); // FL: debug
+ //Log_info1("cbWriteStart:afCb=0x%04x", (IArg)pCb->afCb); // debug
// Invalidate AF circular buffer
Cache_inv(pCb->afCb, pCb->maxNumAfCb*sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
// update flags
pCb->writerActiveFlag = 1;
pCb->emptyFlag = 0;
- pCb->afLagIdx = 0;
+ //pCb->afLagIdx = 0;
- // (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
- //Log_info1("cbWriteStop:afCb=0x%04x", (IArg)pCb->afCb); // FL: debug
+ //Log_info1("cbWriteStop:afCb=0x%04x", (IArg)pCb->afCb); // debug
// update flags
pCb->writerActiveFlag = 0;
pCb->emptyFlag = 1;
- // (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
// Enter gate
key = GateMP_enter(gateHandle);
- //Log_info2("cbWriteAf:gate enter, gateHandle=0x%04x, key=%d", (IArg)gateHandle, (IArg)key); // FL: debug
+ //Log_info2("cbWriteAf:gate enter, gateHandle=0x%04x, key=%d", (IArg)gateHandle, (IArg)key); // debug
// Get circular buffer base pointer
pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]);
- //Log_info1("cbWriteAf:pCb=0x%04x", (IArg)pCb); // FL: debug
+ //Log_info1("cbWriteAf:pCb=0x%04x", (IArg)pCb); // debug
- // (***) FL: revisit
// Invalidate circular buffer configuration.
- // NOTE: Probably only a subset of this information nexeds to be updated.
+ // NOTE: Probably only a subset of this information needs to be updated.
Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
- //Log_info1("cbWriteAf:afCb=0x%04x", (IArg)pCb->afCb); // FL: debug
- //Log_info2("cbWriteAf:pCb->readerActiveFlag=%d, pCb->writerActiveFlag=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->writerActiveFlag); // FL: debug
+ //Log_info1("cbWriteAf:afCb=0x%04x", (IArg)pCb->afCb); // debug
+ //Log_info2("cbWriteAf:pCb->readerActiveFlag=%d, pCb->writerActiveFlag=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->writerActiveFlag); // debug
if ((pCb->readerActiveFlag == 1) && (pAfWrt->sampleCount)) //QIN ?
{
//Log_info2("cbWriteAf:pCb->numAfCb=%d, pCb->maxNumAfCb=%d", (IArg)pCb->readerActiveFlag, (IArg)pCb->maxNumAfCb); // FL: debug
// check overflow
- //while (pCb->numAfCb >= pCb->maxNumAfCb); // FL: debug
+ //while (pCb->numAfCb >= pCb->maxNumAfCb); // debug
if (pCb->numAfCb >= pCb->maxNumAfCb)
{
pCb->errOvrCnt++;
for (i=0; i<pCb->maxAFChanNum; i++)
{
-
pAfCb->data.sample[i] = pPcmBuf;
pPcmBuf += pAfWrt->sampleCount;
pAfCb->data.samsiz[i] = 0;
}
- Cache_inv(pAfCb->data.sample, pCb->maxAFChanNum*sizeof(PAF_AudioData *), Cache_Type_ALLD, 0);
+ 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; i<pCb->maxAFChanNum; i++){
if ((pCb->afWrtIdx +1) >= pCb->maxNumAfCb)
{
//Log_info0("cbWriteAf: AF Wrap around **** ");
+ // next audio frame will be audio frame 0
nextWrtIdx = 0;
}else{
+ // next audio frame will be current audio frame + 1
nextWrtIdx = pCb->afWrtIdx + 1;
}
pAfCb->sampleCount = pAfWrt->sampleCount;
pAfCb->channelConfigurationRequest = pAfWrt->channelConfigurationRequest;
pAfCb->channelConfigurationStream = pAfWrt->channelConfigurationStream;
- // write metadata information updated by decoder //QIN
+ // write metadata information updated by decoder
pAfCb->bsMetadata_type = pAfWrt->bsMetadata_type; /* non zero if metadata is attached. */
pAfCb->pafBsMetadataUpdate = pAfWrt->pafBsMetadataUpdate; /* indicates whether bit-stream metadata update */
pAfCb->numPrivateMetadata = pAfWrt->numPrivateMetadata; /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
pAfCb->bsMetadata_offset = pAfWrt->bsMetadata_offset; /* offset into audio frame for change in bsMetadata_type field */
// write PCM samples
streamMask = pAfWrt->fxns->channelMask(pAfWrt, pAfCb->channelConfigurationStream);
-
for (i = 0; i < pCb->maxAFChanNum; i++)
{
if ((streamMask >> i) & 0x1)
}
}
- #ifdef CB_RW_OP_CAP_PP
+ #ifdef CB_RW_OP_CAP_PP // debug
if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
{
if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
}
// Write metadata to circular buffer
- for (i = 0; i < pAfWrt->numPrivateMetadata; i++) // FL: only copy numPrivateMetadata
+ for (i = 0; i < pAfWrt->numPrivateMetadata; i++) // only copy numPrivateMetadata
{
pAfCb->pafPrivateMetadata[i].offset = pAfWrt->pafPrivateMetadata[i].offset;
pAfCb->pafPrivateMetadata[i].size = pAfWrt->pafPrivateMetadata[i].size;
memcpy(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfWrt->pafPrivateMetadata[i].pMdBuf, pAfWrt->pafPrivateMetadata[i].size);
}
- Cache_inv(pAfCb->pafPrivateMetadata, pAfWrt->numPrivateMetadata*sizeof(PAF_PrivateMetadata *), Cache_Type_ALLD, 0);
+ Cache_inv(pAfCb->pafPrivateMetadata, pAfWrt->numPrivateMetadata*sizeof(PAF_PrivateMetadata *), Cache_Type_ALLD, 0); // FL: this is write back and invalidate??
Cache_wait();
- for (i=0; i<pAfCb->numPrivateMetadata; i++) // FL: only write back numPrivateMetadata
+ for (i=0; i<pAfCb->numPrivateMetadata; i++) // only write back numPrivateMetadata
{
//Log_info4("cbWriteAf: AF: %d nummd: %d offset: %d size: %d ", pCb->afWrtIdx, pAfCb->numPrivateMetadata, pAfCb->pafPrivateMetadata[i].offset, pAfCb->pafPrivateMetadata[i].size);
Cache_wb(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfCb->pafPrivateMetadata[i].size, Cache_Type_ALLD, 0);
Cache_wait();
// update number of audio frames in circular buffer
pCb->numAfCb++;
+
// Update CB Lag index
- if (pCb->afLagIdx < pCb->afInitialLag)
+ //if (pCb->afLagIdx < pCb->afInitialLag)
+ //{
+ // pCb->afLagIdx += 1;
+ //}
+
+ // Update CB primed flag
+ // calculate number of delta samples before
+ if (pCb->primedFlag == 0)
{
- pCb->afLagIdx += 1;
+ pCb->primedFlag = 1;
+
+ // 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;
}
-
// (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
diff --git a/pasdk/test_arm/framework/audioStreamDecodeProc.c b/pasdk/test_arm/framework/audioStreamDecodeProc.c
index 760598eb899e3b36e4fae693f65471134c588377..e56050480217bf2ddd8a0f4148153aa4664b68a1 100644 (file)
UInt32 gCbWrtAfErrCnt =0; // decoder output circular buffer write error count, not including overflows
UInt32 gDecOpCbWrtAfOvr =0; // decoder output circular buffer overflow count
UInt32 gMaxDecOpCbWrtAfOvr =0; // max (consecutive) decoder output circular buffer overflow count
+UInt32 gSlaveCbResetCnt =0; // slave circular buffer reset count
// Global debug counters */
UInt32 gSlaveStartErrCnt =0;
UInt32 gSlaveDecDeactivateCnt =0;
-//#define CAPTURE_DECODER_OUTSAMPLES_PP
+#define CAPTURE_DECODER_OUTSAMPLES_PP
#ifdef CAPTURE_DECODER_OUTSAMPLES_PP
#define CAP_FRAME_MAX 2000
gCbWrtAfErrCnt=0; // reset write circular buffer error count
gDecOpCbWrtAfOvr=0; // reset decoder output circular buffer overflow count
gMaxDecOpCbWrtAfOvr=0; // reset max decoder output circular buffer overflow count
+ gSlaveCbResetCnt=0; // reset slave circular buffer reset count
// FL: debug, log circular buffer control variables
cbLog(pCbCtl, z, 1, "cbWriteStart");
+
// Reset audio frame
resetAf(pP, z, sourceSelect);
// Reset circular buffer
cbReset(pCbCtl, z);
+ gSlaveCbResetCnt++; // increment slave circular buffer reset count
+ Log_info0("ASDT:cbReset");
}
}
else if ((cbErrno == ASP_DECOP_CB_SOK) && (gDecOpCbWrtAfOvr > 0))
diff --git a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.c
index 2c6c2853ed079e00fa1df0c460c169c45ac6e56c..851e003d86b77e11b43551bf5c1bf5d1cb5484a0 100644 (file)
#include "dbgBenchmark.h" // PCM high-sampling rate + SRC + CAR benchmarking
-#ifdef CB_RW_OP_CAP_PP
+#include "evmc66x_gpio_dbg.h" // Debug
+
+#ifdef CB_RW_OP_CAP_PP // debug
// Global variables
Uint32 *gCB_samples_op = NULL;
Uint8 *gCB_op_owner = NULL;
#define DEF_DEC_OP_FRAME_LEN ( PAF_SYS_FRAMELENGTH ) // ( 256 ) // default decoder output frame length
#define DEF_STR_FRAME_LEN ( PAF_SYS_FRAMELENGTH ) // default stream frame length
+#if 0
// Generate mute AF on circular buffer read
static Void cbReadAfMute(
PAF_AudioFrame *pAfRd, // audio frame into which to read
Int16 strFrameLen // stream frame length (output transaction size)
);
+#endif
// Init last audio frame configuration info
static Void cbInitLastAfInfo(
pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_THD;//ASP_DECOP_CB_MAX_NUM_AF_PCM;
pCb->afWrtIdx = ASP_DECOP_CB_INIT_LAG_PCM;
pCb->afRdIdx = 0;
- pCb->pcmRdIdx = 0; // 2*256 in behind
+ pCb->pcmRdIdx = 0;
+
+ // Initialize CB primed flag
+ pCb->primedFlag = 0;
+ // Initialize delta samples
+ pCb->deltaSamps = 0;
// set default value to PCM configuration
pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH;
// initialize audio frame PCM buffers
pPcmBuf = pCb->pcmBuf;
- pMetaBuf = pCb->metaBuf; //QIN
+ pMetaBuf = pCb->metaBuf;
for (n=0; n<pCb->maxNumAfCb; n++)
{
pAfCb = &pCb->afCb[n];
pAfCb->numPrivateMetadata = 0; /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
pAfCb->bsMetadata_offset = 0; /* offset into audio frame for change in bsMetadata_type field */
- // Initialize metadata buffers //QIN
+ // Initialize metadata buffers
for (i=0; i<PAF_MAX_NUM_PRIVATE_MD; i++)
{
pAfCb->pafPrivateMetadata[i].offset = 0;
pCb->errUndCnt = 0;
pCb->errOvrCnt = 0;
- #ifdef CB_RW_OP_CAP_PP
+ #ifdef CB_RW_OP_CAP_PP // debug
// Get address in global variables
gCB_samples_op = pCb->cb_samples_op;
gCB_op_owner = pCb->cb_op_owner;
cbInitLastAfInfo(&pCb->lastAf);
- // (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
// Write back AF circular buffer
{
Cache_wb(pAfCb->data.sample[i], DEF_DEC_OP_FRAME_LEN*sizeof(PAF_AudioData), Cache_Type_ALLD, 0);
}
- // FL: unnecessary since part of AF
- //for (i=0; i<PAF_MAX_NUM_PRIVATE_MD; i++) // Write back metadata //QIN
- //{
- // Cache_wb(&pAfCb->pafPrivateMetadata[i], sizeof(PAF_PrivateMetadata), Cache_Type_ALLD, 0);
- //}
}
Cache_wait();
PAF_AST_DecOpCircBuf *pCb;
PAF_AudioFrame *pAfCb;
PAF_AudioData *pPcmBuf;
- UInt8 *pMetaBuf; //QIN
+ UInt8 *pMetaBuf;
Int8 n;
Int8 i;
Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
- //Log_info1("cbInitSourceSel:afCb=0x%04x", (IArg)pCb->afCb); // FL: debug
+ //Log_info1("cbInitSourceSel:afCb=0x%04x", (IArg)pCb->afCb); // debug
// set source select
pCb->sourceSel = sourceSelect;
// set output frame length
pCb->strFrameLen = strFrameLen;
- pCb->afInitialLag = 0; // default No lag
- pCb->afLagIdx = 0;
-
+ //pCb->afInitialLag = 0; // default No lag
+ //pCb->afLagIdx = 0;
+ // Initialize CB primed flag
+ pCb->primedFlag = 0;
+ // Initialize delta samples
+ pCb->deltaSamps = 0;
// initialize circular buffer maximum number of audio frames
if (sourceSelect == PAF_SOURCE_PCM)
{
pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_PCM;
- // 2*256 in behind
- pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_PCM;
+
+ //pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_PCM;
+ // Initialize target nominal delay
+ pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kPCM;
+
pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_PCM;
pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_PCM;
pCb->pcmRdIdx = 0;
+
pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH;
pCb->maxAFSampCount = DEF_DEC_OP_FRAME_LEN;
else if ((sourceSelect == PAF_SOURCE_DDP) || (sourceSelect == PAF_SOURCE_AC3))
{
pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_DDP;
- // 4*256 in behind
+
+ //pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_DDP;
+ // Initialize target nominal delay
+ pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kDDP;
+
pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_DDP;
pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_DDP;
- pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_DDP;
- pCb->pcmRdIdx = 0; //decOpFrameLen - ASP_DECOP_CB_INIT_LAG_DDP*strFrameLen; // 4*256 behind
+ pCb->pcmRdIdx = 0;
+
pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_DDP;
pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kDDP;
else if (sourceSelect == PAF_SOURCE_THD)
{
pCb->maxNumAfCb = ASP_DECOP_CB_MAX_NUM_AF_THD;
- pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_THD;
+
+ //pCb->afInitialLag = ASP_DECOP_CB_INIT_LAG_THD;
+ // Initialize target nominal delay
+ pCb->targetNDSamps = ASP_DECOP_CB_TARGET_ND_SAMPS_48kTHD;
+
pCb->afWrtIdx = ASP_DECOP_CB_INIT_WRTIDX_THD;
pCb->afRdIdx = ASP_DECOP_CB_INIT_RDIDX_THD;
pCb->pcmRdIdx = 0;
+
pCb->maxAFChanNum = ASP_DECOP_CB_MAX_NUM_PCM_CH_MAT;
pCb->maxAFSampCount = ASP_DECOP_CB_MAX_PCM_FRAME_LEN_48kMAT;
// initialize audio frame PCM buffers
pPcmBuf = pCb->pcmBuf;
- pMetaBuf = pCb->metaBuf; //QIN
+ pMetaBuf = pCb->metaBuf;
for (n=0; n<pCb->maxNumAfCb; n++)
{
pAfCb = &pCb->afCb[n];
pAfCb->data.samsiz[i] = 0;
}
- // Initialize metadata buffers //QIN
+ // Initialize metadata buffers
for (i=0; i<PAF_MAX_NUM_PRIVATE_MD; i++)
{
pAfCb->pafPrivateMetadata[i].offset = 0;
pCb->errUndCnt = 0;
pCb->errOvrCnt = 0;
- // (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
// Write back AF circular buffer
Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
- //Log_info1("cbReadStart:afCb=0x%04x", (IArg)pCb->afCb); // FL: debug
+ //Log_info1("cbReadStart:afCb=0x%04x", (IArg)pCb->afCb); // debug
// update flags
pCb->readerActiveFlag = 1;
- // (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
- //Log_info1("cbReadStop:afCb=0x%04x", (IArg)pCb->afCb); // FL: debug
+ //Log_info1("cbReadStop:afCb=0x%04x", (IArg)pCb->afCb); // debug
// update flags
pCb->readerActiveFlag = 0;
- // (***) FL: revisit
// Write back circular buffer configuration
Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
// Get circular buffer base pointer
pCb = &((*pCbCtl->pXDecOpCb)[cbIdx]);
- // (***) FL: revisit
// Invalidate circular buffer configuration.
Cache_inv(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
Cache_wait();
- //Log_info1("cbReadAf:afCb=0x%04x", (IArg)pCb->afCb); // FL: debug
+ //Log_info1("cbReadAf:afCb=0x%04x", (IArg)pCb->afCb); // debug
if ((pCb->writerActiveFlag == 1) && (pCb->emptyFlag == 1))
{
return ASP_DECOP_CB_READ_INVSTATE;
}
- if (((pCb->writerActiveFlag == 0) && (pCb->emptyFlag == 0)) || (pCb->afLagIdx < pCb->afInitialLag))
+ //if (((pCb->writerActiveFlag == 0) && (pCb->emptyFlag == 0)) || (pCb->afLagIdx < pCb->afInitialLag))
+ if ((pCb->writerActiveFlag == 0) && (pCb->emptyFlag == 0))
{
//
// No active writer, not draining circular buffer.
return ASP_DECOP_CB_SOK;
}
+ //if ((pCb->primedFlag == 0) || ((pCb->primedFlag==1) && (pCb->deltaSamps > 0))
+ if ((pCb->primedFlag == 0) || (pCb->deltaSamps > 0))
+ {
+ if (pCb->primedFlag == 1)
+ {
+ pCb->deltaSamps = pCb->deltaSamps - pCb->strFrameLen;
+ }
+
+ cbReadMuteWithLastAfInfo(pCb, pAfRd);
+
+ // 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_SOK;
+ }
+
+
// (writerActiveFlag,emptyFlag)=(1,0) and (0,1) are left
// Here we are checking (1,0) state here
if (pCb->writerActiveFlag == 1)
toggleState = ~(toggleState);
}
- #ifdef CB_RW_OP_CAP_PP
+ #ifdef CB_RW_OP_CAP_PP // debug
if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
{
if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
// get pointer to current audio frame in circular buffer
pAfCb = &pCb->afCb[pCb->afRdIdx];
- // (***) FL: revisit
// Invalidate audio frame
Cache_inv(pAfCb, sizeof(PAF_AudioFrame), Cache_Type_ALLD, 0);
Cache_inv(pAfCb->data.samsiz, pCb->maxAFChanNum*sizeof(PAF_AudioSize), Cache_Type_ALLD, 0);
- for (i=0; i<pAfCb->numPrivateMetadata; i++) //QIN // FL: only invalidate numPrivateMetadata
+ for (i=0; i<pAfCb->numPrivateMetadata; i++) // only invalidate numPrivateMetadata
{
- Cache_inv(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfCb->pafPrivateMetadata[i].size, Cache_Type_ALLD, 0); // FL: only update metadata package size
+ Cache_inv(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfCb->pafPrivateMetadata[i].size, Cache_Type_ALLD, 0); // only update metadata package size
}
Cache_wait();
pAfRd->channelConfigurationRequest = pAfCb->channelConfigurationRequest;
pAfRd->channelConfigurationStream = pAfCb->channelConfigurationStream;
- // read metadata information updated by decoder //QIN
+ // read metadata information updated by decoder
pAfRd->bsMetadata_type = pAfCb->bsMetadata_type; /* non zero if metadata is attached. */
pAfRd->pafBsMetadataUpdate = pAfCb->pafBsMetadataUpdate; /* indicates whether bit-stream metadata update */
pAfRd->numPrivateMetadata = pAfCb->numPrivateMetadata; /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
pAfRd->bsMetadata_offset = pAfCb->bsMetadata_offset; /* offset into audio frame for change in bsMetadata_type field */
- #ifdef CB_RW_OP_CAP_PP
+ #ifdef CB_RW_OP_CAP_PP // debug
if (pCb->cb_opCnt < CB_OP_COUNT_MAX)
{
if ((pCb->cb_samples_op != NULL) && (pCb->cb_op_owner != NULL))
pAfRd->pafPrivateMetadata[i].size = 0;
}
- // read metadata //QIN
- for (i = 0; i < pAfCb->numPrivateMetadata; i++) // FL: only read numPrivateMetadata
+ // read metadata
+ for (i = 0; i < pAfCb->numPrivateMetadata; i++) // only read numPrivateMetadata
{
- // FL: this is done above
- ////Invalidate metadata data
- //Cache_inv(&pAfCb->pafPrivateMetadata[i], sizeof(PAF_PrivateMetadata), Cache_Type_ALLD, 0);
- //Cache_wait();
-
if ((pAfCb->pafPrivateMetadata[i].offset >= pCb->pcmRdIdx)
&&(pAfCb->pafPrivateMetadata[i].offset < (pCb->pcmRdIdx + pCb->strFrameLen))
&&(pAfCb->pafPrivateMetadata[i].size))
{
- // FL: this is done above
- ////Invalidate metadata data
- //Cache_inv(pAfCb->pafPrivateMetadata[i].pMdBuf, pAfCb->pafPrivateMetadata[i].size, Cache_Type_ALLD, 0);
- //Cache_wait();
-
// the offset is adjusted for segment [pCb->pcmRdIdx, (pCb->pcmRdIdx + pCb->pafFrameLen)]
pAfRd->pafPrivateMetadata[numMetadata].offset = pAfCb->pafPrivateMetadata[i].offset - pCb->pcmRdIdx;
pAfRd->pafPrivateMetadata[numMetadata].size = pAfCb->pafPrivateMetadata[i].size;
}
}
- // (***) FL: revisit
// Write back circular buffer configuration.
// NOTE: Probably only a subset of this information needs to be updated.
Cache_wb(pCb, sizeof(PAF_AST_DecOpCircBuf), Cache_Type_ALLD, 0);
return ASP_DECOP_CB_SOK;
}
+#if 0
// Generate mute AF on circular buffer read
static Void cbReadAfMute(
PAF_AudioFrame *pAfRd, // audio frame into which to read
pAfRd->numPrivateMetadata = 0; /* number of valid private metadata (0 or 1 if metadata filtering enabled) */
pAfRd->bsMetadata_offset = 0; /* offset into audio frame for change in bsMetadata_type field */
}
+#endif
+
// Init last audio frame configuration info
static Void cbInitLastAfInfo(
PAF_AudioFrame *pAfRd // last audio frame stored in CB instance
diff --git a/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h b/pasdk/test_dsp/framework/aspDecOpCircBuf_master.h
index 4bd43cb001a561345973d27a25a9c2cb5a46fb98..f235d4be91209f53848a360ababe673311833690 100644 (file)
PAF_AudioFrame *pAfRd // audio frame into which to read
);
-// Write audio frame to circular buffer
-Int cbWriteAf(
- PAF_AST_DecOpCircBufCtl *pCbCtl, // decoder output circular buffer control
- Int8 cbIdx, // decoder output circular buffer index
- PAF_AudioFrame *pAfWrt // audio frame from which to write
-);
-
#endif /* _ASP_DECOP_CB_MASTER_H_ */
diff --git a/pasdk/test_dsp/framework/audioStreamOutProc.c b/pasdk/test_dsp/framework/audioStreamOutProc.c
index ed65a1123ebebfd2a41f522b7ab0623a6bf812f3..f7135cf862c7ab59c353898da43335591865af38 100644 (file)
UInt32 gCbReadAfErr =0; // read circular buffer error count, not including underflows
UInt32 gDecOpCbRdAfUnd =0; // decoder output circular buffer underflow count
UInt32 gMaxDecOpCbRdAfUnd =0; // max (consecutive) decoder output circular buffer underflow count
+UInt32 gMasterCbResetCnt =0; // master circular buffer reset count
// Global debug counters */
UInt32 gTaskAsopCnt=0; // debug
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
+ gMasterCbResetCnt=0; // reset master circular buffer reset count
- // FL: debug
+ // FL: debug, log circular buffer control variables
cbLog(pCbCtl, z, 1, "PAF_ASOT_decodeInit:cbReadStart");
}
// Reset circular buffer
cbReset(pCbCtl, z);
- Log_info0("PAF_ASOT_decodeStream:cbReset");
+ gMasterCbResetCnt++; // increment master circular buffer reset count
+ Log_info0("ASOT:cbReset");
return cbErrno;
}
index 8c54ff77daf8bd01fc8b864ef79e8014df519004..08c4ba815bd13d19e5bd6997a4e3f43e107be43f 100644 (file)
--- a/pasdk/test_dsp/mib/mib.c
+++ b/pasdk/test_dsp/mib/mib.c
if (status)
return status;
-#if 1 // (***) FL: shows timing of Input Rx SIO reclaim during autodet
+#if 0 // (***) FL: shows timing of Input Rx SIO reclaim during autodet
// (***) debug // B5
{
static Uint8 toggleState = 0;