Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
@ 2024-03-18  4:21 fei.w.wang-at-intel.com
  2024-03-18  4:21 ` [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile fei.w.wang-at-intel.com
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: fei.w.wang-at-intel.com @ 2024-03-18  4:21 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: fei.w.wang

From: Fei Wang <fei.w.wang@intel.com>

There is no Main8/10 profile defined in HEVC REXT profiles. Use Main12
which is compatible with 8/10bit.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavcodec/vaapi_encode_h265.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index c4aabbf5ed..43755e2188 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -1305,12 +1305,12 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx)
 
 static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = {
     { AV_PROFILE_HEVC_MAIN,     8, 3, 1, 1, VAProfileHEVCMain       },
-    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain       },
 #if VA_CHECK_VERSION(0, 37, 0)
     { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10     },
-    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain10     },
 #endif
 #if VA_CHECK_VERSION(1, 2, 0)
+    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain12 },
+    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain12 },
     { AV_PROFILE_HEVC_REXT,    12, 3, 1, 1, VAProfileHEVCMain12 },
     { AV_PROFILE_HEVC_REXT,     8, 3, 1, 0, VAProfileHEVCMain422_10 },
     { AV_PROFILE_HEVC_REXT,    10, 3, 1, 0, VAProfileHEVCMain422_10 },
-- 
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile
  2024-03-18  4:21 [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile fei.w.wang-at-intel.com
@ 2024-03-18  4:21 ` fei.w.wang-at-intel.com
  2024-03-18 21:22   ` Mark Thompson
  2024-03-18 21:11 ` [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile Mark Thompson
  2024-04-15  1:21 ` Xiang, Haihao
  2 siblings, 1 reply; 21+ messages in thread
From: fei.w.wang-at-intel.com @ 2024-03-18  4:21 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: fei.w.wang

From: Fei Wang <fei.w.wang@intel.com>

According to Table A.2 in spec.

Signed-off-by: Fei Wang <fei.w.wang@intel.com>
---
 libavcodec/vaapi_encode_h265.c | 176 +++++++++++++++++++++++----------
 1 file changed, 123 insertions(+), 53 deletions(-)

diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
index 43755e2188..5ed317ce11 100644
--- a/libavcodec/vaapi_encode_h265.c
+++ b/libavcodec/vaapi_encode_h265.c
@@ -258,6 +258,124 @@ fail:
     return err;
 }
 
+static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx)
+{
+    VAAPIEncodeContext      *ctx = avctx->priv_data;
+    VAAPIEncodeH265Context *priv = avctx->priv_data;
+    H265RawVPS              *vps = &priv->raw_vps;
+    H265RawProfileTierLevel *ptl = &vps->profile_tier_level;
+
+    ptl->general_profile_space = 0;
+    ptl->general_profile_idc   = avctx->profile;
+    ptl->general_tier_flag     = priv->tier;
+
+    ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1;
+
+    if (ptl->general_profile_compatibility_flag[1])
+        ptl->general_profile_compatibility_flag[2] = 1;
+    if (ptl->general_profile_compatibility_flag[3]) {
+        ptl->general_profile_compatibility_flag[1] = 1;
+        ptl->general_profile_compatibility_flag[2] = 1;
+    }
+
+    ptl->general_progressive_source_flag    = 1;
+    ptl->general_interlaced_source_flag     = 0;
+    ptl->general_non_packed_constraint_flag = 1;
+    ptl->general_frame_only_constraint_flag = 1;
+
+    if (avctx->profile >= 4) {
+        ptl->general_intra_constraint_flag            = ctx->gop_size == 1;
+        ptl->general_one_picture_only_constraint_flag = 0;
+        ptl->general_lower_bit_rate_constraint_flag   = 1;
+        ptl->general_max_14bit_constraint_flag        = 0;
+
+        switch (ctx->va_profile) {
+#if VA_CHECK_VERSION(1, 2, 0)
+        case VAProfileHEVCMain12:
+            // Main 12
+            ptl->general_max_12bit_constraint_flag      = 1;
+            ptl->general_max_10bit_constraint_flag      = 0;
+            ptl->general_max_8bit_constraint_flag       = 0;
+            ptl->general_max_422chroma_constraint_flag  = 1;
+            ptl->general_max_420chroma_constraint_flag  = 1;
+            ptl->general_max_monochrome_constraint_flag = 0;
+            break;
+        case VAProfileHEVCMain422_10:
+            // Main 4:2:2 10
+            ptl->general_max_12bit_constraint_flag      = 1;
+            ptl->general_max_10bit_constraint_flag      = 1;
+            ptl->general_max_8bit_constraint_flag       = 0;
+            ptl->general_max_422chroma_constraint_flag  = 1;
+            ptl->general_max_420chroma_constraint_flag  = 0;
+            ptl->general_max_monochrome_constraint_flag = 0;
+            break;
+        case VAProfileHEVCMain422_12:
+            // Main 4:2:2 12
+            ptl->general_max_12bit_constraint_flag      = 1;
+            ptl->general_max_10bit_constraint_flag      = 0;
+            ptl->general_max_8bit_constraint_flag       = 0;
+            ptl->general_max_422chroma_constraint_flag  = 1;
+            ptl->general_max_420chroma_constraint_flag  = 0;
+            ptl->general_max_monochrome_constraint_flag = 0;
+            break;
+        case VAProfileHEVCMain444:
+            // Main 4:4:4
+            ptl->general_max_12bit_constraint_flag      = 1;
+            ptl->general_max_10bit_constraint_flag      = 1;
+            ptl->general_max_8bit_constraint_flag       = 1;
+            ptl->general_max_422chroma_constraint_flag  = 0;
+            ptl->general_max_420chroma_constraint_flag  = 0;
+            ptl->general_max_monochrome_constraint_flag = 0;
+            break;
+        case VAProfileHEVCMain444_10:
+            // Main 4:4:4 10
+            ptl->general_max_12bit_constraint_flag      = 1;
+            ptl->general_max_10bit_constraint_flag      = 1;
+            ptl->general_max_8bit_constraint_flag       = 0;
+            ptl->general_max_422chroma_constraint_flag  = 0;
+            ptl->general_max_420chroma_constraint_flag  = 0;
+            ptl->general_max_monochrome_constraint_flag = 0;
+            break;
+        case VAProfileHEVCMain444_12:
+            // Main 4:4:4 12
+            ptl->general_max_12bit_constraint_flag      = 1;
+            ptl->general_max_10bit_constraint_flag      = 0;
+            ptl->general_max_8bit_constraint_flag       = 0;
+            ptl->general_max_422chroma_constraint_flag  = 0;
+            ptl->general_max_420chroma_constraint_flag  = 0;
+            ptl->general_max_monochrome_constraint_flag = 0;
+            break;
+#endif
+        default:
+            av_log(avctx, AV_LOG_ERROR, "Unknown profile to init PTL.\n");
+            return AVERROR(EINVAL);
+        }
+    }
+
+    if (avctx->level != AV_LEVEL_UNKNOWN) {
+        ptl->general_level_idc = avctx->level;
+    } else {
+        const H265LevelDescriptor *level;
+
+        level = ff_h265_guess_level(ptl, avctx->bit_rate,
+                                    ctx->surface_width, ctx->surface_height,
+                                    ctx->nb_slices, ctx->tile_rows, ctx->tile_cols,
+                                    (ctx->b_per_p > 0) + 1);
+        if (level) {
+            av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
+            ptl->general_level_idc = level->level_idc;
+        } else {
+            av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to "
+                   "any normal level; using level 8.5.\n");
+            ptl->general_level_idc = 255;
+            // The tier flag must be set in level 8.5.
+            ptl->general_tier_flag = 1;
+        }
+    }
+
+    return 0;
+}
+
 static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
 {
     VAAPIEncodeContext                *ctx = avctx->priv_data;
@@ -265,13 +383,12 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
     H265RawVPS                        *vps = &priv->raw_vps;
     H265RawSPS                        *sps = &priv->raw_sps;
     H265RawPPS                        *pps = &priv->raw_pps;
-    H265RawProfileTierLevel           *ptl = &vps->profile_tier_level;
     H265RawVUI                        *vui = &sps->vui;
     VAEncSequenceParameterBufferHEVC *vseq = ctx->codec_sequence_params;
     VAEncPictureParameterBufferHEVC  *vpic = ctx->codec_picture_params;
     const AVPixFmtDescriptor *desc;
     int chroma_format, bit_depth;
-    int i;
+    int i, err;
 
     memset(vps, 0, sizeof(*vps));
     memset(sps, 0, sizeof(*sps));
@@ -314,57 +431,10 @@ static int vaapi_encode_h265_init_sequence_params(AVCodecContext *avctx)
     vps->vps_max_sub_layers_minus1     = 0;
     vps->vps_temporal_id_nesting_flag  = 1;
 
-    ptl->general_profile_space = 0;
-    ptl->general_profile_idc   = avctx->profile;
-    ptl->general_tier_flag     = priv->tier;
-
-    ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1;
-
-    if (ptl->general_profile_compatibility_flag[1])
-        ptl->general_profile_compatibility_flag[2] = 1;
-    if (ptl->general_profile_compatibility_flag[3]) {
-        ptl->general_profile_compatibility_flag[1] = 1;
-        ptl->general_profile_compatibility_flag[2] = 1;
-    }
-
-    ptl->general_progressive_source_flag    = 1;
-    ptl->general_interlaced_source_flag     = 0;
-    ptl->general_non_packed_constraint_flag = 1;
-    ptl->general_frame_only_constraint_flag = 1;
-
-    ptl->general_max_14bit_constraint_flag = bit_depth <= 14;
-    ptl->general_max_12bit_constraint_flag = bit_depth <= 12;
-    ptl->general_max_10bit_constraint_flag = bit_depth <= 10;
-    ptl->general_max_8bit_constraint_flag  = bit_depth ==  8;
-
-    ptl->general_max_422chroma_constraint_flag  = chroma_format <= 2;
-    ptl->general_max_420chroma_constraint_flag  = chroma_format <= 1;
-    ptl->general_max_monochrome_constraint_flag = chroma_format == 0;
-
-    ptl->general_intra_constraint_flag = ctx->gop_size == 1;
-    ptl->general_one_picture_only_constraint_flag = 0;
-
-    ptl->general_lower_bit_rate_constraint_flag = 1;
-
-    if (avctx->level != AV_LEVEL_UNKNOWN) {
-        ptl->general_level_idc = avctx->level;
-    } else {
-        const H265LevelDescriptor *level;
-
-        level = ff_h265_guess_level(ptl, avctx->bit_rate,
-                                    ctx->surface_width, ctx->surface_height,
-                                    ctx->nb_slices, ctx->tile_rows, ctx->tile_cols,
-                                    (ctx->b_per_p > 0) + 1);
-        if (level) {
-            av_log(avctx, AV_LOG_VERBOSE, "Using level %s.\n", level->name);
-            ptl->general_level_idc = level->level_idc;
-        } else {
-            av_log(avctx, AV_LOG_VERBOSE, "Stream will not conform to "
-                   "any normal level; using level 8.5.\n");
-            ptl->general_level_idc = 255;
-            // The tier flag must be set in level 8.5.
-            ptl->general_tier_flag = 1;
-        }
+    err = vaapi_encode_h265_init_ptl(avctx);
+    if (err < 0) {
+        av_log(avctx, AV_LOG_ERROR, "Failed to init PTL.\n");
+        return err;
     }
 
     vps->vps_sub_layer_ordering_info_present_flag = 0;
-- 
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
  2024-03-18  4:21 [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile fei.w.wang-at-intel.com
  2024-03-18  4:21 ` [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile fei.w.wang-at-intel.com
@ 2024-03-18 21:11 ` Mark Thompson
  2024-03-20  7:39   ` Wang, Fei W
  2024-04-15  1:21 ` Xiang, Haihao
  2 siblings, 1 reply; 21+ messages in thread
From: Mark Thompson @ 2024-03-18 21:11 UTC (permalink / raw)
  To: ffmpeg-devel

On 18/03/2024 04:21, fei.w.wang-at-intel.com@ffmpeg.org wrote:
> From: Fei Wang <fei.w.wang@intel.com>
> 
> There is no Main8/10 profile defined in HEVC REXT profiles. Use Main12
> which is compatible with 8/10bit.
> 
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>   libavcodec/vaapi_encode_h265.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index c4aabbf5ed..43755e2188 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -1305,12 +1305,12 @@ static av_cold int vaapi_encode_h265_configure(AVCodecContext *avctx)
>   
>   static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = {
>       { AV_PROFILE_HEVC_MAIN,     8, 3, 1, 1, VAProfileHEVCMain       },
> -    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain       },
>   #if VA_CHECK_VERSION(0, 37, 0)
>       { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10     },
> -    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain10     },
>   #endif
>   #if VA_CHECK_VERSION(1, 2, 0)
> +    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain12 },
> +    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain12 },
>       { AV_PROFILE_HEVC_REXT,    12, 3, 1, 1, VAProfileHEVCMain12 },
>       { AV_PROFILE_HEVC_REXT,     8, 3, 1, 0, VAProfileHEVCMain422_10 },
>       { AV_PROFILE_HEVC_REXT,    10, 3, 1, 0, VAProfileHEVCMain422_10 },

What are you actually trying to do here?

See 61aea246627787e80edd1f2eae01df63688dda68: these allow support for the Main Intra and Main 10 Intra profiles using Main and Main 10 encoders respectively (since they need not use any additional rext features).

Changing this to require a Main 12 encoder and marking the streams as requiring such a Main 12 decoder to decode when they don't does not seem helpful.

Thanks,

- Mark
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile
  2024-03-18  4:21 ` [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile fei.w.wang-at-intel.com
@ 2024-03-18 21:22   ` Mark Thompson
  2024-03-20  8:44     ` Wang, Fei W
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Thompson @ 2024-03-18 21:22 UTC (permalink / raw)
  To: ffmpeg-devel

On 18/03/2024 04:21, fei.w.wang-at-intel.com@ffmpeg.org wrote:
> From: Fei Wang <fei.w.wang@intel.com>
> 
> According to Table A.2 in spec.
> 
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>   libavcodec/vaapi_encode_h265.c | 176 +++++++++++++++++++++++----------
>   1 file changed, 123 insertions(+), 53 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index 43755e2188..5ed317ce11 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -258,6 +258,124 @@ fail:
>       return err;
>   }
>   
> +static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx)
> +{
> +    VAAPIEncodeContext      *ctx = avctx->priv_data;
> +    VAAPIEncodeH265Context *priv = avctx->priv_data;
> +    H265RawVPS              *vps = &priv->raw_vps;
> +    H265RawProfileTierLevel *ptl = &vps->profile_tier_level;
> +
> +    ptl->general_profile_space = 0;
> +    ptl->general_profile_idc   = avctx->profile;
> +    ptl->general_tier_flag     = priv->tier;
> +
> +    ptl->general_profile_compatibility_flag[ptl->general_profile_idc] = 1;
> +
> +    if (ptl->general_profile_compatibility_flag[1])
> +        ptl->general_profile_compatibility_flag[2] = 1;
> +    if (ptl->general_profile_compatibility_flag[3]) {
> +        ptl->general_profile_compatibility_flag[1] = 1;
> +        ptl->general_profile_compatibility_flag[2] = 1;
> +    }
> +
> +    ptl->general_progressive_source_flag    = 1;
> +    ptl->general_interlaced_source_flag     = 0;
> +    ptl->general_non_packed_constraint_flag = 1;
> +    ptl->general_frame_only_constraint_flag = 1;
> +
> +    if (avctx->profile >= 4) {
> +        ptl->general_intra_constraint_flag            = ctx->gop_size == 1;
> +        ptl->general_one_picture_only_constraint_flag = 0;
> +        ptl->general_lower_bit_rate_constraint_flag   = 1;
> +        ptl->general_max_14bit_constraint_flag        = 0;
> +
> +        switch (ctx->va_profile) {
> +#if VA_CHECK_VERSION(1, 2, 0)
> +        case VAProfileHEVCMain12:
> +            // Main 12
> +            ptl->general_max_12bit_constraint_flag      = 1;
> +            ptl->general_max_10bit_constraint_flag      = 0;
> +            ptl->general_max_8bit_constraint_flag       = 0;
> +            ptl->general_max_422chroma_constraint_flag  = 1;
> +            ptl->general_max_420chroma_constraint_flag  = 1;
> +            ptl->general_max_monochrome_constraint_flag = 0;
> +            break;
> +        case VAProfileHEVCMain422_10:
> +            // Main 4:2:2 10
> +            ptl->general_max_12bit_constraint_flag      = 1;
> +            ptl->general_max_10bit_constraint_flag      = 1;
> +            ptl->general_max_8bit_constraint_flag       = 0;
> +            ptl->general_max_422chroma_constraint_flag  = 1;
> +            ptl->general_max_420chroma_constraint_flag  = 0;
> +            ptl->general_max_monochrome_constraint_flag = 0;
> +            break;
> +        case VAProfileHEVCMain422_12:
> +            // Main 4:2:2 12
> +            ptl->general_max_12bit_constraint_flag      = 1;
> +            ptl->general_max_10bit_constraint_flag      = 0;
> +            ptl->general_max_8bit_constraint_flag       = 0;
> +            ptl->general_max_422chroma_constraint_flag  = 1;
> +            ptl->general_max_420chroma_constraint_flag  = 0;
> +            ptl->general_max_monochrome_constraint_flag = 0;
> +            break;
> +        case VAProfileHEVCMain444:
> +            // Main 4:4:4
> +            ptl->general_max_12bit_constraint_flag      = 1;
> +            ptl->general_max_10bit_constraint_flag      = 1;
> +            ptl->general_max_8bit_constraint_flag       = 1;
> +            ptl->general_max_422chroma_constraint_flag  = 0;
> +            ptl->general_max_420chroma_constraint_flag  = 0;
> +            ptl->general_max_monochrome_constraint_flag = 0;
> +            break;
> +        case VAProfileHEVCMain444_10:
> +            // Main 4:4:4 10
> +            ptl->general_max_12bit_constraint_flag      = 1;
> +            ptl->general_max_10bit_constraint_flag      = 1;
> +            ptl->general_max_8bit_constraint_flag       = 0;
> +            ptl->general_max_422chroma_constraint_flag  = 0;
> +            ptl->general_max_420chroma_constraint_flag  = 0;
> +            ptl->general_max_monochrome_constraint_flag = 0;
> +            break;
> +        case VAProfileHEVCMain444_12:
> +            // Main 4:4:4 12
> +            ptl->general_max_12bit_constraint_flag      = 1;
> +            ptl->general_max_10bit_constraint_flag      = 0;
> +            ptl->general_max_8bit_constraint_flag       = 0;
> +            ptl->general_max_422chroma_constraint_flag  = 0;
> +            ptl->general_max_420chroma_constraint_flag  = 0;
> +            ptl->general_max_monochrome_constraint_flag = 0;
> +            break;
> +#endif
> +        default:
> +            av_log(avctx, AV_LOG_ERROR, "Unknown profile to init PTL.\n");
> +            return AVERROR(EINVAL);
> +        }
> +    }

Why is this an improvement over the current code which sets the constraint flags based on the actual content of the stream?

Note the requirement in A.3.5 for decoder support:

general_profile_idc is equal to 4 or general_profile_compatibility_flag[ 4 ] is equal to 1 for the bitstream, and
the value of each constraint flag listed in Table A.2 is greater than or equal to the value(s) specified in the row
of Table A.2 for the format range extensions profile for which the decoder conformance is evaluated.

which says that decoders must be able to support streams which set additional constraint flags beyond those which are specified for a particular profile (in particular, an 8-bit 4:2:2 stream must be decodable by any decoder supporting either "Main 4:2:2 10" or "Main 4:4:4", so ideally it shouldn't be marked to require one of those in particular).

Thanks,

- Mark
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
  2024-03-18 21:11 ` [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile Mark Thompson
@ 2024-03-20  7:39   ` Wang, Fei W
  0 siblings, 0 replies; 21+ messages in thread
From: Wang, Fei W @ 2024-03-20  7:39 UTC (permalink / raw)
  To: ffmpeg-devel

On Mon, 2024-03-18 at 21:11 +0000, Mark Thompson wrote:
> On 18/03/2024 04:21, fei.w.wang-at-intel.com@ffmpeg.org wrote:
> > From: Fei Wang <fei.w.wang@intel.com>
> > 
> > There is no Main8/10 profile defined in HEVC REXT profiles. Use
> > Main12
> > which is compatible with 8/10bit.
> > 
> > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > ---
> >   libavcodec/vaapi_encode_h265.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libavcodec/vaapi_encode_h265.c
> > b/libavcodec/vaapi_encode_h265.c
> > index c4aabbf5ed..43755e2188 100644
> > --- a/libavcodec/vaapi_encode_h265.c
> > +++ b/libavcodec/vaapi_encode_h265.c
> > @@ -1305,12 +1305,12 @@ static av_cold int
> > vaapi_encode_h265_configure(AVCodecContext *avctx)
> >   
> >   static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = {
> >       { AV_PROFILE_HEVC_MAIN,     8, 3, 1, 1,
> > VAProfileHEVCMain       },
> > -    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1,
> > VAProfileHEVCMain       },
> >   #if VA_CHECK_VERSION(0, 37, 0)
> >       { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1,
> > VAProfileHEVCMain10     },
> > -    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1,
> > VAProfileHEVCMain10     },
> >   #endif
> >   #if VA_CHECK_VERSION(1, 2, 0)
> > +    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain12 },
> > +    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain12 },
> >       { AV_PROFILE_HEVC_REXT,    12, 3, 1, 1, VAProfileHEVCMain12
> > },
> >       { AV_PROFILE_HEVC_REXT,     8, 3, 1, 0,
> > VAProfileHEVCMain422_10 },
> >       { AV_PROFILE_HEVC_REXT,    10, 3, 1, 0,
> > VAProfileHEVCMain422_10 },
> 
> What are you actually trying to do here?
> 
> See 61aea246627787e80edd1f2eae01df63688dda68: these allow support for
> the Main Intra and Main 10 Intra profiles using Main and Main 10
> encoders respectively (since they need not use any additional rext
> features).

The hack blocks 420 8/10bit with inter frames to use REXT. Make them to
use VAProfileHEVCMain12 should be the best way, just like 422 8/10bit
all use VAProfileHEVCMain422_10.

Thanks
Fei
> 
> Changing this to require a Main 12 encoder and marking the streams as
> requiring such a Main 12 decoder to decode when they don't does not
> seem helpful.
> 
> Thanks,
> 
> - Mark
> _______________________________________________
> 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".
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile
  2024-03-18 21:22   ` Mark Thompson
@ 2024-03-20  8:44     ` Wang, Fei W
  2024-04-01  6:11       ` Wang, Fei W
  2024-04-01 20:02       ` Mark Thompson
  0 siblings, 2 replies; 21+ messages in thread
From: Wang, Fei W @ 2024-03-20  8:44 UTC (permalink / raw)
  To: ffmpeg-devel

On Mon, 2024-03-18 at 21:22 +0000, Mark Thompson wrote:
> On 18/03/2024 04:21, fei.w.wang-at-intel.com@ffmpeg.org wrote:
> > From: Fei Wang <fei.w.wang@intel.com>
> > 
> > According to Table A.2 in spec.
> > 
> > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > ---
> >   libavcodec/vaapi_encode_h265.c | 176 +++++++++++++++++++++++-----
> > -----
> >   1 file changed, 123 insertions(+), 53 deletions(-)
> > 
> > diff --git a/libavcodec/vaapi_encode_h265.c
> > b/libavcodec/vaapi_encode_h265.c
> > index 43755e2188..5ed317ce11 100644
> > --- a/libavcodec/vaapi_encode_h265.c
> > +++ b/libavcodec/vaapi_encode_h265.c
> > @@ -258,6 +258,124 @@ fail:
> >       return err;
> >   }
> >   
> > +static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx)
> > +{
> > +    VAAPIEncodeContext      *ctx = avctx->priv_data;
> > +    VAAPIEncodeH265Context *priv = avctx->priv_data;
> > +    H265RawVPS              *vps = &priv->raw_vps;
> > +    H265RawProfileTierLevel *ptl = &vps->profile_tier_level;
> > +
> > +    ptl->general_profile_space = 0;
> > +    ptl->general_profile_idc   = avctx->profile;
> > +    ptl->general_tier_flag     = priv->tier;
> > +
> > +    ptl->general_profile_compatibility_flag[ptl-
> > >general_profile_idc] = 1;
> > +
> > +    if (ptl->general_profile_compatibility_flag[1])
> > +        ptl->general_profile_compatibility_flag[2] = 1;
> > +    if (ptl->general_profile_compatibility_flag[3]) {
> > +        ptl->general_profile_compatibility_flag[1] = 1;
> > +        ptl->general_profile_compatibility_flag[2] = 1;
> > +    }
> > +
> > +    ptl->general_progressive_source_flag    = 1;
> > +    ptl->general_interlaced_source_flag     = 0;
> > +    ptl->general_non_packed_constraint_flag = 1;
> > +    ptl->general_frame_only_constraint_flag = 1;
> > +
> > +    if (avctx->profile >= 4) {
> > +        ptl->general_intra_constraint_flag            = ctx-
> > >gop_size == 1;
> > +        ptl->general_one_picture_only_constraint_flag = 0;
> > +        ptl->general_lower_bit_rate_constraint_flag   = 1;
> > +        ptl->general_max_14bit_constraint_flag        = 0;
> > +
> > +        switch (ctx->va_profile) {
> > +#if VA_CHECK_VERSION(1, 2, 0)
> > +        case VAProfileHEVCMain12:
> > +            // Main 12
> > +            ptl->general_max_12bit_constraint_flag      = 1;
> > +            ptl->general_max_10bit_constraint_flag      = 0;
> > +            ptl->general_max_8bit_constraint_flag       = 0;
> > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > +            ptl->general_max_420chroma_constraint_flag  = 1;
> > +            ptl->general_max_monochrome_constraint_flag = 0;
> > +            break;
> > +        case VAProfileHEVCMain422_10:
> > +            // Main 4:2:2 10
> > +            ptl->general_max_12bit_constraint_flag      = 1;
> > +            ptl->general_max_10bit_constraint_flag      = 1;
> > +            ptl->general_max_8bit_constraint_flag       = 0;
> > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > +            ptl->general_max_monochrome_constraint_flag = 0;
> > +            break;
> > +        case VAProfileHEVCMain422_12:
> > +            // Main 4:2:2 12
> > +            ptl->general_max_12bit_constraint_flag      = 1;
> > +            ptl->general_max_10bit_constraint_flag      = 0;
> > +            ptl->general_max_8bit_constraint_flag       = 0;
> > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > +            ptl->general_max_monochrome_constraint_flag = 0;
> > +            break;
> > +        case VAProfileHEVCMain444:
> > +            // Main 4:4:4
> > +            ptl->general_max_12bit_constraint_flag      = 1;
> > +            ptl->general_max_10bit_constraint_flag      = 1;
> > +            ptl->general_max_8bit_constraint_flag       = 1;
> > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > +            ptl->general_max_monochrome_constraint_flag = 0;
> > +            break;
> > +        case VAProfileHEVCMain444_10:
> > +            // Main 4:4:4 10
> > +            ptl->general_max_12bit_constraint_flag      = 1;
> > +            ptl->general_max_10bit_constraint_flag      = 1;
> > +            ptl->general_max_8bit_constraint_flag       = 0;
> > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > +            ptl->general_max_monochrome_constraint_flag = 0;
> > +            break;
> > +        case VAProfileHEVCMain444_12:
> > +            // Main 4:4:4 12
> > +            ptl->general_max_12bit_constraint_flag      = 1;
> > +            ptl->general_max_10bit_constraint_flag      = 0;
> > +            ptl->general_max_8bit_constraint_flag       = 0;
> > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > +            ptl->general_max_monochrome_constraint_flag = 0;
> > +            break;
> > +#endif
> > +        default:
> > +            av_log(avctx, AV_LOG_ERROR, "Unknown profile to init
> > PTL.\n");
> > +            return AVERROR(EINVAL);
> > +        }
> > +    }
> 
> Why is this an improvement over the current code which sets the
> constraint flags based on the actual content of the stream?
> 
> Note the requirement in A.3.5 for decoder support:
> 
> general_profile_idc is equal to 4 or
> general_profile_compatibility_flag[ 4 ] is equal to 1 for the
> bitstream, and
> the value of each constraint flag listed in Table A.2 is greater than
> or equal to the value(s) specified in the row
> of Table A.2 for the format range extensions profile for which the
> decoder conformance is evaluated.
> 
> which says that decoders must be able to support streams which set
> additional constraint flags beyond those which are specified for a
> particular profile (in particular, an 8-bit 4:2:2 stream must be
> decodable by any decoder supporting either "Main 4:2:2 10" or "Main
> 4:4:4", so ideally it shouldn't be marked to require one of those in
> particular).

That's a capability request for decoder. For encoder side, I'd prefer
to use the most typical values. The constraint flags in Table A.2/3/5
are strictly checked to get rext profile in ff_h265_get_profile(), and
seems the constraint flags is the only way to distinguish profiles in
rext(all the rext profiles shares same general_profile_idc or
general_profile_compatibility_flag[ 4 ]).

Thanks
Fei

> 
> Thanks,
> 
> - Mark
> _______________________________________________
> 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".
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile
  2024-03-20  8:44     ` Wang, Fei W
@ 2024-04-01  6:11       ` Wang, Fei W
  2024-04-01 20:02       ` Mark Thompson
  1 sibling, 0 replies; 21+ messages in thread
From: Wang, Fei W @ 2024-04-01  6:11 UTC (permalink / raw)
  To: ffmpeg-devel

On Wed, 2024-03-20 at 16:44 +0800, Fei Wang wrote:
> On Mon, 2024-03-18 at 21:22 +0000, Mark Thompson wrote:
> > On 18/03/2024 04:21, fei.w.wang-at-intel.com@ffmpeg.org wrote:
> > > From: Fei Wang <fei.w.wang@intel.com>
> > > 
> > > According to Table A.2 in spec.
> > > 
> > > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > > ---
> > >   libavcodec/vaapi_encode_h265.c | 176 +++++++++++++++++++++++---
> > > --
> > > -----
> > >   1 file changed, 123 insertions(+), 53 deletions(-)
> > > 
> > > diff --git a/libavcodec/vaapi_encode_h265.c
> > > b/libavcodec/vaapi_encode_h265.c
> > > index 43755e2188..5ed317ce11 100644
> > > --- a/libavcodec/vaapi_encode_h265.c
> > > +++ b/libavcodec/vaapi_encode_h265.c
> > > @@ -258,6 +258,124 @@ fail:
> > >       return err;
> > >   }
> > >   
> > > +static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx)
> > > +{
> > > +    VAAPIEncodeContext      *ctx = avctx->priv_data;
> > > +    VAAPIEncodeH265Context *priv = avctx->priv_data;
> > > +    H265RawVPS              *vps = &priv->raw_vps;
> > > +    H265RawProfileTierLevel *ptl = &vps->profile_tier_level;
> > > +
> > > +    ptl->general_profile_space = 0;
> > > +    ptl->general_profile_idc   = avctx->profile;
> > > +    ptl->general_tier_flag     = priv->tier;
> > > +
> > > +    ptl->general_profile_compatibility_flag[ptl-
> > > > general_profile_idc] = 1;
> > > +
> > > +    if (ptl->general_profile_compatibility_flag[1])
> > > +        ptl->general_profile_compatibility_flag[2] = 1;
> > > +    if (ptl->general_profile_compatibility_flag[3]) {
> > > +        ptl->general_profile_compatibility_flag[1] = 1;
> > > +        ptl->general_profile_compatibility_flag[2] = 1;
> > > +    }
> > > +
> > > +    ptl->general_progressive_source_flag    = 1;
> > > +    ptl->general_interlaced_source_flag     = 0;
> > > +    ptl->general_non_packed_constraint_flag = 1;
> > > +    ptl->general_frame_only_constraint_flag = 1;
> > > +
> > > +    if (avctx->profile >= 4) {
> > > +        ptl->general_intra_constraint_flag            = ctx-
> > > > gop_size == 1;
> > > +        ptl->general_one_picture_only_constraint_flag = 0;
> > > +        ptl->general_lower_bit_rate_constraint_flag   = 1;
> > > +        ptl->general_max_14bit_constraint_flag        = 0;
> > > +
> > > +        switch (ctx->va_profile) {
> > > +#if VA_CHECK_VERSION(1, 2, 0)
> > > +        case VAProfileHEVCMain12:
> > > +            // Main 12
> > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > +            ptl->general_max_10bit_constraint_flag      = 0;
> > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > > +            ptl->general_max_420chroma_constraint_flag  = 1;
> > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > +            break;
> > > +        case VAProfileHEVCMain422_10:
> > > +            // Main 4:2:2 10
> > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > +            ptl->general_max_10bit_constraint_flag      = 1;
> > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > +            break;
> > > +        case VAProfileHEVCMain422_12:
> > > +            // Main 4:2:2 12
> > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > +            ptl->general_max_10bit_constraint_flag      = 0;
> > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > +            break;
> > > +        case VAProfileHEVCMain444:
> > > +            // Main 4:4:4
> > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > +            ptl->general_max_10bit_constraint_flag      = 1;
> > > +            ptl->general_max_8bit_constraint_flag       = 1;
> > > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > +            break;
> > > +        case VAProfileHEVCMain444_10:
> > > +            // Main 4:4:4 10
> > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > +            ptl->general_max_10bit_constraint_flag      = 1;
> > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > +            break;
> > > +        case VAProfileHEVCMain444_12:
> > > +            // Main 4:4:4 12
> > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > +            ptl->general_max_10bit_constraint_flag      = 0;
> > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > +            break;
> > > +#endif
> > > +        default:
> > > +            av_log(avctx, AV_LOG_ERROR, "Unknown profile to init
> > > PTL.\n");
> > > +            return AVERROR(EINVAL);
> > > +        }
> > > +    }
> > 
> > Why is this an improvement over the current code which sets the
> > constraint flags based on the actual content of the stream?
> > 
> > Note the requirement in A.3.5 for decoder support:
> > 
> > general_profile_idc is equal to 4 or
> > general_profile_compatibility_flag[ 4 ] is equal to 1 for the
> > bitstream, and
> > the value of each constraint flag listed in Table A.2 is greater
> > than
> > or equal to the value(s) specified in the row
> > of Table A.2 for the format range extensions profile for which the
> > decoder conformance is evaluated.
> > 
> > which says that decoders must be able to support streams which set
> > additional constraint flags beyond those which are specified for a
> > particular profile (in particular, an 8-bit 4:2:2 stream must be
> > decodable by any decoder supporting either "Main 4:2:2 10" or "Main
> > 4:4:4", so ideally it shouldn't be marked to require one of those
> > in
> > particular).
> 
> That's a capability request for decoder. For encoder side, I'd prefer
> to use the most typical values. The constraint flags in Table A.2/3/5
> are strictly checked to get rext profile in ff_h265_get_profile(),
> and
> seems the constraint flags is the only way to distinguish profiles in
> rext(all the rext profiles shares same general_profile_idc or
> general_profile_compatibility_flag[ 4 ]).

Hi Mark,

Any other comments on this patchset?

Thanks
Fei

> 
> Thanks
> Fei
> 
> > Thanks,
> > 
> > - Mark
> > _______________________________________________
> > 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".
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile
  2024-03-20  8:44     ` Wang, Fei W
  2024-04-01  6:11       ` Wang, Fei W
@ 2024-04-01 20:02       ` Mark Thompson
  2024-04-02  5:18         ` Wang, Fei W
  1 sibling, 1 reply; 21+ messages in thread
From: Mark Thompson @ 2024-04-01 20:02 UTC (permalink / raw)
  To: ffmpeg-devel

On 20/03/2024 08:44, Wang, Fei W wrote:
> On Mon, 2024-03-18 at 21:22 +0000, Mark Thompson wrote:
>> On 18/03/2024 04:21, fei.w.wang-at-intel.com@ffmpeg.org wrote:
>>> From: Fei Wang <fei.w.wang@intel.com>
>>>
>>> According to Table A.2 in spec.
>>>
>>> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
>>> ---
>>>    libavcodec/vaapi_encode_h265.c | 176 +++++++++++++++++++++++-----
>>> -----
>>>    1 file changed, 123 insertions(+), 53 deletions(-)
>>>
>>> diff --git a/libavcodec/vaapi_encode_h265.c
>>> b/libavcodec/vaapi_encode_h265.c
>>> index 43755e2188..5ed317ce11 100644
>>> --- a/libavcodec/vaapi_encode_h265.c
>>> +++ b/libavcodec/vaapi_encode_h265.c
>>> @@ -258,6 +258,124 @@ fail:
>>>        return err;
>>>    }
>>>    
>>> +static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx)
>>> +{
>>> +    VAAPIEncodeContext      *ctx = avctx->priv_data;
>>> +    VAAPIEncodeH265Context *priv = avctx->priv_data;
>>> +    H265RawVPS              *vps = &priv->raw_vps;
>>> +    H265RawProfileTierLevel *ptl = &vps->profile_tier_level;
>>> +
>>> +    ptl->general_profile_space = 0;
>>> +    ptl->general_profile_idc   = avctx->profile;
>>> +    ptl->general_tier_flag     = priv->tier;
>>> +
>>> +    ptl->general_profile_compatibility_flag[ptl-
>>>> general_profile_idc] = 1;
>>> +
>>> +    if (ptl->general_profile_compatibility_flag[1])
>>> +        ptl->general_profile_compatibility_flag[2] = 1;
>>> +    if (ptl->general_profile_compatibility_flag[3]) {
>>> +        ptl->general_profile_compatibility_flag[1] = 1;
>>> +        ptl->general_profile_compatibility_flag[2] = 1;
>>> +    }
>>> +
>>> +    ptl->general_progressive_source_flag    = 1;
>>> +    ptl->general_interlaced_source_flag     = 0;
>>> +    ptl->general_non_packed_constraint_flag = 1;
>>> +    ptl->general_frame_only_constraint_flag = 1;
>>> +
>>> +    if (avctx->profile >= 4) {
>>> +        ptl->general_intra_constraint_flag            = ctx-
>>>> gop_size == 1;
>>> +        ptl->general_one_picture_only_constraint_flag = 0;
>>> +        ptl->general_lower_bit_rate_constraint_flag   = 1;
>>> +        ptl->general_max_14bit_constraint_flag        = 0;
>>> +
>>> +        switch (ctx->va_profile) {
>>> +#if VA_CHECK_VERSION(1, 2, 0)
>>> +        case VAProfileHEVCMain12:
>>> +            // Main 12
>>> +            ptl->general_max_12bit_constraint_flag      = 1;
>>> +            ptl->general_max_10bit_constraint_flag      = 0;
>>> +            ptl->general_max_8bit_constraint_flag       = 0;
>>> +            ptl->general_max_422chroma_constraint_flag  = 1;
>>> +            ptl->general_max_420chroma_constraint_flag  = 1;
>>> +            ptl->general_max_monochrome_constraint_flag = 0;
>>> +            break;
>>> +        case VAProfileHEVCMain422_10:
>>> +            // Main 4:2:2 10
>>> +            ptl->general_max_12bit_constraint_flag      = 1;
>>> +            ptl->general_max_10bit_constraint_flag      = 1;
>>> +            ptl->general_max_8bit_constraint_flag       = 0;
>>> +            ptl->general_max_422chroma_constraint_flag  = 1;
>>> +            ptl->general_max_420chroma_constraint_flag  = 0;
>>> +            ptl->general_max_monochrome_constraint_flag = 0;
>>> +            break;
>>> +        case VAProfileHEVCMain422_12:
>>> +            // Main 4:2:2 12
>>> +            ptl->general_max_12bit_constraint_flag      = 1;
>>> +            ptl->general_max_10bit_constraint_flag      = 0;
>>> +            ptl->general_max_8bit_constraint_flag       = 0;
>>> +            ptl->general_max_422chroma_constraint_flag  = 1;
>>> +            ptl->general_max_420chroma_constraint_flag  = 0;
>>> +            ptl->general_max_monochrome_constraint_flag = 0;
>>> +            break;
>>> +        case VAProfileHEVCMain444:
>>> +            // Main 4:4:4
>>> +            ptl->general_max_12bit_constraint_flag      = 1;
>>> +            ptl->general_max_10bit_constraint_flag      = 1;
>>> +            ptl->general_max_8bit_constraint_flag       = 1;
>>> +            ptl->general_max_422chroma_constraint_flag  = 0;
>>> +            ptl->general_max_420chroma_constraint_flag  = 0;
>>> +            ptl->general_max_monochrome_constraint_flag = 0;
>>> +            break;
>>> +        case VAProfileHEVCMain444_10:
>>> +            // Main 4:4:4 10
>>> +            ptl->general_max_12bit_constraint_flag      = 1;
>>> +            ptl->general_max_10bit_constraint_flag      = 1;
>>> +            ptl->general_max_8bit_constraint_flag       = 0;
>>> +            ptl->general_max_422chroma_constraint_flag  = 0;
>>> +            ptl->general_max_420chroma_constraint_flag  = 0;
>>> +            ptl->general_max_monochrome_constraint_flag = 0;
>>> +            break;
>>> +        case VAProfileHEVCMain444_12:
>>> +            // Main 4:4:4 12
>>> +            ptl->general_max_12bit_constraint_flag      = 1;
>>> +            ptl->general_max_10bit_constraint_flag      = 0;
>>> +            ptl->general_max_8bit_constraint_flag       = 0;
>>> +            ptl->general_max_422chroma_constraint_flag  = 0;
>>> +            ptl->general_max_420chroma_constraint_flag  = 0;
>>> +            ptl->general_max_monochrome_constraint_flag = 0;
>>> +            break;
>>> +#endif
>>> +        default:
>>> +            av_log(avctx, AV_LOG_ERROR, "Unknown profile to init
>>> PTL.\n");
>>> +            return AVERROR(EINVAL);
>>> +        }
>>> +    }
>>
>> Why is this an improvement over the current code which sets the
>> constraint flags based on the actual content of the stream?
>>
>> Note the requirement in A.3.5 for decoder support:
>>
>> general_profile_idc is equal to 4 or
>> general_profile_compatibility_flag[ 4 ] is equal to 1 for the
>> bitstream, and
>> the value of each constraint flag listed in Table A.2 is greater than
>> or equal to the value(s) specified in the row
>> of Table A.2 for the format range extensions profile for which the
>> decoder conformance is evaluated.
>>
>> which says that decoders must be able to support streams which set
>> additional constraint flags beyond those which are specified for a
>> particular profile (in particular, an 8-bit 4:2:2 stream must be
>> decodable by any decoder supporting either "Main 4:2:2 10" or "Main
>> 4:4:4", so ideally it shouldn't be marked to require one of those in
>> particular).
> 
> That's a capability request for decoder. For encoder side, I'd prefer
> to use the most typical values. The constraint flags in Table A.2/3/5
> are strictly checked to get rext profile in ff_h265_get_profile(), and
> seems the constraint flags is the only way to distinguish profiles in
> rext(all the rext profiles shares same general_profile_idc or
> general_profile_compatibility_flag[ 4 ]).

Hmm.  I was missing that the VAAPI decoder has fixed matching - it only accepts things which exactly match the hull of each profile, not ones inside it which are compatible.  That seems worth fixing.

Do other decoder implementations do the same thing with strict matching?  libavcodec's software decoder doesn't - the profile isn't really relevant to it.  nvdec doesn't obviously do anything there either because it accepts all rext streams, though presumably some of them fail later.

Thanks,

- Mark
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile
  2024-04-01 20:02       ` Mark Thompson
@ 2024-04-02  5:18         ` Wang, Fei W
  0 siblings, 0 replies; 21+ messages in thread
From: Wang, Fei W @ 2024-04-02  5:18 UTC (permalink / raw)
  To: ffmpeg-devel

On Mon, 2024-04-01 at 21:02 +0100, Mark Thompson wrote:
> On 20/03/2024 08:44, Wang, Fei W wrote:
> > On Mon, 2024-03-18 at 21:22 +0000, Mark Thompson wrote:
> > > On 18/03/2024 04:21, fei.w.wang-at-intel.com@ffmpeg.org wrote:
> > > > From: Fei Wang <fei.w.wang@intel.com>
> > > > 
> > > > According to Table A.2 in spec.
> > > > 
> > > > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > > > ---
> > > >    libavcodec/vaapi_encode_h265.c | 176
> > > > +++++++++++++++++++++++-----
> > > > -----
> > > >    1 file changed, 123 insertions(+), 53 deletions(-)
> > > > 
> > > > diff --git a/libavcodec/vaapi_encode_h265.c
> > > > b/libavcodec/vaapi_encode_h265.c
> > > > index 43755e2188..5ed317ce11 100644
> > > > --- a/libavcodec/vaapi_encode_h265.c
> > > > +++ b/libavcodec/vaapi_encode_h265.c
> > > > @@ -258,6 +258,124 @@ fail:
> > > >        return err;
> > > >    }
> > > >    
> > > > +static int vaapi_encode_h265_init_ptl(AVCodecContext *avctx)
> > > > +{
> > > > +    VAAPIEncodeContext      *ctx = avctx->priv_data;
> > > > +    VAAPIEncodeH265Context *priv = avctx->priv_data;
> > > > +    H265RawVPS              *vps = &priv->raw_vps;
> > > > +    H265RawProfileTierLevel *ptl = &vps->profile_tier_level;
> > > > +
> > > > +    ptl->general_profile_space = 0;
> > > > +    ptl->general_profile_idc   = avctx->profile;
> > > > +    ptl->general_tier_flag     = priv->tier;
> > > > +
> > > > +    ptl->general_profile_compatibility_flag[ptl-
> > > > > general_profile_idc] = 1;
> > > > +
> > > > +    if (ptl->general_profile_compatibility_flag[1])
> > > > +        ptl->general_profile_compatibility_flag[2] = 1;
> > > > +    if (ptl->general_profile_compatibility_flag[3]) {
> > > > +        ptl->general_profile_compatibility_flag[1] = 1;
> > > > +        ptl->general_profile_compatibility_flag[2] = 1;
> > > > +    }
> > > > +
> > > > +    ptl->general_progressive_source_flag    = 1;
> > > > +    ptl->general_interlaced_source_flag     = 0;
> > > > +    ptl->general_non_packed_constraint_flag = 1;
> > > > +    ptl->general_frame_only_constraint_flag = 1;
> > > > +
> > > > +    if (avctx->profile >= 4) {
> > > > +        ptl->general_intra_constraint_flag            = ctx-
> > > > > gop_size == 1;
> > > > +        ptl->general_one_picture_only_constraint_flag = 0;
> > > > +        ptl->general_lower_bit_rate_constraint_flag   = 1;
> > > > +        ptl->general_max_14bit_constraint_flag        = 0;
> > > > +
> > > > +        switch (ctx->va_profile) {
> > > > +#if VA_CHECK_VERSION(1, 2, 0)
> > > > +        case VAProfileHEVCMain12:
> > > > +            // Main 12
> > > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > > +            ptl->general_max_10bit_constraint_flag      = 0;
> > > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > > > +            ptl->general_max_420chroma_constraint_flag  = 1;
> > > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > > +            break;
> > > > +        case VAProfileHEVCMain422_10:
> > > > +            // Main 4:2:2 10
> > > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > > +            ptl->general_max_10bit_constraint_flag      = 1;
> > > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > > +            break;
> > > > +        case VAProfileHEVCMain422_12:
> > > > +            // Main 4:2:2 12
> > > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > > +            ptl->general_max_10bit_constraint_flag      = 0;
> > > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > > +            ptl->general_max_422chroma_constraint_flag  = 1;
> > > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > > +            break;
> > > > +        case VAProfileHEVCMain444:
> > > > +            // Main 4:4:4
> > > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > > +            ptl->general_max_10bit_constraint_flag      = 1;
> > > > +            ptl->general_max_8bit_constraint_flag       = 1;
> > > > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > > +            break;
> > > > +        case VAProfileHEVCMain444_10:
> > > > +            // Main 4:4:4 10
> > > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > > +            ptl->general_max_10bit_constraint_flag      = 1;
> > > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > > +            break;
> > > > +        case VAProfileHEVCMain444_12:
> > > > +            // Main 4:4:4 12
> > > > +            ptl->general_max_12bit_constraint_flag      = 1;
> > > > +            ptl->general_max_10bit_constraint_flag      = 0;
> > > > +            ptl->general_max_8bit_constraint_flag       = 0;
> > > > +            ptl->general_max_422chroma_constraint_flag  = 0;
> > > > +            ptl->general_max_420chroma_constraint_flag  = 0;
> > > > +            ptl->general_max_monochrome_constraint_flag = 0;
> > > > +            break;
> > > > +#endif
> > > > +        default:
> > > > +            av_log(avctx, AV_LOG_ERROR, "Unknown profile to
> > > > init
> > > > PTL.\n");
> > > > +            return AVERROR(EINVAL);
> > > > +        }
> > > > +    }
> > > 
> > > Why is this an improvement over the current code which sets the
> > > constraint flags based on the actual content of the stream?
> > > 
> > > Note the requirement in A.3.5 for decoder support:
> > > 
> > > general_profile_idc is equal to 4 or
> > > general_profile_compatibility_flag[ 4 ] is equal to 1 for the
> > > bitstream, and
> > > the value of each constraint flag listed in Table A.2 is greater
> > > than
> > > or equal to the value(s) specified in the row
> > > of Table A.2 for the format range extensions profile for which
> > > the
> > > decoder conformance is evaluated.
> > > 
> > > which says that decoders must be able to support streams which
> > > set
> > > additional constraint flags beyond those which are specified for
> > > a
> > > particular profile (in particular, an 8-bit 4:2:2 stream must be
> > > decodable by any decoder supporting either "Main 4:2:2 10" or
> > > "Main
> > > 4:4:4", so ideally it shouldn't be marked to require one of those
> > > in
> > > particular).
> > 
> > That's a capability request for decoder. For encoder side, I'd
> > prefer
> > to use the most typical values. The constraint flags in Table
> > A.2/3/5
> > are strictly checked to get rext profile in ff_h265_get_profile(),
> > and
> > seems the constraint flags is the only way to distinguish profiles
> > in
> > rext(all the rext profiles shares same general_profile_idc or
> > general_profile_compatibility_flag[ 4 ]).
> 
> Hmm.  I was missing that the VAAPI decoder has fixed matching - it
> only accepts things which exactly match the hull of each profile, not
> ones inside it which are compatible.  That seems worth fixing.
> 
> Do other decoder implementations do the same thing with strict
> matching?  libavcodec's software decoder doesn't - the profile isn't
> really relevant to it.  nvdec doesn't obviously do anything there
> either because it accepts all rext streams, though presumably some of
> them fail later.

HEVC bsf also checked them strictly in process metadata(called by
ff_h265_guess_level).

And VQ Analyzer(a video stream analysis tool 
https://vicuesoft.com/vq-analyzer/) also report unknown profile if no
this fix.

Thanks
Fei

> 
> Thanks,
> 
> - Mark
> _______________________________________________
> 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".
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
  2024-03-18  4:21 [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile fei.w.wang-at-intel.com
  2024-03-18  4:21 ` [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile fei.w.wang-at-intel.com
  2024-03-18 21:11 ` [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile Mark Thompson
@ 2024-04-15  1:21 ` Xiang, Haihao
  2024-04-15 22:07   ` Mark Thompson
  2 siblings, 1 reply; 21+ messages in thread
From: Xiang, Haihao @ 2024-04-15  1:21 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Wang, Fei W

On Ma, 2024-03-18 at 12:21 +0800, fei.w.wang-at-intel.com@ffmpeg.org wrote:
> From: Fei Wang <fei.w.wang@intel.com>
> 
> There is no Main8/10 profile defined in HEVC REXT profiles. Use Main12
> which is compatible with 8/10bit.
> 
> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> ---
>  libavcodec/vaapi_encode_h265.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
> index c4aabbf5ed..43755e2188 100644
> --- a/libavcodec/vaapi_encode_h265.c
> +++ b/libavcodec/vaapi_encode_h265.c
> @@ -1305,12 +1305,12 @@ static av_cold int
> vaapi_encode_h265_configure(AVCodecContext *avctx)
>  
>  static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = {
>      { AV_PROFILE_HEVC_MAIN,     8, 3, 1, 1, VAProfileHEVCMain       },
> -    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain       },
>  #if VA_CHECK_VERSION(0, 37, 0)
>      { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10     },
> -    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain10     },
>  #endif
>  #if VA_CHECK_VERSION(1, 2, 0)
> +    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain12 },
> +    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain12 },
>      { AV_PROFILE_HEVC_REXT,    12, 3, 1, 1, VAProfileHEVCMain12 },
>      { AV_PROFILE_HEVC_REXT,     8, 3, 1, 0, VAProfileHEVCMain422_10 },
>      { AV_PROFILE_HEVC_REXT,    10, 3, 1, 0, VAProfileHEVCMain422_10 },

Patchset LGTM, I'll push it if there are no comments.

Thanks
Haihao


_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
  2024-04-15  1:21 ` Xiang, Haihao
@ 2024-04-15 22:07   ` Mark Thompson
  2024-04-16  4:57     ` Wang, Fei W
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Thompson @ 2024-04-15 22:07 UTC (permalink / raw)
  To: ffmpeg-devel

On 15/04/2024 02:21, Xiang, Haihao wrote:
> On Ma, 2024-03-18 at 12:21 +0800, fei.w.wang-at-intel.com@ffmpeg.org wrote:
>> From: Fei Wang <fei.w.wang@intel.com>
>>
>> There is no Main8/10 profile defined in HEVC REXT profiles. Use Main12
>> which is compatible with 8/10bit.
>>
>> Signed-off-by: Fei Wang <fei.w.wang@intel.com>
>> ---
>>  libavcodec/vaapi_encode_h265.c | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/libavcodec/vaapi_encode_h265.c b/libavcodec/vaapi_encode_h265.c
>> index c4aabbf5ed..43755e2188 100644
>> --- a/libavcodec/vaapi_encode_h265.c
>> +++ b/libavcodec/vaapi_encode_h265.c
>> @@ -1305,12 +1305,12 @@ static av_cold int
>> vaapi_encode_h265_configure(AVCodecContext *avctx)
>>  
>>  static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = {
>>      { AV_PROFILE_HEVC_MAIN,     8, 3, 1, 1, VAProfileHEVCMain       },
>> -    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain       },
>>  #if VA_CHECK_VERSION(0, 37, 0)
>>      { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1, VAProfileHEVCMain10     },
>> -    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain10     },
>>  #endif
>>  #if VA_CHECK_VERSION(1, 2, 0)
>> +    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain12 },
>> +    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain12 },
>>      { AV_PROFILE_HEVC_REXT,    12, 3, 1, 1, VAProfileHEVCMain12 },
>>      { AV_PROFILE_HEVC_REXT,     8, 3, 1, 0, VAProfileHEVCMain422_10 },
>>      { AV_PROFILE_HEVC_REXT,    10, 3, 1, 0, VAProfileHEVCMain422_10 },
> 
> Patchset LGTM, I'll push it if there are no comments.

Why is this change helpful?

We don't use the rext features allowed in these cases (unlike in the decoder where we have to support them), so Main / Main 10 encoders will be able to produce a compatible stream without pointlessly requiring Main 12 support which many devices do not have.

Thanks,

- Mark
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
  2024-04-15 22:07   ` Mark Thompson
@ 2024-04-16  4:57     ` Wang, Fei W
  2024-04-18  8:21       ` Wang, Fei W
  0 siblings, 1 reply; 21+ messages in thread
From: Wang, Fei W @ 2024-04-16  4:57 UTC (permalink / raw)
  To: ffmpeg-devel

On Mon, 2024-04-15 at 23:07 +0100, Mark Thompson wrote:
> On 15/04/2024 02:21, Xiang, Haihao wrote:
> > On Ma, 2024-03-18 at 12:21 +0800, 
> > fei.w.wang-at-intel.com@ffmpeg.org wrote:
> > > From: Fei Wang <fei.w.wang@intel.com>
> > > 
> > > There is no Main8/10 profile defined in HEVC REXT profiles. Use
> > > Main12
> > > which is compatible with 8/10bit.
> > > 
> > > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > > ---
> > >  libavcodec/vaapi_encode_h265.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/libavcodec/vaapi_encode_h265.c
> > > b/libavcodec/vaapi_encode_h265.c
> > > index c4aabbf5ed..43755e2188 100644
> > > --- a/libavcodec/vaapi_encode_h265.c
> > > +++ b/libavcodec/vaapi_encode_h265.c
> > > @@ -1305,12 +1305,12 @@ static av_cold int
> > > vaapi_encode_h265_configure(AVCodecContext *avctx)
> > >  
> > >  static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] = {
> > >      { AV_PROFILE_HEVC_MAIN,     8, 3, 1, 1,
> > > VAProfileHEVCMain       },
> > > -    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1,
> > > VAProfileHEVCMain       },
> > >  #if VA_CHECK_VERSION(0, 37, 0)
> > >      { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1,
> > > VAProfileHEVCMain10     },
> > > -    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1,
> > > VAProfileHEVCMain10     },
> > >  #endif
> > >  #if VA_CHECK_VERSION(1, 2, 0)
> > > +    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1, VAProfileHEVCMain12
> > > },
> > > +    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1, VAProfileHEVCMain12
> > > },
> > >      { AV_PROFILE_HEVC_REXT,    12, 3, 1, 1, VAProfileHEVCMain12
> > > },
> > >      { AV_PROFILE_HEVC_REXT,     8, 3, 1, 0,
> > > VAProfileHEVCMain422_10 },
> > >      { AV_PROFILE_HEVC_REXT,    10, 3, 1, 0,
> > > VAProfileHEVCMain422_10 },
> > 
> > Patchset LGTM, I'll push it if there are no comments.
> 
> Why is this change helpful?

Together with 2/2 fix on the hw support VAAPI main12 decode and encode:

$ ffmpeg -hwaccel vaapi -f lavfi -i testsrc -vf 'format=nv12,hwupload'
-c:v hevc_vaapi -profile:v rext -vframes 30 -y out.mp4

$ ffmpeg -hwaccel vaapi -i out.mp4 -f null -
...
[hevc @ 0x55b4fda0a780] HEVC profile is not found.
[hevc @ 0x55b4fda0a780] No support for codec hevc profile 4.
[hevc @ 0x55b4fda0a780] Failed setup for format vaapi: hwaccel
initialisation returned error.

Same for p010le as input of encoder.

Thanks
Fei
> 
> We don't use the rext features allowed in these cases (unlike in the
> decoder where we have to support them), so Main / Main 10 encoders
> will be able to produce a compatible stream without pointlessly
> requiring Main 12 support which many devices do not have.
> 
> Thanks,
> 
> - Mark
> _______________________________________________
> 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".
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
  2024-04-16  4:57     ` Wang, Fei W
@ 2024-04-18  8:21       ` Wang, Fei W
  2024-04-22 21:20         ` Mark Thompson
  0 siblings, 1 reply; 21+ messages in thread
From: Wang, Fei W @ 2024-04-18  8:21 UTC (permalink / raw)
  To: ffmpeg-devel

On Tue, 2024-04-16 at 04:57 +0000, Wang, Fei W wrote:
> On Mon, 2024-04-15 at 23:07 +0100, Mark Thompson wrote:
> > On 15/04/2024 02:21, Xiang, Haihao wrote:
> > > On Ma, 2024-03-18 at 12:21 +0800, 
> > > fei.w.wang-at-intel.com@ffmpeg.org wrote:
> > > > From: Fei Wang <fei.w.wang@intel.com>
> > > > 
> > > > There is no Main8/10 profile defined in HEVC REXT profiles. Use
> > > > Main12
> > > > which is compatible with 8/10bit.
> > > > 
> > > > Signed-off-by: Fei Wang <fei.w.wang@intel.com>
> > > > ---
> > > >  libavcodec/vaapi_encode_h265.c | 4 ++--
> > > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/libavcodec/vaapi_encode_h265.c
> > > > b/libavcodec/vaapi_encode_h265.c
> > > > index c4aabbf5ed..43755e2188 100644
> > > > --- a/libavcodec/vaapi_encode_h265.c
> > > > +++ b/libavcodec/vaapi_encode_h265.c
> > > > @@ -1305,12 +1305,12 @@ static av_cold int
> > > > vaapi_encode_h265_configure(AVCodecContext *avctx)
> > > >  
> > > >  static const VAAPIEncodeProfile vaapi_encode_h265_profiles[] =
> > > > {
> > > >      { AV_PROFILE_HEVC_MAIN,     8, 3, 1, 1,
> > > > VAProfileHEVCMain       },
> > > > -    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1,
> > > > VAProfileHEVCMain       },
> > > >  #if VA_CHECK_VERSION(0, 37, 0)
> > > >      { AV_PROFILE_HEVC_MAIN_10, 10, 3, 1, 1,
> > > > VAProfileHEVCMain10     },
> > > > -    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1,
> > > > VAProfileHEVCMain10     },
> > > >  #endif
> > > >  #if VA_CHECK_VERSION(1, 2, 0)
> > > > +    { AV_PROFILE_HEVC_REXT,     8, 3, 1, 1,
> > > > VAProfileHEVCMain12
> > > > },
> > > > +    { AV_PROFILE_HEVC_REXT,    10, 3, 1, 1,
> > > > VAProfileHEVCMain12
> > > > },
> > > >      { AV_PROFILE_HEVC_REXT,    12, 3, 1, 1,
> > > > VAProfileHEVCMain12
> > > > },
> > > >      { AV_PROFILE_HEVC_REXT,     8, 3, 1, 0,
> > > > VAProfileHEVCMain422_10 },
> > > >      { AV_PROFILE_HEVC_REXT,    10, 3, 1, 0,
> > > > VAProfileHEVCMain422_10 },
> > > 
> > > Patchset LGTM, I'll push it if there are no comments.
> > 
> > Why is this change helpful?
> 
> Together with 2/2 fix on the hw support VAAPI main12 decode and
> encode:
> 
> $ ffmpeg -hwaccel vaapi -f lavfi -i testsrc -vf
> 'format=nv12,hwupload'
> -c:v hevc_vaapi -profile:v rext -vframes 30 -y out.mp4
> 
> $ ffmpeg -hwaccel vaapi -i out.mp4 -f null -
> ...
> [hevc @ 0x55b4fda0a780] HEVC profile is not found.
> [hevc @ 0x55b4fda0a780] No support for codec hevc profile 4.
> [hevc @ 0x55b4fda0a780] Failed setup for format vaapi: hwaccel
> initialisation returned error.
> 
> Same for p010le as input of encoder.

Hi

Any further comments on this patchset?

Thanks
Fei
> 
> Thanks
> Fei
> > We don't use the rext features allowed in these cases (unlike in
> > the
> > decoder where we have to support them), so Main / Main 10 encoders
> > will be able to produce a compatible stream without pointlessly
> > requiring Main 12 support which many devices do not have.
> > 
> > Thanks,
> > 
> > - Mark
> > _______________________________________________
> > 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".
> _______________________________________________
> 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".
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile
  2024-04-18  8:21       ` Wang, Fei W
@ 2024-04-22 21:20         ` Mark Thompson
  2024-04-22 21:22           ` [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking Mark Thompson
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Thompson @ 2024-04-22 21:20 UTC (permalink / raw)
  To: ffmpeg-devel

On 18/04/2024 09:21, Wang, Fei W wrote:
> On Tue, 2024-04-16 at 04:57 +0000, Wang, Fei W wrote:
>> On Mon, 2024-04-15 at 23:07 +0100, Mark Thompson wrote:
>>> Why is this change helpful?
>>
>> Together with 2/2 fix on the hw support VAAPI main12 decode and
>> encode:
>>
>> $ ffmpeg -hwaccel vaapi -f lavfi -i testsrc -vf
>> 'format=nv12,hwupload'
>> -c:v hevc_vaapi -profile:v rext -vframes 30 -y out.mp4
>>
>> $ ffmpeg -hwaccel vaapi -i out.mp4 -f null -
>> ...
>> [hevc @ 0x55b4fda0a780] HEVC profile is not found.
>> [hevc @ 0x55b4fda0a780] No support for codec hevc profile 4.
>> [hevc @ 0x55b4fda0a780] Failed setup for format vaapi: hwaccel
>> initialisation returned error.
>>
>> Same for p010le as input of encoder.
> 
> Hi
> 
> Any further comments on this patchset?

I think it is better to fix this by removing the fake constraints on the decoder rather than by adding extra constraints to the encoder.

See patchset following.

Thanks,

- Mark
_______________________________________________
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking
  2024-04-22 21:20         ` Mark Thompson
@ 2024-04-22 21:22           ` Mark Thompson
  2024-04-22 21:23             ` [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles Mark Thompson
                               ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: Mark Thompson @ 2024-04-22 21:22 UTC (permalink / raw)
  To: ffmpeg-devel

Replace existing get_profile() with find_profile(), which finds the
lowest compatible profile rather than requiring an exact match.
---
 libavcodec/h265_profile_level.c | 73 +++++++++++++++++++++------------
 libavcodec/h265_profile_level.h | 70 ++++++++++++++++++++++++++++++-
 libavcodec/vaapi_hevc.c         |  2 +-
 libavcodec/vdpau_hevc.c         |  2 +-
 4 files changed, 117 insertions(+), 30 deletions(-)

diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c
index 7ff9681f65..4bc72414cb 100644
--- a/libavcodec/h265_profile_level.c
+++ b/libavcodec/h265_profile_level.c
@@ -119,41 +119,60 @@ static const H265ProfileDescriptor h265_profiles[] = {
       5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 },
 };

+_Static_assert(H265_PROFILE_COUNT == FF_ARRAY_ELEMS(h265_profiles),
+               "Incorrect H.265 profiles table.");

-const H265ProfileDescriptor *ff_h265_get_profile(const H265RawProfileTierLevel *ptl)
+
+const int ff_h265_profile_compatible(const H265RawProfileTierLevel *ptl,
+                                     int profile)
 {
-    int i;
+    const H265ProfileDescriptor *desc;
+
+    av_assert0(profile >= 0 && profile < H265_PROFILE_COUNT);

     if (ptl->general_profile_space)
-        return NULL;
+        return 0;

-    for (i = 0; i < FF_ARRAY_ELEMS(h265_profiles); i++) {
-        const H265ProfileDescriptor *profile = &h265_profiles[i];
+    desc = &h265_profiles[profile];

-        if (ptl->general_profile_idc &&
-            ptl->general_profile_idc != profile->profile_idc)
-            continue;
-        if (!ptl->general_profile_compatibility_flag[profile->profile_idc])
-            continue;
+    if (ptl->general_profile_idc &&
+        ptl->general_profile_idc != desc->profile_idc)
+        return 0;
+    if (!ptl->general_profile_compatibility_flag[desc->profile_idc])
+        return 0;

-#define check_flag(name) \
-        if (profile->name < 2) { \
-            if (profile->name != ptl->general_ ## name ## _constraint_flag) \
-                continue; \
-        }
-        check_flag(max_14bit);
-        check_flag(max_12bit);
-        check_flag(max_10bit);
-        check_flag(max_8bit);
-        check_flag(max_422chroma);
-        check_flag(max_420chroma);
-        check_flag(max_monochrome);
-        check_flag(intra);
-        check_flag(one_picture_only);
-        check_flag(lower_bit_rate);
+#define check_flag(flag) \
+    if (desc->flag < 2 && \
+        desc->flag > ptl->general_ ## flag ## _constraint_flag) \
+        return 0;
+    check_flag(max_14bit);
+    check_flag(max_12bit);
+    check_flag(max_10bit);
+    check_flag(max_8bit);
+    check_flag(max_422chroma);
+    check_flag(max_420chroma);
+    check_flag(max_monochrome);
+    check_flag(intra);
+    check_flag(one_picture_only);
+    check_flag(lower_bit_rate);
 #undef check_flag

-        return profile;
+    return 1;
+}
+
+
+const H265ProfileDescriptor *ff_h265_get_profile(int profile)
+{
+    av_assert0(profile >= 0 && profile < H265_PROFILE_COUNT);
+
+    return &h265_profiles[profile];
+}
+
+const H265ProfileDescriptor *ff_h265_find_profile(const H265RawProfileTierLevel *ptl)
+{
+    for (int p = 0; p < H265_PROFILE_COUNT; p++) {
+        if (ff_h265_profile_compatible(ptl, p))
+            return &h265_profiles[p];
     }

     return NULL;
@@ -171,7 +190,7 @@ const H265LevelDescriptor *ff_h265_guess_level(const H265RawProfileTierLevel *pt
     int i;

     if (ptl)
-        profile = ff_h265_get_profile(ptl);
+        profile = ff_h265_find_profile(ptl);
     else
         profile = NULL;
     if (!profile) {
diff --git a/libavcodec/h265_profile_level.h b/libavcodec/h265_profile_level.h
index cd30ac5c50..f403f63211 100644
--- a/libavcodec/h265_profile_level.h
+++ b/libavcodec/h265_profile_level.h
@@ -24,6 +24,49 @@
 #include "cbs_h265.h"


+// Enumeration of all H.265 profiles.
+// The list is ordered to match table A.10; numeric values are an index
+// into the latest version of this table and have no codec meaning.
+enum {
+    H265_PROFILE_MONOCHROME,
+    H265_PROFILE_MONOCHROME_10,
+    H265_PROFILE_MONOCHROME_12,
+    H265_PROFILE_MONOCHROME_16,
+    H265_PROFILE_MAIN,
+    H265_PROFILE_SCREEN_EXTENDED_MAIN,
+    H265_PROFILE_MAIN_10,
+    H265_PROFILE_SCREEN_EXTENDED_MAIN_10,
+    H265_PROFILE_MAIN_12,
+    H265_PROFILE_MAIN_STILL_PICTURE,
+    H265_PROFILE_MAIN_10_STILL_PICTURE,
+    H265_PROFILE_MAIN_422_10,
+    H265_PROFILE_MAIN_422_12,
+    H265_PROFILE_MAIN_444,
+    H265_PROFILE_HIGH_THROUGHPUT_444,
+    H265_PROFILE_SCREEN_EXTENDED_MAIN_444,
+    H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444,
+    H265_PROFILE_MAIN_444_10,
+    H265_PROFILE_HIGH_THROUGHPUT_444_10,
+    H265_PROFILE_SCREEN_EXTENDED_MAIN_444_10,
+    H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_10,
+    H265_PROFILE_MAIN_444_12,
+    H265_PROFILE_HIGH_THROUGHPUT_444_14,
+    H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_14,
+    H265_PROFILE_MAIN_INTRA,
+    H265_PROFILE_MAIN_10_INTRA,
+    H265_PROFILE_MAIN_12_INTRA,
+    H265_PROFILE_MAIN_422_10_INTRA,
+    H265_PROFILE_MAIN_422_12_INTRA,
+    H265_PROFILE_MAIN_444_INTRA,
+    H265_PROFILE_MAIN_444_10_INTRA,
+    H265_PROFILE_MAIN_444_12_INTRA,
+    H265_PROFILE_MAIN_444_16_INTRA,
+    H265_PROFILE_MAIN_444_STILL_PICTURE,
+    H265_PROFILE_MAIN_444_16_STILL_PICTURE,
+    H265_PROFILE_HIGH_THROUGHPUT_444_16_INTRA,
+    H265_PROFILE_COUNT,
+};
+
 typedef struct H265LevelDescriptor {
     char        name[4];    // Large enough for all current levels like "4.1"
     uint8_t     level_idc;
@@ -70,7 +113,32 @@ typedef struct H265ProfileDescriptor {
 } H265ProfileDescriptor;


-const H265ProfileDescriptor *ff_h265_get_profile(const H265RawProfileTierLevel *ptl);
+/**
+ * Test whether the PTL structure is compatible with the given profile.
+ *
+ * @param ptl      PTL structure to check.
+ * @param profile  Profile to test compatibility with.  Must be a valid
+ *                 H265_PROFILE_* value.
+ * @return  Nonzero if compatible, zero if incompatible.
+ */
+const int ff_h265_profile_compatible(const H265RawProfileTierLevel *ptl,
+                                     int profile);
+
+/**
+ * Return profile descriptor for the given profile.
+ *
+ * @param profile  Profile number; must be a valid H265_PROFILE_* value.
+ * @return  Profile descriptor.
+ */
+const H265ProfileDescriptor *ff_h265_get_profile(int profile);
+
+/**
+ * Find the first profile compatible with the given PTL structure.
+ *
+ * @param ptl  PTL structure to search for.
+ * @return  First compatible profile, or NULL if no compatible profiles.
+ */
+const H265ProfileDescriptor *ff_h265_find_profile(const H265RawProfileTierLevel *ptl);


 /**
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 3bdd2dd1b8..77f55ff8b1 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -604,7 +604,7 @@ VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
     /* convert PTLCommon to H265RawProfileTierLevel */
     ptl_convert(general_ptl, &h265_raw_ptl);

-    profile = ff_h265_get_profile(&h265_raw_ptl);
+    profile = ff_h265_find_profile(&h265_raw_ptl);
     if (!profile) {
         av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n");
         goto end;
diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c
index 4cd7ce5621..a59a030b1c 100644
--- a/libavcodec/vdpau_hevc.c
+++ b/libavcodec/vdpau_hevc.c
@@ -478,7 +478,7 @@ static int vdpau_hevc_parse_rext_profile(AVCodecContext *avctx, VdpDecoderProfil
     /* convert PTLCommon to H265RawProfileTierLevel */
     ptl_convert(general_ptl, &h265_raw_ptl);

-    profile = ff_h265_get_profile(&h265_raw_ptl);
+    profile = ff_h265_find_profile(&h265_raw_ptl);
     if (!profile) {
         av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n");
         if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH) {
-- 
2.43.0
_______________________________________________
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] 21+ messages in thread

* [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles
  2024-04-22 21:22           ` [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking Mark Thompson
@ 2024-04-22 21:23             ` Mark Thompson
  2024-04-24 13:45               ` Xiang, Haihao
  2024-04-23  0:04             ` [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking Michael Niedermayer
  2024-04-24 13:48             ` Xiang, Haihao
  2 siblings, 1 reply; 21+ messages in thread
From: Mark Thompson @ 2024-04-22 21:23 UTC (permalink / raw)
  To: ffmpeg-devel

Rather than turning the constraint flags into a single profile and then
searching for that profile (and failing if it doesn't match any profile
exactly), instead search all supported profiles and use the first one
which supports the given set of constraint flags.
---
This fixes decode of rext 8-bit 4:2:0; it will correctly pick Main 12 or Main 4:2:2 10 or Main 4:4:4 (first one available) to use as the decoding profile after this patch.

 libavcodec/vaapi_decode.c | 45 ++++++++++++-------
 libavcodec/vaapi_hevc.c   | 95 +++++++++++++++++++++------------------
 libavcodec/vaapi_hevc.h   |  4 +-
 3 files changed, 83 insertions(+), 61 deletions(-)

diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
index 21b273cd0f..f1327464f5 100644
--- a/libavcodec/vaapi_decode.c
+++ b/libavcodec/vaapi_decode.c
@@ -387,7 +387,9 @@ static const struct {
     enum AVCodecID codec_id;
     int codec_profile;
     VAProfile va_profile;
-    VAProfile (*profile_parser)(AVCodecContext *avctx);
+    VAProfile (*match_profile)(AVCodecContext *avctx,
+                               const VAProfile *profile_list,
+                               int profile_count);
 } vaapi_profile_map[] = {
 #define MAP(c, p, v, ...) { AV_CODEC_ID_ ## c, AV_PROFILE_ ## p, VAProfile ## v, __VA_ARGS__ }
     MAP(MPEG2VIDEO,  MPEG2_SIMPLE,    MPEG2Simple ),
@@ -414,9 +416,9 @@ static const struct {
 #endif
 #if VA_CHECK_VERSION(1, 2, 0) && CONFIG_HEVC_VAAPI_HWACCEL
     MAP(HEVC,        HEVC_REXT,       None,
-                 ff_vaapi_parse_hevc_rext_scc_profile ),
+             ff_vaapi_hevc_match_rext_scc_profile ),
     MAP(HEVC,        HEVC_SCC,        None,
-                 ff_vaapi_parse_hevc_rext_scc_profile ),
+             ff_vaapi_hevc_match_rext_scc_profile ),
 #endif
     MAP(MJPEG,       MJPEG_HUFFMAN_BASELINE_DCT,
                                       JPEGBaseline),
@@ -499,22 +501,33 @@ static int vaapi_decode_make_config(AVCodecContext *avctx,
             vaapi_profile_map[i].codec_profile == AV_PROFILE_UNKNOWN)
             profile_match = 1;

-        va_profile = vaapi_profile_map[i].profile_parser ?
-                     vaapi_profile_map[i].profile_parser(avctx) :
-                     vaapi_profile_map[i].va_profile;
         codec_profile = vaapi_profile_map[i].codec_profile;
-
-        for (j = 0; j < profile_count; j++) {
-            if (va_profile == profile_list[j]) {
-                exact_match = profile_match;
+        if (vaapi_profile_map[i].match_profile) {
+            va_profile =
+                vaapi_profile_map[i].match_profile(avctx, profile_list,
+                                                   profile_count);
+            if (va_profile != VAProfileNone) {
+                matched_va_profile = va_profile;
+                matched_ff_profile = codec_profile;
+                exact_match = 1;
                 break;
             }
-        }
-        if (j < profile_count) {
-            matched_va_profile = va_profile;
-            matched_ff_profile = codec_profile;
-            if (exact_match)
-                break;
+        } else {
+            va_profile = vaapi_profile_map[i].va_profile;
+
+            for (j = 0; j < profile_count; j++) {
+                if (va_profile == profile_list[j]) {
+                    exact_match = profile_match;
+                    break;
+                }
+            }
+
+            if (j < profile_count) {
+                matched_va_profile = va_profile;
+                matched_ff_profile = codec_profile;
+                if (exact_match)
+                    break;
+            }
         }
     }
     av_freep(&profile_list);
diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
index 77f55ff8b1..28f7c9280e 100644
--- a/libavcodec/vaapi_hevc.c
+++ b/libavcodec/vaapi_hevc.c
@@ -590,63 +590,70 @@ static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel *h2
 }

 /*
- * Find exact va_profile for HEVC Range Extension and Screen Content Coding Extension
+ * Find compatible va_profile for HEVC Range Extension and Screen
+ * Content Coding Extension profiles.
  */
-VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
+VAProfile ff_vaapi_hevc_match_rext_scc_profile(AVCodecContext *avctx,
+                                               const VAProfile *profile_list,
+                                               int profile_count)
 {
     const HEVCContext *h = avctx->priv_data;
     const HEVCSPS *sps = h->ps.sps;
     const PTL *ptl = &sps->ptl;
     const PTLCommon *general_ptl = &ptl->general_ptl;
-    const H265ProfileDescriptor *profile;
     H265RawProfileTierLevel h265_raw_ptl = {0};

+    static const struct {
+        int profile;
+        VAProfile va_profile;
+    } map[] = {
+#if VA_CHECK_VERSION(1, 2, 0)
+        { H265_PROFILE_MAIN_12,
+          VAProfileHEVCMain12 },
+        { H265_PROFILE_MAIN_422_10,
+          VAProfileHEVCMain422_10 },
+        { H265_PROFILE_MAIN_444,
+          VAProfileHEVCMain444 },
+        { H265_PROFILE_MAIN_444_10,
+          VAProfileHEVCMain444_10 },
+        { H265_PROFILE_MAIN_444_12,
+          VAProfileHEVCMain444_12 },
+        { H265_PROFILE_SCREEN_EXTENDED_MAIN,
+          VAProfileHEVCSccMain },
+        { H265_PROFILE_SCREEN_EXTENDED_MAIN_10,
+          VAProfileHEVCSccMain10 },
+#endif
+#if VA_CHECK_VERSION(1, 8, 0)
+        { H265_PROFILE_SCREEN_EXTENDED_MAIN_444,
+          VAProfileHEVCSccMain444 },
+#endif
+    };
+
     /* convert PTLCommon to H265RawProfileTierLevel */
     ptl_convert(general_ptl, &h265_raw_ptl);

-    profile = ff_h265_find_profile(&h265_raw_ptl);
-    if (!profile) {
-        av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n");
-        goto end;
-    } else {
-        av_log(avctx, AV_LOG_VERBOSE, "HEVC profile %s is found.\n", profile->name);
+    for (int i = 0; i < FF_ARRAY_ELEMS(map); i++) {
+        int available = 0;
+        for (int j = 0; j < profile_count; j++) {
+            if (profile_list[j] == map[i].va_profile) {
+                available = 1;
+                break;
+            }
+        }
+        if (!available)
+            continue;
+
+        if (ff_h265_profile_compatible(&h265_raw_ptl,
+                                       map[i].profile)) {
+            const H265ProfileDescriptor *profile_desc =
+                ff_h265_get_profile(map[i].profile);
+            av_log(avctx, AV_LOG_VERBOSE,
+                   "Decoding with HEVC profile %s.\n",
+                   profile_desc->name);
+            return map[i].va_profile;
+        }
     }

-#if VA_CHECK_VERSION(1, 2, 0)
-    if (!strcmp(profile->name, "Main 12") ||
-        !strcmp(profile->name, "Main 12 Intra"))
-        return VAProfileHEVCMain12;
-    else if (!strcmp(profile->name, "Main 4:2:2 10") ||
-        !strcmp(profile->name, "Main 4:2:2 10 Intra"))
-        return VAProfileHEVCMain422_10;
-    else if (!strcmp(profile->name, "Main 4:2:2 12") ||
-        !strcmp(profile->name, "Main 4:2:2 12 Intra"))
-        return VAProfileHEVCMain422_12;
-    else if (!strcmp(profile->name, "Main 4:4:4") ||
-             !strcmp(profile->name, "Main 4:4:4 Intra"))
-        return VAProfileHEVCMain444;
-    else if (!strcmp(profile->name, "Main 4:4:4 10") ||
-             !strcmp(profile->name, "Main 4:4:4 10 Intra"))
-        return VAProfileHEVCMain444_10;
-    else if (!strcmp(profile->name, "Main 4:4:4 12") ||
-             !strcmp(profile->name, "Main 4:4:4 12 Intra"))
-        return VAProfileHEVCMain444_12;
-    else if (!strcmp(profile->name, "Screen-Extended Main"))
-        return VAProfileHEVCSccMain;
-    else if (!strcmp(profile->name, "Screen-Extended Main 10"))
-        return VAProfileHEVCSccMain10;
-    else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4"))
-        return VAProfileHEVCSccMain444;
-#if VA_CHECK_VERSION(1, 8, 0)
-    else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4 10"))
-        return VAProfileHEVCSccMain444_10;
-#endif
-#else
-    av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is "
-           "not supported with this VA version.\n", profile->name);
-#endif
-
-end:
     if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH) {
         // Default to selecting Main profile if profile mismatch is allowed
         return VAProfileHEVCMain;
diff --git a/libavcodec/vaapi_hevc.h b/libavcodec/vaapi_hevc.h
index 449635d0d7..455c68e6ba 100644
--- a/libavcodec/vaapi_hevc.h
+++ b/libavcodec/vaapi_hevc.h
@@ -22,6 +22,8 @@
 #include <va/va.h>
 #include "avcodec.h"

-VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx);
+VAProfile ff_vaapi_hevc_match_rext_scc_profile(AVCodecContext *avctx,
+                                               const VAProfile *profile_list,
+                                               int profile_count);

 #endif /* AVCODEC_VAAPI_HEVC_H */
-- 
2.43.0
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking
  2024-04-22 21:22           ` [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking Mark Thompson
  2024-04-22 21:23             ` [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles Mark Thompson
@ 2024-04-23  0:04             ` Michael Niedermayer
  2024-04-24 13:48             ` Xiang, Haihao
  2 siblings, 0 replies; 21+ messages in thread
From: Michael Niedermayer @ 2024-04-23  0:04 UTC (permalink / raw)
  To: FFmpeg development discussions and patches


[-- Attachment #1.1: Type: text/plain, Size: 1294 bytes --]

On Mon, Apr 22, 2024 at 10:22:06PM +0100, Mark Thompson wrote:
> Replace existing get_profile() with find_profile(), which finds the
> lowest compatible profile rather than requiring an exact match.
> ---
>  libavcodec/h265_profile_level.c | 73 +++++++++++++++++++++------------
>  libavcodec/h265_profile_level.h | 70 ++++++++++++++++++++++++++++++-
>  libavcodec/vaapi_hevc.c         |  2 +-
>  libavcodec/vdpau_hevc.c         |  2 +-
>  4 files changed, 117 insertions(+), 30 deletions(-)

breaks

TEST    h265-levels
./tests/fate-run.sh fate-h265-levels "fate/fate-suite/" "" "ffmpeg" 'run libavcodec/tests/h265_levels' '' '/dev/null' '' '1' '' '' '' '' '' '' '' '' '' ''
 ffmpeg/libavcodec/tests/h265_levels
Test h265-levels failed. Look at tests/data/fate/h265-levels.err for details.
Assertion profile >= 0 && profile < H265_PROFILE_COUNT failed at libavcodec/h265_profile_level.c:166
Aborted (core dumped)
threads=1
make: *** [tests/Makefile:311: fate-h265-levels] Error 134

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Many that live deserve death. And some that die deserve life. Can you give
it to them? Then do not be too eager to deal out death in judgement. For
even the very wise cannot see all ends. -- Gandalf

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles
  2024-04-22 21:23             ` [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles Mark Thompson
@ 2024-04-24 13:45               ` Xiang, Haihao
  2024-04-28 14:14                 ` Mark Thompson
  0 siblings, 1 reply; 21+ messages in thread
From: Xiang, Haihao @ 2024-04-24 13:45 UTC (permalink / raw)
  To: ffmpeg-devel

On Ma, 2024-04-22 at 22:23 +0100, Mark Thompson wrote:
> Rather than turning the constraint flags into a single profile and then
> searching for that profile (and failing if it doesn't match any profile
> exactly), instead search all supported profiles and use the first one
> which supports the given set of constraint flags.
> ---
> This fixes decode of rext 8-bit 4:2:0; it will correctly pick Main 12 or Main
> 4:2:2 10 or Main 4:4:4 (first one available) to use as the decoding profile
> after this patch.

sw decoding and vaapi decoding might have different bits (There is the same
issue if applying Fei's patchset).  

For example:
$ ffmpeg -hwaccel vaapi -f lavfi -i testsrc -vf 'format=nv12,hwupload' -c:v
hevc_vaapi -profile:v rext -vframes 30 -y out.mp4

8bit ouput if using sw decoding:
$ ffmpeg -i out.mp4 -f null - 
[...]
Stream #0:0(und): Video: wrapped_avframe, yuv420p(tv, progressive), 320x240 [SAR
1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)

12bit output if using vaapi decoding:
$ ffmpeg -hwaccel vaapi -i out.mp4 -f null -
[...]
 Stream #0:0(und): Video: wrapped_avframe, p012le(tv, progressive), 320x240 [SAR
1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)

Thanks
Haihao

> 
>  libavcodec/vaapi_decode.c | 45 ++++++++++++-------
>  libavcodec/vaapi_hevc.c   | 95 +++++++++++++++++++++------------------
>  libavcodec/vaapi_hevc.h   |  4 +-
>  3 files changed, 83 insertions(+), 61 deletions(-)
> 
> diff --git a/libavcodec/vaapi_decode.c b/libavcodec/vaapi_decode.c
> index 21b273cd0f..f1327464f5 100644
> --- a/libavcodec/vaapi_decode.c
> +++ b/libavcodec/vaapi_decode.c
> @@ -387,7 +387,9 @@ static const struct {
>      enum AVCodecID codec_id;
>      int codec_profile;
>      VAProfile va_profile;
> -    VAProfile (*profile_parser)(AVCodecContext *avctx);
> +    VAProfile (*match_profile)(AVCodecContext *avctx,
> +                               const VAProfile *profile_list,
> +                               int profile_count);
>  } vaapi_profile_map[] = {
>  #define MAP(c, p, v, ...) { AV_CODEC_ID_ ## c, AV_PROFILE_ ## p, VAProfile ##
> v, __VA_ARGS__ }
>      MAP(MPEG2VIDEO,  MPEG2_SIMPLE,    MPEG2Simple ),
> @@ -414,9 +416,9 @@ static const struct {
>  #endif
>  #if VA_CHECK_VERSION(1, 2, 0) && CONFIG_HEVC_VAAPI_HWACCEL
>      MAP(HEVC,        HEVC_REXT,       None,
> -                 ff_vaapi_parse_hevc_rext_scc_profile ),
> +             ff_vaapi_hevc_match_rext_scc_profile ),
>      MAP(HEVC,        HEVC_SCC,        None,
> -                 ff_vaapi_parse_hevc_rext_scc_profile ),
> +             ff_vaapi_hevc_match_rext_scc_profile ),
>  #endif
>      MAP(MJPEG,       MJPEG_HUFFMAN_BASELINE_DCT,
>                                        JPEGBaseline),
> @@ -499,22 +501,33 @@ static int vaapi_decode_make_config(AVCodecContext
> *avctx,
>              vaapi_profile_map[i].codec_profile == AV_PROFILE_UNKNOWN)
>              profile_match = 1;
> 
> -        va_profile = vaapi_profile_map[i].profile_parser ?
> -                     vaapi_profile_map[i].profile_parser(avctx) :
> -                     vaapi_profile_map[i].va_profile;
>          codec_profile = vaapi_profile_map[i].codec_profile;
> -
> -        for (j = 0; j < profile_count; j++) {
> -            if (va_profile == profile_list[j]) {
> -                exact_match = profile_match;
> +        if (vaapi_profile_map[i].match_profile) {
> +            va_profile =
> +                vaapi_profile_map[i].match_profile(avctx, profile_list,
> +                                                   profile_count);
> +            if (va_profile != VAProfileNone) {
> +                matched_va_profile = va_profile;
> +                matched_ff_profile = codec_profile;
> +                exact_match = 1;
>                  break;
>              }
> -        }
> -        if (j < profile_count) {
> -            matched_va_profile = va_profile;
> -            matched_ff_profile = codec_profile;
> -            if (exact_match)
> -                break;
> +        } else {
> +            va_profile = vaapi_profile_map[i].va_profile;
> +
> +            for (j = 0; j < profile_count; j++) {
> +                if (va_profile == profile_list[j]) {
> +                    exact_match = profile_match;
> +                    break;
> +                }
> +            }
> +
> +            if (j < profile_count) {
> +                matched_va_profile = va_profile;
> +                matched_ff_profile = codec_profile;
> +                if (exact_match)
> +                    break;
> +            }
>          }
>      }
>      av_freep(&profile_list);
> diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> index 77f55ff8b1..28f7c9280e 100644
> --- a/libavcodec/vaapi_hevc.c
> +++ b/libavcodec/vaapi_hevc.c
> @@ -590,63 +590,70 @@ static int ptl_convert(const PTLCommon *general_ptl,
> H265RawProfileTierLevel *h2
>  }
> 
>  /*
> - * Find exact va_profile for HEVC Range Extension and Screen Content Coding
> Extension
> + * Find compatible va_profile for HEVC Range Extension and Screen
> + * Content Coding Extension profiles.
>   */
> -VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
> +VAProfile ff_vaapi_hevc_match_rext_scc_profile(AVCodecContext *avctx,
> +                                               const VAProfile *profile_list,
> +                                               int profile_count)
>  {
>      const HEVCContext *h = avctx->priv_data;
>      const HEVCSPS *sps = h->ps.sps;
>      const PTL *ptl = &sps->ptl;
>      const PTLCommon *general_ptl = &ptl->general_ptl;
> -    const H265ProfileDescriptor *profile;
>      H265RawProfileTierLevel h265_raw_ptl = {0};
> 
> +    static const struct {
> +        int profile;
> +        VAProfile va_profile;
> +    } map[] = {
> +#if VA_CHECK_VERSION(1, 2, 0)
> +        { H265_PROFILE_MAIN_12,
> +          VAProfileHEVCMain12 },
> +        { H265_PROFILE_MAIN_422_10,
> +          VAProfileHEVCMain422_10 },
> +        { H265_PROFILE_MAIN_444,
> +          VAProfileHEVCMain444 },
> +        { H265_PROFILE_MAIN_444_10,
> +          VAProfileHEVCMain444_10 },
> +        { H265_PROFILE_MAIN_444_12,
> +          VAProfileHEVCMain444_12 },
> +        { H265_PROFILE_SCREEN_EXTENDED_MAIN,
> +          VAProfileHEVCSccMain },
> +        { H265_PROFILE_SCREEN_EXTENDED_MAIN_10,
> +          VAProfileHEVCSccMain10 },
> +#endif
> +#if VA_CHECK_VERSION(1, 8, 0)
> +        { H265_PROFILE_SCREEN_EXTENDED_MAIN_444,
> +          VAProfileHEVCSccMain444 },
> +#endif
> +    };
> +
>      /* convert PTLCommon to H265RawProfileTierLevel */
>      ptl_convert(general_ptl, &h265_raw_ptl);
> 
> -    profile = ff_h265_find_profile(&h265_raw_ptl);
> -    if (!profile) {
> -        av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n");
> -        goto end;
> -    } else {
> -        av_log(avctx, AV_LOG_VERBOSE, "HEVC profile %s is found.\n", profile-
> >name);
> +    for (int i = 0; i < FF_ARRAY_ELEMS(map); i++) {
> +        int available = 0;
> +        for (int j = 0; j < profile_count; j++) {
> +            if (profile_list[j] == map[i].va_profile) {
> +                available = 1;
> +                break;
> +            }
> +        }
> +        if (!available)
> +            continue;
> +
> +        if (ff_h265_profile_compatible(&h265_raw_ptl,
> +                                       map[i].profile)) {
> +            const H265ProfileDescriptor *profile_desc =
> +                ff_h265_get_profile(map[i].profile);
> +            av_log(avctx, AV_LOG_VERBOSE,
> +                   "Decoding with HEVC profile %s.\n",
> +                   profile_desc->name);
> +            return map[i].va_profile;
> +        }
>      }
> 
> -#if VA_CHECK_VERSION(1, 2, 0)
> -    if (!strcmp(profile->name, "Main 12") ||
> -        !strcmp(profile->name, "Main 12 Intra"))
> -        return VAProfileHEVCMain12;
> -    else if (!strcmp(profile->name, "Main 4:2:2 10") ||
> -        !strcmp(profile->name, "Main 4:2:2 10 Intra"))
> -        return VAProfileHEVCMain422_10;
> -    else if (!strcmp(profile->name, "Main 4:2:2 12") ||
> -        !strcmp(profile->name, "Main 4:2:2 12 Intra"))
> -        return VAProfileHEVCMain422_12;
> -    else if (!strcmp(profile->name, "Main 4:4:4") ||
> -             !strcmp(profile->name, "Main 4:4:4 Intra"))
> -        return VAProfileHEVCMain444;
> -    else if (!strcmp(profile->name, "Main 4:4:4 10") ||
> -             !strcmp(profile->name, "Main 4:4:4 10 Intra"))
> -        return VAProfileHEVCMain444_10;
> -    else if (!strcmp(profile->name, "Main 4:4:4 12") ||
> -             !strcmp(profile->name, "Main 4:4:4 12 Intra"))
> -        return VAProfileHEVCMain444_12;
> -    else if (!strcmp(profile->name, "Screen-Extended Main"))
> -        return VAProfileHEVCSccMain;
> -    else if (!strcmp(profile->name, "Screen-Extended Main 10"))
> -        return VAProfileHEVCSccMain10;
> -    else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4"))
> -        return VAProfileHEVCSccMain444;
> -#if VA_CHECK_VERSION(1, 8, 0)
> -    else if (!strcmp(profile->name, "Screen-Extended Main 4:4:4 10"))
> -        return VAProfileHEVCSccMain444_10;
> -#endif
> -#else
> -    av_log(avctx, AV_LOG_WARNING, "HEVC profile %s is "
> -           "not supported with this VA version.\n", profile->name);
> -#endif
> -
> -end:
>      if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH) {
>          // Default to selecting Main profile if profile mismatch is allowed
>          return VAProfileHEVCMain;
> diff --git a/libavcodec/vaapi_hevc.h b/libavcodec/vaapi_hevc.h
> index 449635d0d7..455c68e6ba 100644
> --- a/libavcodec/vaapi_hevc.h
> +++ b/libavcodec/vaapi_hevc.h
> @@ -22,6 +22,8 @@
>  #include <va/va.h>
>  #include "avcodec.h"
> 
> -VAProfile ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx);
> +VAProfile ff_vaapi_hevc_match_rext_scc_profile(AVCodecContext *avctx,
> +                                               const VAProfile *profile_list,
> +                                               int profile_count);
> 
>  #endif /* AVCODEC_VAAPI_HEVC_H */

_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking
  2024-04-22 21:22           ` [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking Mark Thompson
  2024-04-22 21:23             ` [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles Mark Thompson
  2024-04-23  0:04             ` [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking Michael Niedermayer
@ 2024-04-24 13:48             ` Xiang, Haihao
  2 siblings, 0 replies; 21+ messages in thread
From: Xiang, Haihao @ 2024-04-24 13:48 UTC (permalink / raw)
  To: ffmpeg-devel

On Ma, 2024-04-22 at 22:22 +0100, Mark Thompson wrote:
> Replace existing get_profile() with find_profile(), which finds the
> lowest compatible profile rather than requiring an exact match.
> ---
>  libavcodec/h265_profile_level.c | 73 +++++++++++++++++++++------------
>  libavcodec/h265_profile_level.h | 70 ++++++++++++++++++++++++++++++-
>  libavcodec/vaapi_hevc.c         |  2 +-
>  libavcodec/vdpau_hevc.c         |  2 +-
>  4 files changed, 117 insertions(+), 30 deletions(-)
> 
> diff --git a/libavcodec/h265_profile_level.c b/libavcodec/h265_profile_level.c
> index 7ff9681f65..4bc72414cb 100644
> --- a/libavcodec/h265_profile_level.c
> +++ b/libavcodec/h265_profile_level.c
> @@ -119,41 +119,60 @@ static const H265ProfileDescriptor h265_profiles[] = {
>        5, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 4000, 4400, 6.000, 0.5, 6 },
>  };
> 
> +_Static_assert(H265_PROFILE_COUNT == FF_ARRAY_ELEMS(h265_profiles),
> +               "Incorrect H.265 profiles table.");
> 
> -const H265ProfileDescriptor *ff_h265_get_profile(const
> H265RawProfileTierLevel *ptl)
> +
> +const int ff_h265_profile_compatible(const H265RawProfileTierLevel *ptl,
> +                                     int profile)
>  {
> -    int i;
> +    const H265ProfileDescriptor *desc;
> +
> +    av_assert0(profile >= 0 && profile < H265_PROFILE_COUNT);
> 
>      if (ptl->general_profile_space)
> -        return NULL;
> +        return 0;
> 
> -    for (i = 0; i < FF_ARRAY_ELEMS(h265_profiles); i++) {
> -        const H265ProfileDescriptor *profile = &h265_profiles[i];
> +    desc = &h265_profiles[profile];
> 
> -        if (ptl->general_profile_idc &&
> -            ptl->general_profile_idc != profile->profile_idc)
> -            continue;
> -        if (!ptl->general_profile_compatibility_flag[profile->profile_idc])
> -            continue;
> +    if (ptl->general_profile_idc &&
> +        ptl->general_profile_idc != desc->profile_idc)
> +        return 0;
> +    if (!ptl->general_profile_compatibility_flag[desc->profile_idc])
> +        return 0;
> 
> -#define check_flag(name) \
> -        if (profile->name < 2) { \
> -            if (profile->name != ptl->general_ ## name ## _constraint_flag) \
> -                continue; \
> -        }
> -        check_flag(max_14bit);
> -        check_flag(max_12bit);
> -        check_flag(max_10bit);
> -        check_flag(max_8bit);
> -        check_flag(max_422chroma);
> -        check_flag(max_420chroma);
> -        check_flag(max_monochrome);
> -        check_flag(intra);
> -        check_flag(one_picture_only);
> -        check_flag(lower_bit_rate);
> +#define check_flag(flag) \
> +    if (desc->flag < 2 && \
> +        desc->flag > ptl->general_ ## flag ## _constraint_flag) \
> +        return 0;
> +    check_flag(max_14bit);
> +    check_flag(max_12bit);
> +    check_flag(max_10bit);
> +    check_flag(max_8bit);
> +    check_flag(max_422chroma);
> +    check_flag(max_420chroma);
> +    check_flag(max_monochrome);
> +    check_flag(intra);
> +    check_flag(one_picture_only);
> +    check_flag(lower_bit_rate);
>  #undef check_flag
> 
> -        return profile;
> +    return 1;
> +}
> +
> +
> +const H265ProfileDescriptor *ff_h265_get_profile(int profile)
> +{
> +    av_assert0(profile >= 0 && profile < H265_PROFILE_COUNT);
> +
> +    return &h265_profiles[profile];
> +}
> +
> +const H265ProfileDescriptor *ff_h265_find_profile(const
> H265RawProfileTierLevel *ptl)
> +{
> +    for (int p = 0; p < H265_PROFILE_COUNT; p++) {
> +        if (ff_h265_profile_compatible(ptl, p))
> +            return &h265_profiles[p];
>      }
> 
>      return NULL;
> @@ -171,7 +190,7 @@ const H265LevelDescriptor *ff_h265_guess_level(const
> H265RawProfileTierLevel *pt
>      int i;
> 
>      if (ptl)
> -        profile = ff_h265_get_profile(ptl);
> +        profile = ff_h265_find_profile(ptl);
>      else
>          profile = NULL;
>      if (!profile) {
> diff --git a/libavcodec/h265_profile_level.h b/libavcodec/h265_profile_level.h
> index cd30ac5c50..f403f63211 100644
> --- a/libavcodec/h265_profile_level.h
> +++ b/libavcodec/h265_profile_level.h
> @@ -24,6 +24,49 @@
>  #include "cbs_h265.h"
> 
> 
> +// Enumeration of all H.265 profiles.
> +// The list is ordered to match table A.10; numeric values are an index
> +// into the latest version of this table and have no codec meaning.
> +enum {
> +    H265_PROFILE_MONOCHROME,
> +    H265_PROFILE_MONOCHROME_10,
> +    H265_PROFILE_MONOCHROME_12,
> +    H265_PROFILE_MONOCHROME_16,
> +    H265_PROFILE_MAIN,
> +    H265_PROFILE_SCREEN_EXTENDED_MAIN,
> +    H265_PROFILE_MAIN_10,
> +    H265_PROFILE_SCREEN_EXTENDED_MAIN_10,
> +    H265_PROFILE_MAIN_12,
> +    H265_PROFILE_MAIN_STILL_PICTURE,
> +    H265_PROFILE_MAIN_10_STILL_PICTURE,
> +    H265_PROFILE_MAIN_422_10,
> +    H265_PROFILE_MAIN_422_12,
> +    H265_PROFILE_MAIN_444,
> +    H265_PROFILE_HIGH_THROUGHPUT_444,
> +    H265_PROFILE_SCREEN_EXTENDED_MAIN_444,
> +    H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444,
> +    H265_PROFILE_MAIN_444_10,
> +    H265_PROFILE_HIGH_THROUGHPUT_444_10,
> +    H265_PROFILE_SCREEN_EXTENDED_MAIN_444_10,
> +    H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_10,
> +    H265_PROFILE_MAIN_444_12,
> +    H265_PROFILE_HIGH_THROUGHPUT_444_14,
> +    H265_PROFILE_SCREEN_EXTENDED_HIGH_THROUGHPUT_444_14,
> +    H265_PROFILE_MAIN_INTRA,
> +    H265_PROFILE_MAIN_10_INTRA,
> +    H265_PROFILE_MAIN_12_INTRA,
> +    H265_PROFILE_MAIN_422_10_INTRA,
> +    H265_PROFILE_MAIN_422_12_INTRA,
> +    H265_PROFILE_MAIN_444_INTRA,
> +    H265_PROFILE_MAIN_444_10_INTRA,
> +    H265_PROFILE_MAIN_444_12_INTRA,
> +    H265_PROFILE_MAIN_444_16_INTRA,
> +    H265_PROFILE_MAIN_444_STILL_PICTURE,
> +    H265_PROFILE_MAIN_444_16_STILL_PICTURE,
> +    H265_PROFILE_HIGH_THROUGHPUT_444_16_INTRA,
> +    H265_PROFILE_COUNT,
> +};
> +
>  typedef struct H265LevelDescriptor {
>      char        name[4];    // Large enough for all current levels like "4.1"
>      uint8_t     level_idc;
> @@ -70,7 +113,32 @@ typedef struct H265ProfileDescriptor {
>  } H265ProfileDescriptor;
> 
> 
> -const H265ProfileDescriptor *ff_h265_get_profile(const
> H265RawProfileTierLevel *ptl);
> +/**
> + * Test whether the PTL structure is compatible with the given profile.
> + *
> + * @param ptl      PTL structure to check.
> + * @param profile  Profile to test compatibility with.  Must be a valid
> + *                 H265_PROFILE_* value.
> + * @return  Nonzero if compatible, zero if incompatible.
> + */
> +const int ff_h265_profile_compatible(const H265RawProfileTierLevel *ptl,
> +                                     int profile);
> +
> +/**
> + * Return profile descriptor for the given profile.
> + *
> + * @param profile  Profile number; must be a valid H265_PROFILE_* value.
> + * @return  Profile descriptor.
> + */
> +const H265ProfileDescriptor *ff_h265_get_profile(int profile);

ff_h265_get_profile is called in libavcodec/tests/h265_levels.c which should be
changed too.

libavcodec/tests/h265_levels.c:        profile = ff_h265_get_profile(test_bitrate[i].ptl);

Thanks
Haihao

> +
> +/**
> + * Find the first profile compatible with the given PTL structure.
> + *
> + * @param ptl  PTL structure to search for.
> + * @return  First compatible profile, or NULL if no compatible profiles.
> + */
> +const H265ProfileDescriptor *ff_h265_find_profile(const
> H265RawProfileTierLevel *ptl);
> 
> 
>  /**
> diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> index 3bdd2dd1b8..77f55ff8b1 100644
> --- a/libavcodec/vaapi_hevc.c
> +++ b/libavcodec/vaapi_hevc.c
> @@ -604,7 +604,7 @@ VAProfile
> ff_vaapi_parse_hevc_rext_scc_profile(AVCodecContext *avctx)
>      /* convert PTLCommon to H265RawProfileTierLevel */
>      ptl_convert(general_ptl, &h265_raw_ptl);
> 
> -    profile = ff_h265_get_profile(&h265_raw_ptl);
> +    profile = ff_h265_find_profile(&h265_raw_ptl);
>      if (!profile) {
>          av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n");
>          goto end;
> diff --git a/libavcodec/vdpau_hevc.c b/libavcodec/vdpau_hevc.c
> index 4cd7ce5621..a59a030b1c 100644
> --- a/libavcodec/vdpau_hevc.c
> +++ b/libavcodec/vdpau_hevc.c
> @@ -478,7 +478,7 @@ static int vdpau_hevc_parse_rext_profile(AVCodecContext
> *avctx, VdpDecoderProfil
>      /* convert PTLCommon to H265RawProfileTierLevel */
>      ptl_convert(general_ptl, &h265_raw_ptl);
> 
> -    profile = ff_h265_get_profile(&h265_raw_ptl);
> +    profile = ff_h265_find_profile(&h265_raw_ptl);
>      if (!profile) {
>          av_log(avctx, AV_LOG_WARNING, "HEVC profile is not found.\n");
>          if (avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH) {

_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles
  2024-04-24 13:45               ` Xiang, Haihao
@ 2024-04-28 14:14                 ` Mark Thompson
  2024-04-30  6:00                   ` Xiang, Haihao
  0 siblings, 1 reply; 21+ messages in thread
From: Mark Thompson @ 2024-04-28 14:14 UTC (permalink / raw)
  To: ffmpeg-devel

On 24/04/2024 14:45, Xiang, Haihao wrote:
> On Ma, 2024-04-22 at 22:23 +0100, Mark Thompson wrote:
>> Rather than turning the constraint flags into a single profile and then
>> searching for that profile (and failing if it doesn't match any profile
>> exactly), instead search all supported profiles and use the first one
>> which supports the given set of constraint flags.
>> ---
>> This fixes decode of rext 8-bit 4:2:0; it will correctly pick Main 12 or Main
>> 4:2:2 10 or Main 4:4:4 (first one available) to use as the decoding profile
>> after this patch.
> 
> sw decoding and vaapi decoding might have different bits (There is the same
> issue if applying Fei's patchset).  
> 
> For example:
> $ ffmpeg -hwaccel vaapi -f lavfi -i testsrc -vf 'format=nv12,hwupload' -c:v
> hevc_vaapi -profile:v rext -vframes 30 -y out.mp4
> 
> 8bit ouput if using sw decoding:
> $ ffmpeg -i out.mp4 -f null - 
> [...]
> Stream #0:0(und): Video: wrapped_avframe, yuv420p(tv, progressive), 320x240 [SAR
> 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)
> 
> 12bit output if using vaapi decoding:
> $ ffmpeg -hwaccel vaapi -i out.mp4 -f null -
> [...]
>  Stream #0:0(und): Video: wrapped_avframe, p012le(tv, progressive), 320x240 [SAR
> 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)

That comes from what the driver reports support for, though?

E.g. with the Intel iHD driver, I have

        {
            "profile": 23,
            "name": "HEVCMain12",
...
                    "surface_formats": [
                        {
                            "rt_format": "YUV420",
                            "max_width": 16384,
                            "max_height": 16384,
                            "memory_types": [
                                "VA",
                                "DRM_PRIME_2",
                            ],
                            "pixel_formats": [
                                "P012",
                                "P016",
                            ],
                        },

So to decode a 4:2:0 8-bit input it is asking for a P012 or P016 surface.

If the driver reported that a Main 12 profile 4:2:0 8-bit input could be decoded to an NV12 surface then it would be picked by the logic in vaapi_decode_find_best_format(), since it would be a better match than the higher-depth formats.

Thanks,

- Mark
_______________________________________________
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] 21+ messages in thread

* Re: [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles
  2024-04-28 14:14                 ` Mark Thompson
@ 2024-04-30  6:00                   ` Xiang, Haihao
  0 siblings, 0 replies; 21+ messages in thread
From: Xiang, Haihao @ 2024-04-30  6:00 UTC (permalink / raw)
  To: ffmpeg-devel

On So, 2024-04-28 at 15:14 +0100, Mark Thompson wrote:
> On 24/04/2024 14:45, Xiang, Haihao wrote:
> > On Ma, 2024-04-22 at 22:23 +0100, Mark Thompson wrote:
> > > Rather than turning the constraint flags into a single profile and then
> > > searching for that profile (and failing if it doesn't match any profile
> > > exactly), instead search all supported profiles and use the first one
> > > which supports the given set of constraint flags.
> > > ---
> > > This fixes decode of rext 8-bit 4:2:0; it will correctly pick Main 12 or
> > > Main
> > > 4:2:2 10 or Main 4:4:4 (first one available) to use as the decoding
> > > profile
> > > after this patch.
> > 
> > sw decoding and vaapi decoding might have different bits (There is the same
> > issue if applying Fei's patchset).  
> > 
> > For example:
> > $ ffmpeg -hwaccel vaapi -f lavfi -i testsrc -vf 'format=nv12,hwupload' -c:v
> > hevc_vaapi -profile:v rext -vframes 30 -y out.mp4
> > 
> > 8bit ouput if using sw decoding:
> > $ ffmpeg -i out.mp4 -f null - 
> > [...]
> > Stream #0:0(und): Video: wrapped_avframe, yuv420p(tv, progressive), 320x240
> > [SAR
> > 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)
> > 
> > 12bit output if using vaapi decoding:
> > $ ffmpeg -hwaccel vaapi -i out.mp4 -f null -
> > [...]
> >  Stream #0:0(und): Video: wrapped_avframe, p012le(tv, progressive), 320x240
> > [SAR
> > 1:1 DAR 4:3], q=2-31, 200 kb/s, 25 fps, 25 tbn (default)
> 
> That comes from what the driver reports support for, though?
> 
> E.g. with the Intel iHD driver, I have
> 
>         {
>             "profile": 23,
>             "name": "HEVCMain12",
> ...
>                     "surface_formats": [
>                         {
>                             "rt_format": "YUV420",
>                             "max_width": 16384,
>                             "max_height": 16384,
>                             "memory_types": [
>                                 "VA",
>                                 "DRM_PRIME_2",
>                             ],
>                             "pixel_formats": [
>                                 "P012",
>                                 "P016",
>                             ],
>                         },
> 
> So to decode a 4:2:0 8-bit input it is asking for a P012 or P016 surface.
> 
> If the driver reported that a Main 12 profile 4:2:0 8-bit input could be
> decoded to an NV12 surface then it would be picked by the logic in
> vaapi_decode_find_best_format(), since it would be a better match than the
> higher-depth formats.

You are right, the iHD driver doesn't report the support for HEVCMain12 8bit. 

Thanks
Haihao

_______________________________________________
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] 21+ messages in thread

end of thread, other threads:[~2024-04-30  6:00 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-18  4:21 [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile fei.w.wang-at-intel.com
2024-03-18  4:21 ` [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile fei.w.wang-at-intel.com
2024-03-18 21:22   ` Mark Thompson
2024-03-20  8:44     ` Wang, Fei W
2024-04-01  6:11       ` Wang, Fei W
2024-04-01 20:02       ` Mark Thompson
2024-04-02  5:18         ` Wang, Fei W
2024-03-18 21:11 ` [FFmpeg-devel] [PATCH v3 1/2] lavc/vaapi_encode_h265: Map HEVC AV REXT profile to VA REXT profile Mark Thompson
2024-03-20  7:39   ` Wang, Fei W
2024-04-15  1:21 ` Xiang, Haihao
2024-04-15 22:07   ` Mark Thompson
2024-04-16  4:57     ` Wang, Fei W
2024-04-18  8:21       ` Wang, Fei W
2024-04-22 21:20         ` Mark Thompson
2024-04-22 21:22           ` [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking Mark Thompson
2024-04-22 21:23             ` [FFmpeg-devel] [PATCH 2/2] lavc/vaapi_hevc: Don't require exact profiles Mark Thompson
2024-04-24 13:45               ` Xiang, Haihao
2024-04-28 14:14                 ` Mark Thompson
2024-04-30  6:00                   ` Xiang, Haihao
2024-04-23  0:04             ` [FFmpeg-devel] [PATCH 1/2] lavc/h265_profile_level: Expand profile compatibility checking Michael Niedermayer
2024-04-24 13:48             ` 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