diff mbox

[FFmpeg-devel] avutil/hwcontext: add flags field to AVHWFramesContext

Message ID 20180507183955.5522-1-timo@rothenpieler.org
State New
Headers show

Commit Message

Timo Rothenpieler May 7, 2018, 6:39 p.m. UTC
---
 doc/APIchanges        | 3 +++
 libavutil/hwcontext.h | 7 +++++++
 libavutil/version.h   | 2 +-
 3 files changed, 11 insertions(+), 1 deletion(-)

Comments

Philip Langdale May 7, 2018, 6:56 p.m. UTC | #1
On 2018-05-07 11:39, Timo Rothenpieler wrote:
> ---
>  doc/APIchanges        | 3 +++
>  libavutil/hwcontext.h | 7 +++++++
>  libavutil/version.h   | 2 +-
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ede5b186ae..307c7a51ee 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil:     2017-10-21
> 
>  API changes, most recent first:
> 
> +2018-05-xx - xxxxxxxxxx - lavu 56.19.100 - hwcontext.h
> +  Add AVHWFramesContext.flags.
> +
>  2018-04-xx - xxxxxxxxxx - lavu 56.18.100 - pixdesc.h
>    Add AV_PIX_FMT_FLAG_ALPHA to AV_PIX_FMT_PAL8.
> 
> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
> index f5a4b62387..23e2d335a5 100644
> --- a/libavutil/hwcontext.h
> +++ b/libavutil/hwcontext.h
> @@ -226,6 +226,13 @@ typedef struct AVHWFramesContext {
>       * Must be set by the user before calling av_hwframe_ctx_init().
>       */
>      int width, height;
> +
> +    /**
> +     * Special implementation-specific flags.
> +     *
> +     * Must be set by the user before calling av_hwframe_ctx_init().
> +     */
> +    int flags;
>  } AVHWFramesContext;
> 
>  /**
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 5185454d9b..84409b1d69 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>   */
> 
>  #define LIBAVUTIL_VERSION_MAJOR  56
> -#define LIBAVUTIL_VERSION_MINOR  18
> +#define LIBAVUTIL_VERSION_MINOR  19
>  #define LIBAVUTIL_VERSION_MICRO 100
> 
>  #define LIBAVUTIL_VERSION_INT   
> AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \

LGTM.

--phil
Mark Thompson May 7, 2018, 8:45 p.m. UTC | #2
On 07/05/18 19:39, Timo Rothenpieler wrote:
> ---
>  doc/APIchanges        | 3 +++
>  libavutil/hwcontext.h | 7 +++++++
>  libavutil/version.h   | 2 +-
>  3 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index ede5b186ae..307c7a51ee 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -15,6 +15,9 @@ libavutil:     2017-10-21
>  
>  API changes, most recent first:
>  
> +2018-05-xx - xxxxxxxxxx - lavu 56.19.100 - hwcontext.h
> +  Add AVHWFramesContext.flags.
> +
>  2018-04-xx - xxxxxxxxxx - lavu 56.18.100 - pixdesc.h
>    Add AV_PIX_FMT_FLAG_ALPHA to AV_PIX_FMT_PAL8.
>  
> diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
> index f5a4b62387..23e2d335a5 100644
> --- a/libavutil/hwcontext.h
> +++ b/libavutil/hwcontext.h
> @@ -226,6 +226,13 @@ typedef struct AVHWFramesContext {
>       * Must be set by the user before calling av_hwframe_ctx_init().
>       */
>      int width, height;
> +
> +    /**
> +     * Special implementation-specific flags.
> +     *
> +     * Must be set by the user before calling av_hwframe_ctx_init().
> +     */
> +    int flags;
>  } AVHWFramesContext;
>  
>  /**
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 5185454d9b..84409b1d69 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
>   */
>  
>  #define LIBAVUTIL_VERSION_MAJOR  56
> -#define LIBAVUTIL_VERSION_MINOR  18
> +#define LIBAVUTIL_VERSION_MINOR  19
>  #define LIBAVUTIL_VERSION_MICRO 100
>  
>  #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> 

Nack.  Implementation-specific details go in the implementation-specific structure (AVHWFramesContext.hwctx).

What are you actually thining of using this for?  If you want to add flags which are in common between multiple different implementations then maybe it would be suitable to put it here, but something implementation-specific really shouldn't be.

- Mark
Timo Rothenpieler May 7, 2018, 8:52 p.m. UTC | #3
> Nack.  Implementation-specific details go in the implementation-specific structure (AVHWFramesContext.hwctx).
> 
> What are you actually thining of using this for?  If you want to add flags which are in common between multiple different implementations then maybe it would be suitable to put it here, but something implementation-specific really shouldn't be.

I want to add a mapped-frame/dummy mode to the CUDA frame allocator, 
where it does everything a normal hwframes ctx does, except allocating 
memory, because the backing memory comes mapped from the cuvid frame.

Which is a simple flag to set, but there is no way to tell it right now.

The structures in the struct you mentioned are private to libavutil, so 
I can't set them from a decoder.
Mark Thompson May 7, 2018, 9:08 p.m. UTC | #4
On 07/05/18 21:52, Timo Rothenpieler wrote:
>> Nack.  Implementation-specific details go in the implementation-specific structure (AVHWFramesContext.hwctx).
>>
>> What are you actually thining of using this for?  If you want to add flags which are in common between multiple different implementations then maybe it would be suitable to put it here, but something implementation-specific really shouldn't be.
> 
> I want to add a mapped-frame/dummy mode to the CUDA frame allocator, where it does everything a normal hwframes ctx does, except allocating memory, because the backing memory comes mapped from the cuvid frame.
> 
> Which is a simple flag to set, but there is no way to tell it right now.
> 
> The structures in the struct you mentioned are private to libavutil, so I can't set them from a decoder.

They are public, it's just the frames one for CUDA doesn't currently exist.  You want to make a new AVCUDAFramesContext structure in libavutil/hwcontext_cuda.h.

- Mark
Daniel Oberhoff May 8, 2018, 6:45 a.m. UTC | #5
>> 
>> I want to add a mapped-frame/dummy mode to the CUDA frame allocator, where it does everything a normal hwframes ctx does, except allocating memory, because the backing memory comes mapped from the cuvid frame.
>> 
>> Which is a simple flag to set, but there is no way to tell it right now.
>> 
>> The structures in the struct you mentioned are private to libavutil, so I can't set them from a decoder.
> 

Oh, so if i use/set this flag then the pointer i get in the AVFrame(s) are actually mapped from cuvid? I.e. zero-copy? How exactly could I use that?

Best
diff mbox

Patch

diff --git a/doc/APIchanges b/doc/APIchanges
index ede5b186ae..307c7a51ee 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@  libavutil:     2017-10-21
 
 API changes, most recent first:
 
+2018-05-xx - xxxxxxxxxx - lavu 56.19.100 - hwcontext.h
+  Add AVHWFramesContext.flags.
+
 2018-04-xx - xxxxxxxxxx - lavu 56.18.100 - pixdesc.h
   Add AV_PIX_FMT_FLAG_ALPHA to AV_PIX_FMT_PAL8.
 
diff --git a/libavutil/hwcontext.h b/libavutil/hwcontext.h
index f5a4b62387..23e2d335a5 100644
--- a/libavutil/hwcontext.h
+++ b/libavutil/hwcontext.h
@@ -226,6 +226,13 @@  typedef struct AVHWFramesContext {
      * Must be set by the user before calling av_hwframe_ctx_init().
      */
     int width, height;
+
+    /**
+     * Special implementation-specific flags.
+     *
+     * Must be set by the user before calling av_hwframe_ctx_init().
+     */
+    int flags;
 } AVHWFramesContext;
 
 /**
diff --git a/libavutil/version.h b/libavutil/version.h
index 5185454d9b..84409b1d69 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@ 
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  56
-#define LIBAVUTIL_VERSION_MINOR  18
+#define LIBAVUTIL_VERSION_MINOR  19
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \