From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id EDF9A48AF8 for ; Mon, 1 Apr 2024 15:06:01 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7B55F68CE20; Mon, 1 Apr 2024 18:05:58 +0300 (EEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9B3D968C25D for ; Mon, 1 Apr 2024 18:05:52 +0300 (EEST) Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-415698723efso4143395e9.3 for ; Mon, 01 Apr 2024 08:05:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20230601.gappssmtp.com; s=20230601; t=1711983952; x=1712588752; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=Pz0UbvPfNkiVm8f2mOcNt0w30GO3a8fKMnTobALGMRc=; b=OCCn9iVjMhHzTN/sJhweHXVDqsfoaWnp3SyItLWlMqX2GborkhSbses6RiGK/W7gCX YkZoLyWh+cbslSEjwHJS9IOJjpHqWR2W7WJVvSWDlQ2ViuPxYSO8VqzetVTkGe/7YZPP uuPYTFg4E4IYnHnLw5nyxZwe2TqUoAQYvx44JRSro0E0RFKepYPUBru/I/9DBvfELOBZ Q9osOshPnkT4mtXwsW5y57x9ap4RGYdWQ1g3xLZYe4mnLh/dHqx/xJoRZ1diilunjJuk G6FuuI/qPoZ/Ig6nt2x7P9BgRfSVegJb6G5/f5gEjD3dyyNq7SpD4b7N5ly5lrzupVoC ByZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711983952; x=1712588752; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Pz0UbvPfNkiVm8f2mOcNt0w30GO3a8fKMnTobALGMRc=; b=jcgybPRf9Velg6FcmNy6VMdLuLmI2iX1pllod/QJo3B9B23IgzRonKfxG6cKBosGYI Jj3+K1tiClBbTaVsRhZIPrpFt9APSV3QfJpt1WRqgXlNSVuy0/vd/mUeECyM+5f8PRF4 6xIeaWdwqjYJ/tAZ4Hn4CSXrJKLEuILEACPypWbOJrXNQj2zy9d0k/eK5XBgMXJS/iU1 zQ0Czy0ucuUXnt5ojOiK2YHa8FLHkQN77CBRuJCXd5CE7lzTLWxoia6GK4oRPAKzZ9cl 3O1X6fwT+OJJ9Ac+zsTzL912MXwtsKdM8HLBrdidnRH1pXr6CkmY9Wk6zhtWwou52ggh ZpxA== X-Gm-Message-State: AOJu0YwaRMRkaMeAMnkYgDSB8wq78KrdXiAg0F55y7I4iUxfgU16Ae8f ZoPxVqNg03JGwRufc6NzDXICe2z8ukVENKnOKfTpZTvCxYWB4sIQ6asopwyPPd/NFTfstCrjI7b l X-Google-Smtp-Source: AGHT+IHqmKCy2rPLLQQuQekPW7TwXNcpuSUVV82qPWHLd5xc9BrN1zH0WRcn4Uk5FlQ7zD1GSmWlng== X-Received: by 2002:a05:600c:1c12:b0:415:66ac:614d with SMTP id j18-20020a05600c1c1200b0041566ac614dmr1792144wms.13.1711983951575; Mon, 01 Apr 2024 08:05:51 -0700 (PDT) Received: from [192.168.0.15] (cpc92302-cmbg19-2-0-cust1183.5-4.cable.virginm.net. [82.1.212.160]) by smtp.gmail.com with ESMTPSA id g18-20020a05600c4ed200b0041495d17992sm14996824wmq.34.2024.04.01.08.05.51 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 01 Apr 2024 08:05:51 -0700 (PDT) Message-ID: Date: Mon, 1 Apr 2024 16:06:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20240328123711.205-1-samuelsonm@gmail.com> From: Mark Thompson In-Reply-To: <20240328123711.205-1-samuelsonm@gmail.com> Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mfenc: expose more properties of the media foundation encoder 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 28/03/2024 12:34, Mark Samuelson wrote: > Thank you for the notes, here is a new patch that incorporates your suggestions. You are right, the default value of 12 for gop_size is suprising, I didn't know about it before now. > > --- > libavcodec/mf_utils.h | 5 +++++ > libavcodec/mfenc.c | 33 +++++++++++++++++++++++++++------ > 2 files changed, 32 insertions(+), 6 deletions(-) Patch looks good. I did a bit of testing with the Microsoft H.264 MFT: GOP size and compression level work as expected, and VBV parameters seem to be doing something sensible. Under what conditions are you expecting global_quality -> AVEncVideoEncodeQP to do anything, though? When I set it alone the output was always identical regardless of what value I set it to. (Including with "-rate_control quality".) Thanks, - Mark > diff --git a/libavcodec/mf_utils.h b/libavcodec/mf_utils.h > index aebfb9ad21..387c005f38 100644 > --- a/libavcodec/mf_utils.h > +++ b/libavcodec/mf_utils.h > @@ -97,6 +97,11 @@ DEFINE_GUID(ff_CODECAPI_AVEncH264CABACEnable, 0xee6cad62, 0xd305, 0x4248, 0xa > DEFINE_GUID(ff_CODECAPI_AVEncVideoForceKeyFrame, 0x398c1b98, 0x8353, 0x475a, 0x9e, 0xf2, 0x8f, 0x26, 0x5d, 0x26, 0x3, 0x45); > DEFINE_GUID(ff_CODECAPI_AVEncMPVDefaultBPictureCount, 0x8d390aac, 0xdc5c, 0x4200, 0xb5, 0x7f, 0x81, 0x4d, 0x04, 0xba, 0xba, 0xb2); > DEFINE_GUID(ff_CODECAPI_AVScenarioInfo, 0xb28a6e64,0x3ff9,0x446a,0x8a,0x4b,0x0d,0x7a,0x53,0x41,0x32,0x36); > +DEFINE_GUID(ff_CODECAPI_AVEncCommonBufferSize, 0x0db96574, 0xb6a4, 0x4c8b, 0x81, 0x06, 0x37, 0x73, 0xde, 0x03, 0x10, 0xcd); > +DEFINE_GUID(ff_CODECAPI_AVEncCommonMaxBitRate, 0x9651eae4, 0x39b9, 0x4ebf, 0x85, 0xef, 0xd7, 0xf4, 0x44, 0xec, 0x74, 0x65); > +DEFINE_GUID(ff_CODECAPI_AVEncCommonQualityVsSpeed, 0x98332df8, 0x03cd, 0x476b, 0x89, 0xfa, 0x3f, 0x9e, 0x44, 0x2d, 0xec, 0x9f); > +DEFINE_GUID(ff_CODECAPI_AVEncMPVGOPSize, 0x95f31b26, 0x95a4, 0x41aa, 0x93, 0x03, 0x24, 0x6a, 0x7f, 0xc6, 0xee, 0xf1); > +DEFINE_GUID(ff_CODECAPI_AVEncVideoEncodeQP, 0x2cb5696b, 0x23fb, 0x4ce1, 0xa0, 0xf9, 0xef, 0x5b, 0x90, 0xfd, 0x55, 0xca); > > DEFINE_GUID(ff_MF_SA_D3D11_BINDFLAGS, 0xeacf97ad, 0x065c, 0x4408, 0xbe, 0xe3, 0xfd, 0xcb, 0xfd, 0x12, 0x8b, 0xe2); > DEFINE_GUID(ff_MF_SA_D3D11_USAGE, 0xe85fe442, 0x2ca3, 0x486e, 0xa9, 0xc7, 0x10, 0x9d, 0xda, 0x60, 0x98, 0x80); > diff --git a/libavcodec/mfenc.c b/libavcodec/mfenc.c > index 9225692c51..cad531bd7d 100644 > --- a/libavcodec/mfenc.c > +++ b/libavcodec/mfenc.c > @@ -695,6 +695,21 @@ FF_ENABLE_DEPRECATION_WARNINGS > if (c->opt_enc_quality >= 0) > ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVEncCommonQuality, FF_VAL_VT_UI4(c->opt_enc_quality)); > > + if (avctx->rc_max_rate > 0) > + ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVEncCommonMaxBitRate, FF_VAL_VT_UI4(avctx->rc_max_rate)); > + > + if (avctx->gop_size > 0) > + ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVEncMPVGOPSize, FF_VAL_VT_UI4(avctx->gop_size)); > + > + if(avctx->rc_buffer_size > 0) > + ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVEncCommonBufferSize, FF_VAL_VT_UI4(avctx->rc_buffer_size)); > + > + if(avctx->compression_level >= 0) > + ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVEncCommonQualityVsSpeed, FF_VAL_VT_UI4(avctx->compression_level)); > + > + if(avctx->global_quality > 0) > + ICodecAPI_SetValue(c->codec_api, &ff_CODECAPI_AVEncVideoEncodeQP, FF_VAL_VT_UI4(avctx->global_quality )); > + > // Always set the number of b-frames. Qualcomm's HEVC encoder on SD835 > // defaults this to 1, and that setting is buggy with many of the > // rate control modes. (0 or 2 b-frames works fine with most rate > @@ -1223,7 +1238,7 @@ static int mf_init(AVCodecContext *avctx) > > #define OFFSET(x) offsetof(MFContext, x) > > -#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, FMTS, CAPS) \ > +#define MF_ENCODER(MEDIATYPE, NAME, ID, OPTS, FMTS, CAPS, DEFAULTS) \ > static const AVClass ff_ ## NAME ## _mf_encoder_class = { \ > .class_name = #NAME "_mf", \ > .item_name = av_default_item_name, \ > @@ -1243,6 +1258,7 @@ static int mf_init(AVCodecContext *avctx) > FMTS \ > CAPS \ > .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, \ > + .defaults = DEFAULTS, \ > }; > > #define AFMTS \ > @@ -1252,9 +1268,9 @@ static int mf_init(AVCodecContext *avctx) > .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID | \ > AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, > > -MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS, ACAPS); > -MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS, ACAPS); > -MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS, ACAPS); > +MF_ENCODER(AUDIO, aac, AAC, NULL, AFMTS, ACAPS, NULL); > +MF_ENCODER(AUDIO, ac3, AC3, NULL, AFMTS, ACAPS, NULL); > +MF_ENCODER(AUDIO, mp3, MP3, NULL, AFMTS, ACAPS, NULL); > > #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM > static const AVOption venc_opts[] = { > @@ -1283,6 +1299,11 @@ static const AVOption venc_opts[] = { > {NULL} > }; > > +static const FFCodecDefault defaults[] = { > + { "g", "0" }, > + { NULL }, > +}; > + > #define VFMTS \ > .p.pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_NV12, \ > AV_PIX_FMT_YUV420P, \ > @@ -1291,5 +1312,5 @@ static const AVOption venc_opts[] = { > .p.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HYBRID | \ > AV_CODEC_CAP_DR1, > > -MF_ENCODER(VIDEO, h264, H264, venc_opts, VFMTS, VCAPS); > -MF_ENCODER(VIDEO, hevc, HEVC, venc_opts, VFMTS, VCAPS); > +MF_ENCODER(VIDEO, h264, H264, venc_opts, VFMTS, VCAPS, defaults); > +MF_ENCODER(VIDEO, hevc, HEVC, venc_opts, VFMTS, VCAPS, defaults); _______________________________________________ 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".