[MPlayer-cvslog] r23442 - in trunk/libass: ass.c ass.h

eugeni subversion at mplayerhq.hu
Fri Jun 1 21:56:45 CEST 2007


Author: eugeni
Date: Fri Jun  1 21:56:44 2007
New Revision: 23442

Log:
Move code for reading a file and recoding it to utf-8 to a separate function.


Modified:
   trunk/libass/ass.c
   trunk/libass/ass.h

Modified: trunk/libass/ass.c
==============================================================================
--- trunk/libass/ass.c	(original)
+++ trunk/libass/ass.c	Fri Jun  1 21:56:44 2007
@@ -982,17 +982,9 @@ ass_track_t* ass_read_memory(ass_library
 	return track;
 }
 
-/**
- * \brief Read subtitles from file.
- * \param library libass library object
- * \param fname file name
- * \param codepage recode buffer contents from given codepage
- * \return newly allocated track
-*/ 
-ass_track_t* ass_read_file(ass_library_t* library, char* fname, char* codepage)
+char* read_file_recode(char* fname, char* codepage, int* size)
 {
 	char* buf;
-	ass_track_t* track;
 	size_t bufsize;
 	
 	buf = read_file(fname, &bufsize);
@@ -1007,6 +999,26 @@ ass_track_t* ass_read_file(ass_library_t
 	if (!buf)
 		return 0;
 #endif
+	*size = bufsize;
+	return buf;
+}
+
+/**
+ * \brief Read subtitles from file.
+ * \param library libass library object
+ * \param fname file name
+ * \param codepage recode buffer contents from given codepage
+ * \return newly allocated track
+*/ 
+ass_track_t* ass_read_file(ass_library_t* library, char* fname, char* codepage)
+{
+	char* buf;
+	ass_track_t* track;
+	size_t bufsize;
+
+	buf = read_file_recode(fname, codepage, &bufsize);
+	if (!buf)
+		return 0;
 	track = parse_memory(library, buf);
 	free(buf);
 	if (!track)

Modified: trunk/libass/ass.h
==============================================================================
--- trunk/libass/ass.h	(original)
+++ trunk/libass/ass.h	Fri Jun  1 21:56:44 2007
@@ -162,6 +162,8 @@ void ass_process_codec_private(ass_track
 */
 void ass_process_chunk(ass_track_t* track, char *data, int size, long long timecode, long long duration);
 
+char* read_file_recode(char* fname, char* codepage, int* size);
+
 /**
  * \brief Read subtitles from file.
  * \param fname file name



More information about the MPlayer-cvslog mailing list