FFmpeg  4.4.4
opus_metadata_bsf.c
Go to the documentation of this file.
1 /*
2  * This file is part of FFmpeg.
3  *
4  * FFmpeg is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * FFmpeg is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with FFmpeg; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "bsf_internal.h"
20 #include "libavutil/intreadwrite.h"
21 #include "libavutil/opt.h"
22 
23 typedef struct OpusBSFContext {
24  const AVClass *class;
25  int gain;
27 
29 {
30  OpusBSFContext *s = bsfc->priv_data;
31 
32  if (bsfc->par_out->extradata_size < 19)
33  return AVERROR_INVALIDDATA;
34 
35  AV_WL16(bsfc->par_out->extradata + 16, s->gain);
36 
37  return 0;
38 }
39 
40 #define OFFSET(x) offsetof(OpusBSFContext, x)
41 #define FLAGS (AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_BSF_PARAM)
42 static const AVOption opus_metadata_options[] = {
43  { "gain", "Gain, actual amplification is pow(10, gain/(20.0*256))", OFFSET(gain),
44  AV_OPT_TYPE_INT, { .i64 = 0 }, -(INT16_MAX + 1), INT16_MAX, .flags = FLAGS },
45 
46  { NULL },
47 };
48 
49 static const AVClass opus_metadata_class = {
50  .class_name = "opus_metadata_bsf",
51  .item_name = av_default_item_name,
52  .option = opus_metadata_options,
53  .version = LIBAVUTIL_VERSION_INT,
54 };
55 
56 static const enum AVCodecID codec_ids[] = {
58 };
59 
61  .name = "opus_metadata",
62  .priv_data_size = sizeof(OpusBSFContext),
63  .priv_class = &opus_metadata_class,
67 };
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
Definition: bsf.c:253
#define flags(name, subs,...)
Definition: cbs_av1.c:561
#define s(width, name)
Definition: cbs_vp9.c:257
static av_always_inline void filter(int16_t *output, ptrdiff_t out_stride, const int16_t *low, ptrdiff_t low_stride, const int16_t *high, ptrdiff_t high_stride, int len, int clip)
Definition: cfhddsp.c:27
#define NULL
Definition: coverity.c:32
@ AV_OPT_TYPE_INT
Definition: opt.h:225
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition: codec_id.h:46
@ AV_CODEC_ID_NONE
Definition: codec_id.h:47
@ AV_CODEC_ID_OPUS
Definition: codec_id.h:484
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition: error.h:59
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
#define AV_WL16(p, v)
Definition: intreadwrite.h:412
AVOptions.
static enum AVCodecID codec_ids[]
#define FLAGS
const AVBitStreamFilter ff_opus_metadata_bsf
static const AVOption opus_metadata_options[]
#define OFFSET(x)
static const AVClass opus_metadata_class
static int opus_metadata_init(AVBSFContext *bsfc)
The bitstream filter state.
Definition: bsf.h:49
void * priv_data
Opaque filter-specific private data.
Definition: bsf.h:70
AVCodecParameters * par_out
Parameters of the output stream.
Definition: bsf.h:83
const char * name
Definition: bsf.h:99
Describe the class of an AVClass context structure.
Definition: log.h:67
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
int extradata_size
Size of the extradata content in bytes.
Definition: codec_par.h:78
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition: codec_par.h:74
AVOption.
Definition: opt.h:248