Commit 84a86ed7 authored by Sam Hocevar's avatar Sam Hocevar

  * Added support for some terribly braindead DVD subtitles in Kenshin
    which do not have a "stop display" command. Anime fans rejoice!
  * Fixed the BeOS interface to use p_aout_bank instead of p_main->p_aout.
  * Coding-style butchery (mostly tabs).
parent 58ab8de5
......@@ -4,7 +4,7 @@
* includes all common video types and constants.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: video.h,v 1.29 2001/03/21 13:42:33 sam Exp $
* $Id: video.h,v 1.30 2001/05/07 04:42:42 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -123,9 +123,10 @@ typedef struct subpicture_s
int i_size; /* data size */
struct subpicture_s * p_next; /* next subtitle to be displayed */
/* Other properties */
mtime_t begin_date; /* beginning of display date */
mtime_t end_date; /* end of display date */
/* Date properties */
mtime_t i_start; /* beginning of display date */
mtime_t i_stop; /* end of display date */
boolean_t b_ephemer; /* does the subtitle have a TTL ? */
/* Display properties - these properties are only indicative and may be
* changed by the video output thread, or simply ignored depending of the
......
......@@ -2,7 +2,7 @@
* intf_beos.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: intf_beos.cpp,v 1.27 2001/05/01 04:18:17 sam Exp $
* $Id: intf_beos.cpp,v 1.28 2001/05/07 04:42:42 sam Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -101,9 +101,11 @@ typedef struct intf_sys_s
* InterfaceWindow
*****************************************************************************/
InterfaceWindow::InterfaceWindow( BRect frame, const char *name , intf_thread_t *p_interface )
: BWindow(frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK |B_ASYNCHRONOUS_CONTROLS)
InterfaceWindow::InterfaceWindow( BRect frame, const char *name,
intf_thread_t *p_interface )
: BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK
| B_ASYNCHRONOUS_CONTROLS )
{
file_panel = NULL;
p_intf = p_interface;
......@@ -125,28 +127,31 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char *name , intf_thread_t
BMenuItem *mItem;
menu_bar->AddItem( mFile = new BMenu("File") );
menu_bar->AddItem( mFile = new BMenu( "File" ) );
menu_bar->ResizeToPreferred();
mFile->AddItem(mItem = new BMenuItem("Open File" B_UTF8_ELLIPSIS, new BMessage(OPEN_FILE), 'O'));
cd_menu = new CDMenu("Open Disc");
mFile->AddItem(cd_menu);
mFile->AddItem( mItem = new BMenuItem( "Open File" B_UTF8_ELLIPSIS,
new BMessage(OPEN_FILE), 'O') );
cd_menu = new CDMenu( "Open Disc" );
mFile->AddItem( cd_menu );
mFile->AddSeparatorItem();
mFile->AddItem(mItem = new BMenuItem("About" B_UTF8_ELLIPSIS, new BMessage(B_ABOUT_REQUESTED), 'A'));
mFile->AddItem( mItem = new BMenuItem( "About" B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED), 'A') );
mItem->SetTarget( be_app );
mFile->AddItem(mItem = new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
mFile->AddItem(mItem = new BMenuItem( "Quit",
new BMessage(B_QUIT_REQUESTED), 'Q') );
menu_bar->AddItem ( mAudio = new BMenu("Audio") );
menu_bar->AddItem ( mAudio = new BMenu( "Audio" ) );
menu_bar->ResizeToPreferred();
mAudio->AddItem( new LanguageMenu("Language", AUDIO_ES, p_intf) );
mAudio->AddItem( new LanguageMenu("Subtitles", SPU_ES, p_intf) );
mAudio->AddItem( new LanguageMenu( "Language", AUDIO_ES, p_intf ) );
mAudio->AddItem( new LanguageMenu( "Subtitles", SPU_ES, p_intf ) );
rect = Bounds();
rect.top += menu_bar->Bounds().IntegerHeight()+1;
rect.top += menu_bar->Bounds().IntegerHeight() + 1;
BBox* p_view;
p_view = new BBox( rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER );
p_view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
p_view->SetViewColor( ui_color(B_PANEL_BACKGROUND_COLOR) );
/* Buttons */
/* Slow play */
......@@ -243,9 +248,11 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
{
int vol_val = p_vol->Value(); // remember the current volume
static int playback_status; // remember playback state
int i_index;
BAlert *alert;
Activate();
switch( p_message->what )
{
// case B_ABOUT_REQUESTED:
......@@ -254,43 +261,52 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
// break;
case OPEN_FILE:
if(file_panel)
if( file_panel )
{
file_panel->Show();
break;
}
file_panel = new BFilePanel();
file_panel->SetTarget(this);
file_panel->SetTarget( this );
file_panel->Show();
break;
case OPEN_DVD:
const char **device;
char device_method_and_name[B_FILE_NAME_LENGTH + 4];
if(p_message->FindString("device", device) != B_ERROR)
const char **ppsz_device;
char psz_method[ B_FILE_NAME_LENGTH + 4 ];
if( p_message->FindString("device", ppsz_device) != B_ERROR )
{
sprintf(device_method_and_name, "dvd:%s", *device);
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, device_method_and_name );
snprintf( psz_method, B_FILE_NAME_LENGTH + 4,
"dvd:%s", *ppsz_device );
psz_method[ B_FILE_NAME_LENGTH + 4 - 1 ] = '\0';
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, psz_method );
}
break;
case STOP_PLAYBACK:
// this currently stops playback not nicely
if (p_intf->p_input != NULL )
if( p_intf->p_input != NULL )
{
// silence the sound, otherwise very horrible
if (p_main->p_aout != NULL)
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_main->p_aout->i_vol = 0;
p_aout_bank->pp_aout[i_index]->i_savedvolume = p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_END);
vlc_mutex_unlock( &p_aout_bank->lock );
snooze( 400000 );
input_SetStatus( p_intf->p_input, INPUT_STATUS_END );
}
break;
case START_PLAYBACK:
// starts playing in normal mode
// if (p_intf->p_input != NULL )
// {
//
// if (p_main->p_aout != NULL)
// {
// p_main->p_aout->i_vol = vol_val;
......@@ -300,96 +316,137 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
// playback_status = PLAYING;
// }
// break;
case PAUSE_PLAYBACK:
// pause the playback
if (p_intf->p_input != NULL )
if( p_intf->p_input != NULL )
{
// mute the volume if currently playing
if (playback_status == PLAYING)
if( playback_status == PLAYING )
{
if (p_main->p_aout != NULL)
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_main->p_aout->i_vol = 0;
p_aout_bank->pp_aout[i_index]->i_savedvolume =
p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
vlc_mutex_unlock( &p_aout_bank->lock );
playback_status = PAUSED;
}
else
// restore the volume
{
if (p_main->p_aout != NULL)
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_main->p_aout->i_vol = vol_val;
p_aout_bank->pp_aout[i_index]->i_volume =
p_aout_bank->pp_aout[i_index]->i_savedvolume;
p_aout_bank->pp_aout[i_index]->i_savedvolume = 0;
}
vlc_mutex_unlock( &p_aout_bank->lock );
playback_status = PLAYING;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_PAUSE);
snooze( 400000 );
input_SetStatus( p_intf->p_input, INPUT_STATUS_PAUSE );
}
break;
case FASTER_PLAY:
// cycle the fast playback modes
if (p_intf->p_input != NULL )
if( p_intf->p_input != NULL )
{
if (p_main->p_aout != NULL)
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_main->p_aout->i_vol = 0;
p_aout_bank->pp_aout[i_index]->i_savedvolume =
p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_FASTER);
vlc_mutex_unlock( &p_aout_bank->lock );
snooze( 400000 );
input_SetStatus( p_intf->p_input, INPUT_STATUS_FASTER );
}
break;
case SLOWER_PLAY:
// cycle the slow playback modes
if (p_intf->p_input != NULL )
{
if (p_main->p_aout != NULL)
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_main->p_aout->i_vol = 0;
p_aout_bank->pp_aout[i_index]->i_savedvolume =
p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
snooze(400000);
input_SetStatus(p_intf->p_input, INPUT_STATUS_SLOWER);
vlc_mutex_unlock( &p_aout_bank->lock );
snooze( 400000 );
input_SetStatus( p_intf->p_input, INPUT_STATUS_SLOWER );
}
break;
case SEEK_PLAYBACK:
// handled by semaphores;
break;
case VOLUME_CHG:
// adjust the volume
if (p_main->p_aout != NULL)
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
p_main->p_aout->i_vol = vol_val;
if( p_aout_bank->pp_aout[i_index]->i_savedvolume )
{
p_aout_bank->pp_aout[i_index]->i_savedvolume = vol_val;
}
else
{
p_aout_bank->pp_aout[i_index]->i_volume = vol_val;
}
}
vlc_mutex_unlock( &p_aout_bank->lock );
break;
case VOLUME_MUTE:
// mute
if (p_main->p_aout != NULL)
vlc_mutex_lock( &p_aout_bank->lock );
for( i_index = 0 ; i_index < p_aout_bank->i_count ; i_index++ )
{
if (p_main->p_aout->i_vol == 0)
if( p_aout_bank->pp_aout[i_index]->i_savedvolume )
{
p_vol->SetEnabled(true);
p_main->p_aout->i_vol = vol_val;
p_aout_bank->pp_aout[i_index]->i_volume =
p_aout_bank->pp_aout[i_index]->i_savedvolume;
p_aout_bank->pp_aout[i_index]->i_savedvolume = 0;
}
else
{
p_vol->SetEnabled(false);
p_main->p_aout->i_vol = 0;
p_aout_bank->pp_aout[i_index]->i_savedvolume =
p_aout_bank->pp_aout[i_index]->i_volume;
p_aout_bank->pp_aout[i_index]->i_volume = 0;
}
}
vlc_mutex_unlock( &p_aout_bank->lock );
break;
case SELECT_CHANNEL:
{
int32 i = p_message->FindInt32("channel");
input_ChangeES(p_intf->p_input,
p_intf->p_input->stream.pp_es[i], 1);
int32 i = p_message->FindInt32( "channel" );
input_ChangeES( p_intf->p_input,
p_intf->p_input->stream.pp_es[i], 1 );
}
break;
case SELECT_SUBTITLE:
{
int32 i = p_message->FindInt32("subtitle");
input_ChangeES(p_intf->p_input,
p_intf->p_input->stream.pp_es[i], 2);
int32 i = p_message->FindInt32( "subtitle" );
input_ChangeES( p_intf->p_input,
p_intf->p_input->stream.pp_es[i], 2 );
}
break;
case B_REFS_RECEIVED:
case B_SIMPLE_DATA:
{
......@@ -403,6 +460,7 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
}
break;
default:
BWindow::MessageReceived( p_message );
break;
......@@ -447,66 +505,89 @@ void CDMenu::AttachedToWindow(void)
/*****************************************************************************
* CDMenu::GetCD
*****************************************************************************/
int CDMenu::GetCD(const char *directory)
int CDMenu::GetCD( const char *directory )
{
int i_dev;
BDirectory dir;
dir.SetTo(directory);
if(dir.InitCheck() != B_NO_ERROR) {
dir.SetTo( directory );
if( dir.InitCheck() != B_NO_ERROR )
{
return B_ERROR;
}
dir.Rewind();
BEntry entry;
while(dir.GetNextEntry(&entry) >= 0) {
BPath path;
while( dir.GetNextEntry(&entry) >= 0 )
{
const char *name;
entry_ref e;
BPath path;
if(entry.GetPath(&path) != B_NO_ERROR)
if( entry.GetPath(&path) != B_NO_ERROR )
{
continue;
name = path.Path();
}
name = path.Path();
if(entry.GetRef(&e) != B_NO_ERROR)
if( entry.GetRef(&e) != B_NO_ERROR )
{
continue;
}
if(entry.IsDirectory()) {
if(strcmp(e.name, "floppy") == 0)
if( entry.IsDirectory() )
{
if( strcmp(e.name, "floppy") == 0 )
{
continue; // ignore floppy (it is not silent)
int devfd = GetCD(name);
if(devfd >= 0)
}
i_dev = GetCD( name );
if( i_dev >= 0 )
{
return devfd;
return i_dev;
}
}
else {
int devfd;
else
{
device_geometry g;
status_t m;
if(strcmp(e.name, "raw") != 0)
if( strcmp(e.name, "raw") != 0 )
{
continue; // ignore partitions
}
devfd = open(name, O_RDONLY);
if(devfd < 0)
i_dev = open( name, O_RDONLY );
if( i_dev < 0 )
{
continue;
}
if(ioctl(devfd, B_GET_GEOMETRY, &g, sizeof(g)) >= 0) {
if(g.device_type == B_CD) //ensure the drive is a CD-ROM
if( ioctl(i_dev, B_GET_GEOMETRY, &g, sizeof(g)) >= 0 )
{
if( g.device_type == B_CD ) //ensure the drive is a CD-ROM
{
if( ioctl(i_dev, B_GET_MEDIA_STATUS, &m, sizeof(m)) >= 0 )
{
if(ioctl(devfd, B_GET_MEDIA_STATUS, &m, sizeof(m)) >= 0 )
if(m == B_NO_ERROR) //ensure media is present
if( m == B_NO_ERROR ) //ensure media is present
{
BMessage *msg;
msg = new BMessage(OPEN_DVD);
msg->AddString("device", name);
msg = new BMessage( OPEN_DVD );
msg->AddString( "device", name );
BMenuItem *menu_item;
menu_item = new BMenuItem(name, msg);
AddItem(menu_item);
menu_item = new BMenuItem( name, msg );
AddItem( menu_item );
continue;
}
}
}
close(devfd);
}
close( i_dev );
}
}
return B_ERROR;
......@@ -534,7 +615,11 @@ LanguageMenu::~LanguageMenu()
*****************************************************************************/
void LanguageMenu::AttachedToWindow(void)
{
while (RemoveItem((long int)0) != NULL); // remove all items
while( RemoveItem((long int)0) != NULL )
{
; // remove all items
}
SetRadioMode(true);
GetChannels();
BMenu::AttachedToWindow();
......@@ -545,30 +630,32 @@ void LanguageMenu::AttachedToWindow(void)
*****************************************************************************/
int LanguageMenu::GetChannels()
{
char* psz_name;
char *psz_name;
bool b_active;
bool b_found;
int32 i;
int i;
es_descriptor_t *p_es;
if (p_intf->p_input == NULL)
if( p_intf->p_input == NULL )
{
return 1;
}
for (i = 0; i < p_intf->p_input->stream.i_selected_es_number; i++)
for( i = 0; i < p_intf->p_input->stream.i_selected_es_number; i++ )
{
if (kind ==
p_intf->p_input->stream.pp_selected_es[i]->i_cat)
if( kind == p_intf->p_input->stream.pp_selected_es[i]->i_cat )
{
p_es = p_intf->p_input->stream.pp_selected_es[i];
}
}
for (i = 0; i < p_intf->p_input->stream.i_es_number; i++)
for( i = 0; i < p_intf->p_input->stream.i_es_number; i++ )
{
if (kind == p_intf->p_input->stream.pp_es[i]->i_cat)
if( kind == p_intf->p_input->stream.pp_es[i]->i_cat )
{
psz_name = p_intf->p_input->stream.pp_es[i]->psz_desc;
BMessage *msg;
if (kind == AUDIO_ES) //audio
if( kind == AUDIO_ES ) //audio
{
msg = new BMessage(SELECT_CHANNEL);
msg->AddInt32("channel", i);
......@@ -587,15 +674,12 @@ int LanguageMenu::GetChannels()
}
}
/*****************************************************************************
* MediaSlider
*****************************************************************************/
MediaSlider::MediaSlider(BRect frame,
BMessage *message,
int32 minValue,
int32 maxValue)
:BSlider(frame, NULL, NULL, message, minValue, maxValue)
MediaSlider::MediaSlider( BRect frame, BMessage *p_message,
int32 i_min, int32 i_max )
:BSlider(frame, NULL, NULL, p_message, i_min, i_max )
{
}
......@@ -613,16 +697,28 @@ void MediaSlider::DrawThumb(void)
rgb_color black = {0,0,0};
r = ThumbFrame();
v = OffscreenView();
if(IsEnabled())
{
v->SetHighColor(black);
}
else
{
v->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
}
r.InsetBy(r.IntegerWidth()/4, r.IntegerHeight()/(4 * r.IntegerWidth() / r.IntegerHeight()));
v->StrokeEllipse(r);
if(IsEnabled())
{
v->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
else
{
v->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
}
r.InsetBy(1,1);
v->FillEllipse(r);
}
......@@ -630,14 +726,11 @@ void MediaSlider::DrawThumb(void)
/*****************************************************************************
* SeekSlider
*****************************************************************************/
SeekSlider::SeekSlider(BRect frame,
InterfaceWindow *owner,
int32 minValue,
int32 maxValue,
thumb_style thumbType = B_TRIANGLE_THUMB)
:MediaSlider(frame, NULL, minValue, maxValue)
SeekSlider::SeekSlider( BRect frame, InterfaceWindow *p_owner, int32 i_min,
int32 i_max, thumb_style thumbType = B_TRIANGLE_THUMB )
:MediaSlider( frame, NULL, i_min, i_max )
{
fOwner = owner;
fOwner = p_owner;
fMouseDown = false;
}
......@@ -773,32 +866,30 @@ static void intf_Close( intf_thread_t *p_intf )
*****************************************************************************/
static void intf_Run( intf_thread_t *p_intf )
{
float progress;
bool seekNeeded = false;
while( !p_intf->b_die )
{
/* Manage core vlc functions through the callback */
p_intf->pf_manage( p_intf );
/* Manage the slider */
if( p_intf->p_input != NULL && p_intf->p_sys->p_window != NULL)
{
if (acquire_sem(p_intf->p_sys->p_window->fScrubSem) == B_OK)
if( acquire_sem(p_intf->p_sys->p_window->fScrubSem) == B_OK )
{
seekNeeded = true;
}
if (seekNeeded)
if( seekNeeded )
{
uint32 seekTo = (p_intf->p_sys->p_window->p_seek->Value() *
p_intf->p_input->stream.p_selected_area->i_size) / 100;
input_Seek( p_intf->p_input, seekTo );
seekNeeded = false;
}
else if (p_intf->p_sys->p_window->Lock())
else if( p_intf->p_sys->p_window->Lock() )
{
progress = (100. * p_intf->p_input->stream.p_selected_area->i_tell) /
p_intf->p_input->stream.p_selected_area->i_size;
......@@ -813,3 +904,4 @@ static void intf_Run( intf_thread_t *p_intf )
}
} /* extern "C" */
......@@ -2,7 +2,7 @@
* dvd_ifo.c: Functions for ifo parsing
*****************************************************************************
* Copyright (C) 1999-2001 VideoLAN
* $Id: dvd_ifo.c,v 1.25 2001/05/07 03:14:09 stef Exp $
* $Id: dvd_ifo.c,v 1.26 2001/05/07 04:42:42 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......
......@@ -10,7 +10,7 @@
* -dvd_udf to find files
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: input_dvd.c,v 1.56 2001/05/07 03:14:09 stef Exp $
* $Id: input_dvd.c,v 1.57 2001/05/07 04:42:42 sam Exp $
*
* Author: Stphane Borel <stef@via.ecp.fr>
*
......@@ -668,7 +668,6 @@ static int DVDSetArea( input_thread_t * p_input, input_area_t * p_area )
p_dvd->i_cell = vts.cell_inf.i_cell_nb - 1;
}
p_dvd->i_sector = 0;
p_dvd->i_size = DVD_LB_SIZE *
(off_t)( vts.cell_inf.p_cell_map[p_dvd->i_cell].i_end_sector );
......
......@@ -2,7 +2,7 @@
* input_ps.c: PS demux and packet management
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: input_ps.c,v 1.21 2001/05/07 03:14:09 stef Exp $
* $Id: input_ps.c,v 1.22 2001/05/07 04:42:42 sam Exp $
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Cyril Deguet <asmax@via.ecp.fr>
......
......@@ -2,7 +2,7 @@
* vout_sdl.c: SDL video output display method
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vout_sdl.c,v 1.50 2001/05/07 03:14:09 stef Exp $
* $Id: vout_sdl.c,v 1.51 2001/05/07 04:42:42 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Pierre Baillet <oct@zoy.org>
......
......@@ -2,7 +2,7 @@
* vout_xvideo.c: Xvideo video output display method
*****************************************************************************
* Copyright (C) 1998, 1999, 2000, 2001 VideoLAN
* $Id: vout_xvideo.c,v 1.15 2001/05/07 03:14:09 stef Exp $
* $Id: vout_xvideo.c,v 1.16 2001/05/07 04:42:42 sam Exp $
*
* Authors: Shane Harper <shanegh@optusnet.com.au>
* Vincent Seguin <seguin@via.ecp.fr>
......
......@@ -2,7 +2,7 @@
* ac3_parse.c: ac3 parsing procedures
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: ac3_parse.c,v 1.20 2001/05/06 04:32:02 sam Exp $
* $Id: ac3_parse.c,v 1.21 2001/05/07 04:42:42 sam Exp $
*
* Authors: Michel Kaempf <maxx@via.ecp.fr>
* Aaron Holtzman <aholtzma@engr.uvic.ca>
......
......@@ -3,7 +3,7 @@
* Functions are prototyped in mtime.h.
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: mtime.c,v 1.17 2001/04/28 03:36:25 sam Exp $
* $Id: mtime.c,v 1.18 2001/05/07 04:42:42 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......
......@@ -2,7 +2,7 @@
* netutils.c: various network functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: netutils.c,v 1.28 2001/04/28 03:36:25 sam Exp $
* $Id: netutils.c,v 1.29 2001/05/07 04:42:42 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Benoit Steiner <benny@via.ecp.fr>
......
......@@ -2,7 +2,7 @@
* spu_decoder.c : spu decoder thread
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: spu_decoder.c,v 1.41 2001/05/07 03:14:09 stef Exp $
* $Id: spu_decoder.c,v 1.42 2001/05/07 04:42:42 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -49,8 +49,6 @@
#include "spu_decoder.h"
#include "main.h" /* XXX: remove this later */
/*****************************************************************************
* Local prototypes
*****************************************************************************/
......@@ -88,14 +86,12 @@ vlc_thread_t spudec_CreateThread( vdec_config_t * p_config )
p_spudec->p_fifo = p_config->decoder_config.p_decoder_fifo;
/* XXX: The vout request and fifo opening will eventually be here */
/* Spawn an audio output if there is none */
/* Spawn a video output if there is none */
vlc_mutex_lock( &p_vout_bank->lock );
if( p_vout_bank->i_count == 0 )
{
intf_Msg( "spudec: no vout present, spawning one" );
intf_WarnMsg( 1, "spudec: no vout present, spawning one" );
p_spudec->p_vout = vout_CreateThread( NULL );
......@@ -275,9 +271,13 @@ static void ParsePacket( spudec_thread_t *p_spudec )
subpicture_t * p_spu;
u8 * p_src;
intf_WarnMsg( 3, "spudec: trying to gather a 0x%.2x long subtitle",
p_spudec->i_spu_size );
/* We cannot display a subpicture with no date */
if( DECODER_FIFO_START(*p_spudec->p_fifo)->i_pts == 0 )
{
intf_WarnMsg( 3, "spudec error: subtitle without a date" );
return;
}
......@@ -294,9 +294,8 @@ static void ParsePacket( spudec_thread_t *p_spudec )
return;
}
/* Get display time now. If we do it later, we may miss a PTS. */
p_spu->begin_date = p_spu->end_date
= DECODER_FIFO_START(*p_spudec->p_fifo)->i_pts;
/* Get display time now. If we do it later, we may miss the PTS. */
p_spudec->i_pts = DECODER_FIFO_START(*p_spudec->p_fifo)->i_pts;
/* Allocate the temporary buffer we will parse */
p_src = malloc( p_spudec->i_rle_size );
......@@ -313,7 +312,7 @@ static void ParsePacket( spudec_thread_t *p_spudec )
#if 0
/* Dump the subtitle info */
intf_WarnHexDump( 0, p_spu->p_data, p_spudec->i_rle_size );
intf_WarnHexDump( 5, p_spu->p_data, p_spudec->i_rle_size );
#endif
/* Getting the control part */
......@@ -333,9 +332,11 @@ static void ParsePacket( spudec_thread_t *p_spudec )
return;
}
intf_WarnMsg( 3, "spudec: got a valid %ix%i subtitle at (%i,%i), "
"RLE offsets: 0x%x 0x%x",
p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y,
intf_WarnMsg( 3, "spudec: valid subtitle, size: %ix%i, position: %i,%i",
p_spu->i_width, p_spu->i_height, p_spu->i_x, p_spu->i_y );
intf_WarnMsg( 3, "spudec: total size: 0x%x, RLE offsets: 0x%x 0x%x",
p_spudec->i_spu_size,
p_spu->type.spu.i_offset[0], p_spu->type.spu.i_offset[1] );
/* SPU is finished - we can ask the video output to display it */
......@@ -359,20 +360,24 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
int i_index = p_spudec->i_rle_size + 4;
/* The next start-of-control-sequence index and the previous one */
int i_next_index = 0, i_prev_index;
int i_next_seq, i_cur_seq;
/* Command time and date */
u8 i_command;
int i_date;
/* Initialize the structure */
p_spu->i_start = p_spu->i_stop = 0;
p_spu->b_ephemer = 0;
do
{
/* Get the control sequence date */
i_date = GetBits( &p_spudec->bit_stream, 16 );
/* Next offset */
i_prev_index = i_next_index;
i_next_index = GetBits( &p_spudec->bit_stream, 16 );
i_cur_seq = i_index;
i_next_seq = GetBits( &p_spudec->bit_stream, 16 );
/* Skip what we just read */
i_index += 4;
......@@ -387,20 +392,24 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
case SPU_CMD_FORCE_DISPLAY:
/* 00 (force displaying) */
intf_ErrMsg( "spudec: \"force display\" command" );
intf_ErrMsg( "spudec: send mail to <sam@zoy.org> if you "
"want to help debugging this" );
break;
/* Convert the dates in seconds to PTS values */
case SPU_CMD_START_DISPLAY:
/* 01 (start displaying) */
p_spu->begin_date += ( i_date * 11000 );
p_spu->i_start = p_spudec->i_pts + ( i_date * 11000 );
break;
case SPU_CMD_STOP_DISPLAY:
/* 02 (stop displaying) */
p_spu->end_date += ( i_date * 11000 );
p_spu->i_stop = p_spudec->i_pts + ( i_date * 11000 );
break;
......@@ -463,13 +472,13 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
} while( i_command != SPU_CMD_END );
} while( i_index == i_next_index );
} while( i_index == i_next_seq );
/* Check that the last index matches the previous one */
if( i_next_index != i_prev_index )
/* Check that the next sequence index matches the current one */
if( i_next_seq != i_cur_seq )
{
intf_ErrMsg( "spudec error: index mismatch (0x%.4x != 0x%.4x)",
i_next_index, i_prev_index );
i_next_seq, i_cur_seq );
return( 1 );
}
......@@ -480,18 +489,26 @@ static int ParseControlSequences( spudec_thread_t *p_spudec,
return( 1 );
}
if( !p_spu->i_start )
{
intf_ErrMsg( "spudec error: no `start display' command" );
}
if( !p_spu->i_stop )
{
/* This subtitle will live for 5 seconds or until the next subtitle */
p_spu->i_stop = p_spu->i_start + 500 * 11000;
p_spu->b_ephemer = 1;
}
/* Get rid of padding bytes */
switch( p_spudec->i_spu_size - i_index )
{
case 1:
RemoveBits( &p_spudec->bit_stream, 8 );
i_index++;
case 0:
/* Zero or one padding byte, quite usual */
break;
default:
......
......@@ -2,7 +2,7 @@
* spu_decoder.h : sub picture unit decoder thread interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: spu_decoder.h,v 1.7 2001/03/21 13:42:34 sam Exp $
* $Id: spu_decoder.h,v 1.8 2001/05/07 04:42:42 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -47,6 +47,7 @@ typedef struct spudec_thread_s
/*
* Private properties
*/
mtime_t i_pts; /* presentation timestamp */
int i_spu_size; /* size of current SPU packet */
int i_rle_size; /* size of the RLE part */
subpicture_t * p_spu;
......
......@@ -5,7 +5,7 @@
* thread, and destroy a previously oppened video output thread.
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: video_output.c,v 1.125 2001/05/07 03:14:10 stef Exp $
* $Id: video_output.c,v 1.126 2001/05/07 04:42:42 sam Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
*
......@@ -217,11 +217,13 @@ vout_thread_t * vout_CreateThread ( int *pi_status )
p_vout->p_picture[i_index].i_type = EMPTY_PICTURE;
p_vout->p_picture[i_index].i_status = FREE_PICTURE;
}
for( i_index = 0; i_index < VOUT_MAX_SUBPICTURES; i_index++)
{
p_vout->p_subpicture[i_index].i_type = EMPTY_SUBPICTURE;
p_vout->p_subpicture[i_index].i_status= FREE_SUBPICTURE;
p_vout->p_subpicture[i_index].i_status = FREE_SUBPICTURE;
}
p_vout->i_pictures = 0;
/* Create and initialize system-dependant method - this function issues its
......@@ -232,6 +234,7 @@ vout_thread_t * vout_CreateThread ( int *pi_status )
free( p_vout );
return( NULL );
}
intf_WarnMsg( 3, "actual configuration: %dx%d, %d/%d bpp (%d Bpl), "
"masks: 0x%x/0x%x/0x%x",
p_vout->i_width, p_vout->i_height, p_vout->i_screen_depth,
......@@ -337,15 +340,15 @@ void vout_DestroyThread( vout_thread_t *p_vout, int *pi_status )
/*****************************************************************************
* vout_DisplaySubPicture: display a subpicture unit
*****************************************************************************
* Remove the reservation flag of an subpicture, which will cause it to be ready
* Remove the reservation flag of a subpicture, which will cause it to be ready
* for display. The picture does not need to be locked, since it is ignored by
* the output thread if is reserved.
*****************************************************************************/
void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
{
#ifdef TRACE_VOUT
char psz_begin_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
char psz_end_date[MSTRTIME_MAX_SIZE]; /* buffer for date string */
char psz_start[ MSTRTIME_MAX_SIZE ]; /* buffer for date string */
char psz_stop[ MSTRTIME_MAX_SIZE ]; /* buffer for date string */
#endif
#ifdef DEBUG
......@@ -364,8 +367,8 @@ void vout_DisplaySubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
/* Send subpicture information */
intf_DbgMsg("subpicture %p: type=%d, begin date=%s, end date=%s",
p_subpic, p_subpic->i_type,
mstrtime( psz_begin_date, p_subpic->begin_date ),
mstrtime( psz_end_date, p_subpic->end_date ) );
mstrtime( psz_start, p_subpic->i_start ),
mstrtime( psz_stop, p_subpic->i_stop ) );
#endif
}
......@@ -1065,6 +1068,7 @@ static void RunThread( vout_thread_t *p_vout)
display_date = 0;
}
}
/*
* Find the subpictures to display - this operation does not need
* lock, since only READY_SUBPICTURE are handled. If no picture
......@@ -1090,9 +1094,6 @@ static void RunThread( vout_thread_t *p_vout)
p_vout->last_display_date = display_date;
p_vout->p_rendered_pic = p_pic;
/* Set picture dimensions and clear buffer */
SetBufferPicture( p_vout, p_pic );
......@@ -1951,6 +1952,43 @@ static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
{
p_vout_font_t p_font; /* text font */
int i_width, i_height; /* subpicture dimensions */
mtime_t i_date = mdate();
subpicture_t *p_ephemer = NULL;
subpicture_t *p_tmp = p_subpic;
/* Look for the youngest ephemer */
while( p_tmp != NULL )
{
if( p_tmp->i_type == DVD_SUBPICTURE && p_tmp->b_ephemer
&& i_date >= p_tmp->i_start && i_date <= p_tmp->i_stop )
{
if( p_ephemer == NULL || p_tmp->i_start < p_ephemer->i_start )
{
p_ephemer = p_tmp;
}
}
p_tmp = p_tmp->p_next;
}
/* If we found an ephemer, kill it if we find a more recent one */
if( p_ephemer != NULL )
{
p_tmp = p_subpic;
while( p_tmp != NULL )
{
if( p_tmp->i_type == DVD_SUBPICTURE
&& i_date >= p_tmp->i_start && i_date >= p_tmp->i_start
&& p_tmp != p_ephemer && p_tmp->i_start > p_ephemer->i_start )
{
p_ephemer->i_stop = 0;
}
p_tmp = p_tmp->p_next;
}
}
while( p_subpic != NULL )
{
......@@ -1958,12 +1996,12 @@ static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
{
case DVD_SUBPICTURE: /* DVD subpicture unit */
/* test if the picture really has to be displayed */
if( mdate() < p_subpic->begin_date )
if( i_date < p_subpic->i_start )
{
/* not yet, see you later */
break;
}
if( mdate() > p_subpic->end_date )
if( i_date > p_subpic->i_stop )
{
/* too late, destroying the subpic */
vout_DestroySubPicture( p_vout, p_subpic );
......@@ -1973,6 +2011,7 @@ static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
p_subpic, p_vout->i_bytes_per_pixel,
p_vout->i_bytes_per_line );
break;
case TEXT_SUBPICTURE: /* single line text */
/* Select default font if not specified */
p_font = p_subpic->type.text.p_font;
......@@ -2003,11 +2042,12 @@ static void RenderSubPicture( vout_thread_t *p_vout, subpicture_t *p_subpic )
}
break;
#ifdef DEBUG
default:
#ifdef DEBUG
intf_ErrMsg( "error: unknown subpicture %p type %d",
p_subpic, p_subpic->i_type );
#endif
break;
}
p_subpic = p_subpic->p_next;
......
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