55 twolame_close(&
s->glopts);
67 s->glopts = twolame_init();
71 twolame_set_verbosity(
s->glopts,
s->verbosity);
72 twolame_set_mode(
s->glopts,
s->mode);
73 twolame_set_psymodel(
s->glopts,
s->psymodel);
74 twolame_set_energy_levels(
s->glopts,
s->energy);
75 twolame_set_error_protection(
s->glopts,
s->error_protection);
76 twolame_set_copyright(
s->glopts,
s->copyright);
77 twolame_set_original(
s->glopts,
s->original);
80 twolame_set_in_samplerate(
s->glopts, avctx->
sample_rate);
81 twolame_set_out_samplerate(
s->glopts, avctx->
sample_rate);
91 twolame_set_VBR(
s->glopts, TRUE);
92 twolame_set_VBR_level(
s->glopts,
95 "VBR in MP2 is a hack, use another codec that supports it.\n");
97 twolame_set_bitrate(
s->glopts, avctx->
bit_rate / 1000);
100 ret = twolame_init_params(
s->glopts);
121 ret = twolame_encode_buffer_float32_interleaved(
s->glopts,
122 (
const float *)
frame->data[0],
128 ret = twolame_encode_buffer_float32(
s->glopts,
129 (
const float *)
frame->data[0],
130 (
const float *)
frame->data[1],
135 ret = twolame_encode_buffer_interleaved(
s->glopts,
136 (
const short int *)
frame->data[0],
141 ret = twolame_encode_buffer(
s->glopts,
142 (
const short int *)
frame->data[0],
143 (
const short int *)
frame->data[1],
149 "Unsupported sample format %d.\n", avctx->
sample_fmt);
153 ret = twolame_encode_flush(
s->glopts, avpkt->
data, avpkt->
size);
166 avpkt->
pts =
s->next_pts;
177#define OFFSET(x) offsetof(TWOLAMEContext, x)
178#define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
180 {
"mode",
"Mpeg Mode",
OFFSET(
mode),
AV_OPT_TYPE_INT, { .i64 = TWOLAME_AUTO_MODE }, TWOLAME_AUTO_MODE, TWOLAME_MONO,
AE, .unit =
"mode"},
188 {
"error_protection",
"enable CRC error protection",
OFFSET(error_protection),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
AE},
191 {
"verbosity",
"set library optput level (0-10)",
OFFSET(verbosity),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 10,
AE},
196 .class_name =
"libtwolame encoder",
208 16000, 22050, 24000, 32000, 44100, 48000, 0
212 .p.name =
"libtwolame",
228 .p.wrapper_name =
"libtwolame",
const FFCodec ff_libtwolame_encoder
Libavcodec external API header.
Public libavutil channel layout APIs header.
#define CODEC_SAMPLERATES_ARRAY(array)
#define CODEC_CH_LAYOUTS(...)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define CODEC_SAMPLEFMTS(...)
common internal and external API header
int(* init)(AVBSFContext *ctx)
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.
static av_always_inline int64_t ff_samples_to_time_base(const AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_INT
Underlying C type is int.
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
#define AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_MONO
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
@ AV_SAMPLE_FMT_FLTP
float, planar
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
@ AV_SAMPLE_FMT_S16
signed 16 bits
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define LIBAVUTIL_VERSION_INT
static int twolame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static const FFCodecDefault twolame_defaults[]
static av_cold int twolame_encode_init(AVCodecContext *avctx)
static av_cold int twolame_encode_close(AVCodecContext *avctx)
static const int twolame_samplerates[]
static const AVClass twolame_class
mpeg audio declarations for both encoder and decoder.
#define MPA_MAX_CODED_FRAME_SIZE
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
enum AVSampleFormat sample_fmt
audio sample format
int global_quality
Global quality for codecs which cannot change it per frame.
int64_t bit_rate
the average bitrate
int initial_padding
Audio only.
int sample_rate
samples per second
int flags
AV_CODEC_FLAG_*.
int frame_size
Number of samples per channel in an audio frame.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...