Go to the documentation of this file.
56 twolame_close(&
s->glopts);
68 s->glopts = twolame_init();
72 twolame_set_verbosity(
s->glopts,
s->verbosity);
73 twolame_set_mode(
s->glopts,
s->mode);
74 twolame_set_psymodel(
s->glopts,
s->psymodel);
75 twolame_set_energy_levels(
s->glopts,
s->energy);
76 twolame_set_error_protection(
s->glopts,
s->error_protection);
77 twolame_set_copyright(
s->glopts,
s->copyright);
78 twolame_set_original(
s->glopts,
s->original);
81 twolame_set_in_samplerate(
s->glopts, avctx->
sample_rate);
82 twolame_set_out_samplerate(
s->glopts, avctx->
sample_rate);
92 twolame_set_VBR(
s->glopts, TRUE);
93 twolame_set_VBR_level(
s->glopts,
96 "VBR in MP2 is a hack, use another codec that supports it.\n");
98 twolame_set_bitrate(
s->glopts, avctx->
bit_rate / 1000);
101 ret = twolame_init_params(
s->glopts);
122 ret = twolame_encode_buffer_float32_interleaved(
s->glopts,
123 (
const float *)
frame->data[0],
129 ret = twolame_encode_buffer_float32(
s->glopts,
130 (
const float *)
frame->data[0],
131 (
const float *)
frame->data[1],
136 ret = twolame_encode_buffer_interleaved(
s->glopts,
137 (
const short int *)
frame->data[0],
142 ret = twolame_encode_buffer(
s->glopts,
143 (
const short int *)
frame->data[0],
144 (
const short int *)
frame->data[1],
150 "Unsupported sample format %d.\n", avctx->
sample_fmt);
154 ret = twolame_encode_flush(
s->glopts, avpkt->
data, avpkt->
size);
167 avpkt->
pts =
s->next_pts;
178 #define OFFSET(x) offsetof(TWOLAMEContext, x)
179 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
189 {
"error_protection",
"enable CRC error protection",
OFFSET(error_protection),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1,
AE},
192 {
"verbosity",
"set library optput level (0-10)",
OFFSET(verbosity),
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 10,
AE},
209 16000, 22050, 24000, 32000, 44100, 48000, 0
213 .
p.
name =
"libtwolame",
231 #if FF_API_OLD_CHANNEL_LAYOUT
232 .p.channel_layouts = (
const uint64_t[]) {
243 .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
int sample_rate
samples per second
#define AV_CH_LAYOUT_MONO
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
const FFCodec ff_libtwolame_encoder
This structure describes decoded (raw) audio or video data.
#define AV_CHANNEL_LAYOUT_MONO
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
#define AV_CHANNEL_LAYOUT_STEREO
#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)
#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.
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[]
#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_packet(AVCodecContext *avctx, AVPacket *avpkt, int64_t size)
Check AVPacket size and allocate data.