Go to the documentation of this file.
59 switch (
frame->subbands) {
61 for (ch = 0; ch <
frame->channels; ch++) {
62 x = &
s->X[ch][
s->position - 4 *
63 s->increment +
frame->blocks * 4];
65 blk +=
s->increment) {
71 x -= 4 *
s->increment;
74 return frame->blocks * 4;
77 for (ch = 0; ch <
frame->channels; ch++) {
78 x = &
s->X[ch][
s->position - 8 *
79 s->increment +
frame->blocks * 8];
81 blk +=
s->increment) {
87 x -= 8 *
s->increment;
90 return frame->blocks * 8;
107 uint8_t crc_header[11] = { 0 };
110 uint32_t audio_sample;
114 uint32_t levels[2][8];
115 uint32_t sb_sample_delta[2][8];
124 avpkt->
data[1] = (
frame->frequency & 0x03) << 6;
125 avpkt->
data[1] |= (((
frame->blocks >> 2) - 1) & 0x03) << 4;
126 avpkt->
data[1] |= (
frame->mode & 0x03) << 2;
127 avpkt->
data[1] |= (
frame->allocation & 0x01) << 1;
128 avpkt->
data[1] |= ((
frame->subbands == 8) & 0x01) << 0;
138 crc_header[0] = avpkt->
data[1];
139 crc_header[1] = avpkt->
data[2];
146 crc_header[crc_pos >> 3] = joint;
147 crc_pos +=
frame->subbands;
150 for (ch = 0; ch <
frame->channels; ch++) {
151 for (sb = 0; sb <
frame->subbands; sb++) {
153 crc_header[crc_pos >> 3] <<= 4;
154 crc_header[crc_pos >> 3] |=
frame->scale_factor[ch][sb] & 0x0F;
161 crc_header[crc_pos >> 3] <<= 8 - (crc_pos % 8);
167 for (ch = 0; ch <
frame->channels; ch++) {
168 for (sb = 0; sb <
frame->subbands; sb++) {
169 levels[ch][sb] = ((1 <<
bits[ch][sb]) - 1) <<
170 (32 - (
frame->scale_factor[ch][sb] +
172 sb_sample_delta[ch][sb] = (uint32_t) 1 <<
173 (
frame->scale_factor[ch][sb] +
179 for (ch = 0; ch <
frame->channels; ch++) {
180 for (sb = 0; sb <
frame->subbands; sb++) {
182 if (
bits[ch][sb] == 0)
185 audio_sample = ((uint64_t) levels[ch][sb] *
186 (sb_sample_delta[ch][sb] +
187 frame->sb_sample_f[
blk][ch][sb])) >> 32;
251 / (1000000 *
frame->subbands)) - 10, 4, 16) & ~3;
273 memset(&sbc->
dsp.X, 0,
sizeof(sbc->
dsp.X));
275 sbc->
dsp.increment = sbc->
msbc ? 1 : 4;
282 const AVFrame *av_frame,
int *got_packet_ptr)
290 int frame_length = 4 + (4 *
frame->subbands *
frame->channels) / 8
291 + ((
frame->blocks *
frame->bitpool * (1 + dual)
302 if (
frame->subbands == 8)
303 sbc->
dsp.position = sbc->
dsp.sbc_enc_process_input_8s(
304 sbc->
dsp.position, av_frame->
data[0], sbc->
dsp.X,
307 sbc->
dsp.position = sbc->
dsp.sbc_enc_process_input_4s(
308 sbc->
dsp.position, av_frame->
data[0], sbc->
dsp.X,
314 j = sbc->
dsp.sbc_calc_scalefactors_j(
frame->sb_sample_f,
319 sbc->
dsp.sbc_calc_scalefactors(
frame->sb_sample_f,
331 #define OFFSET(x) offsetof(SBCEncContext, x)
332 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM
334 {
"sbc_delay",
"set maximum algorithmic latency",
336 {
"msbc",
"use mSBC mode (wideband speech mono SBC)",
int frame_size
Number of samples per channel in an audio frame.
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
static int put_bytes_output(const PutBitContext *s)
int sample_rate
samples per second
static const int sbc_samplerates[]
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
This structure describes decoded (raw) audio or video data.
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
int nb_channels
Number of channels in this layout.
static int sbc_analyze_audio(SBCDSPContext *s, struct sbc_frame *frame)
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVCodec p
The public AVCodec.
static const AVOption options[]
AVChannelLayout ch_layout
Audio channel layout.
#define FF_CODEC_ENCODE_CB(func)
#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 FF_AVCTX_PROFILE_OPTION(name, description, type, value)
#define AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
This encoder can reorder user opaque values from input AVFrames and return them with corresponding ou...
av_cold void ff_sbcdsp_init(SBCDSPContext *s)
#define CODEC_LONG_NAME(str)
#define CODEC_CH_LAYOUTS(...)
#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.
int(* init)(AVBSFContext *ctx)
#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.
#define DECLARE_ALIGNED(n, t, v)
static int sbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *av_frame, int *got_packet_ptr)
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
#define CODEC_SAMPLEFMTS(...)
#define SBC_X_BUFFER_SIZE
int nb_samples
number of audio samples (per channel) described by this frame
#define i(width, name, range_min, range_max)
@ AV_SAMPLE_FMT_S16
signed 16 bits
const FFCodec ff_sbc_encoder
const char * name
Name of the codec implementation.
const AVProfile ff_sbc_profiles[]
uint8_t ff_sbc_crc8(const AVCRC *ctx, const uint8_t *data, size_t len)
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
static const AVClass sbc_class
main external API structure.
#define CODEC_SAMPLERATES_ARRAY(array)
#define AV_PROFILE_SBC_MSBC
int ff_get_encode_buffer(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int flags)
Get a buffer for a packet.
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
#define SBC_MODE_DUAL_CHANNEL
static size_t sbc_pack_frame(AVPacket *avpkt, struct sbc_frame *frame, int joint, int msbc)
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
#define AV_CHANNEL_LAYOUT_MONO
This structure stores compressed data.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
static av_cold int sbc_encode_init(AVCodecContext *avctx)
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
#define SBC_MODE_JOINT_STEREO