annotate libmpcodecs/ad_liba52.c @ 13873:89bbd098cfda

slight grammar/wording/spelling/markup improvements
author diego
date Fri, 05 Nov 2004 10:14:39 +0000
parents 9d0b052c4f74
children 878745349274
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
1 #include <stdio.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
2 #include <stdlib.h>
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
3 #include <unistd.h>
12285
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
4 #include <math.h>
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
5
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
6 #include "config.h"
8026
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7191
diff changeset
7 #ifdef USE_LIBA52
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7191
diff changeset
8
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
9 #include "mp_msg.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
10 #include "help_mp.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
11
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
12 #include "ad_internal.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
13
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
14 #include "cpudetect.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
15
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
16 #include "../liba52/a52.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
17 #include "../liba52/mm_accel.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
18
5341
6c1d264cc214 do not export the World
arpi
parents: 5340
diff changeset
19 static sample_t * a52_samples;
6c1d264cc214 do not export the World
arpi
parents: 5340
diff changeset
20 static a52_state_t a52_state;
6c1d264cc214 do not export the World
arpi
parents: 5340
diff changeset
21 static uint32_t a52_flags=0;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
22
12285
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
23 #define DRC_NO_ACTION 0
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
24 #define DRC_NO_COMPRESSION 1
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
25 #define DRC_CALLBACK 2
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
26
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
27 float a52_drc_level = 1.0;
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
28 static int a52_drc_action = DRC_NO_ACTION;
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
29
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
30 #include "bswap.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
31
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
32 static ad_info_t info =
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
33 {
7191
1eadce15446c -afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents: 7180
diff changeset
34 "AC3 decoding with liba52",
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
35 "liba52",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
36 "Nick Kurshev",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
37 "Michel LESPINASSE",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
38 ""
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
39 };
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
40
5343
3dd532400d44 argh... Nick messed up driver names too
arpi
parents: 5341
diff changeset
41 LIBAD_EXTERN(liba52)
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
42
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
43 extern int audio_output_channels;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
44
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
45 int a52_fillbuff(sh_audio_t *sh_audio){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
46 int length=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
47 int flags=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
48 int sample_rate=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
49 int bit_rate=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
50
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
51 sh_audio->a_in_buffer_len=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
52 /* sync frame:*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
53 while(1){
10119
1a777e2b8228 ac3 byteswapping support (when format!=0x2000)
arpi
parents: 9003
diff changeset
54 while(sh_audio->a_in_buffer_len<8){
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
55 int c=demux_getc(sh_audio->ds);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
56 if(c<0) return -1; /* EOF*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
57 sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
58 }
10119
1a777e2b8228 ac3 byteswapping support (when format!=0x2000)
arpi
parents: 9003
diff changeset
59 if(sh_audio->format!=0x2000) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
60 length = a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
61 if(length>=7 && length<=3840) break; /* we're done.*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
62 /* bad file => resync*/
10119
1a777e2b8228 ac3 byteswapping support (when format!=0x2000)
arpi
parents: 9003
diff changeset
63 if(sh_audio->format!=0x2000) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8);
1a777e2b8228 ac3 byteswapping support (when format!=0x2000)
arpi
parents: 9003
diff changeset
64 memcpy(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,7);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
65 --sh_audio->a_in_buffer_len;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
66 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
67 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"a52: len=%d flags=0x%X %d Hz %d bit/s\n",length,flags,sample_rate,bit_rate);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
68 sh_audio->samplerate=sample_rate;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
69 sh_audio->i_bps=bit_rate/8;
13427
9d0b052c4f74 setting samplesize to 2 in decoders where neccessary.
reimar
parents: 12285
diff changeset
70 sh_audio->samplesize=2;
10119
1a777e2b8228 ac3 byteswapping support (when format!=0x2000)
arpi
parents: 9003
diff changeset
71 demux_read_data(sh_audio->ds,sh_audio->a_in_buffer+8,length-8);
1a777e2b8228 ac3 byteswapping support (when format!=0x2000)
arpi
parents: 9003
diff changeset
72 if(sh_audio->format!=0x2000)
1a777e2b8228 ac3 byteswapping support (when format!=0x2000)
arpi
parents: 9003
diff changeset
73 swab(sh_audio->a_in_buffer+8,sh_audio->a_in_buffer+8,length-8);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
74
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
75 if(crc16_block(sh_audio->a_in_buffer+2,length-2)!=0)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
76 mp_msg(MSGT_DECAUDIO,MSGL_STATUS,"a52: CRC check failed! \n");
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
77
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
78 return length;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
79 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
80
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
81 /* returns: number of available channels*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
82 static int a52_printinfo(sh_audio_t *sh_audio){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
83 int flags, sample_rate, bit_rate;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
84 char* mode="unknown";
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
85 int channels=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
86 a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
87 switch(flags&A52_CHANNEL_MASK){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
88 case A52_CHANNEL: mode="channel"; channels=2; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
89 case A52_MONO: mode="mono"; channels=1; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
90 case A52_STEREO: mode="stereo"; channels=2; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
91 case A52_3F: mode="3f";channels=3;break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
92 case A52_2F1R: mode="2f+1r";channels=3;break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
93 case A52_3F1R: mode="3f+1r";channels=4;break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
94 case A52_2F2R: mode="2f+2r";channels=4;break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
95 case A52_3F2R: mode="3f+2r";channels=5;break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
96 case A52_CHANNEL1: mode="channel1"; channels=2; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
97 case A52_CHANNEL2: mode="channel2"; channels=2; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
98 case A52_DOLBY: mode="dolby"; channels=2; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
99 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
100 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"AC3: %d.%d (%s%s) %d Hz %3.1f kbit/s\n",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
101 channels, (flags&A52_LFE)?1:0,
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
102 mode, (flags&A52_LFE)?"+lfe":"",
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
103 sample_rate, bit_rate*0.001f);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
104 return (flags&A52_LFE) ? (channels+1) : channels;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
105 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
106
12285
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
107 sample_t dynrng_call (sample_t c, void *data) {
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
108 // fprintf(stderr, "(%lf, %lf): %lf\n", (double)c, (double)a52_drc_level, (double)pow((double)c, a52_drc_level));
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
109 return pow((double)c, a52_drc_level);
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
110 }
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
111
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
112
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
113 static int preinit(sh_audio_t *sh)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
114 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
115 /* Dolby AC3 audio: */
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
116 /* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
117 sh->audio_out_minsize=audio_output_channels*2*256*6;
5458
b3d1348b251f audio input buffer allocation/free cleanup
arpi
parents: 5343
diff changeset
118 sh->audio_in_minsize=3840;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
119 return 1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
120 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
121
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
122 static int init(sh_audio_t *sh_audio)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
123 {
5341
6c1d264cc214 do not export the World
arpi
parents: 5340
diff changeset
124 uint32_t a52_accel=0;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
125 sample_t level=1, bias=384;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
126 int flags=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
127 /* Dolby AC3 audio:*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
128 if(gCpuCaps.hasSSE) a52_accel|=MM_ACCEL_X86_SSE;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
129 if(gCpuCaps.hasMMX) a52_accel|=MM_ACCEL_X86_MMX;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
130 if(gCpuCaps.hasMMX2) a52_accel|=MM_ACCEL_X86_MMXEXT;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
131 if(gCpuCaps.has3DNow) a52_accel|=MM_ACCEL_X86_3DNOW;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
132 if(gCpuCaps.has3DNowExt) a52_accel|=MM_ACCEL_X86_3DNOWEXT;
9003
c428933c7e54 AltiVec detection code ("borrowed" from FFmpeg and
arpi
parents: 8026
diff changeset
133 if(gCpuCaps.hasAltiVec) a52_accel|=MM_ACCEL_PPC_ALTIVEC;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
134 a52_samples=a52_init (a52_accel);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
135 if (a52_samples == NULL) {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
136 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n");
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
137 return 0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
138 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
139 if(a52_fillbuff(sh_audio)<0){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
140 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n");
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
141 return 0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
142 }
12285
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
143
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
144
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
145 /* Init a52 dynrng */
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
146 if (a52_drc_level < 0.001) {
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
147 /* level == 0 --> no compression, init library without callback */
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
148 a52_drc_action = DRC_NO_COMPRESSION;
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
149 } else if (a52_drc_level > 0.999) {
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
150 /* level == 1 --> full compression, do nothing at all (library default = full compression) */
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
151 a52_drc_action = DRC_NO_ACTION;
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
152 } else {
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
153 a52_drc_action = DRC_CALLBACK;
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
154 }
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
155 /* Library init for dynrng has to be done for each frame, see decode_audio() */
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
156
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
157
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
158 /* 'a52 cannot upmix' hotfix:*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
159 a52_printinfo(sh_audio);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
160 sh_audio->channels=audio_output_channels;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
161 while(sh_audio->channels>0){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
162 switch(sh_audio->channels){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
163 case 1: a52_flags=A52_MONO; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
164 /* case 2: a52_flags=A52_STEREO; break;*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
165 case 2: a52_flags=A52_DOLBY; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
166 /* case 3: a52_flags=A52_3F; break;*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
167 case 3: a52_flags=A52_2F1R; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
168 case 4: a52_flags=A52_2F2R; break; /* 2+2*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
169 case 5: a52_flags=A52_3F2R; break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
170 case 6: a52_flags=A52_3F2R|A52_LFE; break; /* 5.1*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
171 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
172 /* test:*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
173 flags=a52_flags|A52_ADJUST_LEVEL;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
174 mp_msg(MSGT_DECAUDIO,MSGL_V,"A52 flags before a52_frame: 0x%X\n",flags);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
175 if (a52_frame (&a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
176 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"a52: error decoding frame -> nosound\n");
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
177 return 0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
178 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
179 mp_msg(MSGT_DECAUDIO,MSGL_V,"A52 flags after a52_frame: 0x%X\n",flags);
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
180 /* frame decoded, let's init resampler:*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
181 if(a52_resample_init(a52_accel,flags,sh_audio->channels)) break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
182 --sh_audio->channels; /* try to decrease no. of channels*/
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
183 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
184 if(sh_audio->channels<=0){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
185 mp_msg(MSGT_DECAUDIO,MSGL_ERR,"a52: no resampler. try different channel setup!\n");
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
186 return 0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
187 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
188 return 1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
189 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
190
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
191 static void uninit(sh_audio_t *sh)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
192 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
193 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
194
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
195 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
196 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
197 switch(cmd)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
198 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
199 case ADCTRL_SKIP_FRAME:
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
200 a52_fillbuff(sh); break; // skip AC3 frame
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
201 return CONTROL_TRUE;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
202 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
203 return CONTROL_UNKNOWN;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
204 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
205
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
206 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
207 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
208 sample_t level=1, bias=384;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
209 int flags=a52_flags|A52_ADJUST_LEVEL;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
210 int i,len=-1;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
211 if(!sh_audio->a_in_buffer_len)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
212 if(a52_fillbuff(sh_audio)<0) return len; /* EOF */
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
213 sh_audio->a_in_buffer_len=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
214 if (a52_frame (&a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
215 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error decoding frame\n");
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
216 return len;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
217 }
12285
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
218
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
219 /* handle dynrng */
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
220 if (a52_drc_action != DRC_NO_ACTION) {
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
221 if (a52_drc_action == DRC_NO_COMPRESSION)
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
222 a52_dynrng(&a52_state, NULL, NULL);
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
223 else
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
224 a52_dynrng(&a52_state, dynrng_call, NULL);
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
225 }
67b8d64af8c7 a52 dynamic range compression support by Peter Gansterer
alex
parents: 10978
diff changeset
226
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
227 len=0;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
228 for (i = 0; i < 6; i++) {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
229 if (a52_block (&a52_state, a52_samples)){
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
230 mp_msg(MSGT_DECAUDIO,MSGL_WARN,"a52: error at resampling\n");
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
231 break;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
232 }
7127
1e47c2e7aa8e mostly compiler warning fixes, some small bugfix
arpi
parents: 5458
diff changeset
233 len+=2*a52_resample(a52_samples,(int16_t *)&buf[len]);
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
234 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
235 return len;
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
236 }
8026
b465ba5897a3 usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents: 7191
diff changeset
237 #endif