Example #1
0
main() 
{
int fd;
  unsigned char* dataptr;
   huffmanTable stdTable = {
    { 0 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 3 , 0 },
    { 1 , 2 , 0 , 3 , 4 , 5 , 6 , 7 , 8 },
  };   
int i;

unsigned long long before , after;
  jEncoder enc = initEncoder(512,512);

  fd = open("prelude.pm",O_RDWR);
  read(fd,frame,262144);
  
  setupTables(enc,&stdTable);
  dmGetUST(&before);
  dataptr = (char*)getBitsPtr(enc);
  printf("%02x %02x %d\n",dataptr[55] , dataptr[56] , i);
  for(i = 0; i < 1000; i++) {
    encodeFrame(enc,(char*)frame);
    /*   printf("%02x %02x %d\n",dataptr[55] , dataptr[56] , i);*/
  }
  dmGetUST(&after);
  printf("%lld\n",(after - before)/i);
  printf("compressed size: %d\n",getCompressedSize(enc));
  fd = open("jout",O_WRONLY|O_CREAT,0666);
  write(fd,getBitsPtr(enc),getCompressedSize(enc));
  close(fd);

}
Example #2
0
/*
==============
SNDDMA_GetDMAPos

return the current sample position (in mono samples, not stereo)
inside the recirculating dma buffer, so the mixing code will know
how many sample are required to fill it up.
===============
*/
int SNDDMA_GetDMAPos(void)
{
    long long ustFuture, ustNow;
    if (!sgisnd_aport) return( 0 );
    alGetFrameTime( sgisnd_aport, &sgisnd_startframe, &ustFuture );
    dmGetUST( (unsigned long long *)&ustNow );
    sgisnd_startframe -= (long long)((ustFuture - ustNow) * sgisnd_frames_per_ns);
    sgisnd_startframe += 100;
//printf( "frame %ld pos %d\n", frame, UST_TO_BUFFPOS( sgisnd_startframe ) );
    return( UST_TO_BUFFPOS( sgisnd_startframe ) );
}