FFmpeg
enc_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_OPUS_ENC_PSY_H
23 #define AVCODEC_OPUS_ENC_PSY_H
24 
25 #include "libavutil/tx.h"
26 #include "libavutil/mem_internal.h"
27 
28 #include "enc.h"
29 #include "celt.h"
30 #include "enc_utils.h"
31 
32 /* Each step is 2.5ms */
33 typedef struct OpusPsyStep {
34  int index; /* Current index */
35  int silence;
36  float energy[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]; /* Masking effects included */
37  float tone[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]; /* Tonality */
38  float stereo[CELT_MAX_BANDS]; /* IS/MS compatibility */
39  float change_amp[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]; /* Jump over last frame */
40  float total_change; /* Total change */
41 
44 } OpusPsyStep;
45 
46 typedef struct OpusBandExcitation {
47  float excitation;
51 
52 typedef struct OpusPsyContext {
57 
61 
63  int max_steps;
64 
69 
70  DECLARE_ALIGNED(32, float, scratch)[2048];
71 
72  /* Stats */
73  float avg_is_band;
76 
77  /* State */
81  int eof;
82  float lambda;
86 
91 
93  struct FFBufQueue *bufqueue, OpusEncOptions *options);
96 
97 #endif /* AVCODEC_OPUS_ENC_PSY_H */
ff_opus_psy_end
int ff_opus_psy_end(OpusPsyContext *s)
Definition: enc_psy.c:595
OpusPsyStep::stereo
float stereo[CELT_MAX_BANDS]
Definition: enc_psy.h:38
CELT_MAX_BANDS
#define CELT_MAX_BANDS
Definition: celt.h:43
mem_internal.h
OpusPsyContext::buffered_steps
int buffered_steps
Definition: enc_psy.h:79
OpusBandExcitation::excitation
float excitation
Definition: enc_psy.h:47
AVTXContext
Definition: tx_priv.h:235
OpusPsyContext::bsize_analysis
int bsize_analysis
Definition: enc_psy.h:68
OpusPsyContext::mdct
AVTXContext * mdct[CELT_BLOCK_NB]
Definition: enc_psy.h:66
int64_t
long long int64_t
Definition: coverity.c:34
ff_opus_psy_postencode_update
void ff_opus_psy_postencode_update(OpusPsyContext *s, CeltFrame *f)
Definition: enc_psy.c:480
CELT_BLOCK_NB
@ CELT_BLOCK_NB
Definition: celt.h:68
OpusBandExcitation::excitation_init
float excitation_init
Definition: enc_psy.h:49
FF_BUFQUEUE_SIZE
#define FF_BUFQUEUE_SIZE
Definition: audiotoolboxenc.c:25
OpusPsyStep::silence
int silence
Definition: enc_psy.h:35
OpusPsyStep::coeffs
float coeffs[OPUS_MAX_CHANNELS][OPUS_BLOCK_SIZE(CELT_BLOCK_960)]
Definition: enc_psy.h:43
OpusPsyContext::steps
OpusPsyStep * steps[FF_BUFQUEUE_SIZE+1]
Definition: enc_psy.h:62
OpusPsyContext::lambda
float lambda
Definition: enc_psy.h:82
OpusPsyContext::bfilter_lo
FFBesselFilter bfilter_lo[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: enc_psy.h:59
OpusPsyContext::avctx
AVCodecContext * avctx
Definition: enc_psy.h:53
OpusPsyStep::change_amp
float change_amp[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: enc_psy.h:39
enc_utils.h
OpusPsyContext::ex
OpusBandExcitation ex[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: enc_psy.h:58
av_tx_fn
void(* av_tx_fn)(AVTXContext *s, void *out, void *in, ptrdiff_t stride)
Function pointer to a function to perform the transform.
Definition: tx.h:151
OpusPsyContext::steps_to_process
int steps_to_process
Definition: enc_psy.h:80
OpusPsyStep
Definition: enc_psy.h:33
s
#define s(width, name)
Definition: cbs_vp9.c:198
ff_opus_psy_celt_frame_init
void ff_opus_psy_celt_frame_init(OpusPsyContext *s, CeltFrame *f, int index)
Definition: enc_psy.c:258
OPUS_BLOCK_SIZE
#define OPUS_BLOCK_SIZE(x)
Definition: enc.h:39
OpusPsyContext
Definition: enc_psy.h:52
OpusBandExcitation::excitation_dist
float excitation_dist
Definition: enc_psy.h:48
OpusPacketInfo
Definition: enc.h:48
CELT_BLOCK_960
@ CELT_BLOCK_960
Definition: celt.h:66
OpusPsyStep::total_change
float total_change
Definition: enc_psy.h:40
OpusPsyContext::dual_stereo_used
int64_t dual_stereo_used
Definition: enc_psy.h:74
options
Definition: swscale.c:42
OpusPsyContext::inflection_points
int * inflection_points
Definition: enc_psy.h:83
ff_opus_psy_init
int ff_opus_psy_init(OpusPsyContext *s, AVCodecContext *avctx, struct FFBufQueue *bufqueue, OpusEncOptions *options)
Definition: enc_psy.c:516
ff_opus_psy_signal_eof
void ff_opus_psy_signal_eof(OpusPsyContext *s)
Definition: enc_psy.c:590
index
int index
Definition: gxfenc.c:90
OpusPsyContext::max_steps
int max_steps
Definition: enc_psy.h:63
OpusPsyStep::bands
float * bands[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: enc_psy.h:42
OpusPsyStep::index
int index
Definition: enc_psy.h:34
f
f
Definition: af_crystalizer.c:122
enc.h
DECLARE_ALIGNED
#define DECLARE_ALIGNED(n, t, v)
Definition: mem_internal.h:104
OpusPsyContext::dsp
AVFloatDSPContext * dsp
Definition: enc_psy.h:54
OpusPsyStep::tone
float tone[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: enc_psy.h:37
AVFloatDSPContext
Definition: float_dsp.h:24
OpusPsyContext::eof
int eof
Definition: enc_psy.h:81
OpusPsyContext::avg_is_band
float avg_is_band
Definition: enc_psy.h:73
FFBufQueue
Structure holding the queue.
Definition: bufferqueue.h:49
OpusPsyStep::energy
float energy[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: enc_psy.h:36
celt.h
ff_opus_psy_process
int ff_opus_psy_process(OpusPsyContext *s, OpusPacketInfo *p)
Definition: enc_psy.c:227
FFBesselFilter
Definition: enc_utils.h:30
OpusPsyContext::inflection_points_count
int inflection_points_count
Definition: enc_psy.h:84
OpusPsyContext::bfilter_hi
FFBesselFilter bfilter_hi[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: enc_psy.h:60
OpusPsyContext::total_packets_out
int64_t total_packets_out
Definition: enc_psy.h:75
AVCodecContext
main external API structure.
Definition: avcodec.h:451
OpusPsyContext::mdct_fn
av_tx_fn mdct_fn[CELT_BLOCK_NB]
Definition: enc_psy.h:67
OpusPsyContext::p
OpusPacketInfo p
Definition: enc_psy.h:78
OpusBandExcitation
Definition: enc_psy.h:46
OPUS_MAX_CHANNELS
#define OPUS_MAX_CHANNELS
Definition: enc.h:34
ff_opus_psy_celt_frame_process
int ff_opus_psy_celt_frame_process(OpusPsyContext *s, CeltFrame *f, int index)
Definition: enc_psy.c:459
OpusPsyContext::options
OpusEncOptions * options
Definition: enc_psy.h:56
OpusEncOptions
Definition: enc.h:43
OpusPsyContext::bufqueue
struct FFBufQueue * bufqueue
Definition: enc_psy.h:55
OpusPsyContext::scratch
float scratch[2048]
Definition: enc_psy.h:70
OpusPsyContext::window
float * window[CELT_BLOCK_NB]
Definition: enc_psy.h:65
tx.h
CeltFrame
Definition: celt.h:98