[Mplayer-cvslog] CVS: main/libmpcodecs ad_ra1428.c,NONE,1.1 Makefile,1.97,1.98 ad.c,1.15,1.16

Roberto Togni CVS rtognimp at mplayerhq.hu
Sun Jun 8 22:27:28 CEST 2003


Update of /cvsroot/mplayer/main/libmpcodecs
In directory mail:/var/tmp.root/cvs-serv21780

Modified Files:
	Makefile ad.c 
Added Files:
	ad_ra1428.c 
Log Message:
RealAudio 1.0 (14_4) and 2.0 (28_8) native decoders.


--- NEW FILE ---
// SAMPLE audio decoder - you can use this file as template when creating new codec!

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "config.h"
#include "ad_internal.h"

static ad_info_t info =  {
	"RealAudio 1.0 and 2.0 native decoder",
	"ra1428",
	"Roberto Togni",
	"http://www.honeypot.net/audio",
	"Decoders taken from a public domain Amiga player"
};

LIBAD_EXTERN(ra1428)

#include "native/common1428.h"



static int preinit(sh_audio_t *sh) {
  sh->samplerate=sh->wf->nSamplesPerSec;
  sh->samplesize=sh->wf->wBitsPerSample/8;
  sh->channels=sh->wf->nChannels;
  sh->sample_format=AFMT_S16_LE;

	switch (sh->format) {
		case mmioFOURCC('1','4','_','4'):
			mp_msg(MSGT_DECAUDIO,MSGL_INFO,"[ra1428] RealAudio 1.0 (14_4)\n");
		  sh->i_bps=1800;
		  break;
		case mmioFOURCC('2','8','_','8'):
			mp_msg(MSGT_DECAUDIO,MSGL_INFO,"[ra1428] RealAudio 2.0 (28_8)\n");
	  	sh->i_bps=1200;
	  	break;
		default:
			mp_msg(MSGT_DECAUDIO,MSGL_ERR,"[ra1428] Unhandled format in preinit: %x\n", sh->format);
			return 0;
	}
  
  sh->audio_out_minsize=128000; // no idea how to get... :(
  sh->audio_in_minsize=((short*)(sh->wf+1))[1]*sh->wf->nBlockAlign;

  return 1; // return values: 1=OK 0=ERROR
}



static int init(sh_audio_t *sh) {
	switch (sh->format) {
		case mmioFOURCC('1','4','_','4'):
			(Real_144*)sh->context = init_144();
		  break;
		case mmioFOURCC('2','8','_','8'):
			(Real_288*)sh->context = init_288();
	  	break;
		default:
			mp_msg(MSGT_DECAUDIO,MSGL_ERR,"[ra1428] Unhandled format in init: %x\n", sh->format);
			return 0;
	}

  return 1; // return values: 1=OK 0=ERROR
}



static void uninit(sh_audio_t *sh) {
	switch (sh->format) {
		case mmioFOURCC('1','4','_','4'):
			free_144((Real_144*)sh->context);
		  break;
		case mmioFOURCC('2','8','_','8'):
			free_288((Real_288*)sh->context);
	  	break;
		default:
			mp_msg(MSGT_DECAUDIO,MSGL_ERR,"[ra1428] Unhandled format in uninit: %x\n", sh->format);
			return;
	}
}



static int decode_audio(sh_audio_t *sh,unsigned char *buf,int minlen,int maxlen) {
  int w=sh->wf->nBlockAlign;
  int h=((short*)(sh->wf+1))[1];
  int cfs=((short*)(sh->wf+1))[3];
	int i,j;

  if(sh->a_in_buffer_len<=0){
		switch (sh->format) {
			case mmioFOURCC('1','4','_','4'):
				demux_read_data(sh->ds, sh->a_in_buffer, sh->wf->nBlockAlign);
				sh->a_in_buffer_size=
				sh->a_in_buffer_len=sh->wf->nBlockAlign;
		 	 break;
			case mmioFOURCC('2','8','_','8'):
				for (j = 0; j < h; j++)
					for (i = 0; i < h/2; i++)
						demux_read_data(sh->ds, sh->a_in_buffer+i*2*w+j*cfs, cfs);
				sh->a_in_buffer_size=
				sh->a_in_buffer_len=sh->wf->nBlockAlign*h;
	 	 	break;
			default:
				mp_msg(MSGT_DECAUDIO,MSGL_ERR,"[ra1428] Unhandled format in decode_audio: %x\n", sh->format);
				return 0;
		}
	}
	
	switch (sh->format) {
		case mmioFOURCC('1','4','_','4'):
			decode_144((Real_144*)sh->context,sh->a_in_buffer+sh->a_in_buffer_size-sh->a_in_buffer_len,(signed short*)buf);
		  break;
		case mmioFOURCC('2','8','_','8'):
			decode_288((Real_288*)sh->context,sh->a_in_buffer+sh->a_in_buffer_size-sh->a_in_buffer_len,(signed short*)buf);
	  	break;
		default:
			mp_msg(MSGT_DECAUDIO,MSGL_ERR,"[ra1428] Unhandled format in init: %x\n", sh->format);
			return 0;
	}

  sh->a_in_buffer_len-=cfs;

  return AUDIOBLOCK*2; // return value: number of _bytes_ written to output buffer,
              // or -1 for EOF (or uncorrectable error)
}

static int control(sh_audio_t *sh,int cmd,void* arg, ...){
    // various optional functions you MAY implement:
    switch(cmd){
      case ADCTRL_RESYNC_STREAM:
        // it is called once after seeking, to resync.
	// Note: sh_audio->a_in_buffer_len=0; is done _before_ this call!
//	...
	return CONTROL_TRUE;
      case ADCTRL_SKIP_FRAME:
        // it is called to skip (jump over) small amount (1/10 sec or 1 frame)
	// of audio data - used to sync audio to video after seeking
	// if you don't return CONTROL_TRUE, it will defaults to:
	//      ds_fill_buffer(sh_audio->ds);  // skip 1 demux packet
//	...
	return CONTROL_TRUE;
    }
  return CONTROL_UNKNOWN;
}

Index: Makefile
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/Makefile,v
retrieving revision 1.97
retrieving revision 1.98
diff -u -r1.97 -r1.98
--- Makefile	22 May 2003 12:38:42 -0000	1.97
+++ Makefile	8 Jun 2003 20:27:25 -0000	1.98
@@ -5,7 +5,7 @@
 LIBNAME2 = libmpencoders.a
 
 AUDIO_SRCS_LIB=ad_liba52.c ad_hwac3.c ad_mp3lib.c
-AUDIO_SRCS_NAT=ad_alaw.c ad_dk3adpcm.c ad_pcm.c ad_dvdpcm.c ad_imaadpcm.c ad_msadpcm.c ad_msgsm.c ad_roqaudio.c
+AUDIO_SRCS_NAT=ad_alaw.c ad_dk3adpcm.c ad_pcm.c ad_dvdpcm.c ad_imaadpcm.c ad_msadpcm.c ad_msgsm.c ad_roqaudio.c ad_ra1428.c
 AUDIO_SRCS_OPT=ad_acm.c ad_dshow.c ad_dmo.c ad_qtaudio.c ad_ffmpeg.c ad_faad.c ad_libvorbis.c ad_libmad.c ad_realaud.c ad_libdv.c
 AUDIO_SRCS=dec_audio.c ad.c $(AUDIO_SRCS_LIB) $(AUDIO_SRCS_NAT) $(AUDIO_SRCS_OPT)
 
@@ -17,7 +17,7 @@
 VFILTER_SRCS=vf.c vf_vo.c vf_crop.c vf_expand.c vf_pp.c vf_scale.c vf_format.c vf_yuy2.c vf_flip.c vf_rgb2bgr.c vf_rotate.c vf_mirror.c vf_palette.c vf_lavc.c vf_dvbscale.c vf_cropdetect.c vf_test.c vf_noise.c vf_yvu9.c vf_rectangle.c vf_lavcdeint.c vf_eq.c vf_eq2.c vf_halfpack.c vf_dint.c vf_1bpp.c vf_bmovl.c vf_2xsai.c vf_unsharp.c vf_swapuv.c vf_il.c vf_boxblur.c vf_sab.c vf_smartblur.c vf_perspective.c vf_down3dright.c vf_field.c vf_denoise3d.c vf_hqdn3d.c vf_detc.c vf_telecine.c vf_tfields.c vf_ivtc.c vf_ilpack.c vf_dsize.c vf_decimate.c
 ENCODER_SRCS=ve.c ve_divx4.c ve_lavc.c ve_vfw.c ve_rawrgb.c ve_libdv.c ve_xvid.c ve_qtvideo.c ve_nuv.c
 
-NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/fli.c native/minilzo.c native/msvidc.c native/nuppelvideo.c native/qtrle.c native/qtrpza.c native/qtsmc.c native/roqav.c native/xa_gsm.c native/svq1.c
+NATIVE_SRCS=native/RTjpegN.c native/cinepak.c native/fli.c native/minilzo.c native/msvidc.c native/nuppelvideo.c native/qtrle.c native/qtrpza.c native/qtsmc.c native/roqav.c native/xa_gsm.c native/svq1.c native/decode144.c native/decode288.c
 
 ifeq ($(FAME),yes)
 VFILTER_SRCS += vf_fame.c

Index: ad.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpcodecs/ad.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ad.c	25 Feb 2003 15:36:30 -0000	1.15
+++ ad.c	8 Jun 2003 20:27:25 -0000	1.16
@@ -38,6 +38,7 @@
 extern ad_functions_t mpcodecs_ad_realaud;
 extern ad_functions_t mpcodecs_ad_libdv;
 extern ad_functions_t mpcodecs_ad_qtaudio;
+extern ad_functions_t mpcodecs_ad_ra1428;
 
 ad_functions_t* mpcodecs_ad_drivers[] =
 {
@@ -85,5 +86,6 @@
 #ifdef HAVE_LIBDV095
   &mpcodecs_ad_libdv,
 #endif
+  &mpcodecs_ad_ra1428,
   NULL
 };



More information about the MPlayer-cvslog mailing list