[FFmpeg-devel] [FFmpeg-cvslog] lavu/opt: add array options

Paul B Mahol onemda at gmail.com
Fri Jul 5 23:06:56 EEST 2024


On Fri, Jul 5, 2024 at 9:38 PM Michael Niedermayer <michael at niedermayer.cc>
wrote:

> On Fri, Mar 08, 2024 at 07:06:17AM +0000, Anton Khirnov wrote:
> > ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu Feb
> 8 08:50:18 2024 +0100| [efe447877811f2f14f814e80ce71383e2f056f36] |
> committer: Anton Khirnov
> >
> > lavu/opt: add array options
> >
> > >
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=efe447877811f2f14f814e80ce71383e2f056f36
> > ---
> >
> >  doc/APIchanges        |   3 +
> >  libavutil/opt.c       | 360
> ++++++++++++++++++++++++++++++++++++++++++++------
> >  libavutil/opt.h       |  56 +++++++-
> >  libavutil/tests/opt.c |  49 +++++++
> >  libavutil/version.h   |   2 +-
> >  tests/ref/fate/opt    |  35 ++++-
> >  6 files changed, 459 insertions(+), 46 deletions(-)
> [...]
> > --- a/libavutil/opt.h
> > +++ b/libavutil/opt.h
> > @@ -250,6 +250,17 @@ enum AVOptionType{
> >      AV_OPT_TYPE_COLOR,
> >      AV_OPT_TYPE_BOOL,
> >      AV_OPT_TYPE_CHLAYOUT,
> > +
> > +    /**
> > +     * May be combined with another regular option type to declare an
> array
> > +     * option.
> > +     *
> > +     * For array options, @ref AVOption.offset should refer to a pointer
> > +     * corresponding to the option type. The pointer should be
> immediately
> > +     * followed by an unsigned int that will store the number of
> elements in the
> > +     * array.
> > +     */
> > +    AV_OPT_TYPE_FLAG_ARRAY = (1 << 16),
>
> This sounds like it suggests undefined behavior
>
> taking a pointer to a pointer of lets say a array of float
> and adding 1 and then dereferencing this as int is undefined behavior
>
> A pointer created that way may not be aligned correctly. This just happens
> to work on the major platforms ...
>
> Or said differently a int *array ; int array_len in a struct arent
> guranteed to have
> the same distance between each other each time.
>

One more reason to replace AVOptions limited API.


>
> thx
>
> [...]
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> He who knows, does not speak. He who speaks, does not know. -- Lao Tsu
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>


More information about the ffmpeg-devel mailing list