diff options
-rw-r--r-- | help/help_mp-cs.h | 2 | ||||
-rw-r--r-- | help/help_mp-de.h | 2 | ||||
-rw-r--r-- | help/help_mp-en.h | 2 | ||||
-rw-r--r-- | help/help_mp-es.h | 2 | ||||
-rw-r--r-- | help/help_mp-fr.h | 2 | ||||
-rw-r--r-- | help/help_mp-hu.h | 2 | ||||
-rw-r--r-- | help/help_mp-it.h | 2 | ||||
-rw-r--r-- | help/help_mp-ru.h | 2 | ||||
-rw-r--r-- | help/help_mp-tr.h | 2 | ||||
-rw-r--r-- | help/help_mp-zh_CN.h | 2 | ||||
-rw-r--r-- | help/help_mp-zh_TW.h | 2 | ||||
-rw-r--r-- | libass/ass_mp.c | 47 | ||||
-rw-r--r-- | libass/ass_mp.h | 1 | ||||
-rw-r--r-- | mplayer.c | 4 |
14 files changed, 61 insertions, 13 deletions
diff --git a/help/help_mp-cs.h b/help/help_mp-cs.h index aa39e02a47..586ad3396d 100644 --- a/help/help_mp-cs.h +++ b/help/help_mp-cs.h @@ -1713,7 +1713,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] chyba překódování souboru.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): fopen selhalo\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): fseek selhalo\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): Odmítám nahrát titulky delší než 10M\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): Odmítám nahrát titulky delší než 100M\n" #define MSGTR_LIBASS_ReadFailed "Čtení selhalo, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Přidán soubos s titulky: <memory> (%d stylů, %d událostí)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Přidán soubos s titulky: %s (%d stylů, %d událostí)\n" diff --git a/help/help_mp-de.h b/help/help_mp-de.h index 48b2e9976a..a1acc609b2 100644 --- a/help/help_mp-de.h +++ b/help/help_mp-de.h @@ -2042,7 +2042,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] Fehler bei Recodierung der Datei.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): fopen fehlgeschlagen\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): fseek fehlgeschlagen\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): Laden von Untertiteln größer als 10M verweigert.\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): Laden von Untertiteln größer als 100M verweigert.\n" #define MSGTR_LIBASS_ReadFailed "Lesen fehlgeschlagen, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Hinzugefügte Untertiteldatei: <Speicher> (%d Styles, %d Ereignisse)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Hinzugefügte Untertiteldatei: %s (%d Styles, %d Ereignisse)\n" diff --git a/help/help_mp-en.h b/help/help_mp-en.h index 5d9413fa33..05485c7aec 100644 --- a/help/help_mp-en.h +++ b/help/help_mp-en.h @@ -1719,7 +1719,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] error recoding file.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): fopen failed\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): fseek failed\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): Refusing to load subtitles larger than 10M\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): Refusing to load subtitles larger than 100M\n" #define MSGTR_LIBASS_ReadFailed "Read failed, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Added subtitle file: <memory> (%d styles, %d events)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Added subtitle file: %s (%d styles, %d events)\n" diff --git a/help/help_mp-es.h b/help/help_mp-es.h index 7cad6e12bd..3b47b5d6a9 100644 --- a/help/help_mp-es.h +++ b/help/help_mp-es.h @@ -2080,7 +2080,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] error recodificando el fichero.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): fopen ha fallado\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): fseek ha fallado\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): No se pueden cargar ficheros de subtítulos mayores de 10M\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): No se pueden cargar ficheros de subtítulos mayores de 100M\n" #define MSGTR_LIBASS_ReadFailed "La lectura ha fallado, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Añadido fichero de subtítulos: <memoria> (%d estilos, %d eventos)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Añadido fichero de subtítulos: %s (%d estilos, %d eventos)\n" diff --git a/help/help_mp-fr.h b/help/help_mp-fr.h index a3baeffd52..ba12805ecd 100644 --- a/help/help_mp-fr.h +++ b/help/help_mp-fr.h @@ -2008,7 +2008,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] erreur lors de l'enregistrement du fichier.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s) : fopen a échoué\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s) : fseek à échoué\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s) : Chargement des fichiers plus grands que 10Mo refusé\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s) : Chargement des fichiers plus grands que 100Mo refusé\n" #define MSGTR_LIBASS_ReadFailed "Lecture impossible, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Ajout d'un fichier de sous-titres : <memory> (%d styles, %d évènements)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Ajout d'un fichier de sous-titres : %s (%d styles, %d events)\n" diff --git a/help/help_mp-hu.h b/help/help_mp-hu.h index 89112b9751..4d7a496a89 100644 --- a/help/help_mp-hu.h +++ b/help/help_mp-hu.h @@ -1718,7 +1718,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] hiba a fájl rögzítésekor.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): fopen sikertelen\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): fseek sikertelen\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): 10M-nél nagyobb felirat fájl betöltése visszautasítva\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): 100M-nél nagyobb felirat fájl betöltése visszautasítva\n" #define MSGTR_LIBASS_ReadFailed "Olvasás sikertelen, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Felirat fájl hozzáadása: <memória> (%d stílus, %d esemény)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Felirat fájl hozzáadása: %s (%d stílus, %d esemény)\n" diff --git a/help/help_mp-it.h b/help/help_mp-it.h index ab33704006..5ecfab9c0a 100644 --- a/help/help_mp-it.h +++ b/help/help_mp-it.h @@ -1713,7 +1713,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] errore ricodificando il file.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): fopen fallita\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): fseek fallita\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): Mi rifiuto di caricare sottotitoli più grandi di 10M\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): Mi rifiuto di caricare sottotitoli più grandi di 100M\n" #define MSGTR_LIBASS_ReadFailed "Lettura fallita, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Aggiunto file sottotitoli: <memoria> (%d stili, %d eventi)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Added subtitle file: %s (%d stili, %d eventi)\n" diff --git a/help/help_mp-ru.h b/help/help_mp-ru.h index 7195615efd..1c0d5dfc24 100644 --- a/help/help_mp-ru.h +++ b/help/help_mp-ru.h @@ -1753,7 +1753,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] ошибка записи файла.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): сбой fopen\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): сбой fseek\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): Отклонение загрузки субтитров больше 10M\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): Отклонение загрузки субтитров больше 100M\n" #define MSGTR_LIBASS_ReadFailed "Ошибка чтения, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Добавлен файл субтитров: <память> (стилей: %d, событий: %d)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Добавлен файл субтитров: %s (стилей: %d, событий: %d)\n" diff --git a/help/help_mp-tr.h b/help/help_mp-tr.h index 36c8497af3..973195d5be 100644 --- a/help/help_mp-tr.h +++ b/help/help_mp-tr.h @@ -2017,7 +2017,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] Dosyayı tekrar kodlamada hata.\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): fopen başarısız\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): fseek başarısız\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): 10 megabayttan büyük altyazıları yüklemeyi reddediyor\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): 100 megabayttan büyük altyazıları yüklemeyi reddediyor\n" #define MSGTR_LIBASS_ReadFailed "Okuma başarısız, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] Altyazı dosyasını ekledi: <bellek> (%d tarz, %d olay)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] Altyazı dosyasını ekledi: %s (%d tarz, %d olay)\n" diff --git a/help/help_mp-zh_CN.h b/help/help_mp-zh_CN.h index 9e0f2809b7..107a5b704e 100644 --- a/help/help_mp-zh_CN.h +++ b/help/help_mp-zh_CN.h @@ -1701,7 +1701,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] 记录到文件出错。\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): 文件打开(fopen)失败\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): 文件定位(fseek)失败\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): 拒绝装入大于10M的字幕\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): 拒绝装入大于100M的字幕\n" #define MSGTR_LIBASS_ReadFailed "读失败, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] 已加入字幕文件: <内存> (%d styles, %d events)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] 已加入字幕文件: %s (%d styles, %d events)\n" diff --git a/help/help_mp-zh_TW.h b/help/help_mp-zh_TW.h index 3ea2e45326..5981fd0a50 100644 --- a/help/help_mp-zh_TW.h +++ b/help/help_mp-zh_TW.h @@ -1968,7 +1968,7 @@ static const char help_text[]= #define MSGTR_LIBASS_ErrorRecodingFile "[ass] 記録到文件出錯。\n" #define MSGTR_LIBASS_FopenFailed "[ass] ass_read_file(%s): 文件打開(fopen)失敗\n" #define MSGTR_LIBASS_FseekFailed "[ass] ass_read_file(%s): 文件定位(fseek)失敗\n" -#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan10M "[ass] ass_read_file(%s): 拒絶裝入大于10M的字幕\n" +#define MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M "[ass] ass_read_file(%s): 拒絶裝入大于100M的字幕\n" #define MSGTR_LIBASS_ReadFailed "讀失敗, %d: %s\n" #define MSGTR_LIBASS_AddedSubtitleFileMemory "[ass] 已加入字幕文件: <内存> (%d styles, %d events)\n" #define MSGTR_LIBASS_AddedSubtitleFileFname "[ass] 已加入字幕文件: %s (%d styles, %d events)\n" diff --git a/libass/ass_mp.c b/libass/ass_mp.c index b5f55cc29a..77d1538aa9 100644 --- a/libass/ass_mp.c +++ b/libass/ass_mp.c @@ -28,6 +28,8 @@ #include "get_path.h" #include "ass_mp.h" +#include "help_mp.h" +#include "stream/stream.h" #ifdef CONFIG_FONTCONFIG #include <fontconfig/fontconfig.h> @@ -216,6 +218,51 @@ ass_track_t* ass_read_subdata(ass_library_t* library, sub_data* subdata, double return track; } +ass_track_t* ass_read_stream(ass_library_t* library, char *fname, char *charset) { + int i; + char *buf = NULL; + ass_track_t *track; + size_t sz = 0; + size_t buf_alloc = 0; + stream_t *fd; + + fd = open_stream(fname, NULL, &i); + if (!fd) { + mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_FopenFailed, fname); + return NULL; + } + if (fd->end_pos > STREAM_BUFFER_SIZE) + /* read entire file if size is known */ + buf_alloc = fd->end_pos; + for (;;) { + if (buf_alloc >= 100*1024*1024) { + mp_msg(MSGT_ASS, MSGL_INFO, MSGTR_LIBASS_RefusingToLoadSubtitlesLargerThan100M, fname); + sz = 0; + break; + } + if (buf_alloc < sz + STREAM_BUFFER_SIZE) + buf_alloc += STREAM_BUFFER_SIZE; + buf = realloc(buf, buf_alloc + 1); + i = stream_read(fd, buf + sz, buf_alloc - sz); + if (i <= 0) break; + sz += i; + } + free_stream(fd); + if (!sz) { + free(buf); + return NULL; + } + buf[sz] = 0; + buf = realloc(buf, sz + 1); + track = ass_read_memory(library, buf, sz, charset); + if (track) { + free(track->name); + track->name = strdup(fname); + } + free(buf); + return track; +} + void ass_configure(ass_renderer_t* priv, int w, int h, int unscaled) { int hinting; ass_set_frame_size(priv, w, h); diff --git a/libass/ass_mp.h b/libass/ass_mp.h index 1584145d1c..5d81b55e4f 100644 --- a/libass/ass_mp.h +++ b/libass/ass_mp.h @@ -59,6 +59,7 @@ extern int ass_hinting; ass_track_t* ass_default_track(ass_library_t* library); int ass_process_subtitle(ass_track_t* track, subtitle* sub); ass_track_t* ass_read_subdata(ass_library_t* library, sub_data* subdata, double fps); +ass_track_t* ass_read_stream(ass_library_t* library, char *fname, char *charset); void ass_configure(ass_renderer_t* priv, int w, int h, int hinting); void ass_configure_fonts(ass_renderer_t* priv); @@ -1082,9 +1082,9 @@ void add_subtitles(char *filename, float fps, int noerr) #ifdef CONFIG_ASS if (ass_enabled) #ifdef CONFIG_ICONV - asst = ass_read_file(ass_library, filename, sub_cp); + asst = ass_read_stream(ass_library, filename, sub_cp); #else - asst = ass_read_file(ass_library, filename, 0); + asst = ass_read_stream(ass_library, filename, 0); #endif if (ass_enabled && subd && !asst) asst = ass_read_subdata(ass_library, subd, fps); |