From 9305b4763e7d1260394debd00cf69fa6b075640a Mon Sep 17 00:00:00 2001 From: max_10 Date: Fri, 1 Mar 2019 22:28:03 +0100 Subject: [PATCH 1/3] Revert "Revert "workaround for double malloc if container_ffmpeg_stop is not called after file play to end"" This reverts commit 83d9b453fcfcb1907a633c112b54a4dbc325fe14. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/a15c6523e2f1df9559f38bd13efd146ffa2d2c81 Author: max_10 Date: 2019-03-01 (Fri, 01 Mar 2019) ------------------ This commit was generated by Migit --- libeplayer3-arm/container/container_ffmpeg.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index ea9fb36..074155c 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -1533,7 +1533,9 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin 0 == strncmp(filename, "file://", 7)) { AVIOContext *avio_ctx = NULL; - custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t)); + if(custom_io_tab[AVIdx] == NULL)//workaround for double malloc if container_ffmpeg_stop is not called after file play to end + custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t)); + memset(custom_io_tab[AVIdx], 0x00, sizeof(CustomIOCtx_t)); custom_io_tab[AVIdx]->szFile = filename; @@ -2731,7 +2733,11 @@ static int32_t container_ffmpeg_stop(Context_t *context) fclose(io->pFile); if (io->pMoovFile) fclose(io->pMoovFile); - free(custom_io_tab[i]); + if(custom_io_tab[i] != NULL) + { + free(custom_io_tab[i]); + custom_io_tab[i] = NULL; + } av_freep(&(avContextTab[i]->pb->buffer)); av_freep(&(avContextTab[i]->pb)); use_custom_io[i] = 0; From 908acaced56677bd02db80427e795b68c6220b7d Mon Sep 17 00:00:00 2001 From: max_10 Date: Fri, 1 Mar 2019 22:28:36 +0100 Subject: [PATCH 2/3] Revert "Revert "try fix to call container_ffmpeg_stop on file EOF"" This reverts commit d7295b8630994d72424c87e6a491181bf3774a53. Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/ff162844e81e0a9b08d3f0f2329365fdce320bc7 Author: max_10 Date: 2019-03-01 (Fri, 01 Mar 2019) ------------------ This commit was generated by Migit --- libeplayer3-arm/container/container_ffmpeg.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libeplayer3-arm/container/container_ffmpeg.c b/libeplayer3-arm/container/container_ffmpeg.c index 074155c..4692b4e 100644 --- a/libeplayer3-arm/container/container_ffmpeg.c +++ b/libeplayer3-arm/container/container_ffmpeg.c @@ -126,6 +126,7 @@ static int32_t container_ffmpeg_seek(Context_t *context, int64_t sec, uint8_t ab static int32_t container_ffmpeg_get_length(Context_t *context, int64_t *length); static int64_t calcPts(uint32_t avContextIdx, AVStream *stream, int64_t pts); static int64_t doCalcPts(int64_t start_time, const AVRational time_base, int64_t pts); +static int32_t container_ffmpeg_stop(Context_t *context); /* Progressive playback means that we play local file * but this local file can grows up, for example @@ -1352,6 +1353,11 @@ static void FFMPEGThread(Context_t *context) do_seek_target_seconds = 0; PlaybackDieNow(1); + if(context && context->playback) + { + container_ffmpeg_stop(context); + } + ffmpeg_printf(10, "terminating\n"); } @@ -1533,8 +1539,7 @@ int32_t container_ffmpeg_init_av_context(Context_t *context, char *filename, uin 0 == strncmp(filename, "file://", 7)) { AVIOContext *avio_ctx = NULL; - if(custom_io_tab[AVIdx] == NULL)//workaround for double malloc if container_ffmpeg_stop is not called after file play to end - custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t)); + custom_io_tab[AVIdx] = malloc(sizeof(CustomIOCtx_t)); memset(custom_io_tab[AVIdx], 0x00, sizeof(CustomIOCtx_t)); From 0976ceac2061672a357916619c1434c70a52bcd3 Mon Sep 17 00:00:00 2001 From: Frankenstone Date: Sat, 2 Mar 2019 10:34:36 +0100 Subject: [PATCH 3/3] armhardware reduce ffmpeg warnings part 2 - thx DbO Origin commit data ------------------ Branch: master Commit: https://github.com/neutrino-images/ni-libstb-hal/commit/e2de3b1050e375a129f1ffaee2bbbe89783a0a51 Author: Frankenstone Date: 2019-03-02 (Sat, 02 Mar 2019) ------------------ This commit was generated by Migit --- libarmbox/video.cpp | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/libarmbox/video.cpp b/libarmbox/video.cpp index 46dc683..3e3f7ca 100644 --- a/libarmbox/video.cpp +++ b/libarmbox/video.cpp @@ -201,14 +201,28 @@ void write_frame(AVFrame* in_frame, int fd) AVPacket pkt; av_init_packet(&pkt); /* encode the image */ +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57,37,100) int got_output = 0; int ret = avcodec_encode_video2(codec_context, &pkt, in_frame, &got_output); if (ret != -1){ - int i =1; +#else + int ret = avcodec_send_frame(codec_context, in_frame); + if (!ret) { + /* signalling end of stream */ + ret = avcodec_send_frame(codec_context, NULL); + } + if (!ret) { +#endif + int i = 1; /* get the delayed frames */ in_frame->pts = i; +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57,37,100) ret = avcodec_encode_video2(codec_context, &pkt, 0, &got_output); if (ret != -1 && got_output){ +#else + ret = avcodec_receive_packet(codec_context, &pkt); + if (!ret) { +#endif if ((pkt.data[3] >> 4) != 0xE){ write_all(fd, pes_header, sizeof(pes_header)); }else{ @@ -227,13 +241,29 @@ void write_frame(AVFrame* in_frame, int fd) int decode_frame(AVCodecContext *codecContext,AVPacket &packet, int fd) { - int decode_ok = 0; AVFrame *frame = av_frame_alloc(); if(frame){ +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57,37,100) + int decode_ok = 0; if ((avcodec_decode_video2(codecContext, frame, &decode_ok, &packet)) < 0 || !decode_ok){ av_frame_free(&frame); return -1; } +#else + int ret; + ret = avcodec_send_packet(codecContext, &packet); + // In particular, we don't expect AVERROR(EAGAIN), because we read all + // decoded frames with avcodec_receive_frame() until done. + if (ret < 0) { + av_frame_free(&frame); + return -1; + } + ret = avcodec_receive_frame(codecContext, frame); + if (ret < 0) { + av_frame_free(&frame); + return -1; + } +#endif AVFrame *dest_frame = av_frame_alloc(); if(dest_frame){ dest_frame->height = (frame->height/2)*2; @@ -604,7 +634,7 @@ void cVideo::SetVideoMode(analog_mode_t mode) void cVideo::ShowPicture(const char * fname) { - hal_debug("%s(%s)\n", __func__, fname); + hal_info("%s(%s)\n", __func__, fname); if (video_standby) { /* does not work and the driver does not seem to like it */