diff --git a/libeplayer3/container/container_ass.c b/libeplayer3/container/container_ass.c index 5e104e7..379daaf 100644 --- a/libeplayer3/container/container_ass.c +++ b/libeplayer3/container/container_ass.c @@ -125,7 +125,9 @@ static int shareFramebuffer = 0; static int framebufferFD = -1; static unsigned char* destination = NULL; static int destStride = 0; -static int threeDMode =0; +static void (*framebufferBlit)(void) = NULL; + +static int needsBlit = 0; static ASS_Track* ass_track = NULL; @@ -212,13 +214,7 @@ void releaseRegions() out.destStride = destStride; writer->writeData(&out); - if(threeDMode == 1){ - out.x = screen_width/2 + next->x; - writer->writeData(&out); - }else if(threeDMode == 2){ - out.y = screen_height/2 + next->y; - writer->writeData(&out); - } + needsBlit = 1; } old = next; next = next->next; @@ -277,13 +273,7 @@ void checkRegions() out.destStride = destStride; writer->writeData(&out); - if(threeDMode == 1){ - out.x = screen_width/2 + next->x; - writer->writeData(&out); - }else if(threeDMode == 2){ - out.y = screen_height/2 + next->y; - writer->writeData(&out); - } + needsBlit = 1; } old = next; @@ -450,13 +440,6 @@ static void ASSThread(Context_t *context) { { if(context && context->playback && context->playback->isPlaying && writer){ writer->writeData(&out); - if(threeDMode == 1){ - out.x = screen_width/2 + img->dst_x; - writer->writeData(&out); - }else if(threeDMode == 2){ - out.y = screen_height/2 + img->dst_y; - writer->writeData(&out); - } } } else @@ -489,6 +472,7 @@ static void ASSThread(Context_t *context) { context->output && context->output->subtitle) context->output->subtitle->Write(context, &sub_out); } + needsBlit = 1; } /* Next image */ @@ -506,12 +490,20 @@ static void ASSThread(Context_t *context) { usleep(1000); } + if (needsBlit && framebufferBlit) + framebufferBlit(); + needsBlit = 0; + /* cleanup no longer used but not overwritten regions */ getMutex(__LINE__); checkRegions(); releaseMutex(__LINE__); } /* while */ + if (needsBlit && framebufferBlit) + framebufferBlit(); + needsBlit = 0; + hasPlayThreadStarted = 0; ass_printf(10, "terminating\n"); @@ -524,8 +516,6 @@ static void ASSThread(Context_t *context) { int container_ass_init(Context_t *context) { - int modefd; - char buf[16]; SubtitleOutputDef_t output; ass_printf(10, ">\n"); @@ -557,40 +547,20 @@ int container_ass_init(Context_t *context) context->output->subtitle->Command(context, OUTPUT_GET_SUBTITLE_OUTPUT, &output); - modefd=open("/proc/stb/video/3d_mode", O_RDWR); - if(modefd > 0){ - read(modefd, buf, 15); - buf[15]='\0'; - close(modefd); - }else threeDMode = 0; - - if(strncmp(buf,"sbs",3)==0)threeDMode = 1; - else if(strncmp(buf,"tab",3)==0)threeDMode = 2; - else threeDMode = 0; - screen_width = output.screen_width; screen_height = output.screen_height; shareFramebuffer = output.shareFramebuffer; framebufferFD = output.framebufferFD; destination = output.destination; destStride = output.destStride; + framebufferBlit = output.framebufferBlit; - ass_printf(10, "width %d, height %d, share %d, fd %d, 3D %d\n", - screen_width, screen_height, shareFramebuffer, framebufferFD, threeDMode); + ass_printf(10, "width %d, height %d, share %d, fd %d\n", + screen_width, screen_height, shareFramebuffer, framebufferFD); - if(threeDMode == 0){ - ass_set_frame_size(ass_renderer, screen_width, screen_height); - ass_set_margins(ass_renderer, (int)(0.03 * screen_height), (int)(0.03 * screen_height) , - (int)(0.03 * screen_width ), (int)(0.03 * screen_width ) ); - }else if(threeDMode == 1){ - ass_set_frame_size(ass_renderer, screen_width/2, screen_height); - ass_set_margins(ass_renderer, (int)(0.03 * screen_height), (int)(0.03 * screen_height) , - (int)(0.03 * screen_width/2 ), (int)(0.03 * screen_width/2 ) ); - }else if(threeDMode == 2){ - ass_set_frame_size(ass_renderer, screen_width, screen_height/2); - ass_set_margins(ass_renderer, (int)(0.03 * screen_height/2), (int)(0.03 * screen_height/2) , - (int)(0.03 * screen_width ), (int)(0.03 * screen_width ) ); - } + ass_set_frame_size(ass_renderer, screen_width, screen_height); + ass_set_margins(ass_renderer, (int)(0.03 * screen_height), (int)(0.03 * screen_height) , + (int)(0.03 * screen_width ), (int)(0.03 * screen_width ) ); ass_set_use_margins(ass_renderer, 1); // ass_set_font_scale(ass_renderer, (ass_font_scale * screen_height) / 240.0); @@ -599,14 +569,7 @@ int container_ass_init(Context_t *context) // ass_set_line_spacing(ass_renderer, (ass_line_spacing * screen_height) / 240.0); ass_set_fonts(ass_renderer, ASS_FONT, "Arial", 0, NULL, 1); - if(threeDMode == 0){ - ass_set_aspect_ratio( ass_renderer, 1.0, 1.0); - }else if(threeDMode == 1){ - ass_set_aspect_ratio( ass_renderer, 0.5, 1.0); - }else if(threeDMode == 2){ - ass_set_aspect_ratio( ass_renderer, 1.0, 0.5); - } - + ass_set_aspect_ratio( ass_renderer, 1.0, 1.0); isContainerRunning = 1; diff --git a/libeplayer3/include/subtitle.h b/libeplayer3/include/subtitle.h index 9587691..d53761c 100644 --- a/libeplayer3/include/subtitle.h +++ b/libeplayer3/include/subtitle.h @@ -121,6 +121,7 @@ typedef struct int shareFramebuffer; int framebufferFD; + void (*framebufferBlit)(void); } SubtitleOutputDef_t; #endif diff --git a/libeplayer3/output/output_subtitle.c b/libeplayer3/output/output_subtitle.c index b789a25..c96b10c 100644 --- a/libeplayer3/output/output_subtitle.c +++ b/libeplayer3/output/output_subtitle.c @@ -109,6 +109,7 @@ static int screen_height = 0; static int destStride = 0; static int shareFramebuffer = 0; static int framebufferFD = -1; +static void (*framebufferBlit) = NULL; static unsigned char* destination = NULL; /* ***************************** */ @@ -783,6 +784,7 @@ static int Command(void *_context, OutputCmd_t command, void * argument) { out->screen_height = screen_height; out->shareFramebuffer = shareFramebuffer; out->framebufferFD = framebufferFD; + out->framebufferBlit = framebufferBlit; out->destination = destination; out->destStride = destStride; break; @@ -793,6 +795,7 @@ static int Command(void *_context, OutputCmd_t command, void * argument) { screen_height = out->screen_height; shareFramebuffer = out->shareFramebuffer; framebufferFD = out->framebufferFD; + framebufferBlit = out->framebufferBlit; destination = out->destination; destStride = out->destStride; break; diff --git a/libspark/playback_libeplayer3.cpp b/libspark/playback_libeplayer3.cpp index f99be07..2b1fcf2 100644 --- a/libspark/playback_libeplayer3.cpp +++ b/libspark/playback_libeplayer3.cpp @@ -73,7 +73,7 @@ bool cPlayback::Open(playmode_t PlayMode) if (framebuffer_callback) { SubtitleOutputDef_t so; memset(&so, 0, sizeof(so)); - framebuffer_callback(&so.destination, &so.screen_width, &so.screen_height, &so.destStride, &so.framebufferFD); + framebuffer_callback(&so.destination, &so.screen_width, &so.screen_height, &so.destStride, &so.framebufferFD, &so.framebufferBlit); so.shareFramebuffer = 1; player->output->subtitle->Command(player, OUTPUT_SET_SUBTITLE_OUTPUT, (void*)&so); } @@ -702,7 +702,7 @@ void cPlayback::GetChapters(std::vector &positions, std::vector