Re: [FFmpeg-devel] [PATCH 6/8] lavc/vaapi_hevc: add function to find exact va_profile for REXT

2020-01-12 Thread Fu, Linjie
> -Original Message-
> From: ffmpeg-devel  On Behalf Of
> Mark Thompson
> Sent: Thursday, January 9, 2020 06:44
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 6/8] lavc/vaapi_hevc: add function to
> find exact va_profile for REXT
> 
> On 29/12/2019 16:30, Linjie Fu wrote:
> > Add vaapi_parse_rext_profile and use profile constraint flags to
> > determine the exact va_profile for HEVC_REXT.
> >
> > Add build object in Makefile for h265_profile_level dependency.
> >
> > Signed-off-by: Linjie Fu 
> > ---
> >  libavcodec/Makefile |  2 +-
> >  libavcodec/vaapi_hevc.c | 69
> +
> >  libavcodec/vaapi_hevc.h | 24 +
> >  3 files changed, 94 insertions(+), 1 deletion(-)
> >  create mode 100644 libavcodec/vaapi_hevc.h
> >
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index c1f35b4..7cb914d 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -884,7 +884,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   +=
> dxva2_hevc.o
> >  OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
> >  OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
> >  OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
> > -OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
> > +OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
> h265_profile_level.o
> >  OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
> >  OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o
> >  OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)+= vaapi_mjpeg.o
> > diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> > index ab48b73..0604e23 100644
> > --- a/libavcodec/vaapi_hevc.c
> > +++ b/libavcodec/vaapi_hevc.c
> > @@ -27,6 +27,8 @@
> >  #include "hevcdec.h"
> >  #include "hwaccel.h"
> >  #include "vaapi_decode.h"
> > +#include "vaapi_hevc.h"
> > +#include "h265_profile_level.h"
> >
> >  typedef struct VAAPIDecodePictureHEVC {
> >  VAPictureParameterBufferHEVC pic_param;
> > @@ -494,6 +496,73 @@ static int
> vaapi_hevc_decode_slice(AVCodecContext *avctx,
> >  return 0;
> >  }
> >
> > +static int ptl_convert(const PTLCommon *general_ptl,
> H265RawProfileTierLevel *h265_raw_ptl)
> > +{
> > +h265_raw_ptl->general_profile_space = general_ptl->profile_space;
> > +h265_raw_ptl->general_tier_flag = general_ptl->tier_flag;
> > +h265_raw_ptl->general_profile_idc   = general_ptl->profile_idc;
> > +
> > +memcpy(h265_raw_ptl->general_profile_compatibility_flag,
> > +  general_ptl->profile_compatibility_flag, 
> > 32 * sizeof(int));
> 
> Not int!

Fixed, thanks.

> 
> > +
> > +h265_raw_ptl->general_progressive_source_flag  = general_ptl-
> >progressive_source_flag;
> > +h265_raw_ptl->general_interlaced_source_flag   = general_ptl-
> >interlaced_source_flag;
> > +h265_raw_ptl->general_non_packed_constraint_flag   = general_ptl-
> >non_packed_constraint_flag;
> > +h265_raw_ptl->general_frame_only_constraint_flag   = general_ptl-
> >frame_only_constraint_flag;
> > +h265_raw_ptl->general_max_12bit_constraint_flag= general_ptl-
> >max_12bit_constraint_flag;
> > +h265_raw_ptl->general_max_10bit_constraint_flag= general_ptl-
> >max_10bit_constraint_flag;
> > +h265_raw_ptl->general_max_8bit_constraint_flag = general_ptl-
> >max_8bit_constraint_flag;
> > +h265_raw_ptl->general_max_422chroma_constraint_flag=
> general_ptl->max_422chroma_constraint_flag;
> > +h265_raw_ptl->general_max_420chroma_constraint_flag=
> general_ptl->max_420chroma_constraint_flag;
> > +h265_raw_ptl->general_max_monochrome_constraint_flag   =
> general_ptl->max_monochrome_constraint_flag;
> > +h265_raw_ptl->general_intra_constraint_flag= general_ptl-
> >intra_constraint_flag;
> > +h265_raw_ptl->general_one_picture_only_constraint_flag =
> general_ptl->one_picture_only_constraint_flag;
> > +h265_raw_ptl->general_lower_bit_rate_constraint_flag   = general_ptl-
> >lower_bit_rate_constraint_flag;
> > +h265_raw_ptl->general_max_14bit_constraint_flag= general_ptl-
> >max_14bit_constraint_flag;
> > +h265_raw_ptl->general_inbld_flag   = 
> > general_ptl->inbld_flag;
> > + 

Re: [FFmpeg-devel] [PATCH 6/8] lavc/vaapi_hevc: add function to find exact va_profile for REXT

2020-01-08 Thread Mark Thompson
On 29/12/2019 16:30, Linjie Fu wrote:
> Add vaapi_parse_rext_profile and use profile constraint flags to
> determine the exact va_profile for HEVC_REXT.
> 
> Add build object in Makefile for h265_profile_level dependency.
> 
> Signed-off-by: Linjie Fu 
> ---
>  libavcodec/Makefile |  2 +-
>  libavcodec/vaapi_hevc.c | 69 
> +
>  libavcodec/vaapi_hevc.h | 24 +
>  3 files changed, 94 insertions(+), 1 deletion(-)
>  create mode 100644 libavcodec/vaapi_hevc.h
> 
> diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> index c1f35b4..7cb914d 100644
> --- a/libavcodec/Makefile
> +++ b/libavcodec/Makefile
> @@ -884,7 +884,7 @@ OBJS-$(CONFIG_HEVC_D3D11VA_HWACCEL)   += dxva2_hevc.o
>  OBJS-$(CONFIG_HEVC_DXVA2_HWACCEL) += dxva2_hevc.o
>  OBJS-$(CONFIG_HEVC_NVDEC_HWACCEL) += nvdec_hevc.o
>  OBJS-$(CONFIG_HEVC_QSV_HWACCEL)   += qsvdec_h2645.o
> -OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o
> +OBJS-$(CONFIG_HEVC_VAAPI_HWACCEL) += vaapi_hevc.o 
> h265_profile_level.o
>  OBJS-$(CONFIG_HEVC_VDPAU_HWACCEL) += vdpau_hevc.o
>  OBJS-$(CONFIG_MJPEG_NVDEC_HWACCEL)+= nvdec_mjpeg.o
>  OBJS-$(CONFIG_MJPEG_VAAPI_HWACCEL)+= vaapi_mjpeg.o
> diff --git a/libavcodec/vaapi_hevc.c b/libavcodec/vaapi_hevc.c
> index ab48b73..0604e23 100644
> --- a/libavcodec/vaapi_hevc.c
> +++ b/libavcodec/vaapi_hevc.c
> @@ -27,6 +27,8 @@
>  #include "hevcdec.h"
>  #include "hwaccel.h"
>  #include "vaapi_decode.h"
> +#include "vaapi_hevc.h"
> +#include "h265_profile_level.h"
>  
>  typedef struct VAAPIDecodePictureHEVC {
>  VAPictureParameterBufferHEVC pic_param;
> @@ -494,6 +496,73 @@ static int vaapi_hevc_decode_slice(AVCodecContext *avctx,
>  return 0;
>  }
>  
> +static int ptl_convert(const PTLCommon *general_ptl, H265RawProfileTierLevel 
> *h265_raw_ptl)
> +{
> +h265_raw_ptl->general_profile_space = general_ptl->profile_space;
> +h265_raw_ptl->general_tier_flag = general_ptl->tier_flag;
> +h265_raw_ptl->general_profile_idc   = general_ptl->profile_idc;
> +
> +memcpy(h265_raw_ptl->general_profile_compatibility_flag,
> +  general_ptl->profile_compatibility_flag, 
> 32 * sizeof(int));

Not int!

> +
> +h265_raw_ptl->general_progressive_source_flag  = 
> general_ptl->progressive_source_flag;
> +h265_raw_ptl->general_interlaced_source_flag   = 
> general_ptl->interlaced_source_flag;
> +h265_raw_ptl->general_non_packed_constraint_flag   = 
> general_ptl->non_packed_constraint_flag;
> +h265_raw_ptl->general_frame_only_constraint_flag   = 
> general_ptl->frame_only_constraint_flag;
> +h265_raw_ptl->general_max_12bit_constraint_flag= 
> general_ptl->max_12bit_constraint_flag;
> +h265_raw_ptl->general_max_10bit_constraint_flag= 
> general_ptl->max_10bit_constraint_flag;
> +h265_raw_ptl->general_max_8bit_constraint_flag = 
> general_ptl->max_8bit_constraint_flag;
> +h265_raw_ptl->general_max_422chroma_constraint_flag= 
> general_ptl->max_422chroma_constraint_flag;
> +h265_raw_ptl->general_max_420chroma_constraint_flag= 
> general_ptl->max_420chroma_constraint_flag;
> +h265_raw_ptl->general_max_monochrome_constraint_flag   = 
> general_ptl->max_monochrome_constraint_flag;
> +h265_raw_ptl->general_intra_constraint_flag= 
> general_ptl->intra_constraint_flag;
> +h265_raw_ptl->general_one_picture_only_constraint_flag = 
> general_ptl->one_picture_only_constraint_flag;
> +h265_raw_ptl->general_lower_bit_rate_constraint_flag   = 
> general_ptl->lower_bit_rate_constraint_flag;
> +h265_raw_ptl->general_max_14bit_constraint_flag= 
> general_ptl->max_14bit_constraint_flag;
> +h265_raw_ptl->general_inbld_flag   = 
> general_ptl->inbld_flag;
> +h265_raw_ptl->general_level_idc= 
> general_ptl->level_idc;

The names are all identical, so a little macroing could make this look a little 
less horrible.

#define copy_field(name) h265_raw_ptl->general_ ## name = general_ptl->name

> +
> +return 0;
> +}
> +
> +/*
> + * Find exact va_profile for HEVC Range Extension
> + */
> +VAProfile ff_vaapi_parse_rext_profile(AVCodecContext *avctx)

Put hevc in the name as well.

> +{
> +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 = NULL;
> +
> +H265RawProfileTierLevel *h265_raw_ptl = 
> av_mallocz(sizeof(H265RawProfileTierLevel));

This structure isn't huge, it could be on the stack.

> +/* convert PTLCommon to H265RawProfileTierLevel */
> +ptl_convert(general_ptl, h265_raw_ptl);
> +
> +profile = ff_h265_get_profile(h265_raw_ptl);
> +av_freep(_raw_ptl);
> +
> +if (!profile)
> +return VAProfileNone;