Commit 7c64ed16 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* modules/misc/freetype.c: spelling errors

* src/libvlc.h: spelling error
* include/ninput.h: There should not yet be a Subtitles section in Doxygen
* src/input/subtitles.c: Doxygen comments for this file
parent b8b1c4e9
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ninput.h * ninput.h
***************************************************************************** *****************************************************************************
* Copyright (C) 1999-2001 VideoLAN * Copyright (C) 1999-2001 VideoLAN
* $Id: ninput.h,v 1.12 2003/09/22 03:40:06 hartman Exp $ * $Id: ninput.h,v 1.13 2003/10/01 22:44:58 hartman Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -226,16 +226,6 @@ VLC_EXPORT( int, demux_Control, ( input_thread_t *, int i_qu ...@@ -226,16 +226,6 @@ VLC_EXPORT( int, demux_Control, ( input_thread_t *, int i_qu
VLC_EXPORT( int, demux_vaControlDefault, ( input_thread_t *, int i_query, va_list ) ); VLC_EXPORT( int, demux_vaControlDefault, ( input_thread_t *, int i_query, va_list ) );
/**
* @}
*/
/**
* \defgroup subtitles Subtitles
* @{
*/
/* Subtitles */ /* Subtitles */
VLC_EXPORT( char **, subtitles_Detect, ( input_thread_t *, char* path, char *fname ) ); VLC_EXPORT( char **, subtitles_Detect, ( input_thread_t *, char* path, char *fname ) );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* freetype.c : Put text on the video, using freetype2 * freetype.c : Put text on the video, using freetype2
***************************************************************************** *****************************************************************************
* Copyright (C) 2002, 2003 VideoLAN * Copyright (C) 2002, 2003 VideoLAN
* $Id: freetype.c,v 1.23 2003/09/30 16:41:13 hartman Exp $ * $Id: freetype.c,v 1.24 2003/10/01 22:44:58 hartman Exp $
* *
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> * Authors: Sigmund Augdal <sigmunau@idi.ntnu.no>
* *
...@@ -90,7 +90,7 @@ vlc_module_begin(); ...@@ -90,7 +90,7 @@ vlc_module_begin();
vlc_module_end(); vlc_module_end();
/** /**
* Private data in a aubpicture. Describes a string. * Private data in a subpicture. Describes a string.
*/ */
struct subpicture_sys_t struct subpicture_sys_t
{ {
...@@ -116,7 +116,7 @@ struct line_desc_t ...@@ -116,7 +116,7 @@ struct line_desc_t
}; };
/***************************************************************************** /*****************************************************************************
* text_remderer_sys_t: freetype local data * text_renderer_sys_t: freetype local data
***************************************************************************** *****************************************************************************
* This structure is part of the video output thread descriptor. * This structure is part of the video output thread descriptor.
* It describes the freetype specific properties of an output thread. * It describes the freetype specific properties of an output thread.
......
...@@ -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.1 2003/09/22 03:40:06 hartman Exp $ * $Id: subtitles.c,v 1.2 2003/10/01 22:44:58 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)
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/ *****************************************************************************/
/**
* \file
* This file contains functions to dectect subtitle files.
*/
#include <stdlib.h> #include <stdlib.h>
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/input.h> #include <vlc/input.h>
...@@ -30,14 +35,38 @@ ...@@ -30,14 +35,38 @@
#include <dirent.h> #include <dirent.h>
#include <ctype.h> #include <ctype.h>
/**
* What's between a directory and a filename?
*/
#if defined( WIN32 ) #if defined( WIN32 )
#define DIRECTORY_SEPARATOR '\\' #define DIRECTORY_SEPARATOR '\\'
#else #else
#define DIRECTORY_SEPARATOR '/' #define DIRECTORY_SEPARATOR '/'
#endif #endif
/**
* We are not going to autodetect more subtitle files than this.
*/
#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
*/
static const char * sub_exts[] = { "utf", "utf8", "utf-8", "sub", "srt", "smi", "txt", "ssa", NULL};
/* extensions from unsupported types */
/* rt, aqt, jss, js, ass */
static void strcpy_trim( char *d, char *s ) static void strcpy_trim( char *d, char *s )
{ {
...@@ -122,17 +151,30 @@ static int compare_sub_priority( const void *a, const void *b ) ...@@ -122,17 +151,30 @@ static int compare_sub_priority( const void *a, const void *b )
} }
} }
/***************************************************************************** /**
* subtitles_Detect: Use the original filename to find a subtitle files. * Detect subtitle files.
*****************************************************************************/ *
char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fname ) * When called this function will split up the psz_fname string into a
* directory, filename and extension. It then opens the directory
* in which the file resides and tries to find possible matches of
* subtitles files.
*
* \brief Use a filename to find subtitle files.
* \ingroup Demux
* \param p_this the calling \ref input_thread_t
* \param psz_path a subdirectory to look into. This is not used atm.
* \param psz_fname the complete filename to base the search on.
* \return an array of filenames with detected possbile subtitles. You
* need to free this after use.
*/
char** subtitles_Detect( input_thread_t *p_this, char *psz_path, char *psz_fname )
{ {
/* variables to be used for derivatives of psz_fname */ /* variables to be used for derivatives of psz_fname */
char *f_dir, *f_fname, *f_fname_noext, *f_fname_trim, *tmp; char *f_dir, *f_fname, *f_fname_noext, *f_fname_trim, *tmp;
/* 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;
int len, i, j, i_sub_count, i_sub_match_fuzziness; int len, i, j, i_sub_count;
subfn *result; /* unsorted results */ subfn *result; /* unsorted results */
char **result2; /* sorted results */ char **result2; /* sorted results */
...@@ -140,10 +182,6 @@ char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fnam ...@@ -140,10 +182,6 @@ char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fnam
DIR *d; DIR *d;
struct dirent *de; struct dirent *de;
char * sub_exts[] = { "utf", "utf8", "utf-8", "sub", "srt", "smi", "txt", "ssa", NULL};
/* extensions from unsupported types */
/* rt, aqt, jss, js, ass */
i_sub_count = 0; i_sub_count = 0;
len = ( strlen( psz_fname ) > 256 ? strlen( psz_fname ) : 256 ) + len = ( strlen( psz_fname ) > 256 ? strlen( psz_fname ) : 256 ) +
( strlen( psz_path ) > 256 ? strlen( psz_path ) : 256 ) + 2; ( strlen( psz_path ) > 256 ? strlen( psz_path ) : 256 ) + 2;
...@@ -181,20 +219,13 @@ char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fnam ...@@ -181,20 +219,13 @@ char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fnam
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 );
i_sub_match_fuzziness = 3;
/* 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
*/
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 );
if( d ) if( d )
{ {
int b_found; int b_found;
while( de = readdir( d ) ) while( ( de = readdir( d ) ) )
{ {
/* retrieve various parts of the filename */ /* retrieve various parts of the filename */
strcpy_strip_ext( tmp_fname_noext, de->d_name ); strcpy_strip_ext( tmp_fname_noext, de->d_name );
...@@ -208,7 +239,7 @@ char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fnam ...@@ -208,7 +239,7 @@ char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fnam
if( strcmp(sub_exts[i], tmp_fname_ext ) == 0 ) if( strcmp(sub_exts[i], tmp_fname_ext ) == 0 )
{ {
b_found = 1; b_found = 1;
msg_Dbg( p_input, "found subtitle: %s", de->d_name ); msg_Dbg( p_this, "found a possible subtitle: %s", de->d_name );
break; break;
} }
} }
...@@ -243,11 +274,11 @@ char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fnam ...@@ -243,11 +274,11 @@ char** subtitles_Detect( input_thread_t *p_input, char *psz_path, char *psz_fnam
if( j == 0 ) i_prio = 1; if( j == 0 ) i_prio = 1;
} }
if( i_prio >= i_sub_match_fuzziness ) if( i_prio >= SUB_FUZZY )
{ {
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_input, "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 );
if( f = fopen( tmpresult, "rt" ) ) if( ( f = fopen( tmpresult, "rt" ) ) )
{ {
fclose( f ); fclose( f );
result[i_sub_count].priority = i_prio; result[i_sub_count].priority = 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.90 2003/09/29 17:36:35 gbazin Exp $ * $Id: libvlc.h,v 1.91 2003/10/01 22:44:58 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>
...@@ -286,8 +286,8 @@ static char *ppsz_language[] = { "auto", "en", "en_GB", "de", "fr", "it", "ja", ...@@ -286,8 +286,8 @@ static char *ppsz_language[] = { "auto", "en", "en_GB", "de", "fr", "it", "ja",
#define SUB_AUTO_TEXT N_("Autodetect subtitle files") #define SUB_AUTO_TEXT N_("Autodetect subtitle files")
#define SUB_AUTO_LONGTEXT \ #define SUB_AUTO_LONGTEXT \
"Automatically detect a subtitle file, if no subtitle filename is" \ "Automatically detect a subtitle file, if no subtitle filename is " \
"is specified." "specified."
#define SUB_FILE_TEXT N_("Use subtitle file") #define SUB_FILE_TEXT N_("Use subtitle file")
#define SUB_FILE_LONGTEXT \ #define SUB_FILE_LONGTEXT \
......
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