changeset 5345:81071ffb7b22

ad_msgsm added
author arpi
date Mon, 25 Mar 2002 22:25:58 +0000
parents 7198d3eba09f
children a781c611f193
files libmpcodecs/Makefile libmpcodecs/ad.c libmpcodecs/ad_msgsm.c
diffstat 3 files changed, 60 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/Makefile	Mon Mar 25 22:04:33 2002 +0000
+++ b/libmpcodecs/Makefile	Mon Mar 25 22:25:58 2002 +0000
@@ -3,7 +3,7 @@
 
 LIBNAME = libmpcodecs.a
 
-AUDIO_SRCS=dec_audio.c ad.c ad_a52.c ad_acm.c ad_alaw.c ad_dk3adpcm.c ad_dk4adpcm.c ad_dshow.c ad_dvdpcm.c ad_ffmpeg.c ad_hwac3.c ad_imaadpcm.c ad_mp3.c ad_msadpcm.c ad_pcm.c ad_roqaudio.c
+AUDIO_SRCS=dec_audio.c ad.c ad_a52.c ad_acm.c ad_alaw.c ad_dk3adpcm.c ad_dk4adpcm.c ad_dshow.c ad_dvdpcm.c ad_ffmpeg.c ad_hwac3.c ad_imaadpcm.c ad_mp3.c ad_msadpcm.c ad_pcm.c ad_roqaudio.c ad_msgsm.c
 VIDEO_SRCS=dec_video.c vd.c vd_null.c vd_cinepak.c vd_qtrpza.c vd_ffmpeg.c vd_dshow.c vd_vfw.c vd_odivx.c vd_divx4.c vd_raw.c vd_xanim.c vd_msvidc.c vd_fli.c vd_qtrle.c vd_qtsmc.c vd_roqvideo.c vd_cyuv.c vd_nuv.c vd_libmpeg2.c vd_msrle.c vd_huffyuv.c vd_zlib.c
 
 ifeq ($(PNG),yes)
--- a/libmpcodecs/ad.c	Mon Mar 25 22:04:33 2002 +0000
+++ b/libmpcodecs/ad.c	Mon Mar 25 22:25:58 2002 +0000
@@ -30,6 +30,7 @@
 extern ad_functions_t mpcodecs_ad_roqaudio;
 extern ad_functions_t mpcodecs_ad_dshow;
 extern ad_functions_t mpcodecs_ad_acm;
+extern ad_functions_t mpcodecs_ad_msgsm;
 
 ad_functions_t* mpcodecs_ad_drivers[] =
 {
@@ -48,6 +49,7 @@
   &mpcodecs_ad_dk4adpcm,
   &mpcodecs_ad_dk3adpcm,
   &mpcodecs_ad_roqaudio,
+  &mpcodecs_ad_msgsm,
 #ifdef USE_WIN32DLL
 #ifdef USE_DIRECTSHOW
   &mpcodecs_ad_dshow,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/libmpcodecs/ad_msgsm.c	Mon Mar 25 22:25:58 2002 +0000
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "config.h"
+#include "ad_internal.h"
+
+static ad_info_t info = 
+{
+	"native MSGSM audio decoder",
+	"msgsm",
+	AFM_GSM,
+	"A'rpi",
+	"XAnim",
+	""
+};
+
+LIBAD_EXTERN(msgsm)
+
+#include "xa/xa_gsm.h"
+
+static int init(sh_audio_t *sh_audio)
+{
+  if(!sh_audio->wf) return 0;
+  // MS-GSM audio codec:
+  GSM_Init();
+  sh_audio->channels=sh_audio->wf->nChannels;
+  sh_audio->samplerate=sh_audio->wf->nSamplesPerSec;
+  // decodes 65 byte -> 320 short
+  // 1 sec: sh_audio->channels*sh_audio->samplerate  samples
+  // 1 frame: 320 samples
+  sh_audio->i_bps=65*(sh_audio->channels*sh_audio->samplerate)/320;  // 1:10
+  return 1;
+}
+
+static int preinit(sh_audio_t *sh_audio)
+{
+  sh_audio->audio_out_minsize=4*320;
+  return 1;
+}
+
+static void uninit(sh_audio_t *sh)
+{
+}
+
+static int control(sh_audio_t *sh,int cmd,void* arg, ...)
+{
+  return CONTROL_UNKNOWN;
+}
+
+static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
+{
+    unsigned char ibuf[65]; // 65 bytes / frame
+    if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF
+    XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short
+    return 2*320;
+}