diff options
author | Joachim Koenig <joachim_koenig@users.sourceforge.net> | 2001-09-06 15:23:14 +0000 |
---|---|---|
committer | Joachim Koenig <joachim_koenig@users.sourceforge.net> | 2001-09-06 15:23:14 +0000 |
commit | 78da614ffea8cadb2f1f79cd845da7e52210965a (patch) | |
tree | 688b9c4e72694979df701d8e28896d7b91c011ca | |
parent | 44c7e547378f3742955b7bce33a98be03cb1bdbe (diff) | |
download | xine-lib-78da614ffea8cadb2f1f79cd845da7e52210965a.tar.gz xine-lib-78da614ffea8cadb2f1f79cd845da7e52210965a.tar.bz2 |
DTS via SPDIF
CVS patchset: 581
CVS date: 2001/09/06 15:23:14
-rw-r--r-- | configure.in | 1 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/audio_out/audio_alsa_out.c | 6 | ||||
-rw-r--r-- | src/demuxers/demux_mpeg_block.c | 11 | ||||
-rw-r--r-- | src/libdts/Makefile.am | 50 | ||||
-rw-r--r-- | src/libdts/xine_decoder.c | 139 | ||||
-rw-r--r-- | src/xine-engine/audio_out.c | 19 | ||||
-rw-r--r-- | src/xine-engine/buffer.h | 3 |
8 files changed, 222 insertions, 9 deletions
diff --git a/configure.in b/configure.in index 863d8cb82..e5173b270 100644 --- a/configure.in +++ b/configure.in @@ -641,6 +641,7 @@ src/liba52/Makefile src/libffmpeg/Makefile src/libffmpeg/libavcodec/Makefile src/liblpcm/Makefile +src/libdts/Makefile src/libmad/Makefile src/libw32dll/Makefile src/libw32dll/wine/Makefile diff --git a/src/Makefile.am b/src/Makefile.am index 350099b66..2f7bfc01f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS = audio_out video_out dxr3 input libmpeg2 libspudec demuxers \ - liba52 libffmpeg liblpcm libw32dll libmad xine-engine + liba52 libffmpeg liblpcm libw32dll libmad xine-engine libdts debug: @list='$(SUBDIRS)'; for subdir in $$list; do \ diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index b262316f3..fa579409d 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -26,7 +26,7 @@ * (c) 2001 James Courtier-Dutton <James@superbug.demon.co.uk> * * - * $Id: audio_alsa_out.c,v 1.25 2001/09/01 18:00:16 jcdutton Exp $ + * $Id: audio_alsa_out.c,v 1.26 2001/09/06 15:25:13 joachim_koenig Exp $ */ #ifdef HAVE_CONFIG_H @@ -148,6 +148,7 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int pcm_device = this->audio_surround51_device; break; case AO_CAP_MODE_A52: + case AO_CAP_MODE_AC5: this->num_channels = 2; pcm_device = this->audio_a52_device; break; @@ -181,7 +182,7 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int return 0; } - if (mode & AO_CAP_MODE_A52) { + if ((mode & AO_CAP_MODE_A52) || (mode & AO_CAP_MODE_AC5)) { snd_pcm_info_alloca(&info); if ((err = snd_pcm_info(this->audio_fd, info)) < 0) { @@ -510,6 +511,7 @@ ao_driver_t *init_audio_out_plugin (config_values_t *config) { this->output_sample_rate = 0; if (config->lookup_int (config, "a52_pass_through", 0)) { this->capabilities |= AO_CAP_MODE_A52; + this->capabilities |= AO_CAP_MODE_AC5; } printf("audio_alsa_out: Capabilities 0x%X\n",this->capabilities); diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index 82e58da4f..110afbf8d 100644 --- a/src/demuxers/demux_mpeg_block.c +++ b/src/demuxers/demux_mpeg_block.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: demux_mpeg_block.c,v 1.38 2001/09/04 16:19:27 guenter Exp $ + * $Id: demux_mpeg_block.c,v 1.39 2001/09/06 15:24:35 joachim_koenig Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -318,11 +318,14 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m if ((p[0]&0xF0) == 0x80) { xprintf (VERBOSE|DEMUX|AC3, "ac3 PES packet, track %02x\n",track); - /* printf ( "ac3 PES packet, track %02x\n",track); */ + /* printf ( "ac3 PES packet, track %02x\n",track); */ buf->content = p+4; buf->size = packet_len-4; - buf->type = BUF_AUDIO_A52 + track; + if (track & 0x8) + buf->type = BUF_AUDIO_DTS + track; + else + buf->type = BUF_AUDIO_A52 + track; buf->PTS = PTS; buf->input_pos = this->input->get_current_pos(this->input); @@ -361,6 +364,8 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m return ; } + + } else if ((stream_id >= 0xbc) && ((stream_id & 0xf0) == 0xe0)) { xprintf (VERBOSE|DEMUX, "video %d\n", stream_id); diff --git a/src/libdts/Makefile.am b/src/libdts/Makefile.am new file mode 100644 index 000000000..6e7a93629 --- /dev/null +++ b/src/libdts/Makefile.am @@ -0,0 +1,50 @@ +CFLAGS = @GLOBAL_CFLAGS@ + +LIBTOOL = $(SHELL) $(top_builddir)/libtool-nofpic + +libdir = $(XINE_PLUGINDIR) + +lib_LTLIBRARIES = xineplug_decode_dts.la + +xineplug_decode_dts_la_SOURCES = xine_decoder.c +xineplug_decode_dts_la_LDFLAGS = -avoid-version -module + +noinst_HEADERS = + + +## +## Install header files (default=$includedir/xine) +## +install-includeHEADERS: $(include_HEADERS) + @$(NORMAL_INSTALL) + $(mkinstalldirs) $(DESTDIR)$(includedir)/xine + @list='$(include_HEADERS)'; for p in $$list; do \ + if test -f "$$p"; then d= ; else d="$(srcdir)/"; fi; \ + echo " $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/xine/$$p"; \ + $(INSTALL_DATA) $$d$$p $(DESTDIR)$(includedir)/xine/$$p; \ + done + + +## +## Remove them +## +uninstall-includeHEADERS: + @$(NORMAL_UNINSTALL) + list='$(include_HEADERS)'; for p in $$list; do \ + rm -f $(DESTDIR)$(includedir)/xine/$$p; \ + done + + +debug: + @$(MAKE) CFLAGS="$(DEBUG_CFLAGS)" + +install-debug: debug + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +mostlyclean-generic: + -rm -f *~ \#* .*~ .\#* + +maintainer-clean-generic: + -@echo "This command is intended for maintainers to use;" + -@echo "it deletes files that may require special tools to rebuild." + -rm -f Makefile.in diff --git a/src/libdts/xine_decoder.c b/src/libdts/xine_decoder.c new file mode 100644 index 000000000..e0d3d0520 --- /dev/null +++ b/src/libdts/xine_decoder.c @@ -0,0 +1,139 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * $Id: xine_decoder.c,v 1.1 2001/09/06 15:23:14 joachim_koenig Exp $ + * + * 04-09-2001 DTS passtrough (C) Joachim Koenig + * + */ + + +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <netinet/in.h> /* ntohs */ +#include "audio_out.h" +#include "buffer.h" +#include "xine_internal.h" + + +typedef struct dts_decoder_s { + audio_decoder_t audio_decoder; + + uint32_t pts; + uint32_t rate; + uint32_t bits_per_sample; + uint32_t number_of_channels; + uint32_t audio_caps; + + ao_instance_t *audio_out; + int output_open; +} dts_decoder_t; + +int dts_can_handle (audio_decoder_t *this_gen, int buf_type) { + buf_type &= 0xFFFF0000; + + return ( buf_type == BUF_AUDIO_DTS); +} + + +void dts_init (audio_decoder_t *this_gen, ao_instance_t *audio_out) { + + dts_decoder_t *this = (dts_decoder_t *) this_gen; + + this->audio_out = audio_out; + this->output_open = 0; + this->pts = 0; + this->rate = 48000; + this->bits_per_sample=16; + this->number_of_channels=2; + this->audio_caps = audio_out->get_capabilities(audio_out); +} + + +void dts_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { + + dts_decoder_t *this = (dts_decoder_t *) this_gen; + int16_t *sample_buffer=(int16_t *)buf->content; + + if ((this->audio_caps & AO_CAP_MODE_AC5) == 0) { + return; + } + + this->pts = buf->PTS; + + + if (!this->output_open) { + this->output_open = (this->audio_out->open (this->audio_out, this->bits_per_sample, + this->rate, + AO_CAP_MODE_AC5)); + } + if (!this->output_open) { + return; + } + + this->audio_out->write (this->audio_out, + sample_buffer, + 1536, + this->pts); + + +} + +void dts_close (audio_decoder_t *this_gen) { + + dts_decoder_t *this = (dts_decoder_t *) this_gen; +printf("libdts: close \n"); + if (this->output_open) + this->audio_out->close (this->audio_out); + this->output_open = 0; +} + +static char *dts_get_id(void) { + return "dts"; +} + +audio_decoder_t *init_audio_decoder_plugin (int iface_version, config_values_t *cfg) { + + dts_decoder_t *this ; + + if (iface_version != 2) { + printf( "libdts: plugin doesn't support plugin API version %d.\n" + "libdts: this means there's a version mismatch between xine and this " + "libdts: decoder plugin.\nInstalling current plugins should help.\n", + iface_version); + return NULL; + } + + this = (dts_decoder_t *) malloc (sizeof (dts_decoder_t)); + + this->audio_decoder.interface_version = 2; + this->audio_decoder.can_handle = dts_can_handle; + this->audio_decoder.init = dts_init; + this->audio_decoder.decode_data = dts_decode_data; + this->audio_decoder.close = dts_close; + this->audio_decoder.get_identifier = dts_get_id; + this->audio_decoder.priority = 1; + + return (audio_decoder_t *) this; +} + diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 69f6136d7..cb9846410 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.11 2001/09/06 13:33:20 jkeil Exp $ + * $Id: audio_out.c,v 1.12 2001/09/06 15:26:07 joachim_koenig Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -304,7 +304,7 @@ static int ao_write(ao_instance_t *this, if (!bDropPackage) { int num_output_frames = (double) num_frames * this->frame_rate_factor; - if ((!this->do_resample) && (this->mode != AO_CAP_MODE_A52)) { + if ((!this->do_resample) && (this->mode != AO_CAP_MODE_A52) && (this->mode != AO_CAP_MODE_AC5)) { xprintf (VERBOSE|AUDIO, "audio_out: writing without resampling\n"); this->driver->write (this->driver, output_frames, num_output_frames ); @@ -351,6 +351,21 @@ static int ao_write(ao_instance_t *this, this->driver->write(this->driver, this->frame_buffer, 1536); break; + case AO_CAP_MODE_AC5: + memset(this->frame_buffer,0xff,6144); + this->frame_buffer[0] = 0xf872; /* spdif syncword */ + this->frame_buffer[1] = 0x4e1f; /* ............. */ + this->frame_buffer[2] = 0x0001; /* */ + + this->frame_buffer[3] = 0x3ee0; + + /* ac3 seems to be swabbed data */ + swab(output_frames,this->frame_buffer+4, 2014 ); + + this->driver->write(this->driver, this->frame_buffer, 1012); + + break; + } xprintf (AUDIO|VERBOSE, "audio_out :audio package written\n"); diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index 9cd17add0..938c3e339 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer.h,v 1.8 2001/09/01 14:33:00 guenter Exp $ + * $Id: buffer.h,v 1.9 2001/09/06 15:23:46 joachim_koenig Exp $ * * * contents: @@ -91,6 +91,7 @@ extern "C" { #define BUF_AUDIO_LPCM_BE 0x03020000 #define BUF_AUDIO_LPCM_LE 0x03030000 #define BUF_AUDIO_AVI 0x03040000 +#define BUF_AUDIO_DTS 0x03050000 /* spu buffer types: */ |