[FFmpeg-devel] [PATCH 2/3] avutil/opt: Add AV_OPT_TYPE_UINT64

Ronald S. Bultje rsbultje at gmail.com
Sun Nov 20 15:56:15 EET 2016


Hi,

On Sun, Nov 20, 2016 at 6:57 AM, Michael Niedermayer <michael at niedermayer.cc
> wrote:

> @@ -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;
> +        } else if (o->max > INT64_MAX + 1ULL && d > INT64_MAX + 1ULL) {
> +            *(uint64_t *)dst = (llrint(d - (INT64_MAX + 1ULL)) +
> (INT64_MAX + 1ULL))*intnum;
> +        } else {
> +            *(int64_t *)dst = llrint(d) * intnum;
> +        }
> +        break;}
>      case AV_OPT_TYPE_FLOAT:
>          *(float *)dst = num * intnum / den;
>          break;


For the stupid, like me: what does this do? More specifically, this seems
an integer codepath, but there is a double in there. Why?

Ronald


More information about the ffmpeg-devel mailing list