www.pudn.com > bladeenc-0.90.0-src.zip > encode.c


/* 
			(c) Copyright 1998, 1999 - Tord Jansson 
			======================================= 
 
		This file is part of the BladeEnc MP3 Encoder, based on 
		ISO's reference code for MPEG Layer 3 compression, and might 
		contain smaller or larger sections that are directly taken 
		from ISO's reference code. 
 
		All changes to the ISO reference code herein are either 
		copyrighted by Tord Jansson (tord.jansson@swipnet.se) 
		or sublicensed to Tord Jansson by a third party. 
 
	BladeEnc is free software; you can redistribute this file 
	and/or modify it under the terms of the GNU Lesser General Public 
	License as published by the Free Software Foundation; either 
	version 2.1 of the License, or (at your option) any later version. 
 
*/ 
 
#include "common.h" 
#include "encoder.h" 
 
 
typedef double MM[SBLIMIT][64]; 
typedef double XX[2][512]; 
 
static int 	off[2]; 
static int 	half[2]; 
 
static MM 	m; 
static XX 	x; 
 
 
/*____ rebuffer_audio() __________________________________________________*/ 
 
void rebuffer_audio( short buffer[2][1152], short * insamp, unsigned int samples_read, int stereo ) 
{ 
  unsigned int j; 
 
  if(stereo == 2) 
	{  
 
		for(j=0;j= 0) 
             modf(filter[i][k]+0.5, &filter[i][k]); 
          else 
             modf(filter[i][k]-0.5, &filter[i][k]); 
          filter[i][k] *= 1e-9; 
   } 
} 
 
 
/*____ initWindowFilterSubband() ____________________________________________*/ 
 
void initWindowFilterSubband( void ) 
{ 
	int i, j; 
 
	off[0] = 0; 
	off[1] = 0; 
	half[0] = 0; 
	half[1] = 0; 
   	for (i=0;i<2;i++) 
		for (j=0;j<512;j++) 
       		x[i][j] = 0; 
 
    create_ana_filter(m); 
} 
 
 
/************************************************************************ 
* 
* filter_subband() 
* 
* PURPOSE:  Calculates the analysis filter bank coefficients 
* 
* SEMANTICS: 
*      The windowed samples #z# is filtered by the digital filter matrix #m# 
* to produce the subband samples #s#. This done by first selectively 
* picking out values from the windowed samples, and then multiplying 
* them by the filter matrix, producing 32 subband samples. 
* 
************************************************************************/ 
 
 
/*____ windowFilterSubband() ____________________________________________*/ 
 
void  oldwindowFilterSubband( short * pBuffer, int k, double s[SBLIMIT] ) 
{ 
 
 double y[64]; 
 int    i,j; 
 
  double  t; 
  double *  rpMM; 
 
  int	offcache; 
 
	double *dp; 
 
 
  dp = &x[k][0]; 
	offcache = off[k]; 
 
  /* replace 32 oldest samples with 32 new samples */ 
  for ( i=0 ; i<32 ; i++ ) 
		dp[31-i+offcache] = (double) pBuffer[i]/SCALE; 
   
  for( i = 0 ; i<64 ; i++ ) 
  { 
    t =  dp[(i+64*0+offcache)&(512-1)] * enwindow[i+64*0]; 
    t += dp[(i+64*1+offcache)&(512-1)] * enwindow[i+64*1]; 
    t += dp[(i+64*2+offcache)&(512-1)] * enwindow[i+64*2]; 
    t += dp[(i+64*3+offcache)&(512-1)] * enwindow[i+64*3]; 
    t += dp[(i+64*4+offcache)&(512-1)] * enwindow[i+64*4]; 
    t += dp[(i+64*5+offcache)&(512-1)] * enwindow[i+64*5]; 
    t += dp[(i+64*6+offcache)&(512-1)] * enwindow[i+64*6]; 
    t += dp[(i+64*7+offcache)&(512-1)] * enwindow[i+64*7]; 
    y[i] = t; 
  } 
 
  off[k] += 480;              /*offset is modulo (HAN_SIZE-1)*/ 
  off[k] &= 512-1; 
 
 
 
  rpMM = (double *) (m); 
 
  for ( i=0 ; i