From: "\"zhilizhao(赵志立)\"" <quinkblack@foxmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: Re: [FFmpeg-devel] [PATCH 4/4] lavc/mediacodecenc: List supported pixel formats on configuration error Date: Tue, 28 Feb 2023 20:25:01 +0800 Message-ID: <tencent_F6C908CEA66557731EC845F3E9F37FF5DA05@qq.com> (raw) In-Reply-To: <015df2df4818b87922ab0e358d1949d50698a71b.camel@haerdin.se> > This patch has been released by Epic Games' legal department. > --- > libavcodec/mediacodecenc.c | 46 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 46 insertions(+) > > diff --git a/libavcodec/mediacodecenc.c b/libavcodec/mediacodecenc.c > index 03c80cbf99..1b8a2837c4 100644 > --- a/libavcodec/mediacodecenc.c > +++ b/libavcodec/mediacodecenc.c > @@ -97,6 +97,12 @@ static const enum AVPixelFormat avc_pix_fmts[] = { > AV_PIX_FMT_NONE > }; > > +static const int in_formats[] = { > + COLOR_FormatYUV420Planar, > + COLOR_FormatYUV420SemiPlanar, > + COLOR_FormatSurface, > +}; > + > static void mediacodec_output_format(AVCodecContext *avctx) > { > MediaCodecEncContext *s = avctx->priv_data; > @@ -131,6 +137,45 @@ static enum AVPixelFormat color2pix_fmt(AVCodecContext *avctx, int color_format) > av_assert0(0); > } > > +// list pixel formats if the user tried to use one that isn't supported on this device > +static void list_pix_fmts(AVCodecContext *avctx, const char *mime) > +{ > + MediaCodecEncContext *s = avctx->priv_data; > + int out_formats[FF_ARRAY_ELEMS(in_formats)], n; > + char *name = ff_AMediaCodec_getName(s->codec); > + > + if (!name) { > + // API level likely below 28 > + return; > + } > + > + if ((n = ff_AMediaCodec_color_formats_intersect(name, mime, in_formats, > + FF_ARRAY_ELEMS(in_formats), > + out_formats, avctx)) < 0) { > + goto done; > + } > + > + for (int i = 0; i < n; i++) { > + if (color2pix_fmt(avctx, out_formats[i]) == avctx->pix_fmt) { > + // user specified a pixel format that is actually supported, > + // no need to print anything > + goto done; > + } > + } > + > + AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); Missing ‘const’ and triggered -Wdeclaration-after-statement. > + av_log(avctx, AV_LOG_ERROR, "pixel format %s not supported by MediaCodec %s\n", desc->name, name); > + av_log(avctx, AV_LOG_INFO, "supported formats are:"); > + for (int i = 0; i < n; i++) { > + desc = av_pix_fmt_desc_get(color2pix_fmt(avctx, out_formats[i])); > + av_log(avctx, AV_LOG_INFO, " %s", desc->name); > + } > + av_log(avctx, AV_LOG_INFO, "\n"); It’s not thread safe, it can be interrupted by other threads' log message. > + > +done: > + av_free(name); > +} > + > static int mediacodec_init_bsf(AVCodecContext *avctx) > { > MediaCodecEncContext *s = avctx->priv_data; > @@ -308,6 +353,7 @@ static av_cold int mediacodec_init(AVCodecContext *avctx) > ret = ff_AMediaCodec_configure(s->codec, format, s->window, NULL, ret); > if (ret) { > av_log(avctx, AV_LOG_ERROR, "MediaCodec configure failed, %s\n", av_err2str(ret)); > + list_pix_fmts(avctx, codec_mime); > goto bailout; > } > > -- > 2.30.2 > _______________________________________________ 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".
next prev parent reply other threads:[~2023-02-28 12:25 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-02-24 8:59 [FFmpeg-devel] [PATCH 1/4] lavc/mediacodecenc: Add pix2color_fmt() and color2pix_fmt() Tomas Härdin 2023-02-24 9:00 ` [FFmpeg-devel] [PATCH 2/4] lavc/mediacodec_wrapper: Refactor ff_AMediaCodecList_getCodecNameByType() Tomas Härdin 2023-02-28 12:13 ` "zhilizhao(赵志立)" 2023-02-24 9:00 ` [FFmpeg-devel] [PATCH 3/4] lavc/mediacodec_wrapper: Add function for probing supported color formats Tomas Härdin 2023-02-28 12:18 ` "zhilizhao(赵志立)" 2023-02-24 9:03 ` [FFmpeg-devel] [PATCH 4/4] lavc/mediacodecenc: List supported pixel formats on configuration error Tomas Härdin 2023-02-28 12:25 ` "zhilizhao(赵志立)" [this message] 2023-02-28 12:02 ` [FFmpeg-devel] [PATCH 1/4] lavc/mediacodecenc: Add pix2color_fmt() and color2pix_fmt() "zhilizhao(赵志立)"
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_F6C908CEA66557731EC845F3E9F37FF5DA05@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