From 1960afd6d989f4bfa9eba33513baf16de8e49fca Mon Sep 17 00:00:00 2001 From: James Courtier-Dutton Date: Fri, 18 Oct 2002 12:28:09 +0000 Subject: Enable liba52 for new api. CVS patchset: 2847 CVS date: 2002/10/18 12:28:09 --- src/Makefile.am | 1 + src/demuxers/demux_mpeg_block.c | 39 ++++-- src/liba52/imdct.c | 4 +- src/liba52/xine_decoder.c | 262 ++++++++++++++++++++++------------------ 4 files changed, 179 insertions(+), 127 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index d79bd337a..e6ad9031a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,6 +32,7 @@ SUBDIRS = \ input \ demuxers \ libffmpeg \ + liba52 \ libmad debug: diff --git a/src/demuxers/demux_mpeg_block.c b/src/demuxers/demux_mpeg_block.c index cb3e22c42..a8775a8f4 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.120 2002/10/18 07:13:10 jcdutton Exp $ + * $Id: demux_mpeg_block.c,v 1.121 2002/10/18 12:28:10 jcdutton Exp $ * * demultiplexer for mpeg 1/2 program streams * @@ -532,6 +532,9 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m buf->input_length = this->input->get_length (this->input); this->video_fifo->put (this->video_fifo, buf); +#ifdef LOG + printf ("demux_mpeg_block: SPU PACK put on fifo\n"); +#endif return; } @@ -556,9 +559,12 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m buf->input_pos = this->input->get_current_pos(this->input); buf->input_length = this->input->get_length (this->input); - if(this->audio_fifo) + if(this->audio_fifo) { this->audio_fifo->put (this->audio_fifo, buf); - else +#ifdef LOG + printf ("demux_mpeg_block: A52 PACK put on fifo\n"); +#endif + } else buf->free_buffer(buf); return ; @@ -620,9 +626,12 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m buf->input_pos = this->input->get_current_pos(this->input); buf->input_length = this->input->get_length (this->input); - if(this->audio_fifo) + if(this->audio_fifo) { this->audio_fifo->put (this->audio_fifo, buf); - else +#ifdef LOG + printf ("demux_mpeg_block: LPCM PACK put on fifo\n"); +#endif + } else buf->free_buffer(buf); return ; @@ -641,6 +650,9 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m buf->input_length = this->input->get_length (this->input); this->video_fifo->put (this->video_fifo, buf); +#ifdef LOG + printf ("demux_mpeg_block: MPEG Video PACK put on fifo\n"); +#endif return ; @@ -659,9 +671,12 @@ static void demux_mpeg_block_parse_pack (demux_mpeg_block_t *this, int preview_m buf->input_pos = this->input->get_current_pos(this->input); buf->input_length = this->input->get_length (this->input); - if(this->audio_fifo) + if(this->audio_fifo) { this->audio_fifo->put (this->audio_fifo, buf); - else +#ifdef LOG + printf ("demux_mpeg_block: MPEG Audio PACK put on fifo\n"); +#endif + } else buf->free_buffer(buf); return ; @@ -856,6 +871,9 @@ static int demux_mpeg_block_estimate_rate (demux_mpeg_block_t *this) { } +#ifdef LOG + printf("demux_mpeg_block:est_rate=%d\n",rate); +#endif return rate; } @@ -1128,6 +1146,10 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str this->status = DEMUX_FINISHED; pthread_mutex_init( &this->mutex, NULL ); +#ifdef LOG + printf("demux_mpeg_block:open_plugin:detection_method=%d\n",stream->content_detection_method); +#endif + switch (stream->content_detection_method) { case XINE_DEMUX_CONTENT_STRATEGY: { @@ -1162,6 +1184,9 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str } demux_mpeg_block_accept_input (this, input); +#ifdef LOG + printf("demux_mpeg_block:open_plugin:Accepting detection_method XINE_DEMUX_CONTENT_STRATEGY blocksize=%d\n",this->blocksize); +#endif break; } } diff --git a/src/liba52/imdct.c b/src/liba52/imdct.c index 648c95ede..31d82fb17 100644 --- a/src/liba52/imdct.c +++ b/src/liba52/imdct.c @@ -419,13 +419,13 @@ void a52_imdct_init (uint32_t mm_accel) #ifdef LIBA52_DJBFFT if (mm_accel & MM_ACCEL_DJBFFT) { - fprintf (stderr, "Using djbfft for IMDCT transform\n"); + fprintf (stderr, "liba52:Using djbfft for IMDCT transform\n"); ifft128 = (void (*) (complex_t *)) fftc4_un128; ifft64 = (void (*) (complex_t *)) fftc4_un64; } else #endif { - fprintf (stderr, "No accelerated IMDCT transform found\n"); + fprintf (stderr, "liba52:No accelerated IMDCT transform found\n"); ifft128 = ifft128_c; ifft64 = ifft64_c; } diff --git a/src/liba52/xine_decoder.c b/src/liba52/xine_decoder.c index 26a7403dc..c8cb9f088 100644 --- a/src/liba52/xine_decoder.c +++ b/src/liba52/xine_decoder.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: xine_decoder.c,v 1.32 2002/09/05 22:18:55 mroi Exp $ + * $Id: xine_decoder.c,v 1.33 2002/10/18 12:28:11 jcdutton Exp $ * * stuff needed to turn liba52 into a xine decoder plugin */ @@ -47,9 +47,15 @@ int a52file; #endif +typedef struct { + audio_decoder_class_t decoder_class; +} a52dec_class_t; + typedef struct a52dec_decoder_s { audio_decoder_t audio_decoder; + a52dec_class_t *class; + xine_stream_t *stream; int64_t pts; uint8_t frame_buffer[3840]; @@ -136,106 +142,6 @@ void a52dec_reset (audio_decoder_t *this_gen) { this->pts = 0; } -void a52dec_init (audio_decoder_t *this_gen, ao_instance_t *audio_out) { - - a52dec_decoder_t *this = (a52dec_decoder_t *) this_gen; - /* int i; */ - - this->audio_out = audio_out; - this->audio_caps = audio_out->get_capabilities(audio_out); - this->syncword = 0; - this->sync_todo = 7; - this->output_open = 0; - this->pts = 0; - - if( !this->a52_state ) - this->a52_state = a52_init (xine_mm_accel()); - - /* - * find out if this driver supports a52 output - * or, if not, how many channels we've got - */ - - if (this->audio_caps & AO_CAP_MODE_A52) - this->bypass_mode = 1; - else { - this->bypass_mode = 0; - - this->a52_flags_map[A52_MONO] = A52_MONO; - this->a52_flags_map[A52_STEREO] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); - this->a52_flags_map[A52_3F] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); - this->a52_flags_map[A52_2F1R] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); - this->a52_flags_map[A52_3F1R] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); - this->a52_flags_map[A52_2F2R] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); - this->a52_flags_map[A52_3F2R] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); - this->a52_flags_map[A52_DOLBY] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); - - this->ao_flags_map[A52_MONO] = AO_CAP_MODE_MONO; - this->ao_flags_map[A52_STEREO] = AO_CAP_MODE_STEREO; - this->ao_flags_map[A52_3F] = AO_CAP_MODE_STEREO; - this->ao_flags_map[A52_2F1R] = AO_CAP_MODE_STEREO; - this->ao_flags_map[A52_3F1R] = AO_CAP_MODE_STEREO; - this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_STEREO; - this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_STEREO; - this->ao_flags_map[A52_DOLBY] = AO_CAP_MODE_STEREO; - - /* find best mode */ - if (this->audio_caps & AO_CAP_MODE_5_1CHANNEL) { - - this->a52_flags_map[A52_2F2R] = A52_2F2R; - this->a52_flags_map[A52_3F2R] = A52_3F2R | A52_LFE; - this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_4CHANNEL; - this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_5CHANNEL; - - } else if (this->audio_caps & AO_CAP_MODE_5CHANNEL) { - - this->a52_flags_map[A52_2F2R] = A52_2F2R; - this->a52_flags_map[A52_3F2R] = A52_3F2R; - this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_4CHANNEL; - this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_5CHANNEL; - - } else if (this->audio_caps & AO_CAP_MODE_4CHANNEL) { - - this->a52_flags_map[A52_2F2R] = A52_2F2R; - this->a52_flags_map[A52_3F2R] = A52_2F2R; - - this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_4CHANNEL; - this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_4CHANNEL; - - /* else if (this->audio_caps & AO_CAP_MODE_STEREO) - defaults are ok */ - } else if (!(this->audio_caps & AO_CAP_MODE_STEREO)) { - printf ("HELP! a mono-only audio driver?!\n"); - - this->a52_flags_map[A52_MONO] = A52_MONO; - this->a52_flags_map[A52_STEREO] = A52_MONO; - this->a52_flags_map[A52_3F] = A52_MONO; - this->a52_flags_map[A52_2F1R] = A52_MONO; - this->a52_flags_map[A52_3F1R] = A52_MONO; - this->a52_flags_map[A52_2F2R] = A52_MONO; - this->a52_flags_map[A52_3F2R] = A52_MONO; - this->a52_flags_map[A52_DOLBY] = A52_MONO; - - this->ao_flags_map[A52_MONO] = AO_CAP_MODE_MONO; - this->ao_flags_map[A52_STEREO] = AO_CAP_MODE_MONO; - this->ao_flags_map[A52_3F] = AO_CAP_MODE_MONO; - this->ao_flags_map[A52_2F1R] = AO_CAP_MODE_MONO; - this->ao_flags_map[A52_3F1R] = AO_CAP_MODE_MONO; - this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_MONO; - this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_MONO; - this->ao_flags_map[A52_DOLBY] = AO_CAP_MODE_MONO; - } - } - - /* - for (i = 0; i<8; i++) - this->a52_flags_map[i] |= A52_ADJUST_LEVEL; - */ -#ifdef DEBUG_A52 - a52file = open ("test.a52", O_CREAT | O_WRONLY | O_TRUNC, 0644); -#endif -} - static inline int16_t blah (int32_t i) { if (i > 0x43c07fff) @@ -420,7 +326,7 @@ static void a52dec_decode_frame (a52dec_decoder_t *this, int64_t pts) { buf->num_frames = 1536; buf->vpts = pts; - + this->audio_out->put_buffer (this->audio_out, buf); } @@ -509,7 +415,7 @@ void a52dec_decode_data (audio_decoder_t *this_gen, buf_element_t *buf) { } } -void a52dec_close (audio_decoder_t *this_gen) { +static void a52dec_dispose (audio_decoder_t *this_gen) { a52dec_decoder_t *this = (a52dec_decoder_t *) this_gen; @@ -524,33 +430,26 @@ void a52dec_close (audio_decoder_t *this_gen) { #ifdef DEBUG_A52 close (a52file); #endif -} - -static char *a52dec_get_id(void) { - return "a/52dec"; -} - -static void a52dec_dispose (audio_decoder_t *this_gen) { free (this_gen); } -static void *init_audio_decoder_plugin (xine_t *xine, void *data) { +static audio_decoder_t *open_plugin (audio_decoder_class_t *class_gen, xine_stream_t *stream) { a52dec_decoder_t *this ; - config_values_t *cfg; + printf ("liba52:open_plugin called\n"); +// config_values_t *cfg; - cfg = xine->config; +// cfg = xine->config; this = (a52dec_decoder_t *) malloc (sizeof (a52dec_decoder_t)); memset(this, 0, sizeof (a52dec_decoder_t)); - this->audio_decoder.init = a52dec_init; this->audio_decoder.decode_data = a52dec_decode_data; this->audio_decoder.reset = a52dec_reset; - this->audio_decoder.close = a52dec_close; - this->audio_decoder.get_identifier = a52dec_get_id; this->audio_decoder.dispose = a52dec_dispose; + this->stream = stream; + this->class = (a52dec_class_t *) class_gen; - +#if 0 this->a52_level = (float) cfg->register_range (cfg, "codec.a52_level", 100, 0, 200, _("a/52 volume control"), @@ -561,10 +460,137 @@ static void *init_audio_decoder_plugin (xine_t *xine, void *data) { this->enable_surround_downmix = cfg->register_bool (cfg, "codec.a52_surround_downmix", 0, _("enable audio downmixing to 2.0 surround stereo"), NULL, 0, NULL, NULL); +#endif + /* int i; */ + + this->audio_out = stream->audio_out; + this->audio_caps = stream->audio_out->get_capabilities(stream->audio_out); + this->syncword = 0; + this->sync_todo = 7; + this->output_open = 0; + this->pts = 0; + + if( !this->a52_state ) + this->a52_state = a52_init (xine_mm_accel()); + + /* + * find out if this driver supports a52 output + * or, if not, how many channels we've got + */ + + if (this->audio_caps & AO_CAP_MODE_A52) + this->bypass_mode = 1; + else { + this->bypass_mode = 0; + + this->a52_flags_map[A52_MONO] = A52_MONO; + this->a52_flags_map[A52_STEREO] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); + this->a52_flags_map[A52_3F] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); + this->a52_flags_map[A52_2F1R] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); + this->a52_flags_map[A52_3F1R] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); + this->a52_flags_map[A52_2F2R] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); + this->a52_flags_map[A52_3F2R] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); + this->a52_flags_map[A52_DOLBY] = ((this->enable_surround_downmix ? A52_DOLBY : A52_STEREO)); + + this->ao_flags_map[A52_MONO] = AO_CAP_MODE_MONO; + this->ao_flags_map[A52_STEREO] = AO_CAP_MODE_STEREO; + this->ao_flags_map[A52_3F] = AO_CAP_MODE_STEREO; + this->ao_flags_map[A52_2F1R] = AO_CAP_MODE_STEREO; + this->ao_flags_map[A52_3F1R] = AO_CAP_MODE_STEREO; + this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_STEREO; + this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_STEREO; + this->ao_flags_map[A52_DOLBY] = AO_CAP_MODE_STEREO; + + /* find best mode */ + if (this->audio_caps & AO_CAP_MODE_5_1CHANNEL) { + + this->a52_flags_map[A52_2F2R] = A52_2F2R; + this->a52_flags_map[A52_3F2R] = A52_3F2R | A52_LFE; + this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_4CHANNEL; + this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_5CHANNEL; + + } else if (this->audio_caps & AO_CAP_MODE_5CHANNEL) { + + this->a52_flags_map[A52_2F2R] = A52_2F2R; + this->a52_flags_map[A52_3F2R] = A52_3F2R; + this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_4CHANNEL; + this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_5CHANNEL; + + } else if (this->audio_caps & AO_CAP_MODE_4CHANNEL) { + + this->a52_flags_map[A52_2F2R] = A52_2F2R; + this->a52_flags_map[A52_3F2R] = A52_2F2R; + + this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_4CHANNEL; + this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_4CHANNEL; + + /* else if (this->audio_caps & AO_CAP_MODE_STEREO) + defaults are ok */ + } else if (!(this->audio_caps & AO_CAP_MODE_STEREO)) { + printf ("HELP! a mono-only audio driver?!\n"); + + this->a52_flags_map[A52_MONO] = A52_MONO; + this->a52_flags_map[A52_STEREO] = A52_MONO; + this->a52_flags_map[A52_3F] = A52_MONO; + this->a52_flags_map[A52_2F1R] = A52_MONO; + this->a52_flags_map[A52_3F1R] = A52_MONO; + this->a52_flags_map[A52_2F2R] = A52_MONO; + this->a52_flags_map[A52_3F2R] = A52_MONO; + this->a52_flags_map[A52_DOLBY] = A52_MONO; + + this->ao_flags_map[A52_MONO] = AO_CAP_MODE_MONO; + this->ao_flags_map[A52_STEREO] = AO_CAP_MODE_MONO; + this->ao_flags_map[A52_3F] = AO_CAP_MODE_MONO; + this->ao_flags_map[A52_2F1R] = AO_CAP_MODE_MONO; + this->ao_flags_map[A52_3F1R] = AO_CAP_MODE_MONO; + this->ao_flags_map[A52_2F2R] = AO_CAP_MODE_MONO; + this->ao_flags_map[A52_3F2R] = AO_CAP_MODE_MONO; + this->ao_flags_map[A52_DOLBY] = AO_CAP_MODE_MONO; + } + } + + /* + for (i = 0; i<8; i++) + this->a52_flags_map[i] |= A52_ADJUST_LEVEL; + */ +#ifdef DEBUG_A52 + a52file = open ("test.a52", O_CREAT | O_WRONLY | O_TRUNC, 0644); +#endif + return &this->audio_decoder; +} + +static char *get_identifier (audio_decoder_class_t *this) { + printf ("liba52:get_identifier called\n"); + return "a/52dec"; +} + +static char *get_description (audio_decoder_class_t *this) { + printf ("liba52:get_description called\n"); + return "liba52 based a52 audio decoder plugin"; +} + +static void dispose_class (audio_decoder_class_t *this) { + printf ("liba52:dispose_class called\n"); + free (this); +} + +static void *init_plugin (xine_t *xine, void *data) { + + a52dec_class_t *this; + + this = (a52dec_class_t *) malloc (sizeof (a52dec_class_t)); + + this->decoder_class.open_plugin = open_plugin; + this->decoder_class.get_identifier = get_identifier; + this->decoder_class.get_description = get_description; + this->decoder_class.dispose = dispose_class; + + printf ("liba52:init_plugin called\n"); return this; } + static uint32_t audio_types[] = { BUF_AUDIO_A52, 0 }; @@ -576,6 +602,6 @@ static decoder_info_t dec_info_audio = { plugin_info_t xine_plugin_info[] = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_AUDIO_DECODER, 9, "a/52", XINE_VERSION_CODE, &dec_info_audio, init_audio_decoder_plugin }, + { PLUGIN_AUDIO_DECODER, 10, "a/52", XINE_VERSION_CODE, &dec_info_audio, init_plugin }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; -- cgit v1.2.3