Commit 503bdd97 authored by Derk-Jan Hartman's avatar Derk-Jan Hartman

* modules/demux/util/sub.c: fixed the subtitle autodetection.

* modules/demux/mkv.cpp: set UTF-8 for matroska subtitles.
parent 25763b6a
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* mkv.cpp : matroska demuxer * mkv.cpp : matroska demuxer
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: mkv.cpp,v 1.24 2003/08/26 18:11:02 fenrir Exp $ * $Id: mkv.cpp,v 1.25 2003/08/26 19:43:51 hartman Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -1048,6 +1048,15 @@ static int Open( vlc_object_t * p_this ) ...@@ -1048,6 +1048,15 @@ static int Open( vlc_object_t * p_this )
i_track + 1, i_track + 1,
tk.i_cat, tk.i_cat,
tk.psz_language, 0 ); tk.psz_language, 0 );
if( tk.i_cat == SPU_ES )
{
vlc_value_t val;
val.psz_string = "UTF-8";
#if defined(HAVE_ICONV)
var_Create( p_input, "subsdec-encoding", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
#endif
var_Set( p_input, "subsdec-encoding", val );
}
if( !strcmp( tk.psz_codec, "V_MS/VFW/FOURCC" ) ) if( !strcmp( tk.psz_codec, "V_MS/VFW/FOURCC" ) )
{ {
if( tk.i_extra_data < (int)sizeof( BITMAPINFOHEADER ) ) if( tk.i_extra_data < (int)sizeof( BITMAPINFOHEADER ) )
......
...@@ -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.24 2003/08/24 14:43:07 titer Exp $ * $Id: sub.c,v 1.25 2003/08/26 19:43:51 hartman Exp $
* *
* Authors: Laurent Aimar <fenrir@via.ecp.fr> * Authors: Laurent Aimar <fenrir@via.ecp.fr>
* *
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
...@@ -246,7 +245,7 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -246,7 +245,7 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
char *psz_result, *psz_basename, *psz_dir = NULL; char *psz_result, *psz_basename, *psz_dir = NULL;
char *psz_file_noext, *psz_extension; char *psz_file_noext, *psz_extension;
int i; int i;
size_t i_dirlen = 0; size_t i_dirlen, i_baselen = 0;
if( psz_filename && *psz_filename ) if( psz_filename && *psz_filename )
{ {
...@@ -277,7 +276,7 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -277,7 +276,7 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
if( psz_extension ) if( psz_extension )
{ {
size_t i_baselen = ( 1 + psz_extension ) - psz_basename; i_baselen = ( 1 + psz_extension ) - psz_basename;
psz_file_noext = (char*)malloc( i_baselen + 1 ); psz_file_noext = (char*)malloc( i_baselen + 1 );
if( !psz_file_noext ) if( !psz_file_noext )
...@@ -292,13 +291,13 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -292,13 +291,13 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
p_dir_handle = opendir( psz_dir ? psz_dir : "" ); p_dir_handle = opendir( psz_dir ? psz_dir : "" );
if( p_dir_handle ) { if( p_dir_handle ) {
int i_found = 0;
while(( p_dir_afile = readdir( p_dir_handle ))) { while(( p_dir_afile = readdir( p_dir_handle ))) {
char* psz_afile_ext = strrchr( p_dir_afile->d_name, '.' ); char* psz_afile_ext = strrchr( p_dir_afile->d_name, '.' );
if( psz_afile_ext ) if( psz_afile_ext )
{ {
int i_found = 0;
++psz_afile_ext; ++psz_afile_ext;
for (i = 0; ppsz_sub_exts[i]; i++) { for (i = 0; ppsz_sub_exts[i]; i++) {
if( strcmp( ppsz_sub_exts[i], psz_afile_ext ) == 0 ) { if( strcmp( ppsz_sub_exts[i], psz_afile_ext ) == 0 ) {
...@@ -306,8 +305,11 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -306,8 +305,11 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
break; break;
} }
} }
if( i_found ) if( i_found ) /* found a file with a subtitle extension */
{
if( strncmp( p_dir_afile->d_name, psz_file_noext, (strlen( p_dir_afile->d_name ) - strlen( psz_afile_ext) ) ) == 0 )
{ {
/* perfect match */
msg_Dbg( p_sub, "autodetected subtitlefile: %s", strdup( p_dir_afile->d_name ) ); msg_Dbg( p_sub, "autodetected subtitlefile: %s", strdup( p_dir_afile->d_name ) );
if( psz_dir ) if( psz_dir )
{ {
...@@ -323,6 +325,7 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename) ...@@ -323,6 +325,7 @@ char* sub_detect( subtitle_demux_t *p_sub, char *psz_filename)
} }
} }
} }
}
closedir( p_dir_handle ); closedir( p_dir_handle );
} }
} }
......
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