Commit 8153d415 authored by Michel Lespinasse's avatar Michel Lespinasse

Proprification du decodeur mpeg audio, comme j'avais fait pour l'ac3 :
separation de ce qui est specifique videolan et de ce qui est generique.

Je compte encore bidouiller pas mal la partie generique, mais deja la ca
marche donc...
parent 4eed2dd0
This diff is collapsed.
......@@ -230,7 +230,8 @@ ac3_decoder_obj = ac3_decoder/ac3_decoder_thread.o \
ac3_decoder/ac3_imdct.o \
ac3_decoder/ac3_downmix.o
audio_decoder_obj = audio_decoder/audio_decoder.o \
audio_decoder_obj = audio_decoder/audio_decoder_thread.o \
audio_decoder/audio_decoder.o \
audio_decoder/audio_math.o
spu_decoder_obj = spu_decoder/spu_decoder.o
......
/*****************************************************************************
* audio_decoder.h : audio decoder thread interface
* audio_decoder.h : audio decoder interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
......@@ -21,87 +21,71 @@
* Boston, MA 02111-1307, USA.
*****************************************************************************/
/*****************************************************************************
* = Prototyped functions are implemented in audio_decoder/audio_decoder.c
*
* = Required headers :
* - "common.h" ( u32, byte_t, boolean_t )
* - "threads.h" ( vlc_thread_t )
* - "input.h" ( ts_packet_t, input_thread_t )
* - "decoder_fifo.h" ( decoder_fifo_t )
* - "audio_output.h" ( aout_fifo_t, aout_thread_t )
*
* = - LSb = Least Significant bit
* - LSB = Least Significant Byte
*
* = - MSb = Most Significant bit
* - MSB = Most Significant Byte
*****************************************************************************/
/**** audio decoder API - public audio decoder structures */
/*
* TODO :
* - Etudier /usr/include/asm/bitops.h d'un peu plus prs, bien qu'il ne me
* semble pas tre possible d'utiliser ces fonctions ici
* - N'y aurait-t-il pas moyen de se passer d'un buffer de bits, en travaillant
* directement sur le flux PES ?
*/
typedef struct audiodec_s audiodec_t;
#define ADEC_FRAME_SIZE 384
typedef struct adec_sync_info_s {
int sample_rate; /* sample rate in Hz */
int frame_size; /* frame size in bytes */
int bit_rate; /* nominal bit rate in kbps */
} adec_sync_info_t;
/*****************************************************************************
* adec_frame_t
*****************************************************************************/
typedef s16 adec_frame_t[ ADEC_FRAME_SIZE ];
typedef struct adec_byte_stream_s {
u8 * p_byte;
u8 * p_end;
void * info;
} adec_byte_stream_t;
/*****************************************************************************
* adec_bank_t
*****************************************************************************/
typedef struct adec_bank_s
{
/**** audio decoder API - functions publically provided by the audio dec. ****/
int adec_init (audiodec_t * p_adec);
int adec_sync_frame (audiodec_t * p_adec, adec_sync_info_t * p_sync_info);
int adec_decode_frame (audiodec_t * p_adec, s16 * buffer);
static adec_byte_stream_t * adec_byte_stream (audiodec_t * p_adec);
/**** audio decoder API - user functions to be provided to the audio dec. ****/
void adec_byte_stream_next (adec_byte_stream_t * p_byte_stream);
/**** EVERYTHING AFTER THIS POINT IS PRIVATE ! DO NOT USE DIRECTLY ****/
/**** audio decoder internal structures ****/
typedef struct adec_bank_s {
float v1[512];
float v2[512];
float * actual;
int pos;
} adec_bank_t;
/*****************************************************************************
* adec_thread_t : audio decoder thread descriptor
*****************************************************************************
* This type describes an audio decoder thread
*****************************************************************************/
typedef struct adec_thread_s
{
/*
* Thread properties
*/
vlc_thread_t thread_id; /* id for thread functions */
boolean_t b_die; /* `die' flag */
boolean_t b_error; /* `error' flag */
typedef struct adec_bit_stream_s {
u32 buffer;
int i_available;
adec_byte_stream_t byte_stream;
int total_bytes_read;
} adec_bit_stream_t;
struct audiodec_s {
/*
* Input properties
*/
decoder_fifo_t fifo; /* stores the PES stream data */
/* The bit stream structure handles the PES stream at the bit level */
bit_stream_t bit_stream;
adec_bit_stream_t bit_stream;
/*
* Decoder properties
*/
u32 header;
int frame_size;
adec_bank_t bank_0;
adec_bank_t bank_1;
};
/*
* Output properties
*/
aout_fifo_t * p_aout_fifo; /* stores the decompressed audio frames */
aout_thread_t * p_aout; /* needed to create the audio fifo */
} adec_thread_t;
/**** audio decoder inline functions ****/
/*****************************************************************************
* Prototypes
*****************************************************************************/
adec_thread_t * adec_CreateThread ( input_thread_t * p_input /* !! , aout_thread_t * p_aout !! */ );
void adec_DestroyThread ( adec_thread_t * p_adec );
static adec_byte_stream_t * adec_byte_stream (audiodec_t * p_adec)
{
return &(p_adec->bit_stream.byte_stream);
}
/*****************************************************************************
* audio_decoder_thread.h : audio decoder thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
*
* Authors:
*
* 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-1307, USA.
*****************************************************************************/
/*****************************************************************************
* adec_thread_t : audio decoder thread descriptor
*****************************************************************************/
typedef struct adec_thread_s
{
/*
* Thread properties
*/
vlc_thread_t thread_id; /* id for thread functions */
boolean_t b_die; /* `die' flag */
boolean_t b_error; /* `error' flag */
/*
* Input properties
*/
decoder_fifo_t fifo; /* stores the PES stream data */
input_thread_t * p_input;
ts_packet_t * p_ts;
int align;
/*
* Decoder properties
*/
audiodec_t audio_decoder;
/*
* Output properties
*/
aout_fifo_t * p_aout_fifo; /* stores the decompressed audio frames */
aout_thread_t * p_aout; /* needed to create the audio fifo */
} adec_thread_t;
/*****************************************************************************
* Prototypes
*****************************************************************************/
adec_thread_t * adec_CreateThread ( input_thread_t * p_input /* !! , aout_thread_t * p_aout !! */ );
void adec_DestroyThread ( adec_thread_t * p_adec );
This diff is collapsed.
/*****************************************************************************
* audio_bit_stream.h: getbits functions for the audio decoder
*****************************************************************************
* Copyright (C) 2000 VideoLAN
*
* Authors:
*
* 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-1307, USA.
*****************************************************************************/
static __inline__ u8 GetByte (adec_bit_stream_t * p_bit_stream)
{
/* Are there some bytes left in the current buffer ? */
if (p_bit_stream->byte_stream.p_byte >= p_bit_stream->byte_stream.p_end) {
/* no, switch to next buffer */
adec_byte_stream_next (&p_bit_stream->byte_stream);
}
p_bit_stream->total_bytes_read++;
return *(p_bit_stream->byte_stream.p_byte++);
}
static __inline__ void NeedBits (adec_bit_stream_t * p_bit_stream, int i_bits)
{
while (p_bit_stream->i_available < i_bits) {
p_bit_stream->buffer |=
((u32)GetByte (p_bit_stream)) << (24 - p_bit_stream->i_available);
p_bit_stream->i_available += 8;
}
}
static __inline__ void DumpBits (adec_bit_stream_t * p_bit_stream, int i_bits)
{
p_bit_stream->buffer <<= i_bits;
p_bit_stream->i_available -= i_bits;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -54,7 +54,8 @@
#include "audio_output.h" /* aout_thread_t */
#include "audio_decoder.h" /* adec_thread_t */
#include "audio_decoder.h" /* audiodec_t (for audio_decoder_thread.h) */
#include "audio_decoder_thread.h" /* adec_thread_t */
#include "ac3_decoder.h" /* ac3dec_t (for ac3_decoder_thread.h) */
#include "ac3_decoder_thread.h" /* ac3dec_thread_t */
......
......@@ -47,7 +47,8 @@
#include "audio_output.h" /* aout_thread_t */
#include "audio_decoder.h" /* adec_thread_t */
#include "audio_decoder.h" /* audiodec_t (for audio_decoder_thread.h) */
#include "audio_decoder_thread.h" /* adec_thread_t */
#include "ac3_decoder.h" /* ac3dec_t (for ac3_decoder_thread.h) */
#include "ac3_decoder_thread.h" /* ac3dec_thread_t */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment