video framerate is extramely low after commit f0d1d5364e30aa98f6d4cefd87f1e365ad5e205c
Closed this issue · 7 comments
amazingfate commented
My environment:
- rkr1 6.1 kernel
- chromium v121
- GPU driver is mainline panthor kernel driver and mainline git mesa
- Mesa has patched gbm to support NV12 rendering.
- mpp is from https://github.com/nyanmisaka/mpp/tree/jellyfin-mpp, from which nyanmisaka/mpp@81aef47 is necessary because kernel 6.1 has changed dma_heap. And mpp also need hack from #12 (comment) to support large av1 videos.
I encountered this issue before but at that moment I didn't configured all things right. Now I find this commit has caused the low fps issue.
JeffyCN commented
could not reproduce this issue...
the only part of this commit that might affect the decoding flow is in rkmpp_dqbuf(), but it looks fine
JeffyCN commented
maybe we can try to compare the v4l-rkmpp's verbose logs.
amazingfate commented
Here are the logs with env LIBV4L_RKMPP_LOG_LEVEL=7
rkmpp_fine.log.gz
rkmpp_slow.log.gz
amazingfate commented
reverting changes to rkmpp_dqbuf
would solve it.
diff --git a/src/libv4l-rkmpp.c b/src/libv4l-rkmpp.c
index 7ad4b53..9ddbf69 100644
--- a/src/libv4l-rkmpp.c
+++ b/src/libv4l-rkmpp.c
@@ -669,6 +669,7 @@ int rkmpp_dqbuf(struct rkmpp_context *ctx, struct v4l2_buffer *buffer)
pthread_mutex_lock(&queue->queue_mutex);
rkmpp_buffer = TAILQ_FIRST(&queue->avail_buffers);
+ TAILQ_REMOVE(&queue->avail_buffers, rkmpp_buffer, entry);
pthread_mutex_unlock(&queue->queue_mutex);
/* Update poll event after avail list changed */
@@ -680,10 +681,11 @@ int rkmpp_dqbuf(struct rkmpp_context *ctx, struct v4l2_buffer *buffer)
RETURN_ERR(EINVAL, -1);
}
- pthread_mutex_lock(&queue->queue_mutex);
+ if (rkmpp_buffer_keyframe(rkmpp_buffer))
+ rkmpp_buffer_clr_keyframe(rkmpp_buffer);
+ if (rkmpp_buffer_error(rkmpp_buffer))
+ rkmpp_buffer_clr_error(rkmpp_buffer);
rkmpp_buffer_clr_available(rkmpp_buffer);
- TAILQ_REMOVE(&queue->avail_buffers, rkmpp_buffer, entry);
- pthread_mutex_unlock(&queue->queue_mutex);
rkmpp_buffer_clr_queued(rkmpp_buffer);
amazingfate commented
And a smaller patch to fix:
diff --git a/src/libv4l-rkmpp.c b/src/libv4l-rkmpp.c
index 7ad4b53..0179b92 100644
--- a/src/libv4l-rkmpp.c
+++ b/src/libv4l-rkmpp.c
@@ -669,6 +669,7 @@ int rkmpp_dqbuf(struct rkmpp_context *ctx, struct v4l2_buffer *buffer)
pthread_mutex_lock(&queue->queue_mutex);
rkmpp_buffer = TAILQ_FIRST(&queue->avail_buffers);
+ TAILQ_REMOVE(&queue->avail_buffers, rkmpp_buffer, entry);
pthread_mutex_unlock(&queue->queue_mutex);
/* Update poll event after avail list changed */
@@ -682,7 +683,6 @@ int rkmpp_dqbuf(struct rkmpp_context *ctx, struct v4l2_buffer *buffer)
pthread_mutex_lock(&queue->queue_mutex);
rkmpp_buffer_clr_available(rkmpp_buffer);
- TAILQ_REMOVE(&queue->avail_buffers, rkmpp_buffer, entry);
pthread_mutex_unlock(&queue->queue_mutex);
rkmpp_buffer_clr_queued(rkmpp_buffer);
JeffyCN commented
huh, there's indeed a mistake around there, try:
--- a/src/libv4l-rkmpp.c
+++ b/src/libv4l-rkmpp.c
@@ -671,9 +671,6 @@ int rkmpp_dqbuf(struct rkmpp_context *ctx, struct v4l2_buffer *buffer)
rkmpp_buffer = TAILQ_FIRST(&queue->avail_buffers);
pthread_mutex_unlock(&queue->queue_mutex);
- /* Update poll event after avail list changed */
- rkmpp_update_poll_event(ctx);
-
ret = rkmpp_to_v4l2_buffer(ctx, rkmpp_buffer, buffer);
if (ret < 0) {
LOGE("failed to convert buffer\n");
@@ -687,6 +684,9 @@ int rkmpp_dqbuf(struct rkmpp_context *ctx, struct v4l2_buffer *buffer)
rkmpp_buffer_clr_queued(rkmpp_buffer);
+ /* Update poll event after avail list changed */
+ rkmpp_update_poll_event(ctx);
+
LOGV(2, "dequeue buffer: %d(%" PRIu64 "), size: %d, type: %d\n",
buffer->index, rkmpp_buffer->timestamp,
rkmpp_buffer->bytesused, buffer->type);
amazingfate commented
Yes that does fix my issue!