[FFmpeg-devel] [PATCH 2/3] avutil/opt: Add AV_OPT_TYPE_UINT64
Michael Niedermayer
michael at niedermayer.cc
Sun Nov 20 22:52:34 EET 2016
On Sun, Nov 20, 2016 at 08:55:44PM +0100, Andreas Cadhalpun wrote:
> On 20.11.2016 12:57, Michael Niedermayer wrote:
> > Requested-by: wm4 ([FFmpeg-devel] [PATCH] avutil/opt: Support max > INT64_MAX in write_number() with AV_OPT_TYPE_INT64)
> > Requested-by: ronald ([FFmpeg-devel] [PATCH] avutil/opt: Support max > INT64_MAX in write_number() with AV_OPT_TYPE_INT64)
> > Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> > ---
> > libavutil/opt.c | 29 +++++++++++++++++++++++++++++
> > libavutil/opt.h | 1 +
> > 2 files changed, 30 insertions(+)
> >
> > diff --git a/libavutil/opt.c b/libavutil/opt.c
> > index 6669356..b6b4d9f 100644
> > --- a/libavutil/opt.c
> > +++ b/libavutil/opt.c
> > @@ -74,6 +74,7 @@ static int read_number(const AVOption *o, const void *dst, double *num, int *den
> > case AV_OPT_TYPE_CHANNEL_LAYOUT:
> > case AV_OPT_TYPE_DURATION:
> > case AV_OPT_TYPE_INT64:
> > + case AV_OPT_TYPE_UINT64:
> > *intnum = *(int64_t *)dst;
> > return 0;
> > case AV_OPT_TYPE_FLOAT:
> > @@ -131,6 +132,20 @@ static int write_number(void *obj, const AVOption *o, void *dst, double num, int
> > if (intnum == 1 && d == (double)INT64_MAX) *(int64_t *)dst = INT64_MAX;
> > else *(int64_t *)dst = llrint(d) * intnum;
> > break;}
> > + case AV_OPT_TYPE_UINT64:{
> > + double d = num / den;
> > + // 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 (intnum == 1 && d == (double)UINT64_MAX) {
> > + *(int64_t *)dst = UINT64_MAX;
>
> Is there a reason why this uses int64_t,
>
> > + } else if (o->max > INT64_MAX + 1ULL && d > INT64_MAX + 1ULL) {
> > + *(uint64_t *)dst = (llrint(d - (INT64_MAX + 1ULL)) + (INT64_MAX + 1ULL))*intnum;
>
> but this uint64_t,
>
> > + } else {
> > + *(int64_t *)dst = llrint(d) * intnum;
>
> and this again int64_t?
these are left over from the year old patch this is based on
fixed locally
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Dictatorship naturally arises out of democracy, and the most aggravated
form of tyranny and slavery out of the most extreme liberty. -- Plato
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20161120/ec32c30c/attachment.sig>
More information about the ffmpeg-devel
mailing list