libavcodec/g726.c File Reference

#include <limits.h>
#include "libavutil/avassert.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "internal.h"
#include "get_bits.h"
#include "put_bits.h"

Go to the source code of this file.

Data Structures

struct  Float11
 G.726 11bit float. More...
struct  G726Tables
struct  G726Context

Defines

#define OFFSET(x)   offsetof(G726Context, x)
#define AE   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM

Typedefs

typedef struct Float11 Float11
 G.726 11bit float.
typedef struct G726Tables G726Tables
typedef struct G726Context G726Context

Functions

static Float11i2f (int i, Float11 *f)
static int16_t mult (Float11 *f1, Float11 *f2)
static int sgn (int value)
static uint8_t quant (G726Context *c, int d)
 Para 4.2.2 page 18: Adaptive quantizer.
static int16_t inverse_quant (G726Context *c, int i)
 Para 4.2.3 page 22: Inverse adaptive quantizer.
static int16_t g726_decode (G726Context *c, int I)
static av_cold int g726_reset (G726Context *c)
static int16_t g726_encode (G726Context *c, int16_t sig)
static av_cold int g726_encode_init (AVCodecContext *avctx)
static av_cold int g726_encode_close (AVCodecContext *avctx)
static int g726_encode_frame (AVCodecContext *avctx, uint8_t *dst, int buf_size, void *data)
static av_cold int g726_decode_init (AVCodecContext *avctx)
static int g726_decode_frame (AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt)
static void g726_decode_flush (AVCodecContext *avctx)

Variables

static const int quant_tbl16 []
 16kbit/s 2bits per sample
static const int16_t iquant_tbl16 []
static const int16_t W_tbl16 []
static const uint8_t F_tbl16 []
static const int quant_tbl24 []
 24kbit/s 3bits per sample
static const int16_t iquant_tbl24 []
static const int16_t W_tbl24 []
static const uint8_t F_tbl24 []
static const int quant_tbl32 []
 32kbit/s 4bits per sample
static const int16_t iquant_tbl32 []
static const int16_t W_tbl32 []
static const uint8_t F_tbl32 []
static const int quant_tbl40 []
 40kbit/s 5bits per sample
static const int16_t iquant_tbl40 []
static const int16_t W_tbl40 []
static const uint8_t F_tbl40 []
static const G726Tables G726Tables_pool []
static const AVOption options []
class {
      class_name = "g726"
      item_name = av_default_item_name
      option = options
      version = LIBAVUTIL_VERSION_INT
}; 
static const AVCodecDefault defaults []
AVCodec ff_adpcm_g726_encoder
AVCodec ff_adpcm_g726_decoder

Define Documentation

#define AE   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM

Definition at line 370 of file g726.c.

#define OFFSET (   x  )     offsetof(G726Context, x)

Definition at line 369 of file g726.c.


Typedef Documentation

typedef struct Float11 Float11

G.726 11bit float.

G.726 Standard uses rather odd 11bit floating point arithmentic for numerous occasions. It's a mistery to me why they did it this way instead of simply using 32bit integer arithmetic.

typedef struct G726Context G726Context
typedef struct G726Tables G726Tables

Function Documentation

static int16_t g726_decode ( G726Context c,
int  I 
) [static]

Definition at line 192 of file g726.c.

Referenced by g726_decode_frame(), and g726_encode().

static void g726_decode_flush ( AVCodecContext avctx  )  [static]

Definition at line 471 of file g726.c.

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

Definition at line 437 of file g726.c.

static av_cold int g726_decode_init ( AVCodecContext avctx  )  [static]

Definition at line 405 of file g726.c.

static int16_t g726_encode ( G726Context c,
int16_t  sig 
) [static]

Definition at line 295 of file g726.c.

Referenced by g726_encode_frame().

static av_cold int g726_encode_close ( AVCodecContext avctx  )  [static]

Definition at line 345 of file g726.c.

static int g726_encode_frame ( AVCodecContext avctx,
uint8_t *  dst,
int  buf_size,
void *  data 
) [static]

Definition at line 351 of file g726.c.

static av_cold int g726_encode_init ( AVCodecContext avctx  )  [static]

Definition at line 306 of file g726.c.

static av_cold int g726_reset ( G726Context c  )  [static]

Definition at line 274 of file g726.c.

Referenced by g726_decode_flush(), g726_decode_init(), and g726_encode_init().

static Float11* i2f ( int  i,
Float11 f 
) [inline, static]

Definition at line 44 of file g726.c.

Referenced by g726_decode().

static int16_t inverse_quant ( G726Context c,
int  i 
) [inline, static]

Para 4.2.3 page 22: Inverse adaptive quantizer.

Definition at line 182 of file g726.c.

Referenced by g726_decode().

static int16_t mult ( Float11 f1,
Float11 f2 
) [inline, static]

Definition at line 54 of file g726.c.

Referenced by g726_decode().

static uint8_t quant ( G726Context c,
int  d 
) [inline, static]

Para 4.2.2 page 18: Adaptive quantizer.

Definition at line 156 of file g726.c.

static int sgn ( int  value  )  [inline, static]

Definition at line 64 of file g726.c.

Referenced by g726_decode().


Variable Documentation

const { ... } [static]
class_name = "g726"

Definition at line 377 of file g726.c.

const AVCodecDefault defaults[] [static]
Initial value:
 {
    { "b", "0" },
    { NULL },
}

Definition at line 383 of file g726.c.

const uint8_t F_tbl16[] [static]
Initial value:
           { 0, 7, 7, 0 }

Definition at line 106 of file g726.c.

const uint8_t F_tbl24[] [static]
Initial value:
           { 0, 1, 2, 7, 7, 2, 1, 0 }

Definition at line 115 of file g726.c.

const uint8_t F_tbl32[] [static]
Initial value:
           { 0, 0, 0, 1, 1, 1, 3, 7, 7, 3, 1, 1, 1, 0, 0, 0 }

Definition at line 126 of file g726.c.

const uint8_t F_tbl40[] [static]
Initial value:
           { 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 6,
             6, 6, 5, 4, 3, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }

Definition at line 142 of file g726.c.

Initial value:
 {
    .name           = "g726",
    .type           = AVMEDIA_TYPE_AUDIO,
    .id             = CODEC_ID_ADPCM_G726,
    .priv_data_size = sizeof(G726Context),
    .init           = g726_decode_init,
    .decode         = g726_decode_frame,
    .flush          = g726_decode_flush,
    .capabilities   = CODEC_CAP_DR1,
    .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"),
}

Definition at line 477 of file g726.c.

Initial value:
 {
    .name           = "g726",
    .type           = AVMEDIA_TYPE_AUDIO,
    .id             = CODEC_ID_ADPCM_G726,
    .priv_data_size = sizeof(G726Context),
    .init           = g726_encode_init,
    .encode         = g726_encode_frame,
    .close          = g726_encode_close,
    .capabilities = CODEC_CAP_SMALL_LAST_FRAME,
    .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
    .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"),
    .priv_class     = &class,
    .defaults       = defaults,
}

Definition at line 388 of file g726.c.

const int16_t iquant_tbl16[] [static]
Initial value:
           { 116, 365, 365, 116 }

Definition at line 102 of file g726.c.

const int16_t iquant_tbl24[] [static]
Initial value:
           { INT16_MIN, 135, 273, 373, 373, 273, 135, INT16_MIN }

Definition at line 111 of file g726.c.

const int16_t iquant_tbl32[] [static]
Initial value:
         { INT16_MIN,   4, 135, 213, 273, 323, 373, 425,
                 425, 373, 323, 273, 213, 135,   4, INT16_MIN }

Definition at line 120 of file g726.c.

const int16_t iquant_tbl40[] [static]
Initial value:
         { INT16_MIN, -66,  28, 104, 169, 224, 274, 318,
                 358, 395, 429, 459, 488, 514, 539, 566,
                 566, 539, 514, 488, 459, 429, 395, 358,
                 318, 274, 224, 169, 104,  28, -66, INT16_MIN }

Definition at line 132 of file g726.c.

item_name = av_default_item_name

Definition at line 378 of file g726.c.

Definition at line 379 of file g726.c.

const AVOption options[] [static]
Initial value:
 {
    { "code_size", "Bits per code", OFFSET(code_size), AV_OPT_TYPE_INT, { 4 }, 2, 5, AE },
    { NULL },
}

Definition at line 371 of file g726.c.

const int quant_tbl16[] [static]
Initial value:
           { 260, INT_MAX }

16kbit/s 2bits per sample

Definition at line 100 of file g726.c.

const int quant_tbl24[] [static]
Initial value:
           {  7, 217, 330, INT_MAX }

24kbit/s 3bits per sample

Definition at line 109 of file g726.c.

const int quant_tbl32[] [static]
Initial value:
           { -125,  79, 177, 245, 299, 348, 399, INT_MAX }

32kbit/s 4bits per sample

Definition at line 118 of file g726.c.

const int quant_tbl40[] [static]
Initial value:
           { -122, -16,  67, 138, 197, 249, 297, 338,
              377, 412, 444, 474, 501, 527, 552, INT_MAX }

40kbit/s 5bits per sample

Definition at line 129 of file g726.c.

Definition at line 380 of file g726.c.

const int16_t W_tbl16[] [static]
Initial value:
           { -22, 439, 439, -22 }

Definition at line 104 of file g726.c.

const int16_t W_tbl24[] [static]
Initial value:
           { -4,  30, 137, 582, 582, 137,  30, -4 }

Definition at line 113 of file g726.c.

const int16_t W_tbl32[] [static]
Initial value:
           { -12,  18,  41,  64, 112, 198, 355, 1122,
            1122, 355, 198, 112,  64,  41,  18, -12}

Definition at line 123 of file g726.c.

const int16_t W_tbl40[] [static]
Initial value:
           {   14,  14,  24,  39,  40,  41,   58,  100,
              141, 179, 219, 280, 358, 440,  529,  696,
              696, 529, 440, 358, 280, 219,  179,  141,
              100,  58,  41,  40,  39,  24,   14,   14 }

Definition at line 137 of file g726.c.