[FFmpeg-devel] [PATCH 1/2] libavutil/libavfilter: add opencl wrapper to ffmpeg

Wei Gao highgod0401 at gmail.com
Mon Mar 25 03:17:20 CET 2013


2013/3/25 Michael Niedermayer <michaelni at gmx.at>

> On Sun, Mar 24, 2013 at 08:00:46PM +0100, Michael Niedermayer wrote:
> > On Sun, Mar 24, 2013 at 06:40:27PM +0100, Stefano Sabatini wrote:
> > > On date Sunday 2013-03-24 19:55:00 +0800, Wei Gao encoded:
> > > >
> > >
> > > > From ab91c74fa166f557eadb39ab399d7ba667b91340 Mon Sep 17 00:00:00
> 2001
> > > > From: highgod0401 <highgod0401 at gmail.com>
> > > > Date: Sun, 24 Mar 2013 19:20:16 +0800
> > > > Subject: [PATCH 1/2] add opencl wrapper to ffmpeg
> > [...]
> >
> > > > +static int access_binaries(cl_device_id *device_ids, int
> numdevices, const char *cl_file_name, FILE **fhandle,
> > > > +                                size_t *binarysizes, char
> **binaries, int write)
> > > > +{
> > > > +    FILE *fd = NULL;
> > > > +    int status;
> > > > +    char filename[1024] = {0};
> > > > +    char cl_name[1024] = {0};
> > > > +    char devicename[1024] = {0};
> > > > +    int i;
> > > > +    for (i = 0; i < numdevices; i++) {
> > > > +        if (device_ids[i] != 0) {
> > > > +            status = clGetDeviceInfo(device_ids[i],
> > > > +                                     CL_DEVICE_NAME,
> > > > +                                     sizeof(devicename),
> > > > +                                     devicename,
> > > > +                                     NULL);
> > > > +            if (status == CL_SUCCESS) {
> > > > +                av_strlcpy(cl_name,cl_file_name,sizeof(cl_name));
> > > > +                snprintf(filename, sizeof(filename),"./%s-%s.bin",
> cl_name, devicename);
> >
> > [...]
> >
> > > > +                    if (binarysizes[i] != 0) {
> > > > +                        output = fopen(filename, "wb");
> >
> > [...]
> >
> > > > +                        }
> > > > +                        fwrite(binaries[i], sizeof(char),
> binarysizes[i], output);
> >
> > theres no gurantee that you have write permission in the current
> > directory or in any directory.
> > Also its not nice from a library to drop files in the current
> > directory unrequested
>
> also, while i didnt read the whole file read/write code it appears
> to me that files are read and executed from the current directory
> this is not safe, someone could have placed a mallicious file there
>
The file is use to save compile informations of OpenCL kernels in ffmpeg.
Because OpenCL kernels is compiled in the runtime, and the compile time
will be longer if there are more OpenCL kernels.If ffmpeg compile kernel
every time, it will cost a long time in compiling every time.So we record
the compile information the first time. And ffmpeg will load the file and
run kernel without compile. It can save much time.

>
> [..]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Let us carefully observe those good qualities wherein our enemies excel us
> and endeavor to excel them, by avoiding what is faulty, and imitating what
> is excellent in them. -- Plutarch
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>


More information about the ffmpeg-devel mailing list