FFmpeg
Loading...
Searching...
No Matches
wavpack.c File Reference

WavPack lossless audio decoder. More...

#include "libavutil/channel_layout.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "bytestream.h"
#include "codec_internal.h"
#include "get_bits.h"
#include "libavutil/refstruct.h"
#include "thread.h"
#include "threadprogress.h"
#include "unary.h"
#include "wavpack.h"
#include "dsd.h"

Go to the source code of this file.

Data Structures

struct  WavpackFrameContext
 
struct  WavpackContext
 
struct  DSDfilters
 

Macros

#define BITSTREAM_READER_LE
 
#define DSD_BYTE_READY(low, high)
 
#define PTABLE_BITS   8
 
#define PTABLE_BINS   (1<<PTABLE_BITS)
 
#define PTABLE_MASK   (PTABLE_BINS-1)
 
#define UP   0x010000fe
 
#define DOWN   0x00010000
 
#define DECAY   8
 
#define PRECISION   20
 
#define VALUE_ONE   (1 << PRECISION)
 
#define PRECISION_USE   12
 
#define RATE_S   20
 
#define MAX_HISTORY_BITS   5
 
#define MAX_HISTORY_BINS   (1 << MAX_HISTORY_BITS)
 
#define MAX_BIN_BYTES   1280
 
#define LEVEL_DECAY(a)
 

Enumerations

enum  Modulation { MODULATION_PCM , MODULATION_DSD }
 

Functions

static av_always_inline unsigned get_tail (GetBitContext *gb, unsigned k)
 
static int update_error_limit (WavpackFrameContext *ctx)
 
static int wv_get_value (WavpackFrameContext *ctx, GetBitContext *gb, int channel, int *last)
 
static int wv_get_value_integer (WavpackFrameContext *s, uint32_t *crc, unsigned S)
 
static float wv_get_value_float (WavpackFrameContext *s, uint32_t *crc, int S)
 
static int wv_check_crc (WavpackFrameContext *s, uint32_t crc, uint32_t crc_extra_bits)
 
static void init_ptable (int *table, int rate_i, int rate_s)
 
static int wv_unpack_dsd_high (WavpackFrameContext *s, uint8_t *dst_left, uint8_t *dst_right)
 
static int wv_unpack_dsd_fast (WavpackFrameContext *s, uint8_t *dst_left, uint8_t *dst_right)
 
static int wv_unpack_dsd_copy (WavpackFrameContext *s, uint8_t *dst_left, uint8_t *dst_right)
 
static int wv_unpack_stereo (WavpackFrameContext *s, GetBitContext *gb, void *dst_l, void *dst_r, const int type)
 
static int wv_unpack_mono (WavpackFrameContext *s, GetBitContext *gb, void *dst, const int type)
 
static av_cold int wv_alloc_frame_context (WavpackContext *c)
 
static int wv_dsd_reset (WavpackContext *s, int channels)
 
static av_cold int wavpack_decode_init (AVCodecContext *avctx)
 
static av_cold int wavpack_decode_end (AVCodecContext *avctx)
 
static int wavpack_decode_block (AVCodecContext *avctx, AVFrame *frame, int block_no, const uint8_t *buf, int buf_size, int *new_progress)
 
static av_cold void wavpack_decode_flush (AVCodecContext *avctx)
 
static int dsd_channel (AVCodecContext *avctx, void *frmptr, int jobnr, int threadnr)
 
static int wavpack_decode_frame (AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
 

Variables

const FFCodec ff_wavpack_decoder
 

Detailed Description

WavPack lossless audio decoder.

Definition in file wavpack.c.

Macro Definition Documentation

◆ BITSTREAM_READER_LE

#define BITSTREAM_READER_LE

Definition at line 26 of file wavpack.c.

◆ DSD_BYTE_READY

#define DSD_BYTE_READY ( low,
high )
Value:
(!(((low) ^ (high)) & 0xff000000))
int high
Definition dovi_rpuenc.c:39

Definition at line 43 of file wavpack.c.

Referenced by wv_unpack_dsd_fast(), and wv_unpack_dsd_high().

◆ PTABLE_BITS

#define PTABLE_BITS   8

Definition at line 45 of file wavpack.c.

◆ PTABLE_BINS

#define PTABLE_BINS   (1<<PTABLE_BITS)

Definition at line 46 of file wavpack.c.

Referenced by init_ptable().

◆ PTABLE_MASK

#define PTABLE_MASK   (PTABLE_BINS-1)

Definition at line 47 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

◆ UP

#define UP   0x010000fe

Definition at line 49 of file wavpack.c.

◆ DOWN

#define DOWN   0x00010000

Definition at line 50 of file wavpack.c.

◆ DECAY

#define DECAY   8

Definition at line 51 of file wavpack.c.

Referenced by init_ptable(), and wv_unpack_dsd_high().

◆ PRECISION

#define PRECISION   20

Definition at line 53 of file wavpack.c.

Referenced by av_dict_set_fxp(), filter(), init(), and wv_unpack_dsd_high().

◆ VALUE_ONE

#define VALUE_ONE   (1 << PRECISION)

Definition at line 54 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

◆ PRECISION_USE

#define PRECISION_USE   12

Definition at line 55 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

◆ RATE_S

#define RATE_S   20

Definition at line 57 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

◆ MAX_HISTORY_BITS

#define MAX_HISTORY_BITS   5

Definition at line 59 of file wavpack.c.

Referenced by wv_unpack_dsd_fast().

◆ MAX_HISTORY_BINS

#define MAX_HISTORY_BINS   (1 << MAX_HISTORY_BITS)

Definition at line 60 of file wavpack.c.

◆ MAX_BIN_BYTES

#define MAX_BIN_BYTES   1280

Definition at line 61 of file wavpack.c.

Referenced by wv_unpack_dsd_fast().

◆ LEVEL_DECAY

#define LEVEL_DECAY ( a)
Value:
(((a) + 0x80) >> 8)
int a

Definition at line 117 of file wavpack.c.

Referenced by update_error_limit(), and wv_get_value().

Enumeration Type Documentation

◆ Modulation

enum Modulation
Enumerator
MODULATION_PCM 
MODULATION_DSD 

Definition at line 63 of file wavpack.c.

Function Documentation

◆ get_tail()

static av_always_inline unsigned get_tail ( GetBitContext * gb,
unsigned k )
static

Definition at line 119 of file wavpack.c.

Referenced by wv_get_value().

◆ update_error_limit()

static int update_error_limit ( WavpackFrameContext * ctx)
static

Definition at line 133 of file wavpack.c.

Referenced by wv_get_value().

◆ wv_get_value()

static int wv_get_value ( WavpackFrameContext * ctx,
GetBitContext * gb,
int channel,
int * last )
static

Definition at line 171 of file wavpack.c.

Referenced by wv_unpack_mono(), and wv_unpack_stereo().

◆ wv_get_value_integer()

static int wv_get_value_integer ( WavpackFrameContext * s,
uint32_t * crc,
unsigned S )
inlinestatic

Definition at line 297 of file wavpack.c.

Referenced by wv_unpack_mono(), and wv_unpack_stereo().

◆ wv_get_value_float()

static float wv_get_value_float ( WavpackFrameContext * s,
uint32_t * crc,
int S )
static

Definition at line 321 of file wavpack.c.

Referenced by wv_unpack_mono(), and wv_unpack_stereo().

◆ wv_check_crc()

static int wv_check_crc ( WavpackFrameContext * s,
uint32_t crc,
uint32_t crc_extra_bits )
inlinestatic

◆ init_ptable()

static void init_ptable ( int * table,
int rate_i,
int rate_s )
static

Definition at line 410 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

◆ wv_unpack_dsd_high()

static int wv_unpack_dsd_high ( WavpackFrameContext * s,
uint8_t * dst_left,
uint8_t * dst_right )
static

Definition at line 435 of file wavpack.c.

Referenced by wavpack_decode_block().

◆ wv_unpack_dsd_fast()

static int wv_unpack_dsd_fast ( WavpackFrameContext * s,
uint8_t * dst_left,
uint8_t * dst_right )
static

Definition at line 578 of file wavpack.c.

Referenced by wavpack_decode_block().

◆ wv_unpack_dsd_copy()

static int wv_unpack_dsd_copy ( WavpackFrameContext * s,
uint8_t * dst_left,
uint8_t * dst_right )
static

Definition at line 739 of file wavpack.c.

Referenced by wavpack_decode_block().

◆ wv_unpack_stereo()

static int wv_unpack_stereo ( WavpackFrameContext * s,
GetBitContext * gb,
void * dst_l,
void * dst_r,
const int type )
inlinestatic

Definition at line 771 of file wavpack.c.

Referenced by wavpack_decode_block().

◆ wv_unpack_mono()

static int wv_unpack_mono ( WavpackFrameContext * s,
GetBitContext * gb,
void * dst,
const int type )
inlinestatic

Definition at line 904 of file wavpack.c.

Referenced by wavpack_decode_block().

◆ wv_alloc_frame_context()

static av_cold int wv_alloc_frame_context ( WavpackContext * c)
static

Definition at line 973 of file wavpack.c.

Referenced by wavpack_decode_block().

◆ wv_dsd_reset()

static int wv_dsd_reset ( WavpackContext * s,
int channels )
static

Definition at line 990 of file wavpack.c.

Referenced by wavpack_decode_block(), wavpack_decode_end(), and wavpack_decode_flush().

◆ wavpack_decode_init()

static av_cold int wavpack_decode_init ( AVCodecContext * avctx)
static

Definition at line 1051 of file wavpack.c.

◆ wavpack_decode_end()

static av_cold int wavpack_decode_end ( AVCodecContext * avctx)
static

Definition at line 1074 of file wavpack.c.

◆ wavpack_decode_block()

static int wavpack_decode_block ( AVCodecContext * avctx,
AVFrame * frame,
int block_no,
const uint8_t * buf,
int buf_size,
int * new_progress )
static

Definition at line 1089 of file wavpack.c.

Referenced by wavpack_decode_frame().

◆ wavpack_decode_flush()

static av_cold void wavpack_decode_flush ( AVCodecContext * avctx)
static

Definition at line 1614 of file wavpack.c.

◆ dsd_channel()

static int dsd_channel ( AVCodecContext * avctx,
void * frmptr,
int jobnr,
int threadnr )
static

Definition at line 1621 of file wavpack.c.

◆ wavpack_decode_frame()

static int wavpack_decode_frame ( AVCodecContext * avctx,
AVFrame * frame,
int * got_frame_ptr,
AVPacket * avpkt )
static

Definition at line 1633 of file wavpack.c.

Variable Documentation

◆ ff_wavpack_decoder

const FFCodec ff_wavpack_decoder
Initial value:
= {
.p.name = "wavpack",
CODEC_LONG_NAME("WavPack"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(WavpackContext),
UPDATE_THREAD_CONTEXT(update_thread_context),
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
#define UPDATE_THREAD_CONTEXT(func)
#define FF_CODEC_DECODE_CB(func)
#define CODEC_LONG_NAME(str)
#define FF_CODEC_CAP_INIT_CLEANUP
The codec allows calling the close function for deallocation even if the init function returned a fai...
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition codec.h:49
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition codec.h:102
#define AV_CODEC_CAP_CHANNEL_CONF
Codec should fill in channel configuration and samplerate instead of container.
Definition codec.h:94
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition codec.h:98
@ AV_CODEC_ID_WAVPACK
Definition codec_id.h:478
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
static av_cold int wavpack_decode_end(AVCodecContext *avctx)
Definition wavpack.c:1074
static int wavpack_decode_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame_ptr, AVPacket *avpkt)
Definition wavpack.c:1633
static av_cold void wavpack_decode_flush(AVCodecContext *avctx)
Definition wavpack.c:1614
static av_cold int wavpack_decode_init(AVCodecContext *avctx)
Definition wavpack.c:1051

Definition at line 1708 of file wavpack.c.