[FFmpeg-devel] [PATCH] lavc/bsf: add an Opus metadata bitstream filter

Andreas Rheinhardt andreas.rheinhardt at gmail.com
Tue May 5 11:59:56 EEST 2020


Lynne:
> The only adjustable field is the gain. Some ripping/transcoding programs 
> have started to use it for replaygain adjustments.
> 
> Patch attached.
> 
> >
> +typedef struct OpusBSFContext {
> +    const AVClass *class;
> +    int64_t gain;
> +} OpusBSFContext;
[...]
> 
> +static const AVOption opus_metadata_options[] = {
> +    { "gain", "Gain, actual amplification is pow(10, gain/(20.0*256))", OFFSET(gain),
> +      AV_OPT_TYPE_INT, { .i64 = 0 }, -(INT16_MAX + 1), INT16_MAX, .flags = FLAGS },
> +
> +    { NULL },
> +};

You are using an AV_OPT_TYPE_INT parameter, yet the actual type of the
destination is int64_t. This won't work on big endian systems. Make gain
an int.

- Andreas

PS: Do we actually support two's complement architectures were
-(INT16_MAX + 1) != INT16_MIN? (A two's complement architecture in which
the representation where the sign bit is set and all other bits is unset
is trap representation is legal according to the C standard. Does
someone know whether it would also be legal according to POSIX?)


More information about the ffmpeg-devel mailing list