annotate libmpcodecs/ad_pcm.c @ 35502:381cd31289f2

Cosmetic: Choose better variable name in Win32 GUI. This has been forgotten in r35588.
author ib
date Tue, 04 Dec 2012 20:10:10 +0000
parents 221d00deafec
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30421
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
diff changeset
1 /*
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
diff changeset
2 * This file is part of MPlayer.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
diff changeset
3 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
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: 30386
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: 30386
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: 30386
diff changeset
7 * (at your option) any later version.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
diff changeset
8 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
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: 30386
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: 30386
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: 30386
diff changeset
12 * GNU General Public License for more details.
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
diff changeset
13 *
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
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: 30386
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: 30386
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: 30386
diff changeset
17 */
bbb6ebec87a0 Add missing license headers to all files in the libmpcodecs directory.
diego
parents: 30386
diff changeset
18
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
19 #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
20 #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
21 #include <unistd.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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
23 #include "config.h"
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
24 #include "ad_internal.h"
17012
6ff3379a0862 Unify include path handling, -I.. is in CFLAGS.
diego
parents: 16307
diff changeset
25 #include "libaf/af_format.h"
25315
dfa8a510c81c Fix all current known multi-channel wrong order problems by adding
ulion
parents: 20704
diff changeset
26 #include "libaf/reorder_ch.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
27
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
28 static const ad_info_t info = {
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
29 "Uncompressed PCM audio decoder",
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
30 "pcm",
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
31 "Nick Kurshev",
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
32 "A'rpi",
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
33 ""
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
34 };
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
35
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
36 LIBAD_EXTERN(pcm)
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
37
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
38 static int init(sh_audio_t * sh_audio)
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
39 {
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
40 WAVEFORMATEX *h = sh_audio->wf;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
41 if (!h)
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
42 return 0;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
43 sh_audio->i_bps = h->nAvgBytesPerSec;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
44 sh_audio->channels = h->nChannels;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
45 sh_audio->samplerate = h->nSamplesPerSec;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
46 sh_audio->samplesize = (h->wBitsPerSample + 7) / 8;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
47 sh_audio->sample_format = AF_FORMAT_S16_LE; // default
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
48 switch (sh_audio->format) { /* hardware formats: */
12539
4edbef7dd28d More support for audio format 0x0
rtognimp
parents: 12498
diff changeset
49 case 0x0:
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
50 case 0x1: // Microsoft PCM
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
51 case 0xfffe: // Extended
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
52 switch (sh_audio->samplesize) {
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
53 case 1: sh_audio->sample_format = AF_FORMAT_U8; break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
54 case 2: sh_audio->sample_format = AF_FORMAT_S16_LE; break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
55 case 3: sh_audio->sample_format = AF_FORMAT_S24_LE; break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
56 case 4: sh_audio->sample_format = AF_FORMAT_S32_LE; break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
57 }
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
58 break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
59 case 0x3: // IEEE float
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
60 sh_audio->sample_format = AF_FORMAT_FLOAT_LE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
61 break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
62 case 0x6: sh_audio->sample_format = AF_FORMAT_A_LAW; break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
63 case 0x7: sh_audio->sample_format = AF_FORMAT_MU_LAW; break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
64 case 0x11: sh_audio->sample_format = AF_FORMAT_IMA_ADPCM; break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
65 case 0x50: sh_audio->sample_format = AF_FORMAT_MPEG2; break;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
66 /* case 0x2000: sh_audio->sample_format=AFMT_AC3; */
12498
827d908c7705 Fix "raw " audio in mov files.
rtognimp
parents: 12478
diff changeset
67 case 0x20776172: // 'raw '
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
68 sh_audio->sample_format = AF_FORMAT_S16_BE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
69 if (sh_audio->samplesize == 1)
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
70 sh_audio->sample_format = AF_FORMAT_U8;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
71 break;
8102
2759150cc687 qt swot support
alex
parents: 7180
diff changeset
72 case 0x736F7774: // 'twos'
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
73 sh_audio->sample_format = AF_FORMAT_S16_BE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
74 // intended fall-through
20704
666efb20e7d5 Fix comment, it's 'sowt', not 'swot' ('twos' reversed)
reimar
parents: 19383
diff changeset
75 case 0x74776F73: // 'sowt'
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
76 if (sh_audio->samplesize == 1)
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
77 sh_audio->sample_format = AF_FORMAT_S8;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
78 break;
14055
efe58d68689e fl32: BE float32 PCM audio in mov files
rtognimp
parents: 13553
diff changeset
79 case 0x32336c66: // 'fl32', bigendian float32
32989
221d00deafec Support 32bit big endian float pcm in aiff.
cehoyos
parents: 32988
diff changeset
80 case 0x32334C46: // 'FL32', bigendian float32 in aiff
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
81 sh_audio->sample_format = AF_FORMAT_FLOAT_BE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
82 sh_audio->samplesize = 4;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
83 break;
17858
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
84 case 0x666c3332: // '23lf', little endian float32, MPlayer internal fourCC
32988
c99a947dae33 Support 'lpcm' in mov files, has audible (clipping?) artefacts on some systems.
cehoyos
parents: 31136
diff changeset
85 case 0x6D63706C: // 'lpcm'
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
86 sh_audio->sample_format = AF_FORMAT_FLOAT_LE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
87 sh_audio->samplesize = 4;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
88 break;
17858
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
89 /* case 0x34366c66: // 'fl64', bigendian float64
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
90 sh_audio->sample_format=AF_FORMAT_FLOAT_BE;
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
91 sh_audio->samplesize=8;
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
92 break;
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
93 case 0x666c3634: // '46lf', little endian float64, MPlayer internal fourCC
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
94 sh_audio->sample_format=AF_FORMAT_FLOAT_LE;
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
95 sh_audio->samplesize=8;
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
96 break;*/
17813
f34f61843448 QuickTime in24 and in32 PCM audio support
rathann
parents: 17012
diff changeset
97 case 0x34326e69: // 'in24', bigendian int24
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
98 sh_audio->sample_format = AF_FORMAT_S24_BE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
99 sh_audio->samplesize = 3;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
100 break;
17858
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
101 case 0x696e3234: // '42ni', little endian int24, MPlayer internal fourCC
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
102 sh_audio->sample_format = AF_FORMAT_S24_LE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
103 sh_audio->samplesize = 3;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
104 break;
17813
f34f61843448 QuickTime in24 and in32 PCM audio support
rathann
parents: 17012
diff changeset
105 case 0x32336e69: // 'in32', bigendian int32
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
106 sh_audio->sample_format = AF_FORMAT_S32_BE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
107 sh_audio->samplesize = 4;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
108 break;
17858
996e419c1671 in24/in32/fl32 little/big-endian QuickTime PCM audio support
rathann
parents: 17813
diff changeset
109 case 0x696e3332: // '23ni', little endian int32, MPlayer internal fourCC
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
110 sh_audio->sample_format = AF_FORMAT_S32_LE;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
111 sh_audio->samplesize = 4;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
112 break;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
113 default:
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
114 if (sh_audio->samplesize != 2)
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
115 sh_audio->sample_format = AF_FORMAT_U8;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
116 }
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
117 if (!sh_audio->samplesize) // this would cause MPlayer to hang later
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
118 sh_audio->samplesize = 2;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
119 return 1;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
120 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
121
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
122 static int 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
123 {
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
124 sh->audio_out_minsize = 2048;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
125 return 1;
5340
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
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
128 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
129 {
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
130 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
131
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
132 static int control(sh_audio_t *sh, int cmd, void *arg, ...)
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 {
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
134 int skip;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
135 switch (cmd) {
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
136 case ADCTRL_SKIP_FRAME:
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
137 skip = sh->i_bps / 16;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
138 skip = skip & (~3);
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
139 demux_read_data(sh->ds, NULL, skip);
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
140 return CONTROL_TRUE;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
141 }
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
142 return CONTROL_UNKNOWN;
5340
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
143 }
0f12fb7c1c5d imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added
arpi
parents:
diff changeset
144
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
145 static int decode_audio(sh_audio_t *sh_audio, unsigned char *buf, int minlen,
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
146 int 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
147 {
31136
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
148 unsigned len = sh_audio->channels * sh_audio->samplesize;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
149 len = (minlen + len - 1) / len * len;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
150 if (len > maxlen)
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
151 // if someone needs hundreds of channels adjust audio_out_minsize
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
152 // based on channels in preinit()
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
153 return -1;
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
154 len = demux_read_data(sh_audio->ds, buf, len);
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
155 if (len > 0 && sh_audio->channels >= 5) {
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
156 reorder_channel_nch(buf, AF_CHANNEL_LAYOUT_WAVEEX_DEFAULT,
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
157 AF_CHANNEL_LAYOUT_MPLAYER_DEFAULT,
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
158 sh_audio->channels, len / sh_audio->samplesize,
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
159 sh_audio->samplesize);
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
160 }
b50bb3e564d6 cosmetics: reformat ad_pcm.c in K&R style
diego
parents: 30504
diff changeset
161 return 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
162 }