rpm: Remove MEncoder from rpm packaging
[mplayer/glamo.git] / libmpcodecs / ad_mp3lib.c
blobf2627575262bb20771adaeb4c56fe21118f86cf0
1 /*
2 * This file is part of MPlayer.
4 * MPlayer is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * MPlayer is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <unistd.h>
23 #include "config.h"
25 #include "ad_internal.h"
26 #include "ad_mp3lib.h"
28 static const ad_info_t info =
30 "MPEG layer-2, layer-3",
31 "mp3lib",
32 "Nick Kurshev",
33 "mpg123",
34 "Optimized to MMX/SSE/3Dnow!"
37 LIBAD_EXTERN(mp3lib)
39 #include "mp3lib/mp3.h"
41 extern int fakemono;
43 static sh_audio_t* dec_audio_sh=NULL;
45 // MP3 decoder buffer callback:
46 int mplayer_audio_read(char *buf,int size){
47 return demux_read_data(dec_audio_sh->ds,buf,size);
50 static int preinit(sh_audio_t *sh)
52 sh->audio_out_minsize=32*36*2*2; //4608;
53 return 1;
56 static int init(sh_audio_t *sh)
58 // MPEG Audio:
59 dec_audio_sh=sh; // save sh_audio for the callback:
60 // MP3_Init(fakemono,mplayer_accel,&mplayer_audio_read); // TODO!!!
61 #ifdef CONFIG_FAKE_MONO
62 MP3_Init(fakemono);
63 #else
64 MP3_Init();
65 #endif
66 MP3_samplerate=MP3_channels=0;
67 sh->a_buffer_len=MP3_DecodeFrame(sh->a_buffer,-1);
68 if(!sh->a_buffer_len) return 0; // unsupported layer/format
69 sh->channels=2; // hack
70 sh->samplesize=2;
71 sh->samplerate=MP3_samplerate;
72 sh->i_bps=MP3_bitrate*(1000/8);
73 MP3_PrintHeader();
74 return 1;
77 static void uninit(sh_audio_t *sh)
81 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
83 switch(cmd)
85 case ADCTRL_RESYNC_STREAM:
86 MP3_DecodeFrame(NULL,-2); // resync
87 MP3_DecodeFrame(NULL,-2); // resync
88 MP3_DecodeFrame(NULL,-2); // resync
89 return CONTROL_TRUE;
90 case ADCTRL_SKIP_FRAME:
91 MP3_DecodeFrame(NULL,-2); // skip MPEG frame
92 return CONTROL_TRUE;
94 return CONTROL_UNKNOWN;
97 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
99 return MP3_DecodeFrame(buf,-1);