53 twolame_close(&
s->glopts);
65 s->glopts = twolame_init();
69 twolame_set_verbosity(
s->glopts,
s->verbosity);
70 twolame_set_mode(
s->glopts,
s->mode);
71 twolame_set_psymodel(
s->glopts,
s->psymodel);
72 twolame_set_energy_levels(
s->glopts,
s->energy);
73 twolame_set_error_protection(
s->glopts,
s->error_protection);
74 twolame_set_copyright(
s->glopts,
s->copyright);
75 twolame_set_original(
s->glopts,
s->original);
77 twolame_set_num_channels(
s->glopts, avctx->
channels);
78 twolame_set_in_samplerate(
s->glopts, avctx->
sample_rate);
79 twolame_set_out_samplerate(
s->glopts, avctx->
sample_rate);
82 if ((
s->mode == TWOLAME_AUTO_MODE && avctx->
channels == 1) ||
s->mode == TWOLAME_MONO)
89 twolame_set_VBR(
s->glopts, TRUE);
90 twolame_set_VBR_level(
s->glopts,
93 "VBR in MP2 is a hack, use another codec that supports it.\n");
95 twolame_set_bitrate(
s->glopts, avctx->
bit_rate / 1000);
98 ret = twolame_init_params(
s->glopts);
119 ret = twolame_encode_buffer_float32_interleaved(
s->glopts,
126 ret = twolame_encode_buffer_float32(
s->glopts,
133 ret = twolame_encode_buffer_interleaved(
s->glopts,
139 ret = twolame_encode_buffer(
s->glopts,
147 "Unsupported sample format %d.\n", avctx->
sample_fmt);
151 ret = twolame_encode_flush(
s->glopts, avpkt->
data, avpkt->
size);
164 avpkt->
pts =
s->next_pts;
175 #define OFFSET(x) offsetof(TWOLAMEContext, x)
176 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
186 {
"error_protection",
"enable CRC error protection",
OFFSET(error_protection),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
AE},
189 {
"verbosity",
"set library optput level (0-10)",
OFFSET(verbosity),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 10,
AE},
206 16000, 22050, 24000, 32000, 44100, 48000, 0
210 .
name =
"libtwolame",
228 .channel_layouts = (
const uint64_t[]) {
233 .wrapper_name =
"libtwolame",
static enum AVSampleFormat sample_fmts[]
static const AVCodecDefault defaults[]
Libavcodec external API header.
static av_cold int init(AVCodecContext *avctx)
common internal and external API header
mode
Use these values in ebur128_init (or'ed).
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
#define AV_CH_LAYOUT_MONO
#define AV_CH_LAYOUT_STEREO
#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_FLAG_QSCALE
Use fixed qscale.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
#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.
AVSampleFormat
Audio sample formats.
@ 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 av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static int twolame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static const AVOption options[]
static av_cold int twolame_encode_init(AVCodecContext *avctx)
AVCodec ff_libtwolame_encoder
static av_cold int twolame_encode_close(AVCodecContext *avctx)
static const int twolame_samplerates[]
static const AVClass twolame_class
static const AVCodecDefault twolame_defaults[]
mpeg audio declarations for both encoder and decoder.
#define MPA_MAX_CODED_FRAME_SIZE
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
main external API structure.
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 channels
number of audio channels
int frame_size
Number of samples per channel in an audio frame.
const char * name
Name of the codec implementation.
This structure describes decoded (raw) audio or video data.
int nb_samples
number of audio samples (per channel) described by this frame
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
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...