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 0926B47290 for ; Tue, 3 Oct 2023 18:02:33 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1AA5C68CB1D; Tue, 3 Oct 2023 21:02:31 +0300 (EEST) Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B8AC868CACA for ; Tue, 3 Oct 2023 21:02:24 +0300 (EEST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 10CAD1BF203 for ; Tue, 3 Oct 2023 18:02:23 +0000 (UTC) Date: Tue, 3 Oct 2023 20:02:22 +0200 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20231003180222.GF3543730@pb2> References: <20220907134122.1244-1-ovchinnikov.dmitrii@gmail.com> <20230726113943.1140-1-lucenticus@gmail.com> MIME-Version: 1.0 In-Reply-To: <20230726113943.1140-1-lucenticus@gmail.com> X-GND-Sasl: michael@niedermayer.cc Subject: Re: [FFmpeg-devel] [PATCH avcodec/amfenc:, 10, bit, support, v3, 1/3] avcodec/amfenc: Fixes the color information in the output. 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-Type: multipart/mixed; boundary="===============7963913909592819796==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============7963913909592819796== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="yuedfix5hmtMJRO4" Content-Disposition: inline --yuedfix5hmtMJRO4 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 26, 2023 at 01:39:27PM +0200, Evgeny Pavlov wrote: > From: Michael Fabian 'Xaymar' Dirks >=20 > added 10 bit support for amf hevc. >=20 > before: >=20 > command - ffmpeg.exe -hide_banner -y -hwaccel d3d11va -hwaccel_output_for= mat d3d11 -i test_10bit_file.mkv -an -c:v h264_amf res.dx11_hw_h264.mkv > output - Format of input frames context (p010le) is not supported by AMF. > command - ffmpeg.exe -hide_banner -y -hwaccel d3d11va -hwaccel_output_for= mat d3d11 -i test_10bit_file -an -c:v hevc_amf res.dx11_hw_hevc.mkv > output - Format of input frames context (p010le) is not supported by AMF. >=20 > after: >=20 > command - ffmpeg.exe -hide_banner -y -hwaccel d3d11va -hwaccel_output_for= mat d3d11 -i test_10bit_file -an -c:v h264_amf res.dx11_hw_h264.mkv > output - 8bit file > command - ffmpeg.exe -hide_banner -y -hwaccel d3d11va -hwaccel_output_for= mat d3d11 -i test_10bit_file -an -c:v hevc_amf res.dx11_hw_hevc.mkv > output - 10bit file >=20 > v2 - lost line returned in ff_amf_pix_fmts > v3 - fixes after review > --- > libavcodec/amfenc.c | 2 ++ > libavcodec/amfenc.h | 1 + > libavcodec/amfenc_h264.c | 49 ++++++++++++++++++++++++++++++++- > libavcodec/amfenc_hevc.c | 58 +++++++++++++++++++++++++++++++++++++++- > 4 files changed, 108 insertions(+), 2 deletions(-) >=20 > diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c > index cb48f8c273..1d863afdc4 100644 > --- a/libavcodec/amfenc.c > +++ b/libavcodec/amfenc.c > @@ -60,6 +60,7 @@ const enum AVPixelFormat ff_amf_pix_fmts[] =3D { > #if CONFIG_DXVA2 > AV_PIX_FMT_DXVA2_VLD, > #endif > + AV_PIX_FMT_P010, > AV_PIX_FMT_NONE > }; > =20 > @@ -72,6 +73,7 @@ static const FormatMap format_map[] =3D > { > { AV_PIX_FMT_NONE, AMF_SURFACE_UNKNOWN }, > { AV_PIX_FMT_NV12, AMF_SURFACE_NV12 }, > + { AV_PIX_FMT_P010, AMF_SURFACE_P010 }, > { AV_PIX_FMT_BGR0, AMF_SURFACE_BGRA }, > { AV_PIX_FMT_RGB0, AMF_SURFACE_RGBA }, > { AV_PIX_FMT_GRAY8, AMF_SURFACE_GRAY8 }, > diff --git a/libavcodec/amfenc.h b/libavcodec/amfenc.h > index 2dbd378ef8..267eb593a2 100644 > --- a/libavcodec/amfenc.h > +++ b/libavcodec/amfenc.h > @@ -21,6 +21,7 @@ > =20 > #include > =20 > +#include > #include > #include > #include > diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c > index 2380aa4e90..4b6708ca8f 100644 > --- a/libavcodec/amfenc_h264.c > +++ b/libavcodec/amfenc_h264.c > @@ -199,6 +199,9 @@ static av_cold int amf_encode_init_h264(AVCodecContex= t *avctx) > AMFRate framerate; > AMFSize framesize =3D AMFConstructSize(avct= x->width, avctx->height); > int deblocking_filter =3D (avctx->flags= & AV_CODEC_FLAG_LOOP_FILTER) ? 1 : 0; > + amf_int64 color_depth; > + amf_int64 color_profile; > + enum AVPixelFormat pix_fmt; > =20 > if (avctx->framerate.num > 0 && avctx->framerate.den > 0) { > framerate =3D AMFConstructRate(avctx->framerate.num, avctx->fram= erate.den); > @@ -262,10 +265,54 @@ FF_ENABLE_DEPRECATION_WARNINGS > AMF_ASSIGN_PROPERTY_RATIO(res, ctx->encoder, AMF_VIDEO_ENCODER_A= SPECT_RATIO, ratio); > } > =20 > - /// Color Range (Partial/TV/MPEG or Full/PC/JPEG) > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN; > + // Color Metadata > + /// Color Range (Support for older Drivers) > if (avctx->color_range =3D=3D AVCOL_RANGE_JPEG) { > AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FU= LL_RANGE_COLOR, 1); > + /// Color Space for Full (JPEG) Range > + switch (avctx->colorspace) { > + case AVCOL_SPC_SMPTE170M: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601; > + break; > + case AVCOL_SPC_BT709: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709; > + break; > + case AVCOL_SPC_BT2020_NCL: > + case AVCOL_SPC_BT2020_CL: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_202= 0; > + break; > + } > + } else { > + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FU= LL_RANGE_COLOR, 0); > + /// Color Space for Limited (MPEG) range > + switch (avctx->colorspace) { > + case AVCOL_SPC_SMPTE170M: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_601; > + break; > + case AVCOL_SPC_BT709: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_709; > + break; > + case AVCOL_SPC_BT2020_NCL: > + case AVCOL_SPC_BT2020_CL: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020; > + break; > + } [...] > + // Color Metadata > + /// Color Range (Support for older Drivers) > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN; > + if (avctx->color_range =3D=3D AVCOL_RANGE_JPEG) { > + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HE= VC_NOMINAL_RANGE, 1); > + /// Color Space for Full (JPEG) Range > + switch (avctx->colorspace) { > + case AVCOL_SPC_SMPTE170M: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601; > + break; > + case AVCOL_SPC_BT709: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709; > + break; > + case AVCOL_SPC_BT2020_NCL: > + case AVCOL_SPC_BT2020_CL: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_202= 0; > + break; > + } > + } else { > + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_HE= VC_NOMINAL_RANGE, 0); > + /// Color Space for Limited (MPEG) Range > + switch (avctx->colorspace) { > + case AVCOL_SPC_SMPTE170M: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_601; > + break; > + case AVCOL_SPC_BT709: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_709; > + break; > + case AVCOL_SPC_BT2020_NCL: > + case AVCOL_SPC_BT2020_CL: > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020; > + break; > + } > + } Looks like code duplication, code duplication should generally be avoided and factored out thx [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Dictatorship: All citizens are under surveillance, all their steps and actions recorded, for the politicians to enforce control. Democracy: All politicians are under surveillance, all their steps and actions recorded, for the citizens to enforce control. --yuedfix5hmtMJRO4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCZRxXKwAKCRBhHseHBAsP q2hvAJ4xu/EMj/U3jlysseLOJJgI/x18ygCffjQDIjoMoqunSzLnVMThv2GI0mA= =saFc -----END PGP SIGNATURE----- --yuedfix5hmtMJRO4-- --===============7963913909592819796== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============7963913909592819796==--