FFmpeg
Loading...
Searching...
No Matches
libavcodec
bsf
opus_metadata.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 "
libavcodec/bsf.h
"
20
#include "
libavcodec/bsf_internal.h
"
21
#include "
libavutil/intreadwrite.h
"
22
#include "
libavutil/opt.h
"
23
24
typedef
struct
OpusBSFContext
{
25
const
AVClass
*
class
;
26
int
gain
;
27
}
OpusBSFContext
;
28
29
static
int
opus_metadata_init
(
AVBSFContext
*bsfc)
30
{
31
OpusBSFContext
*
s
= bsfc->
priv_data
;
32
33
if
(bsfc->
par_out
->
extradata_size
< 19)
34
return
AVERROR_INVALIDDATA
;
35
36
AV_WL16
(bsfc->
par_out
->
extradata
+ 16,
s
->gain);
37
38
return
0;
39
}
40
41
#define OFFSET(x) offsetof(OpusBSFContext, x)
42
#define FLAGS (AV_OPT_FLAG_AUDIO_PARAM|AV_OPT_FLAG_BSF_PARAM)
43
static
const
AVOption
opus_metadata_options
[] = {
44
{
"gain"
,
"Gain, actual amplification is pow(10, gain/(20.0*256))"
,
OFFSET
(gain),
45
AV_OPT_TYPE_INT
, { .i64 = 0 }, -(INT16_MAX + 1), INT16_MAX, .
flags
=
FLAGS
},
46
47
{
NULL
},
48
};
49
50
static
const
AVClass
opus_metadata_class
= {
51
.class_name =
"opus_metadata_bsf"
,
52
.item_name =
av_default_item_name
,
53
.option =
opus_metadata_options
,
54
.version =
LIBAVUTIL_VERSION_INT
,
55
};
56
57
static
const
enum
AVCodecID
codec_ids
[] = {
58
AV_CODEC_ID_OPUS
,
AV_CODEC_ID_NONE
,
59
};
60
61
const
FFBitStreamFilter
ff_opus_metadata_bsf
= {
62
.p.name =
"opus_metadata"
,
63
.p.codec_ids =
codec_ids
,
64
.p.priv_class = &
opus_metadata_class
,
65
.priv_data_size =
sizeof
(
OpusBSFContext
),
66
.
init
= &
opus_metadata_init
,
67
.
filter
= &
ff_bsf_get_packet_ref
,
68
};
codec_ids
static enum AVCodecID codec_ids[]
Definition
aac_adtstoasc.c:146
ff_opus_metadata_bsf
const FFBitStreamFilter ff_opus_metadata_bsf
Definition
opus_metadata.c:61
ff_bsf_get_packet_ref
int ff_bsf_get_packet_ref(AVBSFContext *ctx, AVPacket *pkt)
Called by bitstream filters to get packet for filtering.
Definition
bsf.c:254
bsf.h
bsf_internal.h
flags
#define flags(name, subs,...)
Definition
cbs_h264.c:74
s
#define s(width, name)
Definition
cbs_vp9.c:198
FLAGS
#define FLAGS
Definition
cmdutils.c:598
NULL
#define NULL
Definition
coverity.c:32
init
int(* init)(AVBSFContext *ctx)
Definition
dts2pts.c:608
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition
opt.h:258
AVCodecID
AVCodecID
Identify the syntax and semantics of the bitstream.
Definition
codec_id.h:47
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition
codec_id.h:48
AV_CODEC_ID_OPUS
@ AV_CODEC_ID_OPUS
Definition
codec_id.h:513
AVERROR_INVALIDDATA
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
Definition
error.h:61
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition
log.c:241
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition
version.h:85
intreadwrite.h
AV_WL16
#define AV_WL16(p, v)
Definition
intreadwrite.h:408
opt.h
AVOptions.
opus_metadata_options
static const AVOption opus_metadata_options[]
Definition
opus_metadata.c:43
OFFSET
#define OFFSET(x)
Definition
opus_metadata.c:41
opus_metadata_class
static const AVClass opus_metadata_class
Definition
opus_metadata.c:50
opus_metadata_init
static int opus_metadata_init(AVBSFContext *bsfc)
Definition
opus_metadata.c:29
AVBSFContext
The bitstream filter state.
Definition
bsf.h:68
AVBSFContext::priv_data
void * priv_data
Opaque filter-specific private data.
Definition
bsf.h:83
AVBSFContext::par_out
AVCodecParameters * par_out
Parameters of the output stream.
Definition
bsf.h:96
AVClass
Describe the class of an AVClass context structure.
Definition
log.h:76
AVCodecParameters::extradata_size
int extradata_size
Size of the extradata content in bytes.
Definition
codec_par.h:75
AVCodecParameters::extradata
uint8_t * extradata
Extra binary data needed for initializing the decoder, codec-dependent.
Definition
codec_par.h:71
AVOption
AVOption.
Definition
opt.h:428
FFBitStreamFilter
Definition
bsf_internal.h:29
OpusBSFContext
Definition
opus_metadata.c:24
OpusBSFContext::gain
int gain
Definition
opus_metadata.c:26
filter
void(* filter)(uint8_t *src, ptrdiff_t stride, int qscale)
Definition
h263dsp.c:29
Generated on Mon Aug 17 2026 20:20:52 for FFmpeg by
1.13.2