[MPlayer-cvslog] r30515 - in trunk: help/help_mp-cs.h help/help_mp-de.h help/help_mp-en.h help/help_mp-es.h help/help_mp-fr.h help/help_mp-hu.h help/help_mp-it.h help/help_mp-ru.h help/help_mp-tr.h help/help_mp-zh_...
reimar
subversion at mplayerhq.hu
Fri Feb 5 18:13:48 CET 2010
Author: reimar
Date: Fri Feb 5 18:13:47 2010
New Revision: 30515
Log:
Add support for loading ASS subtitles through the stream layer and thus e.g.
from some network location.
Patch by Yuriy Kaminskiy [yumkam mail ru]
Modified:
trunk/libass/ass_mp.c
trunk/libass/ass_mp.h
trunk/mplayer.c
Changes in other areas also in this revision:
Modified:
trunk/help/help_mp-cs.h
trunk/help/help_mp-de.h
trunk/help/help_mp-en.h
trunk/help/help_mp-es.h
trunk/help/help_mp-fr.h
trunk/help/help_mp-hu.h
trunk/help/help_mp-it.h
trunk/help/help_mp-ru.h
trunk/help/help_mp-tr.h
trunk/help/help_mp-zh_CN.h
trunk/help/help_mp-zh_TW.h
Modified: trunk/libass/ass_mp.c
==============================================================================
--- trunk/libass/ass_mp.c Fri Feb 5 17:42:13 2010 (r30514)
+++ trunk/libass/ass_mp.c Fri Feb 5 18:13:47 2010 (r30515)
@@ -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_librar
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);
Modified: trunk/libass/ass_mp.h
==============================================================================
--- trunk/libass/ass_mp.h Fri Feb 5 17:42:13 2010 (r30514)
+++ trunk/libass/ass_mp.h Fri Feb 5 18:13:47 2010 (r30515)
@@ -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);
Modified: trunk/mplayer.c
==============================================================================
--- trunk/mplayer.c Fri Feb 5 17:42:13 2010 (r30514)
+++ trunk/mplayer.c Fri Feb 5 18:13:47 2010 (r30515)
@@ -1082,9 +1082,9 @@ void add_subtitles(char *filename, float
#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);
More information about the MPlayer-cvslog
mailing list