Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile

2024-04-01 Thread Wang, Fei W
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 +, Mark Thompson wrote:
> > > On 18/03/2024 04:21, fei.w.wang-at-intel@ffmpeg.org wrote:
> > > > From: Fei Wang 
> > > > 
> > > > According to Table A.2 in spec.
> > > > 
> > > > Signed-off-by: Fei Wang 
> > > > ---
> > > >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 = >raw_vps;
> > > > +H265RawProfileTierLevel *ptl = >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;
> > > > +

Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile

2024-04-01 Thread Mark Thompson

On 20/03/2024 08:44, Wang, Fei W wrote:

On Mon, 2024-03-18 at 21:22 +, Mark Thompson wrote:

On 18/03/2024 04:21, fei.w.wang-at-intel@ffmpeg.org wrote:

From: Fei Wang 

According to Table A.2 in spec.

Signed-off-by: Fei Wang 
---
   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 = >raw_vps;
+H265RawProfileTierLevel *ptl = >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 

Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile

2024-04-01 Thread Wang, Fei W
On Wed, 2024-03-20 at 16:44 +0800, Fei Wang wrote:
> On Mon, 2024-03-18 at 21:22 +, Mark Thompson wrote:
> > On 18/03/2024 04:21, fei.w.wang-at-intel@ffmpeg.org wrote:
> > > From: Fei Wang 
> > > 
> > > According to Table A.2 in spec.
> > > 
> > > Signed-off-by: Fei Wang 
> > > ---
> > >   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 = >raw_vps;
> > > +H265RawProfileTierLevel *ptl = >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 

Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile

2024-03-20 Thread Wang, Fei W
On Mon, 2024-03-18 at 21:22 +, Mark Thompson wrote:
> On 18/03/2024 04:21, fei.w.wang-at-intel@ffmpeg.org wrote:
> > From: Fei Wang 
> > 
> > According to Table A.2 in spec.
> > 
> > Signed-off-by: Fei Wang 
> > ---
> >   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 = >raw_vps;
> > +H265RawProfileTierLevel *ptl = >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  = 

Re: [FFmpeg-devel] [PATCH v3 2/2] lavc/vaapi_encode_h265: Set general_*_constriaint flags with profile

2024-03-18 Thread Mark Thompson

On 18/03/2024 04:21, fei.w.wang-at-intel@ffmpeg.org wrote:

From: Fei Wang 

According to Table A.2 in spec.

Signed-off-by: Fei Wang 
---
  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 = >raw_vps;
+H265RawProfileTierLevel *ptl = >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