mirror of
https://github.com/motioneye-project/motioneyeos.git
synced 2025-07-27 13:16:35 +00:00
Merge pull request #1784 from jasaw/rpi-only-omx-endofframe
ffmpeg omx endofframe: updated patch file to official version
This commit is contained in:
commit
211c885786
@ -0,0 +1,66 @@
|
|||||||
|
From e729ce6f24d3bc850c9dfdbd8684d1a54864df2b Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||||
|
Date: Thu, 17 Jan 2019 17:39:34 +0000
|
||||||
|
Subject: [PATCH] avcodec/omx: Fix handling of fragmented buffers
|
||||||
|
|
||||||
|
See https://trac.ffmpeg.org/ticket/7687
|
||||||
|
|
||||||
|
If an encoded frame is returned split over two or more
|
||||||
|
IL buffers due to the size, then there is a race between
|
||||||
|
whether get_buffer will fail, return NULL, and a truncated
|
||||||
|
frame is passed on, or IL will return the remaining part
|
||||||
|
of the encoded frame.
|
||||||
|
If get_buffer returns NULL, part of the frame is left behind
|
||||||
|
in the codec, and will be collected on the next call. That
|
||||||
|
then leaves a frame stuck in the codec. Repeat enough times
|
||||||
|
and the codec FIFO is full, and the pipeline stalls.
|
||||||
|
|
||||||
|
A performance improvement in the Raspberry Pi firmware means
|
||||||
|
that the timing has changed, and now frequently drops into the
|
||||||
|
case where get_buffer returns NULL.
|
||||||
|
|
||||||
|
Add code such that should a buffer be received without
|
||||||
|
OMX_BUFFERFLAG_ENDOFFRAME that get_buffer is called with wait
|
||||||
|
set, so we wait for the remainder of the frame.
|
||||||
|
This code has been made conditional on the Pi build in case
|
||||||
|
other IL implementations don't handle ENDOFFRAME correctly.
|
||||||
|
|
||||||
|
Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
|
||||||
|
---
|
||||||
|
libavcodec/omx.c | 6 +++++-
|
||||||
|
1 file changed, 5 insertions(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/libavcodec/omx.c b/libavcodec/omx.c
|
||||||
|
index 466e0be..e813362 100644
|
||||||
|
--- a/libavcodec/omx.c
|
||||||
|
+++ b/libavcodec/omx.c
|
||||||
|
@@ -739,6 +739,7 @@ static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
|
int ret = 0;
|
||||||
|
OMX_BUFFERHEADERTYPE* buffer;
|
||||||
|
OMX_ERRORTYPE err;
|
||||||
|
+ int had_partial = 0;
|
||||||
|
|
||||||
|
if (frame) {
|
||||||
|
uint8_t *dst[4];
|
||||||
|
@@ -830,7 +831,7 @@ static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
|
// packet, or get EOS.
|
||||||
|
buffer = get_buffer(&s->output_mutex, &s->output_cond,
|
||||||
|
&s->num_done_out_buffers, s->done_out_buffers,
|
||||||
|
- !frame);
|
||||||
|
+ !frame || had_partial);
|
||||||
|
if (!buffer)
|
||||||
|
break;
|
||||||
|
|
||||||
|
@@ -865,6 +866,9 @@ static int omx_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
|
||||||
|
s->output_buf = NULL;
|
||||||
|
s->output_buf_size = 0;
|
||||||
|
}
|
||||||
|
+#if CONFIG_OMX_RPI
|
||||||
|
+ had_partial = 1;
|
||||||
|
+#endif
|
||||||
|
} else {
|
||||||
|
// End of frame, and the caller provided a preallocated frame
|
||||||
|
if ((ret = ff_alloc_packet2(avctx, pkt, s->output_buf_size + buffer->nFilledLen, 0)) < 0) {
|
||||||
|
--
|
||||||
|
2.7.4
|
||||||
|
|
@ -1,31 +0,0 @@
|
|||||||
Addresses https://github.com/raspberrypi/firmware/issues/1087
|
|
||||||
---
|
|
||||||
|
|
||||||
diff -rupEbBN ffmpeg-3.4.4.org/libavcodec/omx.c ffmpeg-3.4.4/libavcodec/omx.c
|
|
||||||
--- ffmpeg-3.4.4.org/libavcodec/omx.c 2019-01-17 15:08:50.141300045 +1100
|
|
||||||
+++ ffmpeg-3.4.4/libavcodec/omx.c 2019-01-17 16:07:12.337292988 +1100
|
|
||||||
@@ -735,6 +735,7 @@ static int omx_encode_frame(AVCodecConte
|
|
||||||
int ret = 0;
|
|
||||||
OMX_BUFFERHEADERTYPE* buffer;
|
|
||||||
OMX_ERRORTYPE err;
|
|
||||||
+ int had_partial = 0;
|
|
||||||
|
|
||||||
if (frame) {
|
|
||||||
uint8_t *dst[4];
|
|
||||||
@@ -826,7 +827,7 @@ static int omx_encode_frame(AVCodecConte
|
|
||||||
// packet, or get EOS.
|
|
||||||
buffer = get_buffer(&s->output_mutex, &s->output_cond,
|
|
||||||
&s->num_done_out_buffers, s->done_out_buffers,
|
|
||||||
- !frame);
|
|
||||||
+ !frame || had_partial);
|
|
||||||
if (!buffer)
|
|
||||||
break;
|
|
||||||
|
|
||||||
@@ -861,6 +862,7 @@ static int omx_encode_frame(AVCodecConte
|
|
||||||
s->output_buf = NULL;
|
|
||||||
s->output_buf_size = 0;
|
|
||||||
}
|
|
||||||
+ had_partial = 1;
|
|
||||||
} else {
|
|
||||||
// End of frame, and the caller provided a preallocated frame
|
|
||||||
if ((ret = ff_alloc_packet2(avctx, pkt, s->output_buf_size + buffer->nFilledLen, 0)) < 0) {
|
|
Loading…
x
Reference in New Issue
Block a user