mirror of
https://github.com/tuxbox-neutrino/libstb-hal.git
synced 2025-08-26 23:13:16 +02:00
libeplayer3: use uint32_t for frame buffer access
This commit is contained in:
@@ -123,8 +123,8 @@ static unsigned int screen_width = 0;
|
|||||||
static unsigned int screen_height = 0;
|
static unsigned int screen_height = 0;
|
||||||
static int shareFramebuffer = 0;
|
static int shareFramebuffer = 0;
|
||||||
static int framebufferFD = -1;
|
static int framebufferFD = -1;
|
||||||
static unsigned char* destination = NULL;
|
static uint32_t *destination = NULL;
|
||||||
static int destStride = 0;
|
static int destStride = 0;
|
||||||
static void (*framebufferBlit)(void) = NULL;
|
static void (*framebufferBlit)(void) = NULL;
|
||||||
|
|
||||||
static int needsBlit = 0;
|
static int needsBlit = 0;
|
||||||
@@ -414,19 +414,17 @@ static void ASSThread(Context_t *context) {
|
|||||||
}
|
}
|
||||||
if (x1 > 0 && y1 > 0)
|
if (x1 > 0 && y1 > 0)
|
||||||
{
|
{
|
||||||
|
x1++;
|
||||||
|
y1++;
|
||||||
int x, y;
|
int x, y;
|
||||||
unsigned char *dst = destination + y0 * destStride + 4 * x0;
|
uint32_t *dst = destination + y0 * destStride/sizeof(uint32_t) + x0;
|
||||||
int destStrideDiff = destStride - (x1 - x0 + 1) * 4;
|
int destStrideDiff = destStride/sizeof(uint32_t) - (x1 - x0);
|
||||||
for (y = y0; y <= y1; y++) {
|
for (y = y0; y < y1; y++) {
|
||||||
for (x = x0; x <= x1; x++) {
|
for (x = x0; x < x1; x++)
|
||||||
*dst++ = 128;
|
*dst++ = 0x80808080;
|
||||||
*dst++ = 128;
|
|
||||||
*dst++ = 128;
|
|
||||||
*dst++ = 128;
|
|
||||||
}
|
|
||||||
dst += destStrideDiff;
|
dst += destStrideDiff;
|
||||||
}
|
}
|
||||||
storeRegion(x0, y0, x1 - x0 + 1, y1 - y0 + 1, undisplay);
|
storeRegion(x0, y0, x1 - x0, y1 - y0, undisplay);
|
||||||
needsBlit = 1;
|
needsBlit = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -114,7 +114,7 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
unsigned char* destination;
|
uint32_t *destination;
|
||||||
unsigned int screen_width;
|
unsigned int screen_width;
|
||||||
unsigned int screen_height;
|
unsigned int screen_height;
|
||||||
unsigned int destStride;
|
unsigned int destStride;
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
#define WRITER_H_
|
#define WRITER_H_
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef enum { eNone, eAudio, eVideo, eGfx} eWriterType_t;
|
typedef enum { eNone, eAudio, eVideo, eGfx} eWriterType_t;
|
||||||
|
|
||||||
@@ -33,7 +34,7 @@ typedef struct {
|
|||||||
int fd;
|
int fd;
|
||||||
unsigned int Screen_Width;
|
unsigned int Screen_Width;
|
||||||
unsigned int Screen_Height;
|
unsigned int Screen_Height;
|
||||||
unsigned char* destination;
|
uint32_t *destination;
|
||||||
unsigned int destStride;
|
unsigned int destStride;
|
||||||
} WriterFBCallData_t;
|
} WriterFBCallData_t;
|
||||||
|
|
||||||
|
@@ -103,14 +103,13 @@ static int readPointer = 0;
|
|||||||
static int writePointer = 0;
|
static int writePointer = 0;
|
||||||
static int hasThreadStarted = 0;
|
static int hasThreadStarted = 0;
|
||||||
static int isSubtitleOpened = 0;
|
static int isSubtitleOpened = 0;
|
||||||
|
static int screen_width = 0;
|
||||||
static int screen_width = 0;
|
static int screen_height = 0;
|
||||||
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 void (*framebufferBlit) = NULL;
|
static uint32_t *destination = NULL;
|
||||||
static unsigned char* destination = NULL;
|
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
|
@@ -95,112 +95,99 @@ if (debug_level >= level) printf("[%s:%s] " fmt, __FILE__, __FUNCTION__, ## x);
|
|||||||
|
|
||||||
static int reset()
|
static int reset()
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int writeData(void* _call)
|
static int writeData(void* _call)
|
||||||
{
|
{
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
WriterFBCallData_t* call = (WriterFBCallData_t*) _call;
|
|
||||||
|
|
||||||
fb_printf(100, "\n");
|
|
||||||
|
|
||||||
if (call == NULL)
|
WriterFBCallData_t* call = (WriterFBCallData_t*) _call;
|
||||||
{
|
|
||||||
fb_err("call data is NULL...\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (call->destination == NULL)
|
fb_printf(100, "\n");
|
||||||
{
|
|
||||||
fb_err("file pointer < 0. ignoring ...\n");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (call->data != NULL)
|
|
||||||
{
|
|
||||||
unsigned int a = (unsigned int)_a(call->color);
|
|
||||||
unsigned int r = (unsigned int)_r(call->color);
|
|
||||||
unsigned int g = (unsigned int)_g(call->color);
|
|
||||||
unsigned int b = (unsigned int)_b(call->color);
|
|
||||||
unsigned int opacity = 255 - a;
|
|
||||||
int src_stride = call->Stride;
|
|
||||||
int dst_stride = call->destStride;
|
|
||||||
int dst_delta = dst_stride - call->Width*4;
|
|
||||||
unsigned int x,y;
|
|
||||||
const unsigned char *src = call->data;
|
|
||||||
unsigned char *dst = call->destination + (call->y * dst_stride + call->x * 4);
|
|
||||||
#if 1 // !HAVE_SPARK_HARDWARE
|
|
||||||
unsigned int k;
|
|
||||||
#else
|
|
||||||
unsigned int k,ck,t;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fb_printf(100, "x %d\n", call->x);
|
if (!call)
|
||||||
fb_printf(100, "y %d\n", call->y);
|
{
|
||||||
fb_printf(100, "width %d\n", call->Width);
|
fb_err("call data is NULL...\n");
|
||||||
fb_printf(100, "height %d\n", call->Height);
|
return 0;
|
||||||
fb_printf(100, "stride %d\n", call->Stride);
|
}
|
||||||
fb_printf(100, "color 0x%.8x\n", call->color);
|
|
||||||
fb_printf(100, "data %p\n", call->data);
|
|
||||||
fb_printf(100, "dest %p\n", call->destination);
|
|
||||||
fb_printf(100, "dest.stride %d\n", call->destStride);
|
|
||||||
|
|
||||||
fb_printf(100, "r 0x%hhx, g 0x%hhx, b 0x%hhx, a 0x%hhx, opacity 0x%hhx\n", r, g, b, a, opacity);
|
if (!call->destination)
|
||||||
|
{
|
||||||
|
fb_err("frame buffer == NULL. ignoring ...\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (y=0;y<call->Height;y++)
|
if (call->data)
|
||||||
{
|
{
|
||||||
for (x = 0; x < call->Width; x++)
|
int src_stride = call->Stride;
|
||||||
{
|
unsigned int x,y;
|
||||||
k = ((unsigned)src[x]) * opacity / 256;
|
const unsigned char *src = call->data;
|
||||||
#if 1 // HAVE_SPARK_HARDWARE
|
int dst_stride = call->destStride/sizeof(uint32_t);
|
||||||
if (src[x]) {
|
int dst_delta = dst_stride - call->Width;
|
||||||
*dst++ = b;
|
uint32_t *dst = call->destination + call->y * dst_stride + call->x;
|
||||||
*dst++ = g;
|
static uint32_t last_color = 0;
|
||||||
*dst++ = r;
|
static uint32_t colortable[256];
|
||||||
*dst++ = k;
|
if (last_color != call->color) {
|
||||||
} else
|
// call->color is rgba, our spark frame buffer is argb
|
||||||
dst += 4;
|
uint32_t c = call->color >> 8;
|
||||||
#else
|
uint32_t a = 255 - (call->color & 0xff);
|
||||||
ck = 255 - k;
|
int i;
|
||||||
t = *dst;
|
for (i = 0; i < 256; i++)
|
||||||
*dst++ = (k*b + ck*t) / 256;
|
colortable[i] = c | (((a * i) >> 8) << 24);
|
||||||
t = *dst;
|
last_color = call->color;
|
||||||
*dst++ = (k*g + ck*t) / 256;
|
}
|
||||||
t = *dst;
|
|
||||||
*dst++ = (k*r + ck*t) / 256;
|
|
||||||
*dst++ = 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
dst += dst_delta;
|
|
||||||
src += src_stride;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
unsigned int y;
|
|
||||||
for (y = 0; y < call->Height; y++)
|
|
||||||
memset(call->destination + ((call->y + y) * call->destStride) + call->x * 4, 0, call->Width * 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
fb_printf(100, "< %d\n", res);
|
fb_printf(100, "x %d\n", call->x);
|
||||||
return res;
|
fb_printf(100, "y %d\n", call->y);
|
||||||
|
fb_printf(100, "width %d\n", call->Width);
|
||||||
|
fb_printf(100, "height %d\n", call->Height);
|
||||||
|
fb_printf(100, "stride %d\n", call->Stride);
|
||||||
|
fb_printf(100, "color 0x%.8x\n", call->color);
|
||||||
|
fb_printf(100, "data %p\n", call->data);
|
||||||
|
fb_printf(100, "dest %p\n", call->destination);
|
||||||
|
fb_printf(100, "dest.stride %d\n", call->destStride);
|
||||||
|
|
||||||
|
for (y=0;y<call->Height;y++) {
|
||||||
|
for (x = 0; x < call->Width; x++) {
|
||||||
|
uint32_t c = colortable[src[x]];
|
||||||
|
if (c >> 24)
|
||||||
|
*dst++ = c;
|
||||||
|
else
|
||||||
|
dst++;
|
||||||
|
}
|
||||||
|
dst += dst_delta;
|
||||||
|
src += src_stride;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unsigned int y;
|
||||||
|
int dst_stride = call->destStride/sizeof(uint32_t);
|
||||||
|
uint32_t *dst = call->destination + call->y * dst_stride + call->x;
|
||||||
|
|
||||||
|
for (y = 0; y < call->Height; y++) {
|
||||||
|
memset(dst, 0, call->Width * 4);
|
||||||
|
dst += dst_stride;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fb_printf(100, "< %d\n", res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
/* Writer Definition */
|
/* Writer Definition */
|
||||||
/* ***************************** */
|
/* ***************************** */
|
||||||
static WriterCaps_t caps = {
|
static WriterCaps_t caps = {
|
||||||
"framebuffer",
|
"framebuffer",
|
||||||
eGfx,
|
eGfx,
|
||||||
"framebuffer",
|
"framebuffer",
|
||||||
0
|
0
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Writer_s WriterFramebuffer = {
|
struct Writer_s WriterFramebuffer = {
|
||||||
&reset,
|
&reset,
|
||||||
&writeData,
|
&writeData,
|
||||||
NULL,
|
NULL,
|
||||||
&caps
|
&caps
|
||||||
};
|
};
|
||||||
|
@@ -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 *, void (**)(void)))
|
cPlayback::cPlayback(int num __attribute__((unused)), void (*fbcb)(uint32_t **, 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 (**)(void));
|
void (*framebuffer_callback)(uint32_t **, 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 *, void (**)(void)) = NULL);
|
cPlayback(int num = 0, void (*fbcb)(uint32_t **, 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