Commit Graph

16 Commits

Author SHA1 Message Date
Andreas Rheinhardt c095358289 avcodec/opus: Move defines to better places
Move ROUND_MUL* macros to their only users and the Celt
macros to opus_celt.h. Also improve the other headers
a bit while at it.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:15:43 +02:00
Andreas Rheinhardt 81b927a53b avcodec/opus: Move remaining celt declarations to opus_celt.h
Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:15:04 +02:00
Andreas Rheinhardt 542c334eb5 avcodec/opus_celt, opus_pvq: Move CeltPVQ typedef to opus_pvq.h
It is more natural that way.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:08:39 +02:00
Andreas Rheinhardt a622f4451f avcodec/opus_celt: Break cyclic inlusion of opus_celt.h<->opus_pvq.h
Simply don't include opus_pvq.h in opus_celt.h: The latter only
uses pointers to CeltPVQ.

Reviewed-by: Lynne <dev@lynne.ee>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
2022-10-05 02:08:16 +02:00
Lynne 543a46b4b2
opus: convert encoder and decoder to lavu/tx
This commit changes both the encoder and decoder to use the new lavu/tx code,
which has faster C transforms and more assembly optimizations.
2022-09-26 20:26:54 +02:00
Anton Khirnov e15371061d lavu/mem: move the DECLARE_ALIGNED macro family to mem_internal on next+1 bump
They are not properly namespaced and not intended for public use.
2021-01-01 14:14:57 +01:00
Lynne 0cea3ca894 opusdsp: create and move deemphasis and postfiltering from opus_celt 2019-04-01 00:19:14 +02:00
Rostislav Pehlivanov 1b8649c2ce opus: add an option to toggle intensity stereo phase inversion
Due to a somewhat high volume of complains, phase inversion has
been made optional with RFC8251. This allows for better bass
frequency response when partially downmixing to play on systems
with an LFE speaker.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-12-04 07:28:45 +00:00
Rostislav Pehlivanov 2ad1768c7b opusenc: implement a psychoacoustic system
This commit implements a psychoacoustic system for the native Opus
encoder. Its unlike any other psychoacoustic system known since its
capable of using a lookahead to make better choices on how to treat the
current frame and how many bits to allocate for it (and future frames).

Also, whilst the main bulk of the analysis function has to run in a
single thread, the per-frame anaylsis functions does not modify the main
psychoacoustic context, so in the future it will be fairly trivial to
run those as slice threads.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-09-23 08:27:44 +01:00
Rostislav Pehlivanov 035c755b4e opusenc: use float_dsp for transient mdcts
vector_fmul_reverse requires padding the window at the front

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-07-13 19:53:52 +01:00
Rostislav Pehlivanov 8e7e74df93 opus_pvq: port to allow for SIMD functions
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-05-16 11:22:07 +01:00
Rostislav Pehlivanov d0a3143193 opusenc: switch between intra/inter mode for coarse energy
Saves around 5kbps.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-04-08 00:54:56 +01:00
Rostislav Pehlivanov 63744d8afd opusenc: remove unused header entries and simplify normalization
Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-04-08 00:27:33 +01:00
Rostislav Pehlivanov 5f47c85e5c opus: add a native Opus encoder
This marks the first time anyone has written an Opus encoder without
using any libopus code. The aim of the encoder is to prove how far
the format can go by writing the craziest encoder for it.

Right now the encoder's basic, it only supports CBR encoding, however
internally every single feature the CELT layer has is implemented
(except the pitch pre-filter which needs to work well with the rest of
whatever gets implemented). Psychoacoustic and rate control systems are
under development.

The encoder takes in frames of 120 samples and depending on the value of
opus_delay the plan is to use the extra buffered frames as lookahead.
Right now the encoder will pick the nearest largest legal frame size and
won't use the lookahead, but that'll change once there's a
psychoacoustic system.

Even though its a pretty basic encoder its already outperforming
any other native encoder FFmpeg has by a huge amount.

The PVQ search algorithm is faster and more accurate than libopus's
algorithm so the encoder's performance is close to that of libopus
at zero complexity (libopus has more SIMD).
The algorithm might be ported to libopus or other codecs using PVQ in
the future.

The encoder still has a few minor bugs, like desyncs at ultra low
bitrates (below 9kbps with 20ms frames).

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-02-14 06:15:36 +00:00
Rostislav Pehlivanov 07b78340dd opus_celt: rename structures to better names and reorganize them
This is meant to be applied on top of my previous patch which
split PVQ into celt_pvq.c and made opus_celt.h

Essentially nothing has been changed other than renaming CeltFrame
to CeltBlock (CeltFrame had absolutely nothing at all to do with
a frame) and CeltContext to CeltFrame.
3 variables have been put in CeltFrame as they make more sense
there rather than being passed around as arguments.
The coefficients have been moved to the CeltBlock structure
(why the hell were they in CeltContext and not in CeltFrame??).

Now the encoder would be able to use the exact context the decoder
uses (plus a couple of extra fields in there).

FATE passes, no slowdowns, etc.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-02-14 06:15:36 +00:00
Rostislav Pehlivanov e538108c21 opus_celt: move quantization and band decoding to opus_pvq.c
A huge amount can be reused by the encoder, as the only thing
which needs to be done would be to add a 10 line celt_icwrsi,
a wrapper around it (celt_alg_quant) and templating the
ff_celt_decode_band to replace entropy decoding functions
with entropy encoding.

There is no performance loss but in fact a performance gain of
around 6% which is caused by the compiler being able to optimize
the decoding more efficiently.

Signed-off-by: Rostislav Pehlivanov <atomnuker@gmail.com>
2017-02-14 06:15:36 +00:00