Mercurial > mplayer.hg
annotate libmpcodecs/ad_liba52.c @ 17314:1bdc7230ea29
Bandaid fix for compilation failure when creating main/.depend with GUI
enabled. This is only a problem if .developer is not present.
author | diego |
---|---|
date | Wed, 04 Jan 2006 15:54:47 +0000 |
parents | 6ff3379a0862 |
children | befc16265bb1 |
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> |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
5 #include <assert.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
|
6 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
7 #include "config.h" |
8026
b465ba5897a3
usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents:
7191
diff
changeset
|
8 #ifdef USE_LIBA52 |
b465ba5897a3
usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents:
7191
diff
changeset
|
9 |
5340
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 "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
|
11 #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
|
12 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
13 #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
|
14 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
15 #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
|
16 |
17012 | 17 #include "libaf/af_format.h" |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
18 |
17012 | 19 #include "liba52/a52.h" |
20 #include "liba52/mm_accel.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
|
21 |
5341 | 22 static sample_t * a52_samples; |
23 static a52_state_t a52_state; | |
24 static uint32_t a52_flags=0; | |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
25 /** Used by a52_resample_float, it defines the mapping between liba52 |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
26 * channels and output channels. The ith nibble from the right in the |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
27 * hex representation of channel_map is the index of the source |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
28 * channel corresponding to the ith output channel. Source channels are |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
29 * indexed 1-6. Silent output channels are marked by 0xf. */ |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
30 static uint32_t channel_map; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
31 |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
32 #define DRC_NO_ACTION 0 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
33 #define DRC_NO_COMPRESSION 1 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
34 #define DRC_CALLBACK 2 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
35 |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
36 /** The output is multiplied by this var. Used for volume control */ |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
37 static sample_t a52_level = 1; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
38 /** The value of the -a52drc switch. */ |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
39 float a52_drc_level = 1.0; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
40 static int a52_drc_action = DRC_NO_ACTION; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
41 |
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 #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
|
43 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
44 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
|
45 { |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
46 "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
|
47 "liba52", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
48 "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
|
49 "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
|
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 }; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
52 |
5343 | 53 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
|
54 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
55 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
|
56 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
57 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
|
58 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
|
59 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
|
60 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
|
61 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
|
62 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
63 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
|
64 /* 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
|
65 while(1){ |
10119 | 66 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
|
67 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
|
68 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
|
69 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
|
70 } |
10119 | 71 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
|
72 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
|
73 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
|
74 /* bad file => resync*/ |
10119 | 75 if(sh_audio->format!=0x2000) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8); |
15560 | 76 memmove(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
|
77 --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
|
78 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
79 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
|
80 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
|
81 sh_audio->i_bps=bit_rate/8; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
82 sh_audio->samplesize=sh_audio->sample_format==AF_FORMAT_FLOAT_NE ? 4 : 2; |
10119 | 83 demux_read_data(sh_audio->ds,sh_audio->a_in_buffer+8,length-8); |
84 if(sh_audio->format!=0x2000) | |
85 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
|
86 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
87 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
|
88 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
|
89 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
90 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
|
91 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
92 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
93 /* 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
|
94 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
|
95 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
|
96 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
|
97 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
|
98 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
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
112 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
|
113 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
|
114 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
|
115 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
|
116 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
|
117 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
118 |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
119 sample_t dynrng_call (sample_t c, void *data) { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
120 // 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
|
121 return pow((double)c, a52_drc_level); |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
122 } |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
123 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
124 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
125 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
|
126 { |
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 /* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ |
15559
9f157ca7e3c2
Make sure that samplesize is at least 2, as some demuxers set it to 1
hzoli
parents:
15558
diff
changeset
|
129 if (sh->samplesize < 2) sh->samplesize = 2; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
130 sh->audio_out_minsize=audio_output_channels*sh->samplesize*256*6; |
5458 | 131 sh->audio_in_minsize=3840; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
132 a52_level = 1.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
|
133 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
|
134 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
135 |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
136 /** |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
137 * \brief Function to convert the "planar" float format used by liba52 |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
138 * into the interleaved float format used by libaf/libao2. |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
139 * \param in the input buffer containing the planar samples. |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
140 * \param out the output buffer where the interleaved result is stored. |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
141 */ |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
142 static int a52_resample_float(float *in, int16_t *out) |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
143 { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
144 unsigned long i; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
145 float *p = (float*) out; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
146 for (i = 0; i != 256; i++) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
147 unsigned long map = channel_map; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
148 do { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
149 unsigned long ch = map & 15; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
150 if (ch == 15) |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
151 *p = 0; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
152 else |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
153 *p = in[i + ((ch-1)<<8)]; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
154 p++; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
155 } while ((map >>= 4)); |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
156 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
157 return (int16_t*) p - out; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
158 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
159 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
160 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
|
161 { |
5341 | 162 uint32_t a52_accel=0; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
163 sample_t level=a52_level, bias=384; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
164 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
|
165 /* 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 if(gCpuCaps.has3DNowExt) a52_accel|=MM_ACCEL_X86_3DNOWEXT; |
9003 | 171 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
|
172 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
|
173 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
|
174 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
|
175 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
|
176 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
177 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
|
178 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
|
179 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
|
180 } |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
181 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
182 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
183 /* Init a52 dynrng */ |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
184 if (a52_drc_level < 0.001) { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
185 /* level == 0 --> no compression, init library without callback */ |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
186 a52_drc_action = DRC_NO_COMPRESSION; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
187 } else if (a52_drc_level > 0.999) { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
188 /* 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
|
189 a52_drc_action = DRC_NO_ACTION; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
190 } else { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
191 a52_drc_action = DRC_CALLBACK; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
192 } |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
193 /* 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
|
194 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
195 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
196 /* '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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 /* 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
|
203 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
|
204 /* 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
210 /* test:*/ |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
211 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
|
212 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
|
213 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
|
214 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
|
215 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
|
216 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
217 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
|
218 /* frame decoded, let's init resampler:*/ |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
219 channel_map = 0; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
220 if (sh_audio->sample_format == AF_FORMAT_FLOAT_NE) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
221 if (!(flags & A52_LFE)) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
222 switch ((flags<<3) | sh_audio->channels) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
223 case (A52_MONO << 3) | 1: channel_map = 0x1; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
224 case (A52_CHANNEL << 3) | 2: |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
225 case (A52_STEREO << 3) | 2: |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
226 case (A52_DOLBY << 3) | 2: channel_map = 0x21; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
227 case (A52_2F1R << 3) | 3: channel_map = 0x321; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
228 case (A52_2F2R << 3) | 4: channel_map = 0x4321; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
229 case (A52_3F << 3) | 5: channel_map = 0x2ff31; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
230 case (A52_3F2R << 3) | 5: channel_map = 0x25431; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
231 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
232 } else if (sh_audio->channels == 6) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
233 switch (flags & ~A52_LFE) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
234 case A52_MONO : channel_map = 0x12ffff; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
235 case A52_CHANNEL: |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
236 case A52_STEREO : |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
237 case A52_DOLBY : channel_map = 0x1fff32; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
238 case A52_3F : channel_map = 0x13ff42; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
239 case A52_2F1R : channel_map = 0x1f4432; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
240 case A52_2F2R : channel_map = 0x1f5432; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
241 case A52_3F2R : channel_map = 0x136542; break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
242 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
243 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
244 if (channel_map) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
245 a52_resample = a52_resample_float; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
246 break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
247 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
248 } else |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
249 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
|
250 --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
|
251 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
252 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
|
253 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
|
254 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
|
255 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
256 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
|
257 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
258 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
259 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
|
260 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
261 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
262 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
263 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
|
264 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
265 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
|
266 { |
15558 | 267 case ADCTRL_RESYNC_STREAM: |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
268 case ADCTRL_SKIP_FRAME: |
15558 | 269 a52_fillbuff(sh); |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
270 return CONTROL_TRUE; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
271 case ADCTRL_SET_VOLUME: { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
272 float vol = *(float*)arg; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
273 if (vol > 60.0) vol = 60.0; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
274 a52_level = vol <= -200.0 ? 0 : pow(10.0,vol/20.0); |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
275 return CONTROL_TRUE; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
276 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
277 case ADCTRL_QUERY_FORMAT: |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
278 if (*(int*)arg == AF_FORMAT_S16_NE || |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
279 *(int*)arg == AF_FORMAT_FLOAT_NE) |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
280 return CONTROL_TRUE; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
281 return CONTROL_FALSE; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
282 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
283 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
|
284 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
285 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
286 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
|
287 { |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
288 sample_t level=a52_level, bias=384; |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
289 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
|
290 int i,len=-1; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
291 if (sh_audio->sample_format == AF_FORMAT_FLOAT_NE) |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
292 bias = 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 } |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
300 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
301 /* handle dynrng */ |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
302 if (a52_drc_action != DRC_NO_ACTION) { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
303 if (a52_drc_action == DRC_NO_COMPRESSION) |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
304 a52_dynrng(&a52_state, NULL, NULL); |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
305 else |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
306 a52_dynrng(&a52_state, dynrng_call, NULL); |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
307 } |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
308 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
309 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
|
310 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
|
311 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
|
312 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
|
313 break; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
314 } |
7127 | 315 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
|
316 } |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
317 assert(len <= maxlen); |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
318 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
|
319 } |
8026
b465ba5897a3
usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents:
7191
diff
changeset
|
320 #endif |