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 4693E40393 for ; Thu, 19 Jan 2023 21:11:13 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0FFED68BBF4; Thu, 19 Jan 2023 23:11:12 +0200 (EET) Received: from relay11.mail.gandi.net (relay11.mail.gandi.net [217.70.178.231]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id CA82A68A2C4 for ; Thu, 19 Jan 2023 23:11:05 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id EB673100002 for ; Thu, 19 Jan 2023 21:11:03 +0000 (UTC) Date: Thu, 19 Jan 2023 22:11:02 +0100 From: Michael Niedermayer To: FFmpeg development discussions and patches Message-ID: <20230119211102.GW1949656@pb2> References: <20220907134122.1244-1-ovchinnikov.dmitrii@gmail.com> <20220907134122.1244-2-ovchinnikov.dmitrii@gmail.com> MIME-Version: 1.0 In-Reply-To: <20220907134122.1244-2-ovchinnikov.dmitrii@gmail.com> Subject: Re: [FFmpeg-devel] [avcodec/amfenc: 10 bit support v2 2/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="===============5260744971499348726==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============5260744971499348726== Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="QVzQgM+zdZ3YWXqn" Content-Disposition: inline --QVzQgM+zdZ3YWXqn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 07, 2022 at 03:41:21PM +0200, OvchinnikovDmitrii wrote: > From: Michael Fabian 'Xaymar' Dirks >=20 >=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 >=20 > --- > libavcodec/amfenc.c | 2 ++ > libavcodec/amfenc.h | 1 + > libavcodec/amfenc_h264.c | 46 ++++++++++++++++++++++++++++++++- > libavcodec/amfenc_hevc.c | 55 +++++++++++++++++++++++++++++++++++++++- > 4 files changed, 102 insertions(+), 2 deletions(-) >=20 > diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c > index a033e1220e..efff9b5ae8 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 mismatching indention > }; > =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 1ab98d2f78..c5ee9d7e35 100644 > --- a/libavcodec/amfenc.h > +++ b/libavcodec/amfenc.h > @@ -21,6 +21,7 @@ > =20 > #include > =20 > +#include > #include > #include > =20 > diff --git a/libavcodec/amfenc_h264.c b/libavcodec/amfenc_h264.c > index eaf7f974f3..7a0198e6a8 100644 > --- a/libavcodec/amfenc_h264.c > +++ b/libavcodec/amfenc_h264.c > @@ -138,6 +138,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); > @@ -195,10 +198,51 @@ static av_cold int amf_encode_init_h264(AVCodecCont= ext *avctx) > 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 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); > + } else { > + AMF_ASSIGN_PROPERTY_BOOL(res, ctx->encoder, AMF_VIDEO_ENCODER_FU= LL_RANGE_COLOR, 0); > + } > + /// Color Space & Depth > + pix_fmt =3D avctx->hw_frames_ctx ? ((AVHWFramesContext*)avctx->hw_fr= ames_ctx->data)->sw_format > + : avctx->pix_fmt; > + color_depth =3D AMF_COLOR_BIT_DEPTH_8; > + if (pix_fmt =3D=3D AV_PIX_FMT_P010) { > + color_depth =3D AMF_COLOR_BIT_DEPTH_10; > + } the surrounding code all used if A=3DX else A=3DY and this does A=3DX if A= =3DY later the same code is repeated and both parts split up > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN; > + switch (avctx->colorspace) { > + case AVCOL_SPC_SMPTE170M: > + if (avctx->color_range =3D=3D AVCOL_RANGE_JPEG) { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601; > + } else { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_601; > + } > + break; > + case AVCOL_SPC_BT709: > + if (avctx->color_range =3D=3D AVCOL_RANGE_JPEG) { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709; > + } else { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_709; > + } > + break; > + case AVCOL_SPC_BT2020_NCL: > + case AVCOL_SPC_BT2020_CL: > + if (avctx->color_range =3D=3D AVCOL_RANGE_JPEG) { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_202= 0; > + } else { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020; > + } > + break; > } > + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_COLOR= _BIT_DEPTH, color_depth); > + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPU= T_COLOR_PROFILE, color_profile); > + /// Color Transfer Characteristics (AMF matches ISO/IEC) > + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPU= T_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc); > + /// Color Primaries (AMF matches ISO/IEC) > + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_OUTPU= T_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries); [...] > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_UNKNOWN; > + switch (avctx->colorspace) { > + case AVCOL_SPC_SMPTE170M: > + if (avctx->color_range =3D=3D AVCOL_RANGE_JPEG) { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_601; > + } else { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_601; > + } > + break; > + case AVCOL_SPC_BT709: > + if (avctx->color_range =3D=3D AVCOL_RANGE_JPEG) { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_709; > + } else { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_709; > + } > + break; > + case AVCOL_SPC_BT2020_NCL: > + case AVCOL_SPC_BT2020_CL: > + if (avctx->color_range =3D=3D AVCOL_RANGE_JPEG) { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_FULL_202= 0; > + } else { > + color_profile =3D AMF_VIDEO_CONVERTER_COLOR_PROFILE_2020; > + } > + break; > + } > + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_= COLOR_BIT_DEPTH, color_depth); > + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_= OUTPUT_COLOR_PROFILE, color_profile); > + /// Color Transfer Characteristics (AMF matches ISO/IEC) > + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_= OUTPUT_TRANSFER_CHARACTERISTIC, (amf_int64)avctx->color_trc); > + /// Color Primaries (AMF matches ISO/IEC) > + AMF_ASSIGN_PROPERTY_INT64(res, ctx->encoder, AMF_VIDEO_ENCODER_HEVC_= OUTPUT_COLOR_PRIMARIES, (amf_int64)avctx->color_primaries); code duplication [...] --=20 Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates --QVzQgM+zdZ3YWXqn Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABEIAB0WIQSf8hKLFH72cwut8TNhHseHBAsPqwUCY8mx3wAKCRBhHseHBAsP q+whAJ9gO0B10IHkWcdKSIzcym8rhNFMGgCfXQ2Lr/NcElh6JULzwRZzJB+beSs= =Z+GH -----END PGP SIGNATURE----- --QVzQgM+zdZ3YWXqn-- --===============5260744971499348726== 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". --===============5260744971499348726==--