FFmpeg  4.0
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 "opusenc.h"
26 #include "opusenc_utils.h"
28 
29 /* Each step is 2.5ms */
30 typedef struct OpusPsyStep {
31  int index; /* Current index */
32  int silence;
33  float energy[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]; /* Masking effects included */
34  float tone[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]; /* Tonality */
35  float stereo[CELT_MAX_BANDS]; /* IS/MS compatibility */
36  float change_amp[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]; /* Jump over last frame */
37  float total_change; /* Total change */
38 
41 } OpusPsyStep;
42 
43 typedef struct OpusBandExcitation {
44  float excitation;
48 
49 typedef struct PsyChain {
50  int start;
51  int end;
52 } PsyChain;
53 
54 typedef struct OpusPsyContext {
59 
60  PsyChain cs[128];
61  int cs_num;
62 
66 
68  int max_steps;
69 
73 
74  DECLARE_ALIGNED(32, float, scratch)[2048];
75 
76  /* Stats */
77  float rc_waste;
78  float avg_is_band;
81 
82  /* State */
88  int eof;
89  float lambda;
93 
98 
100  struct FFBufQueue *bufqueue, OpusEncOptions *options);
103 
104 #endif /* AVCODEC_OPUSENC_PSY_H */
AVCodecContext * avctx
Definition: opusenc_psy.h:55
int64_t total_packets_out
Definition: opusenc_psy.h:80
const char * s
Definition: avisynth_c.h:768
struct FFBufQueue * bufqueue
Definition: opusenc_psy.h:57
int start
Definition: opusenc_psy.h:50
void ff_opus_psy_signal_eof(OpusPsyContext *s)
Definition: opusenc_psy.c:588
Structure holding the queue.
Definition: bufferqueue.h:49
float coeffs[OPUS_MAX_CHANNELS][OPUS_BLOCK_SIZE(CELT_BLOCK_960)]
Definition: opusenc_psy.h:40
OpusEncOptions * options
Definition: opusenc_psy.h:58
int * inflection_points
Definition: opusenc_psy.h:90
float stereo[CELT_MAX_BANDS]
Definition: opusenc_psy.h:35
int ff_opus_psy_celt_frame_process(OpusPsyContext *s, CeltFrame *f, int index)
Definition: opusenc_psy.c:455
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
Definition: mem.h:112
int ff_opus_psy_init(OpusPsyContext *s, AVCodecContext *avctx, struct FFBufQueue *bufqueue, OpusEncOptions *options)
Definition: opusenc_psy.c:516
int ff_opus_psy_end(OpusPsyContext *s)
Definition: opusenc_psy.c:593
AVFloatDSPContext * dsp
Definition: opusenc_psy.h:56
#define OPUS_BLOCK_SIZE(x)
Definition: opusenc.h:39
#define FF_BUFQUEUE_SIZE
float total_change
Definition: opusenc_psy.h:37
float * bands[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: opusenc_psy.h:39
static SDL_Window * window
Definition: ffplay.c:362
FFBesselFilter lambda_lp
Definition: opusenc_psy.h:83
float tone[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: opusenc_psy.h:34
float change_amp[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: opusenc_psy.h:36
float avg_is_band
Definition: opusenc_psy.h:78
int inflection_points_count
Definition: opusenc_psy.h:91
#define CELT_MAX_BANDS
Definition: opus.h:45
main external API structure.
Definition: avcodec.h:1518
int64_t dual_stereo_used
Definition: opusenc_psy.h:79
OpusPacketInfo p
Definition: opusenc_psy.h:84
#define OPUS_MAX_CHANNELS
Definition: opusenc.h:34
void ff_opus_psy_postencode_update(OpusPsyContext *s, CeltFrame *f, OpusRangeCoder *rc)
Definition: opusenc_psy.c:479
const OptionDef options[]
Definition: ffmpeg_opt.c:3292
void ff_opus_psy_celt_frame_init(OpusPsyContext *s, CeltFrame *f, int index)
Definition: opusenc_psy.c:254
float energy[OPUS_MAX_CHANNELS][CELT_MAX_BANDS]
Definition: opusenc_psy.h:33
int ff_opus_psy_process(OpusPsyContext *s, OpusPacketInfo *p)
Definition: opusenc_psy.c:223
int steps_to_process
Definition: opusenc_psy.h:87