Go to the documentation of this file.
22 #include <shine/layer3.h>
33 #define BUFFER_SIZE (4096 * 20)
52 shine_set_config_mpeg_defaults(&
s->config.mpeg);
54 s->config.mpeg.bitr = avctx->
bit_rate / 1000;
58 if (shine_check_config(
s->config.wave.samplerate,
s->config.mpeg.bitr) < 0) {
62 s->shine = shine_initialise(&
s->config);
65 avctx->
frame_size = shine_samples_per_pass(
s->shine);
80 data = shine_encode_buffer(
s->shine, (int16_t **)
frame->data, &written);
82 data = shine_flush(
s->shine, &written);
90 memcpy(
s->buffer +
s->buffer_index,
data, written);
91 s->buffer_index += written;
98 if (
s->buffer_index < 4 || !
s->afq.frame_count)
105 len = hdr.frame_size;
106 if (len <= s->buffer_index) {
109 memcpy(avpkt->
data,
s->buffer,
len);
110 s->buffer_index -=
len;
111 memmove(
s->buffer,
s->buffer +
len,
s->buffer_index);
126 shine_close(
s->shine);
131 44100, 48000, 32000, 0
135 .
p.
name =
"libshine",
147 #if FF_API_OLD_CHANNEL_LAYOUT
156 .p.wrapper_name =
"libshine",
int frame_size
Number of samples per channel in an audio frame.
static av_cold int libshine_encode_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
void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, int64_t *duration)
Remove frame(s) from the queue.
int sample_rate
samples per second
void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
#define AV_CH_LAYOUT_MONO
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
Initialize AudioFrameQueue.
This structure describes decoded (raw) audio or video data.
static av_cold int libshine_encode_close(AVCodecContext *avctx)
#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
uint8_t buffer[BUFFER_SIZE]
int nb_channels
Number of channels in this layout.
AVCodec p
The public AVCodec.
AVChannelLayout ch_layout
Audio channel layout.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
#define FF_CODEC_ENCODE_CB(func)
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
#define AV_CH_LAYOUT_STEREO
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static const int libshine_sample_rates[]
const FFCodec ff_libshine_encoder
int64_t bit_rate
the average bitrate
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
#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.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
@ 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.
const char * name
Name of the codec implementation.
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
static int libshine_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
main external API structure.
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
#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.