Message ID | 20220104090836.31660-5-ming.qian@nxp.com |
---|---|
State | Accepted |
Commit | 35a9307beb6c179a5e517c0d90d5991ed45c07ac |
Headers | show |
Series | [FFmpeg-devel,v5,1/7] avcodec/v4l2_context: don't reinit output queue when dynamic resolution change | expand |
Context | Check | Description |
---|---|---|
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
andriy/make_ppc | success | Make finished |
andriy/make_fate_ppc | fail | Make fate failed |
On Tue, 04. Jan 17:08, Ming Qian wrote: > client need to resume the decoding process > after it dequeues the source change event. > no matter what's the return value of v4l2_resolution_changed(). > if the client doesn't resume the decoding process, > the decoder may keep waiting > > in documentation of v4l2 stateful decoder, we can see the following > description: > The client must continue the sequence as described below to > continue the decoding process. > 1. Dequeue the source change event. > Important > A source change triggers an implicit decoder drain, > similar to the explicit Drain sequence. The decoder is > stopped after it completes. The decoding process must be > resumed with either a pair of calls to > VIDIOC_STREAMOFF() and VIDIOC_STREAMON() on the CAPTURE > queue, or a call to VIDIOC_DECODER_CMD() with the > V4L2_DEC_CMD_START command. > 2. Continue with the Capture Setup sequence. > This is just a clean up to remove the reinit variable so the commit title and description are wrong. Thanks,
On Tue, 04. Jan 17:41, Andriy Gelman wrote: > On Tue, 04. Jan 17:08, Ming Qian wrote: > > client need to resume the decoding process > > after it dequeues the source change event. > > no matter what's the return value of v4l2_resolution_changed(). > > if the client doesn't resume the decoding process, > > the decoder may keep waiting > > > > in documentation of v4l2 stateful decoder, we can see the following > > description: > > The client must continue the sequence as described below to > > continue the decoding process. > > 1. Dequeue the source change event. > > Important > > A source change triggers an implicit decoder drain, > > similar to the explicit Drain sequence. The decoder is > > stopped after it completes. The decoding process must be > > resumed with either a pair of calls to > > VIDIOC_STREAMOFF() and VIDIOC_STREAMON() on the CAPTURE > > queue, or a call to VIDIOC_DECODER_CMD() with the > > V4L2_DEC_CMD_START command. > > 2. Continue with the Capture Setup sequence. > > > > This is just a clean up to remove the reinit variable so the commit title and > description are wrong. > Updated the commit message and pushed. Thanks,
diff --git a/libavcodec/v4l2_context.c b/libavcodec/v4l2_context.c index 0a0f5b226960..b7b584dfbef6 100644 --- a/libavcodec/v4l2_context.c +++ b/libavcodec/v4l2_context.c @@ -180,7 +180,7 @@ static int v4l2_handle_event(V4L2Context *ctx) V4L2m2mContext *s = ctx_to_m2mctx(ctx); struct v4l2_format cap_fmt = s->capture.format; struct v4l2_event evt = { 0 }; - int reinit, ret; + int ret; ret = ioctl(s->fd, VIDIOC_DQEVENT, &evt); if (ret < 0) { @@ -202,8 +202,7 @@ static int v4l2_handle_event(V4L2Context *ctx) return 0; } - reinit = v4l2_resolution_changed(&s->capture, &cap_fmt); - if (reinit) { + if (v4l2_resolution_changed(&s->capture, &cap_fmt)) { s->capture.height = v4l2_get_height(&cap_fmt); s->capture.width = v4l2_get_width(&cap_fmt); s->capture.sample_aspect_ratio = v4l2_get_sar(&s->capture); @@ -212,28 +211,20 @@ static int v4l2_handle_event(V4L2Context *ctx) return 0; } - if (reinit) - s->reinit = 1; + s->reinit = 1; - if (reinit) { - if (s->avctx) - ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height); - if (ret < 0) - av_log(logger(ctx), AV_LOG_WARNING, "update avcodec height and width\n"); + if (s->avctx) + ret = ff_set_dimensions(s->avctx, s->capture.width, s->capture.height); + if (ret < 0) + av_log(logger(ctx), AV_LOG_WARNING, "update avcodec height and width\n"); - ret = ff_v4l2_m2m_codec_reinit(s); - if (ret) { - av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_reinit\n"); - return AVERROR(EINVAL); - } - goto reinit_run; + ret = ff_v4l2_m2m_codec_reinit(s); + if (ret) { + av_log(logger(ctx), AV_LOG_ERROR, "v4l2_m2m_codec_reinit\n"); + return AVERROR(EINVAL); } - /* dummy event received */ - return 0; - /* reinit executed */ -reinit_run: return 1; }
client need to resume the decoding process after it dequeues the source change event. no matter what's the return value of v4l2_resolution_changed(). if the client doesn't resume the decoding process, the decoder may keep waiting in documentation of v4l2 stateful decoder, we can see the following description: The client must continue the sequence as described below to continue the decoding process. 1. Dequeue the source change event. Important A source change triggers an implicit decoder drain, similar to the explicit Drain sequence. The decoder is stopped after it completes. The decoding process must be resumed with either a pair of calls to VIDIOC_STREAMOFF() and VIDIOC_STREAMON() on the CAPTURE queue, or a call to VIDIOC_DECODER_CMD() with the V4L2_DEC_CMD_START command. 2. Continue with the Capture Setup sequence. Signed-off-by: Ming Qian <ming.qian@nxp.com> --- libavcodec/v4l2_context.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-)