mirror of
https://github.com/tuxbox-fork-migrations/recycled-ni-libstb-hal.git
synced 2025-08-26 23:12:44 +02:00
libspark/libeplayer: rudimentary subtitle support, probably unstable
Origin commit data
------------------
Branch: master
Commit: aa0681a555
Author: martii <m4rtii@gmx.de>
Date: 2012-11-04 (Sun, 04 Nov 2012)
------------------
No further description and justification available within origin commit message!
------------------
This commit was generated by Migit
This commit is contained in:
@@ -75,7 +75,11 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
||||
|
||||
#define ASS_RING_SIZE 5
|
||||
|
||||
#ifdef MARTII
|
||||
#define ASS_FONT "/share/fonts/neutrino.ttf"
|
||||
#else
|
||||
#define ASS_FONT "/usr/share/fonts/FreeSans.ttf"
|
||||
#endif
|
||||
|
||||
/* ***************************** */
|
||||
/* Types */
|
||||
@@ -382,14 +386,22 @@ static void ASSThread(Context_t *context) {
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifndef MARTII
|
||||
getMutex(__LINE__);
|
||||
#endif
|
||||
|
||||
//FIXME: durch den sleep bleibt die cpu usage zw. 5 und 13%, ohne
|
||||
// steigt sie bei Verwendung von subtiteln bis auf 95%.
|
||||
// ich hoffe dadurch gehen keine subtitle verloren, wenn die playPts
|
||||
// durch den sleep verschlafen wird. Besser w<>re es den n<>chsten
|
||||
// subtitel zeitpunkt zu bestimmen und solange zu schlafen.
|
||||
#ifdef MARTII
|
||||
usleep(10000);
|
||||
getMutex(__LINE__);
|
||||
checkRegions();
|
||||
#else
|
||||
usleep(1000);
|
||||
#endif
|
||||
|
||||
if(ass_renderer && ass_track)
|
||||
img = ass_render_frame(ass_renderer, ass_track, playPts / 90.0, &change);
|
||||
@@ -414,7 +426,11 @@ static void ASSThread(Context_t *context) {
|
||||
|
||||
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;
|
||||
#endif
|
||||
}
|
||||
|
||||
ass_printf(100, "w %d h %d s %d x %d y %d c %d chg %d now %ld und %ld\n",
|
||||
@@ -531,12 +547,21 @@ static void ASSThread(Context_t *context) {
|
||||
}
|
||||
|
||||
/* cleanup no longer used but not overwritten regions */
|
||||
#ifdef MARTII
|
||||
getMutex(__LINE__);
|
||||
#endif
|
||||
checkRegions();
|
||||
#ifdef MARTII
|
||||
releaseMutex(__LINE__);
|
||||
#endif
|
||||
} /* while */
|
||||
|
||||
hasPlayThreadStarted = 0;
|
||||
|
||||
ass_printf(10, "terminating\n");
|
||||
#ifdef MARTII
|
||||
pthread_exit(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* **************************** */
|
||||
@@ -614,10 +639,18 @@ int container_ass_init(Context_t *context)
|
||||
}
|
||||
|
||||
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);
|
||||
#endif
|
||||
|
||||
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);
|
||||
#endif
|
||||
ass_set_fonts(ass_renderer, ASS_FONT, "Arial", 0, NULL, 1);
|
||||
|
||||
if(threeDMode == 0){
|
||||
@@ -656,6 +689,10 @@ int container_ass_process_data(Context_t *context, SubtitleData_t* data)
|
||||
ass_err("error creating ass_track\n");
|
||||
return cERR_CONTAINER_ASS_ERROR;
|
||||
}
|
||||
#ifdef MARTII
|
||||
ass_track->PlayResX = screen_width;
|
||||
ass_track->PlayResY = screen_height;
|
||||
#endif
|
||||
}
|
||||
|
||||
if ((data->extradata) && (first_kiss))
|
||||
|
@@ -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)
|
||||
{
|
||||
char buf[1024];
|
||||
#ifdef MARTII
|
||||
unsigned
|
||||
#endif
|
||||
int x,pos=0;
|
||||
for(x=0;x<strlen(text);x++){
|
||||
if(text[x]=='\n'){
|
||||
|
@@ -162,6 +162,15 @@ static int writeData(void* _call)
|
||||
{
|
||||
k = ((unsigned)src[x]) * opacity / 255;
|
||||
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;
|
||||
*dst++ = (k*b + ck*t) / 255;
|
||||
t = *dst;
|
||||
@@ -169,6 +178,7 @@ static int writeData(void* _call)
|
||||
t = *dst;
|
||||
*dst++ = (k*r + ck*t) / 255;
|
||||
*dst++ = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
dst += dst_delta;
|
||||
|
@@ -13,6 +13,9 @@ extern ContainerHandler_t ContainerHandler;
|
||||
extern ManagerHandler_t ManagerHandler;
|
||||
|
||||
#include "playback_libeplayer3.h"
|
||||
#ifdef MARTII
|
||||
#include "subtitle.h"
|
||||
#endif
|
||||
|
||||
static Context_t *player;
|
||||
|
||||
@@ -73,6 +76,14 @@ bool cPlayback::Open(playmode_t PlayMode)
|
||||
#ifdef MARTII
|
||||
player->output->Command(player,OUTPUT_ADD, (void*)"dvbsubtitle");
|
||||
player->output->Command(player,OUTPUT_ADD, (void*)"teletext");
|
||||
|
||||
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);
|
||||
so.shareFramebuffer = 1;
|
||||
player->output->subtitle->Command(player, OUTPUT_SET_SUBTITLE_OUTPUT, (void*)&so);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -107,6 +118,7 @@ bool cPlayback::Start(char *filename, unsigned short vpid, int vtype, unsigned s
|
||||
//create playback path
|
||||
mAudioStream=0;
|
||||
#ifdef MARTII
|
||||
mSubtitleStream=-1;
|
||||
mDvbsubtitleStream=-1;
|
||||
mTeletextStream=0;
|
||||
#endif
|
||||
@@ -166,6 +178,39 @@ bool cPlayback::Start(char *filename, unsigned short vpid, int vtype, unsigned s
|
||||
free(TrackList);
|
||||
}
|
||||
}
|
||||
#ifdef MARTII
|
||||
//DVBSUB
|
||||
if(player && player->manager && player->manager->dvbsubtitle) {
|
||||
char ** TrackList = NULL;
|
||||
player->manager->dvbsubtitle->Command(player, MANAGER_LIST, &TrackList);
|
||||
if (TrackList != NULL) {
|
||||
printf("DVBSubtitleTrack List\n");
|
||||
int i = 0;
|
||||
for (i = 0; TrackList[i] != NULL; i+=2) {
|
||||
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]);
|
||||
free(TrackList[i]);
|
||||
free(TrackList[i+1]);
|
||||
}
|
||||
free(TrackList);
|
||||
}
|
||||
}
|
||||
|
||||
//Teletext
|
||||
if(player && player->manager && player->manager->teletext) {
|
||||
char ** TrackList = NULL;
|
||||
player->manager->teletext->Command(player, MANAGER_LIST, &TrackList);
|
||||
if (TrackList != NULL) {
|
||||
printf("TeletextTrack List\n");
|
||||
int i = 0;
|
||||
for (i = 0; TrackList[i] != NULL; i+=2) {
|
||||
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]);
|
||||
free(TrackList[i]);
|
||||
free(TrackList[i+1]);
|
||||
}
|
||||
free(TrackList);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (pm != PLAYMODE_TS && player && player->output && player->playback) {
|
||||
player->output->Command(player, OUTPUT_OPEN, NULL);
|
||||
@@ -267,6 +312,17 @@ bool cPlayback::SetAPid(unsigned short pid, bool ac3)
|
||||
return true;
|
||||
}
|
||||
#ifdef MARTII
|
||||
bool cPlayback::SetSubtitlePid(unsigned short pid)
|
||||
{
|
||||
printf("%s:%s\n", FILENAME, __FUNCTION__);
|
||||
int i=pid;
|
||||
if(pid!=mSubtitleStream){
|
||||
if(player && player->playback)
|
||||
player->playback->Command(player, PLAYBACK_SWITCH_SUBTITLE, (void*)&i);
|
||||
mSubtitleStream=pid;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
bool cPlayback::SetDvbsubtitlePid(unsigned short pid)
|
||||
{
|
||||
printf("%s:%s\n", FILENAME, __FUNCTION__);
|
||||
@@ -382,7 +438,9 @@ bool cPlayback::GetSpeed(int &speed) const
|
||||
bool cPlayback::GetPosition(int &position, int &duration)
|
||||
{
|
||||
bool got_duration = false;
|
||||
#ifndef MARTII
|
||||
printf("%s:%s %d %d\n", FILENAME, __FUNCTION__, position, duration);
|
||||
#endif
|
||||
|
||||
/* hack: if the file is growing (timeshift), then determine its length
|
||||
* by comparing the mtime with the mtime of the xml file */
|
||||
@@ -507,6 +565,29 @@ void cPlayback::FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t
|
||||
}
|
||||
}
|
||||
#ifdef MARTII
|
||||
void cPlayback::FindAllSubtitlePids(uint16_t *pids, uint16_t *numpids, std::string *language)
|
||||
{
|
||||
printf("%s:%s\n", FILENAME, __FUNCTION__);
|
||||
if(player && player->manager && player->manager->subtitle) {
|
||||
char ** TrackList = NULL;
|
||||
player->manager->subtitle->Command(player, MANAGER_LIST, &TrackList);
|
||||
if (TrackList != NULL) {
|
||||
printf("SubtitleTrack List\n");
|
||||
int i = 0,j=0;
|
||||
for (i = 0,j=0; TrackList[i] != NULL; i+=2,j++) {
|
||||
printf("\t%s - %s\n", TrackList[i], TrackList[i+1]);
|
||||
pids[j]=j;
|
||||
// atUnknown, atMPEG, atMP3, atAC3, atDTS, atAAC, atPCM, atOGG, atFLAC
|
||||
language[j]=TrackList[i];
|
||||
free(TrackList[i]);
|
||||
free(TrackList[i+1]);
|
||||
}
|
||||
free(TrackList);
|
||||
*numpids=j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cPlayback::FindAllDvbsubtitlePids(uint16_t *pids, uint16_t *numpids, std::string *language)
|
||||
{
|
||||
printf("%s:%s\n", FILENAME, __FUNCTION__);
|
||||
@@ -533,13 +614,16 @@ void cPlayback::FindAllDvbsubtitlePids(uint16_t *pids, uint16_t *numpids, std::s
|
||||
|
||||
//
|
||||
#ifdef MARTII
|
||||
cPlayback::cPlayback(int num __attribute__((unused)))
|
||||
cPlayback::cPlayback(int num __attribute__((unused)), void (*fbcb)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *))
|
||||
#else
|
||||
cPlayback::cPlayback(int num)
|
||||
#endif
|
||||
{
|
||||
printf("%s:%s\n", FILENAME, __FUNCTION__);
|
||||
playing=false;
|
||||
#ifdef MARTII
|
||||
framebuffer_callback = fbcb;
|
||||
#endif
|
||||
}
|
||||
|
||||
cPlayback::~cPlayback()
|
||||
|
@@ -16,12 +16,18 @@ class cPlayback
|
||||
int nPlaybackSpeed;
|
||||
int mAudioStream;
|
||||
#ifdef MARTII
|
||||
int mSubtitleStream;
|
||||
int mDvbsubtitleStream;
|
||||
int mTeletextStream;
|
||||
void (*framebuffer_callback)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *);
|
||||
#endif
|
||||
bool Stop(void);
|
||||
public:
|
||||
#ifdef MARTII
|
||||
cPlayback(int num = 0, void (*fbcb)(unsigned char **, unsigned int *, unsigned int *, unsigned int *, int *) = NULL);
|
||||
#else
|
||||
cPlayback(int num = 0);
|
||||
#endif
|
||||
~cPlayback();
|
||||
|
||||
bool Open(playmode_t PlayMode);
|
||||
@@ -30,9 +36,11 @@ class cPlayback
|
||||
int ac3, unsigned int duration);
|
||||
bool SetAPid(unsigned short pid, bool ac3);
|
||||
#ifdef MARTII
|
||||
bool SetSubtitlePid(unsigned short pid);
|
||||
bool SetDvbsubtitlePid(unsigned short pid);
|
||||
bool SetTeletextPid(unsigned short pid);
|
||||
unsigned short GetAPid(void) { return mAudioStream; }
|
||||
unsigned short GetSubtitlePid(void) { return mSubtitleStream; }
|
||||
unsigned short GetDvbsubtitlePid(void) { return mDvbsubtitleStream; }
|
||||
unsigned short GetTeletextPid(void) { return mTeletextStream; }
|
||||
#endif
|
||||
@@ -42,6 +50,7 @@ class cPlayback
|
||||
bool SetPosition(int position, bool absolute = false);
|
||||
void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language);
|
||||
#ifdef MARTII
|
||||
void FindAllSubtitlePids(uint16_t *pids, uint16_t *numpids, std::string *language);
|
||||
void FindAllDvbsubtitlePids(uint16_t *pids, uint16_t *numpids, std::string *language);
|
||||
#endif
|
||||
#if 0
|
||||
|
Reference in New Issue
Block a user