Go to the documentation of this file.
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);
85 twolame_set_VBR(
s->glopts,
TRUE);
86 twolame_set_VBR_level(
s->glopts,
89 "VBR in MP2 is a hack, use another codec that supports it.\n");
91 twolame_set_bitrate(
s->glopts, avctx->
bit_rate / 1000);
94 ret = twolame_init_params(
s->glopts);
115 ret = twolame_encode_buffer_float32_interleaved(
s->glopts,
116 (
const float *)
frame->data[0],
122 ret = twolame_encode_buffer_float32(
s->glopts,
123 (
const float *)
frame->data[0],
124 (
const float *)
frame->data[1],
129 ret = twolame_encode_buffer_interleaved(
s->glopts,
130 (
const short int *)
frame->data[0],
135 ret = twolame_encode_buffer(
s->glopts,
136 (
const short int *)
frame->data[0],
137 (
const short int *)
frame->data[1],
143 "Unsupported sample format %d.\n", avctx->
sample_fmt);
147 ret = twolame_encode_flush(
s->glopts, avpkt->
data, avpkt->
size);
160 avpkt->
pts =
s->next_pts;
171 #define OFFSET(x) offsetof(TWOLAMEContext, x)
172 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
182 {
"error_protection",
"enable CRC error protection",
OFFSET(error_protection),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
AE},
185 {
"verbosity",
"set library optput level (0-10)",
OFFSET(verbosity),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 10,
AE},
202 16000, 22050, 24000, 32000, 44100, 48000, 0
206 .
name =
"libtwolame",
224 .channel_layouts = (
const uint64_t[]) {
229 .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.
static av_cold int init(AVCodecContext *avctx)
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
int sample_rate
samples per second
static enum AVSampleFormat sample_fmts[]
#define AV_CH_LAYOUT_MONO
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
This structure describes decoded (raw) audio or video data.
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.
void av_shrink_packet(AVPacket *pkt, int size)
Reduce packet size, correctly zeroing padding.
int initial_padding
Audio only.
static const AVCodecDefault defaults[]
int flags
AV_CODEC_FLAG_*.
#define AV_CH_LAYOUT_STEREO
static av_cold int twolame_encode_init(AVCodecContext *avctx)
static av_always_inline int64_t ff_samples_to_time_base(AVCodecContext *avctx, int64_t samples)
Rescale from sample rate to AVCodecContext.time_base.
#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 LIBAVUTIL_VERSION_INT
Describe the class of an AVClass context structure.
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
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
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
AVCodec ff_libtwolame_encoder
int channels
number of audio channels
static const AVCodecDefault twolame_defaults[]
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.
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[]
#define AV_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
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
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.