mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
libeplayer3/subtitles/spark: use backbuffer and blit
This commit is contained in:
@@ -125,7 +125,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;
|
||||||
|
|
||||||
@@ -212,13 +214,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;
|
||||||
@@ -277,13 +273,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;
|
||||||
@@ -450,13 +440,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
|
||||||
@@ -489,6 +472,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 */
|
||||||
@@ -506,12 +490,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");
|
||||||
@@ -524,8 +516,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");
|
||||||
@@ -557,40 +547,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);
|
||||||
@@ -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_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;
|
||||||
|
@@ -73,7 +73,7 @@ bool cPlayback::Open(playmode_t PlayMode)
|
|||||||
if (framebuffer_callback) {
|
if (framebuffer_callback) {
|
||||||
SubtitleOutputDef_t so;
|
SubtitleOutputDef_t so;
|
||||||
memset(&so, 0, sizeof(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;
|
so.shareFramebuffer = 1;
|
||||||
player->output->subtitle->Command(player, OUTPUT_SET_SUBTITLE_OUTPUT, (void*)&so);
|
player->output->subtitle->Command(player, OUTPUT_SET_SUBTITLE_OUTPUT, (void*)&so);
|
||||||
}
|
}
|
||||||
@@ -702,7 +702,7 @@ void cPlayback::GetChapters(std::vector<int> &positions, std::vector<std::string
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
cPlayback::cPlayback(int num __attribute__((unused)), void (*fbcb)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *))
|
cPlayback::cPlayback(int num __attribute__((unused)), void (*fbcb)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *, void (**)(void)))
|
||||||
{
|
{
|
||||||
printf("%s:%s\n", FILENAME, __FUNCTION__);
|
printf("%s:%s\n", FILENAME, __FUNCTION__);
|
||||||
playing=false;
|
playing=false;
|
||||||
|
@@ -19,10 +19,10 @@ class cPlayback
|
|||||||
int mSubtitleStream;
|
int mSubtitleStream;
|
||||||
int mDvbsubtitleStream;
|
int mDvbsubtitleStream;
|
||||||
int mTeletextStream;
|
int mTeletextStream;
|
||||||
void (*framebuffer_callback)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *);
|
void (*framebuffer_callback)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *, void (**)(void));
|
||||||
bool Stop(void);
|
bool Stop(void);
|
||||||
public:
|
public:
|
||||||
cPlayback(int num = 0, void (*fbcb)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *) = NULL);
|
cPlayback(int num = 0, void (*fbcb)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *, void (**)(void)) = NULL);
|
||||||
~cPlayback();
|
~cPlayback();
|
||||||
|
|
||||||
bool Open(playmode_t PlayMode);
|
bool Open(playmode_t PlayMode);
|
||||||
|
Reference in New Issue
Block a user