From patchwork Tue Dec 8 05:04:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Philip Langdale X-Patchwork-Id: 24425 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 5407544B72E for ; Tue, 8 Dec 2020 07:04:28 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 318876898E4; Tue, 8 Dec 2020 07:04:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail.overt.org (mail.overt.org [157.230.92.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 25438688256 for ; Tue, 8 Dec 2020 07:04:21 +0200 (EET) Received: from authenticated-user (mail.overt.org [157.230.92.47]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by mail.overt.org (Postfix) with ESMTPSA id 989433F570; Mon, 7 Dec 2020 23:04:19 -0600 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=overt.org; s=mail; t=1607403859; bh=jGSD9axITprqRkxbNE4aZ5+TxiQzj0g1tqcF0vmf0wI=; h=From:To:Cc:Subject:Date:From; b=TbVeFOerQXQ+AOrJwa5Kbq4jU3ElcZE2Dh3Cy34WdmpXLJXbwnEezJbhqBeeh4US1 C/MySchTVWI2n5BZVX1ibl0aLq8A/kPyH3bbjHrtx6SqOtg/11ETe9n6fPzBpBX22G UVVMXxrw4HAaepa0oLDNkMNbQPgaVT8P+hLJRiMLBIVMS+sJJiv7E2eO15SYyOOT38 AUW2C+BcbUosxPSkiLd3DvzXGRoVDYCCTI+9luM++GBZzvpUY3LBgKLDlvAo3utsaN nCrmxP0BlNpIphUhPDRIbznaYmfIMeVgrVQct0UU6ZltgFvB/ANPjDTJ5l9c2yZvTU 8SJS0JG6w1elQ== From: Philip Langdale To: ffmpeg-devel@ffmpeg.org Date: Mon, 7 Dec 2020 21:04:12 -0800 Message-Id: <20201208050412.335967-1-philipl@overt.org> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] avcodec/libaom: Support monochrome encoding with libaom >= 2.0.1 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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 Cc: Philip Langdale Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Monochrome encoding with libaom was buggy for a long time, but this was finally sorted out in libaom 2.0.1 (2.0.0 is almost there but was still buggy in realtime mode). Surprisingly, we've never had an external library feature flag in configure before, but it seems reasonable to add such a category. Signed-off-by: Philip Langdale --- Changelog | 1 + configure | 8 ++++++++ libavcodec/libaomenc.c | 14 ++++++++++++++ libavcodec/version.h | 2 +- 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 503317dfae..8f5e849f8d 100644 --- a/Changelog +++ b/Changelog @@ -51,6 +51,7 @@ version : - asubcut filter - Microsoft Paint (MSP) version 2 decoder - Microsoft Paint (MSP) demuxer +- AV1 monochrome encoding support via libaom >= 2.0.1 version 4.3: diff --git a/configure b/configure index 10dd40cab8..6c83895414 100755 --- a/configure +++ b/configure @@ -1829,6 +1829,10 @@ EXTERNAL_LIBRARY_LIST=" vapoursynth " +EXTERNAL_LIBRARY_FEATURES=" + libaom2 +" + HWACCEL_AUTODETECT_LIBRARY_LIST=" amf audiotoolbox @@ -2314,6 +2318,7 @@ HAVE_LIST=" $ARCH_FEATURES $BUILTIN_LIST $COMPLEX_FUNCS + $EXTERNAL_LIBRARY_FEATURES $HAVE_LIST_CMDLINE $HAVE_LIST_PUB $HEADERS_LIST @@ -6329,6 +6334,9 @@ enabled gnutls && require_pkg_config gnutls gnutls gnutls/gnutls.h gn enabled jni && { [ $target_os = "android" ] && check_headers jni.h && enabled pthreads || die "ERROR: jni not found"; } enabled ladspa && require_headers "ladspa.h dlfcn.h" enabled libaom && require_pkg_config libaom "aom >= 1.0.0" aom/aom_codec.h aom_codec_version +if enabled libaom; then + check_pkg_config libaom2 "aom >= 2.0.1" aom/aom_codec.h aom_codec_version +fi enabled libaribb24 && { check_pkg_config libaribb24 "aribb24 > 1.0.3" "aribb24/aribb24.h" arib_instance_new || { enabled gpl && require_pkg_config libaribb24 aribb24 "aribb24/aribb24.h" arib_instance_new; } || die "ERROR: libaribb24 requires version higher than 1.0.3 or --enable-gpl."; } diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index 2b0581b15a..6110472b68 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -338,6 +338,10 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth; switch (avctx->pix_fmt) { +#if HAVE_LIBAOM2 + case AV_PIX_FMT_GRAY8: + enccfg->monochrome = 1; +#endif case AV_PIX_FMT_YUV420P: enccfg->g_profile = FF_PROFILE_AV1_MAIN; *img_fmt = AOM_IMG_FMT_I420; @@ -351,6 +355,11 @@ static int set_pix_fmt(AVCodecContext *avctx, aom_codec_caps_t codec_caps, enccfg->g_profile = FF_PROFILE_AV1_HIGH; *img_fmt = AOM_IMG_FMT_I444; return 0; +#if HAVE_LIBAOM2 + case AV_PIX_FMT_GRAY10: + case AV_PIX_FMT_GRAY12: + enccfg->monochrome = 1; +#endif case AV_PIX_FMT_YUV420P10: case AV_PIX_FMT_YUV420P12: if (codec_caps & AOM_CODEC_CAP_HIGHBITDEPTH) { @@ -1171,6 +1180,11 @@ static const enum AVPixelFormat av1_pix_fmts_highbd[] = { AV_PIX_FMT_YUV444P12, AV_PIX_FMT_GBRP10, AV_PIX_FMT_GBRP12, +#if HAVE_LIBAOM2 + AV_PIX_FMT_GRAY8, + AV_PIX_FMT_GRAY10, + AV_PIX_FMT_GRAY12, +#endif AV_PIX_FMT_NONE }; diff --git a/libavcodec/version.h b/libavcodec/version.h index 1c10d105f6..5b92afe60a 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -29,7 +29,7 @@ #define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MINOR 115 -#define LIBAVCODEC_VERSION_MICRO 101 +#define LIBAVCODEC_VERSION_MICRO 102 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ LIBAVCODEC_VERSION_MINOR, \