Mercurial > mplayer.hg
annotate liba52/test.c @ 25517:788499fc2ae7
Do not duplicate MJpegContext struct, #include the proper header instead.
This also fixes the warnings:
jpeg_enc.c:342: warning: implicit declaration of function 'ff_mjpeg_encode_init'
jpeg_enc.c:384: warning: implicit declaration of function 'ff_mjpeg_encode_picture_header'
jpeg_enc.c:489: warning: implicit declaration of function 'ff_mjpeg_encode_picture_trailer'
jpeg_enc.c:500: warning: implicit declaration of function 'ff_mjpeg_encode_close'
author | diego |
---|---|
date | Sun, 30 Dec 2007 10:49:43 +0000 |
parents | 853622d14aa4 |
children | 8b013fe0f842 |
rev | line source |
---|---|
3396 | 1 // liba52 sample by A'rpi/ESP-team |
25479 | 2 // Reads an AC-3 stream from stdin, decodes and downmixes to s16 stereo PCM |
3 // and writes it to stdout. The resulting stream is playable with sox: | |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
4 // play -c2 -r48000 -sw -fs out.sw |
3396 | 5 |
3507 | 6 //#define TIMING //needs Pentium or newer |
7 | |
3396 | 8 #include <stdio.h> |
9 #include <stdlib.h> | |
10 #include <inttypes.h> | |
12966 | 11 #include <string.h> |
3396 | 12 |
13 #include "a52.h" | |
3908 | 14 #include "mm_accel.h" |
3579 | 15 #include "../cpudetect.h" |
3396 | 16 |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
17 static a52_state_t *state; |
3396 | 18 static uint8_t buf[3840]; |
19 static int buf_size=0; | |
20 | |
21 static int16_t out_buf[6*256*6]; | |
22 | |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
23 void mp_msg( int x, const char *format, ... ) // stub for cpudetect.c |
12966 | 24 { |
25 } | |
26 | |
3507 | 27 #ifdef TIMING |
28 static inline long long rdtsc() | |
29 { | |
30 long long l; | |
31 asm volatile( "rdtsc\n\t" | |
32 : "=A" (l) | |
33 ); | |
34 // printf("%d\n", int(l/1000)); | |
35 return l; | |
36 } | |
37 | |
38 #define STARTTIMING t=rdtsc(); | |
39 #define ENDTIMING sum+=rdtsc()-t; t=rdtsc(); | |
40 #else | |
41 #define STARTTIMING ; | |
42 #define ENDTIMING ; | |
43 #endif | |
44 | |
45 | |
25100 | 46 int main(void){ |
3396 | 47 int accel=0; |
48 int sample_rate=0; | |
49 int bit_rate=0; | |
3507 | 50 #ifdef TIMING |
3511 | 51 long long t, sum=0, min=256*256*256*64; |
3507 | 52 #endif |
3396 | 53 |
3579 | 54 FILE *temp= stdout; |
55 stdout= stderr; //EVIL HACK FIXME | |
56 GetCpuCaps(&gCpuCaps); | |
57 stdout= temp; | |
3908 | 58 // gCpuCaps.hasMMX=0; |
59 // gCpuCaps.hasSSE=0; | |
60 if(gCpuCaps.hasMMX) accel |= MM_ACCEL_X86_MMX; | |
61 if(gCpuCaps.hasMMX2) accel |= MM_ACCEL_X86_MMXEXT; | |
62 if(gCpuCaps.hasSSE) accel |= MM_ACCEL_X86_SSE; | |
63 if(gCpuCaps.has3DNow) accel |= MM_ACCEL_X86_3DNOW; | |
64 // if(gCpuCaps.has3DNowExt) accel |= MM_ACCEL_X86_3DNOWEXT; | |
3579 | 65 |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
66 state = a52_init (accel); |
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
67 if (state == NULL) { |
3396 | 68 fprintf (stderr, "A52 init failed\n"); |
69 return 1; | |
70 } | |
71 | |
72 while(1){ | |
73 int length,i; | |
74 int16_t *s16; | |
75 sample_t level=1, bias=384; | |
76 int flags=0; | |
3565 | 77 int channels=0; |
3396 | 78 |
79 while(buf_size<7){ | |
80 int c=getchar(); | |
81 if(c<0) goto eof; | |
82 buf[buf_size++]=c; | |
83 } | |
3507 | 84 STARTTIMING |
3396 | 85 length = a52_syncinfo (buf, &flags, &sample_rate, &bit_rate); |
3507 | 86 ENDTIMING |
3396 | 87 if(!length){ |
88 // bad file => resync | |
89 memcpy(buf,buf+1,6); | |
90 --buf_size; | |
91 continue; | |
92 } | |
93 fprintf(stderr,"sync. %d bytes 0x%X %d Hz %d kbit\n",length,flags,sample_rate,bit_rate); | |
94 while(buf_size<length){ | |
95 buf[buf_size++]=getchar(); | |
96 } | |
97 | |
98 buf_size=0; | |
99 | |
100 // decode: | |
3908 | 101 flags=A52_STEREO; //A52_STEREO; //A52_DOLBY; //A52_STEREO; // A52_DOLBY // A52_2F2R // A52_3F2R | A52_LFE |
3565 | 102 channels=2; |
103 | |
3396 | 104 flags |= A52_ADJUST_LEVEL; |
3507 | 105 STARTTIMING |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
106 if (a52_frame (state, buf, &flags, &level, bias)) |
3396 | 107 { fprintf(stderr,"error at decoding\n"); continue; } |
3507 | 108 ENDTIMING |
3396 | 109 |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
110 // a52_dynrng (state, NULL, NULL); // disable dynamic range compensation |
3396 | 111 |
3579 | 112 STARTTIMING |
3908 | 113 a52_resample_init(accel,flags,channels); |
3396 | 114 s16 = out_buf; |
115 for (i = 0; i < 6; i++) { | |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
116 if (a52_block (state)) |
3396 | 117 { fprintf(stderr,"error at sampling\n"); break; } |
3565 | 118 // float->int + channels interleaving: |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
119 s16+=a52_resample(a52_samples(state),s16); |
3579 | 120 ENDTIMING |
3396 | 121 } |
3511 | 122 #ifdef TIMING |
123 if(sum<min) min=sum; | |
124 sum=0; | |
125 #endif | |
3908 | 126 fwrite(out_buf,6*256*2*channels,1,stdout); |
3396 | 127 |
128 } | |
129 | |
130 eof: | |
3507 | 131 #ifdef TIMING |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
132 fprintf(stderr, "%4.4fk cycles\n",min/1000.0); |
3511 | 133 sum=0; |
3507 | 134 #endif |
25486
853622d14aa4
Fix compilation of liba52/test.c testing and benchmarking application.
iive
parents:
25479
diff
changeset
|
135 return 0; |
3396 | 136 } |