* [FFmpeg-devel] [PATCH v4] vaapi: support VAProfileH264High10
@ 2023-03-29 8:41 jianfeng.zheng
2023-03-31 4:43 ` Xiang, Haihao
0 siblings, 1 reply; 2+ messages in thread
From: jianfeng.zheng @ 2023-03-29 8:41 UTC (permalink / raw)
To: ffmpeg-devel
see https://github.com/intel/libva/pull/664
Signed-off-by: jianfeng.zheng <jianfeng.zheng@mthreads.com>
---
libavcodec/h264_slice.c | 9 ++++++++-
libavcodec/vaapi_decode.c | 5 +++++
libavcodec/vaapi_encode_h264.c | 27 ++++++++++++++++++++++-----
3 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 7767e16cf1..d05b83a121 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -809,8 +809,15 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback)
*fmt++ = AV_PIX_FMT_YUV444P10;
} else if (CHROMA422(h))
*fmt++ = AV_PIX_FMT_YUV422P10;
- else
+ else {
+#if CONFIG_H264_VAAPI_HWACCEL
+ // Just add as candidate. Whether VAProfileH264High10 usable or
+ // not is decided by vaapi_decode_make_config() defined in FFmpeg
+ // and vaQueryCodingProfile() defined in libva.
+ *fmt++ = AV_PIX_FMT_VAAPI;
+#endif
*fmt++ = AV_PIX_FMT_YUV420P10;
+ }
break;
case 12:
if (CHROMA444(h)) {
diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index ab8c12e364..dd55cbd6f1 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -398,6 +398,11 @@ static const struct {
MAP(MPEG4, MPEG4_ADVANCED_SIMPLE,
MPEG4AdvancedSimple),
MAP(MPEG4, MPEG4_MAIN, MPEG4Main ),
+#if VA_CHECK_VERSION(1, 18, 0)
+ MAP(H264, H264_HIGH_10_INTRA,
+ H264High10 ),
+ MAP(H264, H264_HIGH_10, H264High10 ),
+#endif
MAP(H264, H264_CONSTRAINED_BASELINE,
H264ConstrainedBaseline),
MAP(H264, H264_MAIN, H264Main ),
diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
index 645f6a978d..9ad017d540 100644
--- a/libavcodec/vaapi_encode_h264.c
+++ b/libavcodec/vaapi_encode_h264.c
@@ -23,6 +23,7 @@
#include "libavutil/avassert.h"
#include "libavutil/common.h"
+#include "libavutil/pixdesc.h"
#include "libavutil/internal.h"
#include "libavutil/opt.h"
@@ -301,10 +302,21 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
H264RawPPS *pps = &priv->raw_pps;
VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
VAEncPictureParameterBufferH264 *vpic = ctx->codec_picture_params;
+ const AVPixFmtDescriptor *desc;
+ int bit_depth;
memset(sps, 0, sizeof(*sps));
memset(pps, 0, sizeof(*pps));
+ desc = av_pix_fmt_desc_get(priv->common.input_frames->sw_format);
+ av_assert0(desc);
+ if (desc->nb_components == 1 || desc->log2_chroma_w != 1 || desc->log2_chroma_h != 1) {
+ av_log(avctx, AV_LOG_ERROR, "Chroma format of input pixel format "
+ "%s is not supported.\n", desc->name);
+ return AVERROR(EINVAL);
+ }
+ bit_depth = desc->comp[0].depth;
+
sps->nal_unit_header.nal_ref_idc = 3;
sps->nal_unit_header.nal_unit_type = H264_NAL_SPS;
@@ -314,11 +326,11 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
avctx->profile == FF_PROFILE_H264_MAIN)
sps->constraint_set1_flag = 1;
- if (avctx->profile == FF_PROFILE_H264_HIGH)
+ if (avctx->profile == FF_PROFILE_H264_HIGH || avctx->profile == FF_PROFILE_H264_HIGH_10)
sps->constraint_set3_flag = ctx->gop_size == 1;
if (avctx->profile == FF_PROFILE_H264_MAIN ||
- avctx->profile == FF_PROFILE_H264_HIGH) {
+ avctx->profile == FF_PROFILE_H264_HIGH || avctx->profile == FF_PROFILE_H264_HIGH_10) {
sps->constraint_set4_flag = 1;
sps->constraint_set5_flag = ctx->b_per_p == 0;
}
@@ -359,6 +371,8 @@ static int vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
sps->seq_parameter_set_id = 0;
sps->chroma_format_idc = 1;
+ sps->bit_depth_luma_minus8 = bit_depth - 8;
+ sps->bit_depth_chroma_minus8 = bit_depth - 8;
sps->log2_max_frame_num_minus4 = 4;
sps->pic_order_cnt_type = ctx->max_b_depth ? 0 : 2;
@@ -1144,6 +1158,9 @@ static av_cold int vaapi_encode_h264_configure(AVCodecContext *avctx)
}
static const VAAPIEncodeProfile vaapi_encode_h264_profiles[] = {
+#if VA_CHECK_VERSION(1, 18, 0)
+ { FF_PROFILE_H264_HIGH_10, 10, 3, 1, 1, VAProfileH264High10 },
+#endif
{ FF_PROFILE_H264_HIGH, 8, 3, 1, 1, VAProfileH264High },
{ FF_PROFILE_H264_MAIN, 8, 3, 1, 1, VAProfileH264Main },
{ FF_PROFILE_H264_CONSTRAINED_BASELINE,
@@ -1208,10 +1225,9 @@ static av_cold int vaapi_encode_h264_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "H.264 extended profile "
"is not supported.\n");
return AVERROR_PATCHWELCOME;
- case FF_PROFILE_H264_HIGH_10:
case FF_PROFILE_H264_HIGH_10_INTRA:
- av_log(avctx, AV_LOG_ERROR, "H.264 10-bit profiles "
- "are not supported.\n");
+ av_log(avctx, AV_LOG_ERROR, "H.264 high 10 intra profile "
+ "is not supported.\n");
return AVERROR_PATCHWELCOME;
case FF_PROFILE_H264_HIGH_422:
case FF_PROFILE_H264_HIGH_422_INTRA:
@@ -1304,6 +1320,7 @@ static const AVOption vaapi_encode_h264_options[] = {
{ PROFILE("constrained_baseline", FF_PROFILE_H264_CONSTRAINED_BASELINE) },
{ PROFILE("main", FF_PROFILE_H264_MAIN) },
{ PROFILE("high", FF_PROFILE_H264_HIGH) },
+ { PROFILE("high10", FF_PROFILE_H264_HIGH_10) },
#undef PROFILE
{ "level", "Set level (level_idc)",
--
2.25.1
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH v4] vaapi: support VAProfileH264High10
2023-03-29 8:41 [FFmpeg-devel] [PATCH v4] vaapi: support VAProfileH264High10 jianfeng.zheng
@ 2023-03-31 4:43 ` Xiang, Haihao
0 siblings, 0 replies; 2+ messages in thread
From: Xiang, Haihao @ 2023-03-31 4:43 UTC (permalink / raw)
To: ffmpeg-devel
On Wo, 2023-03-29 at 16:41 +0800, jianfeng.zheng wrote:
> see https://github.com/intel/libva/pull/664
>
> Signed-off-by: jianfeng.zheng <jianfeng.zheng@mthreads.com>
> ---
> libavcodec/h264_slice.c | 9 ++++++++-
> libavcodec/vaapi_decode.c | 5 +++++
> libavcodec/vaapi_encode_h264.c | 27 ++++++++++++++++++++++-----
> 3 files changed, 35 insertions(+), 6 deletions(-)
You might miss the comment:
https://ffmpeg.org/pipermail/ffmpeg-devel/2023-March/307702.html , could you use
separate patches for decoder and encoder ?
Thanks
Haihao
>
> diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
> index 7767e16cf1..d05b83a121 100644
> --- a/libavcodec/h264_slice.c
> +++ b/libavcodec/h264_slice.c
> @@ -809,8 +809,15 @@ static enum AVPixelFormat get_pixel_format(H264Context
> *h, int force_callback)
> *fmt++ = AV_PIX_FMT_YUV444P10;
> } else if (CHROMA422(h))
> *fmt++ = AV_PIX_FMT_YUV422P10;
> - else
> + else {
> +#if CONFIG_H264_VAAPI_HWACCEL
> + // Just add as candidate. Whether VAProfileH264High10 usable or
> + // not is decided by vaapi_decode_make_config() defined in FFmpeg
> + // and vaQueryCodingProfile() defined in libva.
> + *fmt++ = AV_PIX_FMT_VAAPI;
> +#endif
> *fmt++ = AV_PIX_FMT_YUV420P10;
> + }
> break;
> case 12:
> if (CHROMA444(h)) {
> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> index ab8c12e364..dd55cbd6f1 100644
> --- a/libavcodec/vaapi_decode.c
> +++ b/libavcodec/vaapi_decode.c
> @@ -398,6 +398,11 @@ static const struct {
> MAP(MPEG4, MPEG4_ADVANCED_SIMPLE,
> MPEG4AdvancedSimple),
> MAP(MPEG4, MPEG4_MAIN, MPEG4Main ),
> +#if VA_CHECK_VERSION(1, 18, 0)
> + MAP(H264, H264_HIGH_10_INTRA,
> + H264High10 ),
> + MAP(H264, H264_HIGH_10, H264High10 ),
> +#endif
> MAP(H264, H264_CONSTRAINED_BASELINE,
> H264ConstrainedBaseline),
> MAP(H264, H264_MAIN, H264Main ),
> diff --git a/libavcodec/vaapi_encode_h264.c b/libavcodec/vaapi_encode_h264.c
> index 645f6a978d..9ad017d540 100644
> --- a/libavcodec/vaapi_encode_h264.c
> +++ b/libavcodec/vaapi_encode_h264.c
> @@ -23,6 +23,7 @@
>
> #include "libavutil/avassert.h"
> #include "libavutil/common.h"
> +#include "libavutil/pixdesc.h"
> #include "libavutil/internal.h"
> #include "libavutil/opt.h"
>
> @@ -301,10 +302,21 @@ static int
> vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
> H264RawPPS *pps = &priv->raw_pps;
> VAEncSequenceParameterBufferH264 *vseq = ctx->codec_sequence_params;
> VAEncPictureParameterBufferH264 *vpic = ctx->codec_picture_params;
> + const AVPixFmtDescriptor *desc;
> + int bit_depth;
>
> memset(sps, 0, sizeof(*sps));
> memset(pps, 0, sizeof(*pps));
>
> + desc = av_pix_fmt_desc_get(priv->common.input_frames->sw_format);
> + av_assert0(desc);
> + if (desc->nb_components == 1 || desc->log2_chroma_w != 1 || desc-
> >log2_chroma_h != 1) {
> + av_log(avctx, AV_LOG_ERROR, "Chroma format of input pixel format "
> + "%s is not supported.\n", desc->name);
> + return AVERROR(EINVAL);
> + }
> + bit_depth = desc->comp[0].depth;
> +
> sps->nal_unit_header.nal_ref_idc = 3;
> sps->nal_unit_header.nal_unit_type = H264_NAL_SPS;
>
> @@ -314,11 +326,11 @@ static int
> vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
> avctx->profile == FF_PROFILE_H264_MAIN)
> sps->constraint_set1_flag = 1;
>
> - if (avctx->profile == FF_PROFILE_H264_HIGH)
> + if (avctx->profile == FF_PROFILE_H264_HIGH || avctx->profile ==
> FF_PROFILE_H264_HIGH_10)
> sps->constraint_set3_flag = ctx->gop_size == 1;
>
> if (avctx->profile == FF_PROFILE_H264_MAIN ||
> - avctx->profile == FF_PROFILE_H264_HIGH) {
> + avctx->profile == FF_PROFILE_H264_HIGH || avctx->profile ==
> FF_PROFILE_H264_HIGH_10) {
> sps->constraint_set4_flag = 1;
> sps->constraint_set5_flag = ctx->b_per_p == 0;
> }
> @@ -359,6 +371,8 @@ static int
> vaapi_encode_h264_init_sequence_params(AVCodecContext *avctx)
>
> sps->seq_parameter_set_id = 0;
> sps->chroma_format_idc = 1;
> + sps->bit_depth_luma_minus8 = bit_depth - 8;
> + sps->bit_depth_chroma_minus8 = bit_depth - 8;
>
> sps->log2_max_frame_num_minus4 = 4;
> sps->pic_order_cnt_type = ctx->max_b_depth ? 0 : 2;
> @@ -1144,6 +1158,9 @@ static av_cold int
> vaapi_encode_h264_configure(AVCodecContext *avctx)
> }
>
> static const VAAPIEncodeProfile vaapi_encode_h264_profiles[] = {
> +#if VA_CHECK_VERSION(1, 18, 0)
> + { FF_PROFILE_H264_HIGH_10, 10, 3, 1, 1, VAProfileH264High10 },
> +#endif
> { FF_PROFILE_H264_HIGH, 8, 3, 1, 1, VAProfileH264High },
> { FF_PROFILE_H264_MAIN, 8, 3, 1, 1, VAProfileH264Main },
> { FF_PROFILE_H264_CONSTRAINED_BASELINE,
> @@ -1208,10 +1225,9 @@ static av_cold int
> vaapi_encode_h264_init(AVCodecContext *avctx)
> av_log(avctx, AV_LOG_ERROR, "H.264 extended profile "
> "is not supported.\n");
> return AVERROR_PATCHWELCOME;
> - case FF_PROFILE_H264_HIGH_10:
> case FF_PROFILE_H264_HIGH_10_INTRA:
> - av_log(avctx, AV_LOG_ERROR, "H.264 10-bit profiles "
> - "are not supported.\n");
> + av_log(avctx, AV_LOG_ERROR, "H.264 high 10 intra profile "
> + "is not supported.\n");
> return AVERROR_PATCHWELCOME;
> case FF_PROFILE_H264_HIGH_422:
> case FF_PROFILE_H264_HIGH_422_INTRA:
> @@ -1304,6 +1320,7 @@ static const AVOption vaapi_encode_h264_options[] = {
> { PROFILE("constrained_baseline", FF_PROFILE_H264_CONSTRAINED_BASELINE)
> },
> { PROFILE("main", FF_PROFILE_H264_MAIN) },
> { PROFILE("high", FF_PROFILE_H264_HIGH) },
> + { PROFILE("high10", FF_PROFILE_H264_HIGH_10) },
> #undef PROFILE
>
> { "level", "Set level (level_idc)",
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-03-31 4:43 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 8:41 [FFmpeg-devel] [PATCH v4] vaapi: support VAProfileH264High10 jianfeng.zheng
2023-03-31 4:43 ` Xiang, Haihao
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git