Commit 755e6183 authored by Rostislav Pehlivanov's avatar Rostislav Pehlivanov

lavc: implement an ATRAC9 decoder

This commit implements a full ATRAC9 decoder, a simple low-delay codec
developed by Sony and used in most PSVita games, some PS3 games and some
PS4 games. Its similar to AAC in that it uses Huffman coded scalefactors
but instead of vector quantization it just Huffman codes the spectral
coefficients (in a way similar to how Opus splits band energy coding
into coarse and fine precision). It opts to write rather large Huffman
codes by packing several small coefficients into one Huffman coded
symbol, though I don't believe this increases efficiency at all.
Band extension implements SBC in a simple way, first it mirrors the
lower spectrum onto the higher frequencies and then it uses one of 5
filters to shape it. Noise substitution is implemented via 2 of them.
Unlike previous ATRAC codecs, there's no QMF, this is a standard MDCT
codec.

Based off of the reverse engineering work of Alex Barney.
Signed-off-by: 's avatarRostislav Pehlivanov <atomnuker@gmail.com>
parent 3c4af577
...@@ -13,6 +13,7 @@ version <next>: ...@@ -13,6 +13,7 @@ version <next>:
- adeclip filter - adeclip filter
- libtensorflow backend for DNN based filters like srcnn - libtensorflow backend for DNN based filters like srcnn
- vc1 decoder is now bit-exact - vc1 decoder is now bit-exact
- ATRAC9 decoder
version 4.0: version 4.0:
......
...@@ -2565,6 +2565,7 @@ asv2_encoder_select="bswapdsp fdctdsp pixblockdsp" ...@@ -2565,6 +2565,7 @@ asv2_encoder_select="bswapdsp fdctdsp pixblockdsp"
atrac1_decoder_select="mdct sinewin" atrac1_decoder_select="mdct sinewin"
atrac3_decoder_select="mdct" atrac3_decoder_select="mdct"
atrac3p_decoder_select="mdct sinewin" atrac3p_decoder_select="mdct sinewin"
atrac9_decoder_select="mdct"
avrn_decoder_select="exif jpegtables" avrn_decoder_select="exif jpegtables"
bink_decoder_select="blockdsp hpeldsp" bink_decoder_select="blockdsp hpeldsp"
binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs" binkaudio_dct_decoder_select="mdct rdft dct sinewin wma_freqs"
......
...@@ -210,6 +210,7 @@ OBJS-$(CONFIG_ATRAC3P_DECODER) += atrac3plusdec.o atrac3plus.o \ ...@@ -210,6 +210,7 @@ OBJS-$(CONFIG_ATRAC3P_DECODER) += atrac3plusdec.o atrac3plus.o \
atrac3plusdsp.o atrac.o atrac3plusdsp.o atrac.o
OBJS-$(CONFIG_ATRAC3PAL_DECODER) += atrac3plusdec.o atrac3plus.o \ OBJS-$(CONFIG_ATRAC3PAL_DECODER) += atrac3plusdec.o atrac3plus.o \
atrac3plusdsp.o atrac.o atrac3plusdsp.o atrac.o
OBJS-$(CONFIG_ATRAC9_DECODER) += atrac9dec.o
OBJS-$(CONFIG_AURA_DECODER) += cyuv.o OBJS-$(CONFIG_AURA_DECODER) += cyuv.o
OBJS-$(CONFIG_AURA2_DECODER) += aura.o OBJS-$(CONFIG_AURA2_DECODER) += aura.o
OBJS-$(CONFIG_AVRN_DECODER) += avrndec.o mjpegdec.o OBJS-$(CONFIG_AVRN_DECODER) += avrndec.o mjpegdec.o
......
...@@ -392,6 +392,7 @@ extern AVCodec ff_atrac3_decoder; ...@@ -392,6 +392,7 @@ extern AVCodec ff_atrac3_decoder;
extern AVCodec ff_atrac3al_decoder; extern AVCodec ff_atrac3al_decoder;
extern AVCodec ff_atrac3p_decoder; extern AVCodec ff_atrac3p_decoder;
extern AVCodec ff_atrac3pal_decoder; extern AVCodec ff_atrac3pal_decoder;
extern AVCodec ff_atrac9_decoder;
extern AVCodec ff_binkaudio_dct_decoder; extern AVCodec ff_binkaudio_dct_decoder;
extern AVCodec ff_binkaudio_rdft_decoder; extern AVCodec ff_binkaudio_rdft_decoder;
extern AVCodec ff_bmv_audio_decoder; extern AVCodec ff_bmv_audio_decoder;
......
This diff is collapsed.
This diff is collapsed.
...@@ -637,6 +637,7 @@ enum AVCodecID { ...@@ -637,6 +637,7 @@ enum AVCodecID {
AV_CODEC_ID_APTX, AV_CODEC_ID_APTX,
AV_CODEC_ID_APTX_HD, AV_CODEC_ID_APTX_HD,
AV_CODEC_ID_SBC, AV_CODEC_ID_SBC,
AV_CODEC_ID_ATRAC9,
/* subtitle codecs */ /* subtitle codecs */
AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs. AV_CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
......
...@@ -2878,6 +2878,13 @@ static const AVCodecDescriptor codec_descriptors[] = { ...@@ -2878,6 +2878,13 @@ static const AVCodecDescriptor codec_descriptors[] = {
.long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"), .long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"),
.props = AV_CODEC_PROP_LOSSY, .props = AV_CODEC_PROP_LOSSY,
}, },
{
.id = AV_CODEC_ID_ATRAC9,
.type = AVMEDIA_TYPE_AUDIO,
.name = "atrac9",
.long_name = NULL_IF_CONFIG_SMALL("ATRAC9 (Adaptive TRansform Acoustic Coding 9)"),
.props = AV_CODEC_PROP_LOSSY,
},
/* subtitle codecs */ /* subtitle codecs */
{ {
......
...@@ -1536,6 +1536,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba, ...@@ -1536,6 +1536,7 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
case AV_CODEC_ID_GSM_MS: return 320; case AV_CODEC_ID_GSM_MS: return 320;
case AV_CODEC_ID_MP1: return 384; case AV_CODEC_ID_MP1: return 384;
case AV_CODEC_ID_ATRAC1: return 512; case AV_CODEC_ID_ATRAC1: return 512;
case AV_CODEC_ID_ATRAC9:
case AV_CODEC_ID_ATRAC3: return 1024 * framecount; case AV_CODEC_ID_ATRAC3: return 1024 * framecount;
case AV_CODEC_ID_ATRAC3P: return 2048; case AV_CODEC_ID_ATRAC3P: return 2048;
case AV_CODEC_ID_MP2: case AV_CODEC_ID_MP2:
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
#include "libavutil/version.h" #include "libavutil/version.h"
#define LIBAVCODEC_VERSION_MAJOR 58 #define LIBAVCODEC_VERSION_MAJOR 58
#define LIBAVCODEC_VERSION_MINOR 20 #define LIBAVCODEC_VERSION_MINOR 21
#define LIBAVCODEC_VERSION_MICRO 104 #define LIBAVCODEC_VERSION_MICRO 104
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment