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++)
{