From 25f676d95631bc67464b0e561305136ed82b4725 Mon Sep 17 00:00:00 2001 From: TangoCash Date: Sun, 21 Jan 2018 15:46:53 +0100 Subject: [PATCH 1/3] arm try fix fast backward Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/3c4f9f328c4a32238df06942168a63754d6681ac Author: TangoCash Date: 2018-01-21 (Sun, 21 Jan 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3-arm/container/container_ffmpeg.c | 30 +++++++++++--------- libeplayer3-arm/playback/playback.c | 28 ++++++++++++++---- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index 12cd061..67dd742 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -59,7 +59,7 @@ /* ***************************** */ /* Makros/Constants */ /* ***************************** */ -#if (LIBAVFORMAT_VERSION_MAJOR > 57) +#if (LIBAVFORMAT_VERSION_MAJOR > 56) #define TS_BYTES_SEEKING 0 #else #define TS_BYTES_SEEKING 1 @@ -2365,9 +2365,10 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab Track_t *audioTrack = NULL; Track_t *current = NULL; seek_target_flag = 0; + sec *= AV_TIME_BASE; if (!absolute) { - ffmpeg_printf(10, "seeking %f sec\n", sec); + ffmpeg_printf(10, "seeking %lld sec\n", sec / AV_TIME_BASE); if (sec == 0) { ffmpeg_err("sec = 0 ignoring\n"); @@ -2382,14 +2383,15 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab ffmpeg_err("fail to get current PTS\n"); return cERR_CONTAINER_FFMPEG_ERR; } - sec += currPts / 90000; + sec += (currPts / 90000 * AV_TIME_BASE); + } + + if (sec < 0) + { + sec = 0; } } - ffmpeg_printf(10, "goto %d sec\n", sec); - if (sec < 0) - { - sec = 0; - } + ffmpeg_printf(10, "goto %lld sec\n", sec / AV_TIME_BASE); context->manager->video->Command(context, MANAGER_GET_TRACK, &videoTrack); context->manager->audio->Command(context, MANAGER_GET_TRACK, &audioTrack); if (videoTrack != NULL) @@ -2415,7 +2417,7 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab releaseMutex(__FILE__, __FUNCTION__, __LINE__); return cERR_CONTAINER_FFMPEG_NO_ERROR; } - ffmpeg_printf(10, "iformat->flags %d\n", avContextTab[0]->iformat->flags); + ffmpeg_printf(10, "iformat->flags 0x%08x\n", avContextTab[0]->iformat->flags); #if defined(TS_BYTES_SEEKING) && TS_BYTES_SEEKING if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT) { @@ -2426,11 +2428,11 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab * about 10 seconds, backward does not work. */ off_t pos = avio_tell(avContextTab[0]->pb); - ffmpeg_printf(10, "pos %lld %d\n", pos, avContextTab[0]->bit_rate); + ffmpeg_printf(10, "pos %lld %lld\n", pos, avContextTab[0]->bit_rate); if (avContextTab[0]->bit_rate) { sec *= avContextTab[0]->bit_rate / 8; - ffmpeg_printf(10, "bit_rate %d\n", avContextTab[0]->bit_rate); + ffmpeg_printf(10, "bit_rate %lld\n", avContextTab[0]->bit_rate); } else { @@ -2441,14 +2443,14 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab { pos = 0; } - ffmpeg_printf(10, "1. seeking to position %lld bytes ->sec %d\n", pos, sec); - seek_target_bytes = pos; + ffmpeg_printf(10, "1. seeking to position %lld bytes ->sec %lld\n", pos / AV_TIME_BASE, sec / AV_TIME_BASE); + seek_target_bytes = pos / AV_TIME_BASE; do_seek_target_bytes = 1; } else #endif { - seek_target_seconds = sec * AV_TIME_BASE; + seek_target_seconds = sec; do_seek_target_seconds = 1; } releaseMutex(__FILE__, __FUNCTION__, __LINE__); diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index 986017e..0ea3ad3 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -95,7 +95,22 @@ static void SupervisorThread(Context_t *context) hasThreadStarted = 1; playback_printf(10, ">\n"); while (context && context->playback && context->playback->isPlaying && !context->playback->abortRequested) - usleep(100000); + { + if (context->playback->BackWard != 0) + { + /* Offset -3 seconds for backward + * so initial backward speed is 4x */ + int64_t pos = (int64_t)context->playback->Speed - 3; + playback_printf(10, "Speed %d BackWard %d to seek %lld\n", context->playback->Speed, context->playback->BackWard, pos); + context->playback->isSeeking = 1; + context->output->Command(context, OUTPUT_CLEAR, NULL); + context->container->selectedContainer->Command(context, CONTAINER_SEEK, &pos); + context->playback->isSeeking = 0; + usleep(350000); + } else { + usleep(100000); + } + } playback_printf(10, "<\n"); hasThreadStarted = 2; PlaybackTerminate(context); @@ -310,8 +325,10 @@ static int32_t PlaybackContinue(Context_t *context) (context->playback->isPaused || context->playback->isForwarding || context->playback->BackWard || context->playback->SlowMotion)) { - if (context->playback->SlowMotion || context->playback->isForwarding) + if (context->playback->SlowMotion || context->playback->isForwarding || context->playback->BackWard) context->output->Command(context, OUTPUT_CLEAR, NULL); + if (context->playback->BackWard) + context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); context->playback->isPaused = 0; //context->playback->isPlaying = 1; context->playback->isForwarding = 0; @@ -453,15 +470,16 @@ static int PlaybackFastBackward(Context_t *context, int *speed) { context->playback->BackWard = 0; context->playback->Speed = 0; /* reverse end */ + context->output->Command(context, OUTPUT_AUDIOMUTE, "0"); } else { context->playback->isSeeking = 1; context->playback->Speed = *speed; - context->playback->BackWard = 2 ^ (*speed); - playback_printf(1, "S %d B %f\n", context->playback->Speed, context->playback->BackWard); + context->playback->BackWard = 1; + context->output->Command(context, OUTPUT_AUDIOMUTE, "1"); + playback_printf(1, "S %d B %d\n", context->playback->Speed, context->playback->BackWard); } - context->output->Command(context, OUTPUT_AUDIOMUTE, "1"); context->output->Command(context, OUTPUT_CLEAR, NULL); if (context->output->Command(context, OUTPUT_REVERSE, NULL) < 0) { From 0e82f74070c932e05ddf03f8b34f761c30eec17e Mon Sep 17 00:00:00 2001 From: Jacek Jendrzej Date: Wed, 3 Jan 2018 19:33:40 +0100 Subject: [PATCH 2/3] remove double AV_CODEC_ID_EAC3 Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/c62d4b189ec03f188c9d7bbd5bdc4195fce54f82 Author: Jacek Jendrzej Date: 2018-01-03 (Wed, 03 Jan 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3-arm/container/container_ffmpeg.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index 67dd742..eb47aff 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -391,7 +391,6 @@ static char *Codec2Encoding(int32_t codec_id, int32_t media_type, uint8_t *extra case AV_CODEC_ID_WMAV1: case AV_CODEC_ID_WMAV2: return (wma_software_decode) ? "A_IPCM" : "A_WMA"; - case 86056: case AV_CODEC_ID_WMAPRO: return (wma_software_decode) ? "A_IPCM" : "A_WMA/PRO"; case AV_CODEC_ID_WMALOSSLESS: From 0591307fed2335d82a7b0bf84526292e85fce7fb Mon Sep 17 00:00:00 2001 From: max_10 Date: Wed, 24 Jan 2018 01:11:57 +0100 Subject: [PATCH 3/3] arm try improve fast backward Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/e841fe20584565639248614a6f8fdcf54fb2460c Author: max_10 Date: 2018-01-24 (Wed, 24 Jan 2018) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- libeplayer3-arm/container/container_ffmpeg.c | 48 ++++++++++++++++++-- libeplayer3-arm/playback/playback.c | 15 +----- 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index eb47aff..ed39ac1 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -588,8 +588,48 @@ static void FFMPEGThread(Context_t *context) } continue; } + if (context->playback->BackWard && av_gettime() >= showtime) { + context->output->Command(context, OUTPUT_CLEAR, "video"); + + if (bofcount == 1) { + showtime = av_gettime(); + usleep(100000); + continue; + } + + if (avContextTab[0]->iformat->flags & AVFMT_TS_DISCONT) { + off_t pos = avio_tell(avContextTab[0]->pb); + + if (pos > 0) { + float br; + if (avContextTab[0]->bit_rate) + br = avContextTab[0]->bit_rate / 8.0; + else + br = 180000.0; + seek_target_bytes = (double)pos + (double)context->playback->Speed * 8.0 * br; + if (seek_target_bytes < 0) + seek_target_bytes = 1; + do_seek_target_bytes = 1; + } + } + else + { + int64_t currPts = -1; + context->playback->Command(context, PLAYBACK_PTS, &currPts); + seek_target_seconds = ((double)currPts / 90000.0 + context->playback->Speed) * AV_TIME_BASE; + if (seek_target_seconds < 0) + seek_target_seconds = AV_TIME_BASE; + do_seek_target_seconds = 1; + } + showtime = av_gettime() + 300000; //jump back every 300ms + } + else + { + bofcount = 0; + } if (do_seek_target_seconds || do_seek_target_bytes) { + int res = -1; isWaitingForFinish = 0; if (do_seek_target_seconds) { @@ -607,8 +647,9 @@ static void FFMPEGThread(Context_t *context) { seek_target_seconds += avContextTab[i]->start_time; } - //av_seek_frame(avContextTab[i], -1, seek_target_seconds, 0); - avformat_seek_file(avContextTab[i], -1, INT64_MIN, seek_target_seconds, INT64_MAX, 0); + res = avformat_seek_file(avContextTab[i], -1, INT64_MIN, seek_target_seconds, INT64_MAX, 0); + if (res < 0 && context->playback->BackWard) + bofcount = 1; } else { @@ -1784,7 +1825,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 { track.TimeScale = 1000; } - ffmpeg_printf(10, "bit_rate [%d]\n", get_codecpar(stream)->bit_rate); + ffmpeg_printf(10, "bit_rate [%lld]\n", get_codecpar(stream)->bit_rate); ffmpeg_printf(10, "time_base.den [%d]\n", stream->time_base.den); ffmpeg_printf(10, "time_base.num [%d]\n", stream->time_base.num); ffmpeg_printf(10, "width [%d]\n", get_codecpar(stream)->width); @@ -1803,6 +1844,7 @@ int32_t container_ffmpeg_update_tracks(Context_t *context, char *filename, int32 ffmpeg_printf(10, "Stream has no duration so we take the duration from context\n"); track.duration = (int64_t) avContext->duration / 1000; } + ffmpeg_printf(10, "duration [%lld]\n", track.duration); if (context->manager->video) { if (get_codecpar(stream)->codec_id == AV_CODEC_ID_MPEG4) diff --git a/libeplayer3-arm/playback/playback.c b/libeplayer3-arm/playback/playback.c index 0ea3ad3..071ef40 100644 --- a/libeplayer3-arm/playback/playback.c +++ b/libeplayer3-arm/playback/playback.c @@ -96,20 +96,7 @@ static void SupervisorThread(Context_t *context) playback_printf(10, ">\n"); while (context && context->playback && context->playback->isPlaying && !context->playback->abortRequested) { - if (context->playback->BackWard != 0) - { - /* Offset -3 seconds for backward - * so initial backward speed is 4x */ - int64_t pos = (int64_t)context->playback->Speed - 3; - playback_printf(10, "Speed %d BackWard %d to seek %lld\n", context->playback->Speed, context->playback->BackWard, pos); - context->playback->isSeeking = 1; - context->output->Command(context, OUTPUT_CLEAR, NULL); - context->container->selectedContainer->Command(context, CONTAINER_SEEK, &pos); - context->playback->isSeeking = 0; - usleep(350000); - } else { - usleep(100000); - } + usleep(100000); } playback_printf(10, "<\n"); hasThreadStarted = 2;