Commit a132d75c authored by Sam Hocevar's avatar Sam Hocevar

 . this is a coding style patch which removes all "foo(bar){" constructions
   and most of the tabulations.
 . also, fixed a bug in the default subtitle track.
 . and made a few error messages more explicit, ie. changed "error: %s" to
   "foo error: couldn't initialize bar (%s)"
parent df5793c2
......@@ -31,8 +31,8 @@ public:
// standard window member
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message);
// this is the hook controling direct screen connection
// this is the hook controling direct screen connection
virtual void DirectConnected(direct_buffer_info *info);
int32 i_bytes_per_pixel;
......
......@@ -137,7 +137,7 @@
#define INTF_CHANNELS_DEFAULT "vlc.channels"
/* Base delay in micro second for interface sleeps */
#define INTF_IDLE_SLEEP ((int)(0.100*CLOCK_FREQ))
#define INTF_IDLE_SLEEP ((int)(0.050*CLOCK_FREQ))
/* Step for changing gamma, and minimum and maximum values */
#define INTF_GAMMA_STEP .1
......@@ -169,10 +169,10 @@
#define INPUT_MAX_THREADS 10
/* Maximum size of a data packet (128 kB) */
#define INPUT_MAX_PACKET_SIZE 131072
#define INPUT_MAX_PACKET_SIZE 131072
/* Maximum length of a pre-parsed chunk (4 MB) */
#define INPUT_PREPARSE_LENGTH 4194304
#define INPUT_PREPARSE_LENGTH 4194304
/* Maximum length of a hostname or source name */
#define INPUT_MAX_SOURCE_LENGTH 100
......@@ -412,7 +412,7 @@
#define VDEC_CROPRANGE 2048
/* Nice increments for decoders -- necessary for x11 scheduling */
#define VDEC_NICE 3
#define VDEC_NICE 3
/*****************************************************************************
* Generic decoder configuration
......@@ -433,8 +433,8 @@
#define INTF_MSG_QSIZE 64
/* Interface warnig message level */
#define INTF_WARNING_VAR "warning_level"
#define INTF_WARNING_DEFAULT 12
#define INTF_WARNING_VAR "warning_level"
#define INTF_WARNING_DEFAULT 12
/* Define to enable messages queues - disabling messages queue can be usefull
* when debugging, since it allows messages which would not otherwise be printed,
......
......@@ -21,11 +21,11 @@
*****************************************************************************/
/* Basic types definitions */
typedef unsigned char u8;
typedef signed char s8;
typedef unsigned short u16;
typedef signed short s16;
typedef unsigned int u32;
typedef signed int s32;
typedef unsigned long long u64;
typedef signed long long s64;
typedef unsigned char u8;
typedef signed char s8;
typedef unsigned short u16;
typedef signed short s16;
typedef unsigned int u32;
typedef signed int s32;
typedef unsigned long long u64;
typedef signed long long s64;
#ifndef VLC_KEYS
#define VLC_KEYS
#define INTF_KEY_QUIT 0x01
#define INTF_KEY_SET_CHANNEL 0x02
#define INTF_KEY_DEC_VOLUME 0x03
#define INTF_KEY_INC_VOLUME 0x04
#define INTF_KEY_TOGGLE_VOLUME 0x05
#define INTF_KEY_DEC_GAMMA 0x06
#define INTF_KEY_INC_GAMMA 0x07
#define INTF_KEY_TOGGLE_GRAYSCALE 0x08
#define INTF_KEY_TOGGLE_INTERFACE 0x09
#define INTF_KEY_TOGGLE_INFO 0x0A
#define INTF_KEY_TOGGLE_SCALING 0x0B
#define INTF_KEY_UNKNOWN 0x0C
#define INTF_KEY_QUIT 0x01
#define INTF_KEY_SET_CHANNEL 0x02
#define INTF_KEY_DEC_VOLUME 0x03
#define INTF_KEY_INC_VOLUME 0x04
#define INTF_KEY_TOGGLE_VOLUME 0x05
#define INTF_KEY_DEC_GAMMA 0x06
#define INTF_KEY_INC_GAMMA 0x07
#define INTF_KEY_TOGGLE_GRAYSCALE 0x08
#define INTF_KEY_TOGGLE_INTERFACE 0x09
#define INTF_KEY_TOGGLE_INFO 0x0A
#define INTF_KEY_TOGGLE_SCALING 0x0B
#define INTF_KEY_UNKNOWN 0x0C
#endif
......@@ -212,7 +212,7 @@ static __inline__ int vlc_mutex_init( vlc_mutex_t *p_mutex )
#elif defined(HAVE_KERNEL_SCHEDULER_H) && defined(HAVE_KERNEL_OS_H)
// check the arguments and whether it's already been initialized
/* check the arguments and whether it's already been initialized */
if( p_mutex == NULL ) return B_BAD_VALUE;
if( p_mutex->init == 9999 )
{
......
......@@ -25,7 +25,7 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/asoundlib.h> /* for alsa :) */
#include <sys/asoundlib.h> /* for alsa :) */
#include <fcntl.h>
#include <stdlib.h> /* malloc(), free() */
// #include <unistd.h> /* close() */
......
......@@ -63,7 +63,7 @@ typedef struct alsa_card_s
typedef struct aout_sys_s
{
snd_pcm_t * p_alsa_handle;
snd_pcm_t * p_alsa_handle;
alsa_device_t s_alsa_device;
alsa_card_t s_alsa_card;
snd_pcm_channel_params_t s_alsa_channel_params;
......
......@@ -28,7 +28,7 @@
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <SDL/SDL.h> /* for all the SDL stuff */
#include <SDL/SDL.h> /* for all the SDL stuff */
#include <sys/types.h> /* on BSD, uio.h needs types.h */
#include <sys/uio.h> /* for input.h */
......@@ -58,7 +58,7 @@ typedef struct intf_sys_s
{
/* SDL system information */
SDL_Surface * p_display;
boolean_t b_Fullscreen;
boolean_t b_Fullscreen;
} intf_sys_t;
typedef struct vout_sys_s
......@@ -76,7 +76,7 @@ typedef struct vout_sys_s
/* local prototype */
void intf_SDL_Keymap( intf_thread_t * p_intf );
void intf_SDL_Keymap( intf_thread_t * p_intf );
void intf_SDL_Resize( intf_thread_t * p_intf, int width, int height );
void intf_SDL_Fullscreen(intf_thread_t * p_intf);
void intf_SDL_YUVSwitch(intf_thread_t * p_intf);
......
......@@ -99,7 +99,7 @@ plugin_info_t * GetConfig( void )
#else
p_info->yuv_GetPlugin = NULL;
#endif
/* if the SDL libraries are there, assume we can enter the
* initialization part at least, even if we fail afterwards */
......
......@@ -259,7 +259,7 @@ int vout_X11Manage( vout_thread_t *p_vout )
/* Tell the video output thread that it will need to rebuild YUV
* tables. This is needed since conversion buffer size may have
* changed */
* changed */
p_vout->i_changes |= VOUT_YUV_CHANGE;
intf_Msg("Video display resized (%dx%d)", p_vout->i_width, p_vout->i_height);
}
......@@ -412,7 +412,7 @@ static int X11OpenDisplay( vout_thread_t *p_vout, char *psz_display, Window root
* formats. */
p_xpixmap_format = XListPixmapFormats( p_vout->p_sys->p_display, &i_count );
/* Under XFree4.0, the list contains pixmap formats available through
* all video depths ; so we have to check against current depth. */
p_vout->i_bytes_per_pixel = 0;
......
......@@ -23,9 +23,10 @@
static __inline__ u8 GetByte (ac3_byte_stream_t * p_byte_stream)
{
/* Are there some bytes left in the current buffer ? */
if (p_byte_stream->p_byte >= p_byte_stream->p_end) {
/* no, switch to next buffer */
ac3_byte_stream_next (p_byte_stream);
if (p_byte_stream->p_byte >= p_byte_stream->p_end)
{
/* no, switch to next buffer */
ac3_byte_stream_next (p_byte_stream);
}
return *(p_byte_stream->p_byte++);
......@@ -33,9 +34,10 @@ static __inline__ u8 GetByte (ac3_byte_stream_t * p_byte_stream)
static __inline__ void NeedBits (ac3_bit_stream_t * p_bit_stream, int i_bits)
{
while (p_bit_stream->i_available < i_bits) {
while (p_bit_stream->i_available < i_bits)
{
p_bit_stream->buffer |=
((u32)GetByte (&p_bit_stream->byte_stream)) << (24 - p_bit_stream->i_available);
((u32)GetByte (&p_bit_stream->byte_stream)) << (24 - p_bit_stream->i_available);
p_bit_stream->i_available += 8;
}
}
......
......@@ -26,9 +26,9 @@
typedef struct ac3dec_s ac3dec_t;
typedef struct ac3_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 */
int sample_rate; /* sample rate in Hz */
int frame_size; /* frame size in bytes */
int bit_rate; /* nominal bit rate in kbps */
} ac3_sync_info_t;
typedef struct ac3_byte_stream_s {
......@@ -335,40 +335,44 @@ typedef struct audblk_s {
* approximate a 1/6 octave scale.
*/
typedef struct stream_coeffs_s {
typedef struct stream_coeffs_s
{
float fbw[5][256];
float lfe[256];
} stream_coeffs_t;
typedef struct stream_samples_s {
typedef struct stream_samples_s
{
float channel[6][256];
} stream_samples_t;
typedef struct ac3_bit_stream_s {
typedef struct ac3_bit_stream_s
{
u32 buffer;
int i_available;
ac3_byte_stream_t byte_stream;
unsigned int total_bits_read; /* temporary */
unsigned int total_bits_read; /* temporary */
} ac3_bit_stream_t;
struct ac3dec_s {
struct ac3dec_s
{
/*
* Input properties
*/
/* The bit stream structure handles the PES stream at the bit level */
ac3_bit_stream_t bit_stream;
ac3_bit_stream_t bit_stream;
/*
* Decoder properties
*/
syncinfo_t syncinfo;
bsi_t bsi;
audblk_t audblk;
syncinfo_t syncinfo;
bsi_t bsi;
audblk_t audblk;
stream_coeffs_t coeffs;
stream_samples_t samples;
stream_coeffs_t coeffs;
stream_samples_t samples;
};
/**** ac3 decoder inline functions ****/
......
......@@ -2,7 +2,7 @@
* ac3_decoder_thread.h : ac3 decoder thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: ac3_decoder_thread.h,v 1.2 2000/12/21 13:25:50 massiot Exp $
* $Id: ac3_decoder_thread.h,v 1.3 2001/01/05 14:45:47 sam Exp $
*
* Authors:
* Michel Kaempf <maxx@via.ecp.fr>
......@@ -37,7 +37,7 @@ typedef struct ac3dec_thread_s
*/
decoder_fifo_t * p_fifo; /* stores the PES stream data */
data_packet_t * p_data;
int sync_ptr; /* sync ptr from ac3 magic header */
int sync_ptr; /* sync ptr from ac3 magic header */
adec_config_t * p_config;
/*
......
......@@ -27,7 +27,8 @@
#define NORM 16384
typedef struct prefs_s {
typedef struct prefs_s
{
u16 use_dolby_surround;
u16 dual_mono_channel_select;
} prefs_t;
......@@ -56,250 +57,270 @@ void downmix (ac3dec_t * p_ac3dec, s16 * out_buf)
*/
/* There are two main cases, with or without Dolby Surround */
if (global_prefs.use_dolby_surround) {
switch(p_ac3dec->bsi.acmod) {
case 7: /* 3/2 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
left_sur = p_ac3dec->samples.channel[3];
right_sur = p_ac3dec->samples.channel[4];
for (j = 0; j < 256; j++) {
right_tmp = 0.2265f * *left_sur++ + 0.2265f * *right_sur++;
left_tmp = -1 * right_tmp;
right_tmp += 0.3204f * *right++ + 0.2265f * *centre;
left_tmp += 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 6: /* 2/2 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
left_sur = p_ac3dec->samples.channel[2];
right_sur = p_ac3dec->samples.channel[3];
for (j = 0; j < 256; j++) {
right_tmp = 0.2265f * *left_sur++ + 0.2265f * *right_sur++;
left_tmp = -1 * right_tmp;
right_tmp += 0.3204f * *right++;
left_tmp += 0.3204f * *left++ ;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 5: /* 3/1 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
/* Mono surround */
right_sur = p_ac3dec->samples.channel[3];
for (j = 0; j < 256; j++) {
right_tmp = 0.2265f * *right_sur++;
left_tmp = - right_tmp;
right_tmp += 0.3204f * *right++ + 0.2265f * *centre;
left_tmp += 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 4: /* 2/1 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
/* Mono surround */
right_sur = p_ac3dec->samples.channel[2];
for (j = 0; j < 256; j++) {
right_tmp = 0.2265f * *right_sur++;
left_tmp = - right_tmp;
right_tmp += 0.3204f * *right++;
left_tmp += 0.3204f * *left++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 3: /* 3/0 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
for (j = 0; j < 256; j++) {
right_tmp = 0.3204f * *right++ + 0.2265f * *centre;
left_tmp = 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 2: /* 2/0 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
for (j = 0; j < 256; j++) {
*(out_buf++) = *(left++) * NORM;
*(out_buf++) = *(right++) * NORM;
}
break;
case 1: /* 1/0 */
/* Mono program! */
right = p_ac3dec->samples.channel[0];
for (j = 0; j < 256; j++) {
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 0: /* 1+1 */
/* Dual mono, output selected by user */
right = p_ac3dec->samples.channel[global_prefs.dual_mono_channel_select];
for (j = 0; j < 256; j++) {
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
if (global_prefs.use_dolby_surround)
{
switch(p_ac3dec->bsi.acmod)
{
case 7: /* 3/2 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
left_sur = p_ac3dec->samples.channel[3];
right_sur = p_ac3dec->samples.channel[4];
for (j = 0; j < 256; j++)
{
right_tmp = 0.2265f * *left_sur++ + 0.2265f * *right_sur++;
left_tmp = -1 * right_tmp;
right_tmp += 0.3204f * *right++ + 0.2265f * *centre;
left_tmp += 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 6: /* 2/2 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
left_sur = p_ac3dec->samples.channel[2];
right_sur = p_ac3dec->samples.channel[3];
for (j = 0; j < 256; j++)
{
right_tmp = 0.2265f * *left_sur++ + 0.2265f * *right_sur++;
left_tmp = -1 * right_tmp;
right_tmp += 0.3204f * *right++;
left_tmp += 0.3204f * *left++ ;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 5: /* 3/1 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
/* Mono surround */
right_sur = p_ac3dec->samples.channel[3];
for (j = 0; j < 256; j++)
{
right_tmp = 0.2265f * *right_sur++;
left_tmp = - right_tmp;
right_tmp += 0.3204f * *right++ + 0.2265f * *centre;
left_tmp += 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 4: /* 2/1 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
/* Mono surround */
right_sur = p_ac3dec->samples.channel[2];
for (j = 0; j < 256; j++)
{
right_tmp = 0.2265f * *right_sur++;
left_tmp = - right_tmp;
right_tmp += 0.3204f * *right++;
left_tmp += 0.3204f * *left++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 3: /* 3/0 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
for (j = 0; j < 256; j++)
{
right_tmp = 0.3204f * *right++ + 0.2265f * *centre;
left_tmp = 0.3204f * *left++ + 0.2265f * *centre++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 2: /* 2/0 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
for (j = 0; j < 256; j++)
{
*(out_buf++) = *(left++) * NORM;
*(out_buf++) = *(right++) * NORM;
}
break;
case 1: /* 1/0 */
/* Mono program! */
right = p_ac3dec->samples.channel[0];
for (j = 0; j < 256; j++)
{
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 0: /* 1+1 */
/* Dual mono, output selected by user */
right = p_ac3dec->samples.channel[global_prefs.dual_mono_channel_select];
for (j = 0; j < 256; j++)
{
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
}
} else {
/* Non-Dolby surround downmixes */
switch(p_ac3dec->bsi.acmod) {
case 7: /* 3/2 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
left_sur = p_ac3dec->samples.channel[3];
right_sur = p_ac3dec->samples.channel[4];
clev = cmixlev_lut[p_ac3dec->bsi.cmixlev];
slev = smixlev_lut[p_ac3dec->bsi.surmixlev];
for (j = 0; j < 256; j++) {
right_tmp= 0.4142f * *right++ + clev * *centre + slev * *right_sur++;
left_tmp = 0.4142f * *left++ + clev * *centre++ + slev * *left_sur++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 6: /* 2/2 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
left_sur = p_ac3dec->samples.channel[2];
right_sur = p_ac3dec->samples.channel[3];
slev = smixlev_lut[p_ac3dec->bsi.surmixlev];
for (j = 0; j < 256; j++) {
right_tmp= 0.4142f * *right++ + slev * *right_sur++;
left_tmp = 0.4142f * *left++ + slev * *left_sur++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 5: /* 3/1 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
/* Mono surround */
right_sur = p_ac3dec->samples.channel[3];
clev = cmixlev_lut[p_ac3dec->bsi.cmixlev];
slev = smixlev_lut[p_ac3dec->bsi.surmixlev];
for (j = 0; j < 256; j++) {
right_tmp= 0.4142f * *right++ + clev * *centre + slev * *right_sur;
left_tmp = 0.4142f * *left++ + clev * *centre++ + slev * *right_sur++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 4: /* 2/1 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
/* Mono surround */
right_sur = p_ac3dec->samples.channel[2];
slev = smixlev_lut[p_ac3dec->bsi.surmixlev];
for (j = 0; j < 256; j++) {
right_tmp= 0.4142f * *right++ + slev * *right_sur;
left_tmp = 0.4142f * *left++ + slev * *right_sur++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 3: /* 3/0 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
clev = cmixlev_lut[p_ac3dec->bsi.cmixlev];
for (j = 0; j < 256; j++) {
right_tmp= 0.4142f * *right++ + clev * *centre;
left_tmp = 0.4142f * *left++ + clev * *centre++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 2: /* 2/0 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
for (j = 0; j < 256; j++) {
*(out_buf++) = *(left++) * NORM;
*(out_buf++) = *(right++) * NORM;
}
break;
case 1: /* 1/0 */
/* Mono program! */
right = p_ac3dec->samples.channel[0];
for (j = 0; j < 256; j++) {
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 0: /* 1+1 */
/* Dual mono, output selected by user */
right = p_ac3dec->samples.channel[global_prefs.dual_mono_channel_select];
for (j = 0; j < 256; j++) {
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
switch(p_ac3dec->bsi.acmod)
{
case 7: /* 3/2 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
left_sur = p_ac3dec->samples.channel[3];
right_sur = p_ac3dec->samples.channel[4];
clev = cmixlev_lut[p_ac3dec->bsi.cmixlev];
slev = smixlev_lut[p_ac3dec->bsi.surmixlev];
for (j = 0; j < 256; j++)
{
right_tmp= 0.4142f * *right++ + clev * *centre + slev * *right_sur++;
left_tmp = 0.4142f * *left++ + clev * *centre++ + slev * *left_sur++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 6: /* 2/2 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
left_sur = p_ac3dec->samples.channel[2];
right_sur = p_ac3dec->samples.channel[3];
slev = smixlev_lut[p_ac3dec->bsi.surmixlev];
for (j = 0; j < 256; j++)
{
right_tmp= 0.4142f * *right++ + slev * *right_sur++;
left_tmp = 0.4142f * *left++ + slev * *left_sur++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 5: /* 3/1 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
/* Mono surround */
right_sur = p_ac3dec->samples.channel[3];
clev = cmixlev_lut[p_ac3dec->bsi.cmixlev];
slev = smixlev_lut[p_ac3dec->bsi.surmixlev];
for (j = 0; j < 256; j++)
{
right_tmp= 0.4142f * *right++ + clev * *centre + slev * *right_sur;
left_tmp = 0.4142f * *left++ + clev * *centre++ + slev * *right_sur++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 4: /* 2/1 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
/* Mono surround */
right_sur = p_ac3dec->samples.channel[2];
slev = smixlev_lut[p_ac3dec->bsi.surmixlev];
for (j = 0; j < 256; j++)
{
right_tmp= 0.4142f * *right++ + slev * *right_sur;
left_tmp = 0.4142f * *left++ + slev * *right_sur++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 3: /* 3/0 */
left = p_ac3dec->samples.channel[0];
centre = p_ac3dec->samples.channel[1];
right = p_ac3dec->samples.channel[2];
clev = cmixlev_lut[p_ac3dec->bsi.cmixlev];
for (j = 0; j < 256; j++)
{
right_tmp= 0.4142f * *right++ + clev * *centre;
left_tmp = 0.4142f * *left++ + clev * *centre++;
*(out_buf++) = left_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 2: /* 2/0 */
left = p_ac3dec->samples.channel[0];
right = p_ac3dec->samples.channel[1];
for (j = 0; j < 256; j++)
{
*(out_buf++) = *(left++) * NORM;
*(out_buf++) = *(right++) * NORM;
}
break;
case 1: /* 1/0 */
/* Mono program! */
right = p_ac3dec->samples.channel[0];
for (j = 0; j < 256; j++)
{
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
case 0: /* 1+1 */
/* Dual mono, output selected by user */
right = p_ac3dec->samples.channel[global_prefs.dual_mono_channel_select];
for (j = 0; j < 256; j++)
{
right_tmp = 0.7071f * *right++;
*(out_buf++) = right_tmp * NORM;
*(out_buf++) = right_tmp * NORM;
}
break;
}
}
}
......@@ -36,41 +36,48 @@
#include "ac3_internal.h"
static const s16 exps_1[128] =
{ -2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,
{
-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,-2,
-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
0, 0, 0 };
0, 0, 0
};
static const s16 exps_2[128] =
{ -2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
{
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
-2,-2,-2,-2,-2,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2,
0, 0, 0 };
0, 0, 0
};
static const s16 exps_3[128] =
{ -2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
{
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,-2,-1, 0, 1, 2,
0, 0, 0 };
0, 0, 0
};
#define UNPACK_FBW 1
#define UNPACK_CPL 2
#define UNPACK_LFE 4
static __inline__ int exp_unpack_ch (ac3dec_t * p_ac3dec, u16 type,
u16 expstr, u16 ngrps, u16 initial_exp,
u16 exps[], u16 * dest)
u16 expstr, u16 ngrps, u16 initial_exp,
u16 exps[], u16 * dest)
{
u16 i,j;
s16 exp_acc;
if (expstr == EXP_REUSE) {
if (expstr == EXP_REUSE)
{
return 0;
}
......@@ -80,68 +87,76 @@ static __inline__ int exp_unpack_ch (ac3dec_t * p_ac3dec, u16 type,
/* In the case of a fbw channel then the initial absolute values is
* also an exponent */
if (type != UNPACK_CPL) {
if (type != UNPACK_CPL)
{
dest[j++] = exp_acc;
}
/* Loop through the groups and fill the dest array appropriately */
switch (expstr) {
case EXP_D15: /* 1 */
for (i = 0; i < ngrps; i++) {
if (exps[i] > 124) {
intf_ErrMsg ( "ac3dec error: invalid exponent" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
}
break;
case EXP_D25: /* 2 */
for (i = 0; i < ngrps; i++) {
if (exps[i] > 124) {
intf_ErrMsg ( "ac3dec error: invalid exponent" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
}
break;
case EXP_D45: /* 3 */
for (i = 0; i < ngrps; i++) {
if (exps[i] > 124) {
intf_ErrMsg ( "ac3dec error: invalid exponent" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
}
break;
switch (expstr)
{
case EXP_D15: /* 1 */
for (i = 0; i < ngrps; i++)
{
if (exps[i] > 124)
{
intf_ErrMsg ( "ac3dec error: invalid exponent" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
}
break;
case EXP_D25: /* 2 */
for (i = 0; i < ngrps; i++)
{
if (exps[i] > 124)
{
intf_ErrMsg ( "ac3dec error: invalid exponent" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
}
break;
case EXP_D45: /* 3 */
for (i = 0; i < ngrps; i++)
{
if (exps[i] > 124)
{
intf_ErrMsg ( "ac3dec error: invalid exponent" );
return 1;
}
exp_acc += (exps_1[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_2[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
exp_acc += (exps_3[exps[i]] /*- 2*/);
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
dest[j++] = exp_acc;
}
break;
}
return 0;
......@@ -151,31 +166,41 @@ int exponent_unpack (ac3dec_t * p_ac3dec)
{
u16 i;
for (i = 0; i < p_ac3dec->bsi.nfchans; i++) {
if (exp_unpack_ch (p_ac3dec, UNPACK_FBW, p_ac3dec->audblk.chexpstr[i],
p_ac3dec->audblk.nchgrps[i],
p_ac3dec->audblk.exps[i][0],
&p_ac3dec->audblk.exps[i][1],
p_ac3dec->audblk.fbw_exp[i]))
return 1;
for (i = 0; i < p_ac3dec->bsi.nfchans; i++)
{
if (exp_unpack_ch (p_ac3dec, UNPACK_FBW, p_ac3dec->audblk.chexpstr[i],
p_ac3dec->audblk.nchgrps[i],
p_ac3dec->audblk.exps[i][0],
&p_ac3dec->audblk.exps[i][1],
p_ac3dec->audblk.fbw_exp[i]))
{
return 1;
}
}
if (p_ac3dec->audblk.cplinu) {
if (p_ac3dec->audblk.cplinu)
{
if (exp_unpack_ch (p_ac3dec, UNPACK_CPL, p_ac3dec->audblk.cplexpstr,
p_ac3dec->audblk.ncplgrps,
p_ac3dec->audblk.cplabsexp << 1,
p_ac3dec->audblk.cplexps,
&p_ac3dec->audblk.cpl_exp[p_ac3dec->audblk.cplstrtmant]))
return 1;
p_ac3dec->audblk.ncplgrps,
p_ac3dec->audblk.cplabsexp << 1,
p_ac3dec->audblk.cplexps,
&p_ac3dec->audblk.cpl_exp[p_ac3dec->audblk.cplstrtmant]))
{
return 1;
}
}
if (p_ac3dec->bsi.lfeon) {
if (p_ac3dec->bsi.lfeon)
{
if (exp_unpack_ch (p_ac3dec, UNPACK_LFE, p_ac3dec->audblk.lfeexpstr,
2, p_ac3dec->audblk.lfeexps[0],
&p_ac3dec->audblk.lfeexps[1],
p_ac3dec->audblk.lfe_exp))
return 1;
2, p_ac3dec->audblk.lfeexps[0],
&p_ac3dec->audblk.lfeexps[1],
p_ac3dec->audblk.lfe_exp))
{
return 1;
}
}
return 0;
}
......@@ -21,16 +21,16 @@
*****************************************************************************/
/* Exponent strategy constants */
#define EXP_REUSE (0)
#define EXP_D15 (1)
#define EXP_D25 (2)
#define EXP_D45 (3)
#define EXP_REUSE (0)
#define EXP_D15 (1)
#define EXP_D25 (2)
#define EXP_D45 (3)
/* Delta bit allocation constants */
#define DELTA_BIT_REUSE (0)
#define DELTA_BIT_NEW (1)
#define DELTA_BIT_NONE (2)
#define DELTA_BIT_RESERVED (3)
#define DELTA_BIT_REUSE (0)
#define DELTA_BIT_NEW (1)
#define DELTA_BIT_NONE (2)
#define DELTA_BIT_RESERVED (3)
/* ac3_bit_allocate.c */
void bit_allocate (ac3dec_t *);
......
......@@ -34,18 +34,27 @@
#define Q0 ((-2 << 15) / 3.0)
#define Q1 (0)
#define Q2 ((2 << 15) / 3.0)
static float q_1_0[ 32 ] = { Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
0, 0, 0, 0, 0 };
static float q_1_1[ 32 ] = { Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
0, 0, 0, 0, 0 };
static float q_1_2[ 32 ] = { Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
0, 0, 0, 0, 0 };
static float q_1_0[ 32 ] =
{
Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
0, 0, 0, 0, 0
};
static float q_1_1[ 32 ] =
{
Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
Q0, Q0, Q0, Q1, Q1, Q1, Q2, Q2, Q2,
0, 0, 0, 0, 0
};
static float q_1_2[ 32 ] =
{
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
0, 0, 0, 0, 0
};
#undef Q0
#undef Q1
#undef Q2
......@@ -56,26 +65,32 @@ static float q_1_2[ 32 ] = { Q0, Q1, Q2, Q0, Q1, Q2, Q0, Q1, Q2,
#define Q3 ((2 << 15) / 5.0)
#define Q4 ((4 << 15) / 5.0)
static float q_2_0[ 128 ] =
{ Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,
{
Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,Q0,
Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,Q1,
Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,Q2,
Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,Q3,
Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,Q4,
0, 0, 0 };
0, 0, 0
};
static float q_2_1[ 128 ] =
{ Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
{
Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
Q0,Q0,Q0,Q0,Q0,Q1,Q1,Q1,Q1,Q1,Q2,Q2,Q2,Q2,Q2,Q3,Q3,Q3,Q3,Q3,Q4,Q4,Q4,Q4,Q4,
0, 0, 0 };
0, 0, 0
};
static float q_2_2[ 128 ] =
{ Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
{
Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,Q0,Q1,Q2,Q3,Q4,
0, 0, 0 };
0, 0, 0
};
#undef Q0
#undef Q1
#undef Q2
......@@ -93,30 +108,36 @@ static float q_2_2[ 128 ] =
#define Q8 ((6 << 15) / 11.0)
#define Q9 ((8 << 15) / 11.0)
#define QA ((10 << 15) / 11.0)
static float q_4_0[ 128 ] = { Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3,
Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4,
Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5,
Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6,
Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7,
Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8,
Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9,
QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, QA,
0, 0, 0, 0, 0, 0, 0};
static float q_4_1[ 128 ] = { Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
0, 0, 0, 0, 0, 0, 0};
static float q_4_0[ 128 ] =
{
Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0, Q0,
Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1, Q1,
Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2, Q2,
Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3, Q3,
Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4, Q4,
Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5, Q5,
Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6, Q6,
Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7, Q7,
Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8, Q8,
Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9, Q9,
QA, QA, QA, QA, QA, QA, QA, QA, QA, QA, QA,
0, 0, 0, 0, 0, 0, 0
};
static float q_4_1[ 128 ] =
{
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
0, 0, 0, 0, 0, 0, 0
};
#undef Q0
#undef Q1
#undef Q2
......@@ -131,16 +152,22 @@ static float q_4_1[ 128 ] = { Q0, Q1, Q2, Q3, Q4, Q5, Q6, Q7, Q8, Q9, QA,
/* Lookup tables of 0.16 two's complement quantization values */
static float q_3[8] = { (-6 << 15)/7.0, (-4 << 15)/7.0, (-2 << 15)/7.0,
0 , (2 << 15)/7.0, (4 << 15)/7.0,
(6 << 15)/7.0, 0 };
static float q_3[8] =
{
(-6 << 15)/7.0, (-4 << 15)/7.0, (-2 << 15)/7.0,
0 , (2 << 15)/7.0, (4 << 15)/7.0,
(6 << 15)/7.0, 0
};
static float q_5[16] = { (-14 << 15)/15.0, (-12 << 15)/15.0, (-10 << 15)/15.0,
(-8 << 15)/15.0, (-6 << 15)/15.0, (-4 << 15)/15.0,
(-2 << 15)/15.0, 0 , (2 << 15)/15.0,
(4 << 15)/15.0, (6 << 15)/15.0, (8 << 15)/15.0,
(10 << 15)/15.0, (12 << 15)/15.0, (14 << 15)/15.0,
0 };
static float q_5[16] =
{
(-14 << 15)/15.0, (-12 << 15)/15.0, (-10 << 15)/15.0,
(-8 << 15)/15.0, (-6 << 15)/15.0, (-4 << 15)/15.0,
(-2 << 15)/15.0, 0 , (2 << 15)/15.0,
(4 << 15)/15.0, (6 << 15)/15.0, (8 << 15)/15.0,
(10 << 15)/15.0, (12 << 15)/15.0, (14 << 15)/15.0,
0
};
/* These store the persistent state of the packed mantissas */
static float q_1[2];
......@@ -152,7 +179,10 @@ static s32 q_4_pointer;
/* Conversion from bap to number of bits in the mantissas
* zeros account for cases 0,1,2,4 which are special cased */
static u16 qnttztab[16] = { 0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16};
static u16 qnttztab[16] =
{
0, 0, 0, 3, 0, 4, 5, 6, 7, 8, 9, 10, 11, 12, 14, 16
};
static float exp_lut[ 25 ] =
{
......@@ -189,94 +219,103 @@ static __inline__ float float_get (ac3dec_t * p_ac3dec, u16 bap, u16 exp)
u32 group_code;
/* If the bap is 0-5 then we have special cases to take care of */
switch (bap) {
switch (bap)
{
case 0:
return (0); /* FIXME dither */
return (0); /* FIXME dither */
case 1:
if (q_1_pointer >= 0) {
return (q_1[q_1_pointer--] * exp_lut[exp]);
}
if (q_1_pointer >= 0)
{
return (q_1[q_1_pointer--] * exp_lut[exp]);
}
NeedBits (&(p_ac3dec->bit_stream), 5);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 5);
DumpBits (&(p_ac3dec->bit_stream), 5);
if (group_code >= 27) {
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
NeedBits (&(p_ac3dec->bit_stream), 5);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 5);
DumpBits (&(p_ac3dec->bit_stream), 5);
if (group_code >= 27)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
q_1[ 1 ] = q_1_1[ group_code ];
q_1[ 0 ] = q_1_2[ group_code ];
q_1[ 1 ] = q_1_1[ group_code ];
q_1[ 0 ] = q_1_2[ group_code ];
q_1_pointer = 1;
q_1_pointer = 1;
return (q_1_0[group_code] * exp_lut[exp]);
return (q_1_0[group_code] * exp_lut[exp]);
case 2:
if (q_2_pointer >= 0) {
return (q_2[q_2_pointer--] * exp_lut[exp]);
}
NeedBits (&(p_ac3dec->bit_stream), 7);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 7);
DumpBits (&(p_ac3dec->bit_stream), 7);
if (q_2_pointer >= 0)
{
return (q_2[q_2_pointer--] * exp_lut[exp]);
}
NeedBits (&(p_ac3dec->bit_stream), 7);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 7);
DumpBits (&(p_ac3dec->bit_stream), 7);
if (group_code >= 125) {
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
if (group_code >= 125)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
q_2[ 1 ] = q_2_1[ group_code ];
q_2[ 0 ] = q_2_2[ group_code ];
q_2[ 1 ] = q_2_1[ group_code ];
q_2[ 0 ] = q_2_2[ group_code ];
q_2_pointer = 1;
q_2_pointer = 1;
return (q_2_0[ group_code ] * exp_lut[exp]);
return (q_2_0[ group_code ] * exp_lut[exp]);
case 3:
NeedBits (&(p_ac3dec->bit_stream), 3);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 3);
DumpBits (&(p_ac3dec->bit_stream), 3);
NeedBits (&(p_ac3dec->bit_stream), 3);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 3);
DumpBits (&(p_ac3dec->bit_stream), 3);
if (group_code >= 7) {
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
if (group_code >= 7)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
return (q_3[group_code] * exp_lut[exp]);
return (q_3[group_code] * exp_lut[exp]);
case 4:
if (q_4_pointer >= 0) {
return (q_4[q_4_pointer--] * exp_lut[exp]);
}
NeedBits (&(p_ac3dec->bit_stream), 7);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 7);
DumpBits (&(p_ac3dec->bit_stream), 7);
if (q_4_pointer >= 0)
{
return (q_4[q_4_pointer--] * exp_lut[exp]);
}
NeedBits (&(p_ac3dec->bit_stream), 7);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 7);
DumpBits (&(p_ac3dec->bit_stream), 7);
if (group_code >= 121) {
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
if (group_code >= 121)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
q_4[ 0 ] = q_4_1[ group_code ];
q_4[ 0 ] = q_4_1[ group_code ];
q_4_pointer = 0;
q_4_pointer = 0;
return (q_4_0[ group_code ] * exp_lut[exp]);
return (q_4_0[ group_code ] * exp_lut[exp]);
case 5:
NeedBits (&(p_ac3dec->bit_stream), 4);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 4);
DumpBits (&(p_ac3dec->bit_stream), 4);
NeedBits (&(p_ac3dec->bit_stream), 4);
group_code = p_ac3dec->bit_stream.buffer >> (32 - 4);
DumpBits (&(p_ac3dec->bit_stream), 4);
if (group_code >= 15) {
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
if (group_code >= 15)
{
intf_ErrMsg ( "ac3dec error: invalid mantissa" );
}
return (q_5[group_code] * exp_lut[exp]);
return (q_5[group_code] * exp_lut[exp]);
default:
NeedBits (&(p_ac3dec->bit_stream), qnttztab[bap]);
group_code = (((s32)(p_ac3dec->bit_stream.buffer)) >> (32 - qnttztab[bap])) << (16 - qnttztab[bap]);
DumpBits (&(p_ac3dec->bit_stream), qnttztab[bap]);
NeedBits (&(p_ac3dec->bit_stream), qnttztab[bap]);
group_code = (((s32)(p_ac3dec->bit_stream.buffer)) >> (32 - qnttztab[bap])) << (16 - qnttztab[bap]);
DumpBits (&(p_ac3dec->bit_stream), qnttztab[bap]);
return (((s32)group_code) * exp_lut[exp]);
return (((s32)group_code) * exp_lut[exp]);
}
}
......@@ -288,19 +327,25 @@ static __inline__ void uncouple_channel (ac3dec_t * p_ac3dec, u32 ch)
u32 cpl_exp_tmp;
u32 cpl_mant_tmp;
for (i = p_ac3dec->audblk.cplstrtmant; i < p_ac3dec->audblk.cplendmant;) {
if (!p_ac3dec->audblk.cplbndstrc[bnd]) {
for (i = p_ac3dec->audblk.cplstrtmant; i < p_ac3dec->audblk.cplendmant;)
{
if (!p_ac3dec->audblk.cplbndstrc[bnd])
{
cpl_exp_tmp = p_ac3dec->audblk.cplcoexp[ch][bnd] + 3 * p_ac3dec->audblk.mstrcplco[ch];
if (p_ac3dec->audblk.cplcoexp[ch][bnd] == 15)
{
cpl_mant_tmp = (p_ac3dec->audblk.cplcomant[ch][bnd]) << 12;
}
else
{
cpl_mant_tmp = ((0x10) | p_ac3dec->audblk.cplcomant[ch][bnd]) << 11;
}
cpl_coord = ((s16)cpl_mant_tmp) * exp_lut[cpl_exp_tmp];
}
bnd++;
for (j=0;j < 12; j++) {
for (j=0;j < 12; j++)
{
p_ac3dec->coeffs.fbw[ch][i] = cpl_coord * p_ac3dec->audblk.cplfbw[i];
i++;
}
......@@ -315,44 +360,59 @@ void mantissa_unpack (ac3dec_t * p_ac3dec)
q_2_pointer = -1;
q_4_pointer = -1;
if (p_ac3dec->audblk.cplinu) {
if (p_ac3dec->audblk.cplinu)
{
/* 1 */
for (i = 0; !p_ac3dec->audblk.chincpl[i]; i++) {
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++) {
for (i = 0; !p_ac3dec->audblk.chincpl[i]; i++)
{
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++)
{
p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j]);
}
}
/* 2 */
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++) {
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++)
{
p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j]);
}
for (j = p_ac3dec->audblk.cplstrtmant; j < p_ac3dec->audblk.cplendmant; j++) {
for (j = p_ac3dec->audblk.cplstrtmant; j < p_ac3dec->audblk.cplendmant; j++)
{
p_ac3dec->audblk.cplfbw[j] = float_get (p_ac3dec, p_ac3dec->audblk.cpl_bap[j], p_ac3dec->audblk.cpl_exp[j]);
}
uncouple_channel (p_ac3dec, i);
/* 3 */
for (i++; i < p_ac3dec->bsi.nfchans; i++) {
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++) {
for (i++; i < p_ac3dec->bsi.nfchans; i++)
{
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++)
{
p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j]);
}
if (p_ac3dec->audblk.chincpl[i]) {
if (p_ac3dec->audblk.chincpl[i])
{
uncouple_channel (p_ac3dec, i);
}
}
} else {
for (i = 0; i < p_ac3dec->bsi.nfchans; i++) {
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++) {
}
else
{
for (i = 0; i < p_ac3dec->bsi.nfchans; i++)
{
for (j = 0; j < p_ac3dec->audblk.endmant[i]; j++)
{
p_ac3dec->coeffs.fbw[i][j] = float_get (p_ac3dec, p_ac3dec->audblk.fbw_bap[i][j], p_ac3dec->audblk.fbw_exp[i][j]);
}
}
}
if (p_ac3dec->bsi.lfeon) {
if (p_ac3dec->bsi.lfeon)
{
/* There are always 7 mantissas for lfe, no dither for lfe */
for (j = 0; j < 7; j++) {
for (j = 0; j < 7; j++)
{
p_ac3dec->coeffs.lfe[j] = float_get (p_ac3dec, p_ac3dec->audblk.lfe_bap[j], p_ac3dec->audblk.lfe_exp[j]);
}
}
}
......@@ -29,12 +29,14 @@
/* Misc LUT */
static u16 nfchans[] = { 2, 1, 2, 3, 3, 4, 4, 5 };
struct frmsize_s {
struct frmsize_s
{
u16 bit_rate;
u16 frm_size[3];
};
static struct frmsize_s frmsizecod_tbl[] = {
static struct frmsize_s frmsizecod_tbl[] =
{
{ 32 ,{64 ,69 ,96 } },
{ 32 ,{64 ,70 ,96 } },
{ 40 ,{80 ,87 ,120 } },
......@@ -89,7 +91,9 @@ int ac3_sync_frame (ac3dec_t * p_ac3dec, ac3_sync_info_t * p_sync_info)
buf = p_ac3dec->bit_stream.buffer >> (32 - 16);
DumpBits (&(p_ac3dec->bit_stream), 16);
if (buf != 0x0b77)
return 1;
{
return 1;
}
/* Get crc1 - we don't actually use this data though */
NeedBits (&(p_ac3dec->bit_stream), 16);
......@@ -101,15 +105,20 @@ int ac3_sync_frame (ac3dec_t * p_ac3dec, ac3_sync_info_t * p_sync_info)
DumpBits (&(p_ac3dec->bit_stream), 2);
if (p_ac3dec->syncinfo.fscod >= 3)
return 1;
{
return 1;
}
/* Get the frame size code */
NeedBits (&(p_ac3dec->bit_stream), 6);
p_ac3dec->syncinfo.frmsizecod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
p_ac3dec->syncinfo.frmsizecod =
(u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
DumpBits (&(p_ac3dec->bit_stream), 6);
if (p_ac3dec->syncinfo.frmsizecod >= 38)
return 1;
{
return 1;
}
p_sync_info->bit_rate = frmsizecod_tbl[p_ac3dec->syncinfo.frmsizecod].bit_rate;
......@@ -134,7 +143,9 @@ int parse_bsi (ac3dec_t * p_ac3dec)
DumpBits (&(p_ac3dec->bit_stream), 5);
if (p_ac3dec->bsi.bsid > 8)
return 1;
{
return 1;
}
/* Get the audio service provided by the steram */
NeedBits (&(p_ac3dec->bit_stream), 3);
......@@ -150,21 +161,24 @@ int parse_bsi (ac3dec_t * p_ac3dec)
p_ac3dec->bsi.nfchans = nfchans[p_ac3dec->bsi.acmod];
/* If it is in use, get the centre channel mix level */
if ((p_ac3dec->bsi.acmod & 0x1) && (p_ac3dec->bsi.acmod != 0x1)) {
if ((p_ac3dec->bsi.acmod & 0x1) && (p_ac3dec->bsi.acmod != 0x1))
{
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->bsi.cmixlev = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
}
/* If it is in use, get the surround channel mix level */
if (p_ac3dec->bsi.acmod & 0x4) {
if (p_ac3dec->bsi.acmod & 0x4)
{
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->bsi.surmixlev = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
}
/* Get the dolby surround mode if in 2/0 mode */
if (p_ac3dec->bsi.acmod == 0x2) {
if (p_ac3dec->bsi.acmod == 0x2)
{
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->bsi.dsurmod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
......@@ -184,7 +198,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->bsi.compre = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.compre) {
if (p_ac3dec->bsi.compre)
{
/* Get compression gain */
NeedBits (&(p_ac3dec->bit_stream), 8);
p_ac3dec->bsi.compr = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
......@@ -195,7 +210,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->bsi.langcode = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.langcode) {
if (p_ac3dec->bsi.langcode)
{
/* Get langauge code */
NeedBits (&(p_ac3dec->bit_stream), 8);
p_ac3dec->bsi.langcod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
......@@ -206,7 +222,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->bsi.audprodie = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.audprodie) {
if (p_ac3dec->bsi.audprodie)
{
/* Get mix level */
NeedBits (&(p_ac3dec->bit_stream), 5);
p_ac3dec->bsi.mixlevel = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
......@@ -219,7 +236,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
}
/* If we're in dual mono mode then get some extra info */
if (p_ac3dec->bsi.acmod ==0) {
if (p_ac3dec->bsi.acmod ==0)
{
/* Get the dialogue normalization level two */
NeedBits (&(p_ac3dec->bit_stream), 5);
p_ac3dec->bsi.dialnorm2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
......@@ -229,7 +247,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->bsi.compr2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.compr2e) {
if (p_ac3dec->bsi.compr2e)
{
/* Get compression gain two */
NeedBits (&(p_ac3dec->bit_stream), 8);
p_ac3dec->bsi.compr2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
......@@ -240,7 +259,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->bsi.langcod2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.langcod2e) {
if (p_ac3dec->bsi.langcod2e)
{
/* Get langauge code two */
NeedBits (&(p_ac3dec->bit_stream), 8);
p_ac3dec->bsi.langcod2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
......@@ -251,7 +271,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->bsi.audprodi2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.audprodi2e) {
if (p_ac3dec->bsi.audprodi2e)
{
/* Get mix level two */
NeedBits (&(p_ac3dec->bit_stream), 5);
p_ac3dec->bsi.mixlevel2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
......@@ -279,7 +300,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
p_ac3dec->bsi.timecod1e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.timecod1e) {
if (p_ac3dec->bsi.timecod1e)
{
NeedBits (&(p_ac3dec->bit_stream), 14);
p_ac3dec->bsi.timecod1 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 14));
DumpBits (&(p_ac3dec->bit_stream), 14);
......@@ -290,7 +312,8 @@ int parse_bsi (ac3dec_t * p_ac3dec)
p_ac3dec->bsi.timecod2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.timecod2e) {
if (p_ac3dec->bsi.timecod2e)
{
NeedBits (&(p_ac3dec->bit_stream), 14);
p_ac3dec->bsi.timecod2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 14));
DumpBits (&(p_ac3dec->bit_stream), 14);
......@@ -301,14 +324,16 @@ int parse_bsi (ac3dec_t * p_ac3dec)
p_ac3dec->bsi.addbsie = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->bsi.addbsie) {
if (p_ac3dec->bsi.addbsie)
{
/* Get how much info is there */
NeedBits (&(p_ac3dec->bit_stream), 6);
p_ac3dec->bsi.addbsil = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
DumpBits (&(p_ac3dec->bit_stream), 6);
/* Get the additional info */
for (i=0;i<(p_ac3dec->bsi.addbsil + 1);i++) {
for (i=0;i<(p_ac3dec->bsi.addbsil + 1);i++)
{
NeedBits (&(p_ac3dec->bit_stream), 8);
p_ac3dec->bsi.addbsi[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
DumpBits (&(p_ac3dec->bit_stream), 8);
......@@ -323,14 +348,16 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
{
int i, j;
for (i=0; i < p_ac3dec->bsi.nfchans; i++) {
for (i=0; i < p_ac3dec->bsi.nfchans; i++)
{
/* Is this channel an interleaved 256 + 256 block ? */
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.blksw[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
}
for (i=0; i < p_ac3dec->bsi.nfchans; i++) {
for (i=0; i < p_ac3dec->bsi.nfchans; i++)
{
/* Should we dither this channel? */
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.dithflag[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
......@@ -341,7 +368,8 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.dynrnge = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->audblk.dynrnge) {
if (p_ac3dec->audblk.dynrnge)
{
/* Get dynamic range info */
NeedBits (&(p_ac3dec->bit_stream), 8);
p_ac3dec->audblk.dynrng = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
......@@ -349,12 +377,14 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
}
/* If we're in dual mono mode then get the second channel DR info */
if (p_ac3dec->bsi.acmod == 0) {
if (p_ac3dec->bsi.acmod == 0)
{
/* Does dynamic range control two exist? */
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.dynrng2e = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->audblk.dynrng2e) {
if (p_ac3dec->audblk.dynrng2e)
{
/* Get dynamic range info */
NeedBits (&(p_ac3dec->bit_stream), 8);
p_ac3dec->audblk.dynrng2 = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 8));
......@@ -368,28 +398,38 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
DumpBits (&(p_ac3dec->bit_stream), 1);
if ((!blknum) && (!p_ac3dec->audblk.cplstre))
return 1;
{
return 1;
}
if (p_ac3dec->audblk.cplstre) {
if (p_ac3dec->audblk.cplstre)
{
/* Is coupling turned on? */
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.cplinu = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->audblk.cplinu) {
int nb_coupled_channels;
if (p_ac3dec->audblk.cplinu)
{
int nb_coupled_channels;
nb_coupled_channels = 0;
for (i=0; i < p_ac3dec->bsi.nfchans; i++) {
nb_coupled_channels = 0;
for (i=0; i < p_ac3dec->bsi.nfchans; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.chincpl[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->audblk.chincpl[i])
nb_coupled_channels++;
if (p_ac3dec->audblk.chincpl[i])
{
nb_coupled_channels++;
}
}
if (nb_coupled_channels < 2)
{
return 1;
}
if (nb_coupled_channels < 2)
return 1;
if (p_ac3dec->bsi.acmod == 0x2) {
if (p_ac3dec->bsi.acmod == 0x2)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.phsflginu = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
......@@ -401,8 +441,10 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
p_ac3dec->audblk.cplendf = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits (&(p_ac3dec->bit_stream), 4);
if (p_ac3dec->audblk.cplbegf > p_ac3dec->audblk.cplendf + 2)
return 1;
if (p_ac3dec->audblk.cplbegf > p_ac3dec->audblk.cplendf + 2)
{
return 1;
}
p_ac3dec->audblk.ncplsubnd = (p_ac3dec->audblk.cplendf + 2) - p_ac3dec->audblk.cplbegf + 1;
......@@ -414,7 +456,8 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
* band */
p_ac3dec->audblk.ncplbnd = p_ac3dec->audblk.ncplsubnd;
for (i=1; i< p_ac3dec->audblk.ncplsubnd; i++) {
for (i=1; i< p_ac3dec->audblk.ncplsubnd; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.cplbndstrc[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
......@@ -423,25 +466,33 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
}
}
if (p_ac3dec->audblk.cplinu) {
if (p_ac3dec->audblk.cplinu)
{
/* Loop through all the channels and get their coupling co-ords */
for (i=0; i < p_ac3dec->bsi.nfchans;i++) {
for (i=0; i < p_ac3dec->bsi.nfchans;i++)
{
if (!p_ac3dec->audblk.chincpl[i])
{
continue;
}
/* Is there new coupling co-ordinate info? */
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.cplcoe[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if ((!blknum) && (!p_ac3dec->audblk.cplcoe[i]))
return 1;
if ((!blknum) && (!p_ac3dec->audblk.cplcoe[i]))
{
return 1;
}
if (p_ac3dec->audblk.cplcoe[i]) {
if (p_ac3dec->audblk.cplcoe[i])
{
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->audblk.mstrcplco[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
for (j=0;j < p_ac3dec->audblk.ncplbnd; j++) {
for (j=0;j < p_ac3dec->audblk.ncplbnd; j++)
{
NeedBits (&(p_ac3dec->bit_stream), 4);
p_ac3dec->audblk.cplcoexp[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits (&(p_ac3dec->bit_stream), 4);
......@@ -454,8 +505,10 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
/* If we're in dual mono mode, there's going to be some phase info */
if ((p_ac3dec->bsi.acmod == 0x2) && p_ac3dec->audblk.phsflginu &&
(p_ac3dec->audblk.cplcoe[0] || p_ac3dec->audblk.cplcoe[1])) {
for (j=0; j < p_ac3dec->audblk.ncplbnd; j++) {
(p_ac3dec->audblk.cplcoe[0] || p_ac3dec->audblk.cplcoe[1]))
{
for (j=0; j < p_ac3dec->audblk.ncplbnd; j++)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.phsflg[j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
......@@ -465,42 +518,55 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
}
/* If we're in dual mono mode, there may be a rematrix strategy */
if (p_ac3dec->bsi.acmod == 0x2) {
if (p_ac3dec->bsi.acmod == 0x2)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.rematstr = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if ((!blknum) && (!p_ac3dec->audblk.rematstr))
return 1;
if ((!blknum) && (!p_ac3dec->audblk.rematstr))
{
return 1;
}
if (p_ac3dec->audblk.rematstr) {
if (p_ac3dec->audblk.cplinu == 0) {
for (i = 0; i < 4; i++) {
if (p_ac3dec->audblk.rematstr)
{
if (p_ac3dec->audblk.cplinu == 0)
{
for (i = 0; i < 4; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
}
}
if ((p_ac3dec->audblk.cplbegf > 2) && p_ac3dec->audblk.cplinu) {
for (i = 0; i < 4; i++) {
if ((p_ac3dec->audblk.cplbegf > 2) && p_ac3dec->audblk.cplinu)
{
for (i = 0; i < 4; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
}
}
if ((p_ac3dec->audblk.cplbegf <= 2) && p_ac3dec->audblk.cplinu) {
for (i = 0; i < 3; i++) {
if ((p_ac3dec->audblk.cplbegf <= 2) && p_ac3dec->audblk.cplinu)
{
for (i = 0; i < 3; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
}
}
if ((p_ac3dec->audblk.cplbegf == 0) && p_ac3dec->audblk.cplinu)
for (i = 0; i < 2; i++) {
{
for (i = 0; i < 2; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.rematflg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
}
}
}
}
......@@ -511,50 +577,69 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
p_ac3dec->audblk.cplexpstr = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
if ((!blknum) && (p_ac3dec->audblk.cplexpstr == EXP_REUSE))
return 1;
if ((!blknum) && (p_ac3dec->audblk.cplexpstr == EXP_REUSE))
{
return 1;
}
if (p_ac3dec->audblk.cplexpstr==0)
{
p_ac3dec->audblk.ncplgrps = 0;
}
else
{
p_ac3dec->audblk.ncplgrps = (p_ac3dec->audblk.cplendmant - p_ac3dec->audblk.cplstrtmant) /
(3 << (p_ac3dec->audblk.cplexpstr-1));
(3 << (p_ac3dec->audblk.cplexpstr-1));
}
}
for (i = 0; i < p_ac3dec->bsi.nfchans; i++) {
for (i = 0; i < p_ac3dec->bsi.nfchans; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->audblk.chexpstr[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
if ((!blknum) && (p_ac3dec->audblk.chexpstr[i] == EXP_REUSE))
return 1;
if ((!blknum) && (p_ac3dec->audblk.chexpstr[i] == EXP_REUSE))
{
return 1;
}
}
/* Get the exponent strategy for lfe channel */
if (p_ac3dec->bsi.lfeon) {
if (p_ac3dec->bsi.lfeon)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.lfeexpstr = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if ((!blknum) && (p_ac3dec->audblk.lfeexpstr == EXP_REUSE))
return 1;
if ((!blknum) && (p_ac3dec->audblk.lfeexpstr == EXP_REUSE))
{
return 1;
}
}
/* Determine the bandwidths of all the fbw channels */
for (i = 0; i < p_ac3dec->bsi.nfchans; i++) {
for (i = 0; i < p_ac3dec->bsi.nfchans; i++)
{
u16 grp_size;
if (p_ac3dec->audblk.chexpstr[i] != EXP_REUSE) {
if (p_ac3dec->audblk.cplinu && p_ac3dec->audblk.chincpl[i]) {
if (p_ac3dec->audblk.chexpstr[i] != EXP_REUSE)
{
if (p_ac3dec->audblk.cplinu && p_ac3dec->audblk.chincpl[i])
{
p_ac3dec->audblk.endmant[i] = p_ac3dec->audblk.cplstrtmant;
} else {
}
else
{
NeedBits (&(p_ac3dec->bit_stream), 6);
p_ac3dec->audblk.chbwcod[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
DumpBits (&(p_ac3dec->bit_stream), 6);
if (p_ac3dec->audblk.chbwcod[i] > 60)
return 1;
if (p_ac3dec->audblk.chbwcod[i] > 60)
{
return 1;
}
p_ac3dec->audblk.endmant[i] = ((p_ac3dec->audblk.chbwcod[i] + 12) * 3) + 37;
}
......@@ -566,32 +651,41 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
}
/* Get the coupling exponents if they exist */
if (p_ac3dec->audblk.cplinu && (p_ac3dec->audblk.cplexpstr != EXP_REUSE)) {
if (p_ac3dec->audblk.cplinu && (p_ac3dec->audblk.cplexpstr != EXP_REUSE))
{
NeedBits (&(p_ac3dec->bit_stream), 4);
p_ac3dec->audblk.cplabsexp = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits (&(p_ac3dec->bit_stream), 4);
for (i=0; i< p_ac3dec->audblk.ncplgrps;i++) {
for (i=0; i< p_ac3dec->audblk.ncplgrps;i++)
{
NeedBits (&(p_ac3dec->bit_stream), 7);
p_ac3dec->audblk.cplexps[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 7));
DumpBits (&(p_ac3dec->bit_stream), 7);
if (p_ac3dec->audblk.cplexps[i] >= 125)
return 1;
if (p_ac3dec->audblk.cplexps[i] >= 125)
{
return 1;
}
}
}
/* Get the fwb channel exponents */
for (i=0; i < p_ac3dec->bsi.nfchans; i++) {
if (p_ac3dec->audblk.chexpstr[i] != EXP_REUSE) {
for (i=0; i < p_ac3dec->bsi.nfchans; i++)
{
if (p_ac3dec->audblk.chexpstr[i] != EXP_REUSE)
{
NeedBits (&(p_ac3dec->bit_stream), 4);
p_ac3dec->audblk.exps[i][0] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits (&(p_ac3dec->bit_stream), 4);
for (j=1; j<=p_ac3dec->audblk.nchgrps[i];j++) {
for (j=1; j<=p_ac3dec->audblk.nchgrps[i];j++)
{
NeedBits (&(p_ac3dec->bit_stream), 7);
p_ac3dec->audblk.exps[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 7));
DumpBits (&(p_ac3dec->bit_stream), 7);
if (p_ac3dec->audblk.exps[i][j] >= 125)
return 1;
if (p_ac3dec->audblk.exps[i][j] >= 125)
{
return 1;
}
}
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->audblk.gainrng[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
......@@ -600,20 +694,25 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
}
/* Get the lfe channel exponents */
if (p_ac3dec->bsi.lfeon && (p_ac3dec->audblk.lfeexpstr != EXP_REUSE)) {
if (p_ac3dec->bsi.lfeon && (p_ac3dec->audblk.lfeexpstr != EXP_REUSE))
{
NeedBits (&(p_ac3dec->bit_stream), 4);
p_ac3dec->audblk.lfeexps[0] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits (&(p_ac3dec->bit_stream), 4);
NeedBits (&(p_ac3dec->bit_stream), 7);
p_ac3dec->audblk.lfeexps[1] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 7));
DumpBits (&(p_ac3dec->bit_stream), 7);
if (p_ac3dec->audblk.lfeexps[1] >= 125)
return 1;
if (p_ac3dec->audblk.lfeexps[1] >= 125)
{
return 1;
}
NeedBits (&(p_ac3dec->bit_stream), 7);
p_ac3dec->audblk.lfeexps[2] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 7));
DumpBits (&(p_ac3dec->bit_stream), 7);
if (p_ac3dec->audblk.lfeexps[2] >= 125)
return 1;
if (p_ac3dec->audblk.lfeexps[2] >= 125)
{
return 1;
}
}
/* Get the parametric bit allocation parameters */
......@@ -622,9 +721,12 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
DumpBits (&(p_ac3dec->bit_stream), 1);
if ((!blknum) && (!p_ac3dec->audblk.baie))
return 1;
{
return 1;
}
if (p_ac3dec->audblk.baie) {
if (p_ac3dec->audblk.baie)
{
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->audblk.sdcycod = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
......@@ -647,14 +749,18 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
p_ac3dec->audblk.snroffste = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if ((!blknum) && (!p_ac3dec->audblk.snroffste))
return 1;
{
return 1;
}
if (p_ac3dec->audblk.snroffste) {
if (p_ac3dec->audblk.snroffste)
{
NeedBits (&(p_ac3dec->bit_stream), 6);
p_ac3dec->audblk.csnroffst = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 6));
DumpBits (&(p_ac3dec->bit_stream), 6);
if (p_ac3dec->audblk.cplinu) {
if (p_ac3dec->audblk.cplinu)
{
NeedBits (&(p_ac3dec->bit_stream), 4);
p_ac3dec->audblk.cplfsnroffst = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits (&(p_ac3dec->bit_stream), 4);
......@@ -663,7 +769,8 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
DumpBits (&(p_ac3dec->bit_stream), 3);
}
for (i = 0;i < p_ac3dec->bsi.nfchans; i++) {
for (i = 0;i < p_ac3dec->bsi.nfchans; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 4);
p_ac3dec->audblk.fsnroffst[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits (&(p_ac3dec->bit_stream), 4);
......@@ -671,7 +778,8 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
p_ac3dec->audblk.fgaincod[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits (&(p_ac3dec->bit_stream), 3);
}
if (p_ac3dec->bsi.lfeon) {
if (p_ac3dec->bsi.lfeon)
{
NeedBits (&(p_ac3dec->bit_stream), 4);
p_ac3dec->audblk.lfefsnroffst = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 4));
DumpBits (&(p_ac3dec->bit_stream), 4);
......@@ -682,14 +790,18 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
}
/* Get coupling leakage info if it exists */
if (p_ac3dec->audblk.cplinu) {
if (p_ac3dec->audblk.cplinu)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
p_ac3dec->audblk.cplleake = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if ((!blknum) && (!p_ac3dec->audblk.cplleake))
return 1;
if ((!blknum) && (!p_ac3dec->audblk.cplleake))
{
return 1;
}
if (p_ac3dec->audblk.cplleake) {
if (p_ac3dec->audblk.cplleake)
{
NeedBits (&(p_ac3dec->bit_stream), 3);
p_ac3dec->audblk.cplfleak = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits (&(p_ac3dec->bit_stream), 3);
......@@ -704,28 +816,37 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
p_ac3dec->audblk.deltbaie = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->audblk.deltbaie) {
if (p_ac3dec->audblk.cplinu) {
if (p_ac3dec->audblk.deltbaie)
{
if (p_ac3dec->audblk.cplinu)
{
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->audblk.cpldeltbae = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
if (p_ac3dec->audblk.cpldeltbae == 3)
return 1;
if (p_ac3dec->audblk.cpldeltbae == 3)
{
return 1;
}
}
for (i = 0;i < p_ac3dec->bsi.nfchans; i++) {
for (i = 0;i < p_ac3dec->bsi.nfchans; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 2);
p_ac3dec->audblk.deltbae[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 2));
DumpBits (&(p_ac3dec->bit_stream), 2);
if (p_ac3dec->audblk.deltbae[i] == 3)
return 1;
if (p_ac3dec->audblk.deltbae[i] == 3)
{
return 1;
}
}
if (p_ac3dec->audblk.cplinu && (p_ac3dec->audblk.cpldeltbae == DELTA_BIT_NEW)) {
if (p_ac3dec->audblk.cplinu && (p_ac3dec->audblk.cpldeltbae == DELTA_BIT_NEW))
{
NeedBits (&(p_ac3dec->bit_stream), 3);
p_ac3dec->audblk.cpldeltnseg = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits (&(p_ac3dec->bit_stream), 3);
for (i = 0;i < p_ac3dec->audblk.cpldeltnseg + 1; i++) {
for (i = 0;i < p_ac3dec->audblk.cpldeltnseg + 1; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 5);
p_ac3dec->audblk.cpldeltoffst[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits (&(p_ac3dec->bit_stream), 5);
......@@ -738,14 +859,17 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
}
}
for (i = 0; i < p_ac3dec->bsi.nfchans; i++) {
if (p_ac3dec->audblk.deltbae[i] == DELTA_BIT_NEW) {
for (i = 0; i < p_ac3dec->bsi.nfchans; i++)
{
if (p_ac3dec->audblk.deltbae[i] == DELTA_BIT_NEW)
{
NeedBits (&(p_ac3dec->bit_stream), 3);
p_ac3dec->audblk.deltnseg[i] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 3));
DumpBits (&(p_ac3dec->bit_stream), 3);
// if (p_ac3dec->audblk.deltnseg[i] >= 8)
// fprintf (stderr, "parse debug: p_ac3dec->audblk.deltnseg[%i] == %i\n", i, p_ac3dec->audblk.deltnseg[i]);
for (j = 0; j < p_ac3dec->audblk.deltnseg[i] + 1; j++) {
for (j = 0; j < p_ac3dec->audblk.deltnseg[i] + 1; j++)
{
NeedBits (&(p_ac3dec->bit_stream), 5);
p_ac3dec->audblk.deltoffst[i][j] = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 5));
DumpBits (&(p_ac3dec->bit_stream), 5);
......@@ -765,12 +889,14 @@ int parse_audblk (ac3dec_t * p_ac3dec, int blknum)
p_ac3dec->audblk.skiple = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 1));
DumpBits (&(p_ac3dec->bit_stream), 1);
if (p_ac3dec->audblk.skiple) {
if (p_ac3dec->audblk.skiple)
{
NeedBits (&(p_ac3dec->bit_stream), 9);
p_ac3dec->audblk.skipl = (u16)(p_ac3dec->bit_stream.buffer >> (32 - 9));
DumpBits (&(p_ac3dec->bit_stream), 9);
for (i = 0; i < p_ac3dec->audblk.skipl ; i++) {
for (i = 0; i < p_ac3dec->audblk.skipl ; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 8);
DumpBits (&(p_ac3dec->bit_stream), 8);
}
......@@ -787,7 +913,8 @@ void parse_auxdata (ac3dec_t * p_ac3dec)
skip_length = (p_ac3dec->syncinfo.frame_size * 16) - p_ac3dec->bit_stream.total_bits_read - 17 - 1;
// fprintf (stderr, "parse debug: skip_length == %i\n", skip_length);
for (i = 0; i < skip_length; i++) {
for (i = 0; i < skip_length; i++)
{
NeedBits (&(p_ac3dec->bit_stream), 1);
DumpBits (&(p_ac3dec->bit_stream), 1);
}
......@@ -804,3 +931,4 @@ void parse_auxdata (ac3dec_t * p_ac3dec)
NeedBits (&(p_ac3dec->bit_stream), 16);
DumpBits (&(p_ac3dec->bit_stream), 16);
}
......@@ -24,8 +24,8 @@ 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);
/* no, switch to next buffer */
adec_byte_stream_next (&p_bit_stream->byte_stream);
}
p_bit_stream->total_bytes_read++;
......@@ -37,7 +37,7 @@ 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);
((u32)GetByte (p_bit_stream)) << (24 - p_bit_stream->i_available);
p_bit_stream->i_available += 8;
}
}
......
......@@ -26,9 +26,9 @@
typedef struct audiodec_s audiodec_t;
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 */
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;
typedef struct adec_byte_stream_s {
......@@ -72,13 +72,13 @@ struct audiodec_s {
*/
/* The bit stream structure handles the PES stream at the bit level */
adec_bit_stream_t bit_stream;
adec_bit_stream_t bit_stream;
/*
* Decoder properties
*/
u32 header;
int frame_size;
u32 header;
int frame_size;
adec_bank_t bank_0;
adec_bank_t bank_1;
};
......
......@@ -51,7 +51,9 @@ int main (void)
memset (&decoder, 0, sizeof (decoder));
if (adec_init (&decoder))
return 1;
{
return 1;
}
stream = adec_byte_stream (&decoder);
stream->p_byte = NULL;
......@@ -60,17 +62,24 @@ int main (void)
framenum = 0;
while (1) {
int i;
while (1)
{
int i;
if (adec_sync_frame (&decoder, &sync_info))
return 1;
if (adec_decode_frame (&decoder, buffer))
return 1;
if (adec_sync_frame (&decoder, &sync_info))
{
return 1;
}
if (adec_decode_frame (&decoder, buffer))
{
return 1;
}
#if 1
for (i = 0; i < (2*1152); i++)
fprintf ( stderr, "%04X\n",(u16)buffer[i] );
for (i = 0; i < (2*1152); i++)
{
fprintf ( stderr, "%04X\n",(u16)buffer[i] );
}
#endif
}
......@@ -86,11 +95,14 @@ void adec_byte_stream_next (adec_byte_stream_t * p_byte_stream)
fd = p_byte_stream->info;
size = fread (buffer, 1, 1024, fd);
if (size) {
p_byte_stream->p_byte = buffer;
p_byte_stream->p_end = buffer + size;
} else { /* end of stream, read dummy zeroes */
p_byte_stream->p_byte = &dummy;
p_byte_stream->p_end = &dummy + 1;
if (size)
{
p_byte_stream->p_byte = buffer;
p_byte_stream->p_end = buffer + size;
}
else
{ /* end of stream, read dummy zeroes */
p_byte_stream->p_byte = &dummy;
p_byte_stream->p_end = &dummy + 1;
}
}
......@@ -2,7 +2,7 @@
* audio_decoder.h : audio decoder thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: audio_decoder.h,v 1.3 2000/12/21 13:25:50 massiot Exp $
* $Id: audio_decoder.h,v 1.4 2001/01/05 14:45:47 sam Exp $
*
* Authors:
* Michel Kaempf <maxx@via.ecp.fr>
......@@ -43,7 +43,7 @@ typedef struct adec_thread_s
/*
* Decoder properties
*/
audiodec_t audio_decoder;
audiodec_t audio_decoder;
/*
* Output properties
......
......@@ -4,7 +4,7 @@
* decoders.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input.c,v 1.64 2000/12/22 13:04:44 sam Exp $
* $Id: input.c,v 1.65 2001/01/05 14:45:47 sam Exp $
*
* Authors:
*
......@@ -80,7 +80,8 @@ input_thread_t *input_CreateThread ( input_config_t * p_config, int *pi_status )
p_input = (input_thread_t *)malloc( sizeof(input_thread_t) );
if( p_input == NULL )
{
intf_ErrMsg("error: %s", strerror(errno));
intf_ErrMsg( "input error: can't allocate input thread (%s)",
strerror(errno) );
free( p_config );
return( NULL );
}
......@@ -112,7 +113,8 @@ input_thread_t *input_CreateThread ( input_config_t * p_config, int *pi_status )
if( vlc_thread_create( &p_input->thread_id, "input", (void *) RunThread,
(void *) p_input ) )
{
intf_ErrMsg("error: %s", strerror(errno) );
intf_ErrMsg( "input error: can't create input thread (%s)",
strerror(errno) );
free( p_input );
free( p_config );
return( NULL );
......@@ -245,7 +247,7 @@ static void InitThread( input_thread_t * p_input )
case INPUT_METHOD_VLAN_BCAST: /* vlan network method */
/* if( !p_main->b_vlans )
{
intf_ErrMsg("error: vlans are not activated");
intf_ErrMsg("input error: vlans are not activated");
free( p_input );
return( NULL );
} */ /* la-lala */
......@@ -257,7 +259,8 @@ static void InitThread( input_thread_t * p_input )
break;
#ifdef DEBUG
default:
intf_ErrMsg("Unknow input method");
intf_ErrMsg( "input error: unknow method 0x%.4x",
p_input->p_config->i_method );
free( p_input->p_config );
p_input->b_error = 1;
break;
......@@ -344,63 +347,49 @@ static void FileOpen( input_thread_t * p_input )
#define p_config p_input->p_config
if( !strncmp( p_config->p_source, "-", 1 ) )
if( stat( p_config->p_source, &stat_info ) == (-1) )
{
intf_ErrMsg( "input error: cannot stat() file %s (%s)",
p_config->p_source, strerror(errno));
p_input->b_error = 1;
return;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
/* If we are here we can control the pace... */
p_input->stream.b_pace_control = 1;
if( S_ISREG(stat_info.st_mode) || S_ISCHR(stat_info.st_mode)
|| S_ISBLK(stat_info.st_mode) )
{
p_input->stream.b_seekable = 1;
p_input->stream.i_size = stat_info.st_size;
}
else if( S_ISFIFO(stat_info.st_mode) || S_ISSOCK(stat_info.st_mode) )
{
/* stdin */
p_input->i_handle = 0;
vlc_mutex_lock( &p_input->stream.stream_lock );
p_input->stream.b_pace_control = 1;
p_input->stream.b_seekable = 0;
p_input->stream.i_size = 0;
p_input->stream.i_tell = 0;
vlc_mutex_unlock( &p_input->stream.stream_lock );
}
else
{
if( stat( p_config->p_source, &stat_info ) == (-1) )
{
intf_ErrMsg("Cannot stat() file %s (%s)", p_config->p_source,
strerror(errno));
p_input->b_error = 1;
return;
}
vlc_mutex_lock( &p_input->stream.stream_lock );
/* If we are here we can control the pace... */
p_input->stream.b_pace_control = 1;
if( S_ISREG(stat_info.st_mode) || S_ISCHR(stat_info.st_mode)
|| S_ISBLK(stat_info.st_mode) )
{
p_input->stream.b_seekable = 1;
p_input->stream.i_size = stat_info.st_size;
}
else if( S_ISFIFO(stat_info.st_mode) || S_ISSOCK(stat_info.st_mode) )
{
p_input->stream.b_seekable = 0;
p_input->stream.i_size = 0;
}
else
{
vlc_mutex_unlock( &p_input->stream.stream_lock );
intf_ErrMsg("Unknown file type");
p_input->b_error = 1;
return;
}
p_input->stream.i_tell = 0;
vlc_mutex_unlock( &p_input->stream.stream_lock );
intf_ErrMsg( "input error: unknown file type for %s",
p_config->p_source );
p_input->b_error = 1;
return;
}
intf_Msg( "Opening file %s", p_config->p_source );
if( (p_input->i_handle = open( p_config->p_source,
/*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) )
{
intf_ErrMsg("Cannot open file (%s)", strerror(errno));
p_input->b_error = 1;
return;
}
p_input->stream.i_tell = 0;
vlc_mutex_unlock( &p_input->stream.stream_lock );
intf_Msg( "Opening file %s", p_config->p_source );
if( (p_input->i_handle = open( p_config->p_source,
/*O_NONBLOCK | O_LARGEFILE*/0 )) == (-1) )
{
intf_ErrMsg( "input error: cannot open file %s", strerror(errno) );
p_input->b_error = 1;
return;
}
#undef p_config
......
......@@ -100,7 +100,8 @@ intf_thread_t* intf_Create( void )
p_intf = malloc( sizeof( intf_thread_t ) );
if( !p_intf )
{
intf_ErrMsg("error: %s", strerror( ENOMEM ) );
intf_ErrMsg( "intf error: cannot create interface thread (%s)",
strerror( ENOMEM ) );
return( NULL );
}
......@@ -127,7 +128,7 @@ intf_thread_t* intf_Create( void )
if( i_best_score == 0 )
{
free( p_intf );
intf_ErrMsg( "error: no suitable plugin to create interface" );
intf_ErrMsg( "intf error: no suitable plugin" );
return( NULL );
}
......@@ -153,13 +154,13 @@ intf_thread_t* intf_Create( void )
p_intf->p_console = intf_ConsoleCreate();
if( p_intf->p_console == NULL )
{
intf_ErrMsg("error: can't create control console");
intf_ErrMsg( "intf error: cannot create control console" );
free( p_intf );
return( NULL );
}
if( p_intf->p_sys_create( p_intf ) )
{
intf_ErrMsg("error: can't create interface");
intf_ErrMsg("intf error: cannot create interface");
intf_ConsoleDestroy( p_intf->p_console );
free( p_intf );
return( NULL );
......@@ -188,7 +189,7 @@ void intf_Run( intf_thread_t *p_intf )
if( (p_input_config =
(input_config_t *)malloc( sizeof(input_config_t) )) == NULL )
{
intf_ErrMsg("Out of memory");
intf_ErrMsg( "intf error: cannot create input_config_t" );
}
else
{
......@@ -206,7 +207,7 @@ void intf_Run( intf_thread_t *p_intf )
if( (p_input_config =
(input_config_t *)malloc( sizeof(input_config_t) )) == NULL )
{
intf_ErrMsg("Out of memory");
intf_ErrMsg( "intf error: cannot create input_config_t" );
}
else
{
......@@ -222,7 +223,7 @@ void intf_Run( intf_thread_t *p_intf )
* the script could be executed but failed */
else if( intf_ExecScript( main_GetPszVariable( INTF_INIT_SCRIPT_VAR, INTF_INIT_SCRIPT_DEFAULT ) ) > 0 )
{
intf_ErrMsg("warning: error(s) during startup script");
intf_ErrMsg( "intf error: errors occured during startup script" );
}
/* Main loop */
......@@ -562,7 +563,8 @@ static int LoadChannels( intf_thread_t *p_intf, char *psz_filename )
p_file = fopen( psz_filename, "r" );
if( p_file == NULL )
{
intf_ErrMsg("error: can't open %s (%s)", psz_filename, strerror(errno));
intf_ErrMsg( "intf error: cannot open %s (%s)",
psz_filename, strerror(errno) );
return( 1 );
}
......@@ -580,7 +582,8 @@ static int LoadChannels( intf_thread_t *p_intf, char *psz_filename )
p_intf->p_channel = malloc( sizeof( intf_channel_t ) * i_index );
if( p_intf->p_channel == NULL )
{
intf_ErrMsg("error: %s", strerror(ENOMEM));
intf_ErrMsg( "intf error: cannot create intf_channel_t (%s)",
strerror(ENOMEM) );
fclose( p_file );
return( 1 );
}
......@@ -689,7 +692,8 @@ static int ParseChannel( intf_channel_t *p_channel, char *psz_str )
p_channel->psz_description = malloc( i_field_length + 1 );
if( p_channel->psz_description == NULL )
{
intf_ErrMsg("error: %s", strerror( ENOMEM ));
intf_ErrMsg( "intf error: cannot create channel "
"description (%s)", strerror( ENOMEM ) );
i_field = -1;
}
else
......@@ -712,7 +716,8 @@ static int ParseChannel( intf_channel_t *p_channel, char *psz_str )
p_channel->psz_input_source = malloc( i_field_length + 1 );
if( p_channel->psz_input_source == NULL )
{
intf_ErrMsg("error: %s", strerror( ENOMEM ));
intf_ErrMsg( "intf error: cannot create input "
"source (%s)", strerror( ENOMEM ) );
i_field = -1;
}
else
......
......@@ -121,7 +121,7 @@ int intf_ExecCommand( char *psz_cmd )
{
case INTF_FATAL_ERROR: /* fatal error */
/* Print message and terminates the interface thread */
intf_ErrMsg( "fatal error in command `%s'", psz_argv[0] );
intf_ErrMsg( "intf error: fatal error in command `%s'", psz_argv[0] );
p_main->p_intf->b_die = 1;
break;
......@@ -129,9 +129,8 @@ int intf_ExecCommand( char *psz_cmd )
/* Print message, flush messages queue and exit. Note that this
* error should be very rare since it does not even try to cancel
* other threads... */
intf_ErrMsg( "critical error in command `%s', "
"please report this error !", psz_argv[0] );
intf_FlushMsg();
intf_ErrMsgImm( "intf error: critical error in command `%s', "
"please report this error !", psz_argv[0] );
exit( INTF_CRITICAL_ERROR );
break;
......@@ -203,7 +202,7 @@ int intf_ExecScript( char *psz_filename )
}
if( !feof( p_file ) )
{
intf_ErrMsg("error: %s: %s", psz_vlcrc, strerror(errno));
intf_ErrMsg( "intf error: %s: %s", psz_vlcrc, strerror(errno));
return( -1 );
}
......@@ -500,7 +499,8 @@ static int ConvertArgument( intf_arg_t *p_arg, int i_flags, char *psz_str )
#ifdef DEBUG
else /* error: missing type specifier */
{
intf_ErrMsg("error: missing type specifier for `%s' (0x%x)", psz_str, i_flags);
intf_ErrMsg( "intf error: missing type specifier for `%s' (0x%x)",
psz_str, i_flags );
return( 1 );
}
#endif
......
......@@ -392,14 +392,15 @@ void main_PutPszVariable( char *psz_name, char *psz_value )
psz_env = malloc( strlen(psz_name) + strlen(psz_value) + 2 );
if( psz_env == NULL )
{
intf_ErrMsg( "error: %s", strerror(ENOMEM) );
intf_ErrMsg( "intf error: cannot create psz_env (%s)",
strerror(ENOMEM) );
}
else
{
sprintf( psz_env, "%s=%s", psz_name, psz_value );
if( putenv( psz_env ) )
{
intf_ErrMsg( "error: %s", strerror(errno) );
intf_ErrMsg( "intf error: cannot putenv (%s)", strerror(errno) );
}
}
}
......@@ -437,9 +438,6 @@ static void SetDefaultConfiguration( void )
p_main->b_audio = 1;
p_main->b_video = 1;
p_main->b_vlans = 0;
/* This is |_|lt1m4t3 |<l|_|d63 */
main_PutIntVariable( INPUT_DVD_SUBTITLE_VAR, -1 );
}
/*****************************************************************************
......@@ -757,7 +755,7 @@ static void FatalSignalHandler( int i_signal )
signal( SIGQUIT, SIG_IGN );
/* Acknowledge the signal received */
intf_ErrMsgImm("intf: signal %d received, exiting", i_signal );
intf_ErrMsgImm("intf error: signal %d received, exiting", i_signal );
/* Try to terminate everything - this is done by requesting the end of the
* interface thread */
......
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