libspark/libeplayer: rudimentary subtitle support, probably unstable

This commit is contained in:
martii
2012-11-04 15:39:48 +01:00
committed by Stefan Seyfried
parent 1cc9619c49
commit f0446eeeb2
3 changed files with 50 additions and 0 deletions

View File

@@ -76,7 +76,11 @@ if (debug_level >= level) printf("[%s:%s] " fmt, FILENAME, __FUNCTION__, ## x);
#define ASS_RING_SIZE 5 #define ASS_RING_SIZE 5
#ifdef MARTII
#define ASS_FONT "/share/fonts/neutrino.ttf"
#else
#define ASS_FONT "/usr/share/fonts/FreeSans.ttf" #define ASS_FONT "/usr/share/fonts/FreeSans.ttf"
#endif
/* ***************************** */ /* ***************************** */
/* Types */ /* Types */
@@ -383,14 +387,22 @@ static void ASSThread(Context_t *context) {
continue; continue;
} }
#ifndef MARTII
getMutex(__LINE__); getMutex(__LINE__);
#endif
//FIXME: durch den sleep bleibt die cpu usage zw. 5 und 13%, ohne //FIXME: durch den sleep bleibt die cpu usage zw. 5 und 13%, ohne
// steigt sie bei Verwendung von subtiteln bis auf 95%. // steigt sie bei Verwendung von subtiteln bis auf 95%.
// ich hoffe dadurch gehen keine subtitle verloren, wenn die playPts // ich hoffe dadurch gehen keine subtitle verloren, wenn die playPts
// durch den sleep verschlafen wird. Besser w<>re es den n<>chsten // durch den sleep verschlafen wird. Besser w<>re es den n<>chsten
// subtitel zeitpunkt zu bestimmen und solange zu schlafen. // subtitel zeitpunkt zu bestimmen und solange zu schlafen.
#ifdef MARTII
usleep(10000);
getMutex(__LINE__);
checkRegions();
#else
usleep(1000); usleep(1000);
#endif
if(ass_renderer && ass_track) if(ass_renderer && ass_track)
img = ass_render_frame(ass_renderer, ass_track, playPts / 90.0, &change); img = ass_render_frame(ass_renderer, ass_track, playPts / 90.0, &change);
@@ -415,7 +427,11 @@ static void ASSThread(Context_t *context) {
if (ass_track && ass_track->events) if (ass_track && ass_track->events)
{ {
#ifdef MARTII
undisplay = now + (ass_track->events->Duration + 500) / 90000;
#else
undisplay = now + ass_track->events->Duration / 1000 + 0.5; undisplay = now + ass_track->events->Duration / 1000 + 0.5;
#endif
} }
ass_printf(100, "w %d h %d s %d x %d y %d c %d chg %d now %ld und %ld\n", ass_printf(100, "w %d h %d s %d x %d y %d c %d chg %d now %ld und %ld\n",
@@ -532,12 +548,21 @@ static void ASSThread(Context_t *context) {
} }
/* cleanup no longer used but not overwritten regions */ /* cleanup no longer used but not overwritten regions */
#ifdef MARTII
getMutex(__LINE__);
#endif
checkRegions(); checkRegions();
#ifdef MARTII
releaseMutex(__LINE__);
#endif
} /* while */ } /* while */
hasPlayThreadStarted = 0; hasPlayThreadStarted = 0;
ass_printf(10, "terminating\n"); ass_printf(10, "terminating\n");
#ifdef MARTII
pthread_exit(NULL);
#endif
} }
/* **************************** */ /* **************************** */
@@ -615,10 +640,18 @@ int container_ass_init(Context_t *context)
} }
ass_set_use_margins(ass_renderer, 0 ); ass_set_use_margins(ass_renderer, 0 );
#ifdef MARTII
ass_set_font_scale(ass_renderer, (ass_font_scale * screen_height) / 240.0);
#else
ass_set_font_scale(ass_renderer, ass_font_scale); ass_set_font_scale(ass_renderer, ass_font_scale);
#endif
ass_set_hinting(ass_renderer, ASS_HINTING_LIGHT); ass_set_hinting(ass_renderer, ASS_HINTING_LIGHT);
#ifdef MARTII
ass_set_line_spacing(ass_renderer, (ass_line_spacing * screen_height) / 240.0);
#else
ass_set_line_spacing(ass_renderer, ass_line_spacing); ass_set_line_spacing(ass_renderer, ass_line_spacing);
#endif
ass_set_fonts(ass_renderer, ASS_FONT, "Arial", 0, NULL, 1); ass_set_fonts(ass_renderer, ASS_FONT, "Arial", 0, NULL, 1);
if(threeDMode == 0){ if(threeDMode == 0){
@@ -657,6 +690,10 @@ int container_ass_process_data(Context_t *context, SubtitleData_t* data)
ass_err("error creating ass_track\n"); ass_err("error creating ass_track\n");
return cERR_CONTAINER_ASS_ERROR; return cERR_CONTAINER_ASS_ERROR;
} }
#ifdef MARTII
ass_track->PlayResX = screen_width;
ass_track->PlayResY = screen_height;
#endif
} }
if ((data->extradata) && (first_kiss)) if ((data->extradata) && (first_kiss))

View File

@@ -36,6 +36,9 @@ Format: Marked, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
static inline unsigned char* text_to_ass(char *text, long long int pts, double duration) static inline unsigned char* text_to_ass(char *text, long long int pts, double duration)
{ {
char buf[1024]; char buf[1024];
#ifdef MARTII
unsigned
#endif
int x,pos=0; int x,pos=0;
for(x=0;x<strlen(text);x++){ for(x=0;x<strlen(text);x++){
if(text[x]=='\n'){ if(text[x]=='\n'){

View File

@@ -163,6 +163,15 @@ static int writeData(void* _call)
{ {
k = ((unsigned)src[x]) * opacity / 255; k = ((unsigned)src[x]) * opacity / 255;
ck = 255 - k; ck = 255 - k;
#ifdef MARTII // or __sh__, or !HAVE_TRIPLEDRAGON
*dst++ = 0;
t = *dst;
*dst++ = (k*r + ck*t) / 255;
t = *dst;
*dst++ = (k*b + ck*t) / 255;
t = *dst;
*dst++ = (k*g + ck*t) / 255;
#else
t = *dst; t = *dst;
*dst++ = (k*b + ck*t) / 255; *dst++ = (k*b + ck*t) / 255;
t = *dst; t = *dst;
@@ -170,6 +179,7 @@ static int writeData(void* _call)
t = *dst; t = *dst;
*dst++ = (k*r + ck*t) / 255; *dst++ = (k*r + ck*t) / 255;
*dst++ = 0; *dst++ = 0;
#endif
} }
dst += dst_delta; dst += dst_delta;