From b7b58140f40e35a079c738096466c7cabad49139 Mon Sep 17 00:00:00 2001 From: martii Date: Mon, 29 Jul 2013 18:35:48 +0200 Subject: [PATCH] libeplayer3 optimizations Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/5aa75077cd9a02a31ae01439d3f846485e618522 Author: martii Date: 2013-07-29 (Mon, 29 Jul 2013) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- generic-pc/playback.cpp | 4 +++ generic-pc/playback.h | 1 + libeplayer3/container/container_ffmpeg.c | 2 +- libeplayer3/output/writer/framebuffer.c | 45 +++++++++++------------- libeplayer3/output/writer/h264.c | 5 --- libeplayer3/output/writer/pcm.c | 2 +- libspark/playback_libeplayer3.cpp | 5 +++ libspark/playback_libeplayer3.h | 1 + 8 files changed, 33 insertions(+), 32 deletions(-) diff --git a/generic-pc/playback.cpp b/generic-pc/playback.cpp index b5795a5..60c84a8 100644 --- a/generic-pc/playback.cpp +++ b/generic-pc/playback.cpp @@ -73,6 +73,10 @@ bool cPlayback::SetSubtitlePid(unsigned short /*pid*/) return true; } +void cPlayback::GetPts(uint64_t &/*pts*/) +{ +} + bool cPlayback::SetDvbsubtitlePid(unsigned short /*pid*/) { return true; diff --git a/generic-pc/playback.h b/generic-pc/playback.h index 2f43c0d..4df05db 100644 --- a/generic-pc/playback.h +++ b/generic-pc/playback.h @@ -37,6 +37,7 @@ class cPlayback bool SetSpeed(int speed); bool GetSpeed(int &speed) const; bool GetPosition(int &position, int &duration); + void GetPts(uint64_t &pts); bool SetPosition(int position, bool absolute = false); void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language); void FindAllSubtitlePids(uint16_t *pids, uint16_t *numpids, std::string *language); diff --git a/libeplayer3/container/container_ffmpeg.c b/libeplayer3/container/container_ffmpeg.c index 957f63f..958f232 100644 --- a/libeplayer3/container/container_ffmpeg.c +++ b/libeplayer3/container/container_ffmpeg.c @@ -106,7 +106,7 @@ static AVFormatContext* avContext = NULL; static unsigned char isContainerRunning = 0; -long long int latestPts = 0; +static long long int latestPts = 0; static int restart_audio_resampling = 0; static off_t seek_target_bytes = 0; diff --git a/libeplayer3/output/writer/framebuffer.c b/libeplayer3/output/writer/framebuffer.c index 3b69752..be43f21 100644 --- a/libeplayer3/output/writer/framebuffer.c +++ b/libeplayer3/output/writer/framebuffer.c @@ -118,20 +118,19 @@ static int writeData(void* _call) return 0; } + int dst_stride = call->destStride/sizeof(uint32_t); + int dst_delta = dst_stride - call->Width; + uint32_t *dst = call->destination + call->y * dst_stride + call->x; + 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_delta = dst_stride - call->Width; - uint32_t *dst = call->destination + call->y * dst_stride + call->x; - static uint32_t last_color = 0; - static uint32_t colortable[256]; + 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) { // call->color is rgba, our spark frame buffer is argb - uint32_t c = call->color >> 8; - uint32_t a = 255 - (call->color & 0xff); + uint32_t c = call->color >> 8, a = 255 - (call->color & 0xff); int i; for (i = 0; i < 256; i++) { 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.stride %d\n", call->destStride); - for (y=0;yHeight;y++) { - for (x = 0; x < call->Width; x++) { - uint32_t c = colortable[src[x]]; + unsigned char *src_final = src + call->Height * call->Width; + for (; src < src_final; dst += dst_delta, src += src_delta) { + u_char *src_end = src + call->Width; + for (; src < src_end; dst++, src++) { + uint32_t c = colortable[*src]; if (c) - *dst++ = c; - else - dst++; + *dst = c; } - 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; + uint32_t *dst_final = dst + call->Width + call->Height * dst_stride; + for (; dst < dst_final; dst += dst_delta) { + uint32_t *dst_end = dst + call->Width; + for (; dst < dst_end; dst++) + *dst = 0; } } diff --git a/libeplayer3/output/writer/h264.c b/libeplayer3/output/writer/h264.c index 0694e3b..e11a419 100644 --- a/libeplayer3/output/writer/h264.c +++ b/libeplayer3/output/writer/h264.c @@ -92,7 +92,6 @@ typedef struct avcC_s /* ***************************** */ const unsigned char Head[] = {0, 0, 0, 1}; static int initialHeader = 1; -//static int NoOtherBeginningFound = 1; static unsigned int NalLengthBytes = 1; /* ***************************** */ @@ -106,7 +105,6 @@ static unsigned int NalLengthBytes = 1; static int reset() { initialHeader = 1; - //NoOtherBeginningFound = 1; 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) || -// 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))) { 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); return writev(call->fd, iov, ic); } - //NoOtherBeginningFound = 0; if (initialHeader) { diff --git a/libeplayer3/output/writer/pcm.c b/libeplayer3/output/writer/pcm.c index d4fbe36..c49c0d8 100644 --- a/libeplayer3/output/writer/pcm.c +++ b/libeplayer3/output/writer/pcm.c @@ -206,7 +206,7 @@ static int writeData(void* _call) if (initialHeader) { initialHeader = 0; prepareClipPlay(pcmPrivateData->uNoOfChannels, pcmPrivateData->uSampleRate, - pcmPrivateData->uBitsPerSample, pcmPrivateData->bLittleEndian); + pcmPrivateData->uBitsPerSample, pcmPrivateData->bLittleEndian); } unsigned char * buffer = call->data; diff --git a/libspark/playback_libeplayer3.cpp b/libspark/playback_libeplayer3.cpp index f12d25f..11a57ec 100644 --- a/libspark/playback_libeplayer3.cpp +++ b/libspark/playback_libeplayer3.cpp @@ -430,6 +430,11 @@ bool cPlayback::GetSpeed(int &speed) const return true; } +void cPlayback::GetPts(uint64_t &pts) +{ + player->playback->Command(player, PLAYBACK_PTS, (void*)pts); +} + // in milliseconds bool cPlayback::GetPosition(int &position, int &duration) { diff --git a/libspark/playback_libeplayer3.h b/libspark/playback_libeplayer3.h index feb28a0..4bdbabd 100644 --- a/libspark/playback_libeplayer3.h +++ b/libspark/playback_libeplayer3.h @@ -41,6 +41,7 @@ class cPlayback bool SetSpeed(int speed); bool GetSpeed(int &speed) const; bool GetPosition(int &position, int &duration); + void GetPts(uint64_t &pts); bool SetPosition(int position, bool absolute = false); void FindAllPids(uint16_t *apids, unsigned short *ac3flags, uint16_t *numpida, std::string *language); void FindAllSubtitlePids(uint16_t *pids, uint16_t *numpids, std::string *language);