Go to the documentation of this file.
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},
208 16000, 22050, 24000, 32000, 44100, 48000, 0
212 .
p.
name =
"libtwolame",
237 .p.wrapper_name =
"libtwolame",
int frame_size
Number of samples per channel in an audio frame.
@ AV_SAMPLE_FMT_FLTP
float, planar
static av_cold int twolame_encode_close(AVCodecContext *avctx)
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AV_CHANNEL_LAYOUT_STEREO
int sample_rate
samples per second
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
const FFCodec ff_libtwolame_encoder
This structure describes decoded (raw) audio or video data.
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
int nb_channels
Number of channels in this layout.
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int initial_padding
Audio only.
int flags
AV_CODEC_FLAG_*.
#define FF_CODEC_ENCODE_CB(func)
static av_cold int twolame_encode_init(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
int global_quality
Global quality for codecs which cannot change it per frame.
#define CODEC_LONG_NAME(str)
#define LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
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.
int64_t bit_rate
the average bitrate
const char * av_default_item_name(void *ptr)
Return the context name.
static int twolame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
static const AVClass twolame_class
int(* init)(AVBSFContext *ctx)
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
An AVChannelLayout holds information about the channel layout of audio data.
enum AVSampleFormat sample_fmt
audio sample format
#define AV_NOPTS_VALUE
Undefined timestamp value.
static const AVOption options[]
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
AVSampleFormat
Audio sample formats.
@ AV_SAMPLE_FMT_S16
signed 16 bits
const char * name
Name of the codec implementation.
static const FFCodecDefault twolame_defaults[]
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
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
main external API structure.
static const int twolame_samplerates[]
@ 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_CHANNEL_LAYOUT_MONO
This structure stores compressed data.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define MPA_MAX_CODED_FRAME_SIZE
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
int ff_alloc_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.