예제 #1
0
int main(int argc,char* argv[]){
  int len;
  int total=0;
  float length;
  int r;
  int audio_fd;
  
  mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
  if(!mp3file){  printf("file not found\n");  exit(1); }
  
  GetCpuCaps(&gCpuCaps);

  // MPEG Audio:
#ifdef USE_FAKE_MONO
  MP3_Init(0);
#else
  MP3_Init();
#endif
  MP3_samplerate=MP3_channels=0;
  len=MP3_DecodeFrame(buffer,-1);
  
  audio_fd=open("/dev/dsp", O_WRONLY);
  if(audio_fd<0){  printf("Can't open audio device\n");exit(1); }
  r=AFMT_S16_LE;ioctl (audio_fd, SNDCTL_DSP_SETFMT, &r);
  r=MP3_channels-1;ioctl (audio_fd, SNDCTL_DSP_STEREO, &r);
  r=MP3_samplerate;ioctl (audio_fd, SNDCTL_DSP_SPEED, &r);
  printf("audio_setup: using %d Hz samplerate (requested: %d)\n",r,MP3_samplerate);
  
  while(1){
      int len2;
      if(len==0) len=MP3_DecodeFrame(buffer,-1);
      if(len<=0) break; // EOF
      
      // play it
      len2=write(audio_fd,buffer,len);
      if(len2<0) break; // ERROR?
      len-=len2; total+=len2;
      if(len>0){
          // this shouldn't happen...
          memcpy(buffer,buffer+len2,len);
          putchar('!');fflush(stdout);
      }
  }
  
  fclose(mp3file);
  
}
예제 #2
0
void print_version(const char* name)
{
    mp_msg(MSGT_CPLAYER, MSGL_INFO, MP_TITLE, name);

    /* Test for CPU capabilities (and corresponding OS support) for optimizing */
    GetCpuCaps(&gCpuCaps);
#if ARCH_X86
    mp_msg(MSGT_CPLAYER, MSGL_V,
           "CPUflags:  MMX: %d MMX2: %d 3DNow: %d 3DNowExt: %d SSE: %d SSE2: %d SSE3: %d SSSE3: %d SSE4: %d SSE4.2: %d AVX: %d\n",
           gCpuCaps.hasMMX, gCpuCaps.hasMMX2,
           gCpuCaps.has3DNow, gCpuCaps.has3DNowExt,
           gCpuCaps.hasSSE, gCpuCaps.hasSSE2, gCpuCaps.hasSSE3,
           gCpuCaps.hasSSSE3, gCpuCaps.hasSSE4, gCpuCaps.hasSSE42,
           gCpuCaps.hasAVX);
#if CONFIG_RUNTIME_CPUDETECT
    mp_msg(MSGT_CPLAYER, MSGL_V, "Compiled with runtime CPU detection.\n");
#else
    mp_msg(MSGT_CPLAYER, MSGL_V, "Compiled for x86 CPU with extensions:");
if (HAVE_MMX)
    mp_msg(MSGT_CPLAYER,MSGL_V," MMX");
if (HAVE_MMX2)
    mp_msg(MSGT_CPLAYER,MSGL_V," MMX2");
if (HAVE_AMD3DNOW)
    mp_msg(MSGT_CPLAYER,MSGL_V," 3DNow");
if (HAVE_AMD3DNOWEXT)
    mp_msg(MSGT_CPLAYER,MSGL_V," 3DNowExt");
if (HAVE_SSE)
    mp_msg(MSGT_CPLAYER,MSGL_V," SSE");
if (HAVE_SSE2)
    mp_msg(MSGT_CPLAYER,MSGL_V," SSE2");
if (HAVE_SSE3)
    mp_msg(MSGT_CPLAYER,MSGL_V," SSE3");
if (HAVE_SSSE3)
    mp_msg(MSGT_CPLAYER,MSGL_V," SSSE3");
if (HAVE_SSE4)
    mp_msg(MSGT_CPLAYER,MSGL_V," SSE4");
if (HAVE_SSE42)
    mp_msg(MSGT_CPLAYER,MSGL_V," SSE4.2");
if (HAVE_AVX)
    mp_msg(MSGT_CPLAYER,MSGL_V," AVX");
if (HAVE_CMOV)
    mp_msg(MSGT_CPLAYER,MSGL_V," CMOV");
    mp_msg(MSGT_CPLAYER,MSGL_V,"\n");
#endif /* CONFIG_RUNTIME_CPUDETECT */
#endif /* ARCH_X86 */
}
int main(int argc,char* argv[]){
  int len;
  int total=0;
  unsigned int time1;
  float length;
#ifdef DUMP_PCM
  FILE *f=NULL;
  f=fopen("test.pcm","wb");
#endif

  mp3file=fopen((argc>1)?argv[1]:"test.mp3","rb");
  if(!mp3file){  printf("file not found\n");  exit(1); }

  GetCpuCaps(&gCpuCaps);

  // MPEG Audio:
#ifdef CONFIG_FAKE_MONO
  MP3_Init(0);
#else
  MP3_Init();
#endif
  MP3_samplerate=MP3_channels=0;

  time1=GetTimer();
  while((len=MP3_DecodeFrame(buffer,-1))>0 && total<2000000){
      total+=len;
      // play it
#ifdef DUMP_PCM
      fwrite(buffer,len,1,f);
#endif
      //putchar('.');fflush(stdout);
  }
  time1=GetTimer()-time1;
  length=(float)total/(float)(MP3_samplerate*MP3_channels*2);
  printf("\nDecoding time: %8.6f\n",(float)time1*0.000001f);
  printf("Uncompressed size: %d bytes  (%8.3f secs)\n",total,length);
  printf("CPU usage at normal playback: %5.2f %%\n",time1*0.0001f/length);

  fclose(mp3file);
  return 0;
}
예제 #4
0
// module init function
PyMODINIT_FUNC initpygoom(void)
{
    import_pygame_surface();
    Py_InitModule("pygoom", pygoomMethods);
#ifdef VERBOSE
    CpuCaps caps;
    GetCpuCaps(&caps);
    printf ("cpuType = %d\n", caps.cpuType);
    printf ("cpuModel = %d\n", caps.cpuModel);
    printf ("cpuStepping = %d\n", caps.cpuStepping);
    printf ("hasMMX = %d\n", caps.hasMMX);
    printf ("hasMMX2 = %d\n", caps.hasMMX2);
    printf ("has3DNow = %d\n", caps.has3DNow);
    printf ("has3DNowExt = %d\n", caps.has3DNowExt);
    printf ("hasSSE = %d\n", caps.hasSSE);
    printf ("hasSSE2 = %d\n", caps.hasSSE2);
    printf ("isX86 = %d\n", caps.isX86);
    printf ("cl_size = %u\n", caps.cl_size); /* size of cache line */
    printf ("hasAltiVec = %d\n", caps.hasAltiVec);
    printf ("hasTSC = %d\n", caps.hasTSC);
#endif
}
예제 #5
0
main(int argc, char **argv)
{
	int i, funcNum;
	uint8_t *srcBuffer= (uint8_t*)memalign(128, SIZE);
	uint8_t *dstBuffer= (uint8_t*)memalign(128, SIZE);
	int failedNum=0;
	int passedNum=0;
	
	printf("memory corruption test ...\n");
	
	if(argc==2){
		GetCpuCaps(&gCpuCaps);
		printf("testing mmx\n");
	}
	
	sws_rgb2rgb_init(get_sws_cpuflags());
	
	for(funcNum=0; funcNum<100; funcNum++){
		int width;
		int failed=0;
		int srcBpp=0;
		int dstBpp=0;

		printf("."); fflush(stdout);
		memset(srcBuffer, srcByte, SIZE);

		for(width=32; width<64; width++){
			int dstOffset;
			for(dstOffset=128; dstOffset<196; dstOffset++){
				int srcOffset;
				memset(dstBuffer, dstByte, SIZE);

				for(srcOffset=128; srcOffset<196; srcOffset++){
					uint8_t *src= srcBuffer+srcOffset;
					uint8_t *dst= dstBuffer+dstOffset;
					char *name=NULL;
					
					if(failed) break; //don't fill the screen with shit ...

					switch(funcNum){
					case 0:
						srcBpp=2;
						dstBpp=2;
						name="rgb15to16";
						rgb15to16(src, dst, width*srcBpp);
						break;
					case 1:
						srcBpp=2;
						dstBpp=3;
						name="rgb15to24";
						rgb15to24(src, dst, width*srcBpp);
						break;
					case 2:
						srcBpp=2;
						dstBpp=4;
						name="rgb15to32";
						rgb15to32(src, dst, width*srcBpp);
						break;
					case 3:
						srcBpp=2;
						dstBpp=3;
						name="rgb16to24";
						rgb16to24(src, dst, width*srcBpp);
						break;
					case 4:
						srcBpp=2;
						dstBpp=4;
						name="rgb16to32";
						rgb16to32(src, dst, width*srcBpp);
						break;
					case 5:
						srcBpp=3;
						dstBpp=2;
						name="rgb24to15";
						rgb24to15(src, dst, width*srcBpp);
						break;
					case 6:
						srcBpp=3;
						dstBpp=2;
						name="rgb24to16";
						rgb24to16(src, dst, width*srcBpp);
						break;
					case 7:
						srcBpp=3;
						dstBpp=4;
						name="rgb24to32";
						rgb24to32(src, dst, width*srcBpp);
						break;
					case 8:
						srcBpp=4;
						dstBpp=2;
						name="rgb32to15";
						rgb32to15(src, dst, width*srcBpp);
						break;
					case 9:
						srcBpp=4;
						dstBpp=2;
						name="rgb32to16";
						rgb32to16(src, dst, width*srcBpp);
						break;
					case 10:
						srcBpp=4;
						dstBpp=3;
						name="rgb32to24";
						rgb32to24(src, dst, width*srcBpp);
						break;
					case 11:
						srcBpp=2;
						dstBpp=2;
						name="rgb16to15";
						rgb16to15(src, dst, width*srcBpp);
						break;
					
					case 14:
						srcBpp=2;
						dstBpp=2;
						name="rgb15tobgr15";
						rgb15tobgr15(src, dst, width*srcBpp);
						break;
					case 15:
						srcBpp=2;
						dstBpp=2;
						name="rgb15tobgr16";
						rgb15tobgr16(src, dst, width*srcBpp);
						break;
					case 16:
						srcBpp=2;
						dstBpp=3;
						name="rgb15tobgr24";
						rgb15tobgr24(src, dst, width*srcBpp);
						break;
					case 17:
						srcBpp=2;
						dstBpp=4;
						name="rgb15tobgr32";
						rgb15tobgr32(src, dst, width*srcBpp);
						break;
					case 18:
						srcBpp=2;
						dstBpp=2;
						name="rgb16tobgr15";
						rgb16tobgr15(src, dst, width*srcBpp);
						break;
					case 19:
						srcBpp=2;
						dstBpp=2;
						name="rgb16tobgr16";
						rgb16tobgr16(src, dst, width*srcBpp);
						break;
					case 20:
						srcBpp=2;
						dstBpp=3;
						name="rgb16tobgr24";
						rgb16tobgr24(src, dst, width*srcBpp);
						break;
					case 21:
						srcBpp=2;
						dstBpp=4;
						name="rgb16tobgr32";
						rgb16tobgr32(src, dst, width*srcBpp);
						break;
					case 22:
						srcBpp=3;
						dstBpp=2;
						name="rgb24tobgr15";
						rgb24tobgr15(src, dst, width*srcBpp);
						break;
					case 23:
						srcBpp=3;
						dstBpp=2;
						name="rgb24tobgr16";
						rgb24tobgr16(src, dst, width*srcBpp);
						break;
					case 24:
						srcBpp=3;
						dstBpp=3;
						name="rgb24tobgr24";
						rgb24tobgr24(src, dst, width*srcBpp);
						break;
					case 25:
						srcBpp=3;
						dstBpp=4;
						name="rgb24tobgr32";
						rgb24tobgr32(src, dst, width*srcBpp);
						break;
					case 26:
						srcBpp=4;
						dstBpp=2;
						name="rgb32tobgr15";
						rgb32tobgr15(src, dst, width*srcBpp);
						break;
					case 27:
						srcBpp=4;
						dstBpp=2;
						name="rgb32tobgr16";
						rgb32tobgr16(src, dst, width*srcBpp);
						break;
					case 28:
						srcBpp=4;
						dstBpp=3;
						name="rgb32tobgr24";
						rgb32tobgr24(src, dst, width*srcBpp);
						break;
					case 29:
						srcBpp=4;
						dstBpp=4;
						name="rgb32tobgr32";
						rgb32tobgr32(src, dst, width*srcBpp);
						break;

					}
					if(!srcBpp) break;

					for(i=0; i<SIZE; i++){
						if(srcBuffer[i]!=srcByte){
							printf("src damaged at %d w:%d src:%d dst:%d %s\n", 
								i, width, srcOffset, dstOffset, name);
							failed=1;
							break;
						}
					}
					for(i=0; i<dstOffset; i++){
						if(dstBuffer[i]!=dstByte){
							printf("dst damaged at %d w:%d src:%d dst:%d %s\n", 
								i, width, srcOffset, dstOffset, name);
							failed=1;
							break;
						}
					}
					for(i=dstOffset + width*dstBpp; i<SIZE; i++){
						if(dstBuffer[i]!=dstByte){
							printf("dst damaged at %d w:%d src:%d dst:%d %s\n", 
								i, width, srcOffset, dstOffset, name);
							failed=1;
							break;
						}
					}
				}
			}
		}
		if(failed) failedNum++;
		else if(srcBpp) passedNum++;
	}
	
	printf("%d converters passed, %d converters randomly overwrote memory\n", passedNum, failedNum);
	return failedNum;
}