diff mbox series

[FFmpeg-devel,1/4] libavutil/hwcontext_d3d11va: Add nb_surfaces to AVD3D11VAFramesContext

Message ID 20211104054403.1251208-1-wenbin.chen@intel.com
State New
Headers show
Series [FFmpeg-devel,1/4] libavutil/hwcontext_d3d11va: Add nb_surfaces to AVD3D11VAFramesContext
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Wenbin Chen Nov. 4, 2021, 5:44 a.m. UTC
Adding nb_surfaces in AVD3D11VAFramesContext in the end of the structure
to support flexible size of this arrays and align to
AVDXVA2FramesContext and AVVAAPIFramesContext.

Signed-off-by Wenbin Chen <wenbin.chen@intel.com>
---
 libavutil/hwcontext_d3d11va.c | 3 +--
 libavutil/hwcontext_d3d11va.h | 2 ++
 2 files changed, 3 insertions(+), 2 deletions(-)

Comments

Wenbin Chen Nov. 10, 2021, 3:02 a.m. UTC | #1
> Adding nb_surfaces in AVD3D11VAFramesContext in the end of the structure
> to support flexible size of this arrays and align to
> AVDXVA2FramesContext and AVVAAPIFramesContext.
> 
> Signed-off-by Wenbin Chen <wenbin.chen@intel.com>
> ---
>  libavutil/hwcontext_d3d11va.c | 3 +--
>  libavutil/hwcontext_d3d11va.h | 2 ++
>  2 files changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
> index 8ab96bad25..086e7b9daa 100644
> --- a/libavutil/hwcontext_d3d11va.c
> +++ b/libavutil/hwcontext_d3d11va.c
> @@ -72,7 +72,6 @@ static av_cold void load_functions(void)
>  }
> 
>  typedef struct D3D11VAFramesContext {
> -    int nb_surfaces;
>      int nb_surfaces_used;
> 
>      DXGI_FORMAT format;
> @@ -287,7 +286,7 @@ static int d3d11va_frames_init(AVHWFramesContext
> *ctx)
>      hwctx->texture_infos = av_calloc(ctx->initial_pool_size, sizeof(*hwctx-
> >texture_infos));
>      if (!hwctx->texture_infos)
>          return AVERROR(ENOMEM);
> -    s->nb_surfaces = ctx->initial_pool_size;
> +    hwctx->nb_surfaces = ctx->initial_pool_size;
> 
>      ctx->internal->pool_internal =
> av_buffer_pool_init2(sizeof(AVD3D11FrameDescriptor),
>                                                          ctx, d3d11va_pool_alloc, NULL);
> diff --git a/libavutil/hwcontext_d3d11va.h b/libavutil/hwcontext_d3d11va.h
> index 77d2d72f1b..b0df470190 100644
> --- a/libavutil/hwcontext_d3d11va.h
> +++ b/libavutil/hwcontext_d3d11va.h
> @@ -173,6 +173,8 @@ typedef struct AVD3D11VAFramesContext {
>       * This field is ignored/invalid if a user-allocated texture is provided.
>      */
>      AVD3D11FrameDescriptor *texture_infos;
> +
> +    int nb_surfaces;
>  } AVD3D11VAFramesContext;
> 
>  #endif /* AVUTIL_HWCONTEXT_D3D11VA_H */
> --
> 2.25.1

ping
Soft Works Nov. 10, 2021, 8:12 a.m. UTC | #2
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Chen, Wenbin
> Sent: Wednesday, November 10, 2021 4:03 AM
> To: ffmpeg-devel@ffmpeg.org
> Subject: Re: [FFmpeg-devel] [PATCH 1/4] libavutil/hwcontext_d3d11va:
> Add nb_surfaces to AVD3D11VAFramesContext
> 
> > Adding nb_surfaces in AVD3D11VAFramesContext in the end of the
> structure
> > to support flexible size of this arrays and align to
> > AVDXVA2FramesContext and AVVAAPIFramesContext.

There is no flexibility in pool size for D3D11 frames contexts. The
surface count is always identical to initial_pool_size. There's no 
point in exposing it. nb_surfaces could even be removed here.

Also, this change doesn't align with AVVAAPIFramesContext.
In fact not even AVDXVA2FramesContext aligns with AVVAAPIFramesContext.
Both have an nb_surfaces field, but they have different semantics.

The corresponding field to AVVAAPIFramesContext->nb_surfaces is 
DXVA2FramesContext->nb_surfaces_used, not AVDXVA2FramesContext->nb_surfaces.

Kind regards,
softworkz
Wenbin Chen Nov. 11, 2021, 7:55 a.m. UTC | #3
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Chen, Wenbin
> > Sent: Wednesday, November 10, 2021 4:03 AM
> > To: ffmpeg-devel@ffmpeg.org
> > Subject: Re: [FFmpeg-devel] [PATCH 1/4] libavutil/hwcontext_d3d11va:
> > Add nb_surfaces to AVD3D11VAFramesContext
> >
> > > Adding nb_surfaces in AVD3D11VAFramesContext in the end of the
> > structure
> > > to support flexible size of this arrays and align to
> > > AVDXVA2FramesContext and AVVAAPIFramesContext.
> 
> There is no flexibility in pool size for D3D11 frames contexts. The
> surface count is always identical to initial_pool_size. There's no
> point in exposing it. nb_surfaces could even be removed here.
> 
> Also, this change doesn't align with AVVAAPIFramesContext.
> In fact not even AVDXVA2FramesContext aligns with AVVAAPIFramesContext.
> Both have an nb_surfaces field, but they have different semantics.
> 
> The corresponding field to AVVAAPIFramesContext->nb_surfaces is
> DXVA2FramesContext->nb_surfaces_used, not AVDXVA2FramesContext-
> >nb_surfaces.
> 
> Kind regards,
> softworkz
> 
> 
Yes, the nb_surface for d3d11 seems useless, I can use init_pool_size instead.
The nb_surface in dxva works as the same as init_pool_size, and I can use 
init_pool_size instead as well. The original code is good I don't need to change it.
Since I found the real cause for segmentation fault, I will resubmit the patches

Thanks
Wenbin
> 
> 
> 
> _______________________________________________
> 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".
Soft Works Nov. 11, 2021, 9:27 a.m. UTC | #4
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Chen, Wenbin
> Sent: Thursday, November 11, 2021 8:56 AM
> To: FFmpeg development discussions and patches <ffmpeg-
> devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 1/4] libavutil/hwcontext_d3d11va:
> Add nb_surfaces to AVD3D11VAFramesContext
> 
> > > -----Original Message-----
> > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > Chen, Wenbin
> > > Sent: Wednesday, November 10, 2021 4:03 AM
> > > To: ffmpeg-devel@ffmpeg.org
> > > Subject: Re: [FFmpeg-devel] [PATCH 1/4]
> libavutil/hwcontext_d3d11va:
> > > Add nb_surfaces to AVD3D11VAFramesContext
> > >
> > > > Adding nb_surfaces in AVD3D11VAFramesContext in the end of the
> > > structure
> > > > to support flexible size of this arrays and align to
> > > > AVDXVA2FramesContext and AVVAAPIFramesContext.
> >
> > There is no flexibility in pool size for D3D11 frames contexts. The
> > surface count is always identical to initial_pool_size. There's no
> > point in exposing it. nb_surfaces could even be removed here.
> >
> > Also, this change doesn't align with AVVAAPIFramesContext.
> > In fact not even AVDXVA2FramesContext aligns with
> AVVAAPIFramesContext.
> > Both have an nb_surfaces field, but they have different semantics.
> >
> > The corresponding field to AVVAAPIFramesContext->nb_surfaces is
> > DXVA2FramesContext->nb_surfaces_used, not AVDXVA2FramesContext-
> > >nb_surfaces.
> >
> > Kind regards,
> > softworkz
> >
> >
> Yes, the nb_surface for d3d11 seems useless, I can use init_pool_size
> instead.
> The nb_surface in dxva works as the same as init_pool_size, and I can
> use
> init_pool_size instead as well. The original code is good I don't
> need to change it.
> Since I found the real cause for segmentation fault, I will resubmit
> the patches

Sounds good, thanks!
sw
diff mbox series

Patch

diff --git a/libavutil/hwcontext_d3d11va.c b/libavutil/hwcontext_d3d11va.c
index 8ab96bad25..086e7b9daa 100644
--- a/libavutil/hwcontext_d3d11va.c
+++ b/libavutil/hwcontext_d3d11va.c
@@ -72,7 +72,6 @@  static av_cold void load_functions(void)
 }
 
 typedef struct D3D11VAFramesContext {
-    int nb_surfaces;
     int nb_surfaces_used;
 
     DXGI_FORMAT format;
@@ -287,7 +286,7 @@  static int d3d11va_frames_init(AVHWFramesContext *ctx)
     hwctx->texture_infos = av_calloc(ctx->initial_pool_size, sizeof(*hwctx->texture_infos));
     if (!hwctx->texture_infos)
         return AVERROR(ENOMEM);
-    s->nb_surfaces = ctx->initial_pool_size;
+    hwctx->nb_surfaces = ctx->initial_pool_size;
 
     ctx->internal->pool_internal = av_buffer_pool_init2(sizeof(AVD3D11FrameDescriptor),
                                                         ctx, d3d11va_pool_alloc, NULL);
diff --git a/libavutil/hwcontext_d3d11va.h b/libavutil/hwcontext_d3d11va.h
index 77d2d72f1b..b0df470190 100644
--- a/libavutil/hwcontext_d3d11va.h
+++ b/libavutil/hwcontext_d3d11va.h
@@ -173,6 +173,8 @@  typedef struct AVD3D11VAFramesContext {
      * This field is ignored/invalid if a user-allocated texture is provided.
     */
     AVD3D11FrameDescriptor *texture_infos;
+
+    int nb_surfaces;
 } AVD3D11VAFramesContext;
 
 #endif /* AVUTIL_HWCONTEXT_D3D11VA_H */