📄 config.c
字号:
{ int nch, cidx=0; Ch_Info *cip; nch = (cpe == 1) ? 2 : 1; switch (position) { /* use configuration already in MC_Info, but now common_window is valid */ case 0: cidx = ch_index(mip, cpe, tag); if (common_window) { mip->ch_info[cidx].widx = cidx; /* window info is left */ mip->ch_info[cidx+1].widx = cidx; } else { mip->ch_info[cidx].widx = cidx; /* each has window info */ mip->ch_info[cidx+1].widx = cidx+1; } return cidx; /* build configuration */ case 'f': if (mip->nfch + nch > FChans) {/* CommonWarning("Unanticipated front channel"); */ return -1; } if (mip->nfch == 0) { /* consider case of center channel */ if (FCenter) { if (cpe) { /* has center speaker but center channel missing */ cidx = 0 + 1; mip->nfch = 1 + nch; } else { if (mip->nfsce & 1) { /* has center speaker and this is center channel */ /* odd number of leading SCE's */ cidx = 0; mip->nfch = nch; } else { /* has center speaker but center channel missing */ /* even number of leading SCE's */ /* (Note that in implicit congiguration * channel to speaker mapping may be wrong * for first block while count of SCE's prior * to first CPE is being make. However first block * is not written so it doesn't matter. * Second block will be correct. */ cidx = 0 + 1; mip->nfch = 1 + nch; } } } else { if (cpe) { /* no center speaker and center channel missing */ cidx = 0; mip->nfch = nch; } else { /* no center speaker so this is left channel */ cidx = 0; mip->nfch = nch; } } } else { cidx = mip->nfch; mip->nfch += nch; } break; case 's': if (mip->nsch + nch > SChans) {/* CommonWarning("Unanticipated side channel"); */ return -1; } cidx = FChans + mip->nsch; mip->nsch += nch; break; case 'b': if (mip->nbch + nch > BChans) {/* CommonWarning("Unanticipated back channel"); */ return -1; } cidx = FChans + SChans + mip->nbch; mip->nbch += nch; break; case 'l': if (mip->nlch + nch > LChans) {/* CommonWarning("Unanticipated LFE channel"); */ return -1; } cidx = FChans + SChans + BChans + mip->nlch; /* sdb */ mip->nlch += nch; break; default:/* CommonExit(1,"2020: Error in channel configuration"); */ return -1; } mip->nch += nch; if (cpe == 0) { /* SCE */ cip = &mip->ch_info[cidx]; cip->present = 1; cip->tag = tag; cip->cpe = 0; cip->common_window = common_window; cip->widx = cidx; mip->nch = cidx + 1; } else { /* CPE */ /* left */ cip = &mip->ch_info[cidx]; cip->present = 1; cip->tag = tag; cip->cpe = 1; cip->common_window = common_window; cip->ch_is_left = 1; cip->paired_ch = cidx+1; /* right */ cip = &mip->ch_info[cidx+1]; cip->present = 1; cip->tag = tag; cip->cpe = 1; cip->common_window = common_window; cip->ch_is_left = 0; cip->paired_ch = cidx; if (common_window) { mip->ch_info[cidx].widx = cidx; /* window info is left */ mip->ch_info[cidx+1].widx = cidx; } else { mip->ch_info[cidx].widx = cidx; /* each has window info */ mip->ch_info[cidx+1].widx = cidx+1; } mip->nch = cidx + 2; } return cidx;}static char default_position(faacDecHandle hDecoder, MC_Info *mip, int id){ if (mip->nch < FChans) { if (id == ID_CPE) /* first CPE */ hDecoder->first_cpe = 1; else if ((hDecoder->frameNum==0) && !hDecoder->first_cpe) /* count number of SCE prior to first CPE in first block */ mip->nfsce++; return('f'); /* front */ } else if (mip->nch < FChans+SChans) return('s'); /* side */ else if (mip->nch < FChans+SChans+BChans) return('b'); /* back */ return 0;}/* retrieve appropriate channel index for the program * and decoder configuration */int chn_config(faacDecHandle hDecoder, int id, int tag, int common_window, MC_Info *mip){ int cpe, cidx=0; char position; /* channel index to position mapping for 5.1 configuration is * 0 center * 1 left front * 2 right front * 3 left surround * 4 right surround * 5 lfe */ cpe = (id == ID_CPE) ? 1 : 0; if (hDecoder->default_config) { switch (id) { case ID_SCE: case ID_CPE: if ((position = default_position(hDecoder, mip, id)) == 0) {/* CommonExit(1,"2021: Unanticipated channel"); */ return (-1); } cidx = enter_chn(cpe, tag, position, common_window, mip); break; } } else cidx = enter_chn(cpe, tag, 0, common_window, mip); return cidx; /* index of chn in mc_info */}/* * check continuity of configuration from one * block to next */void reset_mc_info(faacDecHandle hDecoder, MC_Info *mip){ int i; Ch_Info *p; /* only reset for implicit configuration */ if (hDecoder->default_config) { /* reset channel counts */ mip->nch = 0; mip->nfch = 0; mip->nsch = 0; mip->nbch = 0; mip->nlch = 0; mip->ncch = 0; if (hDecoder->frameNum == 0) /* reset prior to first block scan only! */ mip->nfsce = 0; for (i=0; i<Chans; i++) { p = &mip->ch_info[i]; p->present = 0; p->cpe = 0; p->ch_is_left = 0; p->paired_ch = 0; p->is_present = 0; p->widx = 0; p->ncch = 0; } }}int check_mc_info(faacDecHandle hDecoder, MC_Info *mip, int new_config){ int i, nch, err; Ch_Info *s, *p; nch = mip->nch; if (new_config) { /* enter valid configuration */ for (i=0; i<nch; i++) { s = &hDecoder->save_mc_info.ch_info[i]; p = &mip->ch_info[i]; s->present = p->present; s->cpe = p->cpe; s->ch_is_left = p->ch_is_left; s->paired_ch = p->paired_ch; } } else { /* check this block's configuration */ err = 0; for (i=0; i<nch; i++) { s = &hDecoder->save_mc_info.ch_info[i]; p = &mip->ch_info[i]; if (s->present != p->present) err=1; if (!s->present) continue; /* sdb */ if (s->cpe != p->cpe) err=1; if (s->ch_is_left != p->ch_is_left) err=1; if (s->paired_ch != p->paired_ch) err=1; } if (err) { /* CommonExit(1,"Channel configuration inconsistency"); */ return 0; } } return 1;}/* given cpe and tag, * returns channel index of SCE or left chn in CPE */static int ch_index(MC_Info *mip, int cpe, int tag){ int ch; for (ch=0; ch<mip->nch; ch++) { if (!(mip->ch_info[ch].present)) continue; if ( (mip->ch_info[ch].cpe == cpe) && (mip->ch_info[ch].tag == tag) ) return ch; } /* no match, so channel is not in this program * dummy up the ch_info structure so rest of chn will parse */ if (XChans > 0) { ch = Chans - XChans; /* left scratch channel */ mip->ch_info[ch].cpe = cpe; mip->ch_info[ch].ch_is_left = 1; mip->ch_info[ch].widx = ch; if (cpe) { mip->ch_info[ch].paired_ch = ch+1; mip->ch_info[ch+1].ch_is_left = 0; mip->ch_info[ch+1].paired_ch = ch; } } else { ch = -1; /* error, no scratch space */ } return ch;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -