Mercurial > mplayer.hg
annotate libmpcodecs/ad_liba52.c @ 30918:be200e917ae1
Remove unused OPTFLAGS variable from config.mak.
author | diego |
---|---|
date | Thu, 25 Mar 2010 19:53:05 +0000 |
parents | ad6740b58b0d |
children | 1aece15222b5 |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
18 |
28445
c6cef3c6768f
Give _XOPEN_SOURCE #define an explicit 600 value. Fixes build on Open Solaris.
diego
parents:
28420
diff
changeset
|
19 #define _XOPEN_SOURCE 600 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
20 #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
|
21 #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
|
22 #include <unistd.h> |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
23 #include <math.h> |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
24 #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
|
25 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
26 #include "config.h" |
8026
b465ba5897a3
usage of libmpeg2, liba52, mp3lib & svq1 can be disabled
arpi
parents:
7191
diff
changeset
|
27 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
28 #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
|
29 #include "help_mp.h" |
23638
a81e246e3b38
Make sure we always have a swab() prototype when we use it,
reimar
parents:
21507
diff
changeset
|
30 #include "mpbswap.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
|
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 #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
|
33 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
34 #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
|
35 |
17012 | 36 #include "libaf/af_format.h" |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
37 |
27588 | 38 #ifdef CONFIG_LIBA52_INTERNAL |
17012 | 39 #include "liba52/a52.h" |
40 #include "liba52/mm_accel.h" | |
27588 | 41 #else |
42 #include <a52dec/a52.h> | |
43 #include <a52dec/mm_accel.h> | |
44 int (* a52_resample) (float * _f, int16_t * s16); | |
45 #endif | |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
46 |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
47 static a52_state_t *a52_state; |
5341 | 48 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
|
49 /** 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
|
50 * 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
|
51 * 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
|
52 * 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
|
53 * 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
|
54 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
|
55 |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
56 #define DRC_NO_ACTION 0 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
57 #define DRC_NO_COMPRESSION 1 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
58 #define DRC_CALLBACK 2 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
59 |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
60 /** 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
|
61 static sample_t a52_level = 1; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
62 /** The value of the -a52drc switch. */ |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
63 float a52_drc_level = 1.0; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
64 static int a52_drc_action = DRC_NO_ACTION; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
65 |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
66 static const ad_info_t info = |
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 { |
7191
1eadce15446c
-afm/-vfm help implemenetd, some cosmetics of ad/vd codec names/comments
arpi
parents:
7180
diff
changeset
|
68 "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
|
69 "liba52", |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
70 "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
|
71 "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
|
72 "" |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
73 }; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
74 |
5343 | 75 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
|
76 |
30555
ad6740b58b0d
libmpcodecs: Mark functions not used outside of their files as static.
diego
parents:
30504
diff
changeset
|
77 static int a52_fillbuff(sh_audio_t *sh_audio) |
ad6740b58b0d
libmpcodecs: Mark functions not used outside of their files as static.
diego
parents:
30504
diff
changeset
|
78 { |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
79 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
|
80 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
|
81 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
|
82 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
|
83 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
84 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
|
85 /* 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
|
86 while(1){ |
10119 | 87 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
|
88 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
|
89 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
|
90 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
|
91 } |
10119 | 92 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
|
93 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
|
94 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
|
95 /* bad file => resync*/ |
10119 | 96 if(sh_audio->format!=0x2000) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8); |
15560 | 97 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
|
98 --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
|
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_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
|
101 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
|
102 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
|
103 sh_audio->samplesize=sh_audio->sample_format==AF_FORMAT_FLOAT_NE ? 4 : 2; |
10119 | 104 demux_read_data(sh_audio->ds,sh_audio->a_in_buffer+8,length-8); |
105 if(sh_audio->format!=0x2000) | |
106 swab(sh_audio->a_in_buffer+8,sh_audio->a_in_buffer+8,length-8); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
107 |
27588 | 108 #ifdef CONFIG_LIBA52_INTERNAL |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
109 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
|
110 mp_msg(MSGT_DECAUDIO,MSGL_STATUS,"a52: CRC check failed! \n"); |
27588 | 111 #endif |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
112 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
113 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
|
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 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
116 /* 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 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
|
128 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
|
129 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
|
130 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
|
131 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
|
132 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
|
133 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
|
134 } |
19944 | 135 mp_msg(MSGT_DECAUDIO,MSGL_V,"AC3: %d.%d (%s%s) %d Hz %3.1f kbit/s\n", |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
136 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
|
137 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
|
138 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
|
139 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
|
140 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
141 |
30555
ad6740b58b0d
libmpcodecs: Mark functions not used outside of their files as static.
diego
parents:
30504
diff
changeset
|
142 static sample_t dynrng_call (sample_t c, void *data) |
ad6740b58b0d
libmpcodecs: Mark functions not used outside of their files as static.
diego
parents:
30504
diff
changeset
|
143 { |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
144 // 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
|
145 return pow((double)c, a52_drc_level); |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
146 } |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
147 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
148 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
149 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
|
150 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
151 /* 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
|
152 /* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */ |
27588 | 153 #ifdef CONFIG_LIBA52_INTERNAL |
15559
9f157ca7e3c2
Make sure that samplesize is at least 2, as some demuxers set it to 1
hzoli
parents:
15558
diff
changeset
|
154 if (sh->samplesize < 2) sh->samplesize = 2; |
27588 | 155 #else |
156 if (sh->samplesize < 4) sh->samplesize = 4; | |
157 #endif | |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
158 sh->audio_out_minsize=audio_output_channels*sh->samplesize*256*6; |
5458 | 159 sh->audio_in_minsize=3840; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
160 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
|
161 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
|
162 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
163 |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
164 /** |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
165 * \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
|
166 * 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
|
167 * \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
|
168 * \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
|
169 */ |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
170 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
|
171 { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
172 unsigned long i; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
173 float *p = (float*) out; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
174 for (i = 0; i != 256; i++) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
175 unsigned long map = channel_map; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
176 do { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
177 unsigned long ch = map & 15; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
178 if (ch == 15) |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
179 *p = 0; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
180 else |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
181 *p = in[i + ((ch-1)<<8)]; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
182 p++; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
183 } while ((map >>= 4)); |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
184 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
185 return (int16_t*) p - out; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
186 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
187 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
188 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
|
189 { |
5341 | 190 uint32_t a52_accel=0; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
191 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
|
192 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
|
193 /* Dolby AC3 audio:*/ |
27587 | 194 #ifdef MM_ACCEL_X86_SSE |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
195 if(gCpuCaps.hasSSE) a52_accel|=MM_ACCEL_X86_SSE; |
27587 | 196 #endif |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
197 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
|
198 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
|
199 if(gCpuCaps.has3DNow) a52_accel|=MM_ACCEL_X86_3DNOW; |
27587 | 200 #ifdef MM_ACCEL_X86_3DNOWEXT |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
201 if(gCpuCaps.has3DNowExt) a52_accel|=MM_ACCEL_X86_3DNOWEXT; |
27587 | 202 #endif |
203 #ifdef MM_ACCEL_PPC_ALTIVEC | |
9003 | 204 if(gCpuCaps.hasAltiVec) a52_accel|=MM_ACCEL_PPC_ALTIVEC; |
27587 | 205 #endif |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
206 a52_state=a52_init (a52_accel); |
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
207 if (a52_state == NULL) { |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
208 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
|
209 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
|
210 } |
27588 | 211 #ifndef CONFIG_LIBA52_INTERNAL |
212 sh_audio->sample_format = AF_FORMAT_FLOAT_NE; | |
213 #endif | |
5340
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_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
|
215 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
|
216 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
|
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 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
220 /* Init a52 dynrng */ |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
221 if (a52_drc_level < 0.001) { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
222 /* level == 0 --> no compression, init library without callback */ |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
223 a52_drc_action = DRC_NO_COMPRESSION; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
224 } else if (a52_drc_level > 0.999) { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
225 /* 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
|
226 a52_drc_action = DRC_NO_ACTION; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
227 } else { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
228 a52_drc_action = DRC_CALLBACK; |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
229 } |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
230 /* 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
|
231 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
232 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
233 /* '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
|
234 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
|
235 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
|
236 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
|
237 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
|
238 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
|
239 /* 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
|
240 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
|
241 /* 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
|
242 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
|
243 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
|
244 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
|
245 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
|
246 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
247 /* test:*/ |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
248 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
|
249 mp_msg(MSGT_DECAUDIO,MSGL_V,"A52 flags before a52_frame: 0x%X\n",flags); |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
250 if (a52_frame (a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){ |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
251 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
|
252 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
|
253 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
254 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
|
255 /* 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
|
256 channel_map = 0; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
257 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
|
258 if (!(flags & A52_LFE)) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
259 switch ((flags<<3) | sh_audio->channels) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
260 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
|
261 case (A52_CHANNEL << 3) | 2: |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
262 case (A52_STEREO << 3) | 2: |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
263 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
|
264 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
|
265 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
|
266 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
|
267 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
|
268 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
269 } else if (sh_audio->channels == 6) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
270 switch (flags & ~A52_LFE) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
271 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
|
272 case A52_CHANNEL: |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
273 case A52_STEREO : |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 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
|
278 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
|
279 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
280 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
281 if (channel_map) { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
282 a52_resample = a52_resample_float; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
283 break; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
284 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
285 } else |
27588 | 286 #ifdef CONFIG_LIBA52_INTERNAL |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
287 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
|
288 --sh_audio->channels; /* try to decrease no. of channels*/ |
27588 | 289 #else |
290 break; | |
291 #endif | |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
292 } |
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->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
|
294 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
|
295 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
|
296 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
297 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
|
298 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
299 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
300 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
|
301 { |
26923 | 302 a52_free(a52_state); |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
303 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
304 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
305 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
|
306 { |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
307 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
|
308 { |
15558 | 309 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
|
310 case ADCTRL_SKIP_FRAME: |
15558 | 311 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
|
312 return CONTROL_TRUE; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
313 case ADCTRL_SET_VOLUME: { |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
314 float vol = *(float*)arg; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
315 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
|
316 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
|
317 return CONTROL_TRUE; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
318 } |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
319 case ADCTRL_QUERY_FORMAT: |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
320 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
|
321 *(int*)arg == AF_FORMAT_FLOAT_NE) |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
322 return CONTROL_TRUE; |
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
323 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
|
324 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
325 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
|
326 } |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
327 |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
328 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
|
329 { |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
330 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
|
331 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
|
332 int i,len=-1; |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
333 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
|
334 bias = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28445
diff
changeset
|
335 if(!sh_audio->a_in_buffer_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
|
336 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
|
337 sh_audio->a_in_buffer_len=0; |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
338 if (a52_frame (a52_state, sh_audio->a_in_buffer, &flags, &level, bias)){ |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
339 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
|
340 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
|
341 } |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
342 |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
343 /* handle dynrng */ |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
344 if (a52_drc_action != DRC_NO_ACTION) { |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
345 if (a52_drc_action == DRC_NO_COMPRESSION) |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
346 a52_dynrng(a52_state, NULL, NULL); |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
347 else |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
348 a52_dynrng(a52_state, dynrng_call, NULL); |
12285
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
349 } |
67b8d64af8c7
a52 dynamic range compression support by Peter Gansterer
alex
parents:
10978
diff
changeset
|
350 |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
351 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
|
352 for (i = 0; i < 6; i++) { |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
353 if (a52_block (a52_state)){ |
5340
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
354 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
|
355 break; |
0f12fb7c1c5d
imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff
changeset
|
356 } |
18720
4bad7f00556e
sync with liba52 0.7.4, patch by Emanuele Giaquinta >emanuele.giaquinta ! gmail * com<
rathann
parents:
17581
diff
changeset
|
357 len+=2*a52_resample(a52_samples(a52_state),(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
|
358 } |
14817
878745349274
Add float output support. Add ADCTRL_QUERY_FORMAT control to report the
hzoli
parents:
13427
diff
changeset
|
359 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
|
360 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
|
361 } |