Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Andriy Gelman <andriy.gelman@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v4 3/3] avcodec/v4l2_m2m_dec: setup capture queue before enqueue the first frame
Date: Sun, 2 Jan 2022 11:53:10 -0500
Message-ID: <20220102165310.agu7efa2fpba7eup@jackie> (raw)
In-Reply-To: <20210819085533.1174-3-ming.qian@nxp.com>

On Thu, 19. Aug 16:55, Ming Qian wrote:
> there are two proper ways to setup capture queue.
> 1. client wait the source change event,
>    then setup the capture queue and streamon
> 2. client setup the capture queue in advance,
>    but to avoid time issues, client should start
>    the capture queue before it enqueue the sequence
>    header to decoder driver through output queue.
>    and the sequence header is always in the first
>    frame, so client should start capture before
>    enqueue the first frame.
> 
> ffmpeg use the method 2 to setup capture queue,
> but currently ffmpeg enqueue the first frame
> before starting the capture queue.
> so in driver side, there are time issues.
> when driver has parsed the resolution from sequence header,
> but the client may not finished setup the capture.
> so driver can't decide whether to notify a source change event to
> client. and the following flow may be chaotic.
> 
> And it's OK that client setup capture queue first, then enqueue the
> first frame.
> 
> Signed-off-by: Ming Qian <ming.qian@nxp.com>
> ---
>  libavcodec/v4l2_m2m_dec.c | 18 ++++++++----------
>  1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git a/libavcodec/v4l2_m2m_dec.c b/libavcodec/v4l2_m2m_dec.c
> index 224eb3d5e7be..6b936b6df2a9 100644
> --- a/libavcodec/v4l2_m2m_dec.c
> +++ b/libavcodec/v4l2_m2m_dec.c
> @@ -149,6 +149,14 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame)
>      if (s->draining)
>          goto dequeue;
>  
> +    ret = v4l2_try_start(avctx);
> +    if (ret) {
> +        /* can't recover */
> +        if (ret != AVERROR(ENOMEM))
> +            ret = 0;
> +        goto fail;
> +    }
> +
>      ret = ff_v4l2_context_enqueue_packet(output, &s->buf_pkt);
>      if (ret < 0 && ret != AVERROR(EAGAIN))
>          goto fail;
> @@ -157,16 +165,6 @@ static int v4l2_receive_frame(AVCodecContext *avctx, AVFrame *frame)
>      if (ret != AVERROR(EAGAIN))
>          av_packet_unref(&s->buf_pkt);
>  
> -    if (!s->draining) {
> -        ret = v4l2_try_start(avctx);
> -        if (ret) {
> -            /* cant recover */
> -            if (ret != AVERROR(ENOMEM))
> -                ret = 0;
> -            goto fail;
> -        }
> -    }
> -
>  dequeue:
>      return ff_v4l2_context_dequeue_frame(capture, frame, -1);
>  fail:

Unfortunately this does not work on odroid xu4.
It needs to parse the parameter sets before VIDIOC_G_FMT ioctl is called on the
capture queue:
https://github.com/hardkernel/linux/blob/odroid-5.4.y/drivers/media/platform/s5p-mfc/s5p_mfc_dec.c#L317

Thanks,
-- 
Andriy
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

      parent reply	other threads:[~2022-01-02 16:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210819085533.1174-1-ming.qian@nxp.com>
2022-01-02 16:23 ` [FFmpeg-devel] [PATCH v4 1/3] avcodec/v4l2_context: don't reinit output queue when dynamic resolution change Andriy Gelman
2022-01-04  7:40   ` [FFmpeg-devel] [EXT] " Ming Qian
     [not found] ` <20210819085533.1174-2-ming.qian@nxp.com>
2022-01-02 16:41   ` [FFmpeg-devel] [PATCH v4 2/3] avcodec/v4l2_context: resume the decoding process after source change event received Andriy Gelman
2022-01-04  7:51     ` [FFmpeg-devel] [EXT] " Ming Qian
2022-01-04 22:48       ` Andriy Gelman
2022-01-04 22:58         ` Andriy Gelman
2022-01-05  2:02           ` Ming Qian
2022-01-08 17:13           ` Andriy Gelman
2022-01-10  8:57             ` Ming Qian
     [not found] ` <20210819085533.1174-3-ming.qian@nxp.com>
2022-01-02 16:53   ` Andriy Gelman [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220102165310.agu7efa2fpba7eup@jackie \
    --to=andriy.gelman@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git