Mercurial > mplayer.hg
annotate libmpcodecs/ad_libmad.c @ 5574:bdfd4b72244a
fixing vertical scaling on non mobility cards, this might have overflowed into the horizontal stuff, so perhaps it fixes the horizontal stuff too
author | michael |
---|---|
date | Fri, 12 Apr 2002 12:29:12 +0000 |
parents | 22b289d7f87f |
children | 4bae3caef7a9 |
rev | line source |
---|---|
5479
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
1 // SAMPLE audio decoder - you can use this file as template when creating new codec! |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
2 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
3 #include <stdio.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
4 #include <stdlib.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
5 #include <unistd.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
6 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
7 #include "config.h" |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
8 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
9 #ifdef USE_LIBMAD |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
10 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
11 #include "ad_internal.h" |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
12 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
13 static ad_info_t info = { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
14 "libmad mpeg audio decoder", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
15 "libmad", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
16 AFM_MAD, |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
17 "A'rpi", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
18 "libmad...", |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
19 "based on Xine's libmad/xine_decoder.c" |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
20 }; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
21 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
22 LIBAD_EXTERN(libmad) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
23 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
24 #include <mad.h> |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
25 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
26 typedef struct mad_decoder_s { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
27 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
28 struct mad_synth synth; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
29 struct mad_stream stream; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
30 struct mad_frame frame; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
31 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
32 int have_frame; |
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 int output_sampling_rate; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
35 int output_open; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
36 int output_mode; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
37 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
38 } mad_decoder_t; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
39 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
40 static int preinit(sh_audio_t *sh){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
41 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
42 mad_decoder_t *this = (mad_decoder_t *) malloc(sizeof(mad_decoder_t)); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
43 memset(this,0,sizeof(mad_decoder_t)); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
44 sh->context = this; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
45 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
46 mad_synth_init (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
47 mad_stream_init (&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
48 mad_frame_init (&this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
49 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
50 sh->audio_out_minsize=2*4608; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
51 sh->audio_in_minsize=4096; |
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 return 1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
54 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
55 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
56 static int read_frame(sh_audio_t *sh){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
57 mad_decoder_t *this = (mad_decoder_t *) sh->context; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
58 int len; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
59 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
60 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
|
61 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
|
62 sh->a_in_buffer_len+=len; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
63 while(1){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
64 int ret; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
65 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
|
66 ret=mad_frame_decode (&this->frame, &this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
67 if (this->stream.next_frame) { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
68 int num_bytes = |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
69 (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
|
70 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
|
71 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
|
72 sh->a_in_buffer_len = num_bytes; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
73 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
74 if (ret == 0) return 1; // OK!!! |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
75 // error! try to resync! |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
76 if(this->stream.error==MAD_ERROR_BUFLEN) break; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
77 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
78 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
79 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
|
80 return 0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
81 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
82 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
83 static int init(sh_audio_t *sh){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
84 mad_decoder_t *this = (mad_decoder_t *) sh->context; |
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 this->have_frame=read_frame(sh); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
87 if(!this->have_frame) return 0; // failed to sync... |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
88 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
89 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
|
90 sh->samplerate=this->frame.header.samplerate; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
91 sh->i_bps=this->frame.header.bitrate/8; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
92 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
93 return 1; |
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 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
96 static void uninit(sh_audio_t *sh){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
97 mad_decoder_t *this = (mad_decoder_t *) sh->context; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
98 mad_synth_finish (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
99 mad_frame_finish (&this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
100 mad_stream_finish(&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
101 free(sh->context); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
102 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
103 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
104 /* utility to scale and round samples to 16 bits */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
105 static inline signed int scale(mad_fixed_t sample) { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
106 /* round */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
107 sample += (1L << (MAD_F_FRACBITS - 16)); |
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 /* clip */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
110 if (sample >= MAD_F_ONE) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
111 sample = MAD_F_ONE - 1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
112 else if (sample < -MAD_F_ONE) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
113 sample = -MAD_F_ONE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
114 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
115 /* quantize */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
116 return sample >> (MAD_F_FRACBITS + 1 - 16); |
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 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
119 static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
120 mad_decoder_t *this = (mad_decoder_t *) sh->context; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
121 int len=0; |
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 while(len<minlen && len+4608<=maxlen){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
124 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
|
125 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
|
126 this->have_frame=0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
127 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
128 mad_synth_frame (&this->synth, &this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
129 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
130 { unsigned int nchannels, nsamples; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
131 mad_fixed_t const *left_ch, *right_ch; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
132 struct mad_pcm *pcm = &this->synth.pcm; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
133 uint16_t *output = (uint16_t*) buf; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
134 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
135 nchannels = pcm->channels; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
136 nsamples = pcm->length; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
137 left_ch = pcm->samples[0]; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
138 right_ch = pcm->samples[1]; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
139 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
140 len+=2*nchannels*nsamples; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
141 buf+=2*nchannels*nsamples; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
142 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
143 while (nsamples--) { |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
144 /* output sample(s) in 16-bit signed little-endian PCM */ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
145 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
146 *output++ = scale(*left_ch++); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
147 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
148 if (nchannels == 2) |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
149 *output++ = scale(*right_ch++); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
150 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
151 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
152 } |
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 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
155 return len?len:-1; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
156 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
157 |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
158 static int control(sh_audio_t *sh,int cmd,void* arg, ...){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
159 mad_decoder_t *this = (mad_decoder_t *) sh->context; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
160 // various optional functions you MAY implement: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
161 switch(cmd){ |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
162 case ADCTRL_RESYNC_STREAM: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
163 sh->a_in_buffer_len=0; // clear audio input buffer |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
164 this->have_frame=0; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
165 mad_synth_init (&this->synth); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
166 mad_stream_init (&this->stream); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
167 mad_frame_init (&this->frame); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
168 return CONTROL_TRUE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
169 case ADCTRL_SKIP_FRAME: |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
170 this->have_frame=read_frame(sh); |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
171 return CONTROL_TRUE; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
172 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
173 return CONTROL_UNKNOWN; |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
174 } |
22b289d7f87f
libmad support, rewritten from scratch using Xine decoder as sample
arpi
parents:
diff
changeset
|
175 #endif |