mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-28 07:51:21 +02:00
libeplayer3/subtitles/spark: use backbuffer and blit
This commit is contained in:
@@ -126,7 +126,9 @@ static int shareFramebuffer = 0;
|
|||||||
static int framebufferFD = -1;
|
static int framebufferFD = -1;
|
||||||
static unsigned char* destination = NULL;
|
static unsigned char* destination = NULL;
|
||||||
static int destStride = 0;
|
static int destStride = 0;
|
||||||
static int threeDMode =0;
|
static void (*framebufferBlit)(void) = NULL;
|
||||||
|
|
||||||
|
static int needsBlit = 0;
|
||||||
|
|
||||||
static ASS_Track* ass_track = NULL;
|
static ASS_Track* ass_track = NULL;
|
||||||
|
|
||||||
@@ -213,13 +215,7 @@ void releaseRegions()
|
|||||||
out.destStride = destStride;
|
out.destStride = destStride;
|
||||||
|
|
||||||
writer->writeData(&out);
|
writer->writeData(&out);
|
||||||
if(threeDMode == 1){
|
needsBlit = 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
old = next;
|
old = next;
|
||||||
next = next->next;
|
next = next->next;
|
||||||
@@ -278,13 +274,7 @@ void checkRegions()
|
|||||||
out.destStride = destStride;
|
out.destStride = destStride;
|
||||||
|
|
||||||
writer->writeData(&out);
|
writer->writeData(&out);
|
||||||
if(threeDMode == 1){
|
needsBlit = 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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
old = next;
|
old = next;
|
||||||
@@ -451,13 +441,6 @@ static void ASSThread(Context_t *context) {
|
|||||||
{
|
{
|
||||||
if(context && context->playback && context->playback->isPlaying && writer){
|
if(context && context->playback && context->playback->isPlaying && writer){
|
||||||
writer->writeData(&out);
|
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
|
else
|
||||||
@@ -490,6 +473,7 @@ static void ASSThread(Context_t *context) {
|
|||||||
context->output && context->output->subtitle)
|
context->output && context->output->subtitle)
|
||||||
context->output->subtitle->Write(context, &sub_out);
|
context->output->subtitle->Write(context, &sub_out);
|
||||||
}
|
}
|
||||||
|
needsBlit = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Next image */
|
/* Next image */
|
||||||
@@ -507,12 +491,20 @@ static void ASSThread(Context_t *context) {
|
|||||||
usleep(1000);
|
usleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (needsBlit && framebufferBlit)
|
||||||
|
framebufferBlit();
|
||||||
|
needsBlit = 0;
|
||||||
|
|
||||||
/* cleanup no longer used but not overwritten regions */
|
/* cleanup no longer used but not overwritten regions */
|
||||||
getMutex(__LINE__);
|
getMutex(__LINE__);
|
||||||
checkRegions();
|
checkRegions();
|
||||||
releaseMutex(__LINE__);
|
releaseMutex(__LINE__);
|
||||||
} /* while */
|
} /* while */
|
||||||
|
|
||||||
|
if (needsBlit && framebufferBlit)
|
||||||
|
framebufferBlit();
|
||||||
|
needsBlit = 0;
|
||||||
|
|
||||||
hasPlayThreadStarted = 0;
|
hasPlayThreadStarted = 0;
|
||||||
|
|
||||||
ass_printf(10, "terminating\n");
|
ass_printf(10, "terminating\n");
|
||||||
@@ -525,8 +517,6 @@ static void ASSThread(Context_t *context) {
|
|||||||
|
|
||||||
int container_ass_init(Context_t *context)
|
int container_ass_init(Context_t *context)
|
||||||
{
|
{
|
||||||
int modefd;
|
|
||||||
char buf[16];
|
|
||||||
SubtitleOutputDef_t output;
|
SubtitleOutputDef_t output;
|
||||||
|
|
||||||
ass_printf(10, ">\n");
|
ass_printf(10, ">\n");
|
||||||
@@ -558,40 +548,20 @@ int container_ass_init(Context_t *context)
|
|||||||
|
|
||||||
context->output->subtitle->Command(context, OUTPUT_GET_SUBTITLE_OUTPUT, &output);
|
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_width = output.screen_width;
|
||||||
screen_height = output.screen_height;
|
screen_height = output.screen_height;
|
||||||
shareFramebuffer = output.shareFramebuffer;
|
shareFramebuffer = output.shareFramebuffer;
|
||||||
framebufferFD = output.framebufferFD;
|
framebufferFD = output.framebufferFD;
|
||||||
destination = output.destination;
|
destination = output.destination;
|
||||||
destStride = output.destStride;
|
destStride = output.destStride;
|
||||||
|
framebufferBlit = output.framebufferBlit;
|
||||||
|
|
||||||
ass_printf(10, "width %d, height %d, share %d, fd %d, 3D %d\n",
|
ass_printf(10, "width %d, height %d, share %d, fd %d\n",
|
||||||
screen_width, screen_height, shareFramebuffer, framebufferFD, threeDMode);
|
screen_width, screen_height, shareFramebuffer, framebufferFD);
|
||||||
|
|
||||||
if(threeDMode == 0){
|
ass_set_frame_size(ass_renderer, screen_width, screen_height);
|
||||||
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) ,
|
||||||
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 ) );
|
||||||
(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_use_margins(ass_renderer, 1);
|
ass_set_use_margins(ass_renderer, 1);
|
||||||
// ass_set_font_scale(ass_renderer, (ass_font_scale * screen_height) / 240.0);
|
// ass_set_font_scale(ass_renderer, (ass_font_scale * screen_height) / 240.0);
|
||||||
@@ -600,14 +570,7 @@ int container_ass_init(Context_t *context)
|
|||||||
// ass_set_line_spacing(ass_renderer, (ass_line_spacing * screen_height) / 240.0);
|
// ass_set_line_spacing(ass_renderer, (ass_line_spacing * screen_height) / 240.0);
|
||||||
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){
|
ass_set_aspect_ratio( ass_renderer, 1.0, 1.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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
isContainerRunning = 1;
|
isContainerRunning = 1;
|
||||||
|
|
||||||
|
@@ -121,6 +121,7 @@ typedef struct
|
|||||||
|
|
||||||
int shareFramebuffer;
|
int shareFramebuffer;
|
||||||
int framebufferFD;
|
int framebufferFD;
|
||||||
|
void (*framebufferBlit)(void);
|
||||||
} SubtitleOutputDef_t;
|
} SubtitleOutputDef_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -109,6 +109,7 @@ static int screen_height = 0;
|
|||||||
static int destStride = 0;
|
static int destStride = 0;
|
||||||
static int shareFramebuffer = 0;
|
static int shareFramebuffer = 0;
|
||||||
static int framebufferFD = -1;
|
static int framebufferFD = -1;
|
||||||
|
static void (*framebufferBlit) = NULL;
|
||||||
static unsigned char* destination = 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->screen_height = screen_height;
|
||||||
out->shareFramebuffer = shareFramebuffer;
|
out->shareFramebuffer = shareFramebuffer;
|
||||||
out->framebufferFD = framebufferFD;
|
out->framebufferFD = framebufferFD;
|
||||||
|
out->framebufferBlit = framebufferBlit;
|
||||||
out->destination = destination;
|
out->destination = destination;
|
||||||
out->destStride = destStride;
|
out->destStride = destStride;
|
||||||
break;
|
break;
|
||||||
@@ -793,6 +795,7 @@ static int Command(void *_context, OutputCmd_t command, void * argument) {
|
|||||||
screen_height = out->screen_height;
|
screen_height = out->screen_height;
|
||||||
shareFramebuffer = out->shareFramebuffer;
|
shareFramebuffer = out->shareFramebuffer;
|
||||||
framebufferFD = out->framebufferFD;
|
framebufferFD = out->framebufferFD;
|
||||||
|
framebufferBlit = out->framebufferBlit;
|
||||||
destination = out->destination;
|
destination = out->destination;
|
||||||
destStride = out->destStride;
|
destStride = out->destStride;
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user