forked from videolan/vlc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ./modules/codec/a52old/a52old.c: ported the old A52 decoder to aout3.
* ./modules/audio_filter/converter/s16tofloat32.c: converter needed for a52old, includes the walken trick and b_in_place = true.
- Loading branch information
Sam Hocevar
committed
Aug 21, 2002
1 parent
620b69b
commit afa6c92
Showing
8 changed files
with
693 additions
and
532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/***************************************************************************** | ||
* s16tofloat32.c : converter from signed 16 bits integer to float32 | ||
***************************************************************************** | ||
* Copyright (C) 2002 VideoLAN | ||
* $Id: s16tofloat32.c,v 1.1 2002/08/21 09:27:40 sam Exp $ | ||
* | ||
* Authors: Samuel Hocevar <[email protected]> | ||
* | ||
* This program 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. | ||
* | ||
* This program 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, USA. | ||
*****************************************************************************/ | ||
|
||
/***************************************************************************** | ||
* Preamble | ||
*****************************************************************************/ | ||
#include <errno.h> | ||
#include <stdlib.h> /* malloc(), free() */ | ||
#include <string.h> | ||
|
||
#include <vlc/vlc.h> | ||
#include "audio_output.h" | ||
#include "aout_internal.h" | ||
|
||
/***************************************************************************** | ||
* Local prototypes | ||
*****************************************************************************/ | ||
static int Create ( vlc_object_t * ); | ||
|
||
static void DoWork ( aout_instance_t *, aout_filter_t *, aout_buffer_t *, | ||
aout_buffer_t * ); | ||
|
||
/***************************************************************************** | ||
* Module descriptor | ||
*****************************************************************************/ | ||
vlc_module_begin(); | ||
set_description( _("aout filter for s16->float32 conversion") ); | ||
set_capability( "audio filter", 1 ); | ||
set_callbacks( Create, NULL ); | ||
vlc_module_end(); | ||
|
||
/***************************************************************************** | ||
* Create: allocate trivial mixer | ||
***************************************************************************** | ||
* This function allocates and initializes a Crop vout method. | ||
*****************************************************************************/ | ||
static int Create( vlc_object_t *p_this ) | ||
{ | ||
aout_filter_t * p_filter = (aout_filter_t *)p_this; | ||
|
||
if ( p_filter->input.i_format != AOUT_FMT_S16_NE | ||
|| p_filter->output.i_format != AOUT_FMT_FLOAT32 ) | ||
{ | ||
return -1; | ||
} | ||
|
||
if ( !AOUT_FMTS_SIMILAR( &p_filter->input, &p_filter->output ) ) | ||
{ | ||
return -1; | ||
} | ||
|
||
p_filter->pf_do_work = DoWork; | ||
p_filter->b_in_place = VLC_TRUE; | ||
|
||
return 0; | ||
} | ||
|
||
/***************************************************************************** | ||
* DoWork: convert a buffer | ||
*****************************************************************************/ | ||
static void DoWork( aout_instance_t * p_aout, aout_filter_t * p_filter, | ||
aout_buffer_t * p_in_buf, aout_buffer_t * p_out_buf ) | ||
{ | ||
int i = p_in_buf->i_nb_samples * p_filter->input.i_channels; | ||
|
||
/* We start from the end because b_in_place is true */ | ||
s16 * p_in = (s16 *)p_in_buf->p_buffer + i - 1; | ||
float * p_out = (float *)p_out_buf->p_buffer + i - 1; | ||
|
||
while( i-- ) | ||
{ | ||
#if 0 | ||
/* Slow version */ | ||
*p_out = (float)*p_in / 32768.0; | ||
#else | ||
/* This is walken's trick based on IEEE float format. On my PIII | ||
* this takes 16 seconds to perform one billion conversions, instead | ||
* of 19 seconds for the above division. */ | ||
s32 i_out = *p_in + 0x43c00000; | ||
float f_out = *(float *)&i_out; | ||
*p_out = f_out - 384.0; | ||
#endif | ||
|
||
p_in--; p_out--; | ||
} | ||
|
||
p_out_buf->i_nb_samples = p_in_buf->i_nb_samples; | ||
p_out_buf->i_nb_bytes = p_in_buf->i_nb_bytes * 2; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* a52old.c: A52 decoder module main file | ||
***************************************************************************** | ||
* Copyright (C) 1999-2001 VideoLAN | ||
* $Id: a52old.c,v 1.2 2002/08/04 20:04:11 sam Exp $ | ||
* $Id: a52old.c,v 1.3 2002/08/21 09:27:40 sam Exp $ | ||
* | ||
* Authors: Michel Lespinasse <[email protected]> | ||
* | ||
|
@@ -31,6 +31,8 @@ | |
#include <vlc/aout.h> | ||
#include <vlc/decoder.h> | ||
|
||
#include "aout_internal.h" | ||
|
||
#ifdef HAVE_UNISTD_H | ||
# include <unistd.h> /* getpid() */ | ||
#endif | ||
|
@@ -39,17 +41,16 @@ | |
#include "downmix.h" | ||
#include "adec.h" | ||
|
||
#define A52DEC_FRAME_SIZE (2*1536) | ||
#define A52DEC_FRAME_SIZE 1536 | ||
|
||
/***************************************************************************** | ||
* Local prototypes | ||
*****************************************************************************/ | ||
static int OpenDecoder ( vlc_object_t * ); | ||
static int RunDecoder ( decoder_fifo_t * ); | ||
static int InitThread ( a52dec_t * p_adec ); | ||
static void EndThread ( a52dec_t * p_adec ); | ||
static void BitstreamCallback ( bit_stream_t *p_bit_stream, | ||
vlc_bool_t b_new_pes ); | ||
static int InitThread ( a52dec_t * ); | ||
static void EndThread ( a52dec_t * ); | ||
static void BitstreamCallback ( bit_stream_t *, vlc_bool_t ); | ||
|
||
/***************************************************************************** | ||
* Module descriptor | ||
|
@@ -94,6 +95,10 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) | |
void * p_orig; /* pointer before memalign */ | ||
vlc_bool_t b_sync = 0; | ||
|
||
mtime_t i_pts; | ||
aout_buffer_t *p_aout_buffer; | ||
audio_sample_format_t output_format; | ||
|
||
/* Allocate the memory needed to store the thread's structure */ | ||
p_a52dec = (a52dec_t *)vlc_memalign( &p_orig, 16, sizeof(a52dec_t) ); | ||
memset( p_a52dec, 0, sizeof( a52dec_t ) ); | ||
|
@@ -121,7 +126,6 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) | |
/* FIXME : do we have enough room to store the decoded frames ?? */ | ||
while ((!p_a52dec->p_fifo->b_die) && (!p_a52dec->p_fifo->b_error)) | ||
{ | ||
s16 * buffer; | ||
sync_info_t sync_info; | ||
|
||
if( !b_sync ) | ||
|
@@ -154,54 +158,64 @@ static int RunDecoder( decoder_fifo_t *p_fifo ) | |
continue; | ||
} | ||
|
||
if( ( p_a52dec->p_aout_fifo != NULL ) && | ||
( p_a52dec->p_aout_fifo->i_rate != sync_info.sample_rate ) ) | ||
if( ( p_a52dec->p_aout_input == NULL )|| | ||
( output_format.i_rate != sync_info.sample_rate ) ) | ||
{ | ||
/* Make sure the output thread leaves the NextFrame() function */ | ||
vlc_mutex_lock (&(p_a52dec->p_aout_fifo->data_lock)); | ||
aout_DestroyFifo (p_a52dec->p_aout_fifo); | ||
vlc_cond_signal (&(p_a52dec->p_aout_fifo->data_wait)); | ||
vlc_mutex_unlock (&(p_a52dec->p_aout_fifo->data_lock)); | ||
if( p_a52dec->p_aout_input ) | ||
{ | ||
/* Delete old output */ | ||
msg_Warn( p_a52dec->p_fifo, "opening a new aout" ); | ||
aout_InputDelete( p_a52dec->p_aout, p_a52dec->p_aout_input ); | ||
} | ||
|
||
p_a52dec->p_aout_fifo = NULL; | ||
/* Set output configuration */ | ||
output_format.i_format = AOUT_FMT_S16_NE; | ||
output_format.i_channels = 2; /* FIXME ! */ | ||
output_format.i_rate = sync_info.sample_rate; | ||
p_a52dec->p_aout_input = aout_InputNew( p_a52dec->p_fifo, | ||
&p_a52dec->p_aout, | ||
&output_format ); | ||
} | ||
|
||
/* Creating the audio output fifo if not created yet */ | ||
if (p_a52dec->p_aout_fifo == NULL ) { | ||
p_a52dec->p_aout_fifo = | ||
aout_CreateFifo( p_a52dec->p_fifo, AOUT_FIFO_PCM, 2, | ||
sync_info.sample_rate, A52DEC_FRAME_SIZE, NULL ); | ||
if ( p_a52dec->p_aout_fifo == NULL ) | ||
{ | ||
p_a52dec->p_fifo->b_error = 1; | ||
break; | ||
} | ||
if( p_a52dec->p_aout_input == NULL ) | ||
{ | ||
msg_Err( p_a52dec->p_fifo, "failed to create aout fifo" ); | ||
p_a52dec->p_fifo->b_error = 1; | ||
continue; | ||
} | ||
|
||
CurrentPTS( &p_a52dec->bit_stream, | ||
&p_a52dec->p_aout_fifo->date[p_a52dec->p_aout_fifo->i_end_frame], | ||
NULL ); | ||
if( !p_a52dec->p_aout_fifo->date[p_a52dec->p_aout_fifo->i_end_frame] ) | ||
p_aout_buffer = aout_BufferNew( p_a52dec->p_aout, | ||
p_a52dec->p_aout_input, | ||
A52DEC_FRAME_SIZE ); | ||
if( !p_aout_buffer ) | ||
{ | ||
p_a52dec->p_aout_fifo->date[ | ||
p_a52dec->p_aout_fifo->i_end_frame] = | ||
LAST_MDATE; | ||
msg_Err( p_a52dec->p_fifo, "cannot get aout buffer" ); | ||
p_a52dec->p_fifo->b_error = 1; | ||
continue; | ||
} | ||
|
||
buffer = ((s16 *)p_a52dec->p_aout_fifo->buffer) + | ||
(p_a52dec->p_aout_fifo->i_end_frame * A52DEC_FRAME_SIZE); | ||
|
||
if (decode_frame (p_a52dec, buffer)) | ||
CurrentPTS( &p_a52dec->bit_stream, &i_pts, NULL ); | ||
if( i_pts > 0 ) | ||
{ | ||
p_a52dec->i_pts = i_pts; | ||
} | ||
p_aout_buffer->start_date = p_a52dec->i_pts; | ||
p_a52dec->i_pts += (mtime_t)1000000 * (mtime_t)A52DEC_FRAME_SIZE | ||
/ (mtime_t)output_format.i_rate; | ||
p_aout_buffer->end_date = p_a52dec->i_pts; | ||
|
||
if (decode_frame (p_a52dec, (s16*)p_aout_buffer->p_buffer)) | ||
{ | ||
b_sync = 0; | ||
aout_BufferDelete( p_a52dec->p_aout, p_a52dec->p_aout_input, | ||
p_aout_buffer ); | ||
continue; | ||
} | ||
|
||
vlc_mutex_lock (&p_a52dec->p_aout_fifo->data_lock); | ||
p_a52dec->p_aout_fifo->i_end_frame = | ||
(p_a52dec->p_aout_fifo->i_end_frame + 1) & AOUT_FIFO_SIZE; | ||
vlc_cond_signal (&p_a52dec->p_aout_fifo->data_wait); | ||
vlc_mutex_unlock (&p_a52dec->p_aout_fifo->data_lock); | ||
else | ||
{ | ||
aout_BufferPlay( p_a52dec->p_aout, p_a52dec->p_aout_input, | ||
p_aout_buffer ); | ||
} | ||
|
||
RealignBits(&p_a52dec->bit_stream); | ||
} | ||
|
@@ -302,7 +316,9 @@ static int InitThread( a52dec_t * p_a52dec ) | |
/* | ||
* Initialize the output properties | ||
*/ | ||
p_a52dec->p_aout_fifo = NULL; | ||
p_a52dec->p_aout = NULL; | ||
p_a52dec->p_aout_input = NULL; | ||
p_a52dec->i_pts = 0; | ||
|
||
/* | ||
* Bit stream | ||
|
@@ -319,14 +335,9 @@ static int InitThread( a52dec_t * p_a52dec ) | |
static void EndThread (a52dec_t * p_a52dec) | ||
{ | ||
/* If the audio output fifo was created, we destroy it */ | ||
if (p_a52dec->p_aout_fifo != NULL) | ||
if( p_a52dec->p_aout_input ) | ||
{ | ||
aout_DestroyFifo (p_a52dec->p_aout_fifo); | ||
|
||
/* Make sure the output thread leaves the NextFrame() function */ | ||
vlc_mutex_lock (&(p_a52dec->p_aout_fifo->data_lock)); | ||
vlc_cond_signal (&(p_a52dec->p_aout_fifo->data_wait)); | ||
vlc_mutex_unlock (&(p_a52dec->p_aout_fifo->data_lock)); | ||
aout_InputDelete( p_a52dec->p_aout, p_a52dec->p_aout_input ); | ||
} | ||
|
||
/* Free allocated structures */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* adec.h : A52 decoder interface | ||
***************************************************************************** | ||
* Copyright (C) 1999, 2000 VideoLAN | ||
* $Id: adec.h,v 1.2 2002/08/08 00:35:11 sam Exp $ | ||
* $Id: adec.h,v 1.3 2002/08/21 09:27:40 sam Exp $ | ||
* | ||
* Authors: Michel Kaempf <[email protected]> | ||
* Renaud Dartus <[email protected]> | ||
|
@@ -399,7 +399,9 @@ struct a52dec_s | |
/* | ||
* Output properties | ||
*/ | ||
aout_fifo_t * p_aout_fifo; /* stores the decompressed audio frames */ | ||
aout_instance_t * p_aout; | ||
aout_input_t * p_aout_input; | ||
mtime_t i_pts; | ||
|
||
float * samples; | ||
void * samples_orig; /* pointer before memalign */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
* downmix.c : A52 downmix module | ||
***************************************************************************** | ||
* Copyright (C) 1999-2001 VideoLAN | ||
* $Id: downmix.c,v 1.1 2002/08/04 17:23:42 sam Exp $ | ||
* $Id: downmix.c,v 1.2 2002/08/21 09:27:40 sam Exp $ | ||
* | ||
* Authors: Renaud Dartus <[email protected]> | ||
* | ||
|
@@ -62,11 +62,13 @@ vlc_module_begin(); | |
set_description( _("SSE A52 downmix module") ); | ||
set_capability( "downmix", 200 ); | ||
add_shortcut( "sse" ); | ||
add_requirement( SSE ); | ||
#elif defined( MODULE_NAME_IS_downmix3dn ) | ||
set_description( _("3D Now! A52 downmix module") ); | ||
set_capability( "downmix", 200 ); | ||
add_shortcut( "3dn" ); | ||
add_shortcut( "3dnow" ); | ||
add_requirement( 3DNOW ); | ||
#endif | ||
set_callbacks( Open, NULL ); | ||
vlc_module_end(); | ||
|
Oops, something went wrong.