FFmpeg
|
#include <inttypes.h>
#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/crc.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "lossless_audiodsp.h"
#include "avcodec.h"
#include "bswapdsp.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "decode.h"
#include "get_bits.h"
#include "unary.h"
Go to the source code of this file.
Data Structures | |
struct | APEFilter |
Filters applied to the decoded data. More... | |
struct | APERice |
struct | APERangecoder |
struct | APEPredictor |
Filter histories. More... | |
struct | APEPredictor64 |
struct | APEContext |
Decoder context. More... | |
Macros | |
#define | MAX_CHANNELS 2 |
#define | MAX_BYTESPERSAMPLE 3 |
#define | APE_FRAMECODE_MONO_SILENCE 1 |
#define | APE_FRAMECODE_STEREO_SILENCE 3 |
#define | APE_FRAMECODE_PSEUDO_STEREO 4 |
#define | HISTORY_SIZE 512 |
#define | PREDICTOR_ORDER 8 |
#define | PREDICTOR_SIZE 50 |
Total size of all predictor histories. More... | |
#define | YDELAYA (18 + PREDICTOR_ORDER*4) |
#define | YDELAYB (18 + PREDICTOR_ORDER*3) |
#define | XDELAYA (18 + PREDICTOR_ORDER*2) |
#define | XDELAYB (18 + PREDICTOR_ORDER) |
#define | YADAPTCOEFFSA 18 |
#define | XADAPTCOEFFSA 14 |
#define | YADAPTCOEFFSB 10 |
#define | XADAPTCOEFFSB 5 |
#define | APE_FILTER_LEVELS 3 |
#define | OFFSET(x) offsetof(APEContext, x) |
#define | PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM) |
Enumerations | |
enum | APECompressionLevel { COMPRESSION_LEVEL_FAST = 1000, COMPRESSION_LEVEL_NORMAL = 2000, COMPRESSION_LEVEL_HIGH = 3000, COMPRESSION_LEVEL_EXTRA_HIGH = 4000, COMPRESSION_LEVEL_INSANE = 5000 } |
Possible compression levels. More... | |
Functions | |
static void | ape_apply_filters (APEContext *ctx, int32_t *decoded0, int32_t *decoded1, int count) |
static void | entropy_decode_mono_0000 (APEContext *ctx, int blockstodecode) |
static void | entropy_decode_stereo_0000 (APEContext *ctx, int blockstodecode) |
static void | entropy_decode_mono_3860 (APEContext *ctx, int blockstodecode) |
static void | entropy_decode_stereo_3860 (APEContext *ctx, int blockstodecode) |
static void | entropy_decode_mono_3900 (APEContext *ctx, int blockstodecode) |
static void | entropy_decode_stereo_3900 (APEContext *ctx, int blockstodecode) |
static void | entropy_decode_stereo_3930 (APEContext *ctx, int blockstodecode) |
static void | entropy_decode_mono_3990 (APEContext *ctx, int blockstodecode) |
static void | entropy_decode_stereo_3990 (APEContext *ctx, int blockstodecode) |
static void | predictor_decode_mono_3800 (APEContext *ctx, int count) |
static void | predictor_decode_stereo_3800 (APEContext *ctx, int count) |
static void | predictor_decode_mono_3930 (APEContext *ctx, int count) |
static void | predictor_decode_stereo_3930 (APEContext *ctx, int count) |
static void | predictor_decode_mono_3950 (APEContext *ctx, int count) |
static void | predictor_decode_stereo_3950 (APEContext *ctx, int count) |
static av_cold int | ape_decode_close (AVCodecContext *avctx) |
static av_cold int | ape_decode_init (AVCodecContext *avctx) |
static void | update_rice (APERice *rice, unsigned int x) |
static int | get_rice_ook (GetBitContext *gb, int k) |
static int | ape_decode_value_3860 (APEContext *ctx, GetBitContext *gb, APERice *rice) |
static int | ape_decode_value_3900 (APEContext *ctx, APERice *rice) |
static int | ape_decode_value_3990 (APEContext *ctx, APERice *rice) |
static int | get_k (int ksum) |
static void | decode_array_0000 (APEContext *ctx, GetBitContext *gb, int32_t *out, APERice *rice, int blockstodecode) |
static int | init_entropy_decoder (APEContext *ctx) |
static void | init_predictor_decoder (APEContext *ctx) |
static int | APESIGN (int32_t x) |
Get inverse sign of integer (-1 for positive, 1 for negative and 0 for zero) More... | |
static av_always_inline int | filter_fast_3320 (APEPredictor *p, const int decoded, const int filter, const int delayA) |
static av_always_inline int | filter_3800 (APEPredictor *p, const unsigned decoded, const int filter, const int delayA, const int delayB, const int start, const int shift) |
static void | long_filter_high_3800 (int32_t *buffer, int order, int shift, int length) |
static void | long_filter_ehigh_3830 (int32_t *buffer, int length) |
static av_always_inline int | predictor_update_3930 (APEPredictor *p, const int decoded, const int filter, const int delayA) |
static av_always_inline int | predictor_update_filter (APEPredictor64 *p, const int decoded, const int filter, const int delayA, const int delayB, const int adaptA, const int adaptB, int interim_mode) |
static void | do_init_filter (APEFilter *f, int16_t *buf, int order) |
static void | init_filter (APEContext *ctx, APEFilter *f, int16_t *buf, int order) |
static void | do_apply_filter (APEContext *ctx, int version, APEFilter *f, int32_t *data, int count, int order, int fracbits) |
static void | apply_filter (APEContext *ctx, APEFilter *f, int32_t *data0, int32_t *data1, int count, int order, int fracbits) |
static int | init_frame_decoder (APEContext *ctx) |
static void | ape_unpack_mono (APEContext *ctx, int count) |
static void | ape_unpack_stereo (APEContext *ctx, int count) |
static int | ape_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt) |
static void | ape_flush (AVCodecContext *avctx) |
Variables | |
static const uint16_t | ape_filter_orders [5][APE_FILTER_LEVELS] |
Filter orders depending on compression level. More... | |
static const uint8_t | ape_filter_fracbits [5][APE_FILTER_LEVELS] |
Filter fraction bits depending on compression level. More... | |
static const int32_t | initial_coeffs_fast_3320 [1] |
static const int32_t | initial_coeffs_a_3800 [3] |
static const int32_t | initial_coeffs_b_3800 [2] |
static const int32_t | initial_coeffs_3930 [4] |
static const int64_t | initial_coeffs_3930_64bit [4] |
static const AVOption | options [] |
static const AVClass | ape_decoder_class |
const FFCodec | ff_ape_decoder |
APE range decoding functions | |
#define | CODE_BITS 32 |
#define | TOP_VALUE ((unsigned int)1 << (CODE_BITS-1)) |
#define | SHIFT_BITS (CODE_BITS - 9) |
#define | EXTRA_BITS ((CODE_BITS-2) % 8 + 1) |
#define | BOTTOM_VALUE (TOP_VALUE >> 8) |
#define | MODEL_ELEMENTS 64 |
static const uint16_t | counts_3970 [22] |
Fixed probabilities for symbols in Monkey Audio version 3.97. More... | |
static const uint16_t | counts_diff_3970 [21] |
Probability ranges for symbols in Monkey Audio version 3.97. More... | |
static const uint16_t | counts_3980 [22] |
Fixed probabilities for symbols in Monkey Audio version 3.98. More... | |
static const uint16_t | counts_diff_3980 [21] |
Probability ranges for symbols in Monkey Audio version 3.98. More... | |
static void | range_start_decoding (APEContext *ctx) |
Start the decoder. More... | |
static void | range_dec_normalize (APEContext *ctx) |
Perform normalization. More... | |
static int | range_decode_culfreq (APEContext *ctx, int tot_f) |
Calculate cumulative frequency for next symbol. More... | |
static int | range_decode_culshift (APEContext *ctx, int shift) |
Decode value with given size in bits. More... | |
static void | range_decode_update (APEContext *ctx, int sy_f, int lt_f) |
Update decoding state. More... | |
static int | range_decode_bits (APEContext *ctx, int n) |
Decode n bits (n <= 16) without modelling. More... | |
static int | range_get_symbol (APEContext *ctx, const uint16_t counts[], const uint16_t counts_diff[]) |
Decode symbol. More... | |
Monkey's Audio lossless audio decoder
Definition in file apedec.c.
#define PREDICTOR_SIZE 50 |
#define YDELAYA (18 + PREDICTOR_ORDER*4) |
#define YDELAYB (18 + PREDICTOR_ORDER*3) |
#define XDELAYA (18 + PREDICTOR_ORDER*2) |
#define XDELAYB (18 + PREDICTOR_ORDER) |
#define OFFSET | ( | x | ) | offsetof(APEContext, x) |
#define PAR (AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM) |
enum APECompressionLevel |
|
static |
Definition at line 1453 of file apedec.c.
Referenced by predictor_decode_mono_3930(), predictor_decode_mono_3950(), predictor_decode_stereo_3930(), and predictor_decode_stereo_3950().
|
static |
Definition at line 676 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 682 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 690 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 698 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 710 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 718 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 734 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 745 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 753 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 1064 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 1009 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 1167 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 1139 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 1316 of file apedec.c.
Referenced by ape_decode_init().
|
static |
Definition at line 1244 of file apedec.c.
Referenced by ape_decode_init().
|
static |
|
static |
|
inlinestatic |
Start the decoder.
Definition at line 344 of file apedec.c.
Referenced by entropy_decode_stereo_3900(), and init_entropy_decoder().
|
inlinestatic |
Perform normalization.
Definition at line 352 of file apedec.c.
Referenced by entropy_decode_stereo_3900(), range_decode_culfreq(), and range_decode_culshift().
|
inlinestatic |
Calculate cumulative frequency for next symbol.
Does NO update!
ctx | decoder context |
tot_f | is the total frequency or (code_value)1<<shift |
Definition at line 373 of file apedec.c.
Referenced by ape_decode_value_3990().
|
inlinestatic |
Decode value with given size in bits.
ctx | decoder context |
shift | number of bits to decode |
Definition at line 385 of file apedec.c.
Referenced by range_decode_bits(), and range_get_symbol().
|
inlinestatic |
Update decoding state.
ctx | decoder context |
sy_f | the interval length (frequency of the symbol) |
lt_f | the lower end (frequency sum of < symbols) |
Definition at line 399 of file apedec.c.
Referenced by ape_decode_value_3990(), range_decode_bits(), and range_get_symbol().
|
inlinestatic |
Decode n bits (n <= 16) without modelling.
Definition at line 406 of file apedec.c.
Referenced by ape_decode_value_3900(), and ape_decode_value_3990().
|
inlinestatic |
Decode symbol.
ctx | decoder context |
counts | probability range start position |
counts_diff | probability range widths |
Definition at line 458 of file apedec.c.
Referenced by ape_decode_value_3900(), and ape_decode_value_3990().
|
inlinestatic |
Definition at line 482 of file apedec.c.
Referenced by ape_decode_value_3900(), and ape_decode_value_3990().
|
inlinestatic |
Definition at line 493 of file apedec.c.
Referenced by decode_array_0000().
|
inlinestatic |
Definition at line 505 of file apedec.c.
Referenced by entropy_decode_mono_3860(), and entropy_decode_stereo_3860().
|
inlinestatic |
Definition at line 538 of file apedec.c.
Referenced by entropy_decode_mono_3900(), entropy_decode_stereo_3900(), and entropy_decode_stereo_3930().
|
inlinestatic |
Definition at line 572 of file apedec.c.
Referenced by entropy_decode_mono_3990(), and entropy_decode_stereo_3990().
|
static |
Definition at line 613 of file apedec.c.
Referenced by decode_array_0000().
|
static |
Definition at line 618 of file apedec.c.
Referenced by entropy_decode_mono_0000(), and entropy_decode_stereo_0000().
|
static |
Definition at line 764 of file apedec.c.
Referenced by init_frame_decoder().
|
static |
Definition at line 822 of file apedec.c.
Referenced by init_frame_decoder().
|
inlinestatic |
Get inverse sign of integer (-1 for positive, 1 for negative and 0 for zero)
Definition at line 873 of file apedec.c.
Referenced by do_apply_filter(), filter_3800(), long_filter_ehigh_3830(), long_filter_high_3800(), predictor_decode_mono_3950(), predictor_update_3930(), and predictor_update_filter().
|
static |
Definition at line 877 of file apedec.c.
Referenced by predictor_decode_mono_3800(), and predictor_decode_stereo_3800().
|
static |
Definition at line 903 of file apedec.c.
Referenced by predictor_decode_mono_3800(), and predictor_decode_stereo_3800().
|
static |
Definition at line 948 of file apedec.c.
Referenced by predictor_decode_mono_3800(), and predictor_decode_stereo_3800().
|
static |
Definition at line 988 of file apedec.c.
Referenced by predictor_decode_mono_3800(), and predictor_decode_stereo_3800().
|
static |
Definition at line 1109 of file apedec.c.
Referenced by predictor_decode_mono_3930(), and predictor_decode_stereo_3930().
|
static |
Definition at line 1189 of file apedec.c.
Referenced by predictor_decode_stereo_3950().
|
static |
Definition at line 1364 of file apedec.c.
Referenced by init_filter().
|
static |
Definition at line 1376 of file apedec.c.
Referenced by init_frame_decoder().
|
static |
Definition at line 1382 of file apedec.c.
Referenced by apply_filter().
|
static |
Definition at line 1444 of file apedec.c.
Referenced by ape_apply_filters().
|
static |
Definition at line 1467 of file apedec.c.
Referenced by ape_decode_frame().
|
static |
Definition at line 1483 of file apedec.c.
Referenced by ape_decode_frame().
|
static |
Definition at line 1504 of file apedec.c.
Referenced by ape_decode_frame().
|
static |
|
static |
|
static |
Filter orders depending on compression level.
Definition at line 82 of file apedec.c.
Referenced by ape_apply_filters(), ape_decode_init(), and init_frame_decoder().
|
static |
Filter fraction bits depending on compression level.
Definition at line 91 of file apedec.c.
Referenced by ape_apply_filters().
|
static |
Fixed probabilities for symbols in Monkey Audio version 3.97.
Definition at line 419 of file apedec.c.
Referenced by ape_decode_value_3900().
|
static |
Probability ranges for symbols in Monkey Audio version 3.97.
Definition at line 428 of file apedec.c.
Referenced by ape_decode_value_3900().
|
static |
Fixed probabilities for symbols in Monkey Audio version 3.98.
Definition at line 437 of file apedec.c.
Referenced by ape_decode_value_3990().
|
static |
Probability ranges for symbols in Monkey Audio version 3.98.
Definition at line 446 of file apedec.c.
Referenced by ape_decode_value_3990().
|
static |
Definition at line 802 of file apedec.c.
Referenced by init_predictor_decoder().
|
static |
Definition at line 806 of file apedec.c.
Referenced by init_predictor_decoder().
|
static |
Definition at line 810 of file apedec.c.
Referenced by init_predictor_decoder().
|
static |
Definition at line 814 of file apedec.c.
Referenced by init_predictor_decoder().
|
static |
Definition at line 818 of file apedec.c.
Referenced by init_predictor_decoder().
|
static |
const FFCodec ff_ape_decoder |