FFmpeg
Data Structures | Macros | Functions | Variables
libmp3lame.c File Reference
#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/mem.h"
#include "libavutil/opt.h"
#include "avcodec.h"
#include "audio_frame_queue.h"
#include "codec_internal.h"
#include "encode.h"
#include "mpegaudio.h"
#include "mpegaudiodecheader.h"

Go to the source code of this file.

Data Structures

struct  LAMEContext
 

Macros

#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)
 
#define AE   AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
 

Functions

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)
 

Variables

static const AVOption options []
 
static const AVClass libmp3lame_class
 
static const FFCodecDefault libmp3lame_defaults []
 
static const int libmp3lame_sample_rates []
 
const FFCodec ff_libmp3lame_encoder
 

Detailed Description

Interface to libmp3lame for mp3 encoding.

Definition in file libmp3lame.c.

Macro Definition Documentation

◆ BUFFER_SIZE

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

Definition at line 43 of file libmp3lame.c.

◆ ENCODE_BUFFER

#define ENCODE_BUFFER (   func,
  buf_type,
  buf_name 
)
Value:
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)

Definition at line 191 of file libmp3lame.c.

◆ OFFSET

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

Definition at line 312 of file libmp3lame.c.

◆ AE

Definition at line 313 of file libmp3lame.c.

Function Documentation

◆ realloc_buffer()

static int realloc_buffer ( LAMEContext s)
static

Definition at line 64 of file libmp3lame.c.

Referenced by mp3lame_encode_frame(), and mp3lame_encode_init().

◆ mp3lame_encode_close()

static av_cold int mp3lame_encode_close ( AVCodecContext avctx)
static

Definition at line 80 of file libmp3lame.c.

Referenced by mp3lame_encode_init().

◆ mp3lame_encode_init()

static av_cold int mp3lame_encode_init ( AVCodecContext avctx)
static

Definition at line 95 of file libmp3lame.c.

◆ mp3lame_encode_frame()

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

Definition at line 199 of file libmp3lame.c.

Variable Documentation

◆ options

const AVOption options[]
static
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 },
{ "copyright", "set copyright flag", OFFSET(copyright), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, AE},
{ "original", "set original flag", OFFSET(original), AV_OPT_TYPE_BOOL, { .i64 = 1 }, 0, 1, AE},
{ NULL },
}

Definition at line 314 of file libmp3lame.c.

◆ libmp3lame_class

const AVClass libmp3lame_class
static
Initial value:
= {
.class_name = "libmp3lame encoder",
.item_name = av_default_item_name,
.option = options,
}

Definition at line 323 of file libmp3lame.c.

◆ libmp3lame_defaults

const FFCodecDefault libmp3lame_defaults[]
static
Initial value:
= {
{ "b", "0" },
{ NULL },
}

Definition at line 330 of file libmp3lame.c.

◆ libmp3lame_sample_rates

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

Definition at line 335 of file libmp3lame.c.

◆ ff_libmp3lame_encoder

const FFCodec ff_libmp3lame_encoder
Initial value:
= {
.p.name = "libmp3lame",
CODEC_LONG_NAME("libmp3lame MP3 (MPEG audio layer 3)"),
.p.type = AVMEDIA_TYPE_AUDIO,
.p.id = AV_CODEC_ID_MP3,
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
.priv_data_size = sizeof(LAMEContext),
.p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P,
.p.supported_samplerates = libmp3lame_sample_rates,
.p.ch_layouts = (const AVChannelLayout[]) { AV_CHANNEL_LAYOUT_MONO,
{ 0 },
},
.p.priv_class = &libmp3lame_class,
.defaults = libmp3lame_defaults,
.p.wrapper_name = "libmp3lame",
}

Definition at line 339 of file libmp3lame.c.

func
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition: jacosubdec.c:68
AV_SAMPLE_FMT_FLTP
@ AV_SAMPLE_FMT_FLTP
float, planar
Definition: samplefmt.h:66
AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_STEREO
Definition: channel_layout.h:393
LAMEContext
Definition: libmp3lame.c:45
AV_SAMPLE_FMT_S32P
@ AV_SAMPLE_FMT_S32P
signed 32 bits, planar
Definition: samplefmt.h:65
FF_CODEC_CAP_NOT_INIT_THREADSAFE
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
Definition: codec_internal.h:35
AV_CODEC_ID_MP3
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
Definition: codec_id.h:447
FF_CODEC_ENCODE_CB
#define FF_CODEC_ENCODE_CB(func)
Definition: codec_internal.h:320
AE
#define AE
Definition: libmp3lame.c:313
libmp3lame_defaults
static const FFCodecDefault libmp3lame_defaults[]
Definition: libmp3lame.c:330
mp3lame_encode_init
static av_cold int mp3lame_encode_init(AVCodecContext *avctx)
Definition: libmp3lame.c:95
s
#define s(width, name)
Definition: cbs_vp9.c:198
AVMEDIA_TYPE_AUDIO
@ AVMEDIA_TYPE_AUDIO
Definition: avutil.h:202
CODEC_LONG_NAME
#define CODEC_LONG_NAME(str)
Definition: codec_internal.h:296
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
NULL
#define NULL
Definition: coverity.c:32
OFFSET
#define OFFSET(x)
Definition: libmp3lame.c:312
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:237
libmp3lame_class
static const AVClass libmp3lame_class
Definition: libmp3lame.c:323
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts.c:368
AV_CODEC_CAP_DR1
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
Definition: codec.h:52
AVChannelLayout
An AVChannelLayout holds information about the channel layout of audio data.
Definition: channel_layout.h:317
AV_SAMPLE_FMT_NONE
@ AV_SAMPLE_FMT_NONE
Definition: samplefmt.h:56
AV_SAMPLE_FMT_S16P
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
Definition: samplefmt.h:64
mp3lame_encode_frame
static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Definition: libmp3lame.c:199
AVSampleFormat
AVSampleFormat
Audio sample formats.
Definition: samplefmt.h:55
frame
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
Definition: filter_design.txt:264
options
static const AVOption options[]
Definition: libmp3lame.c:314
libmp3lame_sample_rates
static const int libmp3lame_sample_rates[]
Definition: libmp3lame.c:335
AV_CODEC_CAP_DELAY
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
Definition: codec.h:76
mp3lame_encode_close
static av_cold int mp3lame_encode_close(AVCodecContext *avctx)
Definition: libmp3lame.c:80
AV_CHANNEL_LAYOUT_MONO
#define AV_CHANNEL_LAYOUT_MONO
Definition: channel_layout.h:392
AV_OPT_TYPE_BOOL
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
Definition: opt.h:327
AV_CODEC_CAP_SMALL_LAST_FRAME
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
Definition: codec.h:81