[MPlayer-cvslog] r18941 - in trunk: subreader.c subreader.h
eugeni
subversion at mplayerhq.hu
Fri Jul 7 20:07:44 CEST 2006
Author: eugeni
Date: Fri Jul 7 20:07:39 2006
New Revision: 18941
Modified:
trunk/subreader.c
trunk/subreader.h
Log:
Split guess_cp() in two functions:
- guess_buffer_cp() determines the encoding of text, given a pointer to a
buffer and its length;
- guess_cp() reads some data from stream and calls guess_buffer_cp()
Modified: trunk/subreader.c
==============================================================================
--- trunk/subreader.c (original)
+++ trunk/subreader.c Fri Jul 7 20:07:39 2006
@@ -1303,20 +1303,15 @@
};
#ifdef HAVE_ENCA
-#define MAX_GUESS_BUFFER_SIZE (256*1024)
-void* guess_cp(stream_t *st, char *preferred_language, char *fallback)
+void* guess_buffer_cp(unsigned char* buffer, int buflen, char *preferred_language, char *fallback)
{
const char **languages;
- size_t langcnt, buflen;
+ size_t langcnt;
EncaAnalyser analyser;
EncaEncoding encoding;
- unsigned char *buffer;
char *detected_sub_cp = NULL;
int i;
- buffer = malloc(MAX_GUESS_BUFFER_SIZE);
- buflen = stream_read(st,buffer, MAX_GUESS_BUFFER_SIZE);
-
languages = enca_get_languages(&langcnt);
mp_msg(MSGT_SUBREADER, MSGL_V, "ENCA supported languages: ");
for (i = 0; i < langcnt; i++) {
@@ -1339,9 +1334,6 @@
}
free(languages);
- free(buffer);
- stream_reset(st);
- stream_seek(st,0);
if (!detected_sub_cp) {
detected_sub_cp = strdup(fallback);
@@ -1350,6 +1342,26 @@
return detected_sub_cp;
}
+
+#define MAX_GUESS_BUFFER_SIZE (256*1024)
+void* guess_cp(stream_t *st, char *preferred_language, char *fallback)
+{
+ size_t buflen;
+ unsigned char *buffer;
+ char *detected_sub_cp = NULL;
+
+ buffer = malloc(MAX_GUESS_BUFFER_SIZE);
+ buflen = stream_read(st,buffer, MAX_GUESS_BUFFER_SIZE);
+
+ detected_sub_cp = guess_buffer_cp(buffer, buflen, preferred_language, fallback);
+
+ free(buffer);
+ stream_reset(st);
+ stream_seek(st,0);
+
+ return detected_sub_cp;
+}
+#undef MAX_GUESS_BUFFER_SIZE
#endif
sub_data* sub_read_file (char *filename, float fps) {
Modified: trunk/subreader.h
==============================================================================
--- trunk/subreader.h (original)
+++ trunk/subreader.h Fri Jul 7 20:07:39 2006
@@ -73,6 +73,7 @@
void subcp_open (struct stream_st *st); /* for demux_ogg.c */
void subcp_close (void); /* for demux_ogg.c */
#ifdef HAVE_ENCA
+void* guess_buffer_cp(unsigned char* buffer, int buflen, char *preferred_language, char *fallback);
void* guess_cp(struct stream_st *st, char *preferred_language, char *fallback);
#endif
char ** sub_filenames(char *path, char *fname);
More information about the MPlayer-cvslog
mailing list