Data Structures | Macros | Functions | Variables
libmp3lame.c File Reference

Interface to libmp3lame for mp3 encoding. More...

#include <lame/lame.h>
#include "libavutil/channel_layout.h"
#include "libavutil/common.h"
#include "libavutil/float_dsp.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "audio_frame_queue.h"
#include "internal.h"
#include "mpegaudio.h"
#include "mpegaudiodecheader.h"

Go to the source code of this file.

Data Structures

struct  LAMEContext


#define BUFFER_SIZE   (7200 + 2 * MPA_FRAME_SIZE + MPA_FRAME_SIZE / 4+1000)
#define ENCODE_BUFFER(func, buf_type, buf_name)
#define OFFSET(x)   offsetof(LAMEContext, x)


static int realloc_buffer (LAMEContext *s)
static av_cold int mp3lame_encode_close (AVCodecContext *avctx)
static av_cold int mp3lame_encode_init (AVCodecContext *avctx)
static int mp3lame_encode_frame (AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)


static const AVOption options []
static const AVClass libmp3lame_class
static const AVCodecDefault libmp3lame_defaults []
static const int libmp3lame_sample_rates []
AVCodec ff_libmp3lame_encoder

Detailed Description

Interface to libmp3lame for mp3 encoding.

Definition in file libmp3lame.c.

Macro Definition Documentation

#define BUFFER_SIZE   (7200 + 2 * MPA_FRAME_SIZE + MPA_FRAME_SIZE / 4+1000)

Definition at line 41 of file libmp3lame.c.

Referenced by realloc_buffer().

#define ENCODE_BUFFER (   func,
do { \
lame_result = func(s->gfp, \
(const buf_type *)buf_name[0], \
(const buf_type *)buf_name[1], frame->nb_samples, \
s->buffer + s->buffer_index, \
s->buffer_size - s->buffer_index); \
} while (0)
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
#define s(width, name)
Definition: cbs_vp9.c:257
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:67

Definition at line 180 of file libmp3lame.c.

Referenced by mp3lame_encode_frame().

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

Definition at line 305 of file libmp3lame.c.

Definition at line 306 of file libmp3lame.c.

Function Documentation

static int realloc_buffer ( LAMEContext s)

Definition at line 60 of file libmp3lame.c.

Referenced by mp3lame_encode_frame(), and mp3lame_encode_init().

static av_cold int mp3lame_encode_close ( AVCodecContext avctx)

Definition at line 76 of file libmp3lame.c.

Referenced by mp3lame_encode_init().

static av_cold int mp3lame_encode_init ( AVCodecContext avctx)

Definition at line 91 of file libmp3lame.c.

static int mp3lame_encode_frame ( AVCodecContext avctx,
AVPacket avpkt,
const AVFrame frame,
int got_packet_ptr 

Definition at line 188 of file libmp3lame.c.

Variable Documentation

const AVOption options[]
Initial value:
= {
{ "reservoir", "use bit reservoir", OFFSET(reservoir), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AE },
{ "joint_stereo", "use joint stereo", OFFSET(joint_stereo), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AE },
{ "abr", "use ABR", OFFSET(abr), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AE },
{ NULL },
#define NULL
Definition: coverity.c:32
#define AE
Definition: libmp3lame.c:306
#define OFFSET(x)
Definition: libmp3lame.c:305

Definition at line 307 of file libmp3lame.c.

const AVClass libmp3lame_class
Initial value:
= {
.class_name = "libmp3lame encoder",
.item_name = av_default_item_name,
.option = options,
Definition: version.h:85
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
static const AVOption options[]
Definition: libmp3lame.c:307

Definition at line 314 of file libmp3lame.c.

const AVCodecDefault libmp3lame_defaults[]
Initial value:
= {
{ "b", "0" },
{ NULL },
#define NULL
Definition: coverity.c:32

Definition at line 321 of file libmp3lame.c.

const int libmp3lame_sample_rates[]
Initial value:
= {
44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000, 0

Definition at line 326 of file libmp3lame.c.

AVCodec ff_libmp3lame_encoder
Initial value:
= {
.name = "libmp3lame",
.long_name = NULL_IF_CONFIG_SMALL("libmp3lame MP3 (MPEG audio layer 3)"),
.priv_data_size = sizeof(LAMEContext),
.supported_samplerates = libmp3lame_sample_rates,
.channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO,
0 },
.priv_class = &libmp3lame_class,
.defaults = libmp3lame_defaults,
.wrapper_name = "libmp3lame",
static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: libmp3lame.c:188
float, planar
Definition: samplefmt.h:69
static const AVClass libmp3lame_class
Definition: libmp3lame.c:314
static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
Definition: libmp3lame.c:91
static av_cold int init(AVCodecContext *avctx)
Definition: avrndec.c:31
static const int libmp3lame_sample_rates[]
Definition: libmp3lame.c:326
static av_cold int mp3lame_encode_close(AVCodecContext *avctx)
Definition: libmp3lame.c:76
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:75
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:115
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:423
static const AVCodecDefault libmp3lame_defaults[]
Definition: libmp3lame.c:321
Codec can be fed a final frame with a smaller size.
Definition: codec.h:80
signed 32 bits, planar
Definition: samplefmt.h:68
Audio sample formats.
Definition: samplefmt.h:58
static enum AVSampleFormat sample_fmts[]
Definition: adpcmenc.c:940
signed 16 bits, planar
Definition: samplefmt.h:67

Definition at line 330 of file libmp3lame.c.