22#include <shine/layer3.h>
33#define BUFFER_SIZE (4096 * 20)
47 shine_set_config_mpeg_defaults(&
s->config.mpeg);
49 s->config.mpeg.bitr = avctx->
bit_rate / 1000;
53 if (shine_check_config(
s->config.wave.samplerate,
s->config.mpeg.bitr) < 0) {
57 s->shine = shine_initialise(&
s->config);
60 avctx->
frame_size = shine_samples_per_pass(
s->shine);
75 data = shine_encode_buffer(
s->shine, (int16_t **)
frame->data, &written);
77 data = shine_flush(
s->shine, &written);
85 memcpy(
s->buffer +
s->buffer_index,
data, written);
86 s->buffer_index += written;
93 if (
s->buffer_index < 4 || !
s->afq.frame_count)
100 len = hdr.frame_size;
104 memcpy(avpkt->
data,
s->buffer,
len);
105 s->buffer_index -=
len;
106 memmove(
s->buffer,
s->buffer +
len,
s->buffer_index);
122 shine_close(
s->shine);
127 44100, 48000, 32000, 0
131 .p.name =
"libshine",
144 .p.wrapper_name =
"libshine",
const FFCodec ff_libshine_encoder
av_cold void ff_af_queue_close(AudioFrameQueue *afq)
Close AudioFrameQueue.
av_cold void ff_af_queue_init(AVCodecContext *avctx, AudioFrameQueue *afq)
Initialize AudioFrameQueue.
int ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, AVPacket *pkt)
Remove frame(s) from the queue.
int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f)
Add a frame to the queue.
Libavcodec external API header.
Public libavutil channel layout APIs header.
#define CODEC_SAMPLERATES_ARRAY(array)
#define CODEC_CH_LAYOUTS(...)
#define FF_CODEC_CAP_NOT_INIT_THREADSAFE
The codec is not known to be init-threadsafe (i.e.
#define FF_CODEC_ENCODE_CB(func)
#define CODEC_LONG_NAME(str)
#define CODEC_SAMPLEFMTS(...)
int(* init)(AVBSFContext *ctx)
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...
#define AV_CODEC_CAP_DR1
Codec uses get_buffer() or get_encode_buffer() for allocating buffers and supports custom allocators.
@ AV_CODEC_ID_MP3
preferred ID for decoding MPEG audio layer 1, 2 or 3
#define AV_CHANNEL_LAYOUT_STEREO
#define AV_CHANNEL_LAYOUT_MONO
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
@ AV_SAMPLE_FMT_S16P
signed 16 bits, planar
static av_cold int libshine_encode_init(AVCodecContext *avctx)
static const int libshine_sample_rates[]
static av_cold int libshine_encode_close(AVCodecContext *avctx)
static int libshine_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
mpeg audio declarations for both encoder and decoder.
int nb_channels
Number of channels in this layout.
main external API structure.
AVChannelLayout ch_layout
Audio channel layout.
int64_t bit_rate
the average bitrate
int sample_rate
samples per second
int frame_size
Number of samples per channel in an audio frame.
This structure describes decoded (raw) audio or video data.
This structure stores compressed data.
uint8_t buffer[BUFFER_SIZE]