libeplayer3 optimizations

This commit is contained in:
martii
2013-07-29 18:35:48 +02:00
parent e11af5361b
commit 3738572731
4 changed files with 22 additions and 32 deletions

View File

@@ -106,7 +106,7 @@ static AVFormatContext* avContext = NULL;
static unsigned char isContainerRunning = 0; static unsigned char isContainerRunning = 0;
long long int latestPts = 0; static long long int latestPts = 0;
static int restart_audio_resampling = 0; static int restart_audio_resampling = 0;
static off_t seek_target_bytes = 0; static off_t seek_target_bytes = 0;

View File

@@ -118,20 +118,19 @@ static int writeData(void* _call)
return 0; return 0;
} }
if (call->data)
{
int src_stride = call->Stride;
unsigned int x,y;
const unsigned char *src = call->data;
int dst_stride = call->destStride/sizeof(uint32_t); int dst_stride = call->destStride/sizeof(uint32_t);
int dst_delta = dst_stride - call->Width; int dst_delta = dst_stride - call->Width;
uint32_t *dst = call->destination + call->y * dst_stride + call->x; uint32_t *dst = call->destination + call->y * dst_stride + call->x;
static uint32_t last_color = 0;
static uint32_t colortable[256]; if (call->data)
{
int src_delta = call->Stride - call->Width;
unsigned char *src = call->data;
static uint32_t last_color = 0, colortable[256];
if (last_color != call->color) { if (last_color != call->color) {
// call->color is rgba, our spark frame buffer is argb // call->color is rgba, our spark frame buffer is argb
uint32_t c = call->color >> 8; uint32_t c = call->color >> 8, a = 255 - (call->color & 0xff);
uint32_t a = 255 - (call->color & 0xff);
int i; int i;
for (i = 0; i < 256; i++) { for (i = 0; i < 256; i++) {
uint32_t k = (a * i) >> 8; uint32_t k = (a * i) >> 8;
@@ -150,25 +149,21 @@ static int writeData(void* _call)
fb_printf(100, "dest %p\n", call->destination); fb_printf(100, "dest %p\n", call->destination);
fb_printf(100, "dest.stride %d\n", call->destStride); fb_printf(100, "dest.stride %d\n", call->destStride);
for (y=0;y<call->Height;y++) { unsigned char *src_final = src + call->Height * call->Width;
for (x = 0; x < call->Width; x++) { for (; src < src_final; dst += dst_delta, src += src_delta) {
uint32_t c = colortable[src[x]]; u_char *src_end = src + call->Width;
for (; src < src_end; dst++, src++) {
uint32_t c = colortable[*src];
if (c) if (c)
*dst++ = c; *dst = c;
else
dst++;
} }
dst += dst_delta;
src += src_stride;
} }
} else { } else {
unsigned int y; uint32_t *dst_final = dst + call->Width + call->Height * dst_stride;
int dst_stride = call->destStride/sizeof(uint32_t); for (; dst < dst_final; dst += dst_delta) {
uint32_t *dst = call->destination + call->y * dst_stride + call->x; uint32_t *dst_end = dst + call->Width;
for (; dst < dst_end; dst++)
for (y = 0; y < call->Height; y++) { *dst = 0;
memset(dst, 0, call->Width * 4);
dst += dst_stride;
} }
} }

View File

@@ -92,7 +92,6 @@ typedef struct avcC_s
/* ***************************** */ /* ***************************** */
const unsigned char Head[] = {0, 0, 0, 1}; const unsigned char Head[] = {0, 0, 0, 1};
static int initialHeader = 1; static int initialHeader = 1;
//static int NoOtherBeginningFound = 1;
static unsigned int NalLengthBytes = 1; static unsigned int NalLengthBytes = 1;
/* ***************************** */ /* ***************************** */
@@ -106,7 +105,6 @@ static unsigned int NalLengthBytes = 1;
static int reset() static int reset()
{ {
initialHeader = 1; initialHeader = 1;
//NoOtherBeginningFound = 1;
return 0; return 0;
} }
@@ -148,8 +146,6 @@ static int writeData(void* _call)
} }
if((call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) || if((call->len > 3) && ((call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x00 && call->data[3] == 0x01) ||
// This seems to make playback unreliable. Disabled for now. --martii
//(call->data[0] == 0x00 && call->data[1] == 0x00 && call->data[2] == 0x01 && NoOtherBeginningFound) ||
(call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff))) (call->data[0] == 0xff && call->data[1] == 0xff && call->data[2] == 0xff && call->data[3] == 0xff)))
{ {
unsigned int PacketLength = 0; unsigned int PacketLength = 0;
@@ -172,7 +168,6 @@ static int writeData(void* _call)
iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, MPEG_VIDEO_PES_START_CODE, call->Pts, FakeStartCode); iov[0].iov_len = InsertPesHeader(PesHeader, PacketLength, MPEG_VIDEO_PES_START_CODE, call->Pts, FakeStartCode);
return writev(call->fd, iov, ic); return writev(call->fd, iov, ic);
} }
//NoOtherBeginningFound = 0;
if (initialHeader) if (initialHeader)
{ {