Commit b841a87b authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* src/input/subtitles.c: made the autodetection fuzziness a config option.

* ALL:
  use a counter and pass this along to New_Subtitle, so we can add more
  than one subtitle file. This 'fixes' a problem where all subtitles got the
  same track_id and therefore were all (un)selected at the same time.
parent b6990fe6
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sub.c * sub.c
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2003 VideoLAN * Copyright (C) 1999-2003 VideoLAN
* $Id: sub.c,v 1.27 2003/10/08 21:03:36 gbazin Exp $ * $Id: sub.c,v 1.28 2003/10/11 22:40:04 hartman Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -43,7 +43,8 @@ static int Open ( vlc_object_t *p_this ); ...@@ -43,7 +43,8 @@ static int Open ( vlc_object_t *p_this );
static int sub_open ( subtitle_demux_t *p_sub, static int sub_open ( subtitle_demux_t *p_sub,
input_thread_t *p_input, input_thread_t *p_input,
char *psz_name, char *psz_name,
mtime_t i_microsecperframe ); mtime_t i_microsecperframe,
int i_track_id );
static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate ); static int sub_demux( subtitle_demux_t *p_sub, mtime_t i_maxdate );
static int sub_seek ( subtitle_demux_t *p_sub, mtime_t i_date ); static int sub_seek ( subtitle_demux_t *p_sub, mtime_t i_date );
static void sub_close( subtitle_demux_t *p_sub ); static void sub_close( subtitle_demux_t *p_sub );
...@@ -231,7 +232,8 @@ static struct ...@@ -231,7 +232,8 @@ static struct
static int sub_open ( subtitle_demux_t *p_sub, static int sub_open ( subtitle_demux_t *p_sub,
input_thread_t *p_input, input_thread_t *p_input,
char *psz_name, char *psz_name,
mtime_t i_microsecperframe ) mtime_t i_microsecperframe,
int i_track_id )
{ {
text_t txt; text_t txt;
vlc_value_t val; vlc_value_t val;
...@@ -424,11 +426,11 @@ static int sub_open ( subtitle_demux_t *p_sub, ...@@ -424,11 +426,11 @@ static int sub_open ( subtitle_demux_t *p_sub,
/* *** add subtitle ES *** */ /* *** add subtitle ES *** */
vlc_mutex_lock( &p_input->stream.stream_lock ); vlc_mutex_lock( &p_input->stream.stream_lock );
p_sub->p_es = input_AddES( p_input, p_input->stream.p_selected_program, p_sub->p_es = input_AddES( p_input, p_input->stream.p_selected_program,
0xff, // FIXME 0xff - i_track_id, /* FIXME */
SPU_ES, NULL, 0 ); SPU_ES, NULL, 0 );
vlc_mutex_unlock( &p_input->stream.stream_lock ); vlc_mutex_unlock( &p_input->stream.stream_lock );
p_sub->p_es->i_stream_id = 0xff; // FIXME p_sub->p_es->i_stream_id = 0xff - i_track_id; /* FIXME */
p_sub->p_es->i_fourcc = VLC_FOURCC( 's','u','b','t' ); p_sub->p_es->i_fourcc = VLC_FOURCC( 's','u','b','t' );
p_sub->i_previously_selected = 0; p_sub->i_previously_selected = 0;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* sub.h * sub.h
***************************************************************************** *****************************************************************************
* Copyright (C) 2001-2003 VideoLAN * Copyright (C) 2001-2003 VideoLAN
* $Id: sub.h,v 1.7 2003/08/23 19:20:29 hartman Exp $ * $Id: sub.h,v 1.8 2003/10/11 22:40:05 hartman Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -47,7 +47,8 @@ typedef struct subtitle_demux_s ...@@ -47,7 +47,8 @@ typedef struct subtitle_demux_s
int (*pf_open) ( struct subtitle_demux_s *p_sub, int (*pf_open) ( struct subtitle_demux_s *p_sub,
input_thread_t*p_input, input_thread_t*p_input,
char *psz_name, char *psz_name,
mtime_t i_microsecperframe ); mtime_t i_microsecperframe,
int i_track_id );
int (*pf_demux)( struct subtitle_demux_s *p_sub, mtime_t i_maxdate ); int (*pf_demux)( struct subtitle_demux_s *p_sub, mtime_t i_maxdate );
int (*pf_seek) ( struct subtitle_demux_s *p_sub, mtime_t i_date ); int (*pf_seek) ( struct subtitle_demux_s *p_sub, mtime_t i_date );
void (*pf_close)( struct subtitle_demux_s *p_sub ); void (*pf_close)( struct subtitle_demux_s *p_sub );
...@@ -89,7 +90,8 @@ typedef struct subtitle_demux_s ...@@ -89,7 +90,8 @@ typedef struct subtitle_demux_s
*****************************************************************************/ *****************************************************************************/
static inline subtitle_demux_t *subtitle_New( input_thread_t *p_input, static inline subtitle_demux_t *subtitle_New( input_thread_t *p_input,
char *psz_name, char *psz_name,
mtime_t i_microsecperframe ); mtime_t i_microsecperframe,
int i_track_id );
/***************************************************************************** /*****************************************************************************
* subtitle_Select: Select the related subtitle ES. * subtitle_Select: Select the related subtitle ES.
*****************************************************************************/ *****************************************************************************/
...@@ -127,7 +129,8 @@ static inline void subtitle_Close( subtitle_demux_t *p_sub ); ...@@ -127,7 +129,8 @@ static inline void subtitle_Close( subtitle_demux_t *p_sub );
static inline static inline
subtitle_demux_t *subtitle_New( input_thread_t *p_input, subtitle_demux_t *subtitle_New( input_thread_t *p_input,
char *psz_name, char *psz_name,
mtime_t i_microsecperframe ) mtime_t i_microsecperframe,
int i_track_id )
{ {
subtitle_demux_t *p_sub; subtitle_demux_t *p_sub;
...@@ -140,7 +143,8 @@ static inline ...@@ -140,7 +143,8 @@ static inline
p_sub->pf_open( p_sub, p_sub->pf_open( p_sub,
p_input, p_input,
psz_name, psz_name,
i_microsecperframe ) >=0 ) i_microsecperframe,
i_track_id ) >=0 )
{ {
msg_Info( p_input, "subtitle started" ); msg_Info( p_input, "subtitle started" );
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* decoders. * decoders.
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: input.c,v 1.246 2003/10/08 21:01:07 gbazin Exp $ * $Id: input.c,v 1.247 2003/10/11 22:40:05 hartman Exp $
* *
* Authors: Christophe Massiot <massiot@via.ecp.fr> * Authors: Christophe Massiot <massiot@via.ecp.fr>
* *
...@@ -112,6 +112,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent, ...@@ -112,6 +112,7 @@ input_thread_t *__input_CreateThread( vlc_object_t *p_parent,
var_Create( p_input, "spu-channel", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT ); var_Create( p_input, "spu-channel", VLC_VAR_INTEGER|VLC_VAR_DOINHERIT );
var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-file", VLC_VAR_FILE | VLC_VAR_DOINHERIT );
var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "sub-autodetect-file", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
var_Create( p_input, "sub-autodetect-fuzzy", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); var_Create( p_input, "sout-audio", VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
...@@ -729,7 +730,7 @@ static int InitThread( input_thread_t * p_input ) ...@@ -729,7 +730,7 @@ static int InitThread( input_thread_t * p_input )
var_Get( p_input, "sub-file", &val ); var_Get( p_input, "sub-file", &val );
if( val.psz_string && *val.psz_string ) if( val.psz_string && *val.psz_string )
{ {
if( ( p_sub = subtitle_New( p_input, strdup(val.psz_string), i_microsecondperframe ) ) ) if( ( p_sub = subtitle_New( p_input, strdup(val.psz_string), i_microsecondperframe, 0 ) ) )
{ {
TAB_APPEND( p_input->p_sys->i_sub, p_input->p_sys->sub, p_sub ); TAB_APPEND( p_input->p_sys->i_sub, p_input->p_sys->sub, p_sub );
subtitle_Select( p_sub ); subtitle_Select( p_sub );
...@@ -740,11 +741,12 @@ static int InitThread( input_thread_t * p_input ) ...@@ -740,11 +741,12 @@ static int InitThread( input_thread_t * p_input )
var_Get( p_input, "sub-autodetect-file", &val ); var_Get( p_input, "sub-autodetect-file", &val );
if( val.b_bool ) if( val.b_bool )
{ {
int i;
char **tmp = subtitles_Detect( p_input, "", p_input->psz_source ); char **tmp = subtitles_Detect( p_input, "", p_input->psz_source );
char **tmp2 = tmp; char **tmp2 = tmp;
while (*tmp2) for( i = 0; *tmp2 != NULL; i++ )
{ {
if( ( p_sub = subtitle_New( p_input, strdup(*tmp2++), i_microsecondperframe ) ) ) if( ( p_sub = subtitle_New( p_input, strdup(*tmp2++), i_microsecondperframe, i ) ) )
{ {
TAB_APPEND( p_input->p_sys->i_sub, p_input->p_sys->sub, p_sub ); TAB_APPEND( p_input->p_sys->i_sub, p_input->p_sys->sub, p_sub );
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* subtitles.c * subtitles.c
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: subtitles.c,v 1.3 2003/10/02 00:16:05 hartman Exp $ * $Id: subtitles.c,v 1.4 2003/10/11 22:40:05 hartman Exp $
* *
* Authors: Derk-Jan Hartman <hartman at videolan.org> * Authors: Derk-Jan Hartman <hartman at videolan.org>
* This is adapted code from the GPL'ed MPlayer (http://mplayerhq.hu) * This is adapted code from the GPL'ed MPlayer (http://mplayerhq.hu)
...@@ -49,17 +49,6 @@ ...@@ -49,17 +49,6 @@
*/ */
#define MAX_SUBTITLE_FILES 128 #define MAX_SUBTITLE_FILES 128
/**
* This determines how fuzzy the returned results will be.
*
* Currently set to 3, other options are:
* 0 = nothing
* 1 = any subtitle file
* 2 = any sub file containing movie name
* 3 = sub file matching movie name exactly
* 4 = sub file matching movie name with additional chars
*/
#define SUB_FUZZY 3
/** /**
* The possible extentions for subtitle files we support * The possible extentions for subtitle files we support
...@@ -173,6 +162,7 @@ char** subtitles_Detect( input_thread_t *p_this, char *psz_path, char *psz_fname ...@@ -173,6 +162,7 @@ char** subtitles_Detect( input_thread_t *p_this, char *psz_path, char *psz_fname
/* variables to be used for derivatives FILE *f */ /* variables to be used for derivatives FILE *f */
char *tmp_fname_noext, *tmp_fname_trim, *tmp_fname_ext, *tmpresult; char *tmp_fname_noext, *tmp_fname_trim, *tmp_fname_ext, *tmpresult;
vlc_value_t fuzzy;
int len, i, j, i_sub_count; int len, i, j, i_sub_count;
subfn *result; /* unsorted results */ subfn *result; /* unsorted results */
char **result2; /* sorted results */ char **result2; /* sorted results */
...@@ -217,7 +207,9 @@ char** subtitles_Detect( input_thread_t *p_this, char *psz_path, char *psz_fname ...@@ -217,7 +207,9 @@ char** subtitles_Detect( input_thread_t *p_this, char *psz_path, char *psz_fname
strcpy_strip_ext( f_fname_noext, f_fname ); strcpy_strip_ext( f_fname_noext, f_fname );
strcpy_trim( f_fname_trim, f_fname_noext ); strcpy_trim( f_fname_trim, f_fname_noext );
var_Get( p_this, "sub-autodetect-fuzzy", &fuzzy );
for( j = 0; j <= 1; j++) for( j = 0; j <= 1; j++)
{ {
d = opendir( j == 0 ? f_dir : psz_path ); d = opendir( j == 0 ? f_dir : psz_path );
...@@ -272,8 +264,8 @@ char** subtitles_Detect( input_thread_t *p_this, char *psz_path, char *psz_fname ...@@ -272,8 +264,8 @@ char** subtitles_Detect( input_thread_t *p_this, char *psz_path, char *psz_fname
/* doesn't contain the movie name */ /* doesn't contain the movie name */
if( j == 0 ) i_prio = 1; if( j == 0 ) i_prio = 1;
} }
if( i_prio >= SUB_FUZZY ) if( i_prio >= fuzzy.i_int )
{ {
sprintf( tmpresult, "%s%s", j == 0 ? f_dir : psz_path, de->d_name ); sprintf( tmpresult, "%s%s", j == 0 ? f_dir : psz_path, de->d_name );
msg_Dbg( p_this, "autodetected subtitle: %s with priority %d", de->d_name, i_prio ); msg_Dbg( p_this, "autodetected subtitle: %s with priority %d", de->d_name, i_prio );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* libvlc.h: main libvlc header * libvlc.h: main libvlc header
***************************************************************************** *****************************************************************************
* Copyright (C) 1998-2002 VideoLAN * Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.h,v 1.94 2003/10/08 19:40:42 gbazin Exp $ * $Id: libvlc.h,v 1.95 2003/10/11 22:40:05 hartman Exp $
* *
* Authors: Vincent Seguin <seguin@via.ecp.fr> * Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -149,7 +149,7 @@ static char *ppsz_language[] = { "auto", "en", "en_GB", "de", "fr", "it", "ja", ...@@ -149,7 +149,7 @@ static char *ppsz_language[] = { "auto", "en", "en_GB", "de", "fr", "it", "ja",
#define AUDIO_FILTER_TEXT N_("Audio filters") #define AUDIO_FILTER_TEXT N_("Audio filters")
#define AUDIO_FILTER_LONGTEXT N_( \ #define AUDIO_FILTER_LONGTEXT N_( \
"This allows you to add audio postprocessing filters, to modify" \ "This allows you to add audio postprocessing filters, to modify " \
"the sound.") "the sound.")
#define HEADPHONE_TEXT N_("Headphone virtual spatialization effect") #define HEADPHONE_TEXT N_("Headphone virtual spatialization effect")
...@@ -291,6 +291,16 @@ static char *ppsz_language[] = { "auto", "en", "en_GB", "de", "fr", "it", "ja", ...@@ -291,6 +291,16 @@ static char *ppsz_language[] = { "auto", "en", "en_GB", "de", "fr", "it", "ja",
"Automatically detect a subtitle file, if no subtitle filename is " \ "Automatically detect a subtitle file, if no subtitle filename is " \
"specified." "specified."
#define SUB_FUZZY_TEXT N_("Subtitle autodection fuzziness")
#define SUB_FUZZY_LONGTEXT \
"This determines how fuzzy subtitle and movie filenaming matching " \
"will be. Options are:\n" \
"0 = no subtitles autodetected\n" \
"1 = any subtitle file\n" \
"2 = any subtitle file containing the movie name\n" \
"3 = subtitle file matching the movie name with additional chars\n" \
"4 = subtitle file matching the movie name exactly"
#define SUB_FILE_TEXT N_("Use subtitle file") #define SUB_FILE_TEXT N_("Use subtitle file")
#define SUB_FILE_LONGTEXT \ #define SUB_FILE_LONGTEXT \
"Load this subtitle file. To be used when autodetect cannot detect " \ "Load this subtitle file. To be used when autodetect cannot detect " \
...@@ -637,6 +647,8 @@ vlc_module_begin(); ...@@ -637,6 +647,8 @@ vlc_module_begin();
INPUT_SUBT_TEXT, INPUT_SUBT_LONGTEXT, VLC_TRUE ); INPUT_SUBT_TEXT, INPUT_SUBT_LONGTEXT, VLC_TRUE );
add_bool( "sub-autodetect-file", VLC_TRUE, NULL, add_bool( "sub-autodetect-file", VLC_TRUE, NULL,
SUB_AUTO_TEXT, SUB_AUTO_LONGTEXT, VLC_FALSE ); SUB_AUTO_TEXT, SUB_AUTO_LONGTEXT, VLC_FALSE );
add_integer( "sub-autodetect-fuzzy", 3, NULL,
SUB_FUZZY_TEXT, SUB_FUZZY_LONGTEXT, VLC_TRUE );
add_file( "sub-file", NULL, NULL, add_file( "sub-file", NULL, NULL,
SUB_FILE_TEXT, SUB_FILE_LONGTEXT, VLC_TRUE ); SUB_FILE_TEXT, SUB_FILE_LONGTEXT, VLC_TRUE );
......
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