[FFmpeg-devel,V2,1/2] lavfi/opencl: add more opencl helper macro

Submitted by Ruiling Song on April 12, 2019, 3:09 p.m.

Details

Message ID 20190412150930.8395-1-ruiling.song@intel.com
State New
Headers show

Commit Message

Ruiling Song April 12, 2019, 3:09 p.m.
Signed-off-by: Ruiling Song <ruiling.song@intel.com>
---
 libavfilter/opencl.h | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

Comments

Mark Thompson April 16, 2019, 9:24 p.m.
On 12/04/2019 16:09, Ruiling Song wrote:
> Signed-off-by: Ruiling Song <ruiling.song@intel.com>
> ---
>  libavfilter/opencl.h | 38 ++++++++++++++++++++++++++++++++++++++
>  1 file changed, 38 insertions(+)
> 
> diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
> index 0b06232ade..0fa5b49d3f 100644
> --- a/libavfilter/opencl.h
> +++ b/libavfilter/opencl.h
> @@ -73,6 +73,44 @@ typedef struct OpenCLFilterContext {
>              goto fail;                                         \
>          }                                                      \
>      } while(0)
> +/**
> +  * release an OpenCL Kernel
> +  */
> +#define CL_RELEASE_KERNEL(k)                                  \
> +do {                                                          \
> +    if (k) {                                                  \
> +        cle = clReleaseKernel(k);                             \
> +        if (cle != CL_SUCCESS)                                \
> +            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
> +                   "OpenCL kernel: %d.\n", cle);              \
> +    }                                                         \
> +} while(0)
> +
> +/**
> +  * release an OpenCL Memory Object
> +  */
> +#define CL_RELEASE_MEMORY(m)                                  \
> +do {                                                          \
> +    if (m) {                                                  \
> +        cle = clReleaseMemObject(m);                          \
> +        if (cle != CL_SUCCESS)                                \
> +            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
> +                   "OpenCL memory: %d.\n", cle);              \
> +    }                                                         \
> +} while(0)
> +
> +/**
> +  * release an OpenCL Command Queue
> +  */
> +#define CL_RELEASE_QUEUE(q)                                   \
> +do {                                                          \
> +    if (q) {                                                  \
> +        cle = clReleaseCommandQueue(q);                       \
> +        if (cle != CL_SUCCESS)                                \
> +            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
> +                   "cl command queue: %d.\n", cle);           \
> +    }                                                         \
> +} while(0)
>  
>  /**
>   * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.
> 

LGTM.

Thanks,

- Mark
Ruiling Song April 26, 2019, 1:14 a.m.
> -----Original Message-----

> From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf

> Of Mark Thompson

> Sent: Wednesday, April 17, 2019 5:25 AM

> To: ffmpeg-devel@ffmpeg.org

> Subject: Re: [FFmpeg-devel] [PATCH V2 1/2] lavfi/opencl: add more opencl

> helper macro

> 

> On 12/04/2019 16:09, Ruiling Song wrote:

> > Signed-off-by: Ruiling Song <ruiling.song@intel.com>

> > ---

> >  libavfilter/opencl.h | 38 ++++++++++++++++++++++++++++++++++++++

> >  1 file changed, 38 insertions(+)

> >

> > diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h

> > index 0b06232ade..0fa5b49d3f 100644

> > --- a/libavfilter/opencl.h

> > +++ b/libavfilter/opencl.h

> > @@ -73,6 +73,44 @@ typedef struct OpenCLFilterContext {

> >              goto fail;                                         \

> >          }                                                      \

> >      } while(0)

> > +/**

> > +  * release an OpenCL Kernel

> > +  */

> > +#define CL_RELEASE_KERNEL(k)                                  \

> > +do {                                                          \

> > +    if (k) {                                                  \

> > +        cle = clReleaseKernel(k);                             \

> > +        if (cle != CL_SUCCESS)                                \

> > +            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \

> > +                   "OpenCL kernel: %d.\n", cle);              \

> > +    }                                                         \

> > +} while(0)

> > +

> > +/**

> > +  * release an OpenCL Memory Object

> > +  */

> > +#define CL_RELEASE_MEMORY(m)                                  \

> > +do {                                                          \

> > +    if (m) {                                                  \

> > +        cle = clReleaseMemObject(m);                          \

> > +        if (cle != CL_SUCCESS)                                \

> > +            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \

> > +                   "OpenCL memory: %d.\n", cle);              \

> > +    }                                                         \

> > +} while(0)

> > +

> > +/**

> > +  * release an OpenCL Command Queue

> > +  */

> > +#define CL_RELEASE_QUEUE(q)                                   \

> > +do {                                                          \

> > +    if (q) {                                                  \

> > +        cle = clReleaseCommandQueue(q);                       \

> > +        if (cle != CL_SUCCESS)                                \

> > +            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \

> > +                   "cl command queue: %d.\n", cle);           \

> > +    }                                                         \

> > +} while(0)

> >

> >  /**

> >   * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.

> >

> 

> LGTM.

Pushed this patch so we can use it in other opencl filters. Thanks!
> 

> 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".

Patch hide | download patch | download mbox

diff --git a/libavfilter/opencl.h b/libavfilter/opencl.h
index 0b06232ade..0fa5b49d3f 100644
--- a/libavfilter/opencl.h
+++ b/libavfilter/opencl.h
@@ -73,6 +73,44 @@  typedef struct OpenCLFilterContext {
             goto fail;                                         \
         }                                                      \
     } while(0)
+/**
+  * release an OpenCL Kernel
+  */
+#define CL_RELEASE_KERNEL(k)                                  \
+do {                                                          \
+    if (k) {                                                  \
+        cle = clReleaseKernel(k);                             \
+        if (cle != CL_SUCCESS)                                \
+            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
+                   "OpenCL kernel: %d.\n", cle);              \
+    }                                                         \
+} while(0)
+
+/**
+  * release an OpenCL Memory Object
+  */
+#define CL_RELEASE_MEMORY(m)                                  \
+do {                                                          \
+    if (m) {                                                  \
+        cle = clReleaseMemObject(m);                          \
+        if (cle != CL_SUCCESS)                                \
+            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
+                   "OpenCL memory: %d.\n", cle);              \
+    }                                                         \
+} while(0)
+
+/**
+  * release an OpenCL Command Queue
+  */
+#define CL_RELEASE_QUEUE(q)                                   \
+do {                                                          \
+    if (q) {                                                  \
+        cle = clReleaseCommandQueue(q);                       \
+        if (cle != CL_SUCCESS)                                \
+            av_log(avctx, AV_LOG_ERROR, "Failed to release "  \
+                   "cl command queue: %d.\n", cle);           \
+    }                                                         \
+} while(0)
 
 /**
  * Return that all inputs and outputs support only AV_PIX_FMT_OPENCL.