FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
mpegaudioenc.c File Reference

The simplest mpeg audio layer 2 encoder. More...

#include "libavutil/channel_layout.h"
#include "avcodec.h"
#include "internal.h"
#include "put_bits.h"
#include "mpegaudio.h"
#include "mpegaudiodsp.h"
#include "mpegaudiodata.h"
#include "mpegaudiotab.h"

Go to the source code of this file.

Data Structures

struct  MpegAudioContext
 

Macros

#define FRAC_BITS   15 /* fractional bits for sb_samples and dct */
 
#define WFRAC_BITS   14 /* fractional bits for window */
 
#define USE_FLOATS
 
#define MUL(a, b)   (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)
 
#define SAMPLES_BUF_SIZE   4096
 
#define WSHIFT   (WFRAC_BITS + 15 - FRAC_BITS)
 
#define SB_NOTALLOCATED   0
 
#define SB_ALLOCATED   1
 
#define SB_NOMORE   2
 

Functions

static av_cold int MPA_encode_init (AVCodecContext *avctx)
 
static void idct32 (int *out, int *tab)
 
static void filter (MpegAudioContext *s, int ch, const short *samples, int incr)
 
static void compute_scale_factors (MpegAudioContext *s, unsigned char scale_code[SBLIMIT], unsigned char scale_factors[SBLIMIT][3], int sb_samples[3][12][SBLIMIT], int sblimit)
 
static void psycho_acoustic_model (MpegAudioContext *s, short smr[SBLIMIT])
 
static void compute_bit_allocation (MpegAudioContext *s, short smr1[MPA_MAX_CHANNELS][SBLIMIT], unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT], int *padding)
 
static void encode_frame (MpegAudioContext *s, unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT], int padding)
 
static int MPA_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
 

Variables

static const AVCodecDefault mp2_defaults []
 
AVCodec ff_mp2_encoder
 

Detailed Description

The simplest mpeg audio layer 2 encoder.

Definition in file mpegaudioenc.c.

Macro Definition Documentation

#define FRAC_BITS   15 /* fractional bits for sb_samples and dct */

Definition at line 33 of file mpegaudioenc.c.

#define WFRAC_BITS   14 /* fractional bits for window */

Definition at line 34 of file mpegaudioenc.c.

Referenced by MPA_encode_init().

#define USE_FLOATS

Definition at line 37 of file mpegaudioenc.c.

#define MUL (   a,
  b 
)    (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS)

Definition at line 46 of file mpegaudioenc.c.

Referenced by idct32().

#define SAMPLES_BUF_SIZE   4096

Definition at line 48 of file mpegaudioenc.c.

Referenced by filter().

#define WSHIFT   (WFRAC_BITS + 15 - FRAC_BITS)

Definition at line 319 of file mpegaudioenc.c.

Referenced by filter().

#define SB_NOTALLOCATED   0

Definition at line 500 of file mpegaudioenc.c.

Referenced by compute_bit_allocation().

#define SB_ALLOCATED   1

Definition at line 501 of file mpegaudioenc.c.

Referenced by compute_bit_allocation().

#define SB_NOMORE   2

Definition at line 502 of file mpegaudioenc.c.

Referenced by compute_bit_allocation().

Function Documentation

static av_cold int MPA_encode_init ( AVCodecContext avctx)
static

Definition at line 79 of file mpegaudioenc.c.

static void idct32 ( int *  out,
int *  tab 
)
static

Definition at line 200 of file mpegaudioenc.c.

Referenced by filter().

static void filter ( MpegAudioContext s,
int  ch,
const short *  samples,
int  incr 
)
static
static void compute_scale_factors ( MpegAudioContext s,
unsigned char  scale_code[SBLIMIT],
unsigned char  scale_factors[SBLIMIT][3],
int  sb_samples[3][12][SBLIMIT],
int  sblimit 
)
static

Definition at line 374 of file mpegaudioenc.c.

Referenced by MPA_encode_frame().

static void psycho_acoustic_model ( MpegAudioContext s,
short  smr[SBLIMIT] 
)
static

Definition at line 490 of file mpegaudioenc.c.

Referenced by MPA_encode_frame().

static void compute_bit_allocation ( MpegAudioContext s,
short  smr1[MPA_MAX_CHANNELS][SBLIMIT],
unsigned char  bit_alloc[MPA_MAX_CHANNELS][SBLIMIT],
int *  padding 
)
static

Definition at line 507 of file mpegaudioenc.c.

Referenced by MPA_encode_frame().

static void encode_frame ( MpegAudioContext s,
unsigned char  bit_alloc[MPA_MAX_CHANNELS][SBLIMIT],
int  padding 
)
static

Definition at line 603 of file mpegaudioenc.c.

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

Definition at line 741 of file mpegaudioenc.c.

Variable Documentation

const AVCodecDefault mp2_defaults[]
static
Initial value:
= {
{ "b", "128k" },
{ NULL },
}

Definition at line 778 of file mpegaudioenc.c.

AVCodec ff_mp2_encoder
Initial value:
= {
.name = "mp2",
.long_name = NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
.priv_data_size = sizeof(MpegAudioContext),
.encode2 = MPA_encode_frame,
.supported_samplerates = (const int[]){
44100, 48000, 32000, 22050, 24000, 16000, 0
},
.channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO,
0 },
.defaults = mp2_defaults,
}

Definition at line 783 of file mpegaudioenc.c.