📄 decoder.cpp
字号:
}
/* ---------- MPEG4_TTS_Play() ---------- */
//
// void MPEG4_TTS_Play()
//
// MPEG-4 TTS Bit Stream阑 decoding 窍咯 利例茄 规过栏肺
// 钦己扁甫 备悼矫挪促.
//
// * 寇何 橇肺弊伐苞 流立牢磐其捞胶窃
//
void MPEG4_TTS_Play()
{
int i, fSnt=0;
int nAdd=0;
int nPOS_MOV;
int nCurPos;
int nSentence=0;
FILE *fp;
SoundOutInit(); // SoundIO.c
fp = Open_File();
free_Data(Frame);
if( Tts->V_en )
{
nPOS_MOV = ppp->m_slider_position.GetPos();
if( Tts->T_en )
{
// slider bar狼 困摹甫 sample荐肺 函券
T_Sync[0] = nPOS_MOV * 500 * 16;
Set_start_time(fp, nPOS_MOV);
nCurPos = nPOS_MOV;
}
else
{
T_Sync[0] = 0;
nCurPos = 0;
}
}
while( rd_txt(fp, Tts, Frame) != 0 ) {
if (nFILE == TRUE && !Frame->Silence)
pText->m_edit_Sentence.SetWindowText(Frame->Sentence->Text);
if(Frame->Sentence == NULL) {
for(i=0; i<8000; i++)
syn.iwave[i]=0;
play(i);
T_Sync[0] += i;
Set_Slider_Pos( T_Sync );
continue;
}
if(Tts->V_en)
{
Video = Snt->Video;
if(Video->PinSnt!=0 && fSnt==1)
{
free_Data(Frame);
continue;
}
else if(Video->PinSnt!=0 && fSnt==0) fSnt=1;
else if(Video->PinSnt==0) {
for(i=0; i<Video->Offset*16; i++)
syn.iwave[i]=0;
play(i);
T_Sync[0] += i;
fSnt=1;
}
VSayOneParagraph(Tts, Frame, T_Sync);
}
if( Tts->V_en != 1 )
{
if( !pOpt->m_check_default.GetCheck() && Tts->T_en )
Frame->Sentence->Speech_Rate = (short)f_SPCHRATE;
if( (int)f_CURPOS_F <= nSentence++ )
{
VSayOneParagraph(Tts, Frame, T_Sync);
// 泅犁 钦己窍绊 乐绰 困摹甫 control dialog 狼 slider 俊 馆康茄促.
nAdd++;
nCurPos = (int)f_CURPOS_F+nAdd;
ppp->m_slider_position_F.SetPos(nCurPos);
// 泅犁 钦己窍绊 乐绰 巩厘阑 sentence edit box俊 钎矫茄促.
}
}
free_Data(Frame);
}
fclose( fp );
SoundOutUninit(); // SoundIo.c
ppp->m_slider_position.SetPos(0);
}
char **cmatrix(int nrh, int nch)
{
int i;
char **m;
m = (char **)malloc((unsigned) (nrh+1)*sizeof(char*));
for( i=0;i <=nrh;i++)
m[i] = (char *) malloc((unsigned) (nch+1)*sizeof(char));
return m;
}
void free_cmatrix(char **m, int nrh, int nch)
{
int i;
for( i=nrh;i >=0;i--) free((char*) (m[i]));
free((char*) m);
}
void Idata_read(int *A, int n, int nbits, unsigned char *B, FILE *fp)
{
int i, nx, ny;
unsigned int X; unsigned char Y;
short W[9]={ 0,1,3,7,0x0F,0x01F,0x03F,0x07F,0x0FF };
Y=B[0]; ny=B[1];
for(i=0; i<n; i++)
{
nx=nbits; *(A+i)=0;
while(nx!=0)
{
if(nx>ny)
{
X=(Y & W[ny]);
*(A+i)=*(A+i) | (X << (nx-ny));
nx-=ny;
ny=8;
fread(&Y,1,1,fp);
}
else
{
X=(Y >> (ny-nx)) & W[nx];
*(A+i)=*(A+i) | X;
ny-=nx;
nx=0;
}
}
}
B[0]=Y; B[1]=ny;
}
void Sdata_read(short *A, int n, int nbits, unsigned char *B, FILE *fp)
{
int i, nx, ny;
unsigned int X; unsigned char Y;
short W[9]={ 0,1,3,7,0x0F,0x01F,0x03F,0x07F,0x0FF };
Y=B[0]; ny=B[1];
for(i=0; i<n; i++)
{
nx=nbits; *(A+i)=0;
while(nx!=0)
{
if(nx>ny)
{
X=(Y & W[ny]);
*(A+i)=*(A+i) | (X << (nx-ny));
nx-=ny;
ny=8;
fread(&Y,1,1,fp);
}
else
{
X=(Y >> (ny-nx)) & W[nx];
*(A+i)=*(A+i) | X;
ny-=nx;
nx=0;
}
}
}
B[0]=Y; B[1]=ny;
}
void Cdata_read(char *A, int n, int nbits, unsigned char *B, FILE *fp)
{
int i, nx, ny;
unsigned char X,Y;
short W[9]={ 0,1,3,7,0x0F,0x01F,0x03F,0x07F,0x0FF };
Y=B[0]; ny=B[1];
for(i=0; i<n; i++)
{
nx=nbits; *(A+i)=0;
while(nx!=0)
{
if(nx>ny)
{
X=(Y & W[ny]);
*(A+i)=*(A+i) | (X << (nx-ny));
nx-=ny; ny=8;
fread(&Y,1,1,fp);
}
else
{
X=(Y >> (ny-nx)) & W[nx];
*(A+i)=*(A+i) | X;
ny-=nx; nx=0;
}
}
}
B[0]=Y; B[1]=ny;
}
void CMdata_read(char **A, int n1, int n2, int nbits, unsigned char *B, FILE *fp)
{
int i, j, nx, ny;
unsigned char X,Y;
short W[9]={ 0,1,3,7,0x0F,0x01F,0x03F,0x07F,0x0FF };
Y=B[0]; ny=B[1];
for(i=0; i<n1; i++)
{
for(j=0; j<n2; j++)
{
nx=nbits; A[i][j]=0;
while(nx!=0)
{
if(nx>ny)
{
X=(Y & W[ny]);
A[i][j]=A[i][j] | (X << (nx-ny));
nx-=ny; ny=8;
fread(&Y,1,1,fp);
}
else
{
X=(Y >> (ny-nx)) & W[nx];
A[i][j]=A[i][j] | X;
ny-=nx; nx=0;
}
}
}
B[0]=Y; B[1]=ny;
}
}
void free_Data(FRAME_Data *Frame)
{
SENTENCE_Data *Snt; int np;
Snt=Frame->Sentence;
if(Snt==NULL) return;
if(Snt->Text!=NULL) free(Snt->Text);
if(Snt->Prosody!=NULL)
{
np=Snt->Prosody->Nphone+2;
if(Snt->Prosody->Phone!=NULL) free(Snt->Prosody->Phone);
if(Snt->Prosody->Dur!=NULL) free(Snt->Prosody->Dur);
if(Snt->Prosody->Ptch!=NULL) free_cmatrix(Snt->Prosody->Ptch,np,3);
if(Snt->Prosody->Energy!=NULL) free_cmatrix(Snt->Prosody->Energy,np,3);
free(Snt->Prosody);
}
if(Snt->Video!=NULL) free(Snt->Video);
if(Snt->Lip_shape!=NULL)
{
if(Snt->Lip_shape->LinSnt!=NULL) free(Snt->Lip_shape->LinSnt);
if(Snt->Lip_shape->Lshape!=NULL) free(Snt->Lip_shape->Lshape);
free(Snt->Lip_shape);
}
if(Snt!=NULL) { free(Snt); Frame->Sentence=NULL; }
}
/* ------ ChangeLip() ------ */
//
// moving picture啊 涝贱葛剧阑 啊瘤绰 版快甫 弊 涝贱阑 拳搁俊 谎妨霖促.
//
// * mk_fmt() call this function.
//
int ChangeLip( FRAME_Data *Frame )
{
int i, j;
int Nlip;
short *LinSnt;
char *Lshape;
Nlip = Frame->Sentence->Lip_shape->Nlip;
LinSnt = Frame->Sentence->Lip_shape->LinSnt;
Lshape = Frame->Sentence->Lip_shape->Lshape;
if( Nlip == 0 ) return(0);
i = (T_Sync[0] - T_Sync[2]) / 16;
for(j = 0; j < Nlip; j++ )
{
if( i >= LinSnt[j] && i<LinSnt[j+1])
{
pCLip->ChangeBitmap((int)Lshape[j]);
break;
}
}
return(1);
}
void Set_Slider_Pos(int *T_Sync)
{
float f_Curpos;
f_Curpos = (float)T_Sync[0] / T_Sync[1] * nS_MAX;
ppp->m_slider_position.SetPos((int)f_Curpos);
}
void ReplaceBitmap(int nLipNum)
{
pCLip->ChangeBitmap(nLipNum);
}
int Check_LipSync()
{
return( pOpt->m_radio_SyncOn.GetCheck() );
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -