56 for (ch = 0; ch < frame->
channels; ch++) {
57 x = &s->X[ch][s->position - 4 *
58 s->increment + frame->
blocks * 4];
59 for (blk = 0; blk < frame->
blocks;
60 blk += s->increment) {
66 x -= 4 * s->increment;
72 for (ch = 0; ch < frame->
channels; ch++) {
73 x = &s->X[ch][s->position - 8 *
74 s->increment + frame->
blocks * 8];
75 for (blk = 0; blk < frame->
blocks;
76 blk += s->increment) {
82 x -= 8 * s->increment;
102 uint8_t crc_header[11] = { 0 };
105 uint32_t audio_sample;
109 uint32_t levels[2][8];
110 uint32_t sb_sample_delta[2][8];
120 avpkt->
data[1] |= (((frame->
blocks >> 2) - 1) & 0x03) << 4;
121 avpkt->
data[1] |= (frame->
mode & 0x03) << 2;
133 crc_header[0] = avpkt->
data[1];
134 crc_header[1] = avpkt->
data[2];
141 crc_header[crc_pos >> 3] = joint;
145 for (ch = 0; ch < frame->
channels; ch++) {
146 for (sb = 0; sb < frame->
subbands; sb++) {
148 crc_header[crc_pos >> 3] <<= 4;
149 crc_header[crc_pos >> 3] |= frame->
scale_factor[ch][sb] & 0x0F;
156 crc_header[crc_pos >> 3] <<= 8 - (crc_pos % 8);
162 for (ch = 0; ch < frame->
channels; ch++) {
163 for (sb = 0; sb < frame->
subbands; sb++) {
164 levels[ch][sb] = ((1 << bits[ch][sb]) - 1) <<
167 sb_sample_delta[ch][sb] = (uint32_t) 1 <<
173 for (blk = 0; blk < frame->
blocks; blk++) {
174 for (ch = 0; ch < frame->
channels; ch++) {
175 for (sb = 0; sb < frame->
subbands; sb++) {
177 if (bits[ch][sb] == 0)
180 audio_sample = ((uint64_t) levels[ch][sb] *
181 (sb_sample_delta[ch][sb] +
184 put_bits(&pb, bits[ch][sb], audio_sample);
246 / (1000000 * frame->
subbands)) - 10, 4, 16) & ~3;
268 memset(&sbc->
dsp.X, 0,
sizeof(sbc->
dsp.X));
270 sbc->
dsp.increment = sbc->
msbc ? 1 : 4;
277 const AVFrame *av_frame,
int *got_packet_ptr)
287 + joint * frame->
subbands) + 7) / 8;
298 sbc->
dsp.position = sbc->
dsp.sbc_enc_process_input_8s(
299 sbc->
dsp.position, av_frame->
data[0], sbc->
dsp.X,
302 sbc->
dsp.position = sbc->
dsp.sbc_enc_process_input_4s(
303 sbc->
dsp.position, av_frame->
data[0], sbc->
dsp.X,
326 #define OFFSET(x) offsetof(SBCEncContext, x) 327 #define AE AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM 329 {
"sbc_delay",
"set maximum algorithmic latency",
331 {
"msbc",
"use mSBC mode (wideband speech mono SBC)",
358 .supported_samplerates = (
const int[]) { 16000, 32000, 44100, 48000, 0 },
const struct AVCodec * codec
#define SBC_X_BUFFER_SIZE
This structure describes decoded (raw) audio or video data.
static const AVOption options[]
static void put_bits(Jpeg2000EncoderContext *s, int val, int n)
put n times val bit
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
static av_cold int init(AVCodecContext *avctx)
const char * av_default_item_name(void *ptr)
Return the context name.
int32_t sb_sample_f[16][2][8]
#define AV_CH_LAYOUT_STEREO
SBC basic "building bricks".
enum sbc_frame::@131 allocation
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
int ff_alloc_packet2(AVCodecContext *avctx, AVPacket *avpkt, int64_t size, int64_t min_size)
Check AVPacket size and/or allocate data.
enum sbc_frame::@130 mode
#define FF_CODEC_CAP_INIT_THREADSAFE
The codec does not modify any global variables in the init function, allowing to call the init functi...
#define DECLARE_ALIGNED(n, t, v)
Declare a variable that is aligned in memory.
#define i(width, name, range_min, range_max)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint32_t scale_factor[2][8]
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static size_t sbc_pack_frame(AVPacket *avpkt, struct sbc_frame *frame, int joint, int msbc)
const char * name
Name of the codec implementation.
static int put_bits_count(PutBitContext *s)
av_cold void ff_sbcdsp_init(SBCDSPContext *s)
#define AV_CODEC_CAP_SMALL_LAST_FRAME
Codec can be fed a final frame with a smaller size.
static const AVClass sbc_class
#define SBC_MODE_JOINT_STEREO
uint8_t ff_sbc_crc8(const AVCRC *ctx, const uint8_t *data, size_t len)
int frame_size
Number of samples per channel in an audio frame.
Libavcodec external API header.
AVSampleFormat
Audio sample formats.
static int sbc_analyze_audio(SBCDSPContext *s, struct sbc_frame *frame)
int sample_rate
samples per second
#define SBC_MODE_DUAL_CHANNEL
main external API structure.
#define FF_PROFILE_SBC_MSBC
static const uint16_t channel_layouts[7]
Describe the class of an AVClass context structure.
const AVProfile ff_sbc_profiles[]
int global_quality
Global quality for codecs which cannot change it per frame.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
const AVCRC * av_crc_get_table(AVCRCId crc_id)
Get an initialized standard CRC table.
common internal api header.
static void flush_put_bits(PutBitContext *s)
Pad the end of the output stream with zeros.
static void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size)
Initialize the PutBitContext s.
#define FF_AVCTX_PROFILE_OPTION(name, description, type, value)
SBC common definitions for the encoder and decoder.
static int sbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *av_frame, int *got_packet_ptr)
int channels
number of audio channels
const int * supported_samplerates
array of supported audio samplerates, or NULL if unknown, array is terminated by 0 ...
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
void ff_sbc_calculate_bits(const struct sbc_frame *frame, int(*bits)[8])
#define AV_CH_LAYOUT_MONO
This structure stores compressed data.
int nb_samples
number of audio samples (per channel) described by this frame
static int sbc_encode_init(AVCodecContext *avctx)