csbtl3.c

来自「希望能帮助大家学习C语言.」· C语言 代码 · 共 311 行

C
311
字号
/*____________________________________________________________________________
	
	MP3 Decoding Libraries
	Lanuguages used: C, C++, ASM

	As much as I would love to, I cannot take
	full credit for writing this code.
	Xing Technology	made MPEG-Layer 3 for us
	to decode. =)
	- ULTiMaTuM -

	MPEG-Layer 3 (MP3)
	Copyright (C) 1995-1997 Xing Technology

  	NOTE: I only edited the bare-minimum. 90%
		of this is original decoding code...
		Hmm... that sounds strange =)

____________________________________________________________________________*/

/****  csbtL3.c  ***************************************************

layer III

  include to  csbt.c

******************************************************************/
/*============================================================*/
/*============ Layer III =====================================*/
/*============================================================*/
void sbt_mono_L3(float *sample, short *pcm, int ch)
{
   int i;

   ch = 0;
   for (i = 0; i < 18; i++)
   {
      fdct32(sample, vbuf + vb_ptr);
      window(vbuf, vb_ptr, pcm);
      sample += 32;
      vb_ptr = (vb_ptr - 32) & 511;
      pcm += 32;
   }

}
/*------------------------------------------------------------*/
void sbt_dual_L3(float *sample, short *pcm, int ch)
{
   int i;

   if (ch == 0)
      for (i = 0; i < 18; i++)
      {
	 fdct32(sample, vbuf + vb_ptr);
	 window_dual(vbuf, vb_ptr, pcm);
	 sample += 32;
	 vb_ptr = (vb_ptr - 32) & 511;
	 pcm += 64;
      }
   else
      for (i = 0; i < 18; i++)
      {
	 fdct32(sample, vbuf2 + vb2_ptr);
	 window_dual(vbuf2, vb2_ptr, pcm + 1);
	 sample += 32;
	 vb2_ptr = (vb2_ptr - 32) & 511;
	 pcm += 64;
      }


}
/*------------------------------------------------------------*/
/*------------------------------------------------------------*/
/*---------------- 16 pt sbt's  -------------------------------*/
/*------------------------------------------------------------*/
void sbt16_mono_L3(float *sample, short *pcm, int ch)
{
   int i;

   ch = 0;
   for (i = 0; i < 18; i++)
   {
      fdct16(sample, vbuf + vb_ptr);
      window16(vbuf, vb_ptr, pcm);
      sample += 32;
      vb_ptr = (vb_ptr - 16) & 255;
      pcm += 16;
   }


}
/*------------------------------------------------------------*/
void sbt16_dual_L3(float *sample, short *pcm, int ch)
{
   int i;


   if (ch == 0)
   {
      for (i = 0; i < 18; i++)
      {
	 fdct16(sample, vbuf + vb_ptr);
	 window16_dual(vbuf, vb_ptr, pcm);
	 sample += 32;
	 vb_ptr = (vb_ptr - 16) & 255;
	 pcm += 32;
      }
   }
   else
   {
      for (i = 0; i < 18; i++)
      {
	 fdct16(sample, vbuf2 + vb2_ptr);
	 window16_dual(vbuf2, vb2_ptr, pcm + 1);
	 sample += 32;
	 vb2_ptr = (vb2_ptr - 16) & 255;
	 pcm += 32;
      }
   }

}
/*------------------------------------------------------------*/
/*---------------- 8 pt sbt's  -------------------------------*/
/*------------------------------------------------------------*/
void sbt8_mono_L3(float *sample, short *pcm, int ch)
{
   int i;

   ch = 0;
   for (i = 0; i < 18; i++)
   {
      fdct8(sample, vbuf + vb_ptr);
      window8(vbuf, vb_ptr, pcm);
      sample += 32;
      vb_ptr = (vb_ptr - 8) & 127;
      pcm += 8;
   }

}
/*------------------------------------------------------------*/
void sbt8_dual_L3(float *sample, short *pcm, int ch)
{
   int i;

   if (ch == 0)
   {
      for (i = 0; i < 18; i++)
      {
	 fdct8(sample, vbuf + vb_ptr);
	 window8_dual(vbuf, vb_ptr, pcm);
	 sample += 32;
	 vb_ptr = (vb_ptr - 8) & 127;
	 pcm += 16;
      }
   }
   else
   {
      for (i = 0; i < 18; i++)
      {
	 fdct8(sample, vbuf2 + vb2_ptr);
	 window8_dual(vbuf2, vb2_ptr, pcm + 1);
	 sample += 32;
	 vb2_ptr = (vb2_ptr - 8) & 127;
	 pcm += 16;
      }
   }



}
/*------------------------------------------------------------*/
/*------- 8 bit output ---------------------------------------*/
/*------------------------------------------------------------*/
void sbtB_mono_L3(float *sample, unsigned char *pcm, int ch)
{
   int i;

   ch = 0;
   for (i = 0; i < 18; i++)
   {
      fdct32(sample, vbuf + vb_ptr);
      windowB(vbuf, vb_ptr, pcm);
      sample += 32;
      vb_ptr = (vb_ptr - 32) & 511;
      pcm += 32;
   }

}
/*------------------------------------------------------------*/
void sbtB_dual_L3(float *sample, unsigned char *pcm, int ch)
{
   int i;

   if (ch == 0)
      for (i = 0; i < 18; i++)
      {
	 fdct32(sample, vbuf + vb_ptr);
	 windowB_dual(vbuf, vb_ptr, pcm);
	 sample += 32;
	 vb_ptr = (vb_ptr - 32) & 511;
	 pcm += 64;
      }
   else
      for (i = 0; i < 18; i++)
      {
	 fdct32(sample, vbuf2 + vb2_ptr);
	 windowB_dual(vbuf2, vb2_ptr, pcm + 1);
	 sample += 32;
	 vb2_ptr = (vb2_ptr - 32) & 511;
	 pcm += 64;
      }

}
/*------------------------------------------------------------*/
/*------------------------------------------------------------*/
/*---------------- 16 pt sbtB's  -------------------------------*/
/*------------------------------------------------------------*/
void sbtB16_mono_L3(float *sample, unsigned char *pcm, int ch)
{
   int i;

   ch = 0;
   for (i = 0; i < 18; i++)
   {
      fdct16(sample, vbuf + vb_ptr);
      windowB16(vbuf, vb_ptr, pcm);
      sample += 32;
      vb_ptr = (vb_ptr - 16) & 255;
      pcm += 16;
   }


}
/*------------------------------------------------------------*/
void sbtB16_dual_L3(float *sample, unsigned char *pcm, int ch)
{
   int i;

   if (ch == 0)
   {
      for (i = 0; i < 18; i++)
      {
	 fdct16(sample, vbuf + vb_ptr);
	 windowB16_dual(vbuf, vb_ptr, pcm);
	 sample += 32;
	 vb_ptr = (vb_ptr - 16) & 255;
	 pcm += 32;
      }
   }
   else
   {
      for (i = 0; i < 18; i++)
      {
	 fdct16(sample, vbuf2 + vb2_ptr);
	 windowB16_dual(vbuf2, vb2_ptr, pcm + 1);
	 sample += 32;
	 vb2_ptr = (vb2_ptr - 16) & 255;
	 pcm += 32;
      }
   }

}
/*------------------------------------------------------------*/
/*---------------- 8 pt sbtB's  -------------------------------*/
/*------------------------------------------------------------*/
void sbtB8_mono_L3(float *sample, unsigned char *pcm, int ch)
{
   int i;

   ch = 0;
   for (i = 0; i < 18; i++)
   {
      fdct8(sample, vbuf + vb_ptr);
      windowB8(vbuf, vb_ptr, pcm);
      sample += 32;
      vb_ptr = (vb_ptr - 8) & 127;
      pcm += 8;
   }

}
/*------------------------------------------------------------*/
void sbtB8_dual_L3(float *sample, unsigned char *pcm, int ch)
{
   int i;

   if (ch == 0)
   {
      for (i = 0; i < 18; i++)
      {
	 fdct8(sample, vbuf + vb_ptr);
	 windowB8_dual(vbuf, vb_ptr, pcm);
	 sample += 32;
	 vb_ptr = (vb_ptr - 8) & 127;
	 pcm += 16;
      }
   }
   else
   {
      for (i = 0; i < 18; i++)
      {
	 fdct8(sample, vbuf2 + vb2_ptr);
	 windowB8_dual(vbuf2, vb2_ptr, pcm + 1);
	 sample += 32;
	 vb2_ptr = (vb2_ptr - 8) & 127;
	 pcm += 16;
      }
   }

}
/*------------------------------------------------------------*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?