Mercurial > mplayer.hg
annotate libmpcodecs/ad_libmad.c @ 35059:568f0925d9a9
Enable panscan for -vo directx.
Not fully working for :noaccel, since it uses
Blt and that does not support scaling beyond
the destination size (or at least it does not
with the current implementation).
author | reimar |
---|---|
date | Fri, 07 Sep 2012 19:16:10 +0000 |
parents | 6cfaa555bec1 |
children | 83d0141a1cdc |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
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:
30420
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:
30420
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:
30420
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
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:
30420
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:
30420
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:
30420
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
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:
30420
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:
30420
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:
30420
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
30420
diff
changeset
|
18 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
19 #include <stdio.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
20 #include <stdlib.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
21 #include <unistd.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
22 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
23 #include "config.h" |
34174
a93891202051
Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents:
31160
diff
changeset
|
24 #include "mp_msg.h" |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
25 #include "ad_internal.h" |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
26 |
31160 | 27 static const ad_info_t info = { |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
28 "libmad mpeg audio decoder", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
29 "libmad", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
30 "A'rpi", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
31 "libmad...", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
32 "based on Xine's libmad/xine_decoder.c" |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
33 }; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
34 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
35 LIBAD_EXTERN(libmad) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
36 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
37 #include <mad.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
38 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
39 typedef struct mad_decoder_s { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
40 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
41 struct mad_synth synth; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
42 struct mad_stream stream; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
43 struct mad_frame frame; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
44 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
45 int have_frame; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
46 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
47 int output_sampling_rate; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
48 int output_open; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
49 int output_mode; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
50 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
51 } mad_decoder_t; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
52 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
53 static int preinit(sh_audio_t *sh){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
54 |
34740 | 55 mad_decoder_t *this = calloc(1, sizeof(mad_decoder_t)); |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
56 sh->context = this; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
57 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
58 mad_synth_init (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
59 mad_stream_init (&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
60 mad_frame_init (&this->frame); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
61 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
62 sh->audio_out_minsize=2*4608; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
63 sh->audio_in_minsize=4096; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
64 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
65 return 1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
66 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
67 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
68 static int read_frame(sh_audio_t *sh){ |
34739 | 69 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
70 int len; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
71 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
72 while((len=demux_read_data(sh->ds,&sh->a_in_buffer[sh->a_in_buffer_len], |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
73 sh->a_in_buffer_size-sh->a_in_buffer_len))>0){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
74 sh->a_in_buffer_len+=len; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
75 while(1){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
76 int ret; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
77 mad_stream_buffer (&this->stream, sh->a_in_buffer, sh->a_in_buffer_len); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
78 ret=mad_frame_decode (&this->frame, &this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
79 if (this->stream.next_frame) { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
80 int num_bytes = |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
81 (char*)sh->a_in_buffer+sh->a_in_buffer_len - (char*)this->stream.next_frame; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
82 memmove(sh->a_in_buffer, this->stream.next_frame, num_bytes); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
83 mp_msg(MSGT_DECAUDIO,MSGL_DBG2,"libmad: %d bytes processed\n",sh->a_in_buffer_len-num_bytes); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
84 sh->a_in_buffer_len = num_bytes; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
85 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
86 if (ret == 0) return 1; // OK!!! |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
87 // error! try to resync! |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
88 if(this->stream.error==MAD_ERROR_BUFLEN) break; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
89 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
90 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
91 mp_msg(MSGT_DECAUDIO,MSGL_INFO,"Cannot sync MAD frame\n"); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
92 return 0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
93 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
94 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
95 static int init(sh_audio_t *sh){ |
34739 | 96 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
97 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
98 this->have_frame=read_frame(sh); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
99 if(!this->have_frame) return 0; // failed to sync... |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
100 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
101 sh->channels=(this->frame.header.mode == MAD_MODE_SINGLE_CHANNEL) ? 1 : 2; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
102 sh->samplerate=this->frame.header.samplerate; |
34741 | 103 if (sh->i_bps < 1) |
104 sh->i_bps=this->frame.header.bitrate/8; | |
13430 | 105 sh->samplesize=2; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
106 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
107 return 1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
108 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
109 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
110 static void uninit(sh_audio_t *sh){ |
34739 | 111 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
112 mad_synth_finish (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
113 mad_frame_finish (&this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
114 mad_stream_finish(&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
115 free(sh->context); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
116 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
117 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
118 /* utility to scale and round samples to 16 bits */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
119 static inline signed int scale(mad_fixed_t sample) { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
120 /* round */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
121 sample += (1L << (MAD_F_FRACBITS - 16)); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
122 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
123 /* clip */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
124 if (sample >= MAD_F_ONE) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
125 sample = MAD_F_ONE - 1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
126 else if (sample < -MAD_F_ONE) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
127 sample = -MAD_F_ONE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
128 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
129 /* quantize */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
130 return sample >> (MAD_F_FRACBITS + 1 - 16); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
131 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
132 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
133 static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){ |
34739 | 134 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
135 int len=0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
136 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
137 while(len<minlen && len+4608<=maxlen){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
138 if(!this->have_frame) this->have_frame=read_frame(sh); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
139 if(!this->have_frame) break; // failed to sync... or EOF |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
140 this->have_frame=0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
141 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
142 mad_synth_frame (&this->synth, &this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
143 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
144 { unsigned int nchannels, nsamples; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
145 mad_fixed_t const *left_ch, *right_ch; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
146 struct mad_pcm *pcm = &this->synth.pcm; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
147 uint16_t *output = (uint16_t*) buf; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
148 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
149 nchannels = pcm->channels; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
150 nsamples = pcm->length; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
151 left_ch = pcm->samples[0]; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
152 right_ch = pcm->samples[1]; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
153 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
154 len+=2*nchannels*nsamples; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
155 buf+=2*nchannels*nsamples; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
156 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
157 while (nsamples--) { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
158 /* output sample(s) in 16-bit signed little-endian PCM */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
159 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
160 *output++ = scale(*left_ch++); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
161 |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
162 if (nchannels == 2) |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
163 *output++ = scale(*right_ch++); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
164 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
165 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
166 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
167 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
18771
diff
changeset
|
168 |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
169 return len?len:-1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
170 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
171 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
172 static int control(sh_audio_t *sh,int cmd,void* arg, ...){ |
34739 | 173 mad_decoder_t *this = sh->context; |
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
174 // various optional functions you MAY implement: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
175 switch(cmd){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
176 case ADCTRL_RESYNC_STREAM: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
177 this->have_frame=0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
178 mad_synth_init (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
179 mad_stream_init (&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
180 mad_frame_init (&this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
181 return CONTROL_TRUE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
182 case ADCTRL_SKIP_FRAME: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
183 this->have_frame=read_frame(sh); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
184 return CONTROL_TRUE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
185 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
186 return CONTROL_UNKNOWN; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
187 } |