Hi, On Sun, Oct 25, 2015 at 3:12 PM, wm4 <nfx...@googlemail.com> wrote:
> On Sun, 25 Oct 2015 19:46:42 +0100 > Michael Niedermayer <michae...@gmx.at> wrote: > > > From: Michael Niedermayer <mich...@niedermayer.cc> > > > > This allows for example to set max to UINT64_MAX and set values in that > > range > > > > Signed-off-by: Michael Niedermayer <mich...@niedermayer.cc> > > --- > > libavutil/opt.c | 12 +++++++++++- > > 1 file changed, 11 insertions(+), 1 deletion(-) > > > > diff --git a/libavutil/opt.c b/libavutil/opt.c > > index 36eeeb0..157179c 100644 > > --- a/libavutil/opt.c > > +++ b/libavutil/opt.c > > @@ -102,7 +102,17 @@ static int write_number(void *obj, const AVOption > *o, void *dst, double num, int > > case AV_OPT_TYPE_INT: *(int *)dst= llrint(num/den)*intnum; > break; > > case AV_OPT_TYPE_DURATION: > > case AV_OPT_TYPE_CHANNEL_LAYOUT: > > - case AV_OPT_TYPE_INT64: *(int64_t *)dst= llrint(num/den)*intnum; > break; > > + case AV_OPT_TYPE_INT64: > > + // We must special case uint64_t here as llrint() does not > support values > > + // outside the int64_t range and there is no portable function > which does > > + // "INT64_MAX + 1ULL" is used as it is representable exactly as > IEEE double > > + // while INT64_MAX is not > > + if (o->max > INT64_MAX + 1ULL && num/den > INT64_MAX + 1ULL) { > > + *(uint64_t *)dst = (llrint(num/den - (INT64_MAX + 1ULL)) + > (INT64_MAX + 1ULL))*intnum; > > + } else { > > + *(int64_t *)dst = llrint(num/den)*intnum; > > + } > > + break; > > case AV_OPT_TYPE_FLOAT: *(float *)dst= num*intnum/den; > break; > > case AV_OPT_TYPE_DOUBLE:*(double *)dst= num*intnum/den; > break; > > case AV_OPT_TYPE_RATIONAL: > > Introducing AV_OPT_TYPE_UINT64 would be cleaner... +1. Ronald _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel