Here are two updated patches.

I have added the current version check to 1.3.7 and removed the header 
check for control operation.


On 05/01/2018 20:51, LongChair . wrote:
> Yes this was bound to very old versions afaik.
>
> Mpp repo was squashed and we didn't have any version requirement
>
> Current version is 1.3.7, if i trust my repo fork, previous version was
> 1.0.0, so we could add that as a requirement.
>
>
> On 05/01/2018 20:30, wm4 wrote:
>> On Fri, 5 Jan 2018 19:22:00 +0000
>> "LongChair ." <longch...@hotmail.com> wrote:
>>
>>> Yes the newly used  control operation seems to have always been there
>>> anyways, so there shouldn't be much compatibility issues.
>> I mean the second patch removes a workaround for some old misbehavior,
>> right? So it should probably be made sure that the user can't use an
>> old version.
>>
>> Also please avoid https://en.wikipedia.org/wiki/Top_posting#Top-posting
>> on the list.
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel@ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

From 0be5095d9858ca0bc28ba8392b7127cef88667df Mon Sep 17 00:00:00 2001
From: LongChair <longch...@hotmail.com>
Date: Sat, 6 Jan 2018 09:36:58 +0100
Subject: [PATCH] avcodec/rkmpp : Fix broken build due to missing control
 operation

This patch is taking care of https://trac.ffmpeg.org/ticket/6834.
It seems that one of the control operations that was available to get the free decoders input slots was removed.
There is another control operation to retrieve the used slots. Given that the input slot count is hardcoded to 4 in mpp at this point, replacing the old control operation by the other one.

This was tested on Rockchip ROCK64.
---
 configure             |  6 ++----
 libavcodec/rkmppdec.c | 10 ++++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 86d81e3cc3..455f9dc3fe 100755
--- a/configure
+++ b/configure
@@ -5993,10 +5993,8 @@ enabled openssl           && { check_pkg_config openssl openssl openssl/ssl.h OP
                                check_lib openssl openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
                                check_lib openssl openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
                                die "ERROR: openssl not found"; }
-enabled rkmpp             && { { require_pkg_config rkmpp rockchip_mpp rockchip/rk_mpi.h mpp_create ||
-                                 die "ERROR : Rockchip MPP was not found."; } &&
-                               { check_func_headers rockchip/rk_mpi_cmd.h "MPP_DEC_GET_FREE_PACKET_SLOT_COUNT" ||
-                                 die "ERROR: Rockchip MPP is outdated, please get a more recent one."; } &&
+enabled rkmpp             && { require_pkg_config rkmpp rockchip_mpp  rockchip/rk_mpi.h mpp_create &&
+                               require_pkg_config rockchip_mpp "rockchip_mpp >= 1.3.7" rockchip/rk_mpi.h mpp_create &&
                                { enabled libdrm ||
                                  die "ERROR: rkmpp requires --enable-libdrm"; }
                              }
diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
index c57a6ded38..946b827918 100644
--- a/libavcodec/rkmppdec.c
+++ b/libavcodec/rkmppdec.c
@@ -40,6 +40,7 @@
 
 #define RECEIVE_FRAME_TIMEOUT   100
 #define FRAMEGROUP_MAX_FRAMES   16
+#define INPUT_MAX_PACKETS       4
 
 typedef struct {
     MppCtx ctx;
@@ -515,16 +516,17 @@ static int rkmpp_receive_frame(AVCodecContext *avctx, AVFrame *frame)
     RKMPPDecoder *decoder = (RKMPPDecoder *)rk_context->decoder_ref->data;
     int ret = MPP_NOK;
     AVPacket pkt = {0};
-    RK_S32 freeslots;
+    RK_S32 usedslots, freeslots;
 
     if (!decoder->eos_reached) {
         // we get the available slots in decoder
-        ret = decoder->mpi->control(decoder->ctx, MPP_DEC_GET_FREE_PACKET_SLOT_COUNT, &freeslots);
+        ret = decoder->mpi->control(decoder->ctx, MPP_DEC_GET_STREAM_COUNT, &usedslots);
         if (ret != MPP_OK) {
-            av_log(avctx, AV_LOG_ERROR, "Failed to get decoder free slots (code = %d).\n", ret);
+            av_log(avctx, AV_LOG_ERROR, "Failed to get decoder used slots (code = %d).\n", ret);
             return ret;
         }
 
+        freeslots = INPUT_MAX_PACKETS - usedslots;
         if (freeslots > 0) {
             ret = ff_decode_get_packet(avctx, &pkt);
             if (ret < 0 && ret != AVERROR_EOF) {
@@ -541,7 +543,7 @@ static int rkmpp_receive_frame(AVCodecContext *avctx, AVFrame *frame)
         }
 
         // make sure we keep decoder full
-        if (freeslots > 1 && decoder->first_frame)
+        if (freeslots > 1)
             return AVERROR(EAGAIN);
     }
 
-- 
2.14.1

From 9b42a3c7f1230d001743099e9930f26a06ca6cf5 Mon Sep 17 00:00:00 2001
From: LongChair <longch...@hotmail.com>
Date: Tue, 2 Jan 2018 12:38:01 +0100
Subject: [PATCH] avcodec/rkmpp : remove stream start retries before first
 frame.

those were needed because of some odd mpp behavior that seems to have been fixed.
Makes the code cleaner.
---
 libavcodec/rkmppdec.c | 24 +++---------------------
 1 file changed, 3 insertions(+), 21 deletions(-)

diff --git a/libavcodec/rkmppdec.c b/libavcodec/rkmppdec.c
index 946b827918..143d05bd51 100644
--- a/libavcodec/rkmppdec.c
+++ b/libavcodec/rkmppdec.c
@@ -47,7 +47,6 @@ typedef struct {
     MppApi *mpi;
     MppBufferGroup frame_group;
 
-    char first_frame;
     char first_packet;
     char eos_reached;
 
@@ -329,28 +328,14 @@ static int rkmpp_retrieve_frame(AVCodecContext *avctx, AVFrame *frame)
     MppBuffer buffer = NULL;
     AVDRMFrameDescriptor *desc = NULL;
     AVDRMLayerDescriptor *layer = NULL;
-    int retrycount = 0;
     int mode;
     MppFrameFormat mppformat;
     uint32_t drmformat;
 
-    // on start of decoding, MPP can return -1, which is supposed to be expected
-    // this is due to some internal MPP init which is not completed, that will
-    // only happen in the first few frames queries, but should not be interpreted
-    // as an error, Therefore we need to retry a couple times when we get -1
-    // in order to let it time to complete it's init, then we sleep a bit between retries.
-retry_get_frame:
     ret = decoder->mpi->decode_get_frame(decoder->ctx, &mppframe);
-    if (ret != MPP_OK && ret != MPP_ERR_TIMEOUT && !decoder->first_frame) {
-        if (retrycount < 5) {
-            av_log(avctx, AV_LOG_DEBUG, "Failed to get a frame, retrying (code = %d, retrycount = %d)\n", ret, retrycount);
-            usleep(10000);
-            retrycount++;
-            goto retry_get_frame;
-        } else {
-            av_log(avctx, AV_LOG_ERROR, "Failed to get a frame from MPP (code = %d)\n", ret);
-            goto fail;
-        }
+    if (ret != MPP_OK && ret != MPP_ERR_TIMEOUT) {
+        av_log(avctx, AV_LOG_ERROR, "Failed to get a frame from MPP (code = %d)\n", ret);
+        goto fail;
     }
 
     if (mppframe) {
@@ -366,7 +351,6 @@ retry_get_frame:
             avctx->height = mpp_frame_get_height(mppframe);
 
             decoder->mpi->control(decoder->ctx, MPP_DEC_SET_INFO_CHANGE_READY, NULL);
-            decoder->first_frame = 1;
 
             av_buffer_unref(&decoder->frames_ref);
 
@@ -480,7 +464,6 @@ retry_get_frame:
                 goto fail;
             }
 
-            decoder->first_frame = 0;
             return 0;
         } else {
             av_log(avctx, AV_LOG_ERROR, "Failed to retrieve the frame buffer, frame is dropped (code = %d)\n", ret);
@@ -560,7 +543,6 @@ static void rkmpp_flush(AVCodecContext *avctx)
 
     ret = decoder->mpi->reset(decoder->ctx);
     if (ret == MPP_OK) {
-        decoder->first_frame = 1;
         decoder->first_packet = 1;
     } else
         av_log(avctx, AV_LOG_ERROR, "Failed to reset MPI (code = %d)\n", ret);
-- 
2.14.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to