FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
wavpack.c File Reference

WavPack lossless audio decoder. More...

#include "libavutil/buffer.h"
#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "bytestream.h"
#include "get_bits.h"
#include "internal.h"
#include "thread.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)   (!(((low) ^ (high)) & 0xff000000))
 
#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 WV_MAX_FRAME_DECODERS   14
 
#define LEVEL_DECAY(a)   (((a) + 0x80) >> 8)
 

Enumerations

enum  Modulation { MODULATION_PCM, MODULATION_DSD }
 

Functions

static av_always_inline unsigned get_tail (GetBitContext *gb, int 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, int block_no, const uint8_t *buf, int buf_size)
 
static 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, void *data, int *got_frame_ptr, AVPacket *avpkt)
 

Variables

AVCodec ff_wavpack_decoder
 

Detailed Description

WavPack lossless audio decoder.

Definition in file wavpack.c.

Macro Definition Documentation

#define BITSTREAM_READER_LE

Definition at line 26 of file wavpack.c.

#define DSD_BYTE_READY (   low,
  high 
)    (!(((low) ^ (high)) & 0xff000000))

Definition at line 41 of file wavpack.c.

Referenced by wv_unpack_dsd_fast(), and wv_unpack_dsd_high().

#define PTABLE_BITS   8

Definition at line 43 of file wavpack.c.

#define PTABLE_BINS   (1<<PTABLE_BITS)

Definition at line 44 of file wavpack.c.

Referenced by init_ptable().

#define PTABLE_MASK   (PTABLE_BINS-1)

Definition at line 45 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

#define UP   0x010000fe

Definition at line 47 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

#define DOWN   0x00010000

Definition at line 48 of file wavpack.c.

Referenced by init_ptable(), and wv_unpack_dsd_high().

#define DECAY   8

Definition at line 49 of file wavpack.c.

Referenced by init_ptable(), and wv_unpack_dsd_high().

#define PRECISION   20

Definition at line 51 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

#define VALUE_ONE   (1 << PRECISION)

Definition at line 52 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

#define PRECISION_USE   12

Definition at line 53 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

#define RATE_S   20

Definition at line 55 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

#define MAX_HISTORY_BITS   5

Definition at line 57 of file wavpack.c.

Referenced by wv_unpack_dsd_fast().

#define MAX_HISTORY_BINS   (1 << MAX_HISTORY_BITS)

Definition at line 58 of file wavpack.c.

#define MAX_BIN_BYTES   1280

Definition at line 59 of file wavpack.c.

Referenced by wv_unpack_dsd_fast().

#define WV_MAX_FRAME_DECODERS   14

Definition at line 98 of file wavpack.c.

Referenced by wv_alloc_frame_context().

#define LEVEL_DECAY (   a)    (((a) + 0x80) >> 8)

Definition at line 119 of file wavpack.c.

Referenced by update_error_limit(), and wv_get_value().

Enumeration Type Documentation

enum Modulation
Enumerator
MODULATION_PCM 
MODULATION_DSD 

Definition at line 61 of file wavpack.c.

Function Documentation

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

Definition at line 121 of file wavpack.c.

Referenced by wv_get_value().

static int update_error_limit ( WavpackFrameContext ctx)
static

Definition at line 135 of file wavpack.c.

Referenced by wv_get_value().

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

Definition at line 173 of file wavpack.c.

Referenced by wv_unpack_mono(), and wv_unpack_stereo().

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

Definition at line 303 of file wavpack.c.

Referenced by wv_unpack_mono(), and wv_unpack_stereo().

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

Definition at line 327 of file wavpack.c.

Referenced by wv_unpack_mono(), and wv_unpack_stereo().

static int wv_check_crc ( WavpackFrameContext s,
uint32_t  crc,
uint32_t  crc_extra_bits 
)
inlinestatic
static void init_ptable ( int table,
int  rate_i,
int  rate_s 
)
static

Definition at line 416 of file wavpack.c.

Referenced by wv_unpack_dsd_high().

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

Definition at line 441 of file wavpack.c.

Referenced by wavpack_decode_block().

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

Definition at line 580 of file wavpack.c.

Referenced by wavpack_decode_block().

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

Definition at line 741 of file wavpack.c.

Referenced by wavpack_decode_block().

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

Definition at line 773 of file wavpack.c.

Referenced by wavpack_decode_block().

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().

static av_cold int wv_alloc_frame_context ( WavpackContext c)
static

Definition at line 971 of file wavpack.c.

Referenced by wavpack_decode_block().

static int wv_dsd_reset ( WavpackContext s,
int  channels 
)
static

Definition at line 985 of file wavpack.c.

Referenced by wavpack_decode_block(), and wavpack_decode_flush().

static av_cold int wavpack_decode_init ( AVCodecContext avctx)
static

Definition at line 1042 of file wavpack.c.

static av_cold int wavpack_decode_end ( AVCodecContext avctx)
static

Definition at line 1061 of file wavpack.c.

static int wavpack_decode_block ( AVCodecContext avctx,
int  block_no,
const uint8_t buf,
int  buf_size 
)
static

Definition at line 1080 of file wavpack.c.

Referenced by wavpack_decode_frame().

static void wavpack_decode_flush ( AVCodecContext avctx)
static

Definition at line 1609 of file wavpack.c.

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

Definition at line 1616 of file wavpack.c.

Referenced by wavpack_decode_frame().

static int wavpack_decode_frame ( AVCodecContext avctx,
void data,
int got_frame_ptr,
AVPacket avpkt 
)
static

Definition at line 1628 of file wavpack.c.

Variable Documentation

AVCodec ff_wavpack_decoder
Initial value:
= {
.name = "wavpack",
.long_name = NULL_IF_CONFIG_SMALL("WavPack"),
.priv_data_size = sizeof(WavpackContext),
}
static void flush(AVCodecContext *avctx)
static void wavpack_decode_flush(AVCodecContext *avctx)
Definition: wavpack.c:1609
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:35
static void decode(AVCodecContext *dec_ctx, AVPacket *pkt, AVFrame *frame, FILE *outfile)
Definition: decode_audio.c:71
#define FF_CODEC_CAP_ALLOCATE_PROGRESS
Definition: internal.h:75
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:153
#define AV_CODEC_CAP_FRAME_THREADS
Codec supports frame-level multithreading.
Definition: codec.h:106
#define ONLY_IF_THREADS_ENABLED(x)
Define a function with only the non-default version specified.
Definition: internal.h:192
#define AV_CODEC_CAP_SLICE_THREADS
Codec supports slice-based (or partition-based) multithreading.
Definition: codec.h:110
static av_cold int wavpack_decode_end(AVCodecContext *avctx)
Definition: wavpack.c:1061
the pkt_dts and pkt_pts fields in AVFrame will work as usual Restrictions on codec whose streams don t reset across will not work because their bitstreams cannot be decoded in parallel *The contents of buffers must not be read before as well as code calling up to before the decode process starts Call have update_thread_context() run it in the next thread.Add AV_CODEC_CAP_FRAME_THREADS to the codec capabilities.There will be very little speed gain at this point but it should work.If there are inter-frame dependencies
static int wavpack_decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
Definition: wavpack.c:1628
static av_cold int wavpack_decode_init(AVCodecContext *avctx)
Definition: wavpack.c:1042
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:50

Definition at line 1703 of file wavpack.c.