예제 #1
0
void L3_format_bitstream( int l3_enc[2][2][samp_per_frame2], L3_side_info_t  *l3_side)
{
  int main_bytes;

  encodeSideInfo( l3_side ); /* store in fifo */
  main_bytes = encodeMainData( l3_enc, l3_side );

  /* send data */
  by = 0;

  while(main_bytes)
  {
    if (!count)
    { /* end of frame so output next header/sideinfo */
      putbytes(fifo[rd].side, fifo[rd].si_len);
      count = fifo[rd].fr_len;
      if(++rd == FIFO_SIZE) rd = 0; /* point to next header/sideinfo */
    }

    if(main_bytes <= count)
    { /* enough room in frame to output rest of main data, this will exit the while loop */
      putbytes(&main_[by],main_bytes);
      count -= main_bytes;
      main_bytes = 0;
    }
    else
    { /* fill current frame up, start new frame next time around the while loop */
      putbytes(&main_[by],count);
      main_bytes -= count;
      by += count;
      count = 0;
    }
  }
}
예제 #2
0
void shine_format_bitstream(shine_global_config *config)
{
    int gr, ch, i;

    for (ch = 0; ch < config->wave.channels; ch++)
        for (gr = 0; gr < config->mpeg.granules_per_frame; gr++)
        {
            int *pi     = &config->l3_enc[ch][gr][0];
            int32_t *pr = &config->mdct_freq[ch][gr][0];
            for (i = 0; i < GRANULE_SIZE; i++)
            {
                if ((pr[i] < 0) && (pi[i] > 0))
                    pi[i] *= -1;
            }
        }

    encodeSideInfo(config);
    encodeMainData(config);
}
예제 #3
0
void III_format_bitstream(	int              bitsPerFrame,
														frame_params     *in_fr_ps,
														int              l3_enc[2][2][576],
														III_side_info_t  *l3_side,
														III_scalefac_t   *scalefac,
														double           (*xr)[2][576],
														char             *ancillary,
														int              ancillary_bits )
{
  int gr, ch, i, mode_gr;
  fr_ps = in_fr_ps;
  stereo = fr_ps->stereo;
  mode_gr = 2;
  
  if ( !PartHoldersInitialized )
  {
		headerPH = initBitHolder( &sFrameData.header, 16*2 );
		frameSIPH = initBitHolder( &sFrameData.frameSI, 4*2 );

		for ( ch = 0; ch < MAX_CHANNELS; ch++ )
	    channelSIPH[ch] = initBitHolder( &sFrameData.channelSI[ch], 8*2 );

		for ( gr = 0; gr < MAX_GRANULES; gr++ )	
	    for ( ch = 0; ch < MAX_CHANNELS; ch++ )
	    {
				spectrumSIPH[gr][ch]   = initBitHolder( &sFrameData.spectrumSI[gr][ch], 32*2 );
				scaleFactorsPH[gr][ch] = initBitHolder( &sFrameData.scaleFactors[gr][ch], 64*2 );
				codedDataPH[gr][ch]    = initBitHolder( &sFrameData.codedData[gr][ch], 576*2 );
				userSpectrumPH[gr][ch] = initBitHolder( &sFrameData.userSpectrum[gr][ch], 4*2 );
	    }
		userFrameDataPH = initBitHolder( &sFrameData.userFrameData, 8*2 );
		
		
		PartHoldersInitialized = 1;
  }

#if 1
  for ( gr = 0; gr < mode_gr; gr++ )
		for ( ch =  0; ch < stereo; ch++ )
		{
	    int *pi = &l3_enc[gr][ch][0];
	    double *pr = &xr[gr][ch][0];
	    for ( i = 0; i < 576; i++, pr++, pi++ )
		  {
				if ( (*pr < 0) && (*pi > 0) )
				  *pi *= -1;
	    }
		}
#endif

  encodeSideInfo( l3_side );
  encodeMainData( l3_enc, l3_side, scalefac );
  write_ancillary_data( ancillary, ancillary_bits );

  if ( l3_side->resvDrain )
		drain_into_ancillary_data( l3_side->resvDrain );

  sFrameData.frameLength = bitsPerFrame;
  sFrameData.nGranules   = mode_gr;
  sFrameData.nChannels   = stereo;

  writeFrame( &sFrameData, &sFrameResults );

  /* we set this here -- it will be tested in the next loops iteration */
  l3_side->main_data_begin = sFrameResults.nextBackPtr;
}