This source file includes following definitions.
- opus_metadata_init
#include "bsf_internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
typedef struct OpusBSFContext {
const AVClass *class;
int gain;
} OpusBSFContext;
static int opus_metadata_init(AVBSFContext *bsfc)
{
OpusBSFContext *s = bsfc->priv_data;
if (bsfc->par_out->extradata_size < 19)
return AVERROR_INVALIDDATA;
AV_WL16(bsfc->par_out->extradata + 16, s->gain);
return 0;
}
#define OFFSET(x) offsetof(OpusBSFContext, x)
#define FLAGS (AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_BSF_PARAM)
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 },
};
static const AVClass opus_metadata_class = {
.class_name = "opus_metadata_bsf",
.item_name = av_default_item_name,
.option = opus_metadata_options,
.version = LIBAVUTIL_VERSION_INT,
};
static const enum AVCodecID codec_ids[] = {
AV_CODEC_ID_OPUS, AV_CODEC_ID_NONE,
};
const AVBitStreamFilter ff_opus_metadata_bsf = {
.name = "opus_metadata",
.priv_data_size = sizeof(OpusBSFContext),
.priv_class = &opus_metadata_class,
.init = &opus_metadata_init,
.filter = &ff_bsf_get_packet_ref,
.codec_ids = codec_ids,
};