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

G.722 ADPCM audio encoder. More...

#include "libavutil/avassert.h"
#include "libavutil/channel_layout.h"
#include "libavutil/mem.h"
#include "avcodec.h"
#include "codec_internal.h"
#include "encode.h"
#include "g722.h"
#include "libavutil/common.h"

Go to the source code of this file.

Macros

#define FREEZE_INTERVAL   128
 
#define MAX_FRAME_SIZE   32768
 
#define MIN_TRELLIS   0
 
#define MAX_TRELLIS   16
 
#define STORE_NODE(index, UPDATE, VALUE)
 

Functions

static av_cold int g722_encode_close (AVCodecContext *avctx)
 
static av_cold int g722_encode_init (AVCodecContext *avctx)
 
static void filter_samples (G722Context *c, const int16_t *samples, int *xlow, int *xhigh)
 
static int encode_high (const struct G722Band *state, int xhigh)
 
static int encode_low (const struct G722Band *state, int xlow)
 
static void g722_encode_trellis (G722Context *c, int trellis, uint8_t *dst, int nb_samples, const int16_t *samples)
 
static av_always_inline void encode_byte (G722Context *c, uint8_t *dst, const int16_t *samples)
 
static void g722_encode_no_trellis (G722Context *c, uint8_t *dst, int nb_samples, const int16_t *samples)
 
static int g722_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 

Variables

static const int16_t low_quant [33]
 
const FFCodec ff_adpcm_g722_encoder
 

Detailed Description

G.722 ADPCM audio encoder.

Definition in file g722enc.c.

Macro Definition Documentation

◆ FREEZE_INTERVAL

#define FREEZE_INTERVAL   128

Definition at line 39 of file g722enc.c.

◆ MAX_FRAME_SIZE

#define MAX_FRAME_SIZE   32768

Definition at line 43 of file g722enc.c.

◆ MIN_TRELLIS

#define MIN_TRELLIS   0

Definition at line 47 of file g722enc.c.

Referenced by g722_encode_init().

◆ MAX_TRELLIS

#define MAX_TRELLIS   16

Definition at line 48 of file g722enc.c.

Referenced by g722_encode_init().

◆ STORE_NODE

#define STORE_NODE ( index,
UPDATE,
VALUE )

Referenced by g722_encode_trellis().

Function Documentation

◆ g722_encode_close()

static av_cold int g722_encode_close ( AVCodecContext * avctx)
static

Definition at line 50 of file g722enc.c.

◆ g722_encode_init()

static av_cold int g722_encode_init ( AVCodecContext * avctx)
static

Definition at line 62 of file g722enc.c.

◆ filter_samples()

static void filter_samples ( G722Context * c,
const int16_t * samples,
int * xlow,
int * xhigh )
inlinestatic

Definition at line 129 of file g722enc.c.

Referenced by g722_encode_trellis().

◆ encode_high()

static int encode_high ( const struct G722Band * state,
int xhigh )
inlinestatic

Definition at line 146 of file g722enc.c.

◆ encode_low()

static int encode_low ( const struct G722Band * state,
int xlow )
inlinestatic

Definition at line 154 of file g722enc.c.

Referenced by g722_encode_trellis().

◆ g722_encode_trellis()

static void g722_encode_trellis ( G722Context * c,
int trellis,
uint8_t * dst,
int nb_samples,
const int16_t * samples )
static

Definition at line 168 of file g722enc.c.

◆ encode_byte()

static av_always_inline void encode_byte ( G722Context * c,
uint8_t * dst,
const int16_t * samples )
static

Definition at line 319 of file g722enc.c.

◆ g722_encode_no_trellis()

static void g722_encode_no_trellis ( G722Context * c,
uint8_t * dst,
int nb_samples,
const int16_t * samples )
static

Definition at line 332 of file g722enc.c.

◆ g722_encode_frame()

static int g722_encode_frame ( AVCodecContext * avctx,
AVPacket * avpkt,
const AVFrame * frame,
int * got_packet_ptr )
static

Definition at line 341 of file g722enc.c.

Variable Documentation

◆ low_quant

const int16_t low_quant[33]
static
Initial value:
= {
35, 72, 110, 150, 190, 233, 276, 323,
370, 422, 473, 530, 587, 650, 714, 786,
858, 940, 1023, 1121, 1219, 1339, 1458, 1612,
1765, 1980, 2195, 2557, 2919
}

Definition at line 122 of file g722enc.c.

Referenced by encode_low().

◆ ff_adpcm_g722_encoder

const FFCodec ff_adpcm_g722_encoder
Initial value:
= {
.p.name = "g722",
CODEC_LONG_NAME("G.722 ADPCM"),
.p.type = AVMEDIA_TYPE_AUDIO,
.priv_data_size = sizeof(G722Context),
.caps_internal = FF_CODEC_CAP_INIT_CLEANUP,
}
static av_cold void close(AVCodecParserContext *s)
Definition apv_parser.c:197
#define CODEC_CH_LAYOUTS(...)
#define FF_CODEC_ENCODE_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...
#define CODEC_SAMPLEFMTS(...)
int(* init)(AVBSFContext *ctx)
Definition dts2pts.c:608
static av_cold int g722_encode_init(AVCodecContext *avctx)
Definition g722enc.c:62
static int g722_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition g722enc.c:341
static av_cold int g722_encode_close(AVCodecContext *avctx)
Definition g722enc.c:50
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
Definition codec.h:147
#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_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
Definition codec.h:84
@ AV_CODEC_ID_ADPCM_G722
Definition codec_id.h:398
#define AV_CHANNEL_LAYOUT_MONO
@ AVMEDIA_TYPE_AUDIO
Definition avutil.h:201
@ AV_SAMPLE_FMT_S16
signed 16 bits
Definition samplefmt.h:58

Definition at line 371 of file g722enc.c.