[FFmpeg-devel] [PATCH] Add av_file_get_size() and av_file_read(), replace cmdutils.h:read_file().
Stefano Sabatini
stefano.sabatini-lala
Mon Dec 6 00:02:18 CET 2010
On date Friday 2010-12-03 18:43:46 +0100, Michael Niedermayer encoded:
> On Fri, Dec 03, 2010 at 05:15:44PM +0100, Stefano Sabatini wrote:
> > On date Thursday 2010-12-02 02:32:30 +0100, Michael Niedermayer encoded:
> > [...]
> > > > +/**
> > > > + * Read the file with name filename, and put its content in a newly
> > > > + * allocated 0-terminated buffer. If filename references a link, the
> > > > + * content of the linked file is read.
> > > > + *
> > > > + * @param bufptr location where pointer to buffer is returned
> > > > + * @param size location where size of buffer is returned
> > > > + * @param log_ctx context used for logging
> > > > + * @return 0 in case of success, a negative value corresponding to an
> > > > + * AVERROR error code in case of failure
> > > > + */
> > > > +int av_file_read(const char *filename, char **bufptr, size_t *size, void *log_ctx);
> > >
> > > this API is crap.
> > > at a minimunm it should support memory mapped files on platforms supporting them
> >
> > We could have a:
> > int av_file_get(const char *filename, size_t *size, void *log_ctx);
> >
> > (alternative name: av_file_open())
> >
> > which returns the filedes and the size performing the boring checks,
> > then the application may suck the content in a buffer or using mmap()
> > access. Would be this acceptable?
>
> its worse in every respect, and still doenst support mmap
>
> what i was thinking of:
> @param **bufptr The file content, can be a allocated buffer or access through mmap
> fd=av_file_map(const char *filename, uint8_t **bufptr, size_t *size, int access_rights, void *log_ctx);
>
> av_file_unmap(int fd, uint8_t *bufptr, size_t size);
Yet this API is overkill and awkward when you only need to open a
file, allocate a buffer and copy the file content to it, without to
keep track of the fd and size (the buffer may need to be released
later in a different context), as it is the case for ffmpeg.c.
--
FFmpeg = Fiendish and Freak Muttering Puristic Elitist Gadget
More information about the ffmpeg-devel
mailing list