FFmpeg
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
libavcodec
opusenc_psy.h
Go to the documentation of this file.
1
/*
2
* Opus encoder
3
* Copyright (c) 2017 Rostislav Pehlivanov <atomnuker@gmail.com>
4
*
5
* This file is part of FFmpeg.
6
*
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
11
*
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
16
*
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
*/
21
22
#ifndef AVCODEC_OPUSENC_PSY_H
23
#define AVCODEC_OPUSENC_PSY_H
24
25
#include "
libavutil/mem_internal.h
"
26
27
#include "
opusenc.h
"
28
#include "
opusenc_utils.h
"
29
#include "
libavfilter/window_func.h
"
30
31
/* Each step is 2.5ms */
32
typedef
struct
OpusPsyStep
{
33
int
index
;
/* Current index */
34
int
silence
;
35
float
energy
[
OPUS_MAX_CHANNELS
][
CELT_MAX_BANDS
];
/* Masking effects included */
36
float
tone
[
OPUS_MAX_CHANNELS
][
CELT_MAX_BANDS
];
/* Tonality */
37
float
stereo
[
CELT_MAX_BANDS
];
/* IS/MS compatibility */
38
float
change_amp
[
OPUS_MAX_CHANNELS
][
CELT_MAX_BANDS
];
/* Jump over last frame */
39
float
total_change
;
/* Total change */
40
41
float
*
bands
[
OPUS_MAX_CHANNELS
][
CELT_MAX_BANDS
];
42
float
coeffs
[
OPUS_MAX_CHANNELS
][
OPUS_BLOCK_SIZE
(
CELT_BLOCK_960
)];
43
}
OpusPsyStep
;
44
45
typedef
struct
OpusBandExcitation
{
46
float
excitation
;
47
float
excitation_dist
;
48
float
excitation_init
;
49
}
OpusBandExcitation
;
50
51
typedef
struct
PsyChain
{
52
int
start
;
53
int
end
;
54
}
PsyChain
;
55
56
typedef
struct
OpusPsyContext
{
57
AVCodecContext
*
avctx
;
58
AVFloatDSPContext
*
dsp
;
59
struct
FFBufQueue
*
bufqueue
;
60
OpusEncOptions
*
options
;
61
62
PsyChain
cs[128];
63
int
cs_num
;
64
65
OpusBandExcitation
ex[
OPUS_MAX_CHANNELS
][
CELT_MAX_BANDS
];
66
FFBesselFilter
bfilter_lo[
OPUS_MAX_CHANNELS
][
CELT_MAX_BANDS
];
67
FFBesselFilter
bfilter_hi[
OPUS_MAX_CHANNELS
][
CELT_MAX_BANDS
];
68
69
OpusPsyStep
*steps[
FF_BUFQUEUE_SIZE
+ 1];
70
int
max_steps
;
71
72
float
*
window
[
CELT_BLOCK_NB
];
73
MDCT15Context
*mdct[
CELT_BLOCK_NB
];
74
int
bsize_analysis
;
75
76
DECLARE_ALIGNED
(32,
float
, scratch)[2048];
77
78
/* Stats */
79
float
rc_waste
;
80
float
avg_is_band
;
81
int64_t
dual_stereo_used
;
82
int64_t
total_packets_out
;
83
84
/* State */
85
FFBesselFilter
lambda_lp
;
86
OpusPacketInfo
p
;
87
int
redo_analysis
;
88
int
buffered_steps
;
89
int
steps_to_process
;
90
int
eof
;
91
float
lambda
;
92
int
*
inflection_points
;
93
int
inflection_points_count
;
94
}
OpusPsyContext
;
95
96
int
ff_opus_psy_process
(
OpusPsyContext
*
s
,
OpusPacketInfo
*p);
97
void
ff_opus_psy_celt_frame_init
(
OpusPsyContext
*
s
,
CeltFrame
*
f
,
int
index
);
98
int
ff_opus_psy_celt_frame_process
(
OpusPsyContext
*
s
,
CeltFrame
*
f
,
int
index
);
99
void
ff_opus_psy_postencode_update
(
OpusPsyContext
*
s
,
CeltFrame
*
f
,
OpusRangeCoder
*rc);
100
101
int
ff_opus_psy_init
(
OpusPsyContext
*
s
,
AVCodecContext
*avctx,
102
struct
FFBufQueue
*bufqueue,
OpusEncOptions
*
options
);
103
void
ff_opus_psy_signal_eof
(
OpusPsyContext
*
s
);
104
int
ff_opus_psy_end
(
OpusPsyContext
*
s
);
105
106
#endif
/* AVCODEC_OPUSENC_PSY_H */
OpusPsyContext::avctx
AVCodecContext * avctx
Definition:
opusenc_psy.h:57
OpusPsyContext::total_packets_out
int64_t total_packets_out
Definition:
opusenc_psy.h:82
OpusPsyContext::bufqueue
struct FFBufQueue * bufqueue
Definition:
opusenc_psy.h:59
opusenc.h
OpusPsyContext::cs_num
int cs_num
Definition:
opusenc_psy.h:63
PsyChain::start
int start
Definition:
opusenc_psy.h:52
OpusPsyContext::buffered_steps
int buffered_steps
Definition:
opusenc_psy.h:88
ff_opus_psy_signal_eof
void ff_opus_psy_signal_eof(OpusPsyContext *s)
Definition:
opusenc_psy.c:588
FFBufQueue
Structure holding the queue.
Definition:
bufferqueue.h:49
OpusPsyStep::coeffs
float coeffs[OPUS_MAX_CHANNELS][OPUS_BLOCK_SIZE(CELT_BLOCK_960)]
Definition:
opusenc_psy.h:42
OpusBandExcitation::excitation
float excitation
Definition:
opusenc_psy.h:46
OpusPsyContext::options
OpusEncOptions * options
Definition:
opusenc_psy.h:60
OpusPsyStep::silence
int silence
Definition:
opusenc_psy.h:34
OpusPsyContext::inflection_points
int * inflection_points
Definition:
opusenc_psy.h:92
OpusBandExcitation::excitation_init
float excitation_init
Definition:
opusenc_psy.h:48
f
#define f(width, name)
Definition:
cbs_vp9.c:255
OpusPsyStep::stereo
float stereo[CELT_MAX_BANDS]
Definition:
opusenc_psy.h:37
ff_opus_psy_celt_frame_process
int ff_opus_psy_celt_frame_process(OpusPsyContext *s, CeltFrame *f, int index)
Definition:
opusenc_psy.c:455
PsyChain
Definition:
opusenc_psy.h:51
opusenc_utils.h
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition:
mem.h:117
ff_opus_psy_init
int ff_opus_psy_init(OpusPsyContext *s, AVCodecContext *avctx, struct FFBufQueue *bufqueue, OpusEncOptions *options)
Definition:
opusenc_psy.c:516
CELT_BLOCK_960
Definition:
opus_celt.h:61
OpusPacketInfo
Definition:
opusenc.h:48
ff_opus_psy_end
int ff_opus_psy_end(OpusPsyContext *s)
Definition:
opusenc_psy.c:593
OpusPsyContext::dsp
AVFloatDSPContext * dsp
Definition:
opusenc_psy.h:58
OPUS_BLOCK_SIZE
#define OPUS_BLOCK_SIZE(x)
Definition:
opusenc.h:39
FF_BUFQUEUE_SIZE
#define FF_BUFQUEUE_SIZE
Definition:
audiotoolboxenc.c:25
OpusPsyStep::total_change
float total_change
Definition:
opusenc_psy.h:39
OpusPsyContext::eof
int eof
Definition:
opusenc_psy.h:90
OpusPsyContext
Definition:
opusenc_psy.h:56
OpusPsyContext::redo_analysis
int redo_analysis
Definition:
opusenc_psy.h:87
OpusPsyContext::rc_waste
float rc_waste
Definition:
opusenc_psy.h:79
OpusPsyStep::bands
float * bands[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition:
opusenc_psy.h:41
window
static SDL_Window * window
Definition:
ffplay.c:368
OpusPsyContext::lambda_lp
FFBesselFilter lambda_lp
Definition:
opusenc_psy.h:85
OpusPsyStep::tone
float tone[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition:
opusenc_psy.h:36
OpusPsyStep::change_amp
float change_amp[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition:
opusenc_psy.h:38
OpusPsyContext::lambda
float lambda
Definition:
opusenc_psy.h:91
OpusPsyContext::avg_is_band
float avg_is_band
Definition:
opusenc_psy.h:80
s
#define s(width, name)
Definition:
cbs_vp9.c:257
OpusPsyContext::inflection_points_count
int inflection_points_count
Definition:
opusenc_psy.h:93
AVFloatDSPContext
Definition:
float_dsp.h:24
OpusRangeCoder
Definition:
opus_rc.h:40
FFBesselFilter
Definition:
opusenc_utils.h:27
CELT_MAX_BANDS
#define CELT_MAX_BANDS
Definition:
opus.h:46
AVCodecContext
main external API structure.
Definition:
avcodec.h:531
PsyChain::end
int end
Definition:
opusenc_psy.h:53
OpusPsyContext::dual_stereo_used
int64_t dual_stereo_used
Definition:
opusenc_psy.h:81
OpusPsyContext::p
OpusPacketInfo p
Definition:
opusenc_psy.h:86
CELT_BLOCK_NB
Definition:
opus_celt.h:63
OPUS_MAX_CHANNELS
#define OPUS_MAX_CHANNELS
Definition:
opusenc.h:34
OpusPsyContext::max_steps
int max_steps
Definition:
opusenc_psy.h:70
ff_opus_psy_postencode_update
void ff_opus_psy_postencode_update(OpusPsyContext *s, CeltFrame *f, OpusRangeCoder *rc)
Definition:
opusenc_psy.c:479
options
const OptionDef options[]
Definition:
ffmpeg_opt.c:3407
OpusPsyStep::index
int index
Definition:
opusenc_psy.h:33
CeltFrame
Definition:
opus_celt.h:93
OpusBandExcitation::excitation_dist
float excitation_dist
Definition:
opusenc_psy.h:47
MDCT15Context
Definition:
mdct15.h:30
ff_opus_psy_celt_frame_init
void ff_opus_psy_celt_frame_init(OpusPsyContext *s, CeltFrame *f, int index)
Definition:
opusenc_psy.c:254
window_func.h
OpusPsyStep::energy
float energy[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition:
opusenc_psy.h:35
ff_opus_psy_process
int ff_opus_psy_process(OpusPsyContext *s, OpusPacketInfo *p)
Definition:
opusenc_psy.c:223
OpusEncOptions
Definition:
opusenc.h:43
mem_internal.h
OpusPsyStep
Definition:
opusenc_psy.h:32
OpusBandExcitation
Definition:
opusenc_psy.h:45
OpusPsyContext::bsize_analysis
int bsize_analysis
Definition:
opusenc_psy.h:74
OpusPsyContext::steps_to_process
int steps_to_process
Definition:
opusenc_psy.h:89
Generated on Sat Jan 23 2021 19:22:34 for FFmpeg by
1.8.11