libavcodec/sonic.c File Reference

Simple free lossless/lossy audio codec Based on Paul Francis Harrison's Bonk (http://www.logarithmic.net/pfh/bonk) Written and designed by Alex Beregszaszi. More...

#include "avcodec.h"
#include "get_bits.h"
#include "golomb.h"

Go to the source code of this file.

Data Structures

struct  SonicContext

Defines

#define MAX_CHANNELS   2
#define MID_SIDE   0
#define LEFT_SIDE   1
#define RIGHT_SIDE   2
#define LATTICE_SHIFT   10
#define SAMPLE_SHIFT   4
#define LATTICE_FACTOR   (1 << LATTICE_SHIFT)
#define SAMPLE_FACTOR   (1 << SAMPLE_SHIFT)
#define BASE_QUANT   0.6
#define RATE_VARIATION   3.0

Typedefs

typedef struct SonicContext SonicContext

Functions

static int divide (int a, int b)
static int shift (int a, int b)
static int shift_down (int a, int b)
static int intlist_write (PutBitContext *pb, int *buf, int entries, int base_2_part)
static int intlist_read (GetBitContext *gb, int *buf, int entries, int base_2_part)
static void predictor_init_state (int *k, int *state, int order)
static int predictor_calc_error (int *k, int *state, int order, int error)
static void modified_levinson_durbin (int *window, int window_entries, int *out, int out_entries, int channels, int *tap_quant)
static int code_samplerate (int samplerate)
static av_cold int sonic_encode_init (AVCodecContext *avctx)
static av_cold int sonic_encode_close (AVCodecContext *avctx)
static int sonic_encode_frame (AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data)
static av_cold int sonic_decode_init (AVCodecContext *avctx)
static av_cold int sonic_decode_close (AVCodecContext *avctx)
static int sonic_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)

Variables

static const int samplerate_table []
AVCodec ff_sonic_decoder
AVCodec ff_sonic_encoder
AVCodec ff_sonic_ls_encoder

Detailed Description

Simple free lossless/lossy audio codec Based on Paul Francis Harrison's Bonk (http://www.logarithmic.net/pfh/bonk) Written and designed by Alex Beregszaszi.

TODO:

  • CABAC put/get_symbol
  • independent quantizer for channels
  • >2 channels support
  • more decorrelation types
  • more tap_quant tests
  • selectable intlist writers/readers (bonk-style, golomb, cabac)

Definition in file sonic.c.


Define Documentation

#define BASE_QUANT   0.6

Definition at line 75 of file sonic.c.

Referenced by sonic_encode_frame().

#define LATTICE_FACTOR   (1 << LATTICE_SHIFT)

Definition at line 72 of file sonic.c.

Referenced by modified_levinson_durbin().

#define LATTICE_SHIFT   10

Definition at line 70 of file sonic.c.

Referenced by modified_levinson_durbin(), predictor_calc_error(), and predictor_init_state().

#define LEFT_SIDE   1

Definition at line 43 of file sonic.c.

Referenced by sonic_decode_frame(), and sonic_encode_frame().

#define MAX_CHANNELS   2

Definition at line 40 of file sonic.c.

Referenced by sonic_decode_init(), and sonic_encode_init().

#define MID_SIDE   0

Definition at line 42 of file sonic.c.

Referenced by sonic_decode_frame(), and sonic_encode_frame().

#define RATE_VARIATION   3.0

Definition at line 76 of file sonic.c.

Referenced by sonic_encode_frame().

#define RIGHT_SIDE   2

Definition at line 44 of file sonic.c.

Referenced by sonic_decode_frame(), and sonic_encode_frame().

#define SAMPLE_FACTOR   (1 << SAMPLE_SHIFT)

Definition at line 73 of file sonic.c.

Referenced by predictor_calc_error(), and sonic_encode_frame().

#define SAMPLE_SHIFT   4

Definition at line 71 of file sonic.c.

Referenced by sonic_decode_frame(), sonic_encode_frame(), and sonic_encode_init().


Typedef Documentation

typedef struct SonicContext SonicContext

Function Documentation

static int code_samplerate ( int  samplerate  )  [inline, static]

Definition at line 484 of file sonic.c.

Referenced by sonic_encode_init().

static int divide ( int  a,
int  b 
) [inline, static]

Definition at line 78 of file sonic.c.

Referenced by sonic_encode_frame().

static int intlist_read ( GetBitContext gb,
int *  buf,
int  entries,
int  base_2_part 
) [inline, static]

Definition at line 107 of file sonic.c.

Referenced by sonic_decode_frame().

static int intlist_write ( PutBitContext pb,
int *  buf,
int  entries,
int  base_2_part 
) [inline, static]

Definition at line 97 of file sonic.c.

Referenced by sonic_encode_frame().

static void modified_levinson_durbin ( int *  window,
int  window_entries,
int *  out,
int  out_entries,
int  channels,
int *  tap_quant 
) [static]

Definition at line 417 of file sonic.c.

Referenced by sonic_encode_frame().

static int predictor_calc_error ( int *  k,
int *  state,
int  order,
int  error 
) [static]

Definition at line 382 of file sonic.c.

Referenced by sonic_decode_frame().

static void predictor_init_state ( int *  k,
int *  state,
int  order 
) [static]

Definition at line 365 of file sonic.c.

Referenced by sonic_decode_frame().

static int shift_down ( int  a,
int  b 
) [inline, static]

Definition at line 91 of file sonic.c.

Referenced by modified_levinson_durbin(), predictor_calc_error(), and predictor_init_state().

static av_cold int sonic_decode_close ( AVCodecContext avctx  )  [static]

Definition at line 836 of file sonic.c.

static int sonic_decode_frame ( AVCodecContext avctx,
void *  data,
int *  got_frame_ptr,
AVPacket avpkt 
) [static]

Definition at line 854 of file sonic.c.

static av_cold int sonic_decode_init ( AVCodecContext avctx  )  [static]

Definition at line 752 of file sonic.c.

static av_cold int sonic_encode_close ( AVCodecContext avctx  )  [static]

Definition at line 606 of file sonic.c.

static int sonic_encode_frame ( AVCodecContext avctx,
uint8_t *  buf,
int  buf_size,
void *  data 
) [static]

Definition at line 625 of file sonic.c.

static av_cold int sonic_encode_init ( AVCodecContext avctx  )  [static]

Definition at line 501 of file sonic.c.


Variable Documentation

Initial value:
 {
    .name           = "sonic",
    .type           = AVMEDIA_TYPE_AUDIO,
    .id             = CODEC_ID_SONIC,
    .priv_data_size = sizeof(SonicContext),
    .init           = sonic_decode_init,
    .close          = sonic_decode_close,
    .decode         = sonic_decode_frame,
    .capabilities   = CODEC_CAP_DR1,
    .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
}

Definition at line 950 of file sonic.c.

Initial value:
 {
    .name           = "sonic",
    .type           = AVMEDIA_TYPE_AUDIO,
    .id             = CODEC_ID_SONIC,
    .priv_data_size = sizeof(SonicContext),
    .init           = sonic_encode_init,
    .encode         = sonic_encode_frame,
    .close          = sonic_encode_close,
    .long_name = NULL_IF_CONFIG_SMALL("Sonic"),
}

Definition at line 964 of file sonic.c.

Initial value:
 {
    .name           = "sonicls",
    .type           = AVMEDIA_TYPE_AUDIO,
    .id             = CODEC_ID_SONIC_LS,
    .priv_data_size = sizeof(SonicContext),
    .init           = sonic_encode_init,
    .encode         = sonic_encode_frame,
    .close          = sonic_encode_close,
    .long_name = NULL_IF_CONFIG_SMALL("Sonic lossless"),
}

Definition at line 977 of file sonic.c.

const int samplerate_table[] [static]
Initial value:
    { 44100, 22050, 11025, 96000, 48000, 32000, 24000, 16000, 8000 }

Definition at line 749 of file sonic.c.