From patchwork Fri Feb 24 09:03:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Tomas_H=C3=A4rdin?= X-Patchwork-Id: 40488 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp1076759pzk; Fri, 24 Feb 2023 01:03:56 -0800 (PST) X-Google-Smtp-Source: AK7set+or59c2XFPnbIfh3OvMz+uqBIen0Vi69rXDAawkZmpBNw6+9rzIU9KYSFebKg5EPWSvaRN X-Received: by 2002:a17:906:198f:b0:8b1:77bf:5b9f with SMTP id g15-20020a170906198f00b008b177bf5b9fmr23940288ejd.13.1677229436278; Fri, 24 Feb 2023 01:03:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677229436; cv=none; d=google.com; s=arc-20160816; b=mQxCcwtTKCAoa2V4inrO4POK/Crmh7Q+/HYpEdM73YBLGoXKxtAZgxRl8pc005yqGl y49oG29GttIGh4WxIcKqMKDpdMBHc3H8pYAGqb1cjGtAtantNTqswH/hxKWs/zGFBre2 K8lQjedUJm6sTU2nybtyn+zQf9yo0Dr6QbiZqhmSzSLbsSQliM6xh7TzVfYwwjZSJWUN D7LKpaZyhvFg6Bkdi4GLmMavnZvv0KzLpfgyVKAGOMIPf4AbOGMJV0hgsvcOf58WdmC7 gePrrBe3Ok27LU8Ckb7I2H1WZxUYbNc0JZKyiFTWa3bSeKa67v3Gwc40u0TClPx2SHgo hR0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:user-agent:references:in-reply-to:date:to:from :message-id:delivered-to; bh=oVWBYmAZnOxNs0x0KVj3GzHdFOHUeaCZPtSxax7SXeI=; b=VHC+2AOD+FbXQhef2iPctGTYp9dHOsDR0XbJCihyAaJ6pZn8Xr3XIDpWeSa84wkhvU 9MYzdhwbSathPfxcAlAhNvBL8MaL/Rinpgi8yTJ6D/qKMHNEIyZLuOx0HMl4FOqAz5V8 ZL03d5q0yD9TY0K4jndPPqJwB/LL18H839TpNk98qcjTG8BVW+F9/rsleiTqsQAAAnKd MsvpNIs931Yl4otgvHFs4pYA24098ts1rKrbNvHRhNhg6QqC8JdiDZMvtPmorK/eqikk iSgsPP0K0maYD2g9z8sjmMl+QFv4kVCTGXp+amBY2nV27o/0f0bXj5LnZjcdD7puxJuX K2Dg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id ew24-20020a170907951800b008d999499f63si13454143ejc.83.2023.02.24.01.03.55; Fri, 24 Feb 2023 01:03:56 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 475C568C11C; Fri, 24 Feb 2023 11:03:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.frobbit.se (mail.frobbit.se [85.30.129.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73F86689C24 for ; Fri, 24 Feb 2023 11:03:46 +0200 (EET) Received: from [10.10.150.69] (1346516434.ip.84grams.net [134.65.164.34]) by mail.frobbit.se (Postfix) with ESMTPSA id F36FC21F10 for ; Fri, 24 Feb 2023 10:03:45 +0100 (CET) Message-ID: <015df2df4818b87922ab0e358d1949d50698a71b.camel@haerdin.se> From: Tomas =?iso-8859-1?q?H=E4rdin?= To: FFmpeg development discussions and patches Date: Fri, 24 Feb 2023 10:03:44 +0100 In-Reply-To: References: User-Agent: Evolution 3.38.3-1+deb11u1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/4] lavc/mediacodecenc: List supported pixel formats on configuration error X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: yesIdrbAHU5x This makes the situation a bit better for users, even if we can't reliably probe pixel formats in init_static_data. I decided to keep this patchset separate from that probing, since printing pixel formats this way should be reliable. /Tomas From eed0ed202bf8c496ab945b32e2e7fc7cad062c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Tue, 10 Jan 2023 20:38:56 +0100 Subject: [PATCH 4/4] lavc/mediacodecenc: List supported pixel formats on configuration error 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); + 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"); + +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