INPUT_DEL_BOOKMARK, /* arg1= seekpoint_t * res=can fail */
INPUT_SET_BOOKMARK, /* arg1= int res=can fail */
+ INPUT_GET_SUBDELAY, /* arg1 = int* res=can fail */
+ INPUT_SET_SUBDELAY, /* arg1 = int res=can fail */
+
INPUT_GET_DIVISIONS
};
#define ACTIONID_PLAY_BOOKMARK9 44
#define ACTIONID_PLAY_BOOKMARK10 45
/* end of contiguous zone */
+#define ACTIONID_SUBDELAY_UP 46
+#define ACTIONID_SUBDELAY_DOWN 47
* hotkeys.c: Hotkey handling for vlc
*****************************************************************************
* Copyright (C) 2004 VideoLAN
- * $Id: hotkeys.c,v 1.17 2004/02/17 03:12:00 hartman Exp $
+ * $Id$
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
aout_VolumeDown( p_intf, 1, &i_newvol );
vout_OSDMessage( p_intf, "Vol %d%%", i_newvol*100/AOUT_VOLUME_MAX);
}
+ else if( i_action == ACTIONID_SUBDELAY_DOWN )
+ {
+ int i_delay;
+ if( input_Control( p_input, INPUT_GET_SUBDELAY, &i_delay ) ==
+ VLC_SUCCESS )
+ {
+ i_delay--;
+ input_Control( p_input, INPUT_SET_SUBDELAY, i_delay );
+ vout_OSDMessage( p_intf, "Subtitle delay %i ms",i_delay*100);
+ }
+ }
+ else if( i_action == ACTIONID_SUBDELAY_UP )
+ {
+ int i_delay;
+ if( input_Control( p_input, INPUT_GET_SUBDELAY, &i_delay ) ==
+ VLC_SUCCESS )
+ {
+ i_delay++;
+ input_Control( p_input, INPUT_SET_SUBDELAY, i_delay );
+ vout_OSDMessage( p_intf, "Subtitle delay %i ms",i_delay*100);
+ }
+ }
else if( i_action == ACTIONID_VOL_MUTE )
{
audio_volume_t i_newvol = -1;
}
else
{
- vout_OSDMessage( p_intf, "Vol %d%%", i_newvol*100/AOUT_VOLUME_MAX );
+ vout_OSDMessage( p_intf, "Vol %d%%",
+ i_newvol*100/AOUT_VOLUME_MAX );
}
}
else if( i_action == ACTIONID_FULLSCREEN )
* sub.c: subtitle demux for external subtitle files
*****************************************************************************
* Copyright (C) 1999-2004 VideoLAN
- * $Id: sub.c,v 1.52 2004/02/22 15:59:53 fenrir Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
* Derk-Jan Hartman <hartman at videolan dot org>
vlc_module_begin();
set_description( _("Text subtitles demux") );
set_capability( "subtitle demux", 12 );
- add_float( "sub-fps", 25.0, NULL,
+ add_float( "sub-fps", 0.0, NULL,
N_("Frames per second"),
SUB_FPS_LONGTEXT, VLC_TRUE );
add_integer( "sub-delay", 0, NULL,
p_sub->pf_demux = sub_demux;
p_sub->pf_seek = sub_seek;
p_sub->pf_close = sub_close;
-
+
/* Initialize the variables */
var_Create( p_this, "sub-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_Create( p_this, "sub-delay", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
p_sub->i_subtitles = 0;
p_sub->subtitle = NULL;
p_sub->p_vobsub_file = 0;
+ p_sub->i_original_mspf = i_microsecperframe;
p_sub->p_input = p_input;
if( !psz_name || !*psz_name )
{
i_microsecperframe = (mtime_t)( (float)1000000 / val.f_float );
}
+ else if( val.f_float == 0 )
+ {
+ /* No value given */
+ i_microsecperframe = 0;
+ }
else if( val.f_float <= 0 )
{
- i_microsecperframe = 40000; /* default: 25fps */
+ /* invalid value, default = 25fps */
+ i_microsecperframe = 40000;
}
var_Get( p_sub, "sub-type", &val);
{
input_thread_t *p_input = p_sub->p_input;
vlc_bool_t b;
+ vlc_value_t val;
+ mtime_t i_delay;
es_out_Control( p_input->p_es_out, ES_OUT_GET_ES_STATE, p_sub->p_es, &b );
if( b && !p_sub->i_previously_selected )
if( p_sub->i_sub_type != SUB_TYPE_VOBSUB )
{
+ var_Get( p_sub, "sub-delay", &val );
+ i_delay = (mtime_t) val.i_int * 100000;
while( p_sub->i_subtitle < p_sub->i_subtitles &&
- p_sub->subtitle[p_sub->i_subtitle].i_start < i_maxdate )
+ p_sub->subtitle[p_sub->i_subtitle].i_start < i_maxdate - i_delay )
{
block_t *p_block;
int i_len = strlen( p_sub->subtitle[p_sub->i_subtitle].psz_text ) + 1;
continue;
}
- /* XXX we should convert all demuxers to use es_out_Control to set pcr and
- * then remove that */
+ /* XXX we should convert all demuxers to use es_out_Control to set * pcr and then remove that */
+ if( i_delay != 0 )
+ {
+ p_sub->subtitle[p_sub->i_subtitle].i_start += i_delay;
+ p_sub->subtitle[p_sub->i_subtitle].i_stop += i_delay;
+ }
+
p_block->i_pts =
input_ClockGetTS( p_sub->p_input,
p_sub->p_input->stream.p_selected_program,
}
memcpy( p_block->p_buffer, p_sub->subtitle[p_sub->i_subtitle].psz_text, i_len );
-
if( p_block->i_pts > 0 )
{
es_out_Send( p_input->p_es_out, p_sub->p_es, p_block );
buffer_text[i] = '\n';
}
}
+ if( i_microsecperframe == 0)
+ {
+ i_microsecperframe = 40000;
+ }
p_subtitle->i_start = (mtime_t)i_start * (mtime_t)i_microsecperframe;
p_subtitle->i_stop = (mtime_t)i_stop * (mtime_t)i_microsecperframe;
p_subtitle->psz_text = strndup( buffer_text, MAX_LINE );
p_subtitle->i_start = i_start;
p_subtitle->i_stop = i_stop;
p_subtitle->psz_text = strdup( buffer_text );
+ /* If framerate is available, use sub-fps */
+ if( i_microsecperframe != 0 && p_sub->i_original_mspf != 0)
+ {
+ p_subtitle->i_start = (mtime_t)i_start *
+ (mtime_t)p_sub->i_original_mspf /
+ (mtime_t)i_microsecperframe;
+ p_subtitle->i_stop = (mtime_t)i_stop *
+ (mtime_t)p_sub->i_original_mspf /
+ (mtime_t)i_microsecperframe;
+ }
return( 0 );
}
else
* sub.h
*****************************************************************************
* Copyright (C) 2001-2004 VideoLAN
- * $Id: sub.h,v 1.20 2004/03/03 20:39:52 gbazin Exp $
+ * $Id$
*
* Authors: Laurent Aimar <fenrir@via.ecp.fr>
*
es_out_id_t *p_es;
int i_previously_selected; /* to make pf_seek */
FILE *p_vobsub_file;
+ mtime_t i_original_mspf;
} subtitle_demux_t;
#include <vlc/input.h>
#include "ninput.h"
+#include "../../modules/demux/util/sub.h"
+
+struct input_thread_sys_t
+{
+ /* subtitles */
+ int i_sub;
+ subtitle_demux_t **sub;
+ int64_t i_stop_time;
+};
/****************************************************************************
* input_Control
int i_ret;
seekpoint_t *p_bkmk, ***ppp_bkmk;
int i_bkmk, *pi_bkmk;
+ int i, *pi;
vlc_value_t val, text;
vlc_mutex_lock( &p_input->stream.stream_lock );
}
break;
+ case INPUT_GET_SUBDELAY:
+ pi = (int)va_arg( args, int *);
+ /* We work on the first subtitle */
+ if( p_input->p_sys != NULL )
+ {
+ if( p_input->p_sys->i_sub > 0 )
+ {
+ i_ret = var_Get( (vlc_object_t *)p_input->p_sys->sub[0],
+ "sub-delay", &val );
+ *pi = val.i_int;
+ }
+ else
+ {
+ msg_Dbg( p_input,"no subtitle track");
+ i_ret = VLC_EGENERIC;
+ }
+ }
+ else
+ {
+ i_ret = VLC_EGENERIC;
+ }
+ break;
+
+ case INPUT_SET_SUBDELAY:
+ i = (int)va_arg( args, int );
+ /* We work on the first subtitle */
+ if( p_input->p_sys )
+ {
+ if( p_input->p_sys->i_sub > 0 )
+ {
+ val.i_int = i;
+ i_ret = var_Set( (vlc_object_t *)p_input->p_sys->sub[0],
+ "sub-delay", val );
+ }
+ else
+ {
+ msg_Dbg( p_input,"no subtitle track");
+ i_ret = VLC_EGENERIC;
+ }
+ }
+ else
+ {
+ i_ret = VLC_EGENERIC;
+ }
+ break;
+
default:
msg_Err( p_input, "unknown query in input_vaControl" );
i_ret = VLC_EGENERIC;
static int InitThread( input_thread_t * p_input )
{
vlc_meta_t *p_meta = NULL, *p_meta_user = NULL;
- float f_fps;
+// float f_fps;
+ double f_fps;
playlist_t *p_playlist;
mtime_t i_length;
/* Get fps */
if( demux_Control( p_input, DEMUX_GET_FPS, &f_fps ) || f_fps < 0.1 )
{
- i_microsecondperframe = 0;
}
else
{
#define VOL_DOWN_KEY_LONGTEXT N_("Select the key to decrease audio volume.")
#define VOL_MUTE_KEY_TEXT N_("Mute")
#define VOL_MUTE_KEY_LONGTEXT N_("Select the key to turn off audio volume.")
+#define SUBDELAY_UP_KEY_TEXT N_("Subtitle delay up")
+#define SUBDELAY_UP_KEY_LONGTEXT N_("Select the key to increase the subtitle delay.")
+#define SUBDELAY_DOWN_KEY_TEXT N_("Subtitle delay down")
+#define SUBDELAY_DOWN_KEY_LONGTEXT N_("Select the key to decrease the subtitle delay.")
#define PLAY_BOOKMARK1_KEY_TEXT N_("Play playlist bookmark 1")
#define PLAY_BOOKMARK2_KEY_TEXT N_("Play playlist bookmark 2")
#define PLAY_BOOKMARK3_KEY_TEXT N_("Play playlist bookmark 3")
add_key( "key-vol-up", KEY_MODIFIER_COMMAND|KEY_UP, NULL, VOL_UP_KEY_TEXT, VOL_UP_KEY_LONGTEXT, VLC_FALSE );
add_key( "key-vol-down", KEY_MODIFIER_COMMAND|KEY_DOWN, NULL, VOL_DOWN_KEY_TEXT, VOL_DOWN_KEY_LONGTEXT, VLC_FALSE );
add_key( "key-vol-mute", KEY_MODIFIER_COMMAND|KEY_MODIFIER_SHIFT|'m', NULL, VOL_MUTE_KEY_TEXT, VOL_MUTE_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "key-subdelay-up", KEY_MODIFIER_COMMAND|'j', NULL,
+ SUBDELAY_UP_KEY_TEXT, SUBDELAY_UP_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "key-subdelay-down", KEY_MODIFIER_COMMAND|'h', NULL,
+ SUBDELAY_DOWN_KEY_TEXT, SUBDELAY_DOWN_KEY_LONGTEXT, VLC_FALSE );
add_key( "key-set-bookmark1", KEY_MODIFIER_COMMAND|KEY_F1, NULL, SET_BOOKMARK1_KEY_TEXT, SET_BOOKMARK_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-set-bookmark2", KEY_MODIFIER_COMMAND|KEY_F2, NULL, SET_BOOKMARK2_KEY_TEXT, SET_BOOKMARK_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-set-bookmark3", KEY_MODIFIER_COMMAND|KEY_F3, NULL, SET_BOOKMARK3_KEY_TEXT, SET_BOOKMARK_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-vol-up", 'a', NULL, VOL_UP_KEY_TEXT, VOL_UP_KEY_LONGTEXT, VLC_FALSE );
add_key( "key-vol-down", 'z', NULL, VOL_DOWN_KEY_TEXT, VOL_DOWN_KEY_LONGTEXT, VLC_FALSE );
add_key( "key-vol-mute", 'm', NULL, VOL_MUTE_KEY_TEXT, VOL_MUTE_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "key-subdelay-up", KEY_MODIFIER_COMMAND|'h', NULL,
+ SUBDELAY_UP_KEY_TEXT, SUBDELAY_UP_KEY_LONGTEXT, VLC_FALSE );
+ add_key( "key-subdelay-down", KEY_MODIFIER_COMMAND|'j', NULL,
+ SUBDELAY_DOWN_KEY_TEXT, SUBDELAY_DOWN_KEY_LONGTEXT, VLC_FALSE );
add_key( "key-set-bookmark1", KEY_MODIFIER_CTRL|KEY_F1, NULL, SET_BOOKMARK1_KEY_TEXT, SET_BOOKMARK_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-set-bookmark2", KEY_MODIFIER_CTRL|KEY_F2, NULL, SET_BOOKMARK2_KEY_TEXT, SET_BOOKMARK_KEY_LONGTEXT, VLC_TRUE );
add_key( "key-set-bookmark3", KEY_MODIFIER_CTRL|KEY_F3, NULL, SET_BOOKMARK3_KEY_TEXT, SET_BOOKMARK_KEY_LONGTEXT, VLC_TRUE );
{ "key-vol-up", ACTIONID_VOL_UP, 0 },
{ "key-vol-down", ACTIONID_VOL_DOWN, 0 },
{ "key-vol-mute", ACTIONID_VOL_MUTE, 0 },
+ { "key-subdelay-down", ACTIONID_SUBDELAY_DOWN, 0 },
+ { "key-subdelay-up", ACTIONID_SUBDELAY_UP, 0 },
{ "key-nav-activate", ACTIONID_NAV_ACTIVATE, 0 },
{ "key-nav-up", ACTIONID_NAV_UP, 0 },
{ "key-nav-down", ACTIONID_NAV_DOWN, 0 },