[FFmpeg-devel] [PATCH] lavu/opencl: add opencl public error API

Michael Niedermayer michaelni at gmx.at
Sun May 5 13:45:34 CEST 2013


On Fri, May 03, 2013 at 08:02:39PM +0200, Stefano Sabatini wrote:
> On date Sunday 2013-04-28 08:52:16 +0800, Wei Gao encoded:
> > Hi,
> > The attachment is the patch according to the comments
> > 
> > 
> > 2013/4/28 Stefano Sabatini <stefasab at gmail.com>
> > 
> > > On date Saturday 2013-04-27 09:52:45 +0800, Wei Gao encoded:
> > > >
> > >
> > >
> > >
> > > LGTM otherwise, maybe with a minor bump in libavutil, thanks.
> > > --
> > > FFmpeg = Fiendish Fundamental Mere Portable Energized Genius
> > > _______________________________________________
> > > ffmpeg-devel mailing list
> > > ffmpeg-devel at ffmpeg.org
> > > http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> > >
> 
> > From 35ef0c10168cf6c46db7aca61b7ac7361d4b02c3 Mon Sep 17 00:00:00 2001
> > From: highgod0401 <highgod0401 at gmail.com>
> > Date: Sun, 28 Apr 2013 08:47:20 +0800
> > Subject: [PATCH] lavu/opencl: add opencl public error API
> > 
> > ---
> >  libavutil/opencl.c  | 48 ++++++++++++++++++++++++------------------------
> >  libavutil/opencl.h  |  8 ++++++++
> >  libavutil/version.h |  2 +-
> >  3 files changed, 33 insertions(+), 25 deletions(-)
> > 
> > diff --git a/libavutil/opencl.c b/libavutil/opencl.c
> > index 1fdb096..e2d5581 100644
> > --- a/libavutil/opencl.c
> > +++ b/libavutil/opencl.c
> > @@ -162,7 +162,7 @@ static const OpenclErrorMsg opencl_err_msg[] = {
> >      {CL_INVALID_DEVICE_PARTITION_COUNT,                 "INVALID DEVICE PARTITION COUNT"},
> >  };
> >  
> > -static const char *opencl_errstr(cl_int status)
> > +const char *av_opencl_errstr(cl_int status)
> >  {
> >      int i;
> >      for (i = 0; i < sizeof(opencl_err_msg); i++) {
> > @@ -201,7 +201,7 @@ static int get_device_list(AVOpenCLDeviceList *device_list)
> >      status = clGetPlatformIDs(0, NULL, &device_list->platform_num);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not get OpenCL platform ids: %s\n", opencl_errstr(status));
> > +               "Could not get OpenCL platform ids: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      platform_ids = av_mallocz(device_list->platform_num * sizeof(cl_platform_id));
> > @@ -210,7 +210,7 @@ static int get_device_list(AVOpenCLDeviceList *device_list)
> >      status = clGetPlatformIDs(device_list->platform_num, platform_ids, NULL);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -                "Could not get OpenCL platform ids: %s\n", opencl_errstr(status));
> > +                "Could not get OpenCL platform ids: %s\n", av_opencl_errstr(status));
> >          ret = AVERROR_EXTERNAL;
> >          goto end;
> >      }
> > @@ -256,7 +256,7 @@ static int get_device_list(AVOpenCLDeviceList *device_list)
> >                                          devices_num[j], device_ids, NULL);
> >                  if (status != CL_SUCCESS) {
> >                      av_log(&opencl_ctx, AV_LOG_WARNING,
> > -                            "Could not get device ID: %s:\n", opencl_errstr(status));
> > +                            "Could not get device ID: %s:\n", av_opencl_errstr(status));
> >                      av_freep(&device_ids);
> >                      continue;
> >                  }
> > @@ -275,7 +275,7 @@ static int get_device_list(AVOpenCLDeviceList *device_list)
> >                                               NULL);
> >                      if (status != CL_SUCCESS) {
> >                          av_log(&opencl_ctx, AV_LOG_WARNING,
> > -                                "Could not get device name: %s\n", opencl_errstr(status));
> > +                                "Could not get device name: %s\n", av_opencl_errstr(status));
> >                          continue;
> >                      }
> >                      device_list->platform_node[i]->device_num++;
> > @@ -416,7 +416,7 @@ int av_opencl_create_kernel(AVOpenCLKernelEnv *env, const char *kernel_name)
> >                  break;
> >          }
> >          if (status != CL_SUCCESS) {
> > -            av_log(&opencl_ctx, AV_LOG_ERROR, "Could not create OpenCL kernel: %s\n", opencl_errstr(status));
> > +            av_log(&opencl_ctx, AV_LOG_ERROR, "Could not create OpenCL kernel: %s\n", av_opencl_errstr(status));
> >              ret = AVERROR_EXTERNAL;
> >              goto end;
> >          }
> > @@ -438,7 +438,7 @@ void av_opencl_release_kernel(AVOpenCLKernelEnv *env)
> >      status = clReleaseKernel(env->kernel);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR, "Could not release kernel: %s\n",
> > -              opencl_errstr(status));
> > +              av_opencl_errstr(status));
> >      }
> >      env->kernel = NULL;
> >      env->command_queue = NULL;
> > @@ -526,14 +526,14 @@ static int init_opencl_env(OpenclContext *opencl_ctx, AVOpenCLExternalEnv *ext_o
> >                                                         NULL, NULL, &status);
> >              if (status != CL_SUCCESS) {
> >                  av_log(opencl_ctx, AV_LOG_ERROR,
> > -                       "Could not get OpenCL context from device type: %s\n", opencl_errstr(status));
> > +                       "Could not get OpenCL context from device type: %s\n", av_opencl_errstr(status));
> >                  return AVERROR_EXTERNAL;
> >              }
> >              opencl_ctx->command_queue = clCreateCommandQueue(opencl_ctx->context, opencl_ctx->device_id,
> >                                                            0, &status);
> >              if (status != CL_SUCCESS) {
> >                  av_log(opencl_ctx, AV_LOG_ERROR,
> > -                       "Could not create OpenCL command queue: %s\n", opencl_errstr(status));
> > +                       "Could not create OpenCL command queue: %s\n", av_opencl_errstr(status));
> >                  return AVERROR_EXTERNAL;
> >              }
> >          }
> > @@ -566,7 +566,7 @@ static int compile_kernel_file(OpenclContext *opencl_ctx)
> >                                                                                  &status);
> >      if(status != CL_SUCCESS) {
> >          av_log(opencl_ctx, AV_LOG_ERROR,
> > -               "Could not create OpenCL program with source code: %s\n", opencl_errstr(status));
> > +               "Could not create OpenCL program with source code: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      if (!opencl_ctx->programs[opencl_ctx->program_count]) {
> > @@ -577,7 +577,7 @@ static int compile_kernel_file(OpenclContext *opencl_ctx)
> >                              opencl_ctx->build_options, NULL, NULL);
> >      if (status != CL_SUCCESS) {
> >          av_log(opencl_ctx, AV_LOG_ERROR,
> > -               "Could not compile OpenCL kernel: %s\n", opencl_errstr(status));
> > +               "Could not compile OpenCL kernel: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      opencl_ctx->program_count++;
> > @@ -628,7 +628,7 @@ void av_opencl_uninit(void)
> >              status = clReleaseProgram(opencl_ctx.programs[i]);
> >              if (status != CL_SUCCESS) {
> >                  av_log(&opencl_ctx, AV_LOG_ERROR,
> > -                       "Could not release OpenCL program: %s\n", opencl_errstr(status));
> > +                       "Could not release OpenCL program: %s\n", av_opencl_errstr(status));
> >              }
> >              opencl_ctx.programs[i] = NULL;
> >          }
> > @@ -637,7 +637,7 @@ void av_opencl_uninit(void)
> >          status = clReleaseCommandQueue(opencl_ctx.command_queue);
> >          if (status != CL_SUCCESS) {
> >              av_log(&opencl_ctx, AV_LOG_ERROR,
> > -                   "Could not release OpenCL command queue: %s\n", opencl_errstr(status));
> > +                   "Could not release OpenCL command queue: %s\n", av_opencl_errstr(status));
> >          }
> >          opencl_ctx.command_queue = NULL;
> >      }
> > @@ -645,7 +645,7 @@ void av_opencl_uninit(void)
> >          status = clReleaseContext(opencl_ctx.context);
> >          if (status != CL_SUCCESS) {
> >              av_log(&opencl_ctx, AV_LOG_ERROR,
> > -                   "Could not release OpenCL context: %s\n", opencl_errstr(status));
> > +                   "Could not release OpenCL context: %s\n", av_opencl_errstr(status));
> >          }
> >          opencl_ctx.context = NULL;
> >      }
> > @@ -661,7 +661,7 @@ int av_opencl_buffer_create(cl_mem *cl_buf, size_t cl_buf_size, int flags, void
> >      cl_int status;
> >      *cl_buf = clCreateBuffer(opencl_ctx.context, flags, cl_buf_size, host_ptr, &status);
> >      if (status != CL_SUCCESS) {
> > -        av_log(&opencl_ctx, AV_LOG_ERROR, "Could not create OpenCL buffer: %s\n", opencl_errstr(status));
> > +        av_log(&opencl_ctx, AV_LOG_ERROR, "Could not create OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      return 0;
> > @@ -675,7 +675,7 @@ void av_opencl_buffer_release(cl_mem *cl_buf)
> >      status = clReleaseMemObject(*cl_buf);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not release OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not release OpenCL buffer: %s\n", av_opencl_errstr(status));
> >      }
> >      memset(cl_buf, 0, sizeof(*cl_buf));
> >  }
> > @@ -689,7 +689,7 @@ int av_opencl_buffer_write(cl_mem dst_cl_buf, uint8_t *src_buf, size_t buf_size)
> >  
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not map OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not map OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      memcpy(mapped, src_buf, buf_size);
> > @@ -697,7 +697,7 @@ int av_opencl_buffer_write(cl_mem dst_cl_buf, uint8_t *src_buf, size_t buf_size)
> >      status = clEnqueueUnmapMemObject(opencl_ctx.command_queue, dst_cl_buf, mapped, 0, NULL, NULL);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not unmap OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not unmap OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      return 0;
> > @@ -712,7 +712,7 @@ int av_opencl_buffer_read(uint8_t *dst_buf, cl_mem src_cl_buf, size_t buf_size)
> >  
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not map OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not map OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      memcpy(dst_buf, mapped, buf_size);
> > @@ -720,7 +720,7 @@ int av_opencl_buffer_read(uint8_t *dst_buf, cl_mem src_cl_buf, size_t buf_size)
> >      status = clEnqueueUnmapMemObject(opencl_ctx.command_queue, src_cl_buf, mapped, 0, NULL, NULL);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not unmap OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not unmap OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      return 0;
> > @@ -749,7 +749,7 @@ int av_opencl_buffer_write_image(cl_mem dst_cl_buf, size_t cl_buffer_size, int d
> >                                  0, NULL, NULL, &status);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not map OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not map OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      temp = mapped;
> > @@ -761,7 +761,7 @@ int av_opencl_buffer_write_image(cl_mem dst_cl_buf, size_t cl_buffer_size, int d
> >      status = clEnqueueUnmapMemObject(opencl_ctx.command_queue, dst_cl_buf, mapped, 0, NULL, NULL);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not unmap OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not unmap OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      return 0;
> > @@ -791,7 +791,7 @@ int av_opencl_buffer_read_image(uint8_t **dst_data, int *plane_size, int plane_n
> >  
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not map OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not map OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      temp = mapped;
> > @@ -804,7 +804,7 @@ int av_opencl_buffer_read_image(uint8_t **dst_data, int *plane_size, int plane_n
> >      status = clEnqueueUnmapMemObject(opencl_ctx.command_queue, src_cl_buf, mapped, 0, NULL, NULL);
> >      if (status != CL_SUCCESS) {
> >          av_log(&opencl_ctx, AV_LOG_ERROR,
> > -               "Could not unmap OpenCL buffer: %s\n", opencl_errstr(status));
> > +               "Could not unmap OpenCL buffer: %s\n", av_opencl_errstr(status));
> >          return AVERROR_EXTERNAL;
> >      }
> >      return 0;
> > diff --git a/libavutil/opencl.h b/libavutil/opencl.h
> > index acafe36..4621e88 100644
> > --- a/libavutil/opencl.h
> > +++ b/libavutil/opencl.h
> > @@ -151,6 +151,14 @@ AVOpenCLExternalEnv *av_opencl_alloc_external_env(void);
> >  void av_opencl_free_external_env(AVOpenCLExternalEnv **ext_opencl_env);
> >  
> >  /**
> > + * Get OpenCL error string.
> > + *
> > + * @param status    OpenCL error code
> > + * @return OpenCL error string
> > + */
> > +const char *av_opencl_errstr(cl_int status);
> > +
> > +/**
> >   * Register kernel code.
> >   *
> >   *  The registered kernel code is stored in a global context, and compiled
> > diff --git a/libavutil/version.h b/libavutil/version.h
> > index abcdba8..4cc6024 100644
> > --- a/libavutil/version.h
> > +++ b/libavutil/version.h
> > @@ -75,7 +75,7 @@
> >   */
> >  
> >  #define LIBAVUTIL_VERSION_MAJOR  52
> > -#define LIBAVUTIL_VERSION_MINOR  27
> > +#define LIBAVUTIL_VERSION_MINOR  28
> >  #define LIBAVUTIL_VERSION_MICRO 101
> 
> LGTM, thanks.

applied

thanks

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No great genius has ever existed without some touch of madness. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20130505/275ac691/attachment.asc>


More information about the ffmpeg-devel mailing list