Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Zhao Zhili" <quinkblack@foxmail.com>
To: "'FFmpeg development discussions and patches'" <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavc/mediacodecenc: Probe supported pixel formats
Date: Sat, 7 Jan 2023 13:02:17 +0800
Message-ID: <tencent_4FD0B5A6CAA7C72AA11318DC5F4B8FE62706@qq.com> (raw)
In-Reply-To: <19df94a9b138b93727530f3cb64f8e13bde60b09.camel@haerdin.se>


> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of Tomas Härdin
> Sent: 2023年1月7日 2:22
> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 1/2] lavc/mediacodecenc: Probe supported pixel formats
> 
> lör 2023-01-07 klockan 02:03 +0800 skrev Zhao Zhili:
> > On Fri, 2023-01-06 at 16:42 +0100, Tomas Härdin wrote:
> >
> > > +            if (!(format = ff_AMediaFormat_new(use_ndk_codec))) {
> > > +                av_log(NULL, AV_LOG_ERROR, "Failed to create media
> > > format\n");
> > > +                ff_AMediaCodec_delete(codec);
> > > +                continue;
> >
> > Here is a use-after-free (codec) issue.
> 
> Oops. I had the call to ff_AMediaCodec_createEncoderByType() inside the
> loop earlier. Will fix.
> 
> 
> > init_static_data should be determinate, no matter when it was called,
> > it should
> > give the same result.
> 
> You mean across devices? That obviously won't work. On the same device?
> I would assume it always returns the same results, modulo what you
> wrote below.

I mean on the same device.

> 
> > In addition to the 'different MediaCodec backends support
> > different pixel format' issue, another concern of this method is that
> > it's not
> > determinate, it can give different results at different
> > time/condition.
> >
> > MediaCodec can fail for all kinds of reasons, and it can fail
> > dynamically. For
> > example, the supported instance is limited
> > (getMaxSupportedInstances()). Some
> > low end/legacy chip only support one instance. So it can fail when
> > another app
> > or another SDK in the same app has already created a codec instance.
> 
> Won't the encoder fail anyway in that case? Also will the JNI probe
> still fail in that case?

Create encoder can fail, and recover after a while. If JNI probe depends on
a codec instance, it has the same issue. Use the codeclist API should be fine,
but then we don't know which omx codec is the default one.

The JNI probe can tell which pixel format is supported after encoder configure
failed at runtime. That's a safe and valid usecase. And it can be implemented
out side of FFmpeg, so it can be called earlier and multiple times, without the
limitation of init_static_data() being called only once.

> 
> > It can
> > fail when out of other resouce (like GPU memory) temporarily. Since
> > init_static_data() only being called once, there is no way to recover
> > from a
> > temporary failure.
> 
> Well, the code can try to probe the color formats more than once inside
> the function. But that feels very wrong.

That's the problem, init_static_data() can't do retry by design. Probe multiple
times inside init_static_data() doesn't work, unless there is a sleep after each
loop, and we can't put sleep inside init_static_data().

> 
> /Tomas
> 
> _______________________________________________
> 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".

_______________________________________________
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".

  reply	other threads:[~2023-01-07  5:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-06 15:42 Tomas Härdin
2023-01-06 15:43 ` [FFmpeg-devel] [PATCH 2/2] lavc/mediacodecenc: Probe actually supported color formats using JNI Tomas Härdin
2023-01-06 18:03 ` [FFmpeg-devel] [PATCH 1/2] lavc/mediacodecenc: Probe supported pixel formats Zhao Zhili
2023-01-06 18:21   ` Tomas Härdin
2023-01-07  5:02     ` Zhao Zhili [this message]
2023-01-09 12:27       ` Tomas Härdin

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=tencent_4FD0B5A6CAA7C72AA11318DC5F4B8FE62706@qq.com \
    --to=quinkblack@foxmail.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